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