Add FIO_PREFERRED_CLOCK_SOURCE to allow selection of clock source on a per-platform...
[fio.git] / os / os-freebsd.h
... / ...
CommitLineData
1#ifndef FIO_OS_FREEBSD_H
2#define FIO_OS_FREEBSD_H
3
4#define FIO_OS os_freebsd
5
6#include <errno.h>
7#include <sys/sysctl.h>
8#include <sys/disk.h>
9#include <sys/thr.h>
10#include <sys/endian.h>
11#include <sys/socket.h>
12
13#include "../file.h"
14
15#define FIO_HAVE_POSIXAIO
16#define FIO_HAVE_ODIRECT
17#define FIO_HAVE_STRSEP
18#define FIO_USE_GENERIC_RAND
19#define FIO_HAVE_CHARDEV_SIZE
20#define FIO_HAVE_GETTID
21#define FIO_HAVE_CLOCK_MONOTONIC
22
23#define OS_MAP_ANON MAP_ANON
24
25#if BYTE_ORDER == LITTLE_ENDIAN
26#define FIO_LITTLE_ENDIAN
27#else
28#define FIO_BIG_ENDIAN
29#endif
30
31#define fio_swap16(x) bswap16(x)
32#define fio_swap32(x) bswap32(x)
33#define fio_swap64(x) bswap64(x)
34
35typedef off_t off64_t;
36
37static inline int blockdev_size(struct fio_file *f, unsigned long long *bytes)
38{
39 off_t size;
40
41 if (!ioctl(f->fd, DIOCGMEDIASIZE, &size)) {
42 *bytes = size;
43 return 0;
44 }
45
46 *bytes = 0;
47 return errno;
48}
49
50static inline int chardev_size(struct fio_file *f, unsigned long long *bytes)
51{
52 return blockdev_size(f, bytes);
53}
54
55static inline int blockdev_invalidate_cache(struct fio_file *f)
56{
57 return EINVAL;
58}
59
60static inline unsigned long long os_phys_mem(void)
61{
62 int mib[2] = { CTL_HW, HW_PHYSMEM };
63 unsigned long long mem;
64 size_t len = sizeof(mem);
65
66 sysctl(mib, 2, &mem, &len, NULL, 0);
67 return mem;
68}
69
70static inline int gettid(void)
71{
72 long lwpid;
73
74 thr_self(&lwpid);
75 return (int) lwpid;
76}
77
78#ifdef MADV_FREE
79#define FIO_MADV_FREE MADV_FREE
80#endif
81
82#endif