Whamcloud - gitweb
Branch b1_6
authoryangsheng <yangsheng>
Wed, 17 Dec 2008 06:03:00 +0000 (06:03 +0000)
committeryangsheng <yangsheng>
Wed, 17 Dec 2008 06:03:00 +0000 (06:03 +0000)
b=17459
i=adilger, bobijam

Make change to ext2_* api for BIG-ENDIAN environment.

lustre/include/liblustre.h

index dc1e481..c3f9b53 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 */