msvcrt: Import cbrtf implementation from musl.

Signed-off-by: Piotr Caban <piotr@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Piotr Caban 2021-05-17 15:37:51 +02:00 committed by Alexandre Julliard
parent d5eedfc39e
commit 09bcc133f0
6 changed files with 29 additions and 20 deletions

1
configure vendored
View File

@ -19623,7 +19623,6 @@ for ac_func in \
atanh \
atanhf \
cbrt \
cbrtf \
erf \
erfc \
erfcf \

View File

@ -2663,7 +2663,6 @@ AC_CHECK_FUNCS(\
atanh \
atanhf \
cbrt \
cbrtf \
erf \
erfc \
erfcf \

View File

@ -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;
}
/*********************************************************************

View File

@ -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,

View File

@ -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);

View File

@ -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