Paul Eggert wrote: > Check that all errno values are positive integer constant expressions. > ... > Also check ESOCKTNOSUPPORT, added in POSIX.1-2024.
Both of these fail on Haiku. I'm adding these two workarounds. 2024-08-12 Bruno Haible <br...@clisp.org> errno tests: Avoid test failure on Haiku. * doc/posix-headers/errno.texi: Mention the Haiku problem. * tests/test-errno.c: On Haiku, don't check that the error numbers are positive. 2024-08-12 Bruno Haible <br...@clisp.org> errno: Ensure ESOCKTNOSUPPORT gets defined. * m4/errno_h.m4 (gl_HEADER_ERRNO_H): Test also whether ESOCKTNOSUPPORT is defined. * lib/errno.in.h (ESOCKTNOSUPPORT, GNULIB_defined_ESOCKTNOSUPPORT): New macros. * lib/strerror-override.h (strerror_override): Declare also if GNULIB_defined_ESOCKTNOSUPPORT is defined. * lib/strerror-override.c (strerror_override): Handle ESOCKTNOSUPPORT. * lib/strerrorname_np.c (strerrorname_np): Move ESOCKTNOSUPPORT code to the POSIX section. * doc/posix-headers/errno.texi: Document the Haiku problem.
>From 32601dbf37935eba9a85b918f477860e7638fc82 Mon Sep 17 00:00:00 2001 From: Bruno Haible <br...@clisp.org> Date: Mon, 12 Aug 2024 17:11:35 +0200 Subject: [PATCH 1/2] errno: Ensure ESOCKTNOSUPPORT gets defined. * m4/errno_h.m4 (gl_HEADER_ERRNO_H): Test also whether ESOCKTNOSUPPORT is defined. * lib/errno.in.h (ESOCKTNOSUPPORT, GNULIB_defined_ESOCKTNOSUPPORT): New macros. * lib/strerror-override.h (strerror_override): Declare also if GNULIB_defined_ESOCKTNOSUPPORT is defined. * lib/strerror-override.c (strerror_override): Handle ESOCKTNOSUPPORT. * lib/strerrorname_np.c (strerrorname_np): Move ESOCKTNOSUPPORT code to the POSIX section. * doc/posix-headers/errno.texi: Document the Haiku problem. --- ChangeLog | 14 ++++++++++++++ doc/posix-headers/errno.texi | 3 +++ lib/errno.in.h | 7 +++++++ lib/strerror-override.c | 5 +++++ lib/strerror-override.h | 3 ++- lib/strerrorname_np.c | 9 ++++----- m4/errno_h.m4 | 5 ++++- 7 files changed, 39 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 16df685b97..c4dda29205 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2024-08-12 Bruno Haible <br...@clisp.org> + + errno: Ensure ESOCKTNOSUPPORT gets defined. + * m4/errno_h.m4 (gl_HEADER_ERRNO_H): Test also whether ESOCKTNOSUPPORT + is defined. + * lib/errno.in.h (ESOCKTNOSUPPORT, GNULIB_defined_ESOCKTNOSUPPORT): New + macros. + * lib/strerror-override.h (strerror_override): Declare also if + GNULIB_defined_ESOCKTNOSUPPORT is defined. + * lib/strerror-override.c (strerror_override): Handle ESOCKTNOSUPPORT. + * lib/strerrorname_np.c (strerrorname_np): Move ESOCKTNOSUPPORT code to + the POSIX section. + * doc/posix-headers/errno.texi: Document the Haiku problem. + 2024-08-12 Bruno Haible <br...@clisp.org> fdutimensat, utimensat tests: Fix test failures on Cygwin. diff --git a/doc/posix-headers/errno.texi b/doc/posix-headers/errno.texi index 83a31f4fb4..4495fbfaee 100644 --- a/doc/posix-headers/errno.texi +++ b/doc/posix-headers/errno.texi @@ -51,6 +51,9 @@ glibc/Linux 2.3.6, glibc/Hurd 2.15, glibc/kFreeBSD 2.15, Mac OS X 10.5, FreeBSD 6.0, NetBSD 9.3, OpenBSD 6.0, Minix 3.1.8, AIX 5.1, HP-UX 11, Cygwin, mingw without pthreads-win32, MSVC 9. @item +The macro @code{ESOCKTNOSUPPORT} is not defined on some platforms: +Haiku. +@item The macro @code{EILSEQ} is not defined on some platforms: LynxOS 178 2.2.2. @item diff --git a/lib/errno.in.h b/lib/errno.in.h index ba927037f6..18eb8a0c58 100644 --- a/lib/errno.in.h +++ b/lib/errno.in.h @@ -270,10 +270,17 @@ # define GNULIB_defined_ENOTRECOVERABLE 1 # endif +/* On LynxOS, the macro EILSEQ is not defined. */ # ifndef EILSEQ # define EILSEQ 2015 # define GNULIB_defined_EILSEQ 1 # endif +/* On Haiku, the macro ESOCKTNOSUPPORT is not defined. */ +# ifndef ESOCKTNOSUPPORT +# define ESOCKTNOSUPPORT 2016 +# define GNULIB_defined_ESOCKTNOSUPPORT 1 +# endif + #endif /* _@GUARD_PREFIX@_ERRNO_H */ #endif /* _@GUARD_PREFIX@_ERRNO_H */ diff --git a/lib/strerror-override.c b/lib/strerror-override.c index b9c1c7aba8..2d9560f909 100644 --- a/lib/strerror-override.c +++ b/lib/strerror-override.c @@ -298,6 +298,11 @@ strerror_override (int errnum) return "Invalid or incomplete multibyte or wide character"; # endif +# if GNULIB_defined_ESOCKTNOSUPPORT + case ESOCKTNOSUPPORT: + return "Socket type not supported"; +# endif + default: return NULL; } diff --git a/lib/strerror-override.h b/lib/strerror-override.h index a1734a242e..c496000389 100644 --- a/lib/strerror-override.h +++ b/lib/strerror-override.h @@ -57,7 +57,8 @@ extern "C" { || GNULIB_defined_ECANCELED \ || GNULIB_defined_EOWNERDEAD \ || GNULIB_defined_ENOTRECOVERABLE \ - || GNULIB_defined_EILSEQ + || GNULIB_defined_EILSEQ \ + || GNULIB_defined_ESOCKTNOSUPPORT extern const char *strerror_override (int errnum) _GL_ATTRIBUTE_CONST; #else # define strerror_override(ignored) NULL diff --git a/lib/strerrorname_np.c b/lib/strerrorname_np.c index 5a93906162..f9f7cb702b 100644 --- a/lib/strerrorname_np.c +++ b/lib/strerrorname_np.c @@ -34,7 +34,7 @@ strerrorname_np (int errnum) case ERANGE: return "ERANGE"; /* Error codes specified by POSIX. - <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/errno.h.html> */ + <https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/errno.h.html> */ #if defined E2BIG case E2BIG: return "E2BIG"; #endif @@ -245,6 +245,9 @@ strerrorname_np (int errnum) #if defined EROFS case EROFS: return "EROFS"; #endif + #if defined ESOCKTNOSUPPORT + case ESOCKTNOSUPPORT: return "ESOCKTNOSUPPORT"; + #endif #if defined ESPIPE case ESPIPE: return "ESPIPE"; #endif @@ -1279,10 +1282,6 @@ strerrorname_np (int errnum) #if defined ESIGPARM case ESIGPARM: return "ESIGPARM"; #endif - /* Linux, Mac OS X, FreeBSD, NetBSD, OpenBSD, AIX, HP-UX, IRIX, OSF/1, Solaris, Minix, Cygwin */ - #if defined ESOCKTNOSUPPORT - case ESOCKTNOSUPPORT: return "ESOCKTNOSUPPORT"; - #endif /* AIX, OSF/1 */ #if defined ESOFT case ESOFT: return "ESOFT"; diff --git a/m4/errno_h.m4 b/m4/errno_h.m4 index 18bfd7b1c1..920ea6cc65 100644 --- a/m4/errno_h.m4 +++ b/m4/errno_h.m4 @@ -1,5 +1,5 @@ # errno_h.m4 -# serial 17 +# serial 18 dnl Copyright (C) 2004, 2006, 2008-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -68,6 +68,9 @@ AC_DEFUN_ONCE([gl_HEADER_ERRNO_H] #endif #if !defined EILSEQ booboo +#endif +#if !defined ESOCKTNOSUPPORT +booboo #endif ], [gl_cv_header_errno_h_complete=no], -- 2.34.1
>From 616a1dadbd350571bd4ea787c4df95466d089875 Mon Sep 17 00:00:00 2001 From: Bruno Haible <br...@clisp.org> Date: Mon, 12 Aug 2024 17:15:10 +0200 Subject: [PATCH 2/2] errno tests: Avoid test failure on Haiku. * doc/posix-headers/errno.texi: Mention the Haiku problem. * tests/test-errno.c: On Haiku, don't check that the error numbers are positive. --- ChangeLog | 7 +++++++ doc/posix-headers/errno.texi | 3 +++ tests/test-errno.c | 9 +++++++-- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index c4dda29205..63b19e0480 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2024-08-12 Bruno Haible <br...@clisp.org> + + errno tests: Avoid test failure on Haiku. + * doc/posix-headers/errno.texi: Mention the Haiku problem. + * tests/test-errno.c: On Haiku, don't check that the error numbers are + positive. + 2024-08-12 Bruno Haible <br...@clisp.org> errno: Ensure ESOCKTNOSUPPORT gets defined. diff --git a/doc/posix-headers/errno.texi b/doc/posix-headers/errno.texi index 4495fbfaee..3b8b22dabb 100644 --- a/doc/posix-headers/errno.texi +++ b/doc/posix-headers/errno.texi @@ -64,4 +64,7 @@ Portability problems not fixed by Gnulib: @itemize +@item +All error numbers are negative on some platforms: +Haiku. @end itemize diff --git a/tests/test-errno.c b/tests/test-errno.c index acd07ab95b..b54dc705dc 100644 --- a/tests/test-errno.c +++ b/tests/test-errno.c @@ -107,9 +107,14 @@ /* end of CHECK_POSIX_ERRNOS */ /* Verify that the POSIX mandated errno values can be used as integer - constant expressions and are all positive. */ -#define POSITIVE_INTEGER_CONSTANT_EXPRESSION(e) static_assert (0 < (e) << 0); + constant expressions and are all positive (except on Haiku). */ +#if defined __HAIKU__ +# define NONZERO_INTEGER_CONSTANT_EXPRESSION(e) static_assert (0 != (e) << 0); +CHECK_POSIX_ERRNOS (NONZERO_INTEGER_CONSTANT_EXPRESSION) +#else +# define POSITIVE_INTEGER_CONSTANT_EXPRESSION(e) static_assert (0 < (e) << 0); CHECK_POSIX_ERRNOS (POSITIVE_INTEGER_CONSTANT_EXPRESSION) +#endif /* Verify that errno values can all be used in #if. */ #define USABLE_IN_IF(e) ^ e -- 2.34.1