32 #include "system/program.h" 33 #include "system/program_stdc.h" 34 #include "system/program_amiga.h" 35 #include "system/program_haiku.h" 36 #include "system/program_test.h" 43 #include <clib/exec_protos.h> 44 static struct DosBase *DosBase =
nullptr;
45 static struct GfxBase *GfxBase =
nullptr;
46 static struct LocaleBase *LocaleBase =
nullptr;
47 static struct IntuitionBase *IntuitionBase =
nullptr;
51 #if (__GNUC__
== 2
&& __GNUC_MINOR__
== 95
) 52 void* operator
new (size_t size) {
return AllocMemSafe(size); }
53 void* operator
new[] (size_t size) {
return AllocMemSafe(size); }
54 void operator
delete (
void* ptr) { FreeMemSafe(ptr); }
55 void operator
delete[] (
void* ptr) { FreeMemSafe(ptr); }
61 #if __cplusplus
> 199711L
63 void* operator
new (std::size_t size) {
return AllocMemSafe(size
); }
64 void* operator
new (std::size_t size,
const std::nothrow_t& nothrow_value)
noexcept {
return AllocMemSafe(size
); }
65 void* operator
new[] (std::size_t size) {
return AllocMemSafe(size
); }
66 void* operator
new[] (std::size_t size,
const std::nothrow_t& nothrow_value)
noexcept {
return AllocMemSafe(size
); }
67 void operator
delete (
void* ptr)
noexcept {
FreeMemSafe(ptr
); }
68 void operator
delete (
void* ptr,
const std::nothrow_t& nothrow_constant)
noexcept {
FreeMemSafe(ptr
); }
69 void operator
delete[] (
void* ptr)
noexcept {
FreeMemSafe(ptr
); }
70 void operator
delete[] (
void* ptr,
const std::nothrow_t& nothrow_constant)
noexcept {
FreeMemSafe(ptr
); }
74 void* operator
new (std::size_t size)
throw (std::bad_alloc) {
return AllocMemSafe(size); }
75 void* operator
new (std::size_t size,
const std::nothrow_t& nothrow_value)
throw() {
return AllocMemSafe(size); }
76 void* operator
new[] (std::size_t size)
throw (std::bad_alloc) {
return AllocMemSafe(size); }
77 void* operator
new[] (std::size_t size,
const std::nothrow_t& nothrow_value)
throw() {
return AllocMemSafe(size); }
78 void operator
delete (
void* ptr)
throw() { FreeMemSafe(ptr); }
79 void operator
delete (
void* ptr,
const std::nothrow_t& nothrow_constant)
throw() { FreeMemSafe(ptr); }
80 void operator
delete[] (
void* ptr)
throw() { FreeMemSafe(ptr); }
81 void operator
delete[] (
void* ptr,
const std::nothrow_t& nothrow_constant)
throw() { FreeMemSafe(ptr); }
86 #if defined(WINDOWS) && defined(_MSC_VER) 88 void* __CRTDECL operator
new (size_t size) {
return AllocMemSafe(size); }
89 void* __CRTDECL operator
new[] (size_t size) {
return AllocMemSafe(size); }
90 void __CRTDECL operator
delete (
void* ptr)
throw() { FreeMemSafe(ptr); }
91 void __CRTDECL operator
delete[] (
void* ptr)
throw() { FreeMemSafe(ptr); }
96 void WriteOut(
const char *string) { printf(
"%s", string); }
97 void WriteOutInt(
int value) { printf(
"%i", value); }
100 int main(
int argc,
char** argv)
102 #if defined(WITHTEST) 103 if (argc == 2 && StrIsEqual(argv[1],
"--test"))
105 Program =
new TestProgram(
false);
107 else if (argc == 2 && StrIsEqual(argv[1],
"--testz"))
109 Program =
new TestProgram(
true);
115 DosBase = (
struct DosBase*)OpenLibrary(AMIGADOS_NAME, AMIGADOS_REV);
116 IntuitionBase = (
struct IntuitionBase*)OpenLibrary(INTUITION_NAME, INTUITION_REV);
117 GfxBase = (
struct GfxBase*)OpenLibrary(GRAPHICS_NAME, GRAPHICS_REV);
118 LocaleBase = (
struct LocaleBase*)OpenLibrary(LOCALE_NAME, LOCALE_REV);
119 Program =
new AmigaProgram();
121 Program =
new HaikuProgram();
133 if (DosBase !=
nullptr)
134 CloseLibrary((
struct Library*)DosBase);
136 if (LocaleBase !=
nullptr)
137 CloseLibrary((
struct Library*)LocaleBase);
139 if (GfxBase !=
nullptr)
140 CloseLibrary((
struct Library*)GfxBase);
142 if (IntuitionBase !=
nullptr)
143 CloseLibrary((
struct Library*)IntuitionBase);
int main(int argc, char **argv)
void * AllocMemSafe(size_t size)
Allocate memory and add it to the global memory list.
virtual void Initialize(int argc, char **argv)=0
void FreeMemSafe(void *block)
Deallocate memory from the global memory list.
void FreeAllSafe()
Deallocate all memory in the global memory list.
int GetExitStatus() const