Skip to content

Commit

Permalink
Experiment the new proposed abi of thread-spawn
Browse files Browse the repository at this point in the history
  • Loading branch information
yamt committed Jan 13, 2023
1 parent 4362b18 commit 6a3cd41
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions libc-bottom-half/sources/__wasilibc_real.c
Original file line number Diff line number Diff line change
Expand Up @@ -660,12 +660,23 @@ __wasi_errno_t __wasi_sock_shutdown(
}

#ifdef _REENTRANT
int32_t __imported_wasi_thread_spawn(int32_t arg0) __attribute__((
void __imported_wasi_thread_spawn(int32_t arg0, int32_t arg1) __attribute__((
__import_module__("wasi"),
__import_name__("thread_spawn")
__import_name__("thread-spawn")
));

int32_t __wasi_thread_spawn(void* start_arg) {
return __imported_wasi_thread_spawn((int32_t) start_arg);
struct {
uint8_t is_error;
union {
uint8_t error;
uint32_t tid;
} u;
} error_or_tid;
__imported_wasi_thread_spawn((int32_t) start_arg, (int32_t)(intptr_t)&error_or_tid);
if (error_or_tid.is_error) {
return -(int)error_or_tid.u.error;
}
return error_or_tid.u.tid;
}
#endif

0 comments on commit 6a3cd41

Please sign in to comment.