WIP: Untested more process runtime bootstrapping, some decisions on how grime is setup..
This commit is contained in:
@@ -2,6 +2,5 @@
|
||||
|
||||
This is a top-level package to adjust odin to my personalized usage.
|
||||
|
||||
I curate all usage of odin's provided package definitons through here. The client and host packages should never directly import them.
|
||||
There is only one definition with static allocations in Grime. Ideally there are also none, but spall profiler needs a context.
|
||||
|
||||
There are no implicit static allocations in Grime. Ideally there are also none from the base/core packages but some probably leak.
|
||||
|
||||
@@ -1,32 +1,21 @@
|
||||
package grime
|
||||
|
||||
import "core:os"
|
||||
|
||||
// Below should be defined per-package
|
||||
|
||||
ensure :: #force_inline proc( condition : b32, msg : string, location := #caller_location )
|
||||
{
|
||||
if condition {
|
||||
return
|
||||
}
|
||||
ensure :: #force_inline proc( condition : b32, msg : string, location := #caller_location ) {
|
||||
if condition do return
|
||||
log_print( msg, LoggerLevel.Warning, location )
|
||||
debug_trap()
|
||||
}
|
||||
|
||||
// TODO(Ed) : Setup exit codes!
|
||||
fatal :: #force_inline proc( msg : string, exit_code : int = -1, location := #caller_location )
|
||||
{
|
||||
fatal :: #force_inline proc( msg : string, exit_code : int = -1, location := #caller_location ) {
|
||||
log_print( msg, LoggerLevel.Fatal, location )
|
||||
debug_trap()
|
||||
process_exit( exit_code )
|
||||
}
|
||||
|
||||
// TODO(Ed) : Setup exit codes!
|
||||
verify :: #force_inline proc( condition : b32, msg : string, exit_code : int = -1, location := #caller_location )
|
||||
{
|
||||
if condition {
|
||||
return
|
||||
}
|
||||
verify :: #force_inline proc( condition : b32, msg : string, exit_code : int = -1, location := #caller_location ) {
|
||||
if condition do return
|
||||
log_print( msg, LoggerLevel.Fatal, location )
|
||||
debug_trap()
|
||||
process_exit( exit_code )
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package grime
|
||||
|
||||
Context :: struct {
|
||||
OdinContext :: struct {
|
||||
allocator: AllocatorInfo,
|
||||
temp_allocator: AllocatorInfo,
|
||||
assertion_failure_proc: Assertion_Failure_Proc,
|
||||
@@ -14,6 +14,6 @@ Context :: struct {
|
||||
_internal: rawptr,
|
||||
}
|
||||
|
||||
context_usr :: #force_inline proc( $ Type : typeid ) -> (^Type) {
|
||||
context_user :: #force_inline proc( $ Type : typeid ) -> (^Type) {
|
||||
return cast(^Type) context.user_ptr
|
||||
}
|
||||
|
||||
@@ -119,7 +119,6 @@ memory_aign_forward :: #force_inline proc( address, alignment : uintptr) -> uint
|
||||
return aligned_address
|
||||
}
|
||||
|
||||
|
||||
// align_up :: proc(address: uintptr, alignment: uintptr) -> uintptr {
|
||||
// return (address + alignment - 1) & ~(alignment - 1)
|
||||
// }
|
||||
|
||||
@@ -78,8 +78,12 @@ import "core:os"
|
||||
file_truncate :: os.truncate
|
||||
file_write :: os.write
|
||||
|
||||
file_read_entire :: os.read_entire_file
|
||||
file_write_entire :: os.write_entire_file
|
||||
file_read_entire_from_filename :: #force_inline proc(name: string, allocator := context.allocator, loc := #caller_location) -> (data: []byte, success: bool) { return os.read_entire_file_from_filename(name, resolve_odin_allocator(allocator), loc) }
|
||||
file_write_entire :: os.write_entire_file
|
||||
|
||||
file_read_entire :: proc {
|
||||
file_read_entire_from_filename,
|
||||
}
|
||||
|
||||
import "core:strings"
|
||||
StrBuilder :: strings.Builder
|
||||
|
||||
@@ -12,26 +12,21 @@ SpallProfiler :: struct {
|
||||
buffer : spall.Buffer,
|
||||
}
|
||||
|
||||
// @(private)
|
||||
// Module_Context : ^SpallProfiler
|
||||
|
||||
// set_profiler_module_context :: #force_inline proc "contextless" ( ctx : ^SpallProfiler ) {
|
||||
// Module_Context = ctx
|
||||
// }
|
||||
set_profiler_module_context :: #force_inline proc "contextless" ( profiler : ^SpallProfiler ) {
|
||||
static_memory.spall_profiler = profiler
|
||||
}
|
||||
|
||||
DISABLE_PROFILING :: true
|
||||
|
||||
@(deferred_none = profile_end, disabled = DISABLE_PROFILING)
|
||||
profile :: #force_inline proc "contextless" ( name : string, loc := #caller_location ) {
|
||||
// spall._buffer_begin( & Module_Context.ctx, & Module_Context.buffer, name, "", loc )
|
||||
spall._buffer_begin( & static_memory.spall_profiler.ctx, & static_memory.spall_profiler.buffer, name, "", loc )
|
||||
}
|
||||
|
||||
@(disabled = DISABLE_PROFILING)
|
||||
profile_begin :: #force_inline proc "contextless" ( name : string, loc := #caller_location ) {
|
||||
// spall._buffer_begin( & Module_Context.ctx, & Module_Context.buffer, name, "", loc )
|
||||
spall._buffer_begin( & static_memory.spall_profiler.ctx, & static_memory.spall_profiler.buffer, name, "", loc )
|
||||
}
|
||||
|
||||
@(disabled = DISABLE_PROFILING)
|
||||
profile_end :: #force_inline proc "contextless" () {
|
||||
// spall._buffer_end( & Module_Context.ctx, & Module_Context.buffer)
|
||||
spall._buffer_end( & static_memory.spall_profiler.ctx, & static_memory.spall_profiler.buffer)
|
||||
}
|
||||
|
||||
9
code2/grime/static_memory.odin
Normal file
9
code2/grime/static_memory.odin
Normal file
@@ -0,0 +1,9 @@
|
||||
package grime
|
||||
|
||||
//region STATIC MEMORY
|
||||
static_memory: StaticMemory
|
||||
//endregion STATIC MEMORY
|
||||
|
||||
StaticMemory :: struct {
|
||||
spall_profiler: ^SpallProfiler,
|
||||
}
|
||||
Reference in New Issue
Block a user