From c4d7dfa0b6bb64924368f2eb73e12a2962183c22 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Sun, 28 Jan 2018 19:19:30 +0800 Subject: All - mingw32 compilation changes --- tools/minicargo/debug.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'tools/minicargo/debug.cpp') diff --git a/tools/minicargo/debug.cpp b/tools/minicargo/debug.cpp index f6fca62e..a3fb9956 100644 --- a/tools/minicargo/debug.cpp +++ b/tools/minicargo/debug.cpp @@ -5,6 +5,9 @@ * debug.cpp * - Debugging helpers */ +#if defined(__MINGW32__) +# define DISABLE_MULTITHREAD // Mingw32 doesn't have c++11 threads +#endif #include #include #include "debug.h" @@ -13,7 +16,9 @@ static int giIndentLevel = 0; static const char* gsDebugPhase = ""; static ::std::set<::std::string> gmDisabledDebug; +#ifndef DISABLE_MULTITHREAD static ::std::mutex gDebugLock; +#endif void Debug_SetPhase(const char* phase_name) { @@ -33,7 +38,9 @@ void Debug_Print(::std::function cb) { if( !Debug_IsEnabled() ) return ; +#ifndef DISABLE_MULTITHREAD ::std::unique_lock<::std::mutex> _lh { gDebugLock }; +#endif ::std::cout << gsDebugPhase << "- "; for(auto i = giIndentLevel; i --; ) @@ -45,7 +52,9 @@ void Debug_EnterScope(const char* name, dbg_cb_t cb) { if( !Debug_IsEnabled() ) return ; +#ifndef DISABLE_MULTITHREAD ::std::unique_lock<::std::mutex> _lh { gDebugLock }; +#endif ::std::cout << gsDebugPhase << "- "; for(auto i = giIndentLevel; i --; ) @@ -59,7 +68,9 @@ void Debug_LeaveScope(const char* name, dbg_cb_t cb) { if( !Debug_IsEnabled() ) return ; +#ifndef DISABLE_MULTITHREAD ::std::unique_lock<::std::mutex> _lh { gDebugLock }; +#endif ::std::cout << gsDebugPhase << "- "; giIndentLevel --; -- cgit v1.2.3