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