summaryrefslogtreecommitdiffstats
path: root/src/include
diff options
context:
space:
mode:
Diffstat (limited to 'src/include')
-rw-r--r--src/include/kernel/heapmgr.H39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/include/kernel/heapmgr.H b/src/include/kernel/heapmgr.H
new file mode 100644
index 000000000..41a3e2cf5
--- /dev/null
+++ b/src/include/kernel/heapmgr.H
@@ -0,0 +1,39 @@
+#ifndef __KERNEL_HEAPMGR_H
+#define __KERNEL_HEAPMGR_H
+
+#include <stdint.h>
+#include <util/lockfree/stack.H>
+
+class HeapManager
+{
+ public:
+ static void* allocate(size_t n);
+ static void free(void *);
+
+ enum
+ {
+ BUCKETS = 8,
+ };
+
+ protected:
+ HeapManager() {};
+ ~HeapManager() {};
+
+ private:
+ void* _allocate(size_t);
+ void _free(void*);
+
+ struct chunk_t
+ {
+ size_t len;
+ chunk_t* next;
+ };
+ Util::Lockfree::Stack<chunk_t> first_chunk[BUCKETS];
+
+ chunk_t* pop_bucket(size_t);
+ void push_bucket(chunk_t*, size_t);
+
+ void newPage();
+};
+
+#endif
OpenPOWER on IntegriCloud