[lttng-dev] [PATCH 02/11] urcu/uatomic: Use atomic builtins if configured
Mathieu Desnoyers
mathieu.desnoyers at efficios.com
Thu Jun 29 14:29:50 EDT 2023
On 6/29/23 13:22, Olivier Dion wrote:
> On Thu, 22 Jun 2023, "Paul E. McKenney" <paulmck at kernel.org> wrote:
>> On Thu, Jun 22, 2023 at 11:55:55AM -0400, Mathieu Desnoyers wrote:
>>> On 6/21/23 19:19, Paul E. McKenney wrote:
>> I suggest C11 volatile atomic load/store. Load/store fusing is permitted
>> for non-volatile atomic loads and stores, and such fusing can ruin your
>> code's entire day. ;-)
>
> After some testing, I got a wall of warnings:
>
> -Wignored-qualifiers:
>
> Warn if the return type of a function has a type qualifier such as
> "const". For ISO C such a type qualifier has no effect, since the
> value returned by a function is not an lvalue. For C++, the warning
> is only emitted for scalar types or "void". ISO C prohibits
> qualified "void" return types on function definitions, so such
> return types always receive a warning even without this option.
>
> Since we are using atomic builtins, for example load:
>
> type __atomic_load_n (type *ptr, int memorder)
>
> If we put the qualifier volatile to TYPE, we end up with the same
> qualifier on the return value, triggering a warning for each atomic
> operation.
>
> This seems to be only a problem when compiling in C++ [0] while in C it
> seems the compiler is more relaxed on this [1].
>
> Ideas to make the toolchains happy? :-)
Change:
(__typeof__(*ptr) *volatile)(ptr);
(which applies the volatile to the pointer, rather than what is pointed to)
to either:
(volatile __typeof__(*ptr) *)(ptr);
or:
(__typeof__(*ptr) volatile *)(ptr);
Thanks,
Mathieu
>
> [0] https://godbolt.org/z/3nW14M3v1
> [1] https://godbolt.org/z/TcTeMeKbW
>
--
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com
More information about the lttng-dev
mailing list