zig

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

commit 5d9660972d4b2f1ed575978e8543c88e1392f6b5 (tree)
parent bd5dc75068dcfb3dcd6b8197ee5d941cacb15cb9
Author: Andrew Kelley <andrew@ziglang.org>
Date:   Wed, 11 Mar 2026 01:56:56 +0100

Merge pull request 'fix: use cmpxchgStrong in `Io.Mutex`' (#31441) from GasInfinity/zig:io-mutex-cmpxchg-strong into master

Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31441
Reviewed-by: Andrew Kelley <andrew@ziglang.org>

Diffstat:
Mlib/std/Io.zig | 6+++---
Mlib/std/Io/RwLock.zig | 2--
Mlib/std/atomic.zig | 2+-
3 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/lib/std/Io.zig b/lib/std/Io.zig @@ -1577,11 +1577,11 @@ pub const Mutex = extern struct { }; pub fn tryLock(m: *Mutex) bool { - return m.state.cmpxchgWeak(.unlocked, .locked_once, .acquire, .monotonic) == null; + return m.state.cmpxchgStrong(.unlocked, .locked_once, .acquire, .monotonic) == null; } pub fn lock(m: *Mutex, io: Io) Cancelable!void { - const initial_state = m.state.cmpxchgWeak( + const initial_state = m.state.cmpxchgStrong( .unlocked, .locked_once, .acquire, @@ -1602,7 +1602,7 @@ pub const Mutex = extern struct { /// /// For a description of cancelation and cancelation points, see `Future.cancel`. pub fn lockUncancelable(m: *Mutex, io: Io) void { - const initial_state = m.state.cmpxchgWeak( + const initial_state = m.state.cmpxchgStrong( .unlocked, .locked_once, .acquire, diff --git a/lib/std/Io/RwLock.zig b/lib/std/Io/RwLock.zig @@ -114,8 +114,6 @@ test "internal state" { } test "smoke test" { - if (builtin.target.cpu.arch.isAARCH64()) return error.SkipZigTest; // https://codeberg.org/ziglang/zig/issues/31393 - const io = testing.io; var rl: Io.RwLock = .init; diff --git a/lib/std/atomic.zig b/lib/std/atomic.zig @@ -509,7 +509,7 @@ pub const Mutex = enum(u8) { locked, pub fn tryLock(m: *Mutex) bool { - return @cmpxchgWeak(Mutex, m, .unlocked, .locked, .acquire, .monotonic) == null; + return @cmpxchgStrong(Mutex, m, .unlocked, .locked, .acquire, .monotonic) == null; } pub fn unlock(m: *Mutex) void {