about summary refs log tree commit diff
path: root/sysdeps/arm/feenablxcpt.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/arm/feenablxcpt.c')
-rw-r--r--sysdeps/arm/feenablxcpt.c42
1 files changed, 17 insertions, 25 deletions
diff --git a/sysdeps/arm/feenablxcpt.c b/sysdeps/arm/feenablxcpt.c
index b286ec5565..afd8943638 100644
--- a/sysdeps/arm/feenablxcpt.c
+++ b/sysdeps/arm/feenablxcpt.c
@@ -25,35 +25,27 @@
 int
 feenableexcept (int excepts)
 {
-  if (ARM_HAVE_VFP)
-    {
-      unsigned long int new_exc, old_exc;
-
-      _FPU_GETCW(new_exc);
-
-      old_exc = (new_exc >> FE_EXCEPT_SHIFT) & FE_ALL_EXCEPT;
+  fpu_control_t fpscr, new_fpscr;
 
-      excepts &= FE_ALL_EXCEPT;
+  /* Fail if a VFP unit isn't present.  */
+  if (!ARM_HAVE_VFP)
+    return -1;
 
-      new_exc |= (excepts << FE_EXCEPT_SHIFT);
+  _FPU_GETCW (fpscr);
+  excepts &= FE_ALL_EXCEPT;
+  new_fpscr = fpscr | (excepts << FE_EXCEPT_SHIFT);
 
-      _FPU_SETCW(new_exc);
+  _FPU_SETCW (new_fpscr);
 
-      if (excepts != 0)
-	{
-	  /* VFPv3 and VFPv4 do not support trapping exceptions, so
-	     test whether the relevant bits were set and fail if
-	     not.  */
-	  unsigned int temp;
-	  _FPU_GETCW (temp);
-	  if ((temp & (excepts << FE_EXCEPT_SHIFT))
-	      != (excepts << FE_EXCEPT_SHIFT))
-	    return -1;
-	}
-
-      return old_exc;
+  if (excepts != 0)
+    {
+      /* Not all VFP architectures support trapping exceptions, so
+	 test whether the relevant bits were set and fail if not.  */
+      _FPU_GETCW (new_fpscr);
+      if ((new_fpscr & (excepts << FE_EXCEPT_SHIFT))
+	  != (excepts << FE_EXCEPT_SHIFT))
+	return -1;
     }
 
-  /* Unsupported, so return -1 for failure.  */
-  return -1;
+  return (fpscr >> FE_EXCEPT_SHIFT) & FE_ALL_EXCEPT;
 }