Thread: unbreak on BSDs after dbc9bdfe02

Utilities/Thread.cpp:1920:2: error: unknown type name 'cpu_set_t'; did you mean 'cpusetid_t'?
        cpu_set_t cs;
        ^~~~~~~~~
        cpusetid_t
/usr/include/sys/types.h:84:22: note: 'cpusetid_t' declared here
typedef __cpusetid_t    cpusetid_t;
                        ^
Utilities/Thread.cpp:1921:2: error: use of undeclared identifier 'CPU_ZERO'
        CPU_ZERO(&cs);
        ^
Utilities/Thread.cpp:1922:2: error: use of undeclared identifier 'CPU_SET'
        CPU_SET(core, &cs);
        ^
Utilities/Thread.cpp:1923:48: error: unknown type name 'cpu_set_t'; did you mean 'cpusetid_t'?
        pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cs);
                                                      ^~~~~~~~~
                                                      cpusetid_t
This commit is contained in:
Jan Beich 2017-11-15 19:26:27 +00:00
parent 380f90b097
commit 4b20202990

View file

@ -19,6 +19,10 @@
#include <mach/thread_act.h>
#include <mach/thread_policy.h>
#endif
#if defined(__DragonFly__) || defined(__FreeBSD__)
#include <pthread_np.h>
#define cpu_set_t cpuset_t
#endif
#include <errno.h>
#include <signal.h>
#include <ucontext.h>
@ -1922,7 +1926,7 @@ void thread_ctrl::set_ideal_processor_core(int core)
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
#elif defined(__linux__) || defined(__DragonFly__) || defined(__FreeBSD__)
cpu_set_t cs;
CPU_ZERO(&cs);
CPU_SET(core, &cs);