+#ifdef O_NOATIME
+#define FIO_O_NOATIME O_NOATIME
+#else
+#define FIO_O_NOATIME 0
+#endif
+
+#ifdef O_ATOMIC
+#define OS_O_ATOMIC O_ATOMIC
+#else
+#define OS_O_ATOMIC 040000000
+#endif
+
+#ifdef MADV_REMOVE
+#define FIO_MADV_FREE MADV_REMOVE
+#endif
+
+#if defined(__builtin_bswap16)
+#define fio_swap16(x) __builtin_bswap16(x)
+#else
+#define fio_swap16(x) __bswap_16(x)
+#endif
+#if defined(__builtin_bswap32)
+#define fio_swap32(x) __builtin_bswap32(x)
+#else
+#define fio_swap32(x) __bswap_32(x)
+#endif
+#if defined(__builtin_bswap64)
+#define fio_swap64(x) __builtin_bswap64(x)
+#else
+#define fio_swap64(x) __bswap_64(x)
+#endif
+
+#define CACHE_LINE_FILE \
+ "/sys/devices/system/cpu/cpu0/cache/index0/coherency_line_size"
+
+static inline int arch_cache_line_size(void)
+{
+ char size[32];
+ int fd, ret;
+
+ fd = open(CACHE_LINE_FILE, O_RDONLY);
+ if (fd < 0)
+ return -1;
+
+ ret = read(fd, size, sizeof(size));
+
+ close(fd);
+
+ if (ret <= 0)
+ return -1;
+ else
+ return atoi(size);
+}
+
+static inline unsigned long long get_fs_size(const char *path)
+{
+ unsigned long long ret;
+ struct statfs s;
+
+ if (statfs(path, &s) < 0)
+ return -1ULL;
+
+ ret = s.f_bsize;
+ ret *= (unsigned long long) s.f_bfree;
+ return ret;
+}
+
+static inline int os_trim(int fd, unsigned long long start,
+ unsigned long long len)
+{
+ uint64_t range[2];
+
+ range[0] = start;
+ range[1] = len;
+
+ if (!ioctl(fd, BLKDISCARD, range))
+ return 0;
+
+ return errno;
+}
+
+#ifdef CONFIG_SCHED_IDLE
+static inline int fio_set_sched_idle(void)
+{
+ struct sched_param p = { .sched_priority = 0, };
+ return sched_setscheduler(gettid(), SCHED_IDLE, &p);
+}
+#endif
+