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