Blame m4/stdalign.m4

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