summaryrefslogtreecommitdiffstats
path: root/Modules/cmathmodule.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2022-02-23 17:16:23 (GMT)
committerGitHub <noreply@github.com>2022-02-23 17:16:23 (GMT)
commit9bbdde218005f552304d9954bb97e3f9185edded (patch)
tree2085d4399dfdcb03bbf9af4c7e5cf92bbdb55f43 /Modules/cmathmodule.c
parent375a56bd4015596c0cf44129c8842a1fe7199785 (diff)
downloadcpython-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/cmathmodule.c')
-rw-r--r--Modules/cmathmodule.c15
1 files changed, 8 insertions, 7 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
+}