]> Savannah Git Hosting - gnulib.git/commitdiff
stddef: Override wrong max_align_t on AIX 7 with xlc in 64-bit mode.
authorBruno Haible <bruno@clisp.org>
Sun, 3 Jan 2021 12:38:03 +0000 (13:38 +0100)
committerBruno Haible <bruno@clisp.org>
Sun, 3 Jan 2021 12:56:59 +0000 (13:56 +0100)
* m4/stddef_h.m4 (gl_STDDEF_H): Make check for good max_align_t
stricter: Add tests for offsetof-based alignof.
* lib/stddef.in.h (max_align_t): Override on AIX in 64-bit mode.
* doc/posix-headers/stddef.texi: Document the AIX max_align_t bug.

ChangeLog
doc/posix-headers/stddef.texi
lib/stddef.in.h
m4/stddef_h.m4

index d7b506cf53d8cb969f245f03f2e7d46c3366a868..82e4a10155718cc8cd410d9ada9703687ba1fd1d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2021-01-03  Bruno Haible  <bruno@clisp.org>
+
+       stddef: Override wrong max_align_t on AIX 7 with xlc in 64-bit mode.
+       * m4/stddef_h.m4 (gl_STDDEF_H): Make check for good max_align_t
+       stricter: Add tests for offsetof-based alignof.
+       * lib/stddef.in.h (max_align_t): Override on AIX in 64-bit mode.
+       * doc/posix-headers/stddef.texi: Document the AIX max_align_t bug.
+
 2021-01-03  Bruno Haible  <bruno@clisp.org>
 
        free-posix: Work around GCC mis-optimization bug.
index 33018efa303a89db4a31dea314451fd9af46e0cc..dbc01034f68fc8cbbf0d65f4cfb84bc52c2f93b0 100644 (file)
@@ -13,7 +13,7 @@ NetBSD 8.0, Solaris 11.0, and others.
 
 @item
 @code{max_align_t} does not have the expected alignment on some platforms:
-NetBSD 8.0/x86.
+NetBSD 8.0/x86, AIX 7.2 with xlc in 64-bit mode.
 
 @item
 Some old platforms fail to provide @code{wchar_t}.
index 6ef45af1d114a9dccb2777cc7e798cf179b2afa0..77147e9bcc7d5a5dabf4085db8dacf0b3568b551 100644 (file)
 
 # ifndef _@GUARD_PREFIX@_STDDEF_H
 
+/* On AIX 7.2, with xlc in 64-bit mode, <stddef.h> defines max_align_t to a
+   type with alignment 4, but 'long' has alignment 8.  */
+#  if defined _AIX && defined _ARCH_PPC64
+#   if !GNULIB_defined_max_align_t
+#    ifdef _MAX_ALIGN_T
+/* /usr/include/stddef.h has already defined max_align_t.  Override it.  */
+typedef long rpl_max_align_t;
+#     define max_align_t rpl_max_align_t
+#    else
+/* Prevent /usr/include/stddef.h from defining max_align_t.  */
+typedef long max_align_t;
+#     define _MAX_ALIGN_T
+#    endif
+#    define GNULIB_defined_max_align_t 1
+#   endif
+#  endif
+
 /* The include_next requires a split double-inclusion guard.  */
 
 #  @INCLUDE_NEXT@ @NEXT_STDDEF_H@
index 7869621c0f9add2ca75ea4021538616fc768337a..cd666c4a58c65d5552fb9ee1704b49796f09b045 100644 (file)
@@ -1,4 +1,4 @@
-# stddef_h.m4 serial 8
+# stddef_h.m4 serial 9
 dnl Copyright (C) 2009-2021 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -28,6 +28,13 @@ AC_DEFUN([gl_STDDEF_H],
             int check1[2 * (__alignof__ (double) <= __alignof__ (max_align_t)) - 1];
             int check2[2 * (__alignof__ (long double) <= __alignof__ (max_align_t)) - 1];
             #endif
+            typedef struct { char a; max_align_t b; } max_helper;
+            typedef struct { char a; long b; } long_helper;
+            typedef struct { char a; double b; } double_helper;
+            typedef struct { char a; long double b; } long_double_helper;
+            int check3[2 * (offsetof (long_helper, b) <= offsetof (max_helper, b)) - 1];
+            int check4[2 * (offsetof (double_helper, b) <= offsetof (max_helper, b)) - 1];
+            int check5[2 * (offsetof (long_double_helper, b) <= offsetof (max_helper, b)) - 1];
           ]])],
        [gl_cv_type_max_align_t=yes],
        [gl_cv_type_max_align_t=no])