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

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