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