Re: [RFC PATCH 7/8] locking/barriers: Use '__unqual_scalar_typeof' for load-acquire macros

From
Will Deacon <will@kernel.org>
Date
2020-01-13 15:01:59
Also in
lkml
Reply to
Arnd Bergmann, 2020-01-10
On Fri, Jan 10, 2020 at 08:42:37PM +0100, Arnd Bergmann wrote:
On Fri, Jan 10, 2020 at 5:57 PM Will Deacon [off-list ref] wrote:
quoted
@@ -128,10 +128,10 @@ do {                                                                      \
 #ifndef __smp_load_acquire
 #define __smp_load_acquire(p)                                          \
 ({                                                                     \
-       typeof(*p) ___p1 = READ_ONCE(*p);                               \
+       __unqual_scalar_typeof(*p) ___p1 = READ_ONCE(*p);               \
        compiletime_assert_atomic_type(*p);                             \
        __smp_mb();                                                     \
-       ___p1;                                                          \
+       (typeof(*p))___p1;                                              \
 })
Doesn't that last  (typeof(*p))___p1 mean you put the potential
'volatile' back on the assignment after you went through the
effort of taking it out?
Yes, but that's ok wrt codegen since the local variable isn't volatile,
and I definitely ran into issues with 'const' if I returned the unqualified
type here.

Will
Thread (32 messages) 32 messages, 10 authors, last reply 2020-01-15
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help