#include <errno.h>
#include <malloc.h>
+#include <unistd.h>
#include <sys/types.h>
#include <sys/fcntl.h>
#include <sys/pset.h>
#define fio_cpu_clear(mask, cpu) pset_assign(PS_NONE, (cpu), NULL)
#define fio_cpu_set(mask, cpu) pset_assign(*(mask), (cpu), NULL)
+static inline int fio_cpu_isset(os_cpu_mask_t *mask, int cpu)
+{
+ const unsigned int max_cpus = sysconf(_SC_NPROCESSORS_ONLN);
+ unsigned int num_cpus;
+ processorid_t *cpus;
+ int i, ret;
+
+ cpus = malloc(sizeof(*cpus) * max_cpus);
+
+ if (pset_info(*mask, NULL, &num_cpus, cpus) < 0) {
+ free(cpus);
+ return 0;
+ }
+
+ ret = 0;
+ for (i = 0; i < num_cpus; i++) {
+ if (cpus[i] == cpu) {
+ ret = 1;
+ break;
+ }
+ }
+
+ free(cpus);
+ return ret;
+}
+
+static inline int fio_cpu_count(os_cpu_mask_t *mask)
+{
+ unsigned int num_cpus;
+
+ if (pset_info(*mask, NULL, &num_cpus, NULL) < 0)
+ return 0;
+
+ return num_cpus;
+}
+
static inline int fio_cpuset_init(os_cpu_mask_t *mask)
{
if (pset_create(mask) < 0)