wasmer_wasix::syscalls::wasix::closure_prepare

Function closure_prepare

Source
pub fn closure_prepare<M: MemorySize>(
    ctx: FunctionEnvMut<'_, WasiEnv>,
    backing_function: u32,
    closure: u32,
    argument_types_ptr: WasmPtr<u8, M>,
    argument_types_length: u32,
    result_types_ptr: WasmPtr<u8, M>,
    result_types_length: u32,
    environment: WasmPtr<u8, M>,
) -> Result<Errno, WasiError>
Expand description

Prepare a closure so that it can be called with a given signature.

When the closure is called after closure_prepare, the arguments will be decoded and passed to the backing function together with a pointer to the environment.

The backing function needs to conform to the following signature: uint8_t* values - a pointer to a buffer containing the arguments. uint8_t* results - a pointer to a buffer where the results will be written. void* environment - the environment that was passed to closure_prepare

backing_function is a pointer (index into __indirect_function_table) to the backing function

closure is a pointer (index into __indirect_function_table) to the closure that was obtained via closure_allocate.

argument_types_ptr is a pointer to the argument types as a list of WasmValueTypes argument_types_length is the number of arguments

result_types_ptr is a pointer to the result types as a list of WasmValueTypes result_types_length is the number of results

environment is the closure environment that will be passed to the backing function alongside the decoded arguments and results