mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-07-27 02:57:21 +03:00
Also check for pthread_getaffinity_np
GNU/Hurd has the cpuset types and macros, but no pthread_getaffinity_np yet.
This commit is contained in:
parent
989914670d
commit
17ae5b5747
3 changed files with 23 additions and 4 deletions
|
|
@ -116,7 +116,7 @@ set_current_thread_affinity(int cpu) {
|
|||
#if defined(JEMALLOC_HAVE_SCHED_SETAFFINITY) || defined(JEMALLOC_HAVE_PTHREAD_SETAFFINITY_NP)
|
||||
#if defined(JEMALLOC_HAVE_SCHED_SETAFFINITY)
|
||||
cpu_set_t cpuset;
|
||||
#else
|
||||
#elif defined(JEMALLOC_HAVE_PTHREAD_GETAFFINITY_NP)
|
||||
# ifndef __NetBSD__
|
||||
cpuset_t cpuset;
|
||||
# else
|
||||
|
|
@ -124,16 +124,20 @@ set_current_thread_affinity(int cpu) {
|
|||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(JEMALLOC_HAVE_SCHED_SETAFFINITY) || defined(JEMALLOC_HAVE_PTHREAD_GETAFFINITY_NP)
|
||||
#ifndef __NetBSD__
|
||||
CPU_ZERO(&cpuset);
|
||||
CPU_SET(cpu, &cpuset);
|
||||
#else
|
||||
cpuset = cpuset_create();
|
||||
#endif
|
||||
#else
|
||||
return 1;
|
||||
#endif
|
||||
|
||||
#if defined(JEMALLOC_HAVE_SCHED_SETAFFINITY)
|
||||
return (sched_setaffinity(0, sizeof(cpu_set_t), &cpuset) != 0);
|
||||
#else
|
||||
#elif defined(JEMALLOC_HAVE_PTHREAD_GETAFFINITY_NP)
|
||||
# ifndef __NetBSD__
|
||||
int ret = pthread_setaffinity_np(pthread_self(), sizeof(cpuset_t),
|
||||
&cpuset);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue