From ff9757e811033daf0ee1632f93d586ef47b15639 Mon Sep 17 00:00:00 2001 From: Gernot Kvas Date: Wed, 15 Aug 2012 17:27:27 -0600 Subject: [PATCH] fix Win32 build regressions Date: Wed, 15 Aug 2012 15:59:25 -0700 (PDT) From: Gernot Kvas Reply-To: avian@googlegroups.com To: avian@googlegroups.com Subject: Win32 build regression Hi, As I've forked on the July 19th and haven't updated since, I decided to merge master into my WinCE branch. I found out that the following commits have introduced build regressions on Windows: 1.)https://github.com/ReadyTalk/avian/commit/5a7c78e71ac7b4045c23d215162fb1284 8f1a5f3 => strncasecmp is undefined for Windows 2.)https://github.com/ReadyTalk/avian/commit/b98abe3f94dbf552595554787ef2115c3 009856c => fpclassify and related constants are undefined for Windows 3.)https://github.com/ReadyTalk/avian/commit/20a290b992112f9b376d3a8d0180c1cca 8dd21e2 => signbit is undefined for Windows I attached a patch that makes everything build through (within Visual Studio, the makefile still fails) --- src/common.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/common.h b/src/common.h index 1c45e2e855..adab2f587f 100644 --- a/src/common.h +++ b/src/common.h @@ -25,6 +25,8 @@ #ifdef _MSC_VER +#include "float.h" + // don't complain about using 'this' in member initializers: # pragma warning(disable:4355) @@ -37,6 +39,34 @@ typedef unsigned int uint32_t; typedef __int64 int64_t; typedef unsigned __int64 uint64_t; +#define strncasecmp _strnicmp + +#define FP_NAN 0 +#define FP_INFINITE 1 +#define FP_UNDEF 2 + +inline int fpclassify(double d) { + + switch(_fpclass(d)) { + case _FPCLASS_SNAN: + case _FPCLASS_QNAN: + return FP_NAN; + case _FPCLASS_PINF: + case _FPCLASS_NINF: + return FP_INFINITE; + } + return FP_UNDEF; +} + +#define INT32_MIN ((int32_t) _I32_MIN) +#define INT32_MAX _I32_MAX +#define INT64_MIN ((int64_t) _I64_MIN) +#define INT64_MAX _I64_MAX + +inline int signbit(double d) { + return _copysign(1.0, d) < 0; +} + # define not ! # define or || # define and &&