+/*
+ * pset binding hooks for fio
+ */
+#define fio_setaffinity(pid, cpumask) \
+ pset_bind((cpumask), P_PID, (pid), NULL)
+#define fio_getaffinity(pid, ptr) ({ 0; })
+
+#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)
+ return -1;
+
+ return 0;
+}
+
+static inline int fio_cpuset_exit(os_cpu_mask_t *mask)
+{
+ if (pset_destroy(*mask) < 0)
+ return -1;
+
+ return 0;
+}
+
+static inline int gettid(void)
+{
+ return pthread_self();
+}
+
+/*
+ * Should be enough, not aware of what (if any) restrictions Solaris has
+ */
+#define FIO_MAX_CPUS 16384
+
+#ifdef MADV_FREE
+#define FIO_MADV_FREE MADV_FREE
+#endif
+