[v2,2/9] eal: use rtm and xtest intrinsics when compiling with msvc

Message ID 1680638847-26430-3-git-send-email-roretzla@linux.microsoft.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series msvc integration changes |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Tyler Retzlaff April 4, 2023, 8:07 p.m. UTC
  Inline assembly is not supported for msvc x64 instead use _xbegin,
_xend, _xabort and _xtest intrinsics.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 lib/eal/x86/include/rte_rtm.h | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
  

Patch

diff --git a/lib/eal/x86/include/rte_rtm.h b/lib/eal/x86/include/rte_rtm.h
index 36bf498..26672cb 100644
--- a/lib/eal/x86/include/rte_rtm.h
+++ b/lib/eal/x86/include/rte_rtm.h
@@ -5,6 +5,9 @@ 
 #ifndef _RTE_RTM_H_
 #define _RTE_RTM_H_ 1
 
+#ifdef RTE_TOOLCHAIN_MSVC
+#include <immintrin.h>
+#endif
 
 /* Official RTM intrinsics interface matching gcc/icc, but works
    on older gcc compatible compilers and binutils. */
@@ -28,31 +31,47 @@ 
 static __rte_always_inline
 unsigned int rte_xbegin(void)
 {
+#ifndef RTE_TOOLCHAIN_MSVC
 	unsigned int ret = RTE_XBEGIN_STARTED;
 
 	asm volatile(".byte 0xc7,0xf8 ; .long 0" : "+a" (ret) :: "memory");
 	return ret;
+#else
+	return _xbegin();
+#endif
 }
 
 static __rte_always_inline
 void rte_xend(void)
 {
+#ifndef RTE_TOOLCHAIN_MSVC
 	 asm volatile(".byte 0x0f,0x01,0xd5" ::: "memory");
+#else
+	_xend();
+#endif
 }
 
 /* not an inline function to workaround a clang bug with -O0 */
+#ifndef RTE_TOOLCHAIN_MSVC
 #define rte_xabort(status) do { \
 	asm volatile(".byte 0xc6,0xf8,%P0" :: "i" (status) : "memory"); \
 } while (0)
+#else
+#define rte_xabort(status) _xabort(status)
+#endif
 
 static __rte_always_inline
 int rte_xtest(void)
 {
+#ifndef RTE_TOOLCHAIN_MSVC
 	unsigned char out;
 
 	asm volatile(".byte 0x0f,0x01,0xd6 ; setnz %0" :
 		"=r" (out) :: "memory");
 	return out;
+#else
+	return _xtest();
+#endif
 }
 
 #ifdef __cplusplus