From 29f1df2eeacb55f994ebb9eff18c444c8de5253e Mon Sep 17 00:00:00 2001 From: TXuian <1163589503@qq.com> Date: Sun, 19 May 2024 17:37:52 +0800 Subject: [PATCH] Fix bitmap64 corner case. --- Ubiquitous/XiZi_AIoT/softkernel/include/bitmap64.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Ubiquitous/XiZi_AIoT/softkernel/include/bitmap64.h b/Ubiquitous/XiZi_AIoT/softkernel/include/bitmap64.h index a3287ab85..77f45e1da 100644 --- a/Ubiquitous/XiZi_AIoT/softkernel/include/bitmap64.h +++ b/Ubiquitous/XiZi_AIoT/softkernel/include/bitmap64.h @@ -47,9 +47,9 @@ static inline int bitmap64_alloc(struct bitmap64* bitmap) { int free_bit = -1; // free bit is the first 0 bit, from [1, 64] - free_bit = __builtin_ffsll(~(bitmap->map)); + free_bit = __builtin_ffsl(~(uint64_t)(bitmap->map)); // handle if bitmap is full (no using 64th bit here) - if (free_bit == 64) { + if (free_bit == 0) { return -1; } assert(free_bit < 64 && free_bit >= 1);