This is the mail archive of the libc-ports@sources.redhat.com mailing list for the libc-ports 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]

PowerPC soft float fesetexceptflag fix


This patch fixes fesetexceptflag, which was clobbering other
exceptions.  I also adjusted where exceptions were raised, based on
my reading of C99.

Checked in, with Steve's approval.

-- 
Daniel Jacobowitz
CodeSourcery

2007-08-29  Daniel Jacobowitz  <dan@codesourcery.com>

	* sysdeps/powerpc/nofpu/fsetexcptflg.c (__fesetexceptflag): Do not
	clobber other exceptions.
	* sysdeps/powerpc/nofpu/feupdateenv.c (__feupdateenv): Raise new
	exceptions.
	* sysdeps/powerpc/nofpu/fraiseexcpt.c (__feraiseexcept): Handle
	multiple new exceptions if some are disabled.
	* sysdeps/powerpc/nofpu/sim-full.c (__simulate_exceptions): Likewise.

Index: sysdeps/powerpc/nofpu/fsetexcptflg.c
===================================================================
--- sysdeps/powerpc/nofpu/fsetexcptflg.c	(revision 179541)
+++ sysdeps/powerpc/nofpu/fsetexcptflg.c	(working copy)
@@ -26,7 +26,7 @@ int
 __fesetexceptflag(const fexcept_t *flagp, int excepts)
 {
   /* Ignore exceptions not listed in 'excepts'.  */
-  __sim_exceptions = *flagp & excepts;
+  __sim_exceptions = (__sim_exceptions & ~excepts) | (*flagp & excepts);
 
   return 0;
 }
Index: sysdeps/powerpc/nofpu/feupdateenv.c
===================================================================
--- sysdeps/powerpc/nofpu/feupdateenv.c	(revision 179541)
+++ sysdeps/powerpc/nofpu/feupdateenv.c	(working copy)
@@ -21,12 +21,12 @@
 
 #include "soft-fp.h"
 #include "soft-supp.h"
+#include <signal.h>
 #include <bp-sym.h>
 
 int
 __feupdateenv (const fenv_t *envp)
 {
-  fenv_union_t u;
   int saved_exceptions;
 
   /* Save currently set exceptions.  */
@@ -37,6 +37,8 @@ __feupdateenv (const fenv_t *envp)
 
   /* Raise old exceptions.  */
   __sim_exceptions |= saved_exceptions;
+  if (saved_exceptions & ~__sim_disabled_exceptions)
+    raise (SIGFPE);
 
   return 0;
 }
Index: sysdeps/powerpc/nofpu/fraiseexcpt.c
===================================================================
--- sysdeps/powerpc/nofpu/fraiseexcpt.c	(revision 179541)
+++ sysdeps/powerpc/nofpu/fraiseexcpt.c	(working copy)
@@ -28,10 +28,7 @@ int
 __feraiseexcept (int x)
 {
   __sim_exceptions |= x;
-  if (x == 0 || __sim_disabled_exceptions & x)
-    /* Ignore exception.  */
-    ;
-  else
+  if (x & ~__sim_disabled_exceptions)
     raise (SIGFPE);
   return 0;
 }
Index: sysdeps/powerpc/nofpu/sim-full.c
===================================================================
--- sysdeps/powerpc/nofpu/sim-full.c	(revision 179541)
+++ sysdeps/powerpc/nofpu/sim-full.c	(working copy)
@@ -37,9 +37,6 @@ void
 __simulate_exceptions (int x)
 {
   __sim_exceptions |= x;
-  if (x == 0 || __sim_disabled_exceptions & x)
-    /* Ignore exception.  */
-    ;
-  else
+  if (x & ~__sim_disabled_exceptions)
     raise (SIGFPE);
 }


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