Skip to content

Commit 0c43584

Browse files
committed
Use deterministic ilog2 when possible
1 parent 3a8055b commit 0c43584

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

plic.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ static bool plic_reg_read(plic_state_t *plic, uint32_t addr, uint32_t *value)
3838
*value = 0;
3939
uint32_t candidates = plic->ip & plic->ie;
4040
if (candidates) {
41-
while (!(candidates & (1 << (++(*value)))))
42-
;
41+
*value = ilog2(candidates);
4342
plic->ip &= ~(1 << (*value));
4443
}
4544
return true;

0 commit comments

Comments
 (0)