"""Auto-generated Python stub file"""


import t, c
from stdint import *
import string
import atom
import viperio
import stdio
MEMHUB_ALIGN: t.CDefine
MEMSLAB_MIN_BLOCK: t.CDefine
MEMSLAB_BITMAP_BYTES: t.CDefine
MEMBUDDY_MIN_BLOCK: t.CDefine
MEMBUDDY_MAX_ORDERS: t.CDefine
MEMBUDDY_HEADER_SIZE: t.CDefine
def _align_up(val: t.CSizeT, align: t.CSizeT) -> t.CSizeT: pass

def _largest_pow2_le(val: t.CSizeT) -> t.CSizeT: pass

def _block_size_at_order(order: t.CInt) -> t.CSizeT: pass

@t.CVTable
class MemManager:
    __provides__: list[str]
    base: t.CVoid | t.CPtr
    size: t.CSizeT
    def __init__(self, base: t.CVoid | t.CPtr, size: t.CSizeT): pass
    def alloc(self, size: t.CSizeT) -> t.CVoid | t.CPtr: pass
    def free(self, ptr: t.CVoid | t.CPtr) -> t.CInt: pass
    def reset(self) -> t.CInt: pass
    def calloc(self, count: t.CSizeT, size: t.CSizeT) -> t.CVoid | t.CPtr: pass
    def realloc(self, ptr: t.CVoid | t.CPtr, new_size: t.CSizeT) -> t.CVoid | t.CPtr: pass
    def __enter__(self) -> 'MemManager' | t.CPtr: pass
    def __exit__(self): pass
    def alloc_buf(self, capacity: t.CSizeT) -> viperio.Buf | t.CPtr: pass

class MemPool(MemManager):
    offset: t.CSizeT
    high_water: t.CSizeT
    def __init__(self, base: t.CVoid | t.CPtr, size: t.CSizeT): pass
    def alloc(self, size: t.CSizeT) -> t.CVoid | t.CPtr: pass
    def free(self, ptr: t.CVoid | t.CPtr) -> t.CInt: pass
    def reset(self) -> t.CInt: pass

class MemSlab(MemManager):
    block_size: t.CSizeT
    block_count: t.CSizeT
    used_count: t.CSizeT
    free_list: t.CVoid | t.CPtr
    alloc_map: t.CUInt8T | t.CPtr
    alloc_map_size: t.CSizeT
    usable: t.CVoid | t.CPtr
    usable_size: t.CSizeT
    def __init__(self, base: t.CVoid | t.CPtr, size: t.CSizeT, block_size: t.CSizeT): pass
    def alloc(self, size: t.CSizeT) -> t.CVoid | t.CPtr: pass
    def free(self, ptr: t.CVoid | t.CPtr) -> t.CInt: pass
    def reset(self) -> t.CInt: pass

class MemBuddy(MemManager):
    __provides__: list[str]
    max_order: t.CInt
    free_lists: t.CUInt64T | t.CPtr
    lock_val: t.CVolatile | t.CInt
    usable: t.CVoid | t.CPtr
    usable_size: t.CSizeT
    def __init__(self, base: t.CVoid | t.CPtr, size: t.CSizeT): pass
    def _fl_push(self, order: t.CInt, block: t.CVoid | t.CPtr): pass
    def _fl_pop(self, order: t.CInt) -> t.CVoid | t.CPtr: pass
    def _fl_find_and_remove(self, order: t.CInt, target: t.CVoid | t.CPtr) -> t.CInt: pass
    def _buddy_of(self, block: t.CVoid | t.CPtr, order: t.CInt) -> t.CVoid | t.CPtr: pass
    def _order_for_size(self, size: t.CSizeT) -> t.CInt: pass
    def _split_to_order(self, to_order: t.CInt) -> t.CVoid | t.CPtr: pass
    def _coalesce(self, block: t.CVoid | t.CPtr, order: t.CInt): pass
    def _is_valid_ptr(self, ptr: t.CVoid | t.CPtr) -> t.CInt: pass
    def _lock(self): pass
    def _unlock(self): pass
    def alloc(self, size: t.CSizeT) -> t.CVoid | t.CPtr: pass
    def free(self, ptr: t.CVoid | t.CPtr) -> t.CInt: pass
    def reset(self) -> t.CInt: pass
    def realloc(self, ptr: t.CVoid | t.CPtr, new_size: t.CSizeT) -> t.CVoid | t.CPtr: pass
    @property
    def mem_size(self) -> t.CSizeT: pass
    def stats(self) -> t.CSizeT: pass
    def free_count(self) -> t.CSizeT: pass
    def self_check(self) -> t.CInt: pass

