Commit 81c58e7d authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

msvcrt: Import frexp implementation from musl.

parent aeeda123
......@@ -3494,10 +3494,28 @@ double CDECL fabs( double x )
/*********************************************************************
* frexp (MSVCRT.@)
*
* Copied from musl: src/math/frexp.c
*/
double CDECL frexp( double x, int *exp )
double CDECL frexp( double x, int *e )
{
return unix_funcs->frexp( x, exp );
UINT64 ux = *(UINT64*)&x;
int ee = ux >> 52 & 0x7ff;
if (!ee) {
if (x) {
x = frexp(x * 0x1p64, e);
*e -= 64;
} else *e = 0;
return x;
} else if (ee == 0x7ff) {
return x;
}
*e = ee - 0x3fe;
ux &= 0x800fffffffffffffull;
ux |= 0x3fe0000000000000ull;
return *(double*)&ux;
}
/*********************************************************************
......
......@@ -95,14 +95,6 @@ static float CDECL unix_fmaf( float x, float y, float z )
}
/*********************************************************************
* frexp
*/
static double CDECL unix_frexp( double x, int *exp )
{
return frexp( x, exp );
}
/*********************************************************************
* frexpf
*/
static float CDECL unix_frexpf( float x, int *exp )
......@@ -281,7 +273,6 @@ static const struct unix_funcs funcs =
unix_exp2,
unix_exp2f,
unix_fmaf,
unix_frexp,
unix_frexpf,
unix_hypot,
unix_hypotf,
......
......@@ -28,7 +28,6 @@ struct unix_funcs
double (CDECL *exp2)(double x);
float (CDECL *exp2f)(float x);
float (CDECL *fmaf)(float x, float y, float z);
double (CDECL *frexp)(double x, int *exp);
float (CDECL *frexpf)(float x, int *exp);
double (CDECL *hypot)(double x, double y);
float (CDECL *hypotf)(float x, float y);
......
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