public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/azanella/clang] x86_64: Provide __sfp_handle_exceptions if compiler does not
@ 2024-04-17 20:15 Adhemerval Zanella
0 siblings, 0 replies; 2+ messages in thread
From: Adhemerval Zanella @ 2024-04-17 20:15 UTC (permalink / raw)
To: glibc-cvs
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=534b6296b804d14fe1a5efbdb2de5c009391d837
commit 534b6296b804d14fe1a5efbdb2de5c009391d837
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Wed Feb 21 10:44:47 2024 -0300
x86_64: Provide __sfp_handle_exceptions if compiler does not
Diff:
---
config.h.in | 3 +++
sysdeps/x86/fpu/sfp-machine.h | 20 +++++++++++++++++++-
sysdeps/x86_64/configure | 31 +++++++++++++++++++++++++++++++
sysdeps/x86_64/configure.ac | 20 ++++++++++++++++++++
4 files changed, 73 insertions(+), 1 deletion(-)
diff --git a/config.h.in b/config.h.in
index 69ac450356..307ac789cf 100644
--- a/config.h.in
+++ b/config.h.in
@@ -294,4 +294,7 @@
/* Define if -mapxf is enabled by default on x86. */
#undef HAVE_X86_APX
+/* Define whether compiler runtime library provides __sfp_handle_exceptions. */
+#undef HAVE_X86_64_SFP_HANDLE_EXCEPTIONS
+
#endif
diff --git a/sysdeps/x86/fpu/sfp-machine.h b/sysdeps/x86/fpu/sfp-machine.h
index dd23c797bd..c2aa2b6901 100644
--- a/sysdeps/x86/fpu/sfp-machine.h
+++ b/sysdeps/x86/fpu/sfp-machine.h
@@ -217,8 +217,26 @@ typedef unsigned int UTItype __attribute__ ((mode (TI)));
(FP_EX_INVALID | FP_EX_DENORM | FP_EX_DIVZERO | FP_EX_OVERFLOW \
| FP_EX_UNDERFLOW | FP_EX_INEXACT)
+#ifdef HAVE_X86_64_SFP_HANDLE_EXCEPTIONS
void __sfp_handle_exceptions (int);
-
+#else
+#include <fenv.h>
+static inline void __sfp_handle_exceptions (int _fex)
+{
+ if (_fex & FP_EX_INVALID)
+ feraiseexcept (FE_INVALID);
+ if (_fex & FP_EX_DENORM)
+ feraiseexcept (__FE_DENORM);
+ if (_fex & FP_EX_DIVZERO)
+ feraiseexcept (FE_DIVBYZERO);
+ if (_fex & FP_EX_OVERFLOW)
+ feraiseexcept (FE_OVERFLOW);
+ if (_fex & FP_EX_UNDERFLOW)
+ feraiseexcept (FE_UNDERFLOW);
+ if (_fex & FP_EX_INEXACT)
+ feraiseexcept (FE_INEXACT);
+}
+#endif
#define FP_HANDLE_EXCEPTIONS \
do { \
if (__builtin_expect (_fex, 0)) \
diff --git a/sysdeps/x86_64/configure b/sysdeps/x86_64/configure
index e641e75d24..65cd4c9962 100755
--- a/sysdeps/x86_64/configure
+++ b/sysdeps/x86_64/configure
@@ -218,6 +218,37 @@ fi
config_vars="$config_vars
have-x86-apx = $libc_cv_x86_have_apx"
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether compiler standard library provides __sfp_handle_exceptions" >&5
+printf %s "checking whether compiler standard library provides __sfp_handle_exceptions... " >&6; }
+if test ${libc_cv_sfp_handle_exceptions+y}
+then :
+ printf %s "(cached) " >&6
+else $as_nop
+ cat > conftest.c <<EOF
+int _start (void) { return 0; }
+int __start (void) { return 0; }
+void __sfp_handle_exceptions (int);
+int main (void) { __sfp_handle_exceptions (0); return 0; }
+EOF
+ if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS $no_ssp -o conftest conftest.c -static -nostartfiles 1>&5'
+ { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; }; then
+ libc_cv_sfp_handle_exceptions=yes
+ else
+ libc_cv_sfp_handle_exceptions=no
+ fi
+ rm -rf conftest*
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_sfp_handle_exceptions" >&5
+printf "%s\n" "$libc_cv_sfp_handle_exceptions" >&6; }
+if test x"$libc_cv_sfp_handle_exceptions" == xyes; then
+ printf "%s\n" "#define HAVE_X86_64_SFP_HANDLE_EXCEPTIONS 1" >>confdefs.h
+
+fi
+
test -n "$critic_missing" && as_fn_error $? "
*** $critic_missing" "$LINENO" 5
diff --git a/sysdeps/x86_64/configure.ac b/sysdeps/x86_64/configure.ac
index 57caf63826..112d1542cd 100644
--- a/sysdeps/x86_64/configure.ac
+++ b/sysdeps/x86_64/configure.ac
@@ -103,5 +103,25 @@ if test $libc_cv_x86_have_apx = yes; then
fi
LIBC_CONFIG_VAR([have-x86-apx], [$libc_cv_x86_have_apx])
+dnl Check if compiler standard library provides __sfp_handle_exceptions, used on
+dnl float128 implementation.
+AC_CACHE_CHECK(whether compiler standard library provides __sfp_handle_exceptions,
+ libc_cv_sfp_handle_exceptions, [dnl
+cat > conftest.c <<EOF
+int _start (void) { return 0; }
+int __start (void) { return 0; }
+void __sfp_handle_exceptions (int);
+int main (void) { __sfp_handle_exceptions (0); return 0; }
+EOF
+ if AC_TRY_COMMAND(${CC-cc} $CFLAGS $CPPFLAGS $no_ssp -o conftest conftest.c -static -nostartfiles 1>&AS_MESSAGE_LOG_FD); then
+ libc_cv_sfp_handle_exceptions=yes
+ else
+ libc_cv_sfp_handle_exceptions=no
+ fi
+ rm -rf conftest*])
+if test x"$libc_cv_sfp_handle_exceptions" == xyes; then
+ AC_DEFINE(HAVE_X86_64_SFP_HANDLE_EXCEPTIONS)
+fi
+
test -n "$critic_missing" && AC_MSG_ERROR([
*** $critic_missing])
^ permalink raw reply [flat|nested] 2+ messages in thread
* [glibc/azanella/clang] x86_64: Provide __sfp_handle_exceptions if compiler does not
@ 2024-04-02 16:01 Adhemerval Zanella
0 siblings, 0 replies; 2+ messages in thread
From: Adhemerval Zanella @ 2024-04-02 16:01 UTC (permalink / raw)
To: glibc-cvs
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=a8ac0d97708e82dad8af9aed86d4a631487cc37f
commit a8ac0d97708e82dad8af9aed86d4a631487cc37f
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Wed Feb 21 10:44:47 2024 -0300
x86_64: Provide __sfp_handle_exceptions if compiler does not
Diff:
---
config.h.in | 3 +++
sysdeps/x86/fpu/sfp-machine.h | 20 +++++++++++++++++++-
sysdeps/x86_64/configure | 31 +++++++++++++++++++++++++++++++
sysdeps/x86_64/configure.ac | 20 ++++++++++++++++++++
4 files changed, 73 insertions(+), 1 deletion(-)
diff --git a/config.h.in b/config.h.in
index cf4212f5eb..98236e11ce 100644
--- a/config.h.in
+++ b/config.h.in
@@ -295,4 +295,7 @@
/* Define if -mmovbe is enabled by default on x86. */
#undef HAVE_X86_MOVBE
+/* Define whether compiler runtime library provides __sfp_handle_exceptions. */
+#undef HAVE_X86_64_SFP_HANDLE_EXCEPTIONS
+
#endif
diff --git a/sysdeps/x86/fpu/sfp-machine.h b/sysdeps/x86/fpu/sfp-machine.h
index dd23c797bd..c2aa2b6901 100644
--- a/sysdeps/x86/fpu/sfp-machine.h
+++ b/sysdeps/x86/fpu/sfp-machine.h
@@ -217,8 +217,26 @@ typedef unsigned int UTItype __attribute__ ((mode (TI)));
(FP_EX_INVALID | FP_EX_DENORM | FP_EX_DIVZERO | FP_EX_OVERFLOW \
| FP_EX_UNDERFLOW | FP_EX_INEXACT)
+#ifdef HAVE_X86_64_SFP_HANDLE_EXCEPTIONS
void __sfp_handle_exceptions (int);
-
+#else
+#include <fenv.h>
+static inline void __sfp_handle_exceptions (int _fex)
+{
+ if (_fex & FP_EX_INVALID)
+ feraiseexcept (FE_INVALID);
+ if (_fex & FP_EX_DENORM)
+ feraiseexcept (__FE_DENORM);
+ if (_fex & FP_EX_DIVZERO)
+ feraiseexcept (FE_DIVBYZERO);
+ if (_fex & FP_EX_OVERFLOW)
+ feraiseexcept (FE_OVERFLOW);
+ if (_fex & FP_EX_UNDERFLOW)
+ feraiseexcept (FE_UNDERFLOW);
+ if (_fex & FP_EX_INEXACT)
+ feraiseexcept (FE_INEXACT);
+}
+#endif
#define FP_HANDLE_EXCEPTIONS \
do { \
if (__builtin_expect (_fex, 0)) \
diff --git a/sysdeps/x86_64/configure b/sysdeps/x86_64/configure
index 48cc2989a8..5741a172df 100755
--- a/sysdeps/x86_64/configure
+++ b/sysdeps/x86_64/configure
@@ -186,6 +186,37 @@ printf "%s\n" "$libc_cv_x86_have_amx_tile" >&6; }
config_vars="$config_vars
have-mamx-tile = $libc_cv_x86_have_amx_tile"
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether compiler standard library provides __sfp_handle_exceptions" >&5
+printf %s "checking whether compiler standard library provides __sfp_handle_exceptions... " >&6; }
+if test ${libc_cv_sfp_handle_exceptions+y}
+then :
+ printf %s "(cached) " >&6
+else $as_nop
+ cat > conftest.c <<EOF
+int _start (void) { return 0; }
+int __start (void) { return 0; }
+void __sfp_handle_exceptions (int);
+int main (void) { __sfp_handle_exceptions (0); return 0; }
+EOF
+ if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS $no_ssp -o conftest conftest.c -static -nostartfiles 1>&5'
+ { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; }; then
+ libc_cv_sfp_handle_exceptions=yes
+ else
+ libc_cv_sfp_handle_exceptions=no
+ fi
+ rm -rf conftest*
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_sfp_handle_exceptions" >&5
+printf "%s\n" "$libc_cv_sfp_handle_exceptions" >&6; }
+if test x"$libc_cv_sfp_handle_exceptions" == xyes; then
+ printf "%s\n" "#define HAVE_X86_64_SFP_HANDLE_EXCEPTIONS 1" >>confdefs.h
+
+fi
+
test -n "$critic_missing" && as_fn_error $? "
*** $critic_missing" "$LINENO" 5
diff --git a/sysdeps/x86_64/configure.ac b/sysdeps/x86_64/configure.ac
index e4770a366e..e7821c3640 100644
--- a/sysdeps/x86_64/configure.ac
+++ b/sysdeps/x86_64/configure.ac
@@ -85,5 +85,25 @@ EOF
rm -rf conftest*])
LIBC_CONFIG_VAR([have-mamx-tile], [$libc_cv_x86_have_amx_tile])
+dnl Check if compiler standard library provides __sfp_handle_exceptions, used on
+dnl float128 implementation.
+AC_CACHE_CHECK(whether compiler standard library provides __sfp_handle_exceptions,
+ libc_cv_sfp_handle_exceptions, [dnl
+cat > conftest.c <<EOF
+int _start (void) { return 0; }
+int __start (void) { return 0; }
+void __sfp_handle_exceptions (int);
+int main (void) { __sfp_handle_exceptions (0); return 0; }
+EOF
+ if AC_TRY_COMMAND(${CC-cc} $CFLAGS $CPPFLAGS $no_ssp -o conftest conftest.c -static -nostartfiles 1>&AS_MESSAGE_LOG_FD); then
+ libc_cv_sfp_handle_exceptions=yes
+ else
+ libc_cv_sfp_handle_exceptions=no
+ fi
+ rm -rf conftest*])
+if test x"$libc_cv_sfp_handle_exceptions" == xyes; then
+ AC_DEFINE(HAVE_X86_64_SFP_HANDLE_EXCEPTIONS)
+fi
+
test -n "$critic_missing" && AC_MSG_ERROR([
*** $critic_missing])
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-04-17 20:15 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-17 20:15 [glibc/azanella/clang] x86_64: Provide __sfp_handle_exceptions if compiler does not Adhemerval Zanella
-- strict thread matches above, loose matches on Subject: below --
2024-04-02 16:01 Adhemerval Zanella
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).