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> | |
c50bdd8f JA |
13 | /* XXX hack to avoid confilcts between rbtree.h and <sys/rb.h> */ |
14 | #define rb_node _rb_node | |
15 | #include <sys/sysctl.h> | |
16 | #undef rb_node | |
17 | #undef rb_left | |
18 | #undef rb_right | |
19 | ||
e2e58886 JA |
20 | #include "../file.h" |
21 | ||
c50bdd8f | 22 | #define FIO_HAVE_ODIRECT |
c50bdd8f | 23 | #define FIO_USE_GENERIC_RAND |
93bcfd20 | 24 | #define FIO_USE_GENERIC_INIT_RANDOM_STATE |
a016c838 | 25 | #define FIO_HAVE_FS_STAT |
b9afd959 | 26 | #define FIO_HAVE_GETTID |
c50bdd8f JA |
27 | |
28 | #undef FIO_HAVE_CPU_AFFINITY /* XXX notyet */ | |
29 | ||
30 | #define OS_MAP_ANON MAP_ANON | |
31 | ||
9b836561 BC |
32 | #ifndef PTHREAD_STACK_MIN |
33 | #define PTHREAD_STACK_MIN 4096 | |
34 | #endif | |
35 | ||
901ebe18 JA |
36 | #define fio_swap16(x) bswap16(x) |
37 | #define fio_swap32(x) bswap32(x) | |
38 | #define fio_swap64(x) bswap64(x) | |
39 | ||
c50bdd8f JA |
40 | typedef off_t off64_t; |
41 | ||
fc0aa68a TK |
42 | static inline int blockdev_size(struct fio_file *f, unsigned long long *bytes) |
43 | { | |
44 | struct disklabel dl; | |
45 | ||
46 | if (!ioctl(f->fd, DIOCGDINFO, &dl)) { | |
47 | *bytes = ((unsigned long long)dl.d_secperunit) * dl.d_secsize; | |
48 | return 0; | |
49 | } | |
50 | ||
51 | *bytes = 0; | |
52 | return errno; | |
53 | } | |
54 | ||
9b836561 | 55 | static inline int blockdev_invalidate_cache(struct fio_file *f) |
c50bdd8f JA |
56 | { |
57 | return EINVAL; | |
58 | } | |
59 | ||
60 | static inline unsigned long long os_phys_mem(void) | |
61 | { | |
62 | int mib[2] = { CTL_HW, HW_PHYSMEM64 }; | |
63 | uint64_t mem; | |
64 | size_t len = sizeof(mem); | |
65 | ||
66 | sysctl(mib, 2, &mem, &len, NULL, 0); | |
67 | return mem; | |
68 | } | |
69 | ||
b9afd959 JA |
70 | static inline int gettid(void) |
71 | { | |
12ae1bee | 72 | return (int) _lwp_self(); |
b9afd959 JA |
73 | } |
74 | ||
a016c838 TK |
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 | ||
c50bdd8f JA |
88 | #ifdef MADV_FREE |
89 | #define FIO_MADV_FREE MADV_FREE | |
90 | #endif | |
91 | ||
c50bdd8f | 92 | #endif |