eta: Fix ETA oddness at crossover points
[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/* XXX hack to avoid confilcts between rbtree.h and <sys/rb.h> */
14#define rb_node _rb_node
15#include <sys/sysctl.h>
16#undef rb_node
17#undef rb_left
18#undef rb_right
19
20#include "../file.h"
21
22#define 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
28#undef FIO_HAVE_CPU_AFFINITY /* XXX notyet */
29
30#define OS_MAP_ANON MAP_ANON
31
32#ifndef PTHREAD_STACK_MIN
33#define PTHREAD_STACK_MIN 4096
34#endif
35
36#define fio_swap16(x) bswap16(x)
37#define fio_swap32(x) bswap32(x)
38#define fio_swap64(x) bswap64(x)
39
40typedef off_t off64_t;
41
42static inline int blockdev_size(struct fio_file *f, unsigned long long *bytes)
43{
44 struct disklabel dl;
45
46 if (!ioctl(f->fd, DIOCGDINFO, &dl)) {
47 *bytes = ((unsigned long long)dl.d_secperunit) * dl.d_secsize;
48 return 0;
49 }
50
51 *bytes = 0;
52 return errno;
53}
54
55static inline int blockdev_invalidate_cache(struct fio_file *f)
56{
57 return EINVAL;
58}
59
60static inline unsigned long long os_phys_mem(void)
61{
62 int mib[2] = { CTL_HW, HW_PHYSMEM64 };
63 uint64_t mem;
64 size_t len = sizeof(mem);
65
66 sysctl(mib, 2, &mem, &len, NULL, 0);
67 return mem;
68}
69
70static inline int gettid(void)
71{
72 return (int) _lwp_self();
73}
74
75static inline unsigned long long get_fs_free_size(const char *path)
76{
77 unsigned long long ret;
78 struct statvfs s;
79
80 if (statvfs(path, &s) < 0)
81 return -1ULL;
82
83 ret = s.f_frsize;
84 ret *= (unsigned long long) s.f_bfree;
85 return ret;
86}
87
88#ifdef MADV_FREE
89#define FIO_MADV_FREE MADV_FREE
90#endif
91
92#endif