Skip to main content

wasm32_ptr_to_i32_arg

Function wasm32_ptr_to_i32_arg 

Source
pub(crate) fn wasm32_ptr_to_i32_arg(ptr: u64) -> Result<i32, Errno>
Expand description

Converts a linear-memory address into the i32 argument used to pass it to a guest export that takes a wasm32 pointer (wasi_thread_start, asyncify_start_unwind, …).

Wasm integers carry no signedness, so every wasm32 address maps to the i32 with the same bit pattern. i32::try_from would wrongly reject valid addresses at or above 2 GiB. Only addresses that do not fit into 32 bits (reachable with memory64) are rejected, with Errno::Overflow.