Skip to content

Commit ba9ca90

Browse files
authored
system_heap -> runtime (#2500)
* very light documentation for runtime * more renaming * one more rename * RunTime -> Runtime
1 parent dc9a1dc commit ba9ca90

File tree

4 files changed

+25
-28
lines changed

4 files changed

+25
-28
lines changed

include/functions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,6 @@ void* SysCfb_GetFbEnd(void);
7979
void RcpUtils_PrintRegisterStatus(void);
8080
void RcpUtils_Reset(void);
8181

82-
void SystemHeap_Init(void* start, u32 size);
82+
void Runtime_Init(void* start, u32 size);
8383

8484
#endif

spec/spec

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,7 @@ beginseg
708708
include "$(BUILD_DIR)/src/libu64/rcp_utils.o"
709709
include "$(BUILD_DIR)/src/libu64/loadfragment2_n64.o"
710710
include "$(BUILD_DIR)/src/libu64/pad.o"
711-
include "$(BUILD_DIR)/src/libu64/system_heap.o"
711+
include "$(BUILD_DIR)/src/libu64/runtime.o"
712712
include "$(BUILD_DIR)/src/libu64/padsetup.o"
713713
#elif PLATFORM_GC
714714
include "$(BUILD_DIR)/src/libu64/logseverity_gc.o"
@@ -720,11 +720,11 @@ beginseg
720720
#endif
721721
include "$(BUILD_DIR)/src/libu64/relocation_gc.o"
722722
include "$(BUILD_DIR)/src/libu64/load_gc.o"
723-
include "$(BUILD_DIR)/src/libu64/system_heap.o"
723+
include "$(BUILD_DIR)/src/libu64/runtime.o"
724724
include "$(BUILD_DIR)/src/libu64/pad.o"
725725
include "$(BUILD_DIR)/src/libu64/padsetup.o"
726726
#elif PLATFORM_IQUE
727-
include "$(BUILD_DIR)/src/libu64/system_heap.o"
727+
include "$(BUILD_DIR)/src/libu64/runtime.o"
728728
include "$(BUILD_DIR)/src/libu64/debug.o"
729729
include "$(BUILD_DIR)/src/libu64/gfxprint.o"
730730
include "$(BUILD_DIR)/src/libu64/logseverity_gc.o"

src/code/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ void Main(void* arg) {
109109
gSystemHeapSize = fb - systemHeapStart;
110110
PRINTF(T("システムヒープ初期化 %08x-%08x %08x\n", "System heap initialization %08x-%08x %08x\n"), systemHeapStart,
111111
fb, gSystemHeapSize);
112-
SystemHeap_Init((void*)systemHeapStart, gSystemHeapSize); // initializes the system heap
112+
Runtime_Init((void*)systemHeapStart, gSystemHeapSize);
113113

114114
#if DEBUG_FEATURES
115115
{
Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,20 @@ typedef void (*arg3_800FC8D8)(void*, u32);
66
typedef void (*arg3_800FC948)(void*, u32, u32, u32, u32, u32, u32, u32, u32);
77
typedef void (*arg3_800FCA18)(void*, u32);
88

9-
typedef struct InitFunc {
9+
typedef struct CtorEntry {
1010
s32 nextOffset;
1111
void (*func)(void);
12-
} InitFunc;
12+
} CtorEntry;
1313

14-
// .data
15-
void* sInitFuncs = NULL;
14+
void* sGlobalCtorEntries = NULL;
1615

1716
#if DEBUG_FEATURES
1817
char sNew[] = "new";
1918
#else
2019
char sNew[] = "";
2120
#endif
2221

23-
// possibly some kind of new() function
24-
void* func_800FC800(u32 size) {
22+
void* Runtime_New(u32 size) {
2523
DECLARE_INTERRUPT_MASK
2624
void* ptr;
2725

@@ -41,8 +39,7 @@ void* func_800FC800(u32 size) {
4139
return ptr;
4240
}
4341

44-
// possibly some kind of delete() function
45-
void func_800FC83C(void* ptr) {
42+
void Runtime_Delete(void* ptr) {
4643
DECLARE_INTERRUPT_MASK
4744

4845
DISABLE_INTERRUPTS();
@@ -81,7 +78,7 @@ void* func_800FC948(void* blk, u32 nBlk, u32 blkSize, arg3_800FC948 arg3) {
8178
DISABLE_INTERRUPTS();
8279

8380
if (blk == NULL) {
84-
blk = func_800FC800(nBlk * blkSize);
81+
blk = Runtime_New(nBlk * blkSize);
8582
}
8683

8784
if (blk != NULL && arg3 != NULL) {
@@ -115,39 +112,39 @@ void func_800FCA18(void* blk, u32 nBlk, u32 blkSize, arg3_800FCA18 arg3, s32 arg
115112
}
116113

117114
if (arg4 != 0) {
118-
func_800FC83C(blk);
115+
Runtime_Delete(blk);
119116
}
120117
}
121118

122119
RESTORE_INTERRUPTS();
123120
}
124121

125-
void func_800FCB34(void) {
126-
InitFunc* initFunc = (InitFunc*)&sInitFuncs;
127-
u32 nextOffset = initFunc->nextOffset;
128-
InitFunc* prev = NULL;
122+
void Runtime_ExecuteGlobalCtors(void) {
123+
CtorEntry* ctorEntry = (CtorEntry*)&sGlobalCtorEntries;
124+
u32 nextOffset = ctorEntry->nextOffset;
125+
CtorEntry* prevEntry = NULL;
129126

130127
while (nextOffset != 0) {
131-
initFunc = (InitFunc*)((s32)initFunc + nextOffset);
128+
ctorEntry = (CtorEntry*)((s32)ctorEntry + nextOffset);
132129

133-
if (initFunc->func != NULL) {
134-
initFunc->func();
130+
if (ctorEntry->func != NULL) {
131+
ctorEntry->func();
135132
}
136133

137-
nextOffset = initFunc->nextOffset;
138-
initFunc->nextOffset = (s32)prev;
139-
prev = initFunc;
134+
nextOffset = ctorEntry->nextOffset;
135+
ctorEntry->nextOffset = (s32)prevEntry;
136+
prevEntry = ctorEntry;
140137
}
141138

142-
sInitFuncs = prev;
139+
sGlobalCtorEntries = prevEntry;
143140
}
144141

145-
void SystemHeap_Init(void* start, u32 size) {
142+
void Runtime_Init(void* start, u32 size) {
146143
#if PLATFORM_N64
147144
__osMallocInit(&gSystemArena, start, size);
148145
#else
149146
SystemArena_Init(start, size);
150147
#endif
151148

152-
func_800FCB34();
149+
Runtime_ExecuteGlobalCtors();
153150
}

0 commit comments

Comments
 (0)