mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-01-19 04:49:25 +08:00
1f8e5847df
The current gamma, gamma_r, gammaf and gammaf_r functions return |gamma(x)| instead of ln(|gamma(x)|) due to a change made back in 2002 to the __ieee754_gamma_r implementation. This patch fixes that, making all of these functions map too their lgamma equivalents. To fix the underlying bug, the __ieee754_gamma functions have been changed to return gamma(x), removing the _r variants as those are no longer necessary. Their names have been changed to __ieee754_tgamma to avoid potential confusion from users. Now that the __ieee754_tgamma functions return the correctly signed value, the tgamma functions have been modified to use them. libm.a now exposes the following gamma functions: ln(|gamma(x)|): __ieee754_lgamma_r __ieee754_lgammaf_r lgamma lgamma_r gamma gamma_r lgammaf lgammaf_r gammaf gammaf_r lgammal (on machines where long double is double) gamma(x): __ieee754_tgamma __ieee754_tgammaf tgamma tgammaf tgammal (on machines where long double is double) Additional aliases for any of the above functions can be added if necessary; in particular, I'm not sure if we need to include __ieee754_gamma*_r functions (which would return ln(|(gamma(x)|). Signed-off-by: Keith Packard <keithp@keithp.com> ---- v2: Switch commit message to ASCII
44 lines
863 B
C
44 lines
863 B
C
/* wf_gamma.c -- float version of w_gamma.c.
|
|
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
|
|
*/
|
|
|
|
/*
|
|
* ====================================================
|
|
* 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.
|
|
* ====================================================
|
|
*
|
|
*/
|
|
|
|
#include "fdlibm.h"
|
|
#include <reent.h>
|
|
#include <errno.h>
|
|
|
|
#ifdef __STDC__
|
|
float gammaf(float x)
|
|
#else
|
|
float gammaf(x)
|
|
float x;
|
|
#endif
|
|
{
|
|
return lgammaf(x);
|
|
}
|
|
|
|
#ifdef _DOUBLE_IS_32BITS
|
|
|
|
#ifdef __STDC__
|
|
double gamma(double x)
|
|
#else
|
|
double gamma(x)
|
|
double x;
|
|
#endif
|
|
{
|
|
return (double) lgammaf((float) x);
|
|
}
|
|
|
|
#endif /* defined(_DOUBLE_IS_32BITS) */
|