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 #ifdef CONFIG_PTHREAD_GETAFFINITY
50 #define FIO_HAVE_GET_THREAD_AFFINITY
51 #define fio_get_thread_affinity(mask) \
52 pthread_getaffinity_np(pthread_self(), sizeof(mask), &(mask))
55 typedef psetid_t os_cpu_mask_t;
57 static inline int chardev_size(struct fio_file *f, unsigned long long *bytes)
63 if (ioctl(f->fd, DKIOCGMEDIAINFO, &info) < 0)
66 *bytes = info.dki_lbsize * info.dki_capacity;
70 static inline int blockdev_invalidate_cache(struct fio_file *f)
75 static inline unsigned long long os_phys_mem(void)
79 pagesize = sysconf(_SC_PAGESIZE);
80 pages = sysconf(_SC_PHYS_PAGES);
81 if (pages == -1 || pagesize == -1)
84 return (unsigned long long) pages * (unsigned long long) pagesize;
87 static inline unsigned long long get_fs_free_size(const char *path)
89 unsigned long long ret;
92 if (statvfs(path, &s) < 0)
96 ret *= (unsigned long long) s.f_bfree;
100 #define FIO_OS_DIRECTIO
101 extern int directio(int, int);
102 static inline int fio_set_odirect(struct fio_file *f)
104 if (directio(f->fd, DIRECTIO_ON) < 0)
111 * pset binding hooks for fio
113 #define fio_setaffinity(pid, cpumask) \
114 pset_bind((cpumask), P_LWPID, (pid), NULL)
115 #define fio_getaffinity(pid, ptr) ({ 0; })
117 #define fio_cpu_clear(mask, cpu) pset_assign(PS_NONE, (cpu), NULL)
118 #define fio_cpu_set(mask, cpu) pset_assign(*(mask), (cpu), NULL)
120 static inline bool fio_cpu_isset(os_cpu_mask_t *mask, int cpu)
122 const unsigned int max_cpus = sysconf(_SC_NPROCESSORS_CONF);
123 unsigned int num_cpus;
128 cpus = malloc(sizeof(*cpus) * max_cpus);
130 if (pset_info(*mask, NULL, &num_cpus, cpus) < 0) {
136 for (i = 0; i < num_cpus; i++) {
137 if (cpus[i] == cpu) {
147 static inline int fio_cpu_count(os_cpu_mask_t *mask)
149 unsigned int num_cpus;
151 if (pset_info(*mask, NULL, &num_cpus, NULL) < 0)
157 static inline int fio_cpuset_init(os_cpu_mask_t *mask)
159 if (pset_create(mask) < 0)
165 static inline int fio_cpuset_exit(os_cpu_mask_t *mask)
167 if (pset_destroy(*mask) < 0)
173 #ifndef CONFIG_HAVE_GETTID
174 static inline int gettid(void)
176 return pthread_self();
181 * Should be enough, not aware of what (if any) restrictions Solaris has
183 #define FIO_MAX_CPUS 16384
186 #define FIO_MADV_FREE MADV_FREE