Commit c12ff71c authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

msvcrt: Import nexttowardf implementation from musl.

parent ac4e6759
...@@ -19640,7 +19640,6 @@ for ac_func in \ ...@@ -19640,7 +19640,6 @@ for ac_func in \
log1pf \ log1pf \
log2 \ log2 \
log2f \ log2f \
nexttowardf \
remainder \ remainder \
remainderf \ remainderf \
remquo \ remquo \
......
...@@ -2680,7 +2680,6 @@ AC_CHECK_FUNCS(\ ...@@ -2680,7 +2680,6 @@ AC_CHECK_FUNCS(\
log1pf \ log1pf \
log2 \ log2 \
log2f \ log2f \
nexttowardf \
remainder \ remainder \
remainderf \ remainderf \
remquo \ remquo \
......
...@@ -3492,13 +3492,44 @@ double CDECL MSVCRT_nexttoward(double num, double next) ...@@ -3492,13 +3492,44 @@ double CDECL MSVCRT_nexttoward(double num, double next)
/********************************************************************* /*********************************************************************
* nexttowardf (MSVCR120.@) * nexttowardf (MSVCR120.@)
*
* Copied from musl: src/math/nexttowardf.c
*/ */
float CDECL MSVCRT_nexttowardf(float num, double next) float CDECL MSVCRT_nexttowardf(float x, double y)
{ {
float ret = unix_funcs->nexttowardf( num, next ); unsigned int ix = *(unsigned int*)&x;
if (!(_fpclass(ret) & (_FPCLASS_PN | _FPCLASS_NN unsigned int e;
| _FPCLASS_SNAN | _FPCLASS_QNAN)) && !isinf(num)) 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; *_errno() = ERANGE;
} }
return ret; return ret;
......
...@@ -548,19 +548,6 @@ static float CDECL unix_modff( float x, float *iptr ) ...@@ -548,19 +548,6 @@ static float CDECL unix_modff( float x, float *iptr )
} }
/********************************************************************* /*********************************************************************
* nexttowardf
*/
static float CDECL unix_nexttowardf(float num, double next)
{
#ifdef HAVE_NEXTTOWARDF
return nexttowardf(num, next);
#else
FIXME("not implemented\n");
return 0;
#endif
}
/*********************************************************************
* pow * pow
*/ */
static double CDECL unix_pow( double x, double y ) static double CDECL unix_pow( double x, double y )
...@@ -793,7 +780,6 @@ static const struct unix_funcs funcs = ...@@ -793,7 +780,6 @@ static const struct unix_funcs funcs =
unix_logbf, unix_logbf,
unix_modf, unix_modf,
unix_modff, unix_modff,
unix_nexttowardf,
unix_pow, unix_pow,
unix_powf, unix_powf,
unix_remainder, unix_remainder,
......
...@@ -72,7 +72,6 @@ struct unix_funcs ...@@ -72,7 +72,6 @@ struct unix_funcs
float (CDECL *logbf)(float x); float (CDECL *logbf)(float x);
double (CDECL *modf)(double x, double *iptr); double (CDECL *modf)(double x, double *iptr);
float (CDECL *modff)(float x, float *iptr); float (CDECL *modff)(float x, float *iptr);
float (CDECL *nexttowardf)(float x, double y);
double (CDECL *pow)(double x, double y); double (CDECL *pow)(double x, double y);
float (CDECL *powf)(float x, float y); float (CDECL *powf)(float x, float y);
double (CDECL *remainder)(double x, double y); double (CDECL *remainder)(double x, double y);
......
...@@ -567,9 +567,6 @@ ...@@ -567,9 +567,6 @@
/* Define to 1 if you have the <net/route.h> header file. */ /* Define to 1 if you have the <net/route.h> header file. */
#undef HAVE_NET_ROUTE_H #undef HAVE_NET_ROUTE_H
/* Define to 1 if you have the `nexttowardf' function. */
#undef HAVE_NEXTTOWARDF
/* Define to 1 if `_msg_ptr' is a member of `ns_msg'. */ /* Define to 1 if `_msg_ptr' is a member of `ns_msg'. */
#undef HAVE_NS_MSG__MSG_PTR #undef HAVE_NS_MSG__MSG_PTR
......
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