blob: de948952f866541acf41cad840efc8fff0529769 [file] [log] [blame]
Jens Axboe2c0ecd22006-06-08 13:25:41 +02001#ifndef FIO_OS_SOLARIS_H
2#define FIO_OS_SOLARIS_H
3
Jens Axboee116f2b2008-06-04 15:14:24 +02004#include <sys/types.h>
5#include <sys/fcntl.h>
Jens Axboe6f7024e2008-12-12 20:42:26 +01006#include <sys/pset.h>
Jens Axboee116f2b2008-06-04 15:14:24 +02007
Jens Axboe2c0ecd22006-06-08 13:25:41 +02008#define FIO_HAVE_POSIXAIO
Jens Axboe417f0062008-06-02 11:59:30 +02009#define FIO_HAVE_SOLARISAIO
Jens Axboefffca022008-06-02 12:23:40 +020010#define FIO_HAVE_FALLOCATE
Jens Axboe207cb0f2008-06-02 12:28:02 +020011#define FIO_HAVE_POSIXAIO_FSYNC
Jens Axboe6f7024e2008-12-12 20:42:26 +010012#define FIO_HAVE_CPU_AFFINITY
Jens Axboe2c0ecd22006-06-08 13:25:41 +020013
Jens Axboedc873b62008-06-04 20:13:04 +020014#define OS_MAP_ANON MAP_ANON
15#define OS_RAND_MAX 2147483648UL
Jens Axboe2c0ecd22006-06-08 13:25:41 +020016
Jens Axboef022ddb2008-06-04 19:55:58 +020017struct solaris_rand_seed {
18 unsigned short r[3];
19};
20
Jens Axboe6f7024e2008-12-12 20:42:26 +010021typedef psetid_t os_cpu_mask_t;
Jens Axboef022ddb2008-06-04 19:55:58 +020022typedef struct solaris_rand_seed os_random_state_t;
Jens Axboe2c0ecd22006-06-08 13:25:41 +020023
24/*
25 * FIXME
26 */
27static inline int blockdev_size(int fd, unsigned long long *bytes)
28{
Jens Axboee5b401d2006-10-18 16:03:40 +020029 return EINVAL;
30}
31
32static inline int blockdev_invalidate_cache(int fd)
33{
34 return EINVAL;
Jens Axboe2c0ecd22006-06-08 13:25:41 +020035}
36
37static inline unsigned long long os_phys_mem(void)
38{
Jens Axboe2c0ecd22006-06-08 13:25:41 +020039 return 0;
Jens Axboe2c0ecd22006-06-08 13:25:41 +020040}
41
42static inline void os_random_seed(unsigned long seed, os_random_state_t *rs)
43{
Jens Axboef022ddb2008-06-04 19:55:58 +020044 rs->r[0] = seed & 0xffff;
45 seed >>= 16;
46 rs->r[1] = seed & 0xffff;
47 seed >>= 16;
48 rs->r[2] = seed & 0xffff;
49 seed48(rs->r);
Jens Axboe2c0ecd22006-06-08 13:25:41 +020050}
51
52static inline long os_random_long(os_random_state_t *rs)
53{
Jens Axboef022ddb2008-06-04 19:55:58 +020054 return nrand48(rs->r);
Jens Axboe2c0ecd22006-06-08 13:25:41 +020055}
56
Jens Axboee116f2b2008-06-04 15:14:24 +020057#define FIO_OS_DIRECTIO
58extern int directio(int, int);
59static inline int fio_set_odirect(int fd)
60{
61 if (directio(fd, DIRECTIO_ON) < 0)
62 return errno;
63
64 return 0;
65}
66
Jens Axboe6f7024e2008-12-12 20:42:26 +010067/*
68 * pset binding hooks for fio
69 */
70#define fio_setaffinity(td) \
71 pset_bind((td)->o.cpumask, P_PID, (td)->pid)
72#define fio_getaffinity(pid, ptr) \
73 sched_getaffinity((pid), sizeof(cpu_set_t), (ptr))
74
75#define fio_cpu_clear(mask, cpu) pset_assign(*(mask), (cpu), PS_NONE)
76#define fio_cpu_set(mask, cpu) pset_assign(*(mask), (cpu), PS_MYID)
77#define fio_cpuset_init(td) pset_create(&(td)->o.cpumask)
78#define fio_cpuset_exit(td) pset_destroy((td)->o.cpumask)
79
80/*
81 * Should be enough, not aware of what (if any) restrictions Solaris has
82 */
83#define FIO_MAX_CPUS 16384
84
Jens Axboe2c0ecd22006-06-08 13:25:41 +020085#endif