44
55use crate :: fs;
66use crate :: io;
7+ #[ cfg( target_os = "hermit" ) ]
8+ use crate :: os:: hermit:: io:: OwnedFd ;
9+ #[ cfg( not( target_os = "hermit" ) ) ]
710use crate :: os:: raw;
811#[ cfg( all( doc, not( target_arch = "wasm32" ) ) ) ]
912use crate :: os:: unix:: io:: AsFd ;
@@ -12,11 +15,20 @@ use crate::os::unix::io::OwnedFd;
1215#[ cfg( target_os = "wasi" ) ]
1316use crate :: os:: wasi:: io:: OwnedFd ;
1417use 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 } ;
1522
1623/// Raw file descriptors.
1724#[ rustc_allowed_through_unstable_modules]
1825#[ stable( feature = "rust1" , since = "1.0.0" ) ]
26+ #[ cfg( not( target_os = "hermit" ) ) ]
1927pub 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 ;
2032
2133/// A trait to extract the raw file descriptor from an underlying object.
2234///
@@ -177,47 +189,47 @@ impl IntoRawFd for fs::File {
177189impl AsRawFd for io:: Stdin {
178190 #[ inline]
179191 fn as_raw_fd ( & self ) -> RawFd {
180- libc :: STDIN_FILENO
192+ STDIN_FILENO
181193 }
182194}
183195
184196#[ stable( feature = "asraw_stdio" , since = "1.21.0" ) ]
185197impl AsRawFd for io:: Stdout {
186198 #[ inline]
187199 fn as_raw_fd ( & self ) -> RawFd {
188- libc :: STDOUT_FILENO
200+ STDOUT_FILENO
189201 }
190202}
191203
192204#[ stable( feature = "asraw_stdio" , since = "1.21.0" ) ]
193205impl AsRawFd for io:: Stderr {
194206 #[ inline]
195207 fn as_raw_fd ( & self ) -> RawFd {
196- libc :: STDERR_FILENO
208+ STDERR_FILENO
197209 }
198210}
199211
200212#[ stable( feature = "asraw_stdio_locks" , since = "1.35.0" ) ]
201213impl < ' a > AsRawFd for io:: StdinLock < ' a > {
202214 #[ inline]
203215 fn as_raw_fd ( & self ) -> RawFd {
204- libc :: STDIN_FILENO
216+ STDIN_FILENO
205217 }
206218}
207219
208220#[ stable( feature = "asraw_stdio_locks" , since = "1.35.0" ) ]
209221impl < ' a > AsRawFd for io:: StdoutLock < ' a > {
210222 #[ inline]
211223 fn as_raw_fd ( & self ) -> RawFd {
212- libc :: STDOUT_FILENO
224+ STDOUT_FILENO
213225 }
214226}
215227
216228#[ stable( feature = "asraw_stdio_locks" , since = "1.35.0" ) ]
217229impl < ' a > AsRawFd for io:: StderrLock < ' a > {
218230 #[ inline]
219231 fn as_raw_fd ( & self ) -> RawFd {
220- libc :: STDERR_FILENO
232+ STDERR_FILENO
221233 }
222234}
223235
0 commit comments