b56ba8026f2263db3cdb1ab34b0d3ce97a0a6708
[fio.git] / os-freebsd.h
1 #ifndef FIO_OS_FREEBSD_H
2 #define FIO_OS_FREEBSD_H
3
4 #undef FIO_HAVE_LIBAIO
5 #define FIO_HAVE_POSIXAIO
6 #undef FIO_HAVE_FADVISE
7 #undef FIO_HAVE_CPU_AFFINITY
8 #undef FIO_HAVE_DISK_UTIL
9 #undef FIO_HAVE_SGIO
10
11 #define OS_MAP_ANON             (MAP_ANON)
12
13 typedef unsigned long os_cpu_mask_t;
14 typedef unsigned int os_random_state_t;
15
16 /*
17  * FIXME
18  */
19 static inline int blockdev_size(int fd, unsigned long long *bytes)
20 {
21         return 1;
22 }
23
24 static inline unsigned long long os_phys_mem(void)
25 {
26         int mib[2] = { CTL_HW, HW_PHYSMEM };
27         unsigned long long mem;
28         size_t len = sizeof(mem);
29
30         sysctl(mib, 2, &mem, &len, NULL, 0);
31         return mem;
32 }
33
34 static inline void os_random_seed(unsigned long seed, os_random_state_t *rs)
35 {
36         srand(seed);
37 }
38
39 static inline long os_random_long(os_random_state_t *rs)
40 {
41         long val;
42
43         val = rand_r(rs);
44         return val;
45 }
46
47 static inline double os_random_double(os_random_state_t *rs)
48 {
49         double val;
50
51         val = (double) rand_r(rs);
52         return val;
53 }
54 #endif