On Tue, 18 May 2021 at 19:38, Philippe Mathieu-Daudé <phi...@redhat.com> wrote: > > When the pointer alignment is known to be safe, we can > directly swap the data in place, without having to rely > on the compiler builtin code. > > Load/store methods expecting aligned pointer use the 'a' > infix. For example to read a 16-bit unsigned value stored > in little endianess at an unaligned pointer: > > val = lduw_le_p(&unaligned_ptr); > > then to store it in big endianess at an aligned pointer: > > stw_be_ap(&aligned_ptr, val);
It sounded from the bug report as if the desired effect was "this access is atomic". Nothing in the documentation here makes that guarantee of the implementation -- it merely imposes an extra requirement on the caller that the pointer alignment is "safe" (which term it does not define...) and a valid implementation would be to implement the "aligned" versions identically to the "unaligned" versions... Q: should the functions at the bottom of this stack of APIs be using something from the atomic.h header? If not, why not? Do we need any of the other atomic primitives ? thanks -- PMM