Skip to content

Commit

Permalink
host_func_getptr/host_func_getptr2: remove offset argument
Browse files Browse the repository at this point in the history
there are no foreseeable users. let's simplify.
  • Loading branch information
yamt committed Aug 7, 2024
1 parent cca2805 commit 71d50f3
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 24 deletions.
22 changes: 11 additions & 11 deletions lib/host_instance.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ host_func_copyin(struct exec_context *ctx, void *hostaddr, uint32_t wasmaddr,
if (ret != 0) {
return ret;
}
ret = host_func_getptr(ctx, wasmaddr, 0, len, &p);
ret = host_func_getptr(ctx, wasmaddr, len, &p);
if (ret != 0) {
return ret;
}
Expand All @@ -184,7 +184,7 @@ host_func_copyout(struct exec_context *ctx, const void *hostaddr,
if (ret != 0) {
return ret;
}
ret = host_func_getptr(ctx, wasmaddr, 0, len, &p);
ret = host_func_getptr(ctx, wasmaddr, len, &p);
if (ret != 0) {
return ret;
}
Expand All @@ -193,29 +193,29 @@ host_func_copyout(struct exec_context *ctx, const void *hostaddr,
}

int
host_func_getptr(struct exec_context *ctx, uint32_t ptr, uint32_t offset,
uint32_t size, void **pp)
host_func_getptr(struct exec_context *ctx, uint32_t ptr, uint32_t size,
void **pp)
{
return host_func_getptr2(ctx, ptr, offset, size, pp, NULL);
return host_func_getptr2(ctx, ptr, size, pp, NULL);
}

int
host_func_getptr2(struct exec_context *ctx, uint32_t ptr, uint32_t offset,
uint32_t size, void **pp, bool *movedp)
host_func_getptr2(struct exec_context *ctx, uint32_t ptr, uint32_t size,
void **pp, bool *movedp)
{
struct meminst *meminst;
int ret = cconv_default_memory(ctx, ctx->instance, &meminst);
if (ret != 0) {
return ret;
}
ret = memory_instance_getptr2(meminst, ptr, offset, size, pp, movedp);
ret = memory_instance_getptr2(meminst, ptr, 0, size, pp, movedp);
if (ret == ETOYWASMTRAP) {
ret = trap_with_id(
ctx, TRAP_OUT_OF_BOUNDS_MEMORY_ACCESS,
"host function invalid memory access at %08" PRIx32
" + %08" PRIx32 ", size %" PRIu32
", meminst size %" PRIu32 ", pagesize %" PRIu32,
ptr, offset, size, meminst->size_in_pages,
", size %" PRIu32 ", meminst size %" PRIu32
", pagesize %" PRIu32,
ptr, size, meminst->size_in_pages,
1 << memtype_page_shift(meminst->type));
assert(ret != 0);
}
Expand Down
8 changes: 4 additions & 4 deletions lib/host_instance.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ int host_func_copyout(struct exec_context *ctx, const void *hostaddr,
uint32_t wasmaddr, size_t len, size_t align);
int host_func_copyin(struct exec_context *ctx, void *hostaddr,
uint32_t wasmaddr, size_t len, size_t align);
int host_func_getptr(struct exec_context *ctx, uint32_t ptr, uint32_t offset,
uint32_t size, void **pp);
int host_func_getptr2(struct exec_context *ctx, uint32_t ptr, uint32_t offset,
uint32_t size, void **pp, bool *movedp);
int host_func_getptr(struct exec_context *ctx, uint32_t ptr, uint32_t size,
void **pp);
int host_func_getptr2(struct exec_context *ctx, uint32_t ptr, 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;
Expand Down
4 changes: 2 additions & 2 deletions libdyld/dyld_dlfcn.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ dyld_dlfcn_load_object(struct exec_context *ctx, struct host_instance *hi,
}

void *vp;
ret = host_func_getptr(ctx, namep, 0, namelen, &vp);
ret = host_func_getptr(ctx, namep, namelen, &vp);
if (ret != 0) {
user_ret = 1;
goto fail;
Expand Down Expand Up @@ -169,7 +169,7 @@ dyld_dlfcn_resolve_symbol(struct exec_context *ctx, struct host_instance *hi,
const struct dyld_dynamic_object *dobj = &VEC_ELEM(d->dynobjs, idx);

void *vp;
ret = host_func_getptr(ctx, namep, 0, namelen, &vp);
ret = host_func_getptr(ctx, namep, namelen, &vp);
if (ret != 0) {
user_ret = 1;
goto fail;
Expand Down
2 changes: 1 addition & 1 deletion libwasi/wasi_abi_path.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ wasi_path_readlink(struct exec_context *ctx, struct host_instance *hi,
* https://github.com/bytecodealliance/wasmtime/commit/24b607cf751930c51f2b6449cdfbf2e81dce1c31
*/
void *p;
host_ret = host_func_getptr(ctx, buf, 0, buflen, &p);
host_ret = host_func_getptr(ctx, buf, buflen, &p);
if (host_ret != 0) {
goto fail;
}
Expand Down
4 changes: 2 additions & 2 deletions libwasi/wasi_abi_poll.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ wasi_poll_oneoff(struct exec_context *ctx, struct host_instance *hi,
if (host_ret != 0) {
goto fail;
}
host_ret = host_func_getptr(ctx, in, 0, insize, &p);
host_ret = host_func_getptr(ctx, in, insize, &p);
if (host_ret != 0) {
goto fail;
}
Expand All @@ -63,7 +63,7 @@ wasi_poll_oneoff(struct exec_context *ctx, struct host_instance *hi,
if (host_ret != 0) {
goto fail;
}
host_ret = host_func_getptr2(ctx, out, 0, outsize, &p, &moved);
host_ret = host_func_getptr2(ctx, out, outsize, &p, &moved);
if (host_ret != 0) {
goto fail;
}
Expand Down
2 changes: 1 addition & 1 deletion libwasi/wasi_abi_random.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ wasi_random_get(struct exec_context *ctx, struct host_instance *hi,
uint32_t buflen = HOST_FUNC_PARAM(ft, params, 1, i32);
int ret = 0;
void *p;
int host_ret = host_func_getptr(ctx, buf, 0, buflen, &p);
int host_ret = host_func_getptr(ctx, buf, buflen, &p);
if (host_ret != 0) {
goto fail;
}
Expand Down
6 changes: 3 additions & 3 deletions libwasi/wasi_subr.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ wasi_copyin_iovec(struct exec_context *ctx, uint32_t iov_uaddr,
if (host_ret != 0) {
goto fail;
}
host_ret = host_func_getptr(ctx, iov_uaddr, 0,
host_ret = host_func_getptr(ctx, iov_uaddr,
iov_count * sizeof(struct wasi_iov), &p);
if (host_ret != 0) {
goto fail;
Expand All @@ -93,8 +93,8 @@ wasi_copyin_iovec(struct exec_context *ctx, uint32_t iov_uaddr,
uint32_t iov_len = le32_decode(&iov_in_module[i].iov_len);
xlog_trace("iov [%" PRIu32 "] base %" PRIx32 " len %" PRIu32,
i, iov_base, iov_len);
host_ret = host_func_getptr2(ctx, iov_base, 0, iov_len, &p,
&moved);
host_ret =
host_func_getptr2(ctx, iov_base, iov_len, &p, &moved);
if (host_ret != 0) {
goto fail;
}
Expand Down

0 comments on commit 71d50f3

Please sign in to comment.