diff options
| author | Garrett D'Amore <garrett@damore.org> | 2024-04-14 14:47:35 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2024-04-14 18:52:56 -0700 |
| commit | 7ca54553bb3e6a801982d6778b41ecd535b63d2a (patch) | |
| tree | 3a9f98c91028a4532d7adeb06e01dea706711787 /src/platform/windows | |
| parent | d11b162ac67268e77c39d633972bc3e05d3f7995 (diff) | |
| download | nng-7ca54553bb3e6a801982d6778b41ecd535b63d2a.tar.gz nng-7ca54553bb3e6a801982d6778b41ecd535b63d2a.tar.bz2 nng-7ca54553bb3e6a801982d6778b41ecd535b63d2a.zip | |
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.
Diffstat (limited to 'src/platform/windows')
| -rw-r--r-- | src/platform/windows/win_clock.c | 17 |
1 files changed, 16 insertions, 1 deletions
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 <garrett@damore.org> +// Copyright 2024 Garrett D'Amore <garrett@damore.org> // Copyright 2017 Capitar IT Group BV <info@capitar.com> // // This software is supplied under the terms of the MIT License, a @@ -10,6 +10,8 @@ #include "core/nng_impl.h" +#include <time.h> + #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) { |
