Skip to content

Commit 4125e5c

Browse files
bpo-26121: Revert to using the own implementations of lgamma and gamma on all platforms. (#637)
1 parent c2cf128 commit 4125e5c

File tree

2 files changed

+1
-33
lines changed

2 files changed

+1
-33
lines changed

Misc/NEWS

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,7 @@ Library
284284
- bpo-28692: Using non-integer value for selecting a plural form in gettext is
285285
now deprecated.
286286

287-
- bpo-26121: Use C library implementation for math functions:
288-
tgamma(), lgamma(), erf() and erfc().
287+
- bpo-26121: Use C library implementation for math functions erf() and erfc().
289288

290289
- bpo-29619: os.stat() and os.DirEntry.inode() now convert inode (st_ino) using
291290
unsigned integers.

Modules/mathmodule.c

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,6 @@ static const double pi = 3.141592653589793238462643383279502884197;
7474
static const double sqrtpi = 1.772453850905516027298167483341145182798;
7575
static const double logpi = 1.144729885849400174143427351353058711647;
7676

77-
#ifndef __APPLE__
78-
# ifdef HAVE_TGAMMA
79-
# define USE_TGAMMA
80-
# endif
81-
# ifdef HAVE_LGAMMA
82-
# define USE_LGAMMA
83-
# endif
84-
#endif
85-
86-
#if !defined(USE_TGAMMA) || !defined(USE_LGAMMA)
87-
8877
static double
8978
sinpi(double x)
9079
{
@@ -241,7 +230,6 @@ lanczos_sum(double x)
241230
}
242231
return num/den;
243232
}
244-
#endif /* !defined(USE_TGAMMA) || !defined(USE_LGAMMA) */
245233

246234
/* Constant for +infinity, generated in the same way as float('inf'). */
247235

@@ -275,14 +263,6 @@ m_nan(void)
275263
static double
276264
m_tgamma(double x)
277265
{
278-
#ifdef USE_TGAMMA
279-
if (x == 0.0) {
280-
errno = EDOM;
281-
/* tgamma(+-0.0) = +-inf, divide-by-zero */
282-
return copysign(Py_HUGE_VAL, x);
283-
}
284-
return tgamma(x);
285-
#else
286266
double absx, r, y, z, sqrtpow;
287267

288268
/* special cases */
@@ -374,7 +354,6 @@ m_tgamma(double x)
374354
if (Py_IS_INFINITY(r))
375355
errno = ERANGE;
376356
return r;
377-
#endif
378357
}
379358

380359
/*
@@ -386,15 +365,6 @@ static double
386365
m_lgamma(double x)
387366
{
388367
double r;
389-
390-
#ifdef USE_LGAMMA
391-
r = lgamma(x);
392-
if (errno == ERANGE && x == floor(x) && x <= 0.0) {
393-
errno = EDOM; /* lgamma(n) = inf, divide-by-zero for */
394-
return Py_HUGE_VAL; /* integers n <= 0 */
395-
}
396-
return r;
397-
#else
398368
double absx;
399369

400370
/* special cases */
@@ -433,7 +403,6 @@ m_lgamma(double x)
433403
if (Py_IS_INFINITY(r))
434404
errno = ERANGE;
435405
return r;
436-
#endif
437406
}
438407

439408
#if !defined(HAVE_ERF) || !defined(HAVE_ERFC)

0 commit comments

Comments
 (0)