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_POSIXAIO
18 #define FIO_HAVE_SOLARISAIO
19 #define FIO_HAVE_POSIXAIO_FSYNC
20 #define FIO_HAVE_CPU_AFFINITY
21 #define FIO_HAVE_PSHARED_MUTEX
22 #define FIO_HAVE_FDATASYNC
23 #define FIO_HAVE_CHARDEV_SIZE
24 #define FIO_USE_GENERIC_BDEV_SIZE
25 #define FIO_USE_GENERIC_INIT_RANDOM_STATE
26 #define FIO_HAVE_GETTID
27 #define FIO_HAVE_FADVISE
29 #define OS_MAP_ANON MAP_ANON
30 #define OS_RAND_MAX 2147483648UL
32 #if defined(_BIG_ENDIAN)
33 #define FIO_BIG_ENDIAN
35 #define FIO_LITTLE_ENDIAN
38 #define fio_swap16(x) BSWAP_16(x)
39 #define fio_swap32(x) BSWAP_32(x)
40 #define fio_swap64(x) BSWAP_64(x)
42 struct solaris_rand_seed {
46 #ifndef POSIX_MADV_SEQUENTIAL
47 #define posix_madvise madvise
48 #define POSIX_MADV_SEQUENTIAL MADV_SEQUENTIAL
49 #define POSIX_MADV_DONTNEED MADV_DONTNEED
50 #define POSIX_MADV_RANDOM MADV_RANDOM
53 #define os_ctime_r(x, y, z) ctime_r((x), (y), (z))
54 #define FIO_OS_HAS_CTIME_R
56 typedef psetid_t os_cpu_mask_t;
57 typedef struct solaris_rand_seed os_random_state_t;
59 static inline int chardev_size(struct fio_file *f, unsigned long long *bytes)
65 if (ioctl(f->fd, DKIOCGMEDIAINFO, &info) < 0)
68 *bytes = info.dki_lbsize * info.dki_capacity;
72 static inline int blockdev_invalidate_cache(struct fio_file *f)
77 static inline unsigned long long os_phys_mem(void)
82 static inline void os_random_seed(unsigned long seed, os_random_state_t *rs)
84 rs->r[0] = seed & 0xffff;
86 rs->r[1] = seed & 0xffff;
88 rs->r[2] = seed & 0xffff;
92 static inline long os_random_long(os_random_state_t *rs)
94 return nrand48(rs->r);
97 #define FIO_OS_DIRECTIO
98 extern int directio(int, int);
99 static inline int fio_set_odirect(int fd)
101 if (directio(fd, DIRECTIO_ON) < 0)
108 * pset binding hooks for fio
110 #define fio_setaffinity(pid, cpumask) \
111 pset_bind((cpumask), P_PID, (pid), NULL)
112 #define fio_getaffinity(pid, ptr) ({ 0; })
114 #define fio_cpu_clear(mask, cpu) pset_assign(PS_NONE, (cpu), NULL)
115 #define fio_cpu_set(mask, cpu) pset_assign(*(mask), (cpu), NULL)
117 static inline int fio_cpuset_init(os_cpu_mask_t *mask)
119 if (pset_create(mask) < 0)
125 static inline int fio_cpuset_exit(os_cpu_mask_t *mask)
127 if (pset_destroy(*mask) < 0)
133 static inline int gettid(void)
135 return pthread_self();
139 * Should be enough, not aware of what (if any) restrictions Solaris has
141 #define FIO_MAX_CPUS 16384
144 #define FIO_MADV_FREE MADV_FREE