]> Savannah Git Hosting - gnulib.git/commitdiff
stddef: Fix test-stddef compilation error on FreeBSD 12/x86.
authorBruno Haible <bruno@clisp.org>
Fri, 27 Jan 2023 19:35:59 +0000 (20:35 +0100)
committerBruno Haible <bruno@clisp.org>
Fri, 27 Jan 2023 19:35:59 +0000 (20:35 +0100)
* m4/stddef_h.m4 (gl_STDDEF_H): When testing for good max_align_t, use
an ISO C compliant definition of _Alignof.

ChangeLog
m4/stddef_h.m4

index 3f7edb597be995c6f32e8ee0eb6fce4a7c479917..3833faffb78e3018d542bd99fdc3449e91b4f98c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2023-01-27  Bruno Haible  <bruno@clisp.org>
+
+       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.
+
 2023-01-25  Bruno Haible  <bruno@clisp.org>
 
        Keep config.h idempotent.
index c0553d6f2ff51c261b441474225ae5314406d63f..a2322ebb7ee1baa9138332201ec1173a990907cb 100644 (file)
@@ -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];