Add additional WAMR header for clangd to find

This commit is contained in:
2026-07-26 18:08:43 +02:00
parent 8c9cc08de0
commit 167c3a1290
2 changed files with 323 additions and 314 deletions
+59
View File
@@ -0,0 +1,59 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
/**
* @file lib_export.h
*
*/
#ifndef _LIB_EXPORT_H_
#define _LIB_EXPORT_H_
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct NativeSymbol {
const char *symbol;
void *func_ptr;
const char *signature;
/* attachment which can be retrieved in native API by
calling wasm_runtime_get_function_attachment(exec_env) */
void *attachment;
} NativeSymbol;
/* clang-format off */
#define EXPORT_WASM_API(symbol) \
{ #symbol, (void *)symbol, NULL, NULL }
#define EXPORT_WASM_API2(symbol) \
{ #symbol, (void *)symbol##_wrapper, NULL, NULL }
#define EXPORT_WASM_API_WITH_SIG(symbol, signature) \
{ #symbol, (void *)symbol, signature, NULL }
#define EXPORT_WASM_API_WITH_SIG2(symbol, signature) \
{ #symbol, (void *)symbol##_wrapper, signature, NULL }
#define EXPORT_WASM_API_WITH_ATT(symbol, signature, attachment) \
{ #symbol, (void *)symbol, signature, attachment }
#define EXPORT_WASM_API_WITH_ATT2(symbol, signature, attachment) \
{ #symbol, (void *)symbol##_wrapper, signature, attachment }
/* clang-format on */
/**
* Get the exported APIs of base lib
*
* @param p_base_lib_apis return the exported API array of base lib
*
* @return the number of the exported API
*/
uint32_t get_base_lib_export_apis(NativeSymbol **p_base_lib_apis);
#ifdef __cplusplus
}
#endif
#endif /* end of _LIB_EXPORT_H_ */
+95 -145
View File
@@ -12,9 +12,9 @@
#ifndef _WASM_EXPORT_H #ifndef _WASM_EXPORT_H
#define _WASM_EXPORT_H #define _WASM_EXPORT_H
#include <stdint.h>
#include <stdbool.h>
#include "lib_export.h" #include "lib_export.h"
#include <stdbool.h>
#include <stdint.h>
#ifndef WASM_RUNTIME_API_EXTERN #ifndef WASM_RUNTIME_API_EXTERN
#if defined(_MSC_BUILD) #if defined(_MSC_BUILD)
@@ -361,8 +361,7 @@ typedef struct SharedHeapInitArgs {
* *
* @return true if success, false otherwise * @return true if success, false otherwise
*/ */
WASM_RUNTIME_API_EXTERN bool WASM_RUNTIME_API_EXTERN bool wasm_runtime_init(void);
wasm_runtime_init(void);
/** /**
* Initialize the WASM runtime environment, WASM running mode, * Initialize the WASM runtime environment, WASM running mode,
@@ -373,16 +372,14 @@ wasm_runtime_init(void);
* *
* @return return true if success, false otherwise * @return return true if success, false otherwise
*/ */
WASM_RUNTIME_API_EXTERN bool WASM_RUNTIME_API_EXTERN bool wasm_runtime_full_init(RuntimeInitArgs *init_args);
wasm_runtime_full_init(RuntimeInitArgs *init_args);
/** /**
* Set the log level. To be called after the runtime is initialized. * Set the log level. To be called after the runtime is initialized.
* *
* @param level the log level to set * @param level the log level to set
*/ */
WASM_RUNTIME_API_EXTERN void WASM_RUNTIME_API_EXTERN void wasm_runtime_set_log_level(log_level_t level);
wasm_runtime_set_log_level(log_level_t level);
/** /**
* Query whether a certain running mode is supported for the runtime * Query whether a certain running mode is supported for the runtime
@@ -409,8 +406,7 @@ wasm_runtime_set_default_running_mode(RunningMode running_mode);
/** /**
* Destroy the WASM runtime environment. * Destroy the WASM runtime environment.
*/ */
WASM_RUNTIME_API_EXTERN void WASM_RUNTIME_API_EXTERN void wasm_runtime_destroy(void);
wasm_runtime_destroy(void);
/** /**
* Allocate memory from runtime memory environment. * Allocate memory from runtime memory environment.
@@ -419,8 +415,7 @@ wasm_runtime_destroy(void);
* *
* @return the pointer to memory allocated * @return the pointer to memory allocated
*/ */
WASM_RUNTIME_API_EXTERN void * WASM_RUNTIME_API_EXTERN void *wasm_runtime_malloc(unsigned int size);
wasm_runtime_malloc(unsigned int size);
/** /**
* Reallocate memory from runtime memory environment * Reallocate memory from runtime memory environment
@@ -430,14 +425,13 @@ wasm_runtime_malloc(unsigned int size);
* *
* @return the pointer to memory reallocated * @return the pointer to memory reallocated
*/ */
WASM_RUNTIME_API_EXTERN void * WASM_RUNTIME_API_EXTERN void *wasm_runtime_realloc(void *ptr,
wasm_runtime_realloc(void *ptr, unsigned int size); unsigned int size);
/* /*
* Free memory to runtime memory environment. * Free memory to runtime memory environment.
*/ */
WASM_RUNTIME_API_EXTERN void WASM_RUNTIME_API_EXTERN void wasm_runtime_free(void *ptr);
wasm_runtime_free(void *ptr);
/* /*
* Get memory info, only pool mode is supported now. * Get memory info, only pool mode is supported now.
@@ -453,8 +447,8 @@ wasm_runtime_get_mem_alloc_info(mem_alloc_info_t *mem_alloc_info);
* *
* @return the package type, return Package_Type_Unknown if the type is unknown * @return the package type, return Package_Type_Unknown if the type is unknown
*/ */
WASM_RUNTIME_API_EXTERN package_type_t WASM_RUNTIME_API_EXTERN package_type_t get_package_type(const uint8_t *buf,
get_package_type(const uint8_t *buf, uint32_t size); uint32_t size);
/** /**
* Get the package type of a buffer (same as get_package_type). * Get the package type of a buffer (same as get_package_type).
@@ -517,8 +511,8 @@ wasm_runtime_get_current_package_version(package_type_t package_type);
* *
* @return true if success, false otherwise * @return true if success, false otherwise
*/ */
WASM_RUNTIME_API_EXTERN bool WASM_RUNTIME_API_EXTERN bool wasm_runtime_is_xip_file(const uint8_t *buf,
wasm_runtime_is_xip_file(const uint8_t *buf, uint32_t size); uint32_t size);
/** /**
* Callback to load a module file into a buffer in multi-module feature * Callback to load a module file into a buffer in multi-module feature
@@ -588,9 +582,8 @@ wasm_runtime_find_module_registered(const char *module_name);
* *
* @return return WASM module loaded, NULL if failed * @return return WASM module loaded, NULL if failed
*/ */
WASM_RUNTIME_API_EXTERN wasm_module_t WASM_RUNTIME_API_EXTERN wasm_module_t wasm_runtime_load(
wasm_runtime_load(uint8_t *buf, uint32_t size, char *error_buf, uint8_t *buf, uint32_t size, char *error_buf, uint32_t error_buf_size);
uint32_t error_buf_size);
/** /**
* Load a WASM module with specified load argument. * Load a WASM module with specified load argument.
@@ -603,8 +596,7 @@ wasm_runtime_load_ex(uint8_t *buf, uint32_t size, const LoadArgs *args,
* Resolve symbols for a previously loaded WASM module. Only useful when the * Resolve symbols for a previously loaded WASM module. Only useful when the
* module was loaded with LoadArgs::no_resolve set to true * module was loaded with LoadArgs::no_resolve set to true
*/ */
WASM_RUNTIME_API_EXTERN bool WASM_RUNTIME_API_EXTERN bool wasm_runtime_resolve_symbols(wasm_module_t module);
wasm_runtime_resolve_symbols(wasm_module_t module);
/** /**
* Load a WASM module from a specified WASM or AOT section list. * Load a WASM module from a specified WASM or AOT section list.
* *
@@ -624,8 +616,7 @@ wasm_runtime_load_from_sections(wasm_section_list_t section_list, bool is_aot,
* *
* @param module the module to be unloaded * @param module the module to be unloaded
*/ */
WASM_RUNTIME_API_EXTERN void WASM_RUNTIME_API_EXTERN void wasm_runtime_unload(wasm_module_t module);
wasm_runtime_unload(wasm_module_t module);
/** /**
* Get the module hash of a WASM module, currently only available on * Get the module hash of a WASM module, currently only available on
@@ -635,8 +626,7 @@ wasm_runtime_unload(wasm_module_t module);
* *
* @return the module hash of the WASM module * @return the module hash of the WASM module
*/ */
char * char *wasm_runtime_get_module_hash(wasm_module_t module);
wasm_runtime_get_module_hash(wasm_module_t module);
/** /**
* Set WASI parameters. * Set WASI parameters.
@@ -671,13 +661,11 @@ wasm_runtime_get_module_hash(wasm_module_t module);
* INVALID_HANDLE_VALUE on Windows), the platform default * INVALID_HANDLE_VALUE on Windows), the platform default
* for STDERR is used. * for STDERR is used.
*/ */
WASM_RUNTIME_API_EXTERN void WASM_RUNTIME_API_EXTERN void wasm_runtime_set_wasi_args_ex(
wasm_runtime_set_wasi_args_ex(wasm_module_t module, const char *dir_list[], wasm_module_t module, const char *dir_list[], uint32_t dir_count,
uint32_t dir_count, const char *map_dir_list[], const char *map_dir_list[], uint32_t map_dir_count, const char *env[],
uint32_t map_dir_count, const char *env[], uint32_t env_count, char *argv[], int argc, int64_t stdinfd,
uint32_t env_count, char *argv[], int argc, int64_t stdoutfd, int64_t stderrfd);
int64_t stdinfd, int64_t stdoutfd,
int64_t stderrfd);
/** /**
* Set WASI parameters. * Set WASI parameters.
@@ -718,11 +706,9 @@ wasm_runtime_set_wasi_ns_lookup_pool(wasm_module_t module,
* *
* @return return the instantiated WASM module instance, NULL if failed * @return return the instantiated WASM module instance, NULL if failed
*/ */
WASM_RUNTIME_API_EXTERN wasm_module_inst_t WASM_RUNTIME_API_EXTERN wasm_module_inst_t wasm_runtime_instantiate(
wasm_runtime_instantiate(const wasm_module_t module, const wasm_module_t module, uint32_t default_stack_size,
uint32_t default_stack_size, uint32_t host_managed_heap_size, char *error_buf, uint32_t error_buf_size);
uint32_t host_managed_heap_size, char *error_buf,
uint32_t error_buf_size);
/** /**
* Instantiate a WASM module, with specified instantiation arguments * Instantiate a WASM module, with specified instantiation arguments
@@ -730,9 +716,8 @@ wasm_runtime_instantiate(const wasm_module_t module,
* Same as wasm_runtime_instantiate, but it also allows overwriting maximum * Same as wasm_runtime_instantiate, but it also allows overwriting maximum
* memory * memory
*/ */
WASM_RUNTIME_API_EXTERN wasm_module_inst_t WASM_RUNTIME_API_EXTERN wasm_module_inst_t wasm_runtime_instantiate_ex(
wasm_runtime_instantiate_ex(const wasm_module_t module, const wasm_module_t module, const InstantiationArgs *args, char *error_buf,
const InstantiationArgs *args, char *error_buf,
uint32_t error_buf_size); uint32_t error_buf_size);
/** /**
@@ -768,22 +753,15 @@ WASM_RUNTIME_API_EXTERN void
wasm_runtime_instantiation_args_set_wasi_arg(struct InstantiationArgs2 *p, wasm_runtime_instantiation_args_set_wasi_arg(struct InstantiationArgs2 *p,
char *argv[], int argc); char *argv[], int argc);
WASM_RUNTIME_API_EXTERN void WASM_RUNTIME_API_EXTERN void wasm_runtime_instantiation_args_set_wasi_env(
wasm_runtime_instantiation_args_set_wasi_env(struct InstantiationArgs2 *p, struct InstantiationArgs2 *p, const char *env[], uint32_t env_count);
const char *env[],
uint32_t env_count);
WASM_RUNTIME_API_EXTERN void WASM_RUNTIME_API_EXTERN void wasm_runtime_instantiation_args_set_wasi_dir(
wasm_runtime_instantiation_args_set_wasi_dir(struct InstantiationArgs2 *p, struct InstantiationArgs2 *p, const char *dir_list[], uint32_t dir_count,
const char *dir_list[], const char *map_dir_list[], uint32_t map_dir_count);
uint32_t dir_count,
const char *map_dir_list[],
uint32_t map_dir_count);
WASM_RUNTIME_API_EXTERN void WASM_RUNTIME_API_EXTERN void wasm_runtime_instantiation_args_set_wasi_stdio(
wasm_runtime_instantiation_args_set_wasi_stdio(struct InstantiationArgs2 *p, struct InstantiationArgs2 *p, int64_t stdinfd, int64_t stdoutfd,
int64_t stdinfd,
int64_t stdoutfd,
int64_t stderrfd); int64_t stderrfd);
WASM_RUNTIME_API_EXTERN void WASM_RUNTIME_API_EXTERN void
@@ -802,9 +780,8 @@ wasm_runtime_instantiation_args_set_wasi_ns_lookup_pool(
* Same as wasm_runtime_instantiate_ex, but this version takes * Same as wasm_runtime_instantiate_ex, but this version takes
* InstantiationArgs2, which can be extended without breaking the ABI. * InstantiationArgs2, which can be extended without breaking the ABI.
*/ */
WASM_RUNTIME_API_EXTERN wasm_module_inst_t WASM_RUNTIME_API_EXTERN wasm_module_inst_t wasm_runtime_instantiate_ex2(
wasm_runtime_instantiate_ex2(const wasm_module_t module, const wasm_module_t module, const struct InstantiationArgs2 *args,
const struct InstantiationArgs2 *args,
char *error_buf, uint32_t error_buf_size); char *error_buf, uint32_t error_buf_size);
/** /**
@@ -879,9 +856,8 @@ wasm_runtime_get_wasi_exit_code(wasm_module_inst_t module_inst);
* *
* @return the function instance found, NULL if not found * @return the function instance found, NULL if not found
*/ */
WASM_RUNTIME_API_EXTERN wasm_function_inst_t WASM_RUNTIME_API_EXTERN wasm_function_inst_t wasm_runtime_lookup_function(
wasm_runtime_lookup_function(const wasm_module_inst_t module_inst, const wasm_module_inst_t module_inst, const char *name);
const char *name);
/** /**
* Get parameter count of the function instance * Get parameter count of the function instance
@@ -891,9 +867,8 @@ wasm_runtime_lookup_function(const wasm_module_inst_t module_inst,
* *
* @return the parameter count of the function instance * @return the parameter count of the function instance
*/ */
WASM_RUNTIME_API_EXTERN uint32_t WASM_RUNTIME_API_EXTERN uint32_t wasm_func_get_param_count(
wasm_func_get_param_count(const wasm_function_inst_t func_inst, const wasm_function_inst_t func_inst, const wasm_module_inst_t module_inst);
const wasm_module_inst_t module_inst);
/** /**
* Get result count of the function instance * Get result count of the function instance
@@ -903,9 +878,8 @@ wasm_func_get_param_count(const wasm_function_inst_t func_inst,
* *
* @return the result count of the function instance * @return the result count of the function instance
*/ */
WASM_RUNTIME_API_EXTERN uint32_t WASM_RUNTIME_API_EXTERN uint32_t wasm_func_get_result_count(
wasm_func_get_result_count(const wasm_function_inst_t func_inst, const wasm_function_inst_t func_inst, const wasm_module_inst_t module_inst);
const wasm_module_inst_t module_inst);
/** /**
* Get parameter types of the function instance * Get parameter types of the function instance
@@ -940,9 +914,8 @@ wasm_func_get_result_types(const wasm_function_inst_t func_inst,
* @return the execution environment, NULL if failed, e.g. invalid * @return the execution environment, NULL if failed, e.g. invalid
* stack size is passed * stack size is passed
*/ */
WASM_RUNTIME_API_EXTERN wasm_exec_env_t WASM_RUNTIME_API_EXTERN wasm_exec_env_t wasm_runtime_create_exec_env(
wasm_runtime_create_exec_env(wasm_module_inst_t module_inst, wasm_module_inst_t module_inst, uint32_t stack_size);
uint32_t stack_size);
/** /**
* Destroy the execution environment. * Destroy the execution environment.
@@ -1018,9 +991,8 @@ wasm_runtime_get_exec_env_singleton(wasm_module_inst_t module_inst);
* *
* @return debug port if success, 0 otherwise. * @return debug port if success, 0 otherwise.
*/ */
WASM_RUNTIME_API_EXTERN uint32_t WASM_RUNTIME_API_EXTERN uint32_t wasm_runtime_start_debug_instance_with_port(
wasm_runtime_start_debug_instance_with_port(wasm_exec_env_t exec_env, wasm_exec_env_t exec_env, int32_t port);
int32_t port);
/** /**
* Same as wasm_runtime_start_debug_instance_with_port(env, -1). * Same as wasm_runtime_start_debug_instance_with_port(env, -1).
@@ -1040,20 +1012,17 @@ wasm_runtime_start_debug_instance(wasm_exec_env_t exec_env);
* *
* @return true if success, false otherwise * @return true if success, false otherwise
*/ */
WASM_RUNTIME_API_EXTERN bool WASM_RUNTIME_API_EXTERN bool wasm_runtime_init_thread_env(void);
wasm_runtime_init_thread_env(void);
/** /**
* Destroy the thread environment * Destroy the thread environment
*/ */
WASM_RUNTIME_API_EXTERN void WASM_RUNTIME_API_EXTERN void wasm_runtime_destroy_thread_env(void);
wasm_runtime_destroy_thread_env(void);
/** /**
* Whether the thread environment is initialized * Whether the thread environment is initialized
*/ */
WASM_RUNTIME_API_EXTERN bool WASM_RUNTIME_API_EXTERN bool wasm_runtime_thread_env_inited(void);
wasm_runtime_thread_env_inited(void);
/** /**
* Get WASM module instance from execution environment * Get WASM module instance from execution environment
@@ -1088,9 +1057,8 @@ wasm_runtime_set_module_inst(wasm_exec_env_t exec_env,
* *
* @return The memory instance if found, NULL otherwise * @return The memory instance if found, NULL otherwise
*/ */
WASM_RUNTIME_API_EXTERN wasm_memory_inst_t WASM_RUNTIME_API_EXTERN wasm_memory_inst_t wasm_runtime_lookup_memory(
wasm_runtime_lookup_memory(const wasm_module_inst_t module_inst, const wasm_module_inst_t module_inst, const char *name);
const char *name);
/** /**
* @brief Get the default memory instance * @brief Get the default memory instance
@@ -1171,8 +1139,8 @@ wasm_memory_get_base_address(const wasm_memory_inst_t memory_inst);
* *
* @return True if successful, false otherwise * @return True if successful, false otherwise
*/ */
WASM_RUNTIME_API_EXTERN bool WASM_RUNTIME_API_EXTERN bool wasm_memory_enlarge(wasm_memory_inst_t memory_inst,
wasm_memory_enlarge(wasm_memory_inst_t memory_inst, uint64_t inc_page_count); uint64_t inc_page_count);
/** /**
* Call the given WASM function of a WASM module instance with * Call the given WASM function of a WASM module instance with
@@ -1409,9 +1377,8 @@ wasm_runtime_is_bounds_checks_enabled(wasm_module_inst_t module_inst);
* it is not an absolute address. * it is not an absolute address.
* Return non-zero if success, zero if failed. * Return non-zero if success, zero if failed.
*/ */
WASM_RUNTIME_API_EXTERN uint64_t WASM_RUNTIME_API_EXTERN uint64_t wasm_runtime_module_malloc(
wasm_runtime_module_malloc(wasm_module_inst_t module_inst, uint64_t size, wasm_module_inst_t module_inst, uint64_t size, void **p_native_addr);
void **p_native_addr);
/** /**
* Free memory to the heap of WASM module instance * Free memory to the heap of WASM module instance
@@ -1435,9 +1402,8 @@ wasm_runtime_module_free(wasm_module_inst_t module_inst, uint64_t ptr);
* it is not an absolute address. * it is not an absolute address.
* Return non-zero if success, zero if failed. * Return non-zero if success, zero if failed.
*/ */
WASM_RUNTIME_API_EXTERN uint64_t WASM_RUNTIME_API_EXTERN uint64_t wasm_runtime_module_dup_data(
wasm_runtime_module_dup_data(wasm_module_inst_t module_inst, const char *src, wasm_module_inst_t module_inst, const char *src, uint64_t size);
uint64_t size);
/** /**
* Validate the app address, check whether it belongs to WASM module * Validate the app address, check whether it belongs to WASM module
@@ -1516,9 +1482,8 @@ wasm_runtime_addr_app_to_native(wasm_module_inst_t module_inst,
* *
* @return the app address converted * @return the app address converted
*/ */
WASM_RUNTIME_API_EXTERN uint64_t WASM_RUNTIME_API_EXTERN uint64_t wasm_runtime_addr_native_to_app(
wasm_runtime_addr_native_to_app(wasm_module_inst_t module_inst, wasm_module_inst_t module_inst, void *native_ptr);
void *native_ptr);
/** /**
* Get the app address range (relative address) that a app address belongs to * Get the app address range (relative address) that a app address belongs to
@@ -1530,11 +1495,9 @@ wasm_runtime_addr_native_to_app(wasm_module_inst_t module_inst,
* *
* @return true if success, false otherwise. * @return true if success, false otherwise.
*/ */
WASM_RUNTIME_API_EXTERN bool WASM_RUNTIME_API_EXTERN bool wasm_runtime_get_app_addr_range(
wasm_runtime_get_app_addr_range(wasm_module_inst_t module_inst, wasm_module_inst_t module_inst, uint64_t app_offset,
uint64_t app_offset, uint64_t *p_app_start_offset, uint64_t *p_app_end_offset);
uint64_t *p_app_start_offset,
uint64_t *p_app_end_offset);
/** /**
* Get the native address range (absolute address) that a native address * Get the native address range (absolute address) that a native address
@@ -1549,11 +1512,9 @@ wasm_runtime_get_app_addr_range(wasm_module_inst_t module_inst,
* *
* @return true if success, false otherwise. * @return true if success, false otherwise.
*/ */
WASM_RUNTIME_API_EXTERN bool WASM_RUNTIME_API_EXTERN bool wasm_runtime_get_native_addr_range(
wasm_runtime_get_native_addr_range(wasm_module_inst_t module_inst, wasm_module_inst_t module_inst, uint8_t *native_ptr,
uint8_t *native_ptr, uint8_t **p_native_start_addr, uint8_t **p_native_end_addr);
uint8_t **p_native_start_addr,
uint8_t **p_native_end_addr);
/** /**
* Get the number of import items for a WASM module * Get the number of import items for a WASM module
@@ -1631,9 +1592,8 @@ wasm_func_type_get_param_count(const wasm_func_type_t func_type);
* *
* @return the kind of the parameter if successful, -1 otherwise * @return the kind of the parameter if successful, -1 otherwise
*/ */
WASM_RUNTIME_API_EXTERN wasm_valkind_t WASM_RUNTIME_API_EXTERN wasm_valkind_t wasm_func_type_get_param_valkind(
wasm_func_type_get_param_valkind(const wasm_func_type_t func_type, const wasm_func_type_t func_type, uint32_t param_index);
uint32_t param_index);
/** /**
* Get the number of results for a function type * Get the number of results for a function type
@@ -1653,9 +1613,8 @@ wasm_func_type_get_result_count(const wasm_func_type_t func_type);
* *
* @return the kind of the result if successful, -1 otherwise * @return the kind of the result if successful, -1 otherwise
*/ */
WASM_RUNTIME_API_EXTERN wasm_valkind_t WASM_RUNTIME_API_EXTERN wasm_valkind_t wasm_func_type_get_result_valkind(
wasm_func_type_get_result_valkind(const wasm_func_type_t func_type, const wasm_func_type_t func_type, uint32_t result_index);
uint32_t result_index);
/** /**
* Get the kind for a global type * Get the kind for a global type
@@ -1978,8 +1937,7 @@ typedef uintptr_t wasm_thread_t;
* *
* @param num maximum thread num * @param num maximum thread num
*/ */
WASM_RUNTIME_API_EXTERN void WASM_RUNTIME_API_EXTERN void wasm_runtime_set_max_thread_num(uint32_t num);
wasm_runtime_set_max_thread_num(uint32_t num);
/** /**
* Spawn a new exec_env, the spawned exec_env * Spawn a new exec_env, the spawned exec_env
@@ -2022,8 +1980,8 @@ wasm_runtime_spawn_thread(wasm_exec_env_t exec_env, wasm_thread_t *tid,
* *
* @return 0 if success, error number otherwise * @return 0 if success, error number otherwise
*/ */
WASM_RUNTIME_API_EXTERN int32_t WASM_RUNTIME_API_EXTERN int32_t wasm_runtime_join_thread(wasm_thread_t tid,
wasm_runtime_join_thread(wasm_thread_t tid, void **retval); void **retval);
/** /**
* Map external object to an internal externref index: if the index * Map external object to an internal externref index: if the index
@@ -2076,8 +2034,8 @@ wasm_externref_set_cleanup(wasm_module_inst_t module_inst, void *extern_obj,
* *
* @return true if success, false otherwise * @return true if success, false otherwise
*/ */
WASM_RUNTIME_API_EXTERN bool WASM_RUNTIME_API_EXTERN bool wasm_externref_ref2obj(uint32_t externref_idx,
wasm_externref_ref2obj(uint32_t externref_idx, void **p_extern_obj); void **p_extern_obj);
/** /**
* Retain an extern object which is mapped to the internal externref * Retain an extern object which is mapped to the internal externref
@@ -2088,8 +2046,7 @@ wasm_externref_ref2obj(uint32_t externref_idx, void **p_extern_obj);
* to retain * to retain
* @return true if success, false otherwise * @return true if success, false otherwise
*/ */
WASM_RUNTIME_API_EXTERN bool WASM_RUNTIME_API_EXTERN bool wasm_externref_retain(uint32_t externref_idx);
wasm_externref_retain(uint32_t externref_idx);
/** /**
* Dump the call stack to stdout * Dump the call stack to stdout
@@ -2123,9 +2080,8 @@ wasm_runtime_get_call_stack_buf_size(wasm_exec_env_t exec_env);
* @return bytes dumped to the buffer, including the terminating null * @return bytes dumped to the buffer, including the terminating null
* byte ('\0'), 0 means error and data in buf may be invalid * byte ('\0'), 0 means error and data in buf may be invalid
*/ */
WASM_RUNTIME_API_EXTERN uint32_t WASM_RUNTIME_API_EXTERN uint32_t wasm_runtime_dump_call_stack_to_buf(
wasm_runtime_dump_call_stack_to_buf(wasm_exec_env_t exec_env, char *buf, wasm_exec_env_t exec_env, char *buf, uint32_t len);
uint32_t len);
/** /**
* Get the size required to store the LLVM PGO profile data * Get the size required to store the LLVM PGO profile data
@@ -2147,9 +2103,8 @@ wasm_runtime_get_pgo_prof_data_size(wasm_module_inst_t module_inst);
* @return bytes dumped to the buffer, 0 means error and data in buf * @return bytes dumped to the buffer, 0 means error and data in buf
* may be invalid * may be invalid
*/ */
WASM_RUNTIME_API_EXTERN uint32_t WASM_RUNTIME_API_EXTERN uint32_t wasm_runtime_dump_pgo_prof_data_to_buf(
wasm_runtime_dump_pgo_prof_data_to_buf(wasm_module_inst_t module_inst, wasm_module_inst_t module_inst, char *buf, uint32_t len);
char *buf, uint32_t len);
/** /**
* Get a custom section by name * Get a custom section by name
@@ -2212,8 +2167,7 @@ typedef void (*enlarge_memory_error_callback_t)(
/** /**
* Setup callback invoked when memory.grow fails * Setup callback invoked when memory.grow fails
*/ */
WASM_RUNTIME_API_EXTERN void WASM_RUNTIME_API_EXTERN void wasm_runtime_set_enlarge_mem_error_callback(
wasm_runtime_set_enlarge_mem_error_callback(
const enlarge_memory_error_callback_t callback, void *user_data); const enlarge_memory_error_callback_t callback, void *user_data);
/* /*
@@ -2268,21 +2222,19 @@ wasm_runtime_set_enlarge_mem_error_callback(
* - The destructor is called only on the main instance. * - The destructor is called only on the main instance.
*/ */
WASM_RUNTIME_API_EXTERN void * WASM_RUNTIME_API_EXTERN void *wasm_runtime_create_context_key(
wasm_runtime_create_context_key(void (*dtor)(wasm_module_inst_t inst, void (*dtor)(wasm_module_inst_t inst, void *ctx));
void *ctx));
WASM_RUNTIME_API_EXTERN void WASM_RUNTIME_API_EXTERN void wasm_runtime_destroy_context_key(void *key);
wasm_runtime_destroy_context_key(void *key);
WASM_RUNTIME_API_EXTERN void WASM_RUNTIME_API_EXTERN void wasm_runtime_set_context(wasm_module_inst_t inst,
wasm_runtime_set_context(wasm_module_inst_t inst, void *key, void *ctx); void *key, void *ctx);
WASM_RUNTIME_API_EXTERN void WASM_RUNTIME_API_EXTERN void
wasm_runtime_set_context_spread(wasm_module_inst_t inst, void *key, void *ctx); wasm_runtime_set_context_spread(wasm_module_inst_t inst, void *key, void *ctx);
WASM_RUNTIME_API_EXTERN void * WASM_RUNTIME_API_EXTERN void *wasm_runtime_get_context(wasm_module_inst_t inst,
wasm_runtime_get_context(wasm_module_inst_t inst, void *key); void *key);
/* /*
* wasm_runtime_begin_blocking_op/wasm_runtime_end_blocking_op * wasm_runtime_begin_blocking_op/wasm_runtime_end_blocking_op
@@ -2419,9 +2371,8 @@ wasm_runtime_create_shared_heap(SharedHeapInitArgs *init_args);
* @param body The body of the shared heap chain to be appended. * @param body The body of the shared heap chain to be appended.
* @return The new head of the shared heap chain. NULL if failed. * @return The new head of the shared heap chain. NULL if failed.
*/ */
WASM_RUNTIME_API_EXTERN wasm_shared_heap_t WASM_RUNTIME_API_EXTERN wasm_shared_heap_t wasm_runtime_chain_shared_heaps(
wasm_runtime_chain_shared_heaps(wasm_shared_heap_t head, wasm_shared_heap_t head, wasm_shared_heap_t body);
wasm_shared_heap_t body);
/** /**
* This function unchains the shared heaps from the given head. If * This function unchains the shared heaps from the given head. If
@@ -2434,8 +2385,8 @@ wasm_runtime_chain_shared_heaps(wasm_shared_heap_t head,
* @return The new head of the shared heap chain. Or the last shared heap in the * @return The new head of the shared heap chain. Or the last shared heap in the
* chain if `entire_chain` is true. * chain if `entire_chain` is true.
*/ */
wasm_shared_heap_t wasm_shared_heap_t wasm_runtime_unchain_shared_heaps(wasm_shared_heap_t head,
wasm_runtime_unchain_shared_heaps(wasm_shared_heap_t head, bool entire_chain); bool entire_chain);
/** /**
* Reset shared heap chain. For each shared heap in the chain, if it is a * Reset shared heap chain. For each shared heap in the chain, if it is a
@@ -2482,9 +2433,8 @@ wasm_runtime_detach_shared_heap(wasm_module_inst_t module_inst);
* (when the wasm memory is 64-bit). Note that it is not an absolute address. * (when the wasm memory is 64-bit). Note that it is not an absolute address.
* Return non-zero if success, zero if failed. * Return non-zero if success, zero if failed.
*/ */
WASM_RUNTIME_API_EXTERN uint64_t WASM_RUNTIME_API_EXTERN uint64_t wasm_runtime_shared_heap_malloc(
wasm_runtime_shared_heap_malloc(wasm_module_inst_t module_inst, uint64_t size, wasm_module_inst_t module_inst, uint64_t size, void **p_native_addr);
void **p_native_addr);
/** /**
* Free the memory allocated from shared heap, or the non-preallocated shared * Free the memory allocated from shared heap, or the non-preallocated shared