mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
std.Io.Threaded: apply netbsd todo hacks to openbsd
This commit is contained in:
parent
369a498023
commit
8c92b1c5bd
1 changed files with 7 additions and 1 deletions
|
|
@ -893,6 +893,7 @@ fn checkCancel(t: *Threaded) error{Canceled}!void {
|
|||
fn mutexLock(userdata: ?*anyopaque, prev_state: Io.Mutex.State, mutex: *Io.Mutex) Io.Cancelable!void {
|
||||
if (builtin.single_threaded) unreachable; // Interface should have prevented this.
|
||||
if (native_os == .netbsd) @panic("TODO");
|
||||
if (native_os == .openbsd) @panic("TODO");
|
||||
const t: *Threaded = @ptrCast(@alignCast(userdata));
|
||||
if (prev_state == .contended) {
|
||||
try futexWait(t, @ptrCast(&mutex.state), @intFromEnum(Io.Mutex.State.contended));
|
||||
|
|
@ -905,6 +906,7 @@ fn mutexLock(userdata: ?*anyopaque, prev_state: Io.Mutex.State, mutex: *Io.Mutex
|
|||
fn mutexLockUncancelable(userdata: ?*anyopaque, prev_state: Io.Mutex.State, mutex: *Io.Mutex) void {
|
||||
if (builtin.single_threaded) unreachable; // Interface should have prevented this.
|
||||
if (native_os == .netbsd) @panic("TODO");
|
||||
if (native_os == .openbsd) @panic("TODO");
|
||||
_ = userdata;
|
||||
if (prev_state == .contended) {
|
||||
futexWaitUncancelable(@ptrCast(&mutex.state), @intFromEnum(Io.Mutex.State.contended));
|
||||
|
|
@ -917,6 +919,7 @@ fn mutexLockUncancelable(userdata: ?*anyopaque, prev_state: Io.Mutex.State, mute
|
|||
fn mutexUnlock(userdata: ?*anyopaque, prev_state: Io.Mutex.State, mutex: *Io.Mutex) void {
|
||||
if (builtin.single_threaded) unreachable; // Interface should have prevented this.
|
||||
if (native_os == .netbsd) @panic("TODO");
|
||||
if (native_os == .openbsd) @panic("TODO");
|
||||
_ = userdata;
|
||||
_ = prev_state;
|
||||
if (@atomicRmw(Io.Mutex.State, &mutex.state, .Xchg, .unlocked, .release) == .contended) {
|
||||
|
|
@ -927,6 +930,7 @@ fn mutexUnlock(userdata: ?*anyopaque, prev_state: Io.Mutex.State, mutex: *Io.Mut
|
|||
fn conditionWaitUncancelable(userdata: ?*anyopaque, cond: *Io.Condition, mutex: *Io.Mutex) void {
|
||||
if (builtin.single_threaded) unreachable; // Deadlock.
|
||||
if (native_os == .netbsd) @panic("TODO");
|
||||
if (native_os == .openbsd) @panic("TODO");
|
||||
const t: *Threaded = @ptrCast(@alignCast(userdata));
|
||||
const t_io = ioBasic(t);
|
||||
comptime assert(@TypeOf(cond.state) == u64);
|
||||
|
|
@ -959,6 +963,7 @@ fn conditionWaitUncancelable(userdata: ?*anyopaque, cond: *Io.Condition, mutex:
|
|||
fn conditionWait(userdata: ?*anyopaque, cond: *Io.Condition, mutex: *Io.Mutex) Io.Cancelable!void {
|
||||
if (builtin.single_threaded) unreachable; // Deadlock.
|
||||
if (native_os == .netbsd) @panic("TODO");
|
||||
if (native_os == .openbsd) @panic("TODO");
|
||||
const t: *Threaded = @ptrCast(@alignCast(userdata));
|
||||
const t_io = ioBasic(t);
|
||||
comptime assert(@TypeOf(cond.state) == u64);
|
||||
|
|
@ -1060,6 +1065,7 @@ fn conditionWake(userdata: ?*anyopaque, cond: *Io.Condition, wake: Io.Condition.
|
|||
// - T1: s & signals == 0 -> FUTEX_WAIT(&epoch, e) (missed both epoch change and state change)
|
||||
_ = cond_epoch.fetchAdd(1, .release);
|
||||
if (native_os == .netbsd) @panic("TODO");
|
||||
if (native_os == .openbsd) @panic("TODO");
|
||||
futexWake(cond_epoch, to_wake);
|
||||
return;
|
||||
};
|
||||
|
|
@ -6001,7 +6007,7 @@ pub fn futexWake(ptr: *const std.atomic.Value(u32), max_waiters: u32) void {
|
|||
/// It can also block threads until the value is set with cancelation via timed
|
||||
/// waits. Statically initializable; four bytes on all targets.
|
||||
pub const ResetEvent = switch (native_os) {
|
||||
.illumos, .netbsd => ResetEventPosix,
|
||||
.illumos, .netbsd, .openbsd => ResetEventPosix,
|
||||
else => ResetEventFutex,
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue