From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 720113858C66 for ; Wed, 19 Jul 2023 10:06:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 720113858C66 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689761188; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=g1esaaytBLIeWhcO4pNoGldZ2VNn53gwnVyBwCZDhJE=; b=ZT6uuekXnU99hIyNyKWB6Q3Ri+dy8g1+yoOLHcDTOdSW+/VLjpZJS5+KtWj/v9xG7QIWNW I6juDJV7C23qwQzy4tGwJybbaLsOjXlLGRBbdvPOYExK7w73SQL74eb/nVbfIRp1Ja9ClL Ms9nNWKL4Vanu1JE8Krtsi/1EStI/PQ= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-302-vvXZkYzyMFKMZr53xUKgBw-1; Wed, 19 Jul 2023 06:06:26 -0400 X-MC-Unique: vvXZkYzyMFKMZr53xUKgBw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 58487101156F; Wed, 19 Jul 2023 10:06:26 +0000 (UTC) Received: from localhost (unknown [10.42.28.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id 082B31121315; Wed, 19 Jul 2023 10:06:25 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed 1/3] libstdc++: Check autoconf macros for strtof and strtold [PR110653] Date: Wed, 19 Jul 2023 11:05:10 +0100 Message-ID: <20230719100625.2494437-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Tested x86_64-linux. Pushed to trunk. -- >8 -- 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 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 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. --- 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++" -- 2.41.0