public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
From: pkubaj@FreeBSD.org
To: gcc-patches@gcc.gnu.org, fortran@gcc.gnu.org
Cc: segher@kernel.crashing.org, Piotr Kubaj <pkubaj@FreeBSD.org>
Subject: [PATCH V2] powerpc: properly check for feenableexcept() on FreeBSD
Date: Tue,  3 May 2022 12:21:12 +0200	[thread overview]
Message-ID: <20220503102111.10406-1-pkubaj@FreeBSD.org> (raw)

From: Piotr Kubaj <pkubaj@FreeBSD.org>

FreeBSD/powerpc* has feenableexcept() defined in fenv.h header.

Signed-off-by: Piotr Kubaj <pkubaj@FreeBSD.org>
---
 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 <fenv.h>
+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 <fenv.h>  ]],
+        [[ 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
-- 
2.36.0


             reply	other threads:[~2022-05-03 10:21 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-03 10:21 pkubaj [this message]
2022-05-03 10:33 ` Piotr Kubaj
2022-05-10 23:32   ` Piotr Kubaj
2022-05-12  7:20     ` Kewen.Lin
2022-05-12 20:16 ` Segher Boessenkool
2022-05-13  2:59   ` Kewen.Lin
2022-05-13 10:34     ` Piotr Kubaj
2022-05-13 12:53       ` Segher Boessenkool
2022-05-14  5:46     ` Piotr Kubaj

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220503102111.10406-1-pkubaj@FreeBSD.org \
    --to=pkubaj@freebsd.org \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=segher@kernel.crashing.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).