From patchwork Wed Jan 8 13:01:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 104347 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7A6E23858424 for ; Wed, 8 Jan 2025 13:05:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7A6E23858424 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=E0FAJ/9N X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id DF5CC3857C58 for ; Wed, 8 Jan 2025 13:02:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DF5CC3857C58 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org DF5CC3857C58 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1736341341; cv=none; b=mtdjzIg7Q4mBdMh34Qj9VdDWX72NX8ww91TBGt4rQKmy3/YDEC5z2w+ggkBO5hb0YI0r+ecw1p1f5NIfoaJ6Asl9u1mZoIkI+qEO2Qe10G+3zQjCTpbSxrB8mcw36T3c5EBqMkZJYDNo+hqweRlzEuVK2WNBNes5nHc0xXk0/u8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1736341341; c=relaxed/simple; bh=eVGJpPuddkw5mhcSJA/AFka3HgYEPjaPayH/AItp7DY=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=w2r7FT08FIKGUDh/3aB8MQ3nje5m79PIy5Wal0RLc4G4+Ho5Dk1EIDBnOQ0Sn73Wpcq1+RwXSyvUhJR6S+rS0XGdL+gee/7IRaE9OtIpSqKBIsGFBhiY0g7ZbdlG9R9TCdO9AKuyvUUcfVPLQHCyO1th74wBV27eyNDPCM4xZww= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DF5CC3857C58 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736341340; 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=AjuCA6dlSXfe0XyBtBy6NrI9UZkruSiyp11XseD4Eu8=; b=E0FAJ/9NqbkEXPiUeHWsTxeCQsg7wYCxFdSgYxcLzq5Rx1tYM1YEiulGv5WOAb5p4LTv/J fWoO6E6hsHl1/b6Lbgb5DQk9mZEKDXNRlq/DsCSsHyw+Gt+3lwNmWMz1AUb5nsGmZ05zoz vZPdByjpcBWj91Y7By+P23SqDdGCl8E= Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-575-L4jmDJWiM3GOSBSRwWmBnA-1; Wed, 08 Jan 2025 08:02:17 -0500 X-MC-Unique: L4jmDJWiM3GOSBSRwWmBnA-1 X-Mimecast-MFC-AGG-ID: L4jmDJWiM3GOSBSRwWmBnA Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E1A2519153C3; Wed, 8 Jan 2025 13:02:15 +0000 (UTC) Received: from localhost (unknown [10.42.28.146]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 6BC20195608D; Wed, 8 Jan 2025 13:02:13 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Use preprocessor conditions in std module [PR118177] Date: Wed, 8 Jan 2025 13:01:54 +0000 Message-ID: <20250108130212.262934-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: JvQSkDFf0wXL77mt2KeZUxNq7B1NO5nYvr-Ke8hIjfE_1736341337 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.2 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, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~patchwork=sourceware.org@gcc.gnu.org The std-clib.cc module definition file assumes that all names are available unconditionally, but that's not true for all targets. Use the same preprocessor conditions as are present in the headers. A similar change is needed in std.cc.in for the features that depend on the SSO std::string, guarded with a __cpp_lib_chrono value indicating full C++20 support. The conditions for are omitted from this change, as there are a large number of them. That probably needs to be fixed. libstdc++-v3/ChangeLog: PR libstdc++/118177 * src/c++23/std-clib.cc.in: Use preprocessor conditions for names which are not always defined. * src/c++23/std.cc.in: Likewise. --- Tested x86_64-linux. Pushed to trunk. libstdc++-v3/src/c++23/std-clib.cc.in | 46 +++++++++++++++++++++++++++ libstdc++-v3/src/c++23/std.cc.in | 2 ++ 2 files changed, 48 insertions(+) diff --git a/libstdc++-v3/src/c++23/std-clib.cc.in b/libstdc++-v3/src/c++23/std-clib.cc.in index 9d175b4bb4d1..6809ad229d7c 100644 --- a/libstdc++-v3/src/c++23/std-clib.cc.in +++ b/libstdc++-v3/src/c++23/std-clib.cc.in @@ -17,7 +17,9 @@ export C_LIB_NAMESPACE { using std::isalnum; using std::isalpha; +#ifdef _GLIBCXX_USE_C99_CTYPE using std::isblank; +#endif using std::iscntrl; using std::isdigit; using std::isgraph; @@ -37,6 +39,7 @@ export C_LIB_NAMESPACE // 28.3 export C_LIB_NAMESPACE { +#ifdef _GLIBCXX_USE_C99_FENV using std::feclearexcept; using std::fegetenv; using std::fegetexceptflag; @@ -50,6 +53,7 @@ export C_LIB_NAMESPACE using std::fetestexcept; using std::feupdateenv; using std::fexcept_t; +#endif } // 17.3.7 [cfloat.syn] @@ -58,13 +62,17 @@ export C_LIB_NAMESPACE // 31.13.2 export C_LIB_NAMESPACE { +#ifdef _GLIBCXX_USE_C99_INTTYPES using std::imaxabs; using std::imaxdiv; using std::imaxdiv_t; using std::strtoimax; using std::strtoumax; +#if defined(_GLIBCXX_USE_WCHAR_T) && _GLIBCXX_USE_C99_INTTYPES_WCHAR_T using std::wcstoimax; using std::wcstoumax; +#endif +#endif } // 17.3.6 [climits.syn] @@ -463,7 +471,9 @@ export C_LIB_NAMESPACE using std::sprintf; using std::sscanf; using std::tmpfile; +#if _GLIBCXX_USE_TMPNAM using std::tmpnam; +#endif using std::ungetc; using std::vfprintf; using std::vfscanf; @@ -480,8 +490,12 @@ export C_LIB_NAMESPACE using std::_Exit; using std::abort; using std::abs; +#ifdef _GLIBCXX_HAVE_ALIGNED_ALLOC using std::aligned_alloc; +#endif +#ifdef _GLIBCXX_HAVE_AT_QUICK_EXIT using std::at_quick_exit; +#endif using std::atexit; using std::atof; using std::atoi; @@ -501,11 +515,15 @@ export C_LIB_NAMESPACE using std::lldiv; using std::lldiv_t; using std::malloc; +#ifdef _GLIBCXX_HAVE_MBSTATE_T using std::mblen; using std::mbstowcs; using std::mbtowc; +#endif using std::qsort; +#ifdef _GLIBCXX_HAVE_QUICK_EXIT using std::quick_exit; +#endif using std::rand; using std::realloc; using std::size_t; @@ -518,8 +536,10 @@ export C_LIB_NAMESPACE using std::strtoul; using std::strtoull; using std::system; +#ifdef _GLIBCXX_USE_WCHAR_T using std::wcstombs; using std::wctomb; +#endif } // 23.5.3 @@ -567,20 +587,27 @@ export C_LIB_NAMESPACE using std::time_t; using std::timespec; using std::tm; +#ifdef _GLIBCXX_HAVE_TIMESPEC_GET using std::timespec_get; +#endif } // 23.5.5 export C_LIB_NAMESPACE { +#if _GLIBCXX_USE_UCHAR_C8RTOMB_MBRTOC8_CXX20 using std::mbrtoc8; using std::c8rtomb; +#endif +#if _GLIBCXX_USE_C11_UCHAR_CXX11 using std::mbrtoc16; using std::c16rtomb; using std::mbrtoc32; using std::c32rtomb; +#endif } +#if _GLIBCXX_USE_WCHAR_T // 23.5.4 export C_LIB_NAMESPACE { @@ -607,11 +634,19 @@ export C_LIB_NAMESPACE using std::tm; using std::ungetwc; using std::vfwprintf; +# if _GLIBCXX_HAVE_VFWSCANF using std::vfwscanf; +#endif +#ifndef _GLIBCXX_HAVE_BROKEN_VSWPRINTF using std::vswprintf; +#endif +# if _GLIBCXX_HAVE_VSWSCANF using std::vswscanf; +#endif using std::vwprintf; +# if _GLIBCXX_HAVE_VWSCANF using std::vwscanf; +#endif using std::wcrtomb; using std::wcscat; using std::wcschr; @@ -630,13 +665,19 @@ export C_LIB_NAMESPACE using std::wcsspn; using std::wcsstr; using std::wcstod; +#if _GLIBCXX_HAVE_WCSTOF using std::wcstof; +#endif using std::wcstok; using std::wcstol; +#if _GLIBCXX_USE_C99_WCHAR using std::wcstold; using std::wcstoll; +#endif using std::wcstoul; +#if _GLIBCXX_USE_C99_WCHAR using std::wcstoull; +#endif using std::wcsxfrm; using std::wctob; using std::wint_t; @@ -648,13 +689,17 @@ export C_LIB_NAMESPACE using std::wprintf; using std::wscanf; } +#endif +#if _GLIBCXX_USE_WCHAR_T // 23.5.2 export C_LIB_NAMESPACE { using std::iswalnum; using std::iswalpha; +#if _GLIBCXX_HAVE_ISWBLANK using std::iswblank; +#endif using std::iswcntrl; using std::iswctype; using std::iswdigit; @@ -674,3 +719,4 @@ export C_LIB_NAMESPACE using std::wctype_t; using std::wint_t; } +#endif diff --git a/libstdc++-v3/src/c++23/std.cc.in b/libstdc++-v3/src/c++23/std.cc.in index 0e5b41c5b3b8..dcba343426c6 100644 --- a/libstdc++-v3/src/c++23/std.cc.in +++ b/libstdc++-v3/src/c++23/std.cc.in @@ -806,6 +806,7 @@ export namespace std using chrono::parse; using chrono::from_stream; using chrono::clock_time_conversion; +#if __cpp_lib_chrono >= 201907L using chrono::tzdb; using chrono::tzdb_list; using chrono::get_tzdb; @@ -828,6 +829,7 @@ export namespace std using chrono::get_leap_second_info; using chrono::time_zone_link; using chrono::local_time_format; +#endif using chrono::is_clock; using chrono::is_clock_v; }