2ba5b4130e
The four litmus tests in Documentation/litmus-tests/atomic do not declare all of their local variables. Although this is just fine for LKMM analysis by herd7, it causes build failures when run in-kernel by klitmus. This commit therefore adjusts these tests to declare all local variables. Reported-by: Andrea Parri <parri.andrea@gmail.com> Signed-off-by: Paul E. McKenney <paulmck@kernel.org> Acked-by: Andrea Parri <parri.andrea@gmail.com>
31 lines
467 B
Plaintext
31 lines
467 B
Plaintext
C cmpxchg-fail-unordered-2
|
|
|
|
(*
|
|
* Result: Sometimes
|
|
*
|
|
* Demonstrate that a failing cmpxchg() operation does not act as either
|
|
* an acquire release operation. (In contrast, a successful cmpxchg()
|
|
* does act as both an acquire and a release operation.)
|
|
*)
|
|
|
|
{}
|
|
|
|
P0(int *x, int *y)
|
|
{
|
|
int r1;
|
|
|
|
WRITE_ONCE(*x, 1);
|
|
r1 = cmpxchg(y, 0, 1);
|
|
}
|
|
|
|
P1(int *x, int *y)
|
|
{
|
|
int r1;
|
|
int r2;
|
|
|
|
r1 = cmpxchg(y, 0, 1);
|
|
r2 = READ_ONCE(*x);
|
|
}
|
|
|
|
exists (0:r1=0 /\ 1:r1=1 /\ 1:r2=0)
|