Commit 09bcc133 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

msvcrt: Import cbrtf implementation from musl.

parent d5eedfc3
......@@ -19623,7 +19623,6 @@ for ac_func in \
atanh \
atanhf \
cbrt \
cbrtf \
erf \
erfc \
erfcf \
......
......@@ -2663,7 +2663,6 @@ AC_CHECK_FUNCS(\
atanh \
atanhf \
cbrt \
cbrtf \
erf \
erfc \
erfcf \
......
......@@ -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;
}
/*********************************************************************
......
......@@ -134,18 +134,6 @@ static double CDECL unix_cbrt(double x)
}
/*********************************************************************
* cbrtf
*/
static float CDECL unix_cbrtf(float x)
{
#ifdef HAVE_CBRTF
return cbrtf(x);
#else
return unix_cbrt(x);
#endif
}
/*********************************************************************
* ceil
*/
static double CDECL unix_ceil( double x )
......@@ -738,7 +726,6 @@ static const struct unix_funcs funcs =
unix_atanh,
unix_atanhf,
unix_cbrt,
unix_cbrtf,
unix_ceil,
unix_ceilf,
unix_cos,
......
......@@ -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);
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment