Commit | Line | Data |
---|---|---|
c50bdd8f JA |
1 | #ifndef FIO_OS_NETBSD_H |
2 | #define FIO_OS_NETBSD_H | |
3 | ||
cca84643 JA |
4 | #define FIO_OS os_netbsd |
5 | ||
c50bdd8f | 6 | #include <errno.h> |
12ae1bee | 7 | #include <lwp.h> |
c50bdd8f | 8 | #include <sys/param.h> |
a016c838 | 9 | #include <sys/statvfs.h> |
fc0aa68a TK |
10 | #include <sys/ioctl.h> |
11 | #include <sys/dkio.h> | |
12 | #include <sys/disklabel.h> | |
1236d61c | 13 | #include <sys/endian.h> |
c50bdd8f JA |
14 | /* XXX hack to avoid confilcts between rbtree.h and <sys/rb.h> */ |
15 | #define rb_node _rb_node | |
16 | #include <sys/sysctl.h> | |
17 | #undef rb_node | |
18 | #undef rb_left | |
19 | #undef rb_right | |
20 | ||
e2e58886 JA |
21 | #include "../file.h" |
22 | ||
c50bdd8f | 23 | #define FIO_HAVE_ODIRECT |
c50bdd8f | 24 | #define FIO_USE_GENERIC_RAND |
93bcfd20 | 25 | #define FIO_USE_GENERIC_INIT_RANDOM_STATE |
a016c838 | 26 | #define FIO_HAVE_FS_STAT |
b9afd959 | 27 | #define FIO_HAVE_GETTID |
c50bdd8f | 28 | |
adcedfb8 | 29 | #undef FIO_HAVE_CPU_AFFINITY /* doesn't exist */ |
c50bdd8f JA |
30 | |
31 | #define OS_MAP_ANON MAP_ANON | |
32 | ||
9b836561 BC |
33 | #ifndef PTHREAD_STACK_MIN |
34 | #define PTHREAD_STACK_MIN 4096 | |
35 | #endif | |
36 | ||
901ebe18 JA |
37 | #define fio_swap16(x) bswap16(x) |
38 | #define fio_swap32(x) bswap32(x) | |
39 | #define fio_swap64(x) bswap64(x) | |
40 | ||
c50bdd8f JA |
41 | typedef off_t off64_t; |
42 | ||
fc0aa68a TK |
43 | static inline int blockdev_size(struct fio_file *f, unsigned long long *bytes) |
44 | { | |
45 | struct disklabel dl; | |
46 | ||
47 | if (!ioctl(f->fd, DIOCGDINFO, &dl)) { | |
48 | *bytes = ((unsigned long long)dl.d_secperunit) * dl.d_secsize; | |
49 | return 0; | |
50 | } | |
51 | ||
52 | *bytes = 0; | |
53 | return errno; | |
54 | } | |
55 | ||
9b836561 | 56 | static inline int blockdev_invalidate_cache(struct fio_file *f) |
c50bdd8f | 57 | { |
22de5d77 | 58 | return ENOTSUP; |
c50bdd8f JA |
59 | } |
60 | ||
61 | static inline unsigned long long os_phys_mem(void) | |
62 | { | |
63 | int mib[2] = { CTL_HW, HW_PHYSMEM64 }; | |
64 | uint64_t mem; | |
65 | size_t len = sizeof(mem); | |
66 | ||
67 | sysctl(mib, 2, &mem, &len, NULL, 0); | |
68 | return mem; | |
69 | } | |
70 | ||
b9afd959 JA |
71 | static inline int gettid(void) |
72 | { | |
12ae1bee | 73 | return (int) _lwp_self(); |
b9afd959 JA |
74 | } |
75 | ||
a016c838 TK |
76 | static inline unsigned long long get_fs_free_size(const char *path) |
77 | { | |
78 | unsigned long long ret; | |
79 | struct statvfs s; | |
80 | ||
81 | if (statvfs(path, &s) < 0) | |
82 | return -1ULL; | |
83 | ||
84 | ret = s.f_frsize; | |
85 | ret *= (unsigned long long) s.f_bfree; | |
86 | return ret; | |
87 | } | |
88 | ||
c50bdd8f JA |
89 | #ifdef MADV_FREE |
90 | #define FIO_MADV_FREE MADV_FREE | |
91 | #endif | |
92 | ||
c50bdd8f | 93 | #endif |