aboutsummaryrefslogtreecommitdiff
path: root/libpsn00b/libc/c++-support.cxx
diff options
context:
space:
mode:
authorJohn Wilbert M. Villamor <lameguy64@gmail.com>2019-07-17 11:30:07 +0800
committerJohn Wilbert M. Villamor <lameguy64@gmail.com>2019-07-17 11:30:07 +0800
commit0d4345a9bf2623df079c50a3bc73cbb7deca1176 (patch)
tree6cda70b844f39fc2d65a806b91a6010066433b56 /libpsn00b/libc/c++-support.cxx
parentb956c5391b955e793a4d54572aa58872b4c66c30 (diff)
downloadpsn00bsdk-0d4345a9bf2623df079c50a3bc73cbb7deca1176.tar.gz
Added C++ support, updated build instructions and makefiles, consolidated libc and libgcc (during build process), libraries now v0.12b and more
Diffstat (limited to 'libpsn00b/libc/c++-support.cxx')
-rw-r--r--libpsn00b/libc/c++-support.cxx40
1 files changed, 40 insertions, 0 deletions
diff --git a/libpsn00b/libc/c++-support.cxx b/libpsn00b/libc/c++-support.cxx
new file mode 100644
index 0000000..fcf7cfc
--- /dev/null
+++ b/libpsn00b/libc/c++-support.cxx
@@ -0,0 +1,40 @@
+#include <assert.h>
+#include <sys/types.h>
+#include <stdlib.h>
+#include <malloc.h>
+
+extern "C"
+
+void __cxa_pure_virtual(void) {
+ /* Pure C++ virtual call; abort! */
+ assert(false);
+}
+
+void* operator new(size_t size) {
+ return malloc(size);
+}
+
+void* operator new[](size_t size) {
+ return malloc(size);
+}
+
+void operator delete(void* ptr) {
+ free(ptr);
+}
+
+void operator delete[](void* ptr) {
+ free(ptr);
+}
+
+/*-
+ * <https://en.cppreference.com/w/cpp/memory/new/operator_delete>
+ *
+ * Called if a user-defined replacement is provided, except that it's
+ * unspecified whether other overloads or this overload is called when deleting
+ * objects of incomplete type and arrays of non-class and trivially-destructible
+ * class types.
+ *
+ * A memory allocator can use the given size to be more efficient */
+void operator delete(void* ptr, unsigned int) {
+ free(ptr);
+} \ No newline at end of file