diff options
| author | Soren Jorvang <soren.jorvang@gmail.com> | 2011-02-02 21:52:43 +0000 |
|---|---|---|
| committer | Soren Jorvang <soren.jorvang@gmail.com> | 2011-02-02 21:52:43 +0000 |
| commit | a3ba93d9ce31c96570bf0b80ac9728ef98e93e77 (patch) | |
| tree | f167c424e81c449e47e1e55757483800579626c2 /Source/Core/Common/Src/Thread.cpp | |
| parent | 39b1ade020157a8bbc9b51453c54a3faccf71495 (diff) | |
Thread affinity on OS X and *BSD.
Keep building the software plugin to prevent rot.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7045 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core/Common/Src/Thread.cpp')
| -rw-r--r-- | Source/Core/Common/Src/Thread.cpp | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/Source/Core/Common/Src/Thread.cpp b/Source/Core/Common/Src/Thread.cpp index 0238b14008..fe9586f427 100644 --- a/Source/Core/Common/Src/Thread.cpp +++ b/Source/Core/Common/Src/Thread.cpp @@ -19,6 +19,12 @@ #include "Thread.h" #include "Common.h" +#ifdef __APPLE__ +#include <mach/mach.h> +#elif defined BSD4_4 +#include <pthread_np.h> +#endif + #ifdef USE_BEGINTHREADEX #include <process.h> #endif @@ -30,6 +36,8 @@ int CurrentThreadId() { #ifdef _WIN32 return GetCurrentThreadId(); +#elif defined __APPLE__ + return mach_thread_self(); #else return 0; #endif @@ -263,10 +271,12 @@ void SetCurrentThreadAffinity(u32 mask) #else // !WIN32, so must be POSIX threads -void LinuxSetThreadAffinity(pthread_t thread, u32 mask) -{ - // This is non-standard -#ifdef __linux__ +void SetThreadAffinity(std::thread::native_handle_type thread, u32 mask) +{ +#ifdef __APPLE__ + thread_policy_set(pthread_mach_thread_np(thread), + THREAD_AFFINITY_POLICY, (integer_t *)&mask, 1); +#elif defined __linux__ || defined BSD4_4 cpu_set_t cpu_set; CPU_ZERO(&cpu_set); @@ -278,14 +288,9 @@ void LinuxSetThreadAffinity(pthread_t thread, u32 mask) #endif } -void SetThreadAffinity(std::thread::native_handle_type thread, u32 mask) -{ - LinuxSetThreadAffinity(thread, mask); -} - void SetCurrentThreadAffinity(u32 mask) { - LinuxSetThreadAffinity(pthread_self(), mask); + SetThreadAffinity(pthread_self(), mask); } static pthread_key_t threadname_key; |
