From 4b202029909f46d61bbcdc466de663d157ba2afc Mon Sep 17 00:00:00 2001 From: Jan Beich Date: Wed, 15 Nov 2017 19:26:27 +0000 Subject: [PATCH] Thread: unbreak on BSDs after dbc9bdfe02ae 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 --- Utilities/Thread.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Utilities/Thread.cpp b/Utilities/Thread.cpp index a6159b1f78..2682ed008b 100644 --- a/Utilities/Thread.cpp +++ b/Utilities/Thread.cpp @@ -19,6 +19,10 @@ #include #include #endif +#if defined(__DragonFly__) || defined(__FreeBSD__) +#include +#define cpu_set_t cpuset_t +#endif #include #include #include @@ -1922,7 +1926,7 @@ void thread_ctrl::set_ideal_processor_core(int core) thread_affinity_policy_data_t policy = { static_cast(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);