aboutsummaryrefslogtreecommitdiff
path: root/include/apos
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2022-04-17 12:22:04 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2022-04-17 12:22:04 +0300
commit2a256aa4f1abb65afa6f3856998bfe00ac960d61 (patch)
tree9ced465d8dbbad184319ceb737b0d2943d7e2b91 /include/apos
parent67c9dc06ca0b5aec6430d50af9444bbe85b6deb5 (diff)
downloadkmi-2a256aa4f1abb65afa6f3856998bfe00ac960d61.tar.gz
kmi-2a256aa4f1abb65afa6f3856998bfe00ac960d61.zip
improve node subsys
+ More robust alignment and less memory usage for status, from enum to bit
Diffstat (limited to 'include/apos')
-rw-r--r--include/apos/bits.h24
-rw-r--r--include/apos/nodes.h4
2 files changed, 28 insertions, 0 deletions
diff --git a/include/apos/bits.h b/include/apos/bits.h
index 699cba4..ca25007 100644
--- a/include/apos/bits.h
+++ b/include/apos/bits.h
@@ -12,6 +12,30 @@
#define __set_nbit(x, y) (__set_bit((x), 1UL << (y)))
#define __clear_nbit(x, y) (__clear_bit((x), 1UL << (y)))
+static inline bool bitmap_is_set(void *bmap, size_t n)
+{
+ uint8_t *bitmap = bmap;
+ size_t i = n / 8;
+ size_t r = n - (i * 8);
+ return __is_nset(bitmap[i], r);
+}
+
+static inline void bitmap_set(void *bmap, size_t n)
+{
+ uint8_t *bitmap = bmap;
+ size_t i = n / 8;
+ size_t r = n - (i * 8);
+ __set_nbit(bitmap[i], r);
+}
+
+static inline void bitmap_clear(void *bmap, size_t n)
+{
+ uint8_t *bitmap = bmap;
+ size_t i = n / 8;
+ size_t r = n - (i * 8);
+ __clear_nbit(bitmap[i], r);
+}
+
uint16_t __bswap16(uint16_t u);
uint32_t __bswap32(uint32_t u);
uint64_t __bswap64(uint64_t u);
diff --git a/include/apos/nodes.h b/include/apos/nodes.h
index 80888e1..0780f75 100644
--- a/include/apos/nodes.h
+++ b/include/apos/nodes.h
@@ -16,6 +16,10 @@ struct node_region {
struct node_root {
size_t node_size;
+ size_t max_nodes;
+
+ ptrdiff_t bitmap;
+ ptrdiff_t first_node;
struct node_region *head;
struct node_region *av_head;