Mercurial > gnulib
annotate m4/stdalign.m4 @ 40186:8964917f9574
autoupdate
author | Karl Berry <karl@freefriends.org> |
---|---|
date | Mon, 18 Feb 2019 08:02:49 -0800 |
parents | b06060465f09 |
children |
rev | line source |
---|---|
16239
91f53c1e1787
doc: C11 and C++11 are now official
Paul Eggert <eggert@cs.ucla.edu>
parents:
16201
diff
changeset
|
1 # Check for stdalign.h that conforms to C11. |
15994 | 2 |
40057
b06060465f09
maint: Run 'make update-copyright'
Paul Eggert <eggert@cs.ucla.edu>
parents:
19484
diff
changeset
|
3 dnl Copyright 2011-2019 Free Software Foundation, Inc. |
15994 | 4 dnl This file is free software; the Free Software Foundation |
5 dnl gives unlimited permission to copy and/or distribute it, | |
6 dnl with or without modifications, as long as this notice is preserved. | |
7 | |
8 # Prepare for substituting <stdalign.h> if it is not supported. | |
9 | |
10 AC_DEFUN([gl_STDALIGN_H], | |
11 [ | |
16140
7fae013a2fd6
stdalign: port to Clang 3.0
Paul Eggert <eggert@cs.ucla.edu>
parents:
15999
diff
changeset
|
12 AC_CACHE_CHECK([for working stdalign.h], |
7fae013a2fd6
stdalign: port to Clang 3.0
Paul Eggert <eggert@cs.ucla.edu>
parents:
15999
diff
changeset
|
13 [gl_cv_header_working_stdalign_h], |
7fae013a2fd6
stdalign: port to Clang 3.0
Paul Eggert <eggert@cs.ucla.edu>
parents:
15999
diff
changeset
|
14 [AC_COMPILE_IFELSE( |
7fae013a2fd6
stdalign: port to Clang 3.0
Paul Eggert <eggert@cs.ucla.edu>
parents:
15999
diff
changeset
|
15 [AC_LANG_PROGRAM( |
7fae013a2fd6
stdalign: port to Clang 3.0
Paul Eggert <eggert@cs.ucla.edu>
parents:
15999
diff
changeset
|
16 [[#include <stdalign.h> |
16318
39ff0ed6c426
stdalign: check that alignof and offsetof are consistent
Paul Eggert <eggert@cs.ucla.edu>
parents:
16239
diff
changeset
|
17 #include <stddef.h> |
39ff0ed6c426
stdalign: check that alignof and offsetof are consistent
Paul Eggert <eggert@cs.ucla.edu>
parents:
16239
diff
changeset
|
18 |
39ff0ed6c426
stdalign: check that alignof and offsetof are consistent
Paul Eggert <eggert@cs.ucla.edu>
parents:
16239
diff
changeset
|
19 /* Test that alignof yields a result consistent with offsetof. |
16319
934a441c5452
Fix bug# typo in previous patch.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16318
diff
changeset
|
20 This catches GCC bug 52023 |
19190 | 21 <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52023>. */ |
16318
39ff0ed6c426
stdalign: check that alignof and offsetof are consistent
Paul Eggert <eggert@cs.ucla.edu>
parents:
16239
diff
changeset
|
22 #ifdef __cplusplus |
39ff0ed6c426
stdalign: check that alignof and offsetof are consistent
Paul Eggert <eggert@cs.ucla.edu>
parents:
16239
diff
changeset
|
23 template <class t> struct alignof_helper { char a; t b; }; |
39ff0ed6c426
stdalign: check that alignof and offsetof are consistent
Paul Eggert <eggert@cs.ucla.edu>
parents:
16239
diff
changeset
|
24 # define ao(type) offsetof (alignof_helper<type>, b) |
39ff0ed6c426
stdalign: check that alignof and offsetof are consistent
Paul Eggert <eggert@cs.ucla.edu>
parents:
16239
diff
changeset
|
25 #else |
39ff0ed6c426
stdalign: check that alignof and offsetof are consistent
Paul Eggert <eggert@cs.ucla.edu>
parents:
16239
diff
changeset
|
26 # define ao(type) offsetof (struct { char a; type b; }, b) |
39ff0ed6c426
stdalign: check that alignof and offsetof are consistent
Paul Eggert <eggert@cs.ucla.edu>
parents:
16239
diff
changeset
|
27 #endif |
16321
1031e29cf9ff
stdalign: relax _Alignof and tighten _Alignas test
Paul Eggert <eggert@cs.ucla.edu>
parents:
16319
diff
changeset
|
28 char test_double[ao (double) % _Alignof (double) == 0 ? 1 : -1]; |
1031e29cf9ff
stdalign: relax _Alignof and tighten _Alignas test
Paul Eggert <eggert@cs.ucla.edu>
parents:
16319
diff
changeset
|
29 char test_long[ao (long int) % _Alignof (long int) == 0 ? 1 : -1]; |
1031e29cf9ff
stdalign: relax _Alignof and tighten _Alignas test
Paul Eggert <eggert@cs.ucla.edu>
parents:
16319
diff
changeset
|
30 char test_alignof[alignof (double) == _Alignof (double) ? 1 : -1]; |
15994 | 31 |
16140
7fae013a2fd6
stdalign: port to Clang 3.0
Paul Eggert <eggert@cs.ucla.edu>
parents:
15999
diff
changeset
|
32 /* Test _Alignas only on platforms where gnulib can help. */ |
7fae013a2fd6
stdalign: port to Clang 3.0
Paul Eggert <eggert@cs.ucla.edu>
parents:
15999
diff
changeset
|
33 #if \ |
17434
6b7c1e9c98d6
stdalign, verify: port to FreeBSD 9.1, to C11, and to C++11
Paul Eggert <eggert@cs.ucla.edu>
parents:
17364
diff
changeset
|
34 ((defined __cplusplus && 201103 <= __cplusplus) \ |
17837
399c34835df9
stdalign: work around Apple GCC 4.0 bug
Paul Eggert <eggert@cs.ucla.edu>
parents:
17576
diff
changeset
|
35 || (defined __APPLE__ && defined __MACH__ \ |
399c34835df9
stdalign: work around Apple GCC 4.0 bug
Paul Eggert <eggert@cs.ucla.edu>
parents:
17576
diff
changeset
|
36 ? 4 < __GNUC__ + (1 <= __GNUC_MINOR__) \ |
399c34835df9
stdalign: work around Apple GCC 4.0 bug
Paul Eggert <eggert@cs.ucla.edu>
parents:
17576
diff
changeset
|
37 : __GNUC__) \ |
18749
93f3ea7943ba
stdalign: tweak version# and test for HP-UX IA64
Paul Eggert <eggert@cs.ucla.edu>
parents:
18746
diff
changeset
|
38 || (__ia64 && (61200 <= __HP_cc || 61200 <= __HP_aCC)) \ |
18746
9c4f3166e538
stdalign: restore previous behavior for HP-UX IA64
Paul Eggert <eggert@cs.ucla.edu>
parents:
18744
diff
changeset
|
39 || __ICC || 0x590 <= __SUNPRO_C || 0x0600 <= __xlC__ \ |
17838
eac9c3308ec8
stdalign: port better to HP compilers
Paul Eggert <eggert@cs.ucla.edu>
parents:
17837
diff
changeset
|
40 || 1300 <= _MSC_VER) |
17364
7524d97ae56f
stdalign: port to stricter ISO C11
Paul Eggert <eggert@cs.ucla.edu>
parents:
17249
diff
changeset
|
41 struct alignas_test { char c; char alignas (8) alignas_8; }; |
7524d97ae56f
stdalign: port to stricter ISO C11
Paul Eggert <eggert@cs.ucla.edu>
parents:
17249
diff
changeset
|
42 char test_alignas[offsetof (struct alignas_test, alignas_8) == 8 |
7524d97ae56f
stdalign: port to stricter ISO C11
Paul Eggert <eggert@cs.ucla.edu>
parents:
17249
diff
changeset
|
43 ? 1 : -1]; |
16140
7fae013a2fd6
stdalign: port to Clang 3.0
Paul Eggert <eggert@cs.ucla.edu>
parents:
15999
diff
changeset
|
44 #endif |
7fae013a2fd6
stdalign: port to Clang 3.0
Paul Eggert <eggert@cs.ucla.edu>
parents:
15999
diff
changeset
|
45 ]])], |
7fae013a2fd6
stdalign: port to Clang 3.0
Paul Eggert <eggert@cs.ucla.edu>
parents:
15999
diff
changeset
|
46 [gl_cv_header_working_stdalign_h=yes], |
7fae013a2fd6
stdalign: port to Clang 3.0
Paul Eggert <eggert@cs.ucla.edu>
parents:
15999
diff
changeset
|
47 [gl_cv_header_working_stdalign_h=no])]) |
7fae013a2fd6
stdalign: port to Clang 3.0
Paul Eggert <eggert@cs.ucla.edu>
parents:
15999
diff
changeset
|
48 |
7fae013a2fd6
stdalign: port to Clang 3.0
Paul Eggert <eggert@cs.ucla.edu>
parents:
15999
diff
changeset
|
49 if test $gl_cv_header_working_stdalign_h = yes; then |
15994 | 50 STDALIGN_H='' |
51 else | |
52 STDALIGN_H='stdalign.h' | |
53 fi | |
54 | |
55 AC_SUBST([STDALIGN_H]) | |
56 AM_CONDITIONAL([GL_GENERATE_STDALIGN_H], [test -n "$STDALIGN_H"]) | |
57 ]) |