Merge branch main into dev/wasi_threads
This commit is contained in:
@ -565,6 +565,7 @@ pthread_create_wrapper(wasm_exec_env_t exec_env,
|
||||
#if WASM_ENABLE_LIBC_WASI != 0
|
||||
WASIContext *wasi_ctx;
|
||||
#endif
|
||||
CApiFuncImport **new_c_api_func_imports = NULL;
|
||||
|
||||
bh_assert(module);
|
||||
bh_assert(module_inst);
|
||||
@ -597,6 +598,46 @@ pthread_create_wrapper(wasm_exec_env_t exec_env,
|
||||
wasm_runtime_set_wasi_ctx(new_module_inst, wasi_ctx);
|
||||
#endif
|
||||
|
||||
/* workaround about passing instantiate-linking information */
|
||||
{
|
||||
CApiFuncImport *c_api_func_imports;
|
||||
uint32 import_func_count = 0;
|
||||
uint32 size_in_bytes = 0;
|
||||
|
||||
#if WASM_ENABLE_INTERP != 0
|
||||
if (module_inst->module_type == Wasm_Module_Bytecode) {
|
||||
new_c_api_func_imports = &(
|
||||
((WASMModuleInstance *)new_module_inst)->e->c_api_func_imports);
|
||||
c_api_func_imports =
|
||||
((WASMModuleInstance *)module_inst)->e->c_api_func_imports;
|
||||
import_func_count = ((WASMModule *)module)->import_function_count;
|
||||
}
|
||||
#endif
|
||||
#if WASM_ENABLE_AOT != 0
|
||||
if (module_inst->module_type == Wasm_Module_AoT) {
|
||||
AOTModuleInstanceExtra *e =
|
||||
(AOTModuleInstanceExtra *)((AOTModuleInstance *)new_module_inst)
|
||||
->e;
|
||||
new_c_api_func_imports = &(e->c_api_func_imports);
|
||||
|
||||
e = (AOTModuleInstanceExtra *)((AOTModuleInstance *)module_inst)->e;
|
||||
c_api_func_imports = e->c_api_func_imports;
|
||||
|
||||
import_func_count = ((AOTModule *)module)->import_func_count;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (import_func_count != 0 && c_api_func_imports) {
|
||||
size_in_bytes = sizeof(CApiFuncImport *) * import_func_count;
|
||||
*new_c_api_func_imports = wasm_runtime_malloc(size_in_bytes);
|
||||
if (!(*new_c_api_func_imports))
|
||||
goto fail;
|
||||
|
||||
bh_memcpy_s(*new_c_api_func_imports, size_in_bytes,
|
||||
c_api_func_imports, size_in_bytes);
|
||||
}
|
||||
}
|
||||
|
||||
if (!(info_node = wasm_runtime_malloc(sizeof(ThreadInfoNode))))
|
||||
goto fail;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user