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