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>
15 #include <sys/statvfs.h>
20 #define FIO_HAVE_CPU_AFFINITY
21 #define FIO_HAVE_CHARDEV_SIZE
22 #define FIO_USE_GENERIC_BDEV_SIZE
23 #define FIO_HAVE_FS_STAT
24 #define FIO_USE_GENERIC_INIT_RANDOM_STATE
25 #define FIO_HAVE_GETTID
27 #define OS_MAP_ANON MAP_ANON
28 #define OS_RAND_MAX 2147483648UL
30 #define fio_swap16(x) BSWAP_16(x)
31 #define fio_swap32(x) BSWAP_32(x)
32 #define fio_swap64(x) BSWAP_64(x)
34 struct solaris_rand_seed {
38 #ifndef POSIX_MADV_SEQUENTIAL
39 #define posix_madvise madvise
40 #define POSIX_MADV_SEQUENTIAL MADV_SEQUENTIAL
41 #define POSIX_MADV_DONTNEED MADV_DONTNEED
42 #define POSIX_MADV_RANDOM MADV_RANDOM
45 #define os_ctime_r(x, y, z) ctime_r((x), (y), (z))
46 #define FIO_OS_HAS_CTIME_R
48 typedef psetid_t os_cpu_mask_t;
49 typedef struct solaris_rand_seed os_random_state_t;
51 static inline int chardev_size(struct fio_file *f, unsigned long long *bytes)
57 if (ioctl(f->fd, DKIOCGMEDIAINFO, &info) < 0)
60 *bytes = info.dki_lbsize * info.dki_capacity;
64 static inline int blockdev_invalidate_cache(struct fio_file *f)
69 static inline unsigned long long os_phys_mem(void)
73 pagesize = sysconf(_SC_PAGESIZE);
74 pages = sysconf(_SC_PHYS_PAGES);
75 if (pages == -1 || pagesize == -1)
78 return (unsigned long long) pages * (unsigned long long) pagesize;
81 static inline unsigned long long get_fs_free_size(const char *path)
83 unsigned long long ret;
86 if (statvfs(path, &s) < 0)
90 ret *= (unsigned long long) s.f_bfree;
94 static inline void os_random_seed(unsigned long seed, os_random_state_t *rs)
96 rs->r[0] = seed & 0xffff;
98 rs->r[1] = seed & 0xffff;
100 rs->r[2] = seed & 0xffff;
104 static inline long os_random_long(os_random_state_t *rs)
106 return nrand48(rs->r);
109 #define FIO_OS_DIRECTIO
110 extern int directio(int, int);
111 static inline int fio_set_odirect(struct fio_file *f)
113 if (directio(f->fd, DIRECTIO_ON) < 0)
120 * pset binding hooks for fio
122 #define fio_setaffinity(pid, cpumask) \
123 pset_bind((cpumask), P_LWPID, (pid), NULL)
124 #define fio_getaffinity(pid, ptr) ({ 0; })
126 #define fio_cpu_clear(mask, cpu) pset_assign(PS_NONE, (cpu), NULL)
127 #define fio_cpu_set(mask, cpu) pset_assign(*(mask), (cpu), NULL)
129 static inline int fio_cpu_isset(os_cpu_mask_t *mask, int cpu)
131 const unsigned int max_cpus = sysconf(_SC_NPROCESSORS_ONLN);
132 unsigned int num_cpus;
136 cpus = malloc(sizeof(*cpus) * max_cpus);
138 if (pset_info(*mask, NULL, &num_cpus, cpus) < 0) {
144 for (i = 0; i < num_cpus; i++) {
145 if (cpus[i] == cpu) {
155 static inline int fio_cpu_count(os_cpu_mask_t *mask)
157 unsigned int num_cpus;
159 if (pset_info(*mask, NULL, &num_cpus, NULL) < 0)
165 static inline int fio_cpuset_init(os_cpu_mask_t *mask)
167 if (pset_create(mask) < 0)
173 static inline int fio_cpuset_exit(os_cpu_mask_t *mask)
175 if (pset_destroy(*mask) < 0)
181 static inline int gettid(void)
183 return pthread_self();
187 * Should be enough, not aware of what (if any) restrictions Solaris has
189 #define FIO_MAX_CPUS 16384
192 #define FIO_MADV_FREE MADV_FREE