From 9698b3b564a476ffd4148aa8dbd6c5bbe65e493b Mon Sep 17 00:00:00 2001 From: Bruce Evans Date: Wed, 2 May 2007 16:54:22 +0000 Subject: [PATCH] Don't assume that int is signed 32-bits in one place. Keep assuming that ints have >= 31 value bits elsewhere. s/int/int32_t/ seems to have been done too globally for all other files in msun/src before msun/ was imported into FreeBSD. Minor fixes in comments. e_lgamma_r.c: Describe special cases in more detail: - exception for lgamma(0) and lgamma(neg.integer) - lgamma(-Inf) = Inf. This is wrong but is required by C99 Annex F. I hope to change this. --- lib/msun/src/e_lgamma_r.c | 14 ++++++++------ lib/msun/src/e_lgammaf_r.c | 5 +++-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/msun/src/e_lgamma_r.c b/lib/msun/src/e_lgamma_r.c index 91989d552bfd..7f2767fe96b5 100644 --- a/lib/msun/src/e_lgamma_r.c +++ b/lib/msun/src/e_lgamma_r.c @@ -76,10 +76,11 @@ static char rcsid[] = "$FreeBSD$"; * * 5. Special Cases * lgamma(2+s) ~ s*(1-Euler) for tiny s - * lgamma(1)=lgamma(2)=0 - * lgamma(x) ~ -log(x) for tiny x - * lgamma(0) = lgamma(inf) = inf - * lgamma(-integer) = +-inf + * lgamma(1) = lgamma(2) = 0 + * lgamma(x) ~ -log(|x|) for tiny x + * lgamma(0) = lgamma(neg.integer) = inf and raise divide-by-zero + * lgamma(inf) = inf + * lgamma(-inf) = inf (bug for bug compatible with C99!?) * */ @@ -205,11 +206,12 @@ double __ieee754_lgamma_r(double x, int *signgamp) { double t,y,z,nadj,p,p1,p2,p3,q,r,w; - int i,hx,lx,ix; + int32_t hx; + int i,lx,ix; EXTRACT_WORDS(hx,lx,x); - /* purge off +-inf, NaN, +-0, and negative arguments */ + /* purge off +-inf, NaN, +-0, tiny and negative arguments */ *signgamp = 1; ix = hx&0x7fffffff; if(ix>=0x7ff00000) return x*x; diff --git a/lib/msun/src/e_lgammaf_r.c b/lib/msun/src/e_lgammaf_r.c index 16087d3d3b59..12bcaa3aa8db 100644 --- a/lib/msun/src/e_lgammaf_r.c +++ b/lib/msun/src/e_lgammaf_r.c @@ -139,11 +139,12 @@ float __ieee754_lgammaf_r(float x, int *signgamp) { float t,y,z,nadj,p,p1,p2,p3,q,r,w; - int i,hx,ix; + int32_t hx; + int i,ix; GET_FLOAT_WORD(hx,x); - /* purge off +-inf, NaN, +-0, and negative arguments */ + /* purge off +-inf, NaN, +-0, tiny and negative arguments */ *signgamp = 1; ix = hx&0x7fffffff; if(ix>=0x7f800000) return x*x;