blob: b58d1308efc49e4bd1cf0d530256f90e9e076afd [file] [log] [blame]
Jens Axboe2c0ecd22006-06-08 13:25:41 +02001#ifndef FIO_OS_SOLARIS_H
2#define FIO_OS_SOLARIS_H
3
Jens Axboe690dec62009-01-06 14:22:30 +01004#include <errno.h>
Jens Axboee116f2b2008-06-04 15:14:24 +02005#include <sys/types.h>
6#include <sys/fcntl.h>
Jens Axboe6f7024e2008-12-12 20:42:26 +01007#include <sys/pset.h>
Jens Axboee116f2b2008-06-04 15:14:24 +02008
Jens Axboe2c0ecd22006-06-08 13:25:41 +02009#define FIO_HAVE_POSIXAIO
Jens Axboe417f0062008-06-02 11:59:30 +020010#define FIO_HAVE_SOLARISAIO
Jens Axboefffca022008-06-02 12:23:40 +020011#define FIO_HAVE_FALLOCATE
Jens Axboe207cb0f2008-06-02 12:28:02 +020012#define FIO_HAVE_POSIXAIO_FSYNC
Jens Axboe6f7024e2008-12-12 20:42:26 +010013#define FIO_HAVE_CPU_AFFINITY
Jens Axboef356d012009-01-05 09:56:29 +010014#define FIO_HAVE_PSHARED_MUTEX
Jens Axboe2c0ecd22006-06-08 13:25:41 +020015
Jens Axboedc873b62008-06-04 20:13:04 +020016#define OS_MAP_ANON MAP_ANON
17#define OS_RAND_MAX 2147483648UL
Jens Axboe2c0ecd22006-06-08 13:25:41 +020018
Jens Axboef022ddb2008-06-04 19:55:58 +020019struct solaris_rand_seed {
20 unsigned short r[3];
21};
22
Jens Axboe6f7024e2008-12-12 20:42:26 +010023typedef psetid_t os_cpu_mask_t;
Jens Axboef022ddb2008-06-04 19:55:58 +020024typedef struct solaris_rand_seed os_random_state_t;
Jens Axboe2c0ecd22006-06-08 13:25:41 +020025
26/*
27 * FIXME
28 */
29static inline int blockdev_size(int fd, unsigned long long *bytes)
30{
Jens Axboee5b401d2006-10-18 16:03:40 +020031 return EINVAL;
32}
33
34static inline int blockdev_invalidate_cache(int fd)
35{
36 return EINVAL;
Jens Axboe2c0ecd22006-06-08 13:25:41 +020037}
38
39static inline unsigned long long os_phys_mem(void)
40{
Jens Axboe2c0ecd22006-06-08 13:25:41 +020041 return 0;
Jens Axboe2c0ecd22006-06-08 13:25:41 +020042}
43
44static inline void os_random_seed(unsigned long seed, os_random_state_t *rs)
45{
Jens Axboef022ddb2008-06-04 19:55:58 +020046 rs->r[0] = seed & 0xffff;
47 seed >>= 16;
48 rs->r[1] = seed & 0xffff;
49 seed >>= 16;
50 rs->r[2] = seed & 0xffff;
51 seed48(rs->r);
Jens Axboe2c0ecd22006-06-08 13:25:41 +020052}
53
54static inline long os_random_long(os_random_state_t *rs)
55{
Jens Axboef022ddb2008-06-04 19:55:58 +020056 return nrand48(rs->r);
Jens Axboe2c0ecd22006-06-08 13:25:41 +020057}
58
Jens Axboee116f2b2008-06-04 15:14:24 +020059#define FIO_OS_DIRECTIO
60extern int directio(int, int);
61static inline int fio_set_odirect(int fd)
62{
63 if (directio(fd, DIRECTIO_ON) < 0)
64 return errno;
65
66 return 0;
67}
68
Jens Axboe6f7024e2008-12-12 20:42:26 +010069/*
70 * pset binding hooks for fio
71 */
72#define fio_setaffinity(td) \
Jens Axboe39555d02008-12-22 11:28:26 +010073 pset_bind((td)->o.cpumask, P_PID, (td)->pid, NULL)
74#define fio_getaffinity(pid, ptr) ({ 0; })
Jens Axboe6f7024e2008-12-12 20:42:26 +010075
Jens Axboe39555d02008-12-22 11:28:26 +010076#define fio_cpu_clear(mask, cpu) pset_assign(PS_NONE, (cpu), NULL)
77#define fio_cpu_set(mask, cpu) pset_assign(*(mask), (cpu), NULL)
Jens Axboed2ce18b2008-12-12 20:51:40 +010078
79static inline int fio_cpuset_init(os_cpu_mask_t *mask)
80{
81 int ret;
82
83 if (pset_create(mask) < 0) {
84 ret = errno;
85 return -1;
86 }
87
88 return 0;
89}
90
91static inline int fio_cpuset_exit(os_cpu_mask_t *mask)
92{
93 int ret;
94
95 if (pset_destroy(*mask) < 0) {
96 ret = errno;
97 return -1;
98 }
99
100 return 0;
101}
Jens Axboe6f7024e2008-12-12 20:42:26 +0100102
103/*
104 * Should be enough, not aware of what (if any) restrictions Solaris has
105 */
106#define FIO_MAX_CPUS 16384
107
Jens Axboe2c0ecd22006-06-08 13:25:41 +0200108#endif