Sophie

Sophie

distrib > Mageia > 7 > armv7hl > media > core-updates > by-pkgid > 3970902531f6e8ab795de2ec3e12d699 > files > 6519

kernel-linus-doc-5.10.33-1.mga7.noarch.rpm

C Atomic-RMW-ops-are-atomic-WRT-atomic_set

(*
 * Result: Never
 *
 * Test that atomic_set() cannot break the atomicity of atomic RMWs.
 * NOTE: This requires herd7 7.56 or later which supports "(void)expr".
 *)

{
	atomic_t v = ATOMIC_INIT(1);
}

P0(atomic_t *v)
{
	(void)atomic_add_unless(v, 1, 0);
}

P1(atomic_t *v)
{
	atomic_set(v, 0);
}

exists
(v=2)