Add latency bin output to the json output format
[fio.git] / os / os-solaris.h
index e6612118ace4baf7afcae38eb9a7126ca45af10e..5b78cc2cc43cb384fb8d5e6e1f952bd6f618c1b6 100644 (file)
@@ -5,6 +5,7 @@
 
 #include <errno.h>
 #include <malloc.h>
+#include <unistd.h>
 #include <sys/types.h>
 #include <sys/fcntl.h>
 #include <sys/pset.h>
@@ -103,6 +104,42 @@ static inline int fio_set_odirect(int fd)
 #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)