[08/10] test-pmd: declare lcore_count atomic when using C11 memory model

Message ID 1739311325-14425-9-git-send-email-andremue@linux.microsoft.com (mailing list archive)
State Not Applicable
Headers
Series enable "app" to be compiled with MSVC |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Andre Muezerie Feb. 11, 2025, 10:02 p.m. UTC
Compiling with MSVC results in the error below:

app/test/test_ring_perf.c(197): error C7712: address argument to atomic
    operation must be a pointer to an atomic integer,
    'volatile unsigned int *' is not valid

The fix is to mark lcore_count as atomic when using C11 memory model.

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
 app/test/test_ring_perf.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
  

Comments

Stephen Hemminger Feb. 11, 2025, 10:12 p.m. UTC | #1
On Tue, 11 Feb 2025 14:02:04 -0800
Andre Muezerie <andremue@linux.microsoft.com> wrote:

> Compiling with MSVC results in the error below:
> 
> app/test/test_ring_perf.c(197): error C7712: address argument to atomic
>     operation must be a pointer to an atomic integer,
>     'volatile unsigned int *' is not valid
> 
> The fix is to mark lcore_count as atomic when using C11 memory model.
> 
> Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>

Prefer using RTE_ATOMIC() all teh time now.
  
fengchengwen Feb. 12, 2025, 1:16 a.m. UTC | #2
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>

On 2025/2/12 6:02, Andre Muezerie wrote:
> Compiling with MSVC results in the error below:
> 
> app/test/test_ring_perf.c(197): error C7712: address argument to atomic
>     operation must be a pointer to an atomic integer,
>     'volatile unsigned int *' is not valid
> 
> The fix is to mark lcore_count as atomic when using C11 memory model.
> 
> Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
  
Andre Muezerie Feb. 12, 2025, 1:16 a.m. UTC | #3
On Tue, Feb 11, 2025 at 02:12:12PM -0800, Stephen Hemminger wrote:
> On Tue, 11 Feb 2025 14:02:04 -0800
> Andre Muezerie <andremue@linux.microsoft.com> wrote:
> 
> > Compiling with MSVC results in the error below:
> > 
> > app/test/test_ring_perf.c(197): error C7712: address argument to atomic
> >     operation must be a pointer to an atomic integer,
> >     'volatile unsigned int *' is not valid
> > 
> > The fix is to mark lcore_count as atomic when using C11 memory model.
> > 
> > Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
> 
> Prefer using RTE_ATOMIC() all teh time now.

You mean even when not explicitly using the C11 model, right?
  

Patch

diff --git a/app/test/test_ring_perf.c b/app/test/test_ring_perf.c
index 57cd04a124..3bb7577629 100644
--- a/app/test/test_ring_perf.c
+++ b/app/test/test_ring_perf.c
@@ -34,7 +34,11 @@  struct lcore_pair {
 	unsigned c1, c2;
 };
 
-static volatile unsigned lcore_count = 0;
+#ifdef RTE_USE_C11_MEM_MODEL
+static RTE_ATOMIC(unsigned int) lcore_count;
+#else
+static volatile unsigned int lcore_count;
+#endif
 
 static void
 test_ring_print_test_string(unsigned int api_type, int esize,