From ba53c0691627e8b3f481e6e7572ec56ea29b3604 Mon Sep 17 00:00:00 2001 From: dannysmith Date: Sat, 8 Oct 2005 02:14:44 +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 f9ac87b321..cef73d7028 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 5ea5bd011f..9301056734 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 df486afb3a..8d4a3f67b1 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; } -- 2.11.0