OSDN Git Service

Re-enable byte-swapping functions for use by journal checksums
authorTheodore Ts'o <tytso@mit.edu>
Sat, 24 May 2008 01:35:50 +0000 (21:35 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Sat, 7 Jun 2008 03:38:38 +0000 (23:38 -0400)
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lib/ext2fs/bitops.h

index 00bc4ab..391b8cd 100644 (file)
@@ -274,6 +274,34 @@ _INLINE_ int ext2fs_find_next_bit_set (void * addr, int size, int offset)
 }
 #endif
 
+_INLINE_ __u32 ext2fs_swab32(__u32 val)
+{
+#ifdef EXT2FS_REQUIRE_486
+       __asm__("bswap %0" : "=r" (val) : "0" (val));
+#else
+       __asm__("xchgb %b0,%h0\n\t"     /* swap lower bytes     */
+               "rorl $16,%0\n\t"       /* swap words           */
+               "xchgb %b0,%h0"         /* swap higher bytes    */
+               :"=q" (val)
+               : "0" (val));
+#endif
+       return val;
+}
+
+_INLINE_ __u16 ext2fs_swab16(__u16 val)
+{
+       __asm__("xchgb %b0,%h0"         /* swap bytes           */ \
+               : "=q" (val) \
+               :  "0" (val)); \
+               return val;
+}
+
+_INLINE_ __u64 ext2fs_swab64(__u64 val)
+{
+       return (ext2fs_swab32(val >> 32) |
+               (((__u64)ext2fs_swab32(val & 0xFFFFFFFFUL)) << 32));
+}
+
 #undef EXT2FS_ADDR
 
 #endif /* i386 */
@@ -316,7 +344,7 @@ _INLINE_ int ext2fs_test_bit(unsigned int nr, const void * addr)
 #endif /* __mc68000__ */
 
 
-#if !defined(_EXT2_HAVE_ASM_SWAB_) && defined(WORDS_BIGENDIAN)
+#if !defined(_EXT2_HAVE_ASM_SWAB_)
 
 _INLINE_ __u16 ext2fs_swab16(__u16 val)
 {