File tree 1 file changed +11
-9
lines changed
1 file changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -203,7 +203,7 @@ get_time(int64_t *sec, int32_t *nsec) {
203
203
}
204
204
#endif
205
205
206
- const uint64_t ns_per_s = 1000000000LL ;
206
+ const int64_t ns_per_s = 1000000000LL ;
207
207
208
208
extern " C" CDECL void
209
209
precise_time_ns (uint64_t *ns) {
@@ -217,18 +217,20 @@ precise_time_ns(uint64_t *ns) {
217
217
uint64_t time_nano = time * (info.numer / info.denom );
218
218
*ns = time_nano;
219
219
#elif __WIN32__
220
- uint64_t ticks_per_s;
221
- QueryPerformanceFrequency ((LARGE_INTEGER *)&ticks_per_s);
222
- if (ticks_per_s == 0LL ) {
223
- ticks_per_s = 1LL ;
220
+ LARGE_INTEGER ticks_per_s;
221
+ BOOL query_result = QueryPerformanceFrequency (&ticks_per_s);
222
+ assert (query_result);
223
+ if (ticks_per_s.QuadPart == 0LL ) {
224
+ ticks_per_s.QuadPart = 1LL ;
224
225
}
225
- uint64_t ticks;
226
- QueryPerformanceCounter ((LARGE_INTEGER *)&ticks);
227
- *ns = ((ticks * ns_per_s) / ticks_per_s);
226
+ LARGE_INTEGER ticks;
227
+ query_result = QueryPerformanceCounter (&ticks);
228
+ assert (query_result);
229
+ *ns = (uint64_t )((ticks.QuadPart * ns_per_s) / ticks_per_s.QuadPart );
228
230
#else
229
231
timespec ts;
230
232
clock_gettime (CLOCK_MONOTONIC, &ts);
231
- *ns = (ts.tv_sec * ns_per_s + ts.tv_nsec );
233
+ *ns = (uint64_t )( ts.tv_sec * ns_per_s + ts.tv_nsec );
232
234
#endif
233
235
}
234
236
You can’t perform that action at this time.
0 commit comments