[v11,07/16] eal: use byte swap intrinsics
Checks
Commit Message
Inline assembly is not supported for MSVC x64 instead expand
use _byteswap_u{ushort,ulong,uint64} intrinsics instead.
Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
Acked-by: Morten Brørup <mb@smartsharesystems.com>
---
lib/eal/include/generic/rte_byteorder.h | 11 +++++++++++
lib/eal/x86/include/rte_byteorder.h | 4 ++++
2 files changed, 15 insertions(+)
Comments
On Fri, Aug 11, 2023 at 9:21 PM Tyler Retzlaff
<roretzla@linux.microsoft.com> wrote:
>
> Inline assembly is not supported for MSVC x64 instead expand
> use _byteswap_u{ushort,ulong,uint64} intrinsics instead.
>
> Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
> Acked-by: Morten Brørup <mb@smartsharesystems.com>
For the record, I rebased this patch on top of
https://patchwork.dpdk.org/project/dpdk/patch/20230824093356.1476716-1-david.marchand@redhat.com/
and moved blocks under a single #ifdef RTE_FORCE_INTRINSICS.
@@ -234,6 +234,7 @@
#endif /* __DOXYGEN__ */
#ifdef RTE_FORCE_INTRINSICS
+#ifndef RTE_TOOLCHAIN_MSVC
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
#define rte_bswap16(x) __builtin_bswap16(x)
#endif
@@ -241,6 +242,16 @@
#define rte_bswap32(x) __builtin_bswap32(x)
#define rte_bswap64(x) __builtin_bswap64(x)
+#else
+/*
+ * note: we may want to #pragma intrsinsic(_byteswap_u{short,long,uint64})
+ */
+#define rte_bswap16(x) _byteswap_ushort(x)
+
+#define rte_bswap32(x) _byteswap_ulong(x)
+
+#define rte_bswap64(x) _byteswap_uint64(x)
+#endif
#endif
@@ -18,6 +18,7 @@
#define RTE_BYTE_ORDER RTE_LITTLE_ENDIAN
#endif
+#ifndef RTE_TOOLCHAIN_MSVC
/*
* An architecture-optimized byte swap for a 16-bit value.
*
@@ -69,6 +70,7 @@ static inline uint32_t rte_arch_bswap32(uint32_t _x)
rte_arch_bswap16(x)))
#endif
#endif
+#endif
#define rte_cpu_to_le_16(x) (x)
#define rte_cpu_to_le_32(x) (x)
@@ -86,11 +88,13 @@ static inline uint32_t rte_arch_bswap32(uint32_t _x)
#define rte_be_to_cpu_32(x) rte_bswap32(x)
#define rte_be_to_cpu_64(x) rte_bswap64(x)
+#ifndef RTE_TOOLCHAIN_MSVC
#ifdef RTE_ARCH_I686
#include "rte_byteorder_32.h"
#else
#include "rte_byteorder_64.h"
#endif
+#endif
#ifdef __cplusplus
}