More endianness for platforms
[fio.git] / os / os-freebsd.h
CommitLineData
ebac4655
JA
1#ifndef FIO_OS_FREEBSD_H
2#define FIO_OS_FREEBSD_H
3
690dec6e 4#include <errno.h>
5c4e1dbc 5#include <sys/sysctl.h>
aa5e69b2 6#include <sys/disk.h>
b939683e 7#include <sys/thr.h>
232f9b73 8#include <sys/endian.h>
5c4e1dbc 9
e2e58886
JA
10#include "../file.h"
11
ebac4655 12#define FIO_HAVE_POSIXAIO
2c0ecd28 13#define FIO_HAVE_ODIRECT
ecc314ba 14#define FIO_HAVE_STRSEP
53531370 15#define FIO_USE_GENERIC_RAND
4ccdccd1 16#define FIO_HAVE_CHARDEV_SIZE
ecc314ba 17#define FIO_HAVE_CLOCK_MONOTONIC
e8d588e4 18#define FIO_HAVE_GETTID
ebac4655 19
dc873b6f 20#define OS_MAP_ANON MAP_ANON
ebac4655 21
232f9b73
JA
22#if BYTE_ORDER == LITTLE_ENDIAN
23#define FIO_LITTLE_ENDIAN
24#else
25#define FIO_BIG_ENDIAN
26#endif
27
28#define fio_swap16(x) bswap16(x)
29#define fio_swap32(x) bswap32(x)
30#define fio_swap64(x) bswap64(x)
31
907249cf
JA
32typedef off_t off64_t;
33
ecc314ba 34static inline int blockdev_size(struct fio_file *f, unsigned long long *bytes)
aa5e69b2
JA
35{
36 off_t size;
37
ecc314ba 38 if (!ioctl(f->fd, DIOCGMEDIASIZE, &size)) {
aa5e69b2
JA
39 *bytes = size;
40 return 0;
41 }
42
2fa55e93 43 *bytes = 0;
aa5e69b2
JA
44 return errno;
45}
46
ecc314ba 47static inline int chardev_size(struct fio_file *f, unsigned long long *bytes)
4ccdccd1 48{
9b836561 49 return blockdev_size(f, bytes);
4ccdccd1
JA
50}
51
ecc314ba 52static inline int blockdev_invalidate_cache(struct fio_file *f)
e5b401d4
JA
53{
54 return EINVAL;
ebac4655
JA
55}
56
32cd46a0
JA
57static inline unsigned long long os_phys_mem(void)
58{
59 int mib[2] = { CTL_HW, HW_PHYSMEM };
60 unsigned long long mem;
61 size_t len = sizeof(mem);
62
63 sysctl(mib, 2, &mem, &len, NULL, 0);
64 return mem;
65}
66
e8d588e4
JA
67static inline int gettid(void)
68{
69 long lwpid;
70
71 thr_self(&lwpid);
72 return (int) lwpid;
73}
74
a1c58075
JA
75#ifdef MADV_FREE
76#define FIO_MADV_FREE MADV_FREE
77#endif
78
ebac4655 79#endif