summaryrefslogtreecommitdiffhomepage
path: root/Public/Kits/SystemKit/HeapAPI.hxx
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-01-31 09:42:54 +0100
committerAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-01-31 09:42:54 +0100
commitfc55f0d69d24fb4908cbd811681f2c3fac53614d (patch)
treeba09a2cdbb225df7ba1a9ec5a12bcbb90b673ead /Public/Kits/SystemKit/HeapAPI.hxx
parent7bed9287589293bd9d712d152539591dee0b28c0 (diff)
kernel: add GKit, improve AMD64 HAL.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'Public/Kits/SystemKit/HeapAPI.hxx')
-rw-r--r--Public/Kits/SystemKit/HeapAPI.hxx65
1 files changed, 65 insertions, 0 deletions
diff --git a/Public/Kits/SystemKit/HeapAPI.hxx b/Public/Kits/SystemKit/HeapAPI.hxx
new file mode 100644
index 00000000..11d4c265
--- /dev/null
+++ b/Public/Kits/SystemKit/HeapAPI.hxx
@@ -0,0 +1,65 @@
+/*
+ * ========================================================
+ *
+ * h-core
+ * Copyright Mahrouss Logic, all rights reserved.
+ *
+ * ========================================================
+ */
+
+#pragma once
+
+#include <CompilerKit/CompilerKit.hpp>
+#include <NewKit/Defines.hpp>
+
+using namespace HCore;
+
+class HMemoryException;
+
+typedef VoidPtr HHeapPtr;
+
+enum {
+ kHeapExpandable = 2,
+ kHeapNoExecute = 4,
+ kHeapShared = 6,
+ kHeapReadOnly = 8,
+ kHeapNoFlags = 0
+};
+
+class HHeap final {
+ private:
+ explicit HHeap();
+
+ public:
+ ~HHeap();
+
+ public:
+ HCORE_COPY_DEFAULT(HHeap);
+
+ public:
+ static HHeap *Shared() noexcept;
+
+ public:
+ void Delete(HHeapPtr me) noexcept;
+ SizeT Tell(HHeapPtr me) noexcept;
+ HHeapPtr New(const SizeT &sz, const Int32 flags = kHeapNoFlags);
+};
+
+class HMemoryException final {
+ public:
+ HMemoryException() = default;
+ ~HMemoryException() = default;
+
+ public:
+ HCORE_COPY_DEFAULT(HMemoryException);
+
+ public:
+ const char *Name();
+ const char *Reason();
+
+ private:
+ const char *mReason{"HeapAPI: Memory Exception!"};
+
+ private:
+ friend HHeap;
+};