summaryrefslogtreecommitdiff
path: root/m4/stdalign.m4
blob: 9752ba568b4d73893610d220f6d2ff039ed88af4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# Check for stdalign.h that conforms to C11.

dnl Copyright 2011-2012 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.

# Prepare for substituting <stdalign.h> if it is not supported.

AC_DEFUN([gl_STDALIGN_H],
[
  AC_CACHE_CHECK([for working stdalign.h],
    [gl_cv_header_working_stdalign_h],
    [AC_COMPILE_IFELSE(
       [AC_LANG_PROGRAM(
          [[#include <stdalign.h>
            int align_int = alignof (int) + _Alignof (double);

            /* Test _Alignas only on platforms where gnulib can help.  */
            #if \
                (__GNUC__ || __IBMC__ || __IBMCPP__ \
                 || 0x5110 <= __SUNPRO_C || 1300 <= _MSC_VER)
              int alignas (8) alignas_int = 1;
            #endif
          ]])],
       [gl_cv_header_working_stdalign_h=yes],
       [gl_cv_header_working_stdalign_h=no])])

  if test $gl_cv_header_working_stdalign_h = yes; then
    STDALIGN_H=''
  else
    STDALIGN_H='stdalign.h'
  fi

  AC_SUBST([STDALIGN_H])
  AM_CONDITIONAL([GL_GENERATE_STDALIGN_H], [test -n "$STDALIGN_H"])
])