diff options
author | David CARLIER <devnexen@gmail.com> | 2020-09-09 18:12:58 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-09 19:12:58 +0200 |
commit | 0683bea283d456253de343f37720789382ece6b2 (patch) | |
tree | 4fd163e03a385145013364a812afd926e13d0329 /src | |
parent | 62913b872ea1b21a5aada55ed323476fbcea61dc (diff) | |
download | minetest-0683bea283d456253de343f37720789382ece6b2.tar.gz minetest-0683bea283d456253de343f37720789382ece6b2.tar.bz2 minetest-0683bea283d456253de343f37720789382ece6b2.zip |
Add NetBSD cpu affinity support code (#10378)
Diffstat (limited to 'src')
-rw-r--r-- | src/threading/thread.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/threading/thread.cpp b/src/threading/thread.cpp index eb51516c6..e19e6ae60 100644 --- a/src/threading/thread.cpp +++ b/src/threading/thread.cpp @@ -33,6 +33,8 @@ DEALINGS IN THE SOFTWARE. #include <sys/prctl.h> #elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) #include <pthread_np.h> +#elif defined(__NetBSD__) + #include <sched.h> #elif defined(_MSC_VER) struct THREADNAME_INFO { DWORD dwType; // Must be 0x1000 @@ -285,7 +287,14 @@ bool Thread::bindToProcessor(unsigned int proc_number) CPU_SET(proc_number, &cpuset); return pthread_setaffinity_np(getThreadHandle(), sizeof(cpuset), &cpuset) == 0; +#elif defined(__NetBSD__) + cpuset_t *cpuset = cpuset_create(); + if (cpuset == NULL) + return false; + int r = pthread_setaffinity_np(getThreadHandle(), cpuset_size(cpuset), cpuset); + cpuset_destroy(cpuset); + return r == 0; #elif defined(__sun) || defined(sun) return processor_bind(P_LWPID, P_MYID, proc_number, NULL) == 0 |