Commit | Line | Data |
---|---|---|
ebac4655 JA |
1 | #ifndef FIO_OS_FREEBSD_H |
2 | #define FIO_OS_FREEBSD_H | |
3 | ||
690dec6e | 4 | #include <errno.h> |
5c4e1dbc | 5 | #include <sys/sysctl.h> |
aa5e69b2 | 6 | #include <sys/disk.h> |
5c4e1dbc | 7 | |
e2e58886 JA |
8 | #include "../file.h" |
9 | ||
ebac4655 | 10 | #define FIO_HAVE_POSIXAIO |
2c0ecd28 | 11 | #define FIO_HAVE_ODIRECT |
ecc314ba BC |
12 | #define FIO_HAVE_IOPRIO |
13 | #define FIO_HAVE_STRSEP | |
53531370 | 14 | #define FIO_USE_GENERIC_RAND |
4ccdccd1 | 15 | #define FIO_HAVE_CHARDEV_SIZE |
ecc314ba | 16 | #define FIO_HAVE_CLOCK_MONOTONIC |
ebac4655 | 17 | |
dc873b6f | 18 | #define OS_MAP_ANON MAP_ANON |
ebac4655 | 19 | |
907249cf JA |
20 | typedef off_t off64_t; |
21 | ||
ecc314ba | 22 | static inline int blockdev_size(struct fio_file *f, unsigned long long *bytes) |
aa5e69b2 JA |
23 | { |
24 | off_t size; | |
25 | ||
ecc314ba | 26 | if (!ioctl(f->fd, DIOCGMEDIASIZE, &size)) { |
aa5e69b2 JA |
27 | *bytes = size; |
28 | return 0; | |
29 | } | |
30 | ||
2fa55e93 | 31 | *bytes = 0; |
aa5e69b2 JA |
32 | return errno; |
33 | } | |
34 | ||
ecc314ba | 35 | static inline int chardev_size(struct fio_file *f, unsigned long long *bytes) |
4ccdccd1 | 36 | { |
ecc314ba | 37 | return blockdev_size(f->fd, bytes); |
4ccdccd1 JA |
38 | } |
39 | ||
ecc314ba | 40 | static inline int blockdev_invalidate_cache(struct fio_file *f) |
e5b401d4 JA |
41 | { |
42 | return EINVAL; | |
ebac4655 JA |
43 | } |
44 | ||
32cd46a0 JA |
45 | static inline unsigned long long os_phys_mem(void) |
46 | { | |
47 | int mib[2] = { CTL_HW, HW_PHYSMEM }; | |
48 | unsigned long long mem; | |
49 | size_t len = sizeof(mem); | |
50 | ||
51 | sysctl(mib, 2, &mem, &len, NULL, 0); | |
52 | return mem; | |
53 | } | |
54 | ||
a1c58075 JA |
55 | #ifdef MADV_FREE |
56 | #define FIO_MADV_FREE MADV_FREE | |
57 | #endif | |
58 | ||
ebac4655 | 59 | #endif |