Commit | Line | Data |
---|---|---|
ebac4655 JA |
1 | #ifndef FIO_OS_FREEBSD_H |
2 | #define FIO_OS_FREEBSD_H | |
3 | ||
cca84643 JA |
4 | #define FIO_OS os_freebsd |
5 | ||
690dec6e | 6 | #include <errno.h> |
5c4e1dbc | 7 | #include <sys/sysctl.h> |
aa5e69b2 | 8 | #include <sys/disk.h> |
b939683e | 9 | #include <sys/thr.h> |
f1415a9f | 10 | #include <sys/socket.h> |
5c4e1dbc | 11 | |
e2e58886 JA |
12 | #include "../file.h" |
13 | ||
2c0ecd28 | 14 | #define FIO_HAVE_ODIRECT |
53531370 | 15 | #define FIO_USE_GENERIC_RAND |
93bcfd20 | 16 | #define FIO_USE_GENERIC_INIT_RANDOM_STATE |
4ccdccd1 | 17 | #define FIO_HAVE_CHARDEV_SIZE |
e8d588e4 | 18 | #define FIO_HAVE_GETTID |
ebac4655 | 19 | |
dc873b6f | 20 | #define OS_MAP_ANON MAP_ANON |
ebac4655 | 21 | |
232f9b73 JA |
22 | #define fio_swap16(x) bswap16(x) |
23 | #define fio_swap32(x) bswap32(x) | |
24 | #define fio_swap64(x) bswap64(x) | |
25 | ||
907249cf JA |
26 | typedef off_t off64_t; |
27 | ||
ecc314ba | 28 | static inline int blockdev_size(struct fio_file *f, unsigned long long *bytes) |
aa5e69b2 JA |
29 | { |
30 | off_t size; | |
31 | ||
ecc314ba | 32 | if (!ioctl(f->fd, DIOCGMEDIASIZE, &size)) { |
aa5e69b2 JA |
33 | *bytes = size; |
34 | return 0; | |
35 | } | |
36 | ||
2fa55e93 | 37 | *bytes = 0; |
aa5e69b2 JA |
38 | return errno; |
39 | } | |
40 | ||
ecc314ba | 41 | static inline int chardev_size(struct fio_file *f, unsigned long long *bytes) |
4ccdccd1 | 42 | { |
9b836561 | 43 | return blockdev_size(f, bytes); |
4ccdccd1 JA |
44 | } |
45 | ||
ecc314ba | 46 | static inline int blockdev_invalidate_cache(struct fio_file *f) |
e5b401d4 JA |
47 | { |
48 | return EINVAL; | |
ebac4655 JA |
49 | } |
50 | ||
32cd46a0 JA |
51 | static inline unsigned long long os_phys_mem(void) |
52 | { | |
53 | int mib[2] = { CTL_HW, HW_PHYSMEM }; | |
54 | unsigned long long mem; | |
55 | size_t len = sizeof(mem); | |
56 | ||
57 | sysctl(mib, 2, &mem, &len, NULL, 0); | |
58 | return mem; | |
59 | } | |
60 | ||
e8d588e4 JA |
61 | static inline int gettid(void) |
62 | { | |
63 | long lwpid; | |
64 | ||
65 | thr_self(&lwpid); | |
66 | return (int) lwpid; | |
67 | } | |
68 | ||
a1c58075 JA |
69 | #ifdef MADV_FREE |
70 | #define FIO_MADV_FREE MADV_FREE | |
71 | #endif | |
72 | ||
ebac4655 | 73 | #endif |