#include #include #define BODY(...) __VA_ARGS__ #define ANNOYING_THROW(prefix, def, body) \ prefix def noexcept(false) \ body #define ANNOYING_NOEXCEPT(prefix, def, body) \ prefix def, const std::nothrow_t& tag) noexcept(true) \ body \ prefix def) noexcept(true) \ body #define ANNOYING_TAGONLY(prefix, def, body) \ prefix def, const std::nothrow_t& tag) noexcept(true) \ body #define PROTOTYPE_FORMER(...) ( __VA_ARGS__ ) #define PROTOTYPE_LATTER(...) ( __VA_ARGS__ ANNOYING_THROW(void *operator new, PROTOTYPE_FORMER(std::size_t n), BODY( { void *buffer = Aurora::Memory::FAlloc(n); if (buffer == nullptr) { throw std::bad_alloc(); } return buffer; })); ANNOYING_TAGONLY(void *operator new, PROTOTYPE_LATTER(std::size_t n), BODY( { return Aurora::Memory::ZAlloc(n); })); ANNOYING_THROW(void *operator new, PROTOTYPE_FORMER(std::size_t n, std::align_val_t al), BODY( { void *buffer = Aurora::Memory::FAlloc(n, Aurora::Types::size_t(al)); if (buffer == nullptr) { throw std::bad_alloc(); } return buffer; })); ANNOYING_TAGONLY(void *operator new, PROTOTYPE_LATTER(std::size_t n, std::align_val_t al), BODY( { return Aurora::Memory::ZAlloc(n, Aurora::Types::size_t(al)); })); ANNOYING_NOEXCEPT(void operator delete, PROTOTYPE_LATTER(void *p), BODY( { Aurora::Memory::Free(p); })); ANNOYING_NOEXCEPT(void operator delete, PROTOTYPE_LATTER(void *p, std::align_val_t al), BODY( { Aurora::Memory::Free(p); })); ANNOYING_NOEXCEPT(void operator delete, PROTOTYPE_LATTER(void *p, std::size_t idc, std::align_val_t al), BODY( { Aurora::Memory::Free(p); })); ANNOYING_NOEXCEPT(void operator delete[], PROTOTYPE_LATTER(void *p), BODY( { Aurora::Memory::Free(p); })); ANNOYING_NOEXCEPT(void operator delete[], PROTOTYPE_LATTER(void *p, std::align_val_t al), BODY( { Aurora::Memory::Free(p); })); ANNOYING_NOEXCEPT(void operator delete[], PROTOTYPE_LATTER(void *p, std::size_t idc, std::align_val_t al), BODY( { Aurora::Memory::Free(p); })); ANNOYING_THROW(void *operator new[], PROTOTYPE_FORMER(std::size_t s), BODY( { void *buffer = Aurora::Memory::FAlloc(s); if (buffer == nullptr) { throw std::bad_alloc(); } return buffer; })); ANNOYING_TAGONLY(void *operator new[], PROTOTYPE_LATTER(std::size_t s), BODY( { return Aurora::Memory::FAlloc(s); })); ANNOYING_THROW(void *operator new[], PROTOTYPE_FORMER(std::size_t s, std::align_val_t al), BODY( { void *buffer = Aurora::Memory::FAlloc(s, Aurora::Types::size_t(al)); if (buffer == nullptr) { throw std::bad_alloc(); } return buffer; })); ANNOYING_TAGONLY(void *operator new[], PROTOTYPE_LATTER(std::size_t s, std::align_val_t al), BODY( { return Aurora::Memory::FAlloc(s, Aurora::Types::size_t(al)); })); /* Applications migrating to AuroraRuntime 2.0 should include an empty file with the following #if defined(_AUHAS_AURORARUNTIME) #include #endif */ #if defined(AURORA_PLATFORM_LINUX) namespace std { struct type_info; } extern void AU_NORETURN __au_cxa_throw(void *pException, std::type_info*, void (*fDtor)(void *pThis)); extern "C" inline void AU_NORETURN __cxa_throw(void *pException, std::type_info *typeInfo, void (*fDtor)(void *pThis)) { __au_cxa_throw(pException, typeInfo, fDtor); } extern "C" AuUInt32 _au_Unwind_RaiseException(struct _Unwind_Exception *pUnwind); extern "C" AuUInt32 _Unwind_RaiseException(struct _Unwind_Exception *pUnwind) { return _au_Unwind_RaiseException(pUnwind); } #endif