diff options
Diffstat (limited to 'gl/m4/stddef_h.m4')
| -rw-r--r-- | gl/m4/stddef_h.m4 | 69 |
1 files changed, 60 insertions, 9 deletions
diff --git a/gl/m4/stddef_h.m4 b/gl/m4/stddef_h.m4 index a2322ebb..127ec05b 100644 --- a/gl/m4/stddef_h.m4 +++ b/gl/m4/stddef_h.m4 | |||
| @@ -1,15 +1,16 @@ | |||
| 1 | # stddef_h.m4 serial 13 | 1 | # stddef_h.m4 |
| 2 | dnl Copyright (C) 2009-2023 Free Software Foundation, Inc. | 2 | # serial 23 |
| 3 | dnl Copyright (C) 2009-2025 Free Software Foundation, Inc. | ||
| 3 | dnl This file is free software; the Free Software Foundation | 4 | dnl This file is free software; the Free Software Foundation |
| 4 | dnl gives unlimited permission to copy and/or distribute it, | 5 | dnl gives unlimited permission to copy and/or distribute it, |
| 5 | dnl with or without modifications, as long as this notice is preserved. | 6 | dnl with or without modifications, as long as this notice is preserved. |
| 7 | dnl This file is offered as-is, without any warranty. | ||
| 6 | 8 | ||
| 7 | dnl A placeholder for <stddef.h>, for platforms that have issues. | 9 | dnl A placeholder for <stddef.h>, for platforms that have issues. |
| 8 | 10 | ||
| 9 | AC_DEFUN_ONCE([gl_STDDEF_H], | 11 | AC_DEFUN_ONCE([gl_STDDEF_H], |
| 10 | [ | 12 | [ |
| 11 | AC_REQUIRE([gl_STDDEF_H_DEFAULTS]) | 13 | AC_REQUIRE([gl_STDDEF_H_DEFAULTS]) |
| 12 | AC_REQUIRE([gt_TYPE_WCHAR_T]) | ||
| 13 | 14 | ||
| 14 | dnl Persuade OpenBSD <stddef.h> to declare max_align_t. | 15 | dnl Persuade OpenBSD <stddef.h> to declare max_align_t. |
| 15 | AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) | 16 | AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) |
| @@ -51,11 +52,6 @@ AC_DEFUN_ONCE([gl_STDDEF_H], | |||
| 51 | GL_GENERATE_STDDEF_H=true | 52 | GL_GENERATE_STDDEF_H=true |
| 52 | fi | 53 | fi |
| 53 | 54 | ||
| 54 | if test $gt_cv_c_wchar_t = no; then | ||
| 55 | HAVE_WCHAR_T=0 | ||
| 56 | GL_GENERATE_STDDEF_H=true | ||
| 57 | fi | ||
| 58 | |||
| 59 | AC_CACHE_CHECK([whether NULL can be used in arbitrary expressions], | 55 | AC_CACHE_CHECK([whether NULL can be used in arbitrary expressions], |
| 60 | [gl_cv_decl_null_works], | 56 | [gl_cv_decl_null_works], |
| 61 | [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stddef.h> | 57 | [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stddef.h> |
| @@ -68,6 +64,60 @@ AC_DEFUN_ONCE([gl_STDDEF_H], | |||
| 68 | GL_GENERATE_STDDEF_H=true | 64 | GL_GENERATE_STDDEF_H=true |
| 69 | fi | 65 | fi |
| 70 | 66 | ||
| 67 | AC_CACHE_CHECK([for unreachable in C], | ||
| 68 | [gl_cv_c_func_unreachable], | ||
| 69 | [AC_LINK_IFELSE( | ||
| 70 | [AC_LANG_PROGRAM( | ||
| 71 | [[#include <stddef.h> | ||
| 72 | ]], | ||
| 73 | [[unreachable (); | ||
| 74 | ]])], | ||
| 75 | [gl_cv_c_func_unreachable=yes], | ||
| 76 | [gl_cv_c_func_unreachable=no]) | ||
| 77 | ]) | ||
| 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 | ||
| 96 | GL_GENERATE_STDDEF_H=true | ||
| 97 | fi | ||
| 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 | |||
| 71 | if $GL_GENERATE_STDDEF_H; then | 121 | if $GL_GENERATE_STDDEF_H; then |
| 72 | gl_NEXT_HEADERS([stddef.h]) | 122 | gl_NEXT_HEADERS([stddef.h]) |
| 73 | fi | 123 | fi |
| @@ -98,7 +148,8 @@ AC_DEFUN([gl_STDDEF_H_REQUIRE_DEFAULTS], | |||
| 98 | AC_DEFUN([gl_STDDEF_H_DEFAULTS], | 148 | AC_DEFUN([gl_STDDEF_H_DEFAULTS], |
| 99 | [ | 149 | [ |
| 100 | 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]) | ||
| 101 | REPLACE_NULL=0; AC_SUBST([REPLACE_NULL]) | 153 | REPLACE_NULL=0; AC_SUBST([REPLACE_NULL]) |
| 102 | HAVE_MAX_ALIGN_T=1; AC_SUBST([HAVE_MAX_ALIGN_T]) | 154 | HAVE_MAX_ALIGN_T=1; AC_SUBST([HAVE_MAX_ALIGN_T]) |
| 103 | HAVE_WCHAR_T=1; AC_SUBST([HAVE_WCHAR_T]) | ||
| 104 | ]) | 155 | ]) |
