Golang's atomic package provides function func LoadUint32(addr *uint32) (val uint32)
. I looked into the assembly implementation:
TEXT ·LoadUint32(SB),NOSPLIT,$0-12
MOVQ addr+0(FP), AX
MOVL 0(AX), AX
MOVL AX, val+8(FP)
RET
which basically load the value from the memory address and return it.
I'm wondering if we have a uint32 pointer(addr) x
, what is the difference between calling atomic.LoadUint32(x)
and directly access it using *x
?