This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: Fix tgamma errno setting on underflow (bug 6810)
- From: Andreas Jaeger <aj at suse dot com>
- To: "Joseph S. Myers" <joseph at codesourcery dot com>, libc-alpha at sourceware dot org
- Date: Thu, 05 Dec 2013 10:21:11 +0100
- Subject: Re: Fix tgamma errno setting on underflow (bug 6810)
- Authentication-results: sourceware.org; auth=none
- References: <Pine dot LNX dot 4 dot 64 dot 1312050154590 dot 21433 at digraph dot polyomino dot org dot uk>
On 12/05/2013 02:56 AM, Joseph S. Myers wrote:
> diff --git a/math/w_tgamma.c b/math/w_tgamma.c
> index 6b6c7c5..d993917 100644
> --- a/math/w_tgamma.c
> +++ b/math/w_tgamma.c
> @@ -15,6 +15,7 @@
> * depending on the library mode.
> */
>
> +#include <errno.h>
> #include <math.h>
> #include <math_private.h>
>
> @@ -24,13 +25,15 @@ __tgamma(double x)
> int local_signgam;
> double y = __ieee754_gamma_r(x,&local_signgam);
>
> - if(__builtin_expect(!__finite(y), 0)
> + if(__builtin_expect(!__finite(y) || y == 0, 0)
I suggest to use __glibc_unlikely for this line.
> && (__finite (x) || __isinf (x) < 0)
> && _LIB_VERSION != _IEEE_) {
> if (x == 0.0)
> return __kernel_standard(x,x,50); /* tgamma pole */
> else if(__floor(x)==x&&x<0.0)
> return __kernel_standard(x,x,41); /* tgamma domain */
> + else if (y == 0)
> + __set_errno (ERANGE); /* tgamma underflow */
> else
> return __kernel_standard(x,x,40); /* tgamma overflow */
> }
> diff --git a/math/w_tgammaf.c b/math/w_tgammaf.c
> index 8bb553e..952fcec 100644
> --- a/math/w_tgammaf.c
> +++ b/math/w_tgammaf.c
> @@ -13,6 +13,7 @@
> * ====================================================
> */
>
> +#include <errno.h>
> #include <math.h>
> #include <math_private.h>
>
> @@ -22,7 +23,7 @@ __tgammaf(float x)
> int local_signgam;
> float y = __ieee754_gammaf_r(x,&local_signgam);
>
> - if(__builtin_expect(!__finitef(y), 0)
> + if(__builtin_expect(!__finitef(y) || y == 0, 0)
Again, let's use __glibc_unlikely,
Fine with those changes,
Andreas
--
Andreas Jaeger aj@{suse.com,opensuse.org} Twitter/Identica: jaegerandi
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn,Jennifer Guild,Felix Imendörffer,HRB16746 (AG Nürnberg)
GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126