From 1d296c01e324a9ce3cfa665d73ef1ad419bb718d Mon Sep 17 00:00:00 2001 From: pouillot Date: Sun, 21 Nov 2010 18:03:30 +0000 Subject: [PATCH] cleaned up portability.h git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@3138 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: 7c16be115e5c0a6a7efe219b735ea0b8a6dbcdde Former-commit-id: ac48c358b73bd5f2679f4225f988b998907975de --- src/libs/portability/portability.h | 36 +++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/src/libs/portability/portability.h b/src/libs/portability/portability.h index f3d3f4b39..9cdb53e2a 100644 --- a/src/libs/portability/portability.h +++ b/src/libs/portability/portability.h @@ -22,13 +22,13 @@ #include #include -#ifdef WIN32 +#ifdef _MSC_VER #include #include #define _WINSOCKAPI_ /* Prevent inclusion of winsock.h in windows.h */ #endif -#ifdef WIN32 +#ifdef _MSC_VER #ifndef HAVE_CONFIG_H #define HAVE_CONFIG_H #endif @@ -60,42 +60,58 @@ static char *strndup(const char *str, int len) #endif +// Apple platform --------------------------------------------------- #ifdef __APPLE__ + #define isnan(x) ((x) != (x)) + #endif +// Windows platform ------------------------------------------------- // Posix functions special names with MS compilers. -#if defined(WIN32) +// Notes on MSVC compilers detection : +// * _MSC_VER define should be prefered to WIN32/_WIN32 +// * MSVC 6 : 1200 <= _MSC_VER < 1300 +// * MSVC 2003 : 1300 <= _MSC_VER < 1400 +// * MSVC 2005 : 1400 <= _MSC_VER < 1500 +// * MSVC 2008 : 1500 <= _MSC_VER +#ifdef _MSC_VER #define isnan _isnan #define snprintf _snprintf -//MSVC 2008 already has this -#if _MSC_VER <= 1400 +// For MSVC 2005 and older (2008 already defines these) +#if _MSC_VER < 1500 + #define vsnprintf _vsnprintf -#define isnan _isnan -#endif + +#endif // _MSC_VER < 1500 // For MSVC 2005 and newer #if _MSC_VER >= 1400 + #ifdef strdup #undef strdup #endif #define strdup _strdup + #define stricmp _stricmp #define strnicmp _strnicmp #define chdir _chdir #define getcwd _getcwd #define chmod _chmod + #ifdef mkdir #undef mkdir #endif #define mkdir(x) _mkdir(x) -#define execvp _execvp -#endif -#endif +#define execvp _execvp + +#endif // _MSC_VER >= 1400 + +#endif // _MSC_VER #endif // _SD_PORTABILITY_H_