You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(ffi): replace removed std.atomic.Mutex with std.Thread.Mutex
`Zig FFI Tests` has been failing on every PR with:
src/catalogue.zig:16:22: error: root source file struct 'atomic'
has no member named 'Mutex'
`std.atomic.Mutex` was removed from the standard library. Nine files in
ffi/zig/src/ still carried a byte-identical hand-rolled wrapper around it
(verified: all nine hash to the same value — one template copied nine times):
const Mutex = struct {
state: std.atomic.Mutex = .unlocked,
pub fn lock(m: *Mutex) void {
while (!m.state.tryLock()) std.atomic.spinLoopHint();
}
pub fn unlock(m: *Mutex) void { m.state.unlock(); }
};
The wrapper's public surface — `lock()` / `unlock()`, instantiated as
`var mutex: Mutex = .{}` — is already exactly `std.Thread.Mutex`'s, so the
whole struct collapses to a one-line alias with no call-site changes:
const Mutex = std.Thread.Mutex;
This is also a behavioural improvement, not merely a compile fix: the wrapper
busy-waited via `spinLoopHint`, burning a core under contention, whereas
`std.Thread.Mutex` parks the waiting thread. 81 other files in this repo
already use `std.Thread.Mutex` directly, so this converges on the in-tree norm
rather than introducing a new one.
Files: sla, catalogue, sdp, loader, verisimdb, guardian, community,
federation, coprocessor.
Verified under the CI pin (zig 0.15.2, per .github/workflows/zig-test.yml) —
all four targets CI runs:
zig build test PASS (13 + 3 tests passed)
zig build readiness PASS (28/28 tests passed)
zig build lib PASS (2/2 steps)
zig build bench PASS (3/3 steps)
Note: `.tool-versions` pins 0.15.1 while the workflow uses 0.15.2. Not changed
here, but the two should be reconciled.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
0 commit comments