@@ -9,8 +9,8 @@ use core::{
99#[ cfg( not( any( target_os = "android" , target_os = "linux" ) ) ) ]
1010pub use crate :: util:: { inner_u32, inner_u64} ;
1111
12- #[ path = "../util_libc .rs" ]
13- pub ( super ) mod util_libc ;
12+ #[ path = "../utils/sys_fill_exact .rs" ]
13+ pub ( super ) mod utils ;
1414
1515/// For all platforms, we use `/dev/urandom` rather than `/dev/random`.
1616/// For more information see the linked man pages in lib.rs.
@@ -46,7 +46,7 @@ pub fn fill_inner(dest: &mut [MaybeUninit<u8>]) -> Result<(), Error> {
4646 if fd == FD_UNINIT || fd == FD_ONGOING_INIT {
4747 fd = open_or_wait ( ) ?;
4848 }
49- util_libc :: sys_fill_exact ( dest, |buf| unsafe {
49+ utils :: sys_fill_exact ( dest, |buf| unsafe {
5050 libc:: read ( fd, buf. as_mut_ptr ( ) . cast :: < c_void > ( ) , buf. len ( ) )
5151 } )
5252}
@@ -58,10 +58,10 @@ fn open_readonly(path: &CStr) -> Result<libc::c_int, Error> {
5858 if fd >= 0 {
5959 return Ok ( fd) ;
6060 }
61- let err = util_libc :: last_os_error ( ) ;
61+ let errno = utils :: get_errno ( ) ;
6262 // We should try again if open() was interrupted.
63- if err . raw_os_error ( ) != Some ( libc:: EINTR ) {
64- return Err ( err ) ;
63+ if errno != libc:: EINTR {
64+ return Err ( Error :: from_errno ( errno ) ) ;
6565 }
6666 }
6767}
@@ -136,7 +136,7 @@ mod sync {
136136
137137#[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
138138mod sync {
139- use super :: { Error , FD , FD_ONGOING_INIT , open_readonly, util_libc :: last_os_error } ;
139+ use super :: { Error , FD , FD_ONGOING_INIT , open_readonly, utils } ;
140140
141141 /// Wait for atomic `FD` to change value from `FD_ONGOING_INIT` to something else.
142142 ///
@@ -152,7 +152,7 @@ mod sync {
152152 debug_assert ! ( {
153153 match ret {
154154 0 => true ,
155- -1 => last_os_error ( ) . raw_os_error ( ) == Some ( libc:: EAGAIN ) ,
155+ -1 => utils :: get_errno ( ) == libc:: EAGAIN ,
156156 _ => false ,
157157 }
158158 } ) ;
@@ -209,12 +209,12 @@ mod sync {
209209 debug_assert_eq ! ( res, 1 ) ;
210210 break Ok ( ( ) ) ;
211211 }
212- let err = last_os_error ( ) ;
212+ let errno = utils :: get_errno ( ) ;
213213 // Assuming that `poll` is called correctly,
214214 // on Linux it can return only EINTR and ENOMEM errors.
215- match err . raw_os_error ( ) {
216- Some ( libc:: EINTR ) => continue ,
217- _ => break Err ( err ) ,
215+ match errno {
216+ libc:: EINTR => continue ,
217+ _ => break Err ( Error :: from_errno ( errno ) ) ,
218218 }
219219 } ;
220220 unsafe { libc:: close ( fd) } ;
0 commit comments