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-656-gdb59bad


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  db59bad394ef61bf6d6ef7916012f2a09d0b3d11 (commit)
      from  001f7b773c637560ecfa686452a5e68d60d07db3 (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=db59bad394ef61bf6d6ef7916012f2a09d0b3d11

commit db59bad394ef61bf6d6ef7916012f2a09d0b3d11
Author: Wilco <wdijkstr@arm.com>
Date:   Tue Jun 24 13:53:04 2014 +0000

    Rewrite feupdateenv
    
    This patch rewrites feupdateenv to improve performance by avoiding
    unnecessary FPSCR reads/writes. It fixes bug 16918 by passing the
    correct return value.
    
    2014-06-24  Wilco  <wdijkstr@arm.com>
    
    	[BZ #16918]
    	* sysdeps/arm/feupdateenv.c (feupdateenv):
    	Rewrite to reduce FPSCR accesses and fix return value.

diff --git a/ChangeLog b/ChangeLog
index 0b0f61a..3330b0b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2014-06-24  Wilco  <wdijkstr@arm.com>
 
+	[BZ #16918]
+	* sysdeps/arm/feupdateenv.c (feupdateenv):
+	Rewrite to reduce FPSCR accesses and fix return value.
+
+2014-06-24  Wilco  <wdijkstr@arm.com>
+
 	* sysdeps/arm/fclrexcpt.c (feclearexcept):
 	Optimize to avoid unnecessary FPSCR writes.
 	* sysdeps/arm/fedisblxcpt.c (fedisableexcept): Likewise.
diff --git a/sysdeps/arm/feupdateenv.c b/sysdeps/arm/feupdateenv.c
index 55a1502..d811678 100644
--- a/sysdeps/arm/feupdateenv.c
+++ b/sysdeps/arm/feupdateenv.c
@@ -18,26 +18,58 @@
    <http://www.gnu.org/licenses/>.  */
 
 #include <fenv.h>
-#include <fpu_control.h>
 #include <arm-features.h>
 
 
 int
 feupdateenv (const fenv_t *envp)
 {
-  fpu_control_t fpscr;
+  fpu_control_t fpscr, new_fpscr, updated_fpscr;
+  int excepts;
 
   /* Fail if a VFP unit isn't present.  */
   if (!ARM_HAVE_VFP)
     return 1;
 
   _FPU_GETCW (fpscr);
+  excepts = fpscr & FE_ALL_EXCEPT;
 
-  /* Install new environment.  */
-  fesetenv (envp);
+  if ((envp != FE_DFL_ENV) && (envp != FE_NOMASK_ENV))
+    {
+      /* Merge current exception flags with the saved fenv.  */
+      new_fpscr = envp->__cw | excepts;
+
+      /* Write new FPSCR if different (ignoring NZCV flags).  */
+      if (((fpscr ^ new_fpscr) & ~_FPU_MASK_NZCV) != 0)
+	_FPU_SETCW (new_fpscr);
+
+      /* Raise the exceptions if enabled in the new FP state.  */
+      if (excepts & (new_fpscr >> FE_EXCEPT_SHIFT))
+	return feraiseexcept (excepts);
+
+      return 0;
+    }
+
+  /* Preserve the reserved FPSCR flags.  */
+  new_fpscr = fpscr & (_FPU_RESERVED | FE_ALL_EXCEPT);
+  new_fpscr |= (envp == FE_DFL_ENV) ? _FPU_DEFAULT : _FPU_IEEE;
+
+  if (((new_fpscr ^ fpscr) & ~_FPU_MASK_NZCV) != 0)
+    {
+      _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 (updated_fpscr);
+
+      if (new_fpscr & ~updated_fpscr)
+	return 1;
+    }
+
+  /* Raise the exceptions if enabled in the new FP state.  */
+  if (excepts & (new_fpscr >> FE_EXCEPT_SHIFT))
+    return feraiseexcept (excepts);
 
-  /* Raise the saved exceptions.  */
-  feraiseexcept (fpscr & FE_ALL_EXCEPT);
   return 0;
 }
 libm_hidden_def (feupdateenv)

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

Summary of changes:
 ChangeLog                 |    6 ++++++
 sysdeps/arm/feupdateenv.c |   44 ++++++++++++++++++++++++++++++++++++++------
 2 files changed, 44 insertions(+), 6 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]