aboutsummaryrefslogtreecommitdiff
path: root/lib/wamr/custom/runtime.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/wamr/custom/runtime.c')
-rw-r--r--lib/wamr/custom/runtime.c73
1 files changed, 0 insertions, 73 deletions
diff --git a/lib/wamr/custom/runtime.c b/lib/wamr/custom/runtime.c
deleted file mode 100644
index 84667e8..0000000
--- a/lib/wamr/custom/runtime.c
+++ /dev/null
@@ -1,73 +0,0 @@
-#include "../core/iwasm/common/wasm_runtime_common.h"
-#include "../core/iwasm/interpreter/wasm.h"
-#include "../core/shared/utils/bh_log.h"
-#include "../wamr.h"
-
-bool wasm_runtime_link_globals(wasm_module_t module, const char *module_name,
- const NativeGlobal *globals,
- uint32_t n_globals) {
-#if WASM_ENABLE_INTERP != 0
- if (module->module_type == Wasm_Module_Bytecode) {
- WASMModule *m = (WASMModule *)module;
-
- struct {
- WASMGlobalImport *g;
- WASMValue v;
- } linked[n_globals];
- memset(linked, 0, sizeof linked);
-
- for (uint32_t i = 0; i < m->import_global_count; i++) {
- WASMGlobalImport *g = &m->import_globals[i].u.global;
- if (strcmp(g->module_name, module_name) != 0) {
- continue;
- }
-
- for (uint32_t j = 0; j < n_globals; j++) {
- const NativeGlobal *n = &globals[j];
- if (strcmp(g->field_name, n->symbol) != 0) {
- continue;
- }
-
- uint8_t val_type;
-
- linked[j].g = g;
- switch (n->val.kind) {
- case WASM_I32:
- val_type = VALUE_TYPE_I32;
- linked[j].v.i32 = n->val.of.i32;
- break;
- case WASM_I64:
- val_type = VALUE_TYPE_I64;
- linked[j].v.i64 = n->val.of.i64;
- break;
- case WASM_F32:
- val_type = VALUE_TYPE_F32;
- linked[j].v.f32 = n->val.of.f32;
- break;
- case WASM_F64:
- val_type = VALUE_TYPE_F64;
- linked[j].v.f64 = n->val.of.f64;
- break;
- default:
- LOG_WARNING("unsupported native global kind %x", n->val.kind);
- return false;
- }
-
- if (g->type.val_type != val_type) {
- LOG_WARNING("global import type %x does not match native type %x",
- g->type.val_type, val_type);
- return false;
- }
- }
- }
-
- for (size_t i = 0; i < n_globals; i++) {
- if (linked[i].g) {
- linked[i].g->is_linked = true;
- linked[i].g->global_data_linked = linked[i].v;
- }
- }
- }
-#endif
- return true;
-}