mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-22 16:18:28 -05:00
cpu affinity: DragonFlyBSD support (#7956)
This commit is contained in:
parent
ebfa769925
commit
27f4c212f3
@ -253,7 +253,7 @@ int pthread_setname_np(const char *name);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Check if we can use setcpuaffinity(). */
|
/* 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
|
#define USE_SETCPUAFFINITY
|
||||||
void setcpuaffinity(const char *cpulist);
|
void setcpuaffinity(const char *cpulist);
|
||||||
#endif
|
#endif
|
||||||
|
@ -36,6 +36,10 @@
|
|||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/cpuset.h>
|
#include <sys/cpuset.h>
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef __DragonFly__
|
||||||
|
#include <pthread.h>
|
||||||
|
#include <pthread_np.h>
|
||||||
|
#endif
|
||||||
#ifdef __NetBSD__
|
#ifdef __NetBSD__
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
@ -72,7 +76,7 @@ void setcpuaffinity(const char *cpulist) {
|
|||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
cpu_set_t cpuset;
|
cpu_set_t cpuset;
|
||||||
#endif
|
#endif
|
||||||
#ifdef __FreeBSD__
|
#if defined (__FreeBSD__) || defined(__DragonFly__)
|
||||||
cpuset_t cpuset;
|
cpuset_t cpuset;
|
||||||
#endif
|
#endif
|
||||||
#ifdef __NetBSD__
|
#ifdef __NetBSD__
|
||||||
@ -139,6 +143,9 @@ void setcpuaffinity(const char *cpulist) {
|
|||||||
#ifdef __FreeBSD__
|
#ifdef __FreeBSD__
|
||||||
cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_TID, -1, sizeof(cpuset), &cpuset);
|
cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_TID, -1, sizeof(cpuset), &cpuset);
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef __DragonFly__
|
||||||
|
pthread_setaffinity_np(pthread_self(), sizeof(cpuset), &cpuset);
|
||||||
|
#endif
|
||||||
#ifdef __NetBSD__
|
#ifdef __NetBSD__
|
||||||
pthread_setaffinity_np(pthread_self(), cpuset_size(cpuset), cpuset);
|
pthread_setaffinity_np(pthread_self(), cpuset_size(cpuset), cpuset);
|
||||||
cpuset_destroy(cpuset);
|
cpuset_destroy(cpuset);
|
||||||
|
Loading…
Reference in New Issue
Block a user