From 89edff3bf08456640186fe47030c282fefadafd6 Mon Sep 17 00:00:00 2001 From: Avik Sil Date: Wed, 24 Jul 2013 14:26:34 +0530 Subject: Use __builtin_bswap routines for endianness swapping Signed-off-by: Avik Sil Signed-off-by: Nikunj A Dadhania Acked-by: Thomas Huth --- include/byteorder.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/byteorder.h b/include/byteorder.h index 29910af..3ad4dd1 100644 --- a/include/byteorder.h +++ b/include/byteorder.h @@ -17,22 +17,24 @@ #ifndef BYTEORDER_H #define BYTEORDER_H +#include + static inline uint16_t bswap_16 (uint16_t x) { - return ((x&0xff00) >> 8) | ((x&0xff) << 8); + return __builtin_bswap16(x); } static inline uint32_t bswap_32 (uint32_t x) { - return bswap_16(x >> 16) | (bswap_16(x) << 16); + return __builtin_bswap32(x); } static inline uint64_t bswap_64 (uint64_t x) { - return (uint64_t) bswap_32(x >> 32) | (uint64_t) bswap_32(x) << 32; + return __builtin_bswap64(x); } -- cgit v1.1