use std::{marker, mem};
use o3::alloc::{self, array};
pub mod owner;
pub mod system;
pub mod tail;
#[repr(align(256))]
#[derive(Clone, Copy)]
pub struct AlignedZst;
#[repr(align(64))]
pub struct AlignedUnit;
#[repr(align(64))]
pub struct Aligned(pub u8);
#[repr(align(64))]
pub struct Header(pub u32);
pub struct Plan<R, T, E = ()> {
roots: usize,
tails: usize,
value: marker::PhantomData<(R, T, E)>,
}
impl<R, T, E> Plan<R, T, E> {
pub fn try_new(roots: usize, tails: usize) -> Result<Self, alloc::Overflow> {
alloc::raw::Bundle::try_layout::<Self>(roots, tails)?;
Ok(Self {
roots,
tails,
value: marker::PhantomData,
})
}
}
unsafe impl<R, T, E> alloc::raw::Shape for Plan<R, T, E> {
type Root = R;
type Tail = T;
type Extra = E;
type Last = ();
fn len(&self) -> usize {
self.roots
}
fn tail_len(&self) -> usize {
self.tails
}
}
pub struct Rows;
unsafe impl alloc::raw::Shape for Rows {
type Root = u32;
type Tail = mem::MaybeUninit<u64>;
type Extra = u8;
type Last = u16;
fn len(&self) -> usize {
3
}
}
unsafe impl alloc::raw::Rows for Rows {}
pub struct EmptyRows<R, T, E, L>(marker::PhantomData<(R, T, E, L)>);
unsafe impl<R, T, E, L> alloc::raw::Shape for EmptyRows<R, T, E, L> {
type Root = R;
type Tail = T;
type Extra = E;
type Last = L;
fn len(&self) -> usize {
0
}
}
unsafe impl<R, T, E, L> alloc::raw::Rows for EmptyRows<R, T, E, L> {}
pub struct Wrapped {
pub block: array::Block<mem::MaybeUninit<Box<u64>>, usize, (usize, usize)>,
}
impl Drop for Wrapped {
fn drop(&mut self) {
let (head, len) = *self.block.state();
let cap = self.block.len();
for index in 0..len {
unsafe { self.block[(head + index) % cap].assume_init_drop() };
}
}
}