1 # Check for stdalign.h that conforms to C11.
3 dnl Copyright 2011-2018 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
8 # Prepare for substituting <stdalign.h> if it is not supported.
10 AC_DEFUN([gl_STDALIGN_H],
12 AC_CACHE_CHECK([for working stdalign.h],
13 [gl_cv_header_working_stdalign_h],
16 [[#include <stdalign.h>
19 /* Test that alignof yields a result consistent with offsetof.
20 This catches GCC bug 52023
21 <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52023>. */
23 template <class t> struct alignof_helper { char a; t b; };
24 # define ao(type) offsetof (alignof_helper<type>, b)
26 # define ao(type) offsetof (struct { char a; type b; }, b)
28 char test_double[ao (double) % _Alignof (double) == 0 ? 1 : -1];
29 char test_long[ao (long int) % _Alignof (long int) == 0 ? 1 : -1];
30 char test_alignof[alignof (double) == _Alignof (double) ? 1 : -1];
32 /* Test _Alignas only on platforms where gnulib can help. */
34 ((defined __cplusplus && 201103 <= __cplusplus) \
35 || (defined __APPLE__ && defined __MACH__ \
36 ? 4 < __GNUC__ + (1 <= __GNUC_MINOR__) \
38 || (__ia64 && (61200 <= __HP_cc || 61200 <= __HP_aCC)) \
39 || __ICC || 0x590 <= __SUNPRO_C || 0x0600 <= __xlC__ \
41 struct alignas_test { char c; char alignas (8) alignas_8; };
42 char test_alignas[offsetof (struct alignas_test, alignas_8) == 8
46 [gl_cv_header_working_stdalign_h=yes],
47 [gl_cv_header_working_stdalign_h=no])])
49 if test $gl_cv_header_working_stdalign_h = yes; then
52 STDALIGN_H='stdalign.h'
55 AC_SUBST([STDALIGN_H])
56 AM_CONDITIONAL([GL_GENERATE_STDALIGN_H], [test -n "$STDALIGN_H"])