14
16
// The compare-and-swap operation, implemented by the CompareAndSwapT
15
17
// functions, is the atomic equivalent of:
25
// The add operation, implemented by the AddT functions, is the atomic
31
// The load and store operations, implemented by the LoadT and StoreT
32
// functions, are the atomic equivalents of "return *addr" and
29
// BUG(rsc): On ARM, the 64-bit functions use instructions unavailable before ARM 11.
41
// BUG(rsc): On x86-32, the 64-bit functions use instructions unavailable before the Pentium MMX.
31
// On x86-32, the 64-bit functions use instructions unavailable before the Pentium MMX.
43
// On both ARM and x86-32, it is the caller's responsibility to arrange for 64-bit
44
// alignment of 64-bit words accessed atomically. The first word in a global
45
// variable or in an allocated struct or slice can be relied upon to be
33
48
// CompareAndSwapInt32 executes the compare-and-swap operation for an int32 value.
34
func CompareAndSwapInt32(val *int32, old, new int32) (swapped bool)
49
func CompareAndSwapInt32(addr *int32, old, new int32) (swapped bool)
36
51
// CompareAndSwapInt64 executes the compare-and-swap operation for an int64 value.
37
func CompareAndSwapInt64(val *int64, old, new int64) (swapped bool)
52
func CompareAndSwapInt64(addr *int64, old, new int64) (swapped bool)
39
54
// CompareAndSwapUint32 executes the compare-and-swap operation for a uint32 value.
40
func CompareAndSwapUint32(val *uint32, old, new uint32) (swapped bool)
55
func CompareAndSwapUint32(addr *uint32, old, new uint32) (swapped bool)
42
57
// CompareAndSwapUint64 executes the compare-and-swap operation for a uint64 value.
43
func CompareAndSwapUint64(val *uint64, old, new uint64) (swapped bool)
58
func CompareAndSwapUint64(addr *uint64, old, new uint64) (swapped bool)
45
60
// CompareAndSwapUintptr executes the compare-and-swap operation for a uintptr value.
46
func CompareAndSwapUintptr(val *uintptr, old, new uintptr) (swapped bool)
61
func CompareAndSwapUintptr(addr *uintptr, old, new uintptr) (swapped bool)
48
63
// CompareAndSwapPointer executes the compare-and-swap operation for a unsafe.Pointer value.
49
func CompareAndSwapPointer(val *unsafe.Pointer, old, new unsafe.Pointer) (swapped bool)
51
// AddInt32 atomically adds delta to *val and returns the new value.
52
func AddInt32(val *int32, delta int32) (new int32)
54
// AddUint32 atomically adds delta to *val and returns the new value.
55
func AddUint32(val *uint32, delta uint32) (new uint32)
57
// AddInt64 atomically adds delta to *val and returns the new value.
58
func AddInt64(val *int64, delta int64) (new int64)
60
// AddUint64 atomically adds delta to *val and returns the new value.
61
func AddUint64(val *uint64, delta uint64) (new uint64)
63
// AddUintptr atomically adds delta to *val and returns the new value.
64
func AddUintptr(val *uintptr, delta uintptr) (new uintptr)
64
func CompareAndSwapPointer(addr *unsafe.Pointer, old, new unsafe.Pointer) (swapped bool)
66
// AddInt32 atomically adds delta to *addr and returns the new value.
67
func AddInt32(addr *int32, delta int32) (new int32)
69
// AddUint32 atomically adds delta to *addr and returns the new value.
70
func AddUint32(addr *uint32, delta uint32) (new uint32)
72
// AddInt64 atomically adds delta to *addr and returns the new value.
73
func AddInt64(addr *int64, delta int64) (new int64)
75
// AddUint64 atomically adds delta to *addr and returns the new value.
76
func AddUint64(addr *uint64, delta uint64) (new uint64)
78
// AddUintptr atomically adds delta to *addr and returns the new value.
79
func AddUintptr(addr *uintptr, delta uintptr) (new uintptr)
66
81
// LoadInt32 atomically loads *addr.
67
82
func LoadInt32(addr *int32) (val int32)