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
28 #define OS_MAP_ANON MAP_ANON
29 #define OS_RAND_MAX 2147483648UL
31 #if defined(_BIG_ENDIAN)
32 #define FIO_BIG_ENDIAN
34 #define FIO_LITTLE_ENDIAN
37 #define fio_swap16(x) BSWAP_16(x)
38 #define fio_swap32(x) BSWAP_32(x)
39 #define fio_swap64(x) BSWAP_64(x)
41 struct solaris_rand_seed {
45 #ifndef POSIX_MADV_SEQUENTIAL
46 #define posix_madvise madvise
47 #define POSIX_MADV_SEQUENTIAL MADV_SEQUENTIAL
48 #define POSIX_MADV_DONTNEED MADV_DONTNEED
49 #define POSIX_MADV_RANDOM MADV_RANDOM
52 typedef psetid_t os_cpu_mask_t;
53 typedef struct solaris_rand_seed os_random_state_t;
55 static inline int chardev_size(struct fio_file *f, unsigned long long *bytes)
61 if (ioctl(f->fd, DKIOCGMEDIAINFO, &info) < 0)
64 *bytes = info.dki_lbsize * info.dki_capacity;
68 static inline int blockdev_invalidate_cache(struct fio_file *f)
73 static inline unsigned long long os_phys_mem(void)
78 static inline void os_random_seed(unsigned long seed, os_random_state_t *rs)
80 rs->r[0] = seed & 0xffff;
82 rs->r[1] = seed & 0xffff;
84 rs->r[2] = seed & 0xffff;
88 static inline long os_random_long(os_random_state_t *rs)
90 return nrand48(rs->r);
93 #define FIO_OS_DIRECTIO
94 extern int directio(int, int);
95 static inline int fio_set_odirect(int fd)
97 if (directio(fd, DIRECTIO_ON) < 0)
104 * pset binding hooks for fio
106 #define fio_setaffinity(pid, cpumask) \
107 pset_bind((cpumask), P_PID, (pid), NULL)
108 #define fio_getaffinity(pid, ptr) ({ 0; })
110 #define fio_cpu_clear(mask, cpu) pset_assign(PS_NONE, (cpu), NULL)
111 #define fio_cpu_set(mask, cpu) pset_assign(*(mask), (cpu), NULL)
113 static inline int fio_cpuset_init(os_cpu_mask_t *mask)
115 if (pset_create(mask) < 0)
121 static inline int fio_cpuset_exit(os_cpu_mask_t *mask)
123 if (pset_destroy(*mask) < 0)
129 static inline int gettid(void)
131 return pthread_self();
135 * Should be enough, not aware of what (if any) restrictions Solaris has
137 #define FIO_MAX_CPUS 16384
140 #define FIO_MADV_FREE MADV_FREE