Commit | Line | Data |
---|---|---|
2c0ecd28 JA |
1 | #ifndef FIO_OS_SOLARIS_H |
2 | #define FIO_OS_SOLARIS_H | |
3 | ||
cca84643 JA |
4 | #define FIO_OS os_solaris |
5 | ||
690dec6e | 6 | #include <errno.h> |
f8ed6d89 | 7 | #include <malloc.h> |
e116f2b9 JA |
8 | #include <sys/types.h> |
9 | #include <sys/fcntl.h> | |
6f7024e4 | 10 | #include <sys/pset.h> |
08987f0e JA |
11 | #include <sys/mman.h> |
12 | #include <sys/dkio.h> | |
232f9b73 | 13 | #include <sys/byteorder.h> |
e116f2b9 | 14 | |
e2e58886 JA |
15 | #include "../file.h" |
16 | ||
2c0ecd28 | 17 | #define FIO_HAVE_POSIXAIO |
417f0068 | 18 | #define FIO_HAVE_SOLARISAIO |
207cb0f0 | 19 | #define FIO_HAVE_POSIXAIO_FSYNC |
6f7024e4 | 20 | #define FIO_HAVE_CPU_AFFINITY |
f356d01d | 21 | #define FIO_HAVE_PSHARED_MUTEX |
c36d16f5 | 22 | #define FIO_HAVE_FDATASYNC |
08987f0e JA |
23 | #define FIO_HAVE_CHARDEV_SIZE |
24 | #define FIO_USE_GENERIC_BDEV_SIZE | |
93bcfd20 | 25 | #define FIO_USE_GENERIC_INIT_RANDOM_STATE |
862745bf | 26 | #define FIO_HAVE_GETTID |
2c0ecd28 | 27 | |
dc873b6f JA |
28 | #define OS_MAP_ANON MAP_ANON |
29 | #define OS_RAND_MAX 2147483648UL | |
2c0ecd28 | 30 | |
232f9b73 JA |
31 | #if defined(_BIG_ENDIAN) |
32 | #define FIO_BIG_ENDIAN | |
33 | #else | |
34 | #define FIO_LITTLE_ENDIAN | |
35 | #endif | |
36 | ||
37 | #define fio_swap16(x) BSWAP_16(x) | |
38 | #define fio_swap32(x) BSWAP_32(x) | |
39 | #define fio_swap64(x) BSWAP_64(x) | |
40 | ||
f022ddb7 JA |
41 | struct solaris_rand_seed { |
42 | unsigned short r[3]; | |
43 | }; | |
44 | ||
3f77f723 | 45 | #ifndef POSIX_MADV_SEQUENTIAL |
08987f0e | 46 | #define posix_madvise madvise |
08987f0e | 47 | #define POSIX_MADV_SEQUENTIAL MADV_SEQUENTIAL |
3f77f723 | 48 | #define POSIX_MADV_DONTNEED MADV_DONTNEED |
08987f0e | 49 | #define POSIX_MADV_RANDOM MADV_RANDOM |
3f77f723 | 50 | #endif |
08987f0e | 51 | |
45054cbe SD |
52 | #define os_ctime_r(x, y, z) ctime_r((x), (y), (z)) |
53 | #define FIO_OS_HAS_CTIME_R | |
54 | ||
6f7024e4 | 55 | typedef psetid_t os_cpu_mask_t; |
f022ddb7 | 56 | typedef struct solaris_rand_seed os_random_state_t; |
2c0ecd28 | 57 | |
08987f0e JA |
58 | static inline int chardev_size(struct fio_file *f, unsigned long long *bytes) |
59 | { | |
60 | struct dk_minfo info; | |
61 | ||
62 | *bytes = 0; | |
63 | ||
64 | if (ioctl(f->fd, DKIOCGMEDIAINFO, &info) < 0) | |
65 | return errno; | |
66 | ||
67 | *bytes = info.dki_lbsize * info.dki_capacity; | |
68 | return 0; | |
69 | } | |
70 | ||
9b836561 | 71 | static inline int blockdev_invalidate_cache(struct fio_file *f) |
e5b401d4 | 72 | { |
08987f0e | 73 | return 0; |
2c0ecd28 JA |
74 | } |
75 | ||
76 | static inline unsigned long long os_phys_mem(void) | |
77 | { | |
2c0ecd28 | 78 | return 0; |
2c0ecd28 JA |
79 | } |
80 | ||
81 | static inline void os_random_seed(unsigned long seed, os_random_state_t *rs) | |
82 | { | |
f022ddb7 JA |
83 | rs->r[0] = seed & 0xffff; |
84 | seed >>= 16; | |
85 | rs->r[1] = seed & 0xffff; | |
86 | seed >>= 16; | |
87 | rs->r[2] = seed & 0xffff; | |
88 | seed48(rs->r); | |
2c0ecd28 JA |
89 | } |
90 | ||
91 | static inline long os_random_long(os_random_state_t *rs) | |
92 | { | |
f022ddb7 | 93 | return nrand48(rs->r); |
2c0ecd28 JA |
94 | } |
95 | ||
e116f2b9 JA |
96 | #define FIO_OS_DIRECTIO |
97 | extern int directio(int, int); | |
98 | static inline int fio_set_odirect(int fd) | |
99 | { | |
100 | if (directio(fd, DIRECTIO_ON) < 0) | |
101 | return errno; | |
102 | ||
103 | return 0; | |
104 | } | |
105 | ||
6f7024e4 JA |
106 | /* |
107 | * pset binding hooks for fio | |
108 | */ | |
e8462bd8 | 109 | #define fio_setaffinity(pid, cpumask) \ |
f2b7ce1c | 110 | pset_bind((cpumask), P_PID, (pid), NULL) |
39555d03 | 111 | #define fio_getaffinity(pid, ptr) ({ 0; }) |
6f7024e4 | 112 | |
39555d03 JA |
113 | #define fio_cpu_clear(mask, cpu) pset_assign(PS_NONE, (cpu), NULL) |
114 | #define fio_cpu_set(mask, cpu) pset_assign(*(mask), (cpu), NULL) | |
d2ce18b5 JA |
115 | |
116 | static inline int fio_cpuset_init(os_cpu_mask_t *mask) | |
117 | { | |
e721c57f | 118 | if (pset_create(mask) < 0) |
d2ce18b5 | 119 | return -1; |
d2ce18b5 JA |
120 | |
121 | return 0; | |
122 | } | |
123 | ||
124 | static inline int fio_cpuset_exit(os_cpu_mask_t *mask) | |
125 | { | |
e721c57f | 126 | if (pset_destroy(*mask) < 0) |
d2ce18b5 | 127 | return -1; |
d2ce18b5 JA |
128 | |
129 | return 0; | |
130 | } | |
6f7024e4 | 131 | |
e8d588e4 JA |
132 | static inline int gettid(void) |
133 | { | |
134 | return pthread_self(); | |
135 | } | |
136 | ||
6f7024e4 JA |
137 | /* |
138 | * Should be enough, not aware of what (if any) restrictions Solaris has | |
139 | */ | |
140 | #define FIO_MAX_CPUS 16384 | |
141 | ||
a1c58075 JA |
142 | #ifdef MADV_FREE |
143 | #define FIO_MADV_FREE MADV_FREE | |
144 | #endif | |
145 | ||
2c0ecd28 | 146 | #endif |