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