Remove old FIXME comment
[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
26static inline int blockdev_size(int fd, unsigned long long *bytes)
27{
28 off_t end = lseek(fd, 0, SEEK_END);
29
30 if (end < 0)
31 return errno;
32
33 *bytes = end;
34 return 0;
35}
36
37static inline int blockdev_invalidate_cache(int fd)
38{
39 return EINVAL;
40}
41
42static inline unsigned long long os_phys_mem(void)
43{
44 return 0;
45}
46
47static inline void os_random_seed(unsigned long seed, os_random_state_t *rs)
48{
49 rs->r[0] = seed & 0xffff;
50 seed >>= 16;
51 rs->r[1] = seed & 0xffff;
52 seed >>= 16;
53 rs->r[2] = seed & 0xffff;
54 seed48(rs->r);
55}
56
57static inline long os_random_long(os_random_state_t *rs)
58{
59 return nrand48(rs->r);
60}
61
62#define FIO_OS_DIRECTIO
63extern int directio(int, int);
64static inline int fio_set_odirect(int fd)
65{
66 if (directio(fd, DIRECTIO_ON) < 0)
67 return errno;
68
69 return 0;
70}
71
72/*
73 * pset binding hooks for fio
74 */
75#define fio_setaffinity(pid, cpumask) \
76 pset_bind((cpumask), P_PID, (pid), NULL)
77#define fio_getaffinity(pid, ptr) ({ 0; })
78
79#define fio_cpu_clear(mask, cpu) pset_assign(PS_NONE, (cpu), NULL)
80#define fio_cpu_set(mask, cpu) pset_assign(*(mask), (cpu), NULL)
81
82static inline int fio_cpuset_init(os_cpu_mask_t *mask)
83{
84 int ret;
85
86 if (pset_create(mask) < 0) {
87 ret = errno;
88 return -1;
89 }
90
91 return 0;
92}
93
94static inline int fio_cpuset_exit(os_cpu_mask_t *mask)
95{
96 int ret;
97
98 if (pset_destroy(*mask) < 0) {
99 ret = errno;
100 return -1;
101 }
102
103 return 0;
104}
105
106/*
107 * Should be enough, not aware of what (if any) restrictions Solaris has
108 */
109#define FIO_MAX_CPUS 16384
110
111#endif