* lib/sys_types.in.h (blksize_t, blkcnt_t): New definitions.
* m4/sys_types_h.m4 (gl_SYS_TYPES_H): Set HAVE_BLKSIZE_T and
HAVE_BLKCNT_T.
* modules/sys_types-h (Makefile.am): Substitute HAVE_BLKSIZE_T and
HAVE_BLKCNT_T.
* tests/test-sys_types-h.c: Check that blksize_t and blkcnt_t are
defined. Include intprops.h. Check the signedness of various types.
* modules/sys_types-h-tests (Depends-on): Add assert-h, intprops.
* doc/posix-headers/sys_types.texi: Mention the issues with blksize_t
and blkcnt_t.
+2025-01-17 Bruno Haible <bruno@clisp.org>
+
+ sys_types-h: Ensure blksize_t and blkcnt_t are defined.
+ * lib/sys_types.in.h (blksize_t, blkcnt_t): New definitions.
+ * m4/sys_types_h.m4 (gl_SYS_TYPES_H): Set HAVE_BLKSIZE_T and
+ HAVE_BLKCNT_T.
+ * modules/sys_types-h (Makefile.am): Substitute HAVE_BLKSIZE_T and
+ HAVE_BLKCNT_T.
+ * tests/test-sys_types-h.c: Check that blksize_t and blkcnt_t are
+ defined. Include intprops.h. Check the signedness of various types.
+ * modules/sys_types-h-tests (Depends-on): Add assert-h, intprops.
+ * doc/posix-headers/sys_types.texi: Mention the issues with blksize_t
+ and blkcnt_t.
+
2025-01-17 Paul Eggert <eggert@cs.ucla.edu>
crc-x86_64: port to old GCC compilers
The type @code{off64_t} is not defined on some platforms:
macOS 14, FreeBSD 10.4, NetBSD 10.0, OpenBSD 7.5, MSVC 14, Cygwin, Haiku, Minix 3.3.
@item
+The type @code{blksize_t} is not defined on some platforms:
+FreeBSD 5.5, OpenBSD 5.6, HP-UX 11.23, IRIX 6.5, mingw, MSVC 14.
+@item
+The type @code{blkcnt_t} is not defined on some platforms:
+FreeBSD 5.5, OpenBSD 5.6, mingw, MSVC 14.
+@item
Some systems leak definitions of @code{major}, @code{minor}, and
@code{makedev} through this header; however, when
@file{sys/sysmacros.h} exists, that file should also be included to
Portability problems not fixed by Gnulib:
@itemize
@item
+On some platforms the types @code{blksize_t} and @code{blkcnt_t} are unsigned:
+Android.
+@item
On some platforms the types @code{blksize_t} and @code{suseconds_t}
are signed integer types that are wider than @code{long}:
glibc x32
# include <stddef.h>
#endif
+/* Define blksize_t, required by POSIX:2024. */
+#if !@HAVE_BLKSIZE_T@
+# if !defined GNULIB_defined_blksize_t
+typedef int blksize_t;
+# define GNULIB_defined_blksize_t 1
+# endif
+#endif
+
+/* Define blkcnt_t, required by POSIX:2024. */
+#if !@HAVE_BLKCNT_T@
+# if !defined GNULIB_defined_blkcnt_t
+typedef long long blkcnt_t;
+# define GNULIB_defined_blkcnt_t 1
+# endif
+#endif
+
#endif /* _@GUARD_PREFIX@_SYS_TYPES_H */
#endif /* _@GUARD_PREFIX@_SYS_TYPES_H */
#endif /* __need_XXX */
# sys_types_h.m4
-# serial 14
+# serial 15
dnl Copyright (C) 2011-2025 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
WINDOWS_STAT_INODES=0
])
AC_SUBST([WINDOWS_STAT_INODES])
+
+ dnl Test whether the 'blksize_t' type is defined.
+ AC_CHECK_TYPE([blksize_t], [HAVE_BLKSIZE_T=1], [HAVE_BLKSIZE_T=0])
+ AC_SUBST([HAVE_BLKSIZE_T])
+
+ dnl Test whether the 'blkcnt_t' type is defined.
+ AC_CHECK_TYPE([blkcnt_t], [HAVE_BLKCNT_T=1], [HAVE_BLKCNT_T=0])
+ AC_SUBST([HAVE_BLKCNT_T])
])
# Initializes the default values for AC_SUBSTed shell variables.
-e 's|@''WINDOWS_64_BIT_OFF_T''@|$(WINDOWS_64_BIT_OFF_T)|g' \
-e 's|@''HAVE_OFF64_T''@|$(HAVE_OFF64_T)|g' \
-e 's|@''WINDOWS_STAT_INODES''@|$(WINDOWS_STAT_INODES)|g' \
+ -e 's|@''HAVE_BLKSIZE_T''@|$(HAVE_BLKSIZE_T)|g' \
+ -e 's|@''HAVE_BLKCNT_T''@|$(HAVE_BLKCNT_T)|g' \
$(srcdir)/sys_types.in.h > $@-t
$(AM_V_at)mv $@-t $@
MOSTLYCLEANFILES += sys/types.h sys/types.h-t
tests/test-sys_types-h.c
Depends-on:
+assert-h
+intprops
sys_types-h-c++-tests
configure.ac:
#include <sys/types.h>
-/* Check that the types are all defined. */
+/* Check that the most important types are defined. */
pid_t t1;
size_t t2;
ssize_t t3;
off_t t4;
mode_t t5;
off64_t t6;
+blksize_t t7;
+blkcnt_t t8;
+
+#include "intprops.h"
+
+/* POSIX requires that pid_t is a signed integer type. */
+static_assert (TYPE_SIGNED (pid_t));
+
+/* POSIX requires that size_t is an unsigned integer type. */
+static_assert (! TYPE_SIGNED (size_t));
+
+/* POSIX requires that ssize_t is a signed integer type. */
+static_assert (TYPE_SIGNED (ssize_t));
+
+/* POSIX requires that off_t is a signed integer type. */
+static_assert (TYPE_SIGNED (off_t));
+static_assert (TYPE_SIGNED (off64_t));
+
+/* POSIX requires that blksize_t is a signed integer type. */
+#if !defined __ANDROID__
+static_assert (TYPE_SIGNED (blksize_t));
+#endif
+
+/* POSIX requires that blkcnt_t is a signed integer type. */
+#if !defined __ANDROID__
+static_assert (TYPE_SIGNED (blkcnt_t));
+#endif
int
main (void)