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