#![allow(unused, non_camel_case_types)]
pub extern crate libc;
pub mod constants;
pub mod types;
pub mod linux;
pub mod unix;
pub fn memory <T> (size: usize, read: bool, write: bool, exec: bool, shared: bool) -> *mut T {
use crate::{constants::{map, mprot}, unix::sys_mmap};
let mut prot = mprot::NONE;
let mut flags = map::ANON;
if read { prot |= mprot::READ; }
if write { prot |= mprot::WRITE; }
if exec { prot |= mprot::EXEC; }
if shared { flags |= map::SHARED; }
else { flags |= map::PRIVATE; }
sys_mmap(0 as *mut (), size, prot, flags, -1, 0) as *mut T
}
pub fn release <T> (mem: *mut T, size: usize) {
crate::unix::sys_munmap(mem as *mut (), size);
}
#[cfg(test)]
mod tests {
#[test]
fn it_works() {
let result = 2 + 2;
assert_eq!(result, 4);
}
}