Change use of unsigned integers to signed integers for clarity in

precise_time_ns

The QueryPerformance* functions take a LARGE_INTEGER, which is a signed
64-bit integer rather than an unsigned 64-bit integer. `ts.tv_sec`, too,
is a signed integer so `ns_per_s` has been changed to a int64_t.
This commit is contained in:
Birunthan Mohanathas 2013-11-11 21:21:24 +02:00
parent 3851f908d1
commit 61f76a5130

View File

@ -203,7 +203,7 @@ get_time(int64_t *sec, int32_t *nsec) {
}
#endif
const uint64_t ns_per_s = 1000000000LL;
const int64_t ns_per_s = 1000000000LL;
extern "C" CDECL void
precise_time_ns(uint64_t *ns) {
@ -217,18 +217,18 @@ precise_time_ns(uint64_t *ns) {
uint64_t time_nano = time * (info.numer / info.denom);
*ns = time_nano;
#elif __WIN32__
uint64_t ticks_per_s;
int64_t ticks_per_s;
QueryPerformanceFrequency((LARGE_INTEGER *)&ticks_per_s);
if (ticks_per_s == 0LL) {
ticks_per_s = 1LL;
}
uint64_t ticks;
int64_t ticks;
QueryPerformanceCounter((LARGE_INTEGER *)&ticks);
*ns = ((ticks * ns_per_s) / ticks_per_s);
*ns = (uint64_t)((ticks * ns_per_s) / ticks_per_s);
#else
timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
*ns = (ts.tv_sec * ns_per_s + ts.tv_nsec);
*ns = (uint64_t)(ts.tv_sec * ns_per_s + ts.tv_nsec);
#endif
}