bpo-36106: Resolve sinpi name clash with libm (IEEE-754 violation). (GH-12027)

The standard math library (libm) may follow IEEE-754 recommendation to
include an implementation of sinPi(), i.e. sinPi(x):=sin(pi*x).
And this triggers a name clash, found by FreeBSD developer
Steve Kargl, who worken on putting sinpi into libm used on FreeBSD
(it has to be named "sinpi", not "sinPi", cf. e.g.
https://en.cppreference.com/w/c/experimental/fpext4).
This commit is contained in:
Dima Pasechnik 2019-02-26 06:36:11 +00:00 committed by Serhiy Storchaka
parent ff3d39faa8
commit f57cd8288d
2 changed files with 5 additions and 4 deletions

View File

@ -0,0 +1 @@
Resolve potential name clash with libm's sinpi(). Patch by Dmitrii Pasechnik.

View File

@ -100,7 +100,7 @@ static const double sqrtpi = 1.772453850905516027298167483341145182798;
} }
static double static double
sinpi(double x) m_sinpi(double x)
{ {
double y, r; double y, r;
int n; int n;
@ -328,7 +328,7 @@ m_tgamma(double x)
integer. */ integer. */
if (absx > 200.0) { if (absx > 200.0) {
if (x < 0.0) { if (x < 0.0) {
return 0.0/sinpi(x); return 0.0/m_sinpi(x);
} }
else { else {
errno = ERANGE; errno = ERANGE;
@ -352,7 +352,7 @@ m_tgamma(double x)
} }
z = z * lanczos_g / y; z = z * lanczos_g / y;
if (x < 0.0) { if (x < 0.0) {
r = -pi / sinpi(absx) / absx * exp(y) / lanczos_sum(absx); r = -pi / m_sinpi(absx) / absx * exp(y) / lanczos_sum(absx);
r -= z * r; r -= z * r;
if (absx < 140.0) { if (absx < 140.0) {
r /= pow(y, absx - 0.5); r /= pow(y, absx - 0.5);
@ -423,7 +423,7 @@ m_lgamma(double x)
r += (absx - 0.5) * (log(absx + lanczos_g - 0.5) - 1); r += (absx - 0.5) * (log(absx + lanczos_g - 0.5) - 1);
if (x < 0.0) if (x < 0.0)
/* Use reflection formula to get value for negative x. */ /* Use reflection formula to get value for negative x. */
r = logpi - log(fabs(sinpi(absx))) - log(absx) - r; r = logpi - log(fabs(m_sinpi(absx))) - log(absx) - r;
if (Py_IS_INFINITY(r)) if (Py_IS_INFINITY(r))
errno = ERANGE; errno = ERANGE;
return r; return r;