Skip to content

Commit 6a3cd41

Browse files
committed
Experiment the new proposed abi of thread-spawn
1 parent 4362b18 commit 6a3cd41

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

libc-bottom-half/sources/__wasilibc_real.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -660,12 +660,23 @@ __wasi_errno_t __wasi_sock_shutdown(
660660
}
661661

662662
#ifdef _REENTRANT
663-
int32_t __imported_wasi_thread_spawn(int32_t arg0) __attribute__((
663+
void __imported_wasi_thread_spawn(int32_t arg0, int32_t arg1) __attribute__((
664664
__import_module__("wasi"),
665-
__import_name__("thread_spawn")
665+
__import_name__("thread-spawn")
666666
));
667667

668668
int32_t __wasi_thread_spawn(void* start_arg) {
669-
return __imported_wasi_thread_spawn((int32_t) start_arg);
669+
struct {
670+
uint8_t is_error;
671+
union {
672+
uint8_t error;
673+
uint32_t tid;
674+
} u;
675+
} error_or_tid;
676+
__imported_wasi_thread_spawn((int32_t) start_arg, (int32_t)(intptr_t)&error_or_tid);
677+
if (error_or_tid.is_error) {
678+
return -(int)error_or_tid.u.error;
679+
}
680+
return error_or_tid.u.tid;
670681
}
671682
#endif

0 commit comments

Comments
 (0)