@@ -29,12 +29,20 @@ function __atomic(ex)
29
29
error (" @atomic macro incomplete!" )
30
30
end
31
31
32
- function atomic_add! (ptr, b)
33
- Core. Intrinsics. atomic_pointermodify (ptr, + , b, :monotonic )
34
- end
35
-
36
- function atomic_and! (ptr, b)
37
- Core. Intrinsics. atomic_pointermodify (ptr, & , b, :monotonic )
32
+ # arithmetic and bitwise operations
33
+
34
+ const ops = Dict (
35
+ :atomic_add! => + ,
36
+ :atomic_sub! => - ,
37
+ :atomic_and! => & ,
38
+ :atomic_or! => - ,
39
+ :atomic_xor! => ⊻ ,
40
+ )
41
+
42
+ for (name, op) in ops
43
+ @eval @inline function $name (ptr, b)
44
+ Core. Intrinsics. atomic_pointermodify (ptr, $ op, b, :monotonic )
45
+ end
38
46
end
39
47
40
48
# Not sure what this one is...
@@ -67,24 +75,11 @@ function atomic_op!(ptr, b)
67
75
Core. Intrinsics. atomic_pointermodify (ptr, & , b, :monotonic )
68
76
end
69
77
70
- function atomic_or! (ptr, b)
71
- Core. Intrinsics. atomic_pointermodify (ptr, | , b, :monotonic )
72
- end
73
-
74
- function atomic_sub! (ptr, b)
75
- Core. Intrinsics. atomic_pointermodify (ptr, - , b, :monotonic )
76
- end
77
-
78
78
# TODO
79
79
function atomic_xchg! (ptr, b)
80
80
Core. Intrinsics. atomic_pointermodify (ptr, & , b, :monotonic )
81
81
end
82
82
83
- # TODO
84
- function atomic_xor! (ptr, b)
85
- Core. Intrinsics. atomic_pointermodify (ptr, & , b, :monotonic )
86
- end
87
-
88
83
# ##
89
84
# CPU implementation of atomic macro
90
85
# ##
0 commit comments