diff options
author | Victor Stinner <vstinner@python.org> | 2022-02-23 17:16:23 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-23 17:16:23 (GMT) |
commit | 9bbdde218005f552304d9954bb97e3f9185edded (patch) | |
tree | 2085d4399dfdcb03bbf9af4c7e5cf92bbdb55f43 /Modules/mathmodule.c | |
parent | 375a56bd4015596c0cf44129c8842a1fe7199785 (diff) | |
download | cpython-9bbdde218005f552304d9954bb97e3f9185edded.zip cpython-9bbdde218005f552304d9954bb97e3f9185edded.tar.gz cpython-9bbdde218005f552304d9954bb97e3f9185edded.tar.bz2 |
bpo-45412: Add _PY_SHORT_FLOAT_REPR macro (GH-31171)
Remove the HAVE_PY_SET_53BIT_PRECISION macro (moved to the internal
C API).
* Move HAVE_PY_SET_53BIT_PRECISION macro to pycore_pymath.h.
* Replace PY_NO_SHORT_FLOAT_REPR macro with _PY_SHORT_FLOAT_REPR
macro which is always defined. gcc -Wundef emits a warning when
using _PY_SHORT_FLOAT_REPR but the macro is not defined, if
pycore_pymath.h include was forgotten.
Diffstat (limited to 'Modules/mathmodule.c')
-rw-r--r-- | Modules/mathmodule.c | 9 |
1 files changed, 5 insertions, 4 deletions
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; } |