mirror of
https://github.com/ziglang/zig.git
synced 2026-02-18 23:39:17 +00:00
std.Thread: don't export wasi_thread_start in single-threaded mode
This commit is contained in:
parent
0555fe8d5b
commit
70414c1f43
@ -1018,12 +1018,15 @@ const WasiThreadImpl = struct {
|
||||
return .{ .thread = &instance.thread };
|
||||
}
|
||||
|
||||
/// Bootstrap procedure, called by the host environment after thread creation.
|
||||
export fn wasi_thread_start(tid: i32, arg: *Instance) void {
|
||||
if (builtin.single_threaded) {
|
||||
// ensure function is not analyzed in single-threaded mode
|
||||
return;
|
||||
comptime {
|
||||
if (!builtin.single_threaded) {
|
||||
@export(wasi_thread_start, .{ .name = "wasi_thread_start" });
|
||||
}
|
||||
}
|
||||
|
||||
/// Called by the host environment after thread creation.
|
||||
fn wasi_thread_start(tid: i32, arg: *Instance) callconv(.c) void {
|
||||
comptime assert(!builtin.single_threaded);
|
||||
__set_stack_pointer(arg.thread.memory.ptr + arg.stack_offset);
|
||||
__wasm_init_tls(arg.thread.memory.ptr + arg.tls_offset);
|
||||
@atomicStore(u32, &WasiThreadImpl.tls_thread_id, @intCast(tid), .seq_cst);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user