From 654bb8b09dd90c12c3a51ffdce800b2255b753b5 Mon Sep 17 00:00:00 2001 From: FreeArtMan Date: Sun, 12 May 2019 12:46:02 +0100 Subject: Moved everything to C+. First test works --- __cpp.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 __cpp.h (limited to '__cpp.h') diff --git a/__cpp.h b/__cpp.h new file mode 100644 index 0000000..6a8e03e --- /dev/null +++ b/__cpp.h @@ -0,0 +1,30 @@ +#include + +extern "C" void* emulate_cc_new(unsigned long len) { \ + void *p = malloc(len); + if (p == 0) { + /* Don't use stdio (e.g. fputs), because that may want to allocate more + * memory. + */ + (void)!write(2, "out of memory\n", 14); + abort(); + } + return p; +} +extern "C" void emulate_cc_delete(void* p) { + if (p != 0) + free(p); +} + +extern "C" void emulate_cc_delete2(void* p, unsigned long len) { + if (p != 0) + free(p); +} + +void* operator new (unsigned long) __attribute__((alias("emulate_cc_new"))); +void* operator new[](unsigned long) __attribute__((alias("emulate_cc_new"))); +void operator delete (void* p) __attribute__((alias("emulate_cc_delete"))); +void operator delete[](void* p) __attribute__((alias("emulate_cc_delete"))); +void operator delete (void* p, unsigned long len) __attribute__((alias("emulate_cc_delete2"))); +void operator delete[](void* p, unsigned long len) __attribute__((alias("emulate_cc_delete2"))); +void* __cxa_pure_virtual = 0; \ No newline at end of file -- cgit v1.2.3