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 \
log1pf \
log2 \
log2f \
nexttowardf \
remainder \
remainderf \
remquo \
......
......@@ -2680,7 +2680,6 @@ AC_CHECK_FUNCS(\
log1pf \
log2 \
log2f \
nexttowardf \
remainder \
remainderf \
remquo \
......
......@@ -3492,13 +3492,44 @@ double CDECL MSVCRT_nexttoward(double num, double next)
/*********************************************************************
* 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 );
if (!(_fpclass(ret) & (_FPCLASS_PN | _FPCLASS_NN
| _FPCLASS_SNAN | _FPCLASS_QNAN)) && !isinf(num))
{
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;
......
......@@ -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
*/
static double CDECL unix_pow( double x, double y )
......@@ -793,7 +780,6 @@ static const struct unix_funcs funcs =
unix_logbf,
unix_modf,
unix_modff,
unix_nexttowardf,
unix_pow,
unix_powf,
unix_remainder,
......
......@@ -72,7 +72,6 @@ struct unix_funcs
float (CDECL *logbf)(float x);
double (CDECL *modf)(double x, double *iptr);
float (CDECL *modff)(float x, float *iptr);
float (CDECL *nexttowardf)(float x, double y);
double (CDECL *pow)(double x, double y);
float (CDECL *powf)(float x, float y);
double (CDECL *remainder)(double x, double y);
......
......@@ -567,9 +567,6 @@
/* Define to 1 if you have the <net/route.h> header file. */
#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'. */
#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