In the beginning...

This commit is contained in:
Zachary Levy
2026-03-08 19:00:41 -07:00
commit f10bf7e3c3
21 changed files with 7536 additions and 0 deletions

63
basic/basic.odin Normal file
View File

@@ -0,0 +1,63 @@
package basic
import "base:runtime"
import "core:prof/spall"
//----- Spall ----------------------------------
SPALL_TRACE :: #config(SPALL_TRACE, false)
spall_ctx: spall.Context
@(thread_local)
spall_buffer: spall.Buffer
//----- Compile globals ----------------------------------
ODIN_BOUNDS_CHECK :: !ODIN_NO_BOUNDS_CHECK
INT_NUM_BITS :: size_of(int) * 8
//----- Array ----------------------------------
// append unless array doesn't room, then panic
append_elem_capped :: #force_inline proc(
array: ^$T/[dynamic]$E,
arg: E,
loc := #caller_location,
) -> (
n: int,
err: runtime.Allocator_Error,
) #optional_allocator_error {
when ODIN_BOUNDS_CHECK {
if len(array) == cap(array) {
panic("Array would have to expand to accomodate append.")
} else {
return append_elem(array, arg, loc)
}
} else {
return append_elem(array, arg, loc)
}
}
append_soa_elem_capped :: proc(
array: ^$T/#soa[dynamic]$E,
arg: E,
loc := #caller_location,
) -> (
n: int,
err: runtime.Allocator_Error,
) #optional_allocator_error {
when ODIN_BOUNDS_CHECK {
if len(array) == cap(array) {
panic("Array would have to expand to accomodate append.")
} else {
return append_soa_elem(array, arg, loc)
}
} else {
return append_soa_elem(array, arg, loc)
}
}
append_capped :: proc {
append_elem_capped,
append_soa_elem_capped,
}