ce426f
# commit 4a28b3ca4bc52d9a3ac0d9edb53d3de510e1b77c
ce426f
# Author: Anton Blanchard <anton@au1.ibm.com>
ce426f
# Date:   Sat Aug 17 18:28:55 2013 +0930
ce426f
# 
ce426f
#     PowerPC floating point little-endian [8 of 15]
ce426f
#     http://sourceware.org/ml/libc-alpha/2013-07/msg00199.html
ce426f
#     
ce426f
#     Corrects floating-point environment code for little-endian.
ce426f
#     
ce426f
#         * sysdeps/powerpc/fpu/fenv_libc.h (fenv_union_t): Replace int
ce426f
#         array with long long.
ce426f
#         * sysdeps/powerpc/fpu/e_sqrt.c (__slow_ieee754_sqrt): Adjust.
ce426f
#         * sysdeps/powerpc/fpu/e_sqrtf.c (__slow_ieee754_sqrtf): Adjust.
ce426f
#         * sysdeps/powerpc/fpu/fclrexcpt.c (__feclearexcept): Adjust.
ce426f
#         * sysdeps/powerpc/fpu/fedisblxcpt.c (fedisableexcept): Adjust.
ce426f
#         * sysdeps/powerpc/fpu/feenablxcpt.c (feenableexcept): Adjust.
ce426f
#         * sysdeps/powerpc/fpu/fegetexcept.c (__fegetexcept): Adjust.
ce426f
#         * sysdeps/powerpc/fpu/feholdexcpt.c (feholdexcept): Adjust.
ce426f
#         * sysdeps/powerpc/fpu/fesetenv.c (__fesetenv): Adjust.
ce426f
#         * sysdeps/powerpc/fpu/feupdateenv.c (__feupdateenv): Adjust.
ce426f
#         * sysdeps/powerpc/fpu/fgetexcptflg.c (__fegetexceptflag): Adjust.
ce426f
#         * sysdeps/powerpc/fpu/fraiseexcpt.c (__feraiseexcept): Adjust.
ce426f
#         * sysdeps/powerpc/fpu/fsetexcptflg.c (__fesetexceptflag): Adjust.
ce426f
#         * sysdeps/powerpc/fpu/ftestexcept.c (fetestexcept): Adjust.
ce426f
# 
ce426f
diff -urN glibc-2.17-c758a686/sysdeps/powerpc/fpu/e_sqrt.c glibc-2.17-c758a686/sysdeps/powerpc/fpu/e_sqrt.c
ce426f
--- glibc-2.17-c758a686/sysdeps/powerpc/fpu/e_sqrt.c	2014-05-27 22:31:42.000000000 -0500
ce426f
+++ glibc-2.17-c758a686/sysdeps/powerpc/fpu/e_sqrt.c	2014-05-27 22:31:43.000000000 -0500
ce426f
@@ -145,7 +145,7 @@
ce426f
       feraiseexcept (FE_INVALID_SQRT);
ce426f
 
ce426f
       fenv_union_t u = { .fenv = fegetenv_register () };
ce426f
-      if ((u.l[1] & FE_INVALID) == 0)
ce426f
+      if ((u.l & FE_INVALID) == 0)
ce426f
 #endif
ce426f
 	feraiseexcept (FE_INVALID);
ce426f
       x = a_nan.value;
ce426f
diff -urN glibc-2.17-c758a686/sysdeps/powerpc/fpu/e_sqrtf.c glibc-2.17-c758a686/sysdeps/powerpc/fpu/e_sqrtf.c
ce426f
--- glibc-2.17-c758a686/sysdeps/powerpc/fpu/e_sqrtf.c	2014-05-27 22:31:42.000000000 -0500
ce426f
+++ glibc-2.17-c758a686/sysdeps/powerpc/fpu/e_sqrtf.c	2014-05-27 22:31:43.000000000 -0500
ce426f
@@ -121,7 +121,7 @@
ce426f
       feraiseexcept (FE_INVALID_SQRT);
ce426f
 
ce426f
       fenv_union_t u = { .fenv = fegetenv_register () };
ce426f
-      if ((u.l[1] & FE_INVALID) == 0)
ce426f
+      if ((u.l & FE_INVALID) == 0)
ce426f
 #endif
ce426f
 	feraiseexcept (FE_INVALID);
ce426f
       x = a_nan.value;
ce426f
diff -urN glibc-2.17-c758a686/sysdeps/powerpc/fpu/fclrexcpt.c glibc-2.17-c758a686/sysdeps/powerpc/fpu/fclrexcpt.c
ce426f
--- glibc-2.17-c758a686/sysdeps/powerpc/fpu/fclrexcpt.c	2014-05-27 22:31:42.000000000 -0500
ce426f
+++ glibc-2.17-c758a686/sysdeps/powerpc/fpu/fclrexcpt.c	2014-05-27 22:31:43.000000000 -0500
ce426f
@@ -28,8 +28,8 @@
ce426f
   u.fenv = fegetenv_register ();
ce426f
 
ce426f
   /* Clear the relevant bits.  */
ce426f
-  u.l[1] = u.l[1] & ~((-(excepts >> (31 - FPSCR_VX) & 1) & FE_ALL_INVALID)
ce426f
-		      | (excepts & FPSCR_STICKY_BITS));
ce426f
+  u.l = u.l & ~((-(excepts >> (31 - FPSCR_VX) & 1) & FE_ALL_INVALID)
ce426f
+		| (excepts & FPSCR_STICKY_BITS));
ce426f
 
ce426f
   /* Put the new state in effect.  */
ce426f
   fesetenv_register (u.fenv);
ce426f
diff -urN glibc-2.17-c758a686/sysdeps/powerpc/fpu/fedisblxcpt.c glibc-2.17-c758a686/sysdeps/powerpc/fpu/fedisblxcpt.c
ce426f
--- glibc-2.17-c758a686/sysdeps/powerpc/fpu/fedisblxcpt.c	2014-05-27 22:31:42.000000000 -0500
ce426f
+++ glibc-2.17-c758a686/sysdeps/powerpc/fpu/fedisblxcpt.c	2014-05-27 22:31:43.000000000 -0500
ce426f
@@ -32,15 +32,15 @@
ce426f
 
ce426f
   fe.fenv = fegetenv_register ();
ce426f
   if (excepts & FE_INEXACT)
ce426f
-    fe.l[1] &= ~(1 << (31 - FPSCR_XE));
ce426f
+    fe.l &= ~(1 << (31 - FPSCR_XE));
ce426f
   if (excepts & FE_DIVBYZERO)
ce426f
-    fe.l[1] &= ~(1 << (31 - FPSCR_ZE));
ce426f
+    fe.l &= ~(1 << (31 - FPSCR_ZE));
ce426f
   if (excepts & FE_UNDERFLOW)
ce426f
-    fe.l[1] &= ~(1 << (31 - FPSCR_UE));
ce426f
+    fe.l &= ~(1 << (31 - FPSCR_UE));
ce426f
   if (excepts & FE_OVERFLOW)
ce426f
-    fe.l[1] &= ~(1 << (31 - FPSCR_OE));
ce426f
+    fe.l &= ~(1 << (31 - FPSCR_OE));
ce426f
   if (excepts & FE_INVALID)
ce426f
-    fe.l[1] &= ~(1 << (31 - FPSCR_VE));
ce426f
+    fe.l &= ~(1 << (31 - FPSCR_VE));
ce426f
   fesetenv_register (fe.fenv);
ce426f
 
ce426f
   new = __fegetexcept ();
ce426f
diff -urN glibc-2.17-c758a686/sysdeps/powerpc/fpu/feenablxcpt.c glibc-2.17-c758a686/sysdeps/powerpc/fpu/feenablxcpt.c
ce426f
--- glibc-2.17-c758a686/sysdeps/powerpc/fpu/feenablxcpt.c	2014-05-27 22:31:42.000000000 -0500
ce426f
+++ glibc-2.17-c758a686/sysdeps/powerpc/fpu/feenablxcpt.c	2014-05-27 22:31:43.000000000 -0500
ce426f
@@ -32,15 +32,15 @@
ce426f
 
ce426f
   fe.fenv = fegetenv_register ();
ce426f
   if (excepts & FE_INEXACT)
ce426f
-    fe.l[1] |= (1 << (31 - FPSCR_XE));
ce426f
+    fe.l |= (1 << (31 - FPSCR_XE));
ce426f
   if (excepts & FE_DIVBYZERO)
ce426f
-    fe.l[1] |= (1 << (31 - FPSCR_ZE));
ce426f
+    fe.l |= (1 << (31 - FPSCR_ZE));
ce426f
   if (excepts & FE_UNDERFLOW)
ce426f
-    fe.l[1] |= (1 << (31 - FPSCR_UE));
ce426f
+    fe.l |= (1 << (31 - FPSCR_UE));
ce426f
   if (excepts & FE_OVERFLOW)
ce426f
-    fe.l[1] |= (1 << (31 - FPSCR_OE));
ce426f
+    fe.l |= (1 << (31 - FPSCR_OE));
ce426f
   if (excepts & FE_INVALID)
ce426f
-    fe.l[1] |= (1 << (31 - FPSCR_VE));
ce426f
+    fe.l |= (1 << (31 - FPSCR_VE));
ce426f
   fesetenv_register (fe.fenv);
ce426f
 
ce426f
   new = __fegetexcept ();
ce426f
diff -urN glibc-2.17-c758a686/sysdeps/powerpc/fpu/fegetexcept.c glibc-2.17-c758a686/sysdeps/powerpc/fpu/fegetexcept.c
ce426f
--- glibc-2.17-c758a686/sysdeps/powerpc/fpu/fegetexcept.c	2014-05-27 22:31:42.000000000 -0500
ce426f
+++ glibc-2.17-c758a686/sysdeps/powerpc/fpu/fegetexcept.c	2014-05-27 22:31:43.000000000 -0500
ce426f
@@ -27,15 +27,15 @@
ce426f
 
ce426f
   fe.fenv = fegetenv_register ();
ce426f
 
ce426f
-  if (fe.l[1] & (1 << (31 - FPSCR_XE)))
ce426f
+  if (fe.l & (1 << (31 - FPSCR_XE)))
ce426f
       result |= FE_INEXACT;
ce426f
-  if (fe.l[1] & (1 << (31 - FPSCR_ZE)))
ce426f
+  if (fe.l & (1 << (31 - FPSCR_ZE)))
ce426f
       result |= FE_DIVBYZERO;
ce426f
-  if (fe.l[1] & (1 << (31 - FPSCR_UE)))
ce426f
+  if (fe.l & (1 << (31 - FPSCR_UE)))
ce426f
       result |= FE_UNDERFLOW;
ce426f
-  if (fe.l[1] & (1 << (31 - FPSCR_OE)))
ce426f
+  if (fe.l & (1 << (31 - FPSCR_OE)))
ce426f
       result |= FE_OVERFLOW;
ce426f
-  if (fe.l[1] & (1 << (31 - FPSCR_VE)))
ce426f
+  if (fe.l & (1 << (31 - FPSCR_VE)))
ce426f
       result |= FE_INVALID;
ce426f
 
ce426f
   return result;
ce426f
diff -urN glibc-2.17-c758a686/sysdeps/powerpc/fpu/feholdexcpt.c glibc-2.17-c758a686/sysdeps/powerpc/fpu/feholdexcpt.c
ce426f
--- glibc-2.17-c758a686/sysdeps/powerpc/fpu/feholdexcpt.c	2014-05-27 22:31:42.000000000 -0500
ce426f
+++ glibc-2.17-c758a686/sysdeps/powerpc/fpu/feholdexcpt.c	2014-05-27 22:33:09.000000000 -0500
ce426f
@@ -30,13 +30,12 @@
ce426f
 
ce426f
   /* Clear everything except for the rounding modes and non-IEEE arithmetic
ce426f
      flag.  */
ce426f
-  new.l[1] = old.l[1] & 7;
ce426f
-  new.l[0] = old.l[0];
ce426f
+  new.l = old.l & 0xffffffff00000007LL;
ce426f
   
ce426f
   /* If the old env had any eabled exceptions, then mask SIGFPE in the
ce426f
      MSR FE0/FE1 bits.  This may allow the FPU to run faster because it
ce426f
      always takes the default action and can not generate SIGFPE. */
ce426f
-  if ((old.l[1] & _FPU_MASK_ALL) != 0)
ce426f
+  if ((old.l & _FPU_MASK_ALL) != 0)
ce426f
     (void)__fe_mask_env ();
ce426f
 
ce426f
   /* Put the new state in effect.  */
ce426f
diff -urN glibc-2.17-c758a686/sysdeps/powerpc/fpu/fenv_libc.h glibc-2.17-c758a686/sysdeps/powerpc/fpu/fenv_libc.h
ce426f
--- glibc-2.17-c758a686/sysdeps/powerpc/fpu/fenv_libc.h	2014-05-27 22:31:42.000000000 -0500
ce426f
+++ glibc-2.17-c758a686/sysdeps/powerpc/fpu/fenv_libc.h	2014-05-27 22:31:43.000000000 -0500
ce426f
@@ -69,7 +69,7 @@
ce426f
 typedef union
ce426f
 {
ce426f
   fenv_t fenv;
ce426f
-  unsigned int l[2];
ce426f
+  unsigned long long l;
ce426f
 } fenv_union_t;
ce426f
 
ce426f
 
ce426f
diff -urN glibc-2.17-c758a686/sysdeps/powerpc/fpu/fesetenv.c glibc-2.17-c758a686/sysdeps/powerpc/fpu/fesetenv.c
ce426f
--- glibc-2.17-c758a686/sysdeps/powerpc/fpu/fesetenv.c	2014-05-27 22:31:42.000000000 -0500
ce426f
+++ glibc-2.17-c758a686/sysdeps/powerpc/fpu/fesetenv.c	2014-05-27 22:35:18.000000000 -0500
ce426f
@@ -36,14 +36,14 @@
ce426f
      exceptions, then unmask SIGFPE in the MSR FE0/FE1 bits.  This will put the
ce426f
      hardware into "precise mode" and may cause the FPU to run slower on some
ce426f
      hardware.  */
ce426f
-  if ((old.l[1] & _FPU_MASK_ALL) == 0 && (new.l[1] & _FPU_MASK_ALL) != 0)
ce426f
+  if ((old.l & _FPU_MASK_ALL) == 0 && (new.l & _FPU_MASK_ALL) != 0)
ce426f
     (void)__fe_nomask_env ();
ce426f
   
ce426f
   /* If the old env had any enabled exceptions and the new env has no enabled
ce426f
      exceptions, then mask SIGFPE in the MSR FE0/FE1 bits.  This may allow the
ce426f
      FPU to run faster because it always takes the default action and can not 
ce426f
      generate SIGFPE. */
ce426f
-  if ((old.l[1] & _FPU_MASK_ALL) != 0 && (new.l[1] & _FPU_MASK_ALL) == 0)
ce426f
+  if ((old.l & _FPU_MASK_ALL) != 0 && (new.l & _FPU_MASK_ALL) == 0)
ce426f
     (void)__fe_mask_env ();
ce426f
     
ce426f
   fesetenv_register (*envp);
ce426f
diff -urN glibc-2.17-c758a686/sysdeps/powerpc/fpu/feupdateenv.c glibc-2.17-c758a686/sysdeps/powerpc/fpu/feupdateenv.c
ce426f
--- glibc-2.17-c758a686/sysdeps/powerpc/fpu/feupdateenv.c	2014-05-27 22:31:42.000000000 -0500
ce426f
+++ glibc-2.17-c758a686/sysdeps/powerpc/fpu/feupdateenv.c	2014-05-27 22:34:23.000000000 -0500
ce426f
@@ -36,20 +36,20 @@
ce426f
   /* Restore rounding mode and exception enable from *envp and merge
ce426f
      exceptions.  Leave fraction rounded/inexact and FP result/CC bits
ce426f
      unchanged.  */
ce426f
-  new.l[1] = (old.l[1] & 0x1FFFFF00) | (new.l[1] & 0x1FF80FFF);
ce426f
+  new.l = (old.l & 0xffffffff1fffff00LL) | (new.l & 0x1ff80fff);
ce426f
   
ce426f
   /* If the old env has no eabled exceptions and the new env has any enabled
ce426f
      exceptions, then unmask SIGFPE in the MSR FE0/FE1 bits.  This will put
ce426f
      the hardware into "precise mode" and may cause the FPU to run slower on
ce426f
      some hardware.  */
ce426f
-  if ((old.l[1] & _FPU_MASK_ALL) == 0 && (new.l[1] & _FPU_MASK_ALL) != 0)
ce426f
+  if ((old.l & _FPU_MASK_ALL) == 0 && (new.l & _FPU_MASK_ALL) != 0)
ce426f
     (void)__fe_nomask_env ();
ce426f
   
ce426f
   /* If the old env had any eabled exceptions and the new env has no enabled
ce426f
      exceptions, then mask SIGFPE in the MSR FE0/FE1 bits.  This may allow the
ce426f
      FPU to run faster because it always takes the default action and can not 
ce426f
      generate SIGFPE. */
ce426f
-  if ((old.l[1] & _FPU_MASK_ALL) != 0 && (new.l[1] & _FPU_MASK_ALL) == 0)
ce426f
+  if ((old.l & _FPU_MASK_ALL) != 0 && (new.l & _FPU_MASK_ALL) == 0)
ce426f
     (void)__fe_mask_env ();
ce426f
 
ce426f
   /* Atomically enable and raise (if appropriate) exceptions set in `new'. */
ce426f
diff -urN glibc-2.17-c758a686/sysdeps/powerpc/fpu/fgetexcptflg.c glibc-2.17-c758a686/sysdeps/powerpc/fpu/fgetexcptflg.c
ce426f
--- glibc-2.17-c758a686/sysdeps/powerpc/fpu/fgetexcptflg.c	2014-05-27 22:31:42.000000000 -0500
ce426f
+++ glibc-2.17-c758a686/sysdeps/powerpc/fpu/fgetexcptflg.c	2014-05-27 22:31:43.000000000 -0500
ce426f
@@ -28,7 +28,7 @@
ce426f
   u.fenv = fegetenv_register ();
ce426f
 
ce426f
   /* Return (all of) it.  */
ce426f
-  *flagp = u.l[1] & excepts & FE_ALL_EXCEPT;
ce426f
+  *flagp = u.l & excepts & FE_ALL_EXCEPT;
ce426f
 
ce426f
   /* Success.  */
ce426f
   return 0;
ce426f
diff -urN glibc-2.17-c758a686/sysdeps/powerpc/fpu/fraiseexcpt.c glibc-2.17-c758a686/sysdeps/powerpc/fpu/fraiseexcpt.c
ce426f
--- glibc-2.17-c758a686/sysdeps/powerpc/fpu/fraiseexcpt.c	2014-05-27 22:31:42.000000000 -0500
ce426f
+++ glibc-2.17-c758a686/sysdeps/powerpc/fpu/fraiseexcpt.c	2014-05-27 22:31:43.000000000 -0500
ce426f
@@ -34,11 +34,11 @@
ce426f
   u.fenv = fegetenv_register ();
ce426f
 
ce426f
   /* Add the exceptions */
ce426f
-  u.l[1] = (u.l[1]
ce426f
-	    | (excepts & FPSCR_STICKY_BITS)
ce426f
-	    /* Turn FE_INVALID into FE_INVALID_SOFTWARE.  */
ce426f
-	    | (excepts >> ((31 - FPSCR_VX) - (31 - FPSCR_VXSOFT))
ce426f
-	       & FE_INVALID_SOFTWARE));
ce426f
+  u.l = (u.l
ce426f
+	 | (excepts & FPSCR_STICKY_BITS)
ce426f
+	 /* Turn FE_INVALID into FE_INVALID_SOFTWARE.  */
ce426f
+	 | (excepts >> ((31 - FPSCR_VX) - (31 - FPSCR_VXSOFT))
ce426f
+	    & FE_INVALID_SOFTWARE));
ce426f
 
ce426f
   /* Store the new status word (along with the rest of the environment),
ce426f
      triggering any appropriate exceptions.  */
ce426f
@@ -50,7 +50,7 @@
ce426f
 	 don't have FE_INVALID_SOFTWARE implemented.  Detect this
ce426f
 	 case and raise FE_INVALID_SNAN instead.  */
ce426f
       u.fenv = fegetenv_register ();
ce426f
-      if ((u.l[1] & FE_INVALID) == 0)
ce426f
+      if ((u.l & FE_INVALID) == 0)
ce426f
 	set_fpscr_bit (FPSCR_VXSNAN);
ce426f
     }
ce426f
 
ce426f
diff -urN glibc-2.17-c758a686/sysdeps/powerpc/fpu/fsetexcptflg.c glibc-2.17-c758a686/sysdeps/powerpc/fpu/fsetexcptflg.c
ce426f
--- glibc-2.17-c758a686/sysdeps/powerpc/fpu/fsetexcptflg.c	2014-05-27 22:31:42.000000000 -0500
ce426f
+++ glibc-2.17-c758a686/sysdeps/powerpc/fpu/fsetexcptflg.c	2014-05-27 22:31:43.000000000 -0500
ce426f
@@ -32,10 +32,10 @@
ce426f
   flag = *flagp & excepts;
ce426f
 
ce426f
   /* Replace the exception status */
ce426f
-  u.l[1] = ((u.l[1] & ~(FPSCR_STICKY_BITS & excepts))
ce426f
-	    | (flag & FPSCR_STICKY_BITS)
ce426f
-	    | (flag >> ((31 - FPSCR_VX) - (31 - FPSCR_VXSOFT))
ce426f
-	       & FE_INVALID_SOFTWARE));
ce426f
+  u.l = ((u.l & ~(FPSCR_STICKY_BITS & excepts))
ce426f
+	 | (flag & FPSCR_STICKY_BITS)
ce426f
+	 | (flag >> ((31 - FPSCR_VX) - (31 - FPSCR_VXSOFT))
ce426f
+	    & FE_INVALID_SOFTWARE));
ce426f
 
ce426f
   /* Store the new status word (along with the rest of the environment).
ce426f
      This may cause floating-point exceptions if the restored state
ce426f
diff -urN glibc-2.17-c758a686/sysdeps/powerpc/fpu/ftestexcept.c glibc-2.17-c758a686/sysdeps/powerpc/fpu/ftestexcept.c
ce426f
--- glibc-2.17-c758a686/sysdeps/powerpc/fpu/ftestexcept.c	2014-05-27 22:31:42.000000000 -0500
ce426f
+++ glibc-2.17-c758a686/sysdeps/powerpc/fpu/ftestexcept.c	2014-05-27 22:31:43.000000000 -0500
ce426f
@@ -28,6 +28,6 @@
ce426f
 
ce426f
   /* The FE_INVALID bit is dealt with correctly by the hardware, so we can
ce426f
      just:  */
ce426f
-  return u.l[1] & excepts;
ce426f
+  return u.l & excepts;
ce426f
 }
ce426f
 libm_hidden_def (fetestexcept)