mirror of
https://github.com/AFLplusplus/AFLplusplus.git
synced 2025-06-15 11:28:08 +00:00
afl-gotcpu: porting to Darwin using mach API.
This commit is contained in:
@ -52,7 +52,7 @@
|
|||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__)
|
#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__APPLE__)
|
||||||
#define HAVE_AFFINITY 1
|
#define HAVE_AFFINITY 1
|
||||||
#if defined(__FreeBSD__)
|
#if defined(__FreeBSD__)
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
@ -62,8 +62,12 @@
|
|||||||
#elif defined(__NetBSD__)
|
#elif defined(__NetBSD__)
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
|
#elif defined(__APPLE__)
|
||||||
|
#include <pthread.h>
|
||||||
|
#include <mach/thread_act.h>
|
||||||
|
#include <mach/thread_policy.h>
|
||||||
#endif
|
#endif
|
||||||
#endif /* __linux__ || __FreeBSD__ || __NetBSD__ */
|
#endif /* __linux__ || __FreeBSD__ || __NetBSD__ || __APPLE__ */
|
||||||
|
|
||||||
/* Get unix time in microseconds. */
|
/* Get unix time in microseconds. */
|
||||||
|
|
||||||
@ -176,6 +180,12 @@ int main(int argc, char** argv) {
|
|||||||
if (c == NULL) PFATAL("cpuset_create failed");
|
if (c == NULL) PFATAL("cpuset_create failed");
|
||||||
|
|
||||||
cpuset_set(i, c);
|
cpuset_set(i, c);
|
||||||
|
#elif defined(__APPLE__)
|
||||||
|
thread_affinity_policy_data_t c = { i };
|
||||||
|
thread_port_t native_thread = pthread_mach_thread_np(pthread_self());
|
||||||
|
if (thread_policy_set(native_thread, THREAD_AFFINITY_POLICY,
|
||||||
|
(thread_policy_t)&c, 1) != KERN_SUCCESS)
|
||||||
|
PFATAL("thread_policy_set failed");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__FreeBSD__)
|
#if defined(__FreeBSD__)
|
||||||
|
Reference in New Issue
Block a user