public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Enable libstdc++ numeric conversions on Cygwin
@ 2015-09-18 15:19 Jennifer Yao
       [not found] ` <CAPQfdhmMGJeb-tq29jTheoo5jUaeiFzcycWFTrpShRE-kPftGw@mail.gmail.com>
  0 siblings, 1 reply; 20+ messages in thread
From: Jennifer Yao @ 2015-09-18 15:19 UTC (permalink / raw)
  To: gcc-patches, libstdc

A number of functions in libstdc++ are guarded by the _GLIBCXX_USE_C99
preprocessor macro, which is only defined on systems that pass all of
the checks for a large set of C99 functions. Consequently, on systems
which lack any of the required C99 facilities (e.g. Cygwin, which
lacks some C99 complex math functions), the numeric conversion
functions (std::stoi(), std::stol(), std::to_string(), etc.) are not
defined—a rather silly outcome, as none of the numeric conversion
functions are implemented using C99 math functions.

This patch enables numeric conversion functions on the aforementioned
systems by splitting the checks for C99 support and defining several
new macros (_GLIBCXX_USE_C99_STDIO, _GLIBCXX_USE_C99_STDLIB, and
_GLIBCXX_USE_C99_WCHAR), which replace the use of _GLIBCXX_USE_C99 in
#if conditionals where appropriate.

Tested on x86_64-pc-cygwin.

Note: Several of the testcases that are newly enabled by the patch
fail on Cygwin due to defects in newlib (e.g. strtof() and wcstof() do
not set errno, strtold() and wcstold() do not handle trailing
non-numeric characters in input strings correctly, etc.). Also, at
least one testcase may fail due to PR 66530
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66530> (to circumvent,
install the build tree or add the directory containing the built DLL
and import library to PATH).

libstdc++-v3/ChangeLog:

2015-09-18  Jennifer Yao  <jenny.hyphen.fa@gmail.com>

    PR libstdc++/58393
    PR libstdc++/61580
    * acinclude.m4 (GLIBCXX_ENABLE_C99, GLIBCXX_CHECK_C99_TR1): Use -std=c++0x
    instead of -std=c++98 in CXXFLAGS. Cache the results of checking for complex
    math and wide character functions. Define preprocessor macros
    _GLIBCXX_USE_C99_STDIO, _GLIBCXX_USE_C99_STDLIB, and _GLIBCXX_USE_C99_WCHAR.
    Reformat to improve readability.
    * config.h.in: Regenerate.
    * config/locale/dragonfly/c_locale.h (std::__convert_from_v): Replace
    _GLIBCXX_USE_C99 with _GLIBCXX_USE_C99_STDIO.
    * config/locale/generic/c_locale.h (std::__convert_from_v): Replace
    _GLIBCXX_USE_C99 with _GLIBCXX_USE_C99_STDIO.
    * config/locale/gnu/c_locale.h (std::__convert_from_v): Replace
    _GLIBCXX_USE_C99 with _GLIBCXX_USE_C99_STDIO.
    * config/os/bsd/dragonfly/os_defines.h: Define _GLIBCXX_USE_C99_STDIO,
    _GLIBCXX_USE_C99_STDLIB, and _GLIBCXX_USE_C99_WCHAR.
    * configure: Regenerate.
    * include/bits/basic_string.h: Change and add preprocessor #if conditionals
    so that numeric conversion functions are defined when
    _GLIBCXX_USE_C99_STDIO, _GLIBCXX_USE_C99_STDLIB, or _GLIBCXX_USE_C99_WCHAR
    are defined, instead of _GLIBCXX_USE_C99.
    * include/bits/locale_facets.tcc (std::num_put::_M_insert_float): Replace
    _GLIBCXX_USE_C99 with _GLIBCXX_USE_C99_STDIO.
    * include/bits/locale_facets_nonio.tcc (std::money_put::do_put): Replace
    _GLIBCXX_USE_C99 with _GLIBCXX_USE_C99_STDIO.
    * include/c_compatibility/math.h: Replace _GLIBCXX_USE_C99 with
    _GLIBCXX_USE_C99_MATH.
    * include/c_compatibility/wchar.h: Replace _GLIBCXX_USE_C99 with
    _GLIBCXX_USE_C99_WCHAR.
    * include/c_global/cstdio: Replace _GLIBCXX_USE_C99 with
    _GLIBCXX_USE_C99_STDIO.
    * include/c_global/cstdlib: Replace _GLIBCXX_USE_C99 with
    _GLIBCXX_USE_C99_STDLIB.
    * include/c_global/cwchar: Replace _GLIBCXX_USE_C99 with
    _GLIBCXX_USE_C99_WCHAR.
    * include/c_std/cstdio: Replace _GLIBCXX_USE_C99 with
    _GLIBCXX_USE_C99_STDIO.
    * include/c_std/cstdlib: Replace _GLIBCXX_USE_C99 with
    _GLIBCXX_USE_C99_STDLIB.
    * include/c_std/cwchar: Replace _GLIBCXX_USE_C99 with
    _GLIBCXX_USE_C99_WCHAR.
    * include/ext/vstring.h: Change and add preprocessor #if conditionals
    so that numeric conversion functions are defined when
    _GLIBCXX_USE_C99_STDIO, _GLIBCXX_USE_C99_STDLIB, or _GLIBCXX_USE_C99_WCHAR
    are defined, instead of _GLIBCXX_USE_C99.
    * include/tr1/cstdio: Replace _GLIBCXX_USE_C99 with
    _GLIBCXX_USE_C99_STDIO.
    * include/tr1/cstdlib: Replace _GLIBCXX_USE_C99 with
    _GLIBCXX_USE_C99_STDLIB.
    * include/tr1/cwchar: Replace _GLIBCXX_USE_C99 with
    _GLIBCXX_USE_C99_WCHAR.
    * include/tr1/stdlib.h: Replace _GLIBCXX_USE_C99 with
    _GLIBCXX_USE_C99_STDLIB.
    * src/c++11/debug.cc (__gnu_debug::_Error_formatter::_M_format_word):
    Replace _GLIBCXX_USE_C99 with _GLIBCXX_USE_C99_STDIO.
    * src/c++98/locale_facets.cc (std::__num_base::_S_format_float): Replace
    _GLIBCXX_USE_C99 with _GLIBCXX_USE_C99_STDIO.
    * testsuite/18_support/exception_ptr/60612-terminate.cc: Replace
    _GLIBCXX_USE_C99 with _GLIBCXX_USE_C99_STDLIB.
    * testsuite/18_support/exception_ptr/60612-unexpected.cc: Replace
    _GLIBCXX_USE_C99 with _GLIBCXX_USE_C99_STDLIB.
    * testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stod.cc
    (test01): Replace _GLIBCXX_USE_C99 with _GLIBCXX_USE_C99_WCHAR.
    * testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stof.cc
    (test01): Replace _GLIBCXX_USE_C99 with _GLIBCXX_USE_C99_WCHAR.
    * testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoi.cc
    (test01): Replace _GLIBCXX_USE_C99 with _GLIBCXX_USE_C99_WCHAR.
    * testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stol.cc
    (test01): Replace _GLIBCXX_USE_C99 with _GLIBCXX_USE_C99_WCHAR.
    * testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stold.cc
    (test01): Replace _GLIBCXX_USE_C99 with _GLIBCXX_USE_C99_WCHAR.
    * testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoll.cc
    (test01): Replace _GLIBCXX_USE_C99 with _GLIBCXX_USE_C99_WCHAR.
    * testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoul.cc
    (test01): Replace _GLIBCXX_USE_C99 with _GLIBCXX_USE_C99_WCHAR.
    * testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoull.cc
    (test01): Replace _GLIBCXX_USE_C99 with _GLIBCXX_USE_C99_WCHAR.
    * testsuite/21_strings/basic_string/numeric_conversions/wchar_t/to_wstring.cc
    (test01): Replace _GLIBCXX_USE_C99 with _GLIBCXX_USE_C99_WCHAR.
    * testsuite/26_numerics/headers/cstdlib/13943.cc: Replace _GLIBCXX_USE_C99
    with _GLIBCXX_USE_C99_STDLIB.
    * testsuite/26_numerics/headers/cstdlib/types_std_c++0x.cc (test01): Replace
    _GLIBCXX_USE_C99 with _GLIBCXX_USE_C99_STDLIB.
    * testsuite/lib/libstdc++.exp (check_v3_target_string_conversions): Change
    preprocessor #if conditional so that it uses _GLIBCXX_USE_C99_STDIO,
    _GLIBCXX_USE_C99_STDLIB, and _GLIBCXX_USE_C99_WCHAR instead of
    _GLIBCXX_USE_C99.
    * testsuite/tr1/8_c_compatibility/cmath/templates.cc: Replace
    _GLIBCXX_USE_C99 with _GLIBCXX_USE_C99_MATH.
    * testsuite/tr1/8_c_compatibility/cstdio/functions.cc (test01): Replace
    _GLIBCXX_USE_C99 with _GLIBCXX_USE_C99_STDIO.
    * testsuite/tr1/8_c_compatibility/cstdlib/functions.cc (test01): Replace
    _GLIBCXX_USE_C99 with _GLIBCXX_USE_C99_STDLIB.
    * testsuite/tr1/8_c_compatibility/cstdlib/types_std_tr1.cc (test01): Replace
    _GLIBCXX_USE_C99 with _GLIBCXX_USE_C99_STDLIB.
    * testsuite/tr1/8_c_compatibility/cwchar/functions.cc (test01): Replace
    _GLIBCXX_USE_C99 with _GLIBCXX_USE_C99_WCHAR.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Fwd: [PATCH] Enable libstdc++ numeric conversions on Cygwin
       [not found] ` <CAPQfdhmMGJeb-tq29jTheoo5jUaeiFzcycWFTrpShRE-kPftGw@mail.gmail.com>
@ 2015-09-18 15:51   ` Jonathan Wakely
  2015-09-19 21:00     ` Jennifer Yao
       [not found]   ` <CAPQfdh=uOjLzi60Dnd0Dd1ycJUDqMWQBCv1aRAGBP97DSUS3+Q@mail.gmail.com>
  1 sibling, 1 reply; 20+ messages in thread
From: Jonathan Wakely @ 2015-09-18 15:51 UTC (permalink / raw)
  To: Jennifer Yao; +Cc: libstdc++, gcc-patches

On 18/09/15 11:17 -0400, Jennifer Yao wrote:
>A number of functions in libstdc++ are guarded by the _GLIBCXX_USE_C99
>preprocessor macro, which is only defined on systems that pass all of
>the checks for a large set of C99 functions. Consequently, on systems
>which lack any of the required C99 facilities (e.g. Cygwin, which
>lacks some C99 complex math functions), the numeric conversion
>functions (std::stoi(), std::stol(), std::to_string(), etc.) are not
>defined—a rather silly outcome, as none of the numeric conversion
>functions are implemented using C99 math functions.
>
>This patch enables numeric conversion functions on the aforementioned
>systems by splitting the checks for C99 support and defining several
>new macros (_GLIBCXX_USE_C99_STDIO, _GLIBCXX_USE_C99_STDLIB, and
>_GLIBCXX_USE_C99_WCHAR), which replace the use of _GLIBCXX_USE_C99 in
>#if conditionals where appropriate.

Awesome! This has been on my TODO list for ages, but I've not made
much progress. I *definitely* want to see this change happen, but
there are some legal prerequisites that need to be met before that can
happen, see
https://gcc.gnu.org/onlinedocs/libstdc++/manual/appendix_contributing.html#contrib.list

Do you already have a copyright assignment for GCC?

If not, would you be willing to complete one?

THanks for doing this work, it will help several other platforms, not
only Cygwin.


N.B. I don't see a patch attached to your mail, but that's not a
problem for now as I don't want to look at it until I know the status
of your copyright assignment (if we don't end up using your patch and
I do it myself then I don't want to plagiarise your work!)



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Fwd: [PATCH] Enable libstdc++ numeric conversions on Cygwin
  2015-09-18 15:51   ` Fwd: " Jonathan Wakely
@ 2015-09-19 21:00     ` Jennifer Yao
  2015-09-21 12:37       ` Jonathan Wakely
  0 siblings, 1 reply; 20+ messages in thread
From: Jennifer Yao @ 2015-09-19 21:00 UTC (permalink / raw)
  To: Jonathan Wakely; +Cc: libstdc++, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 2878 bytes --]

> Do you already have a copyright assignment for GCC?
>
> If not, would you be willing to complete one?

No, but I would be willing to complete one, yes. Are you willing to
send me the appropriate forms, or should I contact someone else?

> N.B. I don't see a patch attached to your mail, but that's not a
> problem for now as I don't want to look at it until I know the status
> of your copyright assignment (if we don't end up using your patch and
> I do it myself then I don't want to plagiarise your work!)

I included the patch in a reply to my original message to
libstdc++@gcc.gnu.org, but I'll attach it here as well.

By the way, the changes that I made are not really that extensive; I
even (unknowingly!) duplicated much of an earlier patch that was
submitted on Bugzilla
<https://gcc.gnu.org/bugzilla/attachment.cgi?id=33060>, although the
poster apparently never got around to testing it.

> THanks for doing this work, it will help several other platforms, not
> only Cygwin.

No problem. ^.^

On Fri, Sep 18, 2015 at 11:49 AM, Jonathan Wakely <jwakely@redhat.com> wrote:
> On 18/09/15 11:17 -0400, Jennifer Yao wrote:
>>
>> A number of functions in libstdc++ are guarded by the _GLIBCXX_USE_C99
>> preprocessor macro, which is only defined on systems that pass all of
>> the checks for a large set of C99 functions. Consequently, on systems
>> which lack any of the required C99 facilities (e.g. Cygwin, which
>> lacks some C99 complex math functions), the numeric conversion
>> functions (std::stoi(), std::stol(), std::to_string(), etc.) are not
>> defined—a rather silly outcome, as none of the numeric conversion
>> functions are implemented using C99 math functions.
>>
>> This patch enables numeric conversion functions on the aforementioned
>> systems by splitting the checks for C99 support and defining several
>> new macros (_GLIBCXX_USE_C99_STDIO, _GLIBCXX_USE_C99_STDLIB, and
>> _GLIBCXX_USE_C99_WCHAR), which replace the use of _GLIBCXX_USE_C99 in
>> #if conditionals where appropriate.
>
>
> Awesome! This has been on my TODO list for ages, but I've not made
> much progress. I *definitely* want to see this change happen, but
> there are some legal prerequisites that need to be met before that can
> happen, see
> https://gcc.gnu.org/onlinedocs/libstdc++/manual/appendix_contributing.html#contrib.list
>
> Do you already have a copyright assignment for GCC?
>
> If not, would you be willing to complete one?
>
> THanks for doing this work, it will help several other platforms, not
> only Cygwin.
>
>
> N.B. I don't see a patch attached to your mail, but that's not a
> problem for now as I don't want to look at it until I know the status
> of your copyright assignment (if we don't end up using your patch and
> I do it myself then I don't want to plagiarise your work!)
>
>
>

[-- Attachment #2: libstdc++-numeric-conversions.patch --]
[-- Type: application/octet-stream, Size: 42659 bytes --]

Index: libstdc++-v3/acinclude.m4
===================================================================
--- libstdc++-v3/acinclude.m4	(revision 227708)
+++ libstdc++-v3/acinclude.m4	(working copy)
@@ -915,236 +915,246 @@
   GLIBCXX_ENABLE(c99,$1,,[turns on ISO/IEC 9899:1999 support])
 
   if test x"$enable_c99" = x"yes"; then
+    AC_LANG_SAVE
+    AC_LANG_CPLUSPLUS
 
-  AC_LANG_SAVE
-  AC_LANG_CPLUSPLUS
+    # Use -std=c++0x (instead of -std=c++98) because C headers on some systems
+    # require it to enable C99 functions, and because the default
+    # (-std=gnu++98 / -std=gnu++0x) leaves __STRICT_ANSI__ undefined and fake
+    # C99 facilities - like pre-standard snprintf - may be spuriously enabled.
+    ac_save_CXXFLAGS="$CXXFLAGS"
+    CXXFLAGS="$CXXFLAGS -std=c++0x"
+    ac_save_LIBS="$LIBS"
+    ac_save_gcc_no_link="$gcc_no_link"
 
-  # Use -std=c++98 because the default (-std=gnu++98) leaves __STRICT_ANSI__
-  # undefined and fake C99 facilities - like pre-standard snprintf - may be
-  # spuriously enabled.
-  # Long term, -std=c++0x could be even better, could manage to explicitly
-  # request C99 facilities to the underlying C headers.
-  ac_save_CXXFLAGS="$CXXFLAGS"
-  CXXFLAGS="$CXXFLAGS -std=c++98"
-  ac_save_LIBS="$LIBS"
-  ac_save_gcc_no_link="$gcc_no_link"
+    if test x$gcc_no_link != xyes; then
+      # Use -fno-exceptions to that the C driver can link these tests without
+      # hitting undefined references to personality routines.
+      CXXFLAGS="$CXXFLAGS -fno-exceptions"
+      AC_CHECK_LIB(m, sin, [LIBS="$LIBS -lm"], [
+        # Use the default compile-only tests in GCC_TRY_COMPILE_OR_LINK
+        gcc_no_link=yes
+      ])
+    fi
 
-  if test x$gcc_no_link != xyes; then
-    # Use -fno-exceptions to that the C driver can link these tests without
-    # hitting undefined references to personality routines.
-    CXXFLAGS="$CXXFLAGS -fno-exceptions"
-    AC_CHECK_LIB(m, sin, [
-      LIBS="$LIBS -lm"
-    ], [
-      # Use the default compile-only tests in GCC_TRY_COMPILE_OR_LINK
-      gcc_no_link=yes
+    # Check for the existence of <math.h> functions used if C99 is enabled.
+    AC_MSG_CHECKING([for ISO C99 support in <math.h>])
+    AC_CACHE_VAL(glibcxx_cv_c99_math, [
+      GCC_TRY_COMPILE_OR_LINK(
+        [#include <math.h>
+         volatile double d1, d2;
+         volatile int i;],
+        [i = fpclassify(d1);
+         i = isfinite(d1);
+         i = isinf(d1);
+         i = isnan(d1);
+         i = isnormal(d1);
+         i = signbit(d1);
+         i = isgreater(d1, d2);
+         i = isgreaterequal(d1, d2);
+         i = isless(d1, d2);
+         i = islessequal(d1, d2);
+         i = islessgreater(d1, d2);
+         i = islessgreater(d1, d2);
+         i = isunordered(d1, d2);
+        ], [glibcxx_cv_c99_math=yes], [glibcxx_cv_c99_math=no])
     ])
-  fi
+    AC_MSG_RESULT($glibcxx_cv_c99_math)
+    if test x"$glibcxx_cv_c99_math" = x"yes"; then
+      AC_DEFINE(_GLIBCXX_USE_C99_MATH, 1,
+        [Define if C99 functions or macros in <math.h> should be imported
+        in <cmath> in namespace std.])
+    fi
 
-  # Check for the existence of <math.h> functions used if C99 is enabled.
-  AC_MSG_CHECKING([for ISO C99 support in <math.h>])
-  AC_CACHE_VAL(glibcxx_cv_c99_math, [
-  GCC_TRY_COMPILE_OR_LINK(
-     [#include <math.h>
-      volatile double d1, d2;
-      volatile int i;],
-     [i = fpclassify(d1);
-      i = isfinite(d1);
-      i = isinf(d1);
-      i = isnan(d1);
-      i = isnormal(d1);
-      i = signbit(d1);
-      i = isgreater(d1, d2);
-      i = isgreaterequal(d1, d2);
-      i = isless(d1, d2);
-      i = islessequal(d1, d2);
-      i = islessgreater(d1, d2);
-      i = islessgreater(d1, d2);
-      i = isunordered(d1, d2);
-     ],[glibcxx_cv_c99_math=yes], [glibcxx_cv_c99_math=no])
-  ])
-  AC_MSG_RESULT($glibcxx_cv_c99_math)
-  if test x"$glibcxx_cv_c99_math" = x"yes"; then
-    AC_DEFINE(_GLIBCXX_USE_C99_MATH, 1,
-	      [Define if C99 functions or macros in <math.h> should be imported
-	      in <cmath> in namespace std.])
-  fi
+    # Check for the existence of <complex.h> complex math functions.
+    # This is necessary even though libstdc++ uses the builtin versions
+    # of these functions, because if the builtin cannot be used, a reference
+    # to the library function is emitted.
+    AC_CHECK_HEADERS(tgmath.h, ac_has_tgmath_h=yes, ac_has_tgmath_h=no)
+    AC_CHECK_HEADERS(complex.h, ac_has_complex_h=yes, ac_has_complex_h=no)
+    if test x"$ac_has_complex_h" = x"yes"; then
+      AC_MSG_CHECKING([for ISO C99 support in <complex.h>])
+      AC_CACHE_VAL(glibcxx_cv_c99_complex, [
+        GCC_TRY_COMPILE_OR_LINK(
+          [#include <complex.h>
+           typedef __complex__ float float_type;
+           typedef __complex__ double double_type;
+           typedef __complex__ long double ld_type;
+           volatile float_type tmpf;
+           volatile double_type tmpd;
+           volatile ld_type tmpld;
+           volatile float f;
+           volatile double d;
+           volatile long double ld;],
+          [f = cabsf(tmpf);
+           f = cargf(tmpf);
+           tmpf = ccosf(tmpf);
+           tmpf = ccoshf(tmpf);
+           tmpf = cexpf(tmpf);
+           tmpf = clogf(tmpf);
+           tmpf = csinf(tmpf);
+           tmpf = csinhf(tmpf);
+           tmpf = csqrtf(tmpf);
+           tmpf = ctanf(tmpf);
+           tmpf = ctanhf(tmpf);
+           tmpf = cpowf(tmpf, tmpf);
+           tmpf = cprojf(tmpf);
+           d = cabs(tmpd);
+           d = carg(tmpd);
+           tmpd = ccos(tmpd);
+           tmpd = ccosh(tmpd);
+           tmpd = cexp(tmpd);
+           tmpd = clog(tmpd);
+           tmpd = csin(tmpd);
+           tmpd = csinh(tmpd);
+           tmpd = csqrt(tmpd);
+           tmpd = ctan(tmpd);
+           tmpd = ctanh(tmpd);
+           tmpd = cpow(tmpd, tmpd);
+           tmpd = cproj(tmpd);
+           ld = cabsl(tmpld);
+           ld = cargl(tmpld);
+           tmpld = ccosl(tmpld);
+           tmpld = ccoshl(tmpld);
+           tmpld = cexpl(tmpld);
+           tmpld = clogl(tmpld);
+           tmpld = csinl(tmpld);
+           tmpld = csinhl(tmpld);
+           tmpld = csqrtl(tmpld);
+           tmpld = ctanl(tmpld);
+           tmpld = ctanhl(tmpld);
+           tmpld = cpowl(tmpld, tmpld);
+           tmpld = cprojl(tmpld);
+          ], [glibcxx_cv_c99_complex=yes], [glibcxx_cv_c99_complex=no])
+      ])
+    fi
+    AC_MSG_RESULT($glibcxx_cv_c99_complex)
+    if test x"$glibcxx_cv_c99_complex" = x"yes"; then
+      AC_DEFINE(_GLIBCXX_USE_C99_COMPLEX, 1,
+        [Define if C99 functions in <complex.h> should be used in
+        <complex>. Using compiler builtins for these functions requires
+        corresponding C99 library functions to be present.])
+    fi
 
-  # Check for the existence of <complex.h> complex math functions.
-  # This is necessary even though libstdc++ uses the builtin versions
-  # of these functions, because if the builtin cannot be used, a reference
-  # to the library function is emitted.
-  AC_CHECK_HEADERS(tgmath.h, ac_has_tgmath_h=yes, ac_has_tgmath_h=no)
-  AC_CHECK_HEADERS(complex.h, ac_has_complex_h=yes, ac_has_complex_h=no)
-  glibcxx_cv_c99_complex=no;
-  if test x"$ac_has_complex_h" = x"yes"; then
-    AC_MSG_CHECKING([for ISO C99 support in <complex.h>])
-    GCC_TRY_COMPILE_OR_LINK(
-       [#include <complex.h>
-	typedef __complex__ float float_type;
-	typedef __complex__ double double_type;
-	typedef __complex__ long double ld_type;
-	volatile float_type tmpf;
-	volatile double_type tmpd;
-	volatile ld_type tmpld;
-	volatile float f;
-	volatile double d;
-	volatile long double ld;],
-       [f = cabsf(tmpf);
-	f = cargf(tmpf);
-	tmpf = ccosf(tmpf);
-	tmpf = ccoshf(tmpf);
-	tmpf = cexpf(tmpf);
-	tmpf = clogf(tmpf);
-	tmpf = csinf(tmpf);
-	tmpf = csinhf(tmpf);
-	tmpf = csqrtf(tmpf);
-	tmpf = ctanf(tmpf);
-	tmpf = ctanhf(tmpf);
-	tmpf = cpowf(tmpf, tmpf);
-	tmpf = cprojf(tmpf);
-	d = cabs(tmpd);
-	d = carg(tmpd);
-	tmpd = ccos(tmpd);
-	tmpd = ccosh(tmpd);
-	tmpd = cexp(tmpd);
-	tmpd = clog(tmpd);
-	tmpd = csin(tmpd);
-	tmpd = csinh(tmpd);
-	tmpd = csqrt(tmpd);
-	tmpd = ctan(tmpd);
-	tmpd = ctanh(tmpd);
-	tmpd = cpow(tmpd, tmpd);
-	tmpd = cproj(tmpd);
-	ld = cabsl(tmpld);
-	ld = cargl(tmpld);
-	tmpld = ccosl(tmpld);
-	tmpld = ccoshl(tmpld);
-	tmpld = cexpl(tmpld);
-	tmpld = clogl(tmpld);
-	tmpld = csinl(tmpld);
-	tmpld = csinhl(tmpld);
-	tmpld = csqrtl(tmpld);
-	tmpld = ctanl(tmpld);
-	tmpld = ctanhl(tmpld);
-	tmpld = cpowl(tmpld, tmpld);
-	tmpld = cprojl(tmpld);
-       ],[glibcxx_cv_c99_complex=yes], [glibcxx_cv_c99_complex=no])
-  fi
-  AC_MSG_RESULT($glibcxx_cv_c99_complex)
-  if test x"$glibcxx_cv_c99_complex" = x"yes"; then
-    AC_DEFINE(_GLIBCXX_USE_C99_COMPLEX, 1,
-	      [Define if C99 functions in <complex.h> should be used in
-	      <complex>. Using compiler builtins for these functions requires
-	      corresponding C99 library functions to be present.])
-  fi
+    # Check for the existence in <stdio.h> of vscanf, et. al.
+    AC_MSG_CHECKING([for ISO C99 support in <stdio.h>])
+    AC_CACHE_VAL(glibcxx_cv_c99_stdio, [
+      GCC_TRY_COMPILE_OR_LINK(
+        [#include <stdio.h>
+         #include <stdarg.h>
+         void foo(char* fmt, ...)
+         {
+           va_list args; va_start(args, fmt);
+           vfscanf(stderr, "%i", args);
+           vscanf("%i", args);
+           vsnprintf(fmt, 0, "%i", args);
+           vsscanf(fmt, "%i", args);
+           snprintf(fmt, 0, "%i");
+         }], [],
+        [glibcxx_cv_c99_stdio=yes], [glibcxx_cv_c99_stdio=no])
+    ])
+    AC_MSG_RESULT($glibcxx_cv_c99_stdio)
+    if test x"$glibcxx_cv_c99_stdio" = x"yes"; then
+      AC_DEFINE(_GLIBCXX_USE_C99_STDIO, 1,
+        [Define if C99 functions or macros in <stdio.h> should be imported
+        in <cstdio> in namespace std.])
+    fi
 
-  # Check for the existence in <stdio.h> of vscanf, et. al.
-  AC_MSG_CHECKING([for ISO C99 support in <stdio.h>])
-  AC_CACHE_VAL(glibcxx_cv_c99_stdio, [
-  GCC_TRY_COMPILE_OR_LINK(
-     [#include <stdio.h>
-      #include <stdarg.h>
-      void foo(char* fmt, ...)
-      {
-	va_list args; va_start(args, fmt);
-	vfscanf(stderr, "%i", args);
-	vscanf("%i", args);
-	vsnprintf(fmt, 0, "%i", args);
-	vsscanf(fmt, "%i", args);
-	snprintf(fmt, 0, "%i");
-      }], [],
-     [glibcxx_cv_c99_stdio=yes], [glibcxx_cv_c99_stdio=no])
-  ])
-  AC_MSG_RESULT($glibcxx_cv_c99_stdio)
+    # Check for the existence in <stdlib.h> of lldiv_t, et. al.
+    AC_MSG_CHECKING([for ISO C99 support in <stdlib.h>])
+    AC_CACHE_VAL(glibcxx_cv_c99_stdlib, [
+      GCC_TRY_COMPILE_OR_LINK(
+        [#include <stdlib.h>
+         volatile float f;
+         volatile long double ld;
+         volatile unsigned long long ll;
+         lldiv_t mydivt;],
+        [char* tmp;
+         f = strtof("gnu", &tmp);
+         ld = strtold("gnu", &tmp);
+         ll = strtoll("gnu", &tmp, 10);
+         ll = strtoull("gnu", &tmp, 10);
+         ll = llabs(10);
+         mydivt = lldiv(10,1);
+         ll = mydivt.quot;
+         ll = mydivt.rem;
+         ll = atoll("10");
+         _Exit(0);
+        ], [glibcxx_cv_c99_stdlib=yes], [glibcxx_cv_c99_stdlib=no])
+    ])
+    AC_MSG_RESULT($glibcxx_cv_c99_stdlib)
+    if test x"$glibcxx_cv_c99_stdlib" = x"yes"; then
+      AC_DEFINE(_GLIBCXX_USE_C99_STDLIB, 1,
+        [Define if C99 functions or macros in <stdlib.h> should be imported
+        in <cstdlib> in namespace std.])
+    fi
 
-  # Check for the existence in <stdlib.h> of lldiv_t, et. al.
-  AC_MSG_CHECKING([for ISO C99 support in <stdlib.h>])
-  AC_CACHE_VAL(glibcxx_cv_c99_stdlib, [
-  GCC_TRY_COMPILE_OR_LINK(
-     [#include <stdlib.h>
-      volatile float f;
-      volatile long double ld;
-      volatile unsigned long long ll;
-      lldiv_t mydivt;],
-     [char* tmp;
-      f = strtof("gnu", &tmp);
-      ld = strtold("gnu", &tmp);
-      ll = strtoll("gnu", &tmp, 10);
-      ll = strtoull("gnu", &tmp, 10);
-      ll = llabs(10);
-      mydivt = lldiv(10,1);
-      ll = mydivt.quot;
-      ll = mydivt.rem;
-      ll = atoll("10");
-      _Exit(0);
-      ],[glibcxx_cv_c99_stdlib=yes], [glibcxx_cv_c99_stdlib=no])
-  ])
-  AC_MSG_RESULT($glibcxx_cv_c99_stdlib)
+    # Check for the existence in <wchar.h> of wcstold, etc.
+    if test x"$ac_has_wchar_h" = xyes &&
+       test x"$ac_has_wctype_h" = xyes; then
+      AC_MSG_CHECKING([for ISO C99 support in <wchar.h>])
+      AC_CACHE_VAL(glibcxx_cv_c99_wchar, [
+        AC_TRY_COMPILE([#include <wchar.h>
+          namespace test
+          {
+            using ::wcstold;
+            using ::wcstoll;
+            using ::wcstoull;
+          }
+        ], [], [glibcxx_cv_c99_wchar=yes], [glibcxx_cv_c99_wchar=no])
+      ])
 
-  # Check for the existence in <wchar.h> of wcstold, etc.
-  glibcxx_cv_c99_wchar=no;
-  if test x"$ac_has_wchar_h" = xyes &&
-     test x"$ac_has_wctype_h" = xyes; then
-    AC_MSG_CHECKING([for ISO C99 support in <wchar.h>])
-    AC_TRY_COMPILE([#include <wchar.h>
-		    namespace test
-		    {
-		      using ::wcstold;
-		      using ::wcstoll;
-		      using ::wcstoull;
-		    }
-		   ],[],[glibcxx_cv_c99_wchar=yes], [glibcxx_cv_c99_wchar=no])
+      # Checks for wide character functions that may not be present.
+      # Injection of these is wrapped with guard macros.
+      # NB: only put functions here, instead of immediately above, if
+      # absolutely necessary.
+      AC_TRY_COMPILE([#include <wchar.h>
+        namespace test { using ::vfwscanf; }], [],
+        [AC_DEFINE(HAVE_VFWSCANF, 1, [Defined if vfwscanf exists.])], [])
 
-    # Checks for wide character functions that may not be present.
-    # Injection of these is wrapped with guard macros.
-    # NB: only put functions here, instead of immediately above, if
-    # absolutely necessary.
-    AC_TRY_COMPILE([#include <wchar.h>
-		    namespace test { using ::vfwscanf; } ], [],
- 	    	   [AC_DEFINE(HAVE_VFWSCANF,1,
-			[Defined if vfwscanf exists.])],[])
+      AC_TRY_COMPILE([#include <wchar.h>
+        namespace test { using ::vswscanf; }], [],
+        [AC_DEFINE(HAVE_VSWSCANF, 1, [Defined if vswscanf exists.])], [])
 
-    AC_TRY_COMPILE([#include <wchar.h>
-		    namespace test { using ::vswscanf; } ], [],
- 	    	   [AC_DEFINE(HAVE_VSWSCANF,1,
-			[Defined if vswscanf exists.])],[])
+      AC_TRY_COMPILE([#include <wchar.h>
+        namespace test { using ::vwscanf; }], [],
+        [AC_DEFINE(HAVE_VWSCANF, 1, [Defined if vwscanf exists.])], [])
 
-    AC_TRY_COMPILE([#include <wchar.h>
-		    namespace test { using ::vwscanf; } ], [],
- 	    	   [AC_DEFINE(HAVE_VWSCANF,1,[Defined if vwscanf exists.])],[])
+      AC_TRY_COMPILE([#include <wchar.h>
+        namespace test { using ::wcstof; }], [],
+        [AC_DEFINE(HAVE_WCSTOF, 1, [Defined if wcstof exists.])], [])
 
-    AC_TRY_COMPILE([#include <wchar.h>
-		    namespace test { using ::wcstof; } ], [],
- 	    	   [AC_DEFINE(HAVE_WCSTOF,1,[Defined if wcstof exists.])],[])
+      AC_TRY_COMPILE([#include <wctype.h>],
+        [wint_t t; int i = iswblank(t);],
+        [AC_DEFINE(HAVE_ISWBLANK, 1, [Defined if iswblank exists.])], [])
 
-    AC_TRY_COMPILE([#include <wctype.h>],
-		   [ wint_t t; int i = iswblank(t);],
- 	    	   [AC_DEFINE(HAVE_ISWBLANK,1,
-			[Defined if iswblank exists.])],[])
+      AC_MSG_RESULT($glibcxx_cv_c99_wchar)
+      if test x"$glibcxx_cv_c99_wchar" = x"yes"; then
+        AC_DEFINE(_GLIBCXX_USE_C99_WCHAR, 1,
+          [Define if C99 functions or macros in <wchar.h> should be imported
+          in <cwchar> in namespace std.])
+      fi
+    fi
 
-    AC_MSG_RESULT($glibcxx_cv_c99_wchar)
-  fi
+    # 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
+      enable_c99=no;
+    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.])
+    fi
 
-  # 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
-    enable_c99=no;
-  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.])
+    gcc_no_link="$ac_save_gcc_no_link"
+    LIBS="$ac_save_LIBS"
+    CXXFLAGS="$ac_save_CXXFLAGS"
+    AC_LANG_RESTORE
   fi
 
-  gcc_no_link="$ac_save_gcc_no_link"
-  LIBS="$ac_save_LIBS"
-  CXXFLAGS="$ac_save_CXXFLAGS"
-  AC_LANG_RESTORE
-  fi
-
   AC_MSG_CHECKING([for fully enabled ISO C99 support])
   AC_MSG_RESULT($enable_c99)
 ])
@@ -1441,14 +1447,15 @@
 dnl facilities in Chapter 8, "C compatibility".
 dnl
 AC_DEFUN([GLIBCXX_CHECK_C99_TR1], [
-
   AC_LANG_SAVE
   AC_LANG_CPLUSPLUS
 
-  # Use -std=c++98 because the default (-std=gnu++98) leaves __STRICT_ANSI__
-  # undefined and fake C99 facilities may be spuriously enabled.
+  # Use -std=c++0x (instead of -std=c++98) because C headers on some systems
+  # require it to enable C99 functions, and because the default
+  # (-std=gnu++98 / -std=gnu++0x) leaves __STRICT_ANSI__ undefined and fake
+  # C99 facilities - like pre-standard snprintf - may be spuriously enabled.
   ac_save_CXXFLAGS="$CXXFLAGS"
-  CXXFLAGS="$CXXFLAGS -std=c++98"
+  CXXFLAGS="$CXXFLAGS -std=c++0x"
 
   # Check for the existence of <complex.h> complex math functions used
   # by tr1/complex.
Index: libstdc++-v3/config/locale/dragonfly/c_locale.h
===================================================================
--- libstdc++-v3/config/locale/dragonfly/c_locale.h	(revision 227708)
+++ libstdc++-v3/config/locale/dragonfly/c_locale.h	(working copy)
@@ -64,7 +64,7 @@
     __builtin_va_list __args;
     __builtin_va_start(__args, __fmt);
 
-#ifdef _GLIBCXX_USE_C99
+#ifdef _GLIBCXX_USE_C99_STDIO
     const int __ret = __builtin_vsnprintf(__out, __size, __fmt, __args);
 #else
     const int __ret = __builtin_vsprintf(__out, __fmt, __args);
Index: libstdc++-v3/config/locale/generic/c_locale.h
===================================================================
--- libstdc++-v3/config/locale/generic/c_locale.h	(revision 227708)
+++ libstdc++-v3/config/locale/generic/c_locale.h	(working copy)
@@ -70,7 +70,7 @@
     __builtin_va_list __args;
     __builtin_va_start(__args, __fmt);
 
-#ifdef _GLIBCXX_USE_C99
+#ifdef _GLIBCXX_USE_C99_STDIO
     const int __ret = __builtin_vsnprintf(__out, __size, __fmt, __args);
 #else
     const int __ret = __builtin_vsprintf(__out, __fmt, __args);
Index: libstdc++-v3/config/locale/gnu/c_locale.h
===================================================================
--- libstdc++-v3/config/locale/gnu/c_locale.h	(revision 227708)
+++ libstdc++-v3/config/locale/gnu/c_locale.h	(working copy)
@@ -88,7 +88,7 @@
     __builtin_va_list __args;
     __builtin_va_start(__args, __fmt);
 
-#ifdef _GLIBCXX_USE_C99
+#ifdef _GLIBCXX_USE_C99_STDIO
     const int __ret = __builtin_vsnprintf(__out, __size, __fmt, __args);
 #else
     const int __ret = __builtin_vsprintf(__out, __fmt, __args);
Index: libstdc++-v3/config/os/bsd/dragonfly/os_defines.h
===================================================================
--- libstdc++-v3/config/os/bsd/dragonfly/os_defines.h	(revision 227708)
+++ libstdc++-v3/config/os/bsd/dragonfly/os_defines.h	(working copy)
@@ -30,6 +30,9 @@
 // file will come before all others.
 
 #define _GLIBCXX_USE_C99 1
+#define _GLIBCXX_USE_C99_STDIO 1
+#define _GLIBCXX_USE_C99_STDLIB 1
+#define _GLIBCXX_USE_C99_WCHAR 1
 #define _GLIBCXX_USE_C99_CHECK 1
 #define _GLIBCXX_USE_C99_DYNAMIC (!(__ISO_C_VISIBLE >= 1999))
 #define _GLIBCXX_USE_C99_LONG_LONG_CHECK 1
Index: libstdc++-v3/include/bits/basic_string.h
===================================================================
--- libstdc++-v3/include/bits/basic_string.h	(revision 227708)
+++ libstdc++-v3/include/bits/basic_string.h	(working copy)
@@ -5383,7 +5383,7 @@
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
 
-#if __cplusplus >= 201103L && defined(_GLIBCXX_USE_C99)
+#if __cplusplus >= 201103L
 
 #include <ext/string_conversions.h>
 
@@ -5392,6 +5392,7 @@
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
 _GLIBCXX_BEGIN_NAMESPACE_CXX11
 
+#ifdef _GLIBCXX_USE_C99_STDLIB
   // 21.4 Numeric Conversions [string.conversions].
   inline int
   stoi(const string& __str, size_t* __idx = 0, int __base = 10)
@@ -5430,7 +5431,9 @@
   inline long double
   stold(const string& __str, size_t* __idx = 0)
   { return __gnu_cxx::__stoa(&std::strtold, "stold", __str.c_str(), __idx); }
+#endif // _GLIBCXX_USE_C99_STDLIB
 
+#ifdef _GLIBCXX_USE_C99_STDIO
   // NB: (v)snprintf vs sprintf.
 
   // DR 1261.
@@ -5494,8 +5497,9 @@
     return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
 					   "%Lf", __val);
   }
+#endif // _GLIBCXX_USE_C99_STDIO
 
-#ifdef _GLIBCXX_USE_WCHAR_T
+#if defined(_GLIBCXX_USE_WCHAR_T) && defined(_GLIBCXX_USE_C99_WCHAR)
   inline int 
   stoi(const wstring& __str, size_t* __idx = 0, int __base = 10)
   { return __gnu_cxx::__stoa<long, int>(&std::wcstol, "stoi", __str.c_str(),
@@ -5597,13 +5601,13 @@
 					    L"%Lf", __val);
   }
 #endif // _GLIBCXX_HAVE_BROKEN_VSWPRINTF
-#endif
+#endif // _GLIBCXX_USE_WCHAR_T && _GLIBCXX_USE_C99_WCHAR
 
 _GLIBCXX_END_NAMESPACE_CXX11
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
 
-#endif /* C++11 && _GLIBCXX_USE_C99 ... */
+#endif /* C++11 */
 
 #if __cplusplus >= 201103L
 
Index: libstdc++-v3/include/bits/locale_facets.tcc
===================================================================
--- libstdc++-v3/include/bits/locale_facets.tcc	(revision 227708)
+++ libstdc++-v3/include/bits/locale_facets.tcc	(working copy)
@@ -959,13 +959,13 @@
     }
 
   // The following code uses vsnprintf (or vsprintf(), when
-  // _GLIBCXX_USE_C99 is not defined) to convert floating point values
-  // for insertion into a stream.  An optimization would be to replace
-  // them with code that works directly on a wide buffer and then use
-  // __pad to do the padding.  It would be good to replace them anyway
-  // to gain back the efficiency that C++ provides by knowing up front
-  // the type of the values to insert.  Also, sprintf is dangerous
-  // since may lead to accidental buffer overruns.  This
+  // _GLIBCXX_USE_C99_STDIO is not defined) to convert floating point
+  // values for insertion into a stream.  An optimization would be to
+  // replace them with code that works directly on a wide buffer and
+  // then use __pad to do the padding.  It would be good to replace
+  // them anyway to gain back the efficiency that C++ provides by
+  // knowing up front the type of the values to insert.  Also, sprintf
+  // is dangerous since may lead to accidental buffer overruns.  This
   // implementation follows the C++ standard fairly directly as
   // outlined in 22.2.2.2 [lib.locale.num.put]
   template<typename _CharT, typename _OutIter>
@@ -992,7 +992,7 @@
 	char __fbuf[16];
 	__num_base::_S_format_float(__io, __fbuf, __mod);
 
-#ifdef _GLIBCXX_USE_C99
+#ifdef _GLIBCXX_USE_C99_STDIO
 	// Precision is always used except for hexfloat format.
 	const bool __use_prec =
 	  (__io.flags() & ios_base::floatfield) != ios_base::floatfield;
Index: libstdc++-v3/include/bits/locale_facets_nonio.tcc
===================================================================
--- libstdc++-v3/include/bits/locale_facets_nonio.tcc	(revision 227708)
+++ libstdc++-v3/include/bits/locale_facets_nonio.tcc	(working copy)
@@ -578,7 +578,7 @@
     {
       const locale __loc = __io.getloc();
       const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
-#ifdef _GLIBCXX_USE_C99
+#ifdef _GLIBCXX_USE_C99_STDIO
       // First try a buffer perhaps big enough.
       int __cs_size = 64;
       char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
Index: libstdc++-v3/include/c_compatibility/math.h
===================================================================
--- libstdc++-v3/include/c_compatibility/math.h	(revision 227708)
+++ libstdc++-v3/include/c_compatibility/math.h	(working copy)
@@ -56,7 +56,7 @@
 using std::floor;
 using std::fmod;
 
-#if _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_MATH
 using std::fpclassify;
 using std::isfinite;
 using std::isinf;
Index: libstdc++-v3/include/c_compatibility/wchar.h
===================================================================
--- libstdc++-v3/include/c_compatibility/wchar.h	(revision 227708)
+++ libstdc++-v3/include/c_compatibility/wchar.h	(working copy)
@@ -103,7 +103,7 @@
 using std::wmemset;
 using std::wcsftime;
 
-#if _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_WCHAR
 using std::wcstold;
 using std::wcstoll;
 using std::wcstoull;
Index: libstdc++-v3/include/c_global/cstdio
===================================================================
--- libstdc++-v3/include/c_global/cstdio	(revision 227708)
+++ libstdc++-v3/include/c_global/cstdio	(working copy)
@@ -146,7 +146,7 @@
   using ::vsprintf;
 } // namespace
 
-#if _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_STDIO
 
 #undef snprintf
 #undef vfscanf
@@ -189,6 +189,6 @@
   using ::__gnu_cxx::vsscanf;
 } // namespace std
 
-#endif // _GLIBCXX_USE_C99
+#endif // _GLIBCXX_USE_C99_STDIO
 
 #endif
Index: libstdc++-v3/include/c_global/cstdlib
===================================================================
--- libstdc++-v3/include/c_global/cstdlib	(revision 227708)
+++ libstdc++-v3/include/c_global/cstdlib	(working copy)
@@ -195,7 +195,7 @@
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
 
-#if _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_STDLIB
 
 #undef _Exit
 #undef llabs
@@ -266,7 +266,7 @@
   using ::__gnu_cxx::strtold;
 } // namespace std
 
-#endif // _GLIBCXX_USE_C99
+#endif // _GLIBCXX_USE_C99_STDLIB
 
 #endif // !_GLIBCXX_HOSTED
 
Index: libstdc++-v3/include/c_global/cwchar
===================================================================
--- libstdc++-v3/include/c_global/cwchar	(revision 227708)
+++ libstdc++-v3/include/c_global/cwchar	(working copy)
@@ -232,7 +232,7 @@
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
 
-#if _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_WCHAR
 
 #undef wcstold
 #undef wcstoll
@@ -289,7 +289,7 @@
   using std::vwscanf;
 #endif
 
-#if _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_WCHAR
   using std::wcstold;
   using std::wcstoll;
   using std::wcstoull;
Index: libstdc++-v3/include/c_std/cstdio
===================================================================
--- libstdc++-v3/include/c_std/cstdio	(revision 227708)
+++ libstdc++-v3/include/c_std/cstdio	(working copy)
@@ -144,7 +144,7 @@
   using ::vsprintf;
 } // namespace std
 
-#if _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_STDIO
 
 #undef snprintf
 #undef vfscanf
Index: libstdc++-v3/include/c_std/cstdlib
===================================================================
--- libstdc++-v3/include/c_std/cstdlib	(revision 227708)
+++ libstdc++-v3/include/c_std/cstdlib	(working copy)
@@ -192,7 +192,7 @@
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
 
-#if _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_STDLIB
 
 #undef _Exit
 #undef llabs
@@ -263,7 +263,7 @@
   using ::__gnu_cxx::strtold;
 } // namespace std
 
-#endif // _GLIBCXX_USE_C99
+#endif // _GLIBCXX_USE_C99_STDLIB
 
 #endif // !_GLIBCXX_HOSTED
 
Index: libstdc++-v3/include/c_std/cwchar
===================================================================
--- libstdc++-v3/include/c_std/cwchar	(revision 227708)
+++ libstdc++-v3/include/c_std/cwchar	(working copy)
@@ -228,7 +228,7 @@
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
 
-#if _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_WCHAR
 
 #undef wcstold
 #undef wcstoll
Index: libstdc++-v3/include/ext/vstring.h
===================================================================
--- libstdc++-v3/include/ext/vstring.h	(revision 227708)
+++ libstdc++-v3/include/ext/vstring.h	(working copy)
@@ -2680,7 +2680,7 @@
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
 
-#if ((__cplusplus >= 201103L) && defined(_GLIBCXX_USE_C99))
+#if __cplusplus >= 201103L
 
 #include <ext/string_conversions.h>
 
@@ -2688,6 +2688,7 @@
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
+#ifdef _GLIBCXX_USE_C99_STDLIB
   // 21.4 Numeric Conversions [string.conversions].
   inline int
   stoi(const __vstring& __str, std::size_t* __idx = 0, int __base = 10)
@@ -2726,7 +2727,9 @@
   inline long double
   stold(const __vstring& __str, std::size_t* __idx = 0)
   { return __gnu_cxx::__stoa(&std::strtold, "stold", __str.c_str(), __idx); }
+#endif // _GLIBCXX_USE_C99_STDLIB
 
+#ifdef _GLIBCXX_USE_C99_STDIO
   // NB: (v)snprintf vs sprintf.
 
   // DR 1261.
@@ -2789,8 +2792,9 @@
     return __gnu_cxx::__to_xstring<__vstring>(&std::vsnprintf, __n,
 					      "%Lf", __val);
   }
+#endif // _GLIBCXX_USE_C99_STDIO
 
-#ifdef _GLIBCXX_USE_WCHAR_T
+#if defined(_GLIBCXX_USE_WCHAR_T) && defined(_GLIBCXX_USE_C99_WCHAR)
   inline int 
   stoi(const __wvstring& __str, std::size_t* __idx = 0, int __base = 10)
   { return __gnu_cxx::__stoa<long, int>(&std::wcstol, "stoi", __str.c_str(),
@@ -2890,8 +2894,8 @@
     return __gnu_cxx::__to_xstring<__wvstring>(&std::vswprintf, __n,
 					       L"%Lf", __val);
   }
-#endif
-#endif
+#endif // _GLIBCXX_HAVE_BROKEN_VSWPRINTF
+#endif // _GLIBCXX_USE_WCHAR_T && _GLIBCXX_USE_C99_WCHAR
 
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
Index: libstdc++-v3/include/tr1/cstdio
===================================================================
--- libstdc++-v3/include/tr1/cstdio	(revision 227708)
+++ libstdc++-v3/include/tr1/cstdio	(working copy)
@@ -33,7 +33,7 @@
 
 #include <cstdio>
 
-#if _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_STDIO
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
Index: libstdc++-v3/include/tr1/cstdlib
===================================================================
--- libstdc++-v3/include/tr1/cstdlib	(revision 227708)
+++ libstdc++-v3/include/tr1/cstdlib	(working copy)
@@ -35,7 +35,7 @@
 
 #if _GLIBCXX_HOSTED
 
-#if _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_STDLIB
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
@@ -65,7 +65,7 @@
 }
 }
 
-#endif // _GLIBCXX_USE_C99 
+#endif // _GLIBCXX_USE_C99_STDLIB
 
 #endif // _GLIBCXX_HOSTED
 
Index: libstdc++-v3/include/tr1/cwchar
===================================================================
--- libstdc++-v3/include/tr1/cwchar	(revision 227708)
+++ libstdc++-v3/include/tr1/cwchar	(working copy)
@@ -52,7 +52,7 @@
   using std::vwscanf;
 #endif
 
-#if _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_WCHAR
   using std::wcstold;
   using std::wcstoll;
   using std::wcstoull;
Index: libstdc++-v3/include/tr1/stdlib.h
===================================================================
--- libstdc++-v3/include/tr1/stdlib.h	(revision 227708)
+++ libstdc++-v3/include/tr1/stdlib.h	(working copy)
@@ -33,7 +33,7 @@
 
 #if _GLIBCXX_HOSTED
 
-#if _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_STDLIB
 
 using std::tr1::atoll;
 using std::tr1::strtoll;
Index: libstdc++-v3/src/c++11/debug.cc
===================================================================
--- libstdc++-v3/src/c++11/debug.cc	(revision 227708)
+++ libstdc++-v3/src/c++11/debug.cc	(working copy)
@@ -871,7 +871,7 @@
 				     int __n __attribute__ ((__unused__)),
 				     const char* __fmt, _Tp __s) const throw ()
     {
-#ifdef _GLIBCXX_USE_C99
+#ifdef _GLIBCXX_USE_C99_STDIO
       std::snprintf(__buf, __n, __fmt, __s);
 #else
       std::sprintf(__buf, __fmt, __s);
Index: libstdc++-v3/src/c++98/locale_facets.cc
===================================================================
--- libstdc++-v3/src/c++98/locale_facets.cc	(revision 227708)
+++ libstdc++-v3/src/c++98/locale_facets.cc	(working copy)
@@ -72,7 +72,7 @@
 
     ios_base::fmtflags __fltfield = __flags & ios_base::floatfield;
 
-#ifdef _GLIBCXX_USE_C99
+#ifdef _GLIBCXX_USE_C99_STDIO
     // Precision is always used except for hexfloat format.
     if (__fltfield != (ios_base::fixed | ios_base::scientific))
 #endif
@@ -89,7 +89,7 @@
       *__fptr++ = 'f';
     else if (__fltfield == ios_base::scientific)
       *__fptr++ = (__flags & ios_base::uppercase) ? 'E' : 'e';
-#ifdef _GLIBCXX_USE_C99
+#ifdef _GLIBCXX_USE_C99_STDIO
     else if (__fltfield == (ios_base::fixed | ios_base::scientific))
       *__fptr++ = (__flags & ios_base::uppercase) ? 'A' : 'a';
 #endif
Index: libstdc++-v3/testsuite/18_support/exception_ptr/60612-terminate.cc
===================================================================
--- libstdc++-v3/testsuite/18_support/exception_ptr/60612-terminate.cc	(revision 227708)
+++ libstdc++-v3/testsuite/18_support/exception_ptr/60612-terminate.cc	(working copy)
@@ -23,7 +23,7 @@
 #include <exception>
 #include <stdlib.h>
 
-#ifdef _GLIBCXX_USE_C99
+#ifdef _GLIBCXX_USE_C99_STDLIB
 void terminate() { _Exit(0); }
 
 void f() noexcept
@@ -39,7 +39,7 @@
 
 int main()
 {
-#ifdef _GLIBCXX_USE_C99
+#ifdef _GLIBCXX_USE_C99_STDLIB
   f();
 #endif
   return 0;
Index: libstdc++-v3/testsuite/18_support/exception_ptr/60612-unexpected.cc
===================================================================
--- libstdc++-v3/testsuite/18_support/exception_ptr/60612-unexpected.cc	(revision 227708)
+++ libstdc++-v3/testsuite/18_support/exception_ptr/60612-unexpected.cc	(working copy)
@@ -23,7 +23,7 @@
 #include <exception>
 #include <stdlib.h>
 
-#ifdef _GLIBCXX_USE_C99
+#ifdef _GLIBCXX_USE_C99_STDLIB
 void unexpected() { _Exit(0); }
 
 void f() throw()
@@ -39,7 +39,7 @@
 
 int main()
 {
-#ifdef _GLIBCXX_USE_C99
+#ifdef _GLIBCXX_USE_C99_STDLIB
   f();
 #endif
 }
Index: libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stod.cc
===================================================================
--- libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stod.cc	(revision 227708)
+++ libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stod.cc	(working copy)
@@ -29,7 +29,7 @@
 void
 test01()
 {
-#ifdef _GLIBCXX_USE_C99
+#ifdef _GLIBCXX_USE_C99_WCHAR
 
   bool test __attribute__((unused)) = false;
   using namespace std;
Index: libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stof.cc
===================================================================
--- libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stof.cc	(revision 227708)
+++ libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stof.cc	(working copy)
@@ -29,7 +29,7 @@
 void
 test01()
 {
-#ifdef _GLIBCXX_USE_C99
+#ifdef _GLIBCXX_USE_C99_WCHAR
 
   bool test __attribute__((unused)) = false;
   using namespace std;
Index: libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoi.cc
===================================================================
--- libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoi.cc	(revision 227708)
+++ libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoi.cc	(working copy)
@@ -29,7 +29,7 @@
 void
 test01()
 {
-#ifdef _GLIBCXX_USE_C99
+#ifdef _GLIBCXX_USE_C99_WCHAR
 
   bool test __attribute__((unused)) = false;
   using namespace std;
Index: libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stol.cc
===================================================================
--- libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stol.cc	(revision 227708)
+++ libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stol.cc	(working copy)
@@ -29,7 +29,7 @@
 void
 test01()
 {
-#ifdef _GLIBCXX_USE_C99
+#ifdef _GLIBCXX_USE_C99_WCHAR
 
   bool test __attribute__((unused)) = false;
   using namespace std;
Index: libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stold.cc
===================================================================
--- libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stold.cc	(revision 227708)
+++ libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stold.cc	(working copy)
@@ -29,7 +29,7 @@
 void
 test01()
 {
-#ifdef _GLIBCXX_USE_C99
+#ifdef _GLIBCXX_USE_C99_WCHAR
 
   bool test __attribute__((unused)) = false;
   using namespace std;
Index: libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoll.cc
===================================================================
--- libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoll.cc	(revision 227708)
+++ libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoll.cc	(working copy)
@@ -29,7 +29,7 @@
 void
 test01()
 {
-#ifdef _GLIBCXX_USE_C99
+#ifdef _GLIBCXX_USE_C99_WCHAR
 
   bool test __attribute__((unused)) = false;
   using namespace std;
Index: libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoul.cc
===================================================================
--- libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoul.cc	(revision 227708)
+++ libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoul.cc	(working copy)
@@ -29,7 +29,7 @@
 void
 test01()
 {
-#ifdef _GLIBCXX_USE_C99
+#ifdef _GLIBCXX_USE_C99_WCHAR
 
   bool test __attribute__((unused)) = false;
   using namespace std;
Index: libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoull.cc
===================================================================
--- libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoull.cc	(revision 227708)
+++ libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoull.cc	(working copy)
@@ -29,7 +29,7 @@
 void
 test01()
 {
-#ifdef _GLIBCXX_USE_C99
+#ifdef _GLIBCXX_USE_C99_WCHAR
 
   bool test __attribute__((unused)) = false;
   using namespace std;
Index: libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/to_wstring.cc
===================================================================
--- libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/to_wstring.cc	(revision 227708)
+++ libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/to_wstring.cc	(working copy)
@@ -27,7 +27,7 @@
 void
 test01()
 {
-#ifdef _GLIBCXX_USE_C99
+#ifdef _GLIBCXX_USE_C99_WCHAR
 
   bool test __attribute__((unused)) = true;
   using namespace std;
Index: libstdc++-v3/testsuite/26_numerics/headers/cstdlib/13943.cc
===================================================================
--- libstdc++-v3/testsuite/26_numerics/headers/cstdlib/13943.cc	(revision 227708)
+++ libstdc++-v3/testsuite/26_numerics/headers/cstdlib/13943.cc	(working copy)
@@ -19,7 +19,7 @@
 #include <cstdlib>
 #include <testsuite_hooks.h>
 
-#if _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_STDLIB
 // libstdc++/13943
 void test01()
 {
@@ -36,7 +36,7 @@
 
 int main()
 {
-#if _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_STDLIB
   test01();
 #endif
   return 0;
Index: libstdc++-v3/testsuite/26_numerics/headers/cstdlib/types_std_c++0x.cc
===================================================================
--- libstdc++-v3/testsuite/26_numerics/headers/cstdlib/types_std_c++0x.cc	(revision 227708)
+++ libstdc++-v3/testsuite/26_numerics/headers/cstdlib/types_std_c++0x.cc	(working copy)
@@ -24,10 +24,10 @@
 
 void test01()
 {
-#if _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_STDLIB
 
   typedef std::lldiv_t     my_lldiv_t;
-  
+
 #endif
 }
 
Index: libstdc++-v3/testsuite/lib/libstdc++.exp
===================================================================
--- libstdc++-v3/testsuite/lib/libstdc++.exp	(revision 227708)
+++ libstdc++-v3/testsuite/lib/libstdc++.exp	(working copy)
@@ -1607,7 +1607,7 @@
 
         set f [open $src "w"]
         puts $f "#include <bits/c++config.h>"
-        puts $f "#if !defined(_GLIBCXX_USE_C99) || defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF)"
+        puts $f "#if !(defined(_GLIBCXX_USE_C99_STDIO) && defined(_GLIBCXX_USE_C99_STDLIB) && defined(_GLIBCXX_USE_C99_WCHAR)) || defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF)"
         puts $f "#  error No string conversions"
         puts $f "#endif"
         close $f
Index: libstdc++-v3/testsuite/tr1/8_c_compatibility/cmath/templates.cc
===================================================================
--- libstdc++-v3/testsuite/tr1/8_c_compatibility/cmath/templates.cc	(revision 227708)
+++ libstdc++-v3/testsuite/tr1/8_c_compatibility/cmath/templates.cc	(working copy)
@@ -23,7 +23,7 @@
 
 #include <tr1/cmath>
 
-#if _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_MATH
 #if !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC
 
 template<typename T>
Index: libstdc++-v3/testsuite/tr1/8_c_compatibility/cstdio/functions.cc
===================================================================
--- libstdc++-v3/testsuite/tr1/8_c_compatibility/cstdio/functions.cc	(revision 227708)
+++ libstdc++-v3/testsuite/tr1/8_c_compatibility/cstdio/functions.cc	(working copy)
@@ -30,7 +30,7 @@
   std::va_list ap;
   va_start(ap, dummy);
 
-#if _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_STDIO
 
   char* s = 0;
   const char* cs = 0;
Index: libstdc++-v3/testsuite/tr1/8_c_compatibility/cstdlib/functions.cc
===================================================================
--- libstdc++-v3/testsuite/tr1/8_c_compatibility/cstdlib/functions.cc	(revision 227708)
+++ libstdc++-v3/testsuite/tr1/8_c_compatibility/cstdlib/functions.cc	(working copy)
@@ -27,7 +27,7 @@
 
 void test01()
 {
-#if _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_STDLIB
 
   long long i = 0;
   const char* s = 0;
Index: libstdc++-v3/testsuite/tr1/8_c_compatibility/cstdlib/types_std_tr1.cc
===================================================================
--- libstdc++-v3/testsuite/tr1/8_c_compatibility/cstdlib/types_std_tr1.cc	(revision 227708)
+++ libstdc++-v3/testsuite/tr1/8_c_compatibility/cstdlib/types_std_tr1.cc	(working copy)
@@ -27,10 +27,10 @@
 
 void test01()
 {
-#if _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_STDLIB
 
   typedef std::tr1::lldiv_t     my_lldiv_t;
-  
+
 #endif
 }
 
Index: libstdc++-v3/testsuite/tr1/8_c_compatibility/cwchar/functions.cc
===================================================================
--- libstdc++-v3/testsuite/tr1/8_c_compatibility/cwchar/functions.cc	(revision 227708)
+++ libstdc++-v3/testsuite/tr1/8_c_compatibility/cwchar/functions.cc	(working copy)
@@ -67,7 +67,7 @@
   ret3 = ret3; // Suppress unused warning.
 #endif
 
-#if _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_WCHAR
 
   const wchar_t* nptr2 = 0;
   wchar_t** endptr2 = 0;

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Fwd: [PATCH] Enable libstdc++ numeric conversions on Cygwin
  2015-09-19 21:00     ` Jennifer Yao
@ 2015-09-21 12:37       ` Jonathan Wakely
  0 siblings, 0 replies; 20+ messages in thread
From: Jonathan Wakely @ 2015-09-21 12:37 UTC (permalink / raw)
  To: Jennifer Yao; +Cc: libstdc++, gcc-patches

On 19/09/15 15:55 -0400, Jennifer Yao wrote:
>> Do you already have a copyright assignment for GCC?
>>
>> If not, would you be willing to complete one?
>
>No, but I would be willing to complete one, yes. Are you willing to
>send me the appropriate forms, or should I contact someone else?

Great, I'll send you the forms, thanks.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] Enable libstdc++ numeric conversions on Cygwin
       [not found]     ` <20151112114049.GY2937@redhat.com>
@ 2015-11-12 13:40       ` Jonathan Wakely
  2015-11-12 14:50         ` Jonathan Wakely
                           ` (2 more replies)
  0 siblings, 3 replies; 20+ messages in thread
From: Jonathan Wakely @ 2015-11-12 13:40 UTC (permalink / raw)
  To: Jennifer Yao; +Cc: libstdc++, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 4386 bytes --]

On 12/11/15 11:40 +0000, Jonathan Wakely wrote:
>On 18/09/15 12:01 -0400, Jennifer Yao wrote:
>>Forgot to include the patch.
>>
>>On Fri, Sep 18, 2015 at 11:17 AM, Jennifer Yao
>><jenny.hyphen.fa@gmail.com> wrote:
>>>A number of functions in libstdc++ are guarded by the _GLIBCXX_USE_C99
>>>preprocessor macro, which is only defined on systems that pass all of
>>>the checks for a large set of C99 functions. Consequently, on systems
>>>which lack any of the required C99 facilities (e.g. Cygwin, which
>>>lacks some C99 complex math functions), the numeric conversion
>>>functions (std::stoi(), std::stol(), std::to_string(), etc.) are not
>>>defined—a rather silly outcome, as none of the numeric conversion
>>>functions are implemented using C99 math functions.
>>>
>>>This patch enables numeric conversion functions on the aforementioned
>>>systems by splitting the checks for C99 support and defining several
>>>new macros (_GLIBCXX_USE_C99_STDIO, _GLIBCXX_USE_C99_STDLIB, and
>>>_GLIBCXX_USE_C99_WCHAR), which replace the use of _GLIBCXX_USE_C99 in
>>>#if conditionals where appropriate.
>
>(Coming back to this now that Jennifer's copyright assignment is
>complete...)
>
>Splitting the _GLIBCXX_USE_C99 macro into more fine-grained macros for
>separate features is definitely the right direction.
>
>However your patch also changes the configure tests to use -std=c++0x
>(which should be -std=c++11, but that's a minor point). On an OS that
>only makes the C99 library available conditionally that will mean that
>configure determines that C99 library features are supported, but we
>will get errors if we try to use those features in C++03 parts of the
>library.
>
>I think a more complete solution is to have two sets of configure
>tests and two sets of macros, so that we define _GLIBCXX_USE_C99_STDIO
>when C99 stdio is available unconditionally, and define
>_GLIBCXX11_USE_C99_STDIO when it's available with -std=c++11.
>
>Then in the library code we can check _GLIBCXX_USE_C99_STDIO if we
>want to use C99 features in C++03 code, and check
>_GLIBCXX11_USE_C99_STDIO if we want to use the features in C++11 code.
>
>That should still solve the problem for the numeric conversion
>functions, because they are defined in C++11 and so would check
>_GLIBCXX11_USE_C99_STDIO, which will be defined for newlib.
>
>Other pieces of the library, such as locales, will use
>_GLIBCXX_USE_C99_STDIO and that might still be false for newlib (and
>for other strict C libraries like the Solaris and FreeBSD libc).
>
>I will make the changes to acinclude.m4 to duplicate the tests, so we
>test once with -std=c++98 and once with -std=c++11, and then change
>the library to check either _GLIBCXX_xxx or _GLIBCXX11_xxx as
>appropriate.

Here's a patch implementing my suggestion.

The major changes since Jennifer's original patch are in acinclude.m4,
to do the autoconf tests once with -std=c++98 and again with
-std=c++11, and in include/bits/c++config to define the
_GLIBCXX_USE_C99_XXX macros according to either _GLIBCXX98_USE_CXX_XXX
or _GLIBCXX11_USE_CXX_XXX, depending on the standard mode in effect
when the file is included.

Because those new definitions in bits/c++config are unconditional I
had to adjust a few #ifdef tests to use #if instead.

I also removed the changes to GLIBCXX_CHECK_C99_TR1, so that there are
no changes to the macros used for the TR1 library. As a follow-up
change I will add a test for <stdint.h> to GLIBCXX_ENABLE_C99 and
change several C++ headers to stop using the TR1 macros.

This passes all tests on powerpc64le-linux, I'll also try to test on
DragonFly and FreeBSD.

Does this look good to everyone?

One downside of this change is that we introduce some (hopefully safe)
ODR violations, where inline functions and templates that depend on
_GLIBCXX_USE_C99_FOO might now be defined differently in C++98 and
C++11 code. Previously they had the same definition, even though in
C++11 mode the value of the _GLIBCXX_USE_C99_FOO macro might have been
sub-optimal (i.e. the C99 features were usable, but the macro said
they weren't). Those ODR violatiosn could be avoided if needed, by
always using the _GLIBCXX98_USE_C99_FOO macro in code that can be
included from either C++98 or C++11. We could still use the
_GLIBCXX11_USE_C99_FOO macro in pure C++11 code (such as the numeric
conversion functions) and get most of the benefit of this change.


[-- Attachment #2: patch.txt --]
[-- Type: text/x-patch, Size: 58290 bytes --]

commit 1459e1d0a0033a8f2605d33f52e2bf789fb6ab33
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Thu Nov 12 13:19:38 2015 +0000

    More fine-grained autoconf checks for C99 library
    
    2015-09-18  Jennifer Yao  <jenny.hyphen.fa@gmail.com>
    	    Jonathan Wakely  <jwakely@redhat.com>
    
    	PR libstdc++/58393
    	PR libstdc++/61580
    	* acinclude.m4 (GLIBCXX_ENABLE_C99): Perform tests twice, with
    	-std=c++11 as well as -std=c++98, and define separate macros for each.
    	Cache the results of checking for complex math and wide character
    	functions. Reformat for readability.
    	* config.h.in: Regenerate.
    	* include/bits/c++config: Define _GLIBCXX_USE_C99_XXX macros to
    	either _GLIBCXX98_USE_C99_XXX or _GLIBCXX11_USE_C99_XXX according to
    	language standard in use.
    	* config/locale/dragonfly/c_locale.h (std::__convert_from_v): Replace
    	_GLIBCXX_USE_C99 with _GLIBCXX_USE_C99_STDIO.
    	* config/locale/generic/c_locale.h (std::__convert_from_v): Likewise.
    	* config/locale/gnu/c_locale.h (std::__convert_from_v): Likewise.
    	* config/os/bsd/dragonfly/os_defines.h: Define _GLIBCXX_USE_C99_STDIO,
    	_GLIBCXX_USE_C99_STDLIB, and _GLIBCXX_USE_C99_WCHAR.
    	* configure: Regenerate.
    	* include/bits/basic_string.h: Make numeric conversion functions
    	depend on _GLIBCXX_USE_C99_STDIO, _GLIBCXX_USE_C99_STDLIB, or
    	_GLIBCXX_USE_C99_WCHAR, instead of _GLIBCXX_USE_C99.
    	* include/ext/vstring.h: Likewise.
    	* include/bits/locale_facets.tcc (std::num_put::_M_insert_float):
    	Replace _GLIBCXX_USE_C99 with _GLIBCXX_USE_C99_STDIO.
    	* include/bits/locale_facets_nonio.tcc (std::money_put::do_put):
    	Likewise.
    	* include/c_compatibility/math.h: Replace _GLIBCXX_USE_C99 with
    	_GLIBCXX_USE_C99_MATH.
    	* include/c_compatibility/wchar.h: Replace _GLIBCXX_USE_C99 with
    	_GLIBCXX_USE_C99_WCHAR.
    	* include/c_global/cstdio: Replace _GLIBCXX_USE_C99 with
    	_GLIBCXX_USE_C99_STDIO.
    	* include/c_global/cstdlib: Replace _GLIBCXX_USE_C99 with
    	_GLIBCXX_USE_C99_STDLIB.
    	* include/c_global/cwchar: Replace _GLIBCXX_USE_C99 with
    	_GLIBCXX_USE_C99_WCHAR.
    	* include/c_std/cstdio: Replace _GLIBCXX_USE_C99 with
    	_GLIBCXX_USE_C99_STDIO.
    	* include/c_std/cstdlib: Replace _GLIBCXX_USE_C99 with
    	_GLIBCXX_USE_C99_STDLIB.
    	* include/c_std/cwchar: Replace _GLIBCXX_USE_C99 with
    	_GLIBCXX_USE_C99_WCHAR.
    	* include/tr1/cstdio: Replace _GLIBCXX_USE_C99 with
    	_GLIBCXX_USE_C99_STDIO.
    	* include/tr1/cstdlib: Replace _GLIBCXX_USE_C99 with
    	_GLIBCXX_USE_C99_STDLIB.
    	* include/tr1/cwchar: Replace _GLIBCXX_USE_C99 with
    	_GLIBCXX_USE_C99_WCHAR.
    	* include/tr1/stdlib.h: Replace _GLIBCXX_USE_C99 with
    	_GLIBCXX_USE_C99_STDLIB.
    	* src/c++98/locale_facets.cc (std::__num_base::_S_format_float):
    	Replace _GLIBCXX_USE_C99 with _GLIBCXX_USE_C99_STDIO.
    	* testsuite/18_support/exception_ptr/60612-terminate.cc: Replace
    	_GLIBCXX_USE_C99 with _GLIBCXX_USE_C99_STDLIB.
    	* testsuite/18_support/exception_ptr/60612-unexpected.cc: Likewise.
    	* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stod.cc
    	(test01): Replace _GLIBCXX_USE_C99 with _GLIBCXX_USE_C99_WCHAR.
    	* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
    	stof.cc: Likewise.
    	* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
    	stoi.cc: Likewise.
    	* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
    	stol.cc: Likewise.
    	* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
    	stold.cc: Likewise.
    	* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
    	stoll.cc: Likewise.
    	* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
    	stoul.cc: Likewise.
    	* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
    	stoull.cc: Likewise.
    	* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
    	to_wstring.cc: Likewise.
    	* testsuite/26_numerics/headers/cstdlib/13943.cc: Replace
    	_GLIBCXX_USE_C99 with _GLIBCXX_USE_C99_STDLIB.
    	* testsuite/26_numerics/headers/cstdlib/types_std_c++0x.cc: Likewise.
    	* testsuite/lib/libstdc++.exp (check_v3_target_string_conversions):
    	Change preprocessor #if conditional so that it uses
    	_GLIBCXX_USE_C99_STDIO, _GLIBCXX_USE_C99_STDLIB, and
    	_GLIBCXX_USE_C99_WCHAR, instead of _GLIBCXX_USE_C99.
    	* testsuite/tr1/8_c_compatibility/cmath/templates.cc: Replace
    	_GLIBCXX_USE_C99 with _GLIBCXX_USE_C99_MATH.
    	* testsuite/tr1/8_c_compatibility/cstdio/functions.cc: Replace
    	_GLIBCXX_USE_C99 with _GLIBCXX_USE_C99_STDIO.
    	* testsuite/tr1/8_c_compatibility/cstdlib/functions.cc: Replace
    	_GLIBCXX_USE_C99 with _GLIBCXX_USE_C99_STDLIB.
    	* testsuite/tr1/8_c_compatibility/cstdlib/types_std_tr1.cc: Likewise.
    	* testsuite/tr1/8_c_compatibility/cwchar/functions.cc: Replace
    	_GLIBCXX_USE_C99 with _GLIBCXX_USE_C99_WCHAR.
    	* testsuite/util/testsuite_fs.h: Replace _GLIBCXX_USE_C99 with
    	_GLIBCXX_USE_C99_STDIO.

diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
index abf2e93..deefa04 100644
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -915,234 +915,438 @@ AC_DEFUN([GLIBCXX_ENABLE_C99], [
   GLIBCXX_ENABLE(c99,$1,,[turns on ISO/IEC 9899:1999 support])
 
   if test x"$enable_c99" = x"yes"; then
+    AC_LANG_SAVE
+    AC_LANG_CPLUSPLUS
 
-  AC_LANG_SAVE
-  AC_LANG_CPLUSPLUS
+    # Use -std=c++98 (instead of -std=gnu++98) because leaving __STRICT_ANSI__
+    # undefined may cause fake C99 facilities, like pre-standard snprintf,
+    # to be spuriously enabled.
+    ac_save_CXXFLAGS="$CXXFLAGS"
+    CXXFLAGS="$CXXFLAGS -std=c++98"
+    ac_save_LIBS="$LIBS"
+    ac_save_gcc_no_link="$gcc_no_link"
 
-  # Use -std=c++98 because the default (-std=gnu++98) leaves __STRICT_ANSI__
-  # undefined and fake C99 facilities - like pre-standard snprintf - may be
-  # spuriously enabled.
-  # Long term, -std=c++0x could be even better, could manage to explicitly
-  # request C99 facilities to the underlying C headers.
-  ac_save_CXXFLAGS="$CXXFLAGS"
-  CXXFLAGS="$CXXFLAGS -std=c++98"
-  ac_save_LIBS="$LIBS"
-  ac_save_gcc_no_link="$gcc_no_link"
+    if test x$gcc_no_link != xyes; then
+      # Use -fno-exceptions to that the C driver can link these tests without
+      # hitting undefined references to personality routines.
+      CXXFLAGS="$CXXFLAGS -fno-exceptions"
+      AC_CHECK_LIB(m, sin, [LIBS="$LIBS -lm"], [
+        # Use the default compile-only tests in GCC_TRY_COMPILE_OR_LINK
+        gcc_no_link=yes
+      ])
+    fi
 
-  if test x$gcc_no_link != xyes; then
-    # Use -fno-exceptions to that the C driver can link these tests without
-    # hitting undefined references to personality routines.
-    CXXFLAGS="$CXXFLAGS -fno-exceptions"
-    AC_CHECK_LIB(m, sin, [
-      LIBS="$LIBS -lm"
-    ], [
-      # Use the default compile-only tests in GCC_TRY_COMPILE_OR_LINK
-      gcc_no_link=yes
+    # Check for the existence of <math.h> functions used if C99 is enabled.
+    AC_MSG_CHECKING([for ISO C99 support in <math.h> for C++98])
+    AC_CACHE_VAL(glibcxx_cv_c99_math_cxx98, [
+      GCC_TRY_COMPILE_OR_LINK(
+        [#include <math.h>
+         volatile double d1, d2;
+         volatile int i;],
+        [i = fpclassify(d1);
+         i = isfinite(d1);
+         i = isinf(d1);
+         i = isnan(d1);
+         i = isnormal(d1);
+         i = signbit(d1);
+         i = isgreater(d1, d2);
+         i = isgreaterequal(d1, d2);
+         i = isless(d1, d2);
+         i = islessequal(d1, d2);
+         i = islessgreater(d1, d2);
+         i = islessgreater(d1, d2);
+         i = isunordered(d1, d2);
+        ], [glibcxx_cv_c99_math_cxx98=yes], [glibcxx_cv_c99_math_cxx98=no])
     ])
-  fi
+    AC_MSG_RESULT($glibcxx_cv_c99_math_cxx98)
+    if test x"$glibcxx_cv_c99_math_cxx98" = x"yes"; then
+      AC_DEFINE(_GLIBCXX98_USE_C99_MATH, 1,
+        [Define if C99 functions or macros in <math.h> should be imported
+        in <cmath> in namespace std for C++98.])
+    fi
 
-  # Check for the existence of <math.h> functions used if C99 is enabled.
-  AC_MSG_CHECKING([for ISO C99 support in <math.h>])
-  AC_CACHE_VAL(glibcxx_cv_c99_math, [
-  GCC_TRY_COMPILE_OR_LINK(
-     [#include <math.h>
-      volatile double d1, d2;
-      volatile int i;],
-     [i = fpclassify(d1);
-      i = isfinite(d1);
-      i = isinf(d1);
-      i = isnan(d1);
-      i = isnormal(d1);
-      i = signbit(d1);
-      i = isgreater(d1, d2);
-      i = isgreaterequal(d1, d2);
-      i = isless(d1, d2);
-      i = islessequal(d1, d2);
-      i = islessgreater(d1, d2);
-      i = islessgreater(d1, d2);
-      i = isunordered(d1, d2);
-     ],[glibcxx_cv_c99_math=yes], [glibcxx_cv_c99_math=no])
-  ])
-  AC_MSG_RESULT($glibcxx_cv_c99_math)
-  if test x"$glibcxx_cv_c99_math" = x"yes"; then
-    AC_DEFINE(_GLIBCXX_USE_C99_MATH, 1,
-	      [Define if C99 functions or macros in <math.h> should be imported
-	      in <cmath> in namespace std.])
-  fi
+    # Check for the existence of <complex.h> complex math functions.
+    # This is necessary even though libstdc++ uses the builtin versions
+    # of these functions, because if the builtin cannot be used, a reference
+    # to the library function is emitted.
+    AC_CHECK_HEADERS(tgmath.h, ac_has_tgmath_h=yes, ac_has_tgmath_h=no)
+    AC_CHECK_HEADERS(complex.h, ac_has_complex_h=yes, ac_has_complex_h=no)
+    if test x"$ac_has_complex_h" = x"yes"; then
+      AC_MSG_CHECKING([for ISO C99 support in <complex.h> for C++98])
+      AC_CACHE_VAL(glibcxx_cv_c99_complex_cxx98, [
+        GCC_TRY_COMPILE_OR_LINK(
+          [#include <complex.h>
+           typedef __complex__ float float_type;
+           typedef __complex__ double double_type;
+           typedef __complex__ long double ld_type;
+           volatile float_type tmpf;
+           volatile double_type tmpd;
+           volatile ld_type tmpld;
+           volatile float f;
+           volatile double d;
+           volatile long double ld;],
+          [f = cabsf(tmpf);
+           f = cargf(tmpf);
+           tmpf = ccosf(tmpf);
+           tmpf = ccoshf(tmpf);
+           tmpf = cexpf(tmpf);
+           tmpf = clogf(tmpf);
+           tmpf = csinf(tmpf);
+           tmpf = csinhf(tmpf);
+           tmpf = csqrtf(tmpf);
+           tmpf = ctanf(tmpf);
+           tmpf = ctanhf(tmpf);
+           tmpf = cpowf(tmpf, tmpf);
+           tmpf = cprojf(tmpf);
+           d = cabs(tmpd);
+           d = carg(tmpd);
+           tmpd = ccos(tmpd);
+           tmpd = ccosh(tmpd);
+           tmpd = cexp(tmpd);
+           tmpd = clog(tmpd);
+           tmpd = csin(tmpd);
+           tmpd = csinh(tmpd);
+           tmpd = csqrt(tmpd);
+           tmpd = ctan(tmpd);
+           tmpd = ctanh(tmpd);
+           tmpd = cpow(tmpd, tmpd);
+           tmpd = cproj(tmpd);
+           ld = cabsl(tmpld);
+           ld = cargl(tmpld);
+           tmpld = ccosl(tmpld);
+           tmpld = ccoshl(tmpld);
+           tmpld = cexpl(tmpld);
+           tmpld = clogl(tmpld);
+           tmpld = csinl(tmpld);
+           tmpld = csinhl(tmpld);
+           tmpld = csqrtl(tmpld);
+           tmpld = ctanl(tmpld);
+           tmpld = ctanhl(tmpld);
+           tmpld = cpowl(tmpld, tmpld);
+           tmpld = cprojl(tmpld);
+          ], [glibcxx_cv_c99_complex_cxx98=yes], [glibcxx_cv_c99_complex_cxx98=no])
+      ])
+    fi
+    AC_MSG_RESULT($glibcxx_cv_c99_complex_cxx98)
+    if test x"$glibcxx_cv_c99_complex_cxx98" = x"yes"; then
+      AC_DEFINE(_GLIBCXX98_USE_C99_COMPLEX, 1,
+        [Define if C99 functions in <complex.h> should be used in
+        <complex> for C++98. Using compiler builtins for these functions
+        requires corresponding C99 library functions to be present.])
+    fi
 
-  # Check for the existence of <complex.h> complex math functions.
-  # This is necessary even though libstdc++ uses the builtin versions
-  # of these functions, because if the builtin cannot be used, a reference
-  # to the library function is emitted.
-  AC_CHECK_HEADERS(tgmath.h, ac_has_tgmath_h=yes, ac_has_tgmath_h=no)
-  AC_CHECK_HEADERS(complex.h, ac_has_complex_h=yes, ac_has_complex_h=no)
-  glibcxx_cv_c99_complex=no;
-  if test x"$ac_has_complex_h" = x"yes"; then
-    AC_MSG_CHECKING([for ISO C99 support in <complex.h>])
-    GCC_TRY_COMPILE_OR_LINK(
-       [#include <complex.h>
-	typedef __complex__ float float_type;
-	typedef __complex__ double double_type;
-	typedef __complex__ long double ld_type;
-	volatile float_type tmpf;
-	volatile double_type tmpd;
-	volatile ld_type tmpld;
-	volatile float f;
-	volatile double d;
-	volatile long double ld;],
-       [f = cabsf(tmpf);
-	f = cargf(tmpf);
-	tmpf = ccosf(tmpf);
-	tmpf = ccoshf(tmpf);
-	tmpf = cexpf(tmpf);
-	tmpf = clogf(tmpf);
-	tmpf = csinf(tmpf);
-	tmpf = csinhf(tmpf);
-	tmpf = csqrtf(tmpf);
-	tmpf = ctanf(tmpf);
-	tmpf = ctanhf(tmpf);
-	tmpf = cpowf(tmpf, tmpf);
-	tmpf = cprojf(tmpf);
-	d = cabs(tmpd);
-	d = carg(tmpd);
-	tmpd = ccos(tmpd);
-	tmpd = ccosh(tmpd);
-	tmpd = cexp(tmpd);
-	tmpd = clog(tmpd);
-	tmpd = csin(tmpd);
-	tmpd = csinh(tmpd);
-	tmpd = csqrt(tmpd);
-	tmpd = ctan(tmpd);
-	tmpd = ctanh(tmpd);
-	tmpd = cpow(tmpd, tmpd);
-	tmpd = cproj(tmpd);
-	ld = cabsl(tmpld);
-	ld = cargl(tmpld);
-	tmpld = ccosl(tmpld);
-	tmpld = ccoshl(tmpld);
-	tmpld = cexpl(tmpld);
-	tmpld = clogl(tmpld);
-	tmpld = csinl(tmpld);
-	tmpld = csinhl(tmpld);
-	tmpld = csqrtl(tmpld);
-	tmpld = ctanl(tmpld);
-	tmpld = ctanhl(tmpld);
-	tmpld = cpowl(tmpld, tmpld);
-	tmpld = cprojl(tmpld);
-       ],[glibcxx_cv_c99_complex=yes], [glibcxx_cv_c99_complex=no])
-  fi
-  AC_MSG_RESULT($glibcxx_cv_c99_complex)
-  if test x"$glibcxx_cv_c99_complex" = x"yes"; then
-    AC_DEFINE(_GLIBCXX_USE_C99_COMPLEX, 1,
-	      [Define if C99 functions in <complex.h> should be used in
-	      <complex>. Using compiler builtins for these functions requires
-	      corresponding C99 library functions to be present.])
-  fi
+    # Check for the existence in <stdio.h> of vscanf, et. al.
+    AC_MSG_CHECKING([for ISO C99 support in <stdio.h> for C++98])
+    AC_CACHE_VAL(glibcxx_cv_c99_stdio_cxx98, [
+      GCC_TRY_COMPILE_OR_LINK(
+        [#include <stdio.h>
+         #include <stdarg.h>
+         void foo(char* fmt, ...)
+         {
+           va_list args; va_start(args, fmt);
+           vfscanf(stderr, "%i", args);
+           vscanf("%i", args);
+           vsnprintf(fmt, 0, "%i", args);
+           vsscanf(fmt, "%i", args);
+           snprintf(fmt, 0, "%i");
+         }], [],
+        [glibcxx_cv_c99_stdio_cxx98=yes], [glibcxx_cv_c99_stdio_cxx98=no])
+    ])
+    AC_MSG_RESULT($glibcxx_cv_c99_stdio_cxx98)
+    if test x"$glibcxx_cv_c99_stdio_cxx98" = x"yes"; then
+      AC_DEFINE(_GLIBCXX98_USE_C99_STDIO, 1,
+        [Define if C99 functions or macros in <stdio.h> should be imported
+        in <cstdio> in namespace std for C++98.])
+    fi
 
-  # Check for the existence in <stdio.h> of vscanf, et. al.
-  AC_MSG_CHECKING([for ISO C99 support in <stdio.h>])
-  AC_CACHE_VAL(glibcxx_cv_c99_stdio, [
-  GCC_TRY_COMPILE_OR_LINK(
-     [#include <stdio.h>
-      #include <stdarg.h>
-      void foo(char* fmt, ...)
-      {
-	va_list args; va_start(args, fmt);
-	vfscanf(stderr, "%i", args);
-	vscanf("%i", args);
-	vsnprintf(fmt, 0, "%i", args);
-	vsscanf(fmt, "%i", args);
-	snprintf(fmt, 0, "%i");
-      }], [],
-     [glibcxx_cv_c99_stdio=yes], [glibcxx_cv_c99_stdio=no])
-  ])
-  AC_MSG_RESULT($glibcxx_cv_c99_stdio)
+    # Check for the existence in <wchar.h> of wcstold, etc.
+    if test x"$ac_has_wchar_h" = xyes &&
+       test x"$ac_has_wctype_h" = xyes; then
+      AC_MSG_CHECKING([for ISO C99 support in <wchar.h> for C++98])
+      AC_CACHE_VAL(glibcxx_cv_c99_wchar_cxx98, [
+        AC_TRY_COMPILE([#include <wchar.h>
+          namespace test
+          {
+            using ::wcstold;
+            using ::wcstoll;
+            using ::wcstoull;
+          }
+        ], [], [glibcxx_cv_c99_wchar_cxx98=yes], [glibcxx_cv_c99_wchar_cxx98=no])
+      ])
 
-  # Check for the existence in <stdlib.h> of lldiv_t, et. al.
-  AC_MSG_CHECKING([for ISO C99 support in <stdlib.h>])
-  AC_CACHE_VAL(glibcxx_cv_c99_stdlib, [
-  GCC_TRY_COMPILE_OR_LINK(
-     [#include <stdlib.h>
-      volatile float f;
-      volatile long double ld;
-      volatile unsigned long long ll;
-      lldiv_t mydivt;],
-     [char* tmp;
-      f = strtof("gnu", &tmp);
-      ld = strtold("gnu", &tmp);
-      ll = strtoll("gnu", &tmp, 10);
-      ll = strtoull("gnu", &tmp, 10);
-      ll = llabs(10);
-      mydivt = lldiv(10,1);
-      ll = mydivt.quot;
-      ll = mydivt.rem;
-      ll = atoll("10");
-      _Exit(0);
-      ],[glibcxx_cv_c99_stdlib=yes], [glibcxx_cv_c99_stdlib=no])
-  ])
-  AC_MSG_RESULT($glibcxx_cv_c99_stdlib)
+      # Checks for wide character functions that may not be present.
+      # Injection of these is wrapped with guard macros.
+      # NB: only put functions here, instead of immediately above, if
+      # absolutely necessary.
+      AC_TRY_COMPILE([#include <wchar.h>
+        namespace test { using ::vfwscanf; }], [],
+        [AC_DEFINE(HAVE_VFWSCANF, 1, [Defined if vfwscanf exists.])], [])
 
-  # Check for the existence in <wchar.h> of wcstold, etc.
-  glibcxx_cv_c99_wchar=no;
-  if test x"$ac_has_wchar_h" = xyes &&
-     test x"$ac_has_wctype_h" = xyes; then
-    AC_MSG_CHECKING([for ISO C99 support in <wchar.h>])
-    AC_TRY_COMPILE([#include <wchar.h>
-		    namespace test
-		    {
-		      using ::wcstold;
-		      using ::wcstoll;
-		      using ::wcstoull;
-		    }
-		   ],[],[glibcxx_cv_c99_wchar=yes], [glibcxx_cv_c99_wchar=no])
+      AC_TRY_COMPILE([#include <wchar.h>
+        namespace test { using ::vswscanf; }], [],
+        [AC_DEFINE(HAVE_VSWSCANF, 1, [Defined if vswscanf exists.])], [])
 
-    # Checks for wide character functions that may not be present.
-    # Injection of these is wrapped with guard macros.
-    # NB: only put functions here, instead of immediately above, if
-    # absolutely necessary.
-    AC_TRY_COMPILE([#include <wchar.h>
-		    namespace test { using ::vfwscanf; } ], [],
- 	    	   [AC_DEFINE(HAVE_VFWSCANF,1,
-			[Defined if vfwscanf exists.])],[])
+      AC_TRY_COMPILE([#include <wchar.h>
+        namespace test { using ::vwscanf; }], [],
+        [AC_DEFINE(HAVE_VWSCANF, 1, [Defined if vwscanf exists.])], [])
 
-    AC_TRY_COMPILE([#include <wchar.h>
-		    namespace test { using ::vswscanf; } ], [],
- 	    	   [AC_DEFINE(HAVE_VSWSCANF,1,
-			[Defined if vswscanf exists.])],[])
+      AC_TRY_COMPILE([#include <wchar.h>
+        namespace test { using ::wcstof; }], [],
+        [AC_DEFINE(HAVE_WCSTOF, 1, [Defined if wcstof exists.])], [])
 
-    AC_TRY_COMPILE([#include <wchar.h>
-		    namespace test { using ::vwscanf; } ], [],
- 	    	   [AC_DEFINE(HAVE_VWSCANF,1,[Defined if vwscanf exists.])],[])
+      AC_TRY_COMPILE([#include <wctype.h>],
+        [wint_t t; int i = iswblank(t);],
+        [AC_DEFINE(HAVE_ISWBLANK, 1, [Defined if iswblank exists.])], [])
 
-    AC_TRY_COMPILE([#include <wchar.h>
-		    namespace test { using ::wcstof; } ], [],
- 	    	   [AC_DEFINE(HAVE_WCSTOF,1,[Defined if wcstof exists.])],[])
+      AC_MSG_RESULT($glibcxx_cv_c99_wchar_cxx98)
+      if test x"$glibcxx_cv_c99_wchar_cxx98" = x"yes"; then
+        AC_DEFINE(_GLIBCXX98_USE_C99_WCHAR, 1,
+          [Define if C99 functions or macros in <wchar.h> should be imported
+          in <cwchar> in namespace std for C++98.])
+      fi
+    fi
 
-    AC_TRY_COMPILE([#include <wctype.h>],
-		   [ wint_t t; int i = iswblank(t);],
- 	    	   [AC_DEFINE(HAVE_ISWBLANK,1,
-			[Defined if iswblank exists.])],[])
+    # Option parsed, now set things appropriately.
+    if test x"$glibcxx_cv_c99_math_cxx98" = x"no" ||
+       test x"$glibcxx_cv_c99_complex_cxx98" = x"no" ||
+       test x"$glibcxx_cv_c99_stdio_cxx98" = x"no" ||
+       test x"$glibcxx_cv_c99_stdlib_cxx98" = x"no" ||
+       test x"$glibcxx_cv_c99_wchar_cxx98" = x"no"; then
+      enable_c99=no;
+    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.])
+    fi
 
-    AC_MSG_RESULT($glibcxx_cv_c99_wchar)
-  fi
+    gcc_no_link="$ac_save_gcc_no_link"
+    LIBS="$ac_save_LIBS"
+    CXXFLAGS="$ac_save_CXXFLAGS"
+    AC_LANG_RESTORE
 
-  # 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
-    enable_c99=no;
-  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.])
-  fi
+    AC_LANG_SAVE
+    AC_LANG_CPLUSPLUS
 
-  gcc_no_link="$ac_save_gcc_no_link"
-  LIBS="$ac_save_LIBS"
-  CXXFLAGS="$ac_save_CXXFLAGS"
-  AC_LANG_RESTORE
+    # Use -std=c++11 and test again for C99 library feature in C++11 mode.
+    # For the reasons given above we use -std=c++11 not -std=gnu++11.
+    ac_save_CXXFLAGS="$CXXFLAGS"
+    CXXFLAGS="$CXXFLAGS -std=c++11"
+    ac_save_LIBS="$LIBS"
+    ac_save_gcc_no_link="$gcc_no_link"
+
+    if test x$gcc_no_link != xyes; then
+      # Use -fno-exceptions to that the C driver can link these tests without
+      # hitting undefined references to personality routines.
+      CXXFLAGS="$CXXFLAGS -fno-exceptions"
+      AC_CHECK_LIB(m, sin, [LIBS="$LIBS -lm"], [
+        # Use the default compile-only tests in GCC_TRY_COMPILE_OR_LINK
+        gcc_no_link=yes
+      ])
+    fi
+
+    # Check for the existence of <math.h> functions used if C99 is enabled.
+    AC_MSG_CHECKING([for ISO C99 support in <math.h> for C++11])
+    AC_CACHE_VAL(glibcxx_cv_c99_math_cxx11, [
+      GCC_TRY_COMPILE_OR_LINK(
+        [#include <math.h>
+         volatile double d1, d2;
+         volatile int i;],
+        [i = fpclassify(d1);
+         i = isfinite(d1);
+         i = isinf(d1);
+         i = isnan(d1);
+         i = isnormal(d1);
+         i = signbit(d1);
+         i = isgreater(d1, d2);
+         i = isgreaterequal(d1, d2);
+         i = isless(d1, d2);
+         i = islessequal(d1, d2);
+         i = islessgreater(d1, d2);
+         i = islessgreater(d1, d2);
+         i = isunordered(d1, d2);
+        ], [glibcxx_cv_c99_math_cxx11=yes], [glibcxx_cv_c99_math_cxx11=no])
+    ])
+    AC_MSG_RESULT($glibcxx_cv_c99_math_cxx11)
+    if test x"$glibcxx_cv_c99_math_cxx11" = x"yes"; then
+      AC_DEFINE(_GLIBCXX11_USE_C99_MATH, 1,
+        [Define if C99 functions or macros in <math.h> should be imported
+        in <cmath> in namespace std for C++11.])
+    fi
+
+    # Check for the existence of <complex.h> complex math functions.
+    # This is necessary even though libstdc++ uses the builtin versions
+    # of these functions, because if the builtin cannot be used, a reference
+    # to the library function is emitted.
+    AC_CHECK_HEADERS(tgmath.h, ac_has_tgmath_h=yes, ac_has_tgmath_h=no)
+    AC_CHECK_HEADERS(complex.h, ac_has_complex_h=yes, ac_has_complex_h=no)
+    if test x"$ac_has_complex_h" = x"yes"; then
+      AC_MSG_CHECKING([for ISO C99 support in <complex.h> for C++11])
+      AC_CACHE_VAL(glibcxx_cv_c99_complex_cxx11, [
+        GCC_TRY_COMPILE_OR_LINK(
+          [#include <complex.h>
+           typedef __complex__ float float_type;
+           typedef __complex__ double double_type;
+           typedef __complex__ long double ld_type;
+           volatile float_type tmpf;
+           volatile double_type tmpd;
+           volatile ld_type tmpld;
+           volatile float f;
+           volatile double d;
+           volatile long double ld;],
+          [f = cabsf(tmpf);
+           f = cargf(tmpf);
+           tmpf = ccosf(tmpf);
+           tmpf = ccoshf(tmpf);
+           tmpf = cexpf(tmpf);
+           tmpf = clogf(tmpf);
+           tmpf = csinf(tmpf);
+           tmpf = csinhf(tmpf);
+           tmpf = csqrtf(tmpf);
+           tmpf = ctanf(tmpf);
+           tmpf = ctanhf(tmpf);
+           tmpf = cpowf(tmpf, tmpf);
+           tmpf = cprojf(tmpf);
+           d = cabs(tmpd);
+           d = carg(tmpd);
+           tmpd = ccos(tmpd);
+           tmpd = ccosh(tmpd);
+           tmpd = cexp(tmpd);
+           tmpd = clog(tmpd);
+           tmpd = csin(tmpd);
+           tmpd = csinh(tmpd);
+           tmpd = csqrt(tmpd);
+           tmpd = ctan(tmpd);
+           tmpd = ctanh(tmpd);
+           tmpd = cpow(tmpd, tmpd);
+           tmpd = cproj(tmpd);
+           ld = cabsl(tmpld);
+           ld = cargl(tmpld);
+           tmpld = ccosl(tmpld);
+           tmpld = ccoshl(tmpld);
+           tmpld = cexpl(tmpld);
+           tmpld = clogl(tmpld);
+           tmpld = csinl(tmpld);
+           tmpld = csinhl(tmpld);
+           tmpld = csqrtl(tmpld);
+           tmpld = ctanl(tmpld);
+           tmpld = ctanhl(tmpld);
+           tmpld = cpowl(tmpld, tmpld);
+           tmpld = cprojl(tmpld);
+          ], [glibcxx_cv_c99_complex_cxx11=yes], [glibcxx_cv_c99_complex_cxx11=no])
+      ])
+    fi
+    AC_MSG_RESULT($glibcxx_cv_c99_complex_cxx11)
+    if test x"$glibcxx_cv_c99_complex_cxx11" = x"yes"; then
+      AC_DEFINE(_GLIBCXX11_USE_C99_COMPLEX, 1,
+        [Define if C99 functions in <complex.h> should be used in
+        <complex> for C++11. Using compiler builtins for these functions
+        requires corresponding C99 library functions to be present.])
+    fi
+
+    # Check for the existence in <stdio.h> of vscanf, et. al.
+    AC_MSG_CHECKING([for ISO C99 support in <stdio.h> for C++11])
+    AC_CACHE_VAL(glibcxx_cv_c99_stdio_cxx11, [
+      GCC_TRY_COMPILE_OR_LINK(
+        [#include <stdio.h>
+         #include <stdarg.h>
+         void foo(char* fmt, ...)
+         {
+           va_list args; va_start(args, fmt);
+           vfscanf(stderr, "%i", args);
+           vscanf("%i", args);
+           vsnprintf(fmt, 0, "%i", args);
+           vsscanf(fmt, "%i", args);
+           snprintf(fmt, 0, "%i");
+         }], [],
+        [glibcxx_cv_c99_stdio_cxx11=yes], [glibcxx_cv_c99_stdio_cxx11=no])
+    ])
+    AC_MSG_RESULT($glibcxx_cv_c99_stdio_cxx11)
+    if test x"$glibcxx_cv_c99_stdio_cxx11" = x"yes"; then
+      AC_DEFINE(_GLIBCXX11_USE_C99_STDIO, 1,
+        [Define if C99 functions or macros in <stdio.h> should be imported
+        in <cstdio> in namespace std for C++11.])
+    fi
+
+    # Check for the existence in <stdlib.h> of lldiv_t, et. al.
+    AC_MSG_CHECKING([for ISO C99 support in <stdlib.h> for C++11])
+    AC_CACHE_VAL(glibcxx_cv_c99_stdlib_cxx11, [
+      GCC_TRY_COMPILE_OR_LINK(
+        [#include <stdlib.h>
+         volatile float f;
+         volatile long double ld;
+         volatile unsigned long long ll;
+         lldiv_t mydivt;],
+        [char* tmp;
+         f = strtof("gnu", &tmp);
+         ld = strtold("gnu", &tmp);
+         ll = strtoll("gnu", &tmp, 10);
+         ll = strtoull("gnu", &tmp, 10);
+         ll = llabs(10);
+         mydivt = lldiv(10,1);
+         ll = mydivt.quot;
+         ll = mydivt.rem;
+         ll = atoll("10");
+         _Exit(0);
+        ], [glibcxx_cv_c99_stdlib_cxx11=yes], [glibcxx_cv_c99_stdlib_cxx11=no])
+    ])
+    AC_MSG_RESULT($glibcxx_cv_c99_stdlib_cxx11)
+    if test x"$glibcxx_cv_c99_stdlib_cxx11" = x"yes"; then
+      AC_DEFINE(_GLIBCXX11_USE_C99_STDLIB, 1,
+        [Define if C99 functions or macros in <stdlib.h> should be imported
+        in <cstdlib> in namespace std for C++11.])
+    fi
+
+    # Check for the existence in <wchar.h> of wcstold, etc.
+    if test x"$ac_has_wchar_h" = xyes &&
+       test x"$ac_has_wctype_h" = xyes; then
+      AC_MSG_CHECKING([for ISO C99 support in <wchar.h> for C++11])
+      AC_CACHE_VAL(glibcxx_cv_c99_wchar_cxx11, [
+        AC_TRY_COMPILE([#include <wchar.h>
+          namespace test
+          {
+            using ::wcstold;
+            using ::wcstoll;
+            using ::wcstoull;
+          }
+        ], [], [glibcxx_cv_c99_wchar_cxx11=yes], [glibcxx_cv_c99_wchar_cxx11=no])
+      ])
+
+      # Checks for wide character functions that may not be present.
+      # Injection of these is wrapped with guard macros.
+      # NB: only put functions here, instead of immediately above, if
+      # absolutely necessary.
+      AC_TRY_COMPILE([#include <wchar.h>
+        namespace test { using ::vfwscanf; }], [],
+        [AC_DEFINE(HAVE_VFWSCANF, 1, [Defined if vfwscanf exists.])], [])
+
+      AC_TRY_COMPILE([#include <wchar.h>
+        namespace test { using ::vswscanf; }], [],
+        [AC_DEFINE(HAVE_VSWSCANF, 1, [Defined if vswscanf exists.])], [])
+
+      AC_TRY_COMPILE([#include <wchar.h>
+        namespace test { using ::vwscanf; }], [],
+        [AC_DEFINE(HAVE_VWSCANF, 1, [Defined if vwscanf exists.])], [])
+
+      AC_TRY_COMPILE([#include <wchar.h>
+        namespace test { using ::wcstof; }], [],
+        [AC_DEFINE(HAVE_WCSTOF, 1, [Defined if wcstof exists.])], [])
+
+      AC_TRY_COMPILE([#include <wctype.h>],
+        [wint_t t; int i = iswblank(t);],
+        [AC_DEFINE(HAVE_ISWBLANK, 1, [Defined if iswblank exists.])], [])
+
+      AC_MSG_RESULT($glibcxx_cv_c99_wchar_cxx11)
+      if test x"$glibcxx_cv_c99_wchar_cxx11" = x"yes"; then
+        AC_DEFINE(_GLIBCXX11_USE_C99_WCHAR, 1,
+          [Define if C99 functions or macros in <wchar.h> should be imported
+          in <cwchar> in namespace std for C++11.])
+      fi
+    fi
+
+    gcc_no_link="$ac_save_gcc_no_link"
+    LIBS="$ac_save_LIBS"
+    CXXFLAGS="$ac_save_CXXFLAGS"
+    AC_LANG_RESTORE
   fi
 
   AC_MSG_CHECKING([for fully enabled ISO C99 support])
diff --git a/libstdc++-v3/config/locale/dragonfly/c_locale.h b/libstdc++-v3/config/locale/dragonfly/c_locale.h
index 5c17cfe..867a404 100644
--- a/libstdc++-v3/config/locale/dragonfly/c_locale.h
+++ b/libstdc++-v3/config/locale/dragonfly/c_locale.h
@@ -64,7 +64,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     __builtin_va_list __args;
     __builtin_va_start(__args, __fmt);
 
-#ifdef _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_STDIO
     const int __ret = __builtin_vsnprintf(__out, __size, __fmt, __args);
 #else
     const int __ret = __builtin_vsprintf(__out, __fmt, __args);
diff --git a/libstdc++-v3/config/locale/generic/c_locale.h b/libstdc++-v3/config/locale/generic/c_locale.h
index ee3ef86..fa7629f 100644
--- a/libstdc++-v3/config/locale/generic/c_locale.h
+++ b/libstdc++-v3/config/locale/generic/c_locale.h
@@ -70,7 +70,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     __builtin_va_list __args;
     __builtin_va_start(__args, __fmt);
 
-#ifdef _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_STDIO
     const int __ret = __builtin_vsnprintf(__out, __size, __fmt, __args);
 #else
     const int __ret = __builtin_vsprintf(__out, __fmt, __args);
diff --git a/libstdc++-v3/config/locale/gnu/c_locale.h b/libstdc++-v3/config/locale/gnu/c_locale.h
index a1dc3d2..f8ddfeb 100644
--- a/libstdc++-v3/config/locale/gnu/c_locale.h
+++ b/libstdc++-v3/config/locale/gnu/c_locale.h
@@ -88,7 +88,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     __builtin_va_list __args;
     __builtin_va_start(__args, __fmt);
 
-#ifdef _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_STDIO
     const int __ret = __builtin_vsnprintf(__out, __size, __fmt, __args);
 #else
     const int __ret = __builtin_vsprintf(__out, __fmt, __args);
diff --git a/libstdc++-v3/config/os/bsd/dragonfly/os_defines.h b/libstdc++-v3/config/os/bsd/dragonfly/os_defines.h
index 2209129..055c5b6 100644
--- a/libstdc++-v3/config/os/bsd/dragonfly/os_defines.h
+++ b/libstdc++-v3/config/os/bsd/dragonfly/os_defines.h
@@ -30,6 +30,9 @@
 // file will come before all others.
 
 #define _GLIBCXX_USE_C99 1
+#define _GLIBCXX_USE_C99_STDIO 1
+#define _GLIBCXX_USE_C99_STDLIB 1
+#define _GLIBCXX_USE_C99_WCHAR 1
 #define _GLIBCXX_USE_C99_CHECK 1
 #define _GLIBCXX_USE_C99_DYNAMIC (!(__ISO_C_VISIBLE >= 1999))
 #define _GLIBCXX_USE_C99_LONG_LONG_CHECK 1
diff --git a/libstdc++-v3/include/bits/basic_string.h b/libstdc++-v3/include/bits/basic_string.h
index 35246d9..b3853cd 100644
--- a/libstdc++-v3/include/bits/basic_string.h
+++ b/libstdc++-v3/include/bits/basic_string.h
@@ -5387,7 +5387,7 @@ _GLIBCXX_END_NAMESPACE_CXX11
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
 
-#if __cplusplus >= 201103L && defined(_GLIBCXX_USE_C99)
+#if __cplusplus >= 201103L
 
 #include <ext/string_conversions.h>
 
@@ -5396,6 +5396,7 @@ namespace std _GLIBCXX_VISIBILITY(default)
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
 _GLIBCXX_BEGIN_NAMESPACE_CXX11
 
+#if _GLIBCXX_USE_C99_STDLIB
   // 21.4 Numeric Conversions [string.conversions].
   inline int
   stoi(const string& __str, size_t* __idx = 0, int __base = 10)
@@ -5434,7 +5435,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
   inline long double
   stold(const string& __str, size_t* __idx = 0)
   { return __gnu_cxx::__stoa(&std::strtold, "stold", __str.c_str(), __idx); }
+#endif // _GLIBCXX_USE_C99_STDLIB
 
+#if _GLIBCXX_USE_C99_STDIO
   // NB: (v)snprintf vs sprintf.
 
   // DR 1261.
@@ -5498,8 +5501,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
     return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
 					   "%Lf", __val);
   }
+#endif // _GLIBCXX_USE_C99_STDIO
 
-#ifdef _GLIBCXX_USE_WCHAR_T
+#if defined(_GLIBCXX_USE_WCHAR_T) && defined(_GLIBCXX_USE_C99_WCHAR)
   inline int 
   stoi(const wstring& __str, size_t* __idx = 0, int __base = 10)
   { return __gnu_cxx::__stoa<long, int>(&std::wcstol, "stoi", __str.c_str(),
@@ -5601,13 +5605,13 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
 					    L"%Lf", __val);
   }
 #endif // _GLIBCXX_HAVE_BROKEN_VSWPRINTF
-#endif
+#endif // _GLIBCXX_USE_WCHAR_T && _GLIBCXX_USE_C99_WCHAR
 
 _GLIBCXX_END_NAMESPACE_CXX11
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
 
-#endif /* C++11 && _GLIBCXX_USE_C99 ... */
+#endif /* C++11 */
 
 #if __cplusplus >= 201103L
 
diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config
index 924f13e..6bcf842 100644
--- a/libstdc++-v3/include/bits/c++config
+++ b/libstdc++-v3/include/bits/c++config
@@ -529,4 +529,40 @@ namespace std
 #undef min
 #undef max
 
+// N.B. these _GLIBCXX_USE_C99_XXX macros are defined unconditionally
+// so they should be tested with #if not with #ifdef.
+#if __cplusplus >= 201103L
+# ifndef _GLIBCXX_USE_C99_MATH
+#  define _GLIBCXX_USE_C99_MATH _GLIBCXX11_USE_C99_MATH
+# endif
+# ifndef _GLIBCXX_USE_C99_COMPLEX
+# define _GLIBCXX_USE_C99_COMPLEX _GLIBCXX11_USE_C99_COMPLEX
+# endif
+# ifndef _GLIBCXX_USE_C99_CSTDIO
+# define _GLIBCXX_USE_C99_CSTDIO _GLIBCXX11_USE_C99_CSTDIO
+# endif
+# ifndef _GLIBCXX_USE_C99_CSTDLIB
+# define _GLIBCXX_USE_C99_CSTDLIB _GLIBCXX11_USE_C99_CSTDLIB
+# endif
+# ifndef _GLIBCXX_USE_C99_WCHAR
+# define _GLIBCXX_USE_C99_WCHAR _GLIBCXX11_USE_C99_WCHAR
+# endif
+#else
+# ifndef _GLIBCXX_USE_C99_MATH
+#  define _GLIBCXX_USE_C99_MATH _GLIBCXX98_USE_C99_MATH
+# endif
+# ifndef _GLIBCXX_USE_C99_COMPLEX
+# define _GLIBCXX_USE_C99_COMPLEX _GLIBCXX98_USE_C99_COMPLEX
+# endif
+# ifndef _GLIBCXX_USE_C99_CSTDIO
+# define _GLIBCXX_USE_C99_CSTDIO _GLIBCXX98_USE_C99_CSTDIO
+# endif
+# ifndef _GLIBCXX_USE_C99_CSTDLIB
+# define _GLIBCXX_USE_C99_CSTDLIB _GLIBCXX98_USE_C99_CSTDLIB
+# endif
+# ifndef _GLIBCXX_USE_C99_WCHAR
+# define _GLIBCXX_USE_C99_WCHAR _GLIBCXX98_USE_C99_WCHAR
+# endif
+#endif
+
 // End of prewritten config; the settings discovered at configure time follow.
diff --git a/libstdc++-v3/include/bits/locale_facets.tcc b/libstdc++-v3/include/bits/locale_facets.tcc
index bd58771..2db2d83 100644
--- a/libstdc++-v3/include/bits/locale_facets.tcc
+++ b/libstdc++-v3/include/bits/locale_facets.tcc
@@ -959,13 +959,13 @@ _GLIBCXX_BEGIN_NAMESPACE_LDBL
     }
 
   // The following code uses vsnprintf (or vsprintf(), when
-  // _GLIBCXX_USE_C99 is not defined) to convert floating point values
-  // for insertion into a stream.  An optimization would be to replace
-  // them with code that works directly on a wide buffer and then use
-  // __pad to do the padding.  It would be good to replace them anyway
-  // to gain back the efficiency that C++ provides by knowing up front
-  // the type of the values to insert.  Also, sprintf is dangerous
-  // since may lead to accidental buffer overruns.  This
+  // _GLIBCXX_USE_C99_STDIO is not defined) to convert floating point
+  // values for insertion into a stream.  An optimization would be to
+  // replace them with code that works directly on a wide buffer and
+  // then use __pad to do the padding.  It would be good to replace
+  // them anyway to gain back the efficiency that C++ provides by
+  // knowing up front the type of the values to insert.  Also, sprintf
+  // is dangerous since may lead to accidental buffer overruns.  This
   // implementation follows the C++ standard fairly directly as
   // outlined in 22.2.2.2 [lib.locale.num.put]
   template<typename _CharT, typename _OutIter>
@@ -992,7 +992,7 @@ _GLIBCXX_BEGIN_NAMESPACE_LDBL
 	char __fbuf[16];
 	__num_base::_S_format_float(__io, __fbuf, __mod);
 
-#ifdef _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_STDIO
 	// Precision is always used except for hexfloat format.
 	const bool __use_prec =
 	  (__io.flags() & ios_base::floatfield) != ios_base::floatfield;
diff --git a/libstdc++-v3/include/bits/locale_facets_nonio.tcc b/libstdc++-v3/include/bits/locale_facets_nonio.tcc
index 2e73b5d..631ef53 100644
--- a/libstdc++-v3/include/bits/locale_facets_nonio.tcc
+++ b/libstdc++-v3/include/bits/locale_facets_nonio.tcc
@@ -578,7 +578,7 @@ _GLIBCXX_BEGIN_NAMESPACE_LDBL_OR_CXX11
     {
       const locale __loc = __io.getloc();
       const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
-#ifdef _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_STDIO
       // First try a buffer perhaps big enough.
       int __cs_size = 64;
       char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
@@ -751,7 +751,7 @@ _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
 		case 'S':
 		  // Seconds. [tm_sec]
 		  // [00, 60] in C99 (one leap-second), [00, 61] in C89.
-#ifdef _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99
 		  __beg = _M_extract_num(__beg, __end, __tm->tm_sec, 0, 60, 2,
 #else
 		  __beg = _M_extract_num(__beg, __end, __tm->tm_sec, 0, 61, 2,
diff --git a/libstdc++-v3/include/c_compatibility/math.h b/libstdc++-v3/include/c_compatibility/math.h
index d6acb6d..7729896 100644
--- a/libstdc++-v3/include/c_compatibility/math.h
+++ b/libstdc++-v3/include/c_compatibility/math.h
@@ -56,7 +56,7 @@ using std::fabs;
 using std::floor;
 using std::fmod;
 
-#if _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_MATH
 using std::fpclassify;
 using std::isfinite;
 using std::isinf;
diff --git a/libstdc++-v3/include/c_compatibility/wchar.h b/libstdc++-v3/include/c_compatibility/wchar.h
index 06b5d47..3bc12d0 100644
--- a/libstdc++-v3/include/c_compatibility/wchar.h
+++ b/libstdc++-v3/include/c_compatibility/wchar.h
@@ -103,7 +103,7 @@ using std::wmemmove;
 using std::wmemset;
 using std::wcsftime;
 
-#if _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_WCHAR
 using std::wcstold;
 using std::wcstoll;
 using std::wcstoull;
diff --git a/libstdc++-v3/include/c_global/cstdio b/libstdc++-v3/include/c_global/cstdio
index d1c958b..486cee9 100644
--- a/libstdc++-v3/include/c_global/cstdio
+++ b/libstdc++-v3/include/c_global/cstdio
@@ -146,7 +146,7 @@ namespace std
   using ::vsprintf;
 } // namespace
 
-#if _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_STDIO
 
 #undef snprintf
 #undef vfscanf
@@ -189,6 +189,6 @@ namespace std
   using ::__gnu_cxx::vsscanf;
 } // namespace std
 
-#endif // _GLIBCXX_USE_C99
+#endif // _GLIBCXX_USE_C99_STDIO
 
 #endif
diff --git a/libstdc++-v3/include/c_global/cstdlib b/libstdc++-v3/include/c_global/cstdlib
index 7e9bb30..a2f44fc 100644
--- a/libstdc++-v3/include/c_global/cstdlib
+++ b/libstdc++-v3/include/c_global/cstdlib
@@ -195,7 +195,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
 
-#if _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_STDLIB
 
 #undef _Exit
 #undef llabs
@@ -266,7 +266,7 @@ namespace std
   using ::__gnu_cxx::strtold;
 } // namespace std
 
-#endif // _GLIBCXX_USE_C99
+#endif // _GLIBCXX_USE_C99_STDLIB
 
 #endif // !_GLIBCXX_HOSTED
 
diff --git a/libstdc++-v3/include/c_global/cwchar b/libstdc++-v3/include/c_global/cwchar
index dddb409..1571463 100644
--- a/libstdc++-v3/include/c_global/cwchar
+++ b/libstdc++-v3/include/c_global/cwchar
@@ -232,7 +232,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
 
-#if _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_WCHAR
 
 #undef wcstold
 #undef wcstoll
@@ -289,7 +289,7 @@ namespace std
   using std::vwscanf;
 #endif
 
-#if _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_WCHAR
   using std::wcstold;
   using std::wcstoll;
   using std::wcstoull;
diff --git a/libstdc++-v3/include/c_std/cstdio b/libstdc++-v3/include/c_std/cstdio
index 37f01ca..b7860f9 100644
--- a/libstdc++-v3/include/c_std/cstdio
+++ b/libstdc++-v3/include/c_std/cstdio
@@ -144,7 +144,7 @@ namespace std
   using ::vsprintf;
 } // namespace std
 
-#if _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_STDIO
 
 #undef snprintf
 #undef vfscanf
diff --git a/libstdc++-v3/include/c_std/cstdlib b/libstdc++-v3/include/c_std/cstdlib
index 0bd7058..7b69884 100644
--- a/libstdc++-v3/include/c_std/cstdlib
+++ b/libstdc++-v3/include/c_std/cstdlib
@@ -192,7 +192,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
 
-#if _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_STDLIB
 
 #undef _Exit
 #undef llabs
@@ -263,7 +263,7 @@ namespace std
   using ::__gnu_cxx::strtold;
 } // namespace std
 
-#endif // _GLIBCXX_USE_C99
+#endif // _GLIBCXX_USE_C99_STDLIB
 
 #endif // !_GLIBCXX_HOSTED
 
diff --git a/libstdc++-v3/include/c_std/cwchar b/libstdc++-v3/include/c_std/cwchar
index aa1b2fa..5aade7f 100644
--- a/libstdc++-v3/include/c_std/cwchar
+++ b/libstdc++-v3/include/c_std/cwchar
@@ -228,7 +228,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
 
-#if _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_WCHAR
 
 #undef wcstold
 #undef wcstoll
diff --git a/libstdc++-v3/include/ext/vstring.h b/libstdc++-v3/include/ext/vstring.h
index 68acd57..8732bd3 100644
--- a/libstdc++-v3/include/ext/vstring.h
+++ b/libstdc++-v3/include/ext/vstring.h
@@ -2680,7 +2680,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
 
-#if ((__cplusplus >= 201103L) && defined(_GLIBCXX_USE_C99))
+#if __cplusplus >= 201103L
 
 #include <ext/string_conversions.h>
 
@@ -2688,6 +2688,7 @@ namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
+#if _GLIBCXX_USE_C99_STDLIB
   // 21.4 Numeric Conversions [string.conversions].
   inline int
   stoi(const __vstring& __str, std::size_t* __idx = 0, int __base = 10)
@@ -2726,7 +2727,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   inline long double
   stold(const __vstring& __str, std::size_t* __idx = 0)
   { return __gnu_cxx::__stoa(&std::strtold, "stold", __str.c_str(), __idx); }
+#endif // _GLIBCXX_USE_C99_STDLIB
 
+#if _GLIBCXX_USE_C99_STDIO
   // NB: (v)snprintf vs sprintf.
 
   // DR 1261.
@@ -2789,8 +2792,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     return __gnu_cxx::__to_xstring<__vstring>(&std::vsnprintf, __n,
 					      "%Lf", __val);
   }
+#endif // _GLIBCXX_USE_C99_STDIO
 
-#ifdef _GLIBCXX_USE_WCHAR_T
+#if defined(_GLIBCXX_USE_WCHAR_T) && defined(_GLIBCXX_USE_C99_WCHAR)
   inline int 
   stoi(const __wvstring& __str, std::size_t* __idx = 0, int __base = 10)
   { return __gnu_cxx::__stoa<long, int>(&std::wcstol, "stoi", __str.c_str(),
@@ -2890,8 +2894,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     return __gnu_cxx::__to_xstring<__wvstring>(&std::vswprintf, __n,
 					       L"%Lf", __val);
   }
-#endif
-#endif
+#endif // _GLIBCXX_HAVE_BROKEN_VSWPRINTF
+#endif // _GLIBCXX_USE_WCHAR_T && _GLIBCXX_USE_C99_WCHAR
 
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
diff --git a/libstdc++-v3/include/std/complex b/libstdc++-v3/include/std/complex
index 5ed4fd5..f1d3b79 100644
--- a/libstdc++-v3/include/std/complex
+++ b/libstdc++-v3/include/std/complex
@@ -995,7 +995,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     complex<_Tp>
     pow(const complex<_Tp>& __x, const _Tp& __y)
     {
-#ifndef _GLIBCXX_USE_C99_COMPLEX
+#if ! _GLIBCXX_USE_C99_COMPLEX
       if (__x == _Tp())
 	return _Tp();
 #endif
@@ -1831,7 +1831,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     arg(_Tp __x)
     {
       typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
-#if (_GLIBCXX_USE_C99_MATH && !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC)
+#if (_GLIBCXX11_USE_C99_MATH && !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC)
       return std::signbit(__x) ? __type(3.1415926535897932384626433832795029L)
 	                       : __type();
 #else
diff --git a/libstdc++-v3/include/tr1/cstdio b/libstdc++-v3/include/tr1/cstdio
index 7681823..b8fc04f 100644
--- a/libstdc++-v3/include/tr1/cstdio
+++ b/libstdc++-v3/include/tr1/cstdio
@@ -33,7 +33,7 @@
 
 #include <cstdio>
 
-#if _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_STDIO
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
diff --git a/libstdc++-v3/include/tr1/cstdlib b/libstdc++-v3/include/tr1/cstdlib
index c3c65eb..35a9133 100644
--- a/libstdc++-v3/include/tr1/cstdlib
+++ b/libstdc++-v3/include/tr1/cstdlib
@@ -35,7 +35,7 @@
 
 #if _GLIBCXX_HOSTED
 
-#if _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_STDLIB
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
@@ -65,7 +65,7 @@ namespace tr1
 }
 }
 
-#endif // _GLIBCXX_USE_C99 
+#endif // _GLIBCXX_USE_C99_STDLIB
 
 #endif // _GLIBCXX_HOSTED
 
diff --git a/libstdc++-v3/include/tr1/cwchar b/libstdc++-v3/include/tr1/cwchar
index 10772ee..0db2262 100644
--- a/libstdc++-v3/include/tr1/cwchar
+++ b/libstdc++-v3/include/tr1/cwchar
@@ -52,7 +52,7 @@ namespace tr1
   using std::vwscanf;
 #endif
 
-#if _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_WCHAR
   using std::wcstold;
   using std::wcstoll;
   using std::wcstoull;
diff --git a/libstdc++-v3/include/tr1/stdlib.h b/libstdc++-v3/include/tr1/stdlib.h
index 310c7bc..5e826d6 100644
--- a/libstdc++-v3/include/tr1/stdlib.h
+++ b/libstdc++-v3/include/tr1/stdlib.h
@@ -33,7 +33,7 @@
 
 #if _GLIBCXX_HOSTED
 
-#if _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_STDLIB
 
 using std::tr1::atoll;
 using std::tr1::strtoll;
diff --git a/libstdc++-v3/src/c++98/locale_facets.cc b/libstdc++-v3/src/c++98/locale_facets.cc
index 071f79e..28b6f3a 100644
--- a/libstdc++-v3/src/c++98/locale_facets.cc
+++ b/libstdc++-v3/src/c++98/locale_facets.cc
@@ -72,7 +72,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
     ios_base::fmtflags __fltfield = __flags & ios_base::floatfield;
 
-#ifdef _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_STDIO
     // Precision is always used except for hexfloat format.
     if (__fltfield != (ios_base::fixed | ios_base::scientific))
 #endif
@@ -89,7 +89,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       *__fptr++ = 'f';
     else if (__fltfield == ios_base::scientific)
       *__fptr++ = (__flags & ios_base::uppercase) ? 'E' : 'e';
-#ifdef _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_STDIO
     else if (__fltfield == (ios_base::fixed | ios_base::scientific))
       *__fptr++ = (__flags & ios_base::uppercase) ? 'A' : 'a';
 #endif
diff --git a/libstdc++-v3/testsuite/18_support/exception_ptr/60612-terminate.cc b/libstdc++-v3/testsuite/18_support/exception_ptr/60612-terminate.cc
index 5f0a4bf..1a53c06 100644
--- a/libstdc++-v3/testsuite/18_support/exception_ptr/60612-terminate.cc
+++ b/libstdc++-v3/testsuite/18_support/exception_ptr/60612-terminate.cc
@@ -23,7 +23,7 @@
 #include <exception>
 #include <stdlib.h>
 
-#ifdef _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_STDLIB
 void terminate() { _Exit(0); }
 
 void f() noexcept
@@ -39,7 +39,7 @@ void f() noexcept
 
 int main()
 {
-#ifdef _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_STDLIB
   f();
 #endif
   return 0;
diff --git a/libstdc++-v3/testsuite/18_support/exception_ptr/60612-unexpected.cc b/libstdc++-v3/testsuite/18_support/exception_ptr/60612-unexpected.cc
index ed3930a..3f8e08d 100644
--- a/libstdc++-v3/testsuite/18_support/exception_ptr/60612-unexpected.cc
+++ b/libstdc++-v3/testsuite/18_support/exception_ptr/60612-unexpected.cc
@@ -23,7 +23,7 @@
 #include <exception>
 #include <stdlib.h>
 
-#ifdef _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_STDLIB
 void unexpected() { _Exit(0); }
 
 void f() throw()
@@ -39,7 +39,7 @@ void f() throw()
 
 int main()
 {
-#ifdef _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_STDLIB
   f();
 #endif
 }
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stod.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stod.cc
index c270d76..ea284cc 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stod.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stod.cc
@@ -29,7 +29,7 @@
 void
 test01()
 {
-#ifdef _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_WCHAR
 
   bool test __attribute__((unused)) = false;
   using namespace std;
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stof.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stof.cc
index 2bb7aea..fd54d57 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stof.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stof.cc
@@ -29,7 +29,7 @@
 void
 test01()
 {
-#ifdef _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_WCHAR
 
   bool test __attribute__((unused)) = false;
   using namespace std;
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoi.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoi.cc
index 24aceb6..8cd0ea1 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoi.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoi.cc
@@ -29,7 +29,7 @@
 void
 test01()
 {
-#ifdef _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_WCHAR
 
   bool test __attribute__((unused)) = false;
   using namespace std;
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stol.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stol.cc
index bc50156..9be3f39 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stol.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stol.cc
@@ -29,7 +29,7 @@
 void
 test01()
 {
-#ifdef _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_WCHAR
 
   bool test __attribute__((unused)) = false;
   using namespace std;
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stold.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stold.cc
index 1461adb..7d9e414 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stold.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stold.cc
@@ -29,7 +29,7 @@
 void
 test01()
 {
-#ifdef _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_WCHAR
 
   bool test __attribute__((unused)) = false;
   using namespace std;
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoll.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoll.cc
index cc91c24..2927da3 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoll.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoll.cc
@@ -29,7 +29,7 @@
 void
 test01()
 {
-#ifdef _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_WCHAR
 
   bool test __attribute__((unused)) = false;
   using namespace std;
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoul.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoul.cc
index 6c26c2bb..256cee5 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoul.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoul.cc
@@ -29,7 +29,7 @@
 void
 test01()
 {
-#ifdef _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_WCHAR
 
   bool test __attribute__((unused)) = false;
   using namespace std;
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoull.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoull.cc
index 91b6479..e102c6a 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoull.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoull.cc
@@ -29,7 +29,7 @@
 void
 test01()
 {
-#ifdef _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_WCHAR
 
   bool test __attribute__((unused)) = false;
   using namespace std;
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/to_wstring.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/to_wstring.cc
index e36c30e..467bd9f 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/to_wstring.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/to_wstring.cc
@@ -27,7 +27,7 @@
 void
 test01()
 {
-#ifdef _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_WCHAR
 
   bool test __attribute__((unused)) = true;
   using namespace std;
diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cstdlib/13943.cc b/libstdc++-v3/testsuite/26_numerics/headers/cstdlib/13943.cc
index 33f8000..50c6b32 100644
--- a/libstdc++-v3/testsuite/26_numerics/headers/cstdlib/13943.cc
+++ b/libstdc++-v3/testsuite/26_numerics/headers/cstdlib/13943.cc
@@ -19,7 +19,7 @@
 #include <cstdlib>
 #include <testsuite_hooks.h>
 
-#if _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_STDLIB
 // libstdc++/13943
 void test01()
 {
@@ -36,7 +36,7 @@ void test01()
 
 int main()
 {
-#if _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_STDLIB
   test01();
 #endif
   return 0;
diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cstdlib/types_std_c++0x.cc b/libstdc++-v3/testsuite/26_numerics/headers/cstdlib/types_std_c++0x.cc
index 0511043..bfcbe9a 100644
--- a/libstdc++-v3/testsuite/26_numerics/headers/cstdlib/types_std_c++0x.cc
+++ b/libstdc++-v3/testsuite/26_numerics/headers/cstdlib/types_std_c++0x.cc
@@ -24,10 +24,10 @@
 
 void test01()
 {
-#if _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_STDLIB
 
   typedef std::lldiv_t     my_lldiv_t;
-  
+
 #endif
 }
 
diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp b/libstdc++-v3/testsuite/lib/libstdc++.exp
index 9a6726c..6bb4d61 100644
--- a/libstdc++-v3/testsuite/lib/libstdc++.exp
+++ b/libstdc++-v3/testsuite/lib/libstdc++.exp
@@ -1614,7 +1614,7 @@ proc check_v3_target_string_conversions { } {
 
         set f [open $src "w"]
         puts $f "#include <bits/c++config.h>"
-        puts $f "#if !defined(_GLIBCXX_USE_C99) || defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF)"
+        puts $f "#if !(defined(_GLIBCXX_USE_C99_STDIO) && defined(_GLIBCXX_USE_C99_STDLIB) && defined(_GLIBCXX_USE_C99_WCHAR)) || defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF)"
         puts $f "#  error No string conversions"
         puts $f "#endif"
         close $f
diff --git a/libstdc++-v3/testsuite/tr1/8_c_compatibility/cmath/templates.cc b/libstdc++-v3/testsuite/tr1/8_c_compatibility/cmath/templates.cc
index b75fda2..ac8933c 100644
--- a/libstdc++-v3/testsuite/tr1/8_c_compatibility/cmath/templates.cc
+++ b/libstdc++-v3/testsuite/tr1/8_c_compatibility/cmath/templates.cc
@@ -23,7 +23,7 @@
 
 #include <tr1/cmath>
 
-#if _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_MATH
 #if !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC
 
 template<typename T>
diff --git a/libstdc++-v3/testsuite/tr1/8_c_compatibility/cstdio/functions.cc b/libstdc++-v3/testsuite/tr1/8_c_compatibility/cstdio/functions.cc
index 0c913e0..5a9eb6c 100644
--- a/libstdc++-v3/testsuite/tr1/8_c_compatibility/cstdio/functions.cc
+++ b/libstdc++-v3/testsuite/tr1/8_c_compatibility/cstdio/functions.cc
@@ -30,7 +30,7 @@ void test01(int dummy, ...)
   std::va_list ap;
   va_start(ap, dummy);
 
-#if _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_STDIO
 
   char* s = 0;
   const char* cs = 0;
diff --git a/libstdc++-v3/testsuite/tr1/8_c_compatibility/cstdlib/functions.cc b/libstdc++-v3/testsuite/tr1/8_c_compatibility/cstdlib/functions.cc
index cfa748d..dfa08ef 100644
--- a/libstdc++-v3/testsuite/tr1/8_c_compatibility/cstdlib/functions.cc
+++ b/libstdc++-v3/testsuite/tr1/8_c_compatibility/cstdlib/functions.cc
@@ -27,7 +27,7 @@
 
 void test01()
 {
-#if _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_STDLIB
 
   long long i = 0;
   const char* s = 0;
diff --git a/libstdc++-v3/testsuite/tr1/8_c_compatibility/cstdlib/types_std_tr1.cc b/libstdc++-v3/testsuite/tr1/8_c_compatibility/cstdlib/types_std_tr1.cc
index 002b6a5..1252463 100644
--- a/libstdc++-v3/testsuite/tr1/8_c_compatibility/cstdlib/types_std_tr1.cc
+++ b/libstdc++-v3/testsuite/tr1/8_c_compatibility/cstdlib/types_std_tr1.cc
@@ -27,10 +27,10 @@
 
 void test01()
 {
-#if _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_STDLIB
 
   typedef std::tr1::lldiv_t     my_lldiv_t;
-  
+
 #endif
 }
 
diff --git a/libstdc++-v3/testsuite/tr1/8_c_compatibility/cwchar/functions.cc b/libstdc++-v3/testsuite/tr1/8_c_compatibility/cwchar/functions.cc
index b964661..c745b19 100644
--- a/libstdc++-v3/testsuite/tr1/8_c_compatibility/cwchar/functions.cc
+++ b/libstdc++-v3/testsuite/tr1/8_c_compatibility/cwchar/functions.cc
@@ -67,7 +67,7 @@ void test01(int dummy, ...)
   ret3 = ret3; // Suppress unused warning.
 #endif
 
-#if _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_WCHAR
 
   const wchar_t* nptr2 = 0;
   wchar_t** endptr2 = 0;
diff --git a/libstdc++-v3/testsuite/util/testsuite_fs.h b/libstdc++-v3/testsuite/util/testsuite_fs.h
index 44aef11..ddcbdcc 100644
--- a/libstdc++-v3/testsuite/util/testsuite_fs.h
+++ b/libstdc++-v3/testsuite/util/testsuite_fs.h
@@ -83,7 +83,7 @@ namespace __gnu_test
     p = tmp;
 #else
     char buf[64];
-#if _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_STDIO
     std::snprintf(buf, 64, "filesystem-ts-test.%lu", (unsigned long)::getpid());
 #else
     std::sprintf(buf, "filesystem-ts-test.%lu", (unsigned long)::getpid());

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] Enable libstdc++ numeric conversions on Cygwin
  2015-11-12 13:40       ` Jonathan Wakely
@ 2015-11-12 14:50         ` Jonathan Wakely
  2015-11-12 17:25           ` Jennifer Yao
  2015-11-12 22:56         ` Andreas Tobler
  2015-11-13 14:52         ` Jonathan Wakely
  2 siblings, 1 reply; 20+ messages in thread
From: Jonathan Wakely @ 2015-11-12 14:50 UTC (permalink / raw)
  To: Jennifer Yao; +Cc: libstdc++, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 1120 bytes --]

On 12/11/15 13:39 +0000, Jonathan Wakely wrote:
>One downside of this change is that we introduce some (hopefully safe)
>ODR violations, where inline functions and templates that depend on
>_GLIBCXX_USE_C99_FOO might now be defined differently in C++98 and
>C++11 code. Previously they had the same definition, even though in
>C++11 mode the value of the _GLIBCXX_USE_C99_FOO macro might have been
>sub-optimal (i.e. the C99 features were usable, but the macro said
>they weren't). Those ODR violatiosn could be avoided if needed, by
>always using the _GLIBCXX98_USE_C99_FOO macro in code that can be
>included from either C++98 or C++11. We could still use the
>_GLIBCXX11_USE_C99_FOO macro in pure C++11 code (such as the numeric
>conversion functions) and get most of the benefit of this change.

This patch (relative to the previous one) would avoid the ODR
problems, by only using the C++98 macro in code that gets used in
C++98 and later, and using the _GLIBCXX11_XXX ones in code that is
never compiled as C++98 (specifically, the numeric conversion
functions).

Maybe this is a safer, more conservative change.


[-- Attachment #2: patch.txt --]
[-- Type: text/x-patch, Size: 7471 bytes --]

diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
index deefa04..11dee8e 100644
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -960,7 +960,7 @@ AC_DEFUN([GLIBCXX_ENABLE_C99], [
     ])
     AC_MSG_RESULT($glibcxx_cv_c99_math_cxx98)
     if test x"$glibcxx_cv_c99_math_cxx98" = x"yes"; then
-      AC_DEFINE(_GLIBCXX98_USE_C99_MATH, 1,
+      AC_DEFINE(_GLIBCXX_USE_C99_MATH, 1,
         [Define if C99 functions or macros in <math.h> should be imported
         in <cmath> in namespace std for C++98.])
     fi
@@ -1029,7 +1029,7 @@ AC_DEFUN([GLIBCXX_ENABLE_C99], [
     fi
     AC_MSG_RESULT($glibcxx_cv_c99_complex_cxx98)
     if test x"$glibcxx_cv_c99_complex_cxx98" = x"yes"; then
-      AC_DEFINE(_GLIBCXX98_USE_C99_COMPLEX, 1,
+      AC_DEFINE(_GLIBCXX_USE_C99_COMPLEX, 1,
         [Define if C99 functions in <complex.h> should be used in
         <complex> for C++98. Using compiler builtins for these functions
         requires corresponding C99 library functions to be present.])
@@ -1054,7 +1054,7 @@ AC_DEFUN([GLIBCXX_ENABLE_C99], [
     ])
     AC_MSG_RESULT($glibcxx_cv_c99_stdio_cxx98)
     if test x"$glibcxx_cv_c99_stdio_cxx98" = x"yes"; then
-      AC_DEFINE(_GLIBCXX98_USE_C99_STDIO, 1,
+      AC_DEFINE(_GLIBCXX_USE_C99_STDIO, 1,
         [Define if C99 functions or macros in <stdio.h> should be imported
         in <cstdio> in namespace std for C++98.])
     fi
@@ -1100,7 +1100,7 @@ AC_DEFUN([GLIBCXX_ENABLE_C99], [
 
       AC_MSG_RESULT($glibcxx_cv_c99_wchar_cxx98)
       if test x"$glibcxx_cv_c99_wchar_cxx98" = x"yes"; then
-        AC_DEFINE(_GLIBCXX98_USE_C99_WCHAR, 1,
+        AC_DEFINE(_GLIBCXX_USE_C99_WCHAR, 1,
           [Define if C99 functions or macros in <wchar.h> should be imported
           in <cwchar> in namespace std for C++98.])
       fi
diff --git a/libstdc++-v3/config/os/bsd/dragonfly/os_defines.h b/libstdc++-v3/config/os/bsd/dragonfly/os_defines.h
index 055c5b6..b21726f 100644
--- a/libstdc++-v3/config/os/bsd/dragonfly/os_defines.h
+++ b/libstdc++-v3/config/os/bsd/dragonfly/os_defines.h
@@ -37,5 +37,8 @@
 #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)
+#define _GLIBCXX11_USE_C99_STDIO 1
+#define _GLIBCXX11_USE_C99_STDLIB 1
+#define _GLIBCXX11_USE_C99_WCHAR 1
 
 #endif
diff --git a/libstdc++-v3/include/bits/basic_string.h b/libstdc++-v3/include/bits/basic_string.h
index b3853cd..2fa345a 100644
--- a/libstdc++-v3/include/bits/basic_string.h
+++ b/libstdc++-v3/include/bits/basic_string.h
@@ -5396,7 +5396,7 @@ namespace std _GLIBCXX_VISIBILITY(default)
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
 _GLIBCXX_BEGIN_NAMESPACE_CXX11
 
-#if _GLIBCXX_USE_C99_STDLIB
+#if _GLIBCXX11_USE_C99_STDLIB
   // 21.4 Numeric Conversions [string.conversions].
   inline int
   stoi(const string& __str, size_t* __idx = 0, int __base = 10)
@@ -5435,9 +5435,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
   inline long double
   stold(const string& __str, size_t* __idx = 0)
   { return __gnu_cxx::__stoa(&std::strtold, "stold", __str.c_str(), __idx); }
-#endif // _GLIBCXX_USE_C99_STDLIB
+#endif // _GLIBCXX11_USE_C99_STDLIB
 
-#if _GLIBCXX_USE_C99_STDIO
+#if _GLIBCXX11_USE_C99_STDIO
   // NB: (v)snprintf vs sprintf.
 
   // DR 1261.
@@ -5501,9 +5501,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
     return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
 					   "%Lf", __val);
   }
-#endif // _GLIBCXX_USE_C99_STDIO
+#endif // _GLIBCXX11_USE_C99_STDIO
 
-#if defined(_GLIBCXX_USE_WCHAR_T) && defined(_GLIBCXX_USE_C99_WCHAR)
+#if defined(_GLIBCXX_USE_WCHAR_T) && defined(_GLIBCXX11_USE_C99_WCHAR)
   inline int 
   stoi(const wstring& __str, size_t* __idx = 0, int __base = 10)
   { return __gnu_cxx::__stoa<long, int>(&std::wcstol, "stoi", __str.c_str(),
@@ -5605,7 +5605,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
 					    L"%Lf", __val);
   }
 #endif // _GLIBCXX_HAVE_BROKEN_VSWPRINTF
-#endif // _GLIBCXX_USE_WCHAR_T && _GLIBCXX_USE_C99_WCHAR
+#endif // _GLIBCXX_USE_WCHAR_T && _GLIBCXX11_USE_C99_WCHAR
 
 _GLIBCXX_END_NAMESPACE_CXX11
 _GLIBCXX_END_NAMESPACE_VERSION
diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config
index 6bcf842..924f13e 100644
--- a/libstdc++-v3/include/bits/c++config
+++ b/libstdc++-v3/include/bits/c++config
@@ -529,40 +529,4 @@ namespace std
 #undef min
 #undef max
 
-// N.B. these _GLIBCXX_USE_C99_XXX macros are defined unconditionally
-// so they should be tested with #if not with #ifdef.
-#if __cplusplus >= 201103L
-# ifndef _GLIBCXX_USE_C99_MATH
-#  define _GLIBCXX_USE_C99_MATH _GLIBCXX11_USE_C99_MATH
-# endif
-# ifndef _GLIBCXX_USE_C99_COMPLEX
-# define _GLIBCXX_USE_C99_COMPLEX _GLIBCXX11_USE_C99_COMPLEX
-# endif
-# ifndef _GLIBCXX_USE_C99_CSTDIO
-# define _GLIBCXX_USE_C99_CSTDIO _GLIBCXX11_USE_C99_CSTDIO
-# endif
-# ifndef _GLIBCXX_USE_C99_CSTDLIB
-# define _GLIBCXX_USE_C99_CSTDLIB _GLIBCXX11_USE_C99_CSTDLIB
-# endif
-# ifndef _GLIBCXX_USE_C99_WCHAR
-# define _GLIBCXX_USE_C99_WCHAR _GLIBCXX11_USE_C99_WCHAR
-# endif
-#else
-# ifndef _GLIBCXX_USE_C99_MATH
-#  define _GLIBCXX_USE_C99_MATH _GLIBCXX98_USE_C99_MATH
-# endif
-# ifndef _GLIBCXX_USE_C99_COMPLEX
-# define _GLIBCXX_USE_C99_COMPLEX _GLIBCXX98_USE_C99_COMPLEX
-# endif
-# ifndef _GLIBCXX_USE_C99_CSTDIO
-# define _GLIBCXX_USE_C99_CSTDIO _GLIBCXX98_USE_C99_CSTDIO
-# endif
-# ifndef _GLIBCXX_USE_C99_CSTDLIB
-# define _GLIBCXX_USE_C99_CSTDLIB _GLIBCXX98_USE_C99_CSTDLIB
-# endif
-# ifndef _GLIBCXX_USE_C99_WCHAR
-# define _GLIBCXX_USE_C99_WCHAR _GLIBCXX98_USE_C99_WCHAR
-# endif
-#endif
-
 // End of prewritten config; the settings discovered at configure time follow.
diff --git a/libstdc++-v3/include/ext/vstring.h b/libstdc++-v3/include/ext/vstring.h
index 8732bd3..36122d4 100644
--- a/libstdc++-v3/include/ext/vstring.h
+++ b/libstdc++-v3/include/ext/vstring.h
@@ -2688,7 +2688,7 @@ namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
-#if _GLIBCXX_USE_C99_STDLIB
+#if _GLIBCXX11_USE_C99_STDLIB
   // 21.4 Numeric Conversions [string.conversions].
   inline int
   stoi(const __vstring& __str, std::size_t* __idx = 0, int __base = 10)
@@ -2727,9 +2727,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   inline long double
   stold(const __vstring& __str, std::size_t* __idx = 0)
   { return __gnu_cxx::__stoa(&std::strtold, "stold", __str.c_str(), __idx); }
-#endif // _GLIBCXX_USE_C99_STDLIB
+#endif // _GLIBCXX11_USE_C99_STDLIB
 
-#if _GLIBCXX_USE_C99_STDIO
+#if _GLIBCXX11_USE_C99_STDIO
   // NB: (v)snprintf vs sprintf.
 
   // DR 1261.
@@ -2792,9 +2792,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     return __gnu_cxx::__to_xstring<__vstring>(&std::vsnprintf, __n,
 					      "%Lf", __val);
   }
-#endif // _GLIBCXX_USE_C99_STDIO
+#endif // _GLIBCXX11_USE_C99_STDIO
 
-#if defined(_GLIBCXX_USE_WCHAR_T) && defined(_GLIBCXX_USE_C99_WCHAR)
+#if defined(_GLIBCXX_USE_WCHAR_T) && defined(_GLIBCXX11_USE_C99_WCHAR)
   inline int 
   stoi(const __wvstring& __str, std::size_t* __idx = 0, int __base = 10)
   { return __gnu_cxx::__stoa<long, int>(&std::wcstol, "stoi", __str.c_str(),
@@ -2895,7 +2895,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 					       L"%Lf", __val);
   }
 #endif // _GLIBCXX_HAVE_BROKEN_VSWPRINTF
-#endif // _GLIBCXX_USE_WCHAR_T && _GLIBCXX_USE_C99_WCHAR
+#endif // _GLIBCXX_USE_WCHAR_T && _GLIBCXX11_USE_C99_WCHAR
 
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] Enable libstdc++ numeric conversions on Cygwin
  2015-11-12 14:50         ` Jonathan Wakely
@ 2015-11-12 17:25           ` Jennifer Yao
  2015-11-12 17:56             ` Jonathan Wakely
  0 siblings, 1 reply; 20+ messages in thread
From: Jennifer Yao @ 2015-11-12 17:25 UTC (permalink / raw)
  To: Jonathan Wakely; +Cc: libstdc++, gcc-patches

> On 12/11/15 13:39 +0000, Jonathan Wakely wrote:
>>
>> One downside of this change is that we introduce some (hopefully safe)
>> ODR violations, where inline functions and templates that depend on
>> _GLIBCXX_USE_C99_FOO might now be defined differently in C++98 and
>> C++11 code. Previously they had the same definition, even though in
>> C++11 mode the value of the _GLIBCXX_USE_C99_FOO macro might have been
>> sub-optimal (i.e. the C99 features were usable, but the macro said
>> they weren't). Those ODR violatiosn could be avoided if needed, by
>> always using the _GLIBCXX98_USE_C99_FOO macro in code that can be
>> included from either C++98 or C++11. We could still use the
>> _GLIBCXX11_USE_C99_FOO macro in pure C++11 code (such as the numeric
>> conversion functions) and get most of the benefit of this change.
>
>
> This patch (relative to the previous one) would avoid the ODR
> problems, by only using the C++98 macro in code that gets used in
> C++98 and later, and using the _GLIBCXX11_XXX ones in code that is
> never compiled as C++98 (specifically, the numeric conversion
> functions).
>
> Maybe this is a safer, more conservative change.

I haven't tested either of your patches yet (the testsuite runs
reeeeally slowly on Cygwin T___T), but I just wanted to express my
approval of the proposed changes (more specifically, the second patch
you posted).

Also, I was not aware that we had to worry about C++03 compatibility.
Sounds tedious.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] Enable libstdc++ numeric conversions on Cygwin
  2015-11-12 17:25           ` Jennifer Yao
@ 2015-11-12 17:56             ` Jonathan Wakely
  0 siblings, 0 replies; 20+ messages in thread
From: Jonathan Wakely @ 2015-11-12 17:56 UTC (permalink / raw)
  To: Jennifer Yao; +Cc: libstdc++, gcc-patches

On 12/11/15 12:24 -0500, Jennifer Yao wrote:
>> On 12/11/15 13:39 +0000, Jonathan Wakely wrote:
>>>
>>> One downside of this change is that we introduce some (hopefully safe)
>>> ODR violations, where inline functions and templates that depend on
>>> _GLIBCXX_USE_C99_FOO might now be defined differently in C++98 and
>>> C++11 code. Previously they had the same definition, even though in
>>> C++11 mode the value of the _GLIBCXX_USE_C99_FOO macro might have been
>>> sub-optimal (i.e. the C99 features were usable, but the macro said
>>> they weren't). Those ODR violatiosn could be avoided if needed, by
>>> always using the _GLIBCXX98_USE_C99_FOO macro in code that can be
>>> included from either C++98 or C++11. We could still use the
>>> _GLIBCXX11_USE_C99_FOO macro in pure C++11 code (such as the numeric
>>> conversion functions) and get most of the benefit of this change.
>>
>>
>> This patch (relative to the previous one) would avoid the ODR
>> problems, by only using the C++98 macro in code that gets used in
>> C++98 and later, and using the _GLIBCXX11_XXX ones in code that is
>> never compiled as C++98 (specifically, the numeric conversion
>> functions).
>>
>> Maybe this is a safer, more conservative change.
>
>I haven't tested either of your patches yet (the testsuite runs
>reeeeally slowly on Cygwin T___T), but I just wanted to express my
>approval of the proposed changes (more specifically, the second patch
>you posted).

The second one doesn't work sadly. If you're going to test, pelase
test the first patch only.

>Also, I was not aware that we had to worry about C++03 compatibility.
>Sounds tedious.

It is :-\


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] Enable libstdc++ numeric conversions on Cygwin
  2015-11-12 13:40       ` Jonathan Wakely
  2015-11-12 14:50         ` Jonathan Wakely
@ 2015-11-12 22:56         ` Andreas Tobler
  2015-11-13 14:52         ` Jonathan Wakely
  2 siblings, 0 replies; 20+ messages in thread
From: Andreas Tobler @ 2015-11-12 22:56 UTC (permalink / raw)
  To: Jonathan Wakely, Jennifer Yao; +Cc: libstdc++, gcc-patches

On 12.11.15 14:39, Jonathan Wakely wrote:
> On 12/11/15 11:40 +0000, Jonathan Wakely wrote:
>> On 18/09/15 12:01 -0400, Jennifer Yao wrote:
>>> Forgot to include the patch.
>>>
>>> On Fri, Sep 18, 2015 at 11:17 AM, Jennifer Yao
>>> <jenny.hyphen.fa@gmail.com> wrote:
>>>> A number of functions in libstdc++ are guarded by the _GLIBCXX_USE_C99
>>>> preprocessor macro, which is only defined on systems that pass all of
>>>> the checks for a large set of C99 functions. Consequently, on systems
>>>> which lack any of the required C99 facilities (e.g. Cygwin, which
>>>> lacks some C99 complex math functions), the numeric conversion
>>>> functions (std::stoi(), std::stol(), std::to_string(), etc.) are not
>>>> defined—a rather silly outcome, as none of the numeric conversion
>>>> functions are implemented using C99 math functions.
>>>>
>>>> This patch enables numeric conversion functions on the aforementioned
>>>> systems by splitting the checks for C99 support and defining several
>>>> new macros (_GLIBCXX_USE_C99_STDIO, _GLIBCXX_USE_C99_STDLIB, and
>>>> _GLIBCXX_USE_C99_WCHAR), which replace the use of _GLIBCXX_USE_C99 in
>>>> #if conditionals where appropriate.
>>
>> (Coming back to this now that Jennifer's copyright assignment is
>> complete...)
>>
>> Splitting the _GLIBCXX_USE_C99 macro into more fine-grained macros for
>> separate features is definitely the right direction.
>>
>> However your patch also changes the configure tests to use -std=c++0x
>> (which should be -std=c++11, but that's a minor point). On an OS that
>> only makes the C99 library available conditionally that will mean that
>> configure determines that C99 library features are supported, but we
>> will get errors if we try to use those features in C++03 parts of the
>> library.
>>
>> I think a more complete solution is to have two sets of configure
>> tests and two sets of macros, so that we define _GLIBCXX_USE_C99_STDIO
>> when C99 stdio is available unconditionally, and define
>> _GLIBCXX11_USE_C99_STDIO when it's available with -std=c++11.
>>
>> Then in the library code we can check _GLIBCXX_USE_C99_STDIO if we
>> want to use C99 features in C++03 code, and check
>> _GLIBCXX11_USE_C99_STDIO if we want to use the features in C++11 code.
>>
>> That should still solve the problem for the numeric conversion
>> functions, because they are defined in C++11 and so would check
>> _GLIBCXX11_USE_C99_STDIO, which will be defined for newlib.
>>
>> Other pieces of the library, such as locales, will use
>> _GLIBCXX_USE_C99_STDIO and that might still be false for newlib (and
>> for other strict C libraries like the Solaris and FreeBSD libc).
>>
>> I will make the changes to acinclude.m4 to duplicate the tests, so we
>> test once with -std=c++98 and once with -std=c++11, and then change
>> the library to check either _GLIBCXX_xxx or _GLIBCXX11_xxx as
>> appropriate.
>
> Here's a patch implementing my suggestion.
>
> The major changes since Jennifer's original patch are in acinclude.m4,
> to do the autoconf tests once with -std=c++98 and again with
> -std=c++11, and in include/bits/c++config to define the
> _GLIBCXX_USE_C99_XXX macros according to either _GLIBCXX98_USE_CXX_XXX
> or _GLIBCXX11_USE_CXX_XXX, depending on the standard mode in effect
> when the file is included.
>
> Because those new definitions in bits/c++config are unconditional I
> had to adjust a few #ifdef tests to use #if instead.
>
> I also removed the changes to GLIBCXX_CHECK_C99_TR1, so that there are
> no changes to the macros used for the TR1 library. As a follow-up
> change I will add a test for <stdint.h> to GLIBCXX_ENABLE_C99 and
> change several C++ headers to stop using the TR1 macros.
>
> This passes all tests on powerpc64le-linux, I'll also try to test on
> DragonFly and FreeBSD.
>
> Does this look good to everyone?
>
> One downside of this change is that we introduce some (hopefully safe)
> ODR violations, where inline functions and templates that depend on
> _GLIBCXX_USE_C99_FOO might now be defined differently in C++98 and
> C++11 code. Previously they had the same definition, even though in
> C++11 mode the value of the _GLIBCXX_USE_C99_FOO macro might have been
> sub-optimal (i.e. the C99 features were usable, but the macro said
> they weren't). Those ODR violatiosn could be avoided if needed, by
> always using the _GLIBCXX98_USE_C99_FOO macro in code that can be
> included from either C++98 or C++11. We could still use the
> _GLIBCXX11_USE_C99_FOO macro in pure C++11 code (such as the numeric
> conversion functions) and get most of the benefit of this change.
>


I have successfully tested this patch on FreeBSD -CURRENT and also on 
CentOS7.1 (x86_64).

I had the previous version installed for a longer time and I see no 
regressions compared with it.

N.B: I didn't apply the follow up patch since you mentioned it does not 
work.

So, for me it looks good and I'm very happy to see this coming in.

Thank you all!!

Regards,
Andreas

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] Enable libstdc++ numeric conversions on Cygwin
  2015-11-12 13:40       ` Jonathan Wakely
  2015-11-12 14:50         ` Jonathan Wakely
  2015-11-12 22:56         ` Andreas Tobler
@ 2015-11-13 14:52         ` Jonathan Wakely
  2015-11-14  8:37           ` Christophe Lyon
  2015-12-08 10:59           ` Alan Lawrence
  2 siblings, 2 replies; 20+ messages in thread
From: Jonathan Wakely @ 2015-11-13 14:52 UTC (permalink / raw)
  To: Jennifer Yao; +Cc: libstdc++, gcc-patches, Andreas Tobler

[-- Attachment #1: Type: text/plain, Size: 4086 bytes --]

On 12/11/15 13:39 +0000, Jonathan Wakely wrote:
>On 12/11/15 11:40 +0000, Jonathan Wakely wrote:
>>On 18/09/15 12:01 -0400, Jennifer Yao wrote:
>>>Forgot to include the patch.
>>>
>>>On Fri, Sep 18, 2015 at 11:17 AM, Jennifer Yao
>>><jenny.hyphen.fa@gmail.com> wrote:
>>>>A number of functions in libstdc++ are guarded by the _GLIBCXX_USE_C99
>>>>preprocessor macro, which is only defined on systems that pass all of
>>>>the checks for a large set of C99 functions. Consequently, on systems
>>>>which lack any of the required C99 facilities (e.g. Cygwin, which
>>>>lacks some C99 complex math functions), the numeric conversion
>>>>functions (std::stoi(), std::stol(), std::to_string(), etc.) are not
>>>>defined—a rather silly outcome, as none of the numeric conversion
>>>>functions are implemented using C99 math functions.
>>>>
>>>>This patch enables numeric conversion functions on the aforementioned
>>>>systems by splitting the checks for C99 support and defining several
>>>>new macros (_GLIBCXX_USE_C99_STDIO, _GLIBCXX_USE_C99_STDLIB, and
>>>>_GLIBCXX_USE_C99_WCHAR), which replace the use of _GLIBCXX_USE_C99 in
>>>>#if conditionals where appropriate.
>>
>>(Coming back to this now that Jennifer's copyright assignment is
>>complete...)
>>
>>Splitting the _GLIBCXX_USE_C99 macro into more fine-grained macros for
>>separate features is definitely the right direction.
>>
>>However your patch also changes the configure tests to use -std=c++0x
>>(which should be -std=c++11, but that's a minor point). On an OS that
>>only makes the C99 library available conditionally that will mean that
>>configure determines that C99 library features are supported, but we
>>will get errors if we try to use those features in C++03 parts of the
>>library.
>>
>>I think a more complete solution is to have two sets of configure
>>tests and two sets of macros, so that we define _GLIBCXX_USE_C99_STDIO
>>when C99 stdio is available unconditionally, and define
>>_GLIBCXX11_USE_C99_STDIO when it's available with -std=c++11.
>>
>>Then in the library code we can check _GLIBCXX_USE_C99_STDIO if we
>>want to use C99 features in C++03 code, and check
>>_GLIBCXX11_USE_C99_STDIO if we want to use the features in C++11 code.
>>
>>That should still solve the problem for the numeric conversion
>>functions, because they are defined in C++11 and so would check
>>_GLIBCXX11_USE_C99_STDIO, which will be defined for newlib.
>>
>>Other pieces of the library, such as locales, will use
>>_GLIBCXX_USE_C99_STDIO and that might still be false for newlib (and
>>for other strict C libraries like the Solaris and FreeBSD libc).
>>
>>I will make the changes to acinclude.m4 to duplicate the tests, so we
>>test once with -std=c++98 and once with -std=c++11, and then change
>>the library to check either _GLIBCXX_xxx or _GLIBCXX11_xxx as
>>appropriate.
>
>Here's a patch implementing my suggestion.
>
>The major changes since Jennifer's original patch are in acinclude.m4,
>to do the autoconf tests once with -std=c++98 and again with
>-std=c++11, and in include/bits/c++config to define the
>_GLIBCXX_USE_C99_XXX macros according to either _GLIBCXX98_USE_CXX_XXX
>or _GLIBCXX11_USE_CXX_XXX, depending on the standard mode in effect
>when the file is included.
>
>Because those new definitions in bits/c++config are unconditional I
>had to adjust a few #ifdef tests to use #if instead.
>
>I also removed the changes to GLIBCXX_CHECK_C99_TR1, so that there are
>no changes to the macros used for the TR1 library. As a follow-up
>change I will add a test for <stdint.h> to GLIBCXX_ENABLE_C99 and
>change several C++ headers to stop using the TR1 macros.
>
>This passes all tests on powerpc64le-linux, I'll also try to test on
>DragonFly and FreeBSD.

That patch was wrong, the new macros in include/bits/c++config used
"CSTDIO" instead of "STDIO" so it caused several tests to go from
PASS to UNSUPPORTED, oops!

This is the correct version, tested again more carefully, on
powerpc64le-linux and powerpc-aix and x86_64-dragonfly.

Committed to trunk.

Jennifer, thanks very much for making this happen.

[-- Attachment #2: patch.txt --]
[-- Type: text/x-patch, Size: 58251 bytes --]

commit 9d0a8d21b790517dbcf1f3c1d83f549e96170feb
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Fri Nov 13 09:23:37 2015 +0000

    More fine-grained autoconf checks for C99 library
    
    2015-11-13  Jennifer Yao  <jenny.hyphen.fa@gmail.com>
    	    Jonathan Wakely  <jwakely@redhat.com>
    
    	PR libstdc++/58393
    	PR libstdc++/61580
    	* acinclude.m4 (GLIBCXX_ENABLE_C99): Perform tests twice, with
    	-std=c++11 as well as -std=c++98, and define separate macros for each.
    	Cache the results of checking for complex math and wide character
    	functions. Reformat for readability.
    	* config.h.in: Regenerate.
    	* include/bits/c++config: Define _GLIBCXX_USE_C99_XXX macros to
    	either _GLIBCXX98_USE_C99_XXX or _GLIBCXX11_USE_C99_XXX according to
    	language standard in use.
    	* config/locale/dragonfly/c_locale.h (std::__convert_from_v): Replace
    	_GLIBCXX_USE_C99 with _GLIBCXX_USE_C99_STDIO.
    	* config/locale/generic/c_locale.h (std::__convert_from_v): Likewise.
    	* config/locale/gnu/c_locale.h (std::__convert_from_v): Likewise.
    	* config/os/bsd/dragonfly/os_defines.h: Define _GLIBCXX_USE_C99_STDIO,
    	_GLIBCXX_USE_C99_STDLIB, and _GLIBCXX_USE_C99_WCHAR.
    	* configure: Regenerate.
    	* include/bits/basic_string.h: Make numeric conversion functions
    	depend on _GLIBCXX_USE_C99_STDIO, _GLIBCXX_USE_C99_STDLIB, or
    	_GLIBCXX_USE_C99_WCHAR, instead of _GLIBCXX_USE_C99.
    	* include/ext/vstring.h: Likewise.
    	* include/bits/locale_facets.tcc (std::num_put::_M_insert_float):
    	Replace _GLIBCXX_USE_C99 with _GLIBCXX_USE_C99_STDIO.
    	* include/bits/locale_facets_nonio.tcc (std::money_put::do_put):
    	Likewise.
    	* include/c_compatibility/math.h: Replace _GLIBCXX_USE_C99 with
    	_GLIBCXX_USE_C99_MATH.
    	* include/c_compatibility/wchar.h: Replace _GLIBCXX_USE_C99 with
    	_GLIBCXX_USE_C99_WCHAR.
    	* include/c_global/cstdio: Replace _GLIBCXX_USE_C99 with
    	_GLIBCXX_USE_C99_STDIO.
    	* include/c_global/cstdlib: Replace _GLIBCXX_USE_C99 with
    	_GLIBCXX_USE_C99_STDLIB.
    	* include/c_global/cwchar: Replace _GLIBCXX_USE_C99 with
    	_GLIBCXX_USE_C99_WCHAR.
    	* include/c_std/cstdio: Replace _GLIBCXX_USE_C99 with
    	_GLIBCXX_USE_C99_STDIO.
    	* include/c_std/cstdlib: Replace _GLIBCXX_USE_C99 with
    	_GLIBCXX_USE_C99_STDLIB.
    	* include/c_std/cwchar: Replace _GLIBCXX_USE_C99 with
    	_GLIBCXX_USE_C99_WCHAR.
    	* include/tr1/cstdio: Replace _GLIBCXX_USE_C99 with
    	_GLIBCXX_USE_C99_STDIO.
    	* include/tr1/cstdlib: Replace _GLIBCXX_USE_C99 with
    	_GLIBCXX_USE_C99_STDLIB.
    	* include/tr1/cwchar: Replace _GLIBCXX_USE_C99 with
    	_GLIBCXX_USE_C99_WCHAR.
    	* include/tr1/stdlib.h: Replace _GLIBCXX_USE_C99 with
    	_GLIBCXX_USE_C99_STDLIB.
    	* src/c++98/locale_facets.cc (std::__num_base::_S_format_float):
    	Replace _GLIBCXX_USE_C99 with _GLIBCXX_USE_C99_STDIO.
    	* testsuite/18_support/exception_ptr/60612-terminate.cc: Replace
    	_GLIBCXX_USE_C99 with _GLIBCXX_USE_C99_STDLIB.
    	* testsuite/18_support/exception_ptr/60612-unexpected.cc: Likewise.
    	* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stod.cc
    	(test01): Replace _GLIBCXX_USE_C99 with _GLIBCXX_USE_C99_WCHAR.
    	* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
    	stof.cc: Likewise.
    	* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
    	stoi.cc: Likewise.
    	* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
    	stol.cc: Likewise.
    	* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
    	stold.cc: Likewise.
    	* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
    	stoll.cc: Likewise.
    	* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
    	stoul.cc: Likewise.
    	* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
    	stoull.cc: Likewise.
    	* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
    	to_wstring.cc: Likewise.
    	* testsuite/26_numerics/headers/cstdlib/13943.cc: Replace
    	_GLIBCXX_USE_C99 with _GLIBCXX_USE_C99_STDLIB.
    	* testsuite/26_numerics/headers/cstdlib/types_std_c++0x.cc: Likewise.
    	* testsuite/lib/libstdc++.exp (check_v3_target_string_conversions):
    	Change preprocessor #if conditional so that it uses
    	_GLIBCXX_USE_C99_STDIO, _GLIBCXX_USE_C99_STDLIB, and
    	_GLIBCXX_USE_C99_WCHAR, instead of _GLIBCXX_USE_C99.
    	* testsuite/tr1/8_c_compatibility/cmath/templates.cc: Replace
    	_GLIBCXX_USE_C99 with _GLIBCXX_USE_C99_MATH.
    	* testsuite/tr1/8_c_compatibility/cstdio/functions.cc: Replace
    	_GLIBCXX_USE_C99 with _GLIBCXX_USE_C99_STDIO.
    	* testsuite/tr1/8_c_compatibility/cstdlib/functions.cc: Replace
    	_GLIBCXX_USE_C99 with _GLIBCXX_USE_C99_STDLIB.
    	* testsuite/tr1/8_c_compatibility/cstdlib/types_std_tr1.cc: Likewise.
    	* testsuite/tr1/8_c_compatibility/cwchar/functions.cc: Replace
    	_GLIBCXX_USE_C99 with _GLIBCXX_USE_C99_WCHAR.
    	* testsuite/util/testsuite_fs.h: Replace _GLIBCXX_USE_C99 with
    	_GLIBCXX_USE_C99_STDIO.

diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
index abf2e93..deefa04 100644
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -915,234 +915,438 @@ AC_DEFUN([GLIBCXX_ENABLE_C99], [
   GLIBCXX_ENABLE(c99,$1,,[turns on ISO/IEC 9899:1999 support])
 
   if test x"$enable_c99" = x"yes"; then
+    AC_LANG_SAVE
+    AC_LANG_CPLUSPLUS
 
-  AC_LANG_SAVE
-  AC_LANG_CPLUSPLUS
+    # Use -std=c++98 (instead of -std=gnu++98) because leaving __STRICT_ANSI__
+    # undefined may cause fake C99 facilities, like pre-standard snprintf,
+    # to be spuriously enabled.
+    ac_save_CXXFLAGS="$CXXFLAGS"
+    CXXFLAGS="$CXXFLAGS -std=c++98"
+    ac_save_LIBS="$LIBS"
+    ac_save_gcc_no_link="$gcc_no_link"
 
-  # Use -std=c++98 because the default (-std=gnu++98) leaves __STRICT_ANSI__
-  # undefined and fake C99 facilities - like pre-standard snprintf - may be
-  # spuriously enabled.
-  # Long term, -std=c++0x could be even better, could manage to explicitly
-  # request C99 facilities to the underlying C headers.
-  ac_save_CXXFLAGS="$CXXFLAGS"
-  CXXFLAGS="$CXXFLAGS -std=c++98"
-  ac_save_LIBS="$LIBS"
-  ac_save_gcc_no_link="$gcc_no_link"
+    if test x$gcc_no_link != xyes; then
+      # Use -fno-exceptions to that the C driver can link these tests without
+      # hitting undefined references to personality routines.
+      CXXFLAGS="$CXXFLAGS -fno-exceptions"
+      AC_CHECK_LIB(m, sin, [LIBS="$LIBS -lm"], [
+        # Use the default compile-only tests in GCC_TRY_COMPILE_OR_LINK
+        gcc_no_link=yes
+      ])
+    fi
 
-  if test x$gcc_no_link != xyes; then
-    # Use -fno-exceptions to that the C driver can link these tests without
-    # hitting undefined references to personality routines.
-    CXXFLAGS="$CXXFLAGS -fno-exceptions"
-    AC_CHECK_LIB(m, sin, [
-      LIBS="$LIBS -lm"
-    ], [
-      # Use the default compile-only tests in GCC_TRY_COMPILE_OR_LINK
-      gcc_no_link=yes
+    # Check for the existence of <math.h> functions used if C99 is enabled.
+    AC_MSG_CHECKING([for ISO C99 support in <math.h> for C++98])
+    AC_CACHE_VAL(glibcxx_cv_c99_math_cxx98, [
+      GCC_TRY_COMPILE_OR_LINK(
+        [#include <math.h>
+         volatile double d1, d2;
+         volatile int i;],
+        [i = fpclassify(d1);
+         i = isfinite(d1);
+         i = isinf(d1);
+         i = isnan(d1);
+         i = isnormal(d1);
+         i = signbit(d1);
+         i = isgreater(d1, d2);
+         i = isgreaterequal(d1, d2);
+         i = isless(d1, d2);
+         i = islessequal(d1, d2);
+         i = islessgreater(d1, d2);
+         i = islessgreater(d1, d2);
+         i = isunordered(d1, d2);
+        ], [glibcxx_cv_c99_math_cxx98=yes], [glibcxx_cv_c99_math_cxx98=no])
     ])
-  fi
+    AC_MSG_RESULT($glibcxx_cv_c99_math_cxx98)
+    if test x"$glibcxx_cv_c99_math_cxx98" = x"yes"; then
+      AC_DEFINE(_GLIBCXX98_USE_C99_MATH, 1,
+        [Define if C99 functions or macros in <math.h> should be imported
+        in <cmath> in namespace std for C++98.])
+    fi
 
-  # Check for the existence of <math.h> functions used if C99 is enabled.
-  AC_MSG_CHECKING([for ISO C99 support in <math.h>])
-  AC_CACHE_VAL(glibcxx_cv_c99_math, [
-  GCC_TRY_COMPILE_OR_LINK(
-     [#include <math.h>
-      volatile double d1, d2;
-      volatile int i;],
-     [i = fpclassify(d1);
-      i = isfinite(d1);
-      i = isinf(d1);
-      i = isnan(d1);
-      i = isnormal(d1);
-      i = signbit(d1);
-      i = isgreater(d1, d2);
-      i = isgreaterequal(d1, d2);
-      i = isless(d1, d2);
-      i = islessequal(d1, d2);
-      i = islessgreater(d1, d2);
-      i = islessgreater(d1, d2);
-      i = isunordered(d1, d2);
-     ],[glibcxx_cv_c99_math=yes], [glibcxx_cv_c99_math=no])
-  ])
-  AC_MSG_RESULT($glibcxx_cv_c99_math)
-  if test x"$glibcxx_cv_c99_math" = x"yes"; then
-    AC_DEFINE(_GLIBCXX_USE_C99_MATH, 1,
-	      [Define if C99 functions or macros in <math.h> should be imported
-	      in <cmath> in namespace std.])
-  fi
+    # Check for the existence of <complex.h> complex math functions.
+    # This is necessary even though libstdc++ uses the builtin versions
+    # of these functions, because if the builtin cannot be used, a reference
+    # to the library function is emitted.
+    AC_CHECK_HEADERS(tgmath.h, ac_has_tgmath_h=yes, ac_has_tgmath_h=no)
+    AC_CHECK_HEADERS(complex.h, ac_has_complex_h=yes, ac_has_complex_h=no)
+    if test x"$ac_has_complex_h" = x"yes"; then
+      AC_MSG_CHECKING([for ISO C99 support in <complex.h> for C++98])
+      AC_CACHE_VAL(glibcxx_cv_c99_complex_cxx98, [
+        GCC_TRY_COMPILE_OR_LINK(
+          [#include <complex.h>
+           typedef __complex__ float float_type;
+           typedef __complex__ double double_type;
+           typedef __complex__ long double ld_type;
+           volatile float_type tmpf;
+           volatile double_type tmpd;
+           volatile ld_type tmpld;
+           volatile float f;
+           volatile double d;
+           volatile long double ld;],
+          [f = cabsf(tmpf);
+           f = cargf(tmpf);
+           tmpf = ccosf(tmpf);
+           tmpf = ccoshf(tmpf);
+           tmpf = cexpf(tmpf);
+           tmpf = clogf(tmpf);
+           tmpf = csinf(tmpf);
+           tmpf = csinhf(tmpf);
+           tmpf = csqrtf(tmpf);
+           tmpf = ctanf(tmpf);
+           tmpf = ctanhf(tmpf);
+           tmpf = cpowf(tmpf, tmpf);
+           tmpf = cprojf(tmpf);
+           d = cabs(tmpd);
+           d = carg(tmpd);
+           tmpd = ccos(tmpd);
+           tmpd = ccosh(tmpd);
+           tmpd = cexp(tmpd);
+           tmpd = clog(tmpd);
+           tmpd = csin(tmpd);
+           tmpd = csinh(tmpd);
+           tmpd = csqrt(tmpd);
+           tmpd = ctan(tmpd);
+           tmpd = ctanh(tmpd);
+           tmpd = cpow(tmpd, tmpd);
+           tmpd = cproj(tmpd);
+           ld = cabsl(tmpld);
+           ld = cargl(tmpld);
+           tmpld = ccosl(tmpld);
+           tmpld = ccoshl(tmpld);
+           tmpld = cexpl(tmpld);
+           tmpld = clogl(tmpld);
+           tmpld = csinl(tmpld);
+           tmpld = csinhl(tmpld);
+           tmpld = csqrtl(tmpld);
+           tmpld = ctanl(tmpld);
+           tmpld = ctanhl(tmpld);
+           tmpld = cpowl(tmpld, tmpld);
+           tmpld = cprojl(tmpld);
+          ], [glibcxx_cv_c99_complex_cxx98=yes], [glibcxx_cv_c99_complex_cxx98=no])
+      ])
+    fi
+    AC_MSG_RESULT($glibcxx_cv_c99_complex_cxx98)
+    if test x"$glibcxx_cv_c99_complex_cxx98" = x"yes"; then
+      AC_DEFINE(_GLIBCXX98_USE_C99_COMPLEX, 1,
+        [Define if C99 functions in <complex.h> should be used in
+        <complex> for C++98. Using compiler builtins for these functions
+        requires corresponding C99 library functions to be present.])
+    fi
 
-  # Check for the existence of <complex.h> complex math functions.
-  # This is necessary even though libstdc++ uses the builtin versions
-  # of these functions, because if the builtin cannot be used, a reference
-  # to the library function is emitted.
-  AC_CHECK_HEADERS(tgmath.h, ac_has_tgmath_h=yes, ac_has_tgmath_h=no)
-  AC_CHECK_HEADERS(complex.h, ac_has_complex_h=yes, ac_has_complex_h=no)
-  glibcxx_cv_c99_complex=no;
-  if test x"$ac_has_complex_h" = x"yes"; then
-    AC_MSG_CHECKING([for ISO C99 support in <complex.h>])
-    GCC_TRY_COMPILE_OR_LINK(
-       [#include <complex.h>
-	typedef __complex__ float float_type;
-	typedef __complex__ double double_type;
-	typedef __complex__ long double ld_type;
-	volatile float_type tmpf;
-	volatile double_type tmpd;
-	volatile ld_type tmpld;
-	volatile float f;
-	volatile double d;
-	volatile long double ld;],
-       [f = cabsf(tmpf);
-	f = cargf(tmpf);
-	tmpf = ccosf(tmpf);
-	tmpf = ccoshf(tmpf);
-	tmpf = cexpf(tmpf);
-	tmpf = clogf(tmpf);
-	tmpf = csinf(tmpf);
-	tmpf = csinhf(tmpf);
-	tmpf = csqrtf(tmpf);
-	tmpf = ctanf(tmpf);
-	tmpf = ctanhf(tmpf);
-	tmpf = cpowf(tmpf, tmpf);
-	tmpf = cprojf(tmpf);
-	d = cabs(tmpd);
-	d = carg(tmpd);
-	tmpd = ccos(tmpd);
-	tmpd = ccosh(tmpd);
-	tmpd = cexp(tmpd);
-	tmpd = clog(tmpd);
-	tmpd = csin(tmpd);
-	tmpd = csinh(tmpd);
-	tmpd = csqrt(tmpd);
-	tmpd = ctan(tmpd);
-	tmpd = ctanh(tmpd);
-	tmpd = cpow(tmpd, tmpd);
-	tmpd = cproj(tmpd);
-	ld = cabsl(tmpld);
-	ld = cargl(tmpld);
-	tmpld = ccosl(tmpld);
-	tmpld = ccoshl(tmpld);
-	tmpld = cexpl(tmpld);
-	tmpld = clogl(tmpld);
-	tmpld = csinl(tmpld);
-	tmpld = csinhl(tmpld);
-	tmpld = csqrtl(tmpld);
-	tmpld = ctanl(tmpld);
-	tmpld = ctanhl(tmpld);
-	tmpld = cpowl(tmpld, tmpld);
-	tmpld = cprojl(tmpld);
-       ],[glibcxx_cv_c99_complex=yes], [glibcxx_cv_c99_complex=no])
-  fi
-  AC_MSG_RESULT($glibcxx_cv_c99_complex)
-  if test x"$glibcxx_cv_c99_complex" = x"yes"; then
-    AC_DEFINE(_GLIBCXX_USE_C99_COMPLEX, 1,
-	      [Define if C99 functions in <complex.h> should be used in
-	      <complex>. Using compiler builtins for these functions requires
-	      corresponding C99 library functions to be present.])
-  fi
+    # Check for the existence in <stdio.h> of vscanf, et. al.
+    AC_MSG_CHECKING([for ISO C99 support in <stdio.h> for C++98])
+    AC_CACHE_VAL(glibcxx_cv_c99_stdio_cxx98, [
+      GCC_TRY_COMPILE_OR_LINK(
+        [#include <stdio.h>
+         #include <stdarg.h>
+         void foo(char* fmt, ...)
+         {
+           va_list args; va_start(args, fmt);
+           vfscanf(stderr, "%i", args);
+           vscanf("%i", args);
+           vsnprintf(fmt, 0, "%i", args);
+           vsscanf(fmt, "%i", args);
+           snprintf(fmt, 0, "%i");
+         }], [],
+        [glibcxx_cv_c99_stdio_cxx98=yes], [glibcxx_cv_c99_stdio_cxx98=no])
+    ])
+    AC_MSG_RESULT($glibcxx_cv_c99_stdio_cxx98)
+    if test x"$glibcxx_cv_c99_stdio_cxx98" = x"yes"; then
+      AC_DEFINE(_GLIBCXX98_USE_C99_STDIO, 1,
+        [Define if C99 functions or macros in <stdio.h> should be imported
+        in <cstdio> in namespace std for C++98.])
+    fi
 
-  # Check for the existence in <stdio.h> of vscanf, et. al.
-  AC_MSG_CHECKING([for ISO C99 support in <stdio.h>])
-  AC_CACHE_VAL(glibcxx_cv_c99_stdio, [
-  GCC_TRY_COMPILE_OR_LINK(
-     [#include <stdio.h>
-      #include <stdarg.h>
-      void foo(char* fmt, ...)
-      {
-	va_list args; va_start(args, fmt);
-	vfscanf(stderr, "%i", args);
-	vscanf("%i", args);
-	vsnprintf(fmt, 0, "%i", args);
-	vsscanf(fmt, "%i", args);
-	snprintf(fmt, 0, "%i");
-      }], [],
-     [glibcxx_cv_c99_stdio=yes], [glibcxx_cv_c99_stdio=no])
-  ])
-  AC_MSG_RESULT($glibcxx_cv_c99_stdio)
+    # Check for the existence in <wchar.h> of wcstold, etc.
+    if test x"$ac_has_wchar_h" = xyes &&
+       test x"$ac_has_wctype_h" = xyes; then
+      AC_MSG_CHECKING([for ISO C99 support in <wchar.h> for C++98])
+      AC_CACHE_VAL(glibcxx_cv_c99_wchar_cxx98, [
+        AC_TRY_COMPILE([#include <wchar.h>
+          namespace test
+          {
+            using ::wcstold;
+            using ::wcstoll;
+            using ::wcstoull;
+          }
+        ], [], [glibcxx_cv_c99_wchar_cxx98=yes], [glibcxx_cv_c99_wchar_cxx98=no])
+      ])
 
-  # Check for the existence in <stdlib.h> of lldiv_t, et. al.
-  AC_MSG_CHECKING([for ISO C99 support in <stdlib.h>])
-  AC_CACHE_VAL(glibcxx_cv_c99_stdlib, [
-  GCC_TRY_COMPILE_OR_LINK(
-     [#include <stdlib.h>
-      volatile float f;
-      volatile long double ld;
-      volatile unsigned long long ll;
-      lldiv_t mydivt;],
-     [char* tmp;
-      f = strtof("gnu", &tmp);
-      ld = strtold("gnu", &tmp);
-      ll = strtoll("gnu", &tmp, 10);
-      ll = strtoull("gnu", &tmp, 10);
-      ll = llabs(10);
-      mydivt = lldiv(10,1);
-      ll = mydivt.quot;
-      ll = mydivt.rem;
-      ll = atoll("10");
-      _Exit(0);
-      ],[glibcxx_cv_c99_stdlib=yes], [glibcxx_cv_c99_stdlib=no])
-  ])
-  AC_MSG_RESULT($glibcxx_cv_c99_stdlib)
+      # Checks for wide character functions that may not be present.
+      # Injection of these is wrapped with guard macros.
+      # NB: only put functions here, instead of immediately above, if
+      # absolutely necessary.
+      AC_TRY_COMPILE([#include <wchar.h>
+        namespace test { using ::vfwscanf; }], [],
+        [AC_DEFINE(HAVE_VFWSCANF, 1, [Defined if vfwscanf exists.])], [])
 
-  # Check for the existence in <wchar.h> of wcstold, etc.
-  glibcxx_cv_c99_wchar=no;
-  if test x"$ac_has_wchar_h" = xyes &&
-     test x"$ac_has_wctype_h" = xyes; then
-    AC_MSG_CHECKING([for ISO C99 support in <wchar.h>])
-    AC_TRY_COMPILE([#include <wchar.h>
-		    namespace test
-		    {
-		      using ::wcstold;
-		      using ::wcstoll;
-		      using ::wcstoull;
-		    }
-		   ],[],[glibcxx_cv_c99_wchar=yes], [glibcxx_cv_c99_wchar=no])
+      AC_TRY_COMPILE([#include <wchar.h>
+        namespace test { using ::vswscanf; }], [],
+        [AC_DEFINE(HAVE_VSWSCANF, 1, [Defined if vswscanf exists.])], [])
 
-    # Checks for wide character functions that may not be present.
-    # Injection of these is wrapped with guard macros.
-    # NB: only put functions here, instead of immediately above, if
-    # absolutely necessary.
-    AC_TRY_COMPILE([#include <wchar.h>
-		    namespace test { using ::vfwscanf; } ], [],
- 	    	   [AC_DEFINE(HAVE_VFWSCANF,1,
-			[Defined if vfwscanf exists.])],[])
+      AC_TRY_COMPILE([#include <wchar.h>
+        namespace test { using ::vwscanf; }], [],
+        [AC_DEFINE(HAVE_VWSCANF, 1, [Defined if vwscanf exists.])], [])
 
-    AC_TRY_COMPILE([#include <wchar.h>
-		    namespace test { using ::vswscanf; } ], [],
- 	    	   [AC_DEFINE(HAVE_VSWSCANF,1,
-			[Defined if vswscanf exists.])],[])
+      AC_TRY_COMPILE([#include <wchar.h>
+        namespace test { using ::wcstof; }], [],
+        [AC_DEFINE(HAVE_WCSTOF, 1, [Defined if wcstof exists.])], [])
 
-    AC_TRY_COMPILE([#include <wchar.h>
-		    namespace test { using ::vwscanf; } ], [],
- 	    	   [AC_DEFINE(HAVE_VWSCANF,1,[Defined if vwscanf exists.])],[])
+      AC_TRY_COMPILE([#include <wctype.h>],
+        [wint_t t; int i = iswblank(t);],
+        [AC_DEFINE(HAVE_ISWBLANK, 1, [Defined if iswblank exists.])], [])
 
-    AC_TRY_COMPILE([#include <wchar.h>
-		    namespace test { using ::wcstof; } ], [],
- 	    	   [AC_DEFINE(HAVE_WCSTOF,1,[Defined if wcstof exists.])],[])
+      AC_MSG_RESULT($glibcxx_cv_c99_wchar_cxx98)
+      if test x"$glibcxx_cv_c99_wchar_cxx98" = x"yes"; then
+        AC_DEFINE(_GLIBCXX98_USE_C99_WCHAR, 1,
+          [Define if C99 functions or macros in <wchar.h> should be imported
+          in <cwchar> in namespace std for C++98.])
+      fi
+    fi
 
-    AC_TRY_COMPILE([#include <wctype.h>],
-		   [ wint_t t; int i = iswblank(t);],
- 	    	   [AC_DEFINE(HAVE_ISWBLANK,1,
-			[Defined if iswblank exists.])],[])
+    # Option parsed, now set things appropriately.
+    if test x"$glibcxx_cv_c99_math_cxx98" = x"no" ||
+       test x"$glibcxx_cv_c99_complex_cxx98" = x"no" ||
+       test x"$glibcxx_cv_c99_stdio_cxx98" = x"no" ||
+       test x"$glibcxx_cv_c99_stdlib_cxx98" = x"no" ||
+       test x"$glibcxx_cv_c99_wchar_cxx98" = x"no"; then
+      enable_c99=no;
+    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.])
+    fi
 
-    AC_MSG_RESULT($glibcxx_cv_c99_wchar)
-  fi
+    gcc_no_link="$ac_save_gcc_no_link"
+    LIBS="$ac_save_LIBS"
+    CXXFLAGS="$ac_save_CXXFLAGS"
+    AC_LANG_RESTORE
 
-  # 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
-    enable_c99=no;
-  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.])
-  fi
+    AC_LANG_SAVE
+    AC_LANG_CPLUSPLUS
 
-  gcc_no_link="$ac_save_gcc_no_link"
-  LIBS="$ac_save_LIBS"
-  CXXFLAGS="$ac_save_CXXFLAGS"
-  AC_LANG_RESTORE
+    # Use -std=c++11 and test again for C99 library feature in C++11 mode.
+    # For the reasons given above we use -std=c++11 not -std=gnu++11.
+    ac_save_CXXFLAGS="$CXXFLAGS"
+    CXXFLAGS="$CXXFLAGS -std=c++11"
+    ac_save_LIBS="$LIBS"
+    ac_save_gcc_no_link="$gcc_no_link"
+
+    if test x$gcc_no_link != xyes; then
+      # Use -fno-exceptions to that the C driver can link these tests without
+      # hitting undefined references to personality routines.
+      CXXFLAGS="$CXXFLAGS -fno-exceptions"
+      AC_CHECK_LIB(m, sin, [LIBS="$LIBS -lm"], [
+        # Use the default compile-only tests in GCC_TRY_COMPILE_OR_LINK
+        gcc_no_link=yes
+      ])
+    fi
+
+    # Check for the existence of <math.h> functions used if C99 is enabled.
+    AC_MSG_CHECKING([for ISO C99 support in <math.h> for C++11])
+    AC_CACHE_VAL(glibcxx_cv_c99_math_cxx11, [
+      GCC_TRY_COMPILE_OR_LINK(
+        [#include <math.h>
+         volatile double d1, d2;
+         volatile int i;],
+        [i = fpclassify(d1);
+         i = isfinite(d1);
+         i = isinf(d1);
+         i = isnan(d1);
+         i = isnormal(d1);
+         i = signbit(d1);
+         i = isgreater(d1, d2);
+         i = isgreaterequal(d1, d2);
+         i = isless(d1, d2);
+         i = islessequal(d1, d2);
+         i = islessgreater(d1, d2);
+         i = islessgreater(d1, d2);
+         i = isunordered(d1, d2);
+        ], [glibcxx_cv_c99_math_cxx11=yes], [glibcxx_cv_c99_math_cxx11=no])
+    ])
+    AC_MSG_RESULT($glibcxx_cv_c99_math_cxx11)
+    if test x"$glibcxx_cv_c99_math_cxx11" = x"yes"; then
+      AC_DEFINE(_GLIBCXX11_USE_C99_MATH, 1,
+        [Define if C99 functions or macros in <math.h> should be imported
+        in <cmath> in namespace std for C++11.])
+    fi
+
+    # Check for the existence of <complex.h> complex math functions.
+    # This is necessary even though libstdc++ uses the builtin versions
+    # of these functions, because if the builtin cannot be used, a reference
+    # to the library function is emitted.
+    AC_CHECK_HEADERS(tgmath.h, ac_has_tgmath_h=yes, ac_has_tgmath_h=no)
+    AC_CHECK_HEADERS(complex.h, ac_has_complex_h=yes, ac_has_complex_h=no)
+    if test x"$ac_has_complex_h" = x"yes"; then
+      AC_MSG_CHECKING([for ISO C99 support in <complex.h> for C++11])
+      AC_CACHE_VAL(glibcxx_cv_c99_complex_cxx11, [
+        GCC_TRY_COMPILE_OR_LINK(
+          [#include <complex.h>
+           typedef __complex__ float float_type;
+           typedef __complex__ double double_type;
+           typedef __complex__ long double ld_type;
+           volatile float_type tmpf;
+           volatile double_type tmpd;
+           volatile ld_type tmpld;
+           volatile float f;
+           volatile double d;
+           volatile long double ld;],
+          [f = cabsf(tmpf);
+           f = cargf(tmpf);
+           tmpf = ccosf(tmpf);
+           tmpf = ccoshf(tmpf);
+           tmpf = cexpf(tmpf);
+           tmpf = clogf(tmpf);
+           tmpf = csinf(tmpf);
+           tmpf = csinhf(tmpf);
+           tmpf = csqrtf(tmpf);
+           tmpf = ctanf(tmpf);
+           tmpf = ctanhf(tmpf);
+           tmpf = cpowf(tmpf, tmpf);
+           tmpf = cprojf(tmpf);
+           d = cabs(tmpd);
+           d = carg(tmpd);
+           tmpd = ccos(tmpd);
+           tmpd = ccosh(tmpd);
+           tmpd = cexp(tmpd);
+           tmpd = clog(tmpd);
+           tmpd = csin(tmpd);
+           tmpd = csinh(tmpd);
+           tmpd = csqrt(tmpd);
+           tmpd = ctan(tmpd);
+           tmpd = ctanh(tmpd);
+           tmpd = cpow(tmpd, tmpd);
+           tmpd = cproj(tmpd);
+           ld = cabsl(tmpld);
+           ld = cargl(tmpld);
+           tmpld = ccosl(tmpld);
+           tmpld = ccoshl(tmpld);
+           tmpld = cexpl(tmpld);
+           tmpld = clogl(tmpld);
+           tmpld = csinl(tmpld);
+           tmpld = csinhl(tmpld);
+           tmpld = csqrtl(tmpld);
+           tmpld = ctanl(tmpld);
+           tmpld = ctanhl(tmpld);
+           tmpld = cpowl(tmpld, tmpld);
+           tmpld = cprojl(tmpld);
+          ], [glibcxx_cv_c99_complex_cxx11=yes], [glibcxx_cv_c99_complex_cxx11=no])
+      ])
+    fi
+    AC_MSG_RESULT($glibcxx_cv_c99_complex_cxx11)
+    if test x"$glibcxx_cv_c99_complex_cxx11" = x"yes"; then
+      AC_DEFINE(_GLIBCXX11_USE_C99_COMPLEX, 1,
+        [Define if C99 functions in <complex.h> should be used in
+        <complex> for C++11. Using compiler builtins for these functions
+        requires corresponding C99 library functions to be present.])
+    fi
+
+    # Check for the existence in <stdio.h> of vscanf, et. al.
+    AC_MSG_CHECKING([for ISO C99 support in <stdio.h> for C++11])
+    AC_CACHE_VAL(glibcxx_cv_c99_stdio_cxx11, [
+      GCC_TRY_COMPILE_OR_LINK(
+        [#include <stdio.h>
+         #include <stdarg.h>
+         void foo(char* fmt, ...)
+         {
+           va_list args; va_start(args, fmt);
+           vfscanf(stderr, "%i", args);
+           vscanf("%i", args);
+           vsnprintf(fmt, 0, "%i", args);
+           vsscanf(fmt, "%i", args);
+           snprintf(fmt, 0, "%i");
+         }], [],
+        [glibcxx_cv_c99_stdio_cxx11=yes], [glibcxx_cv_c99_stdio_cxx11=no])
+    ])
+    AC_MSG_RESULT($glibcxx_cv_c99_stdio_cxx11)
+    if test x"$glibcxx_cv_c99_stdio_cxx11" = x"yes"; then
+      AC_DEFINE(_GLIBCXX11_USE_C99_STDIO, 1,
+        [Define if C99 functions or macros in <stdio.h> should be imported
+        in <cstdio> in namespace std for C++11.])
+    fi
+
+    # Check for the existence in <stdlib.h> of lldiv_t, et. al.
+    AC_MSG_CHECKING([for ISO C99 support in <stdlib.h> for C++11])
+    AC_CACHE_VAL(glibcxx_cv_c99_stdlib_cxx11, [
+      GCC_TRY_COMPILE_OR_LINK(
+        [#include <stdlib.h>
+         volatile float f;
+         volatile long double ld;
+         volatile unsigned long long ll;
+         lldiv_t mydivt;],
+        [char* tmp;
+         f = strtof("gnu", &tmp);
+         ld = strtold("gnu", &tmp);
+         ll = strtoll("gnu", &tmp, 10);
+         ll = strtoull("gnu", &tmp, 10);
+         ll = llabs(10);
+         mydivt = lldiv(10,1);
+         ll = mydivt.quot;
+         ll = mydivt.rem;
+         ll = atoll("10");
+         _Exit(0);
+        ], [glibcxx_cv_c99_stdlib_cxx11=yes], [glibcxx_cv_c99_stdlib_cxx11=no])
+    ])
+    AC_MSG_RESULT($glibcxx_cv_c99_stdlib_cxx11)
+    if test x"$glibcxx_cv_c99_stdlib_cxx11" = x"yes"; then
+      AC_DEFINE(_GLIBCXX11_USE_C99_STDLIB, 1,
+        [Define if C99 functions or macros in <stdlib.h> should be imported
+        in <cstdlib> in namespace std for C++11.])
+    fi
+
+    # Check for the existence in <wchar.h> of wcstold, etc.
+    if test x"$ac_has_wchar_h" = xyes &&
+       test x"$ac_has_wctype_h" = xyes; then
+      AC_MSG_CHECKING([for ISO C99 support in <wchar.h> for C++11])
+      AC_CACHE_VAL(glibcxx_cv_c99_wchar_cxx11, [
+        AC_TRY_COMPILE([#include <wchar.h>
+          namespace test
+          {
+            using ::wcstold;
+            using ::wcstoll;
+            using ::wcstoull;
+          }
+        ], [], [glibcxx_cv_c99_wchar_cxx11=yes], [glibcxx_cv_c99_wchar_cxx11=no])
+      ])
+
+      # Checks for wide character functions that may not be present.
+      # Injection of these is wrapped with guard macros.
+      # NB: only put functions here, instead of immediately above, if
+      # absolutely necessary.
+      AC_TRY_COMPILE([#include <wchar.h>
+        namespace test { using ::vfwscanf; }], [],
+        [AC_DEFINE(HAVE_VFWSCANF, 1, [Defined if vfwscanf exists.])], [])
+
+      AC_TRY_COMPILE([#include <wchar.h>
+        namespace test { using ::vswscanf; }], [],
+        [AC_DEFINE(HAVE_VSWSCANF, 1, [Defined if vswscanf exists.])], [])
+
+      AC_TRY_COMPILE([#include <wchar.h>
+        namespace test { using ::vwscanf; }], [],
+        [AC_DEFINE(HAVE_VWSCANF, 1, [Defined if vwscanf exists.])], [])
+
+      AC_TRY_COMPILE([#include <wchar.h>
+        namespace test { using ::wcstof; }], [],
+        [AC_DEFINE(HAVE_WCSTOF, 1, [Defined if wcstof exists.])], [])
+
+      AC_TRY_COMPILE([#include <wctype.h>],
+        [wint_t t; int i = iswblank(t);],
+        [AC_DEFINE(HAVE_ISWBLANK, 1, [Defined if iswblank exists.])], [])
+
+      AC_MSG_RESULT($glibcxx_cv_c99_wchar_cxx11)
+      if test x"$glibcxx_cv_c99_wchar_cxx11" = x"yes"; then
+        AC_DEFINE(_GLIBCXX11_USE_C99_WCHAR, 1,
+          [Define if C99 functions or macros in <wchar.h> should be imported
+          in <cwchar> in namespace std for C++11.])
+      fi
+    fi
+
+    gcc_no_link="$ac_save_gcc_no_link"
+    LIBS="$ac_save_LIBS"
+    CXXFLAGS="$ac_save_CXXFLAGS"
+    AC_LANG_RESTORE
   fi
 
   AC_MSG_CHECKING([for fully enabled ISO C99 support])
diff --git a/libstdc++-v3/config/locale/dragonfly/c_locale.h b/libstdc++-v3/config/locale/dragonfly/c_locale.h
index 5c17cfe..867a404 100644
--- a/libstdc++-v3/config/locale/dragonfly/c_locale.h
+++ b/libstdc++-v3/config/locale/dragonfly/c_locale.h
@@ -64,7 +64,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     __builtin_va_list __args;
     __builtin_va_start(__args, __fmt);
 
-#ifdef _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_STDIO
     const int __ret = __builtin_vsnprintf(__out, __size, __fmt, __args);
 #else
     const int __ret = __builtin_vsprintf(__out, __fmt, __args);
diff --git a/libstdc++-v3/config/locale/generic/c_locale.h b/libstdc++-v3/config/locale/generic/c_locale.h
index ee3ef86..fa7629f 100644
--- a/libstdc++-v3/config/locale/generic/c_locale.h
+++ b/libstdc++-v3/config/locale/generic/c_locale.h
@@ -70,7 +70,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     __builtin_va_list __args;
     __builtin_va_start(__args, __fmt);
 
-#ifdef _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_STDIO
     const int __ret = __builtin_vsnprintf(__out, __size, __fmt, __args);
 #else
     const int __ret = __builtin_vsprintf(__out, __fmt, __args);
diff --git a/libstdc++-v3/config/locale/gnu/c_locale.h b/libstdc++-v3/config/locale/gnu/c_locale.h
index a1dc3d2..f8ddfeb 100644
--- a/libstdc++-v3/config/locale/gnu/c_locale.h
+++ b/libstdc++-v3/config/locale/gnu/c_locale.h
@@ -88,7 +88,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     __builtin_va_list __args;
     __builtin_va_start(__args, __fmt);
 
-#ifdef _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_STDIO
     const int __ret = __builtin_vsnprintf(__out, __size, __fmt, __args);
 #else
     const int __ret = __builtin_vsprintf(__out, __fmt, __args);
diff --git a/libstdc++-v3/config/os/bsd/dragonfly/os_defines.h b/libstdc++-v3/config/os/bsd/dragonfly/os_defines.h
index 2209129..055c5b6 100644
--- a/libstdc++-v3/config/os/bsd/dragonfly/os_defines.h
+++ b/libstdc++-v3/config/os/bsd/dragonfly/os_defines.h
@@ -30,6 +30,9 @@
 // file will come before all others.
 
 #define _GLIBCXX_USE_C99 1
+#define _GLIBCXX_USE_C99_STDIO 1
+#define _GLIBCXX_USE_C99_STDLIB 1
+#define _GLIBCXX_USE_C99_WCHAR 1
 #define _GLIBCXX_USE_C99_CHECK 1
 #define _GLIBCXX_USE_C99_DYNAMIC (!(__ISO_C_VISIBLE >= 1999))
 #define _GLIBCXX_USE_C99_LONG_LONG_CHECK 1
diff --git a/libstdc++-v3/include/bits/basic_string.h b/libstdc++-v3/include/bits/basic_string.h
index 35246d9..b3853cd 100644
--- a/libstdc++-v3/include/bits/basic_string.h
+++ b/libstdc++-v3/include/bits/basic_string.h
@@ -5387,7 +5387,7 @@ _GLIBCXX_END_NAMESPACE_CXX11
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
 
-#if __cplusplus >= 201103L && defined(_GLIBCXX_USE_C99)
+#if __cplusplus >= 201103L
 
 #include <ext/string_conversions.h>
 
@@ -5396,6 +5396,7 @@ namespace std _GLIBCXX_VISIBILITY(default)
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
 _GLIBCXX_BEGIN_NAMESPACE_CXX11
 
+#if _GLIBCXX_USE_C99_STDLIB
   // 21.4 Numeric Conversions [string.conversions].
   inline int
   stoi(const string& __str, size_t* __idx = 0, int __base = 10)
@@ -5434,7 +5435,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
   inline long double
   stold(const string& __str, size_t* __idx = 0)
   { return __gnu_cxx::__stoa(&std::strtold, "stold", __str.c_str(), __idx); }
+#endif // _GLIBCXX_USE_C99_STDLIB
 
+#if _GLIBCXX_USE_C99_STDIO
   // NB: (v)snprintf vs sprintf.
 
   // DR 1261.
@@ -5498,8 +5501,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
     return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
 					   "%Lf", __val);
   }
+#endif // _GLIBCXX_USE_C99_STDIO
 
-#ifdef _GLIBCXX_USE_WCHAR_T
+#if defined(_GLIBCXX_USE_WCHAR_T) && defined(_GLIBCXX_USE_C99_WCHAR)
   inline int 
   stoi(const wstring& __str, size_t* __idx = 0, int __base = 10)
   { return __gnu_cxx::__stoa<long, int>(&std::wcstol, "stoi", __str.c_str(),
@@ -5601,13 +5605,13 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
 					    L"%Lf", __val);
   }
 #endif // _GLIBCXX_HAVE_BROKEN_VSWPRINTF
-#endif
+#endif // _GLIBCXX_USE_WCHAR_T && _GLIBCXX_USE_C99_WCHAR
 
 _GLIBCXX_END_NAMESPACE_CXX11
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
 
-#endif /* C++11 && _GLIBCXX_USE_C99 ... */
+#endif /* C++11 */
 
 #if __cplusplus >= 201103L
 
diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config
index 924f13e..723feb1 100644
--- a/libstdc++-v3/include/bits/c++config
+++ b/libstdc++-v3/include/bits/c++config
@@ -529,4 +529,40 @@ namespace std
 #undef min
 #undef max
 
+// N.B. these _GLIBCXX_USE_C99_XXX macros are defined unconditionally
+// so they should be tested with #if not with #ifdef.
+#if __cplusplus >= 201103L
+# ifndef _GLIBCXX_USE_C99_MATH
+#  define _GLIBCXX_USE_C99_MATH _GLIBCXX11_USE_C99_MATH
+# endif
+# ifndef _GLIBCXX_USE_C99_COMPLEX
+# define _GLIBCXX_USE_C99_COMPLEX _GLIBCXX11_USE_C99_COMPLEX
+# endif
+# ifndef _GLIBCXX_USE_C99_STDIO
+# define _GLIBCXX_USE_C99_STDIO _GLIBCXX11_USE_C99_STDIO
+# endif
+# ifndef _GLIBCXX_USE_C99_STDLIB
+# define _GLIBCXX_USE_C99_STDLIB _GLIBCXX11_USE_C99_STDLIB
+# endif
+# ifndef _GLIBCXX_USE_C99_WCHAR
+# define _GLIBCXX_USE_C99_WCHAR _GLIBCXX11_USE_C99_WCHAR
+# endif
+#else
+# ifndef _GLIBCXX_USE_C99_MATH
+#  define _GLIBCXX_USE_C99_MATH _GLIBCXX98_USE_C99_MATH
+# endif
+# ifndef _GLIBCXX_USE_C99_COMPLEX
+# define _GLIBCXX_USE_C99_COMPLEX _GLIBCXX98_USE_C99_COMPLEX
+# endif
+# ifndef _GLIBCXX_USE_C99_STDIO
+# define _GLIBCXX_USE_C99_STDIO _GLIBCXX98_USE_C99_STDIO
+# endif
+# ifndef _GLIBCXX_USE_C99_STDLIB
+# define _GLIBCXX_USE_C99_STDLIB _GLIBCXX98_USE_C99_STDLIB
+# endif
+# ifndef _GLIBCXX_USE_C99_WCHAR
+# define _GLIBCXX_USE_C99_WCHAR _GLIBCXX98_USE_C99_WCHAR
+# endif
+#endif
+
 // End of prewritten config; the settings discovered at configure time follow.
diff --git a/libstdc++-v3/include/bits/locale_facets.tcc b/libstdc++-v3/include/bits/locale_facets.tcc
index bd58771..2db2d83 100644
--- a/libstdc++-v3/include/bits/locale_facets.tcc
+++ b/libstdc++-v3/include/bits/locale_facets.tcc
@@ -959,13 +959,13 @@ _GLIBCXX_BEGIN_NAMESPACE_LDBL
     }
 
   // The following code uses vsnprintf (or vsprintf(), when
-  // _GLIBCXX_USE_C99 is not defined) to convert floating point values
-  // for insertion into a stream.  An optimization would be to replace
-  // them with code that works directly on a wide buffer and then use
-  // __pad to do the padding.  It would be good to replace them anyway
-  // to gain back the efficiency that C++ provides by knowing up front
-  // the type of the values to insert.  Also, sprintf is dangerous
-  // since may lead to accidental buffer overruns.  This
+  // _GLIBCXX_USE_C99_STDIO is not defined) to convert floating point
+  // values for insertion into a stream.  An optimization would be to
+  // replace them with code that works directly on a wide buffer and
+  // then use __pad to do the padding.  It would be good to replace
+  // them anyway to gain back the efficiency that C++ provides by
+  // knowing up front the type of the values to insert.  Also, sprintf
+  // is dangerous since may lead to accidental buffer overruns.  This
   // implementation follows the C++ standard fairly directly as
   // outlined in 22.2.2.2 [lib.locale.num.put]
   template<typename _CharT, typename _OutIter>
@@ -992,7 +992,7 @@ _GLIBCXX_BEGIN_NAMESPACE_LDBL
 	char __fbuf[16];
 	__num_base::_S_format_float(__io, __fbuf, __mod);
 
-#ifdef _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_STDIO
 	// Precision is always used except for hexfloat format.
 	const bool __use_prec =
 	  (__io.flags() & ios_base::floatfield) != ios_base::floatfield;
diff --git a/libstdc++-v3/include/bits/locale_facets_nonio.tcc b/libstdc++-v3/include/bits/locale_facets_nonio.tcc
index 2e73b5d..631ef53 100644
--- a/libstdc++-v3/include/bits/locale_facets_nonio.tcc
+++ b/libstdc++-v3/include/bits/locale_facets_nonio.tcc
@@ -578,7 +578,7 @@ _GLIBCXX_BEGIN_NAMESPACE_LDBL_OR_CXX11
     {
       const locale __loc = __io.getloc();
       const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
-#ifdef _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_STDIO
       // First try a buffer perhaps big enough.
       int __cs_size = 64;
       char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
@@ -751,7 +751,7 @@ _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
 		case 'S':
 		  // Seconds. [tm_sec]
 		  // [00, 60] in C99 (one leap-second), [00, 61] in C89.
-#ifdef _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99
 		  __beg = _M_extract_num(__beg, __end, __tm->tm_sec, 0, 60, 2,
 #else
 		  __beg = _M_extract_num(__beg, __end, __tm->tm_sec, 0, 61, 2,
diff --git a/libstdc++-v3/include/c_compatibility/math.h b/libstdc++-v3/include/c_compatibility/math.h
index d6acb6d..7729896 100644
--- a/libstdc++-v3/include/c_compatibility/math.h
+++ b/libstdc++-v3/include/c_compatibility/math.h
@@ -56,7 +56,7 @@ using std::fabs;
 using std::floor;
 using std::fmod;
 
-#if _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_MATH
 using std::fpclassify;
 using std::isfinite;
 using std::isinf;
diff --git a/libstdc++-v3/include/c_compatibility/wchar.h b/libstdc++-v3/include/c_compatibility/wchar.h
index 06b5d47..3bc12d0 100644
--- a/libstdc++-v3/include/c_compatibility/wchar.h
+++ b/libstdc++-v3/include/c_compatibility/wchar.h
@@ -103,7 +103,7 @@ using std::wmemmove;
 using std::wmemset;
 using std::wcsftime;
 
-#if _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_WCHAR
 using std::wcstold;
 using std::wcstoll;
 using std::wcstoull;
diff --git a/libstdc++-v3/include/c_global/cstdio b/libstdc++-v3/include/c_global/cstdio
index d1c958b..486cee9 100644
--- a/libstdc++-v3/include/c_global/cstdio
+++ b/libstdc++-v3/include/c_global/cstdio
@@ -146,7 +146,7 @@ namespace std
   using ::vsprintf;
 } // namespace
 
-#if _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_STDIO
 
 #undef snprintf
 #undef vfscanf
@@ -189,6 +189,6 @@ namespace std
   using ::__gnu_cxx::vsscanf;
 } // namespace std
 
-#endif // _GLIBCXX_USE_C99
+#endif // _GLIBCXX_USE_C99_STDIO
 
 #endif
diff --git a/libstdc++-v3/include/c_global/cstdlib b/libstdc++-v3/include/c_global/cstdlib
index 7e9bb30..a2f44fc 100644
--- a/libstdc++-v3/include/c_global/cstdlib
+++ b/libstdc++-v3/include/c_global/cstdlib
@@ -195,7 +195,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
 
-#if _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_STDLIB
 
 #undef _Exit
 #undef llabs
@@ -266,7 +266,7 @@ namespace std
   using ::__gnu_cxx::strtold;
 } // namespace std
 
-#endif // _GLIBCXX_USE_C99
+#endif // _GLIBCXX_USE_C99_STDLIB
 
 #endif // !_GLIBCXX_HOSTED
 
diff --git a/libstdc++-v3/include/c_global/cwchar b/libstdc++-v3/include/c_global/cwchar
index dddb409..1571463 100644
--- a/libstdc++-v3/include/c_global/cwchar
+++ b/libstdc++-v3/include/c_global/cwchar
@@ -232,7 +232,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
 
-#if _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_WCHAR
 
 #undef wcstold
 #undef wcstoll
@@ -289,7 +289,7 @@ namespace std
   using std::vwscanf;
 #endif
 
-#if _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_WCHAR
   using std::wcstold;
   using std::wcstoll;
   using std::wcstoull;
diff --git a/libstdc++-v3/include/c_std/cstdio b/libstdc++-v3/include/c_std/cstdio
index 37f01ca..b7860f9 100644
--- a/libstdc++-v3/include/c_std/cstdio
+++ b/libstdc++-v3/include/c_std/cstdio
@@ -144,7 +144,7 @@ namespace std
   using ::vsprintf;
 } // namespace std
 
-#if _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_STDIO
 
 #undef snprintf
 #undef vfscanf
diff --git a/libstdc++-v3/include/c_std/cstdlib b/libstdc++-v3/include/c_std/cstdlib
index 0bd7058..7b69884 100644
--- a/libstdc++-v3/include/c_std/cstdlib
+++ b/libstdc++-v3/include/c_std/cstdlib
@@ -192,7 +192,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
 
-#if _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_STDLIB
 
 #undef _Exit
 #undef llabs
@@ -263,7 +263,7 @@ namespace std
   using ::__gnu_cxx::strtold;
 } // namespace std
 
-#endif // _GLIBCXX_USE_C99
+#endif // _GLIBCXX_USE_C99_STDLIB
 
 #endif // !_GLIBCXX_HOSTED
 
diff --git a/libstdc++-v3/include/c_std/cwchar b/libstdc++-v3/include/c_std/cwchar
index aa1b2fa..5aade7f 100644
--- a/libstdc++-v3/include/c_std/cwchar
+++ b/libstdc++-v3/include/c_std/cwchar
@@ -228,7 +228,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
 
-#if _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_WCHAR
 
 #undef wcstold
 #undef wcstoll
diff --git a/libstdc++-v3/include/ext/vstring.h b/libstdc++-v3/include/ext/vstring.h
index 68acd57..8732bd3 100644
--- a/libstdc++-v3/include/ext/vstring.h
+++ b/libstdc++-v3/include/ext/vstring.h
@@ -2680,7 +2680,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
 
-#if ((__cplusplus >= 201103L) && defined(_GLIBCXX_USE_C99))
+#if __cplusplus >= 201103L
 
 #include <ext/string_conversions.h>
 
@@ -2688,6 +2688,7 @@ namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
+#if _GLIBCXX_USE_C99_STDLIB
   // 21.4 Numeric Conversions [string.conversions].
   inline int
   stoi(const __vstring& __str, std::size_t* __idx = 0, int __base = 10)
@@ -2726,7 +2727,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   inline long double
   stold(const __vstring& __str, std::size_t* __idx = 0)
   { return __gnu_cxx::__stoa(&std::strtold, "stold", __str.c_str(), __idx); }
+#endif // _GLIBCXX_USE_C99_STDLIB
 
+#if _GLIBCXX_USE_C99_STDIO
   // NB: (v)snprintf vs sprintf.
 
   // DR 1261.
@@ -2789,8 +2792,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     return __gnu_cxx::__to_xstring<__vstring>(&std::vsnprintf, __n,
 					      "%Lf", __val);
   }
+#endif // _GLIBCXX_USE_C99_STDIO
 
-#ifdef _GLIBCXX_USE_WCHAR_T
+#if defined(_GLIBCXX_USE_WCHAR_T) && defined(_GLIBCXX_USE_C99_WCHAR)
   inline int 
   stoi(const __wvstring& __str, std::size_t* __idx = 0, int __base = 10)
   { return __gnu_cxx::__stoa<long, int>(&std::wcstol, "stoi", __str.c_str(),
@@ -2890,8 +2894,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     return __gnu_cxx::__to_xstring<__wvstring>(&std::vswprintf, __n,
 					       L"%Lf", __val);
   }
-#endif
-#endif
+#endif // _GLIBCXX_HAVE_BROKEN_VSWPRINTF
+#endif // _GLIBCXX_USE_WCHAR_T && _GLIBCXX_USE_C99_WCHAR
 
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
diff --git a/libstdc++-v3/include/std/complex b/libstdc++-v3/include/std/complex
index 5ed4fd5..f1d3b79 100644
--- a/libstdc++-v3/include/std/complex
+++ b/libstdc++-v3/include/std/complex
@@ -995,7 +995,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     complex<_Tp>
     pow(const complex<_Tp>& __x, const _Tp& __y)
     {
-#ifndef _GLIBCXX_USE_C99_COMPLEX
+#if ! _GLIBCXX_USE_C99_COMPLEX
       if (__x == _Tp())
 	return _Tp();
 #endif
@@ -1831,7 +1831,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     arg(_Tp __x)
     {
       typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
-#if (_GLIBCXX_USE_C99_MATH && !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC)
+#if (_GLIBCXX11_USE_C99_MATH && !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC)
       return std::signbit(__x) ? __type(3.1415926535897932384626433832795029L)
 	                       : __type();
 #else
diff --git a/libstdc++-v3/include/tr1/cstdio b/libstdc++-v3/include/tr1/cstdio
index 7681823..b8fc04f 100644
--- a/libstdc++-v3/include/tr1/cstdio
+++ b/libstdc++-v3/include/tr1/cstdio
@@ -33,7 +33,7 @@
 
 #include <cstdio>
 
-#if _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_STDIO
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
diff --git a/libstdc++-v3/include/tr1/cstdlib b/libstdc++-v3/include/tr1/cstdlib
index c3c65eb..35a9133 100644
--- a/libstdc++-v3/include/tr1/cstdlib
+++ b/libstdc++-v3/include/tr1/cstdlib
@@ -35,7 +35,7 @@
 
 #if _GLIBCXX_HOSTED
 
-#if _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_STDLIB
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
@@ -65,7 +65,7 @@ namespace tr1
 }
 }
 
-#endif // _GLIBCXX_USE_C99 
+#endif // _GLIBCXX_USE_C99_STDLIB
 
 #endif // _GLIBCXX_HOSTED
 
diff --git a/libstdc++-v3/include/tr1/cwchar b/libstdc++-v3/include/tr1/cwchar
index 10772ee..0db2262 100644
--- a/libstdc++-v3/include/tr1/cwchar
+++ b/libstdc++-v3/include/tr1/cwchar
@@ -52,7 +52,7 @@ namespace tr1
   using std::vwscanf;
 #endif
 
-#if _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_WCHAR
   using std::wcstold;
   using std::wcstoll;
   using std::wcstoull;
diff --git a/libstdc++-v3/include/tr1/stdlib.h b/libstdc++-v3/include/tr1/stdlib.h
index 310c7bc..5e826d6 100644
--- a/libstdc++-v3/include/tr1/stdlib.h
+++ b/libstdc++-v3/include/tr1/stdlib.h
@@ -33,7 +33,7 @@
 
 #if _GLIBCXX_HOSTED
 
-#if _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_STDLIB
 
 using std::tr1::atoll;
 using std::tr1::strtoll;
diff --git a/libstdc++-v3/src/c++98/locale_facets.cc b/libstdc++-v3/src/c++98/locale_facets.cc
index 071f79e..28b6f3a 100644
--- a/libstdc++-v3/src/c++98/locale_facets.cc
+++ b/libstdc++-v3/src/c++98/locale_facets.cc
@@ -72,7 +72,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
     ios_base::fmtflags __fltfield = __flags & ios_base::floatfield;
 
-#ifdef _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_STDIO
     // Precision is always used except for hexfloat format.
     if (__fltfield != (ios_base::fixed | ios_base::scientific))
 #endif
@@ -89,7 +89,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       *__fptr++ = 'f';
     else if (__fltfield == ios_base::scientific)
       *__fptr++ = (__flags & ios_base::uppercase) ? 'E' : 'e';
-#ifdef _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_STDIO
     else if (__fltfield == (ios_base::fixed | ios_base::scientific))
       *__fptr++ = (__flags & ios_base::uppercase) ? 'A' : 'a';
 #endif
diff --git a/libstdc++-v3/testsuite/18_support/exception_ptr/60612-terminate.cc b/libstdc++-v3/testsuite/18_support/exception_ptr/60612-terminate.cc
index 5f0a4bf..1a53c06 100644
--- a/libstdc++-v3/testsuite/18_support/exception_ptr/60612-terminate.cc
+++ b/libstdc++-v3/testsuite/18_support/exception_ptr/60612-terminate.cc
@@ -23,7 +23,7 @@
 #include <exception>
 #include <stdlib.h>
 
-#ifdef _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_STDLIB
 void terminate() { _Exit(0); }
 
 void f() noexcept
@@ -39,7 +39,7 @@ void f() noexcept
 
 int main()
 {
-#ifdef _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_STDLIB
   f();
 #endif
   return 0;
diff --git a/libstdc++-v3/testsuite/18_support/exception_ptr/60612-unexpected.cc b/libstdc++-v3/testsuite/18_support/exception_ptr/60612-unexpected.cc
index ed3930a..3f8e08d 100644
--- a/libstdc++-v3/testsuite/18_support/exception_ptr/60612-unexpected.cc
+++ b/libstdc++-v3/testsuite/18_support/exception_ptr/60612-unexpected.cc
@@ -23,7 +23,7 @@
 #include <exception>
 #include <stdlib.h>
 
-#ifdef _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_STDLIB
 void unexpected() { _Exit(0); }
 
 void f() throw()
@@ -39,7 +39,7 @@ void f() throw()
 
 int main()
 {
-#ifdef _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_STDLIB
   f();
 #endif
 }
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stod.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stod.cc
index c270d76..ea284cc 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stod.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stod.cc
@@ -29,7 +29,7 @@
 void
 test01()
 {
-#ifdef _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_WCHAR
 
   bool test __attribute__((unused)) = false;
   using namespace std;
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stof.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stof.cc
index 2bb7aea..fd54d57 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stof.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stof.cc
@@ -29,7 +29,7 @@
 void
 test01()
 {
-#ifdef _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_WCHAR
 
   bool test __attribute__((unused)) = false;
   using namespace std;
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoi.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoi.cc
index 24aceb6..8cd0ea1 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoi.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoi.cc
@@ -29,7 +29,7 @@
 void
 test01()
 {
-#ifdef _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_WCHAR
 
   bool test __attribute__((unused)) = false;
   using namespace std;
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stol.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stol.cc
index bc50156..9be3f39 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stol.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stol.cc
@@ -29,7 +29,7 @@
 void
 test01()
 {
-#ifdef _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_WCHAR
 
   bool test __attribute__((unused)) = false;
   using namespace std;
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stold.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stold.cc
index 1461adb..7d9e414 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stold.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stold.cc
@@ -29,7 +29,7 @@
 void
 test01()
 {
-#ifdef _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_WCHAR
 
   bool test __attribute__((unused)) = false;
   using namespace std;
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoll.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoll.cc
index cc91c24..2927da3 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoll.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoll.cc
@@ -29,7 +29,7 @@
 void
 test01()
 {
-#ifdef _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_WCHAR
 
   bool test __attribute__((unused)) = false;
   using namespace std;
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoul.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoul.cc
index 6c26c2bb..256cee5 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoul.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoul.cc
@@ -29,7 +29,7 @@
 void
 test01()
 {
-#ifdef _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_WCHAR
 
   bool test __attribute__((unused)) = false;
   using namespace std;
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoull.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoull.cc
index 91b6479..e102c6a 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoull.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoull.cc
@@ -29,7 +29,7 @@
 void
 test01()
 {
-#ifdef _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_WCHAR
 
   bool test __attribute__((unused)) = false;
   using namespace std;
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/to_wstring.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/to_wstring.cc
index e36c30e..467bd9f 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/to_wstring.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/to_wstring.cc
@@ -27,7 +27,7 @@
 void
 test01()
 {
-#ifdef _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_WCHAR
 
   bool test __attribute__((unused)) = true;
   using namespace std;
diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cstdlib/13943.cc b/libstdc++-v3/testsuite/26_numerics/headers/cstdlib/13943.cc
index 33f8000..50c6b32 100644
--- a/libstdc++-v3/testsuite/26_numerics/headers/cstdlib/13943.cc
+++ b/libstdc++-v3/testsuite/26_numerics/headers/cstdlib/13943.cc
@@ -19,7 +19,7 @@
 #include <cstdlib>
 #include <testsuite_hooks.h>
 
-#if _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_STDLIB
 // libstdc++/13943
 void test01()
 {
@@ -36,7 +36,7 @@ void test01()
 
 int main()
 {
-#if _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_STDLIB
   test01();
 #endif
   return 0;
diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cstdlib/types_std_c++0x.cc b/libstdc++-v3/testsuite/26_numerics/headers/cstdlib/types_std_c++0x.cc
index 0511043..bfcbe9a 100644
--- a/libstdc++-v3/testsuite/26_numerics/headers/cstdlib/types_std_c++0x.cc
+++ b/libstdc++-v3/testsuite/26_numerics/headers/cstdlib/types_std_c++0x.cc
@@ -24,10 +24,10 @@
 
 void test01()
 {
-#if _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_STDLIB
 
   typedef std::lldiv_t     my_lldiv_t;
-  
+
 #endif
 }
 
diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp b/libstdc++-v3/testsuite/lib/libstdc++.exp
index 9a6726c..6a62dfd 100644
--- a/libstdc++-v3/testsuite/lib/libstdc++.exp
+++ b/libstdc++-v3/testsuite/lib/libstdc++.exp
@@ -1614,7 +1614,7 @@ proc check_v3_target_string_conversions { } {
 
         set f [open $src "w"]
         puts $f "#include <bits/c++config.h>"
-        puts $f "#if !defined(_GLIBCXX_USE_C99) || defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF)"
+        puts $f "#if !(_GLIBCXX_USE_C99_STDIO && _GLIBCXX_USE_C99_STDLIB && _GLIBCXX_USE_C99_WCHAR) || defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF)"
         puts $f "#  error No string conversions"
         puts $f "#endif"
         close $f
diff --git a/libstdc++-v3/testsuite/tr1/8_c_compatibility/cmath/templates.cc b/libstdc++-v3/testsuite/tr1/8_c_compatibility/cmath/templates.cc
index b75fda2..ac8933c 100644
--- a/libstdc++-v3/testsuite/tr1/8_c_compatibility/cmath/templates.cc
+++ b/libstdc++-v3/testsuite/tr1/8_c_compatibility/cmath/templates.cc
@@ -23,7 +23,7 @@
 
 #include <tr1/cmath>
 
-#if _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_MATH
 #if !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC
 
 template<typename T>
diff --git a/libstdc++-v3/testsuite/tr1/8_c_compatibility/cstdio/functions.cc b/libstdc++-v3/testsuite/tr1/8_c_compatibility/cstdio/functions.cc
index 0c913e0..5a9eb6c 100644
--- a/libstdc++-v3/testsuite/tr1/8_c_compatibility/cstdio/functions.cc
+++ b/libstdc++-v3/testsuite/tr1/8_c_compatibility/cstdio/functions.cc
@@ -30,7 +30,7 @@ void test01(int dummy, ...)
   std::va_list ap;
   va_start(ap, dummy);
 
-#if _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_STDIO
 
   char* s = 0;
   const char* cs = 0;
diff --git a/libstdc++-v3/testsuite/tr1/8_c_compatibility/cstdlib/functions.cc b/libstdc++-v3/testsuite/tr1/8_c_compatibility/cstdlib/functions.cc
index cfa748d..dfa08ef 100644
--- a/libstdc++-v3/testsuite/tr1/8_c_compatibility/cstdlib/functions.cc
+++ b/libstdc++-v3/testsuite/tr1/8_c_compatibility/cstdlib/functions.cc
@@ -27,7 +27,7 @@
 
 void test01()
 {
-#if _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_STDLIB
 
   long long i = 0;
   const char* s = 0;
diff --git a/libstdc++-v3/testsuite/tr1/8_c_compatibility/cstdlib/types_std_tr1.cc b/libstdc++-v3/testsuite/tr1/8_c_compatibility/cstdlib/types_std_tr1.cc
index 002b6a5..1252463 100644
--- a/libstdc++-v3/testsuite/tr1/8_c_compatibility/cstdlib/types_std_tr1.cc
+++ b/libstdc++-v3/testsuite/tr1/8_c_compatibility/cstdlib/types_std_tr1.cc
@@ -27,10 +27,10 @@
 
 void test01()
 {
-#if _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_STDLIB
 
   typedef std::tr1::lldiv_t     my_lldiv_t;
-  
+
 #endif
 }
 
diff --git a/libstdc++-v3/testsuite/tr1/8_c_compatibility/cwchar/functions.cc b/libstdc++-v3/testsuite/tr1/8_c_compatibility/cwchar/functions.cc
index b964661..c745b19 100644
--- a/libstdc++-v3/testsuite/tr1/8_c_compatibility/cwchar/functions.cc
+++ b/libstdc++-v3/testsuite/tr1/8_c_compatibility/cwchar/functions.cc
@@ -67,7 +67,7 @@ void test01(int dummy, ...)
   ret3 = ret3; // Suppress unused warning.
 #endif
 
-#if _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_WCHAR
 
   const wchar_t* nptr2 = 0;
   wchar_t** endptr2 = 0;
diff --git a/libstdc++-v3/testsuite/util/testsuite_fs.h b/libstdc++-v3/testsuite/util/testsuite_fs.h
index 44aef11..ddcbdcc 100644
--- a/libstdc++-v3/testsuite/util/testsuite_fs.h
+++ b/libstdc++-v3/testsuite/util/testsuite_fs.h
@@ -83,7 +83,7 @@ namespace __gnu_test
     p = tmp;
 #else
     char buf[64];
-#if _GLIBCXX_USE_C99
+#if _GLIBCXX_USE_C99_STDIO
     std::snprintf(buf, 64, "filesystem-ts-test.%lu", (unsigned long)::getpid());
 #else
     std::sprintf(buf, "filesystem-ts-test.%lu", (unsigned long)::getpid());

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] Enable libstdc++ numeric conversions on Cygwin
  2015-11-13 14:52         ` Jonathan Wakely
@ 2015-11-14  8:37           ` Christophe Lyon
  2015-11-14 13:58             ` Jonathan Wakely
  2015-11-14 16:32             ` Jonathan Wakely
  2015-12-08 10:59           ` Alan Lawrence
  1 sibling, 2 replies; 20+ messages in thread
From: Christophe Lyon @ 2015-11-14  8:37 UTC (permalink / raw)
  To: Jonathan Wakely; +Cc: Jennifer Yao, libstdc++, gcc-patches, Andreas Tobler

On 13 November 2015 at 15:52, Jonathan Wakely <jwakely@redhat.com> wrote:
> On 12/11/15 13:39 +0000, Jonathan Wakely wrote:
>>
>> On 12/11/15 11:40 +0000, Jonathan Wakely wrote:
>>>
>>> On 18/09/15 12:01 -0400, Jennifer Yao wrote:
>>>>
>>>> Forgot to include the patch.
>>>>
>>>> On Fri, Sep 18, 2015 at 11:17 AM, Jennifer Yao
>>>> <jenny.hyphen.fa@gmail.com> wrote:
>>>>>
>>>>> A number of functions in libstdc++ are guarded by the _GLIBCXX_USE_C99
>>>>> preprocessor macro, which is only defined on systems that pass all of
>>>>> the checks for a large set of C99 functions. Consequently, on systems
>>>>> which lack any of the required C99 facilities (e.g. Cygwin, which
>>>>> lacks some C99 complex math functions), the numeric conversion
>>>>> functions (std::stoi(), std::stol(), std::to_string(), etc.) are not
>>>>> defined—a rather silly outcome, as none of the numeric conversion
>>>>> functions are implemented using C99 math functions.
>>>>>
>>>>> This patch enables numeric conversion functions on the aforementioned
>>>>> systems by splitting the checks for C99 support and defining several
>>>>> new macros (_GLIBCXX_USE_C99_STDIO, _GLIBCXX_USE_C99_STDLIB, and
>>>>> _GLIBCXX_USE_C99_WCHAR), which replace the use of _GLIBCXX_USE_C99 in
>>>>> #if conditionals where appropriate.
>>>
>>>
>>> (Coming back to this now that Jennifer's copyright assignment is
>>> complete...)
>>>
>>> Splitting the _GLIBCXX_USE_C99 macro into more fine-grained macros for
>>> separate features is definitely the right direction.
>>>
>>> However your patch also changes the configure tests to use -std=c++0x
>>> (which should be -std=c++11, but that's a minor point). On an OS that
>>> only makes the C99 library available conditionally that will mean that
>>> configure determines that C99 library features are supported, but we
>>> will get errors if we try to use those features in C++03 parts of the
>>> library.
>>>
>>> I think a more complete solution is to have two sets of configure
>>> tests and two sets of macros, so that we define _GLIBCXX_USE_C99_STDIO
>>> when C99 stdio is available unconditionally, and define
>>> _GLIBCXX11_USE_C99_STDIO when it's available with -std=c++11.
>>>
>>> Then in the library code we can check _GLIBCXX_USE_C99_STDIO if we
>>> want to use C99 features in C++03 code, and check
>>> _GLIBCXX11_USE_C99_STDIO if we want to use the features in C++11 code.
>>>
>>> That should still solve the problem for the numeric conversion
>>> functions, because they are defined in C++11 and so would check
>>> _GLIBCXX11_USE_C99_STDIO, which will be defined for newlib.
>>>
>>> Other pieces of the library, such as locales, will use
>>> _GLIBCXX_USE_C99_STDIO and that might still be false for newlib (and
>>> for other strict C libraries like the Solaris and FreeBSD libc).
>>>
>>> I will make the changes to acinclude.m4 to duplicate the tests, so we
>>> test once with -std=c++98 and once with -std=c++11, and then change
>>> the library to check either _GLIBCXX_xxx or _GLIBCXX11_xxx as
>>> appropriate.
>>
>>
>> Here's a patch implementing my suggestion.
>>
>> The major changes since Jennifer's original patch are in acinclude.m4,
>> to do the autoconf tests once with -std=c++98 and again with
>> -std=c++11, and in include/bits/c++config to define the
>> _GLIBCXX_USE_C99_XXX macros according to either _GLIBCXX98_USE_CXX_XXX
>> or _GLIBCXX11_USE_CXX_XXX, depending on the standard mode in effect
>> when the file is included.
>>
>> Because those new definitions in bits/c++config are unconditional I
>> had to adjust a few #ifdef tests to use #if instead.
>>
>> I also removed the changes to GLIBCXX_CHECK_C99_TR1, so that there are
>> no changes to the macros used for the TR1 library. As a follow-up
>> change I will add a test for <stdint.h> to GLIBCXX_ENABLE_C99 and
>> change several C++ headers to stop using the TR1 macros.
>>
>> This passes all tests on powerpc64le-linux, I'll also try to test on
>> DragonFly and FreeBSD.
>
>
> That patch was wrong, the new macros in include/bits/c++config used
> "CSTDIO" instead of "STDIO" so it caused several tests to go from
> PASS to UNSUPPORTED, oops!
>
> This is the correct version, tested again more carefully, on
> powerpc64le-linux and powerpc-aix and x86_64-dragonfly.
>
> Committed to trunk.
>

Hi, this commit makes the GCC build to fail for targets using newlib
(I tested arm-none-eabi and aarch64-none-elf)

I'm seeing errors such as:
In file included from
/tmp/9122162_8.tmpdir/aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-aarch64_be-none-elf/gcc3/aarch64_be-none-elf/libstdc++-v3/include/string:52:0,
                 from
/tmp/9122162_8.tmpdir/aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-aarch64_be-none-elf/gcc3/aarch64_be-none-elf/libstdc++-v3/include/bits/locale_classes.h:40,
                 from
/tmp/9122162_8.tmpdir/aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-aarch64_be-none-elf/gcc3/aarch64_be-none-elf/libstdc++-v3/include/bits/ios_base.h:41,
                 from
/tmp/9122162_8.tmpdir/aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-aarch64_be-none-elf/gcc3/aarch64_be-none-elf/libstdc++-v3/include/ios:42,
                 from
/tmp/9122162_8.tmpdir/aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-aarch64_be-none-elf/gcc3/aarch64_be-none-elf/libstdc++-v3/include/istream:38,
                 from
/tmp/9122162_8.tmpdir/aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-aarch64_be-none-elf/gcc3/aarch64_be-none-elf/libstdc++-v3/include/sstream:38,
                 from
/tmp/9122162_8.tmpdir/aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-aarch64_be-none-elf/gcc3/aarch64_be-none-elf/libstdc++-v3/include/complex:45,
                 from
/tmp/9122162_8.tmpdir/aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-aarch64_be-none-elf/gcc3/aarch64_be-none-elf/libstdc++-v3/include/ccomplex:38,
                 from
/tmp/9122162_8.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/libstdc++-v3/include/precompiled/stdc++.h:52:
/tmp/9122162_8.tmpdir/aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-aarch64_be-none-elf/gcc3/aarch64_be-none-elf/libstdc++-v3/include/bits/basic_string.h:
In function 'long long int std::__cxx11::stoll(const wstring&,
std::size_t*, int)':
/tmp/9122162_8.tmpdir/aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-aarch64_be-none-elf/gcc3/aarch64_be-none-elf/libstdc++-v3/include/bits/basic_string.h:5524:31:
error: 'wcstoll' is not a member of 'std'
   { return __gnu_cxx::__stoa(&std::wcstoll, "stoll", __str.c_str(),
                               ^
Sorry I can't provide more details until Monday.

Christophe.




> Jennifer, thanks very much for making this happen.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] Enable libstdc++ numeric conversions on Cygwin
  2015-11-14  8:37           ` Christophe Lyon
@ 2015-11-14 13:58             ` Jonathan Wakely
  2015-11-14 21:23               ` Jennifer Yao
  2015-11-14 16:32             ` Jonathan Wakely
  1 sibling, 1 reply; 20+ messages in thread
From: Jonathan Wakely @ 2015-11-14 13:58 UTC (permalink / raw)
  To: Christophe Lyon; +Cc: Jennifer Yao, libstdc++, gcc-patches, Andreas Tobler

On 14/11/15 09:37 +0100, Christophe Lyon wrote:
>Hi, this commit makes the GCC build to fail for targets using newlib

Doh, this was supposed to *help* newlib!

I'll deal with it asap.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] Enable libstdc++ numeric conversions on Cygwin
  2015-11-14  8:37           ` Christophe Lyon
  2015-11-14 13:58             ` Jonathan Wakely
@ 2015-11-14 16:32             ` Jonathan Wakely
  2015-11-15  8:58               ` Christophe Lyon
  1 sibling, 1 reply; 20+ messages in thread
From: Jonathan Wakely @ 2015-11-14 16:32 UTC (permalink / raw)
  To: Christophe Lyon; +Cc: Jennifer Yao, libstdc++, gcc-patches, Andreas Tobler

On 14/11/15 09:37 +0100, Christophe Lyon wrote:
>Hi, this commit makes the GCC build to fail for targets using newlib
>(I tested arm-none-eabi and aarch64-none-elf)
>
>I'm seeing errors such as:
>In file included from
>/tmp/9122162_8.tmpdir/aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-aarch64_be-none-elf/gcc3/aarch64_be-none-elf/libstdc++-v3/include/string:52:0,
>                 from
>/tmp/9122162_8.tmpdir/aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-aarch64_be-none-elf/gcc3/aarch64_be-none-elf/libstdc++-v3/include/bits/locale_classes.h:40,
>                 from
>/tmp/9122162_8.tmpdir/aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-aarch64_be-none-elf/gcc3/aarch64_be-none-elf/libstdc++-v3/include/bits/ios_base.h:41,
>                 from
>/tmp/9122162_8.tmpdir/aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-aarch64_be-none-elf/gcc3/aarch64_be-none-elf/libstdc++-v3/include/ios:42,
>                 from
>/tmp/9122162_8.tmpdir/aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-aarch64_be-none-elf/gcc3/aarch64_be-none-elf/libstdc++-v3/include/istream:38,
>                 from
>/tmp/9122162_8.tmpdir/aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-aarch64_be-none-elf/gcc3/aarch64_be-none-elf/libstdc++-v3/include/sstream:38,
>                 from
>/tmp/9122162_8.tmpdir/aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-aarch64_be-none-elf/gcc3/aarch64_be-none-elf/libstdc++-v3/include/complex:45,
>                 from
>/tmp/9122162_8.tmpdir/aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-aarch64_be-none-elf/gcc3/aarch64_be-none-elf/libstdc++-v3/include/ccomplex:38,
>                 from
>/tmp/9122162_8.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/libstdc++-v3/include/precompiled/stdc++.h:52:
>/tmp/9122162_8.tmpdir/aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-aarch64_be-none-elf/gcc3/aarch64_be-none-elf/libstdc++-v3/include/bits/basic_string.h:
>In function 'long long int std::__cxx11::stoll(const wstring&,
>std::size_t*, int)':
>/tmp/9122162_8.tmpdir/aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-aarch64_be-none-elf/gcc3/aarch64_be-none-elf/libstdc++-v3/include/bits/basic_string.h:5524:31:
>error: 'wcstoll' is not a member of 'std'
>   { return __gnu_cxx::__stoa(&std::wcstoll, "stoll", __str.c_str(),
>                               ^

This shouldn't be possible unless you're using --enable-cheaders=c
because we have an autoconf test for wcstoll, and if it's found then
it should get added to namespace std by <cwchar>.

Could you let me know the output of:

grep C_INCLUDE_DIR /tmp/9122162_8.tmpdir/aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-aarch64_be-none-elf/gcc3/aarch64_be-none-elf/libstdc++-v3/include/Makefile

Or alternatively:

ls -l /tmp/9122162_8.tmpdir/aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-aarch64_be-none-elf/gcc3/aarch64_be-none-elf/libstdc++-v3/include/cwchar

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] Enable libstdc++ numeric conversions on Cygwin
  2015-11-14 13:58             ` Jonathan Wakely
@ 2015-11-14 21:23               ` Jennifer Yao
  2015-11-15 21:38                 ` Jennifer Yao
  0 siblings, 1 reply; 20+ messages in thread
From: Jennifer Yao @ 2015-11-14 21:23 UTC (permalink / raw)
  To: Jonathan Wakely; +Cc: Christophe Lyon, libstdc++, gcc-patches, Andreas Tobler

> Hi, this commit makes the GCC build to fail for targets using newlib
> (I tested arm-none-eabi and aarch64-none-elf)
>
> I'm seeing errors such as:
> In file included from
> /tmp/9122162_8.tmpdir/aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-aarch64_be-none-elf/gcc3/aarch64_be-none-elf/libstdc++-v3/include/string:52:0,
>                  from
> /tmp/9122162_8.tmpdir/aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-aarch64_be-none-elf/gcc3/aarch64_be-none-elf/libstdc++-v3/include/bits/locale_classes.h:40,
>                  from
> /tmp/9122162_8.tmpdir/aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-aarch64_be-none-elf/gcc3/aarch64_be-none-elf/libstdc++-v3/include/bits/ios_base.h:41,
>                  from
> /tmp/9122162_8.tmpdir/aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-aarch64_be-none-elf/gcc3/aarch64_be-none-elf/libstdc++-v3/include/ios:42,
>                  from
> /tmp/9122162_8.tmpdir/aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-aarch64_be-none-elf/gcc3/aarch64_be-none-elf/libstdc++-v3/include/istream:38,
>                  from
> /tmp/9122162_8.tmpdir/aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-aarch64_be-none-elf/gcc3/aarch64_be-none-elf/libstdc++-v3/include/sstream:38,
>                  from
> /tmp/9122162_8.tmpdir/aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-aarch64_be-none-elf/gcc3/aarch64_be-none-elf/libstdc++-v3/include/complex:45,
>                  from
> /tmp/9122162_8.tmpdir/aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-aarch64_be-none-elf/gcc3/aarch64_be-none-elf/libstdc++-v3/include/ccomplex:38,
>                  from
> /tmp/9122162_8.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/libstdc++-v3/include/precompiled/stdc++.h:52:
> /tmp/9122162_8.tmpdir/aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-aarch64_be-none-elf/gcc3/aarch64_be-none-elf/libstdc++-v3/include/bits/basic_string.h:
> In function 'long long int std::__cxx11::stoll(const wstring&,
> std::size_t*, int)':
> /tmp/9122162_8.tmpdir/aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-aarch64_be-none-elf/gcc3/aarch64_be-none-elf/libstdc++-v3/include/bits/basic_string.h:5524:31:
> error: 'wcstoll' is not a member of 'std'
>    { return __gnu_cxx::__stoa(&std::wcstoll, "stoll", __str.c_str(),
>                                ^
> Sorry I can't provide more details until Monday.

I just finished running the testsuite on x86_64-pc-cygwin for
Jonathan's latest patch and compared the results against an older
(about two months old) run, and so far I'm not seeing any regressions.
Granted, this is strictly preliminary; I'm currently re-running the
testsuite on the up-to-date, unpatched build tree to see if there are
any differences. I'll update when I have more information.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] Enable libstdc++ numeric conversions on Cygwin
  2015-11-14 16:32             ` Jonathan Wakely
@ 2015-11-15  8:58               ` Christophe Lyon
  2015-11-15 11:14                 ` Jonathan Wakely
  0 siblings, 1 reply; 20+ messages in thread
From: Christophe Lyon @ 2015-11-15  8:58 UTC (permalink / raw)
  To: Jonathan Wakely; +Cc: Jennifer Yao, libstdc++, gcc-patches, Andreas Tobler

On 14 November 2015 at 17:32, Jonathan Wakely <jwakely@redhat.com> wrote:
> On 14/11/15 09:37 +0100, Christophe Lyon wrote:
>>
>> Hi, this commit makes the GCC build to fail for targets using newlib
>> (I tested arm-none-eabi and aarch64-none-elf)
>>
>> I'm seeing errors such as:
>> In file included from
>>
>> /tmp/9122162_8.tmpdir/aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-aarch64_be-none-elf/gcc3/aarch64_be-none-elf/libstdc++-v3/include/string:52:0,
>>                 from
>>
>> /tmp/9122162_8.tmpdir/aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-aarch64_be-none-elf/gcc3/aarch64_be-none-elf/libstdc++-v3/include/bits/locale_classes.h:40,
>>                 from
>>
>> /tmp/9122162_8.tmpdir/aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-aarch64_be-none-elf/gcc3/aarch64_be-none-elf/libstdc++-v3/include/bits/ios_base.h:41,
>>                 from
>>
>> /tmp/9122162_8.tmpdir/aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-aarch64_be-none-elf/gcc3/aarch64_be-none-elf/libstdc++-v3/include/ios:42,
>>                 from
>>
>> /tmp/9122162_8.tmpdir/aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-aarch64_be-none-elf/gcc3/aarch64_be-none-elf/libstdc++-v3/include/istream:38,
>>                 from
>>
>> /tmp/9122162_8.tmpdir/aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-aarch64_be-none-elf/gcc3/aarch64_be-none-elf/libstdc++-v3/include/sstream:38,
>>                 from
>>
>> /tmp/9122162_8.tmpdir/aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-aarch64_be-none-elf/gcc3/aarch64_be-none-elf/libstdc++-v3/include/complex:45,
>>                 from
>>
>> /tmp/9122162_8.tmpdir/aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-aarch64_be-none-elf/gcc3/aarch64_be-none-elf/libstdc++-v3/include/ccomplex:38,
>>                 from
>>
>> /tmp/9122162_8.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/libstdc++-v3/include/precompiled/stdc++.h:52:
>>
>> /tmp/9122162_8.tmpdir/aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-aarch64_be-none-elf/gcc3/aarch64_be-none-elf/libstdc++-v3/include/bits/basic_string.h:
>> In function 'long long int std::__cxx11::stoll(const wstring&,
>> std::size_t*, int)':
>>
>> /tmp/9122162_8.tmpdir/aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-aarch64_be-none-elf/gcc3/aarch64_be-none-elf/libstdc++-v3/include/bits/basic_string.h:5524:31:
>> error: 'wcstoll' is not a member of 'std'
>>   { return __gnu_cxx::__stoa(&std::wcstoll, "stoll", __str.c_str(),
>>                               ^
>
>
> This shouldn't be possible unless you're using --enable-cheaders=c
> because we have an autoconf test for wcstoll, and if it's found then
> it should get added to namespace std by <cwchar>.

I configure newlib with:
        --enable-newlib-io-pos-args \
        --enable-newlib-io-c99-formats \
        --enable-newlib-io-long-long \
        --enable-newlib-io-long-double \
        --with-sysroot="${sysroot}"

Ha, and my newlib copy is not very recent, it's from Oct 30th 2013:
maybe it's too old?

>
> Could you let me know the output of:
>
> grep C_INCLUDE_DIR
> /tmp/9122162_8.tmpdir/aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-aarch64_be-none-elf/gcc3/aarch64_be-none-elf/libstdc++-v3/include/Makefile
>
C_INCLUDE_DIR = ${glibcxx_srcdir}/include/c_global
c_base_srcdir = $(C_INCLUDE_DIR)

> Or alternatively:
>
> ls -l
> /tmp/9122162_8.tmpdir/aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-aarch64_be-none-elf/gcc3/aarch64_be-none-elf/libstdc++-v3/include/cwchar
it's a symlink to libstdc++-v3/include/c_global/cwchar in the srcdir

>

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] Enable libstdc++ numeric conversions on Cygwin
  2015-11-15  8:58               ` Christophe Lyon
@ 2015-11-15 11:14                 ` Jonathan Wakely
  2015-11-15 16:25                   ` Christophe Lyon
  0 siblings, 1 reply; 20+ messages in thread
From: Jonathan Wakely @ 2015-11-15 11:14 UTC (permalink / raw)
  To: Christophe Lyon; +Cc: Jennifer Yao, libstdc++, gcc-patches, Andreas Tobler

[-- Attachment #1: Type: text/plain, Size: 545 bytes --]

On 15/11/15 09:58 +0100, Christophe Lyon wrote:
>Ha, and my newlib copy is not very recent, it's from Oct 30th 2013:
>maybe it's too old?

The autoconf checks should handle old versions as well as new.

The problem is I didn't change a defined(_GLIBCXX_USE_C99_WCHAR) to
just test its value, rather than whether it's defined.

As I added to include/bits/c++config on Friday:

// N.B. these _GLIBCXX_USE_C99_XXX macros are defined unconditionally
// so they should be tested with #if not with #ifdef.

Fixed with this patch, committed to trunk.


[-- Attachment #2: patch.txt --]
[-- Type: text/x-patch, Size: 1559 bytes --]

commit 8c33b5d8510378148bdac7247fd99b1f70eec04f
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Sun Nov 15 11:03:54 2015 +0000

    PR libstdc++/68353 fix _GLIBCXX_USE_C99_WCHAR test
    
    	PR libstdc++/68353
    	* include/bits/basic_string.h: Test value of _GLIBCXX_USE_C99_WCHAR
    	not whether it is defined.
    	* include/ext/vstring.h: Likewise.

diff --git a/libstdc++-v3/include/bits/basic_string.h b/libstdc++-v3/include/bits/basic_string.h
index b3853cd..e7f965e 100644
--- a/libstdc++-v3/include/bits/basic_string.h
+++ b/libstdc++-v3/include/bits/basic_string.h
@@ -5503,7 +5503,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
   }
 #endif // _GLIBCXX_USE_C99_STDIO
 
-#if defined(_GLIBCXX_USE_WCHAR_T) && defined(_GLIBCXX_USE_C99_WCHAR)
+#if defined(_GLIBCXX_USE_WCHAR_T) && _GLIBCXX_USE_C99_WCHAR
   inline int 
   stoi(const wstring& __str, size_t* __idx = 0, int __base = 10)
   { return __gnu_cxx::__stoa<long, int>(&std::wcstol, "stoi", __str.c_str(),
diff --git a/libstdc++-v3/include/ext/vstring.h b/libstdc++-v3/include/ext/vstring.h
index 8732bd3..529e4f3 100644
--- a/libstdc++-v3/include/ext/vstring.h
+++ b/libstdc++-v3/include/ext/vstring.h
@@ -2794,7 +2794,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   }
 #endif // _GLIBCXX_USE_C99_STDIO
 
-#if defined(_GLIBCXX_USE_WCHAR_T) && defined(_GLIBCXX_USE_C99_WCHAR)
+#if defined(_GLIBCXX_USE_WCHAR_T) && _GLIBCXX_USE_C99_WCHAR
   inline int 
   stoi(const __wvstring& __str, std::size_t* __idx = 0, int __base = 10)
   { return __gnu_cxx::__stoa<long, int>(&std::wcstol, "stoi", __str.c_str(),

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] Enable libstdc++ numeric conversions on Cygwin
  2015-11-15 11:14                 ` Jonathan Wakely
@ 2015-11-15 16:25                   ` Christophe Lyon
  0 siblings, 0 replies; 20+ messages in thread
From: Christophe Lyon @ 2015-11-15 16:25 UTC (permalink / raw)
  To: Jonathan Wakely; +Cc: Jennifer Yao, libstdc++, gcc-patches, Andreas Tobler

On 15 November 2015 at 12:14, Jonathan Wakely <jwakely@redhat.com> wrote:
> On 15/11/15 09:58 +0100, Christophe Lyon wrote:
>>
>> Ha, and my newlib copy is not very recent, it's from Oct 30th 2013:
>> maybe it's too old?
>
>
> The autoconf checks should handle old versions as well as new.
>
> The problem is I didn't change a defined(_GLIBCXX_USE_C99_WCHAR) to
> just test its value, rather than whether it's defined.
>
> As I added to include/bits/c++config on Friday:
>
> // N.B. these _GLIBCXX_USE_C99_XXX macros are defined unconditionally
> // so they should be tested with #if not with #ifdef.
>
> Fixed with this patch, committed to trunk.
>

Thanks, this does fix the build of aarch64*-none-elf.

The arm*-none-eabi ones are still failing, but for another reason now.
Lots of things have been committed in the past few days :-)

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] Enable libstdc++ numeric conversions on Cygwin
  2015-11-14 21:23               ` Jennifer Yao
@ 2015-11-15 21:38                 ` Jennifer Yao
  2015-11-16  9:48                   ` Jonathan Wakely
  0 siblings, 1 reply; 20+ messages in thread
From: Jennifer Yao @ 2015-11-15 21:38 UTC (permalink / raw)
  To: Jonathan Wakely; +Cc: Christophe Lyon, libstdc++, gcc-patches, Andreas Tobler

> I just finished running the testsuite on x86_64-pc-cygwin for
> Jonathan's latest patch and compared the results against an older
> (about two months old) run, and so far I'm not seeing any regressions.
> Granted, this is strictly preliminary; I'm currently re-running the
> testsuite on the up-to-date, unpatched build tree to see if there are
> any differences. I'll update when I have more information.

Finally finished testing the patch that was committed to trunk on Nov.
13. No regressions to report for x86_64-pc-cygwin.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] Enable libstdc++ numeric conversions on Cygwin
  2015-11-15 21:38                 ` Jennifer Yao
@ 2015-11-16  9:48                   ` Jonathan Wakely
  0 siblings, 0 replies; 20+ messages in thread
From: Jonathan Wakely @ 2015-11-16  9:48 UTC (permalink / raw)
  To: Jennifer Yao; +Cc: Christophe Lyon, libstdc++, gcc-patches, Andreas Tobler

On 15/11/15 16:38 -0500, Jennifer Yao wrote:
>> I just finished running the testsuite on x86_64-pc-cygwin for
>> Jonathan's latest patch and compared the results against an older
>> (about two months old) run, and so far I'm not seeing any regressions.
>> Granted, this is strictly preliminary; I'm currently re-running the
>> testsuite on the up-to-date, unpatched build tree to see if there are
>> any differences. I'll update when I have more information.
>
>Finally finished testing the patch that was committed to trunk on Nov.
>13. No regressions to report for x86_64-pc-cygwin.

Great - thanks for testing.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] Enable libstdc++ numeric conversions on Cygwin
  2015-11-13 14:52         ` Jonathan Wakely
  2015-11-14  8:37           ` Christophe Lyon
@ 2015-12-08 10:59           ` Alan Lawrence
  1 sibling, 0 replies; 20+ messages in thread
From: Alan Lawrence @ 2015-12-08 10:59 UTC (permalink / raw)
  To: Jonathan Wakely, Jennifer Yao; +Cc: libstdc++, gcc-patches, Andreas Tobler

On 13/11/15 14:52, Jonathan Wakely wrote:
> That patch was wrong, the new macros in include/bits/c++config used
> "CSTDIO" instead of "STDIO" so it caused several tests to go from
> PASS to UNSUPPORTED, oops!
>
> This is the correct version, tested again more carefully, on
> powerpc64le-linux and powerpc-aix and x86_64-dragonfly.
>
> Committed to trunk.

Just as a note, on baremetal ARM and AArch64 (arm-none-eabi / aarch64-none-elf), 
this causes a bunch more tests to be executed that were previously UNSUPPORTED, 
including

FAIL: 21_strings/basic_string/numeric_conversions/char/stod.cc execution test
FAIL: 21_strings/basic_string/numeric_conversions/char/stof.cc execution test
FAIL: 21_strings/basic_string/numeric_conversions/char/stold.cc execution test
FAIL: 21_strings/basic_string/numeric_conversions/wchar_t/stod.cc execution test
FAIL: 21_strings/basic_string/numeric_conversions/wchar_t/stof.cc execution test
FAIL: 21_strings/basic_string/numeric_conversions/wchar_t/stold.cc execution test
FAIL: 27_io/basic_ostream/inserters_arithmetic/char/hexfloat.cc execution test

these were previously gated off by the dg-require-string-conversions, via the 
"#if !defined(_GLIBCXX_USE_C99) || defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF)" as 
GLIBCXX_USE_C99 was not defined. However, now we have "#if 
!(_GLIBCXX_USE_C99_STDIO && _GLIBCXX_USE_C99_STDLIB && _GLIBCXX_USE_C99_WCHAR)" 
and all of those are true.

(Note the tests would have failed before if we had executed them, there is no 
change there AFAICS.)

Cheers,
Alan

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2015-12-08 10:59 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-18 15:19 [PATCH] Enable libstdc++ numeric conversions on Cygwin Jennifer Yao
     [not found] ` <CAPQfdhmMGJeb-tq29jTheoo5jUaeiFzcycWFTrpShRE-kPftGw@mail.gmail.com>
2015-09-18 15:51   ` Fwd: " Jonathan Wakely
2015-09-19 21:00     ` Jennifer Yao
2015-09-21 12:37       ` Jonathan Wakely
     [not found]   ` <CAPQfdh=uOjLzi60Dnd0Dd1ycJUDqMWQBCv1aRAGBP97DSUS3+Q@mail.gmail.com>
     [not found]     ` <20151112114049.GY2937@redhat.com>
2015-11-12 13:40       ` Jonathan Wakely
2015-11-12 14:50         ` Jonathan Wakely
2015-11-12 17:25           ` Jennifer Yao
2015-11-12 17:56             ` Jonathan Wakely
2015-11-12 22:56         ` Andreas Tobler
2015-11-13 14:52         ` Jonathan Wakely
2015-11-14  8:37           ` Christophe Lyon
2015-11-14 13:58             ` Jonathan Wakely
2015-11-14 21:23               ` Jennifer Yao
2015-11-15 21:38                 ` Jennifer Yao
2015-11-16  9:48                   ` Jonathan Wakely
2015-11-14 16:32             ` Jonathan Wakely
2015-11-15  8:58               ` Christophe Lyon
2015-11-15 11:14                 ` Jonathan Wakely
2015-11-15 16:25                   ` Christophe Lyon
2015-12-08 10:59           ` Alan Lawrence

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).