Fio 1.99.11
[fio.git] / os / os-freebsd.h
CommitLineData
ebac4655
JA
1#ifndef FIO_OS_FREEBSD_H
2#define FIO_OS_FREEBSD_H
3
cca84643
JA
4#define FIO_OS os_freebsd
5
690dec6e 6#include <errno.h>
5c4e1dbc 7#include <sys/sysctl.h>
aa5e69b2 8#include <sys/disk.h>
b939683e 9#include <sys/thr.h>
232f9b73 10#include <sys/endian.h>
f1415a9f 11#include <sys/socket.h>
5c4e1dbc 12
e2e58886
JA
13#include "../file.h"
14
ebac4655 15#define FIO_HAVE_POSIXAIO
2c0ecd28 16#define FIO_HAVE_ODIRECT
ecc314ba 17#define FIO_HAVE_STRSEP
53531370 18#define FIO_USE_GENERIC_RAND
4ccdccd1 19#define FIO_HAVE_CHARDEV_SIZE
ecc314ba 20#define FIO_HAVE_CLOCK_MONOTONIC
e8d588e4 21#define FIO_HAVE_GETTID
ebac4655 22
dc873b6f 23#define OS_MAP_ANON MAP_ANON
ebac4655 24
232f9b73
JA
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
907249cf
JA
35typedef off_t off64_t;
36
ecc314ba 37static inline int blockdev_size(struct fio_file *f, unsigned long long *bytes)
aa5e69b2
JA
38{
39 off_t size;
40
ecc314ba 41 if (!ioctl(f->fd, DIOCGMEDIASIZE, &size)) {
aa5e69b2
JA
42 *bytes = size;
43 return 0;
44 }
45
2fa55e93 46 *bytes = 0;
aa5e69b2
JA
47 return errno;
48}
49
ecc314ba 50static inline int chardev_size(struct fio_file *f, unsigned long long *bytes)
4ccdccd1 51{
9b836561 52 return blockdev_size(f, bytes);
4ccdccd1
JA
53}
54
ecc314ba 55static inline int blockdev_invalidate_cache(struct fio_file *f)
e5b401d4
JA
56{
57 return EINVAL;
ebac4655
JA
58}
59
32cd46a0
JA
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
e8d588e4
JA
70static inline int gettid(void)
71{
72 long lwpid;
73
74 thr_self(&lwpid);
75 return (int) lwpid;
76}
77
a1c58075
JA
78#ifdef MADV_FREE
79#define FIO_MADV_FREE MADV_FREE
80#endif
81
ebac4655 82#endif