Piotr Caban : msvcrt: Import cbrtf implementation from musl.
Alexandre Julliard
julliard at winehq.org
Mon May 17 15:45:30 CDT 2021
Module: wine
Branch: master
Commit: 09bcc133f0d2ddfd0b88d966fdaab2a741c9e3ff
URL: https://source.winehq.org/git/wine.git/?a=commit;h=09bcc133f0d2ddfd0b88d966fdaab2a741c9e3ff
Author: Piotr Caban <piotr at codeweavers.com>
Date: Mon May 17 15:37:51 2021 +0200
msvcrt: Import cbrtf 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 | 30 +++++++++++++++++++++++++++++-
dlls/msvcrt/unixlib.c | 13 -------------
dlls/msvcrt/unixlib.h | 1 -
include/config.h.in | 3 ---
6 files changed, 29 insertions(+), 20 deletions(-)
diff --git a/configure b/configure
index 886a463a92a..3cbe4bed79e 100755
--- a/configure
+++ b/configure
@@ -19623,7 +19623,6 @@ for ac_func in \
atanh \
atanhf \
cbrt \
- cbrtf \
erf \
erfc \
erfcf \
diff --git a/configure.ac b/configure.ac
index 2b126a7c579..845b076a8ba 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2663,7 +2663,6 @@ AC_CHECK_FUNCS(\
atanh \
atanhf \
cbrt \
- cbrtf \
erf \
erfc \
erfcf \
diff --git a/dlls/msvcrt/math.c b/dlls/msvcrt/math.c
index 41096ded6e4..db59f5a0787 100644
--- a/dlls/msvcrt/math.c
+++ b/dlls/msvcrt/math.c
@@ -4505,10 +4505,38 @@ double CDECL cbrt(double x)
/*********************************************************************
* cbrtf (MSVCR120.@)
+ *
+ * Copied from musl: src/math/cbrtf.c
*/
float CDECL cbrtf(float x)
{
- return unix_funcs->cbrtf( x );
+ static const unsigned B1 = 709958130, B2 = 642849266;
+
+ double r,T;
+ union {float f; UINT32 i;} u = {x};
+ UINT32 hx = u.i & 0x7fffffff;
+
+ if (hx >= 0x7f800000)
+ return x + x;
+
+ if (hx < 0x00800000) { /* zero or subnormal? */
+ if (hx == 0)
+ return x;
+ u.f = x * 0x1p24f;
+ hx = u.i & 0x7fffffff;
+ hx = hx / 3 + B2;
+ } else
+ hx = hx / 3 + B1;
+ u.i &= 0x80000000;
+ u.i |= hx;
+
+ T = u.f;
+ r = T * T * T;
+ T = T * (x + x + r) / (x + r + r);
+
+ r = T * T * T;
+ T = T * (x + x + r) / (x + r + r);
+ return T;
}
/*********************************************************************
diff --git a/dlls/msvcrt/unixlib.c b/dlls/msvcrt/unixlib.c
index a5b59bc2cf3..56c70742133 100644
--- a/dlls/msvcrt/unixlib.c
+++ b/dlls/msvcrt/unixlib.c
@@ -133,18 +133,6 @@ static double CDECL unix_cbrt(double x)
#endif
}
-/*********************************************************************
- * cbrtf
- */
-static float CDECL unix_cbrtf(float x)
-{
-#ifdef HAVE_CBRTF
- return cbrtf(x);
-#else
- return unix_cbrt(x);
-#endif
-}
-
/*********************************************************************
* ceil
*/
@@ -738,7 +726,6 @@ static const struct unix_funcs funcs =
unix_atanh,
unix_atanhf,
unix_cbrt,
- unix_cbrtf,
unix_ceil,
unix_ceilf,
unix_cos,
diff --git a/dlls/msvcrt/unixlib.h b/dlls/msvcrt/unixlib.h
index 3d41967a2a0..c3b2b500c6d 100644
--- a/dlls/msvcrt/unixlib.h
+++ b/dlls/msvcrt/unixlib.h
@@ -30,7 +30,6 @@ struct unix_funcs
double (CDECL *atanh)(double x);
float (CDECL *atanhf)(float x);
double (CDECL *cbrt)(double x);
- float (CDECL *cbrtf)(float x);
double (CDECL *ceil)(double x);
float (CDECL *ceilf)(float x);
double (CDECL *cos)(double x);
diff --git a/include/config.h.in b/include/config.h.in
index 56f3bc90003..34103b765fc 100644
--- a/include/config.h.in
+++ b/include/config.h.in
@@ -70,9 +70,6 @@
/* Define to 1 if you have the `cbrt' function. */
#undef HAVE_CBRT
-/* Define to 1 if you have the `cbrtf' function. */
-#undef HAVE_CBRTF
-
/* Define to 1 if you have the `clock_gettime' function. */
#undef HAVE_CLOCK_GETTIME
More information about the wine-cvs
mailing list