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