msvcrt: Import floorf 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:38:12 +02:00 committed by Alexandre Julliard
parent bba43bd6da
commit e5ddf0e8d8
3 changed files with 22 additions and 11 deletions

View File

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

View File

@ -281,14 +281,6 @@ static double CDECL unix_floor( double x )
return floor( x );
}
/*********************************************************************
* floorf
*/
static float CDECL unix_floorf( float x )
{
return floorf( x );
}
/*********************************************************************
* fma
*/
@ -712,7 +704,6 @@ static const struct unix_funcs funcs =
unix_expm1,
unix_expm1f,
unix_floor,
unix_floorf,
unix_fma,
unix_fmaf,
unix_fmod,

View File

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