psmedley / gcc

GNU General Public License v2.0
7 stars 1 forks source link

Define max_align_t on C++11 #26

Closed komh closed 7 years ago

komh commented 7 years ago

Hi/2.

Here is the patch for max_align_t on C++11. Review, please...

From 37fb62f22a735258af82bd3747704cc36d5e26ca Mon Sep 17 00:00:00 2001
From: KO Myung-Hun <komh@chollian.net>
Date: Sat, 1 Oct 2016 23:32:19 +0900
Subject: [PATCH] OS/2: Define max_align_t on C++11

C++11 requires max_align_t which is a C11 stuff. However, OS/2 kLIBC
headers are not ready for C11.

So, define max_align_t in os_defines.h which is a OS-specefic header
on C++. By this, it's possible to remove _GCC_MAX_ALIGN_T guard of
cstddef, too.

    modified:   libstdc++-v3/config/os/os2/os_defines.h
    modified:   libstdc++-v3/include/c_global/cstddef

---
 libstdc++-v3/config/os/os2/os_defines.h | 8 ++++++++
 libstdc++-v3/include/c_global/cstddef   | 2 +-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/libstdc++-v3/config/os/os2/os_defines.h b/libstdc++-v3/config/os/os2/os_defines.h
index 3bfe3ef..d9044a9 100644
--- a/libstdc++-v3/config/os/os2/os_defines.h
+++ b/libstdc++-v3/config/os/os2/os_defines.h
@@ -38,4 +38,12 @@
 #define _GLIBCXX_USE_C99_LONG_LONG_CHECK 1
 #define _GLIBCXX_USE_C99_LONG_LONG_DYNAMIC (_GLIBCXX_USE_C99_DYNAMIC || !defined __LONG_LONG_SUPPORTED)

+// C++11 requires max_align_t of C11. See gcc/ginclude/stddef.h.
+#if __cplusplus >= 201103L
+typedef struct {
+  long long __max_align_ll __attribute__((__aligned__(__alignof__(long long))));
+  long double __max_align_ld __attribute__((__aligned__(__alignof__(long double))));
+} max_align_t;
+#endif
+
 #endif
diff --git a/libstdc++-v3/include/c_global/cstddef b/libstdc++-v3/include/c_global/cstddef
index b4cb538..1a87dd6 100644
--- a/libstdc++-v3/include/c_global/cstddef
+++ b/libstdc++-v3/include/c_global/cstddef
@@ -44,7 +44,7 @@
 #include <bits/c++config.h>
 #include <stddef.h>

-#if __cplusplus >= 201103L && defined(_GCC_MAX_ALIGN_T)
+#if __cplusplus >= 201103L
 namespace std
 {
   // We handle size_t, ptrdiff_t, and nullptr_t in c++config.h.
-- 
2.9.2
komh commented 7 years ago

If no objections, I'll push soon.

dmik commented 7 years ago

I have no objections so far.

BTW do you have a lot of successful pushes for GCC? Asking because we don't normally push our work so I wonder if we should watch out for conflicts between your pushes and our repo...

komh commented 7 years ago

This is the last patch for GCC, currently. And if possible, it would be better to push your work, too. Or you should take care of any conflicts.