mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-04-27 19:09:47 +03:00
std.Io.Threaded: fix FreeBSD Futex max_waiters (#30094)
On FreeBSD, the maximum waiters should be Cs INT_MAX instead of the maximum of a u32. Waiting for the Io.Event in the broadcast test triggers this bug. Resolves #30715 Co-authored-by: Simon Galli <hubi@hubidubi.net> Reviewed-on: https://codeberg.org/ziglang/zig/pulls/30094 Reviewed-by: Andrew Kelley <andrew@ziglang.org> Co-authored-by: hubidubi <hubidubi@noreply.codeberg.org> Co-committed-by: hubidubi <hubidubi@noreply.codeberg.org>
This commit is contained in:
@@ -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
|
||||
);
|
||||
|
||||
+6
-5
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user