mirror of
git://source.winehq.org/git/wine.git
synced 2024-10-04 18:47:07 +00:00
msvcrt: Import round 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
69ad3c11cf
commit
f4de92a4ed
1
configure
vendored
1
configure
vendored
|
@ -19651,7 +19651,6 @@ for ac_func in \
|
|||
remquof \
|
||||
rint \
|
||||
rintf \
|
||||
round \
|
||||
tgamma \
|
||||
tgammaf \
|
||||
trunc \
|
||||
|
|
|
@ -2694,7 +2694,6 @@ AC_CHECK_FUNCS(\
|
|||
remquof \
|
||||
rint \
|
||||
rintf \
|
||||
round \
|
||||
tgamma \
|
||||
tgammaf \
|
||||
trunc \
|
||||
|
|
|
@ -87,6 +87,14 @@ static inline float fp_barrierf(float x)
|
|||
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 )
|
||||
{
|
||||
double x = 1.0;
|
||||
|
@ -4321,10 +4329,33 @@ short CDECL _dclass(double x)
|
|||
|
||||
/*********************************************************************
|
||||
* round (MSVCR120.@)
|
||||
*
|
||||
* Copied from musl: src/math/round.c
|
||||
*/
|
||||
double CDECL round(double x)
|
||||
{
|
||||
return unix_funcs->round(x);
|
||||
static const double toint = 1 / DBL_EPSILON;
|
||||
|
||||
ULONGLONG llx = *(ULONGLONG*)&x;
|
||||
int e = llx >> 52 & 0x7ff;
|
||||
double y;
|
||||
|
||||
if (e >= 0x3ff + 52)
|
||||
return x;
|
||||
if (llx >> 63)
|
||||
x = -x;
|
||||
if (e < 0x3ff - 1)
|
||||
return 0 * *(double*)&llx;
|
||||
y = fp_barrier(x + toint) - toint - x;
|
||||
if (y > 0.5)
|
||||
y = y + x - 1;
|
||||
else if (y <= -0.5)
|
||||
y = y + x + 1;
|
||||
else
|
||||
y = y + x;
|
||||
if (llx >> 63)
|
||||
y = -y;
|
||||
return y;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
|
|
|
@ -753,18 +753,6 @@ static float CDECL unix_rintf(float x)
|
|||
#endif
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* round
|
||||
*/
|
||||
static double CDECL unix_round(double x)
|
||||
{
|
||||
#ifdef HAVE_ROUND
|
||||
return round(x);
|
||||
#else
|
||||
return unix_rint(x);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* sin
|
||||
*/
|
||||
|
@ -948,7 +936,6 @@ static const struct unix_funcs funcs =
|
|||
unix_remquof,
|
||||
unix_rint,
|
||||
unix_rintf,
|
||||
unix_round,
|
||||
unix_sin,
|
||||
unix_sinf,
|
||||
unix_sinh,
|
||||
|
|
|
@ -90,7 +90,6 @@ struct unix_funcs
|
|||
float (CDECL *remquof)(float x, float y, int *quo);
|
||||
double (CDECL *rint)(double x);
|
||||
float (CDECL *rintf)(float x);
|
||||
double (CDECL *round)(double x);
|
||||
double (CDECL *sin)(double x);
|
||||
float (CDECL *sinf)(float x);
|
||||
double (CDECL *sinh)(double x);
|
||||
|
|
|
@ -690,9 +690,6 @@
|
|||
/* Define to 1 if you have the `rintf' function. */
|
||||
#undef HAVE_RINTF
|
||||
|
||||
/* Define to 1 if you have the `round' function. */
|
||||
#undef HAVE_ROUND
|
||||
|
||||
/* Define to 1 if you have the <sasl/sasl.h> header file. */
|
||||
#undef HAVE_SASL_SASL_H
|
||||
|
||||
|
|
Loading…
Reference in a new issue