mirror of
https://github.com/ziglang/zig.git
synced 2024-12-04 02:48:50 +00:00
18 lines
320 B
Zig
18 lines
320 B
Zig
const assert = @import("std").debug.assert;
|
|
|
|
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;
|
|
}
|