Fio 2.15
[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/statvfs.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_FS_STAT
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 #define fio_swap16(x)   bswap16(x)
35 #define fio_swap32(x)   bswap32(x)
36 #define fio_swap64(x)   bswap64(x)
37
38 typedef off_t off64_t;
39
40 static inline int blockdev_invalidate_cache(struct fio_file *f)
41 {
42         return EINVAL;
43 }
44
45 static inline unsigned long long os_phys_mem(void)
46 {
47         int mib[2] = { CTL_HW, HW_PHYSMEM64 };
48         uint64_t mem;
49         size_t len = sizeof(mem);
50
51         sysctl(mib, 2, &mem, &len, NULL, 0);
52         return mem;
53 }
54
55 static inline int gettid(void)
56 {
57         return (int) _lwp_self();
58 }
59
60 static inline unsigned long long get_fs_free_size(const char *path)
61 {
62         unsigned long long ret;
63         struct statvfs s;
64
65         if (statvfs(path, &s) < 0)
66                 return -1ULL;
67
68         ret = s.f_frsize;
69         ret *= (unsigned long long) s.f_bfree;
70         return ret;
71 }
72
73 #ifdef MADV_FREE
74 #define FIO_MADV_FREE   MADV_FREE
75 #endif
76
77 #endif