about summary refs log tree commit diff
path: root/include/stddef.h
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2014-08-20 17:20:14 -0400
committerRich Felker <dalias@aerifal.cx>2014-08-20 17:20:14 -0400
commit321f4fa9067185aa6bb47403dfba46e8cfe917d3 (patch)
tree99ccc4b3b101b6becae777a80cb28f065cba317d /include/stddef.h
parent4992ace94232a116bdca25481ccc3d6841b83432 (diff)
downloadmusl-321f4fa9067185aa6bb47403dfba46e8cfe917d3.tar.gz
musl-321f4fa9067185aa6bb47403dfba46e8cfe917d3.tar.xz
musl-321f4fa9067185aa6bb47403dfba46e8cfe917d3.zip
add max_align_t definition for C11 and C++11
unfortunately this needs to be able to vary by arch, because of a huge
mess GCC made: the GCC definition, which became the ABI, depends on
quirks in GCC's definition of __alignof__, which does not match the
formal alignment of the type.

GCC's __alignof__ unexpectedly exposes the an implementation detail,
its "preferred alignment" for the type, rather than the formal/ABI
alignment of the type, which it only actually uses in structures. on
most archs the two values are the same, but on some (at least i386)
the preferred alignment is greater than the ABI alignment.

I considered using _Alignas(8) unconditionally, but on at least one
arch (or1k), the alignment of max_align_t with GCC's definition is
only 4 (even the "preferred alignment" for these types is only 4).
Diffstat (limited to 'include/stddef.h')
-rw-r--r--include/stddef.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/include/stddef.h b/include/stddef.h
index 0a329190..bd753853 100644
--- a/include/stddef.h
+++ b/include/stddef.h
@@ -10,6 +10,9 @@
 #define __NEED_ptrdiff_t
 #define __NEED_size_t
 #define __NEED_wchar_t
+#if __STDC_VERSION__ >= 201112L || __cplusplus >= 201103L
+#define __NEED_max_align_t
+#endif
 
 #include <bits/alltypes.h>