Files
allwpilib/upstream_utils/libuv_patches/0010-Remove-uv_clock_gettime-and-add-pragmas-for-missing-.patch
2023-07-14 18:55:32 -07:00

80 lines
2.6 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Tyler Veness <calcmogul@gmail.com>
Date: Fri, 14 Jul 2023 16:40:18 -0700
Subject: [PATCH 10/10] Remove uv_clock_gettime() and add pragmas for missing
libraries
The Win32 function GetSystemTimePreciseAsFileTime() is missing, which
causes compilation errors in uv_clock_gettime(). However, neither WPILib
nor libuv use uv_clock_gettime(), so removing it works around the
problem.
---
include/uv.h | 1 -
src/win/util.c | 33 ++-------------------------------
2 files changed, 2 insertions(+), 32 deletions(-)
diff --git a/include/uv.h b/include/uv.h
index d5342b0d52232bbf83825948cc6bc09e5d74a4c7..9adcf955e143bb323363c9d96da51ccdb618261a 100644
--- a/include/uv.h
+++ b/include/uv.h
@@ -1755,7 +1755,6 @@ UV_EXTERN uint64_t uv_get_total_memory(void);
UV_EXTERN uint64_t uv_get_constrained_memory(void);
UV_EXTERN uint64_t uv_get_available_memory(void);
-UV_EXTERN int uv_clock_gettime(uv_clock_id clock_id, uv_timespec64_t* ts);
UV_EXTERN uint64_t uv_hrtime(void);
UV_EXTERN void uv_sleep(unsigned int msec);
diff --git a/src/win/util.c b/src/win/util.c
index 9324992ec521cc3496e3e9304e600963a3f20897..4ea2eada07f8d7e664bee22e74b20c705a0eb9a3 100644
--- a/src/win/util.c
+++ b/src/win/util.c
@@ -73,7 +73,9 @@ static char *process_title;
static CRITICAL_SECTION process_title_lock;
#pragma comment(lib, "Advapi32.lib")
+#pragma comment(lib, "Dbghelp.lib")
#pragma comment(lib, "IPHLPAPI.lib")
+#pragma comment(lib, "Ole32.lib")
#pragma comment(lib, "Psapi.lib")
#pragma comment(lib, "Userenv.lib")
#pragma comment(lib, "kernel32.lib")
@@ -513,37 +515,6 @@ int uv_get_process_title(char* buffer, size_t size) {
}
-/* https://github.com/libuv/libuv/issues/1674 */
-int uv_clock_gettime(uv_clock_id clock_id, uv_timespec64_t* ts) {
- FILETIME ft;
- int64_t t;
-
- if (ts == NULL)
- return UV_EFAULT;
-
- switch (clock_id) {
- case UV_CLOCK_MONOTONIC:
- uv__once_init();
- t = uv__hrtime(UV__NANOSEC);
- ts->tv_sec = t / 1000000000;
- ts->tv_nsec = t % 1000000000;
- return 0;
- case UV_CLOCK_REALTIME:
- GetSystemTimePreciseAsFileTime(&ft);
- /* In 100-nanosecond increments from 1601-01-01 UTC because why not? */
- t = (int64_t) ft.dwHighDateTime << 32 | ft.dwLowDateTime;
- /* Convert to UNIX epoch, 1970-01-01. Still in 100 ns increments. */
- t -= 116444736000000000ll;
- /* Now convert to seconds and nanoseconds. */
- ts->tv_sec = t / 10000000;
- ts->tv_nsec = t % 10000000 * 100;
- return 0;
- }
-
- return UV_EINVAL;
-}
-
-
uint64_t uv_hrtime(void) {
uv__once_init();
return uv__hrtime(UV__NANOSEC);