diff --git a/dlls/msvcr120/msvcr120.spec b/dlls/msvcr120/msvcr120.spec index cdd5848f7e9..102d6319f47 100644 --- a/dlls/msvcr120/msvcr120.spec +++ b/dlls/msvcr120/msvcr120.spec @@ -2303,9 +2303,9 @@ @ cdecl nextafter(double double) @ cdecl nextafterf(float float) @ cdecl nextafterl(double double) nextafter -@ cdecl nexttoward(double double) MSVCRT_nexttoward -@ cdecl nexttowardf(float double) MSVCRT_nexttowardf -@ cdecl nexttowardl(double double) MSVCRT_nexttoward +@ cdecl nexttoward(double double) __nexttoward +@ cdecl nexttowardf(float double) __nexttowardf +@ cdecl nexttowardl(double double) __nexttoward @ stub norm @ stub normf @ stub norml diff --git a/dlls/msvcrt/math.c b/dlls/msvcrt/math.c index dbd9bde4d32..68218b7007b 100644 --- a/dlls/msvcrt/math.c +++ b/dlls/msvcrt/math.c @@ -4076,59 +4076,6 @@ float CDECL nearbyintf(float x) return x; } -/********************************************************************* - * nexttoward (MSVCR120.@) - */ -double CDECL MSVCRT_nexttoward(double num, double next) -{ - return nextafter(num, next); -} - -/********************************************************************* - * nexttowardf (MSVCR120.@) - * - * Copied from musl: src/math/nexttowardf.c - */ -float CDECL MSVCRT_nexttowardf(float x, double y) -{ - unsigned int ix = *(unsigned int*)&x; - unsigned int e; - float ret; - - if (isnan(x) || isnan(y)) - return x + y; - if (x == y) - return y; - if (x == 0) { - ix = 1; - if (signbit(y)) - ix |= 0x80000000; - } else if (x < y) { - if (signbit(x)) - ix--; - else - ix++; - } else { - if (signbit(x)) - ix++; - else - ix--; - } - e = ix & 0x7f800000; - /* raise overflow if ix is infinite and x is finite */ - if (e == 0x7f800000) { - fp_barrierf(x + x); - *_errno() = ERANGE; - } - ret = *(float*)&ix; - /* raise underflow if ret is subnormal or zero */ - if (e == 0) { - fp_barrierf(x * x + ret * ret); - *_errno() = ERANGE; - } - return ret; -} - #endif /* _MSVCR_VER>=120 */ /********************************************************************* diff --git a/dlls/ucrtbase/ucrtbase.spec b/dlls/ucrtbase/ucrtbase.spec index a6db1a60c5d..a476681fc43 100644 --- a/dlls/ucrtbase/ucrtbase.spec +++ b/dlls/ucrtbase/ucrtbase.spec @@ -1733,9 +1733,9 @@ @ cdecl _o_nextafter(double double) nextafter @ cdecl _o_nextafterf(float float) nextafterf @ cdecl _o_nextafterl(double double) nextafter -@ cdecl _o_nexttoward(double double) MSVCRT_nexttoward -@ cdecl _o_nexttowardf(float double) MSVCRT_nexttowardf -@ cdecl _o_nexttowardl(double double) MSVCRT_nexttoward +@ cdecl _o_nexttoward(double double) __nexttoward +@ cdecl _o_nexttowardf(float double) __nexttowardf +@ cdecl _o_nexttowardl(double double) __nexttoward @ cdecl _o_pow(double double) pow @ cdecl -arch=!i386 _o_powf(float float) powf @ cdecl _o_putc(long ptr) putc @@ -2441,9 +2441,9 @@ @ cdecl nextafter(double double) @ cdecl nextafterf(float float) @ cdecl nextafterl(double double) nextafter -@ cdecl nexttoward(double double) MSVCRT_nexttoward -@ cdecl nexttowardf(float double) MSVCRT_nexttowardf -@ cdecl nexttowardl(double double) MSVCRT_nexttoward +@ cdecl nexttoward(double double) __nexttoward +@ cdecl nexttowardf(float double) __nexttowardf +@ cdecl nexttowardl(double double) __nexttoward @ stub norm @ stub normf @ stub norml diff --git a/libs/musl/src/math/nexttoward.c b/libs/musl/src/math/nexttoward.c index e4cef9535c3..85fbb486129 100644 --- a/libs/musl/src/math/nexttoward.c +++ b/libs/musl/src/math/nexttoward.c @@ -1,7 +1,7 @@ #include "libm.h" #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 -double __cdecl nexttoward(double x, long double y) +double __cdecl __nexttoward(double x, double y) { return nextafter(x, y); } diff --git a/libs/musl/src/math/nexttowardf.c b/libs/musl/src/math/nexttowardf.c index 6c32f6c6733..5be52b882d1 100644 --- a/libs/musl/src/math/nexttowardf.c +++ b/libs/musl/src/math/nexttowardf.c @@ -1,6 +1,6 @@ #include "libm.h" -float __cdecl nexttowardf(float x, long double y) +float __cdecl __nexttowardf(float x, double y) { union {float f; uint32_t i;} ux = {x}; uint32_t e; @@ -26,10 +26,14 @@ float __cdecl nexttowardf(float x, long double y) } e = ux.i & 0x7f800000; /* raise overflow if ux.f is infinite and x is finite */ - if (e == 0x7f800000) + if (e == 0x7f800000) { FORCE_EVAL(x+x); + errno = ERANGE; + } /* raise underflow if ux.f is subnormal or zero */ - if (e == 0) + if (e == 0) { FORCE_EVAL(x*x + ux.f*ux.f); + errno = ERANGE; + } return ux.f; }