Apply clang-format for more src files and update spec test script (#775)
Apply clang-format for core/iwasm/include, core/iwasm/common and core/iwasm/aot files. Update spec cases test script: - Checkout latest commit of https://github.com/WebAssembly/spec - Checkout main branch but not master of https://github.com/WebAssembly/threads - Update wabt to latest version And update source debugging document. Signed-off-by: Wenyong Huang <wenyong.huang@intel.com>
This commit is contained in:
@ -9,7 +9,6 @@
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@ -27,9 +26,9 @@ void
|
||||
aot_destroy_comp_data(aot_comp_data_t comp_data);
|
||||
|
||||
#if WASM_ENABLE_DEBUG_AOT != 0
|
||||
typedef void * dwar_extractor_handle_t;
|
||||
typedef void *dwar_extractor_handle_t;
|
||||
dwar_extractor_handle_t
|
||||
create_dwarf_extractor(aot_comp_data_t comp_data, char * file_name);
|
||||
create_dwarf_extractor(aot_comp_data_t comp_data, char *file_name);
|
||||
#endif
|
||||
|
||||
enum {
|
||||
@ -39,7 +38,7 @@ enum {
|
||||
AOT_LLVMIR_OPT_FILE,
|
||||
};
|
||||
|
||||
typedef struct AOTCompOption{
|
||||
typedef struct AOTCompOption {
|
||||
bool is_jit_mode;
|
||||
bool is_indirect_mode;
|
||||
char *target_arch;
|
||||
@ -62,8 +61,7 @@ typedef struct AOTCompOption{
|
||||
} AOTCompOption, *aot_comp_option_t;
|
||||
|
||||
aot_comp_context_t
|
||||
aot_create_comp_context(aot_comp_data_t comp_data,
|
||||
aot_comp_option_t option);
|
||||
aot_create_comp_context(aot_comp_data_t comp_data, aot_comp_option_t option);
|
||||
|
||||
void
|
||||
aot_destroy_comp_context(aot_comp_context_t comp_ctx);
|
||||
@ -78,8 +76,7 @@ bool
|
||||
aot_emit_object_file(aot_comp_context_t comp_ctx, const char *file_name);
|
||||
|
||||
bool
|
||||
aot_emit_aot_file(aot_comp_context_t comp_ctx,
|
||||
aot_comp_data_t comp_data,
|
||||
aot_emit_aot_file(aot_comp_context_t comp_ctx, aot_comp_data_t comp_data,
|
||||
const char *file_name);
|
||||
|
||||
void
|
||||
@ -88,16 +85,15 @@ aot_destroy_aot_file(uint8_t *aot_file);
|
||||
bool
|
||||
aot_compile_wasm_file_init();
|
||||
|
||||
uint8_t*
|
||||
uint8_t *
|
||||
aot_compile_wasm_file(const uint8_t *wasm_file_buf, uint32_t wasm_file_size,
|
||||
uint32_t opt_level, uint32_t size_level,
|
||||
char *error_buf, uint32_t error_buf_size,
|
||||
uint32_t *p_aot_file_size);
|
||||
uint32_t opt_level, uint32_t size_level, char *error_buf,
|
||||
uint32_t error_buf_size, uint32_t *p_aot_file_size);
|
||||
|
||||
void
|
||||
aot_compile_wasm_file_destroy();
|
||||
|
||||
char*
|
||||
char *
|
||||
aot_get_last_error();
|
||||
|
||||
uint32_t
|
||||
|
||||
@ -21,18 +21,22 @@ typedef struct NativeSymbol {
|
||||
void *attachment;
|
||||
} NativeSymbol;
|
||||
|
||||
#define EXPORT_WASM_API(symbol) {#symbol, (void*)symbol, NULL, NULL}
|
||||
#define EXPORT_WASM_API2(symbol) {#symbol, (void*)symbol##_wrapper, NULL, NULL}
|
||||
/* 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}
|
||||
{ #symbol, (void *)symbol, signature, NULL }
|
||||
#define EXPORT_WASM_API_WITH_SIG2(symbol, signature) \
|
||||
{#symbol, (void*)symbol##_wrapper, signature, NULL}
|
||||
{ #symbol, (void *)symbol##_wrapper, signature, NULL }
|
||||
|
||||
#define EXPORT_WASM_API_WITH_ATT(symbol, signature, attachment) \
|
||||
{#symbol, (void*)symbol, signature, attachment}
|
||||
{ #symbol, (void *)symbol, signature, attachment }
|
||||
#define EXPORT_WASM_API_WITH_ATT2(symbol, signature, attachment) \
|
||||
{#symbol, (void*)symbol##_wrapper, signature, attachment}
|
||||
{ #symbol, (void *)symbol##_wrapper, signature, attachment }
|
||||
/* clang-format on */
|
||||
|
||||
/**
|
||||
* Get the exported APIs of base lib
|
||||
@ -48,5 +52,4 @@ get_base_lib_export_apis(NativeSymbol **p_base_lib_apis);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* end of _LIB_EXPORT_H_ */
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
// WebAssembly C API
|
||||
|
||||
#ifndef WASM_H
|
||||
#define WASM_H
|
||||
#ifndef _WASM_C_API_H_
|
||||
#define _WASM_C_API_H_
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
@ -11,11 +11,11 @@
|
||||
|
||||
#ifndef WASM_API_EXTERN
|
||||
#if defined(_MSC_BUILD)
|
||||
#if defined(COMPILING_WASM_RUNTIME_API)
|
||||
#define WASM_API_EXTERN __declspec(dllexport)
|
||||
#else
|
||||
#define WASM_API_EXTERN __declspec(dllimport)
|
||||
#endif
|
||||
#if defined(COMPILING_WASM_RUNTIME_API)
|
||||
#define WASM_API_EXTERN __declspec(dllexport)
|
||||
#else
|
||||
#define WASM_API_EXTERN __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define WASM_API_EXTERN
|
||||
#endif
|
||||
@ -25,6 +25,8 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* clang-format off */
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Auxiliaries
|
||||
|
||||
@ -776,8 +778,10 @@ static inline void* wasm_val_ptr(const wasm_val_t* val) {
|
||||
|
||||
#undef own
|
||||
|
||||
/* clang-format on */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // #ifdef WASM_H
|
||||
#endif // #ifdef _WASM_C_API_H_
|
||||
|
||||
@ -10,14 +10,13 @@
|
||||
#include <stdbool.h>
|
||||
#include "lib_export.h"
|
||||
|
||||
|
||||
#ifndef WASM_RUNTIME_API_EXTERN
|
||||
#if defined(_MSC_BUILD )
|
||||
#if defined(COMPILING_WASM_RUNTIME_API)
|
||||
#define WASM_RUNTIME_API_EXTERN __declspec(dllexport)
|
||||
#else
|
||||
#define WASM_RUNTIME_API_EXTERN __declspec(dllimport)
|
||||
#endif
|
||||
#if defined(_MSC_BUILD)
|
||||
#if defined(COMPILING_WASM_RUNTIME_API)
|
||||
#define WASM_RUNTIME_API_EXTERN __declspec(dllexport)
|
||||
#else
|
||||
#define WASM_RUNTIME_API_EXTERN __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define WASM_RUNTIME_API_EXTERN
|
||||
#endif
|
||||
@ -27,6 +26,8 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* clang-format off */
|
||||
|
||||
#define get_module_inst(exec_env) \
|
||||
wasm_runtime_get_module_inst(exec_env)
|
||||
|
||||
@ -48,13 +49,12 @@ extern "C" {
|
||||
#define module_free(offset) \
|
||||
wasm_runtime_module_free(module_inst, offset)
|
||||
|
||||
#define native_raw_return_type(type, args) type *raw_ret = (type*)(args)
|
||||
#define native_raw_return_type(type, args) type *raw_ret = (type *)(args)
|
||||
|
||||
#define native_raw_get_arg(type, name, args) type name = *((type*)(args++))
|
||||
#define native_raw_get_arg(type, name, args) type name = *((type *)(args++))
|
||||
|
||||
#define native_raw_set_return(val) *raw_ret = (val)
|
||||
|
||||
|
||||
#ifndef WASM_MODULE_T_DEFINED
|
||||
#define WASM_MODULE_T_DEFINED
|
||||
/* Uninstantiated WASM module loaded from WASM binary file
|
||||
@ -158,14 +158,14 @@ enum wasm_valkind_enum {
|
||||
struct wasm_ref_t;
|
||||
|
||||
typedef struct wasm_val_t {
|
||||
wasm_valkind_t kind;
|
||||
union {
|
||||
int32_t i32;
|
||||
int64_t i64;
|
||||
float f32;
|
||||
double f64;
|
||||
struct wasm_ref_t* ref;
|
||||
} of;
|
||||
wasm_valkind_t kind;
|
||||
union {
|
||||
int32_t i32;
|
||||
int64_t i64;
|
||||
float f32;
|
||||
double f64;
|
||||
struct wasm_ref_t *ref;
|
||||
} of;
|
||||
} wasm_val_t;
|
||||
#endif
|
||||
|
||||
@ -652,10 +652,11 @@ wasm_runtime_validate_app_addr(wasm_module_inst_t module_inst,
|
||||
|
||||
/**
|
||||
* Similar to wasm_runtime_validate_app_addr(), except that the size parameter
|
||||
* is not provided. This function validates the app string address, check whether it
|
||||
* belongs to WASM module instance's address space, or in its heap space or
|
||||
* memory space. Moreover, it checks whether it is the offset of a string that
|
||||
* is end with '\0'.
|
||||
* is not provided. This function validates the app string address, check
|
||||
* whether it belongs to WASM module instance's address space, or in its heap
|
||||
* space or memory space. Moreover, it checks whether it is the offset of a
|
||||
* string that is end with '\0'.
|
||||
*
|
||||
* @param module_inst the WASM module instance
|
||||
* @param app_str_offset the app address of the string to validate, which is a
|
||||
* relative address
|
||||
@ -724,12 +725,15 @@ wasm_runtime_get_app_addr_range(wasm_module_inst_t module_inst,
|
||||
uint32_t *p_app_end_offset);
|
||||
|
||||
/**
|
||||
* Get the native address range (absolute address) that a native address belongs to
|
||||
* Get the native address range (absolute address) that a native address
|
||||
* belongs to
|
||||
*
|
||||
* @param module_inst the WASM module instance
|
||||
* @param native_ptr the native address to retrieve
|
||||
* @param p_native_start_addr buffer to output the native start address if not NULL
|
||||
* @param p_native_end_addr buffer to output the native end address if not NULL
|
||||
* @param p_native_start_addr buffer to output the native start address
|
||||
* if not NULL
|
||||
* @param p_native_end_addr buffer to output the native end address
|
||||
* if not NULL
|
||||
*
|
||||
* @return true if success, false otherwise.
|
||||
*/
|
||||
@ -740,31 +744,31 @@ wasm_runtime_get_native_addr_range(wasm_module_inst_t module_inst,
|
||||
uint8_t **p_native_end_addr);
|
||||
|
||||
/**
|
||||
* Register native functions with same module name
|
||||
*
|
||||
* @param module_name the module name of the native functions
|
||||
* @param native_symbols specifies an array of NativeSymbol structures which
|
||||
* contain the names, function pointers and signatures
|
||||
* Note: WASM runtime will not allocate memory to clone the data, so
|
||||
* user must ensure the array can be used forever
|
||||
* Meanings of letters in function signature:
|
||||
* 'i': the parameter is i32 type
|
||||
* 'I': the parameter is i64 type
|
||||
* 'f': the parameter is f32 type
|
||||
* 'F': the parameter is f64 type
|
||||
* '*': the parameter is a pointer (i32 in WASM), and runtime will
|
||||
* auto check its boundary before calling the native function.
|
||||
* If it is followed by '~', the checked length of the pointer
|
||||
* is gotten from the following parameter, if not, the checked
|
||||
* length of the pointer is 1.
|
||||
* '~': the parameter is the pointer's length with i32 type, and must
|
||||
* follow after '*'
|
||||
* '$': the parameter is a string (i32 in WASM), and runtime will
|
||||
* auto check its boundary before calling the native function
|
||||
* @param n_native_symbols specifies the number of native symbols in the array
|
||||
*
|
||||
* @return true if success, false otherwise
|
||||
*/
|
||||
* Register native functions with same module name
|
||||
*
|
||||
* @param module_name the module name of the native functions
|
||||
* @param native_symbols specifies an array of NativeSymbol structures which
|
||||
* contain the names, function pointers and signatures
|
||||
* Note: WASM runtime will not allocate memory to clone the data, so
|
||||
* user must ensure the array can be used forever
|
||||
* Meanings of letters in function signature:
|
||||
* 'i': the parameter is i32 type
|
||||
* 'I': the parameter is i64 type
|
||||
* 'f': the parameter is f32 type
|
||||
* 'F': the parameter is f64 type
|
||||
* '*': the parameter is a pointer (i32 in WASM), and runtime will
|
||||
* auto check its boundary before calling the native function.
|
||||
* If it is followed by '~', the checked length of the pointer
|
||||
* is gotten from the following parameter, if not, the checked
|
||||
* length of the pointer is 1.
|
||||
* '~': the parameter is the pointer's length with i32 type, and must
|
||||
* follow after '*'
|
||||
* '$': the parameter is a string (i32 in WASM), and runtime will
|
||||
* auto check its boundary before calling the native function
|
||||
* @param n_native_symbols specifies the number of native symbols in the array
|
||||
*
|
||||
* @return true if success, false otherwise
|
||||
*/
|
||||
WASM_RUNTIME_API_EXTERN bool
|
||||
wasm_runtime_register_natives(const char *module_name,
|
||||
NativeSymbol *native_symbols,
|
||||
@ -773,7 +777,7 @@ wasm_runtime_register_natives(const char *module_name,
|
||||
/**
|
||||
* Register native functions with same module name, similar to
|
||||
* wasm_runtime_register_natives, the difference is that runtime passes raw
|
||||
* arguments to native API, which means that the native API should be defined as:
|
||||
* arguments to native API, which means that the native API should be defined as
|
||||
* void foo(wasm_exec_env_t exec_env, uint64 *args);
|
||||
* and native API should extract arguments one by one from args array with macro
|
||||
* native_raw_get_arg
|
||||
@ -802,8 +806,7 @@ wasm_runtime_get_function_attachment(wasm_exec_env_t exec_env);
|
||||
* @param user_data the user data to be set
|
||||
*/
|
||||
WASM_RUNTIME_API_EXTERN void
|
||||
wasm_runtime_set_user_data(wasm_exec_env_t exec_env,
|
||||
void *user_data);
|
||||
wasm_runtime_set_user_data(wasm_exec_env_t exec_env, void *user_data);
|
||||
/**
|
||||
* Get the user data within execution environment.
|
||||
*
|
||||
@ -835,7 +838,7 @@ WASM_RUNTIME_API_EXTERN void
|
||||
wasm_runtime_dump_perf_profiling(wasm_module_inst_t module_inst);
|
||||
|
||||
/* wasm thread callback function type */
|
||||
typedef void* (*wasm_thread_callback_t)(wasm_exec_env_t, void *);
|
||||
typedef void *(*wasm_thread_callback_t)(wasm_exec_env_t, void *);
|
||||
/* wasm thread type */
|
||||
typedef uintptr_t wasm_thread_t;
|
||||
|
||||
@ -938,6 +941,8 @@ wasm_externref_retain(uint32_t externref_idx);
|
||||
WASM_RUNTIME_API_EXTERN void
|
||||
wasm_runtime_dump_call_stack(wasm_exec_env_t exec_env);
|
||||
|
||||
/* clang-format on */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user