3 #include "cpu_features.h"
6 The fesetenv function establishes the floating-point environment
7 represented by the object pointed to by envp. The argument envp
8 points to an object set by a call to fegetenv or feholdexcept, or
9 equal the macro FE_DFL_ENV or an implementation-defined environment
10 macro. Note that fesetenv merely installs the state of the exception
11 flags represented through its argument, and does not raise these
15 extern void (*_imp___fpreset)( void ) ;
17 int fesetenv (const fenv_t * envp)
19 /* Default mxcsr status is to mask all exceptions. All other bits
22 unsigned int _csr = FE_ALL_EXCEPT << __MXCSR_EXCEPT_MASK_SHIFT /*= 0x1f80 */;
24 if (envp == FE_PC64_ENV)
26 * fninit initializes the control register to 0x37f,
27 * the status register to zero and the tag word to 0FFFFh.
28 * The other registers are unaffected.
32 else if (envp == FE_PC53_ENV)
34 * MS _fpreset() does same *except* it sets control word
35 * to 0x27f (53-bit precison).
36 * We force calling _fpreset in msvcrt.dll
41 else if (envp == FE_DFL_ENV)
42 /* Use the choice made at app startup */
47 __asm__ ("fldenv %0;" : : "m" (*envp));
48 /* Setting the reserved high order bits of MXCSR causes a segfault */
49 _csr = envp ->__mxcsr & 0xffff;
54 __asm__ volatile ("ldmxcsr %0" : : "m" (_csr));