use core::cell::Cell;
use core::ptr;
pub struct TlsCallback {
pub func: Cell<Option<fn()>>,
pub next: Cell<*const TlsCallback>,
}
impl TlsCallback {
pub const fn new() -> Self {
Self {
func: Cell::new(None),
next: Cell::new(ptr::null()),
}
}
}
pub unsafe trait Backend {
type Mutex: Mutex;
fn mreserve(ptr: *mut u8, size: usize) -> *mut u8;
unsafe fn mcommit(ptr: *mut u8, size: usize) -> bool;
unsafe fn mdecommit(ptr: *mut u8, size: usize);
unsafe fn munreserve(ptr: *mut u8, size: usize);
fn pagesize() -> usize;
unsafe fn tls_attach(callback: *const TlsCallback);
}
pub unsafe trait Mutex: 'static + Sync + Send {
type Guard<'a>;
unsafe fn new(ptr: *mut Self);
#[must_use]
unsafe fn lock(&self) -> Self::Guard<'_>;
}