blob: 46cc46fe2f012239c1623c14d9f36867bb8fcaeb [file] [log] [blame]
From 690d487df2e60a01ab811aba34587466a38caead Mon Sep 17 00:00:00 2001
From: PJ Reiniger <pj.reiniger@gmail.com>
Date: Tue, 26 Apr 2022 15:26:03 -0400
Subject: [PATCH 5/9] Use roborio time
---
src/unix/linux-core.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/unix/linux-core.c b/src/unix/linux-core.c
index 85f3fc01..12ed7ff1 100644
--- a/src/unix/linux-core.c
+++ b/src/unix/linux-core.c
@@ -67,6 +67,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.
@@ -118,6 +122,9 @@ void uv__platform_loop_delete(uv_loop_t* loop) {
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;
@@ -151,6 +158,7 @@ done:
return 0; /* Not really possible. */
return t.tv_sec * (uint64_t) 1e9 + t.tv_nsec;
+#endif
}