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
Reviewed by:	dim
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D8194
This commit is contained in:
John Baldwin 2016-10-21 23:50:02 +00:00
parent 7627b33010
commit 5dd723425e
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=307756
2 changed files with 13 additions and 0 deletions

View file

@ -62,6 +62,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_ */

View file

@ -100,6 +100,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 */