...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37 package atomic
38
39 import "unsafe"
40
41
42
43 func Load(ptr *uint32) uint32 {
44 return *ptr
45 }
46
47
48
49 func Loadp(ptr unsafe.Pointer) unsafe.Pointer {
50 return *(*unsafe.Pointer)(ptr)
51 }
52
53
54
55 func LoadAcq(ptr *uint32) uint32 {
56 return *ptr
57 }
58
59
60
61 func LoadAcq64(ptr *uint64) uint64 {
62 return *ptr
63 }
64
65
66
67 func LoadAcquintptr(ptr *uintptr) uintptr {
68 return *ptr
69 }
70
71
72
73 func Load8(ptr *uint8) uint8 {
74 return *ptr
75 }
76
77
78
79 func Load64(ptr *uint64) uint64 {
80 return *ptr
81 }
82
83
84
85 func Xadd(ptr *uint32, delta int32) uint32 {
86 new := *ptr + uint32(delta)
87 *ptr = new
88 return new
89 }
90
91
92
93 func Xadd64(ptr *uint64, delta int64) uint64 {
94 new := *ptr + uint64(delta)
95 *ptr = new
96 return new
97 }
98
99
100
101 func Xadduintptr(ptr *uintptr, delta uintptr) uintptr {
102 new := *ptr + delta
103 *ptr = new
104 return new
105 }
106
107
108
109 func Xchg(ptr *uint32, new uint32) uint32 {
110 old := *ptr
111 *ptr = new
112 return old
113 }
114
115
116
117 func Xchg64(ptr *uint64, new uint64) uint64 {
118 old := *ptr
119 *ptr = new
120 return old
121 }
122
123
124
125 func Xchgint32(ptr *int32, new int32) int32 {
126 old := *ptr
127 *ptr = new
128 return old
129 }
130
131
132
133 func Xchgint64(ptr *int64, new int64) int64 {
134 old := *ptr
135 *ptr = new
136 return old
137 }
138
139
140
141 func Xchguintptr(ptr *uintptr, new uintptr) uintptr {
142 old := *ptr
143 *ptr = new
144 return old
145 }
146
147
148
149 func And8(ptr *uint8, val uint8) {
150 *ptr = *ptr & val
151 }
152
153
154
155 func Or8(ptr *uint8, val uint8) {
156 *ptr = *ptr | val
157 }
158
159
160
161
162
163 func And(ptr *uint32, val uint32) {
164 *ptr = *ptr & val
165 }
166
167
168
169 func Or(ptr *uint32, val uint32) {
170 *ptr = *ptr | val
171 }
172
173
174
175 func Cas64(ptr *uint64, old, new uint64) bool {
176 if *ptr == old {
177 *ptr = new
178 return true
179 }
180 return false
181 }
182
183
184
185 func Store(ptr *uint32, val uint32) {
186 *ptr = val
187 }
188
189
190
191 func StoreRel(ptr *uint32, val uint32) {
192 *ptr = val
193 }
194
195
196
197 func StoreRel64(ptr *uint64, val uint64) {
198 *ptr = val
199 }
200
201
202
203 func StoreReluintptr(ptr *uintptr, val uintptr) {
204 *ptr = val
205 }
206
207
208
209 func Store8(ptr *uint8, val uint8) {
210 *ptr = val
211 }
212
213
214
215 func Store64(ptr *uint64, val uint64) {
216 *ptr = val
217 }
218
219
220
221
222
223 func StorepNoWB(ptr unsafe.Pointer, val unsafe.Pointer)
224
225
226
227 func Casint32(ptr *int32, old, new int32) bool {
228 if *ptr == old {
229 *ptr = new
230 return true
231 }
232 return false
233 }
234
235
236
237 func Casint64(ptr *int64, old, new int64) bool {
238 if *ptr == old {
239 *ptr = new
240 return true
241 }
242 return false
243 }
244
245
246
247 func Cas(ptr *uint32, old, new uint32) bool {
248 if *ptr == old {
249 *ptr = new
250 return true
251 }
252 return false
253 }
254
255
256
257 func Casp1(ptr *unsafe.Pointer, old, new unsafe.Pointer) bool {
258 if *ptr == old {
259 *ptr = new
260 return true
261 }
262 return false
263 }
264
265
266
267 func Casuintptr(ptr *uintptr, old, new uintptr) bool {
268 if *ptr == old {
269 *ptr = new
270 return true
271 }
272 return false
273 }
274
275
276
277 func CasRel(ptr *uint32, old, new uint32) bool {
278 if *ptr == old {
279 *ptr = new
280 return true
281 }
282 return false
283 }
284
285
286
287 func Storeint32(ptr *int32, new int32) {
288 *ptr = new
289 }
290
291
292
293 func Storeint64(ptr *int64, new int64) {
294 *ptr = new
295 }
296
297
298
299 func Storeuintptr(ptr *uintptr, new uintptr) {
300 *ptr = new
301 }
302
303
304
305 func Loaduintptr(ptr *uintptr) uintptr {
306 return *ptr
307 }
308
309
310
311 func Loaduint(ptr *uint) uint {
312 return *ptr
313 }
314
315
316
317 func Loadint32(ptr *int32) int32 {
318 return *ptr
319 }
320
321
322
323 func Loadint64(ptr *int64) int64 {
324 return *ptr
325 }
326
327
328
329 func Xaddint32(ptr *int32, delta int32) int32 {
330 new := *ptr + delta
331 *ptr = new
332 return new
333 }
334
335
336
337 func Xaddint64(ptr *int64, delta int64) int64 {
338 new := *ptr + delta
339 *ptr = new
340 return new
341 }
342
View as plain text