libuv: Use WPI (FPGA) clock on roboRio (#1409)

This is set to the FPGA clock by HAL_Initialize.  Note this change means
that libuv loops should not be started until after HAL_Initialize is called (on the Rio).
Non-Rio functionality is unchanged.
This commit is contained in:
Peter Johnson
2018-11-07 00:06:18 -08:00
committed by GitHub
parent 28087424ec
commit e7c98feca2

View File

@@ -65,6 +65,10 @@
# define CLOCK_MONOTONIC_COARSE 6
#endif
#ifdef __FRC_ROBORIO__
#include "wpi/timestamp.h"
#endif
/* This is rather annoying: CLOCK_BOOTTIME lives in <linux/time.h> but we can't
* include that file because it conflicts with <time.h>. We'll just have to
* define it ourselves.
@@ -441,6 +445,9 @@ update_timeout:
uint64_t uv__hrtime(uv_clocktype_t type) {
#ifdef __FRC_ROBORIO__
return wpi::Now() * 1000u;
#else
static clock_t fast_clock_id = -1;
struct timespec t;
clock_t clock_id;
@@ -470,6 +477,7 @@ uint64_t uv__hrtime(uv_clocktype_t type) {
return 0; /* Not really possible. */
return t.tv_sec * (uint64_t) 1e9 + t.tv_nsec;
#endif
}