2004-03-10 00:44:39 +00:00
|
|
|
#ifndef KERNEL_CPP_H
|
|
|
|
#define KERNEL_CPP_H
|
2003-06-27 22:58:58 +00:00
|
|
|
/* cpp - C++ in the kernel
|
|
|
|
**
|
|
|
|
** Initial version by Axel Dörfler, axeld@pinc-software.de
|
2017-02-09 22:03:59 -05:00
|
|
|
** This file may be used under the terms of the MIT License.
|
2003-06-27 22:58:58 +00:00
|
|
|
*/
|
|
|
|
|
2004-03-10 00:44:39 +00:00
|
|
|
#ifdef __cplusplus
|
2003-06-27 22:58:58 +00:00
|
|
|
|
|
|
|
#include <new>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2008-11-03 13:15:12 +00:00
|
|
|
#if _KERNEL_MODE || _LOADER_MODE
|
2003-06-27 22:58:58 +00:00
|
|
|
|
2003-10-12 00:48:49 +00:00
|
|
|
using namespace std;
|
2004-01-06 00:27:34 +00:00
|
|
|
extern const nothrow_t std::nothrow;
|
2003-10-12 00:48:49 +00:00
|
|
|
|
2008-11-03 13:15:12 +00:00
|
|
|
// 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;
|
2003-06-27 22:58:58 +00:00
|
|
|
|
2015-11-07 18:48:26 +01:00
|
|
|
#ifndef __clang__
|
|
|
|
extern void* operator new(size_t size) throw (std::bad_alloc);
|
|
|
|
extern void* operator new[](size_t size) throw (std::bad_alloc);
|
|
|
|
extern void* operator new(size_t size, const std::nothrow_t &) throw ();
|
|
|
|
extern void* operator new[](size_t size, const std::nothrow_t &) throw ();
|
|
|
|
extern void* operator new(size_t size, const mynothrow_t &) throw ();
|
|
|
|
extern void* operator new[](size_t size, const mynothrow_t &) throw ();
|
|
|
|
extern void operator delete(void *ptr) throw ();
|
|
|
|
extern void operator delete[](void *ptr) throw ();
|
|
|
|
#endif
|
|
|
|
|
2015-11-08 00:01:03 +01:00
|
|
|
#if __cplusplus >= 201402L
|
|
|
|
|
|
|
|
inline void
|
|
|
|
operator delete(void *ptr, size_t size) throw ()
|
|
|
|
{
|
|
|
|
free(ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // __cplusplus >= 201402L
|
|
|
|
|
2004-01-06 00:27:34 +00:00
|
|
|
#endif // #if _KERNEL_MODE
|
2004-10-27 22:07:00 +00:00
|
|
|
|
2004-03-10 00:44:39 +00:00
|
|
|
#endif // __cplusplus
|
2003-06-27 22:58:58 +00:00
|
|
|
|
2004-03-10 00:44:39 +00:00
|
|
|
#endif /* KERNEL_CPP_H */
|