about summary refs log tree commit diff
path: root/src/afl-gotcpu.c
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2020-06-17 15:05:14 +0200
committerGitHub <noreply@github.com>2020-06-17 15:05:14 +0200
commit0dc9967984df3f9c250d4c27b6de1cbd4cac3eb3 (patch)
treeca6096f1d22ba87c262bdeaf57455520ef3143e2 /src/afl-gotcpu.c
parent12bdefe00e38cdc3dd8cb028eeac325ab2e94e16 (diff)
parent889e54eab858b1928f74a8c179b32275b62f2286 (diff)
downloadafl++-0dc9967984df3f9c250d4c27b6de1cbd4cac3eb3.tar.gz
Merge pull request #403 from AFLplusplus/dev
push to master
Diffstat (limited to 'src/afl-gotcpu.c')
-rw-r--r--src/afl-gotcpu.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/afl-gotcpu.c b/src/afl-gotcpu.c
index 43b3196b..bd0f7de6 100644
--- a/src/afl-gotcpu.c
+++ b/src/afl-gotcpu.c
@@ -54,7 +54,7 @@
 #include "common.h"
 
 #if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || \
-    defined(__APPLE__) || defined(__DragonFly__)
+    defined(__APPLE__) || defined(__DragonFly__) || defined(__sun)
   #define HAVE_AFFINITY 1
   #if defined(__FreeBSD__) || defined(__DragonFly__)
     #include <pthread.h>
@@ -70,6 +70,8 @@
     #include <pthread.h>
     #include <mach/thread_act.h>
     #include <mach/thread_policy.h>
+  #elif defined(__sun)
+    #include <sys/pset.h>
   #endif
 #endif               /* __linux__ || __FreeBSD__ || __NetBSD__ || __APPLE__ */
 
@@ -181,6 +183,12 @@ int main(int argc, char **argv) {
       if (thread_policy_set(native_thread, THREAD_AFFINITY_POLICY,
                             (thread_policy_t)&c, 1) != KERN_SUCCESS)
         PFATAL("thread_policy_set failed");
+  #elif defined(__sun)
+      psetid_t c;
+
+      if (pset_create(&c)) PFATAL("pset_create failed");
+
+      if (pset_assign(c, i, NULL)) PFATAL("pset_assign failed");
   #endif
 
   #if defined(__FreeBSD__) || defined(__DragonFly__)
@@ -195,6 +203,12 @@ int main(int argc, char **argv) {
       cpuset_destroy(c);
   #endif
 
+  #if defined(__sun)
+      if (pset_bind(c, P_PID, getpid(), NULL)) PFATAL("pset_bind failed");
+
+      pset_destroy(c);
+  #endif
+
   #if defined(__linux__)
       if (sched_setaffinity(0, sizeof(c), &c)) {