From patchwork Wed May 31 20:20:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 1788527 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=RkISGzMc; dkim-atps=neutral Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QWgfC51NNz20PW for ; Thu, 1 Jun 2023 06:21:55 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A93C63857727 for ; Wed, 31 May 2023 20:21:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A93C63857727 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1685564513; bh=PNK2FMT9ljf1bQVyIpMEqIEdJ3glOD5UIyHR0svn/uk=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=RkISGzMcXkQs7LajEHDW+OdN9UH6J1d9n2zuHmeuCrhiwse7L4UC8652XlLvF6Lj5 2Gv8SekEK+Pv/bCJ3d1FIURrnYWOxllxVAJai9jZ4uHm9wp9JN23rVIdKiPs63ELuY U++zCjuvgVTfvEdSL0OG9hMmnq2k3gqs8aL//dK0= 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 EA9F13854178 for ; Wed, 31 May 2023 20:20:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EA9F13854178 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-504-bytszj9MNyS4moSLDqSH_g-1; Wed, 31 May 2023 16:20:56 -0400 X-MC-Unique: bytszj9MNyS4moSLDqSH_g-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0967B3C0F664; Wed, 31 May 2023 20:20:56 +0000 (UTC) Received: from localhost (unknown [10.42.28.9]) by smtp.corp.redhat.com (Postfix) with ESMTP id BDEAA407DEC0; Wed, 31 May 2023 20:20:55 +0000 (UTC) To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Add separate autoconf macro for std::float_t and std::double_t [PR109818] Date: Wed, 31 May 2023 21:20:54 +0100 Message-Id: <20230531202054.20950-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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: Jonathan Wakely via Gcc-patches From: Jonathan Wakely Reply-To: Jonathan Wakely Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Tested x86_64-linux. Pushed to trunk. -- >8 -- This should make it possible to use openlibm with djgpp (and other targets with missing C99 functions). The from openlibm provides all the functions, but not the float_t and double_t typedefs. By separating the autoconf checks for the functionsand the typedefs, we don't disable support for all the functions just because those typedefs are not present. libstdc++-v3/ChangeLog: PR libstdc++/109818 * acinclude.m4 (GLIBCXX_ENABLE_C99): Add separate check for float_t and double_t and define HAVE_C99_FLT_EVAL_TYPES. * config.h.in: Regenerate. * configure: Regenerate. * include/c_global/cmath (float_t, double_t): Guard using new _GLIBCXX_HAVE_C99_FLT_EVAL_TYPES macro. --- libstdc++-v3/acinclude.m4 | 21 ++++++++++++--- libstdc++-v3/config.h.in | 4 +++ libstdc++-v3/configure | 41 ++++++++++++++++++++++++++--- libstdc++-v3/include/c_global/cmath | 2 ++ 4 files changed, 62 insertions(+), 6 deletions(-) diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4 index 66194071b20..6ae141b8c20 100644 --- a/libstdc++-v3/acinclude.m4 +++ b/libstdc++-v3/acinclude.m4 @@ -1273,13 +1273,28 @@ AC_DEFUN([GLIBCXX_ENABLE_C99], [ in in namespace std for C++11.]) fi - # Check for the existence of functions. - AC_CACHE_CHECK([for ISO C99 function support for C++11 in ], - glibcxx_cv_c99_math_funcs, [ + # Check for the existence of typedefs. + AC_CACHE_CHECK([for ISO C99 float types for C++11 in ], + glibcxx_cv_c99_flt_eval_types, [ AC_TRY_COMPILE([#include ], [// Types typedef double_t my_double_t; typedef float_t my_float_t; + ], + [glibcxx_cv_c99_flt_eval_types=yes], + [glibcxx_cv_c99_flt_eval_types=no]) + ]) + if test x"$glibcxx_cv_c99_flt_eval_types" = x"yes"; then + AC_DEFINE(HAVE_C99_FLT_EVAL_TYPES, 1, + [Define if C99 float_t and double_t in should be + imported in in namespace std for C++11.]) + fi + + # Check for the existence of functions. + AC_CACHE_CHECK([for ISO C99 function support for C++11 in ], + glibcxx_cv_c99_math_funcs, [ + AC_TRY_COMPILE([#include ], + [ // Hyperbolic acosh(0.0); acoshf(0.0f); diff --git a/libstdc++-v3/config.h.in b/libstdc++-v3/config.h.in index 4fbf5ef86b9..5a95853cbbe 100644 --- a/libstdc++-v3/config.h.in +++ b/libstdc++-v3/config.h.in @@ -42,6 +42,10 @@ /* Define to 1 if you have the `at_quick_exit' function. */ #undef HAVE_AT_QUICK_EXIT +/* Define if C99 float_t and double_t in should be imported in + in namespace std for C++11. */ +#undef HAVE_C99_FLT_EVAL_TYPES + /* Define to 1 if the target assembler supports thread-local storage. */ #undef HAVE_CC_TLS diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure index ba328a64be2..70d169cf64b 100755 --- a/libstdc++-v3/configure +++ b/libstdc++-v3/configure @@ -18275,6 +18275,43 @@ $as_echo "#define _GLIBCXX11_USE_C99_MATH 1" >>confdefs.h fi + # Check for the existence of typedefs. + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ISO C99 float types for C++11 in " >&5 +$as_echo_n "checking for ISO C99 float types for C++11 in ... " >&6; } +if ${glibcxx_cv_c99_flt_eval_types+:} false; then : + $as_echo_n "(cached) " >&6 +else + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +// Types + typedef double_t my_double_t; + typedef float_t my_float_t; + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + glibcxx_cv_c99_flt_eval_types=yes +else + glibcxx_cv_c99_flt_eval_types=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $glibcxx_cv_c99_flt_eval_types" >&5 +$as_echo "$glibcxx_cv_c99_flt_eval_types" >&6; } + if test x"$glibcxx_cv_c99_flt_eval_types" = x"yes"; then + +$as_echo "#define HAVE_C99_FLT_EVAL_TYPES 1" >>confdefs.h + + fi + # Check for the existence of functions. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ISO C99 function support for C++11 in " >&5 $as_echo_n "checking for ISO C99 function support for C++11 in ... " >&6; } @@ -18288,9 +18325,7 @@ else int main () { -// Types - typedef double_t my_double_t; - typedef float_t my_float_t; + // Hyperbolic acosh(0.0); acoshf(0.0f); diff --git a/libstdc++-v3/include/c_global/cmath b/libstdc++-v3/include/c_global/cmath index c80ee7c8d72..b0ba395eb5c 100644 --- a/libstdc++-v3/include/c_global/cmath +++ b/libstdc++-v3/include/c_global/cmath @@ -1877,9 +1877,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #undef truncf #undef truncl +#ifdef _GLIBCXX_HAVE_C99_FLT_EVAL_TYPES // types using ::double_t; using ::float_t; +#endif // functions using ::acosh;