diff options
author | Bill King <bill.king@nokia.com> | 2009-07-08 23:41:21 (GMT) |
---|---|---|
committer | Bill King <bill.king@nokia.com> | 2009-07-08 23:41:21 (GMT) |
commit | 53228e1b1993524fb1422a8363647b468b3c7c8d (patch) | |
tree | 2adf3ed0cae75cf3beeefbc1010d4e7dd576ac7b | |
parent | 48f049d6fbddd60d99fb6ebc15fd5b52a3b515ec (diff) | |
download | Qt-53228e1b1993524fb1422a8363647b468b3c7c8d.zip Qt-53228e1b1993524fb1422a8363647b468b3c7c8d.tar.gz Qt-53228e1b1993524fb1422a8363647b468b3c7c8d.tar.bz2 |
Hopefully fix isnan/isinf for good (for all platforms)
-rw-r--r-- | src/sql/drivers/psql/qsql_psql.cpp | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/src/sql/drivers/psql/qsql_psql.cpp b/src/sql/drivers/psql/qsql_psql.cpp index 33f2e2b..4eccf4b 100644 --- a/src/sql/drivers/psql/qsql_psql.cpp +++ b/src/sql/drivers/psql/qsql_psql.cpp @@ -59,21 +59,29 @@ #include <pg_config.h> #include <stdlib.h> -#if defined(_MSC_VER) -#include <float.h> -#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 <math.h> +// 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 |