From 04e12006e5e96d516f3f4c32ad4d1770ada432ce Mon Sep 17 00:00:00 2001 From: Keno Fischer Date: Thu, 24 May 2012 23:45:05 -0400 Subject: [PATCH] address compiler warnings in #3 --- src/e_atan2.c | 2 +- src/e_sqrtf.c | 4 ---- src/e_sqrtl.c | 2 ++ src/s_csqrt.c | 2 ++ src/s_csqrtf.c | 2 ++ src/s_csqrtl.c | 3 ++- src/s_fabs.c | 4 ---- src/s_fma.c | 8 ++++---- src/s_fmal.c | 8 ++++---- src/s_fpclassify.c | 11 ----------- src/s_logbl.c | 4 ---- src/s_modf.c | 4 ---- src/s_nextafterl.c | 2 +- src/s_nexttoward.c | 2 +- src/s_nexttowardf.c | 2 +- src/s_scalbn.c | 9 +++------ src/s_scalbnf.c | 8 +++----- src/s_scalbnl.c | 9 +++------ 18 files changed, 29 insertions(+), 57 deletions(-) diff --git a/src/e_atan2.c b/src/e_atan2.c index c4c1c33..6a2a453 100644 --- a/src/e_atan2.c +++ b/src/e_atan2.c @@ -71,7 +71,7 @@ __ieee754_atan2(double y, double x) if(((ix|((lx|-lx)>>31))>0x7ff00000)|| ((iy|((ly|-ly)>>31))>0x7ff00000)) /* x or y is NaN */ return x+y; - if((hx-0x3ff00000|lx)==0) return atan(y); /* x=1.0 */ + if(((hx-0x3ff00000)|lx)==0) return atan(y); /* x=1.0 */ m = ((hy>>31)&1)|((hx>>30)&2); /* 2*sign(x)+sign(y) */ /* when y = 0 */ diff --git a/src/e_sqrtf.c b/src/e_sqrtf.c index e48f9a8..e6afa9f 100644 --- a/src/e_sqrtf.c +++ b/src/e_sqrtf.c @@ -13,10 +13,6 @@ * ==================================================== */ -#ifndef lint -static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_sqrtf.c,v 1.7 2002/05/28 18:15:04 alfred Exp $"; -#endif - #include "openlibm.h" #include "math_private.h" diff --git a/src/e_sqrtl.c b/src/e_sqrtl.c index 9fa40bf..ff1ced7 100644 --- a/src/e_sqrtl.c +++ b/src/e_sqrtl.c @@ -65,7 +65,9 @@ dec(long double x) return (u.e); } +#ifndef __GNUC__ #pragma STDC FENV_ACCESS ON +#endif /* * This is slow, but simple and portable. You should use hardware sqrt diff --git a/src/s_csqrt.c b/src/s_csqrt.c index 684c843..8e20850 100644 --- a/src/s_csqrt.c +++ b/src/s_csqrt.c @@ -40,7 +40,9 @@ * gcc generates is acceptable, since the special cases have already been * handled. */ +#ifndef __GNUC__ #pragma STDC CX_LIMITED_RANGE ON +#endif /* We risk spurious overflow for components >= DBL_MAX / (1 + sqrt(2)). */ #define THRESH 0x1.a827999fcef32p+1022 diff --git a/src/s_csqrtf.c b/src/s_csqrtf.c index d91bd3e..f94c997 100644 --- a/src/s_csqrtf.c +++ b/src/s_csqrtf.c @@ -39,7 +39,9 @@ * gcc generates is acceptable, since the special cases have already been * handled. */ +#ifndef __GNUC__ #pragma STDC CX_LIMITED_RANGE ON +#endif float complex csqrtf(float complex z) diff --git a/src/s_csqrtl.c b/src/s_csqrtl.c index 229db82..8983c2a 100644 --- a/src/s_csqrtl.c +++ b/src/s_csqrtl.c @@ -25,7 +25,6 @@ */ #include "cdefs-compat.h" -//__FBSDID("$FreeBSD: src/lib/msun/src/s_csqrtl.c,v 1.2 2008/08/08 00:15:16 das Exp $"); #include #include @@ -40,7 +39,9 @@ * gcc generates is acceptable, since the special cases have already been * handled. */ +#ifndef __GNUC__ #pragma STDC CX_LIMITED_RANGE ON +#endif /* We risk spurious overflow for components >= LDBL_MAX / (1 + sqrt(2)). */ #define THRESH (LDBL_MAX / 2.414213562373095048801688724209698L) diff --git a/src/s_fabs.c b/src/s_fabs.c index 06688b0..064a6e2 100644 --- a/src/s_fabs.c +++ b/src/s_fabs.c @@ -10,10 +10,6 @@ * ==================================================== */ -#ifndef lint -static char rcsid[] = "$FreeBSD: src/lib/msun/src/s_fabs.c,v 1.7 2002/05/28 18:15:04 alfred Exp $"; -#endif - /* * fabs(x) returns the absolute value of x. */ diff --git a/src/s_fma.c b/src/s_fma.c index 93eae94..757eea4 100644 --- a/src/s_fma.c +++ b/src/s_fma.c @@ -117,7 +117,7 @@ add_and_denormalize(double a, double b, int scale) if (sum.lo != 0) { EXTRACT_WORD64(hibits, sum.hi); bits_lost = -((int)(hibits >> 52) & 0x7ff) - scale + 1; - if (bits_lost != 1 ^ (int)(hibits & 1)) { + if ((bits_lost != 1) ^ (int)(hibits & 1)) { /* hibits += (int)copysign(1.0, sum.hi * sum.lo) */ EXTRACT_WORD64(lobits, sum.lo); hibits += 1 - (((hibits ^ lobits) >> 62) & 2); @@ -216,17 +216,17 @@ fma(double x, double y, double z) case FE_TONEAREST: return (z); case FE_TOWARDZERO: - if (x > 0.0 ^ y < 0.0 ^ z < 0.0) + if ((x > 0.0) ^ (y < 0.0) ^ (z < 0.0)) return (z); else return (nextafter(z, 0)); case FE_DOWNWARD: - if (x > 0.0 ^ y < 0.0) + if ((x > 0.0) ^ (y < 0.0)) return (z); else return (nextafter(z, -INFINITY)); default: /* FE_UPWARD */ - if (x > 0.0 ^ y < 0.0) + if ((x > 0.0) ^ (y < 0.0)) return (nextafter(z, INFINITY)); else return (z); diff --git a/src/s_fmal.c b/src/s_fmal.c index 0943094..c484448 100644 --- a/src/s_fmal.c +++ b/src/s_fmal.c @@ -113,7 +113,7 @@ add_and_denormalize(long double a, long double b, int scale) if (sum.lo != 0) { u.e = sum.hi; bits_lost = -u.bits.exp - scale + 1; - if (bits_lost != 1 ^ (int)(u.bits.manl & 1)) + if ((bits_lost != 1) ^ (int)(u.bits.manl & 1)) sum.hi = nextafterl(sum.hi, INFINITY * sum.lo); } return (ldexp(sum.hi, scale)); @@ -204,17 +204,17 @@ fmal(long double x, long double y, long double z) case FE_TONEAREST: return (z); case FE_TOWARDZERO: - if (x > 0.0 ^ y < 0.0 ^ z < 0.0) + if ((x > 0.0) ^ (y < 0.0) ^ (z < 0.0)) return (z); else return (nextafterl(z, 0)); case FE_DOWNWARD: - if (x > 0.0 ^ y < 0.0) + if ((x > 0.0) ^ (y < 0.0)) return (z); else return (nextafterl(z, -INFINITY)); default: /* FE_UPWARD */ - if (x > 0.0 ^ y < 0.0) + if ((x > 0.0) ^ (y < 0.0)) return (nextafterl(z, INFINITY)); else return (z); diff --git a/src/s_fpclassify.c b/src/s_fpclassify.c index 03a1e98..1f77597 100644 --- a/src/s_fpclassify.c +++ b/src/s_fpclassify.c @@ -29,17 +29,6 @@ #include "fpmath.h" -//#define FP_INFINITE 0x01 -//#define FP_NAN 0x02 -//#define FP_NORMAL 0x04 -//#define FP_SUBNORMAL 0x08 -//#define FP_ZERO 0x10 -//#define fpclassify(x) \ -// ((sizeof (x) == sizeof (float)) ? __fpclassifyf(x) \ -// : (sizeof (x) == sizeof (double)) ? __fpclassifyd(x) \ -// : __fpclassifyl(x)) -// - int __fpclassifyd(double d) { diff --git a/src/s_logbl.c b/src/s_logbl.c index 059b423..a2c2e89 100644 --- a/src/s_logbl.c +++ b/src/s_logbl.c @@ -10,10 +10,6 @@ * ==================================================== */ -#ifndef lint -static char rcsid[] = "$FreeBSD: src/lib/msun/src/s_logbl.c,v 1.1 2007/12/17 03:53:38 das Exp $"; -#endif - #include #include #include diff --git a/src/s_modf.c b/src/s_modf.c index 692e025..52ca7ba 100644 --- a/src/s_modf.c +++ b/src/s_modf.c @@ -10,10 +10,6 @@ * ==================================================== */ -#ifndef lint -static char rcsid[] = "$FreeBSD: src/lib/msun/src/s_modf.c,v 1.8 2007/01/06 21:22:38 das Exp $"; -#endif - /* * modf(double x, double *iptr) * return fraction part of x, and return x's integral part in *iptr. diff --git a/src/s_nextafterl.c b/src/s_nextafterl.c index 8ba05ce..72c5874 100644 --- a/src/s_nextafterl.c +++ b/src/s_nextafterl.c @@ -52,7 +52,7 @@ nextafterl(long double x, long double y) t = ux.e*ux.e; if(t==ux.e) return t; else return ux.e; /* raise underflow flag */ } - if(x>0.0 ^ x0.0) ^ (x0.0 ^ x < y) { /* x -= ulp */ + if((hx>0.0) ^ (x < y)) { /* x -= ulp */ if(lx==0) hx -= 1; lx -= 1; } else { /* x += ulp */ diff --git a/src/s_nexttowardf.c b/src/s_nexttowardf.c index 04cd2d8..bb93378 100644 --- a/src/s_nexttowardf.c +++ b/src/s_nexttowardf.c @@ -41,7 +41,7 @@ nexttowardf(float x, long double y) t = x*x; if(t==x) return t; else return x; /* raise underflow flag */ } - if(hx>=0 ^ x < y) /* x -= ulp */ + if((hx>=0) ^ (x < y)) /* x -= ulp */ hx -= 1; else /* x += ulp */ hx += 1; diff --git a/src/s_scalbn.c b/src/s_scalbn.c index da20175..e4da525 100644 --- a/src/s_scalbn.c +++ b/src/s_scalbn.c @@ -10,10 +10,6 @@ * ==================================================== */ -#ifndef lint -static char rcsid[] = "$FreeBSD: src/lib/msun/src/s_scalbn.c,v 1.11 2005/03/07 21:27:37 das Exp $"; -#endif - /* * scalbn (double x, int n) * scalbn(x,n) returns x* 2**n computed by exponent @@ -51,11 +47,12 @@ scalbn (double x, int n) if (k > 0x7fe) return huge*copysign(huge,x); /* overflow */ if (k > 0) /* normal result */ {SET_HIGH_WORD(x,(hx&0x800fffff)|(k<<20)); return x;} - if (k <= -54) + if (k <= -54) { if (n > 50000) /* in case integer overflow in n+k */ return huge*copysign(huge,x); /*overflow*/ else return tiny*copysign(tiny,x); /*underflow*/ - k += 54; /* subnormal result */ + } + k += 54; /* subnormal result */ SET_HIGH_WORD(x,(hx&0x800fffff)|(k<<20)); return x*twom54; } diff --git a/src/s_scalbnf.c b/src/s_scalbnf.c index db59c1a..cf16667 100644 --- a/src/s_scalbnf.c +++ b/src/s_scalbnf.c @@ -13,9 +13,6 @@ * ==================================================== */ -#ifndef lint -static char rcsid[] = "$FreeBSD: src/lib/msun/src/s_scalbnf.c,v 1.8 2005/03/07 04:52:43 das Exp $"; -#endif #include "cdefs-compat.h" @@ -46,11 +43,12 @@ scalbnf (float x, int n) if (k > 0xfe) return huge*copysignf(huge,x); /* overflow */ if (k > 0) /* normal result */ {SET_FLOAT_WORD(x,(ix&0x807fffff)|(k<<23)); return x;} - if (k <= -25) + if (k <= -25) { if (n > 50000) /* in case integer overflow in n+k */ return huge*copysignf(huge,x); /*overflow*/ else return tiny*copysignf(tiny,x); /*underflow*/ - k += 25; /* subnormal result */ + } + k += 25; /* subnormal result */ SET_FLOAT_WORD(x,(ix&0x807fffff)|(k<<23)); return x*twom25; } diff --git a/src/s_scalbnl.c b/src/s_scalbnl.c index 4218973..db1563a 100644 --- a/src/s_scalbnl.c +++ b/src/s_scalbnl.c @@ -10,10 +10,6 @@ * ==================================================== */ -#ifndef lint -static char rcsid[] = "$FreeBSD: src/lib/msun/src/s_scalbnl.c,v 1.1 2005/03/07 04:52:58 das Exp $"; -#endif - /* * scalbnl (long double x, int n) * scalbnl(x,n) returns x* 2**n computed by exponent @@ -59,11 +55,12 @@ scalbnl (long double x, int n) if (k >= 0x7fff) return huge*copysignl(huge,x); /* overflow */ if (k > 0) /* normal result */ {u.bits.exp = k; return u.e;} - if (k <= -128) + if (k <= -128) { if (n > 50000) /* in case integer overflow in n+k */ return huge*copysign(huge,x); /*overflow*/ else return tiny*copysign(tiny,x); /*underflow*/ - k += 128; /* subnormal result */ + } + k += 128; /* subnormal result */ u.bits.exp = k; return u.e*0x1p-128; }