Move endianness check to OS parts
[fio.git] / os / os-linux.h
index aab74e581e5fc4cb76fa1eb00739ae1c145c9bb4..8d3b97ea1f04015af100c990aba4d50914f99df9 100644 (file)
 #include <linux/unistd.h>
 #include <linux/raw.h>
 #include <linux/major.h>
+#include <endian.h>
 
 #include "indirect.h"
 #include "binject.h"
+#include "../file.h"
 
 #define FIO_HAVE_LIBAIO
 #define FIO_HAVE_POSIXAIO
 #define FIO_HAVE_TRIM
 #define FIO_HAVE_BINJECT
 #define FIO_HAVE_CLOCK_MONOTONIC
+#define FIO_HAVE_GETTID
+
+/*
+ * Can only enable this for newer glibcs, or the header and defines are
+ * missing
+ */
+#if __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 6
+#define FIO_HAVE_LINUX_FALLOCATE
+#endif
 
 #ifdef SYNC_FILE_RANGE_WAIT_BEFORE
 #define FIO_HAVE_SYNC_FILE_RANGE
@@ -100,6 +111,11 @@ static inline int ioprio_set(int which, int who, int ioprio)
        return syscall(__NR_ioprio_set, which, who, ioprio);
 }
 
+static inline int gettid(void)
+{
+       return syscall(__NR_gettid);
+}
+
 /*
  * Just check for SPLICE_F_MOVE, if that isn't there, assume the others
  * aren't either.
@@ -193,7 +209,7 @@ enum {
 #define BLKDISCARD     _IO(0x12,119)
 #endif
 
-static inline int blockdev_invalidate_cache(struct fio_file *fd)
+static inline int blockdev_invalidate_cache(struct fio_file *f)
 {
        return ioctl(f->fd, BLKFLSBUF);
 }
@@ -271,6 +287,14 @@ static inline int fio_lookup_raw(dev_t dev, int *majdev, int *mindev)
 #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 CACHE_LINE_FILE        \
        "/sys/devices/system/cpu/cpu0/cache/index0/coherency_line_size"