msvcrt: Import modff 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-18 19:08:44 +02:00 committed by Alexandre Julliard
parent 9984a5d661
commit 29e99741d9
3 changed files with 31 additions and 11 deletions

View File

@ -922,10 +922,40 @@ float CDECL frexpf( float x, int *exp )
/*********************************************************************
* modff (MSVCRT.@)
*
* Copied from musl: src/math/modff.c
*/
float CDECL modff( float x, float *iptr )
{
return unix_funcs->modff( x, iptr );
union {float f; UINT32 i;} u = {x};
UINT32 mask;
int e = (u.i >> 23 & 0xff) - 0x7f;
/* no fractional part */
if (e >= 23) {
*iptr = x;
if (e == 0x80 && u.i << 9 != 0) { /* nan */
return x;
}
u.i &= 0x80000000;
return u.f;
}
/* no integral part */
if (e < 0) {
u.i &= 0x80000000;
*iptr = u.f;
return x;
}
mask = 0x007fffff >> e;
if ((u.i & mask) == 0) {
*iptr = x;
u.i &= 0x80000000;
return u.f;
}
u.i &= ~mask;
*iptr = u.f;
return x - u.f;
}
#endif

View File

@ -459,14 +459,6 @@ static float CDECL unix_logbf( float x )
return logbf( x );
}
/*********************************************************************
* modff
*/
static float CDECL unix_modff( float x, float *iptr )
{
return modff( x, iptr );
}
/*********************************************************************
* pow
*/
@ -666,7 +658,6 @@ static const struct unix_funcs funcs =
unix_log2f,
unix_logb,
unix_logbf,
unix_modff,
unix_pow,
unix_powf,
unix_remainder,

View File

@ -62,7 +62,6 @@ struct unix_funcs
float (CDECL *log2f)(float x);
double (CDECL *logb)(double x);
float (CDECL *logbf)(float x);
float (CDECL *modff)(float x, float *iptr);
double (CDECL *pow)(double x, double y);
float (CDECL *powf)(float x, float y);
double (CDECL *remainder)(double x, double y);