| 1 |
#include "cgreen/internal/cgreen_time.h" |
| 2 |
#include <stdint.h> |
| 3 |
#include <stdio.h> |
| 4 |
#include <unistd.h> |
| 5 |
#include <windows.h> |
| 6 |
#include <stdbool.h> |
| 7 |
#include <math.h> |
| 8 |
|
| 9 |
static LARGE_INTEGER qry_freq; |
| 10 |
static bool qry_freq_initialized = false; |
| 11 |
|
| 12 |
uint32_t cgreen_time_get_current_milliseconds() { |
| 13 |
if (!qry_freq_initialized) { |
| 14 |
QueryPerformanceFrequency(&qry_freq); |
| 15 |
qry_freq_initialized = true; |
| 16 |
} |
| 17 |
|
| 18 |
LARGE_INTEGER current_count; |
| 19 |
QueryPerformanceCounter(¤t_count); |
| 20 |
|
| 21 |
current_count.QuadPart = current_count.QuadPart * 1000000 / qry_freq.QuadPart; |
| 22 |
|
| 23 |
return trunc(current_count.QuadPart / 1000); |
| 24 |
} |
| 25 |
|
| 26 |
|