...
1
2
3
4
5
6
7 package atomic
8
9
10 func And32(ptr *uint32, val uint32) uint32 {
11 for {
12 old := *ptr
13 if Cas(ptr, old, old&val) {
14 return old
15 }
16 }
17 }
18
19
20 func Or32(ptr *uint32, val uint32) uint32 {
21 for {
22 old := *ptr
23 if Cas(ptr, old, old|val) {
24 return old
25 }
26 }
27 }
28
29
30 func And64(ptr *uint64, val uint64) uint64 {
31 for {
32 old := *ptr
33 if Cas64(ptr, old, old&val) {
34 return old
35 }
36 }
37 }
38
39
40 func Or64(ptr *uint64, val uint64) uint64 {
41 for {
42 old := *ptr
43 if Cas64(ptr, old, old|val) {
44 return old
45 }
46 }
47 }
48
49
50 func Anduintptr(ptr *uintptr, val uintptr) uintptr {
51 for {
52 old := *ptr
53 if Casuintptr(ptr, old, old&val) {
54 return old
55 }
56 }
57 }
58
59
60 func Oruintptr(ptr *uintptr, val uintptr) uintptr {
61 for {
62 old := *ptr
63 if Casuintptr(ptr, old, old|val) {
64 return old
65 }
66 }
67 }
68
View as plain text