diff options
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/cmathmodule.c | 15 | ||||
-rw-r--r-- | Modules/mathmodule.c | 9 |
2 files changed, 13 insertions, 11 deletions
diff --git a/Modules/cmathmodule.c b/Modules/cmathmodule.c index 281d393..c0c0c35 100644 --- a/Modules/cmathmodule.c +++ b/Modules/cmathmodule.c @@ -7,7 +7,8 @@ #endif #include "Python.h" -#include "pycore_dtoa.h" +#include "pycore_pymath.h" // _PY_SHORT_FLOAT_REPR +#include "pycore_dtoa.h" // _Py_dg_stdnan() /* we need DBL_MAX, DBL_MIN, DBL_EPSILON, DBL_MANT_DIG and FLT_RADIX from float.h. We assume that FLT_RADIX is either 2 or 16. */ #include <float.h> @@ -89,14 +90,14 @@ else { /* Constants cmath.inf, cmath.infj, cmath.nan, cmath.nanj. cmath.nan and cmath.nanj are defined only when either - PY_NO_SHORT_FLOAT_REPR is *not* defined (which should be + _PY_SHORT_FLOAT_REPR is 1 (which should be the most common situation on machines using an IEEE 754 representation), or Py_NAN is defined. */ static double m_inf(void) { -#ifndef PY_NO_SHORT_FLOAT_REPR +#if _PY_SHORT_FLOAT_REPR == 1 return _Py_dg_infinity(0); #else return Py_HUGE_VAL; @@ -112,12 +113,12 @@ c_infj(void) return r; } -#if !defined(PY_NO_SHORT_FLOAT_REPR) || defined(Py_NAN) +#if _PY_SHORT_FLOAT_REPR == 1 || defined(Py_NAN) static double m_nan(void) { -#ifndef PY_NO_SHORT_FLOAT_REPR +#if _PY_SHORT_FLOAT_REPR == 1 return _Py_dg_stdnan(0); #else return Py_NAN; @@ -1281,7 +1282,7 @@ cmath_exec(PyObject *mod) PyComplex_FromCComplex(c_infj())) < 0) { return -1; } -#if !defined(PY_NO_SHORT_FLOAT_REPR) || defined(Py_NAN) +#if _PY_SHORT_FLOAT_REPR == 1 || defined(Py_NAN) if (PyModule_AddObject(mod, "nan", PyFloat_FromDouble(m_nan())) < 0) { return -1; } @@ -1426,4 +1427,4 @@ PyMODINIT_FUNC PyInit_cmath(void) { return PyModuleDef_Init(&cmathmodule); -}
\ No newline at end of file +} diff --git a/Modules/mathmodule.c b/Modules/mathmodule.c index 721c9a6..24ae146 100644 --- a/Modules/mathmodule.c +++ b/Modules/mathmodule.c @@ -62,6 +62,7 @@ raised for division by zero and mod by zero. #include "pycore_call.h" // _PyObject_CallNoArgs() #include "pycore_dtoa.h" // _Py_dg_infinity() #include "pycore_long.h" // _PyLong_GetZero() +#include "pycore_pymath.h" // _PY_SHORT_FLOAT_REPR /* For DBL_EPSILON in _math.h */ #include <float.h> /* For _Py_log1p with workarounds for buggy handling of zeros. */ @@ -272,7 +273,7 @@ lanczos_sum(double x) static double m_inf(void) { -#ifndef PY_NO_SHORT_FLOAT_REPR +#if _PY_SHORT_FLOAT_REPR == 1 return _Py_dg_infinity(0); #else return Py_HUGE_VAL; @@ -282,12 +283,12 @@ m_inf(void) /* Constant nan value, generated in the same way as float('nan'). */ /* We don't currently assume that Py_NAN is defined everywhere. */ -#if !defined(PY_NO_SHORT_FLOAT_REPR) || defined(Py_NAN) +#if _PY_SHORT_FLOAT_REPR == 1 || defined(Py_NAN) static double m_nan(void) { -#ifndef PY_NO_SHORT_FLOAT_REPR +#if _PY_SHORT_FLOAT_REPR == 1 return _Py_dg_stdnan(0); #else return Py_NAN; @@ -3837,7 +3838,7 @@ math_exec(PyObject *module) if (PyModule_AddObject(module, "inf", PyFloat_FromDouble(m_inf())) < 0) { return -1; } -#if !defined(PY_NO_SHORT_FLOAT_REPR) || defined(Py_NAN) +#if _PY_SHORT_FLOAT_REPR == 1 || defined(Py_NAN) if (PyModule_AddObject(module, "nan", PyFloat_FromDouble(m_nan())) < 0) { return -1; } |