summaryrefslogtreecommitdiff
path: root/m4/stddef_h.m4
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2018-09-06 22:44:01 +0200
committerBruno Haible <bruno@clisp.org>2018-09-06 22:44:01 +0200
commit2788ef64e87c4cdb786ff08d2cd00ecae76676ee (patch)
treefcc0d5e704becb292ebdaced90a3aa9a9d505ba0 /m4/stddef_h.m4
parentc4af52baedd099698d83e204f67510678230cd16 (diff)
downloadgnulib-2788ef64e87c4cdb786ff08d2cd00ecae76676ee.tar.gz
stddef: Override max_align_t on NetBSD 8.0/x86.
* m4/stddef_h.m4 (gl_STDDEF_H): When testing for max_align_t, test also the value of __alignof__ (max_align_t). * doc/posix-headers/stddef.texi: Mention the issue.
Diffstat (limited to 'm4/stddef_h.m4')
-rw-r--r--m4/stddef_h.m429
1 files changed, 25 insertions, 4 deletions
diff --git a/m4/stddef_h.m4 b/m4/stddef_h.m4
index ba3d201cf3..07b040abdf 100644
--- a/m4/stddef_h.m4
+++ b/m4/stddef_h.m4
@@ -1,5 +1,5 @@
dnl A placeholder for <stddef.h>, for platforms that have issues.
-# stddef_h.m4 serial 5
+# stddef_h.m4 serial 6
dnl Copyright (C) 2009-2018 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -10,13 +10,33 @@ AC_DEFUN([gl_STDDEF_H],
AC_REQUIRE([gl_STDDEF_H_DEFAULTS])
AC_REQUIRE([gt_TYPE_WCHAR_T])
STDDEF_H=
- AC_CHECK_TYPE([max_align_t], [], [HAVE_MAX_ALIGN_T=0; STDDEF_H=stddef.h],
- [[#include <stddef.h>
- ]])
+
+ dnl Test whether the type max_align_t exists and whether its alignment
+ dnl "is as great as is supported by the implementation in all contexts".
+ AC_CACHE_CHECK([for good max_align_t],
+ [gl_cv_type_max_align_t],
+ [AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[#include <stddef.h>
+ unsigned int s = sizeof (max_align_t);
+ #if defined __GNUC__ || defined __IBM__ALIGNOF__
+ int check1[2 * (__alignof__ (double) <= __alignof__ (max_align_t)) - 1];
+ int check2[2 * (__alignof__ (long double) <= __alignof__ (max_align_t)) - 1];
+ #endif
+ ]])],
+ [gl_cv_type_max_align_t=yes],
+ [gl_cv_type_max_align_t=no])
+ ])
+ if test $gl_cv_type_max_align_t = no; then
+ HAVE_MAX_ALIGN_T=0
+ STDDEF_H=stddef.h
+ fi
+
if test $gt_cv_c_wchar_t = no; then
HAVE_WCHAR_T=0
STDDEF_H=stddef.h
fi
+
AC_CACHE_CHECK([whether NULL can be used in arbitrary expressions],
[gl_cv_decl_null_works],
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stddef.h>
@@ -28,6 +48,7 @@ AC_DEFUN([gl_STDDEF_H],
REPLACE_NULL=1
STDDEF_H=stddef.h
fi
+
AC_SUBST([STDDEF_H])
AM_CONDITIONAL([GL_GENERATE_STDDEF_H], [test -n "$STDDEF_H"])
if test -n "$STDDEF_H"; then