|
|
7c0489 |
commit e3d85df50b083c9ba68a40f5d45b201cbec4e68b
|
|
|
7c0489 |
Author: Paul A. Clarke <pc@us.ibm.com>
|
|
|
7c0489 |
Date: Thu Sep 19 09:13:14 2019 -0500
|
|
|
7c0489 |
|
|
|
7c0489 |
[powerpc] fenv_private.h clean up
|
|
|
7c0489 |
|
|
|
7c0489 |
fenv_private.h includes unused functions, magic macro constants, and
|
|
|
7c0489 |
some replicated common code fragments.
|
|
|
7c0489 |
|
|
|
7c0489 |
Remove unused functions, replace magic constants with constants from
|
|
|
7c0489 |
fenv_libc.h, and refactor replicated code.
|
|
|
7c0489 |
|
|
|
7c0489 |
Suggested-by: Paul E. Murphy <murphyp@linux.ibm.com>
|
|
|
7c0489 |
Reviewed-By: Paul E Murphy <murphyp@linux.ibm.com>
|
|
|
7c0489 |
|
|
|
7c0489 |
diff --git a/sysdeps/powerpc/fpu/fedisblxcpt.c b/sysdeps/powerpc/fpu/fedisblxcpt.c
|
|
|
7c0489 |
index 2a776c72fb5a2b70..bdf55ac62f1ffe4f 100644
|
|
|
7c0489 |
--- a/sysdeps/powerpc/fpu/fedisblxcpt.c
|
|
|
7c0489 |
+++ b/sysdeps/powerpc/fpu/fedisblxcpt.c
|
|
|
7c0489 |
@@ -43,8 +43,7 @@ fedisableexcept (int excepts)
|
|
|
7c0489 |
if (fe.l != curr.l)
|
|
|
7c0489 |
fesetenv_mode (fe.fenv);
|
|
|
7c0489 |
|
|
|
7c0489 |
- if (new == 0 && result != 0)
|
|
|
7c0489 |
- (void)__fe_mask_env ();
|
|
|
7c0489 |
+ __TEST_AND_ENTER_NON_STOP (-1ULL, fe.l);
|
|
|
7c0489 |
|
|
|
7c0489 |
return result;
|
|
|
7c0489 |
}
|
|
|
7c0489 |
diff --git a/sysdeps/powerpc/fpu/feenablxcpt.c b/sysdeps/powerpc/fpu/feenablxcpt.c
|
|
|
7c0489 |
index 6f5a828e80965bfa..78ebabed9232c0ad 100644
|
|
|
7c0489 |
--- a/sysdeps/powerpc/fpu/feenablxcpt.c
|
|
|
7c0489 |
+++ b/sysdeps/powerpc/fpu/feenablxcpt.c
|
|
|
7c0489 |
@@ -43,8 +43,7 @@ feenableexcept (int excepts)
|
|
|
7c0489 |
if (fe.l != curr.l)
|
|
|
7c0489 |
fesetenv_mode (fe.fenv);
|
|
|
7c0489 |
|
|
|
7c0489 |
- if (new != 0 && result == 0)
|
|
|
7c0489 |
- (void) __fe_nomask_env_priv ();
|
|
|
7c0489 |
+ __TEST_AND_EXIT_NON_STOP (0ULL, fe.l);
|
|
|
7c0489 |
|
|
|
7c0489 |
return result;
|
|
|
7c0489 |
}
|
|
|
7c0489 |
diff --git a/sysdeps/powerpc/fpu/feholdexcpt.c b/sysdeps/powerpc/fpu/feholdexcpt.c
|
|
|
7c0489 |
index 8ec3fbff82b22f51..9636ecaa0b600b0d 100644
|
|
|
7c0489 |
--- a/sysdeps/powerpc/fpu/feholdexcpt.c
|
|
|
7c0489 |
+++ b/sysdeps/powerpc/fpu/feholdexcpt.c
|
|
|
7c0489 |
@@ -18,7 +18,6 @@
|
|
|
7c0489 |
|
|
|
7c0489 |
#include <fenv_libc.h>
|
|
|
7c0489 |
#include <fpu_control.h>
|
|
|
7c0489 |
-#define _FPU_MASK_ALL (_FPU_MASK_ZM | _FPU_MASK_OM | _FPU_MASK_UM | _FPU_MASK_XM | _FPU_MASK_IM)
|
|
|
7c0489 |
|
|
|
7c0489 |
int
|
|
|
7c0489 |
__feholdexcept (fenv_t *envp)
|
|
|
7c0489 |
@@ -35,11 +34,7 @@ __feholdexcept (fenv_t *envp)
|
|
|
7c0489 |
if (new.l == old.l)
|
|
|
7c0489 |
return 0;
|
|
|
7c0489 |
|
|
|
7c0489 |
- /* If the old env had any enabled exceptions, then mask SIGFPE in the
|
|
|
7c0489 |
- MSR FE0/FE1 bits. This may allow the FPU to run faster because it
|
|
|
7c0489 |
- always takes the default action and can not generate SIGFPE. */
|
|
|
7c0489 |
- if ((old.l & _FPU_MASK_ALL) != 0)
|
|
|
7c0489 |
- (void)__fe_mask_env ();
|
|
|
7c0489 |
+ __TEST_AND_ENTER_NON_STOP (old.l, 0ULL);
|
|
|
7c0489 |
|
|
|
7c0489 |
/* Put the new state in effect. */
|
|
|
7c0489 |
fesetenv_register (new.fenv);
|
|
|
7c0489 |
diff --git a/sysdeps/powerpc/fpu/fenv_libc.h b/sysdeps/powerpc/fpu/fenv_libc.h
|
|
|
7c0489 |
index b10b6a141ded4bfd..36b639c3939586f6 100644
|
|
|
7c0489 |
--- a/sysdeps/powerpc/fpu/fenv_libc.h
|
|
|
7c0489 |
+++ b/sysdeps/powerpc/fpu/fenv_libc.h
|
|
|
7c0489 |
@@ -27,6 +27,26 @@ extern const fenv_t *__fe_nomask_env_priv (void);
|
|
|
7c0489 |
|
|
|
7c0489 |
extern const fenv_t *__fe_mask_env (void) attribute_hidden;
|
|
|
7c0489 |
|
|
|
7c0489 |
+/* If the old env had any enabled exceptions and the new env has no enabled
|
|
|
7c0489 |
+ exceptions, then mask SIGFPE in the MSR FE0/FE1 bits. This may allow the
|
|
|
7c0489 |
+ FPU to run faster because it always takes the default action and can not
|
|
|
7c0489 |
+ generate SIGFPE. */
|
|
|
7c0489 |
+#define __TEST_AND_ENTER_NON_STOP(old, new) \
|
|
|
7c0489 |
+ do { \
|
|
|
7c0489 |
+ if (((old) & FPSCR_ENABLES_MASK) != 0 && ((new) & FPSCR_ENABLES_MASK) == 0) \
|
|
|
7c0489 |
+ (void) __fe_mask_env (); \
|
|
|
7c0489 |
+ } while (0)
|
|
|
7c0489 |
+
|
|
|
7c0489 |
+/* If the old env has no enabled exceptions and the new env has any enabled
|
|
|
7c0489 |
+ exceptions, then unmask SIGFPE in the MSR FE0/FE1 bits. This will put the
|
|
|
7c0489 |
+ hardware into "precise mode" and may cause the FPU to run slower on some
|
|
|
7c0489 |
+ hardware. */
|
|
|
7c0489 |
+#define __TEST_AND_EXIT_NON_STOP(old, new) \
|
|
|
7c0489 |
+ do { \
|
|
|
7c0489 |
+ if (((old) & FPSCR_ENABLES_MASK) == 0 && ((new) & FPSCR_ENABLES_MASK) != 0) \
|
|
|
7c0489 |
+ (void) __fe_nomask_env_priv (); \
|
|
|
7c0489 |
+ } while (0)
|
|
|
7c0489 |
+
|
|
|
7c0489 |
/* The sticky bits in the FPSCR indicating exceptions have occurred. */
|
|
|
7c0489 |
#define FPSCR_STICKY_BITS ((FE_ALL_EXCEPT | FE_ALL_INVALID) & ~FE_INVALID)
|
|
|
7c0489 |
|
|
|
7c0489 |
diff --git a/sysdeps/powerpc/fpu/fenv_private.h b/sysdeps/powerpc/fpu/fenv_private.h
|
|
|
7c0489 |
index 30df92c9a4700dee..c236d45db2f399a4 100644
|
|
|
7c0489 |
--- a/sysdeps/powerpc/fpu/fenv_private.h
|
|
|
7c0489 |
+++ b/sysdeps/powerpc/fpu/fenv_private.h
|
|
|
7c0489 |
@@ -23,73 +23,20 @@
|
|
|
7c0489 |
#include <fenv_libc.h>
|
|
|
7c0489 |
#include <fpu_control.h>
|
|
|
7c0489 |
|
|
|
7c0489 |
-/* Mask for the exception enable bits. */
|
|
|
7c0489 |
-#define _FPU_ALL_TRAPS (_FPU_MASK_ZM | _FPU_MASK_OM | _FPU_MASK_UM \
|
|
|
7c0489 |
- | _FPU_MASK_XM | _FPU_MASK_IM)
|
|
|
7c0489 |
-
|
|
|
7c0489 |
-/* Mask the rounding mode bits. */
|
|
|
7c0489 |
-#define _FPU_MASK_RN 0xfffffffffffffffcLL
|
|
|
7c0489 |
-
|
|
|
7c0489 |
-/* Mask everything but the rounding modes and non-IEEE arithmetic flags. */
|
|
|
7c0489 |
-#define _FPU_MASK_NOT_RN_NI 0xffffffff00000807LL
|
|
|
7c0489 |
-
|
|
|
7c0489 |
-/* Mask restore rounding mode and exception enabled. */
|
|
|
7c0489 |
-#define _FPU_MASK_TRAPS_RN 0xffffffffffffff00LL
|
|
|
7c0489 |
-
|
|
|
7c0489 |
-/* Mask FP result flags, preserve fraction rounded/inexact bits. */
|
|
|
7c0489 |
-#define _FPU_MASK_FRAC_INEX_RET_CC 0xfffffffffff80fffLL
|
|
|
7c0489 |
-
|
|
|
7c0489 |
static __always_inline void
|
|
|
7c0489 |
-__libc_feholdbits_ppc (fenv_t *envp, unsigned long long mask,
|
|
|
7c0489 |
- unsigned long long bits)
|
|
|
7c0489 |
+libc_feholdexcept_setround_ppc (fenv_t *envp, int r)
|
|
|
7c0489 |
{
|
|
|
7c0489 |
fenv_union_t old, new;
|
|
|
7c0489 |
|
|
|
7c0489 |
old.fenv = *envp = fegetenv_register ();
|
|
|
7c0489 |
|
|
|
7c0489 |
- new.l = (old.l & mask) | bits;
|
|
|
7c0489 |
-
|
|
|
7c0489 |
- /* If the old env had any enabled exceptions, then mask SIGFPE in the
|
|
|
7c0489 |
- MSR FE0/FE1 bits. This may allow the FPU to run faster because it
|
|
|
7c0489 |
- always takes the default action and can not generate SIGFPE. */
|
|
|
7c0489 |
- if ((old.l & _FPU_ALL_TRAPS) != 0)
|
|
|
7c0489 |
- (void) __fe_mask_env ();
|
|
|
7c0489 |
+ __TEST_AND_ENTER_NON_STOP (old.l, 0ULL);
|
|
|
7c0489 |
|
|
|
7c0489 |
+ /* Clear everything and set the rounding mode. */
|
|
|
7c0489 |
+ new.l = r;
|
|
|
7c0489 |
fesetenv_register (new.fenv);
|
|
|
7c0489 |
}
|
|
|
7c0489 |
|
|
|
7c0489 |
-static __always_inline void
|
|
|
7c0489 |
-libc_feholdexcept_ppc (fenv_t *envp)
|
|
|
7c0489 |
-{
|
|
|
7c0489 |
- __libc_feholdbits_ppc (envp, _FPU_MASK_NOT_RN_NI, 0LL);
|
|
|
7c0489 |
-}
|
|
|
7c0489 |
-
|
|
|
7c0489 |
-static __always_inline void
|
|
|
7c0489 |
-libc_feholdexcept_setround_ppc (fenv_t *envp, int r)
|
|
|
7c0489 |
-{
|
|
|
7c0489 |
- __libc_feholdbits_ppc (envp, _FPU_MASK_NOT_RN_NI & _FPU_MASK_RN, r);
|
|
|
7c0489 |
-}
|
|
|
7c0489 |
-
|
|
|
7c0489 |
-static __always_inline void
|
|
|
7c0489 |
-libc_fesetround_ppc (int r)
|
|
|
7c0489 |
-{
|
|
|
7c0489 |
- __fesetround_inline (r);
|
|
|
7c0489 |
-}
|
|
|
7c0489 |
-
|
|
|
7c0489 |
-static __always_inline int
|
|
|
7c0489 |
-libc_fetestexcept_ppc (int e)
|
|
|
7c0489 |
-{
|
|
|
7c0489 |
- fenv_union_t u;
|
|
|
7c0489 |
- u.fenv = fegetenv_register ();
|
|
|
7c0489 |
- return u.l & e;
|
|
|
7c0489 |
-}
|
|
|
7c0489 |
-
|
|
|
7c0489 |
-static __always_inline void
|
|
|
7c0489 |
-libc_feholdsetround_ppc (fenv_t *e, int r)
|
|
|
7c0489 |
-{
|
|
|
7c0489 |
- __libc_feholdbits_ppc (e, _FPU_MASK_TRAPS_RN, r);
|
|
|
7c0489 |
-}
|
|
|
7c0489 |
-
|
|
|
7c0489 |
static __always_inline unsigned long long
|
|
|
7c0489 |
__libc_femergeenv_ppc (const fenv_t *envp, unsigned long long old_mask,
|
|
|
7c0489 |
unsigned long long new_mask)
|
|
|
7c0489 |
@@ -102,19 +49,8 @@ __libc_femergeenv_ppc (const fenv_t *envp, unsigned long long old_mask,
|
|
|
7c0489 |
/* Merge bits while masking unwanted bits from new and old env. */
|
|
|
7c0489 |
new.l = (old.l & old_mask) | (new.l & new_mask);
|
|
|
7c0489 |
|
|
|
7c0489 |
- /* If the old env has no enabled exceptions and the new env has any enabled
|
|
|
7c0489 |
- exceptions, then unmask SIGFPE in the MSR FE0/FE1 bits. This will put the
|
|
|
7c0489 |
- hardware into "precise mode" and may cause the FPU to run slower on some
|
|
|
7c0489 |
- hardware. */
|
|
|
7c0489 |
- if ((old.l & _FPU_ALL_TRAPS) == 0 && (new.l & _FPU_ALL_TRAPS) != 0)
|
|
|
7c0489 |
- (void) __fe_nomask_env_priv ();
|
|
|
7c0489 |
-
|
|
|
7c0489 |
- /* If the old env had any enabled exceptions and the new env has no enabled
|
|
|
7c0489 |
- exceptions, then mask SIGFPE in the MSR FE0/FE1 bits. This may allow the
|
|
|
7c0489 |
- FPU to run faster because it always takes the default action and can not
|
|
|
7c0489 |
- generate SIGFPE. */
|
|
|
7c0489 |
- if ((old.l & _FPU_ALL_TRAPS) != 0 && (new.l & _FPU_ALL_TRAPS) == 0)
|
|
|
7c0489 |
- (void) __fe_mask_env ();
|
|
|
7c0489 |
+ __TEST_AND_EXIT_NON_STOP (old.l, new.l);
|
|
|
7c0489 |
+ __TEST_AND_ENTER_NON_STOP (old.l, new.l);
|
|
|
7c0489 |
|
|
|
7c0489 |
/* Atomically enable and raise (if appropriate) exceptions set in `new'. */
|
|
|
7c0489 |
fesetenv_register (new.fenv);
|
|
|
7c0489 |
@@ -139,8 +75,8 @@ libc_feresetround_ppc (fenv_t *envp)
|
|
|
7c0489 |
static __always_inline int
|
|
|
7c0489 |
libc_feupdateenv_test_ppc (fenv_t *envp, int ex)
|
|
|
7c0489 |
{
|
|
|
7c0489 |
- return __libc_femergeenv_ppc (envp, _FPU_MASK_TRAPS_RN,
|
|
|
7c0489 |
- _FPU_MASK_FRAC_INEX_RET_CC) & ex;
|
|
|
7c0489 |
+ return __libc_femergeenv_ppc (envp, ~FPSCR_CONTROL_MASK,
|
|
|
7c0489 |
+ ~FPSCR_STATUS_MASK) & ex;
|
|
|
7c0489 |
}
|
|
|
7c0489 |
|
|
|
7c0489 |
static __always_inline void
|
|
|
7c0489 |
@@ -193,8 +129,7 @@ libc_feholdsetround_noex_ppc_ctx (struct rm_ctx *ctx, int r)
|
|
|
7c0489 |
ctx->env = old.fenv;
|
|
|
7c0489 |
if (__glibc_unlikely (new.l != old.l))
|
|
|
7c0489 |
{
|
|
|
7c0489 |
- if ((old.l & _FPU_ALL_TRAPS) != 0)
|
|
|
7c0489 |
- (void) __fe_mask_env ();
|
|
|
7c0489 |
+ __TEST_AND_ENTER_NON_STOP (old.l, 0ULL);
|
|
|
7c0489 |
fesetenv_register (new.fenv);
|
|
|
7c0489 |
ctx->updated_status = true;
|
|
|
7c0489 |
}
|
|
|
7c0489 |
diff --git a/sysdeps/powerpc/fpu/fesetenv.c b/sysdeps/powerpc/fpu/fesetenv.c
|
|
|
7c0489 |
index ac927c8f3ada40b4..4eab5045c48105e3 100644
|
|
|
7c0489 |
--- a/sysdeps/powerpc/fpu/fesetenv.c
|
|
|
7c0489 |
+++ b/sysdeps/powerpc/fpu/fesetenv.c
|
|
|
7c0489 |
@@ -28,19 +28,8 @@ __fesetenv (const fenv_t *envp)
|
|
|
7c0489 |
new.fenv = *envp;
|
|
|
7c0489 |
old.fenv = fegetenv_status ();
|
|
|
7c0489 |
|
|
|
7c0489 |
- /* If the old env has no enabled exceptions and the new env has any enabled
|
|
|
7c0489 |
- exceptions, then unmask SIGFPE in the MSR FE0/FE1 bits. This will put the
|
|
|
7c0489 |
- hardware into "precise mode" and may cause the FPU to run slower on some
|
|
|
7c0489 |
- hardware. */
|
|
|
7c0489 |
- if ((old.l & FPSCR_ENABLES_MASK) == 0 && (new.l & FPSCR_ENABLES_MASK) != 0)
|
|
|
7c0489 |
- (void) __fe_nomask_env_priv ();
|
|
|
7c0489 |
-
|
|
|
7c0489 |
- /* If the old env had any enabled exceptions and the new env has no enabled
|
|
|
7c0489 |
- exceptions, then mask SIGFPE in the MSR FE0/FE1 bits. This may allow the
|
|
|
7c0489 |
- FPU to run faster because it always takes the default action and can not
|
|
|
7c0489 |
- generate SIGFPE. */
|
|
|
7c0489 |
- if ((old.l & FPSCR_ENABLES_MASK) != 0 && (new.l & FPSCR_ENABLES_MASK) == 0)
|
|
|
7c0489 |
- (void)__fe_mask_env ();
|
|
|
7c0489 |
+ __TEST_AND_EXIT_NON_STOP (old.l, new.l);
|
|
|
7c0489 |
+ __TEST_AND_ENTER_NON_STOP (old.l, new.l);
|
|
|
7c0489 |
|
|
|
7c0489 |
fesetenv_register (new.fenv);
|
|
|
7c0489 |
|
|
|
7c0489 |
diff --git a/sysdeps/powerpc/fpu/fesetmode.c b/sysdeps/powerpc/fpu/fesetmode.c
|
|
|
7c0489 |
index 29e088d5ab1c0d93..58ba02c0a1e64c27 100644
|
|
|
7c0489 |
--- a/sysdeps/powerpc/fpu/fesetmode.c
|
|
|
7c0489 |
+++ b/sysdeps/powerpc/fpu/fesetmode.c
|
|
|
7c0489 |
@@ -33,11 +33,8 @@ fesetmode (const femode_t *modep)
|
|
|
7c0489 |
if (old.l == new.l)
|
|
|
7c0489 |
return 0;
|
|
|
7c0489 |
|
|
|
7c0489 |
- if ((old.l & FPSCR_ENABLES_MASK) == 0 && (new.l & FPSCR_ENABLES_MASK) != 0)
|
|
|
7c0489 |
- (void) __fe_nomask_env_priv ();
|
|
|
7c0489 |
-
|
|
|
7c0489 |
- if ((old.l & FPSCR_ENABLES_MASK) != 0 && (new.l & FPSCR_ENABLES_MASK) == 0)
|
|
|
7c0489 |
- (void) __fe_mask_env ();
|
|
|
7c0489 |
+ __TEST_AND_EXIT_NON_STOP (old.l, new.l);
|
|
|
7c0489 |
+ __TEST_AND_ENTER_NON_STOP (old.l, new.l);
|
|
|
7c0489 |
|
|
|
7c0489 |
fesetenv_mode (new.fenv);
|
|
|
7c0489 |
return 0;
|
|
|
7c0489 |
diff --git a/sysdeps/powerpc/fpu/feupdateenv.c b/sysdeps/powerpc/fpu/feupdateenv.c
|
|
|
7c0489 |
index 2dbd1c4e9ec65ed0..fdd15651e0101f9e 100644
|
|
|
7c0489 |
--- a/sysdeps/powerpc/fpu/feupdateenv.c
|
|
|
7c0489 |
+++ b/sysdeps/powerpc/fpu/feupdateenv.c
|
|
|
7c0489 |
@@ -20,8 +20,6 @@
|
|
|
7c0489 |
#include <fenv_libc.h>
|
|
|
7c0489 |
#include <fpu_control.h>
|
|
|
7c0489 |
|
|
|
7c0489 |
-#define _FPU_MASK_ALL (_FPU_MASK_ZM | _FPU_MASK_OM | _FPU_MASK_UM | _FPU_MASK_XM | _FPU_MASK_IM)
|
|
|
7c0489 |
-
|
|
|
7c0489 |
int
|
|
|
7c0489 |
__feupdateenv (const fenv_t *envp)
|
|
|
7c0489 |
{
|
|
|
7c0489 |
@@ -36,19 +34,8 @@ __feupdateenv (const fenv_t *envp)
|
|
|
7c0489 |
unchanged. */
|
|
|
7c0489 |
new.l = (old.l & 0xffffffff1fffff00LL) | (new.l & 0x1ff80fff);
|
|
|
7c0489 |
|
|
|
7c0489 |
- /* If the old env has no enabled exceptions and the new env has any enabled
|
|
|
7c0489 |
- exceptions, then unmask SIGFPE in the MSR FE0/FE1 bits. This will put
|
|
|
7c0489 |
- the hardware into "precise mode" and may cause the FPU to run slower on
|
|
|
7c0489 |
- some hardware. */
|
|
|
7c0489 |
- if ((old.l & _FPU_MASK_ALL) == 0 && (new.l & _FPU_MASK_ALL) != 0)
|
|
|
7c0489 |
- (void) __fe_nomask_env_priv ();
|
|
|
7c0489 |
-
|
|
|
7c0489 |
- /* If the old env had any enabled exceptions and the new env has no enabled
|
|
|
7c0489 |
- exceptions, then mask SIGFPE in the MSR FE0/FE1 bits. This may allow the
|
|
|
7c0489 |
- FPU to run faster because it always takes the default action and can not
|
|
|
7c0489 |
- generate SIGFPE. */
|
|
|
7c0489 |
- if ((old.l & _FPU_MASK_ALL) != 0 && (new.l & _FPU_MASK_ALL) == 0)
|
|
|
7c0489 |
- (void)__fe_mask_env ();
|
|
|
7c0489 |
+ __TEST_AND_EXIT_NON_STOP (old.l, new.l);
|
|
|
7c0489 |
+ __TEST_AND_ENTER_NON_STOP (old.l, new.l);
|
|
|
7c0489 |
|
|
|
7c0489 |
/* Atomically enable and raise (if appropriate) exceptions set in `new'. */
|
|
|
7c0489 |
fesetenv_register (new.fenv);
|