Making some Runtime progress (#557)

This commit is contained in:
mrshigure 2025-02-04 17:54:29 -08:00 committed by GitHub
parent c15173cc66
commit d340ccf061
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 1537 additions and 24 deletions

View file

@ -2,7 +2,6 @@
#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/critical_regions.h"
#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/signal.h"
#include "stddef.h"
#include "PowerPC_EABI_Support/Runtime/NMWException.h"
void _ExitProcess();

View file

@ -0,0 +1,30 @@
#include "dolphin/os.h"
inline static void InitDefaultHeap(void) {
void* arenaLo;
void* arenaHi;
OSReport("GCN_Mem_Alloc.c : InitDefaultHeap. No Heap Available\n");
OSReport("Metrowerks CW runtime library initializing default heap\n");
arenaLo = OSGetArenaLo();
arenaHi = OSGetArenaHi();
arenaLo = OSInitAlloc(arenaLo, arenaHi, 1);
OSSetArenaLo(arenaLo);
arenaLo = OSRoundUpPtr(arenaLo, 0x20);
arenaHi = OSRoundDownPtr(arenaHi, 0x20);
OSSetCurrentHeap(OSCreateHeap(arenaLo, arenaHi));
OSSetArenaLo(arenaLo = arenaHi);
}
/* 80362914-803629CC 35D254 00B8+00 0/0 1/1 0/0 .text __sys_free */
void __sys_free(void* p) {
if (__OSCurrHeap == -1) {
InitDefaultHeap();
}
OSFreeToHeap(__OSCurrHeap, p);
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,157 @@
#include "PowerPC_EABI_Support/Runtime/NMWException.h"
#include "PowerPC_EABI_Support/Runtime/MWCPlusLib.h"
#define ARRAY_HEADER_SIZE 16
extern "C" {
extern void abort();
}
namespace std {
/**
* @note Address: N/A
* @note Size: 0x20
*/
static void dthandler() { abort(); }
static terminate_handler thandler = dthandler;
/**
* @note Address: N/A
* @note Size: 0x28
*/
static void duhandler() { terminate(); }
static unexpected_handler uhandler = duhandler;
/**
* @note Address: N/A
* @note Size: 0x28
*/
extern void terminate() { thandler(); }
/**
* @note Address: N/A
* @note Size: 0x28
*/
extern void unexpected() { uhandler(); }
} // namespace std
/**
* @note Address: N/A
* @note Size: 0x22C
*/
extern char __throw_catch_compare(const char* throwtype, const char* catchtype, s32* offset_result)
{
const char *cptr1, *cptr2;
*offset_result = 0;
if ((cptr2 = catchtype) == 0) {
return true;
}
cptr1 = throwtype;
if (*cptr2 == 'P') {
cptr2++;
if (*cptr2 == 'C')
cptr2++;
if (*cptr2 == 'V')
cptr2++;
if (*cptr2 == 'v') {
if (*cptr1 == 'P' || *cptr1 == '*') {
return true;
}
}
cptr2 = catchtype;
}
switch (*cptr1) {
case '*':
case '!':
if (*cptr1++ != *cptr2++)
return false;
for (;;) {
if (*cptr1 == *cptr2++) {
if (*cptr1++ == '!') {
s32 offset;
for (offset = 0; *cptr1 != '!';) {
offset = offset * 10 + *cptr1++ - '0';
}
*offset_result = offset;
return true;
}
} else {
while (*cptr1++ != '!') { }
while (*cptr1++ != '!') { }
if (*cptr1 == 0)
return false;
cptr2 = catchtype + 1;
}
}
return false;
}
while ((*cptr1 == 'P' || *cptr1 == 'R') && *cptr1 == *cptr2) {
cptr1++;
cptr2++;
if (*cptr2 == 'C') {
if (*cptr1 == 'C')
cptr1++;
cptr2++;
}
if (*cptr1 == 'C')
return false;
if (*cptr2 == 'V') {
if (*cptr1 == 'V')
cptr1++;
cptr2++;
}
if (*cptr1 == 'V')
return false;
}
for (; *cptr1 == *cptr2; cptr1++, cptr2++) {
if (*cptr1 == 0)
return true;
}
return false;
}
class __partial_array_destructor {
private:
void* p;
size_t size;
size_t n;
ConstructorDestructor dtor;
public:
size_t i;
__partial_array_destructor(void* array, size_t elementsize, size_t nelements, ConstructorDestructor destructor)
{
p = array;
size = elementsize;
n = nelements;
dtor = destructor;
i = n;
}
~__partial_array_destructor()
{
char* ptr;
if (i < n && dtor) {
for (ptr = (char*)p + size * i; i > 0; i--) {
ptr -= size;
DTORCALL_COMPLETE(dtor, ptr);
}
}
}
};