use ::core::mem;
use super::VaPrimitive;
const ALIGN: usize = 4;
#[repr(transparent)]
pub struct VaList<'a>(*const u8, ::core::marker::PhantomData<&'a [u32]>);
impl<'a> VaList<'a> {
unsafe fn get_raw<T: 'static>(&mut self) -> T {
assert_eq!(self.0 as usize % mem::align_of::<T>(), 0);
let rv = ::core::ptr::read(self.0 as *const T);
let slots = (mem::size_of::<T>() + (ALIGN-1)) / ALIGN;
self.0 = self.0.offset( (slots * ALIGN) as isize );
rv
}
}
impl<T: 'static> VaPrimitive for *const T {
unsafe fn get(l: &mut VaList) -> Self {
l.get_raw()
}
}
macro_rules! impl_va_prim {
( $( $t:ty, )+ ) => {
$(
impl VaPrimitive for $t {
unsafe fn get(l: &mut VaList) -> Self {
l.get_raw()
}
}
)+
};
}
impl_va_prim!{
usize, isize,
u64, i64,
u32, i32,
f64,
}