2
* This file has no copyright assigned and is placed in the Public Domain.
3
* This file is part of the w64 mingw-runtime package.
4
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
10
extern int __mingw_has_sse (void);
13
The fesetenv function establishes the floating-point environment
14
represented by the object pointed to by envp. The argument envp
15
points to an object set by a call to fegetenv or feholdexcept, or
16
equal the macro FE_DFL_ENV or an implementation-defined environment
17
macro. Note that fesetenv merely installs the state of the exception
18
flags represented through its argument, and does not raise these
22
extern void (* __MINGW_IMP_SYMBOL(_fpreset))(void);
23
extern void _fpreset(void);
25
int fesetenv (const fenv_t * envp)
27
if (envp == FE_PC64_ENV)
29
* fninit initializes the control register to 0x37f,
30
* the status register to zero and the tag word to 0FFFFh.
31
* The other registers are unaffected.
33
__asm__ __volatile__ ("fninit");
35
else if (envp == FE_PC53_ENV)
37
* MS _fpreset() does same *except* it sets control word
38
* to 0x27f (53-bit precison).
39
* We force calling _fpreset in msvcrt.dll
42
(* __MINGW_IMP_SYMBOL(_fpreset))();
44
else if (envp == FE_DFL_ENV)
45
/* Use the choice made at app startup */
52
_mxcsr = (env.__unused0 << 16) | env.__unused1; /* mxcsr low and high */
53
env.__unused0 = 0xffff;
54
env.__unused1 = 0xffff;
55
__asm__ volatile ("fldenv %0" : : "m" (env)
56
: "st", "st(1)", "st(2)", "st(3)", "st(4)",
57
"st(5)", "st(6)", "st(7)");
58
if (__mingw_has_sse ())
59
__asm__ volatile ("ldmxcsr %0" : : "m" (_mxcsr));