msvcrt: Implement lrint using rint function.

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-10 20:11:48 +02:00 committed by Alexandre Julliard
parent ad2ecc6e06
commit 0838c995ea
6 changed files with 9 additions and 20 deletions

1
configure vendored
View File

@ -19642,7 +19642,6 @@ for ac_func in \
log1pf \
log2 \
log2f \
lrint \
lrintf \
nearbyint \
nearbyintf \

View File

@ -2682,7 +2682,6 @@ AC_CHECK_FUNCS(\
log1pf \
log2 \
log2f \
lrint \
lrintf \
nearbyint \
nearbyintf \

View File

@ -4340,7 +4340,15 @@ float CDECL rintf(float x)
*/
__msvcrt_long CDECL lrint(double x)
{
return unix_funcs->lrint( x );
double d;
d = rint(x);
if ((d < 0 && d != (double)(__msvcrt_long)d)
|| (d >= 0 && d != (double)(__msvcrt_ulong)d)) {
*_errno() = EDOM;
return 0;
}
return d;
}
/*********************************************************************

View File

@ -555,18 +555,6 @@ static float CDECL unix_logbf( float x )
return logbf( x );
}
/*********************************************************************
* lrint
*/
static int CDECL unix_lrint(double x)
{
#ifdef HAVE_LRINT
return lrint(x);
#else
return x >= 0 ? floor(x + 0.5) : ceil(x - 0.5);
#endif
}
/*********************************************************************
* lrintf
*/
@ -894,7 +882,6 @@ static const struct unix_funcs funcs =
unix_log2f,
unix_logb,
unix_logbf,
unix_lrint,
unix_lrintf,
unix_modf,
unix_modff,

View File

@ -72,7 +72,6 @@ struct unix_funcs
float (CDECL *log2f)(float x);
double (CDECL *logb)(double x);
float (CDECL *logbf)(float x);
int (CDECL *lrint)(double x);
int (CDECL *lrintf)(float x);
double (CDECL *modf)(double x, double *iptr);
float (CDECL *modff)(float x, float *iptr);

View File

@ -471,9 +471,6 @@
/* Define to 1 if you have the `log2f' function. */
#undef HAVE_LOG2F
/* Define to 1 if you have the `lrint' function. */
#undef HAVE_LRINT
/* Define to 1 if you have the `lrintf' function. */
#undef HAVE_LRINTF