Whamcloud - gitweb
LU-4674 endianness: Fix __{LITTLE,BIG}_ENDIAN macro usage
[fs/lustre-release.git] / lustre / include / liblustre.h
index e0ba5be..4929dd9 100644 (file)
@@ -46,6 +46,7 @@
  * @{
  */
 #include <fcntl.h>
+#include <endian.h>
 #include <sys/queue.h>
 
 #ifdef __KERNEL__
@@ -89,7 +90,7 @@ void *inter_module_get(char *arg);
 
 static __inline__ int ext2_set_bit(int nr, void *addr)
 {
-#ifdef __BIG_ENDIAN
+#if __BYTE_ORDER == __BIG_ENDIAN
        return set_bit((nr ^ ((BITS_PER_LONG-1) & ~0x7)), addr);
 #else
        return set_bit(nr, addr);
@@ -98,7 +99,7 @@ static __inline__ int ext2_set_bit(int nr, void *addr)
 
 static inline int ext2_clear_bit(int nr, void *addr)
 {
-#ifdef __BIG_ENDIAN
+#if __BYTE_ORDER == __BIG_ENDIAN
        return clear_bit((nr ^ ((BITS_PER_LONG-1) & ~0x7)), addr);
 #else
        return clear_bit(nr, addr);
@@ -107,7 +108,7 @@ static inline int ext2_clear_bit(int nr, void *addr)
 
 static __inline__ int ext2_test_bit(int nr, void *addr)
 {
-#ifdef __BIG_ENDIAN
+#if __BYTE_ORDER == __BIG_ENDIAN
         __const__ unsigned char *tmp = (__const__ unsigned char *) addr;
         return (tmp[nr >> 3] >> (nr & 7)) & 1;
 #else