[PATCH] Feature test macros overhaul: C++ TR1

Yaakov Selkowitz yselkowitz@cygwin.com
Wed Mar 23 21:22:00 GMT 2016


On 2016-03-23 16:19, Yaakov Selkowitz wrote:
> While C++11 was the first version of the standard to use C99 functionality,
> TR1 (for C++03) also does, and G++ does not distinguish between C++98 and
> C++03, or when TR1 is in use.  Therefore, while not strictly correct for
> "pure" C++98, enabling C99 for all C++ usage is the simplest solution (and
> much better than always using -D_GNU_SOURCE as on Linux).
>
> See thread starting: https://sourceware.org/ml/newlib/2016/msg00297.html

This patch to newlib, along with the attached revised patches to GCC 
5.3, allow _GLIBCXX_USE_C99 to be enabled for bare-metal targets.

-- 
Yaakov
-------------- next part --------------
Newlib is missing support for long double math (real and complex) when
it is different from double.  However, AFAICS nothing dependent on just
_GLIBCXX_USE_C99 requires any complex math.

--- origsrc/gcc-5.3.0/libstdc++-v3/acinclude.m4	2015-11-24 07:25:07.000000000 -0600
+++ src/gcc-5.3.0/libstdc++-v3/acinclude.m4	2016-03-22 14:04:56.933798100 -0500
@@ -1128,7 +1128,6 @@ AC_DEFUN([GLIBCXX_ENABLE_C99], [
 
   # Option parsed, now set things appropriately.
   if test x"$glibcxx_cv_c99_math" = x"no" ||
-     test x"$glibcxx_cv_c99_complex" = x"no" ||
      test x"$glibcxx_cv_c99_stdio" = x"no" ||
      test x"$glibcxx_cv_c99_stdlib" = x"no" ||
      test x"$glibcxx_cv_c99_wchar" = x"no"; then
@@ -1136,7 +1133,7 @@ AC_DEFUN([GLIBCXX_ENABLE_C99], [
   else
     AC_DEFINE(_GLIBCXX_USE_C99, 1,
     [Define if C99 functions or macros from <wchar.h>, <math.h>,
-    <complex.h>, <stdio.h>, and <stdlib.h> can be used or exposed.])
+    <stdio.h>, and <stdlib.h> can be used or exposed.])
   fi
 
   gcc_no_link="$ac_save_gcc_no_link"
--- origsrc/gcc-5.3.0/libstdc++-v3/config.h.in	2015-11-24 07:25:07.000000000 -0600
+++ src/gcc-5.3.0/libstdc++-v3/config.h.in	2016-03-22 15:14:43.352905800 -0500
@@ -783,8 +783,8 @@
 /* Define to use Sun versioning in the shared library. */
 #undef _GLIBCXX_SYMVER_SUN
 
-/* Define if C99 functions or macros from <wchar.h>, <math.h>, <complex.h>,
-   <stdio.h>, and <stdlib.h> can be used or exposed. */
+/* Define if C99 functions or macros from <wchar.h>, <math.h>, <stdio.h>,
+   and <stdlib.h> can be used or exposed. */
 #undef _GLIBCXX_USE_C99
 
 /* Define if C99 functions in <complex.h> should be used in <complex>. Using
--- origsrc/gcc-5.3.0/libstdc++-v3/configure	2015-11-26 07:51:04.000000000 -0600
+++ src/gcc-5.3.0/libstdc++-v3/configure	2016-03-22 23:47:32.556098400 -0500
@@ -17270,7 +17270,6 @@ $as_echo "$glibcxx_cv_c99_wchar" >&6; }
 
   # Option parsed, now set things appropriately.
   if test x"$glibcxx_cv_c99_math" = x"no" ||
-     test x"$glibcxx_cv_c99_complex" = x"no" ||
      test x"$glibcxx_cv_c99_stdio" = x"no" ||
      test x"$glibcxx_cv_c99_stdlib" = x"no" ||
      test x"$glibcxx_cv_c99_wchar" = x"no"; then
-------------- next part --------------
--- origsrc/gcc-5.3.0/libstdc++-v3/configure	2015-11-26 07:51:04.000000000 -0600
+++ src/gcc-5.3.0/libstdc++-v3/configure	2016-03-22 23:47:32.556098400 -0500
@@ -27940,12 +27937,15 @@ else
   # on a hosted environment.
   if test "x${with_newlib}" = "xyes"; then
     os_include_dir="os/newlib"
-    $as_echo "#define HAVE_HYPOT 1" >>confdefs.h
+    # GLIBCXX_CHECK_STDLIB_SUPPORT
+    $as_echo "#define HAVE_AT_QUICK_EXIT 1" >>confdefs.h
 
+    $as_echo "#define HAVE_QUICK_EXIT 1" >>confdefs.h
 
-    # GLIBCXX_CHECK_STDLIB_SUPPORT
     $as_echo "#define HAVE_STRTOF 1" >>confdefs.h
 
+    $as_echo "#define HAVE_STRTOLD 1" >>confdefs.h
+
 
     $as_echo "#define HAVE_ACOSF 1" >>confdefs.h
 
@@ -27965,22 +27965,44 @@ else
 
     $as_echo "#define HAVE_FABSF 1" >>confdefs.h
 
+    $as_echo "#define HAVE_FINITE 1" >>confdefs.h
+
+    $as_echo "#define HAVE_FINITEF 1" >>confdefs.h
+
     $as_echo "#define HAVE_FLOORF 1" >>confdefs.h
 
     $as_echo "#define HAVE_FMODF 1" >>confdefs.h
 
     $as_echo "#define HAVE_FREXPF 1" >>confdefs.h
 
+    $as_echo "#define HAVE_HYPOT 1" >>confdefs.h
+
+    $as_echo "#define HAVE_HYPOTF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_ISINF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_ISINFF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_ISNAN 1" >>confdefs.h
+
+    $as_echo "#define HAVE_ISNANF 1" >>confdefs.h
+
     $as_echo "#define HAVE_LDEXPF 1" >>confdefs.h
 
     $as_echo "#define HAVE_LOG10F 1" >>confdefs.h
 
     $as_echo "#define HAVE_LOGF 1" >>confdefs.h
 
+    $as_echo "#define HAVE_MODF 1" >>confdefs.h
+
     $as_echo "#define HAVE_MODFF 1" >>confdefs.h
 
     $as_echo "#define HAVE_POWF 1" >>confdefs.h
 
+    $as_echo "#define HAVE_SINCOS 1" >>confdefs.h
+
+    $as_echo "#define HAVE_SINCOSF 1" >>confdefs.h
+
     $as_echo "#define HAVE_SINF 1" >>confdefs.h
 
     $as_echo "#define HAVE_SINHF 1" >>confdefs.h
--- origsrc/gcc-5.3.0/libstdc++-v3/configure.ac	2015-11-24 07:25:07.000000000 -0600
+++ src/gcc-5.3.0/libstdc++-v3/configure.ac	2016-03-22 23:43:14.621844900 -0500
@@ -294,10 +294,11 @@ else
   # on a hosted environment.
   if test "x${with_newlib}" = "xyes"; then
     os_include_dir="os/newlib"
-    AC_DEFINE(HAVE_HYPOT)
-
     # GLIBCXX_CHECK_STDLIB_SUPPORT
+    AC_DEFINE(HAVE_AT_QUICK_EXIT)
+    AC_DEFINE(HAVE_QUICK_EXIT)
     AC_DEFINE(HAVE_STRTOF)
+    AC_DEFINE(HAVE_STRTOLD)
 
     AC_DEFINE(HAVE_ACOSF)
     AC_DEFINE(HAVE_ASINF)
@@ -308,14 +309,25 @@ else
     AC_DEFINE(HAVE_COSHF)
     AC_DEFINE(HAVE_EXPF)
     AC_DEFINE(HAVE_FABSF)
+    AC_DEFINE(HAVE_FINITE)
+    AC_DEFINE(HAVE_FINITEF)
     AC_DEFINE(HAVE_FLOORF)
     AC_DEFINE(HAVE_FMODF)
     AC_DEFINE(HAVE_FREXPF)
+    AC_DEFINE(HAVE_HYPOT)
+    AC_DEFINE(HAVE_HYPOTF)
+    AC_DEFINE(HAVE_ISINF)
+    AC_DEFINE(HAVE_ISINFF)
+    AC_DEFINE(HAVE_ISNAN)
+    AC_DEFINE(HAVE_ISNANF)
     AC_DEFINE(HAVE_LDEXPF)
     AC_DEFINE(HAVE_LOG10F)
     AC_DEFINE(HAVE_LOGF)
+    AC_DEFINE(HAVE_MODF)
     AC_DEFINE(HAVE_MODFF)
     AC_DEFINE(HAVE_POWF)
+    AC_DEFINE(HAVE_SINCOS)
+    AC_DEFINE(HAVE_SINCOSF)
     AC_DEFINE(HAVE_SINF)
     AC_DEFINE(HAVE_SINHF)
     AC_DEFINE(HAVE_SQRTF)


More information about the Newlib mailing list