Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion core/iwasm/libraries/lib-pthread/lib_pthread_wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@
#include "../common/wasm_runtime_common.h"
#include "thread_manager.h"

#if WASM_ENABLE_INTERP != 0
#include "wasm_runtime.h"
#endif

#if WASM_ENABLE_AOT != 0
#include "aot_runtime.h"
#endif

#define WAMR_PTHREAD_KEYS_MAX 32

/* clang-format off */
Expand Down Expand Up @@ -523,6 +531,7 @@ pthread_create_wrapper(wasm_exec_env_t exec_env,
ThreadInfoNode *info_node = NULL;
ThreadRoutineArgs *routine_args = NULL;
uint32 thread_handle;
uint32 stack_size = 8192;
int32 ret = -1;
#if WASM_ENABLE_LIBC_WASI != 0
WASIContext *wasi_ctx;
Expand All @@ -531,8 +540,22 @@ pthread_create_wrapper(wasm_exec_env_t exec_env,
bh_assert(module);
bh_assert(module_inst);

#if WASM_ENABLE_INTERP != 0
if (module_inst->module_type == Wasm_Module_Bytecode) {
stack_size =
((WASMModuleInstance *)module_inst)->default_wasm_stack_size;
}
#endif

#if WASM_ENABLE_AOT != 0
if (module_inst->module_type == Wasm_Module_AoT) {
stack_size =
((AOTModuleInstance *)module_inst)->default_wasm_stack_size;
}
#endif

if (!(new_module_inst = wasm_runtime_instantiate_internal(
module, true, 8192, 0, NULL, 0)))
module, true, stack_size, 0, NULL, 0)))
return -1;

/* Set custom_data to new module instance */
Expand Down