|
Packit Service |
a2489d |
# Check for stdalign.h that conforms to C11.
|
|
Packit Service |
a2489d |
|
|
Packit Service |
a2489d |
dnl Copyright 2011-2018 Free Software Foundation, Inc.
|
|
Packit Service |
a2489d |
dnl This file is free software; the Free Software Foundation
|
|
Packit Service |
a2489d |
dnl gives unlimited permission to copy and/or distribute it,
|
|
Packit Service |
a2489d |
dnl with or without modifications, as long as this notice is preserved.
|
|
Packit Service |
a2489d |
|
|
Packit Service |
a2489d |
# Prepare for substituting <stdalign.h> if it is not supported.
|
|
Packit Service |
a2489d |
|
|
Packit Service |
a2489d |
AC_DEFUN([gl_STDALIGN_H],
|
|
Packit Service |
a2489d |
[
|
|
Packit Service |
a2489d |
AC_CACHE_CHECK([for working stdalign.h],
|
|
Packit Service |
a2489d |
[gl_cv_header_working_stdalign_h],
|
|
Packit Service |
a2489d |
[AC_COMPILE_IFELSE(
|
|
Packit Service |
a2489d |
[AC_LANG_PROGRAM(
|
|
Packit Service |
a2489d |
[[#include <stdalign.h>
|
|
Packit Service |
a2489d |
#include <stddef.h>
|
|
Packit Service |
a2489d |
|
|
Packit Service |
a2489d |
/* Test that alignof yields a result consistent with offsetof.
|
|
Packit Service |
a2489d |
This catches GCC bug 52023
|
|
Packit Service |
a2489d |
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52023>. */
|
|
Packit Service |
a2489d |
#ifdef __cplusplus
|
|
Packit Service |
a2489d |
template <class t> struct alignof_helper { char a; t b; };
|
|
Packit Service |
a2489d |
# define ao(type) offsetof (alignof_helper<type>, b)
|
|
Packit Service |
a2489d |
#else
|
|
Packit Service |
a2489d |
# define ao(type) offsetof (struct { char a; type b; }, b)
|
|
Packit Service |
a2489d |
#endif
|
|
Packit Service |
a2489d |
char test_double[ao (double) % _Alignof (double) == 0 ? 1 : -1];
|
|
Packit Service |
a2489d |
char test_long[ao (long int) % _Alignof (long int) == 0 ? 1 : -1];
|
|
Packit Service |
a2489d |
char test_alignof[alignof (double) == _Alignof (double) ? 1 : -1];
|
|
Packit Service |
a2489d |
|
|
Packit Service |
a2489d |
/* Test _Alignas only on platforms where gnulib can help. */
|
|
Packit Service |
a2489d |
#if \
|
|
Packit Service |
a2489d |
((defined __cplusplus && 201103 <= __cplusplus) \
|
|
Packit Service |
a2489d |
|| (defined __APPLE__ && defined __MACH__ \
|
|
Packit Service |
a2489d |
? 4 < __GNUC__ + (1 <= __GNUC_MINOR__) \
|
|
Packit Service |
a2489d |
: __GNUC__) \
|
|
Packit Service |
a2489d |
|| (__ia64 && (61200 <= __HP_cc || 61200 <= __HP_aCC)) \
|
|
Packit Service |
a2489d |
|| __ICC || 0x590 <= __SUNPRO_C || 0x0600 <= __xlC__ \
|
|
Packit Service |
a2489d |
|| 1300 <= _MSC_VER)
|
|
Packit Service |
a2489d |
struct alignas_test { char c; char alignas (8) alignas_8; };
|
|
Packit Service |
a2489d |
char test_alignas[offsetof (struct alignas_test, alignas_8) == 8
|
|
Packit Service |
a2489d |
? 1 : -1];
|
|
Packit Service |
a2489d |
#endif
|
|
Packit Service |
a2489d |
]])],
|
|
Packit Service |
a2489d |
[gl_cv_header_working_stdalign_h=yes],
|
|
Packit Service |
a2489d |
[gl_cv_header_working_stdalign_h=no])])
|
|
Packit Service |
a2489d |
|
|
Packit Service |
a2489d |
if test $gl_cv_header_working_stdalign_h = yes; then
|
|
Packit Service |
a2489d |
STDALIGN_H=''
|
|
Packit Service |
a2489d |
else
|
|
Packit Service |
a2489d |
STDALIGN_H='stdalign.h'
|
|
Packit Service |
a2489d |
fi
|
|
Packit Service |
a2489d |
|
|
Packit Service |
a2489d |
AC_SUBST([STDALIGN_H])
|
|
Packit Service |
a2489d |
AM_CONDITIONAL([GL_GENERATE_STDALIGN_H], [test -n "$STDALIGN_H"])
|
|
Packit Service |
a2489d |
])
|