From 05af63dc9bf09869935538f38024f01a303c53fa Mon Sep 17 00:00:00 2001 From: "flatcap.org!ntfs" Date: Tue, 18 Nov 2003 21:17:57 +0000 Subject: [PATCH] remove the dependency on in favour of and (Logical change 1.237) --- include/endians.h | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/include/endians.h b/include/endians.h index 30eaee76..6f7f271f 100644 --- a/include/endians.h +++ b/include/endians.h @@ -30,13 +30,13 @@ * defaults don't necessarily perform appropriate typecasts. * Also, using our own functions means that we can change them if it * turns out that we do need to use the unaligned access macros on - * architectures requirering aligned memory accesses... + * architectures requiring aligned memory accesses... */ -#include +#include +#include -/* The following are not defined on Cygwin... Luckily Cygwin is LE already. */ -#ifdef __CYGWIN32__ +#if (__BYTE_ORDER == __LITTLE_ENDIAN) #define __le16_to_cpu(x) (x) #define __le32_to_cpu(x) (x) @@ -54,8 +54,29 @@ #define __constant_cpu_to_le32(x) (x) #define __constant_cpu_to_le64(x) (x) -#endif /* __CYGWIN32__ */ +#elif (__BYTE_ORDER == __BIG_ENDIAN) +#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) + +#define __constant_le16_to_cpu(x) __bswap_constant_16(x) +#define __constant_le32_to_cpu(x) __bswap_constant_32(x) +#define __constant_le64_to_cpu(x) __bswap_constant_64(x) + +#define __constant_cpu_to_le16(x) __bswap_constant_16(x) +#define __constant_cpu_to_le32(x) __bswap_constant_32(x) +#define __constant_cpu_to_le64(x) __bswap_constant_64(x) + +#else + +#error "You must define __BYTE_ORDER to be __LITTLE_ENDIAN or __BIG_ENDIAN" + +#endif /* Unsigned from LE to CPU conversion. */