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 4A2373839DF1 for ; Thu, 24 Aug 2023 12:45:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4A2373839DF1 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=1692881129; 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=5GoXKaAqJ1WHG4fDHJkaWiy2LP7q0qM/2LSxY1zYm6k=; b=c4kV8zwIA8dR4EWHgqAiT6Ukrpr89gMk44uJDqYFET2Fg9W5iFY+TzEEmzKjPY0vGkcfb3 d79JLVTOIuqDvOh8qwrdC2oOYjH3W3N0xp0xJCs7tSirs+PqQidn379U0cuJBSQQpBFREd soTfaEPoyN+HpkrOByDDot31rzl35js= 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-486-uLzkZjTAMDCMb11qu7m3ew-1; Thu, 24 Aug 2023 08:45:25 -0400 X-MC-Unique: uLzkZjTAMDCMb11qu7m3ew-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9261985CBEA; Thu, 24 Aug 2023 12:45:25 +0000 (UTC) Received: from localhost (unknown [10.42.28.204]) by smtp.corp.redhat.com (Postfix) with ESMTP id 528D86B59A; Thu, 24 Aug 2023 12:45:25 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Implement new SI prefixes in for C++23 (P2734R0) Date: Thu, 24 Aug 2023 13:44:56 +0100 Message-ID: <20230824124524.443635-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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 autolearn=unavailable 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 -- This is a no-op for libstdc++, because our intmax_t is a 64-bit type and so is incapable of representing the largest and smallest ratios from C++11, let alone the new ones. I've added them to the file anyway (and defined the feature test macro) so that if somebody ports libstdc++ to a target with 128-bit intmax_t then they'll be present. libstdc++-v3/ChangeLog: * include/bits/version.def (__cpp_lib_ratio): Define. * include/bits/version.h: Regenerate. * include/std/ratio (quecto, ronto, yocto, zepto) (zetta, yotta, ronna, quetta): Define. * testsuite/20_util/ratio/operations/ops_overflow_neg.cc: Adjust dg-error line numbers. --- libstdc++-v3/include/bits/version.def | 8 +++ libstdc++-v3/include/bits/version.h | 11 ++++ libstdc++-v3/include/std/ratio | 56 +++++++++++++------ .../ratio/operations/ops_overflow_neg.cc | 6 +- 4 files changed, 61 insertions(+), 20 deletions(-) diff --git a/libstdc++-v3/include/bits/version.def b/libstdc++-v3/include/bits/version.def index b50050440d9..80c13d4a447 100644 --- a/libstdc++-v3/include/bits/version.def +++ b/libstdc++-v3/include/bits/version.def @@ -1582,6 +1582,14 @@ ftms = { }; }; +ftms = { + name = ratio; + values = { + v = 202306; + cxxmin = 26; + }; +}; + ftms = { name = to_string; values = { diff --git a/libstdc++-v3/include/bits/version.h b/libstdc++-v3/include/bits/version.h index 8b8c70a6e53..5bddb4b8adc 100644 --- a/libstdc++-v3/include/bits/version.h +++ b/libstdc++-v3/include/bits/version.h @@ -1940,6 +1940,17 @@ #undef __glibcxx_want_string_resize_and_overwrite // from version.def line 1586 +#if !defined(__cpp_lib_ratio) +# if (__cplusplus > 202302L) +# define __glibcxx_ratio 202306L +# if defined(__glibcxx_want_all) || defined(__glibcxx_want_ratio) +# define __cpp_lib_ratio 202306L +# endif +# endif +#endif /* !defined(__cpp_lib_ratio) && defined(__glibcxx_want_ratio) */ +#undef __glibcxx_want_ratio + +// from version.def line 1594 #if !defined(__cpp_lib_to_string) # if (__cplusplus > 202302L) && _GLIBCXX_HOSTED && (__glibcxx_to_chars) # define __glibcxx_to_string 202306L diff --git a/libstdc++-v3/include/std/ratio b/libstdc++-v3/include/std/ratio index 1d285bf916f..c87f54fe1a2 100644 --- a/libstdc++-v3/include/std/ratio +++ b/libstdc++-v3/include/std/ratio @@ -39,6 +39,9 @@ #include #include // intmax_t, uintmax_t +#define __glibcxx_want_ratio +#include + namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION @@ -602,23 +605,42 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template using ratio_subtract = typename __ratio_subtract<_R1, _R2>::type; - - typedef ratio<1, 1000000000000000000> atto; - typedef ratio<1, 1000000000000000> femto; - typedef ratio<1, 1000000000000> pico; - typedef ratio<1, 1000000000> nano; - typedef ratio<1, 1000000> micro; - typedef ratio<1, 1000> milli; - typedef ratio<1, 100> centi; - typedef ratio<1, 10> deci; - typedef ratio< 10, 1> deca; - typedef ratio< 100, 1> hecto; - typedef ratio< 1000, 1> kilo; - typedef ratio< 1000000, 1> mega; - typedef ratio< 1000000000, 1> giga; - typedef ratio< 1000000000000, 1> tera; - typedef ratio< 1000000000000000, 1> peta; - typedef ratio< 1000000000000000000, 1> exa; +#if __INTMAX_WIDTH__ >= 96 +# if __cpp_lib_ratio >= 202306L +# if __INTMAX_WIDTH__ >= 128 + using quecto = ratio< 1, 1000000000000000000000000000000>; +# endif + using ronto = ratio< 1, 1000000000000000000000000000>; +# endif + using yocto = ratio< 1, 1000000000000000000000000>; + using zepto = ratio< 1, 1000000000000000000000>; +#endif + using atto = ratio< 1, 1000000000000000000>; + using femto = ratio< 1, 1000000000000000>; + using pico = ratio< 1, 1000000000000>; + using nano = ratio< 1, 1000000000>; + using micro = ratio< 1, 1000000>; + using milli = ratio< 1, 1000>; + using centi = ratio< 1, 100>; + using deci = ratio< 1, 10>; + using deca = ratio< 10, 1>; + using hecto = ratio< 100, 1>; + using kilo = ratio< 1000, 1>; + using mega = ratio< 1000000, 1>; + using giga = ratio< 1000000000, 1>; + using tera = ratio< 1000000000000, 1>; + using peta = ratio< 1000000000000000, 1>; + using exa = ratio< 1000000000000000000, 1>; +#if __INTMAX_WIDTH__ >= 96 + using zetta = ratio< 1000000000000000000000, 1>; + using yotta = ratio<1000000000000000000000000, 1>; +# if __cpp_lib_ratio >= 202306L + using ronna = ratio<1000000000000000000000000000, 1>; +# if __INTMAX_WIDTH__ >= 128 + using quetta = ratio<1000000000000000000000000000000, 1>; +# endif +# endif +#endif /// @} group ratio _GLIBCXX_END_NAMESPACE_VERSION diff --git a/libstdc++-v3/testsuite/20_util/ratio/operations/ops_overflow_neg.cc b/libstdc++-v3/testsuite/20_util/ratio/operations/ops_overflow_neg.cc index 2e2a59c164c..62034e42a75 100644 --- a/libstdc++-v3/testsuite/20_util/ratio/operations/ops_overflow_neg.cc +++ b/libstdc++-v3/testsuite/20_util/ratio/operations/ops_overflow_neg.cc @@ -43,9 +43,9 @@ test02() // { dg-error "expected initializer" "" { target *-*-* } 35 } // { dg-error "expected initializer" "" { target *-*-* } 37 } // { dg-error "overflow in addition" "" { target *-*-* } 0 } -// { dg-error "overflow in multiplication" "" { target *-*-* } 98 } -// { dg-error "overflow in multiplication" "" { target *-*-* } 100 } -// { dg-error "overflow in multiplication" "" { target *-*-* } 102 } +// { dg-error "overflow in multiplication" "" { target *-*-* } 101 } +// { dg-error "overflow in multiplication" "" { target *-*-* } 103 } +// { dg-error "overflow in multiplication" "" { target *-*-* } 105 } // { dg-error "overflow in constant expression" "" { target *-*-* } 0 } // { dg-error "narrowing conversion" "" { target *-*-* } 0 } // { dg-prune-output "out of range" } -- 2.41.0