mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-12-29 09:16:33 +00:00
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>
35 lines
498 B
Plaintext
35 lines
498 B
Plaintext
C cmpxchg-fail-unordered-1
|
|
|
|
(*
|
|
* Result: Sometimes
|
|
*
|
|
* Demonstrate that a failing cmpxchg() operation does not act as a
|
|
* full barrier. (In contrast, a successful cmpxchg() does act as a
|
|
* full barrier.)
|
|
*)
|
|
|
|
{}
|
|
|
|
P0(int *x, int *y, int *z)
|
|
{
|
|
int r0;
|
|
int r1;
|
|
|
|
WRITE_ONCE(*x, 1);
|
|
r1 = cmpxchg(z, 1, 0);
|
|
r0 = READ_ONCE(*y);
|
|
}
|
|
|
|
P1(int *x, int *y, int *z)
|
|
{
|
|
int r0;
|
|
int r1;
|
|
|
|
WRITE_ONCE(*y, 1);
|
|
r1 = cmpxchg(z, 1, 0);
|
|
r0 = READ_ONCE(*x);
|
|
}
|
|
|
|
locations[0:r1;1:r1]
|
|
exists (0:r0=0 /\ 1:r0=0)
|