Move endianness check to OS parts
authorJens Axboe <axboe@kernel.dk>
Tue, 4 Oct 2011 11:53:35 +0000 (13:53 +0200)
committerJens Axboe <axboe@kernel.dk>
Tue, 4 Oct 2011 11:53:35 +0000 (13:53 +0200)
Signed-off-by: Jens Axboe <axboe@kernel.dk>
os/os-linux.h
server.h

index a36552ba68ba93caf6ca58e5fc9761fc53c0b88d..8d3b97ea1f04015af100c990aba4d50914f99df9 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/unistd.h>
 #include <linux/raw.h>
 #include <linux/major.h>
+#include <endian.h>
 
 #include "indirect.h"
 #include "binject.h"
@@ -286,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"
 
index 98262af85679c4724116cf0f34076ae7cc949d1d..3bb96a2777021b64c31ace58bfb652ff41687412 100644 (file)
--- a/server.h
+++ b/server.h
@@ -3,9 +3,9 @@
 
 #include <inttypes.h>
 #include <string.h>
-#include <endian.h>
 
 #include "stat.h"
+#include "os/os.h"
 
 /*
  * On-wire encoding is little endian
@@ -96,22 +96,20 @@ extern struct fio_net_cmd *fio_net_recv_cmd(int sk, int block);
 extern int exit_backend;
 extern int fio_net_port;
 
-#if __BYTE_ORDER == __LITTLE_ENDIAN
+#ifdef FIO_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)
-#elif __BYTE_ORDER == __BIG_ENDIAN
+#else
 #define __le16_to_cpu(x)               __bswap_16(x)
 #define __le32_to_cpu(x)               __bswap_32(x)
 #define __le64_to_cpu(x)               __bswap_64(x)
 #define __cpu_to_le16(x)               __bswap_16(x)
 #define __cpu_to_le32(x)               __bswap_32(x)
 #define __cpu_to_le64(x)               __bswap_64(x)
-#else
-#error "Endianness not detected"
 #endif
 
 #define le16_to_cpu(val) ({                    \