1 #ifndef TREE_SITTER_CLOCK_H_
2 #define TREE_SITTER_CLOCK_H_
18 LARGE_INTEGER frequency;
19 QueryPerformanceFrequency(&frequency);
20 return micros * (
uint64_t)frequency.QuadPart / 1000000;
24 LARGE_INTEGER frequency;
25 QueryPerformanceFrequency(&frequency);
26 return self * 1000000 / (
uint64_t)frequency.QuadPart;
35 QueryPerformanceCounter(&result);
40 return base + duration;
51 #elif defined(CLOCK_MONOTONIC) && !defined(__APPLE__)
73 clock_gettime(CLOCK_MONOTONIC, &result);
83 result.tv_sec += duration / 1000000;
84 result.tv_nsec += (duration % 1000000) * 1000;
93 if (
self.
tv_sec > other.tv_sec)
return true;
94 if (
self.
tv_sec < other.tv_sec)
return false;
95 return self.tv_nsec > other.tv_nsec;
112 return micros * (
uint64_t)CLOCKS_PER_SEC / 1000000;
116 return self * 1000000 / (
uint64_t)CLOCKS_PER_SEC;
128 return base + duration;
static TSClock clock_null(void)
static TSDuration duration_from_micros(uint64_t micros)
static uint64_t duration_to_micros(TSDuration self)
static bool clock_is_gt(TSClock self, TSClock other)
static TSClock clock_after(TSClock base, TSDuration duration)
static TSClock clock_now(void)
static bool clock_is_null(TSClock self)