doc: minor consistency and spelling changes
[fio.git] / os / os-openbsd.h
CommitLineData
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
97900ebf
SW
28/* Only OpenBSD 5.1 and above have attach-to-open-removed semantics */
29#undef FIO_HAVE_SHM_ATTACH_REMOVED
30
3cd4c66f
J
31#define OS_MAP_ANON MAP_ANON
32
33#ifndef PTHREAD_STACK_MIN
34#define PTHREAD_STACK_MIN 4096
35#endif
36
37#define fio_swap16(x) bswap16(x)
38#define fio_swap32(x) bswap32(x)
39#define fio_swap64(x) bswap64(x)
40
41typedef off_t off64_t;
42
a955f529
TK
43static 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
3cd4c66f
J
56static inline int blockdev_invalidate_cache(struct fio_file *f)
57{
58 return EINVAL;
59}
60
61static 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
71static inline int gettid(void)
72{
73 return (int) pthread_self();
74}
75
1abe3856
TK
76static 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
3cd4c66f
J
89#ifdef MADV_FREE
90#define FIO_MADV_FREE MADV_FREE
91#endif
92
93#endif