diff mbox series

[07/38] lib/blkid: remove 32-bit x86 byteswap assembly

Message ID 20230121203230.27624-8-ebiggers@kernel.org
State Accepted
Headers show
Series e2fsprogs: misc fixes, and add a GitHub Actions file | expand

Commit Message

Eric Biggers Jan. 21, 2023, 8:31 p.m. UTC
From: Eric Biggers <ebiggers@google.com>

libblkid contains 32-bit x86 assembly language implementations of 16-bit
and 32-bit byteswaps.  However, modern compilers can easily generate the
bswap instruction automatically from the corresponding C expression.
And no one ever bothered to add assembly for x86_64 or other
architectures, anyway.  So let's just remove this outdated code, which
was maybe useful in the 90s, but is no longer useful.

Signed-off-by: Eric Biggers <ebiggers@google.com>
---
 lib/blkid/probe.h | 43 -------------------------------------------
 1 file changed, 43 deletions(-)

Comments

Andreas Dilger Jan. 24, 2023, 6:21 p.m. UTC | #1
On Jan 21, 2023, at 1:31 PM, Eric Biggers <ebiggers@kernel.org> wrote:
> 
> From: Eric Biggers <ebiggers@google.com>
> 
> libblkid contains 32-bit x86 assembly language implementations of 16-bit
> and 32-bit byteswaps.  However, modern compilers can easily generate the
> bswap instruction automatically from the corresponding C expression.
> And no one ever bothered to add assembly for x86_64 or other
> architectures, anyway.  So let's just remove this outdated code, which
> was maybe useful in the 90s, but is no longer useful.

I'm not sure what Ted thinks about this, but it might be time to remove
the libblkid implementation in e2fsprogs, and instead depend on the
newer version in util-linux?  However, removing it from e2fsprogs
would add an external dependency on util-linux for non-linux platforms,
though AFAIK it should still be possible to build e2fsprogs without it.

That said, I think the current patch looks fine, and you can add:

Reviewed-by: Andreas Dilger <adilger@dilger.ca>

Cheers, Andreas

> 
> Signed-off-by: Eric Biggers <ebiggers@google.com>
> ---
> lib/blkid/probe.h | 43 -------------------------------------------
> 1 file changed, 43 deletions(-)
> 
> diff --git a/lib/blkid/probe.h b/lib/blkid/probe.h
> index dea4081d0..063a5b5c0 100644
> --- a/lib/blkid/probe.h
> +++ b/lib/blkid/probe.h
> @@ -814,46 +814,6 @@ struct exfat_entry_label {
> #define _INLINE_ static inline
> #endif
> 
> -static __u16 blkid_swab16(__u16 val);
> -static __u32 blkid_swab32(__u32 val);
> -static __u64 blkid_swab64(__u64 val);
> -
> -#if ((defined __GNUC__) && \
> -     (defined(__i386__) || defined(__i486__) || defined(__i586__)))
> -
> -#define _BLKID_HAVE_ASM_BITOPS_
> -
> -_INLINE_ __u32 blkid_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 blkid_swab16(__u16 val)
> -{
> -	__asm__("xchgb %b0,%h0"		/* swap bytes		*/ \
> -		: "=q" (val) \
> -		:  "0" (val)); \
> -		return val;
> -}
> -
> -_INLINE_ __u64 blkid_swab64(__u64 val)
> -{
> -	return (blkid_swab32(val >> 32) |
> -		(((__u64) blkid_swab32(val & 0xFFFFFFFFUL)) << 32));
> -}
> -#endif
> -
> -#if !defined(_BLKID_HAVE_ASM_BITOPS_)
> -
> _INLINE_  __u16 blkid_swab16(__u16 val)
> {
> 	return (val >> 8) | (val << 8);
> @@ -870,9 +830,6 @@ _INLINE_ __u64 blkid_swab64(__u64 val)
> 	return (blkid_swab32(val >> 32) |
> 		(((__u64) blkid_swab32(val & 0xFFFFFFFFUL)) << 32));
> }
> -#endif
> -
> -
> 
> #ifdef WORDS_BIGENDIAN
> #define blkid_le16(x) blkid_swab16(x)
> --
> 2.39.0
> 


Cheers, Andreas
diff mbox series

Patch

diff --git a/lib/blkid/probe.h b/lib/blkid/probe.h
index dea4081d0..063a5b5c0 100644
--- a/lib/blkid/probe.h
+++ b/lib/blkid/probe.h
@@ -814,46 +814,6 @@  struct exfat_entry_label {
 #define _INLINE_ static inline
 #endif
 
-static __u16 blkid_swab16(__u16 val);
-static __u32 blkid_swab32(__u32 val);
-static __u64 blkid_swab64(__u64 val);
-
-#if ((defined __GNUC__) && \
-     (defined(__i386__) || defined(__i486__) || defined(__i586__)))
-
-#define _BLKID_HAVE_ASM_BITOPS_
-
-_INLINE_ __u32 blkid_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 blkid_swab16(__u16 val)
-{
-	__asm__("xchgb %b0,%h0"		/* swap bytes		*/ \
-		: "=q" (val) \
-		:  "0" (val)); \
-		return val;
-}
-
-_INLINE_ __u64 blkid_swab64(__u64 val)
-{
-	return (blkid_swab32(val >> 32) |
-		(((__u64) blkid_swab32(val & 0xFFFFFFFFUL)) << 32));
-}
-#endif
-
-#if !defined(_BLKID_HAVE_ASM_BITOPS_)
-
 _INLINE_  __u16 blkid_swab16(__u16 val)
 {
 	return (val >> 8) | (val << 8);
@@ -870,9 +830,6 @@  _INLINE_ __u64 blkid_swab64(__u64 val)
 	return (blkid_swab32(val >> 32) |
 		(((__u64) blkid_swab32(val & 0xFFFFFFFFUL)) << 32));
 }
-#endif
-
-
 
 #ifdef WORDS_BIGENDIAN
 #define blkid_le16(x) blkid_swab16(x)