RE: [PATCH 2/5] arm64: add __READ_ONCE_EX()

From: David Laight
Date: Sat Nov 09 2024 - 04:49:20 EST


From: Haris Okanovic
> Sent: 05 November 2024 18:31
>
> Perform an exclusive load, which atomically loads a word and arms the
> exclusive monitor to enable wfet()/wfe() accelerated polling.
>
...
> + atomic ? (typeof(*__x))__u.__val : (*(volatile typeof(__x))__x);\

That doesn't do what you want it to do.
(It is wrong in READ_ONCE() as well.)

?: is treated like an arithmetic operator and the result will get
promoted to 'int'.
Moving the first cast outside the ?: probably works:
(typeof(*__x))(atomic ? __u.__val : (*(volatile typeof(__x))__x));

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)