From 7ca54553bb3e6a801982d6778b41ecd535b63d2a Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Sun, 14 Apr 2024 14:47:35 -0700 Subject: Added realtime clock support, and better timestamping. The realtime clock is not (yet) exposed for user applications, but it is used for logging timestamps accurately. --- src/platform/windows/win_clock.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src/platform/windows/win_clock.c') diff --git a/src/platform/windows/win_clock.c b/src/platform/windows/win_clock.c index fc338fdb..2beeec45 100644 --- a/src/platform/windows/win_clock.c +++ b/src/platform/windows/win_clock.c @@ -1,5 +1,5 @@ // -// Copyright 2017 Garrett D'Amore +// Copyright 2024 Garrett D'Amore // Copyright 2017 Capitar IT Group BV // // This software is supplied under the terms of the MIT License, a @@ -10,6 +10,8 @@ #include "core/nng_impl.h" +#include + #ifdef NNG_PLATFORM_WINDOWS nni_time @@ -19,6 +21,19 @@ nni_clock(void) return (GetTickCount64()); } +int +nni_time_get(uint64_t *seconds, uint32_t *nanoseconds) +{ + int rv; + struct timespec ts; + if (timespec_get(&ts, TIME_UTC) == TIME_UTC) { + *seconds = ts.tv_sec; + *nanoseconds = ts.tv_nsec; + return (0); + } + return (nni_win_error(GetLastError())); +} + void nni_msleep(nni_duration dur) { -- cgit v1.2.3-70-g09d2