From 418e341b32d307b4cd8cc4fe5931b09975fa40c8 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 29 Aug 2017 18:27:46 +0200 Subject: [PATCH 1/4] Patches to make it possible to compile with mingw, pt. 1 --- Common/Atomic_Win32.h | 4 ++++ Common/Common.h | 2 ++ Common/ConsoleListener.cpp | 2 +- Common/FileUtil.h | 2 ++ Common/MsgHandler.h | 2 +- 5 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Common/Atomic_Win32.h b/Common/Atomic_Win32.h index e15101733c..7040deb809 100644 --- a/Common/Atomic_Win32.h +++ b/Common/Atomic_Win32.h @@ -88,6 +88,10 @@ inline void AtomicStoreRelease(volatile T& dest, U value) dest = (T)value; // 32-bit writes are always atomic } +#ifdef __MINGW32__ +void *_InterlockedExchangePointer_acq(void *volatile *, void volatile *); +#endif + template inline T* AtomicExchangeAcquire(T* volatile& loc, U newval) { diff --git a/Common/Common.h b/Common/Common.h index f93a71c465..0125068dcb 100644 --- a/Common/Common.h +++ b/Common/Common.h @@ -64,7 +64,9 @@ private: // Check MSC ver #if !defined _MSC_VER || _MSC_VER <= 1000 +#ifndef __MINGW32__ #error needs at least version 1000 of MSC +#endif #endif // Memory leak checks diff --git a/Common/ConsoleListener.cpp b/Common/ConsoleListener.cpp index 7f9e0a7f71..b969b6808a 100644 --- a/Common/ConsoleListener.cpp +++ b/Common/ConsoleListener.cpp @@ -77,7 +77,7 @@ ConsoleListener::~ConsoleListener() Close(); } -#ifdef _WIN32 +#if defined(_WIN32) && !defined(__MINGW32__) // Handle console event bool WINAPI ConsoleHandler(DWORD msgType) { diff --git a/Common/FileUtil.h b/Common/FileUtil.h index f0ce750010..fa132b9311 100644 --- a/Common/FileUtil.h +++ b/Common/FileUtil.h @@ -26,12 +26,14 @@ #include "Common.h" #ifdef _WIN32 +#ifndef __MINGW32__ inline struct tm* localtime_r(const time_t *clock, struct tm *result) { if (localtime_s(result, clock) == 0) return result; return NULL; } #endif +#endif namespace File { diff --git a/Common/MsgHandler.h b/Common/MsgHandler.h index 97e865bedf..75e8137e10 100644 --- a/Common/MsgHandler.h +++ b/Common/MsgHandler.h @@ -33,7 +33,7 @@ extern bool MsgAlert(bool yes_no, int Style, const char* format, ...) void SetEnableAlert(bool enable); #ifndef GEKKO -#ifdef _WIN32 +#if defined(_WIN32) && !defined(__MINGW32__) #define PanicAlert(format, ...) MsgAlert(false, WARNING, format, __VA_ARGS__) #define PanicYesNo(format, ...) MsgAlert(true, WARNING, format, __VA_ARGS__) #else From 4e040986ec566f77cd1c7cc7345b2195d645184a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 29 Aug 2017 18:45:15 +0200 Subject: [PATCH 2/4] Removed MSVC check --- Common/Common.h | 7 ------- 1 file changed, 7 deletions(-) diff --git a/Common/Common.h b/Common/Common.h index 0125068dcb..9a8a6d4270 100644 --- a/Common/Common.h +++ b/Common/Common.h @@ -62,13 +62,6 @@ private: #elif defined(_WIN32) -// Check MSC ver - #if !defined _MSC_VER || _MSC_VER <= 1000 -#ifndef __MINGW32__ - #error needs at least version 1000 of MSC -#endif - #endif - // Memory leak checks #define CHECK_HEAP_INTEGRITY() From cc24b158ac3560e8b1dc1c19226cc3bc5a84c5f3 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 29 Aug 2017 18:46:31 +0200 Subject: [PATCH 3/4] Change this to _MSC_VER --- Common/FileUtil.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Common/FileUtil.h b/Common/FileUtil.h index fa132b9311..5a0a9cb1f3 100644 --- a/Common/FileUtil.h +++ b/Common/FileUtil.h @@ -25,15 +25,13 @@ #include "Common.h" -#ifdef _WIN32 -#ifndef __MINGW32__ +#ifdef _MSC_VER inline struct tm* localtime_r(const time_t *clock, struct tm *result) { if (localtime_s(result, clock) == 0) return result; return NULL; } #endif -#endif namespace File { From 78b6636a2bd58bb81ae203f8d6f50463d4ed81e7 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 29 Aug 2017 18:49:36 +0200 Subject: [PATCH 4/4] Remove this too - we will use UNICODE and _UNICODE defines for mingw build --- Common/ConsoleListener.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Common/ConsoleListener.cpp b/Common/ConsoleListener.cpp index b969b6808a..d899aaf1fd 100644 --- a/Common/ConsoleListener.cpp +++ b/Common/ConsoleListener.cpp @@ -77,7 +77,7 @@ ConsoleListener::~ConsoleListener() Close(); } -#if defined(_WIN32) && !defined(__MINGW32__) +#if defined(_WIN32) // Handle console event bool WINAPI ConsoleHandler(DWORD msgType) {