+#else
+#define FIO_O_NOATIME 0
+#endif
+
+#ifdef MADV_REMOVE
+#define FIO_MADV_FREE MADV_REMOVE
+#endif
+
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+#define FIO_LITTLE_ENDIAN
+#elif __BYTE_ORDER == __BIG_ENDIAN
+#define FIO_BIG_ENDIAN
+#else
+#error "Unknown endianness"
+#endif
+
+#define fio_swap16(x) __bswap_16(x)
+#define fio_swap32(x) __bswap_32(x)
+#define fio_swap64(x) __bswap_64(x)
+
+#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;
+}