rtl: fix bug in bitmap

This commit is contained in:
Loïc Grégoire
2026-05-14 09:01:42 -04:00
parent 3a701067cd
commit 135d86349b
+3 -1
View File
@@ -11,8 +11,9 @@ pub fn BitMap(comptime N: usize) type {
pub const Word = if (N > 32) u64 else get_closest_type(N); pub const Word = if (N > 32) u64 else get_closest_type(N);
const Self = @This(); const Self = @This();
const bits_per_word = @bitSizeOf(Word); const bits_per_word = @bitSizeOf(Word);
const arr_len = (N + bits_per_word - 1) / bits_per_word;
storage: [bits_per_word / N]Word, storage: [arr_len]Word,
/// Initialize a bitmap, setting all bits to `val`. /// Initialize a bitmap, setting all bits to `val`.
pub fn init(val: bool) Self { pub fn init(val: bool) Self {
@@ -65,6 +66,7 @@ test "BitMap has proper underlying type" {
std.debug.assert(BitMap(32).Word == u32); std.debug.assert(BitMap(32).Word == u32);
std.debug.assert(BitMap(64).Word == u64); std.debug.assert(BitMap(64).Word == u64);
std.debug.assert(BitMap(128).Word == u64); std.debug.assert(BitMap(128).Word == u64);
std.debug.assert(BitMap(1024).Word == u64);
} }
test BitMap { test BitMap {