svn commit: r309258 - in stable: 10/include 10/sys/sys 11/include 11/sys/sys
John Baldwin
jhb at FreeBSD.org
Mon Nov 28 18:36:38 UTC 2016
Author: jhb
Date: Mon Nov 28 18:36:37 2016
New Revision: 309258
URL: https://svnweb.freebsd.org/changeset/base/309258
Log:
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
Modified:
stable/10/include/stddef.h
stable/10/sys/sys/_types.h
Directory Properties:
stable/10/ (props changed)
Changes in other areas also in this revision:
Modified:
stable/11/include/stddef.h
stable/11/sys/sys/_types.h
Directory Properties:
stable/11/ (props changed)
Modified: stable/10/include/stddef.h
==============================================================================
--- stable/10/include/stddef.h Mon Nov 28 17:55:32 2016 (r309257)
+++ stable/10/include/stddef.h Mon Nov 28 18:36:37 2016 (r309258)
@@ -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_ */
Modified: stable/10/sys/sys/_types.h
==============================================================================
--- stable/10/sys/sys/_types.h Mon Nov 28 17:55:32 2016 (r309257)
+++ stable/10/sys/sys/_types.h Mon Nov 28 18:36:37 2016 (r309258)
@@ -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 */
More information about the svn-src-stable
mailing list