]> git.saurik.com Git - apple/xnu.git/blame - tools/cocci/os_atomic_normalize.cocci
xnu-6153.11.26.tar.gz
[apple/xnu.git] / tools / cocci / os_atomic_normalize.cocci
CommitLineData
cb323159
A
1// To apply, at the top of xnu.git:
2// $ spatch --max-width=120 --use-gitgrep --in-place --include-headers --sp-file tools/cocci/os_atomic_normalize.cocci -dir .
3//
4// coccinelle insists on adding a space for (void) casts which can be fixed with:
5// $ git grep -l '(void) os_atomic' | xargs -n1 sed -i '' -e 's/(void) os_atomic/(void)os_atomic/'
6
7@os_atomic@
8identifier fn =~ "^os_atomic";
9@@
10
11fn
12
13@script:ocaml unorig@
14fn << os_atomic.fn;
15new_fn;
16@@
17
18new_fn := make_ident (Str.global_replace (Str.regexp "_orig") "" fn)
19
20@@
21identifier os_atomic.fn;
22identifier unorig.new_fn;
23expression A, B, C;
24@@
25
26-(void)fn
27+new_fn
28 (...)
29
30@@ expression E, F, m; @@
31
32(
33- os_atomic_add(E, 1, m)
34+ os_atomic_inc(E, m)
35|
36- os_atomic_add_orig(E, 1, m)
37+ os_atomic_inc_orig(E, m)
38|
39- os_atomic_sub(E, -1, m)
40+ os_atomic_inc(E, m)
41|
42- os_atomic_sub_orig(E, -1, m)
43+ os_atomic_inc_orig(E, m)
44|
45- os_atomic_add(E, -1, m)
46+ os_atomic_dec(E, m)
47|
48- os_atomic_add_orig(E, -1, m)
49+ os_atomic_dec_orig(E, m)
50|
51- os_atomic_sub(E, 1, m)
52+ os_atomic_dec(E, m)
53|
54- os_atomic_sub_orig(E, 1, m)
55+ os_atomic_dec_orig(E, m)
56|
57- os_atomic_add(E, -(F), m)
58+ os_atomic_sub(E, F, m)
59|
60- os_atomic_add_orig(E, -(F), m)
61+ os_atomic_sub_orig(E, F, m)
62|
63- os_atomic_add(E, -F, m)
64+ os_atomic_sub(E, F, m)
65|
66- os_atomic_add_orig(E, -F, m)
67+ os_atomic_sub_orig(E, F, m)
68|
69- os_atomic_sub(E, -(F), m)
70+ os_atomic_add(E, F, m)
71|
72- os_atomic_sub_orig(E, -(F), m)
73+ os_atomic_add_orig(E, F, m)
74|
75- os_atomic_sub(E, -F, m)
76+ os_atomic_add(E, F, m)
77|
78- os_atomic_sub_orig(E, -F, m)
79+ os_atomic_add_orig(E, F, m)
80|
81- os_atomic_and(E, ~(F), m)
82+ os_atomic_andnot(E, F, m)
83|
84- os_atomic_and_orig(E, ~(F), m)
85+ os_atomic_andnot_orig(E, F, m)
86|
87- os_atomic_and(E, ~F, m)
88+ os_atomic_andnot(E, F, m)
89|
90- os_atomic_and_orig(E, ~F, m)
91+ os_atomic_andnot_orig(E, F, m)
92)
93
94// vim:ft=diff: