Bringing in lib stuff (probably will need edits?)

This commit is contained in:
elijah-thomas774
2023-12-20 13:19:38 -05:00
parent 98daf44bb6
commit b4fd5011d1
9 changed files with 389 additions and 3 deletions
+17
View File
@@ -0,0 +1,17 @@
#ifndef _RUNTIME_INIT_CPP_EXCEPTIONS_H
#define _RUNTIME_INIT_CPP_EXCEPTIONS_H
#include "types.h"
#ifdef __cplusplus
extern "C" {
#endif
void __init_cpp_exceptions(void);
void __fini_cpp_exceptions(void);
#ifdef __cplusplus
}
#endif
#endif
+39
View File
@@ -0,0 +1,39 @@
#ifndef _RUNTIME_VA_ARG_H
#define _RUNTIME_VA_ARG_H
#include "types.h"
typedef struct __va_list_struct {
char gpr;
char fpr;
char reserved[2];
char *input_arg_area;
char *reg_save_area;
} _va_list_struct;
typedef _va_list_struct __va_list[1];
#ifdef __cplusplus
extern "C" void *__va_arg(_va_list_struct *, int);
#else
void *__va_arg(_va_list_struct *, int);
#endif
#if IN_VSCODE_EDITOR
#define __builtin_va_info(...)
#define _var_arg_typeof(...)
#endif
// from defined-string in mwcceppc.exe:
// __builtin_va_info: initialize the __va_list_struct
// _var_arg_typeof: convert type to integer for __va_arg
#define __va_start(list, fmt) __builtin_va_info(&list)
#define __va_arg(list, type) (*((type *)__va_arg(ap, _var_arg_typeof(type))))
#define va_start __va_start
#define va_arg __va_arg
#define va_end __va_end
#define va_list __va_list
#define __va_end(list) ((void)0)
#define __va_copy(a, b) (*(a) = *(b))
#endif
+42
View File
@@ -0,0 +1,42 @@
#ifndef _EXCEPTION
#define _EXCEPTION
namespace std {
class exception {
public:
exception() {}
virtual ~exception() {}
virtual const char *what() const {
return "exception";
}
};
class bad_exception : public exception {
public:
bad_exception() {}
virtual ~bad_exception() {}
virtual const char *what() const {
return "bad_exception";
}
};
typedef void (*unexpected_handler)();
unexpected_handler set_unexpected(unexpected_handler handler);
void unexpected();
typedef void (*terminate_handler)();
terminate_handler set_terminate(terminate_handler handler);
void terminate();
} // namespace std
using std::bad_exception;
using std::exception;
using std::set_terminate;
using std::set_unexpected;
using std::terminate;
using std::terminate_handler;
using std::unexpected;
using std::unexpected_handler;
#endif
+37
View File
@@ -0,0 +1,37 @@
#ifndef _GLOBALDESTRUCTORCHAIN
#define _GLOBALDESTRUCTORCHAIN
#include "types.h"
#ifdef __cplusplus
extern "C" {
#endif
#define CTORARG_TYPE int
#define CTORARG_PARTIAL (0)
#define CTORARG_COMPLETE (1)
#define CTORCALL_COMPLETE(ctor, objptr) \
(((void (*)(void *, CTORARG_TYPE))ctor)(objptr, CTORARG_COMPLETE))
#define DTORARG_TYPE int
#define DTORCALL_COMPLETE(dtor, objptr) (((void (*)(void *, DTORARG_TYPE))dtor)(objptr, -1))
typedef struct DestructorChain {
struct DestructorChain *next;
void *destructor;
void *object;
} DestructorChain;
void *__register_global_object(void *object, void *destructor, void *registration);
void __destroy_global_chain(void);
int __register_atexit(void (*)(void));
#ifdef __cplusplus
}
#endif
#endif
+13
View File
@@ -0,0 +1,13 @@
#ifndef PTMF_H
#define PTMF_H
typedef struct __ptmf {
long this_delta; // self-explanatory
long v_offset; // vtable offset
union {
void *f_addr; // function address
long ve_offset; // virtual function entry offset (of vtable)
} f_data;
} __ptmf;
#endif /* PTMF_H */
+19
View File
@@ -0,0 +1,19 @@
#ifndef _DOLPHIN_RUNTIME_H
#define _DOLPHIN_RUNTIME_H
#include "types.h"
#ifdef __cplusplus
extern "C" {
#endif // ifdef __cplusplus
u32 __cvt_fp2unsigned(f64);
// TODO: The rest
void *__copy(char *, char *, size_t);
#ifdef __cplusplus
};
#endif // ifdef __cplusplus
#endif