This is the mail archive of the glibc-cvs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

GNU C Library master sources branch master updated. glibc-2.19-421-gc0c08d0


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, master has been updated
       via  c0c08d02c82275353f5c556f935a1a01714d9d7f (commit)
       via  1a2f40e5d14ed6450696feacf04fca5eeceae7ef (commit)
      from  cf26a0cb6a0bbaca46a01ddad6662e5e5159a32a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=c0c08d02c82275353f5c556f935a1a01714d9d7f

commit c0c08d02c82275353f5c556f935a1a01714d9d7f
Author: Wilco <wdijkstr@arm.com>
Date:   Thu May 15 15:21:55 2014 +0100

    ARM: Improve fenv implementation

diff --git a/ChangeLog b/ChangeLog
index 83719ed..29ffc2d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -897,6 +897,24 @@
 
 2014-05-14  Wilco  <wdijkstr@arm.com>
 
+	* sysdeps/arm/fclrexcpt.c: Optimize to avoid unnecessary FPSCR writes.
+	* sysdeps/arm/fedisblxcpt.c: Likewise.
+	* sysdeps/arm/feenablxcpt.c: Likewise.
+	* sysdeps/arm/fegetround.c: Call (get_rounding_mode).
+	* sysdeps/arm/feholdexcpt.c: Call optimized (libc_feholdexcept_vfp).
+	* sysdeps/arm/fesetenv.c: Special case FE_DFL_ENV and FE_NOMASK_ENV.
+	Call optimized (libc_fesetenv_vfp).
+	* sysdeps/arm/fesetround.c: Call optimized (libc_fesetround_vfp).
+	* sysdeps/arm/feupdateenv.c: Special case FE_DFL_ENV and FE_NOMASK_ENV.
+	Call optimized (libc_feupdateenv_vfp).
+	* sysdeps/arm/fgetexcptflg.c: Call optimized (libc_fetestexcept_vfp).
+	* sysdeps/arm/fsetexcptflg.c: Optimize to avoid unnecessary FPSCR
+	writes.
+	* sysdeps/arm/ftestexcept.c: Call optimized (libc_fetestexcept_vfp).
+	* sysdeps/arm/setfpucw.c: Optimize to avoid unnecessary FPSCR writes.
+
+2014-05-14  Wilco  <wdijkstr@arm.com>
+
 	* sysdeps/arm/fclrexcpt.c: Cleanup.
 	* sysdeps/arm/fedisblxcpt.c: Cleanup.
 	* sysdeps/arm/feenablxcpt.c: Cleanup.
diff --git a/sysdeps/arm/fclrexcpt.c b/sysdeps/arm/fclrexcpt.c
index cbf61a6..31420ed 100644
--- a/sysdeps/arm/fclrexcpt.c
+++ b/sysdeps/arm/fclrexcpt.c
@@ -24,7 +24,7 @@
 int
 feclearexcept (int excepts)
 {
-  fpu_control_t fpscr;
+  fpu_control_t fpscr, new_fpscr;
 
   /* Fail if a VFP unit isn't present unless nothing needs to be done.  */
   if (!ARM_HAVE_VFP)
@@ -32,11 +32,11 @@ feclearexcept (int excepts)
 
   _FPU_GETCW (fpscr);
   excepts &= FE_ALL_EXCEPT;
+  new_fpscr = fpscr & ~excepts;
 
-  /* Clear the relevant bits.  */
-  fpscr = (fpscr & ~FE_ALL_EXCEPT) | (fpscr & FE_ALL_EXCEPT & ~excepts);
-
-  _FPU_SETCW (fpscr);
+  /* Write new exception flags if changed.  */
+  if (new_fpscr != fpscr)
+    _FPU_SETCW (new_fpscr);
 
   return 0;
 }
diff --git a/sysdeps/arm/fedisblxcpt.c b/sysdeps/arm/fedisblxcpt.c
index f2956cd..d5e0f00 100644
--- a/sysdeps/arm/fedisblxcpt.c
+++ b/sysdeps/arm/fedisblxcpt.c
@@ -35,7 +35,9 @@ fedisableexcept (int excepts)
   excepts &= FE_ALL_EXCEPT;
   new_fpscr = fpscr & ~(excepts << FE_EXCEPT_SHIFT);
 
-  _FPU_SETCW (new_fpscr);
+  /* Write new exceptions if changed.  */
+  if (new_fpscr != fpscr)
+    _FPU_SETCW (new_fpscr);
 
   return (fpscr >> FE_EXCEPT_SHIFT) & FE_ALL_EXCEPT;
 }
diff --git a/sysdeps/arm/feenablxcpt.c b/sysdeps/arm/feenablxcpt.c
index afd8943..e649b2f 100644
--- a/sysdeps/arm/feenablxcpt.c
+++ b/sysdeps/arm/feenablxcpt.c
@@ -35,15 +35,15 @@ feenableexcept (int excepts)
   excepts &= FE_ALL_EXCEPT;
   new_fpscr = fpscr | (excepts << FE_EXCEPT_SHIFT);
 
-  _FPU_SETCW (new_fpscr);
-
-  if (excepts != 0)
+  if (new_fpscr != fpscr)
     {
+      _FPU_SETCW (new_fpscr);
+
       /* 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))
+
+      if (((new_fpscr >> FE_EXCEPT_SHIFT) & excepts) != excepts)
 	return -1;
     }
 
diff --git a/sysdeps/arm/fegetround.c b/sysdeps/arm/fegetround.c
index 1c9c151..fbad0b3 100644
--- a/sysdeps/arm/fegetround.c
+++ b/sysdeps/arm/fegetround.c
@@ -16,22 +16,12 @@
    License along with the GNU C Library.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <fenv.h>
-#include <fpu_control.h>
-#include <arm-features.h>
+#include <get-rounding-mode.h>
 
 
 int
 fegetround (void)
 {
-  fpu_control_t fpscr;
-
-  /* FE_TONEAREST is the only supported rounding mode
-     if a VFP unit isn't present.  */
-  if (!ARM_HAVE_VFP)
-    return FE_TONEAREST;
-
-  _FPU_GETCW (fpscr);
-  return fpscr & FE_TOWARDZERO;
+  return get_rounding_mode ();
 }
 libm_hidden_def (fegetround)
diff --git a/sysdeps/arm/feholdexcpt.c b/sysdeps/arm/feholdexcpt.c
index 258ba66..2d79e0c 100644
--- a/sysdeps/arm/feholdexcpt.c
+++ b/sysdeps/arm/feholdexcpt.c
@@ -16,30 +16,18 @@
    License along with the GNU C Library.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <fenv.h>
-#include <fpu_control.h>
+#include <fenv_private.h>
 #include <arm-features.h>
 
 
 int
 feholdexcept (fenv_t *envp)
 {
-  fpu_control_t fpscr;
-
   /* Fail if a VFP unit isn't present.  */
   if (!ARM_HAVE_VFP)
     return 1;
 
-  _FPU_GETCW (fpscr);
-  envp->__cw = fpscr;
-
-  /* Now set all exceptions to non-stop.  */
-  fpscr &= ~(FE_ALL_EXCEPT << FE_EXCEPT_SHIFT);
-
-  /* And clear all exception flags.  */
-  fpscr &= ~FE_ALL_EXCEPT;
-
-  _FPU_SETCW (fpscr);
+  libc_feholdexcept_vfp (envp);
   return 0;
 }
 
diff --git a/sysdeps/arm/fesetenv.c b/sysdeps/arm/fesetenv.c
index 62031d5..9e2aa81 100644
--- a/sysdeps/arm/fesetenv.c
+++ b/sysdeps/arm/fesetenv.c
@@ -16,43 +16,43 @@
    License along with the GNU C Library.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <fenv.h>
-#include <fpu_control.h>
+#include <fenv_private.h>
 #include <arm-features.h>
 
 
 int
 fesetenv (const fenv_t *envp)
 {
-  fpu_control_t fpscr;
-
   /* Fail if a VFP unit isn't present.  */
   if (!ARM_HAVE_VFP)
     return 1;
 
-  _FPU_GETCW (fpscr);
+  if ((envp == FE_DFL_ENV) || (envp == FE_NOMASK_ENV))
+    {
+      fpu_control_t fpscr, new_fpscr;
+
+      _FPU_GETCW (fpscr);
 
-  /* Preserve the reserved FPSCR flags.  */
-  fpscr &= _FPU_RESERVED;
+      /* Preserve the reserved FPSCR flags.  */
+      new_fpscr = fpscr & _FPU_RESERVED;
 
-  if (envp == FE_DFL_ENV)
-    fpscr |= _FPU_DEFAULT;
-  else if (envp == FE_NOMASK_ENV)
-    fpscr |= _FPU_IEEE;
-  else
-    fpscr |= envp->__cw & ~_FPU_RESERVED;
+      if (envp == FE_DFL_ENV)
+	_FPU_SETCW (new_fpscr | _FPU_DEFAULT);
+      else
+	{
+	  _FPU_SETCW (new_fpscr | _FPU_IEEE);
+	  /* Not all VFP architectures support trapping exceptions, so
+	     test whether the relevant bits were set and fail if not.  */
+	  _FPU_GETCW (fpscr);
 
-  _FPU_SETCW (fpscr);
+	  if ((fpscr & _FPU_IEEE) != _FPU_IEEE)
+	    return 1;
+	}
 
-  if (envp == FE_NOMASK_ENV)
-    {
-      /* Not all VFP architectures support trapping exceptions, so
-	 test whether the relevant bits were set and fail if not.  */
-      _FPU_GETCW (fpscr);
-      if ((fpscr & _FPU_IEEE) != _FPU_IEEE)
-	return 1;
+      return 0;
     }
 
+  libc_fesetenv_vfp (envp);
   return 0;
 }
 
diff --git a/sysdeps/arm/fesetround.c b/sysdeps/arm/fesetround.c
index d1b92dc..f52c50a 100644
--- a/sysdeps/arm/fesetround.c
+++ b/sysdeps/arm/fesetround.c
@@ -16,28 +16,22 @@
    License along with the GNU C Library.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <fenv.h>
-#include <fpu_control.h>
+#include <fenv_private.h>
 #include <arm-features.h>
 
 
 int
 fesetround (int round)
 {
-  fpu_control_t fpscr;
-
   /* FE_TONEAREST is the only supported rounding mode
      if a VFP unit isn't present.  */
   if (!ARM_HAVE_VFP)
     return (round == FE_TONEAREST) ? 0 : 1;
 
-  /* Fail if the rounding mode is not valid.  */
   if (round & ~FE_TOWARDZERO)
     return 1;
 
-  _FPU_GETCW (fpscr);
-  fpscr = (fpscr & ~FE_TOWARDZERO) | round;
-  _FPU_SETCW (fpscr);
+  libc_fesetround_vfp (round);
   return 0;
 }
 
diff --git a/sysdeps/arm/feupdateenv.c b/sysdeps/arm/feupdateenv.c
index 55a1502..2a7b3ec 100644
--- a/sysdeps/arm/feupdateenv.c
+++ b/sysdeps/arm/feupdateenv.c
@@ -17,27 +17,35 @@
    License along with the GNU C Library.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <fenv.h>
-#include <fpu_control.h>
+#include <fenv_private.h>
 #include <arm-features.h>
 
 
 int
 feupdateenv (const fenv_t *envp)
 {
-  fpu_control_t fpscr;
+  fenv_t fenv;
 
   /* Fail if a VFP unit isn't present.  */
   if (!ARM_HAVE_VFP)
     return 1;
 
-  _FPU_GETCW (fpscr);
+  if ((envp == FE_DFL_ENV) || (envp == FE_NOMASK_ENV))
+    {
+      fpu_control_t fpscr;
 
-  /* Install new environment.  */
-  fesetenv (envp);
+      _FPU_GETCW (fpscr);
 
-  /* Raise the saved exceptions.  */
-  feraiseexcept (fpscr & FE_ALL_EXCEPT);
+      /* Preserve the reserved FPSCR flags.  */
+      fpscr &= _FPU_RESERVED;
+      fpscr |= (envp == FE_DFL_ENV) ? _FPU_DEFAULT : _FPU_IEEE;
+
+      /* Create a valid fenv to pass to libc_feupdateenv_vfp.  */
+      fenv.__cw = fpscr;
+      envp = &fenv;
+    }
+
+  libc_feupdateenv_vfp (envp);
   return 0;
 }
 libm_hidden_def (feupdateenv)
diff --git a/sysdeps/arm/fgetexcptflg.c b/sysdeps/arm/fgetexcptflg.c
index 63fdfbf..994555c 100644
--- a/sysdeps/arm/fgetexcptflg.c
+++ b/sysdeps/arm/fgetexcptflg.c
@@ -17,22 +17,17 @@
    License along with the GNU C Library.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <fenv.h>
-#include <fpu_control.h>
+#include <fenv_private.h>
 #include <arm-features.h>
 
 
 int
 fegetexceptflag (fexcept_t *flagp, int excepts)
 {
-  fpu_control_t fpscr;
-
   /* Fail if a VFP unit isn't present.  */
   if (!ARM_HAVE_VFP)
     return 1;
 
-  _FPU_GETCW (fpscr);
-
-  *flagp = fpscr & excepts & FE_ALL_EXCEPT;
+  *flagp = libc_fetestexcept_vfp (excepts);
   return 0;
 }
diff --git a/sysdeps/arm/fsetexcptflg.c b/sysdeps/arm/fsetexcptflg.c
index 1a610ff..28810d3 100644
--- a/sysdeps/arm/fsetexcptflg.c
+++ b/sysdeps/arm/fsetexcptflg.c
@@ -25,19 +25,22 @@
 int
 fesetexceptflag (const fexcept_t *flagp, int excepts)
 {
-  fpu_control_t fpscr;
+  fpu_control_t fpscr, new_fpscr;
 
   /* Fail if a VFP unit isn't present unless nothing needs to be done.  */
   if (!ARM_HAVE_VFP)
     return (excepts != 0);
 
   _FPU_GETCW (fpscr);
+  excepts &= FE_ALL_EXCEPT;
 
   /* Set the desired exception mask.  */
-  fpscr &= ~(excepts & FE_ALL_EXCEPT);
-  fpscr |= (*flagp & excepts & FE_ALL_EXCEPT);
+  new_fpscr = fpscr & ~excepts;
+  new_fpscr |= *flagp & excepts;
+
+  /* Write new exception flags if changed.  */
+  if (new_fpscr != fpscr)
+    _FPU_SETCW (new_fpscr);
 
-  /* Save state back to the FPU.  */
-  _FPU_SETCW (fpscr);
   return 0;
 }
diff --git a/sysdeps/arm/ftestexcept.c b/sysdeps/arm/ftestexcept.c
index de082b2..6c5d3a8 100644
--- a/sysdeps/arm/ftestexcept.c
+++ b/sysdeps/arm/ftestexcept.c
@@ -16,23 +16,18 @@
    License along with the GNU C Library.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <fenv.h>
-#include <fpu_control.h>
+#include <fenv_private.h>
 #include <arm-features.h>
 
 
 int
 fetestexcept (int excepts)
 {
-  fpu_control_t fpscr;
-
   /* Return no exception flags if a VFP unit isn't present.  */
   if (!ARM_HAVE_VFP)
     return 0;
 
-  /* Get current exceptions.  */
-  _FPU_GETCW (fpscr);
-
-  return fpscr & excepts & FE_ALL_EXCEPT;
+  return libc_fetestexcept_vfp (excepts);
 }
+
 libm_hidden_def (fetestexcept)
diff --git a/sysdeps/arm/setfpucw.c b/sysdeps/arm/setfpucw.c
index 7416377..259b020 100644
--- a/sysdeps/arm/setfpucw.c
+++ b/sysdeps/arm/setfpucw.c
@@ -24,19 +24,20 @@
 void
 __setfpucw (fpu_control_t set)
 {
-  fpu_control_t fpscr;
+  fpu_control_t fpscr, new_fpscr;
 
   /* Do nothing if a VFP unit isn't present.  */
   if (!ARM_HAVE_VFP)
     return;
 
-  /* Fetch the current control word.  */
   _FPU_GETCW (fpscr);
 
   /* Preserve the reserved bits, and set the rest as the user
      specified (or the default, if the user gave zero).  */
-  fpscr &= _FPU_RESERVED;
-  fpscr |= set & ~_FPU_RESERVED;
+  new_fpscr = fpscr & _FPU_RESERVED;
+  new_fpscr |= set & ~_FPU_RESERVED;
 
-  _FPU_SETCW (fpscr);
+  /* Write FPSCR if changed.  */
+  if (new_fpscr != fpscr)
+    _FPU_SETCW (fpscr);
 }

http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=1a2f40e5d14ed6450696feacf04fca5eeceae7ef

commit 1a2f40e5d14ed6450696feacf04fca5eeceae7ef
Author: Wilco <wdijkstr@arm.com>
Date:   Thu May 15 15:18:40 2014 +0100

    ARM: Improve fenv implementation

diff --git a/ChangeLog b/ChangeLog
index 079e1ed..83719ed 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -895,6 +895,25 @@
 	* nptl/sysdeps/unix/sysv/linux/s390/bits/pthreadtypes.h
 	(pthread_mutex_t): Add lock elision support for s390.
 
+2014-05-14  Wilco  <wdijkstr@arm.com>
+
+	* sysdeps/arm/fclrexcpt.c: Cleanup.
+	* sysdeps/arm/fedisblxcpt.c: Cleanup.
+	* sysdeps/arm/feenablxcpt.c: Cleanup.
+	* sysdeps/arm/fegetenv.c: Cleanup.
+	* sysdeps/arm/fegetexcept.c: Cleanup.
+	* sysdeps/arm/fegetround.c: Cleanup.
+	* sysdeps/arm/feholdexcpt.c: Cleanup.
+	* sysdeps/arm/fesetenv.c: Cleanup.
+	* sysdeps/arm/fesetround.c: Cleanup.
+	* sysdeps/arm/feupdateenv.c: Cleanup.
+	* sysdeps/arm/fgetexcptflg.c: Cleanup.
+	* sysdeps/arm/fraiseexcpt.c: Cleanup.
+	* sysdeps/arm/fsetexcptflg.c: Cleanup.
+	* sysdeps/arm/ftestexcept.c: Cleanup.
+	* sysdeps/arm/get-rounding-mode.h: Cleanup.
+	* sysdeps/arm/setfpucw.c: Cleanup.
+
 2014-05-09  Will Newton  <will.newton@linaro.org>
 
 	* sysdeps/arm/armv7/strcmp.S: New file.
diff --git a/sysdeps/arm/fclrexcpt.c b/sysdeps/arm/fclrexcpt.c
index 72eaab9..cbf61a6 100644
--- a/sysdeps/arm/fclrexcpt.c
+++ b/sysdeps/arm/fclrexcpt.c
@@ -24,27 +24,20 @@
 int
 feclearexcept (int excepts)
 {
-  if (ARM_HAVE_VFP)
-    {
-      unsigned long int temp;
+  fpu_control_t fpscr;
 
-      /* Mask out unsupported bits/exceptions.  */
-      excepts &= FE_ALL_EXCEPT;
+  /* Fail if a VFP unit isn't present unless nothing needs to be done.  */
+  if (!ARM_HAVE_VFP)
+    return (excepts != 0);
 
-      /* Get the current floating point status. */
-      _FPU_GETCW (temp);
+  _FPU_GETCW (fpscr);
+  excepts &= FE_ALL_EXCEPT;
 
-      /* Clear the relevant bits.  */
-      temp = (temp & ~FE_ALL_EXCEPT) | (temp & FE_ALL_EXCEPT & ~excepts);
+  /* Clear the relevant bits.  */
+  fpscr = (fpscr & ~FE_ALL_EXCEPT) | (fpscr & FE_ALL_EXCEPT & ~excepts);
 
-      /* Put the new data in effect.  */
-      _FPU_SETCW (temp);
+  _FPU_SETCW (fpscr);
 
-      /* Success.  */
-      return 0;
-    }
-
-  /* Unsupported, so fail unless nothing needs to be done.  */
-  return (excepts != 0);
+  return 0;
 }
 libm_hidden_def (feclearexcept)
diff --git a/sysdeps/arm/fedisblxcpt.c b/sysdeps/arm/fedisblxcpt.c
index 88da539..f2956cd 100644
--- a/sysdeps/arm/fedisblxcpt.c
+++ b/sysdeps/arm/fedisblxcpt.c
@@ -25,23 +25,17 @@
 int
 fedisableexcept (int excepts)
 {
-  if (ARM_HAVE_VFP)
-    {
-      unsigned long int new_exc, old_exc;
+  fpu_control_t fpscr, new_fpscr;
 
-      _FPU_GETCW(new_exc);
+  /* Fail if a VFP unit isn't present.  */
+  if (!ARM_HAVE_VFP)
+    return -1;
 
-      old_exc = (new_exc >> FE_EXCEPT_SHIFT) & FE_ALL_EXCEPT;
+  _FPU_GETCW (fpscr);
+  excepts &= FE_ALL_EXCEPT;
+  new_fpscr = fpscr & ~(excepts << FE_EXCEPT_SHIFT);
 
-      excepts &= FE_ALL_EXCEPT;
+  _FPU_SETCW (new_fpscr);
 
-      new_exc &= ~(excepts << FE_EXCEPT_SHIFT);
-
-      _FPU_SETCW(new_exc);
-
-      return old_exc;
-    }
-
-  /* Unsupported, so return -1 for failure.  */
-  return -1;
+  return (fpscr >> FE_EXCEPT_SHIFT) & FE_ALL_EXCEPT;
 }
diff --git a/sysdeps/arm/feenablxcpt.c b/sysdeps/arm/feenablxcpt.c
index b286ec5..afd8943 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;
 }
diff --git a/sysdeps/arm/fegetenv.c b/sysdeps/arm/fegetenv.c
index a45c1af..f390c0f 100644
--- a/sysdeps/arm/fegetenv.c
+++ b/sysdeps/arm/fegetenv.c
@@ -24,17 +24,14 @@
 int
 fegetenv (fenv_t *envp)
 {
-  if (ARM_HAVE_VFP)
-    {
-      unsigned long int temp;
-      _FPU_GETCW (temp);
-      envp->__cw = temp;
-
-      /* Success.  */
-      return 0;
-    }
-
-  /* Unsupported, so fail.  */
-  return 1;
+  fpu_control_t fpscr;
+
+  /* Fail if a VFP unit isn't present.  */
+  if (!ARM_HAVE_VFP)
+    return 1;
+
+  _FPU_GETCW (fpscr);
+  envp->__cw = fpscr;
+  return 0;
 }
 libm_hidden_def (fegetenv)
diff --git a/sysdeps/arm/fegetexcept.c b/sysdeps/arm/fegetexcept.c
index 5974c63..aa244d0 100644
--- a/sysdeps/arm/fegetexcept.c
+++ b/sysdeps/arm/fegetexcept.c
@@ -25,15 +25,13 @@
 int
 fegetexcept (void)
 {
-  if (ARM_HAVE_VFP)
-    {
-      unsigned long temp;
+  fpu_control_t fpscr;
 
-      _FPU_GETCW (temp);
+  /* Return with all exceptions disabled if a VFP unit isn't present.  */
+  if (!ARM_HAVE_VFP)
+    return 0;
 
-      return (temp >> FE_EXCEPT_SHIFT) & FE_ALL_EXCEPT;
-    }
+  _FPU_GETCW (fpscr);
 
-  /* Unsupported. Return all exceptions disabled.  */
-  return 0;
+  return (fpscr >> FE_EXCEPT_SHIFT) & FE_ALL_EXCEPT;
 }
diff --git a/sysdeps/arm/fegetround.c b/sysdeps/arm/fegetround.c
index cb4cf1b..1c9c151 100644
--- a/sysdeps/arm/fegetround.c
+++ b/sysdeps/arm/fegetround.c
@@ -24,17 +24,14 @@
 int
 fegetround (void)
 {
-  if (ARM_HAVE_VFP)
-    {
-      unsigned int temp;
+  fpu_control_t fpscr;
 
-      /* Get the current environment.  */
-      _FPU_GETCW (temp);
+  /* FE_TONEAREST is the only supported rounding mode
+     if a VFP unit isn't present.  */
+  if (!ARM_HAVE_VFP)
+    return FE_TONEAREST;
 
-      return temp & FE_TOWARDZERO;
-    }
-
-  /* The current soft-float implementation only handles TONEAREST.  */
-  return FE_TONEAREST;
+  _FPU_GETCW (fpscr);
+  return fpscr & FE_TOWARDZERO;
 }
 libm_hidden_def (fegetround)
diff --git a/sysdeps/arm/feholdexcpt.c b/sysdeps/arm/feholdexcpt.c
index 9ca673c..258ba66 100644
--- a/sysdeps/arm/feholdexcpt.c
+++ b/sysdeps/arm/feholdexcpt.c
@@ -24,27 +24,23 @@
 int
 feholdexcept (fenv_t *envp)
 {
-  if (ARM_HAVE_VFP)
-    {
-      unsigned long int temp;
+  fpu_control_t fpscr;
 
-      /* Store the environment.  */
-      _FPU_GETCW(temp);
-      envp->__cw = temp;
+  /* Fail if a VFP unit isn't present.  */
+  if (!ARM_HAVE_VFP)
+    return 1;
 
-      /* Now set all exceptions to non-stop.  */
-      temp &= ~(FE_ALL_EXCEPT << FE_EXCEPT_SHIFT);
+  _FPU_GETCW (fpscr);
+  envp->__cw = fpscr;
 
-      /* And clear all exception flags.  */
-      temp &= ~FE_ALL_EXCEPT;
+  /* Now set all exceptions to non-stop.  */
+  fpscr &= ~(FE_ALL_EXCEPT << FE_EXCEPT_SHIFT);
 
-      _FPU_SETCW(temp);
+  /* And clear all exception flags.  */
+  fpscr &= ~FE_ALL_EXCEPT;
 
-      return 0;
-    }
-
-  /* Unsupported, so fail.  */
-  return 1;
+  _FPU_SETCW (fpscr);
+  return 0;
 }
 
 libm_hidden_def (feholdexcept)
diff --git a/sysdeps/arm/fesetenv.c b/sysdeps/arm/fesetenv.c
index dabb88b..62031d5 100644
--- a/sysdeps/arm/fesetenv.c
+++ b/sysdeps/arm/fesetenv.c
@@ -24,38 +24,36 @@
 int
 fesetenv (const fenv_t *envp)
 {
-  if (ARM_HAVE_VFP)
+  fpu_control_t fpscr;
+
+  /* Fail if a VFP unit isn't present.  */
+  if (!ARM_HAVE_VFP)
+    return 1;
+
+  _FPU_GETCW (fpscr);
+
+  /* Preserve the reserved FPSCR flags.  */
+  fpscr &= _FPU_RESERVED;
+
+  if (envp == FE_DFL_ENV)
+    fpscr |= _FPU_DEFAULT;
+  else if (envp == FE_NOMASK_ENV)
+    fpscr |= _FPU_IEEE;
+  else
+    fpscr |= envp->__cw & ~_FPU_RESERVED;
+
+  _FPU_SETCW (fpscr);
+
+  if (envp == FE_NOMASK_ENV)
     {
-      unsigned int temp;
-
-      _FPU_GETCW (temp);
-      temp &= _FPU_RESERVED;
-
-      if (envp == FE_DFL_ENV)
-	temp |= _FPU_DEFAULT;
-      else if (envp == FE_NOMASK_ENV)
-	temp |= _FPU_IEEE;
-      else
-	temp |= envp->__cw & ~_FPU_RESERVED;
-
-      _FPU_SETCW (temp);
-
-      if (envp == FE_NOMASK_ENV)
-	{
-	  /* VFPv3 and VFPv4 do not support trapping exceptions, so
-	     test whether the relevant bits were set and fail if
-	     not.  */
-	  _FPU_GETCW (temp);
-	  if ((temp & _FPU_IEEE) != _FPU_IEEE)
-	    return 1;
-	}
-
-      /* Success.  */
-      return 0;
+      /* Not all VFP architectures support trapping exceptions, so
+	 test whether the relevant bits were set and fail if not.  */
+      _FPU_GETCW (fpscr);
+      if ((fpscr & _FPU_IEEE) != _FPU_IEEE)
+	return 1;
     }
 
-  /* Unsupported, so fail.  */
-  return 1;
+  return 0;
 }
 
 libm_hidden_def (fesetenv)
diff --git a/sysdeps/arm/fesetround.c b/sysdeps/arm/fesetround.c
index 6f533d1..d1b92dc 100644
--- a/sysdeps/arm/fesetround.c
+++ b/sysdeps/arm/fesetround.c
@@ -24,30 +24,21 @@
 int
 fesetround (int round)
 {
-  if (ARM_HAVE_VFP)
-    {
-      fpu_control_t temp;
-
-      switch (round)
-	{
-	case FE_TONEAREST:
-	case FE_UPWARD:
-	case FE_DOWNWARD:
-	case FE_TOWARDZERO:
-	  _FPU_GETCW (temp);
-	  temp = (temp & ~FE_TOWARDZERO) | round;
-	  _FPU_SETCW (temp);
-	  return 0;
-	default:
-	  return 1;
-	}
-    }
-  else if (round == FE_TONEAREST)
-    /* This is the only supported rounding mode for soft-fp.  */
-    return 0;
-
-  /* Unsupported, so fail.  */
-  return 1;
+  fpu_control_t fpscr;
+
+  /* FE_TONEAREST is the only supported rounding mode
+     if a VFP unit isn't present.  */
+  if (!ARM_HAVE_VFP)
+    return (round == FE_TONEAREST) ? 0 : 1;
+
+  /* Fail if the rounding mode is not valid.  */
+  if (round & ~FE_TOWARDZERO)
+    return 1;
+
+  _FPU_GETCW (fpscr);
+  fpscr = (fpscr & ~FE_TOWARDZERO) | round;
+  _FPU_SETCW (fpscr);
+  return 0;
 }
 
 libm_hidden_def (fesetround)
diff --git a/sysdeps/arm/feupdateenv.c b/sysdeps/arm/feupdateenv.c
index f5deb60..55a1502 100644
--- a/sysdeps/arm/feupdateenv.c
+++ b/sysdeps/arm/feupdateenv.c
@@ -25,24 +25,19 @@
 int
 feupdateenv (const fenv_t *envp)
 {
-  if (ARM_HAVE_VFP)
-    {
-      unsigned int temp;
+  fpu_control_t fpscr;
 
-      /* Get the current exception state.  */
-      _FPU_GETCW (temp);
+  /* Fail if a VFP unit isn't present.  */
+  if (!ARM_HAVE_VFP)
+    return 1;
 
-      /* Install new environment.  */
-      fesetenv (envp);
+  _FPU_GETCW (fpscr);
 
-      /* Raise the saved exceptions.  */
-      feraiseexcept (temp & FE_ALL_EXCEPT);
+  /* Install new environment.  */
+  fesetenv (envp);
 
-      /* Success.  */
-      return 0;
-    }
-
-  /* Unsupported, so fail.  */
-  return 1;
+  /* Raise the saved exceptions.  */
+  feraiseexcept (fpscr & FE_ALL_EXCEPT);
+  return 0;
 }
 libm_hidden_def (feupdateenv)
diff --git a/sysdeps/arm/fgetexcptflg.c b/sysdeps/arm/fgetexcptflg.c
index beb43be..63fdfbf 100644
--- a/sysdeps/arm/fgetexcptflg.c
+++ b/sysdeps/arm/fgetexcptflg.c
@@ -25,19 +25,14 @@
 int
 fegetexceptflag (fexcept_t *flagp, int excepts)
 {
-  if (ARM_HAVE_VFP)
-    {
-      unsigned long temp;
+  fpu_control_t fpscr;
 
-      /* Get the current exceptions.  */
-      _FPU_GETCW (temp);
+  /* Fail if a VFP unit isn't present.  */
+  if (!ARM_HAVE_VFP)
+    return 1;
 
-      *flagp = temp & excepts & FE_ALL_EXCEPT;
+  _FPU_GETCW (fpscr);
 
-      /* Success.  */
-      return 0;
-    }
-
-  /* Unsupported, so fail.  */
-  return 1;
+  *flagp = fpscr & excepts & FE_ALL_EXCEPT;
+  return 0;
 }
diff --git a/sysdeps/arm/fraiseexcpt.c b/sysdeps/arm/fraiseexcpt.c
index 8b32065..a964cb0 100644
--- a/sysdeps/arm/fraiseexcpt.c
+++ b/sysdeps/arm/fraiseexcpt.c
@@ -25,9 +25,12 @@
 int
 feraiseexcept (int excepts)
 {
-  if (ARM_HAVE_VFP)
+  /* Fail if a VFP unit isn't present unless nothing needs to be done.  */
+  if (!ARM_HAVE_VFP)
+    return (excepts != 0);
+  else
     {
-      int fpscr;
+      fpu_control_t fpscr;
       const float fp_zero = 0.0, fp_one = 1.0, fp_max = FLT_MAX,
                   fp_min = FLT_MIN, fp_1e32 = 1.0e32f, fp_two = 2.0,
 		  fp_three = 3.0;
@@ -98,9 +101,6 @@ feraiseexcept (int excepts)
       /* Success.  */
       return 0;
     }
-
-  /* Unsupported, so fail unless nothing needs to be done.  */
-  return (excepts != 0);
 }
 
 libm_hidden_def (feraiseexcept)
diff --git a/sysdeps/arm/fsetexcptflg.c b/sysdeps/arm/fsetexcptflg.c
index 7e3d007..1a610ff 100644
--- a/sysdeps/arm/fsetexcptflg.c
+++ b/sysdeps/arm/fsetexcptflg.c
@@ -25,24 +25,19 @@
 int
 fesetexceptflag (const fexcept_t *flagp, int excepts)
 {
-  if (ARM_HAVE_VFP)
-    {
-      fexcept_t temp;
+  fpu_control_t fpscr;
 
-      /* Get the current environment.  */
-      _FPU_GETCW (temp);
+  /* Fail if a VFP unit isn't present unless nothing needs to be done.  */
+  if (!ARM_HAVE_VFP)
+    return (excepts != 0);
 
-      /* Set the desired exception mask.  */
-      temp &= ~(excepts & FE_ALL_EXCEPT);
-      temp |= (*flagp & excepts & FE_ALL_EXCEPT);
+  _FPU_GETCW (fpscr);
 
-      /* Save state back to the FPU.  */
-      _FPU_SETCW (temp);
+  /* Set the desired exception mask.  */
+  fpscr &= ~(excepts & FE_ALL_EXCEPT);
+  fpscr |= (*flagp & excepts & FE_ALL_EXCEPT);
 
-      /* Success.  */
-      return 0;
-    }
-
-  /* Unsupported, so fail unless nothing needs to be done.  */
-  return (excepts != 0);
+  /* Save state back to the FPU.  */
+  _FPU_SETCW (fpscr);
+  return 0;
 }
diff --git a/sysdeps/arm/ftestexcept.c b/sysdeps/arm/ftestexcept.c
index 9295c0f..de082b2 100644
--- a/sysdeps/arm/ftestexcept.c
+++ b/sysdeps/arm/ftestexcept.c
@@ -24,17 +24,15 @@
 int
 fetestexcept (int excepts)
 {
-  if (ARM_HAVE_VFP)
-    {
-      fexcept_t temp;
+  fpu_control_t fpscr;
 
-      /* Get current exceptions.  */
-      _FPU_GETCW(temp);
+  /* Return no exception flags if a VFP unit isn't present.  */
+  if (!ARM_HAVE_VFP)
+    return 0;
 
-      return temp & excepts & FE_ALL_EXCEPT;
-    }
+  /* Get current exceptions.  */
+  _FPU_GETCW (fpscr);
 
-  /* Unsupported, return 0.  */
-  return 0;
+  return fpscr & excepts & FE_ALL_EXCEPT;
 }
 libm_hidden_def (fetestexcept)
diff --git a/sysdeps/arm/get-rounding-mode.h b/sysdeps/arm/get-rounding-mode.h
index 7d6054c..a1ecf51 100644
--- a/sysdeps/arm/get-rounding-mode.h
+++ b/sysdeps/arm/get-rounding-mode.h
@@ -28,15 +28,15 @@
 static inline int
 get_rounding_mode (void)
 {
-  if (ARM_HAVE_VFP)
-    {
-      fpu_control_t fc;
-
-      _FPU_GETCW (fc);
-      return fc & FE_TOWARDZERO;
-    }
-  else
+  fpu_control_t fpscr;
+
+  /* FE_TONEAREST is the only supported rounding mode
+     if a VFP unit isn't present.  */
+  if (!ARM_HAVE_VFP)
     return FE_TONEAREST;
+
+  _FPU_GETCW (fpscr);
+  return fpscr & FE_TOWARDZERO;
 }
 
 #endif /* get-rounding-mode.h */
diff --git a/sysdeps/arm/setfpucw.c b/sysdeps/arm/setfpucw.c
index 92333eb..7416377 100644
--- a/sysdeps/arm/setfpucw.c
+++ b/sysdeps/arm/setfpucw.c
@@ -24,20 +24,19 @@
 void
 __setfpucw (fpu_control_t set)
 {
-  if (ARM_HAVE_VFP)
-    {
-      fpu_control_t cw;
+  fpu_control_t fpscr;
 
-      /* Fetch the current control word.  */
-      _FPU_GETCW (cw);
+  /* Do nothing if a VFP unit isn't present.  */
+  if (!ARM_HAVE_VFP)
+    return;
 
-      /* Preserve the reserved bits, and set the rest as the user
-	 specified (or the default, if the user gave zero).  */
-      cw &= _FPU_RESERVED;
-      cw |= set & ~_FPU_RESERVED;
+  /* Fetch the current control word.  */
+  _FPU_GETCW (fpscr);
 
-      _FPU_SETCW (cw);
-    }
+  /* Preserve the reserved bits, and set the rest as the user
+     specified (or the default, if the user gave zero).  */
+  fpscr &= _FPU_RESERVED;
+  fpscr |= set & ~_FPU_RESERVED;
 
-  /* Do nothing if a VFP unit isn't present.  */
+  _FPU_SETCW (fpscr);
 }

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                       |   37 ++++++++++++++++++++++++++++++++++
 sysdeps/arm/fclrexcpt.c         |   29 ++++++++++----------------
 sysdeps/arm/fedisblxcpt.c       |   26 ++++++++++-------------
 sysdeps/arm/feenablxcpt.c       |   40 ++++++++++++++----------------------
 sysdeps/arm/fegetenv.c          |   21 ++++++++-----------
 sysdeps/arm/fegetexcept.c       |   14 +++++-------
 sysdeps/arm/fegetround.c        |   17 +-------------
 sysdeps/arm/feholdexcpt.c       |   28 +++++--------------------
 sysdeps/arm/fesetenv.c          |   42 ++++++++++++++++++--------------------
 sysdeps/arm/fesetround.c        |   37 ++++++++++------------------------
 sysdeps/arm/feupdateenv.c       |   33 ++++++++++++++++-------------
 sysdeps/arm/fgetexcptflg.c      |   22 +++++--------------
 sysdeps/arm/fraiseexcpt.c       |   10 ++++----
 sysdeps/arm/fsetexcptflg.c      |   28 ++++++++++++-------------
 sysdeps/arm/ftestexcept.c       |   19 +++++------------
 sysdeps/arm/get-rounding-mode.h |   16 +++++++-------
 sysdeps/arm/setfpucw.c          |   24 +++++++++++-----------
 17 files changed, 197 insertions(+), 246 deletions(-)


hooks/post-receive
-- 
GNU C Library master sources


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]