Skip to content

Commit e176ebf

Browse files
puranjaymohanpaulmckrcu
authored andcommitted
tools/memory-model: Add atomic_andnot() with its variants
Pull-855[1] added the support of atomic_andnot() to the herd tool. Use this to add the implementation in the LKMM. All of the ordering variants are also added. Here is a small litmus-test that uses this operation: C andnot { atomic_t u = ATOMIC_INIT(7); } P0(atomic_t *u) { r0 = atomic_fetch_andnot(3, u); r1 = READ_ONCE(*u); } exists (0:r0=7 /\ 0:r1=4) Test andnot Allowed States 1 0:r0=7; 0:r1=4; Ok Witnesses Positive: 1 Negative: 0 Condition exists (0:r0=7 /\ 0:r1=4) Observation andnot Always 1 0 Time andnot 0.00 Hash=78f011a0b5a0c65fa1cf106fcd62c845 [1] herd/herdtools7#855 Signed-off-by: Puranjay Mohan <[email protected]> Acked-by: Andrea Parri <[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: Boqun Feng <[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 2ada0ad commit e176ebf

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

tools/memory-model/linux-kernel.def

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ atomic_or(V,X) { __atomic_op(X,|,V); }
7070
atomic_xor(V,X) { __atomic_op(X,^,V); }
7171
atomic_inc(X) { __atomic_op(X,+,1); }
7272
atomic_dec(X) { __atomic_op(X,-,1); }
73+
atomic_andnot(V,X) { __atomic_op(X,&~,V); }
7374

7475
atomic_add_return(V,X) __atomic_op_return{mb}(X,+,V)
7576
atomic_add_return_relaxed(V,X) __atomic_op_return{once}(X,+,V)
@@ -138,3 +139,8 @@ atomic_add_negative(V,X) __atomic_op_return{mb}(X,+,V) < 0
138139
atomic_add_negative_relaxed(V,X) __atomic_op_return{once}(X,+,V) < 0
139140
atomic_add_negative_acquire(V,X) __atomic_op_return{acquire}(X,+,V) < 0
140141
atomic_add_negative_release(V,X) __atomic_op_return{release}(X,+,V) < 0
142+
143+
atomic_fetch_andnot(V,X) __atomic_fetch_op{mb}(X,&~,V)
144+
atomic_fetch_andnot_acquire(V,X) __atomic_fetch_op{acquire}(X,&~,V)
145+
atomic_fetch_andnot_release(V,X) __atomic_fetch_op{release}(X,&~,V)
146+
atomic_fetch_andnot_relaxed(V,X) __atomic_fetch_op{once}(X,&~,V)

0 commit comments

Comments
 (0)