[prev in list] [next in list] [prev in thread] [next in thread]
List: wine-devel
Subject: [PATCH v2 4/4] msvcrt: Don't use fegetenv in nearbyintf.
From: Piotr Caban <piotr () codeweavers ! com>
Date: 2022-01-31 20:36:40
Message-ID: 42ca59ad-4073-3e13-09ed-3c24c0970aff () codeweavers ! com
[Download RAW message or body]
Signed-off-by: Piotr Caban <piotr@codeweavers.com>
---
dlls/msvcrt/math.c | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
["0004-msvcrt-Don-t-use-fegetenv-in-nearbyintf.txt" (text/x-patch)]
diff --git a/dlls/msvcrt/math.c b/dlls/msvcrt/math.c
index 3907dc9dc94..b13a4e03fd1 100644
--- a/dlls/msvcrt/math.c
+++ b/dlls/msvcrt/math.c
@@ -6873,13 +6873,25 @@ double CDECL nearbyint(double x)
*/
float CDECL nearbyintf(float x)
{
- fenv_t env;
+ BOOL update_cw, update_sw;
+ unsigned int cw, sw;
- fegetenv(&env);
- _control87(_MCW_EM, _MCW_EM);
+ _setfp(&cw, 0, &sw, 0);
+ 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);
- feclearexcept(FE_INEXACT);
- feupdateenv(&env);
+ if (update_cw || update_sw)
+ {
+ sw = 0;
+ cw &= ~_EM_INEXACT;
+ _setfp(update_cw ? &cw : NULL, _EM_INEXACT,
+ update_sw ? &sw : NULL, _SW_INEXACT);
+ }
return x;
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic