diff options
author | FreeArtMan <dos21h@gmail.com> | 2019-05-12 12:46:02 +0100 |
---|---|---|
committer | FreeArtMan <dos21h@gmail.com> | 2019-05-12 12:46:02 +0100 |
commit | 654bb8b09dd90c12c3a51ffdce800b2255b753b5 (patch) | |
tree | 67591880f34d6220b9026883b0ceb54f022aa385 /__cpp.h | |
parent | 03bfeedc5f4c04c20764c8a9a58bd02604f27b2c (diff) | |
download | libbuf-654bb8b09dd90c12c3a51ffdce800b2255b753b5.tar.gz libbuf-654bb8b09dd90c12c3a51ffdce800b2255b753b5.zip |
Moved everything to C+. First test works
Diffstat (limited to '__cpp.h')
-rw-r--r-- | __cpp.h | 30 |
1 files changed, 30 insertions, 0 deletions
@@ -0,0 +1,30 @@ +#include <unistd.h> + +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 |