summaryrefslogtreecommitdiff
path: root/m4/stdalign.m4
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2024-04-01 18:50:20 +0800
committerSean Whitton <spwhitton@spwhitton.name>2024-04-01 18:50:20 +0800
commit0fef2018445b257bf26814e6659bc2ff5b270d77 (patch)
tree2310ce1fd8781a6203ec56e2f985f6adfcc2278d /m4/stdalign.m4
parent3a8546615a38337dc991f6546ade63a372edc2ca (diff)
parent49f76dcc17055e60569b6096e8ea3c9961ebbf63 (diff)
downloademacs-0fef2018445b257bf26814e6659bc2ff5b270d77.tar.gz
Merge branch 'athena/unstable' into athena/bookworm-backports
Diffstat (limited to 'm4/stdalign.m4')
-rw-r--r--m4/stdalign.m412
1 files changed, 8 insertions, 4 deletions
diff --git a/m4/stdalign.m4 b/m4/stdalign.m4
index 2683fae7daf..e3c1e609236 100644
--- a/m4/stdalign.m4
+++ b/m4/stdalign.m4
@@ -13,10 +13,10 @@ AC_DEFUN([gl_ALIGNASOF],
[
AC_CACHE_CHECK([for alignas and alignof],
[gl_cv_header_working_stdalign_h],
- [gl_save_CFLAGS=$CFLAGS
+ [gl_saved_CFLAGS=$CFLAGS
for gl_working in "yes, keywords" "yes, <stdalign.h> macros"; do
AS_CASE([$gl_working],
- [*stdalign.h*], [CFLAGS="$gl_save_CFLAGS -DINCLUDE_STDALIGN_H"])
+ [*stdalign.h*], [CFLAGS="$gl_saved_CFLAGS -DINCLUDE_STDALIGN_H"])
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
[[#include <stdint.h>
@@ -56,7 +56,7 @@ AC_DEFUN([gl_ALIGNASOF],
[gl_cv_header_working_stdalign_h=$gl_working],
[gl_cv_header_working_stdalign_h=no])
- CFLAGS=$gl_save_CFLAGS
+ CFLAGS=$gl_saved_CFLAGS
test "$gl_cv_header_working_stdalign_h" != no && break
done])
@@ -112,7 +112,11 @@ AC_DEFUN([gl_ALIGNASOF],
# define _Alignof(type) alignof (type)
# else
template <class __t> struct __alignof_helper { char __a; __t __b; };
-# define _Alignof(type) offsetof (__alignof_helper<type>, __b)
+# if (defined __GNUC__ && 4 <= __GNUC__) || defined __clang__
+# define _Alignof(type) __builtin_offsetof (__alignof_helper<type>, __b)
+# else
+# define _Alignof(type) offsetof (__alignof_helper<type>, __b)
+# endif
# define _GL_STDALIGN_NEEDS_STDDEF 1
# endif
# else