5 void os_clk_tck(long *clk_tck)
8 * The timer resolution is variable on Windows. Try to query it
9 * or use 64 Hz, the clock frequency lower bound. See also
10 * https://carpediemsystems.co.uk/2019/07/18/windows-system-timer-granularity/.
12 unsigned long minRes, maxRes, curRes;
17 if (!(lib = LoadLibrary(TEXT("ntdll.dll"))) ||
18 !(queryTimer = GetProcAddress(lib, "NtQueryTimerResolution")) ||
19 !(setTimer = GetProcAddress(lib, "NtSetTimerResolution"))) {
20 dprint(FD_HELPERTHREAD,
21 "Failed to load ntdll library, set to lower bound 64 Hz\n");
24 queryTimer(&minRes, &maxRes, &curRes);
25 dprint(FD_HELPERTHREAD,
26 "minRes = %lu, maxRes = %lu, curRes = %lu\n",
27 minRes, maxRes, curRes);
29 /* Use maximum resolution for most accurate timestamps */
30 setTimer(maxRes, 1, &curRes);
31 *clk_tck = (long) (10000000L / maxRes);