zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 4ad8bc341328e289744a0cc796043d0dd52bb32d (tree)
parent 9d497d0d7746d819dc5454361a03637a22ebf972
Author: Ben Krieger <me@benkrieger.dev>
Date:   Wed, 31 Dec 2025 16:38:10 -0500

Make Io.Mutex an extern struct

Diffstat:
Mlib/std/Io.zig | 8+++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/lib/std/Io.zig b/lib/std/Io.zig @@ -1348,7 +1348,13 @@ pub fn futexWake(io: Io, comptime T: type, ptr: *align(@alignOf(u32)) const T, m return io.vtable.futexWake(io.userdata, @ptrCast(ptr), max_waiters); } -pub const Mutex = struct { +/// Mutex is a synchronization primitive which enforces atomic access to a +/// shared region of code known as the "critical section". +/// +/// Mutex is an extern struct so that it may be used as a field inside another +/// extern struct. Having a guaranteed memory layout including mutexes is +/// important for IPC over shared memory (mmap). +pub const Mutex = extern struct { state: std.atomic.Value(State), pub const init: Mutex = .{ .state = .init(.unlocked) };