msvcrt: Import asinh implementation from musl.

Signed-off-by: Piotr Caban <piotr@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Piotr Caban 2021-05-25 15:21:15 +02:00 committed by Alexandre Julliard
parent 17174db64a
commit da55a453d1
6 changed files with 19 additions and 25 deletions

1
configure vendored
View File

@ -19616,7 +19616,6 @@ $as_echo "#define HAVE_ISNAN 1" >>confdefs.h
fi
for ac_func in \
asinh \
atanh \
atanhf \
exp2 \

View File

@ -2656,7 +2656,6 @@ then
fi
AC_CHECK_FUNCS(\
asinh \
atanh \
atanhf \
exp2 \

View File

@ -6569,10 +6569,28 @@ double CDECL fmin(double x, double y)
/*********************************************************************
* asinh (MSVCR120.@)
*
* Copied from musl: src/math/asinh.c
*/
double CDECL asinh(double x)
{
return unix_funcs->asinh( x );
UINT64 ux = *(UINT64*)&x;
int e = ux >> 52 & 0x7ff;
int s = ux >> 63;
/* |x| */
ux &= (UINT64)-1 / 2;
x = *(double*)&ux;
if (e >= 0x3ff + 26) /* |x| >= 0x1p26 or inf or nan */
x = log(x) + 0.693147180559945309417232121458176568;
else if (e >= 0x3ff + 1) /* |x| >= 2 */
x = log(2 * x + 1 / (sqrt(x * x + 1) + x));
else if (e >= 0x3ff - 26) /* |x| >= 0x1p-26 */
x = log1p(x + x * x / (sqrt(x * x + 1) + 1));
else /* |x| < 0x1p-26, raise inexact if x != 0 */
fp_barrier(x + 0x1p120f);
return s ? -x : x;
}
/*********************************************************************

View File

@ -42,23 +42,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
/*********************************************************************
* asinh
*/
static double CDECL unix_asinh(double x)
{
#ifdef HAVE_ASINH
return asinh(x);
#else
if (!isfinite(x*x+1))
{
if (x > 0) return log(2) + log(x);
else return -log(2) - log(-x);
}
return log(x + sqrt(x*x+1));
#endif
}
/*********************************************************************
* atanh
*/
@ -410,7 +393,6 @@ static float CDECL unix_tgammaf(float x)
static const struct unix_funcs funcs =
{
unix_asinh,
unix_atanh,
unix_atanhf,
unix_cosh,

View File

@ -23,7 +23,6 @@
struct unix_funcs
{
double (CDECL *asinh)(double x);
double (CDECL *atanh)(double x);
float (CDECL *atanhf)(float x);
double (CDECL *cosh)(double x);

View File

@ -25,9 +25,6 @@
/* Define to 1 if you have the <arpa/nameser.h> header file. */
#undef HAVE_ARPA_NAMESER_H
/* Define to 1 if you have the `asinh' function. */
#undef HAVE_ASINH
/* Define to 1 if you have the <asm/types.h> header file. */
#undef HAVE_ASM_TYPES_H