quiescent_region/
quiescent_region.rs1#[cfg(target_os = "linux")]
4fn main() -> Result<(), Box<dyn std::error::Error>> {
5 let mut region = native_ipc_platform::linux::QuiescentRegion::new(256)?;
6 initialize(&mut region.as_bytes_mut()[..256]);
7 println!(
8 "Linux memfd capability: {} page-rounded bytes",
9 region.len()
10 );
11 Ok(())
12}
13
14#[cfg(target_os = "macos")]
15fn main() -> Result<(), Box<dyn std::error::Error>> {
16 let mut region = native_ipc_platform::macos::QuiescentRegion::new(256)?;
17 initialize(&mut region.as_bytes_mut()[..256]);
18 println!("Mach VM capability: {} page-rounded bytes", region.len());
19 Ok(())
20}
21
22#[cfg(target_os = "windows")]
23fn main() -> Result<(), Box<dyn std::error::Error>> {
24 let mut region = native_ipc_platform::windows::QuiescentRegion::new(256)?;
25 initialize(&mut region.as_bytes_mut()[..256]);
26 println!(
27 "Windows section capability: {} page-rounded bytes",
28 region.len()
29 );
30 Ok(())
31}
32
33#[cfg(not(any(target_os = "linux", target_os = "macos", target_os = "windows")))]
34fn main() {
35 compile_error!("quiescent_region requires Linux, macOS, or Windows");
36}
37
38fn initialize(bytes: &mut [u8]) {
39 assert!(bytes.iter().all(|byte| *byte == 0));
40 bytes[..8].copy_from_slice(b"NIPCDEMO");
41 }