+#ifndef FIO_PREFERRED_ENGINE
+#define FIO_PREFERRED_ENGINE "psync"
+#endif
+
+#ifndef FIO_OS_PATH_SEPARATOR
+#define FIO_OS_PATH_SEPARATOR "/"
+#endif
+
+#ifndef FIO_PREFERRED_CLOCK_SOURCE
+#ifdef CONFIG_CLOCK_GETTIME
+#define FIO_PREFERRED_CLOCK_SOURCE CS_CGETTIME
+#else
+#define FIO_PREFERRED_CLOCK_SOURCE CS_GTOD
+#endif
+#endif
+
+#ifndef FIO_MAX_JOBS
+#define FIO_MAX_JOBS 4096
+#endif
+
+#ifndef CONFIG_SOCKLEN_T
+typedef unsigned int socklen_t;
+#endif
+
+#ifndef FIO_OS_HAS_CTIME_R
+#define os_ctime_r(x, y, z) (void) ctime_r((x), (y))
+#endif
+
+#ifdef FIO_USE_GENERIC_SWAP
+static inline uint16_t fio_swap16(uint16_t val)
+{
+ return (val << 8) | (val >> 8);
+}
+
+static inline uint32_t fio_swap32(uint32_t val)
+{
+ val = ((val & 0xff00ff00UL) >> 8) | ((val & 0x00ff00ffUL) << 8);
+
+ return (val >> 16) | (val << 16);
+}
+
+static inline uint64_t fio_swap64(uint64_t val)
+{
+ val = ((val & 0xff00ff00ff00ff00ULL) >> 8) |
+ ((val & 0x00ff00ff00ff00ffULL) << 8);
+ val = ((val & 0xffff0000ffff0000ULL) >> 16) |
+ ((val & 0x0000ffff0000ffffULL) << 16);
+
+ return (val >> 32) | (val << 32);
+}
+#endif
+
+#ifndef FIO_HAVE_BYTEORDER_FUNCS
+#ifdef CONFIG_LITTLE_ENDIAN
+#define __le16_to_cpu(x) (x)
+#define __le32_to_cpu(x) (x)
+#define __le64_to_cpu(x) (x)
+#define __cpu_to_le16(x) (x)
+#define __cpu_to_le32(x) (x)
+#define __cpu_to_le64(x) (x)
+#else
+#define __le16_to_cpu(x) fio_swap16(x)
+#define __le32_to_cpu(x) fio_swap32(x)
+#define __le64_to_cpu(x) fio_swap64(x)
+#define __cpu_to_le16(x) fio_swap16(x)
+#define __cpu_to_le32(x) fio_swap32(x)
+#define __cpu_to_le64(x) fio_swap64(x)
+#endif
+#endif /* FIO_HAVE_BYTEORDER_FUNCS */
+
+#ifdef FIO_INTERNAL
+#define le16_to_cpu(val) ({ \
+ typecheck(uint16_t, val); \
+ __le16_to_cpu(val); \
+})
+#define le32_to_cpu(val) ({ \
+ typecheck(uint32_t, val); \
+ __le32_to_cpu(val); \
+})
+#define le64_to_cpu(val) ({ \
+ typecheck(uint64_t, val); \
+ __le64_to_cpu(val); \
+})
+#endif
+
+#define cpu_to_le16(val) ({ \
+ typecheck(uint16_t, val); \
+ __cpu_to_le16(val); \
+})
+#define cpu_to_le32(val) ({ \
+ typecheck(uint32_t, val); \
+ __cpu_to_le32(val); \
+})
+#define cpu_to_le64(val) ({ \
+ typecheck(uint64_t, val); \
+ __cpu_to_le64(val); \
+})
+
+#define FIO_DEF_CL_SIZE 128
+
+static inline int os_cache_line_size(void)
+{
+#ifdef FIO_HAVE_CL_SIZE
+ int ret = arch_cache_line_size();
+
+ if (ret <= 0)
+ return FIO_DEF_CL_SIZE;
+
+ return ret;
+#else
+ return FIO_DEF_CL_SIZE;
+#endif
+}
+
+#ifdef FIO_USE_GENERIC_BDEV_SIZE
+static inline int blockdev_size(struct fio_file *f, unsigned long long *bytes)
+{
+ off_t end;
+
+ *bytes = 0;
+
+ end = lseek(f->fd, 0, SEEK_END);
+ if (end < 0)
+ return errno;
+
+ *bytes = end;
+ return 0;
+}
+#endif
+
+#ifdef FIO_USE_GENERIC_RAND
+typedef unsigned int os_random_state_t;
+
+static inline void os_random_seed(unsigned long seed, os_random_state_t *rs)
+{
+ srand(seed);
+}
+
+static inline long os_random_long(os_random_state_t *rs)
+{
+ long val;
+
+ val = rand_r(rs);
+ return val;
+}
+#endif
+
+#ifdef FIO_USE_GENERIC_INIT_RANDOM_STATE
+static inline int init_random_seeds(unsigned long *rand_seeds, int size)
+{
+ int fd;
+
+ fd = open("/dev/urandom", O_RDONLY);
+ if (fd == -1) {
+ return 1;
+ }
+
+ if (read(fd, rand_seeds, size) < size) {
+ close(fd);
+ return 1;
+ }
+
+ close(fd);
+ return 0;
+}
+#endif
+
+#ifndef FIO_HAVE_FS_STAT
+static inline unsigned long long get_fs_free_size(const char *path)