mirror of
https://github.com/wine-mirror/wine
synced 2024-07-09 04:16:08 +00:00
msvcrt: Use the cosh() implementation from the bundled musl library.
With the changes from 60d178b410
.
This commit is contained in:
parent
66bef6db20
commit
9fd9ebcb7a
|
@ -2155,49 +2155,6 @@ double CDECL cos( double x )
|
|||
|
||||
extern double __expo2(double x, double sign);
|
||||
|
||||
/*********************************************************************
|
||||
* cosh (MSVCRT.@)
|
||||
*
|
||||
* Copied from musl: src/math/cosh.c
|
||||
*/
|
||||
double CDECL cosh( double x )
|
||||
{
|
||||
UINT64 ux = *(UINT64*)&x;
|
||||
UINT64 sign = ux & 0x8000000000000000ULL;
|
||||
UINT32 w;
|
||||
double t;
|
||||
|
||||
/* |x| */
|
||||
ux &= (uint64_t)-1 / 2;
|
||||
x = *(double*)&ux;
|
||||
w = ux >> 32;
|
||||
|
||||
/* |x| < log(2) */
|
||||
if (w < 0x3fe62e42) {
|
||||
if (w < 0x3ff00000 - (26 << 20)) {
|
||||
fp_barrier(x + 0x1p120f);
|
||||
return 1;
|
||||
}
|
||||
t = expm1(x);
|
||||
return 1 + t * t / (2 * (1 + t));
|
||||
}
|
||||
|
||||
/* |x| < log(DBL_MAX) */
|
||||
if (w < 0x40862e42) {
|
||||
t = exp(x);
|
||||
/* note: if x>log(0x1p26) then the 1/t is not needed */
|
||||
return 0.5 * (t + 1 / t);
|
||||
}
|
||||
|
||||
/* |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(x, 1.0);
|
||||
return t;
|
||||
}
|
||||
|
||||
/* Copied from musl: src/math/exp_data.c */
|
||||
static const UINT64 exp_T[] = {
|
||||
0x0ULL, 0x3ff0000000000000ULL,
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
double __cdecl cosh(double x)
|
||||
{
|
||||
union {double f; uint64_t i;} u = {.f = x};
|
||||
uint64_t sign = u.i & 0x8000000000000000ULL;
|
||||
uint32_t w;
|
||||
double t;
|
||||
|
||||
|
@ -35,6 +36,10 @@ double __cdecl cosh(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(x, 1.0);
|
||||
return t;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user