From a1745937224b08b365b1fbc9e661fa859aa4da71 Mon Sep 17 00:00:00 2001 From: Danny Smith Date: Sat, 8 Oct 2005 02:14:45 +0000 Subject: [PATCH] * mingwex/fegetenv.c (fegetenv): Restore exception masks. * mingwex/feholdexcept.c (feholdexcept): Don't set exceptions to non-stop. Use "fnclex" to clear exception flags. --- winsup/mingw/ChangeLog | 6 ++++++ winsup/mingw/mingwex/fegetenv.c | 6 ++++-- winsup/mingw/mingwex/feholdexcept.c | 8 +++----- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/winsup/mingw/ChangeLog b/winsup/mingw/ChangeLog index f9ac87b32..cef73d702 100644 --- a/winsup/mingw/ChangeLog +++ b/winsup/mingw/ChangeLog @@ -1,3 +1,9 @@ +2005-10-08 Danny Smith + + * 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 * include/math.h (HUGE_VALF, HUGE_VALL, INFINITY, NAN) diff --git a/winsup/mingw/mingwex/fegetenv.c b/winsup/mingw/mingwex/fegetenv.c index 5ea5bd011..930105673 100644 --- a/winsup/mingw/mingwex/fegetenv.c +++ b/winsup/mingw/mingwex/fegetenv.c @@ -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; } - diff --git a/winsup/mingw/mingwex/feholdexcept.c b/winsup/mingw/mingwex/feholdexcept.c index df486afb3..8d4a3f67b 100644 --- a/winsup/mingw/mingwex/feholdexcept.c +++ b/winsup/mingw/mingwex/feholdexcept.c @@ -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; }