summaryrefslogtreecommitdiff
path: root/lib/stddef.in.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/stddef.in.h')
-rw-r--r--lib/stddef.in.h52
1 files changed, 48 insertions, 4 deletions
diff --git a/lib/stddef.in.h b/lib/stddef.in.h
index 6eadcc3d5a4..431e819b8bf 100644
--- a/lib/stddef.in.h
+++ b/lib/stddef.in.h
@@ -18,7 +18,7 @@
/* Written by Eric Blake. */
/*
- * POSIX 2008 <stddef.h> for platforms that have issues.
+ * POSIX 2008 and ISO C 23 <stddef.h> for platforms that have issues.
* <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/stddef.h.html>
*/
@@ -37,9 +37,9 @@
remember if special invocation has ever been used to obtain wint_t,
in which case we need to clean up NULL yet again. */
-# if !(defined _@GUARD_PREFIX@_STDDEF_H && defined _GL_STDDEF_WINT_T)
+# if !(defined _@GUARD_PREFIX@_STDDEF_H && defined _@GUARD_PREFIX@_STDDEF_WINT_T)
# ifdef __need_wint_t
-# define _GL_STDDEF_WINT_T
+# define _@GUARD_PREFIX@_STDDEF_WINT_T
# endif
# @INCLUDE_NEXT@ @NEXT_STDDEF_H@
/* On TinyCC, make sure that the macros that indicate the special invocation
@@ -69,6 +69,7 @@ typedef long rpl_max_align_t;
typedef long max_align_t;
# define _MAX_ALIGN_T
# endif
+# define __CLANG_MAX_ALIGN_T_DEFINED
# define GNULIB_defined_max_align_t 1
# endif
# endif
@@ -79,7 +80,7 @@ typedef long max_align_t;
/* On NetBSD 5.0, the definition of NULL lacks proper parentheses. */
# if (@REPLACE_NULL@ \
- && (!defined _@GUARD_PREFIX@_STDDEF_H || defined _GL_STDDEF_WINT_T))
+ && (!defined _@GUARD_PREFIX@_STDDEF_H || defined _@GUARD_PREFIX@_STDDEF_WINT_T))
# undef NULL
# ifdef __cplusplus
/* ISO C++ says that the macro NULL must expand to an integer constant
@@ -100,6 +101,11 @@ typedef long max_align_t;
# ifndef _@GUARD_PREFIX@_STDDEF_H
# define _@GUARD_PREFIX@_STDDEF_H
+/* This file uses _Noreturn. */
+#if !_GL_CONFIG_H_INCLUDED
+ #error "Please include config.h first."
+#endif
+
/* Some platforms lack wchar_t. */
#if !@HAVE_WCHAR_T@
# define wchar_t int
@@ -137,11 +143,49 @@ typedef union
long int __i _GL_STDDEF_ALIGNAS (long int);
} rpl_max_align_t;
# define max_align_t rpl_max_align_t
+# define __CLANG_MAX_ALIGN_T_DEFINED
# define GNULIB_defined_max_align_t 1
# endif
# endif
#endif
+/* ISO C 23 ยง 7.21.1 The unreachable macro */
+#ifndef unreachable
+
+/* 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
+# endif
+
+# if _GL_HAS_BUILTIN_UNREACHABLE
+# define unreachable() __builtin_unreachable ()
+# elif 1200 <= _MSC_VER
+# define unreachable() __assume (0)
+# else
+/* Declare abort(), without including <stdlib.h>. */
+extern
+# if defined __cplusplus
+"C"
+# endif
+_Noreturn
+void abort (void)
+# if defined __cplusplus && (__GLIBC__ >= 2)
+throw ()
+# endif
+;
+# define unreachable() abort ()
+# endif
+
+#endif
+
# endif /* _@GUARD_PREFIX@_STDDEF_H */
# endif /* _@GUARD_PREFIX@_STDDEF_H */
#endif /* __need_XXX */