Whamcloud - gitweb
Branch b_release_1_8_0
authoryangsheng <yangsheng>
Thu, 5 Feb 2009 07:49:49 +0000 (07:49 +0000)
committeryangsheng <yangsheng>
Thu, 5 Feb 2009 07:49:49 +0000 (07:49 +0000)
b=17459

i=adilger, bobijam

Fixed ext2_{...}_bit() works well in BIGENDIAN.

lustre/include/liblustre.h

index 0961cd6..cf6cb1a 100644 (file)
@@ -210,17 +210,30 @@ typedef int (write_proc_t)(struct file *file, const char *buffer,
 
 static __inline__ int ext2_set_bit(int nr, void *addr)
 {
+#ifdef __BIG_ENDIAN
+        return set_bit((nr ^ ((BITS_PER_LONG-1) & ~0x7)), addr);
+#else
         return set_bit(nr, addr);
+#endif
 }
 
 static __inline__ int ext2_clear_bit(int nr, void *addr)
 {
+#ifdef __BIG_ENDIAN
+        return clear_bit((nr ^ ((BITS_PER_LONG-1) & ~0x7)), addr);
+#else
         return clear_bit(nr, addr);
+#endif
 }
 
 static __inline__ int ext2_test_bit(int nr, void *addr)
 {
+#ifdef __BIG_ENDIAN
+        __const__ unsigned char *tmp = (__const__ unsigned char *) addr;
+        return (tmp[nr >> 3] >> (nr & 7)) & 1;
+#else
         return test_bit(nr, addr);
+#endif
 }
 
 /* modules */