Skip to content

Commit

Permalink
WASI thread-spawn also requires atomics
Browse files Browse the repository at this point in the history
  • Loading branch information
turbolent committed Jun 22, 2024
1 parent 4f1a046 commit cb253a0
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions wasi/wasi.c
Original file line number Diff line number Diff line change
Expand Up @@ -4124,6 +4124,8 @@ wasi__threadX2Dspawn(

WASI_TRACE(("thread-spawn(startArg=%d)", startArg));

#if defined(WASM_THREAD_TYPE) && (defined(WASM_ATOMICS_MSVC) || defined(WASM_ATOMICS_GCC))

/* Find the thread start function that must be exported by the module */
for (; funcExport->func != NULL; funcExport++) {
if (strcmp(funcExport->name, "wasi_thread_start") == 0) {
Expand Down Expand Up @@ -4155,20 +4157,20 @@ wasi__threadX2Dspawn(
threadStartArg->startFunc = (wasiThreadStartFunc)startFunc;

/* Finally, start the thread */
#ifdef WASM_THREAD_TYPE
{
WASM_THREAD_TYPE thread;
if (!WASM_THREAD_CREATE(&thread, wasiThreadSpawn, threadStartArg)) {
WASI_TRACE(("thread-spawn: pthread_create failed"));
return -1;
}
}

WASI_TRACE(("thread-spawn: threadID=%d", threadID));

#else
WASI_TRACE(("thread-spawn: missing threads implementation"))
WASI_TRACE(("thread-spawn: missing threads and atomics implementation"))
return -1;
#endif

WASI_TRACE(("thread-spawn: threadID=%d", threadID));

return threadID;
}

0 comments on commit cb253a0

Please sign in to comment.