From 1410bd3bd03f057a96348c9167bb7f5c0cb3b0de Mon Sep 17 00:00:00 2001 From: Jan Beich Date: Mon, 10 Oct 2016 02:25:19 +0000 Subject: common: define routines to set thread name on more BSDs src/common/thread.cpp:123:5: error: use of undeclared identifier 'pthread_setname_np' pthread_setname_np(pthread_self(), szThreadName); ^ 1 error generated. --- src/common/thread.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/common/thread.cpp') diff --git a/src/common/thread.cpp b/src/common/thread.cpp index 6e7b39b9a..a4f5fa336 100644 --- a/src/common/thread.cpp +++ b/src/common/thread.cpp @@ -8,7 +8,7 @@ #elif defined(_WIN32) #include #else -#if defined(BSD4_4) || defined(__OpenBSD__) +#if defined(__Bitrig__) || defined(__DragonFly__) || defined(__FreeBSD__) || defined(__OpenBSD__) #include #else #include @@ -117,8 +117,10 @@ void SwitchCurrentThread() { void SetCurrentThreadName(const char* szThreadName) { #ifdef __APPLE__ pthread_setname_np(szThreadName); -#elif defined(__OpenBSD__) +#elif defined(__Bitrig__) || defined(__DragonFly__) || defined(__FreeBSD__) || defined(__OpenBSD__) pthread_set_name_np(pthread_self(), szThreadName); +#elif defined(__NetBSD__) + pthread_setname_np(pthread_self(), "%s", (void*)szThreadName); #else pthread_setname_np(pthread_self(), szThreadName); #endif -- cgit v1.2.3 From 8ce1ec7ffa6b912dfa776d6923a7af18a7761f67 Mon Sep 17 00:00:00 2001 From: Jan Beich Date: Mon, 10 Oct 2016 02:33:41 +0000 Subject: common: only FreeBSD has thread affinity compatible with Linux src/common/thread.cpp:90:5: error: unknown type name 'cpu_set_t'; did you mean 'cpuset_t'? cpu_set_t cpu_set; ^~~~~~~~~ cpuset_t /usr/include/sys/_cpuset.h:48:24: note: 'cpuset_t' declared here typedef struct _cpuset cpuset_t; ^ 1 error generated. --- src/common/thread.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/common/thread.cpp') diff --git a/src/common/thread.cpp b/src/common/thread.cpp index a4f5fa336..9bb2f4e1d 100644 --- a/src/common/thread.cpp +++ b/src/common/thread.cpp @@ -19,6 +19,10 @@ #include #endif +#ifdef __FreeBSD__ +#define cpu_set_t cpuset_t +#endif + namespace Common { int CurrentThreadId() { @@ -86,7 +90,7 @@ void SetCurrentThreadName(const char* szThreadName) { 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) && !(defined ANDROID) +#elif (defined __linux__ || defined __FreeBSD__) && !(defined ANDROID) cpu_set_t cpu_set; CPU_ZERO(&cpu_set); -- cgit v1.2.3