From b9923fe3f2a16bf7dd20862ea6fec51d6716552c Mon Sep 17 00:00:00 2001 From: Andres Salomon Date: Tue, 7 May 2002 05:54:14 +0000 Subject: [PATCH] Make lvm2 compile on big endian archs; use the kernel/glibc's endian conversion stuff, instead of implementing our own. Tested on a little endian system (x86); I'll let the debian handle big endian testing. :) --- lib/mm/xlate.h | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/lib/mm/xlate.h b/lib/mm/xlate.h index 6d4dc4bb3..97b0afaea 100644 --- a/lib/mm/xlate.h +++ b/lib/mm/xlate.h @@ -8,25 +8,21 @@ #ifndef _LVM_XLATE_H #define _LVM_XLATE_H -/* FIXME: finish these as inlines */ +#include -uint16_t shuffle16(uint16_t n); -uint32_t shuffle32(uint32_t n); -uint64_t shuffle64(uint64_t n); +static inline uint16_t xlate16(uint16_t x) +{ + return __cpu_to_le16(x); +} -/* xlate functions move data between core and disk */ -#if __BYTE_ORDER == __BIG_ENDIAN -# define xlate16(x) shuffle16(x) -# define xlate32(x) shuffle32(x) -# define xlate64(x) shuffle64(x) +static inline uint32_t xlate32(uint32_t x) +{ + return __cpu_to_le32(x); +} -#elif __BYTE_ORDER == __LITTLE_ENDIAN -# define xlate16(x) (x) -# define xlate32(x) (x) -# define xlate64(x) (x) - -#else -# error "__BYTE_ORDER must be defined as __LITTLE_ENDIAN or __BIG_ENDIAN" -#endif +static inline uint64_t xlate64(uint64_t x) +{ + return __cpu_to_le64(x); +} #endif -- 2.43.5