package core:mem/virtual

Types

Allocator_Error ¶

Allocator_Error :: runtime.Allocator_Error

Arena ¶

Arena :: struct {
	kind:               Arena_Kind,
	curr_block:         ^Memory_Block,
	total_used:         uint,
	total_reserved:     uint,
	minimum_block_size: uint,
	temp_count:         uint,
}

Arena_Kind ¶

Arena_Kind :: enum uint {
	Growing = 0, // Chained memory blocks (singly linked list).
	Static  = 1, // Fixed reservation sized.
	Buffer  = 2, // Uses a fixed sized buffer.
}

Arena_Temp ¶

Arena_Temp :: struct {
	arena: ^Arena,
	block: ^Memory_Block,
	used:  uint,
}

Memory_Block ¶

Memory_Block :: struct {
	prev:      ^Memory_Block,
	base:      [^]u8,
	used:      uint,
	committed: uint,
	reserved:  uint,
}

Memory_Block_Flag ¶

Memory_Block_Flag :: enum u32 {
	Overflow_Protection, 
}

Memory_Block_Flags ¶

Memory_Block_Flags :: distinct bit_set[Memory_Block_Flag; u32]

Protect_Flag ¶

Protect_Flag :: enum u32 {
	Read, 
	Write, 
	Execute, 
}

Protect_Flags ¶

Protect_Flags :: distinct bit_set[Protect_Flag; u32]

Constants

DEFAULT_ARENA_GROWING_MINIMUM_BLOCK_SIZE ¶

DEFAULT_ARENA_GROWING_MINIMUM_BLOCK_SIZE :: DEFAULT_ARENA_STATIC_COMMIT_SIZE

DEFAULT_ARENA_STATIC_COMMIT_SIZE ¶

DEFAULT_ARENA_STATIC_COMMIT_SIZE :: 1 << 20
 

1 MiB should be enough to start with

DEFAULT_ARENA_STATIC_RESERVE_SIZE ¶

DEFAULT_ARENA_STATIC_RESERVE_SIZE :: 1 << 30 when size_of(uintptr) == 8 else 1 << 27
 

1 GiB on 64-bit systems, 128 MiB on 32-bit systems by default

Protect_No_Access ¶

Protect_No_Access :: Protect_Flags{}

Variables

DEFAULT_PAGE_SIZE ¶

DEFAULT_PAGE_SIZE: uint = …

Procedures

alloc_from_memory_block ¶

alloc_from_memory_block :: proc "odin" (block: ^Memory_Block, min_size, alignment: uint) -> (data: []u8, err: runtime.Allocator_Error) {…}

arena_alloc ¶

arena_alloc :: proc "odin" (arena: ^Arena, size: uint, alignment: uint, loc := #caller_location) -> (data: []u8, err: runtime.Allocator_Error) {…}

arena_allocator ¶

arena_allocator :: proc "odin" (arena: ^Arena) -> runtime.Allocator {…}

arena_allocator_proc ¶

arena_allocator_proc :: proc "odin" (
	allocator_data:  rawptr, 
	mode:            runtime.Allocator_Mode, 
	size, alignment: int, 
	old_memory:      rawptr, 
	old_size:        int, 
) -> ([]u8, runtime.Allocator_Error) {…}

arena_check_temp ¶

arena_check_temp :: proc "odin" (arena: ^Arena, loc := #caller_location) {…}

arena_destroy ¶

arena_destroy :: proc "odin" (arena: ^Arena) {…}

arena_free_all ¶

arena_free_all :: proc "odin" (arena: ^Arena) {…}

arena_growing_bootstrap_new_by_name ¶

arena_growing_bootstrap_new_by_name :: proc "odin" ($T: typeid, $field_name: string = , minimum_block_size: uint = DEFAULT_ARENA_GROWING_MINIMUM_BLOCK_SIZE) -> (ptr: ^typeid, err: runtime.Allocator_Error) {…}

arena_growing_bootstrap_new_by_offset ¶

arena_growing_bootstrap_new_by_offset :: proc "odin" ($T: typeid, offset_to_arena: uintptr, minimum_block_size: uint = DEFAULT_ARENA_GROWING_MINIMUM_BLOCK_SIZE) -> (ptr: ^typeid, err: runtime.Allocator_Error) {…}

arena_growing_free_last_memory_block ¶

arena_growing_free_last_memory_block :: proc "odin" (arena: ^Arena, loc := #caller_location) {…}

arena_init_buffer ¶

arena_init_buffer :: proc "odin" (arena: ^Arena, buffer: []u8) -> (err: runtime.Allocator_Error) {…}

arena_init_growing ¶

arena_init_growing :: proc "odin" (arena: ^Arena, reserved: uint = DEFAULT_ARENA_GROWING_MINIMUM_BLOCK_SIZE) -> (err: runtime.Allocator_Error) {…}

arena_init_static ¶

arena_init_static :: proc "odin" (arena: ^Arena, reserved: uint, commit_size: uint = DEFAULT_ARENA_STATIC_COMMIT_SIZE) -> (err: runtime.Allocator_Error) {…}

arena_static_bootstrap_new_by_name ¶

arena_static_bootstrap_new_by_name :: proc "odin" ($T: typeid, $field_name: string = , reserved: uint) -> (ptr: ^typeid, err: runtime.Allocator_Error) {…}

arena_static_bootstrap_new_by_offset ¶

arena_static_bootstrap_new_by_offset :: proc "odin" ($T: typeid, offset_to_arena: uintptr, minimum_block_size: uint = DEFAULT_ARENA_GROWING_MINIMUM_BLOCK_SIZE) -> (ptr: ^typeid, err: runtime.Allocator_Error) {…}

arena_static_reset_to ¶

arena_static_reset_to :: proc "odin" (arena: ^Arena, pos: uint, loc := #caller_location) -> bool {…}

arena_temp_begin ¶

arena_temp_begin :: proc "odin" (arena: ^Arena, loc := #caller_location) -> (temp: Arena_Temp) {…}

arena_temp_end ¶

arena_temp_end :: proc "odin" (temp: Arena_Temp, loc := #caller_location) {…}

commit ¶

commit :: proc "contextless" (data: rawptr, size: uint) -> runtime.Allocator_Error {…}

decommit ¶

decommit :: proc "contextless" (data: rawptr, size: uint) {…}

memory_block_alloc ¶

memory_block_alloc :: proc "odin" (committed, reserved: uint, flags: Memory_Block_Flags) -> (block: ^Memory_Block, err: runtime.Allocator_Error) {…}

memory_block_dealloc ¶

memory_block_dealloc :: proc "odin" (block_to_free: ^Memory_Block) {…}

protect ¶

protect :: proc "contextless" (data: rawptr, size: uint, flags: Protect_Flags) -> bool {…}

release ¶

release :: proc "contextless" (data: rawptr, size: uint) {…}

reserve ¶

reserve :: proc "contextless" (size: uint) -> (data: []u8, err: runtime.Allocator_Error) {…}

reserve_and_commit ¶

reserve_and_commit :: proc "contextless" (size: uint) -> (data: []u8, err: runtime.Allocator_Error) {…}

Procedure Groups

Source Files

Generation Information

Generated with odin version dev-2022-12 (vendor "odin") Windows_amd64 @ 2022-12-06 21:08:55.170330400 +0000 UTC