[PATCH 0/3] libm: Clean up gamma functions
Keith Packard
keithp@keithp.com
Wed Aug 26 17:03:54 GMT 2020
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).
More information about the Newlib
mailing list