Add missing os/windows/posix.c file.
[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
93bcfd20 19#define FIO_USE_GENERIC_INIT_RANDOM_STATE
4ccdccd1 20#define FIO_HAVE_CHARDEV_SIZE
e8d588e4 21#define FIO_HAVE_GETTID
b4c1fb36 22#define FIO_HAVE_CLOCK_MONOTONIC
ebac4655 23
dc873b6f 24#define OS_MAP_ANON MAP_ANON
ebac4655 25
232f9b73
JA
26#if BYTE_ORDER == LITTLE_ENDIAN
27#define FIO_LITTLE_ENDIAN
28#else
29#define FIO_BIG_ENDIAN
30#endif
31
32#define fio_swap16(x) bswap16(x)
33#define fio_swap32(x) bswap32(x)
34#define fio_swap64(x) bswap64(x)
35
907249cf
JA
36typedef off_t off64_t;
37
ecc314ba 38static inline int blockdev_size(struct fio_file *f, unsigned long long *bytes)
aa5e69b2
JA
39{
40 off_t size;
41
ecc314ba 42 if (!ioctl(f->fd, DIOCGMEDIASIZE, &size)) {
aa5e69b2
JA
43 *bytes = size;
44 return 0;
45 }
46
2fa55e93 47 *bytes = 0;
aa5e69b2
JA
48 return errno;
49}
50
ecc314ba 51static inline int chardev_size(struct fio_file *f, unsigned long long *bytes)
4ccdccd1 52{
9b836561 53 return blockdev_size(f, bytes);
4ccdccd1
JA
54}
55
ecc314ba 56static inline int blockdev_invalidate_cache(struct fio_file *f)
e5b401d4
JA
57{
58 return EINVAL;
ebac4655
JA
59}
60
32cd46a0
JA
61static inline unsigned long long os_phys_mem(void)
62{
63 int mib[2] = { CTL_HW, HW_PHYSMEM };
64 unsigned long long mem;
65 size_t len = sizeof(mem);
66
67 sysctl(mib, 2, &mem, &len, NULL, 0);
68 return mem;
69}
70
e8d588e4
JA
71static inline int gettid(void)
72{
73 long lwpid;
74
75 thr_self(&lwpid);
76 return (int) lwpid;
77}
78
a1c58075
JA
79#ifdef MADV_FREE
80#define FIO_MADV_FREE MADV_FREE
81#endif
82
ebac4655 83#endif