os-freebsd.h revision 4ccdccd149d82c94ec6ccdb4118d9e27479b8516
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#define FIO_HAVE_POSIXAIO
9#define FIO_HAVE_ODIRECT
10#define FIO_USE_GENERIC_RAND
11#define FIO_HAVE_CHARDEV_SIZE
12
13#define OS_MAP_ANON		MAP_ANON
14
15typedef off_t off64_t;
16
17static inline int blockdev_size(int fd, unsigned long long *bytes)
18{
19	off_t size;
20
21	if (!ioctl(fd, DIOCGMEDIASIZE, &size)) {
22		*bytes = size;
23		return 0;
24	}
25
26	*bytes = 0;
27	return errno;
28}
29
30static inline int chardev_size(int fd, unsigned long long *bytes)
31{
32	return blockdev_size(fd, bytes);
33}
34
35static inline int blockdev_invalidate_cache(int fd)
36{
37	return EINVAL;
38}
39
40static inline unsigned long long os_phys_mem(void)
41{
42	int mib[2] = { CTL_HW, HW_PHYSMEM };
43	unsigned long long mem;
44	size_t len = sizeof(mem);
45
46	sysctl(mib, 2, &mem, &len, NULL, 0);
47	return mem;
48}
49
50#ifdef MADV_FREE
51#define FIO_MADV_FREE	MADV_FREE
52#endif
53
54#endif
55