diff options
| author | Birunthan Mohanathas <birunthan@mohanathas.com> | 2013-11-11 21:21:51 +0200 |
|---|---|---|
| committer | Birunthan Mohanathas <birunthan@mohanathas.com> | 2013-11-11 21:21:51 +0200 |
| commit | 36afd606091a708e9a5676c7fb2e4cdc47b9abfd (patch) | |
| tree | 09f363ae5d838f7d63d80de84249f88326a93d70 /src/rt/rust_builtin.cpp | |
| parent | 61f76a51300fd61369255850a41e04720681fcf8 (diff) | |
| download | rust-36afd606091a708e9a5676c7fb2e4cdc47b9abfd.tar.gz rust-36afd606091a708e9a5676c7fb2e4cdc47b9abfd.zip | |
Add asserts to check for faililng QueryPerformance* calls in precise_time_ns
Closes #2675.
Diffstat (limited to 'src/rt/rust_builtin.cpp')
| -rw-r--r-- | src/rt/rust_builtin.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp index 1a3e7d90daa..b8e808863c0 100644 --- a/src/rt/rust_builtin.cpp +++ b/src/rt/rust_builtin.cpp @@ -217,14 +217,16 @@ precise_time_ns(uint64_t *ns) { uint64_t time_nano = time * (info.numer / info.denom); *ns = time_nano; #elif __WIN32__ - int64_t ticks_per_s; - QueryPerformanceFrequency((LARGE_INTEGER *)&ticks_per_s); - if (ticks_per_s == 0LL) { - ticks_per_s = 1LL; + LARGE_INTEGER ticks_per_s; + BOOL query_result = QueryPerformanceFrequency(&ticks_per_s); + assert(query_result); + if (ticks_per_s.QuadPart == 0LL) { + ticks_per_s.QuadPart = 1LL; } - int64_t ticks; - QueryPerformanceCounter((LARGE_INTEGER *)&ticks); - *ns = (uint64_t)((ticks * ns_per_s) / ticks_per_s); + LARGE_INTEGER ticks; + query_result = QueryPerformanceCounter(&ticks); + assert(query_result); + *ns = (uint64_t)((ticks.QuadPart * ns_per_s) / ticks_per_s.QuadPart); #else timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts); |
