From: Theodore Ts'o Date: Sat, 24 May 2008 01:35:50 +0000 (-0400) Subject: Re-enable byte-swapping functions for use by journal checksums X-Git-Tag: v1.41-WIP-0617~24 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=69fbde418b1a197bf793e51b12e23f528b967093;p=thirdparty%2Fe2fsprogs.git Re-enable byte-swapping functions for use by journal checksums Signed-off-by: "Theodore Ts'o" --- diff --git a/lib/ext2fs/bitops.h b/lib/ext2fs/bitops.h index 00bc4ab01..391b8cdb2 100644 --- a/lib/ext2fs/bitops.h +++ b/lib/ext2fs/bitops.h @@ -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) {