blob: 41672d4e10231b3be0a8d3be4e92aa8c45478fe1 [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
12
13#define OS_MAP_ANON (MAP_ANON)
14
15typedef unsigned long os_cpu_mask_t;
Jens Axboe6dfd46b2006-06-07 13:57:06 +020016typedef unsigned int os_random_state_t;
Jens Axboeebac4652005-12-08 15:25:21 +010017
18/*
19 * FIXME
20 */
Jens Axboe9104f872005-12-28 23:50:45 +010021static inline int blockdev_size(int fd, unsigned long long *bytes)
Jens Axboeebac4652005-12-08 15:25:21 +010022{
23 return 1;
24}
25
Jens Axboe32cd46a2006-06-07 13:40:40 +020026static inline unsigned long long os_phys_mem(void)
27{
28 int mib[2] = { CTL_HW, HW_PHYSMEM };
29 unsigned long long mem;
30 size_t len = sizeof(mem);
31
32 sysctl(mib, 2, &mem, &len, NULL, 0);
33 return mem;
34}
35
Jens Axboe6dfd46b2006-06-07 13:57:06 +020036static inline void os_random_seed(unsigned long seed, os_random_state_t *rs)
37{
38 srand(seed);
39}
40
41static inline long os_random_long(os_random_state_t *rs)
42{
43 long val;
44
45 val = rand_r(rs);
46 return val;
47}
48
49static inline double os_random_double(os_random_state_t *rs)
50{
51 double val;
52
53 val = (double) rand_r(rs);
54 return val;
55}
Jens Axboeebac4652005-12-08 15:25:21 +010056#endif