1753226e5512eaa22fcc4283056181f771730fe5
[fio.git] / os / os-netbsd.h
1 #ifndef FIO_OS_NETBSD_H
2 #define FIO_OS_NETBSD_H
3
4 #define FIO_OS  os_netbsd
5
6 #include <errno.h>
7 #include <lwp.h>
8 #include <sys/param.h>
9 #include <sys/endian.h>
10 /* XXX hack to avoid confilcts between rbtree.h and <sys/rb.h> */
11 #define rb_node _rb_node
12 #include <sys/sysctl.h>
13 #undef rb_node
14 #undef rb_left
15 #undef rb_right
16
17 #include "../file.h"
18
19 #define FIO_HAVE_ODIRECT
20 #define FIO_USE_GENERIC_BDEV_SIZE
21 #define FIO_USE_GENERIC_RAND
22 #define FIO_USE_GENERIC_INIT_RANDOM_STATE
23 #define FIO_HAVE_GETTID
24
25 #undef  FIO_HAVE_CPU_AFFINITY   /* XXX notyet */
26
27 #define OS_MAP_ANON             MAP_ANON
28
29 #ifndef PTHREAD_STACK_MIN
30 #define PTHREAD_STACK_MIN 4096
31 #endif
32
33 #if BYTE_ORDER == LITTLE_ENDIAN
34 #define FIO_LITTLE_ENDIAN
35 #else
36 #define FIO_BIG_ENDIAN
37 #endif
38
39 #define fio_swap16(x)   bswap16(x)
40 #define fio_swap32(x)   bswap32(x)
41 #define fio_swap64(x)   bswap64(x)
42
43 typedef off_t off64_t;
44
45 static inline int blockdev_invalidate_cache(struct fio_file *f)
46 {
47         return EINVAL;
48 }
49
50 static inline unsigned long long os_phys_mem(void)
51 {
52         int mib[2] = { CTL_HW, HW_PHYSMEM64 };
53         uint64_t mem;
54         size_t len = sizeof(mem);
55
56         sysctl(mib, 2, &mem, &len, NULL, 0);
57         return mem;
58 }
59
60 static inline int gettid(void)
61 {
62         return (int) _lwp_self();
63 }
64
65 #ifdef MADV_FREE
66 #define FIO_MADV_FREE   MADV_FREE
67 #endif
68
69 /* XXX NetBSD doesn't have getopt_long_only */
70 #define getopt_long_only        getopt_long
71
72 #endif