@@ -53,6 +53,17 @@ uint32
5353get_lib_pthread_export_apis (NativeSymbol * * p_lib_pthread_apis );
5454#endif
5555
56+ #if WASM_ENABLE_LIB_WASI_THREADS != 0
57+ bool
58+ lib_wasi_threads_init (void );
59+
60+ void
61+ lib_wasi_threads_destroy (void );
62+
63+ uint32
64+ get_lib_wasi_threads_export_apis (NativeSymbol * * p_lib_wasi_threads_apis );
65+ #endif
66+
5667uint32
5768get_libc_emcc_export_apis (NativeSymbol * * p_libc_emcc_apis );
5869
@@ -390,7 +401,7 @@ wasm_native_init()
390401 || WASM_ENABLE_BASE_LIB != 0 || WASM_ENABLE_LIBC_EMCC != 0 \
391402 || WASM_ENABLE_LIB_RATS != 0 || WASM_ENABLE_WASI_NN != 0 \
392403 || WASM_ENABLE_APP_FRAMEWORK != 0 || WASM_ENABLE_LIBC_WASI != 0 \
393- || WASM_ENABLE_LIB_PTHREAD != 0
404+ || WASM_ENABLE_LIB_PTHREAD != 0 || WASM_ENABLE_LIB_WASI_THREADS != 0
394405 NativeSymbol * native_symbols ;
395406 uint32 n_native_symbols ;
396407#endif
@@ -445,6 +456,17 @@ wasm_native_init()
445456 goto fail ;
446457#endif
447458
459+ #if WASM_ENABLE_LIB_WASI_THREADS != 0
460+ if (!lib_wasi_threads_init ())
461+ goto fail ;
462+
463+ n_native_symbols = get_lib_wasi_threads_export_apis (& native_symbols );
464+ if (n_native_symbols > 0
465+ && !wasm_native_register_natives ("wasi" , native_symbols ,
466+ n_native_symbols ))
467+ goto fail ;
468+ #endif
469+
448470#if WASM_ENABLE_LIBC_EMCC != 0
449471 n_native_symbols = get_libc_emcc_export_apis (& native_symbols );
450472 if (n_native_symbols > 0
@@ -465,15 +487,15 @@ wasm_native_init()
465487 n_native_symbols = get_wasi_nn_export_apis (& native_symbols );
466488 if (!wasm_native_register_natives ("wasi_nn" , native_symbols ,
467489 n_native_symbols ))
468- return false ;
490+ goto fail ;
469491#endif
470492
471493 return true;
472494#if WASM_ENABLE_SPEC_TEST != 0 || WASM_ENABLE_LIBC_BUILTIN != 0 \
473495 || WASM_ENABLE_BASE_LIB != 0 || WASM_ENABLE_LIBC_EMCC != 0 \
474496 || WASM_ENABLE_LIB_RATS != 0 || WASM_ENABLE_WASI_NN != 0 \
475497 || WASM_ENABLE_APP_FRAMEWORK != 0 || WASM_ENABLE_LIBC_WASI != 0 \
476- || WASM_ENABLE_LIB_PTHREAD != 0
498+ || WASM_ENABLE_LIB_PTHREAD != 0 || WASM_ENABLE_LIB_WASI_THREADS != 0
477499fail :
478500 wasm_native_destroy ();
479501 return false;
@@ -489,6 +511,10 @@ wasm_native_destroy()
489511 lib_pthread_destroy ();
490512#endif
491513
514+ #if WASM_ENABLE_LIB_WASI_THREADS != 0
515+ lib_wasi_threads_destroy ();
516+ #endif
517+
492518 node = g_native_symbols_list ;
493519 while (node ) {
494520 node_next = node -> next ;
0 commit comments