From 18f407110bfb55052043adff0f490b53b928ed60 Mon Sep 17 00:00:00 2001 From: Themaister Date: Sat, 24 Dec 2011 20:43:58 +0100 Subject: [PATCH] Fixup compatibility. --- audio/xaudio-c/xaudio-c.c | 7 ++++++- posix_string.c | 13 +++++++++---- posix_string.h | 10 +++++++--- strl.h | 10 ++++++++-- 4 files changed, 30 insertions(+), 10 deletions(-) diff --git a/audio/xaudio-c/xaudio-c.c b/audio/xaudio-c/xaudio-c.c index 38f9f2b2e4..7eb9c9fb55 100644 --- a/audio/xaudio-c/xaudio-c.c +++ b/audio/xaudio-c/xaudio-c.c @@ -4,13 +4,18 @@ License: Public Domain */ -#include "xaudio-c.h" #include "xaudio.h" +#include "xaudio-c.h" #include #define MAX_BUFFERS 16 #define MAX_BUFFERS_MASK (MAX_BUFFERS - 1) +#undef min +#undef max +#define min(a, b) ((a) < (b) ? (a) : (b)) +#define max(a, b) ((a) > (b) ? (a) : (b)) + struct xaudio2 { const IXAudio2VoiceCallbackVtbl *lpVtbl; diff --git a/posix_string.c b/posix_string.c index 2314156e2c..3b8c70766c 100644 --- a/posix_string.c +++ b/posix_string.c @@ -16,13 +16,18 @@ */ #include "posix_string.h" + +#undef strcasecmp +#undef strdup +#undef isblank #include #include -#include #include #include "strl.h" -int strcasecmp(const char *a, const char *b) +#include + +int strcasecmp_ssnes__(const char *a, const char *b) { while (*a && *b) { @@ -38,7 +43,7 @@ int strcasecmp(const char *a, const char *b) return tolower(*a) - tolower(*b); } -char *strdup(const char *orig) +char *strdup_ssnes__(const char *orig) { size_t len = strlen(orig) + 1; char *ret = (char*)malloc(len); @@ -49,7 +54,7 @@ char *strdup(const char *orig) return ret; } -int isblank(int c) +int isblank_ssnes__(int c) { return (c == ' ') || (c == '\t'); } diff --git a/posix_string.h b/posix_string.h index 7f568b64e7..185a24df5a 100644 --- a/posix_string.h +++ b/posix_string.h @@ -19,14 +19,18 @@ #define __SSNES_POSIX_STRING_H #ifdef _WIN32 - +#ifdef __cplusplus +extern "C" { +#endif #define strcasecmp(a, b) strcasecmp_ssnes__(a, b) #define strdup(orig) strdup_ssnes__(orig) #define isblank(c) isblank_ssnes__(c) int strcasecmp(const char *a, const char *b); char *strdup(const char *orig); int isblank(int c); -#endif - +#ifdef __cplusplus +} +#endif +#endif #endif diff --git a/strl.h b/strl.h index a80382cc62..665c67f077 100644 --- a/strl.h +++ b/strl.h @@ -26,13 +26,19 @@ #endif #ifndef HAVE_STRL + +#ifdef __cplusplus +extern "C" { +#endif // Avoid possible naming collitions during link since we prefer to use the actual name. #define strlcpy(dst, src, size) strlcpy_ssnes__(dst, src, size) #define strlcat(dst, src, size) strlcat_ssnes__(dst, src, size) size_t strlcpy(char *dest, const char *source, size_t size); size_t strlcat(char *dest, const char *source, size_t size); -#endif - +#ifdef __cplusplus +} +#endif +#endif #endif