diff --git a/include/functions.h b/include/functions.h index 8144d18e98..1fe27acb2c 100644 --- a/include/functions.h +++ b/include/functions.h @@ -79,6 +79,6 @@ void* SysCfb_GetFbEnd(void); void RcpUtils_PrintRegisterStatus(void); void RcpUtils_Reset(void); -void SystemHeap_Init(void* start, u32 size); +void Runtime_Init(void* start, u32 size); #endif diff --git a/spec/spec b/spec/spec index 31d0a88018..362d83c1aa 100644 --- a/spec/spec +++ b/spec/spec @@ -708,7 +708,7 @@ beginseg include "$(BUILD_DIR)/src/libu64/rcp_utils.o" include "$(BUILD_DIR)/src/libu64/loadfragment2_n64.o" include "$(BUILD_DIR)/src/libu64/pad.o" - include "$(BUILD_DIR)/src/libu64/system_heap.o" + include "$(BUILD_DIR)/src/libu64/runtime.o" include "$(BUILD_DIR)/src/libu64/padsetup.o" #elif PLATFORM_GC include "$(BUILD_DIR)/src/libu64/logseverity_gc.o" @@ -720,11 +720,11 @@ beginseg #endif include "$(BUILD_DIR)/src/libu64/relocation_gc.o" include "$(BUILD_DIR)/src/libu64/load_gc.o" - include "$(BUILD_DIR)/src/libu64/system_heap.o" + include "$(BUILD_DIR)/src/libu64/runtime.o" include "$(BUILD_DIR)/src/libu64/pad.o" include "$(BUILD_DIR)/src/libu64/padsetup.o" #elif PLATFORM_IQUE - include "$(BUILD_DIR)/src/libu64/system_heap.o" + include "$(BUILD_DIR)/src/libu64/runtime.o" include "$(BUILD_DIR)/src/libu64/debug.o" include "$(BUILD_DIR)/src/libu64/gfxprint.o" include "$(BUILD_DIR)/src/libu64/logseverity_gc.o" diff --git a/src/code/main.c b/src/code/main.c index fffc72194d..79c40658cc 100644 --- a/src/code/main.c +++ b/src/code/main.c @@ -109,7 +109,7 @@ void Main(void* arg) { gSystemHeapSize = fb - systemHeapStart; PRINTF(T("システムヒープ初期化 %08x-%08x %08x\n", "System heap initialization %08x-%08x %08x\n"), systemHeapStart, fb, gSystemHeapSize); - SystemHeap_Init((void*)systemHeapStart, gSystemHeapSize); // initializes the system heap + Runtime_Init((void*)systemHeapStart, gSystemHeapSize); #if DEBUG_FEATURES { diff --git a/src/libu64/system_heap.c b/src/libu64/runtime.c similarity index 76% rename from src/libu64/system_heap.c rename to src/libu64/runtime.c index 3a98ef3cef..9dbb522f55 100644 --- a/src/libu64/system_heap.c +++ b/src/libu64/runtime.c @@ -6,13 +6,12 @@ typedef void (*arg3_800FC8D8)(void*, u32); typedef void (*arg3_800FC948)(void*, u32, u32, u32, u32, u32, u32, u32, u32); typedef void (*arg3_800FCA18)(void*, u32); -typedef struct InitFunc { +typedef struct CtorEntry { s32 nextOffset; void (*func)(void); -} InitFunc; +} CtorEntry; -// .data -void* sInitFuncs = NULL; +void* sGlobalCtorEntries = NULL; #if DEBUG_FEATURES char sNew[] = "new"; @@ -20,8 +19,7 @@ char sNew[] = "new"; char sNew[] = ""; #endif -// possibly some kind of new() function -void* func_800FC800(u32 size) { +void* Runtime_New(u32 size) { DECLARE_INTERRUPT_MASK void* ptr; @@ -41,8 +39,7 @@ void* func_800FC800(u32 size) { return ptr; } -// possibly some kind of delete() function -void func_800FC83C(void* ptr) { +void Runtime_Delete(void* ptr) { DECLARE_INTERRUPT_MASK DISABLE_INTERRUPTS(); @@ -81,7 +78,7 @@ void* func_800FC948(void* blk, u32 nBlk, u32 blkSize, arg3_800FC948 arg3) { DISABLE_INTERRUPTS(); if (blk == NULL) { - blk = func_800FC800(nBlk * blkSize); + blk = Runtime_New(nBlk * blkSize); } if (blk != NULL && arg3 != NULL) { @@ -115,39 +112,39 @@ void func_800FCA18(void* blk, u32 nBlk, u32 blkSize, arg3_800FCA18 arg3, s32 arg } if (arg4 != 0) { - func_800FC83C(blk); + Runtime_Delete(blk); } } RESTORE_INTERRUPTS(); } -void func_800FCB34(void) { - InitFunc* initFunc = (InitFunc*)&sInitFuncs; - u32 nextOffset = initFunc->nextOffset; - InitFunc* prev = NULL; +void Runtime_ExecuteGlobalCtors(void) { + CtorEntry* ctorEntry = (CtorEntry*)&sGlobalCtorEntries; + u32 nextOffset = ctorEntry->nextOffset; + CtorEntry* prevEntry = NULL; while (nextOffset != 0) { - initFunc = (InitFunc*)((s32)initFunc + nextOffset); + ctorEntry = (CtorEntry*)((s32)ctorEntry + nextOffset); - if (initFunc->func != NULL) { - initFunc->func(); + if (ctorEntry->func != NULL) { + ctorEntry->func(); } - nextOffset = initFunc->nextOffset; - initFunc->nextOffset = (s32)prev; - prev = initFunc; + nextOffset = ctorEntry->nextOffset; + ctorEntry->nextOffset = (s32)prevEntry; + prevEntry = ctorEntry; } - sInitFuncs = prev; + sGlobalCtorEntries = prevEntry; } -void SystemHeap_Init(void* start, u32 size) { +void Runtime_Init(void* start, u32 size) { #if PLATFORM_N64 __osMallocInit(&gSystemArena, start, size); #else SystemArena_Init(start, size); #endif - func_800FCB34(); + Runtime_ExecuteGlobalCtors(); }