[PATCH 0/3] libm: Clean up gamma functions
Keith Packard via Newlib <[email protected]>
| Newsgroups | gmane.comp.lib.newlib |
|---|---|
| Message-ID | <[email protected]> |
This series cleans up some API oddities and inaccuracies in errno/exception reporting from the various gamma related functions. With this series applied, newlib now matches the POSIX spec (and glibc) for tgamma/lgamma functions. I've left the 'gamma' functions BSD compatible (tgamma instead of lgamma) to avoid changing the API. [PATCH 1/3] libm: Fix sign value returned from __ieee754_lgamma*_r(-0) Following the C spec, gamma(-0) should be -INFINITY rather than +INFINITY, so the *signgamp value in lgamma should be -1 rather than +1 for this case. [PATCH 2/3] libm: Remove __ieee754_gamma_r variants Back in 2002, a patch changed the various gamma functions so that the returned abs(gamma) instead of the ln of gamma. This left the _r variants in place, with their extra parameter to return the sign of the resulting value. This doesn't make any sense to me and looks like it was just a mistake. I've changed the __ieee754_gamma functions to apply the sign value locally and eliminated the gamma_r versions as those are no longer useful. [PATCH 3/3] libm: Adjust errno/exception values for gamma/lgamma There's a pretty detailed discussion in the commit message here, the short version is that tgamma and lgamma are specified with different errno/exception behaviour for one class of inputs (negative integers).