Skip to content

Commit 932709b

Browse files
committed
Wrap built-in function with wrapper function
wrap __builtin_ffs with static inline ffs function.
1 parent 54bcc0b commit 932709b

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

common.h

+5
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ static inline int ilog2(int x)
1717
return 31 - __builtin_clz(x | 1);
1818
}
1919

20+
static inline int ffs(int x)
21+
{
22+
return __builtin_ffs(x);
23+
}
24+
2025
/* Range check
2126
* For any variable range checking:
2227
* if (x >= minx && x <= maxx) ...

riscv.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,7 @@ void vm_step(hart_t *vm)
806806
vm->current_pc = vm->pc;
807807
if ((vm->sstatus_sie || !vm->s_mode) && (vm->sip & vm->sie)) {
808808
uint32_t applicable = (vm->sip & vm->sie);
809-
uint8_t idx = __builtin_ffs(applicable) - 1;
809+
uint8_t idx = ffs(applicable) - 1;
810810
if (idx == 1) {
811811
emu_state_t *data = PRIV(vm);
812812
data->clint.msip[vm->mhartid] = 0;

0 commit comments

Comments
 (0)