# HG changeset patch # User Chris Cannam # Date 1297265136 0 # Node ID c313a173f4a9cc776d69f36974f2d4e5d4e1bd1f # Parent 6eb4c658c799768eff0de570394499d9a4eaf4be * Sort out this isnan/isinf nonsense once and for all diff -r 6eb4c658c799 -r c313a173f4a9 maths/nan-inf.h --- a/maths/nan-inf.h Wed Feb 09 11:47:20 2011 +0000 +++ b/maths/nan-inf.h Wed Feb 09 15:25:36 2011 +0000 @@ -2,19 +2,12 @@ #ifndef NAN_INF_H #define NAN_INF_H -#include - -#ifdef sun - -#include -#define ISNAN(x) ((sizeof(x)==sizeof(float))?isnanf(x):isnand(x)) -#define ISINF(x) (!finite(x)) - -#else - -#define ISNAN(x) isnan(x) -#define ISINF(x) isinf(x) +#define ISNAN(x) (sizeof(x) == sizeof(double) ? ISNANd(x) : ISNANf(x)) +static inline int ISNANf(float x) { return x != x; } +static inline int ISNANd(double x) { return x != x; } + +#define ISINF(x) (sizeof(x) == sizeof(double) ? ISINFd(x) : ISINFf(x)) +static inline int ISINFf(float x) { return !ISNANf(x) && ISNANf(x - x); } +static inline int ISINFd(double x) { return !ISNANd(x) && ISNANd(x - x); } #endif - -#endif