1
1
use crate :: sys:: time:: TimeSpec ;
2
- #[ cfg( any(
3
- target_os = "freebsd" ,
4
- target_os = "dragonfly" ,
5
- target_os = "linux" ,
6
- target_os = "android" ,
7
- target_os = "emscripten" ,
8
- ) ) ]
2
+ #[ cfg( any( freebsdlike, linux_android, target_os = "emscripten" ) ) ]
9
3
#[ cfg( feature = "process" ) ]
10
4
use crate :: unistd:: Pid ;
11
5
use crate :: { Errno , Result } ;
@@ -29,10 +23,8 @@ impl ClockId {
29
23
#![ feature = "process" ]
30
24
/// Returns `ClockId` of a `pid` CPU-time clock
31
25
#[ cfg( any(
32
- target_os = "freebsd" ,
33
- target_os = "dragonfly" ,
34
- target_os = "linux" ,
35
- target_os = "android" ,
26
+ freebsdlike,
27
+ linux_android,
36
28
target_os = "emscripten" ,
37
29
) ) ]
38
30
pub fn pid_cpu_clock_id( pid: Pid ) -> Result <Self > {
@@ -62,28 +54,13 @@ impl ClockId {
62
54
self . 0
63
55
}
64
56
65
- #[ cfg( any(
66
- target_os = "android" ,
67
- target_os = "emscripten" ,
68
- target_os = "fuchsia" ,
69
- target_os = "linux"
70
- ) ) ]
57
+ #[ cfg( any( linux_android, target_os = "emscripten" , target_os = "fuchsia" ) ) ]
71
58
pub const CLOCK_BOOTTIME : ClockId = ClockId ( libc:: CLOCK_BOOTTIME ) ;
72
- #[ cfg( any(
73
- target_os = "android" ,
74
- target_os = "emscripten" ,
75
- target_os = "fuchsia" ,
76
- target_os = "linux"
77
- ) ) ]
59
+ #[ cfg( any( linux_android, target_os = "emscripten" , target_os = "fuchsia" ) ) ]
78
60
pub const CLOCK_BOOTTIME_ALARM : ClockId =
79
61
ClockId ( libc:: CLOCK_BOOTTIME_ALARM ) ;
80
62
pub const CLOCK_MONOTONIC : ClockId = ClockId ( libc:: CLOCK_MONOTONIC ) ;
81
- #[ cfg( any(
82
- target_os = "android" ,
83
- target_os = "emscripten" ,
84
- target_os = "fuchsia" ,
85
- target_os = "linux"
86
- ) ) ]
63
+ #[ cfg( any( linux_android, target_os = "emscripten" , target_os = "fuchsia" ) ) ]
87
64
pub const CLOCK_MONOTONIC_COARSE : ClockId =
88
65
ClockId ( libc:: CLOCK_MONOTONIC_COARSE ) ;
89
66
#[ cfg( freebsdlike) ]
@@ -92,42 +69,25 @@ impl ClockId {
92
69
#[ cfg( freebsdlike) ]
93
70
pub const CLOCK_MONOTONIC_PRECISE : ClockId =
94
71
ClockId ( libc:: CLOCK_MONOTONIC_PRECISE ) ;
95
- #[ cfg( any(
96
- target_os = "android" ,
97
- target_os = "emscripten" ,
98
- target_os = "fuchsia" ,
99
- target_os = "linux"
100
- ) ) ]
72
+ #[ cfg( any( linux_android, target_os = "emscripten" , target_os = "fuchsia" ) ) ]
101
73
pub const CLOCK_MONOTONIC_RAW : ClockId = ClockId ( libc:: CLOCK_MONOTONIC_RAW ) ;
102
74
#[ cfg( any(
103
- target_os = "android" ,
75
+ linux_android,
76
+ apple_targets,
77
+ freebsdlike,
104
78
target_os = "emscripten" ,
105
79
target_os = "fuchsia" ,
106
- apple_targets,
107
- target_os = "freebsd" ,
108
- target_os = "dragonfly" ,
109
80
target_os = "redox" ,
110
- target_os = "linux"
111
81
) ) ]
112
82
pub const CLOCK_PROCESS_CPUTIME_ID : ClockId =
113
83
ClockId ( libc:: CLOCK_PROCESS_CPUTIME_ID ) ;
114
84
#[ cfg( freebsdlike) ]
115
85
pub const CLOCK_PROF : ClockId = ClockId ( libc:: CLOCK_PROF ) ;
116
86
pub const CLOCK_REALTIME : ClockId = ClockId ( libc:: CLOCK_REALTIME ) ;
117
- #[ cfg( any(
118
- target_os = "android" ,
119
- target_os = "emscripten" ,
120
- target_os = "fuchsia" ,
121
- target_os = "linux"
122
- ) ) ]
87
+ #[ cfg( any( linux_android, target_os = "emscripten" , target_os = "fuchsia" ) ) ]
123
88
pub const CLOCK_REALTIME_ALARM : ClockId =
124
89
ClockId ( libc:: CLOCK_REALTIME_ALARM ) ;
125
- #[ cfg( any(
126
- target_os = "android" ,
127
- target_os = "emscripten" ,
128
- target_os = "fuchsia" ,
129
- target_os = "linux"
130
- ) ) ]
90
+ #[ cfg( any( linux_android, target_os = "emscripten" , target_os = "fuchsia" ) ) ]
131
91
pub const CLOCK_REALTIME_COARSE : ClockId =
132
92
ClockId ( libc:: CLOCK_REALTIME_COARSE ) ;
133
93
#[ cfg( freebsdlike) ]
@@ -143,21 +103,14 @@ impl ClockId {
143
103
all( target_os = "linux" , target_env = "musl" )
144
104
) ) ]
145
105
pub const CLOCK_SGI_CYCLE : ClockId = ClockId ( libc:: CLOCK_SGI_CYCLE ) ;
146
- #[ cfg( any(
147
- target_os = "android" ,
148
- target_os = "emscripten" ,
149
- target_os = "fuchsia" ,
150
- target_os = "linux"
151
- ) ) ]
106
+ #[ cfg( any( linux_android, target_os = "emscripten" , target_os = "fuchsia" ) ) ]
152
107
pub const CLOCK_TAI : ClockId = ClockId ( libc:: CLOCK_TAI ) ;
153
108
#[ cfg( any(
154
- target_os = "android" ,
109
+ linux_android,
110
+ apple_targets,
111
+ freebsdlike,
155
112
target_os = "emscripten" ,
156
113
target_os = "fuchsia" ,
157
- apple_targets,
158
- target_os = "freebsd" ,
159
- target_os = "dragonfly" ,
160
- target_os = "linux"
161
114
) ) ]
162
115
pub const CLOCK_THREAD_CPUTIME_ID : ClockId =
163
116
ClockId ( libc:: CLOCK_THREAD_CPUTIME_ID ) ;
@@ -224,13 +177,7 @@ pub fn clock_settime(clock_id: ClockId, timespec: TimeSpec) -> Result<()> {
224
177
225
178
/// Get the clock id of the specified process id, (see
226
179
/// [clock_getcpuclockid(3)](https://pubs.opengroup.org/onlinepubs/009695399/functions/clock_getcpuclockid.html)).
227
- #[ cfg( any(
228
- target_os = "freebsd" ,
229
- target_os = "dragonfly" ,
230
- target_os = "linux" ,
231
- target_os = "android" ,
232
- target_os = "emscripten" ,
233
- ) ) ]
180
+ #[ cfg( any( freebsdlike, linux_android, target_os = "emscripten" ) ) ]
234
181
#[ cfg( feature = "process" ) ]
235
182
#[ cfg_attr( docsrs, doc( cfg( feature = "process" ) ) ) ]
236
183
pub fn clock_getcpuclockid ( pid : Pid ) -> Result < ClockId > {
0 commit comments