From 2788ef64e87c4cdb786ff08d2cd00ecae76676ee Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Thu, 6 Sep 2018 22:44:01 +0200 Subject: [PATCH] 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. --- ChangeLog | 7 +++++++ doc/posix-headers/stddef.texi | 4 ++++ m4/stddef_h.m4 | 29 +++++++++++++++++++++++++---- 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 57cdd8ea7b..12372c7c3d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2018-09-06 Bruno Haible + + 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. + 2018-09-06 Bruno Haible fcntl: Fix F_DUPFD_CLOEXEC behaviour on Haiku. diff --git a/doc/posix-headers/stddef.texi b/doc/posix-headers/stddef.texi index f5b6696e14..a27b597fd3 100644 --- a/doc/posix-headers/stddef.texi +++ b/doc/posix-headers/stddef.texi @@ -11,6 +11,10 @@ Portability problems fixed by Gnulib: Some platforms fail to provide @code{max_align_t}, which was added in C11: Solaris 11.0 and others. +@item +@code{max_align_t} does not have the expected alignment on some platforms: +NetBSD 8.0/x86. + @item Some old platforms fail to provide @code{wchar_t}. 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 , 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 - ]]) + + 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 + 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 @@ -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 -- 2.39.5