diff options
author | Victor Stinner <vstinner@python.org> | 2021-10-13 21:27:50 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-13 21:27:50 (GMT) |
commit | 194a9526d8ee6abbbe58ef48520ec87a7e83f327 (patch) | |
tree | ff8b22ba8a475d7da5a5b5a6ca75316bd9d44c5d /Include/pymath.h | |
parent | aac29af6785712019d34f1a7f15b3c408a4f68ae (diff) | |
download | cpython-194a9526d8ee6abbbe58ef48520ec87a7e83f327.zip cpython-194a9526d8ee6abbbe58ef48520ec87a7e83f327.tar.gz cpython-194a9526d8ee6abbbe58ef48520ec87a7e83f327.tar.bz2 |
bpo-45440: Require math.h isinf() to build (GH-28894)
Building Python now requires a C99 <math.h> header file providing
isinf(), isnan() and isfinite() functions.
Remove the Py_FORCE_DOUBLE() macro. It was used by the
Py_IS_INFINITY() macro.
Changes:
* Remove Py_IS_NAN(), Py_IS_INFINITY() and Py_IS_FINITE()
in PC/pyconfig.h.
* Remove the _Py_force_double() function.
* configure no longer checks if math.h defines isinf(), isnan() and
isfinite().
Diffstat (limited to 'Include/pymath.h')
-rw-r--r-- | Include/pymath.h | 80 |
1 files changed, 9 insertions, 71 deletions
diff --git a/Include/pymath.h b/Include/pymath.h index d688e50..57310fc 100644 --- a/Include/pymath.h +++ b/Include/pymath.h @@ -4,8 +4,6 @@ #ifndef Py_PYMATH_H #define Py_PYMATH_H -#include "pyconfig.h" // HAVE_DECL_ISNAN - /* High precision definition of pi and e (Euler) * The values are taken from libc6's math.h. */ @@ -29,77 +27,17 @@ #define Py_MATH_TAU 6.2831853071795864769252867665590057683943L #endif +// Py_IS_NAN(X) +// Return 1 if float or double arg is a NaN, else 0. +#define Py_IS_NAN(X) isnan(X) -/* On x86, Py_FORCE_DOUBLE forces a floating-point number out of an x87 FPU - register and into a 64-bit memory location, rounding from extended - precision to double precision in the process. On other platforms it does - nothing. */ - -/* we take double rounding as evidence of x87 usage */ -#ifndef Py_LIMITED_API -#ifndef Py_FORCE_DOUBLE -# ifdef X87_DOUBLE_ROUNDING -PyAPI_FUNC(double) _Py_force_double(double); -# define Py_FORCE_DOUBLE(X) (_Py_force_double(X)) -# else -# define Py_FORCE_DOUBLE(X) (X) -# endif -#endif -#endif - -/* Py_IS_NAN(X) - * Return 1 if float or double arg is a NaN, else 0. - * Caution: - * X is evaluated more than once. - * This may not work on all platforms. Each platform has *some* - * way to spell this, though -- override in pyconfig.h if you have - * a platform where it doesn't work. - * Note: PC/pyconfig.h defines Py_IS_NAN as _isnan - */ -#ifndef Py_IS_NAN -# if defined HAVE_DECL_ISNAN && HAVE_DECL_ISNAN == 1 -# define Py_IS_NAN(X) isnan(X) -# else -# define Py_IS_NAN(X) ((X) != (X)) -# endif -#endif - -/* Py_IS_INFINITY(X) - * Return 1 if float or double arg is an infinity, else 0. - * Caution: - * X is evaluated more than once. - * This implementation may set the underflow flag if |X| is very small; - * it really can't be implemented correctly (& easily) before C99. - * Override in pyconfig.h if you have a better spelling on your platform. - * Py_FORCE_DOUBLE is used to avoid getting false negatives from a - * non-infinite value v sitting in an 80-bit x87 register such that - * v becomes infinite when spilled from the register to 64-bit memory. - * Note: PC/pyconfig.h defines Py_IS_INFINITY as _isinf - */ -#ifndef Py_IS_INFINITY -# if defined HAVE_DECL_ISINF && HAVE_DECL_ISINF == 1 -# define Py_IS_INFINITY(X) isinf(X) -# else -# define Py_IS_INFINITY(X) ((X) && \ - (Py_FORCE_DOUBLE(X)*0.5 == Py_FORCE_DOUBLE(X))) -# endif -#endif +// Py_IS_INFINITY(X) +// Return 1 if float or double arg is an infinity, else 0. +#define Py_IS_INFINITY(X) isinf(X) -/* Py_IS_FINITE(X) - * Return 1 if float or double arg is neither infinite nor NAN, else 0. - * Some compilers (e.g. VisualStudio) have intrinsics for this, so a special - * macro for this particular test is useful - * Note: PC/pyconfig.h defines Py_IS_FINITE as _finite - */ -#ifndef Py_IS_FINITE -# if defined HAVE_DECL_ISFINITE && HAVE_DECL_ISFINITE == 1 -# define Py_IS_FINITE(X) isfinite(X) -# elif defined HAVE_FINITE -# define Py_IS_FINITE(X) finite(X) -# else -# define Py_IS_FINITE(X) (!Py_IS_INFINITY(X) && !Py_IS_NAN(X)) -# endif -#endif +// Py_IS_FINITE(X) +// Return 1 if float or double arg is neither infinite nor NAN, else 0. +#define Py_IS_FINITE(X) isfinite(X) /* HUGE_VAL is supposed to expand to a positive double infinity. Python * uses Py_HUGE_VAL instead because some platforms are broken in this |