@@ -9,7 +9,7 @@ use cfg_if::cfg_if;
9
9
use std:: fmt;
10
10
use std:: mem;
11
11
#[ cfg( any( target_os = "dragonfly" , target_os = "freebsd" ) ) ]
12
- use std:: os:: unix:: io:: RawFd ;
12
+ use std:: os:: unix:: io:: BorrowedFd ;
13
13
use std:: ptr;
14
14
use std:: str:: FromStr ;
15
15
@@ -980,8 +980,8 @@ pub type type_of_thread_id = libc::pid_t;
980
980
// as a pointer, because neither libc nor the kernel ever dereference it. nix
981
981
// therefore presents it as an intptr_t, which is how kevent uses it.
982
982
#[ cfg( not( any( target_os = "openbsd" , target_os = "redox" ) ) ) ]
983
- #[ derive( Clone , Copy , Debug , Eq , Hash , PartialEq ) ]
984
- pub enum SigevNotify {
983
+ #[ derive( Clone , Copy , Debug ) ]
984
+ pub enum SigevNotify < ' fd> {
985
985
/// No notification will be delivered
986
986
SigevNone ,
987
987
/// Notify by delivering a signal to the process.
@@ -999,7 +999,7 @@ pub enum SigevNotify {
999
999
#[ cfg_attr( docsrs, doc( cfg( all( ) ) ) ) ]
1000
1000
SigevKevent {
1001
1001
/// File descriptor of the kqueue to notify.
1002
- kq: RawFd ,
1002
+ kq: BorrowedFd < ' fd> ,
1003
1003
/// Will be contained in the kevent's `udata` field.
1004
1004
udata: libc:: intptr_t
1005
1005
} ,
@@ -1015,6 +1015,10 @@ pub enum SigevNotify {
1015
1015
/// structure of the queued signal.
1016
1016
si_value: libc:: intptr_t
1017
1017
} ,
1018
+ /// A helper variant to resolve the unused parameter (`'fd`) problem on platforms
1019
+ /// other than FreeBSD and DragonFly.
1020
+ #[ doc( hidden) ]
1021
+ _Unreachable( std:: marker:: PhantomData <& ' fd std:: convert:: Infallible >) ,
1018
1022
}
1019
1023
}
1020
1024
@@ -1029,6 +1033,8 @@ mod sigevent {
1029
1033
use super :: SigevNotify ;
1030
1034
#[ cfg( any( target_os = "freebsd" , target_os = "linux" ) ) ]
1031
1035
use super :: type_of_thread_id;
1036
+ #[ cfg( any( target_os = "freebsd" , target_os = "dragonfly" ) ) ]
1037
+ use std:: os:: unix:: io:: AsRawFd ;
1032
1038
1033
1039
/// Used to request asynchronous notification of the completion of certain
1034
1040
/// events, such as POSIX AIO and timers.
@@ -1069,12 +1075,13 @@ mod sigevent {
1069
1075
#[ cfg( all( target_os = "linux" , target_env = "uclibc" ) ) ]
1070
1076
SigevNotify :: SigevThreadId { ..} => libc:: SIGEV_THREAD_ID ,
1071
1077
#[ cfg( any( all( target_os = "linux" , target_env = "musl" ) , target_arch = "mips" ) ) ]
1072
- SigevNotify :: SigevThreadId { ..} => 4 // No SIGEV_THREAD_ID defined
1078
+ SigevNotify :: SigevThreadId { ..} => 4 , // No SIGEV_THREAD_ID defined
1079
+ SigevNotify :: _Unreachable( _) => unreachable!( "This variant could never be constructed" )
1073
1080
} ;
1074
1081
sev. sigev_signo = match sigev_notify {
1075
1082
SigevNotify :: SigevSignal { signal, .. } => signal as libc:: c_int,
1076
1083
#[ cfg( any( target_os = "dragonfly" , target_os = "freebsd" ) ) ]
1077
- SigevNotify :: SigevKevent { kq, ..} => kq,
1084
+ SigevNotify :: SigevKevent { kq, ..} => kq. as_raw_fd ( ) ,
1078
1085
#[ cfg( any( target_os = "linux" , target_os = "freebsd" ) ) ]
1079
1086
SigevNotify :: SigevThreadId { signal, .. } => signal as libc:: c_int,
1080
1087
_ => 0
@@ -1086,6 +1093,7 @@ mod sigevent {
1086
1093
SigevNotify :: SigevKevent { udata, .. } => udata as * mut libc:: c_void,
1087
1094
#[ cfg( any( target_os = "freebsd" , target_os = "linux" ) ) ]
1088
1095
SigevNotify :: SigevThreadId { si_value, .. } => si_value as * mut libc:: c_void,
1096
+ SigevNotify :: _Unreachable( _) => unreachable!( "This variant could never be constructed" )
1089
1097
} ;
1090
1098
SigEvent :: set_tid( & mut sev, & sigev_notify) ;
1091
1099
SigEvent { sigevent: sev}
0 commit comments