1 #ifndef FIO_OS_SOLARIS_H
2 #define FIO_OS_SOLARIS_H
4 #define FIO_OS os_solaris
14 #include <sys/byteorder.h>
15 #include <sys/statvfs.h>
19 #include "../lib/types.h"
21 #define FIO_HAVE_CPU_AFFINITY
22 #define FIO_HAVE_CHARDEV_SIZE
23 #define FIO_USE_GENERIC_BDEV_SIZE
24 #define FIO_HAVE_FS_STAT
25 #define FIO_USE_GENERIC_INIT_RANDOM_STATE
26 #define FIO_HAVE_GETTID
28 #define OS_MAP_ANON MAP_ANON
29 #define OS_RAND_MAX 2147483648UL
31 #define fio_swap16(x) BSWAP_16(x)
32 #define fio_swap32(x) BSWAP_32(x)
33 #define fio_swap64(x) BSWAP_64(x)
35 struct solaris_rand_seed {
39 #ifndef POSIX_MADV_SEQUENTIAL
40 #define posix_madvise madvise
41 #define POSIX_MADV_SEQUENTIAL MADV_SEQUENTIAL
42 #define POSIX_MADV_DONTNEED MADV_DONTNEED
43 #define POSIX_MADV_RANDOM MADV_RANDOM
46 #define os_ctime_r(x, y, z) ctime_r((x), (y), (z))
47 #define FIO_OS_HAS_CTIME_R
49 typedef psetid_t os_cpu_mask_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 #define FIO_OS_DIRECTIO
95 extern int directio(int, int);
96 static inline int fio_set_odirect(struct fio_file *f)
98 if (directio(f->fd, DIRECTIO_ON) < 0)
105 * pset binding hooks for fio
107 #define fio_setaffinity(pid, cpumask) \
108 pset_bind((cpumask), P_LWPID, (pid), NULL)
109 #define fio_getaffinity(pid, ptr) ({ 0; })
111 #define fio_cpu_clear(mask, cpu) pset_assign(PS_NONE, (cpu), NULL)
112 #define fio_cpu_set(mask, cpu) pset_assign(*(mask), (cpu), NULL)
114 static inline bool fio_cpu_isset(os_cpu_mask_t *mask, int cpu)
116 const unsigned int max_cpus = sysconf(_SC_NPROCESSORS_ONLN);
117 unsigned int num_cpus;
122 cpus = malloc(sizeof(*cpus) * max_cpus);
124 if (pset_info(*mask, NULL, &num_cpus, cpus) < 0) {
130 for (i = 0; i < num_cpus; i++) {
131 if (cpus[i] == cpu) {
141 static inline int fio_cpu_count(os_cpu_mask_t *mask)
143 unsigned int num_cpus;
145 if (pset_info(*mask, NULL, &num_cpus, NULL) < 0)
151 static inline int fio_cpuset_init(os_cpu_mask_t *mask)
153 if (pset_create(mask) < 0)
159 static inline int fio_cpuset_exit(os_cpu_mask_t *mask)
161 if (pset_destroy(*mask) < 0)
167 #ifndef CONFIG_HAVE_GETTID
168 static inline int gettid(void)
170 return pthread_self();
175 * Should be enough, not aware of what (if any) restrictions Solaris has
177 #define FIO_MAX_CPUS 16384
180 #define FIO_MADV_FREE MADV_FREE