mirror of
https://github.com/Ed94/WATL_Exercise.git
synced 2025-08-04 22:32:43 -07:00
progress on odin setup
This commit is contained in:
@@ -68,22 +68,19 @@ Raw_Slice :: struct {
|
||||
data: rawptr,
|
||||
len: int,
|
||||
}
|
||||
|
||||
slice_assert :: proc "contextless" (s: $Type / []$SliceType) -> Type {
|
||||
return assert(len(s) > 0) && s != nil
|
||||
}
|
||||
slice_end :: proc "contextless" (s : $Type / []$SliceType) -> Type {
|
||||
return s[len(s) - 1]
|
||||
}
|
||||
size_of_slice_type :: proc(slice: $Type / []$SliceType) -> int {
|
||||
size_of_slice_type :: proc "contextless" (slice: $Type / []$SliceType) -> int {
|
||||
return size_of(E)
|
||||
}
|
||||
|
||||
@(require_results)
|
||||
to_bytes :: proc "contextless" (s: []$Type) -> []byte {
|
||||
return ([^]byte)(raw_data(s))[:len(s) * size_of(T)]
|
||||
}
|
||||
|
||||
slice_zero :: proc "contextless" (data: $Type / []$SliceType) -> Type {
|
||||
zero(raw_data(data), size_of(E) * len(data))
|
||||
return data
|
||||
@@ -103,7 +100,7 @@ slice_copy_non_overlapping :: proc "contextless" (dst, src: $Type / []$SliceType
|
||||
return n
|
||||
}
|
||||
|
||||
sll_stack_push_n :: proc(first: ^$SLL_NodeType, n: ^SLL_NodeType) {
|
||||
sll_stack_push_n :: proc "contextless" (first: ^$SLL_NodeType, n: ^SLL_NodeType) {
|
||||
n.next = first^
|
||||
first^ = n
|
||||
}
|
||||
@@ -118,7 +115,7 @@ sll_queue_push_nz :: proc(nil_val: ^$SLL_NodeType, first: ^SLL_NodeType, last: ^
|
||||
n.next = nil_val
|
||||
}
|
||||
}
|
||||
sll_queue_push_n :: proc(first: ^$SLL_NodeType, last: ^SLL_NodeType, n: ^SLL_NodeType) {
|
||||
sll_queue_push_n :: proc "contextless" (first: ^$SLL_NodeType, last: ^SLL_NodeType, n: ^SLL_NodeType) {
|
||||
sll_queue_push_nz(nil, first, last, n)
|
||||
}
|
||||
//#endregion("Memory")
|
||||
@@ -140,12 +137,12 @@ AllocatorQueryFlag :: enum u64 {
|
||||
AllocatorQuery_Alloc,
|
||||
AllocatorQuery_Free,
|
||||
// Wipe the allocator's state
|
||||
AllocatorQuery_Reset,
|
||||
AllocatorQuery_Reset,
|
||||
// Supports both grow and shrink
|
||||
AllocatorQuery_Shrink,
|
||||
AllocatorQuery_Grow,
|
||||
AllocatorQuery_Grow,
|
||||
// Ability to rewind to a save point (ex: arenas, stack), must also be able to save such a point
|
||||
AllocatorQuery_Rewind,
|
||||
AllocatorQuery_Rewind,
|
||||
}
|
||||
AllocatorQueryFlags :: bit_set[AllocatorQueryFlag; u64]
|
||||
AllocatorSP :: struct {
|
||||
@@ -190,25 +187,37 @@ MEMORY_ALIGNMENT_DEFAULT :: 2 * size_of(rawptr)
|
||||
allocator_query :: proc(ainfo: AllocatorInfo) -> AlllocatorQueryInfo {
|
||||
|
||||
}
|
||||
mem_free :: proc(ainfo: AllocatorInfo, mem: []byte) {
|
||||
mem_free :: proc(ainfo: AllocatorInfo, mem: []byte) {
|
||||
|
||||
}
|
||||
mem_reset :: proc(ainfo: AllocatorInfo) {
|
||||
mem_reset :: proc(ainfo: AllocatorInfo) {
|
||||
|
||||
}
|
||||
mem_rewind :: proc(ainfo: AllocatorInfo, save_point: AllocatorSP)
|
||||
{
|
||||
mem_rewind :: proc(ainfo: AllocatorInfo, save_point: AllocatorSP) {
|
||||
|
||||
}
|
||||
mem_save_point :: proc(ainfo: AllocatorInfo) -> AllocatorSP
|
||||
mem_save_point :: proc(ainfo: AllocatorInfo) -> AllocatorSP {
|
||||
|
||||
mem_alloc :: proc(ainfo: AllocatorInfo) -> []byte
|
||||
mem_grow :: proc(ainfo: AllocatorInfo, mem: []byte, alignment: int = MEMORY_ALIGNMENT_DEFAULT, no_zero: b32 = false)
|
||||
mem_resize :: proc(ainfo: AllocatorInfo, mem: []byte, alignment: int = MEMORY_ALIGNMENT_DEFAULT, no_zero: b32 = false)
|
||||
mem_shrink :: proc(ainfo: AllocatorInfo, mem: []byte, alignment: int = MEMORY_ALIGNMENT_DEFAULT, no_zero: b32 = false)
|
||||
}
|
||||
mem_alloc :: proc(ainfo: AllocatorInfo, size: int, alignment: int = MEMORY_ALIGNMENT_DEFAULT, no_zero: b32 = false) -> []byte {
|
||||
|
||||
alloc_type :: proc(ainfo: AllocatorInfo, $Type: typeid) -> []Type
|
||||
alloc_slice :: proc(ainfo: AllocatorInfo, $Type: typeid, num : int) -> []Type
|
||||
}
|
||||
mem_grow :: proc(ainfo: AllocatorInfo, mem: []byte, size: int, alignment: int = MEMORY_ALIGNMENT_DEFAULT, no_zero: b32 = false) -> []byte {
|
||||
|
||||
}
|
||||
mem_resize :: proc(ainfo: AllocatorInfo, mem: []byte, size: int, alignment: int = MEMORY_ALIGNMENT_DEFAULT, no_zero: b32 = false) -> []byte {
|
||||
|
||||
}
|
||||
mem_shrink :: proc(ainfo: AllocatorInfo, mem: []byte, size: int, alignment: int = MEMORY_ALIGNMENT_DEFAULT, no_zero: b32 = false) -> []byte {
|
||||
|
||||
}
|
||||
|
||||
alloc_type :: proc(ainfo: AllocatorInfo, $Type: typeid) -> []Type {
|
||||
|
||||
}
|
||||
alloc_slice :: proc(ainfo: AllocatorInfo, $Type: typeid, num : int) -> []Type {
|
||||
|
||||
}
|
||||
//#endregion Allocator Interface
|
||||
|
||||
//#region("Strings")
|
||||
@@ -217,3 +226,146 @@ Raw_String :: struct {
|
||||
len: int,
|
||||
}
|
||||
//#endregion("Strings")
|
||||
|
||||
|
||||
//#region("FArena")
|
||||
FArena :: struct {
|
||||
mem: []byte,
|
||||
used: int,
|
||||
}
|
||||
farena_make :: proc(backing: []byte) -> FArena { arena := FArena {mem = backing}; return arena }
|
||||
farena_init :: proc(arena: ^FArena, backing: []byte) {
|
||||
|
||||
}
|
||||
farena_push :: proc(arena: ^FArena, $Type: typeid, amount: int, alignment: int = MEMORY_ALIGNMENT_DEFAULT) -> []Type {
|
||||
|
||||
}
|
||||
farena_reset :: proc(arena: ^FArena) {
|
||||
arena.used = 0
|
||||
}
|
||||
farena_rewind :: proc(arena: ^FArena, save_point: AllocatorSP) {
|
||||
|
||||
}
|
||||
farena_save :: proc(arena: FArena) -> AllocatorSP {
|
||||
|
||||
}
|
||||
farena_allocator_proc :: proc(input: AllocatorProc_In, output: ^AllocatorProc_Out) {
|
||||
|
||||
}
|
||||
//#endregion("FArena")
|
||||
|
||||
//#region("OS")
|
||||
OS_SystemInfo :: struct {
|
||||
target_page_size: int,
|
||||
}
|
||||
os_init :: proc() {
|
||||
|
||||
}
|
||||
os_system_info :: proc() {
|
||||
|
||||
}
|
||||
os_vmem_commit :: proc(vm: rawptr, size: int, no_large_pages: b32 = false) {
|
||||
|
||||
}
|
||||
os_vmem_reserve :: proc(size: int, base_addr: int = 0, no_large_pages: b32 = false) -> rawptr {
|
||||
|
||||
}
|
||||
os_vmem_release :: proc(vm : rawptr, size: int) {
|
||||
|
||||
}
|
||||
//#endregion("OS")
|
||||
|
||||
//#region("VArena")
|
||||
VArenaFlag :: enum u32 {
|
||||
No_Large_Pages,
|
||||
}
|
||||
VArenaFlags :: bit_set[VArenaFlag; u32]
|
||||
VArena :: struct {
|
||||
reserve_start: int,
|
||||
reserve: int,
|
||||
commit_size: int,
|
||||
committed: int,
|
||||
commit_used: int,
|
||||
flags: VArenaFlags,
|
||||
}
|
||||
varena_make :: proc(base_addr, reserve_size, commit_size: int, flags: VArenaFlags) -> VArena {
|
||||
|
||||
}
|
||||
varena_push :: proc(va: ^VArena, $Type: typeid, amount: int, alignment: int = MEMORY_ALIGNMENT_DEFAULT) -> []Type {
|
||||
|
||||
}
|
||||
varena_release :: proc(va: ^VArena) {
|
||||
|
||||
}
|
||||
varena_rewind :: proc(va: ^VArena) {
|
||||
|
||||
}
|
||||
varena_shrink :: proc(va: ^VArena) {
|
||||
|
||||
}
|
||||
varena_save :: proc(va: ^VArena) {
|
||||
|
||||
}
|
||||
varena_allocator_proc :: proc(input: AllocatorProc_In, output: ^AllocatorProc_Out) {
|
||||
|
||||
}
|
||||
//#endregion("VArena")
|
||||
|
||||
//#region("Arena (Casey-Ryan Composite Arena")
|
||||
ArenaFlag :: enum u32 {
|
||||
No_Large_Pages,
|
||||
No_Chaining,
|
||||
}
|
||||
ArenaFlags :: bit_set[ArenaFlag; u32]
|
||||
Arena :: struct {
|
||||
backing: ^VArena,
|
||||
prev: ^Arena,
|
||||
curr: ^Arena,
|
||||
base_pos: int,
|
||||
pos: int,
|
||||
flags: ArenaFlags,
|
||||
}
|
||||
arena_make :: proc()
|
||||
arena_push :: proc()
|
||||
arena_release :: proc()
|
||||
arena_reset :: proc()
|
||||
arena_rewind :: proc()
|
||||
arena_save :: proc()
|
||||
arena_allocator_proc :: proc(input: AllocatorProc_In, output: AllocatorProc_Out)
|
||||
//#endregion("Arena (Casey-Ryan Composite Arena")
|
||||
|
||||
//#region("Hashing")
|
||||
hash64_djb8 :: proc() {}
|
||||
//#endregion("Hashing")
|
||||
|
||||
//#region("Key Table 1-Layer Linear (KT1L)")
|
||||
KT1L_Slot :: struct($type: typeid) {
|
||||
key: u64,
|
||||
value: type
|
||||
}
|
||||
KT1L_Meta :: struct {
|
||||
slot_size: int,
|
||||
kt_value_offset: int,
|
||||
type_width: int,
|
||||
type_name: string,
|
||||
}
|
||||
kt1l_populate_slice_a2_Slice_Byte :: proc(kt: ^[]KT1L_Slot(byte), m: KT1L_Meta, backing: AllocatorInfo, values: []byte, num_values: []byte) {
|
||||
|
||||
}
|
||||
kt1l_populate_slice_a2 :: proc($Type: typeid, kt: ^[]KT1L_Slot(Type), backing: AllocatorInfo, values: [][2]Type) {
|
||||
|
||||
}
|
||||
//#endregion("Key Table 1-Layer Linear (KT1L)")
|
||||
|
||||
//#region("Key Table 1-Layer Chained-Chunked-Cells (KT1CX)")
|
||||
|
||||
//#endregion("Key Table 1-Layer Chained-Chunked-Cells (KT1CX)")
|
||||
|
||||
//#region("String Operations")
|
||||
//#endregion("String Operations")
|
||||
|
||||
//#region("File System")
|
||||
//#endregion("File System")
|
||||
|
||||
//#region("WATL")
|
||||
//#endregion("WATL")
|
||||
|
Reference in New Issue
Block a user