From 407771105099a5350c222eb3e40963fe4f7e3475 Mon Sep 17 00:00:00 2001 From: Federico Di Gregorio Date: Mon, 2 Mar 2009 09:19:23 +0100 Subject: [PATCH] More cross-platform build fixes --- ChangeLog | 5 +++++ psycopg/config.h | 13 +++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 65f6cc65..d93c2efe 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-03-02 Federico Di Gregorio + + * psycopg/config.h: applied patch from Jason Erickson to build + with MSVC. Solaris version of isinf() is now a macro. + 2009-02-27 Federico Di Gregorio * psycopg/config.h: added check to provide compatible isinf() diff --git a/psycopg/config.h b/psycopg/config.h index 33aa5c8b..3ee0c7da 100644 --- a/psycopg/config.h +++ b/psycopg/config.h @@ -127,6 +127,15 @@ static struct tm *localtime_r(time_t *t, struct tm *tm) } /* remove the inline keyword, since it doesn't work unless C++ file */ #define inline + +/* Hmmm, MSVC doesn't have a isnan/isinf function, but has _isnan function */ +#if defined (_MSC_VER) +#define isnan(x) (_isnan(x)) +/* The following line was hacked together from simliar code by Bjorn Reese + * in libxml2 code */ +#define isinf(x) ((_fpclass(x) == _FPCLASS_PINF) ? 1 \ + : ((_fpclass(x) == _FPCLASS_NINF) ? -1 : 0)) +#endif #endif #if (defined(__FreeBSD__) && __FreeBSD_version < 503000) || (defined(_WIN32) && !defined(__GNUC__)) || defined(__sun__) || defined(sun) @@ -142,10 +151,10 @@ static double round(double num) #define PQfreemem free #endif -/* resolve missing isinf() function for Solaris **/ +/* resolve missing isinf() function for Solaris */ #if defined (__SVR4) && defined (__sun) #include -int isinf(double x) { return !finite(x) && x==x; } +#define isinf(x) (!finite((x)) && (x)==(x)) #endif #endif /* !defined(PSYCOPG_CONFIG_H) */