[PATCH] Correct command line parsing
[fio.git] / os-freebsd.h
1 #ifndef FIO_OS_FREEBSD_H
2 #define FIO_OS_FREEBSD_H
3
4 #include <sys/sysctl.h>
5
6 #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
12 #define FIO_HAVE_ODIRECT
13
14 #define OS_MAP_ANON             (MAP_ANON)
15
16 typedef unsigned long os_cpu_mask_t;
17 typedef unsigned int os_random_state_t;
18
19 /*
20  * FIXME
21  */
22 static inline int blockdev_size(int fd, unsigned long long *bytes)
23 {
24         return 1;
25 }
26
27 static inline unsigned long long os_phys_mem(void)
28 {
29         int mib[2] = { CTL_HW, HW_PHYSMEM };
30         unsigned long long mem;
31         size_t len = sizeof(mem);
32
33         sysctl(mib, 2, &mem, &len, NULL, 0);
34         return mem;
35 }
36
37 static inline void os_random_seed(unsigned long seed, os_random_state_t *rs)
38 {
39         srand(seed);
40 }
41
42 static inline long os_random_long(os_random_state_t *rs)
43 {
44         long val;
45
46         val = rand_r(rs);
47         return val;
48 }
49
50 static inline double os_random_double(os_random_state_t *rs)
51 {
52         double val;
53
54         val = (double) rand_r(rs);
55         return val;
56 }
57 #endif