From patchwork Mon Nov 14 13:57:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 19830 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2162435wru; Mon, 14 Nov 2022 06:05:53 -0800 (PST) X-Google-Smtp-Source: AA0mqf73FvoSwGWJuDjT2JwiePxBEJw6tdJQWbeQzEMFohGuCx3oWz6AZTVLTI9I+fyq+4ncj8W6 X-Received: by 2002:a2e:a553:0:b0:277:3ca2:dacc with SMTP id e19-20020a2ea553000000b002773ca2daccmr3966404ljn.121.1668434753672; Mon, 14 Nov 2022 06:05:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668434753; cv=none; d=google.com; s=arc-20160816; b=LDd5jlMjfZ2wu0GNvgBDL3doOyt9BsKiJM/VItW0qd2VQE5JT3ysHMM/J0AxOklbhM zpjsxIqb3csoEaUC5JiY8qryEhPm+Alf4JMm4Ri13BMBlG/RSbFkpZnV34sxTyj8BsRn mcC3G1IRbzhiAHHSvqrGb8LZLbWxqchFRhG6r7LRvlmFthi9uVZFmYNevg6AJJYyhwvW VaCmUh1M/zC7jDYsnEwrSEbNNMUMrfMDfRzP6acJymApT/cOXhaGwYtb6sn/dTYpWc1i Ff5sXoCxGCSmBlFKPjp5RNFLz6/nHehN/qlrxZo0Qk3/JmUz71Kso7uO1zAXUxrSiwB0 KZ3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:cc:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=CuFSnfR7BBZ+7yXL2i/edtT/qNrHbAkvJlctt+779EA=; b=VN5Xq/54bUOG0Wxi63R9ELJYkBuALeCbaFX7Va3PconnOFwLhz5EbCHraQDi5x3XJl QbL9lUY9K6Gx3PQKz8NUTKfe0sbUgSTPz+ZkSRrXTB8Zd9tjDgtT6tULjyCAFdIz0uwt 5gfQh06/s3Pky5fgc+Iu1JTN6iInAqhP72jwATNoezJyOozUJRnEZ9CR7oz6f4Bz55yF zMPscdByyEJL5cRGQSrUzEOIaUGgvD+3D86tgBao7XiA/jjZBYaBj/Mbq0NghtxtCUxP uXtBN1lTynGOGS0f7EdZO1/AKbCIK27xZtjnxLq/Ca2l9GThDltF9q6jgtNESj/Jxs7+ 7sJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="G5CD5/rf"; 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 he42-20020a1709073daa00b00781132a4ca6si9492019ejc.850.2022.11.14.06.05.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Nov 2022 06:05:53 -0800 (PST) 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="G5CD5/rf"; 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 386BA382EF17 for ; Mon, 14 Nov 2022 13:59:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 386BA382EF17 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1668434348; bh=CuFSnfR7BBZ+7yXL2i/edtT/qNrHbAkvJlctt+779EA=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=G5CD5/rfle9Pi0ZgIxSffOWNQYvE/aqFJT7bbjN/a3F24W0BqZq7hvfi6QBQp5//d akLI8qczJwjKsbNb7DUdX8c9KT7H+Vg5SBC/iqZtHgp3N5Ym+GGhziGXt/cHG4V6pU uSfCChfV6KzDHNR8r+mZdEWneRSuskOQoZ3Zx3g4= 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 ESMTPS id DB902393BA7E for ; Mon, 14 Nov 2022 13:57:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org DB902393BA7E Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-561-cWgr7VefNlakb9kI0qr8jw-1; Mon, 14 Nov 2022 08:57:54 -0500 X-MC-Unique: cWgr7VefNlakb9kI0qr8jw-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 588F53C10146; Mon, 14 Nov 2022 13:57:54 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C175BC15BB3; Mon, 14 Nov 2022 13:57:53 +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 2AEDvm6A2846319 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 14 Nov 2022 14:57:49 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 2AEDvmSw2846318; Mon, 14 Nov 2022 14:57:48 +0100 Date: Mon, 14 Nov 2022 14:57:48 +0100 To: Jonathan Wakely Cc: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org Subject: [PATCH] libstdc++: Fix up for extended floating point types [PR107649] 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.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, 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 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 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?1749480640285920040?= X-GMAIL-MSGID: =?utf-8?q?1749480640285920040?= Hi! As filed by Jonathan in the PR, I've screwed up the requires syntax in the extended floating point specialization: - requires(__complex_type<_Tp>::type) + requires requires { typename __complex_type<_Tp>::type; } and doing this change resulted in lots of errors because __complex_whatever overfloads from extended floating point types were declared after the templates which used them. The following patch fixes that. Bootstrapped/regtested on x86_64-linux and i686-linux, additionally I've tested that with _GLIBCXX_HAVE_FLOAT128_MATH not being defined while __STDCPP_FLOAT128_T__ defined one can still use std::complex for basic arithmetic etc., just one can't expect std::sin etc. to work in that case (because we don't have any implementation). Ok for trunk? 2022-11-14 Jakub Jelinek Jonathan Wakely PR libstdc++/107649 * include/std/complex (__complex_abs, __complex_arg, __complex_cos, __complex_cosh, __complex_exp, __complex_log, __complex_sin, __complex_sinh, __complex_sqrt, __complex_tan, __complex_tanh, __complex_pow): Move __complex__ _Float{16,32,64,128} and __complex__ decltype(0.0bf16) overloads earlier in the file. (complex): Fix up requires on the partial specialization for extended float types. (__complex_acos, __complex_asin, __complex_atan, __complex_acosh, __complex_asinh, __complex_atanh): Move __complex__ _Float{16,32,64,128} and __complex__ decltype(0.0bf16) overloads earlier in the file. Jakub --- libstdc++-v3/include/std/complex.jj 2022-10-31 20:15:49.756552019 +0100 +++ libstdc++-v3/include/std/complex 2022-11-12 01:56:42.970560123 +0100 @@ -598,6 +598,264 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __z.imag(); } #endif +#if _GLIBCXX_USE_C99_COMPLEX +#if defined(__STDCPP_FLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32) + inline _Float16 + __complex_abs(__complex__ _Float16 __z) + { return _Float16(__builtin_cabsf(__z)); } + + inline _Float16 + __complex_arg(__complex__ _Float16 __z) + { return _Float16(__builtin_cargf(__z)); } + + inline __complex__ _Float16 + __complex_cos(__complex__ _Float16 __z) + { return static_cast<__complex__ _Float16>(__builtin_ccosf(__z)); } + + inline __complex__ _Float16 + __complex_cosh(__complex__ _Float16 __z) + { return static_cast<__complex__ _Float16>(__builtin_ccoshf(__z)); } + + inline __complex__ _Float16 + __complex_exp(__complex__ _Float16 __z) + { return static_cast<__complex__ _Float16>(__builtin_cexpf(__z)); } + + inline __complex__ _Float16 + __complex_log(__complex__ _Float16 __z) + { return static_cast<__complex__ _Float16>(__builtin_clogf(__z)); } + + inline __complex__ _Float16 + __complex_sin(__complex__ _Float16 __z) + { return static_cast<__complex__ _Float16>(__builtin_csinf(__z)); } + + inline __complex__ _Float16 + __complex_sinh(__complex__ _Float16 __z) + { return static_cast<__complex__ _Float16>(__builtin_csinhf(__z)); } + + inline __complex__ _Float16 + __complex_sqrt(__complex__ _Float16 __z) + { return static_cast<__complex__ _Float16>(__builtin_csqrtf(__z)); } + + inline __complex__ _Float16 + __complex_tan(__complex__ _Float16 __z) + { return static_cast<__complex__ _Float16>(__builtin_ctanf(__z)); } + + inline __complex__ _Float16 + __complex_tanh(__complex__ _Float16 __z) + { return static_cast<__complex__ _Float16>(__builtin_ctanhf(__z)); } + + inline __complex__ _Float16 + __complex_pow(__complex__ _Float16 __x, __complex__ _Float16 __y) + { return static_cast<__complex__ _Float16>(__builtin_cpowf(__x, __y)); } +#endif + +#if defined(__STDCPP_FLOAT32_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32) + inline _Float32 + __complex_abs(__complex__ _Float32 __z) { return __builtin_cabsf(__z); } + + inline _Float32 + __complex_arg(__complex__ _Float32 __z) { return __builtin_cargf(__z); } + + inline __complex__ _Float32 + __complex_cos(__complex__ _Float32 __z) { return __builtin_ccosf(__z); } + + inline __complex__ _Float32 + __complex_cosh(__complex__ _Float32 __z) { return __builtin_ccoshf(__z); } + + inline __complex__ _Float32 + __complex_exp(__complex__ _Float32 __z) { return __builtin_cexpf(__z); } + + inline __complex__ _Float32 + __complex_log(__complex__ _Float32 __z) { return __builtin_clogf(__z); } + + inline __complex__ _Float32 + __complex_sin(__complex__ _Float32 __z) { return __builtin_csinf(__z); } + + inline __complex__ _Float32 + __complex_sinh(__complex__ _Float32 __z) { return __builtin_csinhf(__z); } + + inline __complex__ _Float32 + __complex_sqrt(__complex__ _Float32 __z) { return __builtin_csqrtf(__z); } + + inline __complex__ _Float32 + __complex_tan(__complex__ _Float32 __z) { return __builtin_ctanf(__z); } + + inline __complex__ _Float32 + __complex_tanh(__complex__ _Float32 __z) { return __builtin_ctanhf(__z); } + + inline __complex__ _Float32 + __complex_pow(__complex__ _Float32 __x, __complex__ _Float32 __y) + { return __builtin_cpowf(__x, __y); } +#endif + +#if defined(__STDCPP_FLOAT64_T__) && defined(_GLIBCXX_DOUBLE_IS_IEEE_BINARY64) + inline _Float64 + __complex_abs(__complex__ _Float64 __z) { return __builtin_cabs(__z); } + + inline _Float64 + __complex_arg(__complex__ _Float64 __z) { return __builtin_carg(__z); } + + inline __complex__ _Float64 + __complex_cos(__complex__ _Float64 __z) { return __builtin_ccos(__z); } + + inline __complex__ _Float64 + __complex_cosh(__complex__ _Float64 __z) { return __builtin_ccosh(__z); } + + inline __complex__ _Float64 + __complex_exp(__complex__ _Float64 __z) { return __builtin_cexp(__z); } + + inline __complex__ _Float64 + __complex_log(__complex__ _Float64 __z) { return __builtin_clog(__z); } + + inline __complex__ _Float64 + __complex_sin(__complex__ _Float64 __z) { return __builtin_csin(__z); } + + inline __complex__ _Float64 + __complex_sinh(__complex__ _Float64 __z) { return __builtin_csinh(__z); } + + inline __complex__ _Float64 + __complex_sqrt(__complex__ _Float64 __z) { return __builtin_csqrt(__z); } + + inline __complex__ _Float64 + __complex_tan(__complex__ _Float64 __z) { return __builtin_ctan(__z); } + + inline __complex__ _Float64 + __complex_tanh(__complex__ _Float64 __z) { return __builtin_ctanh(__z); } + + inline __complex__ _Float64 + __complex_pow(__complex__ _Float64 __x, __complex__ _Float64 __y) + { return __builtin_cpow(__x, __y); } +#endif + +#if defined(__STDCPP_FLOAT128_T__) && defined(_GLIBCXX_LDOUBLE_IS_IEEE_BINARY128) + inline _Float128 + __complex_abs(__complex__ _Float128 __z) { return __builtin_cabsl(__z); } + + inline _Float128 + __complex_arg(__complex__ _Float128 __z) { return __builtin_cargl(__z); } + + inline __complex__ _Float128 + __complex_cos(__complex__ _Float128 __z) { return __builtin_ccosl(__z); } + + inline __complex__ _Float128 + __complex_cosh(__complex__ _Float128 __z) { return __builtin_ccoshl(__z); } + + inline __complex__ _Float128 + __complex_exp(__complex__ _Float128 __z) { return __builtin_cexpl(__z); } + + inline __complex__ _Float128 + __complex_log(__complex__ _Float128 __z) { return __builtin_clogl(__z); } + + inline __complex__ _Float128 + __complex_sin(__complex__ _Float128 __z) { return __builtin_csinl(__z); } + + inline __complex__ _Float128 + __complex_sinh(__complex__ _Float128 __z) { return __builtin_csinhl(__z); } + + inline __complex__ _Float128 + __complex_sqrt(__complex__ _Float128 __z) { return __builtin_csqrtl(__z); } + + inline __complex__ _Float128 + __complex_tan(__complex__ _Float128 __z) { return __builtin_ctanl(__z); } + + inline __complex__ _Float128 + __complex_tanh(__complex__ _Float128 __z) { return __builtin_ctanhl(__z); } + + inline __complex__ _Float128 + __complex_pow(__complex__ _Float128 __x, __complex__ _Float128 __y) + { return __builtin_cpowl(__x, __y); } +#elif defined(__STDCPP_FLOAT128_T__) && defined(_GLIBCXX_HAVE_FLOAT128_MATH) + inline _Float128 + __complex_abs(__complex__ _Float128 __z) { return __builtin_cabsf128(__z); } + + inline _Float128 + __complex_arg(__complex__ _Float128 __z) { return __builtin_cargf128(__z); } + + inline __complex__ _Float128 + __complex_cos(__complex__ _Float128 __z) { return __builtin_ccosf128(__z); } + + inline __complex__ _Float128 + __complex_cosh(__complex__ _Float128 __z) { return __builtin_ccoshf128(__z); } + + inline __complex__ _Float128 + __complex_exp(__complex__ _Float128 __z) { return __builtin_cexpf128(__z); } + + inline __complex__ _Float128 + __complex_log(__complex__ _Float128 __z) { return __builtin_clogf128(__z); } + + inline __complex__ _Float128 + __complex_sin(__complex__ _Float128 __z) { return __builtin_csinf128(__z); } + + inline __complex__ _Float128 + __complex_sinh(__complex__ _Float128 __z) { return __builtin_csinhf128(__z); } + + inline __complex__ _Float128 + __complex_sqrt(__complex__ _Float128 __z) { return __builtin_csqrtf128(__z); } + + inline __complex__ _Float128 + __complex_tan(__complex__ _Float128 __z) { return __builtin_ctanf128(__z); } + + inline __complex__ _Float128 + __complex_tanh(__complex__ _Float128 __z) { return __builtin_ctanhf128(__z); } + + inline __complex__ _Float128 + __complex_pow(__complex__ _Float128 __x, __complex__ _Float128 __y) + { return __builtin_cpowf128(__x, __y); } +#endif + +#if defined(__STDCPP_BFLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32) + inline __gnu_cxx::__bfloat16_t + __complex_abs(__complex__ decltype(0.0bf16) __z) + { return __gnu_cxx::__bfloat16_t(__builtin_cabsf(__z)); } + + inline __gnu_cxx::__bfloat16_t + __complex_arg(__complex__ decltype(0.0bf16) __z) + { return __gnu_cxx::__bfloat16_t(__builtin_cargf(__z)); } + + inline __complex__ decltype(0.0bf16) + __complex_cos(__complex__ decltype(0.0bf16) __z) + { return static_cast<__complex__ decltype(0.0bf16)>(__builtin_ccosf(__z)); } + + inline __complex__ decltype(0.0bf16) + __complex_cosh(__complex__ decltype(0.0bf16) __z) + { return static_cast<__complex__ decltype(0.0bf16)>(__builtin_ccoshf(__z)); } + + inline __complex__ decltype(0.0bf16) + __complex_exp(__complex__ decltype(0.0bf16) __z) + { return static_cast<__complex__ decltype(0.0bf16)>(__builtin_cexpf(__z)); } + + inline __complex__ decltype(0.0bf16) + __complex_log(__complex__ decltype(0.0bf16) __z) + { return static_cast<__complex__ decltype(0.0bf16)>(__builtin_clogf(__z)); } + + inline __complex__ decltype(0.0bf16) + __complex_sin(__complex__ decltype(0.0bf16) __z) + { return static_cast<__complex__ decltype(0.0bf16)>(__builtin_csinf(__z)); } + + inline __complex__ decltype(0.0bf16) + __complex_sinh(__complex__ decltype(0.0bf16) __z) + { return static_cast<__complex__ decltype(0.0bf16)>(__builtin_csinhf(__z)); } + + inline __complex__ decltype(0.0bf16) + __complex_sqrt(__complex__ decltype(0.0bf16) __z) + { return static_cast<__complex__ decltype(0.0bf16)>(__builtin_csqrtf(__z)); } + + inline __complex__ decltype(0.0bf16) + __complex_tan(__complex__ decltype(0.0bf16) __z) + { return static_cast<__complex__ decltype(0.0bf16)>(__builtin_ctanf(__z)); } + + inline __complex__ decltype(0.0bf16) + __complex_tanh(__complex__ decltype(0.0bf16) __z) + { return static_cast<__complex__ decltype(0.0bf16)>(__builtin_ctanhf(__z)); } + + inline __complex__ decltype(0.0bf16) + __complex_pow(__complex__ decltype(0.0bf16) __x, + __complex__ decltype(0.0bf16) __y) + { return static_cast<__complex__ decltype(0.0bf16)>(__builtin_cpowf(__x, + __y)); } +#endif +#endif + // 26.2.7/3 abs(__z): Returns the magnitude of __z. template inline _Tp @@ -1080,264 +1338,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : std::pow(complex<_Tp>(__x), __y); } -#if _GLIBCXX_USE_C99_COMPLEX -#if defined(__STDCPP_FLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32) - inline _Float16 - __complex_abs(__complex__ _Float16 __z) - { return _Float16(__builtin_cabsf(__z)); } - - inline _Float16 - __complex_arg(__complex__ _Float16 __z) - { return _Float16(__builtin_cargf(__z)); } - - inline __complex__ _Float16 - __complex_cos(__complex__ _Float16 __z) - { return static_cast<__complex__ _Float16>(__builtin_ccosf(__z)); } - - inline __complex__ _Float16 - __complex_cosh(__complex__ _Float16 __z) - { return static_cast<__complex__ _Float16>(__builtin_ccoshf(__z)); } - - inline __complex__ _Float16 - __complex_exp(__complex__ _Float16 __z) - { return static_cast<__complex__ _Float16>(__builtin_cexpf(__z)); } - - inline __complex__ _Float16 - __complex_log(__complex__ _Float16 __z) - { return static_cast<__complex__ _Float16>(__builtin_clogf(__z)); } - - inline __complex__ _Float16 - __complex_sin(__complex__ _Float16 __z) - { return static_cast<__complex__ _Float16>(__builtin_csinf(__z)); } - - inline __complex__ _Float16 - __complex_sinh(__complex__ _Float16 __z) - { return static_cast<__complex__ _Float16>(__builtin_csinhf(__z)); } - - inline __complex__ _Float16 - __complex_sqrt(__complex__ _Float16 __z) - { return static_cast<__complex__ _Float16>(__builtin_csqrtf(__z)); } - - inline __complex__ _Float16 - __complex_tan(__complex__ _Float16 __z) - { return static_cast<__complex__ _Float16>(__builtin_ctanf(__z)); } - - inline __complex__ _Float16 - __complex_tanh(__complex__ _Float16 __z) - { return static_cast<__complex__ _Float16>(__builtin_ctanhf(__z)); } - - inline __complex__ _Float16 - __complex_pow(__complex__ _Float16 __x, __complex__ _Float16 __y) - { return static_cast<__complex__ _Float16>(__builtin_cpowf(__x, __y)); } -#endif - -#if defined(__STDCPP_FLOAT32_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32) - inline _Float32 - __complex_abs(__complex__ _Float32 __z) { return __builtin_cabsf(__z); } - - inline _Float32 - __complex_arg(__complex__ _Float32 __z) { return __builtin_cargf(__z); } - - inline __complex__ _Float32 - __complex_cos(__complex__ _Float32 __z) { return __builtin_ccosf(__z); } - - inline __complex__ _Float32 - __complex_cosh(__complex__ _Float32 __z) { return __builtin_ccoshf(__z); } - - inline __complex__ _Float32 - __complex_exp(__complex__ _Float32 __z) { return __builtin_cexpf(__z); } - - inline __complex__ _Float32 - __complex_log(__complex__ _Float32 __z) { return __builtin_clogf(__z); } - - inline __complex__ _Float32 - __complex_sin(__complex__ _Float32 __z) { return __builtin_csinf(__z); } - - inline __complex__ _Float32 - __complex_sinh(__complex__ _Float32 __z) { return __builtin_csinhf(__z); } - - inline __complex__ _Float32 - __complex_sqrt(__complex__ _Float32 __z) { return __builtin_csqrtf(__z); } - - inline __complex__ _Float32 - __complex_tan(__complex__ _Float32 __z) { return __builtin_ctanf(__z); } - - inline __complex__ _Float32 - __complex_tanh(__complex__ _Float32 __z) { return __builtin_ctanhf(__z); } - - inline __complex__ _Float32 - __complex_pow(__complex__ _Float32 __x, __complex__ _Float32 __y) - { return __builtin_cpowf(__x, __y); } -#endif - -#if defined(__STDCPP_FLOAT64_T__) && defined(_GLIBCXX_DOUBLE_IS_IEEE_BINARY64) - inline _Float64 - __complex_abs(__complex__ _Float64 __z) { return __builtin_cabs(__z); } - - inline _Float64 - __complex_arg(__complex__ _Float64 __z) { return __builtin_carg(__z); } - - inline __complex__ _Float64 - __complex_cos(__complex__ _Float64 __z) { return __builtin_ccos(__z); } - - inline __complex__ _Float64 - __complex_cosh(__complex__ _Float64 __z) { return __builtin_ccosh(__z); } - - inline __complex__ _Float64 - __complex_exp(__complex__ _Float64 __z) { return __builtin_cexp(__z); } - - inline __complex__ _Float64 - __complex_log(__complex__ _Float64 __z) { return __builtin_clog(__z); } - - inline __complex__ _Float64 - __complex_sin(__complex__ _Float64 __z) { return __builtin_csin(__z); } - - inline __complex__ _Float64 - __complex_sinh(__complex__ _Float64 __z) { return __builtin_csinh(__z); } - - inline __complex__ _Float64 - __complex_sqrt(__complex__ _Float64 __z) { return __builtin_csqrt(__z); } - - inline __complex__ _Float64 - __complex_tan(__complex__ _Float64 __z) { return __builtin_ctan(__z); } - - inline __complex__ _Float64 - __complex_tanh(__complex__ _Float64 __z) { return __builtin_ctanh(__z); } - - inline __complex__ _Float64 - __complex_pow(__complex__ _Float64 __x, __complex__ _Float64 __y) - { return __builtin_cpow(__x, __y); } -#endif - -#if defined(__STDCPP_FLOAT128_T__) && defined(_GLIBCXX_LDOUBLE_IS_IEEE_BINARY128) - inline _Float128 - __complex_abs(__complex__ _Float128 __z) { return __builtin_cabsl(__z); } - - inline _Float128 - __complex_arg(__complex__ _Float128 __z) { return __builtin_cargl(__z); } - - inline __complex__ _Float128 - __complex_cos(__complex__ _Float128 __z) { return __builtin_ccosl(__z); } - - inline __complex__ _Float128 - __complex_cosh(__complex__ _Float128 __z) { return __builtin_ccoshl(__z); } - - inline __complex__ _Float128 - __complex_exp(__complex__ _Float128 __z) { return __builtin_cexpl(__z); } - - inline __complex__ _Float128 - __complex_log(__complex__ _Float128 __z) { return __builtin_clogl(__z); } - - inline __complex__ _Float128 - __complex_sin(__complex__ _Float128 __z) { return __builtin_csinl(__z); } - - inline __complex__ _Float128 - __complex_sinh(__complex__ _Float128 __z) { return __builtin_csinhl(__z); } - - inline __complex__ _Float128 - __complex_sqrt(__complex__ _Float128 __z) { return __builtin_csqrtl(__z); } - - inline __complex__ _Float128 - __complex_tan(__complex__ _Float128 __z) { return __builtin_ctanl(__z); } - - inline __complex__ _Float128 - __complex_tanh(__complex__ _Float128 __z) { return __builtin_ctanhl(__z); } - - inline __complex__ _Float128 - __complex_pow(__complex__ _Float128 __x, __complex__ _Float128 __y) - { return __builtin_cpowl(__x, __y); } -#elif defined(__STDCPP_FLOAT128_T__) && defined(_GLIBCXX_HAVE_FLOAT128_MATH) - inline _Float128 - __complex_abs(__complex__ _Float128 __z) { return __builtin_cabsf128(__z); } - - inline _Float128 - __complex_arg(__complex__ _Float128 __z) { return __builtin_cargf128(__z); } - - inline __complex__ _Float128 - __complex_cos(__complex__ _Float128 __z) { return __builtin_ccosf128(__z); } - - inline __complex__ _Float128 - __complex_cosh(__complex__ _Float128 __z) { return __builtin_ccoshf128(__z); } - - inline __complex__ _Float128 - __complex_exp(__complex__ _Float128 __z) { return __builtin_cexpf128(__z); } - - inline __complex__ _Float128 - __complex_log(__complex__ _Float128 __z) { return __builtin_clogf128(__z); } - - inline __complex__ _Float128 - __complex_sin(__complex__ _Float128 __z) { return __builtin_csinf128(__z); } - - inline __complex__ _Float128 - __complex_sinh(__complex__ _Float128 __z) { return __builtin_csinhf128(__z); } - - inline __complex__ _Float128 - __complex_sqrt(__complex__ _Float128 __z) { return __builtin_csqrtf128(__z); } - - inline __complex__ _Float128 - __complex_tan(__complex__ _Float128 __z) { return __builtin_ctanf128(__z); } - - inline __complex__ _Float128 - __complex_tanh(__complex__ _Float128 __z) { return __builtin_ctanhf128(__z); } - - inline __complex__ _Float128 - __complex_pow(__complex__ _Float128 __x, __complex__ _Float128 __y) - { return __builtin_cpowf128(__x, __y); } -#endif - -#if defined(__STDCPP_BFLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32) - inline __gnu_cxx::__bfloat16_t - __complex_abs(__complex__ decltype(0.0bf16) __z) - { return __gnu_cxx::__bfloat16_t(__builtin_cabsf(__z)); } - - inline __gnu_cxx::__bfloat16_t - __complex_arg(__complex__ decltype(0.0bf16) __z) - { return __gnu_cxx::__bfloat16_t(__builtin_cargf(__z)); } - - inline __complex__ decltype(0.0bf16) - __complex_cos(__complex__ decltype(0.0bf16) __z) - { return static_cast<__complex__ decltype(0.0bf16)>(__builtin_ccosf(__z)); } - - inline __complex__ decltype(0.0bf16) - __complex_cosh(__complex__ decltype(0.0bf16) __z) - { return static_cast<__complex__ decltype(0.0bf16)>(__builtin_ccoshf(__z)); } - - inline __complex__ decltype(0.0bf16) - __complex_exp(__complex__ decltype(0.0bf16) __z) - { return static_cast<__complex__ decltype(0.0bf16)>(__builtin_cexpf(__z)); } - - inline __complex__ decltype(0.0bf16) - __complex_log(__complex__ decltype(0.0bf16) __z) - { return static_cast<__complex__ decltype(0.0bf16)>(__builtin_clogf(__z)); } - - inline __complex__ decltype(0.0bf16) - __complex_sin(__complex__ decltype(0.0bf16) __z) - { return static_cast<__complex__ decltype(0.0bf16)>(__builtin_csinf(__z)); } - - inline __complex__ decltype(0.0bf16) - __complex_sinh(__complex__ decltype(0.0bf16) __z) - { return static_cast<__complex__ decltype(0.0bf16)>(__builtin_csinhf(__z)); } - - inline __complex__ decltype(0.0bf16) - __complex_sqrt(__complex__ decltype(0.0bf16) __z) - { return static_cast<__complex__ decltype(0.0bf16)>(__builtin_csqrtf(__z)); } - - inline __complex__ decltype(0.0bf16) - __complex_tan(__complex__ decltype(0.0bf16) __z) - { return static_cast<__complex__ decltype(0.0bf16)>(__builtin_ctanf(__z)); } - - inline __complex__ decltype(0.0bf16) - __complex_tanh(__complex__ decltype(0.0bf16) __z) - { return static_cast<__complex__ decltype(0.0bf16)>(__builtin_ctanhf(__z)); } - - inline __complex__ decltype(0.0bf16) - __complex_pow(__complex__ decltype(0.0bf16) __x, - __complex__ decltype(0.0bf16) __y) - { return static_cast<__complex__ decltype(0.0bf16)>(__builtin_cpowf(__x, - __y)); } -#endif -#endif - /// 26.2.3 complex specializations /// complex specialization template<> @@ -1835,7 +1835,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #endif template - requires(__complex_type<_Tp>::type) + requires requires { typename __complex_type<_Tp>::type; } class complex<_Tp> { public: @@ -2022,6 +2022,162 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } #if _GLIBCXX_USE_C99_COMPLEX_TR1 +#if defined(__STDCPP_FLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32) + inline __complex__ _Float16 + __complex_acos(__complex__ _Float16 __z) + { return static_cast<__complex__ _Float16>(__builtin_cacosf(__z)); } + + inline __complex__ _Float16 + __complex_asin(__complex__ _Float16 __z) + { return static_cast<__complex__ _Float16>(__builtin_casinf(__z)); } + + inline __complex__ _Float16 + __complex_atan(__complex__ _Float16 __z) + { return static_cast<__complex__ _Float16>(__builtin_catanf(__z)); } + + inline __complex__ _Float16 + __complex_acosh(__complex__ _Float16 __z) + { return static_cast<__complex__ _Float16>(__builtin_cacoshf(__z)); } + + inline __complex__ _Float16 + __complex_asinh(__complex__ _Float16 __z) + { return static_cast<__complex__ _Float16>(__builtin_casinhf(__z)); } + + inline __complex__ _Float16 + __complex_atanh(__complex__ _Float16 __z) + { return static_cast<__complex__ _Float16>(__builtin_catanhf(__z)); } +#endif + +#if defined(__STDCPP_FLOAT32_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32) + inline __complex__ _Float32 + __complex_acos(__complex__ _Float32 __z) + { return __builtin_cacosf(__z); } + + inline __complex__ _Float32 + __complex_asin(__complex__ _Float32 __z) + { return __builtin_casinf(__z); } + + inline __complex__ _Float32 + __complex_atan(__complex__ _Float32 __z) + { return __builtin_catanf(__z); } + + inline __complex__ _Float32 + __complex_acosh(__complex__ _Float32 __z) + { return __builtin_cacoshf(__z); } + + inline __complex__ _Float32 + __complex_asinh(__complex__ _Float32 __z) + { return __builtin_casinhf(__z); } + + inline __complex__ _Float32 + __complex_atanh(__complex__ _Float32 __z) + { return __builtin_catanhf(__z); } +#endif + +#if defined(__STDCPP_FLOAT64_T__) && defined(_GLIBCXX_DOUBLE_IS_IEEE_BINARY64) + inline __complex__ _Float64 + __complex_acos(__complex__ _Float64 __z) + { return __builtin_cacos(__z); } + + inline __complex__ _Float64 + __complex_asin(__complex__ _Float64 __z) + { return __builtin_casin(__z); } + + inline __complex__ _Float64 + __complex_atan(__complex__ _Float64 __z) + { return __builtin_catan(__z); } + + inline __complex__ _Float64 + __complex_acosh(__complex__ _Float64 __z) + { return __builtin_cacosh(__z); } + + inline __complex__ _Float64 + __complex_asinh(__complex__ _Float64 __z) + { return __builtin_casinh(__z); } + + inline __complex__ _Float64 + __complex_atanh(__complex__ _Float64 __z) + { return __builtin_catanh(__z); } +#endif + +#if defined(__STDCPP_FLOAT128_T__) && defined(_GLIBCXX_LDOUBLE_IS_IEEE_BINARY128) + inline __complex__ _Float128 + __complex_acos(__complex__ _Float128 __z) + { return __builtin_cacosl(__z); } + + inline __complex__ _Float128 + __complex_asin(__complex__ _Float128 __z) + { return __builtin_casinl(__z); } + + inline __complex__ _Float128 + __complex_atan(__complex__ _Float128 __z) + { return __builtin_catanl(__z); } + + inline __complex__ _Float128 + __complex_acosh(__complex__ _Float128 __z) + { return __builtin_cacoshl(__z); } + + inline __complex__ _Float128 + __complex_asinh(__complex__ _Float128 __z) + { return __builtin_casinhl(__z); } + + inline __complex__ _Float128 + __complex_atanh(__complex__ _Float128 __z) + { return __builtin_catanhl(__z); } +#elif defined(__STDCPP_FLOAT128_T__) && defined(_GLIBCXX_HAVE_FLOAT128_MATH) + inline __complex__ _Float128 + __complex_acos(__complex__ _Float128 __z) + { return __builtin_cacosf128(__z); } + + inline __complex__ _Float128 + __complex_asin(__complex__ _Float128 __z) + { return __builtin_casinf128(__z); } + + inline __complex__ _Float128 + __complex_atan(__complex__ _Float128 __z) + { return __builtin_catanf128(__z); } + + inline __complex__ _Float128 + __complex_acosh(__complex__ _Float128 __z) + { return __builtin_cacoshf128(__z); } + + inline __complex__ _Float128 + __complex_asinh(__complex__ _Float128 __z) + { return __builtin_casinhf128(__z); } + + inline __complex__ _Float128 + __complex_atanh(__complex__ _Float128 __z) + { return __builtin_catanhf128(__z); } +#endif + +#if defined(__STDCPP_BFLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32) + inline __complex__ decltype(0.0bf16) + __complex_acos(__complex__ decltype(0.0bf16) __z) + { return static_cast<__complex__ decltype(0.0bf16)>(__builtin_cacosf(__z)); } + + inline __complex__ decltype(0.0bf16) + __complex_asin(__complex__ decltype(0.0bf16) __z) + { return static_cast<__complex__ decltype(0.0bf16)>(__builtin_casinf(__z)); } + + inline __complex__ decltype(0.0bf16) + __complex_atan(__complex__ decltype(0.0bf16) __z) + { return static_cast<__complex__ decltype(0.0bf16)>(__builtin_catanf(__z)); } + + inline __complex__ decltype(0.0bf16) + __complex_acosh(__complex__ decltype(0.0bf16) __z) + { return static_cast<__complex__ decltype(0.0bf16)>(__builtin_cacoshf(__z)); } + + inline __complex__ decltype(0.0bf16) + __complex_asinh(__complex__ decltype(0.0bf16) __z) + { return static_cast<__complex__ decltype(0.0bf16)>(__builtin_casinhf(__z)); } + + inline __complex__ decltype(0.0bf16) + __complex_atanh(__complex__ decltype(0.0bf16) __z) + { return static_cast<__complex__ decltype(0.0bf16)>(__builtin_catanhf(__z)); } +#endif +#endif + +#if _GLIBCXX_USE_C99_COMPLEX_TR1 inline __complex__ float __complex_acos(__complex__ float __z) { return __builtin_cacosf(__z); } @@ -2247,162 +2403,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __complex_atanh(__z); } #endif -#if _GLIBCXX_USE_C99_COMPLEX_TR1 -#if defined(__STDCPP_FLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32) - inline __complex__ _Float16 - __complex_acos(__complex__ _Float16 __z) - { return static_cast<__complex__ _Float16>(__builtin_cacosf(__z)); } - - inline __complex__ _Float16 - __complex_asin(__complex__ _Float16 __z) - { return static_cast<__complex__ _Float16>(__builtin_casinf(__z)); } - - inline __complex__ _Float16 - __complex_atan(__complex__ _Float16 __z) - { return static_cast<__complex__ _Float16>(__builtin_catanf(__z)); } - - inline __complex__ _Float16 - __complex_acosh(__complex__ _Float16 __z) - { return static_cast<__complex__ _Float16>(__builtin_cacoshf(__z)); } - - inline __complex__ _Float16 - __complex_asinh(__complex__ _Float16 __z) - { return static_cast<__complex__ _Float16>(__builtin_casinhf(__z)); } - - inline __complex__ _Float16 - __complex_atanh(__complex__ _Float16 __z) - { return static_cast<__complex__ _Float16>(__builtin_catanhf(__z)); } -#endif - -#if defined(__STDCPP_FLOAT32_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32) - inline __complex__ _Float32 - __complex_acos(__complex__ _Float32 __z) - { return __builtin_cacosf(__z); } - - inline __complex__ _Float32 - __complex_asin(__complex__ _Float32 __z) - { return __builtin_casinf(__z); } - - inline __complex__ _Float32 - __complex_atan(__complex__ _Float32 __z) - { return __builtin_catanf(__z); } - - inline __complex__ _Float32 - __complex_acosh(__complex__ _Float32 __z) - { return __builtin_cacoshf(__z); } - - inline __complex__ _Float32 - __complex_asinh(__complex__ _Float32 __z) - { return __builtin_casinhf(__z); } - - inline __complex__ _Float32 - __complex_atanh(__complex__ _Float32 __z) - { return __builtin_catanhf(__z); } -#endif - -#if defined(__STDCPP_FLOAT64_T__) && defined(_GLIBCXX_DOUBLE_IS_IEEE_BINARY64) - inline __complex__ _Float64 - __complex_acos(__complex__ _Float64 __z) - { return __builtin_cacos(__z); } - - inline __complex__ _Float64 - __complex_asin(__complex__ _Float64 __z) - { return __builtin_casin(__z); } - - inline __complex__ _Float64 - __complex_atan(__complex__ _Float64 __z) - { return __builtin_catan(__z); } - - inline __complex__ _Float64 - __complex_acosh(__complex__ _Float64 __z) - { return __builtin_cacosh(__z); } - - inline __complex__ _Float64 - __complex_asinh(__complex__ _Float64 __z) - { return __builtin_casinh(__z); } - - inline __complex__ _Float64 - __complex_atanh(__complex__ _Float64 __z) - { return __builtin_catanh(__z); } -#endif - -#if defined(__STDCPP_FLOAT128_T__) && defined(_GLIBCXX_LDOUBLE_IS_IEEE_BINARY128) - inline __complex__ _Float128 - __complex_acos(__complex__ _Float128 __z) - { return __builtin_cacosl(__z); } - - inline __complex__ _Float128 - __complex_asin(__complex__ _Float128 __z) - { return __builtin_casinl(__z); } - - inline __complex__ _Float128 - __complex_atan(__complex__ _Float128 __z) - { return __builtin_catanl(__z); } - - inline __complex__ _Float128 - __complex_acosh(__complex__ _Float128 __z) - { return __builtin_cacoshl(__z); } - - inline __complex__ _Float128 - __complex_asinh(__complex__ _Float128 __z) - { return __builtin_casinhl(__z); } - - inline __complex__ _Float128 - __complex_atanh(__complex__ _Float128 __z) - { return __builtin_catanhl(__z); } -#elif defined(__STDCPP_FLOAT128_T__) && defined(_GLIBCXX_HAVE_FLOAT128_MATH) - inline __complex__ _Float128 - __complex_acos(__complex__ _Float128 __z) - { return __builtin_cacosf128(__z); } - - inline __complex__ _Float128 - __complex_asin(__complex__ _Float128 __z) - { return __builtin_casinf128(__z); } - - inline __complex__ _Float128 - __complex_atan(__complex__ _Float128 __z) - { return __builtin_catanf128(__z); } - - inline __complex__ _Float128 - __complex_acosh(__complex__ _Float128 __z) - { return __builtin_cacoshf128(__z); } - - inline __complex__ _Float128 - __complex_asinh(__complex__ _Float128 __z) - { return __builtin_casinhf128(__z); } - - inline __complex__ _Float128 - __complex_atanh(__complex__ _Float128 __z) - { return __builtin_catanhf128(__z); } -#endif - -#if defined(__STDCPP_BFLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32) - inline __complex__ decltype(0.0bf16) - __complex_acos(__complex__ decltype(0.0bf16) __z) - { return static_cast<__complex__ decltype(0.0bf16)>(__builtin_cacosf(__z)); } - - inline __complex__ decltype(0.0bf16) - __complex_asin(__complex__ decltype(0.0bf16) __z) - { return static_cast<__complex__ decltype(0.0bf16)>(__builtin_casinf(__z)); } - - inline __complex__ decltype(0.0bf16) - __complex_atan(__complex__ decltype(0.0bf16) __z) - { return static_cast<__complex__ decltype(0.0bf16)>(__builtin_catanf(__z)); } - - inline __complex__ decltype(0.0bf16) - __complex_acosh(__complex__ decltype(0.0bf16) __z) - { return static_cast<__complex__ decltype(0.0bf16)>(__builtin_cacoshf(__z)); } - - inline __complex__ decltype(0.0bf16) - __complex_asinh(__complex__ decltype(0.0bf16) __z) - { return static_cast<__complex__ decltype(0.0bf16)>(__builtin_casinhf(__z)); } - - inline __complex__ decltype(0.0bf16) - __complex_atanh(__complex__ decltype(0.0bf16) __z) - { return static_cast<__complex__ decltype(0.0bf16)>(__builtin_catanhf(__z)); } -#endif -#endif - template inline _Tp /// fabs(__z) [8.1.8].