summaryrefslogtreecommitdiff
path: root/m4
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2023-01-27 20:37:19 +0100
committerBruno Haible <bruno@clisp.org>2023-01-27 20:37:19 +0100
commitc9dfdba295edbd9d2ae8d8ba441d404f357b6c0e (patch)
tree68a0334048d63b37fe79e0b7b71600cdc86d1500 /m4
parent267923869ddd11d899a744100eb047fc808b9647 (diff)
downloadgnulib-c9dfdba295edbd9d2ae8d8ba441d404f357b6c0e.tar.gz
stddef: Fix test-stddef compilation error on FreeBSD 12/x86.
* m4/stddef_h.m4 (gl_STDDEF_H): When testing for good max_align_t, use an ISO C compliant definition of _Alignof.
Diffstat (limited to 'm4')
-rw-r--r--m4/stddef_h.m411
1 files changed, 9 insertions, 2 deletions
diff --git a/m4/stddef_h.m4 b/m4/stddef_h.m4
index c0553d6f2f..a2322ebb7e 100644
--- a/m4/stddef_h.m4
+++ b/m4/stddef_h.m4
@@ -1,4 +1,4 @@
-# stddef_h.m4 serial 12
+# stddef_h.m4 serial 13
dnl Copyright (C) 2009-2023 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -22,7 +22,14 @@ AC_DEFUN_ONCE([gl_STDDEF_H],
[gl_cv_type_max_align_t],
[AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
- [[#include <stddef.h>
+ [[/* On FreeBSD 12.0/x86, max_align_t defined by <stddef.h> has
+ the correct alignment with the default (wrong) definition of
+ _Alignof, but a wrong alignment as soon as we activate an
+ ISO C compliant _Alignof definition. */
+ #if ((defined __GNUC__ && 4 <= __GNUC__) || defined __clang__) && !defined __cplusplus
+ #define _Alignof(type) __builtin_offsetof (struct { char __a; type __b; }, __b)
+ #endif
+ #include <stddef.h>
unsigned int s = sizeof (max_align_t);
#if defined __GNUC__ || defined __clang__ || defined __IBM__ALIGNOF__
int check1[2 * (__alignof__ (double) <= __alignof__ (max_align_t)) - 1];