Files
allwpilib/upstream_utils/libuv_patches/0005-Use-roborio-time.patch
Tyler Veness 44abc8dfa6 [upstream_utils] Remove git version from upstream patches (#4351)
This reduces commit noise when other git versions are used. The version
was removed by passing `--no-signature` to `git format-patch` which is
now documented in the readme.
2022-08-13 18:31:26 -07:00

43 lines
1.1 KiB
Diff

From 92a83a3979d5281553ab624e6c4b0ae8a708ddf8 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 85f3fc0..12ed7ff 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
}