Blame SOURCES/glibc-rh1302086-6.patch

147e83
commit c95b3011018893fcc473279768a67a24a73bbef2
147e83
Author: Wilco <wdijkstr@arm.com>
147e83
Date:   Mon Jun 2 12:20:17 2014 +0100
147e83
147e83
    [AArch64] Rewrite feupdateenv (BZ 17009).
147e83
147e83
diff --git a/ports/sysdeps/aarch64/fpu/feupdateenv.c b/ports/sysdeps/aarch64/fpu/feupdateenv.c
147e83
index 6d64a9b..ac2f6fe 100644
147e83
--- a/ports/sysdeps/aarch64/fpu/feupdateenv.c
147e83
+++ b/ports/sysdeps/aarch64/fpu/feupdateenv.c
147e83
@@ -22,16 +22,65 @@
147e83
 int
147e83
 feupdateenv (const fenv_t *envp)
147e83
 {
147e83
+  fpu_control_t fpcr;
147e83
+  fpu_control_t fpcr_new;
147e83
+  fpu_control_t updated_fpcr;
147e83
   fpu_fpsr_t fpsr;
147e83
+  fpu_fpsr_t fpsr_new;
147e83
+  int excepts;
147e83
 
147e83
-  /* Get the current exception state.  */
147e83
+  _FPU_GETCW (fpcr);
147e83
   _FPU_GETFPSR (fpsr);
147e83
+  excepts = fpsr & FE_ALL_EXCEPT;
147e83
 
147e83
-  /* Install new environment.  */
147e83
-  fesetenv (envp);
147e83
+  if ((envp != FE_DFL_ENV) && (envp != FE_NOMASK_ENV))
147e83
+    {
147e83
+      fpcr_new = envp->__fpcr;
147e83
+      fpsr_new = envp->__fpsr | excepts;
147e83
 
147e83
-  /* Raise the saved exceptions.  */
147e83
-  feraiseexcept (fpsr & FE_ALL_EXCEPT);
147e83
+      if (fpcr != fpcr_new)
147e83
+        _FPU_SETCW (fpcr_new);
147e83
+
147e83
+      if (fpsr != fpsr_new)
147e83
+        _FPU_SETFPSR (fpsr_new);
147e83
+
147e83
+      if (excepts & (fpcr_new >> FE_EXCEPT_SHIFT))
147e83
+        return feraiseexcept (excepts);
147e83
+
147e83
+      return 0;
147e83
+    }
147e83
+
147e83
+  fpcr_new = fpcr & _FPU_RESERVED;
147e83
+  fpsr_new = fpsr & (_FPU_FPSR_RESERVED | FE_ALL_EXCEPT);
147e83
+
147e83
+  if (envp == FE_DFL_ENV)
147e83
+    {
147e83
+      fpcr_new |= _FPU_DEFAULT;
147e83
+      fpsr_new |= _FPU_FPSR_DEFAULT;
147e83
+    }
147e83
+  else
147e83
+    {
147e83
+      fpcr_new |= _FPU_FPCR_IEEE;
147e83
+      fpsr_new |= _FPU_FPSR_IEEE;
147e83
+    }
147e83
+
147e83
+  _FPU_SETFPSR (fpsr_new);
147e83
+
147e83
+  if (fpcr != fpcr_new)
147e83
+    {
147e83
+      _FPU_SETCW (fpcr_new);
147e83
+
147e83
+      /* Trapping exceptions are optional in AArch64; the relevant enable
147e83
+	 bits in FPCR are RES0 hence the absence of support can be detected
147e83
+	 by reading back the FPCR and comparing with the required value.  */
147e83
+      _FPU_GETCW (updated_fpcr);
147e83
+
147e83
+      if (fpcr_new & ~updated_fpcr)
147e83
+        return 1;
147e83
+    }
147e83
+
147e83
+  if (excepts & (fpcr_new >> FE_EXCEPT_SHIFT))
147e83
+    return feraiseexcept (excepts);
147e83
 
147e83
   return 0;
147e83
 }