Migrate Atomic methods from seq_cst-only to the explicit ordering surface now that comptime value params work on generic-struct methods (workers3c4305f/d7a6857/d95ba0a): - atomic.sx: load/store take a comptime $o: Ordering (explicit, Rust-style; no default, matching design 4.6). a.load(.acquire) -> 'load atomic .. acquire'. - call.zig: atomicOrderingFromNode resolves a comptime-bound ordering identifier via comptimeIntNamed (+ atomicOrderingFromTag); documents the sx-Ordering <-> IR-AtomicOrdering declaration-order invariant. The per-op validity guard fires through the method path (a.load(.release) is a compile error). - 1700 migrated to explicit orderings (output unchanged 7/42/43). Suite green (715/0).
18 lines
633 B
Plaintext
18 lines
633 B
Plaintext
// Atomic($T) load/store with explicit memory orderings, single-thread.
|
|
// Stream A (atomics) A.0 + A.0.5 — the ordering is a comptime `$o: Ordering`
|
|
// param (explicit, Rust-style): a.load(.acquire) emits `load atomic … acquire`.
|
|
// An invalid combination (a.load(.release)) is a compile error (see 1131).
|
|
#import "modules/std.sx";
|
|
#import "modules/std/atomic.sx";
|
|
|
|
main :: () {
|
|
a := Atomic(i64).init(7);
|
|
print("init: {}\n", a.load(.seq_cst));
|
|
|
|
a.store(42, .release);
|
|
print("after store: {}\n", a.load(.acquire));
|
|
|
|
a.store(a.load(.relaxed) + 1, .seq_cst);
|
|
print("incremented: {}\n", a.load(.seq_cst));
|
|
}
|