Blame SOURCES/glibc-aarch64-fpu-optional-trapping-exceptions.patch

ce426f
commit 302949e2940a9da3f6364a1574619e621b7e1e71
ce426f
Author: Marcus Shawcroft <marcus.shawcroft@arm.com>
ce426f
Date:   Fri Mar 7 14:05:20 2014 +0000
ce426f
ce426f
    [PATCH] [AArch64] Optional trapping exceptions support.
ce426f
    
ce426f
    Trapping exceptions in AArch64 are optional.  The relevant exception
ce426f
    control bits in FPCR are are defined as RES0 hence the absence of
ce426f
    support can be detected by reading back the FPCR and comparing with
ce426f
    the desired value.
ce426f
ce426f
--- glibc-2.17-c758a686/ports/sysdeps/aarch64/fpu/feenablxcpt.c
ce426f
+++ glibc-2.17-c758a686/ports/sysdeps/aarch64/fpu/feenablxcpt.c
ce426f
@@ -35,5 +35,18 @@ feenableexcept (int excepts)
ce426f
 
ce426f
   _FPU_SETCW (fpcr);
ce426f
 
ce426f
+  /* Trapping exceptions are optional in AArch64 the relevant enable
ce426f
+     bits in FPCR are RES0 hence the absence of support can be
ce426f
+     detected by reading back the FPCR and comparing with the required
ce426f
+     value.  */
ce426f
+  if (excepts)
ce426f
+    {
ce426f
+      fpu_control_t updated_fpcr;
ce426f
+
ce426f
+      _FPU_GETCW (updated_fpcr);
ce426f
+      if (((updated_fpcr >> FE_EXCEPT_SHIFT) & excepts) != excepts)
ce426f
+	return -1;
ce426f
+    }
ce426f
+
ce426f
   return original_excepts;
ce426f
 }
ce426f
--- glibc-2.17-c758a686/ports/sysdeps/aarch64/fpu/fesetenv.c
ce426f
+++ glibc-2.17-c758a686/ports/sysdeps/aarch64/fpu/fesetenv.c
ce426f
@@ -24,6 +24,7 @@ fesetenv (const fenv_t *envp)
ce426f
 {
ce426f
   fpu_control_t fpcr;
ce426f
   fpu_fpsr_t fpsr;
ce426f
+  fpu_control_t updated_fpcr;
ce426f
 
ce426f
   _FPU_GETCW (fpcr);
ce426f
   _FPU_GETFPSR (fpsr);
ce426f
@@ -51,6 +52,15 @@ fesetenv (const fenv_t *envp)
ce426f
 
ce426f
   _FPU_SETCW (fpcr);
ce426f
 
ce426f
+  /* Trapping exceptions are optional in AArch64 the relevant enable
ce426f
+     bits in FPCR are RES0 hence the absence of support can be
ce426f
+     detected by reading back the FPCR and comparing with the required
ce426f
+     value.  */
ce426f
+
ce426f
+  _FPU_GETCW (updated_fpcr);
ce426f
+  if ((updated_fpcr & fpcr) != fpcr)
ce426f
+    return 1;
ce426f
+
ce426f
   return 0;
ce426f
 }
ce426f
 
ce426f
commit 423a7160af7fcffc61aac5e2e36d0b6b5b083214
ce426f
Author: Wilco <wdijkstr@arm.com>
ce426f
Date:   Thu Apr 17 09:39:27 2014 +0100
ce426f
ce426f
    Add fenv test support for targets which don't have FP traps.
ce426f
ce426f
(removed unnecessary code to limit it to test-fenv.c --kyle)
ce426f
ce426f
--- glibc-2.17-c758a686/math/test-fenv.c
ce426f
+++ glibc-2.17-c758a686/math/test-fenv.c
ce426f
@@ -233,14 +234,9 @@ feenv_nomask_test (const char *flag_name, int fe_exc)
ce426f
 #if defined FE_NOMASK_ENV
ce426f
   int status;
ce426f
   pid_t pid;
ce426f
-  fenv_t saved;
ce426f
 
ce426f
-  fegetenv (&saved);
ce426f
-  errno = 0;
ce426f
-  fesetenv (FE_NOMASK_ENV);
ce426f
-  status = errno;
ce426f
-  fesetenv (&saved);
ce426f
-  if (status == ENOSYS)
ce426f
+  if (1
ce426f
+      && fesetenv (FE_NOMASK_ENV) != 0)
ce426f
     {
ce426f
       printf ("Test: not testing FE_NOMASK_ENV, it isn't implemented.\n");
ce426f
       return;
ce426f
@@ -349,7 +345,13 @@ feexcp_nomask_test (const char *flag_name, int fe_exc)
ce426f
   int status;
ce426f
   pid_t pid;
ce426f
 
ce426f
-  printf ("Test: after fedisableexcept (%s) processes will abort\n",
ce426f
+  if (1 && feenableexcept (fe_exc) == -1)
ce426f
+    {
ce426f
+      printf ("Test: not testing feenableexcept, it isn't implemented.\n");
ce426f
+      return;
ce426f
+    }
ce426f
+
ce426f
+  printf ("Test: after feenableexcept (%s) processes will abort\n",
ce426f
 	  flag_name);
ce426f
   printf ("      when feraiseexcept (%s) is called.\n", flag_name);
ce426f
   pid = fork ();
ce426f
@@ -470,7 +472,6 @@ feenable_test (const char *flag_name, int fe_exc)
ce426f
 {
ce426f
   int excepts;
ce426f
 
ce426f
-
ce426f
   printf ("Tests for feenableexcepts etc. with flag %s\n", flag_name);
ce426f
 
ce426f
   /* First disable all exceptions.  */
ce426f
@@ -488,8 +489,12 @@ feenable_test (const char *flag_name, int fe_exc)
ce426f
 	      flag_name, excepts);
ce426f
       ++count_errors;
ce426f
     }
ce426f
-
ce426f
   excepts = feenableexcept (fe_exc);
ce426f
+  if (1 && excepts == -1)
ce426f
+    {
ce426f
+      printf ("Test: not testing feenableexcept, it isn't implemented.\n");
ce426f
+      return;
ce426f
+    }
ce426f
   if (excepts == -1)
ce426f
     {
ce426f
       printf ("Test: feenableexcept (%s) failed\n", flag_name);