| 1 | #ifndef FIO_OS_FREEBSD_H |
| 2 | #define FIO_OS_FREEBSD_H |
| 3 | |
| 4 | #include <errno.h> |
| 5 | #include <sys/sysctl.h> |
| 6 | #include <sys/disk.h> |
| 7 | |
| 8 | #include "../file.h" |
| 9 | |
| 10 | #define FIO_HAVE_POSIXAIO |
| 11 | #define FIO_HAVE_ODIRECT |
| 12 | #define FIO_HAVE_IOPRIO |
| 13 | #define FIO_HAVE_STRSEP |
| 14 | #define FIO_USE_GENERIC_RAND |
| 15 | #define FIO_HAVE_CHARDEV_SIZE |
| 16 | #define FIO_HAVE_CLOCK_MONOTONIC |
| 17 | |
| 18 | #define OS_MAP_ANON MAP_ANON |
| 19 | |
| 20 | typedef off_t off64_t; |
| 21 | |
| 22 | static inline int blockdev_size(struct fio_file *f, unsigned long long *bytes) |
| 23 | { |
| 24 | off_t size; |
| 25 | |
| 26 | if (!ioctl(f->fd, DIOCGMEDIASIZE, &size)) { |
| 27 | *bytes = size; |
| 28 | return 0; |
| 29 | } |
| 30 | |
| 31 | *bytes = 0; |
| 32 | return errno; |
| 33 | } |
| 34 | |
| 35 | static inline int chardev_size(struct fio_file *f, unsigned long long *bytes) |
| 36 | { |
| 37 | return blockdev_size(f->fd, bytes); |
| 38 | } |
| 39 | |
| 40 | static inline int blockdev_invalidate_cache(struct fio_file *f) |
| 41 | { |
| 42 | return EINVAL; |
| 43 | } |
| 44 | |
| 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 | |
| 55 | #ifdef MADV_FREE |
| 56 | #define FIO_MADV_FREE MADV_FREE |
| 57 | #endif |
| 58 | |
| 59 | #endif |