public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jonathan Wakely <redi@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org
Subject: [gcc r14-2635] libstdc++: Check autoconf macros for strtof and strtold [PR110653]
Date: Wed, 19 Jul 2023 10:04:20 +0000 (GMT)	[thread overview]
Message-ID: <20230719100420.F1AAD3858C66@sourceware.org> (raw)

https://gcc.gnu.org/g:58303d42809f0e01f23262f592d37943f7703f71

commit r14-2635-g58303d42809f0e01f23262f592d37943f7703f71
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Thu Jul 13 10:44:57 2023 +0100

    libstdc++: Check autoconf macros for strtof and strtold [PR110653]
    
    As well as the _GLIBCXX_USE_C99_STDLIB check, we also have a separate
    check in linkage.m4 for just strtof and strtold. We can use that to
    declare std::strtof and std::strtold in <cstdlib> for additional
    targets. That allows us to enable std::stold on hpux11.11 which is
    missing strtoll, strtoull and strtof, so doesn't define
    _GLIBCXX_USE_C99_STDLIB. Although it doesn't help hpux11.11, we can
    define std::stof for more targets this way too.
    
    As with the previous commit for PR110653, this only affects the narrow
    character overloads. std::stof and std::stold for wstring still requires
    C99 <wchar.h> support.
    
    libstdc++-v3/ChangeLog:
    
            PR libstdc++/110653
            * include/bits/basic_string.h [_GLIBCXX_HAVE_STRTOF] (stof):
            Define.
            [_GLIBCXX_HAVE_STRTOLD] (stold): Define.
            * include/c_global/cstdlib [_GLIBCXX_HAVE_STRTOF] (strtof):
            Declare in namespace std.
            [_GLIBCXX_HAVE_STRTOLD] (strtold): Likewise.

Diff:
---
 libstdc++-v3/include/bits/basic_string.h |  6 ++++--
 libstdc++-v3/include/c_global/cstdlib    | 14 ++++++++++++++
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/libstdc++-v3/include/bits/basic_string.h b/libstdc++-v3/include/bits/basic_string.h
index 01e25dad20e..32f5d4421f7 100644
--- a/libstdc++-v3/include/bits/basic_string.h
+++ b/libstdc++-v3/include/bits/basic_string.h
@@ -4148,12 +4148,14 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
   stod(const string& __str, size_t* __idx = 0)
   { return __gnu_cxx::__stoa(&std::strtod, "stod", __str.c_str(), __idx); }
 
-#if _GLIBCXX_USE_C99_STDLIB
+#if _GLIBCXX_USE_C99_STDLIB || _GLIBCXX_HAVE_STRTOF
   // NB: strtof vs strtod.
   inline float
   stof(const string& __str, size_t* __idx = 0)
   { return __gnu_cxx::__stoa(&std::strtof, "stof", __str.c_str(), __idx); }
+#endif
 
+#if _GLIBCXX_USE_C99_STDLIB || _GLIBCXX_HAVE_STRTOLD
   inline long double
   stold(const string& __str, size_t* __idx = 0)
   { return __gnu_cxx::__stoa(&std::strtold, "stold", __str.c_str(), __idx); }
@@ -4161,7 +4163,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
   inline long double
   stold(const string& __str, size_t* __idx = 0)
   { return std::stod(__str, __idx); }
-#endif // _GLIBCXX_USE_C99_STDLIB
+#endif
 
   // DR 1261. Insufficent overloads for to_string / to_wstring
 
diff --git a/libstdc++-v3/include/c_global/cstdlib b/libstdc++-v3/include/c_global/cstdlib
index aeb961ad69d..60317aa9a4a 100644
--- a/libstdc++-v3/include/c_global/cstdlib
+++ b/libstdc++-v3/include/c_global/cstdlib
@@ -256,6 +256,20 @@ namespace std
   using ::__gnu_cxx::strtold;
 } // namespace std
 
+#else  // ! _GLIBCXX_USE_C99_STDLIB
+
+// We also check for strtof and strtold separately from _GLIBCXX_USE_C99_STDLIB
+
+#if _GLIBCXX_HAVE_STRTOF
+#undef strtof
+namespace std { using ::strtof; }
+#endif
+
+#if _GLIBCXX_HAVE_STRTOLD
+#undef strtold
+namespace std { using ::strtold; }
+#endif
+
 #endif // _GLIBCXX_USE_C99_STDLIB
 
 } // extern "C++"

                 reply	other threads:[~2023-07-19 10:04 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230719100420.F1AAD3858C66@sourceware.org \
    --to=redi@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    --cc=libstdc++-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).