summaryrefslogtreecommitdiffstats
path: root/winsup/mingw/mingwex/feclearexcept.c
diff options
context:
space:
mode:
Diffstat (limited to 'winsup/mingw/mingwex/feclearexcept.c')
-rw-r--r--winsup/mingw/mingwex/feclearexcept.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/winsup/mingw/mingwex/feclearexcept.c b/winsup/mingw/mingwex/feclearexcept.c
index 8c943893b..a68884f41 100644
--- a/winsup/mingw/mingwex/feclearexcept.c
+++ b/winsup/mingw/mingwex/feclearexcept.c
@@ -1,4 +1,5 @@
#include <fenv.h>
+#include "cpu_features.h"
/* 7.6.2.1
The feclearexcept function clears the supported exceptions
@@ -7,9 +8,17 @@
int feclearexcept (int excepts)
{
fenv_t _env;
+ excepts &= FE_ALL_EXCEPT;
__asm__ volatile ("fnstenv %0;" : "=m" (_env)); /* get the env */
- _env.__status_word &= ~(excepts & FE_ALL_EXCEPT); /* clear the except */
+ _env.__status_word &= ~excepts; /* clear the except */
__asm__ volatile ("fldenv %0;" :: "m" (_env)); /*set the env */
+ if (__HAS_SSE)
+ {
+ unsigned _csr;
+ __asm__ volatile("stmxcsr %0" : "=m" (_csr)); /* get the register */
+ _csr &= ~excepts; /* clear the except */
+ __asm__ volatile("ldmxcsr %0" : : "m" (_csr)); /* set the register */
+ }
return 0;
}