[many] Fix many cases of 1 << n exceeding the size of int

Yet again burned by the fack that integer literals are assumed to be of
type int, so `1 << n` is 0 for any n >= 32. This burned me in the frame
allocator, but I also grepped for all instances of `1 <<` and fixed
those too.
This commit is contained in:
Justin C. Miller
2023-02-18 19:53:04 -08:00
parent 42db1e8899
commit 55c88dd943
7 changed files with 20 additions and 19 deletions

View File

@@ -249,13 +249,13 @@ build_frame_blocks(const util::counted<bootproto::mem_entry> &kmap)
unsigned i = 0;
uint64_t b1 = (page_count + 4095) / 4096;
blk->map1 = (1 << b1) - 1;
blk->map1 = (1ull << b1) - 1;
uint64_t b2 = (page_count + 63) / 64;
uint64_t b2q = b2 / 64;
uint64_t b2r = b2 % 64;
g_alloc.memset(blk->map2, b2q, 0xff);
blk->map2[b2q] = (1 << b2r) - 1;
blk->map2[b2q] = (1ull << b2r) - 1;
break;
}
}
@@ -269,7 +269,7 @@ build_frame_blocks(const util::counted<bootproto::mem_entry> &kmap)
size_t b = blk.count / 64;
size_t r = blk.count % 64;
g_alloc.memset(blk.bitmap, b*8, 0xff);
blk.bitmap[b] = (1 << r) - 1;
blk.bitmap[b] = (1ull << r) - 1;
bitmap += bitmap_size(blk.count);
}