summaryrefslogtreecommitdiffstats
path: root/Modules/cmathmodule.c
diff options
context:
space:
mode:
authorChristian Heimes <christian@python.org>2021-10-25 08:25:27 (GMT)
committerGitHub <noreply@github.com>2021-10-25 08:25:27 (GMT)
commitfa26245a1c1aa938cce391348d6bd879da357522 (patch)
treeb193ebf766f3105a880ce8d8f7160b090b0c77b2 /Modules/cmathmodule.c
parent51ed2c56a1852cd6b09c85ba81312dc9782772ce (diff)
downloadcpython-fa26245a1c1aa938cce391348d6bd879da357522.zip
cpython-fa26245a1c1aa938cce391348d6bd879da357522.tar.gz
cpython-fa26245a1c1aa938cce391348d6bd879da357522.tar.bz2
bpo-45548: Remove _math.c workarounds for pre-C99 libm (GH-29179)
The :mod:`math` and :mod:`cmath` implementation now require a C99 compatible ``libm`` and no longer ship with workarounds for missing acosh, asinh, expm1, and log1p functions. The changeset also removes ``_math.c`` and moves the last remaining workaround into ``_math.h``. This simplifies static builds with ``Modules/Setup`` and resolves symbol conflicts. Co-authored-by: Mark Dickinson <mdickinson@enthought.com> Co-authored-by: Brett Cannon <brett@python.org> Signed-off-by: Christian Heimes <christian@python.org>
Diffstat (limited to 'Modules/cmathmodule.c')
-rw-r--r--Modules/cmathmodule.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/Modules/cmathmodule.c b/Modules/cmathmodule.c
index 0e0489c..281d393 100644
--- a/Modules/cmathmodule.c
+++ b/Modules/cmathmodule.c
@@ -8,11 +8,13 @@
#include "Python.h"
#include "pycore_dtoa.h"
-#include "_math.h"
/* 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>
+/* For _Py_log1p with workarounds for buggy handling of zeros. */
+#include "_math.h"
+
#include "clinic/cmathmodule.c.h"
/*[clinic input]
module cmath
@@ -246,7 +248,7 @@ cmath_acos_impl(PyObject *module, Py_complex z)
s2.imag = z.imag;
s2 = cmath_sqrt_impl(module, s2);
r.real = 2.*atan2(s1.real, s2.real);
- r.imag = m_asinh(s2.real*s1.imag - s2.imag*s1.real);
+ r.imag = asinh(s2.real*s1.imag - s2.imag*s1.real);
}
errno = 0;
return r;
@@ -280,7 +282,7 @@ cmath_acosh_impl(PyObject *module, Py_complex z)
s2.real = z.real + 1.;
s2.imag = z.imag;
s2 = cmath_sqrt_impl(module, s2);
- r.real = m_asinh(s1.real*s2.real + s1.imag*s2.imag);
+ r.real = asinh(s1.real*s2.real + s1.imag*s2.imag);
r.imag = 2.*atan2(s1.imag, s2.real);
}
errno = 0;
@@ -340,7 +342,7 @@ cmath_asinh_impl(PyObject *module, Py_complex z)
s2.real = 1.-z.imag;
s2.imag = z.real;
s2 = cmath_sqrt_impl(module, s2);
- r.real = m_asinh(s1.real*s2.imag-s2.real*s1.imag);
+ r.real = asinh(s1.real*s2.imag-s2.real*s1.imag);
r.imag = atan2(z.imag, s1.real*s2.real-s1.imag*s2.imag);
}
errno = 0;