On Mon, 18 May 2026 17:07:35 +0200
Thomas Monjalon <[email protected]> wrote:

> When compiling with C++20 standard requirement (default in GCC 16),
> the increment and decrement of volatile variables are rejected:
> 
> rte_spinlock.h:241:14: error:
>       '++' expression of 'volatile'-qualified type is deprecated
> rte_spinlock.h:252:21: error:
>       '--' expression of 'volatile'-qualified type is deprecated
> rte_spinlock.h:278:14: error:
>       '++' expression of 'volatile'-qualified type is deprecated
> 
> The count field of rte_spinlock_recursive_t
> does not need the volatile qualifier
> because it is only accessed by the thread holding the lock,
> which already provides the necessary memory ordering.
> 
> The user field can be accessed outside of the lock,
> so it must handled as a C11 atomic variable.
> 
> Fixes: af75078fece3 ("first public release")
> Cc: [email protected]
> 
> Signed-off-by: Thomas Monjalon <[email protected]>

I would also suggest renaming 'user' to 'owner' to follow common
practice in other places. It also provides an intentional API
break if somebody is misguided enough to do direct access to the
structure field.

Reply via email to