]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[2.7] bpo-36106: resolve sinpi name clash with libm (IEEE-754 violation). (GH-12027...
authorDima Pasechnik <dimpase@gmail.com>
Tue, 26 Feb 2019 10:41:15 +0000 (10:41 +0000)
committerSerhiy Storchaka <storchaka@gmail.com>
Tue, 26 Feb 2019 10:41:15 +0000 (12:41 +0200)
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).

Misc/NEWS.d/next/Library/2019-02-25-13-21-43.bpo-36106.VuhEiQ.rst [new file with mode: 0644]
Modules/mathmodule.c

diff --git a/Misc/NEWS.d/next/Library/2019-02-25-13-21-43.bpo-36106.VuhEiQ.rst b/Misc/NEWS.d/next/Library/2019-02-25-13-21-43.bpo-36106.VuhEiQ.rst
new file mode 100644 (file)
index 0000000..36e1750
--- /dev/null
@@ -0,0 +1 @@
+Resolve potential name clash with libm's sinpi(). Patch by Dmitrii Pasechnik.
index 67354a759498d5d8abf2f344570fd0dbc4d2ca83..e2ad281e12075a08b2071f8789afd618e28c4fb5 100644 (file)
@@ -71,7 +71,7 @@ static const double pi = 3.141592653589793238462643383279502884197;
 static const double sqrtpi = 1.772453850905516027298167483341145182798;
 
 static double
-sinpi(double x)
+m_sinpi(double x)
 {
     double y, r;
     int n;
@@ -270,7 +270,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;
@@ -294,7 +294,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);
@@ -366,7 +366,7 @@ m_lgamma(double x)
             (x-0.5)*(log(x+lanczos_g-0.5)-1);
     }
     else {
-        r = log(pi) - log(fabs(sinpi(absx))) - log(absx) -
+        r = log(pi) - log(fabs(m_sinpi(absx))) - log(absx) -
             (log(lanczos_sum(absx)) - lanczos_g +
              (absx-0.5)*(log(absx+lanczos_g-0.5)-1));
     }