@@ -9,9 +9,6 @@ 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;
14-
1512/// For all platforms, we use `/dev/urandom` rather than `/dev/random`.
1613/// For more information see the linked man pages in lib.rs.
1714/// - On Linux, "/dev/urandom is preferred and sufficient in all use cases".
@@ -40,13 +37,15 @@ const FD_ONGOING_INIT: libc::c_int = -2;
4037// `Ordering::Acquire` to synchronize with it.
4138static FD : AtomicI32 = AtomicI32 :: new ( FD_UNINIT ) ;
4239
40+ crate :: impl_utils!( get_errno, last_os_error, sys_fill_exact) ;
41+
4342#[ inline]
4443pub fn fill_inner ( dest : & mut [ MaybeUninit < u8 > ] ) -> Result < ( ) , Error > {
4544 let mut fd = FD . load ( Ordering :: Acquire ) ;
4645 if fd == FD_UNINIT || fd == FD_ONGOING_INIT {
4746 fd = open_or_wait ( ) ?;
4847 }
49- util_libc :: sys_fill_exact ( dest, |buf| unsafe {
48+ sys_fill_exact ( dest, |buf| unsafe {
5049 libc:: read ( fd, buf. as_mut_ptr ( ) . cast :: < c_void > ( ) , buf. len ( ) )
5150 } )
5251}
@@ -58,7 +57,7 @@ fn open_readonly(path: &CStr) -> Result<libc::c_int, Error> {
5857 if fd >= 0 {
5958 return Ok ( fd) ;
6059 }
61- let err = util_libc :: last_os_error ( ) ;
60+ let err = last_os_error ( ) ;
6261 // We should try again if open() was interrupted.
6362 if err. raw_os_error ( ) != Some ( libc:: EINTR ) {
6463 return Err ( err) ;
@@ -136,7 +135,7 @@ mod sync {
136135
137136#[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
138137mod sync {
139- use super :: { Error , FD , FD_ONGOING_INIT , open_readonly , util_libc :: last_os_error } ;
138+ use super :: { Error , FD , FD_ONGOING_INIT , last_os_error , open_readonly } ;
140139
141140 /// Wait for atomic `FD` to change value from `FD_ONGOING_INIT` to something else.
142141 ///
0 commit comments