hash: cleanups
[fio.git] / os / os-netbsd.h
... / ...
CommitLineData
1#ifndef FIO_OS_NETBSD_H
2#define FIO_OS_NETBSD_H
3
4#define FIO_OS os_netbsd
5
6#include <errno.h>
7#include <lwp.h>
8#include <sys/param.h>
9#include <sys/statvfs.h>
10#include <sys/ioctl.h>
11#include <sys/dkio.h>
12#include <sys/disklabel.h>
13#include <sys/endian.h>
14#include <sys/sysctl.h>
15
16/* XXX hack to avoid conflicts between rbtree.h and <sys/rbtree.h> */
17#undef rb_node
18#undef rb_left
19#undef rb_right
20
21#include "../file.h"
22
23#define FIO_HAVE_ODIRECT
24#define FIO_USE_GENERIC_INIT_RANDOM_STATE
25#define FIO_HAVE_FS_STAT
26#define FIO_HAVE_GETTID
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#ifdef CONFIG_PTHREAD_GETAFFINITY
39#define FIO_HAVE_GET_THREAD_AFFINITY
40#define fio_get_thread_affinity(mask) \
41 pthread_getaffinity_np(pthread_self(), sizeof(mask), &(mask))
42#endif
43
44static inline int blockdev_size(struct fio_file *f, unsigned long long *bytes)
45{
46 struct disklabel dl;
47
48 if (!ioctl(f->fd, DIOCGDINFO, &dl)) {
49 *bytes = ((unsigned long long)dl.d_secperunit) * dl.d_secsize;
50 return 0;
51 }
52
53 *bytes = 0;
54 return errno;
55}
56
57static inline int blockdev_invalidate_cache(struct fio_file *f)
58{
59 return ENOTSUP;
60}
61
62static inline unsigned long long os_phys_mem(void)
63{
64 int mib[2] = { CTL_HW, HW_PHYSMEM64 };
65 uint64_t mem;
66 size_t len = sizeof(mem);
67
68 sysctl(mib, 2, &mem, &len, NULL, 0);
69 return mem;
70}
71
72#ifndef CONFIG_HAVE_GETTID
73static inline int gettid(void)
74{
75 return (int) _lwp_self();
76}
77#endif
78
79static inline unsigned long long get_fs_free_size(const char *path)
80{
81 unsigned long long ret;
82 struct statvfs s;
83
84 if (statvfs(path, &s) < 0)
85 return -1ULL;
86
87 ret = s.f_frsize;
88 ret *= (unsigned long long) s.f_bfree;
89 return ret;
90}
91
92#ifdef MADV_FREE
93#define FIO_MADV_FREE MADV_FREE
94#endif
95
96#endif