Module: wine Branch: master Commit: 17174db64a81e170a4aa288def3a984879f75b95 URL: https://source.winehq.org/git/wine.git/?a=commit;h=17174db64a81e170a4aa288de...
Author: Piotr Caban piotr@codeweavers.com Date: Tue May 25 15:21:13 2021 +0200
msvcrt: Import asinhf implementation from musl.
Signed-off-by: Piotr Caban piotr@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
configure | 1 - configure.ac | 1 - dlls/msvcrt/math.c | 19 ++++++++++++++++++- dlls/msvcrt/unixlib.c | 13 ------------- dlls/msvcrt/unixlib.h | 1 - include/config.h.in | 3 --- 6 files changed, 18 insertions(+), 20 deletions(-)
diff --git a/configure b/configure index a0510d8a36f..d7b558784fd 100755 --- a/configure +++ b/configure @@ -19617,7 +19617,6 @@ fi
for ac_func in \ asinh \ - asinhf \ atanh \ atanhf \ exp2 \ diff --git a/configure.ac b/configure.ac index 0dd919f1a2c..73afcc9c6d0 100644 --- a/configure.ac +++ b/configure.ac @@ -2657,7 +2657,6 @@ fi
AC_CHECK_FUNCS(\ asinh \ - asinhf \ atanh \ atanhf \ exp2 \ diff --git a/dlls/msvcrt/math.c b/dlls/msvcrt/math.c index 01c0c053aa5..65d01105a45 100644 --- a/dlls/msvcrt/math.c +++ b/dlls/msvcrt/math.c @@ -6577,10 +6577,27 @@ double CDECL asinh(double x)
/********************************************************************* * asinhf (MSVCR120.@) + * + * Copied from musl: src/math/asinhf.c */ float CDECL asinhf(float x) { - return unix_funcs->asinhf( x ); + UINT32 ux = *(UINT32*)&x; + UINT32 i = ux & 0x7fffffff; + int s = ux >> 31; + + /* |x| */ + x = *(float*)&i; + + if (i >= 0x3f800000 + (12 << 23))/* |x| >= 0x1p12 or inf or nan */ + x = logf(x) + 0.693147180559945309417232121458176568f; + else if (i >= 0x3f800000 + (1 << 23)) /* |x| >= 2 */ + x = logf(2 * x + 1 / (sqrtf(x * x + 1) + x)); + else if (i >= 0x3f800000 - (12 << 23)) /* |x| >= 0x1p-12 */ + x = log1pf(x + x * x / (sqrtf(x * x + 1) + 1)); + else /* |x| < 0x1p-12, raise inexact if x!=0 */ + fp_barrierf(x + 0x1p120f); + return s ? -x : x; }
/********************************************************************* diff --git a/dlls/msvcrt/unixlib.c b/dlls/msvcrt/unixlib.c index f51739cf0c9..f937ee5e65e 100644 --- a/dlls/msvcrt/unixlib.c +++ b/dlls/msvcrt/unixlib.c @@ -59,18 +59,6 @@ static double CDECL unix_asinh(double x) #endif }
-/********************************************************************* - * asinhf - */ -static float CDECL unix_asinhf(float x) -{ -#ifdef HAVE_ASINHF - return asinhf(x); -#else - return unix_asinh(x); -#endif -} - /********************************************************************* * atanh */ @@ -423,7 +411,6 @@ static float CDECL unix_tgammaf(float x) static const struct unix_funcs funcs = { unix_asinh, - unix_asinhf, unix_atanh, unix_atanhf, unix_cosh, diff --git a/dlls/msvcrt/unixlib.h b/dlls/msvcrt/unixlib.h index b4275e3750b..6a3732234a2 100644 --- a/dlls/msvcrt/unixlib.h +++ b/dlls/msvcrt/unixlib.h @@ -24,7 +24,6 @@ struct unix_funcs { double (CDECL *asinh)(double x); - float (CDECL *asinhf)(float x); double (CDECL *atanh)(double x); float (CDECL *atanhf)(float x); double (CDECL *cosh)(double x); diff --git a/include/config.h.in b/include/config.h.in index ab6c2bc3381..f44f72c459d 100644 --- a/include/config.h.in +++ b/include/config.h.in @@ -28,9 +28,6 @@ /* Define to 1 if you have the `asinh' function. */ #undef HAVE_ASINH
-/* Define to 1 if you have the `asinhf' function. */ -#undef HAVE_ASINHF - /* Define to 1 if you have the <asm/types.h> header file. */ #undef HAVE_ASM_TYPES_H