summaryrefslogtreecommitdiffstats
path: root/gl/m4/stddef_h.m4
diff options
context:
space:
mode:
Diffstat (limited to 'gl/m4/stddef_h.m4')
-rw-r--r--gl/m4/stddef_h.m463
1 files changed, 49 insertions, 14 deletions
diff --git a/gl/m4/stddef_h.m4 b/gl/m4/stddef_h.m4
index 84d3bae8..127ec05b 100644
--- a/gl/m4/stddef_h.m4
+++ b/gl/m4/stddef_h.m4
@@ -1,16 +1,16 @@
1# stddef_h.m4 1# stddef_h.m4
2# serial 14 2# serial 23
3dnl Copyright (C) 2009-2024 Free Software Foundation, Inc. 3dnl Copyright (C) 2009-2025 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
7 8
8dnl A placeholder for <stddef.h>, for platforms that have issues. 9dnl A placeholder for <stddef.h>, for platforms that have issues.
9 10
10AC_DEFUN_ONCE([gl_STDDEF_H], 11AC_DEFUN_ONCE([gl_STDDEF_H],
11[ 12[
12 AC_REQUIRE([gl_STDDEF_H_DEFAULTS]) 13 AC_REQUIRE([gl_STDDEF_H_DEFAULTS])
13 AC_REQUIRE([gt_TYPE_WCHAR_T])
14 14
15 dnl Persuade OpenBSD <stddef.h> to declare max_align_t. 15 dnl Persuade OpenBSD <stddef.h> to declare max_align_t.
16 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) 16 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
@@ -52,11 +52,6 @@ AC_DEFUN_ONCE([gl_STDDEF_H],
52 GL_GENERATE_STDDEF_H=true 52 GL_GENERATE_STDDEF_H=true
53 fi 53 fi
54 54
55 if test $gt_cv_c_wchar_t = no; then
56 HAVE_WCHAR_T=0
57 GL_GENERATE_STDDEF_H=true
58 fi
59
60 AC_CACHE_CHECK([whether NULL can be used in arbitrary expressions], 55 AC_CACHE_CHECK([whether NULL can be used in arbitrary expressions],
61 [gl_cv_decl_null_works], 56 [gl_cv_decl_null_works],
62 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stddef.h> 57 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stddef.h>
@@ -69,21 +64,60 @@ AC_DEFUN_ONCE([gl_STDDEF_H],
69 GL_GENERATE_STDDEF_H=true 64 GL_GENERATE_STDDEF_H=true
70 fi 65 fi
71 66
72 AC_CACHE_CHECK([for unreachable], 67 AC_CACHE_CHECK([for unreachable in C],
73 [gl_cv_func_unreachable], 68 [gl_cv_c_func_unreachable],
74 [AC_LINK_IFELSE( 69 [AC_LINK_IFELSE(
75 [AC_LANG_PROGRAM( 70 [AC_LANG_PROGRAM(
76 [[#include <stddef.h> 71 [[#include <stddef.h>
77 ]], 72 ]],
78 [[unreachable (); 73 [[unreachable ();
79 ]])], 74 ]])],
80 [gl_cv_func_unreachable=yes], 75 [gl_cv_c_func_unreachable=yes],
81 [gl_cv_func_unreachable=no]) 76 [gl_cv_c_func_unreachable=no])
82 ]) 77 ])
83 if test $gl_cv_func_unreachable = no; then 78 if test $gl_cv_c_func_unreachable = no; then
79 GL_GENERATE_STDDEF_H=true
80 HAVE_C_UNREACHABLE=0
81 else
82 HAVE_C_UNREACHABLE=1
83 fi
84 AC_SUBST([HAVE_C_UNREACHABLE])
85 dnl Provide gl_unreachable() unconditionally.
86 GL_GENERATE_STDDEF_H=true
87
88 dnl https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114869
89 AC_CACHE_CHECK([whether nullptr_t needs <stddef.h>],
90 [gl_cv_nullptr_t_needs_stddef],
91 [AC_COMPILE_IFELSE([AC_LANG_DEFINES_PROVIDED[nullptr_t x;]],
92 [gl_cv_nullptr_t_needs_stddef=no],
93 [gl_cv_nullptr_t_needs_stddef=yes])])
94 if test "$gl_cv_nullptr_t_needs_stddef" = no; then
95 NULLPTR_T_NEEDS_STDDEF=0
84 GL_GENERATE_STDDEF_H=true 96 GL_GENERATE_STDDEF_H=true
85 fi 97 fi
86 98
99 dnl https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114870
100 dnl affects GCC 13.3 and 14.2.
101 AC_CACHE_CHECK([whether <stddef.h> is idempotent],
102 [gl_cv_stddef_idempotent],
103 [AC_COMPILE_IFELSE([AC_LANG_SOURCE(
104 [[
105 #if \
106 ((__GNUC__ == 13 && __GNUC_MINOR__ <= 3) \
107 || (__GNUC__ == 14 && __GNUC_MINOR__ <= 2))
108 #error "bug 114870 is present"
109 #endif
110 ]])],
111 [gl_cv_stddef_idempotent="guessing yes"],
112 [gl_cv_stddef_idempotent="guessing no"])
113 ])
114 case "$gl_cv_stddef_idempotent" in
115 *yes) ;;
116 *) STDDEF_NOT_IDEMPOTENT=1
117 GL_GENERATE_STDDEF_H=true
118 ;;
119 esac
120
87 if $GL_GENERATE_STDDEF_H; then 121 if $GL_GENERATE_STDDEF_H; then
88 gl_NEXT_HEADERS([stddef.h]) 122 gl_NEXT_HEADERS([stddef.h])
89 fi 123 fi
@@ -114,7 +148,8 @@ AC_DEFUN([gl_STDDEF_H_REQUIRE_DEFAULTS],
114AC_DEFUN([gl_STDDEF_H_DEFAULTS], 148AC_DEFUN([gl_STDDEF_H_DEFAULTS],
115[ 149[
116 dnl Assume proper GNU behavior unless another module says otherwise. 150 dnl Assume proper GNU behavior unless another module says otherwise.
151 NULLPTR_T_NEEDS_STDDEF=1; AC_SUBST([NULLPTR_T_NEEDS_STDDEF])
152 STDDEF_NOT_IDEMPOTENT=0; AC_SUBST([STDDEF_NOT_IDEMPOTENT])
117 REPLACE_NULL=0; AC_SUBST([REPLACE_NULL]) 153 REPLACE_NULL=0; AC_SUBST([REPLACE_NULL])
118 HAVE_MAX_ALIGN_T=1; AC_SUBST([HAVE_MAX_ALIGN_T]) 154 HAVE_MAX_ALIGN_T=1; AC_SUBST([HAVE_MAX_ALIGN_T])
119 HAVE_WCHAR_T=1; AC_SUBST([HAVE_WCHAR_T])
120]) 155])