summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2016-11-28 18:36:37 +0000
committerjhb <jhb@FreeBSD.org>2016-11-28 18:36:37 +0000
commit3d2d7a75e475fa129c001fa8411a5ad5f3a08958 (patch)
tree5805d4bdf966b4bf80bcc265eddcfae3c253daaa
parent313b26c41177fe20d7c6635dcbc8be85c51dec2e (diff)
downloadFreeBSD-src-3d2d7a75e475fa129c001fa8411a5ad5f3a08958.zip
FreeBSD-src-3d2d7a75e475fa129c001fa8411a5ad5f3a08958.tar.gz
MFC 307756: Define max_align_t for C11.
libc++'s stddef.h includes an existing definition of max_align_t for C++11, but it is only defined for C++, not for C. In addition, GCC and clang both define an alternate version of max_align_t that uses a union of multiple types rather than a plain long double as in libc++. This adds a __max_align_t to <sys/_types.h> that matches the GCC and clang definition that is mapped to max_align_t in <stddef.h>. PR: 210890
-rw-r--r--include/stddef.h8
-rw-r--r--sys/sys/_types.h5
2 files changed, 13 insertions, 0 deletions
diff --git a/include/stddef.h b/include/stddef.h
index 2c73a2e..99629e0 100644
--- a/include/stddef.h
+++ b/include/stddef.h
@@ -59,6 +59,14 @@ typedef ___wchar_t wchar_t;
#endif
#endif
+#if __STDC_VERSION__ >= 201112L || __cplusplus >= 201103L
+#ifndef __CLANG_MAX_ALIGN_T_DEFINED
+typedef __max_align_t max_align_t;
+#define __CLANG_MAX_ALIGN_T_DEFINED
+#define __GCC_MAX_ALIGN_T
+#endif
+#endif
+
#define offsetof(type, member) __offsetof(type, member)
#endif /* _STDDEF_H_ */
diff --git a/sys/sys/_types.h b/sys/sys/_types.h
index ffef9d8..8c16c6e 100644
--- a/sys/sys/_types.h
+++ b/sys/sys/_types.h
@@ -99,6 +99,11 @@ typedef __uint_least32_t __char32_t;
#define _CHAR32_T_DECLARED
#endif
+typedef struct {
+ long long __max_align1 __aligned(_Alignof(long long));
+ long double __max_align2 __aligned(_Alignof(long double));
+} __max_align_t;
+
typedef __uint32_t __dev_t; /* device number */
typedef __uint32_t __fixpt_t; /* fixed point number */
OpenPOWER on IntegriCloud