Jens Axboe | 2c0ecd2 | 2006-06-08 13:25:41 +0200 | [diff] [blame] | 1 | #ifndef FIO_OS_SOLARIS_H |
| 2 | #define FIO_OS_SOLARIS_H |
| 3 | |
Jens Axboe | e116f2b | 2008-06-04 15:14:24 +0200 | [diff] [blame] | 4 | #include <sys/types.h> |
| 5 | #include <sys/fcntl.h> |
Jens Axboe | 6f7024e | 2008-12-12 20:42:26 +0100 | [diff] [blame] | 6 | #include <sys/pset.h> |
Jens Axboe | e116f2b | 2008-06-04 15:14:24 +0200 | [diff] [blame] | 7 | |
Jens Axboe | 2c0ecd2 | 2006-06-08 13:25:41 +0200 | [diff] [blame] | 8 | #define FIO_HAVE_POSIXAIO |
Jens Axboe | 417f006 | 2008-06-02 11:59:30 +0200 | [diff] [blame] | 9 | #define FIO_HAVE_SOLARISAIO |
Jens Axboe | fffca02 | 2008-06-02 12:23:40 +0200 | [diff] [blame] | 10 | #define FIO_HAVE_FALLOCATE |
Jens Axboe | 207cb0f | 2008-06-02 12:28:02 +0200 | [diff] [blame] | 11 | #define FIO_HAVE_POSIXAIO_FSYNC |
Jens Axboe | 6f7024e | 2008-12-12 20:42:26 +0100 | [diff] [blame] | 12 | #define FIO_HAVE_CPU_AFFINITY |
Jens Axboe | 2c0ecd2 | 2006-06-08 13:25:41 +0200 | [diff] [blame] | 13 | |
Jens Axboe | dc873b6 | 2008-06-04 20:13:04 +0200 | [diff] [blame] | 14 | #define OS_MAP_ANON MAP_ANON |
| 15 | #define OS_RAND_MAX 2147483648UL |
Jens Axboe | 2c0ecd2 | 2006-06-08 13:25:41 +0200 | [diff] [blame] | 16 | |
Jens Axboe | f022ddb | 2008-06-04 19:55:58 +0200 | [diff] [blame] | 17 | struct solaris_rand_seed { |
| 18 | unsigned short r[3]; |
| 19 | }; |
| 20 | |
Jens Axboe | 6f7024e | 2008-12-12 20:42:26 +0100 | [diff] [blame] | 21 | typedef psetid_t os_cpu_mask_t; |
Jens Axboe | f022ddb | 2008-06-04 19:55:58 +0200 | [diff] [blame] | 22 | typedef struct solaris_rand_seed os_random_state_t; |
Jens Axboe | 2c0ecd2 | 2006-06-08 13:25:41 +0200 | [diff] [blame] | 23 | |
| 24 | /* |
| 25 | * FIXME |
| 26 | */ |
| 27 | static inline int blockdev_size(int fd, unsigned long long *bytes) |
| 28 | { |
Jens Axboe | e5b401d | 2006-10-18 16:03:40 +0200 | [diff] [blame] | 29 | return EINVAL; |
| 30 | } |
| 31 | |
| 32 | static inline int blockdev_invalidate_cache(int fd) |
| 33 | { |
| 34 | return EINVAL; |
Jens Axboe | 2c0ecd2 | 2006-06-08 13:25:41 +0200 | [diff] [blame] | 35 | } |
| 36 | |
| 37 | static inline unsigned long long os_phys_mem(void) |
| 38 | { |
Jens Axboe | 2c0ecd2 | 2006-06-08 13:25:41 +0200 | [diff] [blame] | 39 | return 0; |
Jens Axboe | 2c0ecd2 | 2006-06-08 13:25:41 +0200 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | static inline void os_random_seed(unsigned long seed, os_random_state_t *rs) |
| 43 | { |
Jens Axboe | f022ddb | 2008-06-04 19:55:58 +0200 | [diff] [blame] | 44 | 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 Axboe | 2c0ecd2 | 2006-06-08 13:25:41 +0200 | [diff] [blame] | 50 | } |
| 51 | |
| 52 | static inline long os_random_long(os_random_state_t *rs) |
| 53 | { |
Jens Axboe | f022ddb | 2008-06-04 19:55:58 +0200 | [diff] [blame] | 54 | return nrand48(rs->r); |
Jens Axboe | 2c0ecd2 | 2006-06-08 13:25:41 +0200 | [diff] [blame] | 55 | } |
| 56 | |
Jens Axboe | e116f2b | 2008-06-04 15:14:24 +0200 | [diff] [blame] | 57 | #define FIO_OS_DIRECTIO |
| 58 | extern int directio(int, int); |
| 59 | static 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 Axboe | 6f7024e | 2008-12-12 20:42:26 +0100 | [diff] [blame] | 67 | /* |
| 68 | * pset binding hooks for fio |
| 69 | */ |
| 70 | #define fio_setaffinity(td) \ |
Jens Axboe | 39555d0 | 2008-12-22 11:28:26 +0100 | [diff] [blame^] | 71 | pset_bind((td)->o.cpumask, P_PID, (td)->pid, NULL) |
| 72 | #define fio_getaffinity(pid, ptr) ({ 0; }) |
Jens Axboe | 6f7024e | 2008-12-12 20:42:26 +0100 | [diff] [blame] | 73 | |
Jens Axboe | 39555d0 | 2008-12-22 11:28:26 +0100 | [diff] [blame^] | 74 | #define fio_cpu_clear(mask, cpu) pset_assign(PS_NONE, (cpu), NULL) |
| 75 | #define fio_cpu_set(mask, cpu) pset_assign(*(mask), (cpu), NULL) |
Jens Axboe | d2ce18b | 2008-12-12 20:51:40 +0100 | [diff] [blame] | 76 | |
| 77 | static inline int fio_cpuset_init(os_cpu_mask_t *mask) |
| 78 | { |
| 79 | int ret; |
| 80 | |
| 81 | if (pset_create(mask) < 0) { |
| 82 | ret = errno; |
| 83 | return -1; |
| 84 | } |
| 85 | |
| 86 | return 0; |
| 87 | } |
| 88 | |
| 89 | static inline int fio_cpuset_exit(os_cpu_mask_t *mask) |
| 90 | { |
| 91 | int ret; |
| 92 | |
| 93 | if (pset_destroy(*mask) < 0) { |
| 94 | ret = errno; |
| 95 | return -1; |
| 96 | } |
| 97 | |
| 98 | return 0; |
| 99 | } |
Jens Axboe | 6f7024e | 2008-12-12 20:42:26 +0100 | [diff] [blame] | 100 | |
| 101 | /* |
| 102 | * Should be enough, not aware of what (if any) restrictions Solaris has |
| 103 | */ |
| 104 | #define FIO_MAX_CPUS 16384 |
| 105 | |
Jens Axboe | 2c0ecd2 | 2006-06-08 13:25:41 +0200 | [diff] [blame] | 106 | #endif |