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