Commit d9a0c55e authored by Daniel Lehman's avatar Daniel Lehman Committed by Alexandre Julliard

msvcr120: Add remainder.

parent 5bf43458
......@@ -16876,6 +16876,8 @@ for ac_func in \
lrintf \
lround \
lroundf \
remainder \
remainderf \
rint \
rintf \
round \
......
......@@ -2534,6 +2534,8 @@ AC_CHECK_FUNCS(\
lrintf \
lround \
lroundf \
remainder \
remainderf \
rint \
rintf \
round \
......
......@@ -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
......
......@@ -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
......
......@@ -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();
}
......@@ -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
......
......@@ -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);
}
......@@ -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
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment