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