Skip to content

Commit

Permalink
Merge pull request #155 from sifive/fix-c99
Browse files Browse the repository at this point in the history
Fix compliance with c99
  • Loading branch information
nategraff-sifive authored Aug 14, 2019
2 parents ad2ed6b + b7d07f6 commit 1e49464
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
7 changes: 7 additions & 0 deletions metal/time.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,18 @@

#include <time.h>

#include <sys/types.h>

/*!
* @file time.h
* @brief API for dealing with time
*/

struct timeval {
time_t tv_sec;
suseconds_t tv_usec;
};

int metal_gettimeofday(struct timeval *tp, void *tzp);

time_t metal_time(void);
Expand Down
2 changes: 1 addition & 1 deletion src/drivers/riscv_cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ void __metal_exception_handler(void) {
metal_vector_mode __metal_controller_interrupt_vector_mode(void) {
uintptr_t val;

asm volatile("csrr %0, mtvec" : "=r"(val));
__asm__ volatile("csrr %0, mtvec" : "=r"(val));
val &= METAL_MTVEC_MASK;

switch (val) {
Expand Down
2 changes: 2 additions & 0 deletions src/drivers/sifive_rtc0.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,5 @@ __METAL_DEFINE_VTABLE(__metal_driver_vtable_sifive_rtc0) = {
};

#endif

typedef int no_empty_translation_units;
6 changes: 4 additions & 2 deletions src/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
int metal_gettimeofday(struct timeval *tp, void *tzp) {
int rv;
unsigned long long mcc, timebase;
if (rv = metal_timer_get_cyclecount(0, &mcc)) {
rv = metal_timer_get_cyclecount(0, &mcc);
if (rv != 0) {
return -1;
}
if (rv = metal_timer_get_timebase_frequency(0, &timebase)) {
rv = metal_timer_get_timebase_frequency(0, &timebase);
if (rv != 0) {
return -1;
}
tp->tv_sec = mcc / timebase;
Expand Down

0 comments on commit 1e49464

Please sign in to comment.