diff --git a/lib/std/Io/Threaded.zig b/lib/std/Io/Threaded.zig index 60ee5df945..88ec774771 100644 --- a/lib/std/Io/Threaded.zig +++ b/lib/std/Io/Threaded.zig @@ -1104,7 +1104,7 @@ const Thread = struct { const rc = std.c._umtx_op( @intFromPtr(ptr), @intFromEnum(std.c.UMTX_OP.WAKE_PRIVATE), - @as(c_ulong, max_waiters), + @as(c_ulong, @min(max_waiters, std.math.maxInt(c_int))), 0, // there is no timeout struct 0, // there is no timeout struct pointer ); diff --git a/lib/std/Io/test.zig b/lib/std/Io/test.zig index 70af7a25ee..7b652a495e 100644 --- a/lib/std/Io/test.zig +++ b/lib/std/Io/test.zig @@ -818,10 +818,11 @@ test "Event broadcast" { event: Io.Event = .unset, counter: std.atomic.Value(usize) = std.atomic.Value(usize).init(num_threads), - fn wait(self: *@This()) void { + fn wait(self: *@This()) !void { if (self.counter.fetchSub(1, .acq_rel) == 1) { self.event.set(io); } + try self.event.wait(io); } }; @@ -829,9 +830,9 @@ test "Event broadcast" { start_barrier: Barrier = .{}, finish_barrier: Barrier = .{}, - fn run(self: *@This()) void { - self.start_barrier.wait(); - self.finish_barrier.wait(); + fn run(self: *@This()) !void { + try self.start_barrier.wait(); + try self.finish_barrier.wait(); } }; @@ -841,5 +842,5 @@ test "Event broadcast" { for (&threads) |*t| t.* = try std.Thread.spawn(.{}, Context.run, .{&ctx}); defer for (threads) |t| t.join(); - ctx.run(); + try ctx.run(); }