diff options
author | John Hodge (Mutabah) <acessdev@gmail.com> | 2018-02-11 15:33:08 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-11 15:33:08 +0800 |
commit | 6caf5739a97774b2602106e616db75e8a0ad5f8a (patch) | |
tree | 9d16f869bbff27743fe7c233fba9c4665a4d9138 /tools/minicargo/debug.cpp | |
parent | 9e864a5d3ea05706ea6c7f68e47d32629a2c877e (diff) | |
parent | 3718f8cb7ee7b8c93e4d69b9aa2e00b4f50efd62 (diff) | |
download | mrust-6caf5739a97774b2602106e616db75e8a0ad5f8a.tar.gz |
Merge pull request #52 from thepowersgang/common_layout
Merge "common_layout" branch
Diffstat (limited to 'tools/minicargo/debug.cpp')
-rw-r--r-- | tools/minicargo/debug.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
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 <set> #include <iostream> #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<void(::std::ostream& os)> 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 --; |