Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 1 | #ifndef FIO_OS_FREEBSD_H |
| 2 | #define FIO_OS_FREEBSD_H |
| 3 | |
Jens Axboe | 690dec6 | 2009-01-06 14:22:30 +0100 | [diff] [blame] | 4 | #include <errno.h> |
Jens Axboe | 5c4e1db | 2006-06-07 14:17:08 +0200 | [diff] [blame] | 5 | #include <sys/sysctl.h> |
Jens Axboe | aa5e69b | 2010-06-24 09:25:15 +0200 | [diff] [blame] | 6 | #include <sys/disk.h> |
Jens Axboe | b939683 | 2011-07-30 13:29:58 +0200 | [diff] [blame] | 7 | #include <sys/thr.h> |
Jens Axboe | 5c4e1db | 2006-06-07 14:17:08 +0200 | [diff] [blame] | 8 | |
Jens Axboe | e2e5888 | 2011-01-04 08:36:06 +0100 | [diff] [blame] | 9 | #include "../file.h" |
| 10 | |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 11 | #define FIO_HAVE_POSIXAIO |
Jens Axboe | 2c0ecd2 | 2006-06-08 13:25:41 +0200 | [diff] [blame] | 12 | #define FIO_HAVE_ODIRECT |
Bruce Cran | ecc314b | 2011-01-04 10:59:30 +0100 | [diff] [blame] | 13 | #define FIO_HAVE_STRSEP |
Jens Axboe | 5353137 | 2009-12-15 10:28:37 +0100 | [diff] [blame] | 14 | #define FIO_USE_GENERIC_RAND |
Jens Axboe | 4ccdccd | 2010-06-24 10:27:22 +0200 | [diff] [blame] | 15 | #define FIO_HAVE_CHARDEV_SIZE |
Bruce Cran | ecc314b | 2011-01-04 10:59:30 +0100 | [diff] [blame] | 16 | #define FIO_HAVE_CLOCK_MONOTONIC |
Jens Axboe | e8d588e | 2011-07-12 22:33:53 +0200 | [diff] [blame] | 17 | #define FIO_HAVE_GETTID |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 18 | |
Jens Axboe | dc873b6 | 2008-06-04 20:13:04 +0200 | [diff] [blame] | 19 | #define OS_MAP_ANON MAP_ANON |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 20 | |
Jens Axboe | 907249c | 2010-06-22 10:30:11 +0200 | [diff] [blame] | 21 | typedef off_t off64_t; |
| 22 | |
Bruce Cran | ecc314b | 2011-01-04 10:59:30 +0100 | [diff] [blame] | 23 | static inline int blockdev_size(struct fio_file *f, unsigned long long *bytes) |
Jens Axboe | aa5e69b | 2010-06-24 09:25:15 +0200 | [diff] [blame] | 24 | { |
| 25 | off_t size; |
| 26 | |
Bruce Cran | ecc314b | 2011-01-04 10:59:30 +0100 | [diff] [blame] | 27 | if (!ioctl(f->fd, DIOCGMEDIASIZE, &size)) { |
Jens Axboe | aa5e69b | 2010-06-24 09:25:15 +0200 | [diff] [blame] | 28 | *bytes = size; |
| 29 | return 0; |
| 30 | } |
| 31 | |
Jens Axboe | 2fa55e9 | 2010-06-24 09:36:11 +0200 | [diff] [blame] | 32 | *bytes = 0; |
Jens Axboe | aa5e69b | 2010-06-24 09:25:15 +0200 | [diff] [blame] | 33 | return errno; |
| 34 | } |
| 35 | |
Bruce Cran | ecc314b | 2011-01-04 10:59:30 +0100 | [diff] [blame] | 36 | static inline int chardev_size(struct fio_file *f, unsigned long long *bytes) |
Jens Axboe | 4ccdccd | 2010-06-24 10:27:22 +0200 | [diff] [blame] | 37 | { |
Bruce Cran | 9b83656 | 2011-01-08 19:49:54 +0100 | [diff] [blame] | 38 | return blockdev_size(f, bytes); |
Jens Axboe | 4ccdccd | 2010-06-24 10:27:22 +0200 | [diff] [blame] | 39 | } |
| 40 | |
Bruce Cran | ecc314b | 2011-01-04 10:59:30 +0100 | [diff] [blame] | 41 | static inline int blockdev_invalidate_cache(struct fio_file *f) |
Jens Axboe | e5b401d | 2006-10-18 16:03:40 +0200 | [diff] [blame] | 42 | { |
| 43 | return EINVAL; |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 44 | } |
| 45 | |
Jens Axboe | 32cd46a | 2006-06-07 13:40:40 +0200 | [diff] [blame] | 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 | |
Jens Axboe | e8d588e | 2011-07-12 22:33:53 +0200 | [diff] [blame] | 56 | static inline int gettid(void) |
| 57 | { |
| 58 | long lwpid; |
| 59 | |
| 60 | thr_self(&lwpid); |
| 61 | return (int) lwpid; |
| 62 | } |
| 63 | |
Jens Axboe | a1c5807 | 2009-08-04 23:17:02 +0200 | [diff] [blame] | 64 | #ifdef MADV_FREE |
| 65 | #define FIO_MADV_FREE MADV_FREE |
| 66 | #endif |
| 67 | |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 68 | #endif |