From 58c28e0f7844903c2dc57fb3ea122ef8f00cad19 Mon Sep 17 00:00:00 2001 From: "cantab.net!aia21" Date: Fri, 9 Apr 2004 14:49:40 +0000 Subject: [PATCH] - Move constant bswap macros out of the ifdefs in endians.h so they are always available. (Yuval) - Add conditional include of sys/param.h in endians.h which provides endianness support on Cygwin. (Yuval) (Logical change 1.362) --- include/ntfs/endians.h | 63 +++++++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 29 deletions(-) diff --git a/include/ntfs/endians.h b/include/ntfs/endians.h index bc230919..6192fc16 100644 --- a/include/ntfs/endians.h +++ b/include/ntfs/endians.h @@ -46,6 +46,9 @@ #ifdef HAVE_MACHINE_ENDIAN_H # include #endif +#ifdef HAVE_SYS_PARAM_H +# include +#endif #ifndef __BYTE_ORDER # ifdef _BYTE_ORDER # define __BYTE_ORDER _BYTE_ORDER @@ -56,6 +59,8 @@ # define __BYTE_ORDER BYTE_ORDER # define __LITTLE_ENDIAN LITTLE_ENDIAN # define __BIG_ENDIAN BIG_ENDIAN +# else +# error "__BYTE_ORDER is not defined." # endif # endif #endif @@ -63,34 +68,6 @@ # include #endif -#if (__BYTE_ORDER == __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) - -#define __constant_le16_to_cpu(x) (x) -#define __constant_le32_to_cpu(x) (x) -#define __constant_le64_to_cpu(x) (x) - -#define __constant_cpu_to_le16(x) (x) -#define __constant_cpu_to_le32(x) (x) -#define __constant_cpu_to_le64(x) (x) - -#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 __ntfs_bswap_constant_16(x) \ (u16)((((u16)(x) & 0xff00) >> 8) | \ (((u16)(x) & 0x00ff) << 8)) @@ -111,6 +88,34 @@ (((u64)(x) & 0x000000000000ff00ull) << 40) | \ (((u64)(x) & 0x00000000000000ffull) << 56)) +#if defined(__LITTLE_ENDIAN) && (__BYTE_ORDER == __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) + +#define __constant_le16_to_cpu(x) (x) +#define __constant_le32_to_cpu(x) (x) +#define __constant_le64_to_cpu(x) (x) + +#define __constant_cpu_to_le16(x) (x) +#define __constant_cpu_to_le32(x) (x) +#define __constant_cpu_to_le64(x) (x) + +#elif defined(__BIG_ENDIAN) && (__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) __ntfs_bswap_constant_16((u16)(x)) #define __constant_le32_to_cpu(x) __ntfs_bswap_constant_32((u32)(x)) #define __constant_le64_to_cpu(x) __ntfs_bswap_constant_64((u64)(x)) @@ -121,7 +126,7 @@ #else -#error "You must define __BYTE_ORDER to be __LITTLE_ENDIAN or __BIG_ENDIAN" +#error "You must define __BYTE_ORDER to be __LITTLE_ENDIAN or __BIG_ENDIAN." #endif