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