summaryrefslogtreecommitdiff
path: root/ext/POSIX
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2014-11-17 20:36:22 -0500
committerJarkko Hietaniemi <jhi@iki.fi>2014-11-17 21:04:41 -0500
commit256fef9369dcaa9ef030bed7ae45a20a6e67d234 (patch)
tree90e9f7beb24e62f361e6cf3f68b2560a7d6d76b8 /ext/POSIX
parent7678a27f4952a056585a8a498c06ed926556563b (diff)
downloadperl-256fef9369dcaa9ef030bed7ae45a20a6e67d234.tar.gz
Platform may have only one of lgamma/tgamma.
Diffstat (limited to 'ext/POSIX')
-rw-r--r--ext/POSIX/POSIX.xs23
1 files changed, 11 insertions, 12 deletions
diff --git a/ext/POSIX/POSIX.xs b/ext/POSIX/POSIX.xs
index 8a985bcb89..452f766f27 100644
--- a/ext/POSIX/POSIX.xs
+++ b/ext/POSIX/POSIX.xs
@@ -736,13 +736,18 @@ static IV my_ilogb(NV x)
* nor these) do NOT set the global signgam variable. This is not
* necessarily a bad thing. */
-/* Note that tgamma() and lgamma() depend on each other. */
-#if !defined(c99_tgamma) || !defined(c99_lgamma)
+/* Note that tgamma() and lgamma() implementations depend on each other. */
+
+#ifndef c99_tgamma
static NV my_tgamma(NV x);
+# define c99_tgamma my_tgamma
+#endif
+#ifndef c99_lgamma
static NV my_lgamma(NV x);
+# define c99_lgamma my_lgamma
#endif
-#if !defined(c99_tgamma) || !defined(c99_lgamma)
+#ifndef HAS_TGAMMA
static NV my_tgamma(NV x)
{
const NV gamma = 0.577215664901532860606512090; /* Euler's gamma constant. */
@@ -826,14 +831,11 @@ static NV my_tgamma(NV x)
return NV_INF;
}
- return Perl_exp(my_lgamma(x));
+ return Perl_exp(c99_lgamma(x));
}
-# ifndef c99_tgamma
-# define c99_tgamma my_tgamma
-# endif
#endif
-#if !defined(c99_lgamma) || !defined(c99_tgamma)
+#ifndef HAS_LGAMMA
static NV my_lgamma(NV x)
{
if (Perl_isnan(x))
@@ -843,7 +845,7 @@ static NV my_lgamma(NV x)
if (x == 1.0 || x == 2.0)
return 0;
if (x < 12.0)
- return Perl_log(PERL_ABS(my_tgamma(x)));
+ return Perl_log(PERL_ABS(c99_tgamma(x)));
/* Abramowitz and Stegun 6.1.41
* Asymptotic series should be good to at least 11 or 12 figures
* For error analysis, see Whittiker and Watson
@@ -873,9 +875,6 @@ static NV my_lgamma(NV x)
return (x - 0.5) * Perl_log(x) - x + half_log_of_two_pi + series;
}
}
-# ifndef c99_lgamma
-# define c99_lgamma my_lgamma
-# endif
#endif
#ifndef c99_log1p