Merge branch 'fix_verify' of https://github.com/charles-jacobsen/fio
[fio.git] / os / os-dragonfly.h
... / ...
CommitLineData
1#ifndef FIO_OS_DRAGONFLY_H
2#define FIO_OS_DRAGONFLY_H
3
4#define FIO_OS os_dragonfly
5
6#include <errno.h>
7#include <unistd.h>
8#include <sys/param.h>
9#include <sys/sysctl.h>
10#include <sys/statvfs.h>
11#include <sys/diskslice.h>
12
13#include "../file.h"
14
15#define FIO_HAVE_ODIRECT
16#define FIO_USE_GENERIC_RAND
17#define FIO_USE_GENERIC_INIT_RANDOM_STATE
18#define FIO_HAVE_FS_STAT
19#define FIO_HAVE_CHARDEV_SIZE
20#define FIO_HAVE_GETTID
21
22#undef FIO_HAVE_CPU_AFFINITY /* XXX notyet */
23
24#define OS_MAP_ANON MAP_ANON
25
26#ifndef PTHREAD_STACK_MIN
27#define PTHREAD_STACK_MIN 4096
28#endif
29
30#define fio_swap16(x) bswap16(x)
31#define fio_swap32(x) bswap32(x)
32#define fio_swap64(x) bswap64(x)
33
34typedef off_t off64_t;
35
36static inline int blockdev_size(struct fio_file *f, unsigned long long *bytes)
37{
38 struct partinfo pi;
39
40 if (!ioctl(f->fd, DIOCGPART, &pi)) {
41 *bytes = (unsigned long long) pi.media_size;
42 return 0;
43 }
44
45 *bytes = 0;
46 return errno;
47}
48
49static inline int chardev_size(struct fio_file *f, unsigned long long *bytes)
50{
51 return blockdev_size(f, bytes);
52}
53
54static inline int blockdev_invalidate_cache(struct fio_file *f)
55{
56 return EINVAL;
57}
58
59static inline unsigned long long os_phys_mem(void)
60{
61 int mib[2] = { CTL_HW, HW_PHYSMEM };
62 uint64_t mem;
63 size_t len = sizeof(mem);
64
65 sysctl(mib, 2, &mem, &len, NULL, 0);
66 return mem;
67}
68
69static inline int gettid(void)
70{
71 return (int) lwp_gettid();
72}
73
74static inline unsigned long long get_fs_free_size(const char *path)
75{
76 unsigned long long ret;
77 struct statvfs s;
78
79 if (statvfs(path, &s) < 0)
80 return -1ULL;
81
82 ret = s.f_frsize;
83 ret *= (unsigned long long) s.f_bfree;
84 return ret;
85}
86
87#ifdef MADV_FREE
88#define FIO_MADV_FREE MADV_FREE
89#endif
90
91#endif