FIO Windows update
[fio.git] / os / os-freebsd.h
CommitLineData
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>
5c4e1dbc 7
ebac4655 8#define FIO_HAVE_POSIXAIO
2c0ecd28 9#define FIO_HAVE_ODIRECT
ecc314ba
BC
10#define FIO_HAVE_IOPRIO
11#define FIO_HAVE_STRSEP
53531370 12#define FIO_USE_GENERIC_RAND
4ccdccd1 13#define FIO_HAVE_CHARDEV_SIZE
ecc314ba 14#define FIO_HAVE_CLOCK_MONOTONIC
ebac4655 15
dc873b6f 16#define OS_MAP_ANON MAP_ANON
ebac4655 17
907249cf
JA
18typedef off_t off64_t;
19
ecc314ba 20static inline int blockdev_size(struct fio_file *f, unsigned long long *bytes)
aa5e69b2
JA
21{
22 off_t size;
23
ecc314ba 24 if (!ioctl(f->fd, DIOCGMEDIASIZE, &size)) {
aa5e69b2
JA
25 *bytes = size;
26 return 0;
27 }
28
2fa55e93 29 *bytes = 0;
aa5e69b2
JA
30 return errno;
31}
32
ecc314ba 33static inline int chardev_size(struct fio_file *f, unsigned long long *bytes)
4ccdccd1 34{
ecc314ba 35 return blockdev_size(f->fd, bytes);
4ccdccd1
JA
36}
37
ecc314ba 38static inline int blockdev_invalidate_cache(struct fio_file *f)
e5b401d4
JA
39{
40 return EINVAL;
ebac4655
JA
41}
42
32cd46a0
JA
43static inline unsigned long long os_phys_mem(void)
44{
45 int mib[2] = { CTL_HW, HW_PHYSMEM };
46 unsigned long long mem;
47 size_t len = sizeof(mem);
48
49 sysctl(mib, 2, &mem, &len, NULL, 0);
50 return mem;
51}
52
a1c58075
JA
53#ifdef MADV_FREE
54#define FIO_MADV_FREE MADV_FREE
55#endif
56
ebac4655 57#endif