From 53228e1b1993524fb1422a8363647b468b3c7c8d Mon Sep 17 00:00:00 2001 From: Bill King Date: Thu, 9 Jul 2009 09:41:21 +1000 Subject: Hopefully fix isnan/isinf for good (for all platforms) --- src/sql/drivers/psql/qsql_psql.cpp | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) (limited to 'src/sql') diff --git a/src/sql/drivers/psql/qsql_psql.cpp b/src/sql/drivers/psql/qsql_psql.cpp index 33f2e2b1bb..4eccf4b264 100644 --- a/src/sql/drivers/psql/qsql_psql.cpp +++ b/src/sql/drivers/psql/qsql_psql.cpp @@ -59,21 +59,29 @@ #include #include -#if defined(_MSC_VER) -#include -#define isnan(x) _isnan(x) -int isinf(double x) -{ - if(_fpclass(x) == _FPCLASS_NINF) - return -1; - else if(_fpclass(x) == _FPCLASS_PINF) - return 1; - else return 0; -} -#else #include +// below code taken from an example at http://www.gnu.org/software/hello/manual/autoconf/Function-Portability.html +#ifndef isnan + # define isnan(x) \ + (sizeof (x) == sizeof (long double) ? isnan_ld (x) \ + : sizeof (x) == sizeof (double) ? isnan_d (x) \ + : isnan_f (x)) + static inline int isnan_f (float x) { return x != x; } + static inline int isnan_d (double x) { return x != x; } + static inline int isnan_ld (long double x) { return x != x; } #endif +#ifndef isinf + # define isinf(x) \ + (sizeof (x) == sizeof (long double) ? isinf_ld (x) \ + : sizeof (x) == sizeof (double) ? isinf_d (x) \ + : isinf_f (x)) + static inline int isinf_f (float x) { return isnan (x - x); } + static inline int isinf_d (double x) { return isnan (x - x); } + static inline int isinf_ld (long double x) { return isnan (x - x); } +#endif + + // workaround for postgres defining their OIDs in a private header file #define QBOOLOID 16 #define QINT8OID 20 -- cgit v1.2.3