The ACCESS_ONCE macro is used in situations where a value is retrieved from a repository that is known (or suspected) that it is volatile, but not typed as such. The goal is to extract the current value of the storage location in such a way as to defeat the optimizing compiler, which otherwise could cache the value in the register or not provide the storage at all.
The construction, as it is written, applies “volatile” to the storage location indirectly, declaring a suitably typed pointer to this location. According to the C standard, this means that the object be evaluated strictly according to the rules of the abstract machine .
Your proposed change will not apply volatile to the storage location, so it will not achieve this goal. The search for values can be optimized.
By the way, I see this as a brevity model for the stated purpose. I leave complex far worse than that.
david.pfx
source share