]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/RISC-V_RV32_SiFive_HiFive1_FreedomStudio/freedom-metal/gloss/sys_gettimeofday.c
Rename the RISC-V_RV32_SiFive_Hifive1_GCC folder to RISC-V_RV32_SiFive_HiFive1_Freedo...
[freertos] / FreeRTOS / Demo / RISC-V_RV32_SiFive_HiFive1_FreedomStudio / freedom-metal / gloss / sys_gettimeofday.c
1 #include <errno.h>
2 #include <metal/timer.h>
3 #include <sys/time.h>
4
5 int
6 _gettimeofday(struct timeval *tp, void *tzp)
7 {
8     int rv;
9     unsigned long long mcc, timebase;
10     if (rv = metal_timer_get_cyclecount(0, &mcc)) {
11         return -1;
12     }
13     if (rv = metal_timer_get_timebase_frequency(0, &timebase)) {
14         return -1;
15     }
16     tp->tv_sec = mcc / timebase;
17     tp->tv_usec = mcc % timebase * 1000000 / timebase;
18     return 0;
19 }