@@ -4,7 +4,6 @@ use crate::backend::c;
44#[ cfg( any( linux_kernel, solarish, target_os = "redox" ) ) ]
55use crate :: backend:: conv:: ret;
66use crate :: backend:: conv:: ret_c_int;
7- #[ cfg( feature = "alloc" ) ]
87#[ cfg( any( linux_kernel, target_os = "illumos" , target_os = "redox" ) ) ]
98use crate :: backend:: conv:: ret_u32;
109#[ cfg( solarish) ]
@@ -24,11 +23,7 @@ use crate::io;
2423use crate :: utils:: as_mut_ptr;
2524#[ cfg( any( linux_kernel, target_os = "illumos" , target_os = "redox" ) ) ]
2625use crate :: utils:: as_ptr;
27- #[ cfg( any(
28- all( feature = "alloc" , bsd) ,
29- solarish,
30- all( feature = "alloc" , any( linux_kernel, target_os = "redox" ) ) ,
31- ) ) ]
26+ #[ cfg( solarish) ]
3227use core:: mem:: MaybeUninit ;
3328#[ cfg( any(
3429 bsd,
@@ -107,7 +102,7 @@ pub(crate) fn kqueue() -> io::Result<OwnedFd> {
107102pub ( crate ) unsafe fn kevent (
108103 kq : BorrowedFd < ' _ > ,
109104 changelist : & [ Event ] ,
110- eventlist : & mut [ MaybeUninit < Event > ] ,
105+ eventlist : ( * mut Event , usize ) ,
111106 timeout : Option < & c:: timespec > ,
112107) -> io:: Result < c:: c_int > {
113108 ret_c_int ( c:: kevent (
@@ -117,11 +112,8 @@ pub(crate) unsafe fn kevent(
117112 . len ( )
118113 . try_into ( )
119114 . map_err ( |_| io:: Errno :: OVERFLOW ) ?,
120- eventlist. as_mut_ptr ( ) . cast ( ) ,
121- eventlist
122- . len ( )
123- . try_into ( )
124- . map_err ( |_| io:: Errno :: OVERFLOW ) ?,
115+ eventlist. 0 . cast ( ) ,
116+ eventlist. 1 . try_into ( ) . map_err ( |_| io:: Errno :: OVERFLOW ) ?,
125117 timeout. map_or ( null ( ) , as_ptr) ,
126118 ) )
127119}
@@ -512,11 +504,10 @@ pub(crate) fn epoll_del(epoll: BorrowedFd<'_>, source: BorrowedFd<'_>) -> io::Re
512504}
513505
514506#[ inline]
515- #[ cfg( feature = "alloc" ) ]
516507#[ cfg( any( linux_kernel, target_os = "illumos" , target_os = "redox" ) ) ]
517- pub ( crate ) fn epoll_wait (
508+ pub ( crate ) unsafe fn epoll_wait (
518509 epoll : BorrowedFd < ' _ > ,
519- events : & mut [ MaybeUninit < crate :: event:: epoll:: Event > ] ,
510+ events : ( * mut crate :: event:: epoll:: Event , usize ) ,
520511 timeout : Option < & Timespec > ,
521512) -> io:: Result < usize > {
522513 // If we're on Linux >= 5.11 and a libc that has an `epoll_pwait2`
@@ -527,7 +518,7 @@ pub(crate) fn epoll_wait(
527518 target_env = "gnu" ,
528519 not( fix_y2038)
529520 ) ) ]
530- unsafe {
521+ {
531522 weak ! {
532523 fn epoll_pwait2(
533524 c:: c_int,
@@ -541,8 +532,8 @@ pub(crate) fn epoll_wait(
541532 if let Some ( epoll_pwait2_func) = epoll_pwait2. get ( ) {
542533 return ret_u32 ( epoll_pwait2_func (
543534 borrowed_fd ( epoll) ,
544- events. as_mut_ptr ( ) . cast :: < c:: epoll_event > ( ) ,
545- events. len ( ) . try_into ( ) . unwrap_or ( i32:: MAX ) ,
535+ events. 0 . cast :: < c:: epoll_event > ( ) ,
536+ events. 1 . try_into ( ) . unwrap_or ( i32:: MAX ) ,
546537 crate :: utils:: option_as_ptr ( timeout) . cast ( ) ,
547538 null ( ) ,
548539 ) )
@@ -552,7 +543,7 @@ pub(crate) fn epoll_wait(
552543
553544 // If we're on Linux >= 5.11, use `epoll_pwait2` via `libc::syscall`.
554545 #[ cfg( all( linux_kernel, feature = "linux_5_11" ) ) ]
555- unsafe {
546+ {
556547 use linux_raw_sys:: general:: __kernel_timespec as timespec;
557548
558549 syscall ! {
@@ -567,8 +558,8 @@ pub(crate) fn epoll_wait(
567558
568559 ret_u32 ( epoll_pwait2 (
569560 borrowed_fd ( epoll) ,
570- events. as_mut_ptr ( ) . cast :: < c:: epoll_event > ( ) ,
571- events. len ( ) . try_into ( ) . unwrap_or ( i32:: MAX ) ,
561+ events. 0 . cast :: < c:: epoll_event > ( ) ,
562+ events. 1 . try_into ( ) . unwrap_or ( i32:: MAX ) ,
572563 crate :: utils:: option_as_ptr ( timeout) . cast ( ) ,
573564 null ( ) ,
574565 ) )
@@ -577,16 +568,16 @@ pub(crate) fn epoll_wait(
577568
578569 // Otherwise just use `epoll_wait`.
579570 #[ cfg( not( all( linux_kernel, feature = "linux_5_11" ) ) ) ]
580- unsafe {
571+ {
581572 let timeout = match timeout {
582573 None => -1 ,
583574 Some ( timeout) => timeout. as_c_int_millis ( ) . ok_or ( io:: Errno :: INVAL ) ?,
584575 } ;
585576
586577 ret_u32 ( c:: epoll_wait (
587578 borrowed_fd ( epoll) ,
588- events. as_mut_ptr ( ) . cast :: < c:: epoll_event > ( ) ,
589- events. len ( ) . try_into ( ) . unwrap_or ( i32:: MAX ) ,
579+ events. 0 . cast :: < c:: epoll_event > ( ) ,
580+ events. 1 . try_into ( ) . unwrap_or ( i32:: MAX ) ,
590581 timeout,
591582 ) )
592583 . map ( |i| i as usize )
0 commit comments