diff --git a/Include/AuroraAlloc.cpp b/Include/AuroraAlloc.cpp new file mode 100644 index 00000000..ad82f2af --- /dev/null +++ b/Include/AuroraAlloc.cpp @@ -0,0 +1,120 @@ +#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 +*/ \ No newline at end of file diff --git a/Source/Alloc.cpp b/Source/Alloc.cpp new file mode 100644 index 00000000..0596f62a --- /dev/null +++ b/Source/Alloc.cpp @@ -0,0 +1,10 @@ +/*** + Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved. + + File: Alloc.cpp + Date: 2021-6-27 + Author: Reece +***/ +#if defined(_AUHAS_AURORARUNTIME) || defined(AURORA_ENGINE_RUNTIME) || defined(AURORA_ENGINE_KERNEL) + #include +#endif \ No newline at end of file diff --git a/Source/Entrypoint.cpp b/Source/Entrypoint.cpp index 2b741af3..3c687157 100644 --- a/Source/Entrypoint.cpp +++ b/Source/Entrypoint.cpp @@ -16,6 +16,8 @@ #include "IO/FS/FS.hpp" #include "Hashing/Hashing.hpp" #include "Debug/Debug.hpp" +#include "Async/Async.hpp" + static void Init() { @@ -28,6 +30,7 @@ static void Init() Aurora::Processes::Init(); Aurora::RNG::Init(); Aurora::Hashing::InitHashing(); + Aurora::Async::InitAsync(); } static void Pump()