Bladeren bron

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

Denis Vlasenko 16 jaren geleden
bovenliggende
commit
d4f94ef391
11 gewijzigde bestanden met toevoegingen van 68 en 216 verwijderingen
  1. 4 5
      libm/Makefile.in
  2. 0 25
      libm/e_gamma.c
  3. 0 25
      libm/e_gamma_r.c
  4. 0 26
      libm/e_lgamma.c
  5. 60 8
      libm/e_lgamma_r.c
  6. 2 0
      libm/e_remainder.c
  7. 2 2
      libm/math_private.h
  8. 0 13
      libm/w_drem.c
  9. 0 36
      libm/w_gamma.c
  10. 0 37
      libm/w_lgamma.c
  11. 0 39
      libm/w_tgamma.c

+ 4 - 5
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 \

+ 0 - 25
libm/e_gamma.c

@@ -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 <math.h>
-#include "math_private.h"
-
-double attribute_hidden __ieee754_gamma(double x)
-{
-	return __ieee754_gamma_r(x, &signgam);
-}

+ 0 - 25
libm/e_gamma_r.c

@@ -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);
-}

+ 0 - 26
libm/e_lgamma.c

@@ -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 <math.h>
-#include "math_private.h"
-
-double attribute_hidden __ieee754_lgamma(double x)
-{
-	return __ieee754_lgamma_r(x,&signgam);
-}

+ 60 - 8
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)

+ 2 - 0
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)

+ 2 - 2
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;

+ 0 - 13
libm/w_drem.c

@@ -1,13 +0,0 @@
-/*
- * drem() wrapper for remainder().
- *
- * Written by J.T. Conklin, <jtc@wimsey.com>
- * Placed into the Public Domain, 1994.
- */
-
-#include <math.h>
-
-double drem(double x, double y)
-{
-	return remainder(x, y);
-}

+ 0 - 36
libm/w_gamma.c

@@ -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 <math.h>
-#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
-}

+ 0 - 37
libm/w_lgamma.c

@@ -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 <math.h>
-#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)

+ 0 - 39
libm/w_tgamma.c

@@ -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)