aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/i386/fpu/fsetexcptflg.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/i386/fpu/fsetexcptflg.c')
-rw-r--r--sysdeps/i386/fpu/fsetexcptflg.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/sysdeps/i386/fpu/fsetexcptflg.c b/sysdeps/i386/fpu/fsetexcptflg.c
index 2bfc736054..d262738b68 100644
--- a/sysdeps/i386/fpu/fsetexcptflg.c
+++ b/sysdeps/i386/fpu/fsetexcptflg.c
@@ -21,6 +21,9 @@
#include <fenv.h>
#include <math.h>
#include <bp-sym.h>
+#include <unistd.h>
+#include <ldsodefs.h>
+#include <dl-procinfo.h>
int
__fesetexceptflag (const fexcept_t *flagp, int excepts)
@@ -39,6 +42,22 @@ __fesetexceptflag (const fexcept_t *flagp, int excepts)
the next floating-point instruction. */
__asm__ ("fldenv %0" : : "m" (*&temp));
+ /* If the CPU supports SSE, we set 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));
+
+ /* Set the relevant bits. */
+ xnew_exc &= ~(excepts & FE_ALL_EXCEPT);
+ xnew_exc |= *flagp & excepts & FE_ALL_EXCEPT;
+
+ /* Put the new data in effect. */
+ __asm__ ("ldmxcsr %0" : : "m" (*&xnew_exc));
+ }
+
/* Success. */
return 0;
}