about summary refs log tree commit diff
path: root/sysdeps/i386/fpu/fesetround.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/i386/fpu/fesetround.c')
-rw-r--r--sysdeps/i386/fpu/fesetround.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/sysdeps/i386/fpu/fesetround.c b/sysdeps/i386/fpu/fesetround.c
index 342ae49c60..342ed42318 100644
--- a/sysdeps/i386/fpu/fesetround.c
+++ b/sysdeps/i386/fpu/fesetround.c
@@ -1,5 +1,5 @@
 /* Set current rounding direction.
-   Copyright (C) 1997 Free Software Foundation, Inc.
+   Copyright (C) 1997, 2003 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
 
@@ -19,6 +19,9 @@
    02111-1307 USA.  */
 
 #include <fenv.h>
+#include <unistd.h>
+#include <ldsodefs.h>
+#include <dl-procinfo.h>
 
 int
 fesetround (int round)
@@ -34,5 +37,16 @@ fesetround (int round)
   cw |= round;
   __asm__ ("fldcw %0" : : "m" (*&cw));
 
+  /* If the CPU supports SSE we set the MXCSR as well.  */
+  if ((GL(dl_hwcap_mask) & HWCAP_I386_XMM) != 0)
+    {
+      unsigned int xcw;
+
+      __asm__ ("stmxcsr %0" : "=m" (*&xcw));
+      cw &= ~0x6000;
+      cw |= round << 3;
+      __asm__ ("ldmxcsr %0" : : "m" (*&xcw));
+    }
+
   return 0;
 }