Skip to content
This repository has been archived by the owner on Mar 22, 2024. It is now read-only.

FreeBSD: implements cpu availability command line. #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion afl-gotcpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,14 @@
#include "types.h"
#include "debug.h"

#ifdef __linux__
#if defined(__linux__) || defined(__FreeBSD__)
# define HAVE_AFFINITY 1
# if defined(__FreeBSD__)
# include <pthread.h>
# include <pthread_np.h>
# include <sys/cpuset.h>
# define cpu_set_t cpuset_t
# endif
#endif /* __linux__ */


Expand Down Expand Up @@ -149,8 +155,13 @@ int main(int argc, char** argv) {
CPU_ZERO(&c);
CPU_SET(i, &c);

#if defined(__FreeBSD__)
if (pthread_setaffinity_np(pthread_self(), sizeof(c), &c))
PFATAL("pthread_setaffinity_np failed");
#else
if (sched_setaffinity(0, sizeof(c), &c))
PFATAL("sched_setaffinity failed");
#endif

util_perc = measure_preemption(CTEST_CORE_TRG_MS);

Expand Down