Declaring it volatile
Posted Aug 6, 2012 18:16 UTC (Mon) by
PaulMcKenney (subscriber, #9624)
In reply to:
Declaring it volatile by daglwn
Parent article:
ACCESS_ONCE()
It does sound like it just might be well past time for typeof() in the C/C++ standards. ;-) That said, both gcc and llvm seem to support typeof(), and I bet a lot of other compilers do as well, either directly or indirectly. But perhaps the Linux kernel will eventually move from typeof() to C++11 decltype(), once the commonly-used compiler versions support it.
Yes, you can in principle use manually coded temporaries to enable compiler optimizations in cases where a lock is held that prevents changes to the variable being loaded, but it is not at all clear to me why this would be a better solution than using ACCESS_ONCE(), especially in the Linux kernel.
(
Log in to post comments)