about summary refs log tree commit diff
path: root/sysdeps/i386/fpu/fgetexcptflg.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/i386/fpu/fgetexcptflg.c')
-rw-r--r--sysdeps/i386/fpu/fgetexcptflg.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/sysdeps/i386/fpu/fgetexcptflg.c b/sysdeps/i386/fpu/fgetexcptflg.c
index 5f60511b61..1a0e6df63e 100644
--- a/sysdeps/i386/fpu/fgetexcptflg.c
+++ b/sysdeps/i386/fpu/fgetexcptflg.c
@@ -1,5 +1,5 @@
 /* Store current representation for exceptions.
-   Copyright (C) 1997,99,2000,01 Free Software Foundation, Inc.
+   Copyright (C) 1997,99,2000,01,11 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
 
@@ -19,7 +19,10 @@
    02111-1307 USA.  */
 
 #include <fenv.h>
-#include <bp-sym.h>
+#include <unistd.h>
+#include <ldsodefs.h>
+#include <dl-procinfo.h>
+
 
 int
 __fegetexceptflag (fexcept_t *flagp, int excepts)
@@ -31,6 +34,17 @@ __fegetexceptflag (fexcept_t *flagp, int excepts)
 
   *flagp = temp & excepts & FE_ALL_EXCEPT;
 
+  /* If the CPU supports SSE, we clear the MXCSR as well.  */
+  if ((GLRO(dl_hwcap) & HWCAP_I386_XMM) != 0)
+    {
+      unsigned int sse_exc;
+
+      /* Get the current MXCSR.  */
+      __asm__ ("stmxcsr %0" : "=m" (*&sse_exc));
+
+      *flagp |= sse_exc & excepts & FE_ALL_EXCEPT;
+    }
+
   /* Success.  */
   return 0;
 }
@@ -38,7 +52,7 @@ __fegetexceptflag (fexcept_t *flagp, int excepts)
 #include <shlib-compat.h>
 #if SHLIB_COMPAT (libm, GLIBC_2_1, GLIBC_2_2)
 strong_alias (__fegetexceptflag, __old_fegetexceptflag)
-compat_symbol (libm, BP_SYM (__old_fegetexceptflag), BP_SYM (fegetexceptflag), GLIBC_2_1);
+compat_symbol (libm, __old_fegetexceptflag, fegetexceptflag, GLIBC_2_1);
 #endif
 
-versioned_symbol (libm, BP_SYM (__fegetexceptflag), BP_SYM (fegetexceptflag), GLIBC_2_2);
+versioned_symbol (libm, __fegetexceptflag, fegetexceptflag, GLIBC_2_2);