From b0afb8fe0ff1d87165af9df61501197a06240dda Mon Sep 17 00:00:00 2001 From: Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> Date: Sun, 28 Dec 2025 12:13:40 +0100 Subject: Sync with Gnulib stable-202507 code (a8ac9f9ce5) --- gl/stddef.in.h | 103 ++++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 69 insertions(+), 34 deletions(-) (limited to 'gl/stddef.in.h') diff --git a/gl/stddef.in.h b/gl/stddef.in.h index fa8998d9..e8c55ff1 100644 --- a/gl/stddef.in.h +++ b/gl/stddef.in.h @@ -1,6 +1,6 @@ /* A substitute for POSIX 2008 , for platforms that have issues. - Copyright (C) 2009-2024 Free Software Foundation, Inc. + Copyright (C) 2009-2025 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -27,13 +27,21 @@ #endif @PRAGMA_COLUMNS@ -#if defined __need_wchar_t || defined __need_size_t \ - || defined __need_ptrdiff_t || defined __need_NULL \ - || defined __need_wint_t +#if (defined __need_wchar_t || defined __need_size_t \ + || defined __need_ptrdiff_t || defined __need_NULL \ + || defined __need_wint_t) \ + /* Avoid warning triggered by "gcc -std=gnu23 -Wsystem-headers" \ + in GCC 13.3 and 14.2 \ + . */ \ + && !@STDDEF_NOT_IDEMPOTENT@ /* Special invocation convention inside gcc header files. In - particular, gcc provides a version of that blindly - redefines NULL even when __need_wint_t was defined, even though - wint_t is not normally provided by . Hence, we must + particular, in some ancient versions of GCC blindly + redefined NULL when __need_wint_t was defined, even though wint_t + is not normally provided by . + (FIXME: It's not clear what GCC versions those were - perhaps so + ancient that we can stop worrying about this?) + Although glibc 2.26 (2017) and later do not use __need_wint_t, + for portability to macOS, Cygwin, Haiku, and older Glibc + GCC, remember if special invocation has ever been used to obtain wint_t, in which case we need to clean up NULL yet again. */ @@ -52,6 +60,13 @@ # endif #else +/* For @STDDEF_NOT_IDEMPOTENT@. */ +# undef __need_wchar_t +# undef __need_size_t +# undef __need_ptrdiff_t +# undef __need_NULL +# undef __need_wint_t + /* Normal invocation convention. */ # ifndef _@GUARD_PREFIX@_STDDEF_H @@ -74,6 +89,12 @@ typedef long max_align_t; # endif # endif +# if !defined _GCC_NULLPTR_T && !@NULLPTR_T_NEEDS_STDDEF@ + /* Suppress unwanted nullptr_t typedef. See + . */ +# define _GCC_NULLPTR_T +# endif + /* The include_next requires a split double-inclusion guard. */ # @INCLUDE_NEXT@ @NEXT_STDDEF_H@ @@ -110,7 +131,7 @@ typedef long max_align_t; */ #ifndef _GL_ATTRIBUTE_NOTHROW # if defined __cplusplus -# if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 2) || __clang_major >= 4 +# if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 2) || __clang_major__ >= 4 # if __cplusplus >= 201103L # define _GL_ATTRIBUTE_NOTHROW noexcept (true) # else @@ -128,11 +149,6 @@ typedef long max_align_t; # endif #endif -/* Some platforms lack wchar_t. */ -#if !@HAVE_WCHAR_T@ -# define wchar_t int -#endif - /* Some platforms lack max_align_t. The check for _GCC_MAX_ALIGN_T is a hack in case the configure-time test was done with g++ even though we are currently compiling with gcc. @@ -172,38 +188,57 @@ typedef union #endif /* ISO C 23 § 7.21.1 The unreachable macro */ -#ifndef unreachable +/* This macro is only usable in C, not in C++. + There is no way to define it as a macro in C++, because that would break code + that does + #include + ... std::unreachable() ... + Similarly, there is no way to define it as an inline function in C++, because + that would break code that does + #include + using std::unreachable; + As a workaround, we define a macro gl_unreachable, that is like unreachable, + but is usable in both C and C++. */ /* Code borrowed from verify.h. */ -# ifndef _GL_HAS_BUILTIN_UNREACHABLE -# if defined __clang_major__ && __clang_major__ < 5 -# define _GL_HAS_BUILTIN_UNREACHABLE 0 -# elif 4 < __GNUC__ + (5 <= __GNUC_MINOR__) -# define _GL_HAS_BUILTIN_UNREACHABLE 1 -# elif defined __has_builtin -# define _GL_HAS_BUILTIN_UNREACHABLE __has_builtin (__builtin_unreachable) -# else -# define _GL_HAS_BUILTIN_UNREACHABLE 0 -# endif +#ifndef _GL_HAS_BUILTIN_UNREACHABLE +# if defined __clang_major__ && __clang_major__ < 5 +# define _GL_HAS_BUILTIN_UNREACHABLE 0 +# elif 4 < __GNUC__ + (5 <= __GNUC_MINOR__) && !defined __clang__ +# define _GL_HAS_BUILTIN_UNREACHABLE 1 +# elif defined __has_builtin +# define _GL_HAS_BUILTIN_UNREACHABLE __has_builtin (__builtin_unreachable) +# else +# define _GL_HAS_BUILTIN_UNREACHABLE 0 # endif +#endif -# if _GL_HAS_BUILTIN_UNREACHABLE -# define unreachable() __builtin_unreachable () -# elif 1200 <= _MSC_VER -# define unreachable() __assume (0) -# else +#if _GL_HAS_BUILTIN_UNREACHABLE +# define gl_unreachable() __builtin_unreachable () +#elif 1200 <= _MSC_VER +# define gl_unreachable() __assume (0) +#elif !defined __cplusplus && @HAVE_C_UNREACHABLE@ +# define gl_unreachable() unreachable () +#else /* Declare abort(), without including . */ extern -# if defined __cplusplus +# if defined __cplusplus "C" -# endif +# endif _Noreturn void abort (void) -# if defined __cplusplus && (__GLIBC__ >= 2) +# if defined __cplusplus && (__GLIBC__ >= 2) _GL_ATTRIBUTE_NOTHROW -# endif +# endif ; -# define unreachable() abort () +# define gl_unreachable() abort () +#endif + +#if !defined __cplusplus && !@HAVE_C_UNREACHABLE@ +/* In C, define unreachable as a macro. */ + +# ifndef unreachable +# define unreachable() gl_unreachable () # endif #endif -- cgit v1.2.3-74-g34f1