Skip to content

Commit

Permalink
chore(wasi) groudwork for multiple wasi interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
thibaultcha committed Sep 26, 2024
1 parent 9e1f295 commit 35e8eb7
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion config
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ NGX_WASM_SRCS="\
$ngx_addon_dir/src/wasm/wrt/ngx_wrt_utils.c \
$ngx_addon_dir/src/wasm/vm/ngx_wavm.c \
$ngx_addon_dir/src/wasm/vm/ngx_wavm_host.c \
$ngx_addon_dir/src/wasm/wasi/ngx_wasi_host.c"
$ngx_addon_dir/src/wasm/wasi/ngx_wasi_preview1_host.c"

NGX_WASM_CORE_SRCS="\
$ngx_addon_dir/src/wasm/ngx_wasm_core_module.c \
Expand Down
2 changes: 1 addition & 1 deletion src/wasm/wasi/ngx_wasi.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#define WASI_ERRNO_NOTSUP 58


extern ngx_wavm_host_def_t ngx_wasi_host;
extern ngx_wavm_host_def_t ngx_wasip1_host;


#endif /* _NGX_WASI_H_INCLUDED_ */
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ static ngx_wavm_host_func_def_t ngx_wasi_hfuncs[] = {
};


ngx_wavm_host_def_t ngx_wasi_host = {
ngx_string("ngx_wasi"),
ngx_wavm_host_def_t ngx_wasip1_host = {
ngx_string("ngx_wasi_preview1"),
ngx_wasi_hfuncs,
};
2 changes: 1 addition & 1 deletion src/wasm/wrt/ngx_wrt_v8.c
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ ngx_v8_link_module(ngx_wrt_module_t *module, ngx_array_t *hfuncs,
name.data = (u_char *) importname->data;

hfunc = ngx_wavm_host_hfunc_create(module->engine->pool,
&ngx_wasi_host, &name);
&ngx_wasip1_host, &name);

if (hfunc) {
dd(" -> wasi resolved: \"%.*s\"",
Expand Down
2 changes: 1 addition & 1 deletion src/wasm/wrt/ngx_wrt_wasmer.c
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ ngx_wasmer_link_module(ngx_wrt_module_t *module, ngx_array_t *hfuncs,
name.data = (u_char *) importname->data;

hfunc = ngx_wavm_host_hfunc_create(module->engine->pool,
&ngx_wasi_host, &name);
&ngx_wasip1_host, &name);

if (hfunc) {
dd(" -> wasi resolved by host function: \"%.*s\"",
Expand Down
10 changes: 5 additions & 5 deletions src/wasm/wrt/ngx_wrt_wasmtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,17 +280,17 @@ ngx_wasmtime_init_engine(ngx_wrt_engine_t *engine, wasm_config_t *config,

nwasi = 0;

for (i = 0; ngx_wasi_host.funcs[i].ptr; i++) {
for (i = 0; ngx_wasip1_host.funcs[i].ptr; i++) {
nwasi++;
}

engine->pool = pool;
engine->wasi_hfuncs = ngx_pcalloc(pool, sizeof(ngx_wavm_hfunc_t *) * nwasi);

for (i = 0; ngx_wasi_host.funcs[i].ptr; i++) {
def = &ngx_wasi_host.funcs[i];
for (i = 0; ngx_wasip1_host.funcs[i].ptr; i++) {
def = &ngx_wasip1_host.funcs[i];

hfunc = ngx_wavm_host_hfunc_create(pool, &ngx_wasi_host, &def->name);
hfunc = ngx_wavm_host_hfunc_create(pool, &ngx_wasip1_host, &def->name);

err->res = wasmtime_linker_define_func(engine->linker,
wasi_module,
Expand All @@ -316,7 +316,7 @@ ngx_wasmtime_destroy_engine(ngx_wrt_engine_t *engine)
{
size_t i;

for (i = 0; ngx_wasi_host.funcs[i].ptr; i++) {
for (i = 0; ngx_wasip1_host.funcs[i].ptr; i++) {
wasm_functype_delete(engine->wasi_hfuncs[i]->functype);
}

Expand Down

0 comments on commit 35e8eb7

Please sign in to comment.