Commit 2a5e68ab authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

msvcrt: Import ceil implementation from musl.

parent e5d667de
...@@ -1740,10 +1740,31 @@ float CDECL _hypotf(float x, float y) ...@@ -1740,10 +1740,31 @@ float CDECL _hypotf(float x, float y)
/********************************************************************* /*********************************************************************
* ceil (MSVCRT.@) * ceil (MSVCRT.@)
*
* Based on musl: src/math/ceilf.c
*/ */
double CDECL ceil( double x ) double CDECL ceil( double x )
{ {
return unix_funcs->ceil(x); union {double f; UINT64 i;} u = {x};
int e = (u.i >> 52 & 0x7ff) - 0x3ff;
UINT64 m;
if (e >= 52)
return x;
if (e >= 0) {
m = 0x000fffffffffffffULL >> e;
if ((u.i & m) == 0)
return x;
if (u.i >> 63 == 0)
u.i += m;
u.i &= ~m;
} else {
if (u.i >> 63)
return -0.0;
else if (u.i << 1)
return 1.0;
}
return u.f;
} }
/********************************************************************* /*********************************************************************
......
...@@ -122,14 +122,6 @@ static float CDECL unix_atanhf(float x) ...@@ -122,14 +122,6 @@ static float CDECL unix_atanhf(float x)
} }
/********************************************************************* /*********************************************************************
* ceil
*/
static double CDECL unix_ceil( double x )
{
return ceil( x );
}
/*********************************************************************
* ceilf * ceilf
*/ */
static float CDECL unix_ceilf( float x ) static float CDECL unix_ceilf( float x )
...@@ -713,7 +705,6 @@ static const struct unix_funcs funcs = ...@@ -713,7 +705,6 @@ static const struct unix_funcs funcs =
unix_asinhf, unix_asinhf,
unix_atanh, unix_atanh,
unix_atanhf, unix_atanhf,
unix_ceil,
unix_ceilf, unix_ceilf,
unix_cos, unix_cos,
unix_cosf, unix_cosf,
......
...@@ -29,7 +29,6 @@ struct unix_funcs ...@@ -29,7 +29,6 @@ struct unix_funcs
float (CDECL *asinhf)(float x); float (CDECL *asinhf)(float x);
double (CDECL *atanh)(double x); double (CDECL *atanh)(double x);
float (CDECL *atanhf)(float x); float (CDECL *atanhf)(float x);
double (CDECL *ceil)(double x);
float (CDECL *ceilf)(float x); float (CDECL *ceilf)(float x);
double (CDECL *cos)(double x); double (CDECL *cos)(double x);
float (CDECL *cosf)(float x); float (CDECL *cosf)(float x);
......
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