Piotr Caban : msvcrt: Import acoshf implementation from musl.

Alexandre Julliard julliard at winehq.org
Tue May 25 16:08:16 CDT 2021


Module: wine
Branch: master
Commit: 75537f43752c9cceef2f02d1f13e9f1b245840c1
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=75537f43752c9cceef2f02d1f13e9f1b245840c1

Author: Piotr Caban <piotr at codeweavers.com>
Date:   Tue May 25 15:21:06 2021 +0200

msvcrt: Import acoshf implementation from musl.

Signed-off-by: Piotr Caban <piotr at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 configure             |  1 -
 configure.ac          |  1 -
 dlls/msvcrt/math.c    | 12 +++++++++++-
 dlls/msvcrt/unixlib.c | 13 -------------
 dlls/msvcrt/unixlib.h |  1 -
 include/config.h.in   |  3 ---
 6 files changed, 11 insertions(+), 20 deletions(-)

diff --git a/configure b/configure
index 0de80eca5ee..3f1fc453e34 100755
--- a/configure
+++ b/configure
@@ -19617,7 +19617,6 @@ fi
 
 for ac_func in \
 	acosh \
-	acoshf \
 	asinh \
 	asinhf \
 	atanh \
diff --git a/configure.ac b/configure.ac
index c144fa1bbdd..e1989cc2868 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2657,7 +2657,6 @@ fi
 
 AC_CHECK_FUNCS(\
 	acosh \
-	acoshf \
 	asinh \
 	asinhf \
 	atanh \
diff --git a/dlls/msvcrt/math.c b/dlls/msvcrt/math.c
index 811fce1531d..01c50800567 100644
--- a/dlls/msvcrt/math.c
+++ b/dlls/msvcrt/math.c
@@ -6599,16 +6599,26 @@ double CDECL acosh(double x)
 
 /*********************************************************************
  *      acoshf (MSVCR120.@)
+ *
+ * Copied from musl: src/math/acoshf.c
  */
 float CDECL acoshf(float x)
 {
+    UINT32 a = *(UINT32*)&x & 0x7fffffff;
+
     if (x < 1)
     {
         *_errno() = EDOM;
         feraiseexcept(FE_INVALID);
         return NAN;
     }
-    return unix_funcs->acoshf( x );
+
+    if (a < 0x3f800000 + (1 << 23)) /* |x| < 2, up to 2ulp error in [1,1.125] */
+        return log1pf(x - 1 + sqrtf((x - 1) * (x - 1) + 2 * (x - 1)));
+    if (*(UINT32*)&x < 0x3f800000 + (12 << 23)) /* 2 <= x < 0x1p12 */
+        return logf(2 * x - 1 / (x + sqrtf(x * x - 1)));
+    /* x >= 0x1p12 or x <= -2 or nan */
+    return logf(x) + 0.693147180559945309417232121458176568f;
 }
 
 /*********************************************************************
diff --git a/dlls/msvcrt/unixlib.c b/dlls/msvcrt/unixlib.c
index c69ca440504..efd3021aa59 100644
--- a/dlls/msvcrt/unixlib.c
+++ b/dlls/msvcrt/unixlib.c
@@ -55,18 +55,6 @@ static double CDECL unix_acosh(double x)
 #endif
 }
 
-/*********************************************************************
- *      acoshf
- */
-static float CDECL unix_acoshf(float x)
-{
-#ifdef HAVE_ACOSHF
-    return acoshf(x);
-#else
-    return unix_acosh(x);
-#endif
-}
-
 /*********************************************************************
  *      asinh
  */
@@ -448,7 +436,6 @@ static float CDECL unix_tgammaf(float x)
 static const struct unix_funcs funcs =
 {
     unix_acosh,
-    unix_acoshf,
     unix_asinh,
     unix_asinhf,
     unix_atanh,
diff --git a/dlls/msvcrt/unixlib.h b/dlls/msvcrt/unixlib.h
index 6fbafe064c1..2f171339d30 100644
--- a/dlls/msvcrt/unixlib.h
+++ b/dlls/msvcrt/unixlib.h
@@ -24,7 +24,6 @@
 struct unix_funcs
 {
     double          (CDECL *acosh)(double x);
-    float           (CDECL *acoshf)(float 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 74d54a942a6..b94337818ca 100644
--- a/include/config.h.in
+++ b/include/config.h.in
@@ -12,9 +12,6 @@
 /* Define to 1 if you have the `acosh' function. */
 #undef HAVE_ACOSH
 
-/* Define to 1 if you have the `acoshf' function. */
-#undef HAVE_ACOSHF
-
 /* Define to 1 if you have the <alias.h> header file. */
 #undef HAVE_ALIAS_H
 




More information about the wine-cvs mailing list