Module: wine Branch: master Commit: 0838c995ea540975ff37cc7dead0f28084c24eb6 URL: https://source.winehq.org/git/wine.git/?a=commit;h=0838c995ea540975ff37cc7de...
Author: Piotr Caban piotr@codeweavers.com Date: Mon May 10 20:11:48 2021 +0200
msvcrt: Implement lrint using rint function.
Signed-off-by: Piotr Caban piotr@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
configure | 1 - configure.ac | 1 - dlls/msvcrt/math.c | 10 +++++++++- dlls/msvcrt/unixlib.c | 13 ------------- dlls/msvcrt/unixlib.h | 1 - include/config.h.in | 3 --- 6 files changed, 9 insertions(+), 20 deletions(-)
diff --git a/configure b/configure index 25161a1f27a..2b17a5b20c7 100755 --- a/configure +++ b/configure @@ -19642,7 +19642,6 @@ for ac_func in \ log1pf \ log2 \ log2f \ - lrint \ lrintf \ nearbyint \ nearbyintf \ diff --git a/configure.ac b/configure.ac index 46d6f17fe73..7af593fa6fd 100644 --- a/configure.ac +++ b/configure.ac @@ -2682,7 +2682,6 @@ AC_CHECK_FUNCS(\ log1pf \ log2 \ log2f \ - lrint \ lrintf \ nearbyint \ nearbyintf \ diff --git a/dlls/msvcrt/math.c b/dlls/msvcrt/math.c index 1e67aa03964..fd580d44a9d 100644 --- a/dlls/msvcrt/math.c +++ b/dlls/msvcrt/math.c @@ -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; }
/********************************************************************* diff --git a/dlls/msvcrt/unixlib.c b/dlls/msvcrt/unixlib.c index e36c2e047b9..0353859eec2 100644 --- a/dlls/msvcrt/unixlib.c +++ b/dlls/msvcrt/unixlib.c @@ -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, diff --git a/dlls/msvcrt/unixlib.h b/dlls/msvcrt/unixlib.h index 74545507b26..83356b0125b 100644 --- a/dlls/msvcrt/unixlib.h +++ b/dlls/msvcrt/unixlib.h @@ -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); diff --git a/include/config.h.in b/include/config.h.in index ee34d528122..5dac8fd704c 100644 --- a/include/config.h.in +++ b/include/config.h.in @@ -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