wasmer/lib/win-exception-handler/src/exception_handling.rs
Ivan Enderlin edb6cbefca fix(runtime-core) Share the definition of Trampoline across all the backends.
This patch updates all the backends to use the definition of
`Trampoline` as defined in the `wasmer_runtime_core::typed_func`
module. That way, there is no copy of that type, and as such, it is
easier to avoid regression (a simple `cargo check` does the job).

This patch also formats the `use` statements in the updated files.
2019-10-30 13:10:34 +01:00

56 lines
1.1 KiB
Rust

use std::ptr::NonNull;
use wasmer_runtime_core::{
typed_func::Trampoline,
vm::{Ctx, Func},
};
type CallProtectedResult = Result<(), CallProtectedData>;
#[repr(C)]
pub struct CallProtectedData {
pub code: u64,
pub exception_address: u64,
pub instruction_pointer: u64,
}
extern "C" {
#[link_name = "callProtected"]
pub fn __call_protected(
trampoline: Trampoline,
ctx: *mut Ctx,
func: NonNull<Func>,
param_vec: *const u64,
return_vec: *mut u64,
out_result: *mut CallProtectedData,
) -> u8;
}
pub fn _call_protected(
trampoline: Trampoline,
ctx: *mut Ctx,
func: NonNull<Func>,
param_vec: *const u64,
return_vec: *mut u64,
) -> CallProtectedResult {
let mut out_result = CallProtectedData {
code: 0,
exception_address: 0,
instruction_pointer: 0,
};
let result = unsafe {
__call_protected(
trampoline,
ctx,
func,
param_vec,
return_vec,
&mut out_result,
)
};
if result == 1 {
Ok(())
} else {
Err(out_result)
}
}