Source file
test/escape_runtime_atomic.go
1
2
3
4
5
6
7
8
9 package escape
10
11 import (
12 "internal/runtime/atomic"
13 "unsafe"
14 )
15
16
17 func Loadp(addr unsafe.Pointer) unsafe.Pointer {
18 return atomic.Loadp(addr)
19 }
20
21 var ptr unsafe.Pointer
22
23 func Storep() {
24 var x int
25 atomic.StorepNoWB(unsafe.Pointer(&ptr), unsafe.Pointer(&x))
26 }
27
28 func Casp1() {
29
30 x := new(int)
31 var y int
32 atomic.Casp1(&ptr, unsafe.Pointer(x), unsafe.Pointer(&y))
33 }
34
View as plain text