Commit | Line | Data |
---|---|---|
3cd4c66f J |
1 | #ifndef FIO_OS_OPENBSD_H |
2 | #define FIO_OS_OPENBSD_H | |
3 | ||
4 | #define FIO_OS os_openbsd | |
5 | ||
6 | #include <errno.h> | |
7 | #include <sys/param.h> | |
1abe3856 | 8 | #include <sys/statvfs.h> |
a955f529 TK |
9 | #include <sys/ioctl.h> |
10 | #include <sys/dkio.h> | |
11 | #include <sys/disklabel.h> | |
3cd4c66f J |
12 | /* XXX hack to avoid conflicts between rbtree.h and <sys/tree.h> */ |
13 | #include <sys/sysctl.h> | |
14 | #undef RB_BLACK | |
15 | #undef RB_RED | |
16 | #undef RB_ROOT | |
17 | ||
18 | #include "../file.h" | |
19 | ||
20 | #undef FIO_HAVE_ODIRECT | |
3cd4c66f J |
21 | #define FIO_USE_GENERIC_RAND |
22 | #define FIO_USE_GENERIC_INIT_RANDOM_STATE | |
1abe3856 | 23 | #define FIO_HAVE_FS_STAT |
3cd4c66f J |
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 | ||
a955f529 TK |
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 | ||
3cd4c66f J |
53 | static inline int blockdev_invalidate_cache(struct fio_file *f) |
54 | { | |
55 | return EINVAL; | |
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 | static inline int gettid(void) | |
69 | { | |
70 | return (int) pthread_self(); | |
71 | } | |
72 | ||
1abe3856 TK |
73 | static inline unsigned long long get_fs_free_size(const char *path) |
74 | { | |
75 | unsigned long long ret; | |
76 | struct statvfs s; | |
77 | ||
78 | if (statvfs(path, &s) < 0) | |
79 | return -1ULL; | |
80 | ||
81 | ret = s.f_frsize; | |
82 | ret *= (unsigned long long) s.f_bfree; | |
83 | return ret; | |
84 | } | |
85 | ||
3cd4c66f J |
86 | #ifdef MADV_FREE |
87 | #define FIO_MADV_FREE MADV_FREE | |
88 | #endif | |
89 | ||
90 | #endif |