* Remove another thread local in `instance.rs` This commit removes another usage of `thread_local!` in the continued effort to centralize all thread-local state per-call (or basically state needed for traps) in one location. This removal is targeted at the support for custom signal handlers on instances, removing the previous stack of instances with instead a linked list of instances. The `with_signals_on` method is no longer necessary (since it was always called anyway) and is inferred from the first `vmctx` argument of the entrypoints into wasm. These functions establish a linked list of instances on the stack, if needed, to handle signals when they happen. This involved some refactoring where some C++ glue was moved into Rust, so now Rust handles a bit more of the signal handling logic. * Update some inline docs about `HandleTrap`
32 lines
1.1 KiB
Rust
32 lines
1.1 KiB
Rust
//! windows-specific extension for the `wasmtime` crate.
|
|
//!
|
|
//! This module is only available on Windows targets.
|
|
//! It is not available on Linux or macOS, for example. Note that the import path for
|
|
//! this module is `wasmtime::windows::...`, which is intended to emphasize that it
|
|
//! is platform-specific.
|
|
//!
|
|
//! The traits contained in this module are intended to extend various types
|
|
//! throughout the `wasmtime` crate with extra functionality that's only
|
|
//! available on Windows.
|
|
|
|
use crate::Instance;
|
|
|
|
/// Extensions for the [`Instance`] type only available on Windows.
|
|
pub trait InstanceExt {
|
|
/// Configures a custom signal handler to execute.
|
|
///
|
|
/// TODO: needs more documentation.
|
|
unsafe fn set_signal_handler<H>(&self, handler: H)
|
|
where
|
|
H: 'static + Fn(winapi::um::winnt::PEXCEPTION_POINTERS) -> bool;
|
|
}
|
|
|
|
impl InstanceExt for Instance {
|
|
unsafe fn set_signal_handler<H>(&self, handler: H)
|
|
where
|
|
H: 'static + Fn(winapi::um::winnt::PEXCEPTION_POINTERS) -> bool,
|
|
{
|
|
self.instance_handle.clone().set_signal_handler(handler);
|
|
}
|
|
}
|