mirror of
https://github.com/ziglang/zig.git
synced 2024-11-30 09:02:32 +00:00
17b935325e
See #226 Closes #220
15 lines
330 B
Zig
15 lines
330 B
Zig
const assert = @import("std").debug.assert;
|
|
const AtomicOrder = @import("builtin").AtomicOrder;
|
|
|
|
test "cmpxchg" {
|
|
var x: i32 = 1234;
|
|
while (!@cmpxchg(&x, 1234, 5678, AtomicOrder.SeqCst, AtomicOrder.SeqCst)) {}
|
|
assert(x == 5678);
|
|
}
|
|
|
|
test "fence" {
|
|
var x: i32 = 1234;
|
|
@fence(AtomicOrder.SeqCst);
|
|
x = 5678;
|
|
}
|