From 610a730c79c90298d41cb3138041e83ba9cdb1d2 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Tue, 4 Oct 2011 13:53:35 +0200 Subject: [PATCH] Move endianness check to OS parts Signed-off-by: Jens Axboe --- os/os-linux.h | 9 +++++++++ server.h | 8 +++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/os/os-linux.h b/os/os-linux.h index a36552ba..8d3b97ea 100644 --- a/os/os-linux.h +++ b/os/os-linux.h @@ -12,6 +12,7 @@ #include #include #include +#include #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" diff --git a/server.h b/server.h index 98262af8..3bb96a27 100644 --- a/server.h +++ b/server.h @@ -3,9 +3,9 @@ #include #include -#include #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) ({ \ -- 2.25.1