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