/*-
* 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
#endif /* RTE_ARCH_X86_64 */
+#ifndef RTE_FORCE_INTRINSICS
/**
* Swap bytes in a 16-bit value.
*/
rte_constant_bswap16(x) : \
rte_arch_bswap16(x)))
-#ifndef RTE_FORCE_INTRINSICS
/**
* Swap bytes in a 32-bit value.
*/
#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.