1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-22 02:32:36 +01:00

Fix set thread affinity on OS X (#3757)

This commit is contained in:
scribam 2017-11-19 23:02:35 +01:00 committed by Ivan
parent 12ecba7d49
commit 222c0e0fc5

View File

@ -16,6 +16,8 @@
#ifdef __APPLE__ #ifdef __APPLE__
#define _XOPEN_SOURCE #define _XOPEN_SOURCE
#define __USE_GNU #define __USE_GNU
#include <mach/thread_act.h>
#include <mach/thread_policy.h>
#endif #endif
#include <errno.h> #include <errno.h>
#include <signal.h> #include <signal.h>
@ -1916,6 +1918,10 @@ void thread_ctrl::set_ideal_processor_core(int core)
#ifdef _WIN32 #ifdef _WIN32
HANDLE _this_thread = GetCurrentThread(); HANDLE _this_thread = GetCurrentThread();
SetThreadIdealProcessor(_this_thread, core); SetThreadIdealProcessor(_this_thread, core);
#elif __APPLE__
thread_affinity_policy_data_t policy = { static_cast<integer_t>(core) };
thread_port_t mach_thread = pthread_mach_thread_np(pthread_self());
thread_policy_set(mach_thread, THREAD_AFFINITY_POLICY, (thread_policy_t)&policy, 1);
#else #else
cpu_set_t cs; cpu_set_t cs;
CPU_ZERO(&cs); CPU_ZERO(&cs);