Skip to content

Commit

Permalink
add host_func_trap
Browse files Browse the repository at this point in the history
  • Loading branch information
yamt committed Aug 7, 2024
1 parent 88cf9af commit 8d89055
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/exec.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ int invoke(struct funcinst *finst, const struct resulttype *paramtype,
int check_interrupt(struct exec_context *ctx);
int check_interrupt_interval_ms(struct exec_context *ctx);

int vtrap(struct exec_context *ctx, enum trapid id, const char *fmt,
va_list ap);
int trap_with_id(struct exec_context *ctx, enum trapid id, const char *fmt,
...) __attribute__((__format__(__printf__, 3, 4)));
int memory_getptr(struct exec_context *ctx, uint32_t memidx, uint32_t ptr,
Expand Down
11 changes: 11 additions & 0 deletions lib/host_instance.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,17 @@ host_func_memory_getptr2(struct exec_context *ctx, uint32_t memidx,
return memory_getptr2(ctx, memidx, ptr, offset, size, pp, movedp);
}

int
host_func_trap(struct exec_context *ctx, const char *fmt, ...)
{
int ret;
va_list ap;
va_start(ap, fmt);
ret = vtrap(ctx, TRAP_MISC, fmt, ap);
va_end(ap);
return ret;
}

int
schedule_call_from_hostfunc(struct exec_context *ctx,
struct restart_info *restart,
Expand Down
2 changes: 2 additions & 0 deletions lib/host_instance.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ int host_func_memory_getptr(struct exec_context *ctx, uint32_t memidx,
int host_func_memory_getptr2(struct exec_context *ctx, uint32_t memidx,
uint32_t ptr, uint32_t offset, uint32_t size,
void **pp, bool *movedp);
int host_func_trap(struct exec_context *ctx, const char *fmt, ...)
__attribute__((__format__(__printf__, 2, 3)));
struct restart_info;
int schedule_call_from_hostfunc(struct exec_context *ctx,
struct restart_info *restart,
Expand Down

0 comments on commit 8d89055

Please sign in to comment.