| ... | ... | @@ -1023,6 +1023,7 @@ fn cancel( |
| 1023 | 1023 | fn mutexLock(userdata: ?*anyopaque, prev_state: Io.Mutex.State, mutex: *Io.Mutex) Io.Cancelable!void { |
| 1024 | 1024 | if (builtin.single_threaded) unreachable; // Interface should have prevented this. |
| 1025 | 1025 | if (native_os == .netbsd) @panic("TODO"); |
| 1026 | if (native_os == .openbsd) @panic("TODO"); |
| 1026 | 1027 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 1027 | 1028 | const current_thread = Thread.getCurrent(t); |
| 1028 | 1029 | if (prev_state == .contended) { |
| ... | ... | @@ -1036,6 +1037,7 @@ fn mutexLock(userdata: ?*anyopaque, prev_state: Io.Mutex.State, mutex: *Io.Mutex |
| 1036 | 1037 | fn mutexLockUncancelable(userdata: ?*anyopaque, prev_state: Io.Mutex.State, mutex: *Io.Mutex) void { |
| 1037 | 1038 | if (builtin.single_threaded) unreachable; // Interface should have prevented this. |
| 1038 | 1039 | if (native_os == .netbsd) @panic("TODO"); |
| 1040 | if (native_os == .openbsd) @panic("TODO"); |
| 1039 | 1041 | _ = userdata; |
| 1040 | 1042 | if (prev_state == .contended) { |
| 1041 | 1043 | futexWaitUncancelable(@ptrCast(&mutex.state), @intFromEnum(Io.Mutex.State.contended)); |
| ... | ... | @@ -1048,6 +1050,7 @@ fn mutexLockUncancelable(userdata: ?*anyopaque, prev_state: Io.Mutex.State, mute |
| 1048 | 1050 | fn mutexUnlock(userdata: ?*anyopaque, prev_state: Io.Mutex.State, mutex: *Io.Mutex) void { |
| 1049 | 1051 | if (builtin.single_threaded) unreachable; // Interface should have prevented this. |
| 1050 | 1052 | if (native_os == .netbsd) @panic("TODO"); |
| 1053 | if (native_os == .openbsd) @panic("TODO"); |
| 1051 | 1054 | _ = userdata; |
| 1052 | 1055 | _ = prev_state; |
| 1053 | 1056 | if (@atomicRmw(Io.Mutex.State, &mutex.state, .Xchg, .unlocked, .release) == .contended) { |
| ... | ... | @@ -1058,6 +1061,7 @@ fn mutexUnlock(userdata: ?*anyopaque, prev_state: Io.Mutex.State, mutex: *Io.Mut |
| 1058 | 1061 | fn conditionWaitUncancelable(userdata: ?*anyopaque, cond: *Io.Condition, mutex: *Io.Mutex) void { |
| 1059 | 1062 | if (builtin.single_threaded) unreachable; // Deadlock. |
| 1060 | 1063 | if (native_os == .netbsd) @panic("TODO"); |
| 1064 | if (native_os == .openbsd) @panic("TODO"); |
| 1061 | 1065 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 1062 | 1066 | const t_io = ioBasic(t); |
| 1063 | 1067 | comptime assert(@TypeOf(cond.state) == u64); |
| ... | ... | @@ -1090,6 +1094,7 @@ fn conditionWaitUncancelable(userdata: ?*anyopaque, cond: *Io.Condition, mutex: |
| 1090 | 1094 | fn conditionWait(userdata: ?*anyopaque, cond: *Io.Condition, mutex: *Io.Mutex) Io.Cancelable!void { |
| 1091 | 1095 | if (builtin.single_threaded) unreachable; // Deadlock. |
| 1092 | 1096 | if (native_os == .netbsd) @panic("TODO"); |
| 1097 | if (native_os == .openbsd) @panic("TODO"); |
| 1093 | 1098 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 1094 | 1099 | const current_thread = Thread.getCurrent(t); |
| 1095 | 1100 | const t_io = ioBasic(t); |
| ... | ... | @@ -1192,6 +1197,7 @@ fn conditionWake(userdata: ?*anyopaque, cond: *Io.Condition, wake: Io.Condition. |
| 1192 | 1197 | // - T1: s & signals == 0 -> FUTEX_WAIT(&epoch, e) (missed both epoch change and state change) |
| 1193 | 1198 | _ = cond_epoch.fetchAdd(1, .release); |
| 1194 | 1199 | if (native_os == .netbsd) @panic("TODO"); |
| 1200 | if (native_os == .openbsd) @panic("TODO"); |
| 1195 | 1201 | futexWake(cond_epoch, to_wake); |
| 1196 | 1202 | return; |
| 1197 | 1203 | }; |
| ... | ... | @@ -6862,7 +6868,7 @@ pub fn futexWake(ptr: *const std.atomic.Value(u32), max_waiters: u32) void { |
| 6862 | 6868 | /// It can also block threads until the value is set with cancelation via timed |
| 6863 | 6869 | /// waits. Statically initializable; four bytes on all targets. |
| 6864 | 6870 | pub const ResetEvent = switch (native_os) { |
| 6865 | | .illumos, .netbsd => ResetEventPosix, |
| 6871 | .illumos, .netbsd, .openbsd => ResetEventPosix, |
| 6866 | 6872 | else => ResetEventFutex, |
| 6867 | 6873 | }; |
| 6868 | 6874 | |