summaryrefslogtreecommitdiffstats
path: root/gl/m4/stdalign.m4
diff options
context:
space:
mode:
Diffstat (limited to 'gl/m4/stdalign.m4')
-rw-r--r--gl/m4/stdalign.m423
1 files changed, 13 insertions, 10 deletions
diff --git a/gl/m4/stdalign.m4 b/gl/m4/stdalign.m4
index 20be01a..78577cb 100644
--- a/gl/m4/stdalign.m4
+++ b/gl/m4/stdalign.m4
@@ -1,6 +1,6 @@
1# Check for stdalign.h that conforms to C11. 1# Check for stdalign.h that conforms to C11.
2 2
3dnl Copyright 2011-2013 Free Software Foundation, Inc. 3dnl Copyright 2011-2022 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
@@ -13,12 +13,13 @@ AC_DEFUN([gl_STDALIGN_H],
13 [gl_cv_header_working_stdalign_h], 13 [gl_cv_header_working_stdalign_h],
14 [AC_COMPILE_IFELSE( 14 [AC_COMPILE_IFELSE(
15 [AC_LANG_PROGRAM( 15 [AC_LANG_PROGRAM(
16 [[#include <stdalign.h> 16 [[#include <stdint.h>
17 #include <stdalign.h>
17 #include <stddef.h> 18 #include <stddef.h>
18 19
19 /* Test that alignof yields a result consistent with offsetof. 20 /* Test that alignof yields a result consistent with offsetof.
20 This catches GCC bug 52023 21 This catches GCC bug 52023
21 <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52023>. */ 22 <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52023>. */
22 #ifdef __cplusplus 23 #ifdef __cplusplus
23 template <class t> struct alignof_helper { char a; t b; }; 24 template <class t> struct alignof_helper { char a; t b; };
24 # define ao(type) offsetof (alignof_helper<type>, b) 25 # define ao(type) offsetof (alignof_helper<type>, b)
@@ -32,8 +33,13 @@ AC_DEFUN([gl_STDALIGN_H],
32 /* Test _Alignas only on platforms where gnulib can help. */ 33 /* Test _Alignas only on platforms where gnulib can help. */
33 #if \ 34 #if \
34 ((defined __cplusplus && 201103 <= __cplusplus) \ 35 ((defined __cplusplus && 201103 <= __cplusplus) \
35 || __GNUC__ || __IBMC__ || __IBMCPP__ || __ICC \ 36 || (__TINYC__ && defined __attribute__) \
36 || 0x5110 <= __SUNPRO_C || 1300 <= _MSC_VER) 37 || (defined __APPLE__ && defined __MACH__ \
38 ? 4 < __GNUC__ + (1 <= __GNUC_MINOR__) \
39 : __GNUC__) \
40 || (__ia64 && (61200 <= __HP_cc || 61200 <= __HP_aCC)) \
41 || __ICC || 0x590 <= __SUNPRO_C || 0x0600 <= __xlC__ \
42 || 1300 <= _MSC_VER)
37 struct alignas_test { char c; char alignas (8) alignas_8; }; 43 struct alignas_test { char c; char alignas (8) alignas_8; };
38 char test_alignas[offsetof (struct alignas_test, alignas_8) == 8 44 char test_alignas[offsetof (struct alignas_test, alignas_8) == 8
39 ? 1 : -1]; 45 ? 1 : -1];
@@ -43,11 +49,8 @@ AC_DEFUN([gl_STDALIGN_H],
43 [gl_cv_header_working_stdalign_h=no])]) 49 [gl_cv_header_working_stdalign_h=no])])
44 50
45 if test $gl_cv_header_working_stdalign_h = yes; then 51 if test $gl_cv_header_working_stdalign_h = yes; then
46 STDALIGN_H='' 52 GL_GENERATE_STDALIGN_H=false
47 else 53 else
48 STDALIGN_H='stdalign.h' 54 GL_GENERATE_STDALIGN_H=true
49 fi 55 fi
50
51 AC_SUBST([STDALIGN_H])
52 AM_CONDITIONAL([GL_GENERATE_STDALIGN_H], [test -n "$STDALIGN_H"])
53]) 56])