| 1 |
Index: rust-clock-steering-0.2.1/src/unix.rs |
| 2 |
=================================================================== |
| 3 |
--- rust-clock-steering-0.2.1.orig/src/unix.rs |
| 4 |
+++ rust-clock-steering-0.2.1/src/unix.rs |
| 5 |
@@ -293,12 +293,11 @@ impl UnixClock { |
| 6 |
let esterror = est_error.as_nanos() as libc::c_long / 1000; |
| 7 |
let maxerror = max_error.as_nanos() as libc::c_long / 1000; |
| 8 |
|
| 9 |
- libc::timex { |
| 10 |
- modes, |
| 11 |
- esterror, |
| 12 |
- maxerror, |
| 13 |
- ..EMPTY_TIMEX |
| 14 |
- } |
| 15 |
+ let mut result = EMPTY_TIMEX; |
| 16 |
+ result.modes = modes; |
| 17 |
+ result.esterror = esterror.into(); |
| 18 |
+ result.maxerror = maxerror.into(); |
| 19 |
+ result |
| 20 |
} |
| 21 |
|
| 22 |
#[cfg(target_os = "linux")] |
| 23 |
@@ -308,14 +307,13 @@ impl UnixClock { |
| 24 |
|
| 25 |
let time = libc::timeval { |
| 26 |
tv_sec: offset.seconds, |
| 27 |
- tv_usec: offset.nanos as libc::suseconds_t, |
| 28 |
+ tv_usec: offset.nanos as _, |
| 29 |
}; |
| 30 |
|
| 31 |
- libc::timex { |
| 32 |
- modes, |
| 33 |
- time, |
| 34 |
- ..EMPTY_TIMEX |
| 35 |
- } |
| 36 |
+ let mut result = EMPTY_TIMEX; |
| 37 |
+ result.modes = modes; |
| 38 |
+ result.time = time; |
| 39 |
+ result |
| 40 |
} |
| 41 |
|
| 42 |
#[cfg(target_os = "linux")] |
| 43 |
@@ -386,7 +384,7 @@ impl UnixClock { |
| 44 |
// Since Linux 2.6.26, the supplied value is clamped to the range (-32768000, |
| 45 |
// +32768000). In older kernels, an EINVAL error occurs if the supplied value is |
| 46 |
// out of range. (32768000 is 500 << 16) |
| 47 |
- timex.freq = frequency.clamp(-32_768_000 + 1, 32_768_000 - 1); |
| 48 |
+ timex.freq = frequency.clamp(-32_768_000 + 1, 32_768_000 - 1).into(); |
| 49 |
|
| 50 |
timex |
| 51 |
} |
| 52 |
@@ -469,11 +467,9 @@ impl Clock for UnixClock { |
| 53 |
|
| 54 |
#[cfg(target_os = "linux")] |
| 55 |
fn set_tai(&self, tai_offset: i32) -> Result<(), Error> { |
| 56 |
- let mut timex = libc::timex { |
| 57 |
- modes: libc::ADJ_TAI, |
| 58 |
- constant: tai_offset as _, |
| 59 |
- ..EMPTY_TIMEX |
| 60 |
- }; |
| 61 |
+ let mut timex = EMPTY_TIMEX; |
| 62 |
+ timex.modes = libc::ADJ_TAI; |
| 63 |
+ timex.constant = tai_offset as _; |
| 64 |
|
| 65 |
self.clock_adjtime(&mut timex) |
| 66 |
} |
| 67 |
@@ -652,50 +648,12 @@ fn current_time_timeval(timespec: libc:: |
| 68 |
Timestamp { seconds, nanos } |
| 69 |
} |
| 70 |
|
| 71 |
-const EMPTY_TIMESPEC: libc::timespec = libc::timespec { |
| 72 |
- tv_sec: 0, |
| 73 |
- tv_nsec: 0, |
| 74 |
-}; |
| 75 |
+const EMPTY_TIMESPEC: libc::timespec = unsafe { core::mem::zeroed() }; |
| 76 |
|
| 77 |
// Libc has no good other way of obtaining this, so let's at least make our |
| 78 |
// functions more readable. |
| 79 |
#[cfg(all(target_os = "linux", target_env = "gnu"))] |
| 80 |
-pub const EMPTY_TIMEX: libc::timex = libc::timex { |
| 81 |
- modes: 0, |
| 82 |
- offset: 0, |
| 83 |
- freq: 0, |
| 84 |
- maxerror: 0, |
| 85 |
- esterror: 0, |
| 86 |
- status: 0, |
| 87 |
- constant: 0, |
| 88 |
- precision: 0, |
| 89 |
- tolerance: 0, |
| 90 |
- time: libc::timeval { |
| 91 |
- tv_sec: 0, |
| 92 |
- tv_usec: 0, |
| 93 |
- }, |
| 94 |
- tick: 0, |
| 95 |
- ppsfreq: 0, |
| 96 |
- jitter: 0, |
| 97 |
- shift: 0, |
| 98 |
- stabil: 0, |
| 99 |
- jitcnt: 0, |
| 100 |
- calcnt: 0, |
| 101 |
- errcnt: 0, |
| 102 |
- stbcnt: 0, |
| 103 |
- tai: 0, |
| 104 |
- __unused1: 0, |
| 105 |
- __unused2: 0, |
| 106 |
- __unused3: 0, |
| 107 |
- __unused4: 0, |
| 108 |
- __unused5: 0, |
| 109 |
- __unused6: 0, |
| 110 |
- __unused7: 0, |
| 111 |
- __unused8: 0, |
| 112 |
- __unused9: 0, |
| 113 |
- __unused10: 0, |
| 114 |
- __unused11: 0, |
| 115 |
-}; |
| 116 |
+pub const EMPTY_TIMEX: libc::timex = unsafe { core::mem::zeroed() }; |
| 117 |
|
| 118 |
#[cfg(all(target_os = "linux", target_env = "musl"))] |
| 119 |
pub const EMPTY_TIMEX: libc::timex = libc::timex { |