4
4
5
5
use crate :: fs;
6
6
use crate :: io;
7
+ #[ cfg( target_os = "hermit" ) ]
8
+ use crate :: os:: hermit:: io:: OwnedFd ;
9
+ #[ cfg( not( target_os = "hermit" ) ) ]
7
10
use crate :: os:: raw;
8
11
#[ cfg( all( doc, not( target_arch = "wasm32" ) ) ) ]
9
12
use crate :: os:: unix:: io:: AsFd ;
@@ -12,11 +15,20 @@ use crate::os::unix::io::OwnedFd;
12
15
#[ cfg( target_os = "wasi" ) ]
13
16
use crate :: os:: wasi:: io:: OwnedFd ;
14
17
use crate :: sys_common:: { AsInner , IntoInner } ;
18
+ #[ cfg( target_os = "hermit" ) ]
19
+ use hermit_abi:: { STDERR_FILENO , STDIN_FILENO , STDOUT_FILENO } ;
20
+ #[ cfg( not( target_os = "hermit" ) ) ]
21
+ use libc:: { STDERR_FILENO , STDIN_FILENO , STDOUT_FILENO } ;
15
22
16
23
/// Raw file descriptors.
17
24
#[ rustc_allowed_through_unstable_modules]
18
25
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
26
+ #[ cfg( not( target_os = "hermit" ) ) ]
19
27
pub type RawFd = raw:: c_int ;
28
+ #[ rustc_allowed_through_unstable_modules]
29
+ #[ stable( feature = "rust1" , since = "1.0.0" ) ]
30
+ #[ cfg( target_os = "hermit" ) ]
31
+ pub type RawFd = i32 ;
20
32
21
33
/// A trait to extract the raw file descriptor from an underlying object.
22
34
///
@@ -177,47 +189,47 @@ impl IntoRawFd for fs::File {
177
189
impl AsRawFd for io:: Stdin {
178
190
#[ inline]
179
191
fn as_raw_fd ( & self ) -> RawFd {
180
- libc :: STDIN_FILENO
192
+ STDIN_FILENO
181
193
}
182
194
}
183
195
184
196
#[ stable( feature = "asraw_stdio" , since = "1.21.0" ) ]
185
197
impl AsRawFd for io:: Stdout {
186
198
#[ inline]
187
199
fn as_raw_fd ( & self ) -> RawFd {
188
- libc :: STDOUT_FILENO
200
+ STDOUT_FILENO
189
201
}
190
202
}
191
203
192
204
#[ stable( feature = "asraw_stdio" , since = "1.21.0" ) ]
193
205
impl AsRawFd for io:: Stderr {
194
206
#[ inline]
195
207
fn as_raw_fd ( & self ) -> RawFd {
196
- libc :: STDERR_FILENO
208
+ STDERR_FILENO
197
209
}
198
210
}
199
211
200
212
#[ stable( feature = "asraw_stdio_locks" , since = "1.35.0" ) ]
201
213
impl < ' a > AsRawFd for io:: StdinLock < ' a > {
202
214
#[ inline]
203
215
fn as_raw_fd ( & self ) -> RawFd {
204
- libc :: STDIN_FILENO
216
+ STDIN_FILENO
205
217
}
206
218
}
207
219
208
220
#[ stable( feature = "asraw_stdio_locks" , since = "1.35.0" ) ]
209
221
impl < ' a > AsRawFd for io:: StdoutLock < ' a > {
210
222
#[ inline]
211
223
fn as_raw_fd ( & self ) -> RawFd {
212
- libc :: STDOUT_FILENO
224
+ STDOUT_FILENO
213
225
}
214
226
}
215
227
216
228
#[ stable( feature = "asraw_stdio_locks" , since = "1.35.0" ) ]
217
229
impl < ' a > AsRawFd for io:: StderrLock < ' a > {
218
230
#[ inline]
219
231
fn as_raw_fd ( & self ) -> RawFd {
220
- libc :: STDERR_FILENO
232
+ STDERR_FILENO
221
233
}
222
234
}
223
235
0 commit comments