eal: provide per lcore macros for MSVC

Message ID 1689024585-17303-2-git-send-email-roretzla@linux.microsoft.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series eal: provide per lcore macros for MSVC |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/github-robot: build success github build: passed
ci/intel-Functional success Functional PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-aarch-unit-testing success Testing PASS
ci/iol-unit-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-intel-Functional success Functional Testing PASS

Commit Message

Tyler Retzlaff July 10, 2023, 9:29 p.m. UTC
  Provide per lcore macros that use __declspec(thread) and uses C23
typeof.

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

Comments

Thomas Monjalon July 11, 2023, 6:25 a.m. UTC | #1
10/07/2023 23:29, Tyler Retzlaff:
> Provide per lcore macros that use __declspec(thread) and uses C23
> typeof.
> 
> Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
> ---
> +#ifndef RTE_TOOLCHAIN_MSVC
>  /**
>   * Macro to define a per lcore variable "var" of type "type", don't
>   * use keywords like "static" or "volatile" in type, just prefix the
> @@ -37,6 +38,13 @@
>   */
>  #define RTE_DECLARE_PER_LCORE(type, name)			\
>  	extern __thread __typeof__(type) per_lcore_##name
> +#else
> +#define RTE_DEFINE_PER_LCORE(type, name)			\
> +	__declspec(thread) typeof(type) per_lcore_##name
> +
> +#define RTE_DECLARE_PER_LCORE(type, name)			\
> +	extern __declspec(thread) typeof(type) per_lcore_##name
> +#endif

It would be better (here and in other MSVC patches)
to have the opposite logic: start with MSVC implementation.

#ifdef MSVC
	MSVC implementation
#else
	POSIX implementation
#endif
  

Patch

diff --git a/lib/eal/include/rte_per_lcore.h b/lib/eal/include/rte_per_lcore.h
index eaedf0c..4ef8905 100644
--- a/lib/eal/include/rte_per_lcore.h
+++ b/lib/eal/include/rte_per_lcore.h
@@ -24,6 +24,7 @@ 
 
 #include <pthread.h>
 
+#ifndef RTE_TOOLCHAIN_MSVC
 /**
  * Macro to define a per lcore variable "var" of type "type", don't
  * use keywords like "static" or "volatile" in type, just prefix the
@@ -37,6 +38,13 @@ 
  */
 #define RTE_DECLARE_PER_LCORE(type, name)			\
 	extern __thread __typeof__(type) per_lcore_##name
+#else
+#define RTE_DEFINE_PER_LCORE(type, name)			\
+	__declspec(thread) typeof(type) per_lcore_##name
+
+#define RTE_DECLARE_PER_LCORE(type, name)			\
+	extern __declspec(thread) typeof(type) per_lcore_##name
+#endif
 
 /**
  * Read/write the per-lcore variable value