Remove getopt_long_only macro from NetBSD header
[fio.git] / os / os-openbsd.h
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>
8 #include <sys/statvfs.h>
9 /* XXX hack to avoid conflicts between rbtree.h and <sys/tree.h> */
10 #include <sys/sysctl.h>
11 #undef RB_BLACK
12 #undef RB_RED
13 #undef RB_ROOT
14
15 #include "../file.h"
16
17 #undef  FIO_HAVE_ODIRECT
18 #define FIO_USE_GENERIC_BDEV_SIZE
19 #define FIO_USE_GENERIC_RAND
20 #define FIO_USE_GENERIC_INIT_RANDOM_STATE
21 #define FIO_HAVE_FS_STAT
22 #define FIO_HAVE_GETTID
23
24 #undef  FIO_HAVE_CPU_AFFINITY   /* XXX notyet */
25
26 #define OS_MAP_ANON             MAP_ANON
27
28 #ifndef PTHREAD_STACK_MIN
29 #define PTHREAD_STACK_MIN 4096
30 #endif
31
32 #define fio_swap16(x)   bswap16(x)
33 #define fio_swap32(x)   bswap32(x)
34 #define fio_swap64(x)   bswap64(x)
35
36 typedef off_t off64_t;
37
38 static inline int blockdev_invalidate_cache(struct fio_file *f)
39 {
40         return EINVAL;
41 }
42
43 static inline unsigned long long os_phys_mem(void)
44 {
45         int mib[2] = { CTL_HW, HW_PHYSMEM64 };
46         uint64_t mem;
47         size_t len = sizeof(mem);
48
49         sysctl(mib, 2, &mem, &len, NULL, 0);
50         return mem;
51 }
52
53 static inline int gettid(void)
54 {
55         return (int) pthread_self();
56 }
57
58 static inline unsigned long long get_fs_free_size(const char *path)
59 {
60         unsigned long long ret;
61         struct statvfs s;
62
63         if (statvfs(path, &s) < 0)
64                 return -1ULL;
65
66         ret = s.f_frsize;
67         ret *= (unsigned long long) s.f_bfree;
68         return ret;
69 }
70
71 #ifdef MADV_FREE
72 #define FIO_MADV_FREE   MADV_FREE
73 #endif
74
75 #endif