From d4f94ef391e602b6c2df453283ab2aeca1905eb2 Mon Sep 17 00:00:00 2001 From: Denis Vlasenko Date: Mon, 29 Dec 2008 16:00:21 +0000 Subject: libm/*: delete many incarnations of logarithmic gamma function, aliasing them instead af appropriate. Also alias drem to remainder. text data bss dec hex filename - 43568 176 4 43748 aae4 lib/libm.so + 43444 176 4 43624 aa68 lib/libm.so --- libm/Makefile.in | 9 ++++--- libm/e_gamma.c | 25 -------------------- libm/e_gamma_r.c | 25 -------------------- libm/e_lgamma.c | 26 -------------------- libm/e_lgamma_r.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++------- libm/e_remainder.c | 2 ++ libm/math_private.h | 4 ++-- libm/w_drem.c | 13 ---------- libm/w_gamma.c | 36 ---------------------------- libm/w_lgamma.c | 37 ----------------------------- libm/w_tgamma.c | 39 ------------------------------ 11 files changed, 68 insertions(+), 216 deletions(-) delete mode 100644 libm/e_gamma.c delete mode 100644 libm/e_gamma_r.c delete mode 100644 libm/e_lgamma.c delete mode 100644 libm/w_drem.c delete mode 100644 libm/w_gamma.c delete mode 100644 libm/w_lgamma.c delete mode 100644 libm/w_tgamma.c diff --git a/libm/Makefile.in b/libm/Makefile.in index f86f3985e..9cbe82c84 100644 --- a/libm/Makefile.in +++ b/libm/Makefile.in @@ -57,8 +57,8 @@ LD_MSRC := ldouble_wrappers.c ifeq ($(DO_C99_MATH),y) libm_CSRC := \ e_acos.c e_acosh.c e_asin.c e_atan2.c e_atanh.c e_cosh.c \ - e_exp.c e_fmod.c e_gamma.c e_gamma_r.c e_hypot.c e_j0.c \ - e_j1.c e_jn.c e_lgamma.c e_lgamma_r.c e_log.c e_log2.c e_log10.c \ + e_exp.c e_fmod.c e_hypot.c e_j0.c \ + e_j1.c e_jn.c e_lgamma_r.c e_log.c e_log2.c e_log10.c \ e_pow.c e_remainder.c e_rem_pio2.c e_scalb.c e_sinh.c \ e_sqrt.c k_cos.c k_rem_pio2.c k_sin.c k_standard.c k_tan.c \ s_asinh.c s_atan.c s_cbrt.c s_ceil.c s_copysign.c s_cos.c \ @@ -67,13 +67,12 @@ libm_CSRC := \ s_log1p.c s_logb.c s_matherr.c s_modf.c s_nextafter.c s_round.c \ s_rint.c s_scalbn.c s_signgam.c s_significand.c s_sin.c s_tan.c \ s_tanh.c s_trunc.c \ - w_cabs.c w_drem.c w_gamma.c \ - w_lgamma.c \ + w_cabs.c \ nan.c carg.c s_llrint.c \ s_fpclassify.c s_fpclassifyf.c s_signbit.c s_signbitf.c \ s_isnan.c s_isnanf.c s_isinf.c s_isinff.c s_finitef.c \ s_fdim.c s_fma.c s_fmax.c s_fmin.c \ - s_remquo.c s_scalbln.c w_exp2.c w_tgamma.c + s_remquo.c s_scalbln.c w_exp2.c # REMOVED: w_gamma_r.c FL_MOBJ := \ acosf.o acoshf.o asinf.o asinhf.o atan2f.o atanf.o atanhf.o cbrtf.o \ diff --git a/libm/e_gamma.c b/libm/e_gamma.c deleted file mode 100644 index 470c26ea6..000000000 --- a/libm/e_gamma.c +++ /dev/null @@ -1,25 +0,0 @@ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - * - */ - -/* __ieee754_gamma(x) - * Return the logarithm of the Gamma function of x. - * - * Method: call __ieee754_gamma_r - */ - -#include -#include "math_private.h" - -double attribute_hidden __ieee754_gamma(double x) -{ - return __ieee754_gamma_r(x, &signgam); -} diff --git a/libm/e_gamma_r.c b/libm/e_gamma_r.c deleted file mode 100644 index b244a24bb..000000000 --- a/libm/e_gamma_r.c +++ /dev/null @@ -1,25 +0,0 @@ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - * - */ - -/* __ieee754_gamma_r(x, signgamp) - * Reentrant version of the logarithm of the Gamma function - * with user provide pointer for the sign of Gamma(x). - * - * Method: See __ieee754_lgamma_r - */ - -#include "math_private.h" - -double attribute_hidden __ieee754_gamma_r(double x, int *signgamp) -{ - return __ieee754_lgamma_r(x, signgamp); -} diff --git a/libm/e_lgamma.c b/libm/e_lgamma.c deleted file mode 100644 index b9838c48a..000000000 --- a/libm/e_lgamma.c +++ /dev/null @@ -1,26 +0,0 @@ - -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - * - */ - -/* __ieee754_lgamma(x) - * Return the logarithm of the Gamma function of x. - * - * Method: call __ieee754_lgamma_r - */ - -#include -#include "math_private.h" - -double attribute_hidden __ieee754_lgamma(double x) -{ - return __ieee754_lgamma_r(x,&signgam); -} diff --git a/libm/e_lgamma_r.c b/libm/e_lgamma_r.c index 5aacadcfd..075fdc4f0 100644 --- a/libm/e_lgamma_r.c +++ b/libm/e_lgamma_r.c @@ -312,25 +312,77 @@ double lgamma_r(double x, int *signgamp) strong_alias(__ieee754_lgamma_r, lgamma_r) #endif +/* __ieee754_lgamma(x) + * Return the logarithm of the Gamma function of x. + */ +double attribute_hidden __ieee754_lgamma(double x) +{ + return __ieee754_lgamma_r(x, &signgam); +} + /* - * wrapper double gamma_r(double x, int *signgamp) + * wrapper double lgamma(double x) */ -double gamma_r(double x, int *signgamp); -libm_hidden_proto(gamma_r) #ifndef _IEEE_LIBM -double gamma_r(double x, int *signgamp) +double lgamma(double x) { - double y = __ieee754_lgamma_r(x, signgamp); + double y = __ieee754_lgamma_r(x, &signgam); if (_LIB_VERSION == _IEEE_) return y; if (!isfinite(y) && isfinite(x)) { if (floor(x) == x && x <= 0.0) - return __kernel_standard(x, x, 41); /* gamma pole */ - return __kernel_standard(x, x, 40); /* gamma overflow */ + return __kernel_standard(x, x, 15); /* lgamma pole */ + return __kernel_standard(x, x, 14); /* lgamma overflow */ } return y; } #else +strong_alias(__ieee754_lgamma, lgamma); +#endif +libm_hidden_def(lgamma) + + + +/* NB: gamma function is an old name for lgamma. + * It is deprecated. + * Some C math libraries redefine it as a "true gamma", i.e., + * not a ln(|Gamma(x)|) but just Gamma(x), but standards + * introduced tgamma name for that. + */ +#ifndef _IEEE_LIBM +strong_alias(lgamma_r, gamma_r) +strong_alias(lgamma, gamma) +#else strong_alias(__ieee754_lgamma_r, gamma_r) +strong_alias(__ieee754_lgamma, gamma) +#endif + + + +// FIXME! Looks like someone just used __ieee754_gamma_r, +// believing it's a "true" gamma function, but it was not! +// Our tgamma is WRONG. + +/* double tgamma(double x) + * Return the Gamma function of x. + */ +double tgamma(double x) +{ + double y; + int local_signgam; + + y = __ieee754_lgamma_r(x, &local_signgam); // was __ieee754_gamma_r + if (local_signgam < 0) + y = -y; +#ifndef _IEEE_LIBM + if (_LIB_VERSION == _IEEE_) + return y; + if (!isfinite(y) && isfinite(x)) { + if (floor(x) == x && x <= 0.0) + return __kernel_standard(x, x, 41); /* tgamma pole */ + return __kernel_standard(x, x, 40); /* tgamma overflow */ + } #endif -libm_hidden_def(gamma_r) + return y; +} +libm_hidden_def(tgamma) diff --git a/libm/e_remainder.c b/libm/e_remainder.c index c4972cfdd..3d5ca772a 100644 --- a/libm/e_remainder.c +++ b/libm/e_remainder.c @@ -77,7 +77,9 @@ double remainder(double x, double y) return __kernel_standard(x, y, 28); /* remainder(x,0) */ return z; } +strong_alias(remainder, drem) #else strong_alias(__ieee754_remainder, remainder) +strong_alias(__ieee754_remainder, drem) #endif libm_hidden_def(remainder) diff --git a/libm/math_private.h b/libm/math_private.h index 437371f34..80c270718 100644 --- a/libm/math_private.h +++ b/libm/math_private.h @@ -162,9 +162,9 @@ extern double __ieee754_cosh (double) attribute_hidden; extern double __ieee754_fmod (double,double) attribute_hidden; extern double __ieee754_pow (double,double) attribute_hidden; extern double __ieee754_lgamma_r (double,int *) attribute_hidden; -extern double __ieee754_gamma_r (double,int *) attribute_hidden; +/*extern double __ieee754_gamma_r (double,int *) attribute_hidden;*/ extern double __ieee754_lgamma (double) attribute_hidden; -extern double __ieee754_gamma (double) attribute_hidden; +/*extern double __ieee754_gamma (double) attribute_hidden;*/ extern double __ieee754_log10 (double) attribute_hidden; extern double __ieee754_sinh (double) attribute_hidden; extern double __ieee754_hypot (double,double) attribute_hidden; diff --git a/libm/w_drem.c b/libm/w_drem.c deleted file mode 100644 index 046e17756..000000000 --- a/libm/w_drem.c +++ /dev/null @@ -1,13 +0,0 @@ -/* - * drem() wrapper for remainder(). - * - * Written by J.T. Conklin, - * Placed into the Public Domain, 1994. - */ - -#include - -double drem(double x, double y) -{ - return remainder(x, y); -} diff --git a/libm/w_gamma.c b/libm/w_gamma.c deleted file mode 100644 index 246c8f764..000000000 --- a/libm/w_gamma.c +++ /dev/null @@ -1,36 +0,0 @@ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -/* double gamma(double x) - * Return the logarithm of the Gamma function of x. - * - * Method: call gamma_r - */ - -#include -#include "math_private.h" - -double gamma(double x) -{ -#ifdef _IEEE_LIBM - return __ieee754_lgamma_r(x, &signgam); -#else - double y = __ieee754_lgamma_r(x, &signgam); - if (_LIB_VERSION == _IEEE_) - return y; - if (!isfinite(y) && isfinite(x)) { - if (floor(x) == x && x <= 0.0) - return __kernel_standard(x, x, 41); /* gamma pole */ - return __kernel_standard(x, x, 40); /* gamma overflow */ - } - return y; -#endif -} diff --git a/libm/w_lgamma.c b/libm/w_lgamma.c deleted file mode 100644 index 9ef9051f1..000000000 --- a/libm/w_lgamma.c +++ /dev/null @@ -1,37 +0,0 @@ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -/* double lgamma(double x) - * Return the logarithm of the Gamma function of x. - * - * Method: call __ieee754_lgamma_r - */ - -#include -#include "math_private.h" - -double lgamma(double x) -{ -#ifdef _IEEE_LIBM - return __ieee754_lgamma_r(x, &signgam); -#else - double y = __ieee754_lgamma_r(x, &signgam); - if (_LIB_VERSION == _IEEE_) - return y; - if (!isfinite(y) && isfinite(x)) { - if (floor(x) == x && x <= 0.0) - return __kernel_standard(x, x, 15); /* lgamma pole */ - return __kernel_standard(x, x, 14); /* lgamma overflow */ - } - return y; -#endif -} -libm_hidden_def(lgamma) diff --git a/libm/w_tgamma.c b/libm/w_tgamma.c deleted file mode 100644 index 3ad473b2f..000000000 --- a/libm/w_tgamma.c +++ /dev/null @@ -1,39 +0,0 @@ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -/* double gamma(double x) - * Return the logarithm of the Gamma function of x or the Gamma function of x, - * depending on the library mode. - */ - -#include "math.h" -#include "math_private.h" - -double tgamma(double x) -{ - double y; - int local_signgam; - - y = __ieee754_gamma_r(x, &local_signgam); - if (local_signgam < 0) - y = -y; -#ifndef _IEEE_LIBM - if (_LIB_VERSION == _IEEE_) - return y; - if (!isfinite(y) && isfinite(x)) { - if (floor(x) == x && x <= 0.0) - return __kernel_standard(x, x, 41); /* tgamma pole */ - return __kernel_standard(x, x, 40); /* tgamma overflow */ - } -#endif - return y; -} -libm_hidden_def(tgamma) -- cgit v1.2.3