blob: 5d8258bd9460e2e6edaf14f441b291b1acb91fbb [file] [log] [blame]
Jens Axboec50bdd82010-05-21 07:14:04 +02001#ifndef FIO_OS_NETBSD_H
2#define FIO_OS_NETBSD_H
3
4#include <errno.h>
5#include <sys/param.h>
Jens Axboeb9396832011-07-30 13:29:58 +02006#include <sys/thr.h>
Jens Axboe901ebe12011-10-04 23:31:00 +02007#include <sys/endian.h>
Jens Axboec50bdd82010-05-21 07:14:04 +02008/* XXX hack to avoid confilcts between rbtree.h and <sys/rb.h> */
9#define rb_node _rb_node
10#include <sys/sysctl.h>
11#undef rb_node
12#undef rb_left
13#undef rb_right
14
Jens Axboee2e58882011-01-04 08:36:06 +010015#include "../file.h"
16
Jens Axboec50bdd82010-05-21 07:14:04 +020017#define FIO_HAVE_POSIXAIO
18#define FIO_HAVE_FADVISE
Jens Axboec50bdd82010-05-21 07:14:04 +020019#define FIO_HAVE_ODIRECT
20#define FIO_HAVE_STRSEP
21#define FIO_HAVE_FDATASYNC
22#define FIO_USE_GENERIC_BDEV_SIZE
23#define FIO_USE_GENERIC_RAND
Jens Axboeb9afd952011-07-12 23:49:16 +020024#define FIO_HAVE_GETTID
Jens Axboec50bdd82010-05-21 07:14:04 +020025
26#undef FIO_HAVE_CPU_AFFINITY /* XXX notyet */
27
28#define OS_MAP_ANON MAP_ANON
29
Bruce Cran9b836562011-01-08 19:49:54 +010030#ifndef PTHREAD_STACK_MIN
31#define PTHREAD_STACK_MIN 4096
32#endif
33
Jens Axboe901ebe12011-10-04 23:31:00 +020034#if BYTE_ORDER == LITTLE_ENDIAN
35#define FIO_LITTLE_ENDIAN
36#else
37#define FIO_BIG_ENDIAN
38#endif
39
40#define fio_swap16(x) bswap16(x)
41#define fio_swap32(x) bswap32(x)
42#define fio_swap64(x) bswap64(x)
43
Jens Axboec50bdd82010-05-21 07:14:04 +020044typedef off_t off64_t;
45
Bruce Cran9b836562011-01-08 19:49:54 +010046static inline int blockdev_invalidate_cache(struct fio_file *f)
Jens Axboec50bdd82010-05-21 07:14:04 +020047{
48 return EINVAL;
49}
50
51static inline unsigned long long os_phys_mem(void)
52{
53 int mib[2] = { CTL_HW, HW_PHYSMEM64 };
54 uint64_t mem;
55 size_t len = sizeof(mem);
56
57 sysctl(mib, 2, &mem, &len, NULL, 0);
58 return mem;
59}
60
Jens Axboeb9afd952011-07-12 23:49:16 +020061static inline int gettid(void)
62{
63 long lwpid;
64
65 thr_self(&lwpid);
66 return (int) lwpid;
67}
68
Jens Axboec50bdd82010-05-21 07:14:04 +020069#ifdef MADV_FREE
70#define FIO_MADV_FREE MADV_FREE
71#endif
72
73/* XXX NetBSD doesn't have getopt_long_only */
74#define getopt_long_only getopt_long
75
76#endif