mirror of
https://github.com/ziglang/zig.git
synced 2025-12-15 18:53:07 +00:00
parent
069a079ddc
commit
50bbb9d960
@ -306,7 +306,7 @@ const FreebsdImpl = struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const rc = os.freebsd._umtx_op(
|
const rc = os.freebsd._umtx_op(
|
||||||
@intFromPtr(&ptr.value),
|
@intFromPtr(&ptr.raw),
|
||||||
@intFromEnum(os.freebsd.UMTX_OP.WAIT_UINT_PRIVATE),
|
@intFromEnum(os.freebsd.UMTX_OP.WAIT_UINT_PRIVATE),
|
||||||
@as(c_ulong, expect),
|
@as(c_ulong, expect),
|
||||||
tm_size,
|
tm_size,
|
||||||
@ -328,7 +328,7 @@ const FreebsdImpl = struct {
|
|||||||
|
|
||||||
fn wake(ptr: *const atomic.Value(u32), max_waiters: u32) void {
|
fn wake(ptr: *const atomic.Value(u32), max_waiters: u32) void {
|
||||||
const rc = os.freebsd._umtx_op(
|
const rc = os.freebsd._umtx_op(
|
||||||
@intFromPtr(&ptr.value),
|
@intFromPtr(&ptr.raw),
|
||||||
@intFromEnum(os.freebsd.UMTX_OP.WAKE_PRIVATE),
|
@intFromEnum(os.freebsd.UMTX_OP.WAKE_PRIVATE),
|
||||||
@as(c_ulong, max_waiters),
|
@as(c_ulong, max_waiters),
|
||||||
0, // there is no timeout struct
|
0, // there is no timeout struct
|
||||||
@ -354,7 +354,7 @@ const OpenbsdImpl = struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const rc = os.openbsd.futex(
|
const rc = os.openbsd.futex(
|
||||||
@as(*const volatile u32, @ptrCast(&ptr.value)),
|
@as(*const volatile u32, @ptrCast(&ptr.raw)),
|
||||||
os.openbsd.FUTEX_WAIT | os.openbsd.FUTEX_PRIVATE_FLAG,
|
os.openbsd.FUTEX_WAIT | os.openbsd.FUTEX_PRIVATE_FLAG,
|
||||||
@as(c_int, @bitCast(expect)),
|
@as(c_int, @bitCast(expect)),
|
||||||
if (timeout != null) &ts else null,
|
if (timeout != null) &ts else null,
|
||||||
@ -379,7 +379,7 @@ const OpenbsdImpl = struct {
|
|||||||
|
|
||||||
fn wake(ptr: *const atomic.Value(u32), max_waiters: u32) void {
|
fn wake(ptr: *const atomic.Value(u32), max_waiters: u32) void {
|
||||||
const rc = os.openbsd.futex(
|
const rc = os.openbsd.futex(
|
||||||
@as(*const volatile u32, @ptrCast(&ptr.value)),
|
@as(*const volatile u32, @ptrCast(&ptr.raw)),
|
||||||
os.openbsd.FUTEX_WAKE | os.openbsd.FUTEX_PRIVATE_FLAG,
|
os.openbsd.FUTEX_WAKE | os.openbsd.FUTEX_PRIVATE_FLAG,
|
||||||
std.math.cast(c_int, max_waiters) orelse std.math.maxInt(c_int),
|
std.math.cast(c_int, max_waiters) orelse std.math.maxInt(c_int),
|
||||||
null, // FUTEX_WAKE takes no timeout ptr
|
null, // FUTEX_WAKE takes no timeout ptr
|
||||||
@ -414,7 +414,7 @@ const DragonflyImpl = struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const value = @as(c_int, @bitCast(expect));
|
const value = @as(c_int, @bitCast(expect));
|
||||||
const addr = @as(*const volatile c_int, @ptrCast(&ptr.value));
|
const addr = @as(*const volatile c_int, @ptrCast(&ptr.raw));
|
||||||
const rc = os.dragonfly.umtx_sleep(addr, value, timeout_us);
|
const rc = os.dragonfly.umtx_sleep(addr, value, timeout_us);
|
||||||
|
|
||||||
switch (os.errno(rc)) {
|
switch (os.errno(rc)) {
|
||||||
@ -443,7 +443,7 @@ const DragonflyImpl = struct {
|
|||||||
// https://man.dragonflybsd.org/?command=umtx§ion=2
|
// https://man.dragonflybsd.org/?command=umtx§ion=2
|
||||||
// > umtx_wakeup() will generally return 0 unless the address is bad.
|
// > umtx_wakeup() will generally return 0 unless the address is bad.
|
||||||
// We are fine with the address being bad (e.g. for Semaphore.post() where Semaphore.wait() frees the Semaphore)
|
// We are fine with the address being bad (e.g. for Semaphore.post() where Semaphore.wait() frees the Semaphore)
|
||||||
const addr = @as(*const volatile c_int, @ptrCast(&ptr.value));
|
const addr = @as(*const volatile c_int, @ptrCast(&ptr.raw));
|
||||||
_ = os.dragonfly.umtx_wakeup(addr, to_wake);
|
_ = os.dragonfly.umtx_wakeup(addr, to_wake);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -461,7 +461,7 @@ const WasmImpl = struct {
|
|||||||
\\memory.atomic.wait32 0
|
\\memory.atomic.wait32 0
|
||||||
\\local.set %[ret]
|
\\local.set %[ret]
|
||||||
: [ret] "=r" (-> u32),
|
: [ret] "=r" (-> u32),
|
||||||
: [ptr] "r" (&ptr.value),
|
: [ptr] "r" (&ptr.raw),
|
||||||
[expected] "r" (@as(i32, @bitCast(expect))),
|
[expected] "r" (@as(i32, @bitCast(expect))),
|
||||||
[timeout] "r" (to),
|
[timeout] "r" (to),
|
||||||
);
|
);
|
||||||
@ -484,7 +484,7 @@ const WasmImpl = struct {
|
|||||||
\\memory.atomic.notify 0
|
\\memory.atomic.notify 0
|
||||||
\\local.set %[ret]
|
\\local.set %[ret]
|
||||||
: [ret] "=r" (-> u32),
|
: [ret] "=r" (-> u32),
|
||||||
: [ptr] "r" (&ptr.value),
|
: [ptr] "r" (&ptr.raw),
|
||||||
[waiters] "r" (max_waiters),
|
[waiters] "r" (max_waiters),
|
||||||
);
|
);
|
||||||
_ = woken_count; // can be 0 when linker flag 'shared-memory' is not enabled
|
_ = woken_count; // can be 0 when linker flag 'shared-memory' is not enabled
|
||||||
|
|||||||
@ -2387,6 +2387,7 @@ fn handleSegfaultPosix(sig: i32, info: *const os.siginfo_t, ctx_ptr: ?*const any
|
|||||||
else => unreachable,
|
else => unreachable,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const code = if (native_os == .netbsd) info.info.code else info.code;
|
||||||
nosuspend switch (panic_stage) {
|
nosuspend switch (panic_stage) {
|
||||||
0 => {
|
0 => {
|
||||||
panic_stage = 1;
|
panic_stage = 1;
|
||||||
@ -2396,14 +2397,14 @@ fn handleSegfaultPosix(sig: i32, info: *const os.siginfo_t, ctx_ptr: ?*const any
|
|||||||
panic_mutex.lock();
|
panic_mutex.lock();
|
||||||
defer panic_mutex.unlock();
|
defer panic_mutex.unlock();
|
||||||
|
|
||||||
dumpSegfaultInfoPosix(sig, info.code, addr, ctx_ptr);
|
dumpSegfaultInfoPosix(sig, code, addr, ctx_ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
waitForOtherThreadToFinishPanicking();
|
waitForOtherThreadToFinishPanicking();
|
||||||
},
|
},
|
||||||
else => {
|
else => {
|
||||||
// panic mutex already locked
|
// panic mutex already locked
|
||||||
dumpSegfaultInfoPosix(sig, info.code, addr, ctx_ptr);
|
dumpSegfaultInfoPosix(sig, code, addr, ctx_ptr);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user