From patchwork Tue Sep 27 08:45:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 1485 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5044:0:0:0:0:0 with SMTP id h4csp217517wrt; Tue, 27 Sep 2022 01:47:21 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6zFqv1JMc70MlQuX0vb2XZVJil5R3T5ldr0KfguLgTjss2BzUIGFE3mlGscjeJc+Io7OR/ X-Received: by 2002:a05:6402:4511:b0:43b:a182:8a0a with SMTP id ez17-20020a056402451100b0043ba1828a0amr26579588edb.410.1664268441380; Tue, 27 Sep 2022 01:47:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664268441; cv=none; d=google.com; s=arc-20160816; b=Zh4d92kYQUYhFSCMqSWEK31Cr2hEq2SKKR53nU6sA89FC85jzF0Br8hg2vxQLlyL1l qzfl/UT7c5HW4XZobLtNPmFPCixaHF5QDTFjtzKjdqky5eWBrRtPCidDAhg6SSdp8pQE wc6GTn3QtDg4KvnfM9QjUvVPbdPvj0OXTFRVRU2ISuipolbfqr77a1bRhwNsM7m+S3Cl oVWYixqZVXAxrdL/nhZg0F65ZsL6TaQczO2LsYeiQCzOXtRVsvFJ4syxAXNu2nuRVH24 TaWCiFwPh6prRKuuJYdJ4v7iXzy2DmZYT19KbajAKgmKbMLn3hP8rZ0FCiBVnDXIS6am vNmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=hRn4EtjC5AgUq0xnLEC38J6UeL+5AxMZfCw0aYa2aCg=; b=OCrEyyBy4eIuPCyadH+zIjydeQvdVeNvO4wzlngo/Jf8TMx0zx6LCliP+WPoJkt5j/ W+3Mx+wuCfG4hDNG1PFf3+IUHvrNqhc7iaTMeqz4QuV0B7Lx/QTiQw0KHgTuICTo/GXB /G73nScbsm7oFbVbHQNI2M0nG+JhmAHXmnVCGckk6emQeEDaeyT/MJW9iXRAtxFB4DgP nsE/e95eORLYPwwra37cav+Au5X9Nqs7l5M3/70TcNcLHWTtQ1883MRvOVhF05FVjcbx CrR6subFpGGU1nvBd9MKfxaVZSRcQk9gQh2kqbUE5twJ7auaTzIjHuR4sPpzHmLOu5Hy pHEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=eXkosMYt; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id d1-20020a50cd41000000b0044eab363b67si1055615edj.130.2022.09.27.01.47.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 01:47:21 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=eXkosMYt; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CE6933851A94 for ; Tue, 27 Sep 2022 08:46:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CE6933851A94 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1664268383; bh=hRn4EtjC5AgUq0xnLEC38J6UeL+5AxMZfCw0aYa2aCg=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=eXkosMYtbGWKtRGjdbG5ylRqP4oH7H1cqVVp+ovXib/xP/m/5nM4CITlQIzYMS44S 0kJwp1HHwMrVViAUGlWn3ixOqvTuyIMG1pdeivRGuJYZK+7KxussMFtXtFZQbin1Be fdsxBAcpIKKXfLdYzF1RVsuVL1F+P6olvoJ9nbAU= 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.133.124]) by sourceware.org (Postfix) with ESMTPS id 1DAE33856DE0 for ; Tue, 27 Sep 2022 08:45:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1DAE33856DE0 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-190-bF7TatsVOCC4wN4Z5L5uDw-1; Tue, 27 Sep 2022 04:45:30 -0400 X-MC-Unique: bF7TatsVOCC4wN4Z5L5uDw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CB51C85A583; Tue, 27 Sep 2022 08:45:29 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.194]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 506C8C15BA4; Tue, 27 Sep 2022 08:45:29 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 28R8jQAE3815172 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 27 Sep 2022 10:45:26 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 28R8jQMj3815171; Tue, 27 Sep 2022 10:45:26 +0200 Date: Tue, 27 Sep 2022 10:45:25 +0200 To: Jonathan Wakely Subject: [RFC PATCH] libstdc++: Partial library support for std::float{16,32,64,128}_t Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_LOTSOFHASH, KAM_SHORT, 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Cc: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1745111944931314058?= X-GMAIL-MSGID: =?utf-8?q?1745111944931314058?= Hi! The following patch is partial support for std::float{16,32,64,128}_t in libstdc++. https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p1467r9.html says that , , , and need changes too, but before doing that, it would be nice to get an agreement on what macros to use etc. The support for cmath/complex is possible in multiple ways: 1) glibc >= 2.26 support whatever{f32,f64,f128} APIs next to whatever{f,,l} APIs, so I think we can use __builtin_sin{f32,f64,f128} etc. to support _Float{32,64,128} overloads 2) if not, pretty much everywhere float is actually the same mode as _Float32 and double as _Float64, I guess one could use guards like #if __FLT32_MANT_DIG__ == __FLT_MANT_DIG__ \ && __FLT32_MAX_EXP__ == __FLT_MAX_EXP__ or #if __FLT64_MANT_DIG__ == __DBL_MANT_DIG__ \ && __FLT64_MAX_EXP__ == __DBL_MAX_EXP__ or even #if __FLT128_MANT_DIG__ == __LDBL_MANT_DIG__ \ && __FLT128_MAX_EXP__ == __LDBL_MAX_EXP__ for the few arches like aarch64 where long double and _Float128 has the same mode. Then we can use __builtin_sin{f,,l} etc. to support _Float{32,64,128} overloads 3) not sure what to do as fallback if neither 1) nor 2) work out, not provide the overloads, or even undef __STDCPP_FLOAT32_T__ etc. in the library? 4) AFAIK glibc doesn't have _Float16 APIs, so we need to widen and use __builtin_sinf32 1) or __builtin_sinf 2) for _Float16 and explicitly do narrowing cast 5) bfloat16_t needs more work even on the compiler side, but once the support is there and in stdfloat and other headers touched by the patch below (testcases already include bfloat16_t though), it will need something like 4) too. The patch also doesn't include any testcases to cover the changes, it isn't clear to me where to put that. Tested on x86_64-linux. 2022-09-27 Jakub Jelinek * include/std/stdfloat: New file. * include/std/numbers (__glibcxx_numbers): Define and use it for __float128 explicit instantiations as well as _Float{16,32,64,128}. * include/std/atomic (atomic<_Float16>, atomic<_Float32>, atomic<_Float64>, atomic<_Float128>): New explicit instantiations. * include/std/type_traits (__is_floating_point_helper<_Float16>, __is_floating_point_helper<_Float32>, __is_floating_point_helper<_Float64>, __is_floating_point_helper<_Float128>): Likewise. * include/std/limits (__glibcxx_concat3_, __glibcxx_concat3, __glibcxx_float_n): Define. (numeric_limits<_Float16>, numeric_limits<_Float32>, numeric_limits<_Float64>, numeric_limits<_Float128>): New explicit instantiations. * include/Makefile.am (std_headers): Add stdfloat. * include/Makefile.in: Regenerated. * include/precompiled/stdc++.h: Include stdfloat. * testsuite/18_support/headers/stdfloat/types_std.cc: New test. * testsuite/18_support/headers/limits/synopsis_cxx23.cc: New test. * testsuite/26_numerics/numbers/4.cc: New test. * testsuite/29_atomics/atomic_float/requirements_cxx23.cc: New test. Jakub --- libstdc++-v3/include/std/stdfloat.jj 2022-09-27 08:49:45.932769534 +0200 +++ libstdc++-v3/include/std/stdfloat 2022-09-27 08:49:45.932769534 +0200 @@ -0,0 +1,58 @@ +// -*- C++ -*- + +// Copyright (C) 2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/stdfloat + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_STDFLOAT +#define _GLIBCXX_STDFLOAT 1 + +#if __cplusplus > 202002L +#include + +namespace std +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + #ifdef __STDCPP_FLOAT16_T__ + using float16_t = _Float16; + #endif + + #ifdef __STDCPP_FLOAT32_T__ + using float32_t = _Float32; + #endif + + #ifdef __STDCPP_FLOAT64_T__ + using float64_t = _Float64; + #endif + + #ifdef __STDCPP_FLOAT128_T__ + using float128_t = _Float128; + #endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std +#endif // C++23 +#endif // _GLIBCXX_STDFLOAT --- libstdc++-v3/include/std/numbers.jj 2022-01-11 22:31:41.525756652 +0100 +++ libstdc++-v3/include/std/numbers 2022-09-27 08:49:45.933769521 +0200 @@ -133,72 +133,94 @@ namespace numbers inline constexpr double egamma = egamma_v; inline constexpr double phi = phi_v; +#define __glibcxx_numbers(TYPE, SUFFIX) \ + /* e */ \ + template<> \ + inline constexpr TYPE e_v \ + = 2.718281828459045235360287471352662498##SUFFIX; \ + \ + /* log_2 e */ \ + template<> \ + inline constexpr TYPE log2e_v \ + = 1.442695040888963407359924681001892137##SUFFIX; \ + \ + /* log_10 e */ \ + template<> \ + inline constexpr TYPE log10e_v \ + = 0.434294481903251827651128918916605082##SUFFIX; \ + \ + /* pi */ \ + template<> \ + inline constexpr TYPE pi_v \ + = 3.141592653589793238462643383279502884##SUFFIX; \ + \ + /* 1/pi */ \ + template<> \ + inline constexpr TYPE inv_pi_v \ + = 0.318309886183790671537767526745028724##SUFFIX; \ + \ + /* 1/sqrt(pi) */ \ + template<> \ + inline constexpr TYPE inv_sqrtpi_v \ + = 0.564189583547756286948079451560772586##SUFFIX; \ + \ + /* log_e 2 */ \ + template<> \ + inline constexpr TYPE ln2_v \ + = 0.693147180559945309417232121458176568##SUFFIX; \ + \ + /* log_e 10 */ \ + template<> \ + inline constexpr TYPE ln10_v \ + = 2.302585092994045684017991454684364208##SUFFIX; \ + \ + /* sqrt(2) */ \ + template<> \ + inline constexpr TYPE sqrt2_v \ + = 1.414213562373095048801688724209698079##SUFFIX; \ + \ + /* sqrt(3) */ \ + template<> \ + inline constexpr TYPE sqrt3_v \ + = 1.732050807568877293527446341505872367##SUFFIX; \ + \ + /* 1/sqrt(3) */ \ + template<> \ + inline constexpr TYPE inv_sqrt3_v \ + = 0.577350269189625764509148780501957456##SUFFIX; \ + \ + /* The Euler-Mascheroni constant */ \ + template<> \ + inline constexpr TYPE egamma_v \ + = 0.577215664901532860606512090082402431##SUFFIX; \ + \ + /* The golden ratio, (1+sqrt(5))/2 */ \ + template<> \ + inline constexpr TYPE phi_v \ + = 1.618033988749894848204586834365638118##SUFFIX + +#ifdef __STDCPP_FLOAT16_T__ +__glibcxx_numbers (_Float16, F16); +#endif + +#ifdef __STDCPP_FLOAT32_T__ +__glibcxx_numbers (_Float32, F32); +#endif + +#ifdef __STDCPP_FLOAT64_T__ +__glibcxx_numbers (_Float64, F64); +#endif + +#ifdef __STDCPP_FLOAT128_T__ +__glibcxx_numbers (_Float128, F128); +#endif + #if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_FLOAT128) - template<> - inline constexpr __float128 e_v<__float128> - = 2.718281828459045235360287471352662498Q; - - /// log_2 e - template<> - inline constexpr __float128 log2e_v<__float128> - = 1.442695040888963407359924681001892137Q; - - /// log_10 e - template<> - inline constexpr __float128 log10e_v<__float128> - = 0.434294481903251827651128918916605082Q; - - /// pi - template<> - inline constexpr __float128 pi_v<__float128> - = 3.141592653589793238462643383279502884Q; - - /// 1/pi - template<> - inline constexpr __float128 inv_pi_v<__float128> - = 0.318309886183790671537767526745028724Q; - - /// 1/sqrt(pi) - template<> - inline constexpr __float128 inv_sqrtpi_v<__float128> - = 0.564189583547756286948079451560772586Q; - - /// log_e 2 - template<> - inline constexpr __float128 ln2_v<__float128> - = 0.693147180559945309417232121458176568Q; - - /// log_e 10 - template<> - inline constexpr __float128 ln10_v<__float128> - = 2.302585092994045684017991454684364208Q; - - /// sqrt(2) - template<> - inline constexpr __float128 sqrt2_v<__float128> - = 1.414213562373095048801688724209698079Q; - - /// sqrt(3) - template<> - inline constexpr __float128 sqrt3_v<__float128> - = 1.732050807568877293527446341505872367Q; - - /// 1/sqrt(3) - template<> - inline constexpr __float128 inv_sqrt3_v<__float128> - = 0.577350269189625764509148780501957456Q; - - /// The Euler-Mascheroni constant - template<> - inline constexpr __float128 egamma_v<__float128> - = 0.577215664901532860606512090082402431Q; - - /// The golden ratio, (1+sqrt(5))/2 - template<> - inline constexpr __float128 phi_v<__float128> - = 1.618033988749894848204586834365638118Q; +__glibcxx_numbers (__float128, Q); #endif // USE_FLOAT128 +#undef __glibcxx_numbers + } // namespace numbers /// @} _GLIBCXX_END_NAMESPACE_VERSION --- libstdc++-v3/include/std/atomic.jj 2022-09-11 22:28:56.375164180 +0200 +++ libstdc++-v3/include/std/atomic 2022-09-27 08:49:45.934769507 +0200 @@ -1625,6 +1625,74 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION using __atomic_float::operator=; }; +#ifdef __STDCPP_FLOAT16_T__ + template<> + struct atomic<_Float16> : __atomic_float<_Float16> + { + atomic() noexcept = default; + + constexpr + atomic(_Float16 __fp) noexcept : __atomic_float<_Float16>(__fp) + { } + + atomic& operator=(const atomic&) volatile = delete; + atomic& operator=(const atomic&) = delete; + + using __atomic_float<_Float16>::operator=; + }; +#endif + +#ifdef __STDCPP_FLOAT32_T__ + template<> + struct atomic<_Float32> : __atomic_float<_Float32> + { + atomic() noexcept = default; + + constexpr + atomic(_Float32 __fp) noexcept : __atomic_float<_Float32>(__fp) + { } + + atomic& operator=(const atomic&) volatile = delete; + atomic& operator=(const atomic&) = delete; + + using __atomic_float<_Float32>::operator=; + }; +#endif + +#ifdef __STDCPP_FLOAT64_T__ + template<> + struct atomic<_Float64> : __atomic_float<_Float64> + { + atomic() noexcept = default; + + constexpr + atomic(_Float64 __fp) noexcept : __atomic_float<_Float64>(__fp) + { } + + atomic& operator=(const atomic&) volatile = delete; + atomic& operator=(const atomic&) = delete; + + using __atomic_float<_Float64>::operator=; + }; +#endif + +#ifdef __STDCPP_FLOAT128_T__ + template<> + struct atomic<_Float128> : __atomic_float<_Float128> + { + atomic() noexcept = default; + + constexpr + atomic(_Float128 __fp) noexcept : __atomic_float<_Float128>(__fp) + { } + + atomic& operator=(const atomic&) volatile = delete; + atomic& operator=(const atomic&) = delete; + + using __atomic_float<_Float128>::operator=; + }; +#endif + #define __cpp_lib_atomic_ref 201806L /// Class template to provide atomic operations on a non-atomic variable. --- libstdc++-v3/include/std/type_traits.jj 2022-09-25 22:22:03.979596700 +0200 +++ libstdc++-v3/include/std/type_traits 2022-09-27 08:49:45.934769507 +0200 @@ -459,6 +459,30 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct __is_floating_point_helper : public true_type { }; +#ifdef __STDCPP_FLOAT16_T__ + template<> + struct __is_floating_point_helper<_Float16> + : public true_type { }; +#endif + +#ifdef __STDCPP_FLOAT32_T__ + template<> + struct __is_floating_point_helper<_Float32> + : public true_type { }; +#endif + +#ifdef __STDCPP_FLOAT64_T__ + template<> + struct __is_floating_point_helper<_Float64> + : public true_type { }; +#endif + +#ifdef __STDCPP_FLOAT128_T__ + template<> + struct __is_floating_point_helper<_Float128> + : public true_type { }; +#endif + #if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_FLOAT128) template<> struct __is_floating_point_helper<__float128> --- libstdc++-v3/include/std/limits.jj 2022-01-11 22:31:41.525756652 +0100 +++ libstdc++-v3/include/std/limits 2022-09-27 08:49:45.933769521 +0200 @@ -1890,6 +1890,115 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #undef __glibcxx_long_double_traps #undef __glibcxx_long_double_tinyness_before +#if __cplusplus > 202202L + +#define __glibcxx_concat3_(P,M,S) P ## M ## S +#define __glibcxx_concat3(P,M,S) __glibcxx_concat3_ (P,M,S) + +#define __glibcxx_float_n(BITSIZE) \ + __extension__ \ + template<> \ + struct numeric_limits<_Float##BITSIZE> \ + { \ + static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true; \ + \ + static _GLIBCXX_CONSTEXPR _Float##BITSIZE \ + min() _GLIBCXX_USE_NOEXCEPT \ + { return __glibcxx_concat3 (__FLT, BITSIZE, _MIN__); } \ + \ + static _GLIBCXX_CONSTEXPR _Float##BITSIZE \ + max() _GLIBCXX_USE_NOEXCEPT \ + { return __glibcxx_concat3 (__FLT, BITSIZE, _MAX__); } \ + \ + static _GLIBCXX_CONSTEXPR _Float##BITSIZE \ + lowest() noexcept \ + { return -__glibcxx_concat3 (__FLT, BITSIZE, _MAX__); } \ + \ + static _GLIBCXX_USE_CONSTEXPR int digits \ + = __glibcxx_concat3 (__FLT, BITSIZE, _MANT_DIG__); \ + static _GLIBCXX_USE_CONSTEXPR int digits10 \ + = __glibcxx_concat3 (__FLT, BITSIZE, _DIG__); \ + static _GLIBCXX_USE_CONSTEXPR int max_digits10 \ + = __glibcxx_max_digits10 (__glibcxx_concat3 (__FLT, BITSIZE, \ + _MANT_DIG__)); \ + static _GLIBCXX_USE_CONSTEXPR bool is_signed = true; \ + static _GLIBCXX_USE_CONSTEXPR bool is_integer = false; \ + static _GLIBCXX_USE_CONSTEXPR bool is_exact = false; \ + static _GLIBCXX_USE_CONSTEXPR int radix \ + = __glibcxx_concat3 (__FLT, BITSIZE, _RADIX__); \ + \ + static _GLIBCXX_CONSTEXPR _Float##BITSIZE \ + epsilon() _GLIBCXX_USE_NOEXCEPT \ + { return __glibcxx_concat3 (__FLT, BITSIZE, _EPSILON__); } \ + \ + static _GLIBCXX_CONSTEXPR _Float##BITSIZE \ + round_error() _GLIBCXX_USE_NOEXCEPT { return 0.5F##BITSIZE; } \ + \ + static _GLIBCXX_USE_CONSTEXPR int min_exponent \ + = __glibcxx_concat3 (__FLT, BITSIZE, _MIN_EXP__); \ + static _GLIBCXX_USE_CONSTEXPR int min_exponent10 \ + = __glibcxx_concat3 (__FLT, BITSIZE, _MIN_10_EXP__); \ + static _GLIBCXX_USE_CONSTEXPR int max_exponent \ + = __glibcxx_concat3 (__FLT, BITSIZE, _MAX_EXP__); \ + static _GLIBCXX_USE_CONSTEXPR int max_exponent10 \ + = __glibcxx_concat3 (__FLT, BITSIZE, _MAX_10_EXP__); \ + \ + static _GLIBCXX_USE_CONSTEXPR bool has_infinity \ + = __glibcxx_concat3 (__FLT, BITSIZE, _HAS_INFINITY__); \ + static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN \ + = __glibcxx_concat3 (__FLT, BITSIZE, _HAS_QUIET_NAN__); \ + static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN \ + = has_quiet_NaN; \ + static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm \ + = bool(__glibcxx_concat3 (__FLT, BITSIZE, _HAS_DENORM__)) \ + ? denorm_present : denorm_absent; \ + static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false; \ + \ + static _GLIBCXX_CONSTEXPR _Float##BITSIZE \ + infinity() _GLIBCXX_USE_NOEXCEPT \ + { return __builtin_huge_valf##BITSIZE(); } \ + \ + static _GLIBCXX_CONSTEXPR _Float##BITSIZE \ + quiet_NaN() _GLIBCXX_USE_NOEXCEPT \ + { return __builtin_nanf##BITSIZE(""); } \ + \ + static _GLIBCXX_CONSTEXPR _Float##BITSIZE \ + signaling_NaN() _GLIBCXX_USE_NOEXCEPT \ + { return __builtin_nansf##BITSIZE(""); } \ + \ + static _GLIBCXX_CONSTEXPR _Float##BITSIZE \ + denorm_min() _GLIBCXX_USE_NOEXCEPT \ + { return __glibcxx_concat3 (__FLT, BITSIZE, _DENORM_MIN__); } \ + \ + static _GLIBCXX_USE_CONSTEXPR bool is_iec559 \ + = as_infinity && has_quiet_NaN && has_denorm == denorm_present; \ + static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true; \ + static _GLIBCXX_USE_CONSTEXPR bool is_modulo = false; \ + \ + static _GLIBCXX_USE_CONSTEXPR bool traps = false; \ + static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false; \ + static _GLIBCXX_USE_CONSTEXPR float_round_style round_style \ + = round_to_nearest; \ + }; \ + +#ifdef __STDCPP_FLOAT16_T__ +__glibcxx_float_n(16) +#endif +#ifdef __STDCPP_FLOAT32_T__ +__glibcxx_float_n(32) +#endif +#ifdef __STDCPP_FLOAT64_T__ +__glibcxx_float_n(64) +#endif +#ifdef __STDCPP_FLOAT128_T__ +__glibcxx_float_n(128) +#endif +#undef __glibcxx_float_n +#undef __glibcxx_concat3 +#undef __glibcxx_concat3_ + +#endif + _GLIBCXX_END_NAMESPACE_VERSION } // namespace --- libstdc++-v3/include/Makefile.am.jj 2022-08-10 23:16:41.981479135 +0200 +++ libstdc++-v3/include/Makefile.am 2022-09-27 09:33:16.838564748 +0200 @@ -83,6 +83,7 @@ std_headers = \ ${std_srcdir}/stack \ ${std_srcdir}/stacktrace \ ${std_srcdir}/stdexcept \ + ${std_srcdir}/stdfloat \ ${std_srcdir}/stop_token \ ${std_srcdir}/streambuf \ ${std_srcdir}/string \ --- libstdc++-v3/include/Makefile.in.jj 2022-08-10 23:16:41.982479122 +0200 +++ libstdc++-v3/include/Makefile.in 2022-09-27 09:33:30.089386201 +0200 @@ -441,6 +441,7 @@ std_headers = \ ${std_srcdir}/stack \ ${std_srcdir}/stacktrace \ ${std_srcdir}/stdexcept \ + ${std_srcdir}/stdfloat \ ${std_srcdir}/stop_token \ ${std_srcdir}/streambuf \ ${std_srcdir}/string \ --- libstdc++-v3/include/precompiled/stdc++.h.jj 2022-05-23 21:44:49.094846916 +0200 +++ libstdc++-v3/include/precompiled/stdc++.h 2022-09-27 08:49:45.932769534 +0200 @@ -159,4 +159,5 @@ # include #endif #include +#include #endif --- libstdc++-v3/testsuite/18_support/headers/stdfloat/types_std.cc.jj 2022-09-27 08:56:15.806529350 +0200 +++ libstdc++-v3/testsuite/18_support/headers/stdfloat/types_std.cc 2022-09-27 09:26:58.681660524 +0200 @@ -0,0 +1,40 @@ +// { dg-options "-std=gnu++2b" } +// { dg-do compile { target c++23 } } + +// Copyright (C) 2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +namespace gnu +{ +#if defined(__STDCPP_FLOAT16_T__) + typedef std::float16_t t1; +#endif +#if defined(__STDCPP_FLOAT32_T__) + typedef std::float32_t t2; +#endif +#if defined(__STDCPP_FLOAT64_T__) + typedef std::float64_t t3; +#endif +#if defined(__STDCPP_FLOAT128_T__) + typedef std::float128_t t4; +#endif +#if defined(__STDCPP_BFLOAT16_T__) + typedef std::bfloat16_t t5; +#endif +} --- libstdc++-v3/testsuite/18_support/headers/limits/synopsis_cxx23.cc.jj 2022-09-27 09:00:16.815274177 +0200 +++ libstdc++-v3/testsuite/18_support/headers/limits/synopsis_cxx23.cc 2022-09-27 09:26:44.055857783 +0200 @@ -0,0 +1,43 @@ +// { dg-options "-std=gnu++2b" } +// { dg-do compile { target c++23 } } +// { dg-require-normal-namespace "" } + +// Copyright (C) 2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +namespace std { + template class numeric_limits; + +#if defined(__STDCPP_FLOAT16_T__) + template<> class numeric_limits; +#endif +#if defined(__STDCPP_FLOAT32_T__) + template<> class numeric_limits; +#endif +#if defined(__STDCPP_FLOAT64_T__) + template<> class numeric_limits; +#endif +#if defined(__STDCPP_FLOAT128_T__) + template<> class numeric_limits; +#endif +#if defined(__STDCPP_BFLOAT16_T__) + template<> class numeric_limits; +#endif +} --- libstdc++-v3/testsuite/26_numerics/numbers/4.cc.jj 2022-09-27 09:04:07.578159213 +0200 +++ libstdc++-v3/testsuite/26_numerics/numbers/4.cc 2022-09-27 09:06:44.603039943 +0200 @@ -0,0 +1,122 @@ +// Copyright (C) 2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-options "-std=gnu++2b" } +// { dg-do compile { target c++23 } } + +#include +#include + +#if defined(__STDCPP_FLOAT16_T__) +void +test01() +{ + const std::float16_t* d1 = &std::numbers::e_v; + const std::float16_t* d2 = &std::numbers::log2e_v; + const std::float16_t* d3 = &std::numbers::log10e_v; + const std::float16_t* d4 = &std::numbers::pi_v; + const std::float16_t* d5 = &std::numbers::inv_pi_v; + const std::float16_t* d6 = &std::numbers::inv_sqrtpi_v; + const std::float16_t* d7 = &std::numbers::ln2_v; + const std::float16_t* d8 = &std::numbers::ln10_v; + const std::float16_t* d9 = &std::numbers::sqrt2_v; + const std::float16_t* d10 = &std::numbers::sqrt3_v; + const std::float16_t* d11 = &std::numbers::inv_sqrt3_v; + const std::float16_t* d12 = &std::numbers::egamma_v; + const std::float16_t* d13 = &std::numbers::phi_v; +} +#endif + +#if defined(__STDCPP_FLOAT32_T__) +void +test02() +{ + const std::float32_t* d1 = &std::numbers::e_v; + const std::float32_t* d2 = &std::numbers::log2e_v; + const std::float32_t* d3 = &std::numbers::log10e_v; + const std::float32_t* d4 = &std::numbers::pi_v; + const std::float32_t* d5 = &std::numbers::inv_pi_v; + const std::float32_t* d6 = &std::numbers::inv_sqrtpi_v; + const std::float32_t* d7 = &std::numbers::ln2_v; + const std::float32_t* d8 = &std::numbers::ln10_v; + const std::float32_t* d9 = &std::numbers::sqrt2_v; + const std::float32_t* d10 = &std::numbers::sqrt3_v; + const std::float32_t* d11 = &std::numbers::inv_sqrt3_v; + const std::float32_t* d12 = &std::numbers::egamma_v; + const std::float32_t* d13 = &std::numbers::phi_v; +} +#endif + +#if defined(__STDCPP_FLOAT64_T__) +void +test03() +{ + const std::float64_t* d1 = &std::numbers::e_v; + const std::float64_t* d2 = &std::numbers::log2e_v; + const std::float64_t* d3 = &std::numbers::log10e_v; + const std::float64_t* d4 = &std::numbers::pi_v; + const std::float64_t* d5 = &std::numbers::inv_pi_v; + const std::float64_t* d6 = &std::numbers::inv_sqrtpi_v; + const std::float64_t* d7 = &std::numbers::ln2_v; + const std::float64_t* d8 = &std::numbers::ln10_v; + const std::float64_t* d9 = &std::numbers::sqrt2_v; + const std::float64_t* d10 = &std::numbers::sqrt3_v; + const std::float64_t* d11 = &std::numbers::inv_sqrt3_v; + const std::float64_t* d12 = &std::numbers::egamma_v; + const std::float64_t* d13 = &std::numbers::phi_v; +} +#endif + +#if defined(__STDCPP_FLOAT128_T__) +void +test04() +{ + const std::float128_t* d1 = &std::numbers::e_v; + const std::float128_t* d2 = &std::numbers::log2e_v; + const std::float128_t* d3 = &std::numbers::log10e_v; + const std::float128_t* d4 = &std::numbers::pi_v; + const std::float128_t* d5 = &std::numbers::inv_pi_v; + const std::float128_t* d6 = &std::numbers::inv_sqrtpi_v; + const std::float128_t* d7 = &std::numbers::ln2_v; + const std::float128_t* d8 = &std::numbers::ln10_v; + const std::float128_t* d9 = &std::numbers::sqrt2_v; + const std::float128_t* d10 = &std::numbers::sqrt3_v; + const std::float128_t* d11 = &std::numbers::inv_sqrt3_v; + const std::float128_t* d12 = &std::numbers::egamma_v; + const std::float128_t* d13 = &std::numbers::phi_v; +} +#endif + +#if defined(__STDCPP_BFLOAT16_T__) +void +test05() +{ + const std::bfloat16_t* d1 = &std::numbers::e_v; + const std::bfloat16_t* d2 = &std::numbers::log2e_v; + const std::bfloat16_t* d3 = &std::numbers::log10e_v; + const std::bfloat16_t* d4 = &std::numbers::pi_v; + const std::bfloat16_t* d5 = &std::numbers::inv_pi_v; + const std::bfloat16_t* d6 = &std::numbers::inv_sqrtpi_v; + const std::bfloat16_t* d7 = &std::numbers::ln2_v; + const std::bfloat16_t* d8 = &std::numbers::ln10_v; + const std::bfloat16_t* d9 = &std::numbers::sqrt2_v; + const std::bfloat16_t* d10 = &std::numbers::sqrt3_v; + const std::bfloat16_t* d11 = &std::numbers::inv_sqrt3_v; + const std::bfloat16_t* d12 = &std::numbers::egamma_v; + const std::bfloat16_t* d13 = &std::numbers::phi_v; +} +#endif --- libstdc++-v3/testsuite/29_atomics/atomic_float/requirements_cxx23.cc.jj 2022-09-27 09:14:12.423997581 +0200 +++ libstdc++-v3/testsuite/29_atomics/atomic_float/requirements_cxx23.cc 2022-09-27 09:16:26.005195519 +0200 @@ -0,0 +1,112 @@ +// Copyright (C) 2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-options "-std=gnu++2b" } +// { dg-do compile { target c++23 } } + +#include +#include + +#if defined(__STDCPP_FLOAT16_T__) +void +test01() +{ + using A = std::atomic; + static_assert( std::is_standard_layout_v ); + static_assert( !std::is_trivially_default_constructible_v ); + static_assert( std::is_trivially_destructible_v ); + static_assert( std::is_same_v ); + static_assert( std::is_same_v ); + static_assert( !std::is_copy_constructible_v ); + static_assert( !std::is_move_constructible_v ); + static_assert( !std::is_copy_assignable_v ); + static_assert( !std::is_move_assignable_v ); + static_assert( !std::is_assignable_v ); +} +#endif + +#if defined(__STDCPP_FLOAT32_T__) +void +test02() +{ + using A = std::atomic; + static_assert( std::is_standard_layout_v ); + static_assert( !std::is_trivially_default_constructible_v ); + static_assert( std::is_trivially_destructible_v ); + static_assert( std::is_same_v ); + static_assert( std::is_same_v ); + static_assert( !std::is_copy_constructible_v ); + static_assert( !std::is_move_constructible_v ); + static_assert( !std::is_copy_assignable_v ); + static_assert( !std::is_move_assignable_v ); + static_assert( !std::is_assignable_v ); +} +#endif + +#if defined(__STDCPP_FLOAT64_T__) +void +test03() +{ + using A = std::atomic; + static_assert( std::is_standard_layout_v ); + static_assert( !std::is_trivially_default_constructible_v ); + static_assert( std::is_trivially_destructible_v ); + static_assert( std::is_same_v ); + static_assert( std::is_same_v ); + static_assert( !std::is_copy_constructible_v ); + static_assert( !std::is_move_constructible_v ); + static_assert( !std::is_copy_assignable_v ); + static_assert( !std::is_move_assignable_v ); + static_assert( !std::is_assignable_v ); +} +#endif + +#if defined(__STDCPP_FLOAT128_T__) +void +test04() +{ + using A = std::atomic; + static_assert( std::is_standard_layout_v ); + static_assert( !std::is_trivially_default_constructible_v ); + static_assert( std::is_trivially_destructible_v ); + static_assert( std::is_same_v ); + static_assert( std::is_same_v ); + static_assert( !std::is_copy_constructible_v ); + static_assert( !std::is_move_constructible_v ); + static_assert( !std::is_copy_assignable_v ); + static_assert( !std::is_move_assignable_v ); + static_assert( !std::is_assignable_v ); +} +#endif + +#if defined(__STDCPP_BFLOAT16_T__) +void +test05() +{ + using A = std::atomic; + static_assert( std::is_standard_layout_v ); + static_assert( !std::is_trivially_default_constructible_v ); + static_assert( std::is_trivially_destructible_v ); + static_assert( std::is_same_v ); + static_assert( std::is_same_v ); + static_assert( !std::is_copy_constructible_v ); + static_assert( !std::is_move_constructible_v ); + static_assert( !std::is_copy_assignable_v ); + static_assert( !std::is_move_assignable_v ); + static_assert( !std::is_assignable_v ); +} +#endif