Skip to content

Commit b545ba0

Browse files
dimpaseserhiy-storchaka
authored andcommitted
[2.7] bpo-36106: resolve sinpi name clash with libm (IEEE-754 violation). (GH-12027) (GH-12050)
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 worked 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).
1 parent af83770 commit b545ba0

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Resolve potential name clash with libm's sinpi(). Patch by Dmitrii Pasechnik.

Modules/mathmodule.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ static const double pi = 3.141592653589793238462643383279502884197;
7171
static const double sqrtpi = 1.772453850905516027298167483341145182798;
7272

7373
static double
74-
sinpi(double x)
74+
m_sinpi(double x)
7575
{
7676
double y, r;
7777
int n;
@@ -270,7 +270,7 @@ m_tgamma(double x)
270270
integer. */
271271
if (absx > 200.0) {
272272
if (x < 0.0) {
273-
return 0.0/sinpi(x);
273+
return 0.0/m_sinpi(x);
274274
}
275275
else {
276276
errno = ERANGE;
@@ -294,7 +294,7 @@ m_tgamma(double x)
294294
}
295295
z = z * lanczos_g / y;
296296
if (x < 0.0) {
297-
r = -pi / sinpi(absx) / absx * exp(y) / lanczos_sum(absx);
297+
r = -pi / m_sinpi(absx) / absx * exp(y) / lanczos_sum(absx);
298298
r -= z * r;
299299
if (absx < 140.0) {
300300
r /= pow(y, absx - 0.5);
@@ -366,7 +366,7 @@ m_lgamma(double x)
366366
(x-0.5)*(log(x+lanczos_g-0.5)-1);
367367
}
368368
else {
369-
r = log(pi) - log(fabs(sinpi(absx))) - log(absx) -
369+
r = log(pi) - log(fabs(m_sinpi(absx))) - log(absx) -
370370
(log(lanczos_sum(absx)) - lanczos_g +
371371
(absx-0.5)*(log(absx+lanczos_g-0.5)-1));
372372
}

0 commit comments

Comments
 (0)