Module: wine Branch: master Commit: 07ec052e5423f6bbacc2bac0c5684211cecca04f URL: https://source.winehq.org/git/wine.git/?a=commit;h=07ec052e5423f6bbacc2bac0c...
Author: Martin Storsjo martin@martin.st Date: Wed Jul 28 14:42:19 2021 +0200
msvcrt: Make the tanh function NAN preserving.
Signed-off-by: Martin Storsjo martin@martin.st Signed-off-by: Piotr Caban piotr@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/msvcrt/math.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/dlls/msvcrt/math.c b/dlls/msvcrt/math.c index a2b03110cf0..69b807f722c 100644 --- a/dlls/msvcrt/math.c +++ b/dlls/msvcrt/math.c @@ -4336,12 +4336,11 @@ double CDECL tan( double x ) double CDECL tanh( double x ) { UINT64 ui = *(UINT64*)&x; + UINT64 sign = ui & 0x8000000000000000ULL; UINT32 w; - int sign; double t;
/* x = |x| */ - sign = ui >> 63; ui &= (UINT64)-1 / 2; x = *(double*)&ui; w = ui >> 32; @@ -4349,11 +4348,15 @@ double CDECL tanh( double x ) if (w > 0x3fe193ea) { /* |x| > log(3)/2 ~= 0.5493 or nan */ if (w > 0x40340000) { + if (ui > 0x7ff0000000000000ULL) { + *(UINT64*)&x = ui | sign | 0x0008000000000000ULL; #if _MSVCR_VER < 140 - if (isnan(x)) return math_error(_DOMAIN, "tanh", x, 0, x); +#else + return x; #endif - /* |x| > 20 or nan */ + } + /* |x| > 20 */ /* note: this branch avoids raising overflow */ fp_barrier(x + 0x1p120f); t = 1 - 0 / x;