Update all Windows files except dobuild.cmd to use LF line endings
[fio.git] / os / os-solaris.h
CommitLineData
2c0ecd28
JA
1#ifndef FIO_OS_SOLARIS_H
2#define FIO_OS_SOLARIS_H
3
cca84643
JA
4#define FIO_OS os_solaris
5
690dec6e 6#include <errno.h>
f8ed6d89 7#include <malloc.h>
e116f2b9
JA
8#include <sys/types.h>
9#include <sys/fcntl.h>
6f7024e4 10#include <sys/pset.h>
08987f0e
JA
11#include <sys/mman.h>
12#include <sys/dkio.h>
232f9b73 13#include <sys/byteorder.h>
e116f2b9 14
e2e58886
JA
15#include "../file.h"
16
6f7024e4 17#define FIO_HAVE_CPU_AFFINITY
f356d01d 18#define FIO_HAVE_PSHARED_MUTEX
08987f0e
JA
19#define FIO_HAVE_CHARDEV_SIZE
20#define FIO_USE_GENERIC_BDEV_SIZE
93bcfd20 21#define FIO_USE_GENERIC_INIT_RANDOM_STATE
862745bf 22#define FIO_HAVE_GETTID
2c0ecd28 23
dc873b6f
JA
24#define OS_MAP_ANON MAP_ANON
25#define OS_RAND_MAX 2147483648UL
2c0ecd28 26
232f9b73
JA
27#define fio_swap16(x) BSWAP_16(x)
28#define fio_swap32(x) BSWAP_32(x)
29#define fio_swap64(x) BSWAP_64(x)
30
f022ddb7
JA
31struct solaris_rand_seed {
32 unsigned short r[3];
33};
34
3f77f723 35#ifndef POSIX_MADV_SEQUENTIAL
08987f0e 36#define posix_madvise madvise
08987f0e 37#define POSIX_MADV_SEQUENTIAL MADV_SEQUENTIAL
3f77f723 38#define POSIX_MADV_DONTNEED MADV_DONTNEED
08987f0e 39#define POSIX_MADV_RANDOM MADV_RANDOM
3f77f723 40#endif
08987f0e 41
45054cbe
SD
42#define os_ctime_r(x, y, z) ctime_r((x), (y), (z))
43#define FIO_OS_HAS_CTIME_R
44
6f7024e4 45typedef psetid_t os_cpu_mask_t;
f022ddb7 46typedef struct solaris_rand_seed os_random_state_t;
2c0ecd28 47
08987f0e
JA
48static inline int chardev_size(struct fio_file *f, unsigned long long *bytes)
49{
50 struct dk_minfo info;
51
52 *bytes = 0;
53
54 if (ioctl(f->fd, DKIOCGMEDIAINFO, &info) < 0)
55 return errno;
56
57 *bytes = info.dki_lbsize * info.dki_capacity;
58 return 0;
59}
60
9b836561 61static inline int blockdev_invalidate_cache(struct fio_file *f)
e5b401d4 62{
08987f0e 63 return 0;
2c0ecd28
JA
64}
65
66static inline unsigned long long os_phys_mem(void)
67{
2c0ecd28 68 return 0;
2c0ecd28
JA
69}
70
71static inline void os_random_seed(unsigned long seed, os_random_state_t *rs)
72{
f022ddb7
JA
73 rs->r[0] = seed & 0xffff;
74 seed >>= 16;
75 rs->r[1] = seed & 0xffff;
76 seed >>= 16;
77 rs->r[2] = seed & 0xffff;
78 seed48(rs->r);
2c0ecd28
JA
79}
80
81static inline long os_random_long(os_random_state_t *rs)
82{
f022ddb7 83 return nrand48(rs->r);
2c0ecd28
JA
84}
85
e116f2b9
JA
86#define FIO_OS_DIRECTIO
87extern int directio(int, int);
88static inline int fio_set_odirect(int fd)
89{
90 if (directio(fd, DIRECTIO_ON) < 0)
91 return errno;
92
93 return 0;
94}
95
6f7024e4
JA
96/*
97 * pset binding hooks for fio
98 */
e8462bd8 99#define fio_setaffinity(pid, cpumask) \
f2b7ce1c 100 pset_bind((cpumask), P_PID, (pid), NULL)
39555d03 101#define fio_getaffinity(pid, ptr) ({ 0; })
6f7024e4 102
39555d03
JA
103#define fio_cpu_clear(mask, cpu) pset_assign(PS_NONE, (cpu), NULL)
104#define fio_cpu_set(mask, cpu) pset_assign(*(mask), (cpu), NULL)
d2ce18b5
JA
105
106static inline int fio_cpuset_init(os_cpu_mask_t *mask)
107{
e721c57f 108 if (pset_create(mask) < 0)
d2ce18b5 109 return -1;
d2ce18b5
JA
110
111 return 0;
112}
113
114static inline int fio_cpuset_exit(os_cpu_mask_t *mask)
115{
e721c57f 116 if (pset_destroy(*mask) < 0)
d2ce18b5 117 return -1;
d2ce18b5
JA
118
119 return 0;
120}
6f7024e4 121
e8d588e4
JA
122static inline int gettid(void)
123{
124 return pthread_self();
125}
126
6f7024e4
JA
127/*
128 * Should be enough, not aware of what (if any) restrictions Solaris has
129 */
130#define FIO_MAX_CPUS 16384
131
a1c58075
JA
132#ifdef MADV_FREE
133#define FIO_MADV_FREE MADV_FREE
134#endif
135
2c0ecd28 136#endif