OSDN Git Service

* mingwex/fegetenv.c (fegetenv): Restore exception masks.
authordannysmith <dannysmith>
Sat, 8 Oct 2005 02:14:44 +0000 (02:14 +0000)
committerdannysmith <dannysmith>
Sat, 8 Oct 2005 02:14:44 +0000 (02:14 +0000)
* mingwex/feholdexcept.c (feholdexcept): Don't set exceptions
to non-stop. Use "fnclex" to clear exception flags.

winsup/mingw/ChangeLog
winsup/mingw/mingwex/fegetenv.c
winsup/mingw/mingwex/feholdexcept.c

index f9ac87b..cef73d7 100644 (file)
@@ -1,3 +1,9 @@
+2005-10-08  Danny Smith  <dannysmith@users.sourceforge.net>
+
+       * mingwex/fegetenv.c (fegetenv): Restore exception masks.
+       * mingwex/feholdexcept.c (feholdexcept): Don't set exceptions
+       to non-stop. Use "fnclex" to clear exception flags.
+
 2005-09-24  Danny Smith  <dannysmith@users.sourceforge.net>
 
        * include/math.h (HUGE_VALF, HUGE_VALL, INFINITY, NAN)
index 5ea5bd0..9301056 100644 (file)
@@ -2,11 +2,13 @@
 
 /* 7.6.4.1
    The fegetenv function stores the current floating-point environment
-   in the object pointed to by envp. */
+   in the object pointed to by envp.  */
 
 int fegetenv (fenv_t * envp)
 {
   __asm__ ("fnstenv %0;": "=m" (*envp));
+ /* fnstenv sets control word to non-stop for all exceptions, so we
+    need to reload our env to restore the original mask.  */
+  __asm__ ("fldenv %0" : : "m" (*envp));
   return 0;
 }
-
index df486af..8d4a3f6 100644 (file)
@@ -8,11 +8,9 @@
 
 int feholdexcept (fenv_t * envp)
 {
-  fenv_t tmp_env;
   __asm__ ("fnstenv %0;" : "=m" (* envp)); /* save current into envp */
-  tmp_env = * envp;
-  tmp_env.__status_word &= ~FE_ALL_EXCEPT; /* clear exception flags */
-  tmp_env.__control_word |= FE_ALL_EXCEPT;  /* set cw to non-stop */
-  __asm__ volatile ("fldenv %0;" : : "m" (tmp_env)); /* install the copy */
+ /* fnstenv sets control word to non-stop for all exceptions, so all we
+    need to do is clear the exception flags.  */
+  __asm__ ("fnclex");
   return 0;
 }