]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
PowerPC floating point little-endian [8 of 15]
authorAnton Blanchard <anton@au1.ibm.com>
Sat, 17 Aug 2013 08:58:55 +0000 (18:28 +0930)
committerAlan Modra <amodra@gmail.com>
Fri, 4 Oct 2013 01:04:26 +0000 (10:34 +0930)
http://sourceware.org/ml/libc-alpha/2013-07/msg00199.html

Corrects floating-point environment code for little-endian.

* sysdeps/powerpc/fpu/fenv_libc.h (fenv_union_t): Replace int
array with long long.
* sysdeps/powerpc/fpu/e_sqrt.c (__slow_ieee754_sqrt): Adjust.
* sysdeps/powerpc/fpu/e_sqrtf.c (__slow_ieee754_sqrtf): Adjust.
* sysdeps/powerpc/fpu/fclrexcpt.c (__feclearexcept): Adjust.
* sysdeps/powerpc/fpu/fedisblxcpt.c (fedisableexcept): Adjust.
* sysdeps/powerpc/fpu/feenablxcpt.c (feenableexcept): Adjust.
* sysdeps/powerpc/fpu/fegetexcept.c (__fegetexcept): Adjust.
* sysdeps/powerpc/fpu/feholdexcpt.c (feholdexcept): Adjust.
* sysdeps/powerpc/fpu/fesetenv.c (__fesetenv): Adjust.
* sysdeps/powerpc/fpu/feupdateenv.c (__feupdateenv): Adjust.
* sysdeps/powerpc/fpu/fgetexcptflg.c (__fegetexceptflag): Adjust.
* sysdeps/powerpc/fpu/fraiseexcpt.c (__feraiseexcept): Adjust.
* sysdeps/powerpc/fpu/fsetexcptflg.c (__fesetexceptflag): Adjust.
* sysdeps/powerpc/fpu/ftestexcept.c (fetestexcept): Adjust.

15 files changed:
ChangeLog
sysdeps/powerpc/fpu/e_sqrt.c
sysdeps/powerpc/fpu/e_sqrtf.c
sysdeps/powerpc/fpu/fclrexcpt.c
sysdeps/powerpc/fpu/fedisblxcpt.c
sysdeps/powerpc/fpu/feenablxcpt.c
sysdeps/powerpc/fpu/fegetexcept.c
sysdeps/powerpc/fpu/feholdexcpt.c
sysdeps/powerpc/fpu/fenv_libc.h
sysdeps/powerpc/fpu/fesetenv.c
sysdeps/powerpc/fpu/feupdateenv.c
sysdeps/powerpc/fpu/fgetexcptflg.c
sysdeps/powerpc/fpu/fraiseexcpt.c
sysdeps/powerpc/fpu/fsetexcptflg.c
sysdeps/powerpc/fpu/ftestexcept.c

index f03095c54c56837b1cd200a30b80dd591fb929e2..2de7a41767e48e5f26b4ab019d38804cf91813d2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2013-10-04  Anton Blanchard <anton@au1.ibm.com>
+
+       * sysdeps/powerpc/fpu/fenv_libc.h (fenv_union_t): Replace int
+       array with long long.
+       * sysdeps/powerpc/fpu/e_sqrt.c (__slow_ieee754_sqrt): Adjust.
+       * sysdeps/powerpc/fpu/e_sqrtf.c (__slow_ieee754_sqrtf): Adjust.
+       * sysdeps/powerpc/fpu/fclrexcpt.c (__feclearexcept): Adjust.
+       * sysdeps/powerpc/fpu/fedisblxcpt.c (fedisableexcept): Adjust.
+       * sysdeps/powerpc/fpu/feenablxcpt.c (feenableexcept): Adjust.
+       * sysdeps/powerpc/fpu/fegetexcept.c (__fegetexcept): Adjust.
+       * sysdeps/powerpc/fpu/feholdexcpt.c (feholdexcept): Adjust.
+       * sysdeps/powerpc/fpu/fesetenv.c (__fesetenv): Adjust.
+       * sysdeps/powerpc/fpu/feupdateenv.c (__feupdateenv): Adjust.
+       * sysdeps/powerpc/fpu/fgetexcptflg.c (__fegetexceptflag): Adjust.
+       * sysdeps/powerpc/fpu/fraiseexcpt.c (__feraiseexcept): Adjust.
+       * sysdeps/powerpc/fpu/fsetexcptflg.c (__fesetexceptflag): Adjust.
+       * sysdeps/powerpc/fpu/ftestexcept.c (fetestexcept): Adjust.
+
 2013-10-04  Anton Blanchard <anton@au1.ibm.com>
 
        * sysdeps/powerpc/bits/mathinline.h (__signbitf): Use builtin.
index 3efe277f37573377ed8f197384f386508f805af3..2d50fb525e48044decf1e150ae5557e1bde38f2e 100644 (file)
@@ -145,7 +145,7 @@ __slow_ieee754_sqrt (double x)
       feraiseexcept (FE_INVALID_SQRT);
 
       fenv_union_t u = { .fenv = fegetenv_register () };
-      if ((u.l[1] & FE_INVALID) == 0)
+      if ((u.l & FE_INVALID) == 0)
 #endif
        feraiseexcept (FE_INVALID);
       x = a_nan.value;
index 6e50a3cd75efb4a281ff6b29e07dcd40b95fbcfe..91d2d37d7b182f69a48c26770f07469084f81cdd 100644 (file)
@@ -121,7 +121,7 @@ __slow_ieee754_sqrtf (float x)
       feraiseexcept (FE_INVALID_SQRT);
 
       fenv_union_t u = { .fenv = fegetenv_register () };
-      if ((u.l[1] & FE_INVALID) == 0)
+      if ((u.l & FE_INVALID) == 0)
 #endif
        feraiseexcept (FE_INVALID);
       x = a_nan.value;
index 86575dba67dd3d3f718d158d4d13beec9026594c..7f66e21ce2669886aba14806fcadc2c585ee7372 100644 (file)
@@ -28,8 +28,8 @@ __feclearexcept (int excepts)
   u.fenv = fegetenv_register ();
 
   /* Clear the relevant bits.  */
-  u.l[1] = u.l[1] & ~((-(excepts >> (31 - FPSCR_VX) & 1) & FE_ALL_INVALID)
-                     | (excepts & FPSCR_STICKY_BITS));
+  u.l = u.l & ~((-(excepts >> (31 - FPSCR_VX) & 1) & FE_ALL_INVALID)
+               | (excepts & FPSCR_STICKY_BITS));
 
   /* Put the new state in effect.  */
   fesetenv_register (u.fenv);
index 659566b67ef4ab49ae83725376ce0ae0c9c0714e..f2c45a60c65d4eabc17a537a265f2b40b155e3f9 100644 (file)
@@ -32,15 +32,15 @@ fedisableexcept (int excepts)
 
   fe.fenv = fegetenv_register ();
   if (excepts & FE_INEXACT)
-    fe.l[1] &= ~(1 << (31 - FPSCR_XE));
+    fe.l &= ~(1 << (31 - FPSCR_XE));
   if (excepts & FE_DIVBYZERO)
-    fe.l[1] &= ~(1 << (31 - FPSCR_ZE));
+    fe.l &= ~(1 << (31 - FPSCR_ZE));
   if (excepts & FE_UNDERFLOW)
-    fe.l[1] &= ~(1 << (31 - FPSCR_UE));
+    fe.l &= ~(1 << (31 - FPSCR_UE));
   if (excepts & FE_OVERFLOW)
-    fe.l[1] &= ~(1 << (31 - FPSCR_OE));
+    fe.l &= ~(1 << (31 - FPSCR_OE));
   if (excepts & FE_INVALID)
-    fe.l[1] &= ~(1 << (31 - FPSCR_VE));
+    fe.l &= ~(1 << (31 - FPSCR_VE));
   fesetenv_register (fe.fenv);
 
   new = __fegetexcept ();
index fc4bfffad5e761daa78afe43f025b68105429eb1..472796d15c7731e036bfd3f1d0125640216c76ab 100644 (file)
@@ -32,15 +32,15 @@ feenableexcept (int excepts)
 
   fe.fenv = fegetenv_register ();
   if (excepts & FE_INEXACT)
-    fe.l[1] |= (1 << (31 - FPSCR_XE));
+    fe.l |= (1 << (31 - FPSCR_XE));
   if (excepts & FE_DIVBYZERO)
-    fe.l[1] |= (1 << (31 - FPSCR_ZE));
+    fe.l |= (1 << (31 - FPSCR_ZE));
   if (excepts & FE_UNDERFLOW)
-    fe.l[1] |= (1 << (31 - FPSCR_UE));
+    fe.l |= (1 << (31 - FPSCR_UE));
   if (excepts & FE_OVERFLOW)
-    fe.l[1] |= (1 << (31 - FPSCR_OE));
+    fe.l |= (1 << (31 - FPSCR_OE));
   if (excepts & FE_INVALID)
-    fe.l[1] |= (1 << (31 - FPSCR_VE));
+    fe.l |= (1 << (31 - FPSCR_VE));
   fesetenv_register (fe.fenv);
 
   new = __fegetexcept ();
index f3d5724e91ed5c166dd23bfa776b3c52b67ecb4e..23d47a27e9c56f74df588b50c176b376283513e4 100644 (file)
@@ -27,15 +27,15 @@ __fegetexcept (void)
 
   fe.fenv = fegetenv_register ();
 
-  if (fe.l[1] & (1 << (31 - FPSCR_XE)))
+  if (fe.l & (1 << (31 - FPSCR_XE)))
       result |= FE_INEXACT;
-  if (fe.l[1] & (1 << (31 - FPSCR_ZE)))
+  if (fe.l & (1 << (31 - FPSCR_ZE)))
       result |= FE_DIVBYZERO;
-  if (fe.l[1] & (1 << (31 - FPSCR_UE)))
+  if (fe.l & (1 << (31 - FPSCR_UE)))
       result |= FE_UNDERFLOW;
-  if (fe.l[1] & (1 << (31 - FPSCR_OE)))
+  if (fe.l & (1 << (31 - FPSCR_OE)))
       result |= FE_OVERFLOW;
-  if (fe.l[1] & (1 << (31 - FPSCR_VE)))
+  if (fe.l & (1 << (31 - FPSCR_VE)))
       result |= FE_INVALID;
 
   return result;
index 013d2bfbb4b68f2e5ebe7a8cfb979f17b8673e7e..0ecf0f7bc5e5d77800236c4b1e6e43fb8e9ffce2 100644 (file)
@@ -30,13 +30,12 @@ feholdexcept (fenv_t *envp)
 
   /* Clear everything except for the rounding modes and non-IEEE arithmetic
      flag.  */
-  new.l[1] = old.l[1] & 7;
-  new.l[0] = old.l[0];
+  new.l = old.l & 0xffffffff00000007LL;
 
   /* If the old env had any enabled exceptions, then mask SIGFPE in the
      MSR FE0/FE1 bits.  This may allow the FPU to run faster because it
      always takes the default action and can not generate SIGFPE. */
-  if ((old.l[1] & _FPU_MASK_ALL) != 0)
+  if ((old.l & _FPU_MASK_ALL) != 0)
     (void)__fe_mask_env ();
 
   /* Put the new state in effect.  */
index 191095156873e6bd025dd64cf676e067e080c27e..baa2a7d39a458e8f1da6c007057588d1bbb052f3 100644 (file)
@@ -69,7 +69,7 @@ libm_hidden_proto (__fe_nomask_env)
 typedef union
 {
   fenv_t fenv;
-  unsigned int l[2];
+  unsigned long long l;
 } fenv_union_t;
 
 
index e92adb4c58004ec11144b78ebcdfbfc3da853a6c..6c00b267ae6f6446c5a61c06bbcc919096c3361b 100644 (file)
@@ -34,14 +34,14 @@ __fesetenv (const fenv_t *envp)
      exceptions, then unmask SIGFPE in the MSR FE0/FE1 bits.  This will put the
      hardware into "precise mode" and may cause the FPU to run slower on some
      hardware.  */
-  if ((old.l[1] & _FPU_MASK_ALL) == 0 && (new.l[1] & _FPU_MASK_ALL) != 0)
+  if ((old.l & _FPU_MASK_ALL) == 0 && (new.l & _FPU_MASK_ALL) != 0)
     (void)__fe_nomask_env ();
 
   /* If the old env had any enabled exceptions and the new env has no enabled
      exceptions, then mask SIGFPE in the MSR FE0/FE1 bits.  This may allow the
      FPU to run faster because it always takes the default action and can not
      generate SIGFPE. */
-  if ((old.l[1] & _FPU_MASK_ALL) != 0 && (new.l[1] & _FPU_MASK_ALL) == 0)
+  if ((old.l & _FPU_MASK_ALL) != 0 && (new.l & _FPU_MASK_ALL) == 0)
     (void)__fe_mask_env ();
 
   fesetenv_register (*envp);
index 6500ea1737d03ab2dc93e933195a5f4b23ccf15d..677504416f34a4aaf8e6b3eddf4a3b2622f65457 100644 (file)
@@ -34,20 +34,20 @@ __feupdateenv (const fenv_t *envp)
   /* Restore rounding mode and exception enable from *envp and merge
      exceptions.  Leave fraction rounded/inexact and FP result/CC bits
      unchanged.  */
-  new.l[1] = (old.l[1] & 0x1FFFFF00) | (new.l[1] & 0x1FF80FFF);
+  new.l = (old.l & 0xffffffff1fffff00LL) | (new.l & 0x1ff80fff);
 
   /* If the old env has no enabled exceptions and the new env has any enabled
      exceptions, then unmask SIGFPE in the MSR FE0/FE1 bits.  This will put
      the hardware into "precise mode" and may cause the FPU to run slower on
      some hardware.  */
-  if ((old.l[1] & _FPU_MASK_ALL) == 0 && (new.l[1] & _FPU_MASK_ALL) != 0)
+  if ((old.l & _FPU_MASK_ALL) == 0 && (new.l & _FPU_MASK_ALL) != 0)
     (void)__fe_nomask_env ();
 
   /* If the old env had any enabled exceptions and the new env has no enabled
      exceptions, then mask SIGFPE in the MSR FE0/FE1 bits.  This may allow the
      FPU to run faster because it always takes the default action and can not
      generate SIGFPE. */
-  if ((old.l[1] & _FPU_MASK_ALL) != 0 && (new.l[1] & _FPU_MASK_ALL) == 0)
+  if ((old.l & _FPU_MASK_ALL) != 0 && (new.l & _FPU_MASK_ALL) == 0)
     (void)__fe_mask_env ();
 
   /* Atomically enable and raise (if appropriate) exceptions set in `new'. */
index f6327ce170c879193e634762c8981b94a48243f5..1395bede0cc3c8dbd66a2d9535f24665218a2eb8 100644 (file)
@@ -27,7 +27,7 @@ __fegetexceptflag (fexcept_t *flagp, int excepts)
   u.fenv = fegetenv_register ();
 
   /* Return (all of) it.  */
-  *flagp = u.l[1] & excepts & FE_ALL_EXCEPT;
+  *flagp = u.l & excepts & FE_ALL_EXCEPT;
 
   /* Success.  */
   return 0;
index 9118c1954a89e3b342f2f4941dbbd8a047074dbf..6193071bd47cb5524535a3039b58b56634b35fa5 100644 (file)
@@ -33,11 +33,11 @@ __feraiseexcept (int excepts)
   u.fenv = fegetenv_register ();
 
   /* Add the exceptions */
-  u.l[1] = (u.l[1]
-           | (excepts & FPSCR_STICKY_BITS)
-           /* Turn FE_INVALID into FE_INVALID_SOFTWARE.  */
-           | (excepts >> ((31 - FPSCR_VX) - (31 - FPSCR_VXSOFT))
-              & FE_INVALID_SOFTWARE));
+  u.l = (u.l
+        | (excepts & FPSCR_STICKY_BITS)
+        /* Turn FE_INVALID into FE_INVALID_SOFTWARE.  */
+        | (excepts >> ((31 - FPSCR_VX) - (31 - FPSCR_VXSOFT))
+           & FE_INVALID_SOFTWARE));
 
   /* Store the new status word (along with the rest of the environment),
      triggering any appropriate exceptions.  */
@@ -49,7 +49,7 @@ __feraiseexcept (int excepts)
         don't have FE_INVALID_SOFTWARE implemented.  Detect this
         case and raise FE_INVALID_SNAN instead.  */
       u.fenv = fegetenv_register ();
-      if ((u.l[1] & FE_INVALID) == 0)
+      if ((u.l & FE_INVALID) == 0)
        set_fpscr_bit (FPSCR_VXSNAN);
     }
 
index c050d4022b7a0d3355db0dd40381c6f3fee54356..0d309c8d5f7635820f2b99702a1c7ac0e2d6f5d0 100644 (file)
@@ -31,10 +31,10 @@ __fesetexceptflag (const fexcept_t *flagp, int excepts)
   flag = *flagp & excepts;
 
   /* Replace the exception status */
-  u.l[1] = ((u.l[1] & ~(FPSCR_STICKY_BITS & excepts))
-           | (flag & FPSCR_STICKY_BITS)
-           | (flag >> ((31 - FPSCR_VX) - (31 - FPSCR_VXSOFT))
-              & FE_INVALID_SOFTWARE));
+  u.l = ((u.l & ~(FPSCR_STICKY_BITS & excepts))
+        | (flag & FPSCR_STICKY_BITS)
+        | (flag >> ((31 - FPSCR_VX) - (31 - FPSCR_VXSOFT))
+           & FE_INVALID_SOFTWARE));
 
   /* Store the new status word (along with the rest of the environment).
      This may cause floating-point exceptions if the restored state
index 0dbc3befb8e664cf2f2707787d765e045ea11bbb..86eea0fb0801106fd84e611f31d5f8c3af65ec2c 100644 (file)
@@ -28,6 +28,6 @@ fetestexcept (int excepts)
 
   /* The FE_INVALID bit is dealt with correctly by the hardware, so we can
      just:  */
-  return u.l[1] & excepts;
+  return u.l & excepts;
 }
 libm_hidden_def (fetestexcept)