From patchwork Tue May 16 09:11:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 94565 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp284608vqo; Tue, 16 May 2023 02:13:37 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6e4l2+RY/Sjf4HA9flaJk/Bs62H3BPfsTBKn4Cg6HUDlzxXxhrBLkjLJbBwM/gBhJfleeH X-Received: by 2002:a17:907:1c14:b0:95e:d74d:c4e6 with SMTP id nc20-20020a1709071c1400b0095ed74dc4e6mr44377104ejc.25.1684228416876; Tue, 16 May 2023 02:13:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684228416; cv=none; d=google.com; s=arc-20160816; b=ZhoVI91WcX/ez8AaX/cTV5c61uxYnMXLATSnuQTHuva2B8HV7d4wDEC1p/ZjcpZf7U ZCxBJ7FJnNn8gLyJp8YRaupeWWxV08NbHu0anUmsbYU130i2IvdBRbE+FvgyXT9gNEis pNni33T70ZWFfPo9DXmT5SQRVUq/plfZNE/5880/HDMwaBfG1ufjGEiTa/0dHzLOGqNE z2QoB9peV9e0IcN65ZMGluz32TCbj2ItySUTztGaSpZxmmiD1Pt8e9TCyAuEuLv+Djyy vPQEE3GF/I3UmEhl5RmjyLfPwURNDqw6ckWOveAjHqo+HmKJLrUvC/8Ymm4fNKR/14Wm Ocbw== 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-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=LXbU9XirQ8+0A/rfv2aXhCRjnj3T+2nRg8bduS9Hk1s=; b=T9piO0D2d8pNS78pe7pWB+cRE/95+Cqlf2fIhB01yuiHQISNTIGomDUe5Ugq3vMcVU y+18y0wj9oKPEOVSdsykwY5zlO9H3bKUjjX8AniNDEibdXaBNnbrO13eU11O+u8HA81M H/9fG8OL8tmNkT7j2OEr3r7m6xuFRmO42tDIXcZiAnUXt5KJsOY1WAWjtxJoB/S0u13h f0lc15BpoFWu78vcC4r/4npUYhTHGmQOkY3SWktYWZgevDTt148dgM4dNzOHnJDbPZQ8 vRhiABjdUWVi+rpSn0gOq/SU5YmdK5Q5OD5lobpna4yZaGNAMBxfL1bza/NxauR3d8r0 RaCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="eGlaCjD/"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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. [8.43.85.97]) by mx.google.com with ESMTPS id et21-20020a170907295500b0095389804380si11875804ejc.220.2023.05.16.02.13.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 May 2023 02:13:36 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="eGlaCjD/"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 A678938560B4 for ; Tue, 16 May 2023 09:12:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A678938560B4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1684228347; bh=LXbU9XirQ8+0A/rfv2aXhCRjnj3T+2nRg8bduS9Hk1s=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=eGlaCjD/UeaRF9tqXU8+RBNKmcX8x/R55lAKlwVokNkZRM3r3u4ON7gdY/SDSsm91 nMr071lhgdbeYKttHu8yrvN0IRDyYrXCzMQRQzkY9fPrMTzMxIE0+DbZob0JCRTmFt V6T7wTQTZbzZ0HTff806wmabtfigOB/ZcFbEFsXg= 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 8B415385770E for ; Tue, 16 May 2023 09:11:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8B415385770E 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-45-TovUKMJUNcKMXvSe9NAF2A-1; Tue, 16 May 2023 05:11:34 -0400 X-MC-Unique: TovUKMJUNcKMXvSe9NAF2A-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0080985A5B1; Tue, 16 May 2023 09:11:34 +0000 (UTC) Received: from localhost (unknown [10.42.28.178]) by smtp.corp.redhat.com (Postfix) with ESMTP id 97FD24021CD; Tue, 16 May 2023 09:11:33 +0000 (UTC) To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed 1/3] libstdc++: Stop using _GLIBCXX_USE_C99_COMPLEX_TR1 in Date: Tue, 16 May 2023 10:11:30 +0100 Message-Id: <20230516091132.1698684-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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: Jonathan Wakely via Gcc-patches From: Jonathan Wakely Reply-To: Jonathan Wakely 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?1766041496568475103?= X-GMAIL-MSGID: =?utf-8?q?1766041496568475103?= Tested powerpc64le-linux. Pushed to trunk. -- >8 -- The _GLIBCXX_USE_C99_COMPLEX_TR1 macro (and the comments about it in acinclude.m4 and config.h) are misleading when it is also used for , not only . It is also wrong, because the configure checks for TR1 use -std=c++98 and a target might define cacos etc. for C++11 but not for C++98. Add a separate configure check for the inverse trigonometric functions that are covered by _GLIBCXX_USE_C99_COMPLEX_TR1, but using -std=c++11 for the checks. Use the result of that separate check in . libstdc++-v3/ChangeLog: * acinclude.m4 (GLIBCXX_USE_C99): Check for complex inverse trig functions in C++11 mode and define _GLIBCXX_USE_C99_COMPLEX_ARC. * config.h.in: Regenerate. * configure: Regenerate. * doc/doxygen/user.cfg.in (PREDEFINED): Add new macro. * include/std/complex: Check _GLIBCXX_USE_C99_COMPLEX_ARC instead of _GLIBCXX_USE_C99_COMPLEX_TR1. --- libstdc++-v3/acinclude.m4 | 37 +++++++++++++++++++ libstdc++-v3/config.h.in | 5 +++ libstdc++-v3/configure | 53 ++++++++++++++++++++++++++++ libstdc++-v3/doc/doxygen/user.cfg.in | 1 + libstdc++-v3/include/std/complex | 14 ++++---- 5 files changed, 103 insertions(+), 7 deletions(-) diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4 index 0ce3b8b5b31..84b12adbc24 100644 --- a/libstdc++-v3/acinclude.m4 +++ b/libstdc++-v3/acinclude.m4 @@ -1200,6 +1200,43 @@ AC_DEFUN([GLIBCXX_ENABLE_C99], [ requires corresponding C99 library functions to be present.]) fi + # Check for the existence of complex inverse trigonometric + # math functions used by for C++11 and later. + ac_c99_complex_arc=no; + if test x"$ac_has_complex_h" = x"yes"; then + AC_MSG_CHECKING([for ISO C99 support for inverse trig functions in ]) + AC_TRY_COMPILE([#include ], + [typedef __complex__ float float_type; float_type tmpf; + cacosf(tmpf); + casinf(tmpf); + catanf(tmpf); + cacoshf(tmpf); + casinhf(tmpf); + catanhf(tmpf); + typedef __complex__ double double_type; double_type tmpd; + cacos(tmpd); + casin(tmpd); + catan(tmpd); + cacosh(tmpd); + casinh(tmpd); + catanh(tmpd); + typedef __complex__ long double ld_type; ld_type tmpld; + cacosl(tmpld); + casinl(tmpld); + catanl(tmpld); + cacoshl(tmpld); + casinhl(tmpld); + catanhl(tmpld); + ],[ac_c99_complex_arc=yes], [ac_c99_complex_arc=no]) + fi + AC_MSG_RESULT($ac_c99_complex_arc) + if test x"$ac_c99_complex_arc" = x"yes"; then + AC_DEFINE(_GLIBCXX_USE_C99_COMPLEX_ARC, 1, + [Define if C99 inverse trig functions in should be + used in . Using compiler builtins for these functions + requires corresponding C99 library functions to be present.]) + fi + # Check for the existence in of vscanf, et. al. AC_CACHE_CHECK([for ISO C99 support in for C++11], glibcxx_cv_c99_stdio_cxx11, [ diff --git a/libstdc++-v3/doc/doxygen/user.cfg.in b/libstdc++-v3/doc/doxygen/user.cfg.in index 14981c96f95..210e13400b9 100644 --- a/libstdc++-v3/doc/doxygen/user.cfg.in +++ b/libstdc++-v3/doc/doxygen/user.cfg.in @@ -2352,6 +2352,7 @@ PREDEFINED = __cplusplus=202002L \ _GLIBCXX_USE_NOEXCEPT=noexcept \ _GLIBCXX_USE_WCHAR_T \ _GLIBCXX_USE_LONG_LONG \ + _GLIBCXX_USE_C99_COMPLEX_ARC \ _GLIBCXX_USE_C99_STDINT_TR1 \ _GLIBCXX_USE_SCHED_YIELD \ _GLIBCXX_USE_NANOSLEEP \ diff --git a/libstdc++-v3/include/std/complex b/libstdc++-v3/include/std/complex index 0f5f14c3ddb..40fc062e53d 100644 --- a/libstdc++-v3/include/std/complex +++ b/libstdc++-v3/include/std/complex @@ -2021,7 +2021,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return std::complex<_Tp>(__pi_2 - __t.real(), -__t.imag()); } -#if _GLIBCXX_USE_C99_COMPLEX_TR1 +#if _GLIBCXX_USE_C99_COMPLEX_ARC #if defined(__STDCPP_FLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32) inline __complex__ _Float16 __complex_acos(__complex__ _Float16 __z) @@ -2177,7 +2177,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #endif #endif -#if _GLIBCXX_USE_C99_COMPLEX_TR1 +#if _GLIBCXX_USE_C99_COMPLEX_ARC inline __complex__ float __complex_acos(__complex__ float __z) { return __builtin_cacosf(__z); } @@ -2213,7 +2213,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return std::complex<_Tp>(__t.imag(), -__t.real()); } -#if _GLIBCXX_USE_C99_COMPLEX_TR1 +#if _GLIBCXX_USE_C99_COMPLEX_ARC inline __complex__ float __complex_asin(__complex__ float __z) { return __builtin_casinf(__z); } @@ -2257,7 +2257,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _Tp(0.25) * log(__num / __den)); } -#if _GLIBCXX_USE_C99_COMPLEX_TR1 +#if _GLIBCXX_USE_C99_COMPLEX_ARC inline __complex__ float __complex_atan(__complex__ float __z) { return __builtin_catanf(__z); } @@ -2293,7 +2293,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION + std::sqrt(_Tp(0.5) * (__z - _Tp(1.0)))); } -#if _GLIBCXX_USE_C99_COMPLEX_TR1 +#if _GLIBCXX_USE_C99_COMPLEX_ARC inline __complex__ float __complex_acosh(__complex__ float __z) { return __builtin_cacoshf(__z); } @@ -2332,7 +2332,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return std::log(__t + __z); } -#if _GLIBCXX_USE_C99_COMPLEX_TR1 +#if _GLIBCXX_USE_C99_COMPLEX_ARC inline __complex__ float __complex_asinh(__complex__ float __z) { return __builtin_casinhf(__z); } @@ -2376,7 +2376,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _Tp(0.5) * atan2(_Tp(2.0) * __z.imag(), __x)); } -#if _GLIBCXX_USE_C99_COMPLEX_TR1 +#if _GLIBCXX_USE_C99_COMPLEX_ARC inline __complex__ float __complex_atanh(__complex__ float __z) { return __builtin_catanhf(__z); }