|
|
@@ -27,151 +27,187 @@ extern "C" {
|
|
|
|
|
|
#if WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS != 0
|
|
|
|
|
|
-#define PUT_I64_TO_ADDR(addr, value) do { \
|
|
|
- *(int64*)(addr) = (int64)(value); \
|
|
|
- } while (0)
|
|
|
-#define PUT_F64_TO_ADDR(addr, value) do { \
|
|
|
- *(float64*)(addr) = (float64)(value); \
|
|
|
- } while (0)
|
|
|
-
|
|
|
-#define GET_I64_FROM_ADDR(addr) (*(int64*)(addr))
|
|
|
-#define GET_F64_FROM_ADDR(addr) (*(float64*)(addr))
|
|
|
+#define PUT_I64_TO_ADDR(addr, value) \
|
|
|
+ do { \
|
|
|
+ *(int64 *)(addr) = (int64)(value); \
|
|
|
+ } while (0)
|
|
|
+#define PUT_F64_TO_ADDR(addr, value) \
|
|
|
+ do { \
|
|
|
+ *(float64 *)(addr) = (float64)(value); \
|
|
|
+ } while (0)
|
|
|
+
|
|
|
+#define GET_I64_FROM_ADDR(addr) (*(int64 *)(addr))
|
|
|
+#define GET_F64_FROM_ADDR(addr) (*(float64 *)(addr))
|
|
|
|
|
|
/* For STORE opcodes */
|
|
|
#define STORE_I64 PUT_I64_TO_ADDR
|
|
|
-#define STORE_U32(addr, value) do { \
|
|
|
- *(uint32*)(addr) = (uint32)(value); \
|
|
|
- } while (0)
|
|
|
-#define STORE_U16(addr, value) do { \
|
|
|
- *(uint16*)(addr) = (uint16)(value); \
|
|
|
- } while (0)
|
|
|
+#define STORE_U32(addr, value) \
|
|
|
+ do { \
|
|
|
+ *(uint32 *)(addr) = (uint32)(value); \
|
|
|
+ } while (0)
|
|
|
+#define STORE_U16(addr, value) \
|
|
|
+ do { \
|
|
|
+ *(uint16 *)(addr) = (uint16)(value); \
|
|
|
+ } while (0)
|
|
|
|
|
|
/* For LOAD opcodes */
|
|
|
-#define LOAD_I64(addr) (*(int64*)(addr))
|
|
|
-#define LOAD_F64(addr) (*(float64*)(addr))
|
|
|
-#define LOAD_I32(addr) (*(int32*)(addr))
|
|
|
-#define LOAD_U32(addr) (*(uint32*)(addr))
|
|
|
-#define LOAD_I16(addr) (*(int16*)(addr))
|
|
|
-#define LOAD_U16(addr) (*(uint16*)(addr))
|
|
|
-
|
|
|
-#define STORE_PTR(addr, ptr) do { \
|
|
|
- *(void**)addr = (void*)ptr; \
|
|
|
- } while (0)
|
|
|
-
|
|
|
-#else /* WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS != 0 */
|
|
|
-
|
|
|
-#define PUT_I64_TO_ADDR(addr, value) do { \
|
|
|
- uint32 *addr_u32 = (uint32*)(addr); \
|
|
|
- union { int64 val; uint32 parts[2]; } u; \
|
|
|
- u.val = (int64)(value); \
|
|
|
- addr_u32[0] = u.parts[0]; \
|
|
|
- addr_u32[1] = u.parts[1]; \
|
|
|
- } while (0)
|
|
|
-#define PUT_F64_TO_ADDR(addr, value) do { \
|
|
|
- uint32 *addr_u32 = (uint32*)(addr); \
|
|
|
- union { float64 val; uint32 parts[2]; } u; \
|
|
|
- u.val = (value); \
|
|
|
- addr_u32[0] = u.parts[0]; \
|
|
|
- addr_u32[1] = u.parts[1]; \
|
|
|
- } while (0)
|
|
|
+#define LOAD_I64(addr) (*(int64 *)(addr))
|
|
|
+#define LOAD_F64(addr) (*(float64 *)(addr))
|
|
|
+#define LOAD_I32(addr) (*(int32 *)(addr))
|
|
|
+#define LOAD_U32(addr) (*(uint32 *)(addr))
|
|
|
+#define LOAD_I16(addr) (*(int16 *)(addr))
|
|
|
+#define LOAD_U16(addr) (*(uint16 *)(addr))
|
|
|
+
|
|
|
+#define STORE_PTR(addr, ptr) \
|
|
|
+ do { \
|
|
|
+ *(void **)addr = (void *)ptr; \
|
|
|
+ } while (0)
|
|
|
+
|
|
|
+#else /* WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS != 0 */
|
|
|
+
|
|
|
+#define PUT_I64_TO_ADDR(addr, value) \
|
|
|
+ do { \
|
|
|
+ uint32 *addr_u32 = (uint32 *)(addr); \
|
|
|
+ union { \
|
|
|
+ int64 val; \
|
|
|
+ uint32 parts[2]; \
|
|
|
+ } u; \
|
|
|
+ u.val = (int64)(value); \
|
|
|
+ addr_u32[0] = u.parts[0]; \
|
|
|
+ addr_u32[1] = u.parts[1]; \
|
|
|
+ } while (0)
|
|
|
+#define PUT_F64_TO_ADDR(addr, value) \
|
|
|
+ do { \
|
|
|
+ uint32 *addr_u32 = (uint32 *)(addr); \
|
|
|
+ union { \
|
|
|
+ float64 val; \
|
|
|
+ uint32 parts[2]; \
|
|
|
+ } u; \
|
|
|
+ u.val = (value); \
|
|
|
+ addr_u32[0] = u.parts[0]; \
|
|
|
+ addr_u32[1] = u.parts[1]; \
|
|
|
+ } while (0)
|
|
|
|
|
|
static inline int64
|
|
|
GET_I64_FROM_ADDR(uint32 *addr)
|
|
|
{
|
|
|
- union { int64 val; uint32 parts[2]; } u;
|
|
|
+ union {
|
|
|
+ int64 val;
|
|
|
+ uint32 parts[2];
|
|
|
+ } u;
|
|
|
u.parts[0] = addr[0];
|
|
|
u.parts[1] = addr[1];
|
|
|
return u.val;
|
|
|
}
|
|
|
|
|
|
static inline float64
|
|
|
-GET_F64_FROM_ADDR (uint32 *addr)
|
|
|
+GET_F64_FROM_ADDR(uint32 *addr)
|
|
|
{
|
|
|
- union { float64 val; uint32 parts[2]; } u;
|
|
|
+ union {
|
|
|
+ float64 val;
|
|
|
+ uint32 parts[2];
|
|
|
+ } u;
|
|
|
u.parts[0] = addr[0];
|
|
|
u.parts[1] = addr[1];
|
|
|
return u.val;
|
|
|
}
|
|
|
|
|
|
/* For STORE opcodes */
|
|
|
-#define STORE_I64(addr, value) do { \
|
|
|
- uintptr_t addr1 = (uintptr_t)(addr); \
|
|
|
- union { int64 val; uint32 u32[2]; \
|
|
|
- uint16 u16[4]; uint8 u8[8]; } u; \
|
|
|
- if ((addr1 & (uintptr_t)7) == 0) \
|
|
|
- *(int64*)(addr) = (int64)(value); \
|
|
|
- else { \
|
|
|
- u.val = (int64)(value); \
|
|
|
- if ((addr1 & (uintptr_t)3) == 0) { \
|
|
|
- ((uint32*)(addr))[0] = u.u32[0]; \
|
|
|
- ((uint32*)(addr))[1] = u.u32[1]; \
|
|
|
- } \
|
|
|
- else if ((addr1 & (uintptr_t)1) == 0) { \
|
|
|
- ((uint16*)(addr))[0] = u.u16[0]; \
|
|
|
- ((uint16*)(addr))[1] = u.u16[1]; \
|
|
|
- ((uint16*)(addr))[2] = u.u16[2]; \
|
|
|
- ((uint16*)(addr))[3] = u.u16[3]; \
|
|
|
- } \
|
|
|
- else { \
|
|
|
- int32 t; \
|
|
|
- for (t = 0; t < 8; t++) \
|
|
|
- ((uint8*)(addr))[t] = u.u8[t]; \
|
|
|
- } \
|
|
|
- } \
|
|
|
- } while (0)
|
|
|
-
|
|
|
-#define STORE_U32(addr, value) do { \
|
|
|
- uintptr_t addr1 = (uintptr_t)(addr); \
|
|
|
- union { uint32 val; \
|
|
|
- uint16 u16[2]; uint8 u8[4]; } u; \
|
|
|
- if ((addr1 & (uintptr_t)3) == 0) \
|
|
|
- *(uint32*)(addr) = (uint32)(value); \
|
|
|
- else { \
|
|
|
- u.val = (uint32)(value); \
|
|
|
- if ((addr1 & (uintptr_t)1) == 0) { \
|
|
|
- ((uint16*)(addr))[0] = u.u16[0]; \
|
|
|
- ((uint16*)(addr))[1] = u.u16[1]; \
|
|
|
- } \
|
|
|
- else { \
|
|
|
- ((uint8*)(addr))[0] = u.u8[0]; \
|
|
|
- ((uint8*)(addr))[1] = u.u8[1]; \
|
|
|
- ((uint8*)(addr))[2] = u.u8[2]; \
|
|
|
- ((uint8*)(addr))[3] = u.u8[3]; \
|
|
|
- } \
|
|
|
- } \
|
|
|
- } while (0)
|
|
|
-
|
|
|
-#define STORE_U16(addr, value) do { \
|
|
|
- union { uint16 val; uint8 u8[2]; } u; \
|
|
|
- u.val = (uint16)(value); \
|
|
|
- ((uint8*)(addr))[0] = u.u8[0]; \
|
|
|
- ((uint8*)(addr))[1] = u.u8[1]; \
|
|
|
- } while (0)
|
|
|
+#define STORE_I64(addr, value) \
|
|
|
+ do { \
|
|
|
+ uintptr_t addr1 = (uintptr_t)(addr); \
|
|
|
+ union { \
|
|
|
+ int64 val; \
|
|
|
+ uint32 u32[2]; \
|
|
|
+ uint16 u16[4]; \
|
|
|
+ uint8 u8[8]; \
|
|
|
+ } u; \
|
|
|
+ if ((addr1 & (uintptr_t)7) == 0) \
|
|
|
+ *(int64 *)(addr) = (int64)(value); \
|
|
|
+ else { \
|
|
|
+ u.val = (int64)(value); \
|
|
|
+ if ((addr1 & (uintptr_t)3) == 0) { \
|
|
|
+ ((uint32 *)(addr))[0] = u.u32[0]; \
|
|
|
+ ((uint32 *)(addr))[1] = u.u32[1]; \
|
|
|
+ } \
|
|
|
+ else if ((addr1 & (uintptr_t)1) == 0) { \
|
|
|
+ ((uint16 *)(addr))[0] = u.u16[0]; \
|
|
|
+ ((uint16 *)(addr))[1] = u.u16[1]; \
|
|
|
+ ((uint16 *)(addr))[2] = u.u16[2]; \
|
|
|
+ ((uint16 *)(addr))[3] = u.u16[3]; \
|
|
|
+ } \
|
|
|
+ else { \
|
|
|
+ int32 t; \
|
|
|
+ for (t = 0; t < 8; t++) \
|
|
|
+ ((uint8 *)(addr))[t] = u.u8[t]; \
|
|
|
+ } \
|
|
|
+ } \
|
|
|
+ } while (0)
|
|
|
+
|
|
|
+#define STORE_U32(addr, value) \
|
|
|
+ do { \
|
|
|
+ uintptr_t addr1 = (uintptr_t)(addr); \
|
|
|
+ union { \
|
|
|
+ uint32 val; \
|
|
|
+ uint16 u16[2]; \
|
|
|
+ uint8 u8[4]; \
|
|
|
+ } u; \
|
|
|
+ if ((addr1 & (uintptr_t)3) == 0) \
|
|
|
+ *(uint32 *)(addr) = (uint32)(value); \
|
|
|
+ else { \
|
|
|
+ u.val = (uint32)(value); \
|
|
|
+ if ((addr1 & (uintptr_t)1) == 0) { \
|
|
|
+ ((uint16 *)(addr))[0] = u.u16[0]; \
|
|
|
+ ((uint16 *)(addr))[1] = u.u16[1]; \
|
|
|
+ } \
|
|
|
+ else { \
|
|
|
+ ((uint8 *)(addr))[0] = u.u8[0]; \
|
|
|
+ ((uint8 *)(addr))[1] = u.u8[1]; \
|
|
|
+ ((uint8 *)(addr))[2] = u.u8[2]; \
|
|
|
+ ((uint8 *)(addr))[3] = u.u8[3]; \
|
|
|
+ } \
|
|
|
+ } \
|
|
|
+ } while (0)
|
|
|
+
|
|
|
+#define STORE_U16(addr, value) \
|
|
|
+ do { \
|
|
|
+ union { \
|
|
|
+ uint16 val; \
|
|
|
+ uint8 u8[2]; \
|
|
|
+ } u; \
|
|
|
+ u.val = (uint16)(value); \
|
|
|
+ ((uint8 *)(addr))[0] = u.u8[0]; \
|
|
|
+ ((uint8 *)(addr))[1] = u.u8[1]; \
|
|
|
+ } while (0)
|
|
|
|
|
|
/* For LOAD opcodes */
|
|
|
static inline int64
|
|
|
LOAD_I64(void *addr)
|
|
|
{
|
|
|
uintptr_t addr1 = (uintptr_t)addr;
|
|
|
- union { int64 val; uint32 u32[2];
|
|
|
- uint16 u16[4]; uint8 u8[8]; } u;
|
|
|
+ union {
|
|
|
+ int64 val;
|
|
|
+ uint32 u32[2];
|
|
|
+ uint16 u16[4];
|
|
|
+ uint8 u8[8];
|
|
|
+ } u;
|
|
|
if ((addr1 & (uintptr_t)7) == 0)
|
|
|
- return *(int64*)addr;
|
|
|
+ return *(int64 *)addr;
|
|
|
|
|
|
if ((addr1 & (uintptr_t)3) == 0) {
|
|
|
- u.u32[0] = ((uint32*)addr)[0];
|
|
|
- u.u32[1] = ((uint32*)addr)[1];
|
|
|
+ u.u32[0] = ((uint32 *)addr)[0];
|
|
|
+ u.u32[1] = ((uint32 *)addr)[1];
|
|
|
}
|
|
|
else if ((addr1 & (uintptr_t)1) == 0) {
|
|
|
- u.u16[0] = ((uint16*)addr)[0];
|
|
|
- u.u16[1] = ((uint16*)addr)[1];
|
|
|
- u.u16[2] = ((uint16*)addr)[2];
|
|
|
- u.u16[3] = ((uint16*)addr)[3];
|
|
|
+ u.u16[0] = ((uint16 *)addr)[0];
|
|
|
+ u.u16[1] = ((uint16 *)addr)[1];
|
|
|
+ u.u16[2] = ((uint16 *)addr)[2];
|
|
|
+ u.u16[3] = ((uint16 *)addr)[3];
|
|
|
}
|
|
|
else {
|
|
|
int32 t;
|
|
|
for (t = 0; t < 8; t++)
|
|
|
- u.u8[t] = ((uint8*)addr)[t];
|
|
|
+ u.u8[t] = ((uint8 *)addr)[t];
|
|
|
}
|
|
|
return u.val;
|
|
|
}
|
|
|
@@ -180,25 +216,29 @@ static inline float64
|
|
|
LOAD_F64(void *addr)
|
|
|
{
|
|
|
uintptr_t addr1 = (uintptr_t)addr;
|
|
|
- union { float64 val; uint32 u32[2];
|
|
|
- uint16 u16[4]; uint8 u8[8]; } u;
|
|
|
+ union {
|
|
|
+ float64 val;
|
|
|
+ uint32 u32[2];
|
|
|
+ uint16 u16[4];
|
|
|
+ uint8 u8[8];
|
|
|
+ } u;
|
|
|
if ((addr1 & (uintptr_t)7) == 0)
|
|
|
- return *(float64*)addr;
|
|
|
+ return *(float64 *)addr;
|
|
|
|
|
|
if ((addr1 & (uintptr_t)3) == 0) {
|
|
|
- u.u32[0] = ((uint32*)addr)[0];
|
|
|
- u.u32[1] = ((uint32*)addr)[1];
|
|
|
+ u.u32[0] = ((uint32 *)addr)[0];
|
|
|
+ u.u32[1] = ((uint32 *)addr)[1];
|
|
|
}
|
|
|
else if ((addr1 & (uintptr_t)1) == 0) {
|
|
|
- u.u16[0] = ((uint16*)addr)[0];
|
|
|
- u.u16[1] = ((uint16*)addr)[1];
|
|
|
- u.u16[2] = ((uint16*)addr)[2];
|
|
|
- u.u16[3] = ((uint16*)addr)[3];
|
|
|
+ u.u16[0] = ((uint16 *)addr)[0];
|
|
|
+ u.u16[1] = ((uint16 *)addr)[1];
|
|
|
+ u.u16[2] = ((uint16 *)addr)[2];
|
|
|
+ u.u16[3] = ((uint16 *)addr)[3];
|
|
|
}
|
|
|
else {
|
|
|
int32 t;
|
|
|
for (t = 0; t < 8; t++)
|
|
|
- u.u8[t] = ((uint8*)addr)[t];
|
|
|
+ u.u8[t] = ((uint8 *)addr)[t];
|
|
|
}
|
|
|
return u.val;
|
|
|
}
|
|
|
@@ -207,19 +247,23 @@ static inline int32
|
|
|
LOAD_I32(void *addr)
|
|
|
{
|
|
|
uintptr_t addr1 = (uintptr_t)addr;
|
|
|
- union { int32 val; uint16 u16[2]; uint8 u8[4]; } u;
|
|
|
+ union {
|
|
|
+ int32 val;
|
|
|
+ uint16 u16[2];
|
|
|
+ uint8 u8[4];
|
|
|
+ } u;
|
|
|
if ((addr1 & (uintptr_t)3) == 0)
|
|
|
- return *(int32*)addr;
|
|
|
+ return *(int32 *)addr;
|
|
|
|
|
|
if ((addr1 & (uintptr_t)1) == 0) {
|
|
|
- u.u16[0] = ((uint16*)addr)[0];
|
|
|
- u.u16[1] = ((uint16*)addr)[1];
|
|
|
+ u.u16[0] = ((uint16 *)addr)[0];
|
|
|
+ u.u16[1] = ((uint16 *)addr)[1];
|
|
|
}
|
|
|
else {
|
|
|
- u.u8[0] = ((uint8*)addr)[0];
|
|
|
- u.u8[1] = ((uint8*)addr)[1];
|
|
|
- u.u8[2] = ((uint8*)addr)[2];
|
|
|
- u.u8[3] = ((uint8*)addr)[3];
|
|
|
+ u.u8[0] = ((uint8 *)addr)[0];
|
|
|
+ u.u8[1] = ((uint8 *)addr)[1];
|
|
|
+ u.u8[2] = ((uint8 *)addr)[2];
|
|
|
+ u.u8[3] = ((uint8 *)addr)[3];
|
|
|
}
|
|
|
return u.val;
|
|
|
}
|
|
|
@@ -228,13 +272,16 @@ static inline int16
|
|
|
LOAD_I16(void *addr)
|
|
|
{
|
|
|
uintptr_t addr1 = (uintptr_t)addr;
|
|
|
- union { int16 val; uint8 u8[2]; } u;
|
|
|
+ union {
|
|
|
+ int16 val;
|
|
|
+ uint8 u8[2];
|
|
|
+ } u;
|
|
|
if ((addr1 & (uintptr_t)1)) {
|
|
|
- u.u8[0] = ((uint8*)addr)[0];
|
|
|
- u.u8[1] = ((uint8*)addr)[1];
|
|
|
+ u.u8[0] = ((uint8 *)addr)[0];
|
|
|
+ u.u8[1] = ((uint8 *)addr)[1];
|
|
|
return u.val;
|
|
|
}
|
|
|
- return *(int16*)addr;
|
|
|
+ return *(int16 *)addr;
|
|
|
}
|
|
|
|
|
|
#define LOAD_U32(addr) ((uint32)LOAD_I32(addr))
|
|
|
@@ -246,7 +293,7 @@ LOAD_I16(void *addr)
|
|
|
#define STORE_PTR(addr, ptr) STORE_I64(addr, (uintptr_t)ptr)
|
|
|
#endif
|
|
|
|
|
|
-#endif /* WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS != 0 */
|
|
|
+#endif /* WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS != 0 */
|
|
|
|
|
|
typedef struct WASMModuleCommon {
|
|
|
/* Module type, for module loaded from WASM bytecode binary,
|
|
|
@@ -361,8 +408,8 @@ get_package_type(const uint8 *buf, uint32 size);
|
|
|
|
|
|
/* See wasm_export.h for description */
|
|
|
WASM_RUNTIME_API_EXTERN WASMModuleCommon *
|
|
|
-wasm_runtime_load(const uint8 *buf, uint32 size,
|
|
|
- char *error_buf, uint32 error_buf_size);
|
|
|
+wasm_runtime_load(const uint8 *buf, uint32 size, char *error_buf,
|
|
|
+ uint32 error_buf_size);
|
|
|
|
|
|
/* See wasm_export.h for description */
|
|
|
WASM_RUNTIME_API_EXTERN WASMModuleCommon *
|
|
|
@@ -386,9 +433,9 @@ wasm_runtime_deinstantiate_internal(WASMModuleInstanceCommon *module_inst,
|
|
|
|
|
|
/* See wasm_export.h for description */
|
|
|
WASM_RUNTIME_API_EXTERN WASMModuleInstanceCommon *
|
|
|
-wasm_runtime_instantiate(WASMModuleCommon *module,
|
|
|
- uint32 stack_size, uint32 heap_size,
|
|
|
- char *error_buf, uint32 error_buf_size);
|
|
|
+wasm_runtime_instantiate(WASMModuleCommon *module, uint32 stack_size,
|
|
|
+ uint32 heap_size, char *error_buf,
|
|
|
+ uint32 error_buf_size);
|
|
|
|
|
|
/* See wasm_export.h for description */
|
|
|
WASM_RUNTIME_API_EXTERN void
|
|
|
@@ -396,7 +443,7 @@ wasm_runtime_deinstantiate(WASMModuleInstanceCommon *module_inst);
|
|
|
|
|
|
/* See wasm_export.h for description */
|
|
|
WASM_RUNTIME_API_EXTERN WASMFunctionInstanceCommon *
|
|
|
-wasm_runtime_lookup_function(WASMModuleInstanceCommon * const module_inst,
|
|
|
+wasm_runtime_lookup_function(WASMModuleInstanceCommon *const module_inst,
|
|
|
const char *name, const char *signature);
|
|
|
|
|
|
/* Internal API */
|
|
|
@@ -432,8 +479,8 @@ wasm_runtime_get_user_data(WASMExecEnv *exec_env);
|
|
|
/* See wasm_export.h for description */
|
|
|
WASM_RUNTIME_API_EXTERN bool
|
|
|
wasm_runtime_call_wasm(WASMExecEnv *exec_env,
|
|
|
- WASMFunctionInstanceCommon *function,
|
|
|
- uint32 argc, uint32 argv[]);
|
|
|
+ WASMFunctionInstanceCommon *function, uint32 argc,
|
|
|
+ uint32 argv[]);
|
|
|
|
|
|
WASM_RUNTIME_API_EXTERN bool
|
|
|
wasm_runtime_call_wasm_a(WASMExecEnv *exec_env,
|
|
|
@@ -465,14 +512,13 @@ wasm_runtime_call_wasm_v(WASMExecEnv *exec_env,
|
|
|
* the caller can call wasm_runtime_get_exception to get exception info.
|
|
|
*/
|
|
|
bool
|
|
|
-wasm_runtime_call_indirect(WASMExecEnv *exec_env,
|
|
|
- uint32 element_indices,
|
|
|
+wasm_runtime_call_indirect(WASMExecEnv *exec_env, uint32 element_indices,
|
|
|
uint32 argc, uint32 argv[]);
|
|
|
|
|
|
bool
|
|
|
-wasm_runtime_create_exec_env_and_call_wasm(WASMModuleInstanceCommon *module_inst,
|
|
|
- WASMFunctionInstanceCommon *function,
|
|
|
- uint32 argc, uint32 argv[]);
|
|
|
+wasm_runtime_create_exec_env_and_call_wasm(
|
|
|
+ WASMModuleInstanceCommon *module_inst, WASMFunctionInstanceCommon *function,
|
|
|
+ uint32 argc, uint32 argv[]);
|
|
|
|
|
|
bool
|
|
|
wasm_runtime_create_exec_env_singleton(WASMModuleInstanceCommon *module_inst);
|
|
|
@@ -482,8 +528,8 @@ wasm_runtime_get_exec_env_singleton(WASMModuleInstanceCommon *module_inst);
|
|
|
|
|
|
/* See wasm_export.h for description */
|
|
|
WASM_RUNTIME_API_EXTERN bool
|
|
|
-wasm_application_execute_main(WASMModuleInstanceCommon *module_inst,
|
|
|
- int32 argc, char *argv[]);
|
|
|
+wasm_application_execute_main(WASMModuleInstanceCommon *module_inst, int32 argc,
|
|
|
+ char *argv[]);
|
|
|
|
|
|
/* See wasm_export.h for description */
|
|
|
WASM_RUNTIME_API_EXTERN bool
|
|
|
@@ -559,8 +605,7 @@ wasm_runtime_addr_native_to_app(WASMModuleInstanceCommon *module_inst,
|
|
|
/* See wasm_export.h for description */
|
|
|
WASM_RUNTIME_API_EXTERN bool
|
|
|
wasm_runtime_get_app_addr_range(WASMModuleInstanceCommon *module_inst,
|
|
|
- uint32 app_offset,
|
|
|
- uint32 *p_app_start_offset,
|
|
|
+ uint32 app_offset, uint32 *p_app_start_offset,
|
|
|
uint32 *p_app_end_offset);
|
|
|
|
|
|
/* See wasm_export.h for description */
|
|
|
@@ -600,8 +645,7 @@ wasm_runtime_register_module_internal(const char *module_name,
|
|
|
WASMModuleCommon *module,
|
|
|
uint8 *orig_file_buf,
|
|
|
uint32 orig_file_buf_size,
|
|
|
- char *error_buf,
|
|
|
- uint32 error_buf_size);
|
|
|
+ char *error_buf, uint32 error_buf_size);
|
|
|
|
|
|
void
|
|
|
wasm_runtime_unregister_module(const WASMModuleCommon *module);
|
|
|
@@ -610,8 +654,8 @@ bool
|
|
|
wasm_runtime_is_module_registered(const char *module_name);
|
|
|
|
|
|
bool
|
|
|
-wasm_runtime_add_loading_module(const char *module_name,
|
|
|
- char *error_buf, uint32 error_buf_size);
|
|
|
+wasm_runtime_add_loading_module(const char *module_name, char *error_buf,
|
|
|
+ uint32 error_buf_size);
|
|
|
|
|
|
void
|
|
|
wasm_runtime_delete_loading_module(const char *module_name);
|
|
|
@@ -628,30 +672,28 @@ wasm_runtime_is_built_in_module(const char *module_name);
|
|
|
|
|
|
#if WASM_ENABLE_THREAD_MGR != 0
|
|
|
bool
|
|
|
-wasm_exec_env_get_aux_stack(WASMExecEnv *exec_env,
|
|
|
- uint32 *start_offset, uint32 *size);
|
|
|
+wasm_exec_env_get_aux_stack(WASMExecEnv *exec_env, uint32 *start_offset,
|
|
|
+ uint32 *size);
|
|
|
|
|
|
bool
|
|
|
-wasm_exec_env_set_aux_stack(WASMExecEnv *exec_env,
|
|
|
- uint32 start_offset, uint32 size);
|
|
|
+wasm_exec_env_set_aux_stack(WASMExecEnv *exec_env, uint32 start_offset,
|
|
|
+ uint32 size);
|
|
|
#endif
|
|
|
|
|
|
#if WASM_ENABLE_LIBC_WASI != 0
|
|
|
WASM_RUNTIME_API_EXTERN void
|
|
|
-wasm_runtime_set_wasi_args_ex(WASMModuleCommon *module,
|
|
|
- const char *dir_list[], uint32 dir_count,
|
|
|
- const char *map_dir_list[], uint32 map_dir_count,
|
|
|
- const char *env_list[], uint32 env_count,
|
|
|
- char *argv[], int argc,
|
|
|
- int stdinfd, int stdoutfd, int stderrfd);
|
|
|
+wasm_runtime_set_wasi_args_ex(WASMModuleCommon *module, const char *dir_list[],
|
|
|
+ uint32 dir_count, const char *map_dir_list[],
|
|
|
+ uint32 map_dir_count, const char *env_list[],
|
|
|
+ uint32 env_count, char *argv[], int argc,
|
|
|
+ int stdinfd, int stdoutfd, int stderrfd);
|
|
|
|
|
|
/* See wasm_export.h for description */
|
|
|
WASM_RUNTIME_API_EXTERN void
|
|
|
-wasm_runtime_set_wasi_args(WASMModuleCommon *module,
|
|
|
- const char *dir_list[], uint32 dir_count,
|
|
|
- const char *map_dir_list[], uint32 map_dir_count,
|
|
|
- const char *env_list[], uint32 env_count,
|
|
|
- char *argv[], int argc);
|
|
|
+wasm_runtime_set_wasi_args(WASMModuleCommon *module, const char *dir_list[],
|
|
|
+ uint32 dir_count, const char *map_dir_list[],
|
|
|
+ uint32 map_dir_count, const char *env_list[],
|
|
|
+ uint32 env_count, char *argv[], int argc);
|
|
|
|
|
|
/* See wasm_export.h for description */
|
|
|
WASM_RUNTIME_API_EXTERN bool
|
|
|
@@ -665,9 +707,8 @@ bool
|
|
|
wasm_runtime_init_wasi(WASMModuleInstanceCommon *module_inst,
|
|
|
const char *dir_list[], uint32 dir_count,
|
|
|
const char *map_dir_list[], uint32 map_dir_count,
|
|
|
- const char *env[], uint32 env_count,
|
|
|
- char *argv[], uint32 argc,
|
|
|
- int stdinfd, int stdoutfd, int stderrfd,
|
|
|
+ const char *env[], uint32 env_count, char *argv[],
|
|
|
+ uint32 argc, int stdinfd, int stdoutfd, int stderrfd,
|
|
|
char *error_buf, uint32 error_buf_size);
|
|
|
|
|
|
void
|
|
|
@@ -685,8 +726,8 @@ wasm_runtime_get_wasi_ctx(WASMModuleInstanceCommon *module_inst);
|
|
|
#if WASM_ENABLE_REF_TYPES != 0
|
|
|
/* See wasm_export.h for description */
|
|
|
WASM_RUNTIME_API_EXTERN bool
|
|
|
-wasm_externref_obj2ref(WASMModuleInstanceCommon *module_inst,
|
|
|
- void *extern_obj, uint32 *p_externref_idx);
|
|
|
+wasm_externref_obj2ref(WASMModuleInstanceCommon *module_inst, void *extern_obj,
|
|
|
+ uint32 *p_externref_idx);
|
|
|
|
|
|
/* See wasm_export.h for description */
|
|
|
WASM_RUNTIME_API_EXTERN bool
|
|
|
@@ -711,7 +752,7 @@ wasm_externref_cleanup(WASMModuleInstanceCommon *module_inst);
|
|
|
#endif /* end of WASM_ENABLE_REF_TYPES */
|
|
|
|
|
|
/* Get module of the current exec_env */
|
|
|
-WASMModuleCommon*
|
|
|
+WASMModuleCommon *
|
|
|
wasm_exec_env_get_module(WASMExecEnv *exec_env);
|
|
|
|
|
|
/**
|
|
|
@@ -722,7 +763,8 @@ wasm_exec_env_get_module(WASMExecEnv *exec_env);
|
|
|
* @return return true if enlarge successfully, false otherwise
|
|
|
*/
|
|
|
bool
|
|
|
-wasm_runtime_enlarge_memory(WASMModuleInstanceCommon *module, uint32 inc_page_count);
|
|
|
+wasm_runtime_enlarge_memory(WASMModuleInstanceCommon *module,
|
|
|
+ uint32 inc_page_count);
|
|
|
|
|
|
/* See wasm_export.h for description */
|
|
|
WASM_RUNTIME_API_EXTERN bool
|
|
|
@@ -739,14 +781,14 @@ wasm_runtime_register_natives_raw(const char *module_name,
|
|
|
bool
|
|
|
wasm_runtime_invoke_native(WASMExecEnv *exec_env, void *func_ptr,
|
|
|
const WASMType *func_type, const char *signature,
|
|
|
- void *attachment,
|
|
|
- uint32 *argv, uint32 argc, uint32 *ret);
|
|
|
+ void *attachment, uint32 *argv, uint32 argc,
|
|
|
+ uint32 *ret);
|
|
|
|
|
|
bool
|
|
|
wasm_runtime_invoke_native_raw(WASMExecEnv *exec_env, void *func_ptr,
|
|
|
const WASMType *func_type, const char *signature,
|
|
|
- void *attachment,
|
|
|
- uint32 *argv, uint32 argc, uint32 *ret);
|
|
|
+ void *attachment, uint32 *argv, uint32 argc,
|
|
|
+ uint32 *ret);
|
|
|
|
|
|
void
|
|
|
wasm_runtime_read_v128(const uint8 *bytes, uint64 *ret1, uint64 *ret2);
|
|
|
@@ -755,8 +797,8 @@ void
|
|
|
wasm_runtime_dump_module_mem_consumption(const WASMModuleCommon *module);
|
|
|
|
|
|
void
|
|
|
-wasm_runtime_dump_module_inst_mem_consumption(const WASMModuleInstanceCommon
|
|
|
- *module_inst);
|
|
|
+wasm_runtime_dump_module_inst_mem_consumption(
|
|
|
+ const WASMModuleInstanceCommon *module_inst);
|
|
|
|
|
|
void
|
|
|
wasm_runtime_dump_exec_env_mem_consumption(const WASMExecEnv *exec_env);
|
|
|
@@ -773,37 +815,32 @@ wasm_runtime_finalize_call_function(WASMExecEnv *exec_env,
|
|
|
|
|
|
bool
|
|
|
wasm_runtime_get_export_func_type(const WASMModuleCommon *module_comm,
|
|
|
- const WASMExport *export_,
|
|
|
- WASMType **out);
|
|
|
+ const WASMExport *export_, WASMType **out);
|
|
|
|
|
|
bool
|
|
|
wasm_runtime_get_export_global_type(const WASMModuleCommon *module_comm,
|
|
|
const WASMExport *export_,
|
|
|
- uint8 *out_val_type,
|
|
|
- bool *out_mutability);
|
|
|
+ uint8 *out_val_type, bool *out_mutability);
|
|
|
|
|
|
bool
|
|
|
wasm_runtime_get_export_memory_type(const WASMModuleCommon *module_comm,
|
|
|
const WASMExport *export_,
|
|
|
- uint32 *out_min_page,
|
|
|
- uint32 *out_max_page);
|
|
|
+ uint32 *out_min_page, uint32 *out_max_page);
|
|
|
|
|
|
bool
|
|
|
wasm_runtime_get_export_table_type(const WASMModuleCommon *module_comm,
|
|
|
const WASMExport *export_,
|
|
|
- uint8 *out_elem_type,
|
|
|
- uint32 *out_min_size,
|
|
|
+ uint8 *out_elem_type, uint32 *out_min_size,
|
|
|
uint32 *out_max_size);
|
|
|
|
|
|
bool
|
|
|
wasm_runtime_invoke_c_api_native(WASMModuleInstanceCommon *module_inst,
|
|
|
void *func_ptr, WASMType *func_type,
|
|
|
- uint32 argc, uint32 *argv,
|
|
|
- bool with_env, void *wasm_c_api_env);
|
|
|
+ uint32 argc, uint32 *argv, bool with_env,
|
|
|
+ void *wasm_c_api_env);
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
}
|
|
|
#endif
|
|
|
|
|
|
#endif /* end of _WASM_COMMON_H */
|
|
|
-
|