https://gitlab.winehq.org/wine/wine/-/merge_requests/7748#note_105461
huge thanks to @bernhardu for narrowing it down. does this work for you?
-- v2: libs/musl: Base rounding constant on precision mode.
From: Daniel Lehman dlehman25@gmail.com
--- dlls/ntdll/math.c | 5 +++++ libs/musl/src/math/rint.c | 13 +++++-------- 2 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/dlls/ntdll/math.c b/dlls/ntdll/math.c index 73a5bb8cd33..2d0d593a7d1 100644 --- a/dlls/ntdll/math.c +++ b/dlls/ntdll/math.c @@ -30,6 +30,11 @@ double math_error( int type, const char *name, double arg1, double arg2, double return retval; }
+unsigned int __cdecl _control87(unsigned int, unsigned int) +{ + return 0; +} + /********************************************************************* * abs (NTDLL.@) */ diff --git a/libs/musl/src/math/rint.c b/libs/musl/src/math/rint.c index ad35201b266..dbe353caaf9 100644 --- a/libs/musl/src/math/rint.c +++ b/libs/musl/src/math/rint.c @@ -3,22 +3,19 @@ #include <stdint.h> #include "libm.h"
-#if FLT_EVAL_METHOD==0 || FLT_EVAL_METHOD==1 -#define EPS DBL_EPSILON -#elif FLT_EVAL_METHOD==2 -#define EPS LDBL_EPSILON -#endif -static const double_t toint = 1/EPS; - double __cdecl rint(double x) { union {double f; uint64_t i;} u = {x}; int e = u.i>>52 & 0x7ff; int s = u.i>>63; - double_t y; + double_t y, toint;
if (e >= 0x3ff+52) return x; + + if ((_control87(0, 0) & _MCW_PC) == _PC_24) toint = 1 / FLT_EPSILON; + else toint = 1 / DBL_EPSILON; + if (s) y = fp_barrier(x - toint) + toint; else
latest tested with 78bc12338556d7aa2e970df9121755618d568dcf reverted