Re-enable byte-swapping functions for use by journal checksums

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
bitmap-optimize
Theodore Ts'o 2008-05-23 21:35:50 -04:00
parent 2ea504bd64
commit 69fbde418b
1 changed files with 29 additions and 1 deletions

View 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)
{