diff options
author | bunnei <bunneidev@gmail.com> | 2016-10-31 15:33:39 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-31 15:33:39 -0400 |
commit | 946b62c03dad318673138d9e9b5030aa7a195206 (patch) | |
tree | a608c553f6c905961ce23647b3282599afd30ce6 /src/common/thread.cpp | |
parent | dc1e04137c3788a49b042a6aab95a9508cdee484 (diff) | |
parent | 8b833d3a97712de3d547123bd4399ba8b530e2ac (diff) |
Merge pull request #2123 from jbeich/freebsd
Fix build on DragonFly and FreeBSD
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 @@ #elif defined(_WIN32) #include <Windows.h> #else -#if defined(BSD4_4) || defined(__OpenBSD__) +#if defined(__Bitrig__) || defined(__DragonFly__) || defined(__FreeBSD__) || defined(__OpenBSD__) #include <pthread_np.h> #else #include <pthread.h> @@ -19,6 +19,10 @@ #include <unistd.h> #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); @@ -117,8 +121,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 |