Skip to content

Commit 5580bb2

Browse files
committed
Fix Clang error when disabling Zicsr
When using 'make ENABLE_Zicsr=0 CC=clang', the following error is observed: src/emulate.c:83:20: error: unused function 'update_time' [-Werror,-Wunused-function] 83 | static inline void update_time(riscv_t *rv) | ^~~~~~~~~~~ 1 error generated Fix this by guarding the update_time function definition with RV32_HAS(Zicsr) macro. This ensures the function is only defined when the Zicsr is enabled.
1 parent 7384d92 commit 5580bb2

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/emulate.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,14 @@ static void __trap_handler(riscv_t *rv);
7979
}
8080

8181
/* FIXME: use more precise methods for updating time, e.g., RTC */
82+
#if RV32_HAS(Zicsr)
8283
static uint64_t ctr = 0;
8384
static inline void update_time(riscv_t *rv)
8485
{
8586
rv->csr_time[0] = ctr & 0xFFFFFFFF;
8687
rv->csr_time[1] = ctr >> 32;
8788
}
89+
#endif
8890

8991
#if RV32_HAS(Zicsr)
9092
/* get a pointer to a CSR */

0 commit comments

Comments
 (0)