From 137305d58ab81d0406baa675fc51c697eb0078ff Mon Sep 17 00:00:00 2001 From: Christian Prochaska Date: Mon, 6 Mar 2017 23:56:54 +0100 Subject: [PATCH] libc: add 'max_align_t' type Fixes #2334 --- repos/libports/lib/import/import-stdcxx.mk | 5 -- repos/libports/ports/libc.hash | 2 +- .../src/lib/libc/patches/max_align_t.patch | 59 +++++++++++++++++++ 3 files changed, 60 insertions(+), 6 deletions(-) create mode 100644 repos/libports/src/lib/libc/patches/max_align_t.patch diff --git a/repos/libports/lib/import/import-stdcxx.mk b/repos/libports/lib/import/import-stdcxx.mk index 4de2068b67..62d270466d 100644 --- a/repos/libports/lib/import/import-stdcxx.mk +++ b/repos/libports/lib/import/import-stdcxx.mk @@ -19,8 +19,3 @@ CC_OPT += -D_GLIBCXX_HAVE_MBSTATE_T # use compiler-builtin atomic operations CC_OPT += -D_GLIBCXX_ATOMIC_BUILTINS_4 - -# GCC's stddef.h defines the 'max_align_t' type, which is used in the 'cstddef' -# C++ header file. libc's version of stddef.h shadows GCC's version, so it is -# included explicitly here. -CC_OPT += -include $(LIBGCC_INC_DIR)/stddef.h diff --git a/repos/libports/ports/libc.hash b/repos/libports/ports/libc.hash index d27ba80e84..3405c07bb4 100644 --- a/repos/libports/ports/libc.hash +++ b/repos/libports/ports/libc.hash @@ -1 +1 @@ -d8d8c56df0ee6a1c3bd2c08c1f013a1ab7c408a7 +95577a93137d4fda7e095374eacd5e20c4ea5e18 diff --git a/repos/libports/src/lib/libc/patches/max_align_t.patch b/repos/libports/src/lib/libc/patches/max_align_t.patch new file mode 100644 index 0000000000..029b95ba55 --- /dev/null +++ b/repos/libports/src/lib/libc/patches/max_align_t.patch @@ -0,0 +1,59 @@ +From 689bb2db9dbb8fa247c030735dbd6e4f861d0e60 Mon Sep 17 00:00:00 2001 +From: jhb +Date: Fri, 21 Oct 2016 23:50:02 +0000 +Subject: [PATCH] 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 that matches the GCC and +clang definition that is mapped to max_align_t in . + +PR: 210890 +Reviewed by: dim +MFC after: 1 month +Differential Revision: https://reviews.freebsd.org/D8194 + +cproc: slightly modified for Genode (_Alignof -> __alignof__) + +--- + include/stddef.h | 8 ++++++++ + sys/sys/_types.h | 5 +++++ + 2 files changed, 13 insertions(+) + +diff --git a/include/stddef.h b/include/stddef.h +index 7898da2..7f2d2f0c 100644 +--- src/lib/libc/include/stddef.h ++++ src/lib/libc/include/stddef.h +@@ -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_ */ +diff --git a/sys/sys/_types.h b/sys/sys/_types.h +index ecc1c7e..8736651 100644 +--- src/lib/libc/sys/sys/_types.h ++++ src/lib/libc/sys/sys/_types.h +@@ -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 */