From 92692cccfe0524ba7cece97e495e8c62a57b1c23 Mon Sep 17 00:00:00 2001 From: quou Date: Tue, 31 Dec 2024 23:51:13 +1100 Subject: implement get_time for windows --- qstd/plat.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'qstd') 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 -- cgit v1.2.3-54-g00ecf