Skip to content

Commit 2ada0ad

Browse files
puranjaymohanpaulmckrcu
authored andcommitted
tools/memory-model: Add atomic_and()/or()/xor() and add_negative
Pull-849[1] added the support of '&', '|', and '^' to the herd7 tool's atomics operations. Use these in linux-kernel.def to implement atomic_and()/or()/xor() with all their ordering variants. atomic_add_negative() is already available so add its acquire, release, and relaxed ordering variants. [1] herd/herdtools7#849 Signed-off-by: Puranjay Mohan <[email protected]> Acked-by: Andrea Parri <[email protected]> Reviewed-by: Boqun Feng <[email protected]> Signed-off-by: Paul E. McKenney <[email protected]> Cc: Alan Stern <[email protected]> Cc: Will Deacon <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Nicholas Piggin <[email protected]> Cc: David Howells <[email protected]> Cc: Jade Alglave <[email protected]> Cc: Luc Maranget <[email protected]> Cc: Akira Yokosawa <[email protected]> Cc: Daniel Lustig <[email protected]> Cc: Joel Fernandes <[email protected]> Cc: <[email protected]>
1 parent 2014c95 commit 2ada0ad

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tools/memory-model/linux-kernel.def

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ atomic_set_release(X,V) { smp_store_release(X,V); }
6565

6666
atomic_add(V,X) { __atomic_op(X,+,V); }
6767
atomic_sub(V,X) { __atomic_op(X,-,V); }
68+
atomic_and(V,X) { __atomic_op(X,&,V); }
69+
atomic_or(V,X) { __atomic_op(X,|,V); }
70+
atomic_xor(V,X) { __atomic_op(X,^,V); }
6871
atomic_inc(X) { __atomic_op(X,+,1); }
6972
atomic_dec(X) { __atomic_op(X,-,1); }
7073

@@ -77,6 +80,21 @@ atomic_fetch_add_relaxed(V,X) __atomic_fetch_op{once}(X,+,V)
7780
atomic_fetch_add_acquire(V,X) __atomic_fetch_op{acquire}(X,+,V)
7881
atomic_fetch_add_release(V,X) __atomic_fetch_op{release}(X,+,V)
7982

83+
atomic_fetch_and(V,X) __atomic_fetch_op{mb}(X,&,V)
84+
atomic_fetch_and_relaxed(V,X) __atomic_fetch_op{once}(X,&,V)
85+
atomic_fetch_and_acquire(V,X) __atomic_fetch_op{acquire}(X,&,V)
86+
atomic_fetch_and_release(V,X) __atomic_fetch_op{release}(X,&,V)
87+
88+
atomic_fetch_or(V,X) __atomic_fetch_op{mb}(X,|,V)
89+
atomic_fetch_or_relaxed(V,X) __atomic_fetch_op{once}(X,|,V)
90+
atomic_fetch_or_acquire(V,X) __atomic_fetch_op{acquire}(X,|,V)
91+
atomic_fetch_or_release(V,X) __atomic_fetch_op{release}(X,|,V)
92+
93+
atomic_fetch_xor(V,X) __atomic_fetch_op{mb}(X,^,V)
94+
atomic_fetch_xor_relaxed(V,X) __atomic_fetch_op{once}(X,^,V)
95+
atomic_fetch_xor_acquire(V,X) __atomic_fetch_op{acquire}(X,^,V)
96+
atomic_fetch_xor_release(V,X) __atomic_fetch_op{release}(X,^,V)
97+
8098
atomic_inc_return(X) __atomic_op_return{mb}(X,+,1)
8199
atomic_inc_return_relaxed(X) __atomic_op_return{once}(X,+,1)
82100
atomic_inc_return_acquire(X) __atomic_op_return{acquire}(X,+,1)
@@ -117,3 +135,6 @@ atomic_sub_and_test(V,X) __atomic_op_return{mb}(X,-,V) == 0
117135
atomic_dec_and_test(X) __atomic_op_return{mb}(X,-,1) == 0
118136
atomic_inc_and_test(X) __atomic_op_return{mb}(X,+,1) == 0
119137
atomic_add_negative(V,X) __atomic_op_return{mb}(X,+,V) < 0
138+
atomic_add_negative_relaxed(V,X) __atomic_op_return{once}(X,+,V) < 0
139+
atomic_add_negative_acquire(V,X) __atomic_op_return{acquire}(X,+,V) < 0
140+
atomic_add_negative_release(V,X) __atomic_op_return{release}(X,+,V) < 0

0 commit comments

Comments
 (0)