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

Commit

Permalink
FreeBSD: implements cpu availability command line.
Browse files Browse the repository at this point in the history
  • Loading branch information
devnexen committed Jul 31, 2019
1 parent fb1f871 commit f182880
Showing 1 changed file with 12 additions and 1 deletion.
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(__linux__)
if (sched_setaffinity(0, sizeof(c), &c))
PFATAL("sched_setaffinity failed");
#elif defined(__FreeBSD__)
if (pthread_setaffinity_np(pthread_self(), sizeof(c), &c))
PFATAL("pthread_setaffinity_np failed");
#endif

util_perc = measure_preemption(CTEST_CORE_TRG_MS);

Expand Down

0 comments on commit f182880

Please sign in to comment.