Paolo Bonzini <pbonzini@...>
Il ven 5 feb 2021, 19:21 Laszlo Ersek <lersek@...> ha scritto:
To expand: it is an assumption on the implementation of the C compiler; itThis is why I'd like someone else to write the primitives :)Not as long as it's a pointer or smaller.ReleaseMemoryFence ();No concern that the store might not be atomic?
admittedly goes beyond the C standard but it is a reasonable assumption,
compilers may *merge* loads and stores but have no reason to split aligned
loads and stores. Likewise for processors (the pointer limitation is
because sizes larger than the pointer's may not have an instruction that
reads or writes them atomically).
The standard would require you to use C11 atomic loads and stores, but as
far as I understand you cannot assume that they exist on all edk2 compilers.
- Is it architecture-dependent?
- Is it alignment-dependent?
Unaligned pointers are already undefined behavior so you can ignore how
they are dealt with at the processor level.