1 //! Implementation of Wasmtime's system primitives for Unix-like operating 2 //! systems. 3 //! 4 //! This module handles Linux and macOS for example. 5 6 use core::cell::Cell; 7 8 #[cfg(has_virtual_memory)] 9 pub mod mmap; 10 pub mod traphandlers; 11 #[cfg(has_host_compiler_backend)] 12 pub mod unwind; 13 #[cfg(has_virtual_memory)] 14 pub mod vm; 15 16 #[cfg(all(has_native_signals, target_vendor = "apple"))] 17 pub mod machports; 18 #[cfg(has_native_signals)] 19 pub mod signals; 20 21 #[cfg(all(target_os = "linux", target_pointer_width = "64", feature = "std"))] 22 mod pagemap; 23 #[cfg(not(all(target_os = "linux", target_pointer_width = "64", feature = "std")))] 24 use crate::vm::pagemap_disabled as pagemap; 25 26 std::thread_local!(static TLS: Cell<*mut u8> = const { Cell::new(std::ptr::null_mut()) }); 27 28 #[inline] tls_get() -> *mut u829pub fn tls_get() -> *mut u8 { 30 TLS.with(|p| p.get()) 31 } 32 33 #[inline] tls_set(ptr: *mut u8)34pub fn tls_set(ptr: *mut u8) { 35 TLS.with(|p| p.set(ptr)); 36 } 37