eal: provide per lcore macros for MSVC
Checks
Commit Message
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
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
@@ -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