diff --git a/src/config.h b/src/config.h index 320837b7e..b9c68f38b 100644 --- a/src/config.h +++ b/src/config.h @@ -253,7 +253,7 @@ int pthread_setname_np(const char *name); #endif /* Check if we can use setcpuaffinity(). */ -#if (defined __linux || defined __NetBSD__ || defined __FreeBSD__) +#if (defined __linux || defined __NetBSD__ || defined __FreeBSD__ || defined __DragonFly__) #define USE_SETCPUAFFINITY void setcpuaffinity(const char *cpulist); #endif diff --git a/src/setcpuaffinity.c b/src/setcpuaffinity.c index 13594113c..77b162103 100644 --- a/src/setcpuaffinity.c +++ b/src/setcpuaffinity.c @@ -36,6 +36,10 @@ #include #include #endif +#ifdef __DragonFly__ +#include +#include +#endif #ifdef __NetBSD__ #include #include @@ -72,7 +76,7 @@ void setcpuaffinity(const char *cpulist) { #ifdef __linux__ cpu_set_t cpuset; #endif -#ifdef __FreeBSD__ +#if defined (__FreeBSD__) || defined(__DragonFly__) cpuset_t cpuset; #endif #ifdef __NetBSD__ @@ -139,6 +143,9 @@ void setcpuaffinity(const char *cpulist) { #ifdef __FreeBSD__ cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_TID, -1, sizeof(cpuset), &cpuset); #endif +#ifdef __DragonFly__ + pthread_setaffinity_np(pthread_self(), sizeof(cpuset), &cpuset); +#endif #ifdef __NetBSD__ pthread_setaffinity_np(pthread_self(), cpuset_size(cpuset), cpuset); cpuset_destroy(cpuset);