Skip to content
This repository has been archived by the owner on Aug 17, 2022. It is now read-only.

fixing compilation error with older linux env #20

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions sim/riscv/sim-main.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,12 @@ fetch_csr (SIM_CPU *cpu, const char *name, int csr, unsigned_word *reg)
{
struct timespec ts;

#if defined(CLOCK_BOOTTIME)
if (clock_gettime (CLOCK_BOOTTIME, &ts) == 0)
#else
if (clock_gettime (CLOCK_MONOTONIC, &ts) == 0)
#endif

{
uint64_t time = (uint64_t)ts.tv_sec * 1000 * 1000 + ts.tv_nsec;
*reg = (csr == CSR_TIME) ? time : (time >> 32);
Expand Down