1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
Index: rust-prometheus-0.13.4/src/histogram.rs
===================================================================
--- rust-prometheus-0.13.4.orig/src/histogram.rs
+++ rust-prometheus-0.13.4/src/histogram.rs
@@ -528,8 +528,8 @@ impl Instant {
#[cfg(all(feature = "nightly", target_os = "linux"))]
Instant::MonotonicCoarse(t) => {
let now = get_time_coarse();
- let now_ms = now.0.tv_sec * MILLIS_PER_SEC + now.0.tv_nsec / NANOS_PER_MILLI;
- let t_ms = t.0.tv_sec * MILLIS_PER_SEC + t.0.tv_nsec / NANOS_PER_MILLI;
+ let now_ms = (now.0.tv_sec as i64) * MILLIS_PER_SEC + (now.0.tv_nsec as i64) / NANOS_PER_MILLI;
+ let t_ms = (t.0.tv_sec as i64) * MILLIS_PER_SEC + (t.0.tv_nsec as i64) / NANOS_PER_MILLI;
let dur = now_ms - t_ms;
if dur >= 0 {
Duration::from_millis(dur as u64)
@@ -559,10 +559,8 @@ mod coarse {
pub const MILLIS_PER_SEC: i64 = 1_000;
pub fn get_time_coarse() -> Timespec {
- let mut t = Timespec(timespec {
- tv_sec: 0,
- tv_nsec: 0,
- });
+ let t : libc::timespec = unsafe { std::mem::zeroed() };
+ let mut t = Timespec(t);
assert_eq!(
unsafe { clock_gettime(CLOCK_MONOTONIC_COARSE, &mut t.0) },
0
|