Skip to content

Commit

Permalink
bpo-36106: Resolve sinpi name clash with libm (IEEE-754 violation). (G…
Browse files Browse the repository at this point in the history
…H-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: Dima Pasechnik <dimpase@gmail.com>
  • Loading branch information
miss-islington and dimpase authored Feb 26, 2019
1 parent 0395869 commit 4e6646f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Resolve potential name clash with libm's sinpi(). Patch by Dmitrii Pasechnik.
8 changes: 4 additions & 4 deletions Modules/mathmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ static const double sqrtpi = 1.772453850905516027298167483341145182798;
#endif /* !defined(HAVE_ERF) || !defined(HAVE_ERFC) */

static double
sinpi(double x)
m_sinpi(double x)
{
double y, r;
int n;
Expand Down Expand Up @@ -305,7 +305,7 @@ m_tgamma(double x)
integer. */
if (absx > 200.0) {
if (x < 0.0) {
return 0.0/sinpi(x);
return 0.0/m_sinpi(x);
}
else {
errno = ERANGE;
Expand All @@ -329,7 +329,7 @@ m_tgamma(double x)
}
z = z * lanczos_g / y;
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;
if (absx < 140.0) {
r /= pow(y, absx - 0.5);
Expand Down Expand Up @@ -400,7 +400,7 @@ m_lgamma(double x)
r += (absx - 0.5) * (log(absx + lanczos_g - 0.5) - 1);
if (x < 0.0)
/* 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))
errno = ERANGE;
return r;
Expand Down

0 comments on commit 4e6646f

Please sign in to comment.