Commit 9984a5d6 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

msvcrt: Import modf implementation from musl.

parent bc5f2888
...@@ -2000,10 +2000,40 @@ double CDECL frexp( double x, int *exp ) ...@@ -2000,10 +2000,40 @@ double CDECL frexp( double x, int *exp )
/********************************************************************* /*********************************************************************
* modf (MSVCRT.@) * modf (MSVCRT.@)
*
* Copied from musl: src/math/modf.c
*/ */
double CDECL modf( double x, double *iptr ) double CDECL modf( double x, double *iptr )
{ {
return unix_funcs->modf( x, iptr ); union {double f; UINT64 i;} u = {x};
UINT64 mask;
int e = (u.i >> 52 & 0x7ff) - 0x3ff;
/* no fractional part */
if (e >= 52) {
*iptr = x;
if (e == 0x400 && u.i << 12 != 0) /* nan */
return x;
u.i &= 1ULL << 63;
return u.f;
}
/* no integral part*/
if (e < 0) {
u.i &= 1ULL << 63;
*iptr = u.f;
return x;
}
mask = -1ULL >> 12 >> e;
if ((u.i & mask) == 0) {
*iptr = x;
u.i &= 1ULL << 63;
return u.f;
}
u.i &= ~mask;
*iptr = u.f;
return x - u.f;
} }
/********************************************************************** /**********************************************************************
......
...@@ -460,14 +460,6 @@ static float CDECL unix_logbf( float x ) ...@@ -460,14 +460,6 @@ static float CDECL unix_logbf( float x )
} }
/********************************************************************* /*********************************************************************
* modf
*/
static double CDECL unix_modf( double x, double *iptr )
{
return modf( x, iptr );
}
/*********************************************************************
* modff * modff
*/ */
static float CDECL unix_modff( float x, float *iptr ) static float CDECL unix_modff( float x, float *iptr )
...@@ -674,7 +666,6 @@ static const struct unix_funcs funcs = ...@@ -674,7 +666,6 @@ static const struct unix_funcs funcs =
unix_log2f, unix_log2f,
unix_logb, unix_logb,
unix_logbf, unix_logbf,
unix_modf,
unix_modff, unix_modff,
unix_pow, unix_pow,
unix_powf, unix_powf,
......
...@@ -62,7 +62,6 @@ struct unix_funcs ...@@ -62,7 +62,6 @@ struct unix_funcs
float (CDECL *log2f)(float x); float (CDECL *log2f)(float x);
double (CDECL *logb)(double x); double (CDECL *logb)(double x);
float (CDECL *logbf)(float x); float (CDECL *logbf)(float x);
double (CDECL *modf)(double x, double *iptr);
float (CDECL *modff)(float x, float *iptr); float (CDECL *modff)(float x, float *iptr);
double (CDECL *pow)(double x, double y); double (CDECL *pow)(double x, double y);
float (CDECL *powf)(float x, float y); float (CDECL *powf)(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