From b4ead0073268f32338e7ee348c87a75f0d8d1dba Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Fri, 17 Jan 2025 22:51:55 +0100 Subject: [PATCH] sys_stat-h: Ensure blksize_t and blkcnt_t are defined. * tests/test-sys_stat-h.c: Check that blksize_t and blkcnt_t are defined. Include intprops.h. Check the signedness of various types. * modules/sys_stat-h-tests (Depends-on): Add intprops. * doc/posix-headers/sys_stat.texi: Mention the issues with blksize_t and blkcnt_t. --- ChangeLog | 7 +++++++ doc/posix-headers/sys_stat.texi | 9 +++++++++ modules/sys_stat-h-tests | 1 + tests/test-sys_stat-h.c | 17 +++++++++++++++++ 4 files changed, 34 insertions(+) diff --git a/ChangeLog b/ChangeLog index 8b77cac9ee..f41d5c885f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2025-01-17 Bruno Haible + sys_stat-h: Ensure blksize_t and blkcnt_t are defined. + * tests/test-sys_stat-h.c: Check that blksize_t and blkcnt_t are + defined. Include intprops.h. Check the signedness of various types. + * modules/sys_stat-h-tests (Depends-on): Add intprops. + * doc/posix-headers/sys_stat.texi: Mention the issues with blksize_t and + blkcnt_t. + 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 diff --git a/doc/posix-headers/sys_stat.texi b/doc/posix-headers/sys_stat.texi index bc889e986f..764451255f 100644 --- a/doc/posix-headers/sys_stat.texi +++ b/doc/posix-headers/sys_stat.texi @@ -12,6 +12,12 @@ Portability problems fixed by Gnulib module @code{sys_stat-h}: The type @code{mode_t} is not defined on some platforms: MSVC 14. @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 macros, such as @code{S_IFMT} or @code{S_IFIFO}, are missing on some platforms. @item @@ -54,6 +60,9 @@ Also, on platforms where @code{ino_t} is a 32-bit type, Portability problems not fixed by Gnulib: @itemize @item +On some platforms the types @code{blksize_t} and @code{blkcnt_t} are unsigned: +Android. +@item The macro @code{S_IFBLK} is missing on some platforms: MSVC 14. @item diff --git a/modules/sys_stat-h-tests b/modules/sys_stat-h-tests index a13ea11e45..aa853c5bad 100644 --- a/modules/sys_stat-h-tests +++ b/modules/sys_stat-h-tests @@ -3,6 +3,7 @@ tests/test-sys_stat-h.c Depends-on: assert-h +intprops sys_stat-h-c++-tests configure.ac: diff --git a/tests/test-sys_stat-h.c b/tests/test-sys_stat-h.c index f433935fb1..510aa21ea3 100644 --- a/tests/test-sys_stat-h.c +++ b/tests/test-sys_stat-h.c @@ -328,9 +328,26 @@ invalid UTIME macros nlink_t t1; off_t t2; mode_t t3; +blksize_t t4; +blkcnt_t t5; struct timespec st; +#include "intprops.h" + +/* POSIX requires that off_t is a signed integer type. */ +static_assert (TYPE_SIGNED (off_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) { -- 2.39.5