@@ -4,7 +4,6 @@ use crate::backend::c;
4
4
#[ cfg( any( linux_kernel, solarish, target_os = "redox" ) ) ]
5
5
use crate :: backend:: conv:: ret;
6
6
use crate :: backend:: conv:: ret_c_int;
7
- #[ cfg( feature = "alloc" ) ]
8
7
#[ cfg( any( linux_kernel, target_os = "illumos" , target_os = "redox" ) ) ]
9
8
use crate :: backend:: conv:: ret_u32;
10
9
#[ cfg( solarish) ]
@@ -24,11 +23,7 @@ use crate::io;
24
23
use crate :: utils:: as_mut_ptr;
25
24
#[ cfg( any( linux_kernel, target_os = "illumos" , target_os = "redox" ) ) ]
26
25
use 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) ]
32
27
use core:: mem:: MaybeUninit ;
33
28
#[ cfg( any(
34
29
bsd,
@@ -107,7 +102,7 @@ pub(crate) fn kqueue() -> io::Result<OwnedFd> {
107
102
pub ( crate ) unsafe fn kevent (
108
103
kq : BorrowedFd < ' _ > ,
109
104
changelist : & [ Event ] ,
110
- eventlist : & mut [ MaybeUninit < Event > ] ,
105
+ eventlist : ( * mut Event , usize ) ,
111
106
timeout : Option < & c:: timespec > ,
112
107
) -> io:: Result < c:: c_int > {
113
108
ret_c_int ( c:: kevent (
@@ -117,11 +112,8 @@ pub(crate) unsafe fn kevent(
117
112
. len ( )
118
113
. try_into ( )
119
114
. 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 ) ?,
125
117
timeout. map_or ( null ( ) , as_ptr) ,
126
118
) )
127
119
}
@@ -512,11 +504,10 @@ pub(crate) fn epoll_del(epoll: BorrowedFd<'_>, source: BorrowedFd<'_>) -> io::Re
512
504
}
513
505
514
506
#[ inline]
515
- #[ cfg( feature = "alloc" ) ]
516
507
#[ cfg( any( linux_kernel, target_os = "illumos" , target_os = "redox" ) ) ]
517
- pub ( crate ) fn epoll_wait (
508
+ pub ( crate ) unsafe fn epoll_wait (
518
509
epoll : BorrowedFd < ' _ > ,
519
- events : & mut [ MaybeUninit < crate :: event:: epoll:: Event > ] ,
510
+ events : ( * mut crate :: event:: epoll:: Event , usize ) ,
520
511
timeout : Option < & Timespec > ,
521
512
) -> io:: Result < usize > {
522
513
// If we're on Linux >= 5.11 and a libc that has an `epoll_pwait2`
@@ -527,7 +518,7 @@ pub(crate) fn epoll_wait(
527
518
target_env = "gnu" ,
528
519
not( fix_y2038)
529
520
) ) ]
530
- unsafe {
521
+ {
531
522
weak ! {
532
523
fn epoll_pwait2(
533
524
c:: c_int,
@@ -541,8 +532,8 @@ pub(crate) fn epoll_wait(
541
532
if let Some ( epoll_pwait2_func) = epoll_pwait2. get ( ) {
542
533
return ret_u32 ( epoll_pwait2_func (
543
534
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 ) ,
546
537
crate :: utils:: option_as_ptr ( timeout) . cast ( ) ,
547
538
null ( ) ,
548
539
) )
@@ -552,7 +543,7 @@ pub(crate) fn epoll_wait(
552
543
553
544
// If we're on Linux >= 5.11, use `epoll_pwait2` via `libc::syscall`.
554
545
#[ cfg( all( linux_kernel, feature = "linux_5_11" ) ) ]
555
- unsafe {
546
+ {
556
547
use linux_raw_sys:: general:: __kernel_timespec as timespec;
557
548
558
549
syscall ! {
@@ -567,8 +558,8 @@ pub(crate) fn epoll_wait(
567
558
568
559
ret_u32 ( epoll_pwait2 (
569
560
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 ) ,
572
563
crate :: utils:: option_as_ptr ( timeout) . cast ( ) ,
573
564
null ( ) ,
574
565
) )
@@ -577,16 +568,16 @@ pub(crate) fn epoll_wait(
577
568
578
569
// Otherwise just use `epoll_wait`.
579
570
#[ cfg( not( all( linux_kernel, feature = "linux_5_11" ) ) ) ]
580
- unsafe {
571
+ {
581
572
let timeout = match timeout {
582
573
None => -1 ,
583
574
Some ( timeout) => timeout. as_c_int_millis ( ) . ok_or ( io:: Errno :: INVAL ) ?,
584
575
} ;
585
576
586
577
ret_u32 ( c:: epoll_wait (
587
578
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 ) ,
590
581
timeout,
591
582
) )
592
583
. map ( |i| i as usize )
0 commit comments