Fw: [PATCH 3/3] libm: Adjust errno/exception values for gamma/lgamma
C Howland
cc1964t@gmail.com
Thu Aug 27 17:55:33 GMT 2020
> ------------------------------
> *From:* Newlib <newlib-bounces@sourceware.org> on behalf of Keith Packard
> via Newlib <newlib@sourceware.org>
> *Sent:* Wednesday, August 26, 2020 1:03 PM
> *To:* newlib@sourceware.org <newlib@sourceware.org>
> *Subject:* [PATCH 3/3] libm: Adjust errno/exception values for
> gamma/lgamma
>
>
>
>
> This makes all of gamma/lgamma functions match POSIX (and glibc) for
> errno and exception values for both gamma and lgamma functions.
>
> The big change is to support the exception/errno value differences for
> tgamma/lgamma for negative integer arguments. tgamma produces
> EDOM/FE_INVALID while lgamma produces ERANGE/FE_DIVBYZERO.
>
> This was done by splitting the lowest level __ieee754_lgamma*_r
> functions apart. The new lower-level ___ieee754_lgamma*_r functions
> can now produce exceptions which are correct for either lgamma or
> tgamma and use the value in the signgamp parameter to select which
> mode to operate in.
>
> All functions now return EDOM/FE_INVALID for -INFINITY, although POSIX
> doesn't specify this behavior for lgamma. It does match glibc at
> least.
>
I think you're looking at an old GLIBC. From my RHEL7 lgamma() man page:
" If the result overflows, a range error occurs, and the functions
return
HUGE_VAL, HUGE_VALF, or HUGE_VALL, respectively, with the correct
math‐
ematical sign.
...
BUGS
In glibc 2.9 and earlier, when a pole error occurs, errno is set
to
EDOM; instead of the POSIX-mandated ERANGE. Since version 2.10,
glibc
does the right thing."
POSIX has only pole and range errors listed for lgamma(), both of which
return ERANGE, so it is definitely improper to return EDOM. It should be
range, so ERANGE/FE_OVERFLOW is what it ought to be.
>
> Signed-off-by: Keith Packard <keithp@keithp.com>
>
>
More information about the Newlib
mailing list