summaryrefslogtreecommitdiff
path: root/src/common/thread.cpp
diff options
context:
space:
mode:
authorGravatar darkf2014-11-28 21:38:20 -0800
committerGravatar darkf2014-11-28 21:38:20 -0800
commit459502e48ccb6607e531112e7ae89f62b75023c8 (patch)
tree491c2a24f1496d4abab0d3339e559b9facc74265 /src/common/thread.cpp
parentMerge pull request #223 from linkmauve/remove-thread (diff)
downloadyuzu-459502e48ccb6607e531112e7ae89f62b75023c8.tar.gz
yuzu-459502e48ccb6607e531112e7ae89f62b75023c8.tar.xz
yuzu-459502e48ccb6607e531112e7ae89f62b75023c8.zip
Fix MinGW build
Diffstat (limited to 'src/common/thread.cpp')
-rw-r--r--src/common/thread.cpp23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/common/thread.cpp b/src/common/thread.cpp
index dc153ba71..6eeda0828 100644
--- a/src/common/thread.cpp
+++ b/src/common/thread.cpp
@@ -17,7 +17,7 @@ namespace Common
17 17
18int CurrentThreadId() 18int CurrentThreadId()
19{ 19{
20#ifdef _WIN32 20#ifdef MSVC_VER
21 return GetCurrentThreadId(); 21 return GetCurrentThreadId();
22#elif defined __APPLE__ 22#elif defined __APPLE__
23 return mach_thread_self(); 23 return mach_thread_self();
@@ -27,6 +27,14 @@ int CurrentThreadId()
27} 27}
28 28
29#ifdef _WIN32 29#ifdef _WIN32
30// Supporting functions
31void SleepCurrentThread(int ms)
32{
33 Sleep(ms);
34}
35#endif
36
37#ifdef MSVC_VER
30 38
31void SetThreadAffinity(std::thread::native_handle_type thread, u32 mask) 39void SetThreadAffinity(std::thread::native_handle_type thread, u32 mask)
32{ 40{
@@ -38,12 +46,6 @@ void SetCurrentThreadAffinity(u32 mask)
38 SetThreadAffinityMask(GetCurrentThread(), mask); 46 SetThreadAffinityMask(GetCurrentThread(), mask);
39} 47}
40 48
41// Supporting functions
42void SleepCurrentThread(int ms)
43{
44 Sleep(ms);
45}
46
47void SwitchCurrentThread() 49void SwitchCurrentThread()
48{ 50{
49 SwitchToThread(); 51 SwitchToThread();
@@ -82,7 +84,7 @@ void SetCurrentThreadName(const char* szThreadName)
82 {} 84 {}
83} 85}
84 86
85#else // !WIN32, so must be POSIX threads 87#else // !MSVC_VER, so must be POSIX threads
86 88
87void SetThreadAffinity(std::thread::native_handle_type thread, u32 mask) 89void SetThreadAffinity(std::thread::native_handle_type thread, u32 mask)
88{ 90{
@@ -106,6 +108,7 @@ void SetCurrentThreadAffinity(u32 mask)
106 SetThreadAffinity(pthread_self(), mask); 108 SetThreadAffinity(pthread_self(), mask);
107} 109}
108 110
111#ifndef _WIN32
109void SleepCurrentThread(int ms) 112void SleepCurrentThread(int ms)
110{ 113{
111 usleep(1000 * ms); 114 usleep(1000 * ms);
@@ -115,7 +118,10 @@ void SwitchCurrentThread()
115{ 118{
116 usleep(1000 * 1); 119 usleep(1000 * 1);
117} 120}
121#endif
118 122
123// MinGW with the POSIX threading model does not support pthread_setname_np
124#if !defined(_WIN32) || defined(MSVC_VER)
119void SetCurrentThreadName(const char* szThreadName) 125void SetCurrentThreadName(const char* szThreadName)
120{ 126{
121#ifdef __APPLE__ 127#ifdef __APPLE__
@@ -126,6 +132,7 @@ void SetCurrentThreadName(const char* szThreadName)
126 pthread_setname_np(pthread_self(), szThreadName); 132 pthread_setname_np(pthread_self(), szThreadName);
127#endif 133#endif
128} 134}
135#endif
129 136
130#endif 137#endif
131 138