Closed komh closed 8 years ago
Here is the patch. I've added macros to enable those features as built-in. Because we cannot fix kLIBC headers. If kLIBC headers are fixed, this patch except os_defines.h is unnecessary.
From 1e73f8d3899f95dc6664e8e5876b2ed452203a1f Mon Sep 17 00:00:00 2001
From: KO Myung-Hun <komh@chollian.net>
Date: Tue, 16 Feb 2016 15:36:58 +0900
Subject: [PATCH] OS/2: Enable C99 stuffs in C++11
C++11 supports some C99 features. However OS/2 kLIBC headers do not
support them well.
To workaround, define some feature test macros as built-in. They are
__STDC_CONSTANT_MACROS
__STDC_LIMIT_MACROS
__LONG_LONG_SUPPORTED
Especially, __LONG_LONG_SUPPORTED enables _GLIBCXX_USE_C99 feature in
libstdc++-v3, which use -std=c++98 to test C99 features in C++.
modified: gcc/config/i386/emx.h
modified: libstdc++-v3/config/os/os2/os_defines.h
---
gcc/config/i386/emx.h | 11 +++++++++++
libstdc++-v3/config/os/os2/os_defines.h | 5 +++++
2 files changed, 16 insertions(+)
diff --git a/gcc/config/i386/emx.h b/gcc/config/i386/emx.h
index 474d2ec..855297b 100644
--- a/gcc/config/i386/emx.h
+++ b/gcc/config/i386/emx.h
@@ -380,6 +380,17 @@ do { \
builtin_define ("_cdecl=__attribute__((__cdecl__))"); \
builtin_define ("_Cdecl=__attribute__((__cdecl__))"); \
} \
+ if (c_dialect_cxx ()) \
+ { \
+ if (cxx_dialect >= cxx11) \
+ { \
+ builtin_define ("__STDC_CONSTANT_MACROS"); \
+ builtin_define ("__STDC_LIMIT_MACROS"); \
+ } \
+ if (cxx_dialect >= cxx11 || \
+ flag_iso /* For _GLIBCXX_USE_C99 of libstdc++-v3) */) \
+ builtin_define ("__LONG_LONG_SUPPORTED"); \
+ } \
builtin_define_std ("__KLIBC__=0"); \
builtin_define_std ("__KLIBC_MINOR__=6"); \
builtin_define_std ("__KLIBC_PATCHLEVEL__=3"); \
diff --git a/libstdc++-v3/config/os/os2/os_defines.h b/libstdc++-v3/config/os/os2/os_defines.h
index 50ea322..3bfe3ef 100644
--- a/libstdc++-v3/config/os/os2/os_defines.h
+++ b/libstdc++-v3/config/os/os2/os_defines.h
@@ -33,4 +33,9 @@
// System-specific #define, typedefs, corrections, etc, go here. This
// file will come before all others.
+#define _GLIBCXX_USE_C99_CHECK 1
+#define _GLIBCXX_USE_C99_DYNAMIC (!(__ISO_C_VISIBLE >= 1999))
+#define _GLIBCXX_USE_C99_LONG_LONG_CHECK 1
+#define _GLIBCXX_USE_C99_LONG_LONG_DYNAMIC (_GLIBCXX_USE_C99_DYNAMIC || !defined __LONG_LONG_SUPPORTED)
+
#endif
--
2.7.0
Pushed as commit fef1630c35955e6352f9734b43d20758ce7508be.
Hi/2.
Some C99 features in C++11 are not enabled. For example, INT64_C() of stdint.h and long long stuffs. Especially, long long stuffs disables _GLIBCXX_USE_C99 feature of libstdc++-v3. As a result, many C99 functions such as lldiv() are missing in std namespace. #14 is releated to this.