summaryrefslogtreecommitdiff
path: root/src/op/current_memory.c
diff options
context:
space:
mode:
authorXavier Del Campo Romero <xavi.dcr@tutanota.com>2023-11-26 22:43:30 +0100
committerXavier Del Campo Romero <xavi.dcr@tutanota.com>2023-12-29 23:36:21 +0100
commit52c18e60929b64285d4bb333f87482d954c9b2e0 (patch)
tree836ab3a01d160f45cda4f5a28522fc0bf471011c /src/op/current_memory.c
First commitfirst-step
Diffstat (limited to 'src/op/current_memory.c')
-rw-r--r--src/op/current_memory.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/op/current_memory.c b/src/op/current_memory.c
new file mode 100644
index 0000000..4c1f26a
--- /dev/null
+++ b/src/op/current_memory.c
@@ -0,0 +1,35 @@
+#include <ops.h>
+#include <interp.h>
+#include <interp_private.h>
+#include <wasm_types.h>
+#include <stddef.h>
+#include <stdio.h>
+
+static int op(FILE *const f, struct interp *const i)
+{
+ varuint1 reserved;
+
+ if (varuint1_read(f, &reserved))
+ {
+ fprintf(stderr, "%s: varuint1_read failed\n", __func__);
+ return 1;
+ }
+ else if (reserved)
+ {
+ fprintf(stderr, "%s: unexpected non-zero reserved value %u\n",
+ __func__, (unsigned)reserved);
+ return 1;
+ }
+
+ return 0;
+}
+
+int op_current_memory(struct interp *const i)
+{
+ return op(i->cfg.f, i);
+}
+
+int check_current_memory(FILE *const f)
+{
+ return op(f, NULL);
+}