msvcrt: Don't use fegetenv in nearbyintf.

Signed-off-by: Piotr Caban <piotr@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Piotr Caban 2022-01-31 21:36:40 +01:00 committed by Alexandre Julliard
parent 5d9d195f49
commit 201266769d
1 changed files with 17 additions and 5 deletions

View File

@ -6873,13 +6873,25 @@ double CDECL nearbyint(double x)
*/ */
float CDECL nearbyintf(float x) float CDECL nearbyintf(float x)
{ {
fenv_t env; BOOL update_cw, update_sw;
unsigned int cw, sw;
fegetenv(&env); _setfp(&cw, 0, &sw, 0);
_control87(_MCW_EM, _MCW_EM); update_cw = !(cw & _EM_INEXACT);
update_sw = !(sw & _SW_INEXACT);
if (update_cw)
{
cw |= _EM_INEXACT;
_setfp(&cw, _EM_INEXACT, NULL, 0);
}
x = rintf(x); x = rintf(x);
feclearexcept(FE_INEXACT); if (update_cw || update_sw)
feupdateenv(&env); {
sw = 0;
cw &= ~_EM_INEXACT;
_setfp(update_cw ? &cw : NULL, _EM_INEXACT,
update_sw ? &sw : NULL, _SW_INEXACT);
}
return x; return x;
} }