11 #elif defined(__FreeBSD__)
12 #include "os-freebsd.h"
13 #elif defined(__NetBSD__)
14 #include "os-netbsd.h"
15 #elif defined(__sun__)
16 #include "os-solaris.h"
17 #elif defined(__APPLE__)
23 #elif defined(__CYGWIN__)
24 #include "os-windows.h"
26 #error "unsupported os"
29 #ifdef FIO_HAVE_LIBAIO
33 #ifdef FIO_HAVE_POSIXAIO
42 #ifndef FIO_HAVE_STRSEP
43 #include "../lib/strsep.h"
47 #define OS_MSG_DONTWAIT MSG_DONTWAIT
50 #ifndef FIO_HAVE_FADVISE
51 #define posix_fadvise(fd, off, len, advice) (0)
53 #ifndef POSIX_FADV_DONTNEED
54 #define POSIX_FADV_DONTNEED (0)
55 #define POSIX_FADV_SEQUENTIAL (0)
56 #define POSIX_FADV_RANDOM (0)
58 #endif /* FIO_HAVE_FADVISE */
60 #ifndef FIO_HAVE_CPU_AFFINITY
61 #define fio_setaffinity(pid, mask) (0)
62 #define fio_getaffinity(pid, mask) do { } while (0)
63 #define fio_cpu_clear(mask, cpu) do { } while (0)
64 #define fio_cpuset_exit(mask) (-1)
65 typedef unsigned long os_cpu_mask_t;
68 #ifndef FIO_HAVE_IOPRIO
69 #define ioprio_set(which, who, prio) (0)
72 #ifndef FIO_HAVE_ODIRECT
75 #define OS_O_DIRECT O_DIRECT
78 #ifndef FIO_HAVE_HUGETLB
81 #define FIO_HUGE_PAGE 0
85 #define FIO_HUGE_PAGE 4194304
90 #define FIO_O_NOATIME 0
94 #define OS_RAND_MAX RAND_MAX
97 #ifdef FIO_HAVE_CLOCK_MONOTONIC
98 #define FIO_TIMER_CLOCK CLOCK_MONOTONIC
100 #define FIO_TIMER_CLOCK CLOCK_REALTIME
103 #ifndef FIO_HAVE_RAWBIND
104 #define fio_lookup_raw(dev, majdev, mindev) 1
107 #ifndef FIO_PREFERRED_ENGINE
108 #define FIO_PREFERRED_ENGINE "sync"
112 #define FIO_MAX_JOBS 2048
115 #ifndef FIO_HAVE_BLKTRACE
116 static inline int is_blktrace(const char *fname)
121 static inline int load_blktrace(struct thread_data *td, const char *fname)
127 #define FIO_DEF_CL_SIZE 128
129 static inline int os_cache_line_size(void)
131 #ifdef FIO_HAVE_CL_SIZE
132 int ret = arch_cache_line_size();
135 return FIO_DEF_CL_SIZE;
139 return FIO_DEF_CL_SIZE;
143 #ifdef FIO_USE_GENERIC_BDEV_SIZE
144 static inline int blockdev_size(struct fio_file *f, unsigned long long *bytes)
150 end = lseek(f->fd, 0, SEEK_END);
159 #ifdef FIO_USE_GENERIC_RAND
160 typedef unsigned int os_random_state_t;
162 static inline void os_random_seed(unsigned long seed, os_random_state_t *rs)
167 static inline long os_random_long(os_random_state_t *rs)
176 #ifndef FIO_HAVE_FS_STAT
177 static inline unsigned long long get_fs_size(const char *path)
183 #ifndef FIO_HAVE_CPU_ONLINE_SYSCONF
184 static inline unsigned int cpus_online(void)
186 return sysconf(_SC_NPROCESSORS_ONLN);
190 #ifndef FIO_HAVE_GETTID
191 static inline int gettid(void)