From e7c98feca28a14e5dbb984199e56eb4b03cb186a Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Wed, 7 Nov 2018 00:06:18 -0800 Subject: [PATCH] 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. --- wpiutil/src/main/native/libuv/unix/linux-core.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/wpiutil/src/main/native/libuv/unix/linux-core.cpp b/wpiutil/src/main/native/libuv/unix/linux-core.cpp index 44229477fe..3bf8beb559 100644 --- a/wpiutil/src/main/native/libuv/unix/linux-core.cpp +++ b/wpiutil/src/main/native/libuv/unix/linux-core.cpp @@ -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 but we can't * include that file because it conflicts with . 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 }