From 03bdd6d52dd2a5ad5ec35b3bd92431acf0bd8055 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Mon, 3 Apr 2023 17:43:51 +0200 Subject: [PATCH] msvcrt: Use the sinh() implementation from the bundled musl library. With the changes from 11166aa01e7d17f8535977f648c0b5e098d43bd9. --- dlls/msvcrt/math.c | 40 --------------------------------------- libs/musl/src/math/sinh.c | 5 +++++ 2 files changed, 5 insertions(+), 40 deletions(-) diff --git a/dlls/msvcrt/math.c b/dlls/msvcrt/math.c index 8bce6727ac4..5efdc6fc12e 100644 --- a/dlls/msvcrt/math.c +++ b/dlls/msvcrt/math.c @@ -2153,8 +2153,6 @@ double CDECL cos( double x ) } } -extern double __expo2(double x, double sign); - /* Copied from musl: src/math/exp_data.c */ static const UINT64 exp_T[] = { 0x0ULL, 0x3ff0000000000000ULL, @@ -2860,44 +2858,6 @@ double CDECL sin( double x ) } } -/********************************************************************* - * sinh (MSVCRT.@) - */ -double CDECL sinh( double x ) -{ - UINT64 ux = *(UINT64*)&x; - UINT64 sign = ux & 0x8000000000000000ULL; - UINT32 w; - double t, h, absx; - - h = 0.5; - if (ux >> 63) - h = -h; - /* |x| */ - ux &= (UINT64)-1 / 2; - absx = *(double*)&ux; - w = ux >> 32; - - /* |x| < log(DBL_MAX) */ - if (w < 0x40862e42) { - t = expm1(absx); - if (w < 0x3ff00000) { - if (w < 0x3ff00000 - (26 << 20)) - return x; - return h * (2 * t - t * t / (t + 1)); - } - return h * (t + t / (t + 1)); - } - - /* |x| > log(DBL_MAX) or nan */ - /* note: the result is stored to handle overflow */ - if (ux > 0x7ff0000000000000ULL) - *(UINT64*)&t = ux | sign | 0x0008000000000000ULL; - else - t = __expo2(absx, 2 * h); - return t; -} - static BOOL sqrt_validate( double *x, BOOL update_sw ) { short c = _dclass(*x); diff --git a/libs/musl/src/math/sinh.c b/libs/musl/src/math/sinh.c index af3ef8493b1..2d05ba80860 100644 --- a/libs/musl/src/math/sinh.c +++ b/libs/musl/src/math/sinh.c @@ -7,6 +7,7 @@ double __cdecl sinh(double x) { union {double f; uint64_t i;} u = {.f = x}; + uint64_t sign = u.i & 0x8000000000000000ULL; uint32_t w; double t, h, absx; @@ -34,6 +35,10 @@ double __cdecl sinh(double x) /* |x| > log(DBL_MAX) or nan */ /* note: the result is stored to handle overflow */ + if (w > 0x7ff00000) { + u.i |= sign | 0x0008000000000000ULL; + return u.f; + } t = __expo2(absx, 2*h); return t; }