From 664f00763b20bcf07de6f06d37c3152061132c6e Mon Sep 17 00:00:00 2001 From: Jeff Johnston Date: Thu, 9 Jul 2009 17:04:56 +0000 Subject: [PATCH] 2009-07-09 Craig Howland * libm/math/ef_scalb.c: Replace isnanf() (pre-C99 function call) with isnan() (C99 macro). * libm/math/wf_log.c: Ditto. * libm/math/wf_j0.c: Ditto. * libm/math/wf_sqrt.c: Ditto. * libm/math/wf_pow.c: Ditto. * libm/math/wf_fmod.c: Ditto. * libm/math/wf_remainder.c: Ditto. * libm/math/wf_scalb.c: Ditto. * libm/math/wf_atanh.c: Ditto. * libm/math/wf_cosh.c: Ditto. * libm/math/wf_acos.c: Ditto. * libm/math/wf_acosh.c: Ditto. * libm/math/wf_jn.c: Ditto. * libm/math/wf_log10.c: Ditto. * libm/math/wf_asin.c: Ditto. * libm/math/wf_j1.c: Ditto. * libm/common/sf_isnan.c: Add #include , fix comment. * libm/common/sf_isinf.c: Add #include , adjust comment to match that from s_isinf.c. * libc/include/machine/ieeefp.h: Simplify isinf and isnan macros to remove un-necessary extension use (in a similar manner to as was recently done in math.h). * libc/include/math.h: Remove isnanf and isinff prototypes (are in ieeefp.h). * libm/machine/spu/sf_isinf.c: Fix comment (remove ). --- newlib/ChangeLog | 29 ++++++++++++++++++++++++++++ newlib/libc/include/machine/ieeefp.h | 8 ++------ newlib/libc/include/math.h | 5 ++--- newlib/libm/common/sf_isinf.c | 10 ++++++++-- newlib/libm/common/sf_isnan.c | 5 ++++- newlib/libm/machine/spu/sf_isinf.c | 2 +- newlib/libm/math/ef_scalb.c | 2 +- newlib/libm/math/wf_acos.c | 2 +- newlib/libm/math/wf_acosh.c | 2 +- newlib/libm/math/wf_asin.c | 2 +- newlib/libm/math/wf_atanh.c | 2 +- newlib/libm/math/wf_cosh.c | 2 +- newlib/libm/math/wf_fmod.c | 2 +- newlib/libm/math/wf_j0.c | 4 ++-- newlib/libm/math/wf_j1.c | 4 ++-- newlib/libm/math/wf_jn.c | 4 ++-- newlib/libm/math/wf_log.c | 2 +- newlib/libm/math/wf_log10.c | 2 +- newlib/libm/math/wf_pow.c | 6 +++--- newlib/libm/math/wf_remainder.c | 2 +- newlib/libm/math/wf_scalb.c | 2 +- newlib/libm/math/wf_sqrt.c | 2 +- 22 files changed, 67 insertions(+), 34 deletions(-) diff --git a/newlib/ChangeLog b/newlib/ChangeLog index 222b8a8fd..47b6c0f57 100644 --- a/newlib/ChangeLog +++ b/newlib/ChangeLog @@ -1,3 +1,32 @@ +2009-07-09 Craig Howland + + * libm/math/ef_scalb.c: Replace isnanf() (pre-C99 function call) with + isnan() (C99 macro). + * libm/math/wf_log.c: Ditto. + * libm/math/wf_j0.c: Ditto. + * libm/math/wf_sqrt.c: Ditto. + * libm/math/wf_pow.c: Ditto. + * libm/math/wf_fmod.c: Ditto. + * libm/math/wf_remainder.c: Ditto. + * libm/math/wf_scalb.c: Ditto. + * libm/math/wf_atanh.c: Ditto. + * libm/math/wf_cosh.c: Ditto. + * libm/math/wf_acos.c: Ditto. + * libm/math/wf_acosh.c: Ditto. + * libm/math/wf_jn.c: Ditto. + * libm/math/wf_log10.c: Ditto. + * libm/math/wf_asin.c: Ditto. + * libm/math/wf_j1.c: Ditto. + * libm/common/sf_isnan.c: Add #include , fix comment. + * libm/common/sf_isinf.c: Add #include , adjust comment to + match that from s_isinf.c. + * libc/include/machine/ieeefp.h: Simplify isinf and isnan macros to + remove un-necessary extension use (in a similar manner to as was + recently done in math.h). + * libc/include/math.h: Remove isnanf and isinff prototypes (are in + ieeefp.h). + * libm/machine/spu/sf_isinf.c: Fix comment (remove ). + 2009-07-06 Joel Sherrill * libc/include/sys/features.h: Enable UNIX98 mutex attributes diff --git a/newlib/libc/include/machine/ieeefp.h b/newlib/libc/include/machine/ieeefp.h index 531a20cd5..7b6280fcd 100644 --- a/newlib/libc/include/machine/ieeefp.h +++ b/newlib/libc/include/machine/ieeefp.h @@ -80,12 +80,8 @@ (__extension__ ({__typeof__(y) __y = (y); \ (sizeof (__y) == sizeof (float)) ? (1) : \ fpclassify(__y) != FP_INFINITE && fpclassify(__y) != FP_NAN;})) -#define isinf(x) \ - (__extension__ ({__typeof__(x) __x = (x); \ - (sizeof (__x) == sizeof (float)) ? (0) : __isinfd(__x);})) -#define isnan(x) \ - (__extension__ ({__typeof__(x) __x = (x); \ - (sizeof (__x) == sizeof (float)) ? (0) : __isnand(__x);})) +#define isinf(__x) ((sizeof (__x) == sizeof (float)) ? (0) : __isinfd(__x)) +#define isnan(__x) ((sizeof (__x) == sizeof (float)) ? (0) : __isnand(__x)) /* * Macros for use in ieeefp.h. We can't just define the real ones here diff --git a/newlib/libc/include/math.h b/newlib/libc/include/math.h index ca65a44b2..c1bc7b04a 100644 --- a/newlib/libc/include/math.h +++ b/newlib/libc/include/math.h @@ -195,7 +195,8 @@ extern int __signbitd (double x); * arguments. C99 specifies that these names are reserved for macros * supporting multiple floating point types. Thus, they are * now defined as macros. Implementations of the old functions - * taking double arguments still exist for compatibility purposes. */ + * taking double arguments still exist for compatibility purposes + * (prototypes for them are in ). */ #ifndef isinf #define isinf(y) (fpclassify(y) == FP_INFINITE) #endif @@ -329,8 +330,6 @@ extern float fmaf _PARAMS((float, float, float)); extern float infinityf _PARAMS((void)); extern float nanf _PARAMS((const char *)); -extern int isnanf _PARAMS((float)); -extern int isinff _PARAMS((float)); extern int finitef _PARAMS((float)); extern float copysignf _PARAMS((float, float)); extern int ilogbf _PARAMS((float)); diff --git a/newlib/libm/common/sf_isinf.c b/newlib/libm/common/sf_isinf.c index 74ba4edf7..6595a681c 100644 --- a/newlib/libm/common/sf_isinf.c +++ b/newlib/libm/common/sf_isinf.c @@ -1,11 +1,17 @@ /* * isinff(x) returns 1 if x is +-infinity, else 0; * - * isinff is an extension declared in and - * . + * isinf is a macro in the C99 standard. It was previously + * implemented as isinf and isinff functions by newlib and are still declared + * as such in . Newlib supplies it here as a function if the user + * chooses to use or needs to link older code compiled with the + * previous declaration. */ #include "fdlibm.h" +#include + +#undef isinff int _DEFUN (isinff, (x), diff --git a/newlib/libm/common/sf_isnan.c b/newlib/libm/common/sf_isnan.c index befc3b2b2..ddda6b331 100644 --- a/newlib/libm/common/sf_isnan.c +++ b/newlib/libm/common/sf_isnan.c @@ -15,10 +15,13 @@ /* * isnanf(x) returns 1 is x is nan, else 0; * - * isnanf is an extension declared in and . + * isnanf is an extension declared in . */ #include "fdlibm.h" +#include + +#undef isnanf int _DEFUN (isnanf, (x), diff --git a/newlib/libm/machine/spu/sf_isinf.c b/newlib/libm/machine/spu/sf_isinf.c index 7cba324f9..3c5f8d81f 100644 --- a/newlib/libm/machine/spu/sf_isinf.c +++ b/newlib/libm/machine/spu/sf_isinf.c @@ -34,7 +34,7 @@ /* * On the SPU isinff(x) always returns 0. * - * isinff is an extension declared in and . + * isinff is an extension declared in . */ int isinff (float x) diff --git a/newlib/libm/math/ef_scalb.c b/newlib/libm/math/ef_scalb.c index 3677a3b1f..8d973b1e7 100644 --- a/newlib/libm/math/ef_scalb.c +++ b/newlib/libm/math/ef_scalb.c @@ -35,7 +35,7 @@ #ifdef _SCALB_INT return scalbnf(x,fn); #else - if (isnanf(x)||isnanf(fn)) return x*fn; + if (isnan(x)||isnan(fn)) return x*fn; if (!finitef(fn)) { if(fn>(float)0.0) return x*fn; else return x/(-fn); diff --git a/newlib/libm/math/wf_acos.c b/newlib/libm/math/wf_acos.c index 38817b82b..ff9f80b26 100644 --- a/newlib/libm/math/wf_acos.c +++ b/newlib/libm/math/wf_acos.c @@ -33,7 +33,7 @@ float z; struct exception exc; z = __ieee754_acosf(x); - if(_LIB_VERSION == _IEEE_ || isnanf(x)) return z; + if(_LIB_VERSION == _IEEE_ || isnan(x)) return z; if(fabsf(x)>(float)1.0) { /* acosf(|x|>1) */ exc.type = DOMAIN; diff --git a/newlib/libm/math/wf_acosh.c b/newlib/libm/math/wf_acosh.c index 19c2450e6..fc8ec3a0a 100644 --- a/newlib/libm/math/wf_acosh.c +++ b/newlib/libm/math/wf_acosh.c @@ -34,7 +34,7 @@ float z; struct exception exc; z = __ieee754_acoshf(x); - if(_LIB_VERSION == _IEEE_ || isnanf(x)) return z; + if(_LIB_VERSION == _IEEE_ || isnan(x)) return z; if(x<(float)1.0) { /* acoshf(x<1) */ exc.type = DOMAIN; diff --git a/newlib/libm/math/wf_asin.c b/newlib/libm/math/wf_asin.c index fc39e977c..385de5499 100644 --- a/newlib/libm/math/wf_asin.c +++ b/newlib/libm/math/wf_asin.c @@ -35,7 +35,7 @@ float z; struct exception exc; z = __ieee754_asinf(x); - if(_LIB_VERSION == _IEEE_ || isnanf(x)) return z; + if(_LIB_VERSION == _IEEE_ || isnan(x)) return z; if(fabsf(x)>(float)1.0) { /* asinf(|x|>1) */ exc.type = DOMAIN; diff --git a/newlib/libm/math/wf_atanh.c b/newlib/libm/math/wf_atanh.c index 457cdc6e2..565630411 100644 --- a/newlib/libm/math/wf_atanh.c +++ b/newlib/libm/math/wf_atanh.c @@ -32,7 +32,7 @@ float z,y; struct exception exc; z = __ieee754_atanhf(x); - if(_LIB_VERSION == _IEEE_ || isnanf(x)) return z; + if(_LIB_VERSION == _IEEE_ || isnan(x)) return z; y = fabsf(x); if(y>=(float)1.0) { if(y>(float)1.0) { diff --git a/newlib/libm/math/wf_cosh.c b/newlib/libm/math/wf_cosh.c index 82b76f3c4..02eb12472 100644 --- a/newlib/libm/math/wf_cosh.c +++ b/newlib/libm/math/wf_cosh.c @@ -33,7 +33,7 @@ float z; struct exception exc; z = __ieee754_coshf(x); - if(_LIB_VERSION == _IEEE_ || isnanf(x)) return z; + if(_LIB_VERSION == _IEEE_ || isnan(x)) return z; if(fabsf(x)>(float)8.9415985107e+01) { /* coshf(finite) overflow */ #ifndef HUGE_VAL diff --git a/newlib/libm/math/wf_fmod.c b/newlib/libm/math/wf_fmod.c index 320daabde..030ca3e7a 100644 --- a/newlib/libm/math/wf_fmod.c +++ b/newlib/libm/math/wf_fmod.c @@ -33,7 +33,7 @@ float z; struct exception exc; z = __ieee754_fmodf(x,y); - if(_LIB_VERSION == _IEEE_ ||isnanf(y)||isnanf(x)) return z; + if(_LIB_VERSION == _IEEE_ ||isnan(y)||isnan(x)) return z; if(y==(float)0.0) { /* fmodf(x,0) */ exc.type = DOMAIN; diff --git a/newlib/libm/math/wf_j0.c b/newlib/libm/math/wf_j0.c index 0f3a7c1c6..1f7f5ede5 100644 --- a/newlib/libm/math/wf_j0.c +++ b/newlib/libm/math/wf_j0.c @@ -32,7 +32,7 @@ #else struct exception exc; float z = __ieee754_j0f(x); - if(_LIB_VERSION == _IEEE_ || isnanf(x)) return z; + if(_LIB_VERSION == _IEEE_ || isnan(x)) return z; if(fabsf(x)>(float)X_TLOSS) { /* j0f(|x|>X_TLOSS) */ exc.type = TLOSS; @@ -66,7 +66,7 @@ float z; struct exception exc; z = __ieee754_y0f(x); - if(_LIB_VERSION == _IEEE_ || isnanf(x) ) return z; + if(_LIB_VERSION == _IEEE_ || isnan(x) ) return z; if(x <= (float)0.0){ #ifndef HUGE_VAL #define HUGE_VAL inf diff --git a/newlib/libm/math/wf_j1.c b/newlib/libm/math/wf_j1.c index f9d3e0ed8..b91962881 100644 --- a/newlib/libm/math/wf_j1.c +++ b/newlib/libm/math/wf_j1.c @@ -34,7 +34,7 @@ float z; struct exception exc; z = __ieee754_j1f(x); - if(_LIB_VERSION == _IEEE_ || isnanf(x) ) return z; + if(_LIB_VERSION == _IEEE_ || isnan(x) ) return z; if(fabsf(x)>(float)X_TLOSS) { /* j1f(|x|>X_TLOSS) */ exc.type = TLOSS; @@ -68,7 +68,7 @@ float z; struct exception exc; z = __ieee754_y1f(x); - if(_LIB_VERSION == _IEEE_ || isnanf(x) ) return z; + if(_LIB_VERSION == _IEEE_ || isnan(x) ) return z; if(x <= (float)0.0){ /* y1f(0) = -inf or y1f(x<0) = NaN */ #ifndef HUGE_VAL diff --git a/newlib/libm/math/wf_jn.c b/newlib/libm/math/wf_jn.c index c3a52630b..837b6b703 100644 --- a/newlib/libm/math/wf_jn.c +++ b/newlib/libm/math/wf_jn.c @@ -30,7 +30,7 @@ float z; struct exception exc; z = __ieee754_jnf(n,x); - if(_LIB_VERSION == _IEEE_ || isnanf(x) ) return z; + if(_LIB_VERSION == _IEEE_ || isnan(x) ) return z; if(fabsf(x)>(float)X_TLOSS) { /* jnf(|x|>X_TLOSS) */ exc.type = TLOSS; @@ -65,7 +65,7 @@ float z; struct exception exc; z = __ieee754_ynf(n,x); - if(_LIB_VERSION == _IEEE_ || isnanf(x) ) return z; + if(_LIB_VERSION == _IEEE_ || isnan(x) ) return z; if(x <= (float)0.0){ /* ynf(n,0) = -inf or ynf(x<0) = NaN */ #ifndef HUGE_VAL diff --git a/newlib/libm/math/wf_log.c b/newlib/libm/math/wf_log.c index 989eeb335..4518b863b 100644 --- a/newlib/libm/math/wf_log.c +++ b/newlib/libm/math/wf_log.c @@ -33,7 +33,7 @@ float z; struct exception exc; z = __ieee754_logf(x); - if(_LIB_VERSION == _IEEE_ || isnanf(x) || x > (float)0.0) return z; + if(_LIB_VERSION == _IEEE_ || isnan(x) || x > (float)0.0) return z; #ifndef HUGE_VAL #define HUGE_VAL inf double inf = 0.0; diff --git a/newlib/libm/math/wf_log10.c b/newlib/libm/math/wf_log10.c index 41dd93a7b..11c595637 100644 --- a/newlib/libm/math/wf_log10.c +++ b/newlib/libm/math/wf_log10.c @@ -33,7 +33,7 @@ float z; struct exception exc; z = __ieee754_log10f(x); - if(_LIB_VERSION == _IEEE_ || isnanf(x)) return z; + if(_LIB_VERSION == _IEEE_ || isnan(x)) return z; if(x<=(float)0.0) { #ifndef HUGE_VAL #define HUGE_VAL inf diff --git a/newlib/libm/math/wf_pow.c b/newlib/libm/math/wf_pow.c index eaeed85ab..a30f8808e 100644 --- a/newlib/libm/math/wf_pow.c +++ b/newlib/libm/math/wf_pow.c @@ -33,8 +33,8 @@ float z; struct exception exc; z=__ieee754_powf(x,y); - if(_LIB_VERSION == _IEEE_|| isnanf(y)) return z; - if(isnanf(x)) { + if(_LIB_VERSION == _IEEE_|| isnan(y)) return z; + if(isnan(x)) { if(y==(float)0.0) { /* powf(NaN,0.0) */ /* error only if _LIB_VERSION == _SVID_ & _XOPEN_ */ @@ -97,7 +97,7 @@ } if(!finitef(z)) { if(finitef(x)&&finitef(y)) { - if(isnanf(z)) { + if(isnan(z)) { /* neg**non-integral */ exc.type = DOMAIN; exc.name = "powf"; diff --git a/newlib/libm/math/wf_remainder.c b/newlib/libm/math/wf_remainder.c index 0071a9772..f38c23785 100644 --- a/newlib/libm/math/wf_remainder.c +++ b/newlib/libm/math/wf_remainder.c @@ -33,7 +33,7 @@ float z; struct exception exc; z = __ieee754_remainderf(x,y); - if(_LIB_VERSION == _IEEE_ || isnanf(y)) return z; + if(_LIB_VERSION == _IEEE_ || isnan(y)) return z; if(y==(float)0.0) { /* remainderf(x,0) */ exc.type = DOMAIN; diff --git a/newlib/libm/math/wf_scalb.c b/newlib/libm/math/wf_scalb.c index bd2d9f8b4..d2c3cd2aa 100644 --- a/newlib/libm/math/wf_scalb.c +++ b/newlib/libm/math/wf_scalb.c @@ -50,7 +50,7 @@ struct exception exc; z = __ieee754_scalbf(x,fn); if(_LIB_VERSION == _IEEE_) return z; - if(!(finitef(z)||isnanf(z))&&finitef(x)) { + if(!(finitef(z)||isnan(z))&&finitef(x)) { /* scalbf overflow; SVID also returns +-HUGE_VAL */ exc.type = OVERFLOW; exc.name = "scalbf"; diff --git a/newlib/libm/math/wf_sqrt.c b/newlib/libm/math/wf_sqrt.c index 6e792c923..4536ba0ac 100644 --- a/newlib/libm/math/wf_sqrt.c +++ b/newlib/libm/math/wf_sqrt.c @@ -33,7 +33,7 @@ float z; struct exception exc; z = __ieee754_sqrtf(x); - if(_LIB_VERSION == _IEEE_ || isnanf(x)) return z; + if(_LIB_VERSION == _IEEE_ || isnan(x)) return z; if(x<(float)0.0) { /* sqrtf(negative) */ exc.type = DOMAIN;