+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.
@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}.
# 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@
-# 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,
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])