diff mbox series

[1/4] Use libc_fe* macros in ldbl-128/s_nearbyintl.c.

Message ID 20200325100628.883397-1-stli@linux.ibm.com
State New
Headers show
Series [1/4] Use libc_fe* macros in ldbl-128/s_nearbyintl.c. | expand

Commit Message

Stefan Liebler March 25, 2020, 10:06 a.m. UTC
The calls to feholdexcept and fesetenv are replaced
by the libc_fe* macros as it is also done in nearbyintf
and nearbyint.
---
 sysdeps/ieee754/float128/float128_private.h | 10 ++++++++++
 sysdeps/ieee754/ldbl-128/s_nearbyintl.c     |  9 +++++----
 sysdeps/x86/fpu/fenv_private.h              |  4 ++++
 3 files changed, 19 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/sysdeps/ieee754/float128/float128_private.h b/sysdeps/ieee754/float128/float128_private.h
index f97463d9dc..af1ed8f3c0 100644
--- a/sysdeps/ieee754/float128/float128_private.h
+++ b/sysdeps/ieee754/float128/float128_private.h
@@ -66,6 +66,16 @@ 
 # define libc_feupdateenv_testl(ENV, EX) libc_feupdateenv_testf128 (ENV, EX)
 #endif
 
+#ifdef libc_feholdexceptf128
+# undef libc_feholdexceptl
+# define libc_feholdexceptl(ENV) libc_feholdexceptf128 (ENV)
+#endif
+
+#ifdef libc_fesetenvf128
+# undef libc_fesetenvl
+# define libc_fesetenvl(ENV) libc_fesetenvf128 (ENV)
+#endif
+
 /* misc macros from the header below.  */
 #include <fix-fp-int-convert-overflow.h>
 #undef FIX_LDBL_LONG_CONVERT_OVERFLOW
diff --git a/sysdeps/ieee754/ldbl-128/s_nearbyintl.c b/sysdeps/ieee754/ldbl-128/s_nearbyintl.c
index 8d26786f78..c0bc6fbd6d 100644
--- a/sysdeps/ieee754/ldbl-128/s_nearbyintl.c
+++ b/sysdeps/ieee754/ldbl-128/s_nearbyintl.c
@@ -27,6 +27,7 @@ 
 #include <math.h>
 #include <math-barriers.h>
 #include <math_private.h>
+#include <fenv_private.h>
 #include <libm-alias-ldouble.h>
 #include <math-use-builtins.h>
 
@@ -53,11 +54,11 @@  __nearbyintl (_Float128 x)
     {
       if (j0 < 0)
 	{
-	  feholdexcept (&env);
+	  libc_feholdexceptl (&env);
 	  w = TWO112[sx] + math_opt_barrier (x);
 	  t = w - TWO112[sx];
 	  math_force_eval (t);
-	  fesetenv (&env);
+	  libc_fesetenvl (&env);
 	  GET_LDOUBLE_MSW64 (i0, t);
 	  SET_LDOUBLE_MSW64 (t, (i0 & 0x7fffffffffffffffLL) | (sx << 63));
 	  return t;
@@ -70,11 +71,11 @@  __nearbyintl (_Float128 x)
       else
 	return x;		/* x is integral  */
     }
-  feholdexcept (&env);
+  libc_feholdexceptl (&env);
   w = TWO112[sx] + math_opt_barrier (x);
   t = w - TWO112[sx];
   math_force_eval (t);
-  fesetenv (&env);
+  libc_fesetenvl (&env);
   return t;
 #endif /* ! USE_NEARBYINTL_BUILTIN  */
 }
diff --git a/sysdeps/x86/fpu/fenv_private.h b/sysdeps/x86/fpu/fenv_private.h
index 4b081e015b..23a430362a 100644
--- a/sysdeps/x86/fpu/fenv_private.h
+++ b/sysdeps/x86/fpu/fenv_private.h
@@ -300,12 +300,16 @@  libc_feresetround_387 (fenv_t *e)
   SET_RESTORE_ROUND_GENERIC (RM, libc_feholdsetround_sse, libc_feresetround_sse)
 # define libc_feholdexcept_setroundf128	libc_feholdexcept_setround_sse
 # define libc_feupdateenv_testf128	libc_feupdateenv_test_sse
+# define libc_feholdexceptf128	libc_feholdexcept_sse
+# define libc_fesetenvf128	libc_fesetenv_sse
 #else
 /* The 387 rounding mode is used by soft-fp for 32-bit, but whether
    387 or SSE exceptions are used depends on whether libgcc was built
    for SSE math, which is not known when glibc is being built.  */
 # define libc_feholdexcept_setroundf128	default_libc_feholdexcept_setround
 # define libc_feupdateenv_testf128	default_libc_feupdateenv_test
+# define libc_feholdexceptf128	default_libc_feholdexcept
+# define libc_fesetenvf128	default_libc_fesetenv
 #endif
 
 /* We have support for rounding mode context.  */