Merge tag 'byteswap-for-linus-20121219' of git://git.infradead.org/users/dwmw2/byteswap
Pull preparatory gcc intrisics bswap patch from David Woodhouse:
"This single patch is effectively a no-op for now. It enables
architectures to opt in to using GCC's __builtin_bswapXX() intrinsics
for byteswapping, and if we merge this now then the architecture
maintainers can enable it for their arch during the next cycle without
dependency issues.
It's worth making it a par-arch opt-in, because although in *theory*
the compiler should never do worse than hand-coded assembler (and of
course it also ought to do a lot better on platforms like Atom and
PowerPC which have load-and-swap or store-and-swap instructions), that
isn't always the case. See
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46453
for example."
* tag 'byteswap-for-linus-20121219' of git://git.infradead.org/users/dwmw2/byteswap:
byteorder: allow arch to opt to use GCC intrinsics for byteswapping
This commit is contained in:
@@ -45,7 +45,9 @@
|
||||
|
||||
static inline __attribute_const__ __u16 __fswab16(__u16 val)
|
||||
{
|
||||
#ifdef __arch_swab16
|
||||
#ifdef __HAVE_BUILTIN_BSWAP16__
|
||||
return __builtin_bswap16(val);
|
||||
#elif defined (__arch_swab16)
|
||||
return __arch_swab16(val);
|
||||
#else
|
||||
return ___constant_swab16(val);
|
||||
@@ -54,7 +56,9 @@ static inline __attribute_const__ __u16 __fswab16(__u16 val)
|
||||
|
||||
static inline __attribute_const__ __u32 __fswab32(__u32 val)
|
||||
{
|
||||
#ifdef __arch_swab32
|
||||
#ifdef __HAVE_BUILTIN_BSWAP32__
|
||||
return __builtin_bswap32(val);
|
||||
#elif defined(__arch_swab32)
|
||||
return __arch_swab32(val);
|
||||
#else
|
||||
return ___constant_swab32(val);
|
||||
@@ -63,7 +67,9 @@ static inline __attribute_const__ __u32 __fswab32(__u32 val)
|
||||
|
||||
static inline __attribute_const__ __u64 __fswab64(__u64 val)
|
||||
{
|
||||
#ifdef __arch_swab64
|
||||
#ifdef __HAVE_BUILTIN_BSWAP64__
|
||||
return __builtin_bswap64(val);
|
||||
#elif defined (__arch_swab64)
|
||||
return __arch_swab64(val);
|
||||
#elif defined(__SWAB_64_THRU_32__)
|
||||
__u32 h = val >> 32;
|
||||
|
||||
Reference in New Issue
Block a user