diff options
Diffstat (limited to 'src/common/thread.cpp')
| -rw-r--r-- | src/common/thread.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/common/thread.cpp b/src/common/thread.cpp index 6e7b39b9a..9bb2f4e1d 100644 --- a/src/common/thread.cpp +++ b/src/common/thread.cpp | |||
| @@ -8,7 +8,7 @@ | |||
| 8 | #elif defined(_WIN32) | 8 | #elif defined(_WIN32) |
| 9 | #include <Windows.h> | 9 | #include <Windows.h> |
| 10 | #else | 10 | #else |
| 11 | #if defined(BSD4_4) || defined(__OpenBSD__) | 11 | #if defined(__Bitrig__) || defined(__DragonFly__) || defined(__FreeBSD__) || defined(__OpenBSD__) |
| 12 | #include <pthread_np.h> | 12 | #include <pthread_np.h> |
| 13 | #else | 13 | #else |
| 14 | #include <pthread.h> | 14 | #include <pthread.h> |
| @@ -19,6 +19,10 @@ | |||
| 19 | #include <unistd.h> | 19 | #include <unistd.h> |
| 20 | #endif | 20 | #endif |
| 21 | 21 | ||
| 22 | #ifdef __FreeBSD__ | ||
| 23 | #define cpu_set_t cpuset_t | ||
| 24 | #endif | ||
| 25 | |||
| 22 | namespace Common { | 26 | namespace Common { |
| 23 | 27 | ||
| 24 | int CurrentThreadId() { | 28 | int CurrentThreadId() { |
| @@ -86,7 +90,7 @@ void SetCurrentThreadName(const char* szThreadName) { | |||
| 86 | void SetThreadAffinity(std::thread::native_handle_type thread, u32 mask) { | 90 | void SetThreadAffinity(std::thread::native_handle_type thread, u32 mask) { |
| 87 | #ifdef __APPLE__ | 91 | #ifdef __APPLE__ |
| 88 | thread_policy_set(pthread_mach_thread_np(thread), THREAD_AFFINITY_POLICY, (integer_t*)&mask, 1); | 92 | thread_policy_set(pthread_mach_thread_np(thread), THREAD_AFFINITY_POLICY, (integer_t*)&mask, 1); |
| 89 | #elif (defined __linux__ || defined BSD4_4) && !(defined ANDROID) | 93 | #elif (defined __linux__ || defined __FreeBSD__) && !(defined ANDROID) |
| 90 | cpu_set_t cpu_set; | 94 | cpu_set_t cpu_set; |
| 91 | CPU_ZERO(&cpu_set); | 95 | CPU_ZERO(&cpu_set); |
| 92 | 96 | ||
| @@ -117,8 +121,10 @@ void SwitchCurrentThread() { | |||
| 117 | void SetCurrentThreadName(const char* szThreadName) { | 121 | void SetCurrentThreadName(const char* szThreadName) { |
| 118 | #ifdef __APPLE__ | 122 | #ifdef __APPLE__ |
| 119 | pthread_setname_np(szThreadName); | 123 | pthread_setname_np(szThreadName); |
| 120 | #elif defined(__OpenBSD__) | 124 | #elif defined(__Bitrig__) || defined(__DragonFly__) || defined(__FreeBSD__) || defined(__OpenBSD__) |
| 121 | pthread_set_name_np(pthread_self(), szThreadName); | 125 | pthread_set_name_np(pthread_self(), szThreadName); |
| 126 | #elif defined(__NetBSD__) | ||
| 127 | pthread_setname_np(pthread_self(), "%s", (void*)szThreadName); | ||
| 122 | #else | 128 | #else |
| 123 | pthread_setname_np(pthread_self(), szThreadName); | 129 | pthread_setname_np(pthread_self(), szThreadName); |
| 124 | #endif | 130 | #endif |