Add generic bdev_size function
[fio.git] / os / os-solaris.h
CommitLineData
2c0ecd28
JA
1#ifndef FIO_OS_SOLARIS_H
2#define FIO_OS_SOLARIS_H
3
690dec6e 4#include <errno.h>
e116f2b9
JA
5#include <sys/types.h>
6#include <sys/fcntl.h>
6f7024e4 7#include <sys/pset.h>
e116f2b9 8
2c0ecd28 9#define FIO_HAVE_POSIXAIO
417f0068 10#define FIO_HAVE_SOLARISAIO
fffca02d 11#define FIO_HAVE_FALLOCATE
207cb0f0 12#define FIO_HAVE_POSIXAIO_FSYNC
6f7024e4 13#define FIO_HAVE_CPU_AFFINITY
f356d01d 14#define FIO_HAVE_PSHARED_MUTEX
792d5517 15#define FIO_USE_GENERIC_BDEV_SIZE
2c0ecd28 16
dc873b6f
JA
17#define OS_MAP_ANON MAP_ANON
18#define OS_RAND_MAX 2147483648UL
2c0ecd28 19
f022ddb7
JA
20struct solaris_rand_seed {
21 unsigned short r[3];
22};
23
6f7024e4 24typedef psetid_t os_cpu_mask_t;
f022ddb7 25typedef struct solaris_rand_seed os_random_state_t;
2c0ecd28 26
e5b401d4
JA
27static inline int blockdev_invalidate_cache(int fd)
28{
29 return EINVAL;
2c0ecd28
JA
30}
31
32static inline unsigned long long os_phys_mem(void)
33{
2c0ecd28 34 return 0;
2c0ecd28
JA
35}
36
37static inline void os_random_seed(unsigned long seed, os_random_state_t *rs)
38{
f022ddb7
JA
39 rs->r[0] = seed & 0xffff;
40 seed >>= 16;
41 rs->r[1] = seed & 0xffff;
42 seed >>= 16;
43 rs->r[2] = seed & 0xffff;
44 seed48(rs->r);
2c0ecd28
JA
45}
46
47static inline long os_random_long(os_random_state_t *rs)
48{
f022ddb7 49 return nrand48(rs->r);
2c0ecd28
JA
50}
51
e116f2b9
JA
52#define FIO_OS_DIRECTIO
53extern int directio(int, int);
54static inline int fio_set_odirect(int fd)
55{
56 if (directio(fd, DIRECTIO_ON) < 0)
57 return errno;
58
59 return 0;
60}
61
6f7024e4
JA
62/*
63 * pset binding hooks for fio
64 */
e8462bd8 65#define fio_setaffinity(pid, cpumask) \
f2b7ce1c 66 pset_bind((cpumask), P_PID, (pid), NULL)
39555d03 67#define fio_getaffinity(pid, ptr) ({ 0; })
6f7024e4 68
39555d03
JA
69#define fio_cpu_clear(mask, cpu) pset_assign(PS_NONE, (cpu), NULL)
70#define fio_cpu_set(mask, cpu) pset_assign(*(mask), (cpu), NULL)
d2ce18b5
JA
71
72static inline int fio_cpuset_init(os_cpu_mask_t *mask)
73{
74 int ret;
75
76 if (pset_create(mask) < 0) {
77 ret = errno;
78 return -1;
79 }
80
81 return 0;
82}
83
84static inline int fio_cpuset_exit(os_cpu_mask_t *mask)
85{
86 int ret;
87
88 if (pset_destroy(*mask) < 0) {
89 ret = errno;
90 return -1;
91 }
92
93 return 0;
94}
6f7024e4
JA
95
96/*
97 * Should be enough, not aware of what (if any) restrictions Solaris has
98 */
99#define FIO_MAX_CPUS 16384
100
a1c58075
JA
101#ifdef MADV_FREE
102#define FIO_MADV_FREE MADV_FREE
103#endif
104
2c0ecd28 105#endif