@@ -22,7 +22,7 @@ use sys::{cvt, cvt_r};
2222pub struct AnonPipe ( FileDesc ) ;
2323
2424pub fn anon_pipe ( ) -> io:: Result < ( AnonPipe , AnonPipe ) > {
25- weak ! { fn pipe2( * mut c_int, c_int) -> c_int }
25+ syscall ! { fn pipe2( fds : * mut c_int, flags : c_int) -> c_int }
2626 static INVALID : AtomicBool = ATOMIC_BOOL_INIT ;
2727
2828 let mut fds = [ 0 ; 2 ] ;
@@ -39,22 +39,20 @@ pub fn anon_pipe() -> io::Result<(AnonPipe, AnonPipe)> {
3939 !INVALID . load ( Ordering :: SeqCst )
4040 {
4141
42- if let Some ( pipe) = pipe2. get ( ) {
43- // Note that despite calling a glibc function here we may still
44- // get ENOSYS. Glibc has `pipe2` since 2.9 and doesn't try to
45- // emulate on older kernels, so if you happen to be running on
46- // an older kernel you may see `pipe2` as a symbol but still not
47- // see the syscall.
48- match cvt ( unsafe { pipe ( fds. as_mut_ptr ( ) , libc:: O_CLOEXEC ) } ) {
49- Ok ( _) => {
50- return Ok ( ( AnonPipe ( FileDesc :: new ( fds[ 0 ] ) ) ,
51- AnonPipe ( FileDesc :: new ( fds[ 1 ] ) ) ) ) ;
52- }
53- Err ( ref e) if e. raw_os_error ( ) == Some ( libc:: ENOSYS ) => {
54- INVALID . store ( true , Ordering :: SeqCst ) ;
55- }
56- Err ( e) => return Err ( e) ,
42+ // Note that despite calling a glibc function here we may still
43+ // get ENOSYS. Glibc has `pipe2` since 2.9 and doesn't try to
44+ // emulate on older kernels, so if you happen to be running on
45+ // an older kernel you may see `pipe2` as a symbol but still not
46+ // see the syscall.
47+ match cvt ( unsafe { pipe2 ( fds. as_mut_ptr ( ) , libc:: O_CLOEXEC ) } ) {
48+ Ok ( _) => {
49+ return Ok ( ( AnonPipe ( FileDesc :: new ( fds[ 0 ] ) ) ,
50+ AnonPipe ( FileDesc :: new ( fds[ 1 ] ) ) ) ) ;
51+ }
52+ Err ( ref e) if e. raw_os_error ( ) == Some ( libc:: ENOSYS ) => {
53+ INVALID . store ( true , Ordering :: SeqCst ) ;
5754 }
55+ Err ( e) => return Err ( e) ,
5856 }
5957 }
6058 cvt ( unsafe { libc:: pipe ( fds. as_mut_ptr ( ) ) } ) ?;
0 commit comments