Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add missing length_unsafe #4

Merged
merged 1 commit into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/extism.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ static ExtismStatus init_plugin(ExtismPlugin *plugin,
FN(log_warn, "(I)"), FN(log_error, "(I)"),
FN(config_get, "(I)I"), FN(var_get, "(I)I"),
FN(var_set, "(II)"), FN(http_request, "(II)I"),
FN(http_status_code, "()i"),
};
FN(http_status_code, "()i"), FN(length_unsafe, "(I)I")};
#undef FN
size_t nkernel = sizeof(kernel) / sizeof(NativeSymbol);

Expand Down
2 changes: 2 additions & 0 deletions src/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ struct ExtismKernel {
wasm_function_inst_t alloc;
wasm_function_inst_t free;
wasm_function_inst_t length;
wasm_function_inst_t length_unsafe;
wasm_function_inst_t reset;
wasm_function_inst_t input_offset;
wasm_function_inst_t input_length;
Expand Down Expand Up @@ -47,6 +48,7 @@ uint64_t k_alloc(wasm_exec_env_t env, uint64_t size);
void k_reset(wasm_exec_env_t env);
void k_free(wasm_exec_env_t env, uint64_t offs);
uint64_t k_length(wasm_exec_env_t env, uint64_t offs);
uint64_t k_length_unsafe(wasm_exec_env_t env, uint64_t offs);
void k_output_set(wasm_exec_env_t env, uint64_t offs, uint64_t length);
uint64_t k_output_length(wasm_exec_env_t env);
uint64_t k_output_offset(wasm_exec_env_t env);
Expand Down
10 changes: 10 additions & 0 deletions src/kernel.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ uint64_t k_length(wasm_exec_env_t env, uint64_t offs) {
return results[0].of.i64;
}

uint64_t k_length_unsafe(wasm_exec_env_t env, uint64_t offs) {
KERNEL_INIT(plugin, kernel);
wasm_val_t params[] = {{.kind = WASM_I64, .of = {.i64 = offs}}};
wasm_val_t results[] = {{.kind = WASM_I64, .of = {.i64 = 0}}};
KERNEL_CALL(wasm_runtime_call_wasm_a(env, kernel->length_unsafe, 1, results,
1, params));
return results[0].of.i64;
}

void k_output_set(wasm_exec_env_t env, uint64_t offs, uint64_t length) {
KERNEL_INIT(plugin, kernel);
wasm_val_t params[] = {{.kind = WASM_I64, .of = {.i64 = offs}},
Expand Down Expand Up @@ -315,6 +324,7 @@ void init_kernel(struct ExtismKernel *kernel,
KERNEL_FN(alloc);
KERNEL_FN(free);
KERNEL_FN(length);
KERNEL_FN(length_unsafe);
KERNEL_FN(reset);
KERNEL_FN(input_set);
KERNEL_FN(input_offset);
Expand Down
Loading