1 //! Custom platform support in Wasmtime.
2 //!
3 //! This module contains an implementation of defining Wasmtime's platform
4 //! support in terms of a minimal C API. This API can be found in the `capi`
5 //! module and all other functionality here is implemented in terms of that
6 //! module.
7 //!
8 //! For more information about this see `./examples/min-platform` as well as
9 //! `./docs/examples-minimal.md`.
10 
11 #![warn(dead_code, unused_imports)]
12 
13 #[cfg(has_virtual_memory)]
14 use crate::prelude::*;
15 
16 pub mod capi;
17 #[cfg(has_virtual_memory)]
18 pub mod mmap;
19 pub mod traphandlers;
20 #[cfg(has_host_compiler_backend)]
21 pub mod unwind;
22 #[cfg(has_virtual_memory)]
23 pub mod vm;
24 
25 #[cfg(has_virtual_memory)]
cvt(rc: i32) -> Result<()>26 fn cvt(rc: i32) -> Result<()> {
27     match rc {
28         0 => Ok(()),
29         code => bail!("os error {code}"),
30     }
31 }
32 
33 #[inline]
tls_get() -> *mut u834 pub fn tls_get() -> *mut u8 {
35     unsafe { capi::wasmtime_tls_get() }
36 }
37 
38 #[inline]
tls_set(ptr: *mut u8)39 pub fn tls_set(ptr: *mut u8) {
40     unsafe { capi::wasmtime_tls_set(ptr) }
41 }
42