diff options
author | Theodore Ts'o <tytso@mit.edu> | 2001-02-20 16:28:40 +0000 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2001-02-20 16:28:40 +0000 |
commit | 9ec53cf4f32cc65e91a9c71651f05a6d872a7088 (patch) | |
tree | d7770d5e8a5fe7aa7d33f80a6d79f995fa3c087e /lib/ext2fs/bitops.h | |
parent | 93345d1588606ccc558406202bff8f86360ab03f (diff) | |
download | e2fsprogs-9ec53cf4f32cc65e91a9c71651f05a6d872a7088.tar.gz |
ChangeLog, Makefile.in, bitops.h, tst_byteswap.c:
bitops.h (ext2fs_swab16, ext2fs_swab32): Add i386 assembly inline
functions.
tst_byteswap.c: New function to test the byteswap functions. Add to
regression test suite.
Diffstat (limited to 'lib/ext2fs/bitops.h')
-rw-r--r-- | lib/ext2fs/bitops.h | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/lib/ext2fs/bitops.h b/lib/ext2fs/bitops.h index 6ab77819..f91f5645 100644 --- a/lib/ext2fs/bitops.h +++ b/lib/ext2fs/bitops.h @@ -109,7 +109,8 @@ extern void ext2fs_set_bitmap_padding(ext2fs_generic_bitmap map); defined(__i586__))) #define _EXT2_HAVE_ASM_BITOPS_ - +#define _EXT2_HAVE_ASM_SWAB_ + /* * These are done by inline assembly for speed reasons..... * @@ -155,6 +156,28 @@ _INLINE_ int ext2fs_test_bit(int nr, const void * addr) return oldbit; } +_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; +} + #undef EXT2FS_ADDR #endif /* i386 */ @@ -314,7 +337,7 @@ _INLINE_ int ext2fs_test_bit(int nr, const void *addr) #endif /* __sparc__ */ -#ifndef _EXT2_HAVE_ASM_SWAB +#ifndef _EXT2_HAVE_ASM_SWAB_ _INLINE_ __u16 ext2fs_swab16(__u16 val) { |