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