@@ -81,6 +81,11 @@ use libc::{self, c_int};
81
81
82
82
use crate :: SigId ;
83
83
84
+ #[ cfg( target_os = "aix" ) ]
85
+ const MSG_NOWAIT : i32 = libc:: MSG_NONBLOCK ;
86
+ #[ cfg( not( target_os = "aix" ) ) ]
87
+ const MSG_NOWAIT : i32 = libc:: MSG_DONTWAIT ;
88
+
84
89
#[ derive( Copy , Clone ) ]
85
90
pub ( crate ) enum WakeMethod {
86
91
Send ,
@@ -141,10 +146,7 @@ pub(crate) fn wake(pipe: RawFd, method: WakeMethod) {
141
146
let data = b"X" as * const _ as * const _ ;
142
147
match method {
143
148
WakeMethod :: Write => libc:: write ( pipe, data, 1 ) ,
144
- #[ cfg( target_os = "aix" ) ]
145
- WakeMethod :: Send => libc:: send ( pipe, data, 1 , libc:: MSG_NONBLOCK ) ,
146
- #[ cfg( not( target_os = "aix" ) ) ]
147
- WakeMethod :: Send => libc:: send ( pipe, data, 1 , libc:: MSG_DONTWAIT ) ,
149
+ WakeMethod :: Send => libc:: send ( pipe, data, 1 , MSG_NOWAIT ) ,
148
150
} ;
149
151
}
150
152
}
@@ -173,10 +175,7 @@ pub(crate) fn wake(pipe: RawFd, method: WakeMethod) {
173
175
/// * If it is not possible, the [`O_NONBLOCK`][libc::O_NONBLOCK] will be set on the file
174
176
/// descriptor and [`write`][libc::write] will be used instead.
175
177
pub fn register_raw ( signal : c_int , pipe : RawFd ) -> Result < SigId , Error > {
176
- #[ cfg( not( target_os = "aix" ) ) ]
177
- let res = unsafe { libc:: send ( pipe, & [ ] as * const _ , 0 , libc:: MSG_DONTWAIT ) } ;
178
- #[ cfg( target_os = "aix" ) ]
179
- let res = unsafe { libc:: send ( pipe, & [ ] as * const _ , 0 , libc:: MSG_NONBLOCK ) } ;
178
+ let res = unsafe { libc:: send ( pipe, & [ ] as * const _ , 0 , MSG_NOWAIT ) } ;
180
179
let fd = match ( res, Error :: last_os_error ( ) . kind ( ) ) {
181
180
( 0 , _) | ( -1 , ErrorKind :: WouldBlock ) => WakeFd {
182
181
fd : pipe,
0 commit comments