From 61f76a51300fd61369255850a41e04720681fcf8 Mon Sep 17 00:00:00 2001 From: Birunthan Mohanathas Date: Mon, 11 Nov 2013 21:21:24 +0200 Subject: [PATCH] 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. --- src/rt/rust_builtin.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp index b9c3851cc6309..1a3e7d90daa66 100644 --- a/src/rt/rust_builtin.cpp +++ b/src/rt/rust_builtin.cpp @@ -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 }