From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 65361 invoked by alias); 18 Sep 2015 15:14:21 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 65326 invoked by uid 89); 18 Sep 2015 15:14:17 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.1 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mail-la0-f42.google.com Received: from mail-la0-f42.google.com (HELO mail-la0-f42.google.com) (209.85.215.42) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Fri, 18 Sep 2015 15:14:15 +0000 Received: by lamp12 with SMTP id p12so31811081lam.0; Fri, 18 Sep 2015 08:14:11 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.112.155.195 with SMTP id vy3mr3415672lbb.9.1442589251607; Fri, 18 Sep 2015 08:14:11 -0700 (PDT) Received: by 10.25.154.147 with HTTP; Fri, 18 Sep 2015 08:14:11 -0700 (PDT) Date: Fri, 18 Sep 2015 15:19:00 -0000 Message-ID: Subject: [PATCH] Enable libstdc++ numeric conversions on Cygwin From: Jennifer Yao To: gcc-patches@gcc.gnu.org, libstdc@gcc.gnu.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-SW-Source: 2015-09/txt/msg01426.txt.bz2 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=E2=80=94a 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 (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 PR libstdc++/58393 PR libstdc++/61580 * acinclude.m4 (GLIBCXX_ENABLE_C99, GLIBCXX_CHECK_C99_TR1): Use -std=3D= c++0x instead of -std=3Dc++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_W= CHAR. 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 conditio= nals so that numeric conversion functions are defined when _GLIBCXX_USE_C99_STDIO, _GLIBCXX_USE_C99_STDLIB, or _GLIBCXX_USE_C99_WC= HAR are defined, instead of _GLIBCXX_USE_C99. * include/bits/locale_facets.tcc (std::num_put::_M_insert_float): Repla= ce _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_WC= HAR 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_wstr= ing.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): Re= place _GLIBCXX_USE_C99 with _GLIBCXX_USE_C99_STDLIB. * testsuite/lib/libstdc++.exp (check_v3_target_string_conversions): Cha= nge 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): Re= place _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.