Fill in os_phys_mem() stub for HP-UX
[fio.git] / os / os-freebsd.h
... / ...
CommitLineData
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#include "../file.h"
9
10#define FIO_HAVE_POSIXAIO
11#define FIO_HAVE_ODIRECT
12#define FIO_HAVE_STRSEP
13#define FIO_USE_GENERIC_RAND
14#define FIO_HAVE_CHARDEV_SIZE
15#define FIO_HAVE_CLOCK_MONOTONIC
16
17#define OS_MAP_ANON MAP_ANON
18
19typedef off_t off64_t;
20
21static inline int blockdev_size(struct fio_file *f, unsigned long long *bytes)
22{
23 off_t size;
24
25 if (!ioctl(f->fd, DIOCGMEDIASIZE, &size)) {
26 *bytes = size;
27 return 0;
28 }
29
30 *bytes = 0;
31 return errno;
32}
33
34static inline int chardev_size(struct fio_file *f, unsigned long long *bytes)
35{
36 return blockdev_size(f, bytes);
37}
38
39static inline int blockdev_invalidate_cache(struct fio_file *f)
40{
41 return EINVAL;
42}
43
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
54#ifdef MADV_FREE
55#define FIO_MADV_FREE MADV_FREE
56#endif
57
58#endif