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 16 using namespace std; 17 extern 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. 22 typedef struct {} mynothrow_t; 23 extern const mynothrow_t mynothrow; 24 25 #if __cplusplus >= 201402L 26 #define _THROW(x) 27 #define _NOEXCEPT noexcept 28 #else 29 #define _THROW(x) throw (x) 30 #define _NOEXCEPT throw () 31 #endif 32 extern void* operator new(size_t size) _THROW(std::bad_alloc); 33 extern void* operator new[](size_t size) _THROW(std::bad_alloc); 34 extern void* operator new(size_t size, const std::nothrow_t &) _NOEXCEPT; 35 extern void* operator new[](size_t size, const std::nothrow_t &) _NOEXCEPT; 36 extern void* operator new(size_t size, const mynothrow_t &) _NOEXCEPT; 37 extern void* operator new[](size_t size, const mynothrow_t &) _NOEXCEPT; 38 extern void operator delete(void *ptr) _NOEXCEPT; 39 extern void operator delete[](void *ptr) _NOEXCEPT; 40 41 #if __cplusplus >= 201402L 42 extern void operator delete(void* ptr, std::size_t) _NOEXCEPT; 43 extern void operator delete[](void* ptr, std::size_t) _NOEXCEPT; 44 #endif // __cplusplus >= 201402L 45 46 #endif // #if _KERNEL_MODE 47 48 #endif // __cplusplus 49 50 #endif /* KERNEL_CPP_H */ 51