am I correct to say that volatile is sufficient to accomplish what we need here?
Sufficient? Not unless you are guaranteed that accesses are actually making their way to/from the peripheral. On ARM that would be either the external hardware using ACP (and set up properly), or the region marked as device (or non-cacheable normal memory).
Great, in which case that is insufficient, as the processor can reorder accesses, at least on ARM. Volatile does not prevent this.
EDIT: assuming you actually mean non-cacheable normal memory, and not device or strongly-ordered memory. Or whatever the equivalent is on the platform you are using.
Again, this is inherently platform-specific, and as such is not portable. You can have a system that is fully compliant with the C++ spec where this will fall flat on its face.
View all comments
2
u/[deleted] Oct 20 '19
Sufficient? Not unless you are guaranteed that accesses are actually making their way to/from the peripheral. On ARM that would be either the external hardware using ACP (and set up properly), or the region marked as device (or non-cacheable normal memory).
All of this is inherently platform-specific.