diff options
Diffstat (limited to 'gl/stddef.in.h')
| -rw-r--r-- | gl/stddef.in.h | 103 |
1 files changed, 69 insertions, 34 deletions
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 @@ | |||
| 1 | /* A substitute for POSIX 2008 <stddef.h>, for platforms that have issues. | 1 | /* A substitute for POSIX 2008 <stddef.h>, for platforms that have issues. |
| 2 | 2 | ||
| 3 | Copyright (C) 2009-2024 Free Software Foundation, Inc. | 3 | Copyright (C) 2009-2025 Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | This file is free software: you can redistribute it and/or modify | 5 | This file is free software: you can redistribute it and/or modify |
| 6 | it under the terms of the GNU Lesser General Public License as | 6 | it under the terms of the GNU Lesser General Public License as |
| @@ -27,13 +27,21 @@ | |||
| 27 | #endif | 27 | #endif |
| 28 | @PRAGMA_COLUMNS@ | 28 | @PRAGMA_COLUMNS@ |
| 29 | 29 | ||
| 30 | #if defined __need_wchar_t || defined __need_size_t \ | 30 | #if (defined __need_wchar_t || defined __need_size_t \ |
| 31 | || defined __need_ptrdiff_t || defined __need_NULL \ | 31 | || defined __need_ptrdiff_t || defined __need_NULL \ |
| 32 | || defined __need_wint_t | 32 | || defined __need_wint_t) \ |
| 33 | /* Avoid warning triggered by "gcc -std=gnu23 -Wsystem-headers" \ | ||
| 34 | in GCC 13.3 and 14.2 \ | ||
| 35 | <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114870>. */ \ | ||
| 36 | && !@STDDEF_NOT_IDEMPOTENT@ | ||
| 33 | /* Special invocation convention inside gcc header files. In | 37 | /* Special invocation convention inside gcc header files. In |
| 34 | particular, gcc provides a version of <stddef.h> that blindly | 38 | particular, <stddef.h> in some ancient versions of GCC blindly |
| 35 | redefines NULL even when __need_wint_t was defined, even though | 39 | redefined NULL when __need_wint_t was defined, even though wint_t |
| 36 | wint_t is not normally provided by <stddef.h>. Hence, we must | 40 | is not normally provided by <stddef.h>. |
| 41 | (FIXME: It's not clear what GCC versions those were - perhaps so | ||
| 42 | ancient that we can stop worrying about this?) | ||
| 43 | Although glibc 2.26 (2017) and later do not use __need_wint_t, | ||
| 44 | for portability to macOS, Cygwin, Haiku, and older Glibc + GCC, | ||
| 37 | remember if special invocation has ever been used to obtain wint_t, | 45 | remember if special invocation has ever been used to obtain wint_t, |
| 38 | in which case we need to clean up NULL yet again. */ | 46 | in which case we need to clean up NULL yet again. */ |
| 39 | 47 | ||
| @@ -52,6 +60,13 @@ | |||
| 52 | # endif | 60 | # endif |
| 53 | 61 | ||
| 54 | #else | 62 | #else |
| 63 | /* For @STDDEF_NOT_IDEMPOTENT@. */ | ||
| 64 | # undef __need_wchar_t | ||
| 65 | # undef __need_size_t | ||
| 66 | # undef __need_ptrdiff_t | ||
| 67 | # undef __need_NULL | ||
| 68 | # undef __need_wint_t | ||
| 69 | |||
| 55 | /* Normal invocation convention. */ | 70 | /* Normal invocation convention. */ |
| 56 | 71 | ||
| 57 | # ifndef _@GUARD_PREFIX@_STDDEF_H | 72 | # ifndef _@GUARD_PREFIX@_STDDEF_H |
| @@ -74,6 +89,12 @@ typedef long max_align_t; | |||
| 74 | # endif | 89 | # endif |
| 75 | # endif | 90 | # endif |
| 76 | 91 | ||
| 92 | # if !defined _GCC_NULLPTR_T && !@NULLPTR_T_NEEDS_STDDEF@ | ||
| 93 | /* Suppress unwanted nullptr_t typedef. See | ||
| 94 | <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114869>. */ | ||
| 95 | # define _GCC_NULLPTR_T | ||
| 96 | # endif | ||
| 97 | |||
| 77 | /* The include_next requires a split double-inclusion guard. */ | 98 | /* The include_next requires a split double-inclusion guard. */ |
| 78 | 99 | ||
| 79 | # @INCLUDE_NEXT@ @NEXT_STDDEF_H@ | 100 | # @INCLUDE_NEXT@ @NEXT_STDDEF_H@ |
| @@ -110,7 +131,7 @@ typedef long max_align_t; | |||
| 110 | */ | 131 | */ |
| 111 | #ifndef _GL_ATTRIBUTE_NOTHROW | 132 | #ifndef _GL_ATTRIBUTE_NOTHROW |
| 112 | # if defined __cplusplus | 133 | # if defined __cplusplus |
| 113 | # if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 2) || __clang_major >= 4 | 134 | # if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 2) || __clang_major__ >= 4 |
| 114 | # if __cplusplus >= 201103L | 135 | # if __cplusplus >= 201103L |
| 115 | # define _GL_ATTRIBUTE_NOTHROW noexcept (true) | 136 | # define _GL_ATTRIBUTE_NOTHROW noexcept (true) |
| 116 | # else | 137 | # else |
| @@ -128,11 +149,6 @@ typedef long max_align_t; | |||
| 128 | # endif | 149 | # endif |
| 129 | #endif | 150 | #endif |
| 130 | 151 | ||
| 131 | /* Some platforms lack wchar_t. */ | ||
| 132 | #if !@HAVE_WCHAR_T@ | ||
| 133 | # define wchar_t int | ||
| 134 | #endif | ||
| 135 | |||
| 136 | /* Some platforms lack max_align_t. The check for _GCC_MAX_ALIGN_T is | 152 | /* Some platforms lack max_align_t. The check for _GCC_MAX_ALIGN_T is |
| 137 | a hack in case the configure-time test was done with g++ even though | 153 | a hack in case the configure-time test was done with g++ even though |
| 138 | we are currently compiling with gcc. | 154 | we are currently compiling with gcc. |
| @@ -172,38 +188,57 @@ typedef union | |||
| 172 | #endif | 188 | #endif |
| 173 | 189 | ||
| 174 | /* ISO C 23 § 7.21.1 The unreachable macro */ | 190 | /* ISO C 23 § 7.21.1 The unreachable macro */ |
| 175 | #ifndef unreachable | 191 | /* This macro is only usable in C, not in C++. |
| 192 | There is no way to define it as a macro in C++, because that would break code | ||
| 193 | that does | ||
| 194 | #include <utility> | ||
| 195 | ... std::unreachable() ... | ||
| 196 | Similarly, there is no way to define it as an inline function in C++, because | ||
| 197 | that would break code that does | ||
| 198 | #include <utility> | ||
| 199 | using std::unreachable; | ||
| 200 | As a workaround, we define a macro gl_unreachable, that is like unreachable, | ||
| 201 | but is usable in both C and C++. */ | ||
| 176 | 202 | ||
| 177 | /* Code borrowed from verify.h. */ | 203 | /* Code borrowed from verify.h. */ |
| 178 | # ifndef _GL_HAS_BUILTIN_UNREACHABLE | 204 | #ifndef _GL_HAS_BUILTIN_UNREACHABLE |
| 179 | # if defined __clang_major__ && __clang_major__ < 5 | 205 | # if defined __clang_major__ && __clang_major__ < 5 |
| 180 | # define _GL_HAS_BUILTIN_UNREACHABLE 0 | 206 | # define _GL_HAS_BUILTIN_UNREACHABLE 0 |
| 181 | # elif 4 < __GNUC__ + (5 <= __GNUC_MINOR__) | 207 | # elif 4 < __GNUC__ + (5 <= __GNUC_MINOR__) && !defined __clang__ |
| 182 | # define _GL_HAS_BUILTIN_UNREACHABLE 1 | 208 | # define _GL_HAS_BUILTIN_UNREACHABLE 1 |
| 183 | # elif defined __has_builtin | 209 | # elif defined __has_builtin |
| 184 | # define _GL_HAS_BUILTIN_UNREACHABLE __has_builtin (__builtin_unreachable) | 210 | # define _GL_HAS_BUILTIN_UNREACHABLE __has_builtin (__builtin_unreachable) |
| 185 | # else | 211 | # else |
| 186 | # define _GL_HAS_BUILTIN_UNREACHABLE 0 | 212 | # define _GL_HAS_BUILTIN_UNREACHABLE 0 |
| 187 | # endif | ||
| 188 | # endif | 213 | # endif |
| 214 | #endif | ||
| 189 | 215 | ||
| 190 | # if _GL_HAS_BUILTIN_UNREACHABLE | 216 | #if _GL_HAS_BUILTIN_UNREACHABLE |
| 191 | # define unreachable() __builtin_unreachable () | 217 | # define gl_unreachable() __builtin_unreachable () |
| 192 | # elif 1200 <= _MSC_VER | 218 | #elif 1200 <= _MSC_VER |
| 193 | # define unreachable() __assume (0) | 219 | # define gl_unreachable() __assume (0) |
| 194 | # else | 220 | #elif !defined __cplusplus && @HAVE_C_UNREACHABLE@ |
| 221 | # define gl_unreachable() unreachable () | ||
| 222 | #else | ||
| 195 | /* Declare abort(), without including <stdlib.h>. */ | 223 | /* Declare abort(), without including <stdlib.h>. */ |
| 196 | extern | 224 | extern |
| 197 | # if defined __cplusplus | 225 | # if defined __cplusplus |
| 198 | "C" | 226 | "C" |
| 199 | # endif | 227 | # endif |
| 200 | _Noreturn | 228 | _Noreturn |
| 201 | void abort (void) | 229 | void abort (void) |
| 202 | # if defined __cplusplus && (__GLIBC__ >= 2) | 230 | # if defined __cplusplus && (__GLIBC__ >= 2) |
| 203 | _GL_ATTRIBUTE_NOTHROW | 231 | _GL_ATTRIBUTE_NOTHROW |
| 204 | # endif | 232 | # endif |
| 205 | ; | 233 | ; |
| 206 | # define unreachable() abort () | 234 | # define gl_unreachable() abort () |
| 235 | #endif | ||
| 236 | |||
| 237 | #if !defined __cplusplus && !@HAVE_C_UNREACHABLE@ | ||
| 238 | /* In C, define unreachable as a macro. */ | ||
| 239 | |||
| 240 | # ifndef unreachable | ||
| 241 | # define unreachable() gl_unreachable () | ||
| 207 | # endif | 242 | # endif |
| 208 | 243 | ||
| 209 | #endif | 244 | #endif |
