diff options
author | quou <quou@disroot.org> | 2024-12-31 23:51:13 +1100 |
---|---|---|
committer | quou <quou@disroot.org> | 2024-12-31 23:51:13 +1100 |
commit | 92692cccfe0524ba7cece97e495e8c62a57b1c23 (patch) | |
tree | 2e93fe5f14e28bc7426a5f045d85422317d07e63 | |
parent | 7c983d91a738ba2e88ed8011a1a358446dd10918 (diff) |
implement get_time for windows
-rw-r--r-- | qstd/plat.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/qstd/plat.c b/qstd/plat.c index 15e0265..b34e8cb 100644 --- a/qstd/plat.c +++ b/qstd/plat.c @@ -186,5 +186,22 @@ void pbreak(int code) { #endif } +uint64_t timer_freq; +int timer_init = 0; + +void init_timer(void) { + LARGE_INTEGER f; + QueryPerformanceFrequency(&f); + timer_freq = (uint64_t)f.QuadPart; + timer_init = 1; +} + +uint64_t get_time(void) { + if (!timer_init) + init_timer(); + LARGE_INTEGER ticks; + QueryPerformanceCounter(&ticks); + return (uint64_t)ticks.QuadPart * 1000000000 / timer_freq; +} #endif |