use crate::util::ReprCSlice;
use core::ptr::NonNull;
#[non_exhaustive]
#[repr(u8)]
pub enum Alignment {
A1 = 0,
A2 = 1,
A4 = 2,
A8 = 3,
A16 = 4,
A32 = 5,
A64 = 6
}
#[repr(C)]
pub struct Allocator {
ptr: NonNull<()>,
vtable: VTable
}
#[repr(C)]
pub struct VTable {
vtable_zig: NonNull<()>,
alloc_c: extern "C" fn(
vtable_zig: NonNull<()>,
allocator: NonNull<()>,
len: usize,
alignment: Alignment,
ret_addr: usize
) -> ReprCSlice<u8>,
resize_c: extern "C" fn(
vtable_zig: NonNull<()>,
allocator: NonNull<()>,
memory: ReprCSlice<u8>,
alignment: Alignment,
new_len: usize,
ret_addr: usize
) -> bool,
remap_c: extern "C" fn(
vtable_zig: NonNull<()>,
allocator: NonNull<()>,
memory: ReprCSlice<u8>,
alignment: Alignment,
new_len: usize,
ret_addr: usize
) -> ReprCSlice<u8>,
free_c: extern "C" fn(
vtable_zig: NonNull<()>,
allocator: NonNull<()>,
memory: ReprCSlice<u8>,
alignment: Alignment,
ret_addr: usize
)
}
const _: () = {
assert!(size_of::<Alignment>() == 1);
assert!(align_of::<Alignment>() == 1);
assert!(size_of::<Allocator>() == 6 * size_of::<usize>());
assert!(align_of::<Allocator>() == align_of::<usize>());
assert!(size_of::<VTable>() == 5 * size_of::<usize>());
assert!(align_of::<VTable>() == align_of::<usize>());
};