aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/i386/fpu/fclrexcpt.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/i386/fpu/fclrexcpt.c')
-rw-r--r--sysdeps/i386/fpu/fclrexcpt.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/sysdeps/i386/fpu/fclrexcpt.c b/sysdeps/i386/fpu/fclrexcpt.c
index c3e7c3ed48..f7ccd3acf6 100644
--- a/sysdeps/i386/fpu/fclrexcpt.c
+++ b/sysdeps/i386/fpu/fclrexcpt.c
@@ -19,6 +19,9 @@
02111-1307 USA. */
#include <fenv.h>
+#include <unistd.h>
+#include <ldsodefs.h>
+#include <dl-procinfo.h>
int
__feclearexcept (int excepts)
@@ -38,6 +41,21 @@ __feclearexcept (int excepts)
/* Put the new data in effect. */
__asm__ ("fldenv %0" : : "m" (*&temp));
+ /* If the CPU supports SSE, we clear the MXCSR as well. */
+ if ((GL(dl_hwcap) & HWCAP_I386_XMM) != 0)
+ {
+ unsigned int xnew_exc;
+
+ /* Get the current MXCSR. */
+ __asm__ ("stmxcsr %0" : "=m" (*&xnew_exc));
+
+ /* Clear the relevant bits. */
+ xnew_exc &= excepts ^ FE_ALL_EXCEPT;
+
+ /* Put the new data in effect. */
+ __asm__ ("ldmxcsr %0" : : "m" (*&xnew_exc));
+ }
+
/* Success. */
return 0;
}