2017-01-05 00:57:48 -08:00
|
|
|
const assert = @import("std").debug.assert;
|
|
|
|
|
2016-12-18 21:41:37 -08:00
|
|
|
fn cmpxchg() {
|
|
|
|
@setFnTest(this);
|
|
|
|
|
|
|
|
var x: i32 = 1234;
|
|
|
|
while (!@cmpxchg(&x, 1234, 5678, AtomicOrder.SeqCst, AtomicOrder.SeqCst)) {}
|
|
|
|
assert(x == 5678);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn fence() {
|
|
|
|
@setFnTest(this);
|
|
|
|
|
|
|
|
var x: i32 = 1234;
|
|
|
|
@fence(AtomicOrder.SeqCst);
|
|
|
|
x = 5678;
|
|
|
|
}
|