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

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).