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>
This commit is contained in:
Christian Heimes 2021-10-25 11:25:27 +03:00 committed by GitHub
parent 51ed2c56a1
commit fa26245a1c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 51 additions and 346 deletions

View file

@ -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;