2018-12-11 03:44:07 +03:00
|
|
|
/*
|
2022-10-12 21:42:02 +03:00
|
|
|
* Copyright 2003-2022, Axel Dörfler, axeld@pinc-software.de.
|
|
|
|
* Copyright 2004-2022, Haiku, Inc. All rights reserved.
|
2018-12-11 03:44:07 +03:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
|
|
|
#ifndef _KERNEL_UTIL_KERNEL_CPP_H
|
|
|
|
#define _KERNEL_UTIL_KERNEL_CPP_H
|
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
|
|
|
|
2018-12-11 03:44:07 +03:00
|
|
|
using 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
|
|
|
|
2020-03-08 06:10:24 +03:00
|
|
|
#if __cplusplus >= 201103L
|
2018-05-28 21:43:15 +03:00
|
|
|
#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;
|
2022-10-12 21:42:02 +03:00
|
|
|
extern void operator delete(void *ptr, const std::nothrow_t &) _NOEXCEPT;
|
2015-11-07 20:48:26 +03:00
|
|
|
|
2015-11-08 02:01:03 +03:00
|
|
|
#if __cplusplus >= 201402L
|
2018-08-02 06:42:24 +03:00
|
|
|
extern void operator delete(void* ptr, std::size_t) _NOEXCEPT;
|
|
|
|
extern void operator delete[](void* ptr, std::size_t) _NOEXCEPT;
|
2015-11-08 02:01:03 +03:00
|
|
|
#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
|
|
|
|
2018-12-11 03:44:07 +03:00
|
|
|
#endif /* _KERNEL_UTIL_KERNEL_CPP_H */
|