* Made kernel_cpp.h usable in the runtime loader.

* Added new(mynothrow) operators which avoid clashes when also linking
  against libgcc.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28474 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2008-11-03 13:15:12 +00:00
parent bfc607d44f
commit 56eb43e3ca
2 changed files with 26 additions and 14 deletions
+20 -10
View File
@@ -11,20 +11,16 @@
#include <new> #include <new>
#include <stdlib.h> #include <stdlib.h>
#if _KERNEL_MODE #if _KERNEL_MODE || _LOADER_MODE
using namespace std; using namespace std;
extern const nothrow_t std::nothrow; extern const nothrow_t std::nothrow;
// Oh no! C++ in the kernel! Are you nuts? // We need new() versions we can use when also linking against libgcc.
// // std::nothrow can't be used since it's defined in both libgcc and
// - no exceptions // kernel_cpp.cpp.
// - (almost) no virtuals (well, the Query code now uses them) typedef struct {} mynothrow_t;
// - it's basically only the C++ syntax, and type checking extern const mynothrow_t mynothrow;
// - since one tend to encapsulate everything in classes, it has a slightly
// higher memory overhead
// - nicer code
// - easier to maintain
inline void * inline void *
@@ -58,6 +54,20 @@ operator new[](size_t size, const std::nothrow_t &) throw ()
} }
inline void *
operator new(size_t size, const mynothrow_t &) throw ()
{
return malloc(size);
}
inline void *
operator new[](size_t size, const mynothrow_t &) throw ()
{
return malloc(size);
}
inline void inline void
operator delete(void *ptr) throw () operator delete(void *ptr) throw ()
{ {
+2
View File
@@ -38,6 +38,8 @@ const nothrow_t std::nothrow = {};
# endif # endif
#endif #endif
const mynothrow_t mynothrow = {};
#if __GNUC__ == 2 #if __GNUC__ == 2
extern "C" void extern "C" void