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