blob: 01c5ce917b57d9501774cd80d8a84e82b6df6b35 [file] [log] [blame]
Jens Axboeebac4652005-12-08 15:25:21 +01001#ifndef FIO_OS_FREEBSD_H
2#define FIO_OS_FREEBSD_H
3
Jens Axboe5c4e1db2006-06-07 14:17:08 +02004#include <sys/sysctl.h>
5
Jens Axboeebac4652005-12-08 15:25:21 +01006#undef FIO_HAVE_LIBAIO
7#define FIO_HAVE_POSIXAIO
8#undef FIO_HAVE_FADVISE
9#undef FIO_HAVE_CPU_AFFINITY
10#undef FIO_HAVE_DISK_UTIL
11#undef FIO_HAVE_SGIO
Jens Axboe2c0ecd22006-06-08 13:25:41 +020012#define FIO_HAVE_ODIRECT
Jens Axboeebac4652005-12-08 15:25:21 +010013
14#define OS_MAP_ANON (MAP_ANON)
15
16typedef unsigned long os_cpu_mask_t;
Jens Axboe6dfd46b2006-06-07 13:57:06 +020017typedef unsigned int os_random_state_t;
Jens Axboeebac4652005-12-08 15:25:21 +010018
19/*
20 * FIXME
21 */
Jens Axboe9104f872005-12-28 23:50:45 +010022static inline int blockdev_size(int fd, unsigned long long *bytes)
Jens Axboeebac4652005-12-08 15:25:21 +010023{
Jens Axboee5b401d2006-10-18 16:03:40 +020024 return EINVAL;
25}
26
27static inline int blockdev_invalidate_cache(int fd)
28{
29 return EINVAL;
Jens Axboeebac4652005-12-08 15:25:21 +010030}
31
Jens Axboe32cd46a2006-06-07 13:40:40 +020032static inline unsigned long long os_phys_mem(void)
33{
34 int mib[2] = { CTL_HW, HW_PHYSMEM };
35 unsigned long long mem;
36 size_t len = sizeof(mem);
37
38 sysctl(mib, 2, &mem, &len, NULL, 0);
39 return mem;
40}
41
Jens Axboe6dfd46b2006-06-07 13:57:06 +020042static inline void os_random_seed(unsigned long seed, os_random_state_t *rs)
43{
44 srand(seed);
45}
46
47static inline long os_random_long(os_random_state_t *rs)
48{
49 long val;
50
51 val = rand_r(rs);
52 return val;
53}
54
55static inline double os_random_double(os_random_state_t *rs)
56{
57 double val;
58
59 val = (double) rand_r(rs);
60 return val;
61}
Jens Axboeebac4652005-12-08 15:25:21 +010062#endif