summaryrefslogtreecommitdiff
path: root/math/amath/patches/patch-app_main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'math/amath/patches/patch-app_main.cpp')
-rw-r--r--math/amath/patches/patch-app_main.cpp50
1 files changed, 50 insertions, 0 deletions
diff --git a/math/amath/patches/patch-app_main.cpp b/math/amath/patches/patch-app_main.cpp
new file mode 100644
index 00000000000..1fe5521a801
--- /dev/null
+++ b/math/amath/patches/patch-app_main.cpp
@@ -0,0 +1,50 @@
+$NetBSD: patch-app_main.cpp,v 1.1 2017/02/17 17:09:17 joerg Exp $
+
+Replace operators must be global.
+
+--- app/main.cpp.orig 2017-02-17 12:12:18.536908981 +0000
++++ app/main.cpp
+@@ -27,6 +27,43 @@
+ #include "system/program.h"
+ #include "system/base/io.h"
+
++#if (__GNUC__ == 2 && __GNUC_MINOR__ == 95)
++void* operator new (size_t size) {
++ return AllocMemSafe(size);
++}
++
++void* operator new[] (size_t size) {
++ return AllocMemSafe(size);
++}
++
++void operator delete (void* ptr) {
++ FreeMemSafe(ptr);
++}
++
++void operator delete[] (void* ptr) {
++ FreeMemSafe(ptr);
++}
++#endif
++
++#if (__GNUC__ > 2) || defined (_WIN32)
++#include <new>
++void* operator new (size_t size) throw(std::bad_alloc) {
++ return AllocMemSafe(size);
++}
++
++void* operator new[] (size_t size) throw(std::bad_alloc) {
++ return AllocMemSafe(size);
++}
++
++void operator delete (void* ptr) throw() {
++ FreeMemSafe(ptr);
++}
++
++void operator delete[] (void* ptr) throw() {
++ FreeMemSafe(ptr);
++}
++#endif
++
+ int main(int argc, char **argv)
+ {
+ Program = CreateProgram(argc, argv);