diff options
Diffstat (limited to 'lib/sbi')
-rw-r--r-- | lib/sbi/riscv_asm.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/sbi/riscv_asm.c b/lib/sbi/riscv_asm.c index 4c24a51..d7b9b2b 100644 --- a/lib/sbi/riscv_asm.c +++ b/lib/sbi/riscv_asm.c @@ -213,6 +213,9 @@ static unsigned long ctz(unsigned long x) { unsigned long ret = 0; + if (x == 0) + return 8 * sizeof(x); + while (!(x & 1UL)) { ret++; x = x >> 1; |