33use crate :: backend:: c;
44#[ cfg( any( linux_kernel, target_os = "redox" ) ) ]
55use crate :: backend:: conv:: ret_u32;
6- use crate :: backend:: conv:: { ret, ret_c_int, ret_owned_fd} ;
6+ use crate :: backend:: conv:: { borrowed_fd , ret, ret_c_int, ret_owned_fd} ;
77#[ cfg( solarish) ]
88use crate :: event:: port:: Event ;
99#[ cfg( any(
@@ -14,11 +14,14 @@ use crate::event::port::Event;
1414) ) ]
1515use crate :: event:: EventfdFlags ;
1616use crate :: event:: PollFd ;
17- use crate :: fd:: OwnedFd ;
17+ use crate :: fd:: { BorrowedFd , OwnedFd } ;
1818use crate :: io;
19+ #[ cfg( solarish) ]
1920use crate :: utils:: as_mut_ptr;
21+ #[ cfg( any( linux_kernel, target_os = "redox" ) ) ]
22+ use crate :: utils:: as_ptr;
23+ use core:: mem:: MaybeUninit ;
2024use core:: ptr:: null_mut;
21- use { crate :: backend:: conv:: borrowed_fd, crate :: fd:: BorrowedFd , core:: mem:: MaybeUninit } ;
2225#[ cfg( all( feature = "alloc" , bsd) ) ]
2326use { crate :: event:: kqueue:: Event , crate :: utils:: as_ptr, core:: ptr:: null} ;
2427
@@ -181,10 +184,10 @@ pub(crate) fn port_send(
181184
182185#[ cfg( not( any( windows, target_os = "redox" , target_os = "wasi" ) ) ) ]
183186pub ( crate ) fn pause ( ) {
184- let r = unsafe { libc :: pause ( ) } ;
187+ let r = unsafe { c :: pause ( ) } ;
185188 let errno = libc_errno:: errno ( ) . 0 ;
186189 debug_assert_eq ! ( r, -1 ) ;
187- debug_assert_eq ! ( errno, libc :: EINTR ) ;
190+ debug_assert_eq ! ( errno, c :: EINTR ) ;
188191}
189192
190193#[ inline]
@@ -198,7 +201,7 @@ pub(crate) fn epoll_create(flags: super::epoll::CreateFlags) -> io::Result<Owned
198201pub ( crate ) fn epoll_add (
199202 epoll : BorrowedFd < ' _ > ,
200203 source : BorrowedFd ,
201- event : & mut crate :: event:: epoll:: Event ,
204+ event : & crate :: event:: epoll:: Event ,
202205) -> io:: Result < ( ) > {
203206 // We use our own `Event` struct instead of libc's because
204207 // ours preserves pointer provenance instead of just using a `u64`,
@@ -208,7 +211,8 @@ pub(crate) fn epoll_add(
208211 borrowed_fd ( epoll) ,
209212 c:: EPOLL_CTL_ADD ,
210213 borrowed_fd ( source) ,
211- as_mut_ptr ( event) . cast ( ) ,
214+ // The event is read-only even though libc has a non-const pointer.
215+ as_ptr ( event) as * mut c:: epoll_event ,
212216 ) )
213217 }
214218}
@@ -218,14 +222,15 @@ pub(crate) fn epoll_add(
218222pub ( crate ) fn epoll_mod (
219223 epoll : BorrowedFd < ' _ > ,
220224 source : BorrowedFd ,
221- event : & mut crate :: event:: epoll:: Event ,
225+ event : & crate :: event:: epoll:: Event ,
222226) -> io:: Result < ( ) > {
223227 unsafe {
224228 ret ( c:: epoll_ctl (
225229 borrowed_fd ( epoll) ,
226230 c:: EPOLL_CTL_MOD ,
227231 borrowed_fd ( source) ,
228- as_mut_ptr ( event) . cast ( ) ,
232+ // The event is read-only even though libc has a non-const pointer.
233+ as_ptr ( event) as * mut c:: epoll_event ,
229234 ) )
230235 }
231236}
0 commit comments