mirror of
git://source.winehq.org/git/wine.git
synced 2024-10-14 16:47:17 +00:00
msvcrt: Import rint implementation from musl.
Signed-off-by: Piotr Caban <piotr@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
d5fb715536
commit
cba9981c47
1
configure
vendored
1
configure
vendored
|
@ -19652,7 +19652,6 @@ for ac_func in \
|
||||||
remainderf \
|
remainderf \
|
||||||
remquo \
|
remquo \
|
||||||
remquof \
|
remquof \
|
||||||
rint \
|
|
||||||
rintf \
|
rintf \
|
||||||
tgamma \
|
tgamma \
|
||||||
tgammaf \
|
tgammaf \
|
||||||
|
|
|
@ -2692,7 +2692,6 @@ AC_CHECK_FUNCS(\
|
||||||
remainderf \
|
remainderf \
|
||||||
remquo \
|
remquo \
|
||||||
remquof \
|
remquof \
|
||||||
rint \
|
|
||||||
rintf \
|
rintf \
|
||||||
tgamma \
|
tgamma \
|
||||||
tgammaf \
|
tgammaf \
|
||||||
|
|
|
@ -87,6 +87,14 @@ static inline float fp_barrierf(float x)
|
||||||
return y;
|
return y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if _MSVCR_VER>=120
|
||||||
|
static inline double fp_barrier(double x)
|
||||||
|
{
|
||||||
|
volatile double y = x;
|
||||||
|
return y;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static inline double CDECL ret_nan( BOOL update_sw )
|
static inline double CDECL ret_nan( BOOL update_sw )
|
||||||
{
|
{
|
||||||
double x = 1.0;
|
double x = 1.0;
|
||||||
|
@ -4273,10 +4281,33 @@ float CDECL log2f(float x)
|
||||||
|
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
* rint (MSVCR120.@)
|
* rint (MSVCR120.@)
|
||||||
|
*
|
||||||
|
* Copied from musl: src/math/rint.c
|
||||||
*/
|
*/
|
||||||
double CDECL rint(double x)
|
double CDECL rint(double x)
|
||||||
{
|
{
|
||||||
return unix_funcs->rint(x);
|
static const double toint = 1 / DBL_EPSILON;
|
||||||
|
|
||||||
|
ULONGLONG llx = *(ULONGLONG*)&x;
|
||||||
|
int e = llx >> 52 & 0x7ff;
|
||||||
|
int s = llx >> 63;
|
||||||
|
unsigned cw;
|
||||||
|
double y;
|
||||||
|
|
||||||
|
if (e >= 0x3ff+52)
|
||||||
|
return x;
|
||||||
|
cw = _controlfp(0, 0);
|
||||||
|
if ((cw & _MCW_PC) != _PC_53)
|
||||||
|
_controlfp(_PC_53, _MCW_PC);
|
||||||
|
if (s)
|
||||||
|
y = fp_barrier(x - toint) + toint;
|
||||||
|
else
|
||||||
|
y = fp_barrier(x + toint) - toint;
|
||||||
|
if ((cw & _MCW_PC) != _PC_53)
|
||||||
|
_controlfp(cw, _MCW_PC);
|
||||||
|
if (y == 0)
|
||||||
|
return s ? -0.0 : 0;
|
||||||
|
return y;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
|
|
|
@ -729,18 +729,6 @@ static float CDECL unix_remquof(float x, float y, int *quo)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************************************************************
|
|
||||||
* rint
|
|
||||||
*/
|
|
||||||
static double CDECL unix_rint(double x)
|
|
||||||
{
|
|
||||||
#ifdef HAVE_RINT
|
|
||||||
return rint(x);
|
|
||||||
#else
|
|
||||||
return x >= 0 ? floor(x + 0.5) : ceil(x - 0.5);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
* rintf
|
* rintf
|
||||||
*/
|
*/
|
||||||
|
@ -934,7 +922,6 @@ static const struct unix_funcs funcs =
|
||||||
unix_remainderf,
|
unix_remainderf,
|
||||||
unix_remquo,
|
unix_remquo,
|
||||||
unix_remquof,
|
unix_remquof,
|
||||||
unix_rint,
|
|
||||||
unix_rintf,
|
unix_rintf,
|
||||||
unix_sin,
|
unix_sin,
|
||||||
unix_sinf,
|
unix_sinf,
|
||||||
|
|
|
@ -88,7 +88,6 @@ struct unix_funcs
|
||||||
float (CDECL *remainderf)(float x, float y);
|
float (CDECL *remainderf)(float x, float y);
|
||||||
double (CDECL *remquo)(double x, double y, int *quo);
|
double (CDECL *remquo)(double x, double y, int *quo);
|
||||||
float (CDECL *remquof)(float x, float y, int *quo);
|
float (CDECL *remquof)(float x, float y, int *quo);
|
||||||
double (CDECL *rint)(double x);
|
|
||||||
float (CDECL *rintf)(float x);
|
float (CDECL *rintf)(float x);
|
||||||
double (CDECL *sin)(double x);
|
double (CDECL *sin)(double x);
|
||||||
float (CDECL *sinf)(float x);
|
float (CDECL *sinf)(float x);
|
||||||
|
|
|
@ -684,9 +684,6 @@
|
||||||
/* Define to 1 if you have the `res_getservers' function. */
|
/* Define to 1 if you have the `res_getservers' function. */
|
||||||
#undef HAVE_RES_GETSERVERS
|
#undef HAVE_RES_GETSERVERS
|
||||||
|
|
||||||
/* Define to 1 if you have the `rint' function. */
|
|
||||||
#undef HAVE_RINT
|
|
||||||
|
|
||||||
/* Define to 1 if you have the `rintf' function. */
|
/* Define to 1 if you have the `rintf' function. */
|
||||||
#undef HAVE_RINTF
|
#undef HAVE_RINTF
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue