diff options
author | bunnei <bunneidev@gmail.com> | 2014-12-30 23:54:02 -0500 |
---|---|---|
committer | bunnei <bunneidev@gmail.com> | 2014-12-30 23:54:02 -0500 |
commit | 29da5da9513c0faae0880d2fced18f80ef89923b (patch) | |
tree | 9a652fd606e57f322ca07e1468ea3ae83addf6a2 /src/common/thread.cpp | |
parent | 74d7b45d09c172bdb6dce665903537a784acb110 (diff) | |
parent | 5d10b212ecebb15fb1463edc08c725d8e29fa44a (diff) |
Merge pull request #369 from darkf/mingw_
Fix MinGW build (2)
Diffstat (limited to 'src/common/thread.cpp')
-rw-r--r-- | src/common/thread.cpp | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/src/common/thread.cpp b/src/common/thread.cpp index 8c83d67b5..8bf005857 100644 --- a/src/common/thread.cpp +++ b/src/common/thread.cpp @@ -17,7 +17,7 @@ namespace Common int CurrentThreadId() { -#ifdef _WIN32 +#ifdef _MSC_VER return GetCurrentThreadId(); #elif defined __APPLE__ return mach_thread_self(); @@ -27,6 +27,14 @@ int CurrentThreadId() } #ifdef _WIN32 +// Supporting functions +void SleepCurrentThread(int ms) +{ + Sleep(ms); +} +#endif + +#ifdef _MSC_VER void SetThreadAffinity(std::thread::native_handle_type thread, u32 mask) { @@ -38,12 +46,6 @@ void SetCurrentThreadAffinity(u32 mask) SetThreadAffinityMask(GetCurrentThread(), mask); } -// Supporting functions -void SleepCurrentThread(int ms) -{ - Sleep(ms); -} - void SwitchCurrentThread() { SwitchToThread(); @@ -82,7 +84,7 @@ void SetCurrentThreadName(const char* szThreadName) {} } -#else // !WIN32, so must be POSIX threads +#else // !MSVC_VER, so must be POSIX threads void SetThreadAffinity(std::thread::native_handle_type thread, u32 mask) { @@ -106,6 +108,7 @@ void SetCurrentThreadAffinity(u32 mask) SetThreadAffinity(pthread_self(), mask); } +#ifndef _WIN32 void SleepCurrentThread(int ms) { usleep(1000 * ms); @@ -115,7 +118,10 @@ void SwitchCurrentThread() { usleep(1000 * 1); } +#endif +// MinGW with the POSIX threading model does not support pthread_setname_np +#if !defined(_WIN32) || defined(_MSC_VER) void SetCurrentThreadName(const char* szThreadName) { #ifdef __APPLE__ @@ -126,6 +132,7 @@ void SetCurrentThreadName(const char* szThreadName) pthread_setname_np(pthread_self(), szThreadName); #endif } +#endif #endif |