From eb92c487b35e26aa1e08815c4480d0bc5cc9f370 Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Sat, 10 Mar 2012 08:55:53 -0800 Subject: Create and use SET_RESTORE_ROUND{,_NOEX,_53BIT}{,F,L}. --- sysdeps/x86_64/fpu/math_private.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'sysdeps/x86_64') diff --git a/sysdeps/x86_64/fpu/math_private.h b/sysdeps/x86_64/fpu/math_private.h index 8b1fe70d2c..3289afc58b 100644 --- a/sysdeps/x86_64/fpu/math_private.h +++ b/sysdeps/x86_64/fpu/math_private.h @@ -119,6 +119,29 @@ libc_feupdateenv (fenv_t *e) #define libc_feupdateenv libc_feupdateenv #define libc_feupdateenvf libc_feupdateenv +static __always_inline void +libc_feholdsetround (fenv_t *e, int r) +{ + unsigned int mxcsr; + asm (STMXCSR " %0" : "=m" (*&mxcsr)); + e->__mxcsr = mxcsr; + mxcsr = (mxcsr & ~0x6000) | (r << 3); + asm volatile (LDMXCSR " %0" : : "m" (*&mxcsr)); +} +#define libc_feholdsetround libc_feholdsetround +#define libc_feholdsetroundf libc_feholdsetround + +static __always_inline void +libc_feresetround (fenv_t *e) +{ + unsigned int mxcsr; + asm (STMXCSR " %0" : "=m" (*&mxcsr)); + mxcsr = (mxcsr & ~0x6000) | (e->__mxcsr & 0x6000); + asm volatile (LDMXCSR " %0" : : "m" (*&mxcsr)); +} +#define libc_feresetround libc_feresetround +#define libc_feresetroundf libc_feresetround + #include_next extern __always_inline double -- cgit v1.2.3