regressions/common: Add Mac OS X implementation off aff_iterate.

ck_pring
Samy Al Bahra 14 years ago
parent e23e85b9e9
commit 9f53c39600

@ -32,6 +32,9 @@
#include <unistd.h> #include <unistd.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/syscall.h> #include <sys/syscall.h>
#elif defined(__MACH__)
#include <mach/mach.h>
#include <mach/thread_policy.h>
#endif #endif
#ifndef CORES #ifndef CORES
@ -66,6 +69,20 @@ aff_iterate(struct affinity *acb)
return sched_setaffinity(gettid(), sizeof(s), &s); return sched_setaffinity(gettid(), sizeof(s), &s);
} }
#elif defined(__MACH__)
CK_CC_UNUSED static int
aff_iterate(struct affinity *acb)
{
thread_affinity_policy_data_t policy;
unsigned int c;
c = ck_pr_faa_uint(&acb->request, acb->delta) % CORES;
policy.affinity_tag = c;
return thread_policy_set(mach_thread_self(),
THREAD_AFFINITY_POLICY,
(thread_policy_t)&policy,
THREAD_AFFINITY_POLICY_COUNT);
}
#else #else
CK_CC_UNUSED static int CK_CC_UNUSED static int
aff_iterate(struct affinity *acb CK_CC_UNUSED) aff_iterate(struct affinity *acb CK_CC_UNUSED)

Loading…
Cancel
Save