kernel_cpp.h revision b6f76ebe
1#ifndef KERNEL_CPP_H
2#define KERNEL_CPP_H
3/* cpp - C++ in the kernel
4**
5** Initial version by Axel D��rfler, axeld@pinc-software.de
6** This file may be used under the terms of the MIT License.
7*/
8
9#ifdef __cplusplus
10
11#include <new>
12#include <stdlib.h>
13
14#if _KERNEL_MODE || _LOADER_MODE
15
16using namespace std;
17extern const nothrow_t std::nothrow;
18
19// We need new() versions we can use when also linking against libgcc.
20// std::nothrow can't be used since it's defined in both libgcc and
21// kernel_cpp.cpp.
22typedef struct {} mynothrow_t;
23extern const mynothrow_t mynothrow;
24
25#ifndef __clang__
26extern void* operator new(size_t size) throw (std::bad_alloc);
27extern void* operator new[](size_t size) throw (std::bad_alloc);
28extern void* operator new(size_t size, const std::nothrow_t &) throw ();
29extern void* operator new[](size_t size, const std::nothrow_t &) throw ();
30extern void* operator new(size_t size, const mynothrow_t &) throw ();
31extern void* operator new[](size_t size, const mynothrow_t &) throw ();
32extern void operator delete(void *ptr) throw ();
33extern void operator delete[](void *ptr) throw ();
34#endif
35
36#if __cplusplus >= 201402L
37
38inline void
39operator delete(void *ptr, size_t size) throw ()
40{
41	free(ptr);
42}
43
44#endif // __cplusplus >= 201402L
45
46#endif	// #if _KERNEL_MODE
47
48#endif	// __cplusplus
49
50#endif	/* KERNEL_CPP_H */
51