its compiling... (prepping for runtime testing)

This commit is contained in:
ed
2025-02-08 23:27:06 -05:00
parent 3b12268f46
commit 50c7853b9f
15 changed files with 138 additions and 54 deletions
+2
View File
@@ -181,4 +181,6 @@ void* arena_allocator_proc(void* allocator_data, AllocatorMode mode, SSIZE size,
}
break;
}
return allocated_ptr;
}
+1 -1
View File
@@ -139,7 +139,7 @@ arena_pop(Arena* arena, SSIZE amt) {
//- rjf: temporary arena scopes
inline TempArena
temp_begin(Arena *arena) {
temp_begin(Arena* arena) {
U64 pos = arena_pos(arena);
TempArena temp = {arena, pos};
return temp;
+3 -1
View File
@@ -48,6 +48,8 @@ struct Log
////////////////////////////////
//~ rjf: Log Creation/Selection
Log* log_alloc(AllocatorInfo ainfo, U64 arena_block_size);
void log_release(Log* log);
MD_API void log_select (Log* log);
@@ -82,5 +84,5 @@ MD_API void log_msgf(LogMsgKind kind, char* fmt, ...);
////////////////////////////////
//~ rjf: Log Scopes
MD_API void log_scope_begin(void);
void log_scope_begin(void);
MD_API LogScopeResult log_scope_end(Arena* arena);
+1
View File
@@ -242,6 +242,7 @@ varena__alloc(VArenaParams params)
vm->committed = commit_size;
vm->commit_used = 0;
vm->flags = params.flags;
return vm;
}
void
+3 -7
View File
@@ -2016,10 +2016,7 @@ fuzzy_match_find(Arena *arena, String8 needle, String8 haystack)
FuzzyMatchRangeList
fuzzy_match_find_alloc(AllocatorInfo ainfo, String8 needle, String8 haystack)
{
// TODO(Ed): Review, we should just keep using thread scratch arenas (and provide them to teh context)
Arena* arena = arena_alloc(.backing = ainfo, .block_size = MB(1));
TempArena scratch = temp_begin(&arena, 1);
TempArena scratch = scratch_begin(0, 0);
String8List needles = str8_split(scratch.arena, needle, (U8*)" ", 1, 0);
FuzzyMatchRangeList
result = {0};
@@ -2045,7 +2042,7 @@ fuzzy_match_find_alloc(AllocatorInfo ainfo, String8 needle, String8 haystack)
}
if (find_pos < haystack.size) {
Rng1U64 range = r1u64(find_pos, find_pos+needle_n->string.size);
FuzzyMatchRangeNode* n = push_array(arena, FuzzyMatchRangeNode, 1);
FuzzyMatchRangeNode* n = push_array(scratch.arena, FuzzyMatchRangeNode, 1);
n->range = range;
sll_queue_push(result.first, result.last, n);
result.count += 1;
@@ -2053,7 +2050,6 @@ fuzzy_match_find_alloc(AllocatorInfo ainfo, String8 needle, String8 haystack)
}
}
temp_end(scratch);
arena_release(arena);
return result;
}
@@ -2239,7 +2235,7 @@ str8_serial_alloc_u64(AllocatorInfo ainfo, String8List* srl, U64 x) {
}
void
str8_serial_push_u32(AllocatorInfo ainfo, String8List* srl, U32 x) {
str8_serial_alloc_u32(AllocatorInfo ainfo, String8List* srl, U32 x) {
U8* buf = alloc_array_no_zero(ainfo, U8, 4);
memory_copy(buf, &x, 4);
String8 *str = &srl->last->string;
+19 -9
View File
@@ -16,24 +16,34 @@ MD_API_C thread_static TCTX* tctx_thread_local = 0;
#endif
void
tctx_init_and_equip(TCTX* tctx){
tctx_init_and_equip(TCTX* tctx)
{
memory_zero_struct(tctx);
Arena** arena_ptr = tctx->arenas;
for (U64 i = 0; i < array_count(tctx->arenas); i += 1, arena_ptr += 1) {
// TODO(Ed): Review this, we are not exposing a way for the user to defining the backing of these thread-context arenas.
VArena* vm = varena_alloc(.reserve_size = VARENA_DEFAULT_RESERVE, .commit_size = VARENA_DEFAULT_COMMIT);
*arena_ptr = arena_alloc(.backing = varena_allocator(vm));
for (U64 i = 0; i < array_count(tctx->arenas); i += 1, arena_ptr += 1)
{
if (*arena_ptr == nullptr)
{
VArena* vm = varena_alloc(.reserve_size = VARENA_DEFAULT_RESERVE, .commit_size = VARENA_DEFAULT_COMMIT);
*arena_ptr = arena_alloc(.backing = varena_allocator(vm));
}
}
tctx_thread_local = tctx;
}
void
tctx_init_and_equip_ainfos(TCTX* tctx, AllocatorInfo ainfos[2]) {
tctx_init_and_equip_alloc(TCTX* tctx, AllocatorInfo ainfo)
{
memory_zero_struct(tctx);
Arena** arena_ptr = tctx->arenas;
for (U64 i = 0; i < array_count(tctx->arenas); i += 1, arena_ptr += 1) {
// TODO(Ed): Is this ok? Is it alright that the thread context can use Arenas?
*arena_ptr = arena_alloc(.backing = ainfos[i]);
for (U64 i = 0; i < array_count(tctx->arenas); i += 1, arena_ptr += 1)
{
if (*arena_ptr == nullptr)
{
*arena_ptr = arena_alloc(.backing = ainfo);
}
}
tctx_thread_local = tctx;
}
+4 -4
View File
@@ -25,10 +25,10 @@ struct TCTX
////////////////////////////////
// NOTE(allen): Thread Context Functions
MD_API void tctx_init_and_equip(TCTX* tctx);
MD_API void tctx_init_and_equip_ainfos(TCTX* tctx, AllocatorInfo ainfos[2]);
MD_API void tctx_release(void);
MD_API TCTX* tctx_get_equipped(void);
MD_API void tctx_init_and_equip (TCTX* tctx);
MD_API void tctx_init_and_equip_alloc(TCTX* tctx, AllocatorInfo ainfo);
MD_API void tctx_release (void);
MD_API TCTX* tctx_get_equipped (void);
MD_API Arena* tctx_get_scratch(Arena** conflicts, U64 count);