* 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:
@@ -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 *
|
||||||
@@ -34,7 +30,7 @@ operator new(size_t size) throw (std::bad_alloc)
|
|||||||
// keep the prototype as specified in <new>, or else GCC 3
|
// keep the prototype as specified in <new>, or else GCC 3
|
||||||
// won't like us
|
// won't like us
|
||||||
return malloc(size);
|
return malloc(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline void *
|
inline void *
|
||||||
@@ -42,7 +38,7 @@ operator new[](size_t size) throw (std::bad_alloc)
|
|||||||
{
|
{
|
||||||
return malloc(size);
|
return malloc(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline void *
|
inline void *
|
||||||
operator new(size_t size, const std::nothrow_t &) throw ()
|
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
|
inline void
|
||||||
operator delete(void *ptr) throw ()
|
operator delete(void *ptr) throw ()
|
||||||
{
|
{
|
||||||
free(ptr);
|
free(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2003-2007, Haiku Inc. All rights reserved.
|
* Copyright 2003-2007, Haiku Inc. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
* Axel Dörfler, [email protected].
|
* Axel Dörfler, [email protected].
|
||||||
* Ingo Weinhold, [email protected].
|
* Ingo Weinhold, [email protected].
|
||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user