Module: wine Branch: master Commit: bc9105e238a076da6e22e0df77a6de6a6f3cd0a7 URL: https://source.winehq.org/git/wine.git/?a=commit;h=bc9105e238a076da6e22e0df7...
Author: Piotr Caban piotr@codeweavers.com Date: Tue May 25 15:21:10 2021 +0200
msvcrt: Import acosh 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 | 12 +++++++++++- dlls/msvcrt/unixlib.c | 14 -------------- dlls/msvcrt/unixlib.h | 1 - include/config.h.in | 3 --- 6 files changed, 11 insertions(+), 21 deletions(-)
diff --git a/configure b/configure index 3f1fc453e34..a0510d8a36f 100755 --- a/configure +++ b/configure @@ -19616,7 +19616,6 @@ $as_echo "#define HAVE_ISNAN 1" >>confdefs.h fi
for ac_func in \ - acosh \ asinh \ asinhf \ atanh \ diff --git a/configure.ac b/configure.ac index e1989cc2868..0dd919f1a2c 100644 --- a/configure.ac +++ b/configure.ac @@ -2656,7 +2656,6 @@ then fi
AC_CHECK_FUNCS(\ - acosh \ asinh \ asinhf \ atanh \ diff --git a/dlls/msvcrt/math.c b/dlls/msvcrt/math.c index 01c50800567..01c0c053aa5 100644 --- a/dlls/msvcrt/math.c +++ b/dlls/msvcrt/math.c @@ -6585,16 +6585,26 @@ float CDECL asinhf(float x)
/********************************************************************* * acosh (MSVCR120.@) + * + * Copied from musl: src/math/acosh.c */ double CDECL acosh(double x) { + int e = *(UINT64*)&x >> 52 & 0x7ff; + if (x < 1) { *_errno() = EDOM; feraiseexcept(FE_INVALID); return NAN; } - return unix_funcs->acosh( x ); + + if (e < 0x3ff + 1) /* |x| < 2, up to 2ulp error in [1,1.125] */ + return log1p(x - 1 + sqrt((x - 1) * (x - 1) + 2 * (x - 1))); + if (e < 0x3ff + 26) /* |x| < 0x1p26 */ + return log(2 * x - 1 / (x + sqrt(x * x - 1))); + /* |x| >= 0x1p26 or nan */ + return log(x) + 0.693147180559945309417232121458176568; }
/********************************************************************* diff --git a/dlls/msvcrt/unixlib.c b/dlls/msvcrt/unixlib.c index efd3021aa59..f51739cf0c9 100644 --- a/dlls/msvcrt/unixlib.c +++ b/dlls/msvcrt/unixlib.c @@ -42,19 +42,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
-/********************************************************************* - * acosh - */ -static double CDECL unix_acosh(double x) -{ -#ifdef HAVE_ACOSH - return acosh(x); -#else - if (!isfinite(x*x)) return log(2) + log(x); - return log(x + sqrt(x*x-1)); -#endif -} - /********************************************************************* * asinh */ @@ -435,7 +422,6 @@ static float CDECL unix_tgammaf(float x)
static const struct unix_funcs funcs = { - unix_acosh, unix_asinh, unix_asinhf, unix_atanh, diff --git a/dlls/msvcrt/unixlib.h b/dlls/msvcrt/unixlib.h index 2f171339d30..b4275e3750b 100644 --- a/dlls/msvcrt/unixlib.h +++ b/dlls/msvcrt/unixlib.h @@ -23,7 +23,6 @@
struct unix_funcs { - double (CDECL *acosh)(double x); double (CDECL *asinh)(double x); float (CDECL *asinhf)(float x); double (CDECL *atanh)(double x); diff --git a/include/config.h.in b/include/config.h.in index b94337818ca..ab6c2bc3381 100644 --- a/include/config.h.in +++ b/include/config.h.in @@ -9,9 +9,6 @@ /* Define to the file extension for executables. */ #undef EXEEXT
-/* Define to 1 if you have the `acosh' function. */ -#undef HAVE_ACOSH - /* Define to 1 if you have the <alias.h> header file. */ #undef HAVE_ALIAS_H