@@ -13,7 +13,6 @@ use io;
13
13
use libc:: { self , c_int} ;
14
14
use mem;
15
15
use ptr;
16
- use sync:: atomic:: { AtomicBool , Ordering } ;
17
16
use sys:: { cvt, cvt_r} ;
18
17
use sys:: fd:: FileDesc ;
19
18
@@ -30,21 +29,17 @@ pub fn anon_pipe() -> io::Result<(AnonPipe, AnonPipe)> {
30
29
// CLOEXEC flag is to use the `pipe2` syscall on Linux. This was added in
31
30
// 2.6.27, however, and because we support 2.6.18 we must detect this
32
31
// support dynamically.
33
- static TRY_PIPE2 : AtomicBool = AtomicBool :: new ( cfg ! ( target_os = "linux" ) ) ;
34
- if TRY_PIPE2 . load ( Ordering :: Relaxed ) {
32
+ if cfg ! ( any( target_os = "dragonfly" ,
33
+ target_os = "freebsd" ,
34
+ target_os = "linux" ,
35
+ target_os = "netbsd" ,
36
+ target_os = "openbsd" ) )
37
+ {
35
38
weak ! { fn pipe2( * mut c_int, c_int) -> c_int }
36
39
if let Some ( pipe) = pipe2. get ( ) {
37
- match cvt ( unsafe { pipe ( fds. as_mut_ptr ( ) , libc:: O_CLOEXEC ) } ) {
38
- Err ( ref e) if e. raw_os_error ( ) == Some ( libc:: ENOSYS ) => {
39
- TRY_PIPE2 . store ( false , Ordering :: Relaxed ) ;
40
- // Fall through
41
- } ,
42
- res => {
43
- res?;
44
- return Ok ( ( AnonPipe ( FileDesc :: new ( fds[ 0 ] ) ) ,
45
- AnonPipe ( FileDesc :: new ( fds[ 1 ] ) ) ) ) ;
46
- }
47
- }
40
+ cvt ( unsafe { pipe ( fds. as_mut_ptr ( ) , libc:: O_CLOEXEC ) } ) ?;
41
+ return Ok ( ( AnonPipe ( FileDesc :: new ( fds[ 0 ] ) ) ,
42
+ AnonPipe ( FileDesc :: new ( fds[ 1 ] ) ) ) ) ;
48
43
}
49
44
}
50
45
cvt ( unsafe { libc:: pipe ( fds. as_mut_ptr ( ) ) } ) ?;
0 commit comments