summaryrefslogtreecommitdiffhomepage
path: root/include/CoreRuntimeKit/C++/new
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2026-01-24 15:31:17 +0100
committerAmlal El Mahrouss <amlal@nekernel.org>2026-01-24 15:32:32 +0100
commit97868f338a02ad5acd8049f0ba0474d330e11877 (patch)
tree34d7642918ea47c899ea2a009384576f41dbb527 /include/CoreRuntimeKit/C++/new
parent41458b7253c524db10088657c930d300fc1b09ca (diff)
feat: More runtime improvements for Nectar and NeKernel C++ Runtime.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'include/CoreRuntimeKit/C++/new')
-rw-r--r--include/CoreRuntimeKit/C++/new58
1 files changed, 58 insertions, 0 deletions
diff --git a/include/CoreRuntimeKit/C++/new b/include/CoreRuntimeKit/C++/new
new file mode 100644
index 0000000..beb40c3
--- /dev/null
+++ b/include/CoreRuntimeKit/C++/new
@@ -0,0 +1,58 @@
+/* ========================================
+
+ Copyright (C) 2025, Amlal El Mahrouss, licensed under the Apache 2.0 license.
+
+======================================== */
+
+#pragma once
+
+#include <defines>
+
+namespace std {
+struct nothrow_t final {
+ explicit nothrow_t() = default;
+ ~nothrow_t() = default;
+};
+
+struct placement_t final {
+ explicit placement_t() = default;
+ ~placement_t() = default;
+
+ void* __base{};
+ int32_t __align{};
+ size_t __size{};
+};
+} // namespace std
+
+// AMLALE: Define the placement_t feature.
+#ifndef __cpp_has_placement
+#define __cpp_has_placement 1
+#endif
+
+// AMLALE: Define nothrow
+#ifndef __cpp_has_nothrow
+#define __cpp_has_nothrow 1
+#endif
+
+void* operator new(size_t);
+void* operator new[](size_t);
+
+/// \brief placement_t new and delete operators. Governs how the memory shall be placed.
+/// \note This is a feature that shall be used wisely, failure to do so will produce Undefined Behaviors at runtime.
+void* operator _placement_new(size_t);
+void operator _placement_delete(void*);
+
+/// \note This should NOT fail, failure to meet the conditions will cause the program's state to be aborted.
+/// \brief Set the placement policy of future memory allocations.
+template <class PlaceableType>
+void set_placement_policy(const PlaceableType&) noexcept;
+
+void* operator new(size_t, const nothrow_t&) noexcept;
+void* operator new(size_t, void*) noexcept;
+void* operator new[](size_t, const nothrow_t&) noexcept;
+void* operator new[](size_t, void*) noexcept;
+
+void operator delete(void*) noexcept;
+void operator delete(void*, size_t) noexcept;
+
+void operator delete[](void*) noexcept;