From patchwork Tue May 3 10:21:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Piotr Kubaj X-Patchwork-Id: 53415 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B2EAF385780F for ; Tue, 3 May 2022 10:22:26 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail.anongoth.pl (mail.anongoth.pl [46.248.190.61]) by sourceware.org (Postfix) with ESMTPS id 8F0E83858C51; Tue, 3 May 2022 10:21:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8F0E83858C51 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=FreeBSD.org Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=FreeBSD.org Received: from KGPE-D16.g.anongoth.pl (unknown [192.168.1.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: pkubaj@anongoth.pl) by mail.anongoth.pl (Postfix) with ESMTPSA id 5336A1890D1; Tue, 3 May 2022 12:21:51 +0200 (CEST) From: pkubaj@FreeBSD.org To: gcc-patches@gcc.gnu.org, fortran@gcc.gnu.org Subject: [PATCH V2] powerpc: properly check for feenableexcept() on FreeBSD Date: Tue, 3 May 2022 12:21:12 +0200 Message-Id: <20220503102111.10406-1-pkubaj@FreeBSD.org> X-Mailer: git-send-email 2.36.0 MIME-Version: 1.0 X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_SOFTFAIL, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: , Cc: Piotr Kubaj , segher@kernel.crashing.org Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" From: Piotr Kubaj FreeBSD/powerpc* has feenableexcept() defined in fenv.h header. Signed-off-by: Piotr Kubaj --- libgfortran/configure | 41 +++++++++++++++++++++++++++++++++++++++- libgfortran/configure.ac | 17 ++++++++++++++++- 2 files changed, 56 insertions(+), 2 deletions(-) diff --git a/libgfortran/configure b/libgfortran/configure index ae64dca3114..ad71694ef05 100755 --- a/libgfortran/configure +++ b/libgfortran/configure @@ -27338,8 +27338,45 @@ fi +case x$target in + xpowerpc*-freebsd*) + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for fenv.h and feenableexcept" >&5 +$as_echo_n "checking for fenv.h and feenableexcept... " >&6; } +if ${have_feenableexcept+:} false; then : + $as_echo_n "(cached) " >&6 +else + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + #include +int +main () +{ + feenableexcept(FE_DIVBYZERO | FE_INVALID); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + have_feenableexcept="yes" +else + have_feenableexcept="no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_feenableexcept" >&5 +$as_echo "$have_feenableexcept" >&6; } + if test "x$have_feenableexcept" = "xyes"; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_FEENABLEEXCEPT 1 +_ACEOF + + fi; + ;; + *) # Check for GNU libc feenableexcept -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for feenableexcept in -lm" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for feenableexcept in -lm" >&5 $as_echo_n "checking for feenableexcept in -lm... " >&6; } if ${ac_cv_lib_m_feenableexcept+:} false; then : $as_echo_n "(cached) " >&6 @@ -27384,6 +27421,8 @@ $as_echo "#define HAVE_FEENABLEEXCEPT 1" >>confdefs.h fi + ;; +esac # At least for glibc, clock_gettime is in librt. But don't # pull that in if it still doesn't give us the function we want. This diff --git a/libgfortran/configure.ac b/libgfortran/configure.ac index 97cc490cb5e..2dd6d345b22 100644 --- a/libgfortran/configure.ac +++ b/libgfortran/configure.ac @@ -602,8 +602,23 @@ fi # Check whether we have a __float128 type, depends on enable_libquadmath_support LIBGFOR_CHECK_FLOAT128 +case x$target in + xpowerpc*-freebsd*) + AC_CACHE_CHECK([for fenv.h and feenableexcept], have_feenableexcept, [ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM( + [[ #include ]], + [[ feenableexcept(FE_DIVBYZERO | FE_INVALID); ]])], + [ have_feenableexcept="yes" ], + [ have_feenableexcept="no" ])]) + if test "x$have_feenableexcept" = "xyes"; then + AC_DEFINE(HAVE_FEENABLEEXCEPT,1,[fenv.h includes feenableexcept]) + fi; + ;; + *) # Check for GNU libc feenableexcept -AC_CHECK_LIB([m],[feenableexcept],[have_feenableexcept=yes AC_DEFINE([HAVE_FEENABLEEXCEPT],[1],[libm includes feenableexcept])]) + AC_CHECK_LIB([m],[feenableexcept],[have_feenableexcept=yes AC_DEFINE([HAVE_FEENABLEEXCEPT],[1],[libm includes feenableexcept])]) + ;; +esac # At least for glibc, clock_gettime is in librt. But don't # pull that in if it still doesn't give us the function we want. This