Piotr Caban : msvcrt: Import remainder implementation from musl.

Alexandre Julliard julliard at winehq.org
Wed May 19 14:55:13 CDT 2021


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

Author: Piotr Caban <piotr at codeweavers.com>
Date:   Wed May 19 15:26:17 2021 +0200

msvcrt: Import remainder 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    | 11 +++++++----
 dlls/msvcrt/unixlib.c | 14 --------------
 dlls/msvcrt/unixlib.h |  1 -
 include/config.h.in   |  3 ---
 include/msvcrt/math.h |  2 ++
 7 files changed, 9 insertions(+), 24 deletions(-)

diff --git a/configure b/configure
index 0ec898ca762..827d17d7500 100755
--- a/configure
+++ b/configure
@@ -19638,7 +19638,6 @@ for ac_func in \
 	log1pf \
 	log2 \
 	log2f \
-	remainder \
 	remainderf \
 	tgamma \
 	tgammaf
diff --git a/configure.ac b/configure.ac
index 72db35563e7..8b319923816 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2678,7 +2678,6 @@ AC_CHECK_FUNCS(\
 	log1pf \
 	log2 \
 	log2f \
-	remainder \
 	remainderf \
 	tgamma \
 	tgammaf
diff --git a/dlls/msvcrt/math.c b/dlls/msvcrt/math.c
index ae3b9aa76e6..6c856700f94 100644
--- a/dlls/msvcrt/math.c
+++ b/dlls/msvcrt/math.c
@@ -5474,13 +5474,16 @@ float CDECL _scalbf(float num, __msvcrt_long power)
 
 /*********************************************************************
  *      remainder (MSVCR120.@)
+ *
+ * Copied from musl: src/math/remainder.c
  */
 double CDECL remainder(double x, double y)
 {
-    /* this matches 64-bit Windows.  32-bit Windows is slightly different */
-    if(!isfinite(x)) *_errno() = EDOM;
-    if(isnan(y) || y==0.0) *_errno() = EDOM;
-    return unix_funcs->remainder( x, y );
+    int q;
+#if _MSVCR_VER == 120 && defined(__x86_64__)
+    if (isnan(x) || isnan(y)) *_errno() = EDOM;
+#endif
+    return remquo(x, y, &q);
 }
 
 /*********************************************************************
diff --git a/dlls/msvcrt/unixlib.c b/dlls/msvcrt/unixlib.c
index cd22d36acb4..b1f824f4c72 100644
--- a/dlls/msvcrt/unixlib.c
+++ b/dlls/msvcrt/unixlib.c
@@ -475,19 +475,6 @@ static float CDECL unix_powf( float x, float y )
     return powf( x, y );
 }
 
-/*********************************************************************
- *      remainder
- */
-static double CDECL unix_remainder(double x, double y)
-{
-#ifdef HAVE_REMAINDER
-    return remainder(x, y);
-#else
-    FIXME( "not implemented\n" );
-    return 0;
-#endif
-}
-
 /*********************************************************************
  *      remainderf
  */
@@ -634,7 +621,6 @@ static const struct unix_funcs funcs =
     unix_logbf,
     unix_pow,
     unix_powf,
-    unix_remainder,
     unix_remainderf,
     unix_sin,
     unix_sinf,
diff --git a/dlls/msvcrt/unixlib.h b/dlls/msvcrt/unixlib.h
index f71ceea1cab..d301a9716cf 100644
--- a/dlls/msvcrt/unixlib.h
+++ b/dlls/msvcrt/unixlib.h
@@ -64,7 +64,6 @@ struct unix_funcs
     float           (CDECL *logbf)(float x);
     double          (CDECL *pow)(double x, double y);
     float           (CDECL *powf)(float x, float y);
-    double          (CDECL *remainder)(double x, double y);
     float           (CDECL *remainderf)(float x, float y);
     double          (CDECL *sin)(double x);
     float           (CDECL *sinf)(float x);
diff --git a/include/config.h.in b/include/config.h.in
index 1d54a041ce2..58325f3df92 100644
--- a/include/config.h.in
+++ b/include/config.h.in
@@ -630,9 +630,6 @@
 /* Define to 1 if you have the `readlink' function. */
 #undef HAVE_READLINK
 
-/* Define to 1 if you have the `remainder' function. */
-#undef HAVE_REMAINDER
-
 /* Define to 1 if you have the `remainderf' function. */
 #undef HAVE_REMAINDERF
 
diff --git a/include/msvcrt/math.h b/include/msvcrt/math.h
index d2977b67c34..d4db618f542 100644
--- a/include/msvcrt/math.h
+++ b/include/msvcrt/math.h
@@ -73,6 +73,8 @@ _ACRTIMP double __cdecl fmod(double, double);
 _ACRTIMP double __cdecl fmin(double, double);
 _ACRTIMP double __cdecl fmax(double, double);
 _ACRTIMP double __cdecl erf(double);
+_ACRTIMP double __cdecl remquo(double, double, int*);
+_ACRTIMP float __cdecl remquof(float, float, int*);
 
 _ACRTIMP double __cdecl _hypot(double, double);
 _ACRTIMP double __cdecl _j0(double);




More information about the wine-cvs mailing list