summaryrefslogtreecommitdiff
path: root/lib/alignof.h
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2020-08-09 15:58:10 +0200
committerBruno Haible <bruno@clisp.org>2020-08-09 15:58:10 +0200
commit57caf9541d98314102a55dd1cd0b8dc2be747471 (patch)
tree4ce7a17a15154f0f84398b7df3313e2126ead326 /lib/alignof.h
parentcae4fcab00ff89a5271376aed615cfa8c067fca2 (diff)
downloadgnulib-57caf9541d98314102a55dd1cd0b8dc2be747471.tar.gz
Use __alignof__ with clang.
* m4/stddef_h.m4 (gl_STDDEF_H): Test the alignment of max_align_t also on clang. * lib/alignof.h (alignof_type): Use __alignof__ also on clang. * lib/stdalign.in.h (_Alignof): Don't activate the GCC workaround on clang. * lib/malloca.h (sa_alignof): Use __alignof__ also on clang. * lib/bitset/list.c (lbitset_elt_alloc): Use __alignof__ also on clang. * lib/bitset/table.c (tbitset_elt_alloc): Likewise. * tests/test-stddef.c: Very the behaviour of __alignof__ also on clang.
Diffstat (limited to 'lib/alignof.h')
-rw-r--r--lib/alignof.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/alignof.h b/lib/alignof.h
index c72e914406..3a8d8d2343 100644
--- a/lib/alignof.h
+++ b/lib/alignof.h
@@ -36,12 +36,14 @@
/* alignof_type (TYPE)
Determine the good alignment of an object of the given type at compile time.
Note that this is not necessarily the same as alignof_slot(type).
- For example, with GNU C on x86 platforms: alignof_type(double) = 8, but
+ For example, with GNU C on x86 platforms and with clang on Linux/x86:
+ alignof_type(long long) = 8, but alignof_slot(long long) = 4.
+ And alignof_type(double) = 8, but
- when -malign-double is not specified: alignof_slot(double) = 4,
- when -malign-double is specified: alignof_slot(double) = 8.
Note: The result cannot be used as a value for an 'enum' constant,
due to bugs in HP-UX 10.20 cc and AIX 3.2.5 xlc. */
-#if defined __GNUC__ || defined __IBM__ALIGNOF__
+#if defined __GNUC__ || defined __clang__ || defined __IBM__ALIGNOF__
# define alignof_type __alignof__
#else
# define alignof_type alignof_slot