Piotr Caban : msvcrt: Import llround implementation from musl.

Alexandre Julliard julliard at winehq.org
Thu Apr 29 16:38:32 CDT 2021


Module: wine
Branch: master
Commit: 389e0532fe2ae0eac770c90df31773a3c6c91a47
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=389e0532fe2ae0eac770c90df31773a3c6c91a47

Author: Piotr Caban <piotr at codeweavers.com>
Date:   Thu Apr 29 17:06:33 2021 +0200

msvcrt: Import llround implementation from musl.

Signed-off-by: Piotr Caban <piotr at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 configure             |  1 -
 configure.ac          |  1 -
 dlls/msvcrt/math.c    |  9 ++++++++-
 dlls/msvcrt/unixlib.c | 13 -------------
 dlls/msvcrt/unixlib.h |  1 -
 include/config.h.in   |  3 ---
 6 files changed, 8 insertions(+), 20 deletions(-)

diff --git a/configure b/configure
index 61ff110a9d4..690f9333f14 100755
--- a/configure
+++ b/configure
@@ -19635,7 +19635,6 @@ for ac_func in \
 	lgammaf \
 	llrint \
 	llrintf \
-	llround \
 	log1p \
 	log1pf \
 	log2 \
diff --git a/configure.ac b/configure.ac
index a8842bcb52a..b0977c112b4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2678,7 +2678,6 @@ AC_CHECK_FUNCS(\
 	lgammaf \
 	llrint \
 	llrintf \
-	llround \
 	log1p \
 	log1pf \
 	log2 \
diff --git a/dlls/msvcrt/math.c b/dlls/msvcrt/math.c
index e5c2ed66d2b..c8dd53cf095 100644
--- a/dlls/msvcrt/math.c
+++ b/dlls/msvcrt/math.c
@@ -4376,10 +4376,17 @@ __msvcrt_long CDECL lroundf(float x)
 
 /*********************************************************************
  *      llround (MSVCR120.@)
+ *
+ * Copied from musl: src/math/llround.c
  */
 __int64 CDECL llround(double x)
 {
-    return unix_funcs->llround( x );
+    double d = round(x);
+    if (d != (double)(__int64)d) {
+        *_errno() = EDOM;
+        return 0;
+    }
+    return d;
 }
 
 /*********************************************************************
diff --git a/dlls/msvcrt/unixlib.c b/dlls/msvcrt/unixlib.c
index e23456e8250..e3ddd486e93 100644
--- a/dlls/msvcrt/unixlib.c
+++ b/dlls/msvcrt/unixlib.c
@@ -789,18 +789,6 @@ static int CDECL unix_lroundf(float x)
 #endif
 }
 
-/*********************************************************************
- *      llround
- */
-static __int64 CDECL unix_llround(double x)
-{
-#ifdef HAVE_LLROUND
-    return llround(x);
-#else
-    return unix_round(x);
-#endif
-}
-
 /*********************************************************************
  *      sin
  */
@@ -956,7 +944,6 @@ static const struct unix_funcs funcs =
     unix_lgammaf,
     unix_llrint,
     unix_llrintf,
-    unix_llround,
     unix_log,
     unix_logf,
     unix_log10,
diff --git a/dlls/msvcrt/unixlib.h b/dlls/msvcrt/unixlib.h
index db090a9a2aa..49ec319d219 100644
--- a/dlls/msvcrt/unixlib.h
+++ b/dlls/msvcrt/unixlib.h
@@ -62,7 +62,6 @@ struct unix_funcs
     float           (CDECL *lgammaf)(float x);
     __int64         (CDECL *llrint)(double x);
     __int64         (CDECL *llrintf)(float x);
-    __int64         (CDECL *llround)(double x);
     double          (CDECL *log)(double x);
     float           (CDECL *logf)(float x);
     double          (CDECL *log10)(double x);
diff --git a/include/config.h.in b/include/config.h.in
index 25c4e3f42ec..71f9f4350b0 100644
--- a/include/config.h.in
+++ b/include/config.h.in
@@ -459,9 +459,6 @@
 /* Define to 1 if you have the `llrintf' function. */
 #undef HAVE_LLRINTF
 
-/* Define to 1 if you have the `llround' function. */
-#undef HAVE_LLROUND
-
 /* Define to 1 if you have the `log1p' function. */
 #undef HAVE_LOG1P
 




More information about the wine-cvs mailing list