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> |
b939683e | 7 | #include <sys/thr.h> |
5c4e1dbc | 8 | |
e2e58886 JA |
9 | #include "../file.h" |
10 | ||
ebac4655 | 11 | #define FIO_HAVE_POSIXAIO |
2c0ecd28 | 12 | #define FIO_HAVE_ODIRECT |
ecc314ba | 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 |
e8d588e4 | 17 | #define FIO_HAVE_GETTID |
ebac4655 | 18 | |
dc873b6f | 19 | #define OS_MAP_ANON MAP_ANON |
ebac4655 | 20 | |
907249cf JA |
21 | typedef off_t off64_t; |
22 | ||
ecc314ba | 23 | static inline int blockdev_size(struct fio_file *f, unsigned long long *bytes) |
aa5e69b2 JA |
24 | { |
25 | off_t size; | |
26 | ||
ecc314ba | 27 | if (!ioctl(f->fd, DIOCGMEDIASIZE, &size)) { |
aa5e69b2 JA |
28 | *bytes = size; |
29 | return 0; | |
30 | } | |
31 | ||
2fa55e93 | 32 | *bytes = 0; |
aa5e69b2 JA |
33 | return errno; |
34 | } | |
35 | ||
ecc314ba | 36 | static inline int chardev_size(struct fio_file *f, unsigned long long *bytes) |
4ccdccd1 | 37 | { |
9b836561 | 38 | return blockdev_size(f, bytes); |
4ccdccd1 JA |
39 | } |
40 | ||
ecc314ba | 41 | static inline int blockdev_invalidate_cache(struct fio_file *f) |
e5b401d4 JA |
42 | { |
43 | return EINVAL; | |
ebac4655 JA |
44 | } |
45 | ||
32cd46a0 JA |
46 | static inline unsigned long long os_phys_mem(void) |
47 | { | |
48 | int mib[2] = { CTL_HW, HW_PHYSMEM }; | |
49 | unsigned long long mem; | |
50 | size_t len = sizeof(mem); | |
51 | ||
52 | sysctl(mib, 2, &mem, &len, NULL, 0); | |
53 | return mem; | |
54 | } | |
55 | ||
e8d588e4 JA |
56 | static inline int gettid(void) |
57 | { | |
58 | long lwpid; | |
59 | ||
60 | thr_self(&lwpid); | |
61 | return (int) lwpid; | |
62 | } | |
63 | ||
a1c58075 JA |
64 | #ifdef MADV_FREE |
65 | #define FIO_MADV_FREE MADV_FREE | |
66 | #endif | |
67 | ||
ebac4655 | 68 | #endif |