[PATCH 2/2] msvcrt: Use isfinite instead of finitef
Alex Henrie
alexhenrie24 at gmail.com
Tue Sep 25 22:03:03 CDT 2018
Signed-off-by: Alex Henrie <alexhenrie24 at gmail.com>
---
This one wasn't causing any problems in practice that I know of, but
it's less confusing to just use the standard macro.
---
configure.ac | 1 -
dlls/msvcrt/math.c | 42 +++++++++++++++++++-----------------------
2 files changed, 19 insertions(+), 24 deletions(-)
diff --git a/configure.ac b/configure.ac
index 2cc481630c..ff8c98fde6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2146,7 +2146,6 @@ AC_CHECK_FUNCS(\
dlopen \
epoll_create \
ffs \
- finitef \
fnmatch \
fork \
fpclass \
diff --git a/dlls/msvcrt/math.c b/dlls/msvcrt/math.c
index dbfaa24756..a98defd868 100644
--- a/dlls/msvcrt/math.c
+++ b/dlls/msvcrt/math.c
@@ -34,10 +34,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
-#ifndef HAVE_FINITEF
-#define finitef(x) isfinite(x)
-#endif
-
/* FIXME: Does not work with -NAN and -0. */
#ifndef signbit
#define signbit(x) ((x) < 0)
@@ -159,7 +155,7 @@ float CDECL MSVCRT__copysignf( float num, float sign )
*/
float CDECL MSVCRT__nextafterf( float num, float next )
{
- if (!finitef(num) || !finitef(next)) *MSVCRT__errno() = MSVCRT_EDOM;
+ if (!isfinite(num) || !isfinite(next)) *MSVCRT__errno() = MSVCRT_EDOM;
return nextafterf( num, next );
}
@@ -171,7 +167,7 @@ float CDECL MSVCRT__nextafterf( float num, float next )
*/
int CDECL MSVCRT__finitef( float num )
{
- return finitef(num) != 0; /* See comment for _isnan() */
+ return isfinite(num) != 0; /* See comment for _isnan() */
}
/*********************************************************************
@@ -207,7 +203,7 @@ float CDECL MSVCRT_acosf( float x )
* cancellation. The sqrt() makes things worse. A safer way to calculate
* acos() is to use atan2(sqrt((1 - x) * (1 + x)), x). */
float ret = atan2f(sqrtf((1 - x) * (1 + x)), x);
- if (x < -1.0 || x > 1.0 || !finitef(x)) math_error(_DOMAIN, "acosf", x, 0, ret);
+ if (x < -1.0 || x > 1.0 || !isfinite(x)) math_error(_DOMAIN, "acosf", x, 0, ret);
return ret;
}
@@ -217,7 +213,7 @@ float CDECL MSVCRT_acosf( float x )
float CDECL MSVCRT_asinf( float x )
{
float ret = atan2f(x, sqrtf((1 - x) * (1 + x)));
- if (x < -1.0 || x > 1.0 || !finitef(x)) math_error(_DOMAIN, "asinf", x, 0, ret);
+ if (x < -1.0 || x > 1.0 || !isfinite(x)) math_error(_DOMAIN, "asinf", x, 0, ret);
return ret;
}
@@ -227,7 +223,7 @@ float CDECL MSVCRT_asinf( float x )
float CDECL MSVCRT_atanf( float x )
{
float ret = atanf(x);
- if (!finitef(x)) math_error(_DOMAIN, "atanf", x, 0, ret);
+ if (!isfinite(x)) math_error(_DOMAIN, "atanf", x, 0, ret);
return ret;
}
@@ -247,7 +243,7 @@ float CDECL MSVCRT_atan2f( float x, float y )
float CDECL MSVCRT_cosf( float x )
{
float ret = cosf(x);
- if (!finitef(x)) math_error(_DOMAIN, "cosf", x, 0, ret);
+ if (!isfinite(x)) math_error(_DOMAIN, "cosf", x, 0, ret);
return ret;
}
@@ -268,8 +264,8 @@ float CDECL MSVCRT_expf( float x )
{
float ret = expf(x);
if (isnan(x)) math_error(_DOMAIN, "expf", x, 0, ret);
- else if (finitef(x) && !ret) math_error(_UNDERFLOW, "expf", x, 0, ret);
- else if (finitef(x) && !finitef(ret)) math_error(_OVERFLOW, "expf", x, 0, ret);
+ else if (isfinite(x) && !ret) math_error(_UNDERFLOW, "expf", x, 0, ret);
+ else if (isfinite(x) && !isfinite(ret)) math_error(_OVERFLOW, "expf", x, 0, ret);
return ret;
}
@@ -279,7 +275,7 @@ float CDECL MSVCRT_expf( float x )
float CDECL MSVCRT_fmodf( float x, float y )
{
float ret = fmodf(x, y);
- if (!finitef(x) || !finitef(y)) math_error(_DOMAIN, "fmodf", x, 0, ret);
+ if (!isfinite(x) || !isfinite(y)) math_error(_DOMAIN, "fmodf", x, 0, ret);
return ret;
}
@@ -312,9 +308,9 @@ float CDECL MSVCRT_powf( float x, float y )
{
float z = powf(x,y);
if (x < 0 && y != floorf(y)) math_error(_DOMAIN, "powf", x, y, z);
- else if (!x && finitef(y) && y < 0) math_error(_SING, "powf", x, y, z);
- else if (finitef(x) && finitef(y) && !finitef(z)) math_error(_OVERFLOW, "powf", x, y, z);
- else if (x && finitef(x) && finitef(y) && !z) math_error(_UNDERFLOW, "powf", x, y, z);
+ else if (!x && isfinite(y) && y < 0) math_error(_SING, "powf", x, y, z);
+ else if (isfinite(x) && isfinite(y) && !isfinite(z)) math_error(_OVERFLOW, "powf", x, y, z);
+ else if (x && isfinite(x) && isfinite(y) && !z) math_error(_UNDERFLOW, "powf", x, y, z);
return z;
}
@@ -324,7 +320,7 @@ float CDECL MSVCRT_powf( float x, float y )
float CDECL MSVCRT_sinf( float x )
{
float ret = sinf(x);
- if (!finitef(x)) math_error(_DOMAIN, "sinf", x, 0, ret);
+ if (!isfinite(x)) math_error(_DOMAIN, "sinf", x, 0, ret);
return ret;
}
@@ -354,7 +350,7 @@ float CDECL MSVCRT_sqrtf( float x )
float CDECL MSVCRT_tanf( float x )
{
float ret = tanf(x);
- if (!finitef(x)) math_error(_DOMAIN, "tanf", x, 0, ret);
+ if (!isfinite(x)) math_error(_DOMAIN, "tanf", x, 0, ret);
return ret;
}
@@ -364,7 +360,7 @@ float CDECL MSVCRT_tanf( float x )
float CDECL MSVCRT_tanhf( float x )
{
float ret = tanhf(x);
- if (!finitef(x)) math_error(_DOMAIN, "tanhf", x, 0, ret);
+ if (!isfinite(x)) math_error(_DOMAIN, "tanhf", x, 0, ret);
return ret;
}
@@ -2468,7 +2464,7 @@ float CDECL MSVCR120_exp2f(float x)
{
#ifdef HAVE_EXP2F
float ret = exp2f(x);
- if (finitef(x) && !finitef(ret)) *MSVCRT__errno() = MSVCRT_ERANGE;
+ if (isfinite(x) && !isfinite(ret)) *MSVCRT__errno() = MSVCRT_ERANGE;
return ret;
#else
return MSVCR120_exp2(x);
@@ -2507,7 +2503,7 @@ float CDECL MSVCR120_expm1f(float x)
#else
float ret = exp(x) - 1;
#endif
- if (finitef(x) && !finitef(ret)) *MSVCRT__errno() = MSVCRT_ERANGE;
+ if (isfinite(x) && !isfinite(ret)) *MSVCRT__errno() = MSVCRT_ERANGE;
return ret;
}
@@ -3152,7 +3148,7 @@ float CDECL MSVCR120_atanhf(float x)
ret = atanhf(x);
- if (!finitef(ret)) *MSVCRT__errno() = MSVCRT_ERANGE;
+ if (!isfinite(ret)) *MSVCRT__errno() = MSVCRT_ERANGE;
return ret;
#else
return MSVCR120_atanh(x);
@@ -3223,7 +3219,7 @@ 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(!isfinite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
if(isnan(y) || y==0.0f) *MSVCRT__errno() = MSVCRT_EDOM;
return remainderf(x, y);
#else
--
2.19.0
More information about the wine-devel
mailing list