blob: aef578e8014d8258b962408bd5f1a0c604264a7e [file] [log] [blame]
Jens Axboec50bdd82010-05-21 07:14:04 +02001#ifndef FIO_OS_NETBSD_H
2#define FIO_OS_NETBSD_H
3
Jens Axboecca84642011-10-07 12:47:57 +02004#define FIO_OS os_netbsd
5
Jens Axboec50bdd82010-05-21 07:14:04 +02006#include <errno.h>
7#include <sys/param.h>
Jens Axboeb9396832011-07-30 13:29:58 +02008#include <sys/thr.h>
Jens Axboe901ebe12011-10-04 23:31:00 +02009#include <sys/endian.h>
Jens Axboec50bdd82010-05-21 07:14:04 +020010/* XXX hack to avoid confilcts between rbtree.h and <sys/rb.h> */
11#define rb_node _rb_node
12#include <sys/sysctl.h>
13#undef rb_node
14#undef rb_left
15#undef rb_right
16
Jens Axboee2e58882011-01-04 08:36:06 +010017#include "../file.h"
18
Jens Axboec50bdd82010-05-21 07:14:04 +020019#define FIO_HAVE_POSIXAIO
20#define FIO_HAVE_FADVISE
Jens Axboec50bdd82010-05-21 07:14:04 +020021#define FIO_HAVE_ODIRECT
22#define FIO_HAVE_STRSEP
23#define FIO_HAVE_FDATASYNC
24#define FIO_USE_GENERIC_BDEV_SIZE
25#define FIO_USE_GENERIC_RAND
Bruce Cran93bcfd22012-02-20 20:18:19 +010026#define FIO_USE_GENERIC_INIT_RANDOM_STATE
Jens Axboeb9afd952011-07-12 23:49:16 +020027#define FIO_HAVE_GETTID
Jens Axboec50bdd82010-05-21 07:14:04 +020028
29#undef FIO_HAVE_CPU_AFFINITY /* XXX notyet */
30
31#define OS_MAP_ANON MAP_ANON
32
Bruce Cran9b836562011-01-08 19:49:54 +010033#ifndef PTHREAD_STACK_MIN
34#define PTHREAD_STACK_MIN 4096
35#endif
36
Jens Axboe901ebe12011-10-04 23:31:00 +020037#if BYTE_ORDER == LITTLE_ENDIAN
38#define FIO_LITTLE_ENDIAN
39#else
40#define FIO_BIG_ENDIAN
41#endif
42
43#define fio_swap16(x) bswap16(x)
44#define fio_swap32(x) bswap32(x)
45#define fio_swap64(x) bswap64(x)
46
Jens Axboec50bdd82010-05-21 07:14:04 +020047typedef off_t off64_t;
48
Bruce Cran9b836562011-01-08 19:49:54 +010049static inline int blockdev_invalidate_cache(struct fio_file *f)
Jens Axboec50bdd82010-05-21 07:14:04 +020050{
51 return EINVAL;
52}
53
54static inline unsigned long long os_phys_mem(void)
55{
56 int mib[2] = { CTL_HW, HW_PHYSMEM64 };
57 uint64_t mem;
58 size_t len = sizeof(mem);
59
60 sysctl(mib, 2, &mem, &len, NULL, 0);
61 return mem;
62}
63
Jens Axboeb9afd952011-07-12 23:49:16 +020064static inline int gettid(void)
65{
66 long lwpid;
67
68 thr_self(&lwpid);
69 return (int) lwpid;
70}
71
Jens Axboec50bdd82010-05-21 07:14:04 +020072#ifdef MADV_FREE
73#define FIO_MADV_FREE MADV_FREE
74#endif
75
76/* XXX NetBSD doesn't have getopt_long_only */
77#define getopt_long_only getopt_long
78
79#endif