#![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_select! {
miri => {
mod miri;
pub use miri::*;
}
not(feature = "std") => {
mod custom;
pub use custom::*;
}
windows => {
mod windows;
pub use windows::*;
}
unix => {
mod unix;
pub use unix::*;
}
_ => {
mod custom;
pub use custom::*;
}
}