Daniel Lehman : msvcr120: Add remainder.
Alexandre Julliard
julliard at wine.codeweavers.com
Thu Apr 7 11:42:52 CDT 2016
Module: wine
Branch: master
Commit: d9a0c55e7eb6ea9cb822260decef4a49d425c6a0
URL: http://source.winehq.org/git/wine.git/?a=commit;h=d9a0c55e7eb6ea9cb822260decef4a49d425c6a0
Author: Daniel Lehman <dlehman at esri.com>
Date: Tue Apr 5 12:53:12 2016 -0700
msvcr120: Add remainder.
Signed-off-by: Daniel Lehman <dlehman at esri.com>
Signed-off-by: Piotr Caban <piotr at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
configure | 2 +
configure.ac | 2 +
.../api-ms-win-crt-math-l1-1-0.spec | 6 +--
dlls/msvcr120/msvcr120.spec | 6 +--
dlls/msvcr120/tests/msvcr120.c | 48 ++++++++++++++++++++++
dlls/msvcr120_app/msvcr120_app.spec | 6 +--
dlls/msvcrt/math.c | 40 ++++++++++++++++++
dlls/ucrtbase/ucrtbase.spec | 6 +--
include/config.h.in | 6 +++
9 files changed, 110 insertions(+), 12 deletions(-)
diff --git a/configure b/configure
index 0547967..223d5c6 100755
--- a/configure
+++ b/configure
@@ -16876,6 +16876,8 @@ for ac_func in \
lrintf \
lround \
lroundf \
+ remainder \
+ remainderf \
rint \
rintf \
round \
diff --git a/configure.ac b/configure.ac
index 20478df..6189aa9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2534,6 +2534,8 @@ AC_CHECK_FUNCS(\
lrintf \
lround \
lroundf \
+ remainder \
+ remainderf \
rint \
rintf \
round \
diff --git a/dlls/api-ms-win-crt-math-l1-1-0/api-ms-win-crt-math-l1-1-0.spec b/dlls/api-ms-win-crt-math-l1-1-0/api-ms-win-crt-math-l1-1-0.spec
index 2809b66..f752c83 100644
--- a/dlls/api-ms-win-crt-math-l1-1-0/api-ms-win-crt-math-l1-1-0.spec
+++ b/dlls/api-ms-win-crt-math-l1-1-0/api-ms-win-crt-math-l1-1-0.spec
@@ -304,9 +304,9 @@
@ stub norml
@ cdecl pow(double double) ucrtbase.pow
@ cdecl -arch=arm,x86_64 powf(float float) ucrtbase.powf
-@ stub remainder
-@ stub remainderf
-@ stub remainderl
+@ cdecl remainder(double double) ucrtbase.remainder
+@ cdecl remainderf(float float) ucrtbase.remainderf
+@ cdecl remainderl(double double) ucrtbase.remainderl
@ stub remquo
@ stub remquof
@ stub remquol
diff --git a/dlls/msvcr120/msvcr120.spec b/dlls/msvcr120/msvcr120.spec
index 58d04e1..ad9749a 100644
--- a/dlls/msvcr120/msvcr120.spec
+++ b/dlls/msvcr120/msvcr120.spec
@@ -2324,9 +2324,9 @@
@ cdecl rand() MSVCRT_rand
@ cdecl rand_s(ptr) MSVCRT_rand_s
@ cdecl realloc(ptr long) MSVCRT_realloc
-@ stub remainder
-@ stub remainderf
-@ stub remainderl
+@ cdecl remainder(double double) MSVCR120_remainder
+@ cdecl remainderf(float float) MSVCR120_remainderf
+@ cdecl remainderl(double double) MSVCR120_remainderl
@ cdecl remove(str) MSVCRT_remove
@ stub remquo
@ stub remquof
diff --git a/dlls/msvcr120/tests/msvcr120.c b/dlls/msvcr120/tests/msvcr120.c
index 54c86c6..e267111 100644
--- a/dlls/msvcr120/tests/msvcr120.c
+++ b/dlls/msvcr120/tests/msvcr120.c
@@ -88,6 +88,12 @@ static void (CDECL *p_free)(void*);
static float (CDECL *p_strtof)(const char *, char **);
static int (CDECL *p__finite)(double);
static float (CDECL *p_wcstof)(const wchar_t*, wchar_t**);
+static double (CDECL *p_remainder)(double, double);
+static int* (CDECL *p_errno)(void);
+
+/* make sure we use the correct errno */
+#undef errno
+#define errno (*p_errno())
static BOOL init(void)
{
@@ -113,6 +119,8 @@ static BOOL init(void)
p_strtof = (void*)GetProcAddress(module, "strtof");
p__finite = (void*)GetProcAddress(module, "_finite");
p_wcstof = (void*)GetProcAddress(module, "wcstof");
+ p_remainder = (void*)GetProcAddress(module, "remainder");
+ p_errno = (void*)GetProcAddress(module, "_errno");
return TRUE;
}
@@ -389,6 +397,45 @@ static void test__strtof(void)
p_setlocale(LC_ALL, "C");
}
+static void test_remainder(void)
+{
+ struct {
+ double x, y, r;
+ errno_t e;
+ } tests[] = {
+ { 3.0, 2.0, -1.0, -1 },
+ { 1.0, 1.0, 0.0, -1 },
+ { INFINITY, 0.0, NAN, EDOM },
+ { INFINITY, 42.0, NAN, EDOM },
+ { NAN, 0.0, NAN, EDOM },
+ { NAN, 42.0, NAN, EDOM },
+ { 0.0, INFINITY, 0.0, -1 },
+ { 42.0, INFINITY, 42.0, -1 },
+ { 0.0, NAN, NAN, EDOM },
+ { 42.0, NAN, NAN, EDOM },
+ { 1.0, 0.0, NAN, EDOM },
+ { INFINITY, INFINITY, NAN, EDOM },
+ };
+ errno_t e;
+ double r;
+ int i;
+
+ if(sizeof(void*) != 8) /* errno handling slightly different on 32-bit */
+ return;
+
+ for(i=0; i<sizeof(tests)/sizeof(*tests); i++) {
+ errno = -1;
+ r = p_remainder(tests[i].x, tests[i].y);
+ e = errno;
+
+ ok(tests[i].e == e, "expected errno %i, but got %i\n", tests[i].e, e);
+ if(_isnan(tests[i].r))
+ ok(_isnan(r), "expected NAN, but got %f\n", r);
+ else
+ ok(tests[i].r == r, "expected result %f, but got %f\n", tests[i].r, r);
+ }
+}
+
START_TEST(msvcr120)
{
if (!init()) return;
@@ -400,4 +447,5 @@ START_TEST(msvcr120)
test__GetConcurrency();
test__W_Gettnames();
test__strtof();
+ test_remainder();
}
diff --git a/dlls/msvcr120_app/msvcr120_app.spec b/dlls/msvcr120_app/msvcr120_app.spec
index 7f195e4..fb3e4a3 100644
--- a/dlls/msvcr120_app/msvcr120_app.spec
+++ b/dlls/msvcr120_app/msvcr120_app.spec
@@ -1987,9 +1987,9 @@
@ cdecl rand() msvcr120.rand
@ cdecl rand_s(ptr) msvcr120.rand_s
@ cdecl realloc(ptr long) msvcr120.realloc
-@ stub remainder
-@ stub remainderf
-@ stub remainderl
+@ cdecl remainder(double double) msvcr120.remainder
+@ cdecl remainderf(float float) msvcr120.remainderf
+@ cdecl remainderl(double double) msvcr120.remainderl
@ cdecl remove(str) msvcr120.remove
@ stub remquo
@ stub remquof
diff --git a/dlls/msvcrt/math.c b/dlls/msvcrt/math.c
index bd0b92b..b9e0533 100644
--- a/dlls/msvcrt/math.c
+++ b/dlls/msvcrt/math.c
@@ -2790,3 +2790,43 @@ LDOUBLE CDECL MSVCR120_scalbnl(LDOUBLE num, MSVCRT_long power)
{
return MSVCRT__scalb(num, power);
}
+
+/*********************************************************************
+ * remainder (MSVCR120.@)
+ */
+double CDECL MSVCR120_remainder(double x, double y)
+{
+#ifdef HAVE_REMAINDER
+ /* this matches 64-bit Windows. 32-bit Windows is slightly different */
+ if(!finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
+ if(isnan(y) || y==0.0) *MSVCRT__errno() = MSVCRT_EDOM;
+ return remainder(x, y);
+#else
+ FIXME( "not implemented\n" );
+ return 0.0;
+#endif
+}
+
+/*********************************************************************
+ * remainderf (MSVCR120.@)
+ */
+float CDECL MSVCR120_remainderf(float x, float y)
+{
+#ifdef HAVE_REMAINDERF
+ /* this matches 64-bit Windows. 32-bit Windows is slightly different */
+ if(!finitef(x)) *MSVCRT__errno() = MSVCRT_EDOM;
+ if(isnanf(y) || y==0.0f) *MSVCRT__errno() = MSVCRT_EDOM;
+ return remainderf(x, y);
+#else
+ FIXME( "not implemented\n" );
+ return 0.0f;
+#endif
+}
+
+/*********************************************************************
+ * remainderl (MSVCR120.@)
+ */
+LDOUBLE CDECL MSVCR120_remainderl(LDOUBLE x, LDOUBLE y)
+{
+ return MSVCR120_remainder(x, y);
+}
diff --git a/dlls/ucrtbase/ucrtbase.spec b/dlls/ucrtbase/ucrtbase.spec
index 1ef5c3b..0670f6e 100644
--- a/dlls/ucrtbase/ucrtbase.spec
+++ b/dlls/ucrtbase/ucrtbase.spec
@@ -2458,9 +2458,9 @@
@ cdecl rand() MSVCRT_rand
@ cdecl rand_s(ptr) MSVCRT_rand_s
@ cdecl realloc(ptr long) MSVCRT_realloc
-@ stub remainder
-@ stub remainderf
-@ stub remainderl
+@ cdecl remainder(double double) MSVCR120_remainder
+@ cdecl remainderf(float float) MSVCR120_remainderf
+@ cdecl remainderl(double double) MSVCR120_remainderl
@ cdecl remove(str) MSVCRT_remove
@ stub remquo
@ stub remquof
diff --git a/include/config.h.in b/include/config.h.in
index cb0ddd6..0650f31 100644
--- a/include/config.h.in
+++ b/include/config.h.in
@@ -726,6 +726,12 @@
/* 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
+
/* Define to 1 if the system has the type `request_sense'. */
#undef HAVE_REQUEST_SENSE
More information about the wine-cvs
mailing list