File tree Expand file tree Collapse file tree 3 files changed +37
-4
lines changed Expand file tree Collapse file tree 3 files changed +37
-4
lines changed Original file line number Diff line number Diff line change @@ -166,10 +166,15 @@ pub(crate) fn clock_gettime_dynamic(id: DynamicClockId<'_>) -> io::Result<Timesp
166
166
#[ cfg( linux_kernel) ]
167
167
DynamicClockId :: Tai => c:: CLOCK_TAI ,
168
168
169
- #[ cfg( any( linux_kernel, target_os = "openbsd" ) ) ]
169
+ #[ cfg( any(
170
+ freebsdlike,
171
+ linux_kernel,
172
+ target_os = "fuchsia" ,
173
+ target_os = "openbsd"
174
+ ) ) ]
170
175
DynamicClockId :: Boottime => c:: CLOCK_BOOTTIME ,
171
176
172
- #[ cfg( linux_kernel) ]
177
+ #[ cfg( any ( linux_kernel, target_os = "fuchsia" ) ) ]
173
178
DynamicClockId :: BoottimeAlarm => c:: CLOCK_BOOTTIME_ALARM ,
174
179
} ;
175
180
Original file line number Diff line number Diff line change @@ -96,10 +96,15 @@ pub enum DynamicClockId<'a> {
96
96
Tai ,
97
97
98
98
/// `CLOCK_BOOTTIME`, available on Linux >= 2.6.39
99
- #[ cfg( any( linux_kernel, target_os = "openbsd" ) ) ]
99
+ #[ cfg( any(
100
+ freebsdlike,
101
+ linux_kernel,
102
+ target_os = "fuchsia" ,
103
+ target_os = "openbsd"
104
+ ) ) ]
100
105
Boottime ,
101
106
102
107
/// `CLOCK_BOOTTIME_ALARM`, available on Linux >= 2.6.39
103
- #[ cfg( linux_kernel) ]
108
+ #[ cfg( any ( linux_kernel, target_os = "fuchsia" ) ) ]
104
109
BoottimeAlarm ,
105
110
}
Original file line number Diff line number Diff line change 5
5
#[ cfg( not( any( solarish, target_os = "netbsd" , target_os = "redox" ) ) ) ]
6
6
use rustix:: time:: { clock_gettime, ClockId } ;
7
7
8
+ /// Attempt to test that the boot clock is monotonic. Time may or may not
9
+ /// advance, but it shouldn't regress.
10
+ #[ cfg( any(
11
+ freebsdlike,
12
+ linux_kernel,
13
+ target_os = "fuchsia" ,
14
+ target_os = "openbsd"
15
+ ) ) ]
16
+ #[ test]
17
+ fn test_boottime_clock ( ) {
18
+ use rustix:: time:: { clock_gettime_dynamic, DynamicClockId } ;
19
+
20
+ if let Ok ( a) = clock_gettime_dynamic ( DynamicClockId :: Boottime ) {
21
+ if let Ok ( b) = clock_gettime_dynamic ( DynamicClockId :: Boottime ) {
22
+ if b. tv_sec == a. tv_sec {
23
+ assert ! ( b. tv_nsec >= a. tv_nsec) ;
24
+ } else {
25
+ assert ! ( b. tv_sec > a. tv_sec) ;
26
+ }
27
+ }
28
+ }
29
+ }
30
+
8
31
/// Attempt to test that the uptime clock is monotonic. Time may or may not
9
32
/// advance, but it shouldn't regress.
10
33
#[ cfg( any( freebsdlike, target_os = "openbsd" ) ) ]
You can’t perform that action at this time.
0 commit comments