glusterfs: update for new API
[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 #include <sys/ioctl.h>
11 #include <sys/dkio.h>
12 #include <sys/disklabel.h>
13 #include <sys/endian.h>
14 #include <sys/sysctl.h>
15
16 /* XXX hack to avoid confilcts between rbtree.h and <sys/rbtree.h> */
17 #undef rb_node
18 #undef rb_left
19 #undef rb_right
20
21 #include "../file.h"
22
23 #define FIO_HAVE_ODIRECT
24 #define FIO_USE_GENERIC_INIT_RANDOM_STATE
25 #define FIO_HAVE_FS_STAT
26 #define FIO_HAVE_GETTID
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_size(struct fio_file *f, unsigned long long *bytes)
41 {
42         struct disklabel dl;
43
44         if (!ioctl(f->fd, DIOCGDINFO, &dl)) {
45                 *bytes = ((unsigned long long)dl.d_secperunit) * dl.d_secsize;
46                 return 0;
47         }
48
49         *bytes = 0;
50         return errno;
51 }
52
53 static inline int blockdev_invalidate_cache(struct fio_file *f)
54 {
55         return ENOTSUP;
56 }
57
58 static inline unsigned long long os_phys_mem(void)
59 {
60         int mib[2] = { CTL_HW, HW_PHYSMEM64 };
61         uint64_t mem;
62         size_t len = sizeof(mem);
63
64         sysctl(mib, 2, &mem, &len, NULL, 0);
65         return mem;
66 }
67
68 #ifndef CONFIG_HAVE_GETTID
69 static inline int gettid(void)
70 {
71         return (int) _lwp_self();
72 }
73 #endif
74
75 static inline unsigned long long get_fs_free_size(const char *path)
76 {
77         unsigned long long ret;
78         struct statvfs s;
79
80         if (statvfs(path, &s) < 0)
81                 return -1ULL;
82
83         ret = s.f_frsize;
84         ret *= (unsigned long long) s.f_bfree;
85         return ret;
86 }
87
88 #ifdef MADV_FREE
89 #define FIO_MADV_FREE   MADV_FREE
90 #endif
91
92 #endif