Initial commit

This commit is contained in:
Luke Street 2023-11-18 23:52:51 -05:00
commit c8c516e548
222 changed files with 38483 additions and 0 deletions

0
src/REL/empty.c Normal file
View file

19
src/REL/executor.c Normal file
View file

@ -0,0 +1,19 @@
#include "REL/executor.h"
int _prolog(void) {
const VoidFunc* ctors = _ctors;
while (*ctors != 0) {
(**ctors)();
ctors++;
}
ModuleProlog();
return 0;
}
void _epilog(void) {
const VoidFunc* dtors = _dtors;
while (*dtors != 0) {
(**dtors)();
dtors++;
}
}

View file

@ -0,0 +1,60 @@
#include "Runtime.PPCEABI.H/NMWException.h"
#if __MWERKS__
#pragma exceptions off
#pragma internal on
#endif
#ifdef __cplusplus
extern "C" {
#endif
void __init_cpp_exceptions(void);
void __fini_cpp_exceptions(void);
typedef struct __eti_init_info {
void* eti_start;
void* eti_end;
void* code_start;
unsigned long code_size;
} __eti_init_info;
extern __eti_init_info _eti_init_info[];
#ifdef __cplusplus
}
#endif
static int fragmentID = -2;
/* clang-format off */
static asm char* GetR2() {
nofralloc;
mr r3, r2
blr
}
/* clang-format on */
void __init_cpp_exceptions(void) {
char* R2;
if (fragmentID == -2) {
R2 = GetR2();
fragmentID = __register_fragment(_eti_init_info, R2);
}
}
void __fini_cpp_exceptions(void) {
if (fragmentID != -2) {
__unregister_fragment(fragmentID);
fragmentID = -2;
}
}
/* clang-format off */
__declspec(section ".ctors")
extern void* const __init_cpp_exceptions_reference = __init_cpp_exceptions;
__declspec(section ".dtors")
extern void* const __destroy_global_chain_reference = __destroy_global_chain;
__declspec(section ".dtors")
extern void* const __fini_cpp_exceptions_reference = __fini_cpp_exceptions;
/* clang-format on */

View file

@ -0,0 +1,24 @@
#include "Runtime.PPCEABI.H/NMWException.h"
DestructorChain* __global_destructor_chain;
void* __register_global_object(void* object, void* destructor, void* regmem) {
((DestructorChain*)regmem)->next = __global_destructor_chain;
((DestructorChain*)regmem)->destructor = destructor;
((DestructorChain*)regmem)->object = object;
__global_destructor_chain = (DestructorChain*)regmem;
return object;
}
void __destroy_global_chain(void) {
DestructorChain* iter;
while ((iter = __global_destructor_chain) != 0) {
__global_destructor_chain = iter->next;
DTORCALL(iter->destructor, iter->object);
}
}
/* clang-format off */
__declspec(section ".dtors")
static void* const __destroy_global_chain_reference = __destroy_global_chain;
/* clang-format on */