j0!

Humbedooh and moa have managed to gobble something together that
compiles on both, FreeBSD and Solaris. But maybe someone who
actually knows how to program would like to review this before
I commit the Solaris portion of the patch:


diff --git a/iocore/eventsystem/UnixEventProcessor.cc 
b/iocore/eventsystem/UnixEventProcessor.cc
index 78f6f7d..95c0835 100644
--- a/iocore/eventsystem/UnixEventProcessor.cc
+++ b/iocore/eventsystem/UnixEventProcessor.cc
@@ -26,10 +26,14 @@
 #if TS_USE_HWLOC
 #include <hwloc.h>
 // TODO: (humbedooh): Make this build on Solaris with hwloc.
-#if defined(freebsd) || defined(solaris)
+#if defined(freebsd) || defined(darwin)
 #include <sys/cpuset.h>
 #define cpu_set_t cpuset_t
 #include <pthread_np.h>
+#elif defined(solaris)
+#include <sys/procset.h>
+#include <sys/processor.h>
+#include <sys/types.h>
 #endif
 #endif
 #include "ink_defs.h"
@@ -106,7 +110,9 @@ EventProcessor::start(int n_event_threads)
 #if TS_USE_HWLOC
   int affinity = 0;
   REC_ReadConfigInteger(affinity, "proxy.config.exec_thread.affinity");
+#if !defined(solaris)
   cpu_set_t cpuset;
+#endif
   const hwloc_topology_t *topology = ink_get_topology();
   int cu = hwloc_get_nbobjs_by_type(*topology, HWLOC_OBJ_CORE);
   int pu = hwloc_get_nbobjs_by_type(*topology, HWLOC_OBJ_PU);
@@ -121,11 +127,18 @@ EventProcessor::start(int n_event_threads)
 
 #if TS_USE_HWLOC
     if (affinity == 1) {
-      CPU_ZERO(&cpuset);
       int cpu = (i - 1) % num_cpus;
+#if !defined(solaris)
+      CPU_ZERO(&cpuset);
       CPU_SET(cpu, &cpuset);
+#endif
+
       Debug("iocore_thread", "setaffinity tid: %p, net thread: %d, cpu: %d", 
tid, i, cpu);
+#if !defined(solaris)
       assert(pthread_setaffinity_np(tid, sizeof(cpu_set_t), &cpuset) == 0);
+#else
+      assert(processor_bind(P_LWPID, tid, cpu, NULL));
+#endif
     }
 #endif
   }

Reply via email to