Skip to content

Commit 956c3d3

Browse files
dimpasevstinner
authored andcommitted
00446: Resolve sinpi name clash with libm
bpo-36106: Resolve sinpi name clash with libm (IEEE-754 violation). (pythonGH-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). (cherry picked from commit f57cd82) Co-authored-by: Victor Stinner <vstinner@python.org>
1 parent 38e5d6c commit 956c3d3

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Modules/mathmodule.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ static const double sqrtpi = 1.772453850905516027298167483341145182798;
6767
static const double logpi = 1.144729885849400174143427351353058711647;
6868

6969
static double
70-
sinpi(double x)
70+
m_sinpi(double x)
7171
{
7272
double y, r;
7373
int n;
@@ -296,7 +296,7 @@ m_tgamma(double x)
296296
integer. */
297297
if (absx > 200.0) {
298298
if (x < 0.0) {
299-
return 0.0/sinpi(x);
299+
return 0.0/m_sinpi(x);
300300
}
301301
else {
302302
errno = ERANGE;
@@ -320,7 +320,7 @@ m_tgamma(double x)
320320
}
321321
z = z * lanczos_g / y;
322322
if (x < 0.0) {
323-
r = -pi / sinpi(absx) / absx * exp(y) / lanczos_sum(absx);
323+
r = -pi / m_sinpi(absx) / absx * exp(y) / lanczos_sum(absx);
324324
r -= z * r;
325325
if (absx < 140.0) {
326326
r /= pow(y, absx - 0.5);
@@ -390,7 +390,7 @@ m_lgamma(double x)
390390
r += (absx - 0.5) * (log(absx + lanczos_g - 0.5) - 1);
391391
if (x < 0.0)
392392
/* Use reflection formula to get value for negative x. */
393-
r = logpi - log(fabs(sinpi(absx))) - log(absx) - r;
393+
r = logpi - log(fabs(m_sinpi(absx))) - log(absx) - r;
394394
if (Py_IS_INFINITY(r))
395395
errno = ERANGE;
396396
return r;

0 commit comments

Comments
 (0)