aboutsummaryrefslogtreecommitdiff
path: root/src/op/current_memory.c
blob: 4c1f26a752d7638cc346bafcd3dd18eb2403e811 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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);
}