aboutsummaryrefslogtreecommitdiff
path: root/math
diff options
context:
space:
mode:
Diffstat (limited to 'math')
-rw-r--r--math/Makefile2
-rw-r--r--math/Versions1
-rw-r--r--math/bits/mathcalls.h6
-rw-r--r--math/libm-test.c67
4 files changed, 39 insertions, 37 deletions
diff --git a/math/Makefile b/math/Makefile
index 9f2d3367e5..4bd9580084 100644
--- a/math/Makefile
+++ b/math/Makefile
@@ -49,7 +49,7 @@ libm-calls = e_acos e_acosh e_asin e_atan2 e_atanh e_cosh e_exp e_fmod \
s_modf s_nextafter s_nextafterx s_rint s_scalbn s_scalbln \
s_significand s_sin s_tan s_tanh w_acos w_acosh w_asin \
w_atan2 w_atanh w_cosh w_drem w_exp w_exp2 w_exp10 w_fmod \
- w_gamma w_hypot w_j0 w_j1 w_jn w_lgamma w_lgamma_r \
+ w_tgamma w_hypot w_j0 w_j1 w_jn w_lgamma w_lgamma_r \
w_log w_log10 w_pow w_remainder w_scalb w_sinh w_sqrt \
s_signbit s_fpclassify s_fmax s_fmin s_fdim s_nan s_trunc \
s_remquo s_log2 s_exp2 s_round s_nearbyint s_sincos \
diff --git a/math/Versions b/math/Versions
index 8864ef1b87..580fa253aa 100644
--- a/math/Versions
+++ b/math/Versions
@@ -111,6 +111,7 @@ libm {
scalbln; scalblnf; scalblnl;
sincos; sincosf; sincosl;
trunc; truncf; truncl;
+ tgamma; tgammaf; tgammal;
# complex functions
cabs; cabsf; cabsl;
diff --git a/math/bits/mathcalls.h b/math/bits/mathcalls.h
index 30bbb7c0aa..a94707ffe3 100644
--- a/math/bits/mathcalls.h
+++ b/math/bits/mathcalls.h
@@ -224,8 +224,12 @@ __MATHCALL (yn,, (int, _Mdouble_));
/* Error, gamma, and Bessel functions. */
__MATHCALL (erf,, (_Mdouble_));
__MATHCALL (erfc,, (_Mdouble_));
-__MATHCALL (gamma,, (_Mdouble_));
__MATHCALL (lgamma,, (_Mdouble_));
+__MATHCALL (tgamma,, (_Mdouble_));
+#endif
+
+#if defined __USE_MISC || defined __USE_XOPEN
+__MATHCALL (gamma,, (_Mdouble_));
#endif
#ifdef __USE_MISC
diff --git a/math/libm-test.c b/math/libm-test.c
index 52358d5b34..95d285e1c7 100644
--- a/math/libm-test.c
+++ b/math/libm-test.c
@@ -51,7 +51,7 @@
modf, nearbyint, nextafter,
pow, remainder, remquo, rint, lrint, llrint,
round, lround, llround,
- scalb, scalbn, signbit, sin, sincos, sinh, sqrt, tan, tanh, trunc
+ scalb, scalbn, signbit, sin, sincos, sinh, sqrt, tan, tanh, tgamma, trunc
and for the following complex math functions:
cabs, cacos, cacosh, carg, casin, casinh, catan, catanh,
@@ -1413,15 +1413,9 @@ signbit_test (void)
}
-/*
- gamma has different semantics depending on _LIB_VERSION:
- if _LIB_VERSION is _SVID, gamma is just an alias for lgamma,
- otherwise gamma is the real gamma function as definied in ISO C 9X.
-*/
static void
gamma_test (void)
{
- int save_lib_version = _LIB_VERSION;
errno = 0;
FUNC(gamma) (1);
if (errno == ENOSYS)
@@ -1430,14 +1424,12 @@ gamma_test (void)
feclearexcept (FE_ALL_EXCEPT);
- _LIB_VERSION = _SVID_;
-
check_isinfp ("gamma (+inf) == +inf", FUNC(gamma) (plus_infty));
- check_exc ("gamma (0) == HUGE plus divide by zero exception",
- FUNC(gamma) (0), HUGE, DIVIDE_BY_ZERO_EXCEPTION);
+ check_isinfp_exc ("gamma (0) == +inf plus divide by zero exception",
+ FUNC(gamma) (0), DIVIDE_BY_ZERO_EXCEPTION);
- check_exc ("gamma (x) == HUGE plus divide by zero exception for integer x <= 0",
- FUNC(gamma) (-3), HUGE, DIVIDE_BY_ZERO_EXCEPTION);
+ check_isinfp_exc ("gamma (x) == +inf plus divide by zero exception for integer x <= 0",
+ FUNC(gamma) (-3), DIVIDE_BY_ZERO_EXCEPTION);
check_isnan_exc ("gamma (-inf) == NaN plus invalid exception",
FUNC(gamma) (minus_infty), INVALID_EXCEPTION);
@@ -1459,39 +1451,43 @@ gamma_test (void)
FUNC(log) (2*FUNC(sqrt) (M_PIl)), CHOOSE (0, 1e-15, 0));
check_int ("gamma (-0.5) sets signgam to -1", signgam, -1);
+}
- _LIB_VERSION = _IEEE_;
+static void
+tgamma_test (void)
+{
+ errno = 0;
+ FUNC(tgamma) (1);
+ if (errno == ENOSYS)
+ /* Function not implemented. */
+ return;
+ feclearexcept (FE_ALL_EXCEPT);
- check_isinfp ("gamma (+inf) == +inf", FUNC(gamma) (plus_infty));
- check_isnan_exc ("gamma (0) == NaN plus invalid exception",
- FUNC(gamma) (0), INVALID_EXCEPTION);
- check_isnan_exc_ext ("gamma (x) == NaN plus invalid exception for integer x <= 0",
- FUNC(gamma) (-2), INVALID_EXCEPTION, -2);
- check_isnan_exc ("gamma (-inf) == NaN plus invalid exception",
- FUNC(gamma) (minus_infty), INVALID_EXCEPTION);
+ check_isinfp ("tgamma (+inf) == +inf", FUNC(tgamma) (plus_infty));
+ check_isnan_exc ("tgamma (0) == NaN plus invalid exception",
+ FUNC(tgamma) (0), INVALID_EXCEPTION);
+
+ check_isnan_exc_ext ("tgamma (x) == NaN plus invalid exception for integer x <= 0",
+ FUNC(tgamma) (-2), INVALID_EXCEPTION, -2);
+ check_isnan_exc ("tgamma (-inf) == NaN plus invalid exception",
+ FUNC(tgamma) (minus_infty), INVALID_EXCEPTION);
#ifdef TODO
- check_eps ("gamma (0.5) == sqrt(pi)", FUNC(gamma) (0.5), FUNC(sqrt) (M_PIl),
- CHOOSE (0, 5e-16, 2e-7));
+ check_eps ("tgamma (0.5) == sqrt(pi)", FUNC(tgamma) (0.5),
+ FUNC(sqrt) (M_PIl), CHOOSE (0, 5e-16, 2e-7));
#endif
- check_eps ("gamma (-0.5) == -2*sqrt(pi)", FUNC(gamma) (-0.5),
+ check_eps ("tgamma (-0.5) == -2*sqrt(pi)", FUNC(tgamma) (-0.5),
-2*FUNC(sqrt) (M_PIl), CHOOSE (0, 5e-16, 3e-7));
- check ("gamma (1) == 1", FUNC(gamma) (1), 1);
- check ("gamma (4) == 6", FUNC(gamma) (4), 6);
+ check ("tgamma (1) == 1", FUNC(tgamma) (1), 1);
+ check ("tgamma (4) == 6", FUNC(tgamma) (4), 6);
- check_eps ("gamma (0.7) == 1.29805...", FUNC(gamma) (0.7),
+ check_eps ("tgamma (0.7) == 1.29805...", FUNC(tgamma) (0.7),
1.29805533264755778568L, CHOOSE(0, 3e-16, 2e-7));
- check ("gamma (1.2) == 0.91816...", FUNC(gamma) (1.2), 0.91816874239976061064L);
-
- check_isnan_exc ("gamma (0.0) == NaN plus invalid exception",
- FUNC(gamma) (0.0), INVALID_EXCEPTION);
- check_isnan_exc ("gamma (-1.0) == NaN plus invalid exception",
- FUNC(gamma) (-1.0), INVALID_EXCEPTION);
-
- _LIB_VERSION = save_lib_version;
+ check ("tgamma (1.2) == 0.91816...", FUNC(tgamma) (1.2),
+ 0.91816874239976061064L);
}
@@ -6012,6 +6008,7 @@ main (int argc, char *argv[])
erf_test ();
erfc_test ();
gamma_test ();
+ tgamma_test ();
lgamma_test ();
/* nearest integer functions */