summaryrefslogtreecommitdiffstats
path: root/lib/bitmap.h
diff options
context:
space:
mode:
authorJon Santmyer <jon@jonsantmyer.com>2026-10-07 17:37:26 -0400
committerJon Santmyer <jon@jonsantmyer.com>2026-10-07 17:37:26 -0400
commit434ddcd907832b1febc7d70e4faa52109c7eb3bd (patch)
tree00c1ade91f9806d831f10e6006732b294e73f613 /lib/bitmap.h
parent8d48bbd9746228b63bafa5f92b621998d7d8f3d3 (diff)
downloadjove-kernel-434ddcd907832b1febc7d70e4faa52109c7eb3bd.tar.gz
jove-kernel-434ddcd907832b1febc7d70e4faa52109c7eb3bd.tar.bz2
jove-kernel-434ddcd907832b1febc7d70e4faa52109c7eb3bd.zip
add memory region object for better memory managment
Diffstat (limited to 'lib/bitmap.h')
-rw-r--r--lib/bitmap.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/bitmap.h b/lib/bitmap.h
new file mode 100644
index 0000000..db9653a
--- /dev/null
+++ b/lib/bitmap.h
@@ -0,0 +1,25 @@
+#ifndef _JOVE_LIB_BITMAP_H
+#define _JOVE_LIB_BITMAP_H 1
+
+#include <stddef.h>
+#include <stdbool.h>
+
+typedef unsigned char bitmap_block_t;
+#define BITMAP_BLOCK_BITS (sizeof(bitmap_block_t) * 8)
+
+struct bitmap
+{
+ unsigned int total_bits;
+ unsigned int free_bits;
+ unsigned int last_free_bit;
+ bitmap_block_t data[];
+};
+
+extern bool bitmap_check(struct bitmap *bitmap, size_t idx);
+extern void bitmap_set(struct bitmap *bitmap, size_t idx);
+extern void bitmap_unset(struct bitmap *bitmap, size_t idx);
+
+int bitmap_findfree(struct bitmap *bitmap);
+int bitmap_findfree_contig(struct bitmap *bitmap, size_t size);
+
+#endif