blob: 317d403f3bd3f228deeaf7d45f00312986c65be3 [file] [log] [blame]
Jens Axboeebac4652005-12-08 15:25:21 +01001#ifndef FIO_OS_FREEBSD_H
2#define FIO_OS_FREEBSD_H
3
Jens Axboe690dec62009-01-06 14:22:30 +01004#include <errno.h>
Jens Axboe5c4e1db2006-06-07 14:17:08 +02005#include <sys/sysctl.h>
Jens Axboeaa5e69b2010-06-24 09:25:15 +02006#include <sys/disk.h>
Jens Axboeb9396832011-07-30 13:29:58 +02007#include <sys/thr.h>
Jens Axboe5c4e1db2006-06-07 14:17:08 +02008
Jens Axboee2e58882011-01-04 08:36:06 +01009#include "../file.h"
10
Jens Axboeebac4652005-12-08 15:25:21 +010011#define FIO_HAVE_POSIXAIO
Jens Axboe2c0ecd22006-06-08 13:25:41 +020012#define FIO_HAVE_ODIRECT
Bruce Cranecc314b2011-01-04 10:59:30 +010013#define FIO_HAVE_STRSEP
Jens Axboe53531372009-12-15 10:28:37 +010014#define FIO_USE_GENERIC_RAND
Jens Axboe4ccdccd2010-06-24 10:27:22 +020015#define FIO_HAVE_CHARDEV_SIZE
Bruce Cranecc314b2011-01-04 10:59:30 +010016#define FIO_HAVE_CLOCK_MONOTONIC
Jens Axboee8d588e2011-07-12 22:33:53 +020017#define FIO_HAVE_GETTID
Jens Axboeebac4652005-12-08 15:25:21 +010018
Jens Axboedc873b62008-06-04 20:13:04 +020019#define OS_MAP_ANON MAP_ANON
Jens Axboeebac4652005-12-08 15:25:21 +010020
Jens Axboe907249c2010-06-22 10:30:11 +020021typedef off_t off64_t;
22
Bruce Cranecc314b2011-01-04 10:59:30 +010023static inline int blockdev_size(struct fio_file *f, unsigned long long *bytes)
Jens Axboeaa5e69b2010-06-24 09:25:15 +020024{
25 off_t size;
26
Bruce Cranecc314b2011-01-04 10:59:30 +010027 if (!ioctl(f->fd, DIOCGMEDIASIZE, &size)) {
Jens Axboeaa5e69b2010-06-24 09:25:15 +020028 *bytes = size;
29 return 0;
30 }
31
Jens Axboe2fa55e92010-06-24 09:36:11 +020032 *bytes = 0;
Jens Axboeaa5e69b2010-06-24 09:25:15 +020033 return errno;
34}
35
Bruce Cranecc314b2011-01-04 10:59:30 +010036static inline int chardev_size(struct fio_file *f, unsigned long long *bytes)
Jens Axboe4ccdccd2010-06-24 10:27:22 +020037{
Bruce Cran9b836562011-01-08 19:49:54 +010038 return blockdev_size(f, bytes);
Jens Axboe4ccdccd2010-06-24 10:27:22 +020039}
40
Bruce Cranecc314b2011-01-04 10:59:30 +010041static inline int blockdev_invalidate_cache(struct fio_file *f)
Jens Axboee5b401d2006-10-18 16:03:40 +020042{
43 return EINVAL;
Jens Axboeebac4652005-12-08 15:25:21 +010044}
45
Jens Axboe32cd46a2006-06-07 13:40:40 +020046static 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 Axboee8d588e2011-07-12 22:33:53 +020056static inline int gettid(void)
57{
58 long lwpid;
59
60 thr_self(&lwpid);
61 return (int) lwpid;
62}
63
Jens Axboea1c58072009-08-04 23:17:02 +020064#ifdef MADV_FREE
65#define FIO_MADV_FREE MADV_FREE
66#endif
67
Jens Axboeebac4652005-12-08 15:25:21 +010068#endif