X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_eal%2Fcommon%2Finclude%2Frte_byteorder.h;h=8451440163c9f77a38650abfd446e621af9009bb;hb=12204589517e06230e24e0f23396222f2929bd77;hp=82058e954f0f7aef6af855e481199632c0484742;hpb=1c1d4d7a923d4804f1926fc5264f9ecdd8977b04;p=dpdk.git diff --git a/lib/librte_eal/common/include/rte_byteorder.h b/lib/librte_eal/common/include/rte_byteorder.h index 82058e954f..8451440163 100644 --- a/lib/librte_eal/common/include/rte_byteorder.h +++ b/lib/librte_eal/common/include/rte_byteorder.h @@ -1,7 +1,7 @@ /*- * BSD LICENSE * - * Copyright(c) 2010-2013 Intel Corporation. All rights reserved. + * Copyright(c) 2010-2014 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -152,6 +152,7 @@ static inline uint64_t rte_arch_bswap64(uint64_t x) #endif /* RTE_ARCH_X86_64 */ +#ifndef RTE_FORCE_INTRINSICS /** * Swap bytes in a 16-bit value. */ @@ -159,7 +160,6 @@ static inline uint64_t rte_arch_bswap64(uint64_t x) rte_constant_bswap16(x) : \ rte_arch_bswap16(x))) -#ifndef RTE_FORCE_INTRINSICS /** * Swap bytes in a 32-bit value. */ @@ -176,7 +176,17 @@ static inline uint64_t rte_arch_bswap64(uint64_t x) #else -/* __builtin_bswap16 is only available gcc 4.8 and upwards */ +/** + * Swap bytes in a 16-bit value. + * __builtin_bswap16 is only available gcc 4.8 and upwards + */ +#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) +#define rte_bswap16(x) __builtin_bswap16(x) +#else +#define rte_bswap16(x) ((uint16_t)(__builtin_constant_p(x) ? \ + rte_constant_bswap16(x) : \ + rte_arch_bswap16(x))) +#endif /** * Swap bytes in a 32-bit value.