* 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

View File

@ -11,20 +11,16 @@
#include <new>
#include <stdlib.h>
#if _KERNEL_MODE
#if _KERNEL_MODE || _LOADER_MODE
using namespace std;
extern const nothrow_t std::nothrow;
// Oh no! C++ in the kernel! Are you nuts?
//
// - no exceptions
// - (almost) no virtuals (well, the Query code now uses them)
// - it's basically only the C++ syntax, and type checking
// - since one tend to encapsulate everything in classes, it has a slightly
// higher memory overhead
// - nicer code
// - easier to maintain
// 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
// kernel_cpp.cpp.
typedef struct {} mynothrow_t;
extern const mynothrow_t mynothrow;
inline void *
@ -34,7 +30,7 @@ operator new(size_t size) throw (std::bad_alloc)
// keep the prototype as specified in <new>, or else GCC 3
// won't like us
return malloc(size);
}
}
inline void *
@ -42,7 +38,7 @@ operator new[](size_t size) throw (std::bad_alloc)
{
return malloc(size);
}
inline void *
operator new(size_t size, const std::nothrow_t &) throw ()
@ -58,11 +54,25 @@ 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
operator delete(void *ptr) throw ()
{
free(ptr);
}
}
inline void

View File

@ -1,7 +1,7 @@
/*
* Copyright 2003-2007, Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*
*
* Authors:
* Axel Dörfler, axeld@pinc-software.de.
* Ingo Weinhold, bonefish@users.sf.net.
@ -38,6 +38,8 @@ const nothrow_t std::nothrow = {};
# endif
#endif
const mynothrow_t mynothrow = {};
#if __GNUC__ == 2
extern "C" void