1 #ifndef FIO_OS_SOLARIS_H
2 #define FIO_OS_SOLARIS_H
4 #define FIO_OS os_solaris
10 #include <sys/fcntl.h>
14 #include <sys/byteorder.h>
18 #define FIO_HAVE_CPU_AFFINITY
19 #define FIO_HAVE_PSHARED_MUTEX
20 #define FIO_HAVE_CHARDEV_SIZE
21 #define FIO_USE_GENERIC_BDEV_SIZE
22 #define FIO_USE_GENERIC_INIT_RANDOM_STATE
23 #define FIO_HAVE_GETTID
25 #define OS_MAP_ANON MAP_ANON
26 #define OS_RAND_MAX 2147483648UL
28 #define fio_swap16(x) BSWAP_16(x)
29 #define fio_swap32(x) BSWAP_32(x)
30 #define fio_swap64(x) BSWAP_64(x)
32 struct solaris_rand_seed {
36 #ifndef POSIX_MADV_SEQUENTIAL
37 #define posix_madvise madvise
38 #define POSIX_MADV_SEQUENTIAL MADV_SEQUENTIAL
39 #define POSIX_MADV_DONTNEED MADV_DONTNEED
40 #define POSIX_MADV_RANDOM MADV_RANDOM
43 #define os_ctime_r(x, y, z) ctime_r((x), (y), (z))
44 #define FIO_OS_HAS_CTIME_R
46 typedef psetid_t os_cpu_mask_t;
47 typedef struct solaris_rand_seed os_random_state_t;
49 static inline int chardev_size(struct fio_file *f, unsigned long long *bytes)
55 if (ioctl(f->fd, DKIOCGMEDIAINFO, &info) < 0)
58 *bytes = info.dki_lbsize * info.dki_capacity;
62 static inline int blockdev_invalidate_cache(struct fio_file *f)
67 static inline unsigned long long os_phys_mem(void)
72 static inline void os_random_seed(unsigned long seed, os_random_state_t *rs)
74 rs->r[0] = seed & 0xffff;
76 rs->r[1] = seed & 0xffff;
78 rs->r[2] = seed & 0xffff;
82 static inline long os_random_long(os_random_state_t *rs)
84 return nrand48(rs->r);
87 #define FIO_OS_DIRECTIO
88 extern int directio(int, int);
89 static inline int fio_set_odirect(int fd)
91 if (directio(fd, DIRECTIO_ON) < 0)
98 * pset binding hooks for fio
100 #define fio_setaffinity(pid, cpumask) \
101 pset_bind((cpumask), P_PID, (pid), NULL)
102 #define fio_getaffinity(pid, ptr) ({ 0; })
104 #define fio_cpu_clear(mask, cpu) pset_assign(PS_NONE, (cpu), NULL)
105 #define fio_cpu_set(mask, cpu) pset_assign(*(mask), (cpu), NULL)
107 static inline int fio_cpu_isset(os_cpu_mask_t *mask, int cpu)
109 const unsigned int max_cpus = sysconf(_SC_NPROCESSORS_ONLN);
110 unsigned int num_cpus;
114 cpus = malloc(sizeof(*cpus) * max_cpus);
116 if (pset_info(*mask, NULL, &num_cpus, cpus) < 0) {
122 for (i = 0; i < num_cpus; i++) {
123 if (cpus[i] == cpu) {
133 static inline int fio_cpu_count(os_cpu_mask_t *mask)
135 unsigned int num_cpus;
137 if (pset_info(*mask, NULL, &num_cpus, NULL) < 0)
143 static inline int fio_cpuset_init(os_cpu_mask_t *mask)
145 if (pset_create(mask) < 0)
151 static inline int fio_cpuset_exit(os_cpu_mask_t *mask)
153 if (pset_destroy(*mask) < 0)
159 static inline int gettid(void)
161 return pthread_self();
165 * Should be enough, not aware of what (if any) restrictions Solaris has
167 #define FIO_MAX_CPUS 16384
170 #define FIO_MADV_FREE MADV_FREE