James Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame^] | 1 | From 690d487df2e60a01ab811aba34587466a38caead Mon Sep 17 00:00:00 2001 |
| 2 | From: PJ Reiniger <pj.reiniger@gmail.com> |
| 3 | Date: Tue, 26 Apr 2022 15:26:03 -0400 |
| 4 | Subject: [PATCH 5/9] Use roborio time |
| 5 | |
| 6 | --- |
| 7 | src/unix/linux-core.c | 8 ++++++++ |
| 8 | 1 file changed, 8 insertions(+) |
| 9 | |
| 10 | diff --git a/src/unix/linux-core.c b/src/unix/linux-core.c |
| 11 | index 85f3fc01..12ed7ff1 100644 |
| 12 | --- a/src/unix/linux-core.c |
| 13 | +++ b/src/unix/linux-core.c |
| 14 | @@ -67,6 +67,10 @@ |
| 15 | # define CLOCK_MONOTONIC_COARSE 6 |
| 16 | #endif |
| 17 | |
| 18 | +#ifdef __FRC_ROBORIO__ |
| 19 | +#include "wpi/timestamp.h" |
| 20 | +#endif |
| 21 | + |
| 22 | /* This is rather annoying: CLOCK_BOOTTIME lives in <linux/time.h> but we can't |
| 23 | * include that file because it conflicts with <time.h>. We'll just have to |
| 24 | * define it ourselves. |
| 25 | @@ -118,6 +122,9 @@ void uv__platform_loop_delete(uv_loop_t* loop) { |
| 26 | |
| 27 | |
| 28 | uint64_t uv__hrtime(uv_clocktype_t type) { |
| 29 | +#ifdef __FRC_ROBORIO__ |
| 30 | + return wpi::Now() * 1000u; |
| 31 | +#else |
| 32 | static clock_t fast_clock_id = -1; |
| 33 | struct timespec t; |
| 34 | clock_t clock_id; |
| 35 | @@ -151,6 +158,7 @@ done: |
| 36 | return 0; /* Not really possible. */ |
| 37 | |
| 38 | return t.tv_sec * (uint64_t) 1e9 + t.tv_nsec; |
| 39 | +#endif |
| 40 | } |
| 41 | |
| 42 | |