msvcrt: Use the sinh() implementation from the bundled musl library.

With the changes from 11166aa01e.
This commit is contained in:
Alexandre Julliard 2023-04-03 17:43:51 +02:00
parent 9fd9ebcb7a
commit 03bdd6d52d
2 changed files with 5 additions and 40 deletions

View file

@ -2153,8 +2153,6 @@ double CDECL cos( double x )
} }
} }
extern double __expo2(double x, double sign);
/* Copied from musl: src/math/exp_data.c */ /* Copied from musl: src/math/exp_data.c */
static const UINT64 exp_T[] = { static const UINT64 exp_T[] = {
0x0ULL, 0x3ff0000000000000ULL, 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 ) static BOOL sqrt_validate( double *x, BOOL update_sw )
{ {
short c = _dclass(*x); short c = _dclass(*x);

View file

@ -7,6 +7,7 @@
double __cdecl sinh(double x) double __cdecl sinh(double x)
{ {
union {double f; uint64_t i;} u = {.f = x}; union {double f; uint64_t i;} u = {.f = x};
uint64_t sign = u.i & 0x8000000000000000ULL;
uint32_t w; uint32_t w;
double t, h, absx; double t, h, absx;
@ -34,6 +35,10 @@ double __cdecl sinh(double x)
/* |x| > log(DBL_MAX) or nan */ /* |x| > log(DBL_MAX) or nan */
/* note: the result is stored to handle overflow */ /* note: the result is stored to handle overflow */
if (w > 0x7ff00000) {
u.i |= sign | 0x0008000000000000ULL;
return u.f;
}
t = __expo2(absx, 2*h); t = __expo2(absx, 2*h);
return t; return t;
} }