1 //! OS-related abstractions required by Wasmtime.
2 //!
3 //! This module is intended to house all logic that's specific to either Unix
4 //! or Windows, for example. The goal of this module is to be the "single
5 //! module" to edit if Wasmtime is ported to a new platform. Ideally all that's
6 //! needed is an extra block below and a new platform should be good to go after
7 //! filling out the implementation.
8 
9 #![allow(clippy::cast_sign_loss)] // platforms too fiddly to worry about this
10 
11 /// What happens to a mapping after it is decommitted?
12 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
13 pub enum DecommitBehavior {
14     /// The mapping is zeroed.
15     Zero,
16     /// The original mapping is restored. If it was zero, then it is zero again;
17     /// if it was a CoW mapping, then the original CoW mapping is restored;
18     /// etc...
19     RestoreOriginalMapping,
20 }
21 
22 cfg_if::cfg_if! {
23     if #[cfg(miri)] {
24         mod miri;
25         pub use miri::*;
26     } else if #[cfg(windows)] {
27         mod windows;
28         pub use windows::*;
29     } else if #[cfg(unix)] {
30         mod unix;
31         pub use unix::*;
32     } else {
33         mod custom;
34         pub use custom::*;
35     }
36 }
37