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