Commit e5ddf0e8 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

msvcrt: Import floorf implementation from musl.

parent bba43bd6
......@@ -827,10 +827,31 @@ float CDECL ceilf( float x )
/*********************************************************************
* floorf (MSVCRT.@)
*
* Copied from musl: src/math/floorf.c
*/
float CDECL floorf( float x )
{
return unix_funcs->floorf(x);
union {float f; UINT32 i;} u = {x};
int e = (int)(u.i >> 23 & 0xff) - 0x7f;
UINT32 m;
if (e >= 23)
return x;
if (e >= 0) {
m = 0x007fffff >> e;
if ((u.i & m) == 0)
return x;
if (u.i >> 31)
u.i += m;
u.i &= ~m;
} else {
if (u.i >> 31 == 0)
return 0;
else if (u.i << 1)
return -1;
}
return u.f;
}
/*********************************************************************
......
......@@ -282,14 +282,6 @@ static double CDECL unix_floor( double x )
}
/*********************************************************************
* floorf
*/
static float CDECL unix_floorf( float x )
{
return floorf( x );
}
/*********************************************************************
* fma
*/
static double CDECL unix_fma( double x, double y, double z )
......@@ -712,7 +704,6 @@ static const struct unix_funcs funcs =
unix_expm1,
unix_expm1f,
unix_floor,
unix_floorf,
unix_fma,
unix_fmaf,
unix_fmod,
......
......@@ -44,7 +44,6 @@ struct unix_funcs
double (CDECL *expm1)(double x);
float (CDECL *expm1f)(float x);
double (CDECL *floor)(double x);
float (CDECL *floorf)(float x);
double (CDECL *fma)(double x, double y, double z);
float (CDECL *fmaf)(float x, float y, float z);
double (CDECL *fmod)(double x, double 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