pub trait Memory
{
#[inline(always)]
fn wrap(address: *mut c_void, size: size_t) -> Self;
#[inline(always)]
fn address(&self) -> *mut c_void;
#[inline(always)]
fn size(&self) -> size_t;
#[inline(always)]
fn is_null(&self) -> bool
{
self.address().is_null()
}
#[inline(always)]
fn to_node(&self, node: NodeIndex)
{
unsafe { numa_tonode_memory(self.address(), self.size(), node.0 as c_int) }
}
#[inline(always)]
fn set_local(&self)
{
unsafe { numa_setlocal_memory(self.address(), self.size()) }
}
#[inline(always)]
fn police(&self)
{
unsafe { numa_police_memory(self.address(), self.size()) }
}
fn bind(&self, nodes: &NodeMask, memory_policy: MemoryPolicy, flags: MovePagesFlags::Flags) -> Result<(), ErrorKind>
{
use ::std::io::ErrorKind::*;
let bitmask = nodes.bitmask();
match unsafe { mbind(self.address(), self.size() as c_ulong, memory_policy as c_int, (*bitmask).maskp, (*bitmask).size, flags.bits()) }
{
0 => Ok(()),
-1 => match errno().0
{
::libc::EFAULT => panic!("Used an invalid address, an address not in this process or their was an unmapped hole in the length supplied"),
::libc::EINVAL => Err(InvalidInput),
::libc::EIO => Err(PermissionDenied),
::libc::ENOMEM => Err(Other),
::libc::EPERM => Err(PermissionDenied),
unexpected @ _ => panic!("Did not expect numa_move_pages to set errno {}", unexpected),
},
unexpected @ _ => panic!("Did not expect numa_move_pages to return {}", unexpected),
}
}
}