DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] provide Windows/MSVC lcore macros
@ 2023-07-10 21:29 Tyler Retzlaff
  2023-07-10 21:29 ` [PATCH] eal: provide per lcore macros for MSVC Tyler Retzlaff
  2023-07-11 15:52 ` [PATCH v2] provide Windows/MSVC lcore macros Tyler Retzlaff
  0 siblings, 2 replies; 11+ messages in thread
From: Tyler Retzlaff @ 2023-07-10 21:29 UTC (permalink / raw)
  To: dev; +Cc: david.marchand, thomas, Tyler Retzlaff

Provide MSVC compatible macros RTE_DEFINE_PER_LCORE and
RTE_DECLARE_PER_LCORE that expand appropriately for Windows/MSVC

NOTICE:

It is intentional that devtools/checkpatches.pl generates an error
about parenthesis to allow comparison with clang/gcc versions of
these macros which also do not have the parenthesis.

```
ERROR:COMPLEX_MACRO: Macros with complex values should be enclosed in parenthesis
#31: FILE: lib/eal/include/rte_per_lcore.h:42:
+#define RTE_DEFINE_PER_LCORE(type, name)                       \
+       __declspec(thread) typeof(type) per_lcore_##name

ERROR:COMPLEX_MACRO: Macros with complex values should be enclosed in parenthesis
#34: FILE: lib/eal/include/rte_per_lcore.h:45:
+#define RTE_DECLARE_PER_LCORE(type, name)                      \
+       extern __declspec(thread) typeof(type) per_lcore_##name
```

Tyler Retzlaff (1):
  eal: provide per lcore macros for MSVC

 lib/eal/include/rte_per_lcore.h | 8 ++++++++
 1 file changed, 8 insertions(+)

-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH] eal: provide per lcore macros for MSVC
  2023-07-10 21:29 [PATCH] provide Windows/MSVC lcore macros Tyler Retzlaff
@ 2023-07-10 21:29 ` Tyler Retzlaff
  2023-07-11  6:25   ` Thomas Monjalon
  2023-07-11 15:52 ` [PATCH v2] provide Windows/MSVC lcore macros Tyler Retzlaff
  1 sibling, 1 reply; 11+ messages in thread
From: Tyler Retzlaff @ 2023-07-10 21:29 UTC (permalink / raw)
  To: dev; +Cc: david.marchand, thomas, Tyler Retzlaff

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(+)

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
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] eal: provide per lcore macros for MSVC
  2023-07-10 21:29 ` [PATCH] eal: provide per lcore macros for MSVC Tyler Retzlaff
@ 2023-07-11  6:25   ` Thomas Monjalon
  0 siblings, 0 replies; 11+ messages in thread
From: Thomas Monjalon @ 2023-07-11  6:25 UTC (permalink / raw)
  To: dev, Tyler Retzlaff; +Cc: david.marchand

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



^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v2] provide Windows/MSVC lcore macros
  2023-07-10 21:29 [PATCH] provide Windows/MSVC lcore macros Tyler Retzlaff
  2023-07-10 21:29 ` [PATCH] eal: provide per lcore macros for MSVC Tyler Retzlaff
@ 2023-07-11 15:52 ` Tyler Retzlaff
  2023-07-11 15:52   ` [PATCH v2] eal: provide per lcore macros for MSVC Tyler Retzlaff
  1 sibling, 1 reply; 11+ messages in thread
From: Tyler Retzlaff @ 2023-07-11 15:52 UTC (permalink / raw)
  To: dev; +Cc: david.marchand, thomas, Tyler Retzlaff

Provide MSVC compatible macros RTE_DEFINE_PER_LCORE and
RTE_DECLARE_PER_LCORE that expand appropriately for Windows/MSVC

NOTICE:

It is intentional that devtools/checkpatches.pl generates an error
about parenthesis to allow comparison with clang/gcc versions of
these macros which also do not have the parenthesis.

```
ERROR:COMPLEX_MACRO: Macros with complex values should be enclosed in parenthesis
#31: FILE: lib/eal/include/rte_per_lcore.h:42:
+#define RTE_DEFINE_PER_LCORE(type, name)                       \
+       __declspec(thread) typeof(type) per_lcore_##name

ERROR:COMPLEX_MACRO: Macros with complex values should be enclosed in parenthesis
#34: FILE: lib/eal/include/rte_per_lcore.h:45:
+#define RTE_DECLARE_PER_LCORE(type, name)                      \
+       extern __declspec(thread) typeof(type) per_lcore_##name
```

v2:
    * invert macro test for msvc #ifndef -> #ifdef

Tyler Retzlaff (1):
  eal: provide per lcore macros for MSVC

 lib/eal/include/rte_per_lcore.h | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v2] eal: provide per lcore macros for MSVC
  2023-07-11 15:52 ` [PATCH v2] provide Windows/MSVC lcore macros Tyler Retzlaff
@ 2023-07-11 15:52   ` Tyler Retzlaff
  2023-07-11 16:09     ` Stephen Hemminger
  2023-08-31 11:57     ` Thomas Monjalon
  0 siblings, 2 replies; 11+ messages in thread
From: Tyler Retzlaff @ 2023-07-11 15:52 UTC (permalink / raw)
  To: dev; +Cc: david.marchand, thomas, Tyler Retzlaff

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 | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/lib/eal/include/rte_per_lcore.h b/lib/eal/include/rte_per_lcore.h
index eaedf0c..2b846f9 100644
--- a/lib/eal/include/rte_per_lcore.h
+++ b/lib/eal/include/rte_per_lcore.h
@@ -24,19 +24,27 @@
 
 #include <pthread.h>
 
+#ifdef 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
  * whole macro.
  */
 #define RTE_DEFINE_PER_LCORE(type, name)			\
-	__thread __typeof__(type) per_lcore_##name
+	__declspec(thread) typeof(type) per_lcore_##name
 
 /**
  * Macro to declare an extern per lcore variable "var" of type "type"
  */
 #define RTE_DECLARE_PER_LCORE(type, name)			\
+	extern __declspec(thread) typeof(type) per_lcore_##name
+#else
+#define RTE_DEFINE_PER_LCORE(type, name)			\
+	__thread __typeof__(type) per_lcore_##name
+
+#define RTE_DECLARE_PER_LCORE(type, name)			\
 	extern __thread __typeof__(type) per_lcore_##name
+#endif
 
 /**
  * Read/write the per-lcore variable value
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2] eal: provide per lcore macros for MSVC
  2023-07-11 15:52   ` [PATCH v2] eal: provide per lcore macros for MSVC Tyler Retzlaff
@ 2023-07-11 16:09     ` Stephen Hemminger
  2023-08-25  8:49       ` David Marchand
  2023-08-31 11:57     ` Thomas Monjalon
  1 sibling, 1 reply; 11+ messages in thread
From: Stephen Hemminger @ 2023-07-11 16:09 UTC (permalink / raw)
  To: Tyler Retzlaff; +Cc: dev, david.marchand, thomas

On Tue, 11 Jul 2023 08:52:27 -0700
Tyler Retzlaff <roretzla@linux.microsoft.com> wrote:

> Provide per lcore macros that use __declspec(thread) and uses C23
> typeof.
> 
> Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
> ---

Acked-by: Stephen Hemminger <stephen@networkplumber.org>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2] eal: provide per lcore macros for MSVC
  2023-07-11 16:09     ` Stephen Hemminger
@ 2023-08-25  8:49       ` David Marchand
  0 siblings, 0 replies; 11+ messages in thread
From: David Marchand @ 2023-08-25  8:49 UTC (permalink / raw)
  To: Tyler Retzlaff; +Cc: dev, thomas, Stephen Hemminger

On Tue, Jul 11, 2023 at 6:10 PM Stephen Hemminger
<stephen@networkplumber.org> wrote:
>
> On Tue, 11 Jul 2023 08:52:27 -0700
> Tyler Retzlaff <roretzla@linux.microsoft.com> wrote:
>
> > Provide per lcore macros that use __declspec(thread) and uses C23
> > typeof.
> >
> > Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
> Acked-by: Stephen Hemminger <stephen@networkplumber.org>

Applied, thanks.

-- 
David Marchand


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2] eal: provide per lcore macros for MSVC
  2023-07-11 15:52   ` [PATCH v2] eal: provide per lcore macros for MSVC Tyler Retzlaff
  2023-07-11 16:09     ` Stephen Hemminger
@ 2023-08-31 11:57     ` Thomas Monjalon
  2023-08-31 23:08       ` Tyler Retzlaff
  1 sibling, 1 reply; 11+ messages in thread
From: Thomas Monjalon @ 2023-08-31 11:57 UTC (permalink / raw)
  To: Tyler Retzlaff; +Cc: dev, david.marchand, Stephen Hemminger

11/07/2023 17:52, Tyler Retzlaff:
> +#ifdef 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
>   * whole macro.
>   */
>  #define RTE_DEFINE_PER_LCORE(type, name)			\
> -	__thread __typeof__(type) per_lcore_##name
> +	__declspec(thread) typeof(type) per_lcore_##name
>  
>  /**
>   * Macro to declare an extern per lcore variable "var" of type "type"
>   */
>  #define RTE_DECLARE_PER_LCORE(type, name)			\
> +	extern __declspec(thread) typeof(type) per_lcore_##name
> +#else
> +#define RTE_DEFINE_PER_LCORE(type, name)			\
> +	__thread __typeof__(type) per_lcore_##name
> +
> +#define RTE_DECLARE_PER_LCORE(type, name)			\
>  	extern __thread __typeof__(type) per_lcore_##name
> +#endif

I'm afraid you damaged the doxygen document here.
Please check what happens when generating doxygen.
I suppose it does not take the RTE_TOOLCHAIN_MSVC path,
so it does not find any comment.




^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2] eal: provide per lcore macros for MSVC
  2023-08-31 11:57     ` Thomas Monjalon
@ 2023-08-31 23:08       ` Tyler Retzlaff
  2023-09-21  9:36         ` Thomas Monjalon
  0 siblings, 1 reply; 11+ messages in thread
From: Tyler Retzlaff @ 2023-08-31 23:08 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev, david.marchand, Stephen Hemminger

On Thu, Aug 31, 2023 at 01:57:36PM +0200, Thomas Monjalon wrote:
> 11/07/2023 17:52, Tyler Retzlaff:
> > +#ifdef 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
> >   * whole macro.
> >   */
> >  #define RTE_DEFINE_PER_LCORE(type, name)			\
> > -	__thread __typeof__(type) per_lcore_##name
> > +	__declspec(thread) typeof(type) per_lcore_##name
> >  
> >  /**
> >   * Macro to declare an extern per lcore variable "var" of type "type"
> >   */
> >  #define RTE_DECLARE_PER_LCORE(type, name)			\
> > +	extern __declspec(thread) typeof(type) per_lcore_##name
> > +#else
> > +#define RTE_DEFINE_PER_LCORE(type, name)			\
> > +	__thread __typeof__(type) per_lcore_##name
> > +
> > +#define RTE_DECLARE_PER_LCORE(type, name)			\
> >  	extern __thread __typeof__(type) per_lcore_##name
> > +#endif
> 
> I'm afraid you damaged the doxygen document here.
> Please check what happens when generating doxygen.
> I suppose it does not take the RTE_TOOLCHAIN_MSVC path,
> so it does not find any comment.

Thanks Thomas i will look into fixing it.

> 
> 

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2] eal: provide per lcore macros for MSVC
  2023-08-31 23:08       ` Tyler Retzlaff
@ 2023-09-21  9:36         ` Thomas Monjalon
  2023-09-21 15:45           ` Tyler Retzlaff
  0 siblings, 1 reply; 11+ messages in thread
From: Thomas Monjalon @ 2023-09-21  9:36 UTC (permalink / raw)
  To: Tyler Retzlaff; +Cc: dev, david.marchand, Stephen Hemminger

01/09/2023 01:08, Tyler Retzlaff:
> On Thu, Aug 31, 2023 at 01:57:36PM +0200, Thomas Monjalon wrote:
> > 11/07/2023 17:52, Tyler Retzlaff:
> > > +#ifdef 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
> > >   * whole macro.
> > >   */
> > >  #define RTE_DEFINE_PER_LCORE(type, name)			\
> > > -	__thread __typeof__(type) per_lcore_##name
> > > +	__declspec(thread) typeof(type) per_lcore_##name
> > >  
> > >  /**
> > >   * Macro to declare an extern per lcore variable "var" of type "type"
> > >   */
> > >  #define RTE_DECLARE_PER_LCORE(type, name)			\
> > > +	extern __declspec(thread) typeof(type) per_lcore_##name
> > > +#else
> > > +#define RTE_DEFINE_PER_LCORE(type, name)			\
> > > +	__thread __typeof__(type) per_lcore_##name
> > > +
> > > +#define RTE_DECLARE_PER_LCORE(type, name)			\
> > >  	extern __thread __typeof__(type) per_lcore_##name
> > > +#endif
> > 
> > I'm afraid you damaged the doxygen document here.
> > Please check what happens when generating doxygen.
> > I suppose it does not take the RTE_TOOLCHAIN_MSVC path,
> > so it does not find any comment.
> 
> Thanks Thomas i will look into fixing it.

Please can you send the fix?



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2] eal: provide per lcore macros for MSVC
  2023-09-21  9:36         ` Thomas Monjalon
@ 2023-09-21 15:45           ` Tyler Retzlaff
  0 siblings, 0 replies; 11+ messages in thread
From: Tyler Retzlaff @ 2023-09-21 15:45 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev, david.marchand, Stephen Hemminger

On Thu, Sep 21, 2023 at 11:36:32AM +0200, Thomas Monjalon wrote:
> 01/09/2023 01:08, Tyler Retzlaff:
> > On Thu, Aug 31, 2023 at 01:57:36PM +0200, Thomas Monjalon wrote:
> > > 11/07/2023 17:52, Tyler Retzlaff:
> > > > +#ifdef 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
> > > >   * whole macro.
> > > >   */
> > > >  #define RTE_DEFINE_PER_LCORE(type, name)			\
> > > > -	__thread __typeof__(type) per_lcore_##name
> > > > +	__declspec(thread) typeof(type) per_lcore_##name
> > > >  
> > > >  /**
> > > >   * Macro to declare an extern per lcore variable "var" of type "type"
> > > >   */
> > > >  #define RTE_DECLARE_PER_LCORE(type, name)			\
> > > > +	extern __declspec(thread) typeof(type) per_lcore_##name
> > > > +#else
> > > > +#define RTE_DEFINE_PER_LCORE(type, name)			\
> > > > +	__thread __typeof__(type) per_lcore_##name
> > > > +
> > > > +#define RTE_DECLARE_PER_LCORE(type, name)			\
> > > >  	extern __thread __typeof__(type) per_lcore_##name
> > > > +#endif
> > > 
> > > I'm afraid you damaged the doxygen document here.
> > > Please check what happens when generating doxygen.
> > > I suppose it does not take the RTE_TOOLCHAIN_MSVC path,
> > > so it does not find any comment.
> > 
> > Thanks Thomas i will look into fixing it.
> 
> Please can you send the fix?
> 

Sure, do you want me to just move the documentation to the non MSVC path
or do you have another prefered solution in mind?

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2023-09-21 15:45 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-10 21:29 [PATCH] provide Windows/MSVC lcore macros Tyler Retzlaff
2023-07-10 21:29 ` [PATCH] eal: provide per lcore macros for MSVC Tyler Retzlaff
2023-07-11  6:25   ` Thomas Monjalon
2023-07-11 15:52 ` [PATCH v2] provide Windows/MSVC lcore macros Tyler Retzlaff
2023-07-11 15:52   ` [PATCH v2] eal: provide per lcore macros for MSVC Tyler Retzlaff
2023-07-11 16:09     ` Stephen Hemminger
2023-08-25  8:49       ` David Marchand
2023-08-31 11:57     ` Thomas Monjalon
2023-08-31 23:08       ` Tyler Retzlaff
2023-09-21  9:36         ` Thomas Monjalon
2023-09-21 15:45           ` Tyler Retzlaff

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).