Blame SOURCES/xfsprogs-3.2.0-bigendian.patch

564d46
[PATCH] xfsprogs: fix crc32 build on big endian
564d46
564d46
While kernelspace can test #ifdef __LITTLE_ENDIAN, this
564d46
doesn't work in userspace.  __LITTLE_ENDIAN is defined -
564d46
as is __BIG_ENDIAN.
564d46
564d46
So we build on all boxes as __LITTLE_ENDIAN, and the
564d46
self-test (thankfully!) fails on big endian boxes.
564d46
564d46
Fix this by testing __BYTE_ORDER values.
564d46
564d46
And add an else which should never be hit, but just in case...
564d46
564d46
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
564d46
Reviewed-by: Dave Chinner <dchinner@redhat.com>
564d46
---
564d46
564d46
diff --git a/libxfs/crc32.c b/libxfs/crc32.c
564d46
index 1c0d958..0f847d2 100644
564d46
--- a/libxfs/crc32.c
564d46
+++ b/libxfs/crc32.c
564d46
@@ -63,18 +63,20 @@ typedef __u32	u64;
564d46
 static inline u32
564d46
 crc32_body(u32 crc, unsigned char const *buf, size_t len, const u32 (*tab)[256])
564d46
 {
564d46
-# ifdef __LITTLE_ENDIAN
564d46
+#if __BYTE_ORDER == __LITTLE_ENDIAN
564d46
 #  define DO_CRC(x) crc = t0[(crc ^ (x)) & 255] ^ (crc >> 8)
564d46
 #  define DO_CRC4 (t3[(q) & 255] ^ t2[(q >> 8) & 255] ^ \
564d46
 		   t1[(q >> 16) & 255] ^ t0[(q >> 24) & 255])
564d46
 #  define DO_CRC8 (t7[(q) & 255] ^ t6[(q >> 8) & 255] ^ \
564d46
 		   t5[(q >> 16) & 255] ^ t4[(q >> 24) & 255])
564d46
-# else
564d46
+# elif __BYTE_ORDER == __BIG_ENDIAN
564d46
 #  define DO_CRC(x) crc = t0[((crc >> 24) ^ (x)) & 255] ^ (crc << 8)
564d46
 #  define DO_CRC4 (t0[(q) & 255] ^ t1[(q >> 8) & 255] ^ \
564d46
 		   t2[(q >> 16) & 255] ^ t3[(q >> 24) & 255])
564d46
 #  define DO_CRC8 (t4[(q) & 255] ^ t5[(q >> 8) & 255] ^ \
564d46
 		   t6[(q >> 16) & 255] ^ t7[(q >> 24) & 255])
564d46
+# else
564d46
+#  error What endian are you?
564d46
 # endif
564d46
 	const u32 *b;
564d46
 	size_t    rem_len;
564d46
564d46