1 #ifndef FIO_OS_SOLARIS_H
2 #define FIO_OS_SOLARIS_H
4 #define FIO_OS os_solaris
13 #include <sys/byteorder.h>
17 #define FIO_HAVE_CPU_AFFINITY
18 #define FIO_HAVE_PSHARED_MUTEX
19 #define FIO_HAVE_CHARDEV_SIZE
20 #define FIO_USE_GENERIC_BDEV_SIZE
21 #define FIO_USE_GENERIC_INIT_RANDOM_STATE
22 #define FIO_HAVE_GETTID
24 #define OS_MAP_ANON MAP_ANON
25 #define OS_RAND_MAX 2147483648UL
27 #define fio_swap16(x) BSWAP_16(x)
28 #define fio_swap32(x) BSWAP_32(x)
29 #define fio_swap64(x) BSWAP_64(x)
31 struct solaris_rand_seed {
35 #ifndef POSIX_MADV_SEQUENTIAL
36 #define posix_madvise madvise
37 #define POSIX_MADV_SEQUENTIAL MADV_SEQUENTIAL
38 #define POSIX_MADV_DONTNEED MADV_DONTNEED
39 #define POSIX_MADV_RANDOM MADV_RANDOM
42 #define os_ctime_r(x, y, z) ctime_r((x), (y), (z))
43 #define FIO_OS_HAS_CTIME_R
45 typedef psetid_t os_cpu_mask_t;
46 typedef struct solaris_rand_seed os_random_state_t;
48 static inline int chardev_size(struct fio_file *f, unsigned long long *bytes)
54 if (ioctl(f->fd, DKIOCGMEDIAINFO, &info) < 0)
57 *bytes = info.dki_lbsize * info.dki_capacity;
61 static inline int blockdev_invalidate_cache(struct fio_file *f)
66 static inline unsigned long long os_phys_mem(void)
71 static inline void os_random_seed(unsigned long seed, os_random_state_t *rs)
73 rs->r[0] = seed & 0xffff;
75 rs->r[1] = seed & 0xffff;
77 rs->r[2] = seed & 0xffff;
81 static inline long os_random_long(os_random_state_t *rs)
83 return nrand48(rs->r);
86 #define FIO_OS_DIRECTIO
87 extern int directio(int, int);
88 static inline int fio_set_odirect(int fd)
90 if (directio(fd, DIRECTIO_ON) < 0)
97 * pset binding hooks for fio
99 #define fio_setaffinity(pid, cpumask) \
100 pset_bind((cpumask), P_PID, (pid), NULL)
101 #define fio_getaffinity(pid, ptr) ({ 0; })
103 #define fio_cpu_clear(mask, cpu) pset_assign(PS_NONE, (cpu), NULL)
104 #define fio_cpu_set(mask, cpu) pset_assign(*(mask), (cpu), NULL)
106 static inline int fio_cpu_isset(os_cpu_mask_t *mask, int cpu)
108 const unsigned int max_cpus = cpus_online();
112 cpus = malloc(sizeof(*cpus) * max_cpus);
114 if (pset_info(*mask, NULL, &num_cpus, cpus) < 0) {
120 for (i = 0; i < max_cpus; i++) {
121 if (cpus[i] == cpu) {
131 static inline int fio_cpuset_init(os_cpu_mask_t *mask)
133 if (pset_create(mask) < 0)
139 static inline int fio_cpuset_count(os_cpu_mask_t *mask)
141 unsigned int num_cpus;
143 if (pset_info(*mask, NULL, &num_cpus, NULL) < 0)
149 static inline int fio_cpuset_exit(os_cpu_mask_t *mask)
151 if (pset_destroy(*mask) < 0)
157 static inline int gettid(void)
159 return pthread_self();
163 * Should be enough, not aware of what (if any) restrictions Solaris has
165 #define FIO_MAX_CPUS 16384
168 #define FIO_MADV_FREE MADV_FREE