diff options
author | Avik Sil <aviksil@linux.vnet.ibm.com> | 2013-07-24 14:26:34 +0530 |
---|---|---|
committer | Nikunj A Dadhania <nikunj@linux.vnet.ibm.com> | 2013-07-24 14:46:22 +0530 |
commit | 89edff3bf08456640186fe47030c282fefadafd6 (patch) | |
tree | 2df6e0735697a6070e699e1f533dbd039156dbf1 /include | |
parent | a4e14d308fb321de4bbd7e30458b3b128db3c4db (diff) | |
download | SLOF-89edff3bf08456640186fe47030c282fefadafd6.zip SLOF-89edff3bf08456640186fe47030c282fefadafd6.tar.gz SLOF-89edff3bf08456640186fe47030c282fefadafd6.tar.bz2 |
Use __builtin_bswap routines for endianness swapping
Signed-off-by: Avik Sil <aviksil@linux.vnet.ibm.com>
Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
Acked-by: Thomas Huth <thuth@de.ibm.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/byteorder.h | 8 |
1 files changed, 5 insertions, 3 deletions
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 <stdint.h> + 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); } |