Skip to content

Commit

Permalink
host_instance.h: move a few things from wasi_impl.h
Browse files Browse the repository at this point in the history
  • Loading branch information
yamt committed May 27, 2024
1 parent 168e62e commit 3f99b6f
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion lib/host_instance.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,18 @@ struct host_func {
const struct functype *ft, const struct cell *params, \
struct cell *results)

#define HOST_FUNC(FUNC_PREFIX, NAME, TYPE) \
#define HOST_FUNC_PREFIX(FUNC_PREFIX, NAME, TYPE) \
{ \
.name = NAME_FROM_CSTR_LITERAL(#NAME), .type = TYPE, \
.func = FUNC_PREFIX##NAME, \
}

#define HOST_FUNC(NAME, FUNC, TYPE) \
{ \
.name = NAME_FROM_CSTR_LITERAL(#NAME), .type = TYPE, \
.func = FUNC, \
}

#define HOST_FUNC_CONVERT_PARAMS(FT, PARAMS) \
struct val *converted_params = \
calloc((FT)->parameter.ntypes, sizeof(*converted_params)); \
Expand All @@ -44,6 +50,18 @@ struct host_func {
val_to_cells(&tmp, &(RESULTS)[cidx], csz); \
} while (0)

#if defined(TOYWASM_ENABLE_TRACING)
#define HOST_FUNC_TRACE \
do { \
xlog_trace("host func %s called", __func__); \
host_func_dump_params(ft, params); \
} while (0)
#else
#define HOST_FUNC_TRACE \
do { \
} while (0)
#endif

struct host_instance {
int dummy;
};
Expand Down

0 comments on commit 3f99b6f

Please sign in to comment.