From 2a256aa4f1abb65afa6f3856998bfe00ac960d61 Mon Sep 17 00:00:00 2001 From: Kimplul Date: Sun, 17 Apr 2022 12:22:04 +0300 Subject: improve node subsys + More robust alignment and less memory usage for status, from enum to bit --- include/apos/bits.h | 24 ++++++++++++++++++++++++ include/apos/nodes.h | 4 ++++ 2 files changed, 28 insertions(+) (limited to 'include') 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; -- cgit v1.3