Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=45631 Signed-off-by: Zebediah Figura z.figura12@gmail.com --- .../api-ms-win-crt-math-l1-1-0.spec | 6 +-- dlls/msvcr120/msvcr120.spec | 6 +-- dlls/msvcr120/tests/msvcr120.c | 49 +++++++++++++++++++ dlls/msvcr120_app/msvcr120_app.spec | 6 +-- dlls/msvcrt/math.c | 16 ++++++ dlls/ucrtbase/ucrtbase.spec | 6 +-- 6 files changed, 77 insertions(+), 12 deletions(-)
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 0d645e5587..f5e4fb1f8f 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 @@ -297,9 +297,9 @@ @ cdecl nextafter(double double) ucrtbase.nextafter @ cdecl nextafterf(float float) ucrtbase.nextafterf @ cdecl nextafterl(double double) ucrtbase.nextafterl -@ stub nexttoward -@ stub nexttowardf -@ stub nexttowardl +@ cdecl nexttoward(double double) ucrtbase.nexttoward +@ cdecl nexttowardf(float double) ucrtbase.nexttowardf +@ cdecl nexttowardl(double double) ucrtbase.nexttowardl @ stub norm @ stub normf @ stub norml diff --git a/dlls/msvcr120/msvcr120.spec b/dlls/msvcr120/msvcr120.spec index 47834e5d62..cfb7889d4a 100644 --- a/dlls/msvcr120/msvcr120.spec +++ b/dlls/msvcr120/msvcr120.spec @@ -2302,9 +2302,9 @@ @ cdecl nextafter(double double) MSVCRT__nextafter @ cdecl nextafterf(float float) MSVCRT__nextafterf @ cdecl nextafterl(double double) MSVCRT__nextafter -@ stub nexttoward -@ stub nexttowardf -@ stub nexttowardl +@ cdecl nexttoward(double double) MSVCRT_nexttoward +@ cdecl nexttowardf(float double) MSVCRT_nexttowardf +@ cdecl nexttowardl(double double) MSVCRT_nexttoward @ stub norm @ stub normf @ stub norml diff --git a/dlls/msvcr120/tests/msvcr120.c b/dlls/msvcr120/tests/msvcr120.c index 79b667e42b..42bb6257b5 100644 --- a/dlls/msvcr120/tests/msvcr120.c +++ b/dlls/msvcr120/tests/msvcr120.c @@ -192,6 +192,9 @@ static unsigned short (__cdecl *p_wctype)(const char*); static int (__cdecl *p_vsscanf)(const char*, const char *, __ms_va_list valist); static _Dcomplex* (__cdecl *p__Cbuild)(_Dcomplex*, double, double); static double (__cdecl *p_creal)(_Dcomplex); +static double (__cdecl *p_nexttoward)(double, double); +static float (__cdecl *p_nexttowardf)(float, double); +static double (__cdecl *p_nexttowardl)(double, double);
/* make sure we use the correct errno */ #undef errno @@ -252,6 +255,9 @@ static BOOL init(void) SET(p_vsscanf, "vsscanf"); SET(p__Cbuild, "_Cbuild"); SET(p_creal, "creal"); + SET(p_nexttoward, "nexttoward"); + SET(p_nexttowardf, "nexttowardf"); + SET(p_nexttowardl, "nexttowardl"); if(sizeof(void*) == 8) { /* 64-bit initialization */ SET(p_critical_section_ctor, "??0critical_section@Concurrency@@QEAA@XZ"); @@ -964,6 +970,48 @@ static void test__Cbuild(void) ok(d == 3.0, "creal returned %lf\n", d); }
+static void test_nexttoward(void) +{ + double d; + float f; + int i; + + struct + { + double source; + double dir; + float f; + double d; + } + tests[] = + { + {0.0, 1.0, 1.0e-45f, 5.0e-324}, + {0.0, -1.0, -1.0e-45f, -5.0e-324}, + {1.0, 2.0, 1.00000012f, 1.0000000000000002}, + {1.0, 0.0, 0.99999994f, 0.9999999999999999}, + {1.0, 1.0, 1.0f, 1.0}, + {0.0, INFINITY, 1.0e-45f, 5.0e-324}, + {FLT_MAX, INFINITY, INFINITY, 3.402823466385289e+038}, + {DBL_MAX, INFINITY, INFINITY, INFINITY}, + {INFINITY, 0, FLT_MAX, DBL_MAX}, + }; + + for (i = 0; i < ARRAY_SIZE(tests); ++i) + { + d = p_nexttoward(tests[i].source, tests[i].dir); + ok(d == tests[i].d, "Expected %0.16e, got %0.16e.\n", tests[i].d, d); + f = p_nexttowardf(tests[i].source, tests[i].dir); + ok(f == tests[i].f, "Expected %0.8e, got %0.8e.\n", tests[i].f, f); + d = p_nexttowardl(tests[i].source, tests[i].dir); + ok(d == tests[i].d, "Expected %0.16e, got %0.16e.\n", tests[i].d, d); + } + + d = p_nexttoward(NAN, 0); + ok(_isnan(d), "Expected NAN, got %0.16e.\n", d); + d = p_nexttoward(0, NAN); + ok(_isnan(d), "Expected NAN, got %0.16e.\n", d); +} + START_TEST(msvcr120) { if (!init()) return; @@ -983,4 +1031,5 @@ START_TEST(msvcr120) test_wctype(); test_vsscanf(); test__Cbuild(); + test_nexttoward(); } diff --git a/dlls/msvcr120_app/msvcr120_app.spec b/dlls/msvcr120_app/msvcr120_app.spec index e5b26a4746..c139b8e251 100644 --- a/dlls/msvcr120_app/msvcr120_app.spec +++ b/dlls/msvcr120_app/msvcr120_app.spec @@ -1965,9 +1965,9 @@ @ cdecl nextafter(double double) msvcr120.nextafter @ cdecl nextafterf(float float) msvcr120.nextafterf @ cdecl nextafterl(double double) msvcr120.nextafterl -@ stub nexttoward -@ stub nexttowardf -@ stub nexttowardl +@ cdecl nexttoward(double double) msvcr120.nexttoward +@ cdecl nexttowardf(float double) msvcr120.nexttowardf +@ cdecl nexttowardl(double double) msvcr120.nexttowardl @ stub norm @ stub normf @ stub norml diff --git a/dlls/msvcrt/math.c b/dlls/msvcrt/math.c index d4785d3508..c83818c9ce 100644 --- a/dlls/msvcrt/math.c +++ b/dlls/msvcrt/math.c @@ -1542,6 +1542,22 @@ double CDECL MSVCRT__nextafter(double num, double next) return retval; }
+/********************************************************************* + * nexttoward (MSVCRT.@) + */ +double CDECL MSVCRT_nexttoward(double num, double next) +{ + return nexttoward(num, next); +} + +/********************************************************************* + * nexttoward (MSVCRT.@) + */ +float CDECL MSVCRT_nexttowardf(float num, double next) +{ + return nexttowardf(num, next); +} + /********************************************************************* * _ecvt (MSVCRT.@) */ diff --git a/dlls/ucrtbase/ucrtbase.spec b/dlls/ucrtbase/ucrtbase.spec index 142ac86913..7c729123d9 100644 --- a/dlls/ucrtbase/ucrtbase.spec +++ b/dlls/ucrtbase/ucrtbase.spec @@ -2438,9 +2438,9 @@ @ cdecl nextafter(double double) MSVCRT__nextafter @ cdecl nextafterf(float float) MSVCRT__nextafterf @ cdecl nextafterl(double double) MSVCRT__nextafter -@ stub nexttoward -@ stub nexttowardf -@ stub nexttowardl +@ cdecl nexttoward(double double) MSVCRT_nexttoward +@ cdecl nexttowardf(float double) MSVCRT_nexttowardf +@ cdecl nexttowardl(double double) MSVCRT_nexttoward @ stub norm @ stub normf @ stub norml
Thanks for working on this. You should add some error handling tests for nexttoward to test_math_errors in dlls/ucrtbase/tests/misc.c.
-Alex
Hi Zebediah,
You should probably add configure checks for nexttowad* availability.
Thanks, Piotr