#![allow(
clippy::cast_sign_loss,
reason = "platforms too fiddly to worry about this"
)]
use crate::runtime::vm::SendSyncPtr;
use core::ptr::{self, NonNull};
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
pub enum DecommitBehavior {
Zero,
RestoreOriginalMapping,
}
fn empty_mmap() -> SendSyncPtr<[u8]> {
#[repr(C, align(4096))]
struct PageAligned;
let empty_page_alloc: &mut [PageAligned] = &mut [];
let empty = NonNull::new(ptr::slice_from_raw_parts_mut(
empty_page_alloc.as_mut_ptr().cast(),
0,
))
.unwrap();
SendSyncPtr::from(empty)
}
cfg_if::cfg_if! {
if #[cfg(miri)] {
mod miri;
pub use miri::*;
} else if #[cfg(not(feature = "std"))] {
mod custom;
pub use custom::*;
} else if #[cfg(windows)] {
mod windows;
pub use windows::*;
} else if #[cfg(unix)] {
mod unix;
pub use unix::*;
} else {
mod custom;
pub use custom::*;
}
}