1 #ifndef FIO_OS_OPENBSD_H
2 #define FIO_OS_OPENBSD_H
4 #define FIO_OS os_openbsd
8 #include <sys/statvfs.h>
11 #include <sys/disklabel.h>
12 #include <sys/endian.h>
13 #include <sys/utsname.h>
14 /* XXX hack to avoid conflicts between rbtree.h and <sys/tree.h> */
15 #include <sys/sysctl.h>
22 #undef FIO_HAVE_ODIRECT
23 #define FIO_USE_GENERIC_RAND
24 #define FIO_USE_GENERIC_INIT_RANDOM_STATE
25 #define FIO_HAVE_FS_STAT
26 #define FIO_HAVE_GETTID
27 #define FIO_HAVE_SHM_ATTACH_REMOVED
29 #undef FIO_HAVE_CPU_AFFINITY /* doesn't exist */
31 #define OS_MAP_ANON MAP_ANON
33 #ifndef PTHREAD_STACK_MIN
34 #define PTHREAD_STACK_MIN 4096
37 #define fio_swap16(x) bswap16(x)
38 #define fio_swap32(x) bswap32(x)
39 #define fio_swap64(x) bswap64(x)
41 typedef off_t off64_t;
43 static inline int blockdev_size(struct fio_file *f, unsigned long long *bytes)
47 if (!ioctl(f->fd, DIOCGDINFO, &dl)) {
48 *bytes = ((unsigned long long)dl.d_secperunit) * dl.d_secsize;
56 static inline int blockdev_invalidate_cache(struct fio_file *f)
61 static inline unsigned long long os_phys_mem(void)
63 int mib[2] = { CTL_HW, HW_PHYSMEM64 };
65 size_t len = sizeof(mem);
67 sysctl(mib, 2, &mem, &len, NULL, 0);
71 static inline int gettid(void)
73 return (int)(intptr_t) pthread_self();
76 static inline unsigned long long get_fs_free_size(const char *path)
78 unsigned long long ret;
81 if (statvfs(path, &s) < 0)
85 ret *= (unsigned long long) s.f_bfree;
90 #define FIO_MADV_FREE MADV_FREE
93 static inline int shm_attach_to_open_removed(void)
98 if (uname(&uts) == -1)
102 * Return 1 if >= OpenBSD 5.1 according to 97900ebf,
103 * assuming both major/minor versions are < 10.
105 if (uts.release[0] > '9' || uts.release[0] < '0')
107 if (uts.release[1] != '.')
109 if (uts.release[2] > '9' || uts.release[2] < '0')
112 major = uts.release[0] - '0';
113 minor = uts.release[2] - '0';
117 if (major == 5 && minor >= 1)