btrfs-progs: kernel-lib: bitops: Fix big endian compilation

Replaced bswap with _ variants bswap_32 etc. While it's a glibc
extension, all of the popular libc implementations (glibc, uClibc, musl,
BIONIC) seem to support it.

Added static inline to two functions to match little endian variants. This
fixes a linking error experienced when compiling on gcc 7.3.0 with LTO,
possibly a bug that was fixed later.

Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Rosen Penev <rosenp@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Rosen Penev 2018-11-05 11:06:41 -08:00 committed by David Sterba
parent d72d913291
commit ed570e2df3
1 changed files with 4 additions and 4 deletions

View File

@ -178,9 +178,9 @@ static inline unsigned long find_next_zero_bit(const unsigned long *addr,
static inline unsigned long ext2_swab(const unsigned long y) static inline unsigned long ext2_swab(const unsigned long y)
{ {
#if BITS_PER_LONG == 64 #if BITS_PER_LONG == 64
return (unsigned long) bswap64((u64) y); return (unsigned long) bswap_64((u64) y);
#elif BITS_PER_LONG == 32 #elif BITS_PER_LONG == 32
return (unsigned long) bswap32((u32) y); return (unsigned long) bswap_32((u32) y);
#else #else
#error BITS_PER_LONG not defined #error BITS_PER_LONG not defined
#endif #endif
@ -218,14 +218,14 @@ static inline unsigned long _find_next_bit_le(const unsigned long *addr1,
return min(start + __ffs(ext2_swab(tmp)), nbits); return min(start + __ffs(ext2_swab(tmp)), nbits);
} }
unsigned long find_next_zero_bit_le(const void *addr, unsigned long size, static inline unsigned long find_next_zero_bit_le(const void *addr, unsigned long size,
unsigned long offset) unsigned long offset)
{ {
return _find_next_bit_le(addr, NULL, size, offset, ~0UL); return _find_next_bit_le(addr, NULL, size, offset, ~0UL);
} }
unsigned long find_next_bit_le(const void *addr, unsigned long size, static inline unsigned long find_next_bit_le(const void *addr, unsigned long size,
unsigned long offset) unsigned long offset)
{ {
return _find_next_bit_le(addr, NULL, size, offset, 0UL); return _find_next_bit_le(addr, NULL, size, offset, 0UL);