aboutsummaryrefslogtreecommitdiffstats
path: root/m4/stdalign.m4
diff options
context:
space:
mode:
authorPaul Eggert2012-05-26 16:14:36 -0700
committerPaul Eggert2012-05-26 16:14:36 -0700
commitcaf8a9b2b301aba06735d403317b75b41df59bfe (patch)
treebfafb3cc0cf8a2f2394b4ed721e7c3d4891b78ab /m4/stdalign.m4
parentfe453991eafc32a890297a2003ac532b9f579f92 (diff)
downloademacs-caf8a9b2b301aba06735d403317b75b41df59bfe.tar.gz
emacs-caf8a9b2b301aba06735d403317b75b41df59bfe.zip
Merge from gnulib.
Fixes: debbugs:11527
Diffstat (limited to 'm4/stdalign.m4')
-rw-r--r--m4/stdalign.m451
1 files changed, 51 insertions, 0 deletions
diff --git a/m4/stdalign.m4 b/m4/stdalign.m4
new file mode 100644
index 00000000000..6659c9c3ecd
--- /dev/null
+++ b/m4/stdalign.m4
@@ -0,0 +1,51 @@
1# Check for stdalign.h that conforms to C11.
2
3dnl Copyright 2011-2012 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7
8# Prepare for substituting <stdalign.h> if it is not supported.
9
10AC_DEFUN([gl_STDALIGN_H],
11[
12 AC_CACHE_CHECK([for working stdalign.h],
13 [gl_cv_header_working_stdalign_h],
14 [AC_COMPILE_IFELSE(
15 [AC_LANG_PROGRAM(
16 [[#include <stdalign.h>
17 #include <stddef.h>
18
19 /* Test that alignof yields a result consistent with offsetof.
20 This catches GCC bug 52023
21 <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52023>. */
22 #ifdef __cplusplus
23 template <class t> struct alignof_helper { char a; t b; };
24 # define ao(type) offsetof (alignof_helper<type>, b)
25 #else
26 # define ao(type) offsetof (struct { char a; type b; }, b)
27 #endif
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];
31
32 /* Test _Alignas only on platforms where gnulib can help. */
33 #if \
34 (__GNUC__ || __IBMC__ || __IBMCPP__ \
35 || 0x5110 <= __SUNPRO_C || 1300 <= _MSC_VER)
36 int alignas (8) alignas_int = 1;
37 char test_alignas[_Alignof (alignas_int) == 8 ? 1 : -1];
38 #endif
39 ]])],
40 [gl_cv_header_working_stdalign_h=yes],
41 [gl_cv_header_working_stdalign_h=no])])
42
43 if test $gl_cv_header_working_stdalign_h = yes; then
44 STDALIGN_H=''
45 else
46 STDALIGN_H='stdalign.h'
47 fi
48
49 AC_SUBST([STDALIGN_H])
50 AM_CONDITIONAL([GL_GENERATE_STDALIGN_H], [test -n "$STDALIGN_H"])
51])