about summary refs log tree commit diff
path: root/sysdeps/i386/fpu/feenablxcpt.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/i386/fpu/feenablxcpt.c')
-rw-r--r--sysdeps/i386/fpu/feenablxcpt.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/sysdeps/i386/fpu/feenablxcpt.c b/sysdeps/i386/fpu/feenablxcpt.c
index a672d0e821..65a0a2944c 100644
--- a/sysdeps/i386/fpu/feenablxcpt.c
+++ b/sysdeps/i386/fpu/feenablxcpt.c
@@ -1,5 +1,5 @@
 /* Enable floating-point exceptions.
-   Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2000, 2003 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Andreas Jaeger <aj@suse.de>, 1999.
 
@@ -19,11 +19,15 @@
    02111-1307 USA.  */
 
 #include <fenv.h>
+#include <unistd.h>
+#include <ldsodefs.h>
+#include <dl-procinfo.h>
 
 int
 feenableexcept (int excepts)
 {
-  unsigned short int new_exc, old_exc;
+  unsigned short int new_exc;
+  unsigned short int old_exc;
 
   /* Get the current control word.  */
   __asm__ ("fstcw %0" : "=m" (*&new_exc));
@@ -34,5 +38,18 @@ feenableexcept (int excepts)
   new_exc &= ~excepts;
   __asm__ ("fldcw %0" : : "m" (*&new_exc));
 
+  /* If the CPU supports SSE we set the MXCSR as well.  */
+  if ((GL(dl_hwcap_mask) & HWCAP_I386_XMM) != 0)
+    {
+      unsigned int xnew_exc;
+
+      /* Get the current control word.  */
+      __asm__ ("ldmxcsr %0" : "=m" (*&xnew_exc));
+
+      xnew_exc &= ~excepts;
+
+      __asm__ ("stmxcsr %0" : : "m" (*&xnew_exc));
+    }
+
   return old_exc;
 }