@@ -22,11 +22,7 @@ use std::os::unix::io::RawFd;
2222 all( target_os = "freebsd" , target_arch = "x86_64" ) ,
2323) ) ]
2424use std:: path:: PathBuf ;
25- #[ cfg( any(
26- target_os = "android" ,
27- target_os = "freebsd" ,
28- target_os = "linux"
29- ) ) ]
25+ #[ cfg( any( linux_android, target_os = "freebsd" ) ) ]
3026use std:: {
3127 os:: unix:: io:: { AsFd , AsRawFd } ,
3228 ptr,
@@ -36,8 +32,7 @@ use std::{
3632use crate :: { sys:: stat:: Mode , NixPath , Result } ;
3733
3834#[ cfg( any(
39- target_os = "linux" ,
40- target_os = "android" ,
35+ linux_android,
4136 target_os = "emscripten" ,
4237 target_os = "fuchsia" ,
4338 target_os = "wasi" ,
@@ -81,10 +76,11 @@ libc_bitflags!(
8176 /// Open the file in append-only mode.
8277 O_APPEND ;
8378 /// Generate a signal when input or output becomes possible.
84- #[ cfg( not( any( target_os = "aix" ,
85- target_os = "illumos" ,
86- target_os = "solaris" ,
87- target_os = "haiku" ) ) ) ]
79+ #[ cfg( not( any(
80+ solarish,
81+ target_os = "aix" ,
82+ target_os = "haiku"
83+ ) ) ) ]
8884 O_ASYNC ;
8985 /// Closes the file descriptor once an `execve` call is made.
9086 ///
@@ -93,19 +89,18 @@ libc_bitflags!(
9389 /// Create the file if it does not exist.
9490 O_CREAT ;
9591 /// Try to minimize cache effects of the I/O for this file.
96- #[ cfg( any( target_os = "android" ,
97- target_os = "dragonfly" ,
98- target_os = "freebsd" ,
99- target_os = "linux" ,
100- target_os = "netbsd" ) ) ]
92+ #[ cfg( any(
93+ freebsdlike ,
94+ linux_android ,
95+ target_os = "netbsd"
96+ ) ) ]
10197 O_DIRECT ;
10298 /// If the specified path isn't a directory, fail.
10399 #[ cfg( not( solarish) ) ]
104100 O_DIRECTORY ;
105101 /// Implicitly follow each `write()` with an `fdatasync()`.
106- #[ cfg( any( target_os = "android" ,
102+ #[ cfg( any( linux_android ,
107103 apple_targets,
108- target_os = "linux" ,
109104 target_os = "netbsd" ,
110105 target_os = "openbsd" ) ) ]
111106 O_DSYNC ;
@@ -144,7 +139,7 @@ libc_bitflags!(
144139 /// Obtain a file descriptor for low-level access.
145140 ///
146141 /// The file itself is not opened and other file operations will fail.
147- #[ cfg( any( target_os = "android" , target_os = "linux" , target_os = "redox" ) ) ]
142+ #[ cfg( any( linux_android , target_os = "redox" ) ) ]
148143 O_PATH ;
149144 /// Only allow reading.
150145 ///
@@ -184,7 +179,7 @@ libc_bitflags!(
184179/// Computes the raw fd consumed by a function of the form `*at`.
185180#[ cfg( any(
186181 all( feature = "fs" , not( target_os = "redox" ) ) ,
187- all( feature = "process" , any ( target_os = "android" , target_os = "linux" ) ) ,
182+ all( feature = "process" , linux_android ) ,
188183 all( feature = "fanotify" , target_os = "linux" )
189184) ) ]
190185pub ( crate ) fn at_rawfd ( fd : Option < RawFd > ) -> raw:: c_int {
@@ -346,8 +341,7 @@ fn inner_readlink<P: ?Sized + NixPath>(
346341 )
347342 }
348343 #[ cfg( not( any(
349- target_os = "android" ,
350- target_os = "linux" ,
344+ linux_android,
351345 target_os = "redox"
352346 ) ) ) ]
353347 Some ( dirfd) => super :: sys:: stat:: fstatat(
@@ -406,7 +400,7 @@ pub fn readlinkat<P: ?Sized + NixPath>(
406400}
407401}
408402
409- #[ cfg( any( target_os = "android" , target_os = "linux" , target_os = "freebsd" ) ) ]
403+ #[ cfg( any( linux_android , target_os = "freebsd" ) ) ]
410404#[ cfg( feature = "fs" ) ]
411405libc_bitflags ! (
412406 /// Additional flags for file sealing, which allows for limiting operations on a file.
@@ -460,14 +454,12 @@ pub enum FcntlArg<'a> {
460454 #[ cfg( linux_android) ]
461455 F_OFD_GETLK ( & ' a mut libc:: flock) ,
462456 #[ cfg( any(
463- target_os = "android" ,
464- target_os = "linux" ,
457+ linux_android,
465458 target_os = "freebsd"
466459 ) ) ]
467460 F_ADD_SEALS ( SealFlag ) ,
468461 #[ cfg( any(
469- target_os = "android" ,
470- target_os = "linux" ,
462+ linux_android,
471463 target_os = "freebsd"
472464 ) ) ]
473465 F_GET_SEALS ,
@@ -530,16 +522,14 @@ pub fn fcntl(fd: RawFd, arg: FcntlArg) -> Result<c_int> {
530522 #[ cfg( linux_android) ]
531523 F_OFD_GETLK ( flock) => libc:: fcntl( fd, libc:: F_OFD_GETLK , flock) ,
532524 #[ cfg( any(
533- target_os = "android" ,
534- target_os = "linux" ,
525+ linux_android,
535526 target_os = "freebsd"
536527 ) ) ]
537528 F_ADD_SEALS ( flag) => {
538529 libc:: fcntl( fd, libc:: F_ADD_SEALS , flag. bits( ) )
539530 }
540531 #[ cfg( any(
541- target_os = "android" ,
542- target_os = "linux" ,
532+ linux_android,
543533 target_os = "freebsd"
544534 ) ) ]
545535 F_GET_SEALS => libc:: fcntl( fd, libc:: F_GET_SEALS ) ,
@@ -672,7 +662,7 @@ feature! {
672662// Note: FreeBSD defines the offset argument as "off_t". Linux and Android
673663// define it as "loff_t". But on both OSes, on all supported platforms, those
674664// are 64 bits. So Nix uses i64 to make the docs simple and consistent.
675- #[ cfg( any( target_os = "android" , target_os = "freebsd" , target_os = "linux ") ) ]
665+ #[ cfg( any( linux_android , target_os = "freebsd" ) ) ]
676666pub fn copy_file_range<Fd1 : AsFd , Fd2 : AsFd >(
677667 fd_in: Fd1 ,
678668 off_in: Option <& mut i64 >,
@@ -960,8 +950,7 @@ pub fn fspacectl_all(
960950}
961951
962952#[ cfg( any(
963- target_os = "linux" ,
964- target_os = "android" ,
953+ linux_android,
965954 target_os = "emscripten" ,
966955 target_os = "fuchsia" ,
967956 target_os = "wasi" ,
@@ -1008,13 +997,11 @@ mod posix_fadvise {
1008997}
1009998
1010999#[ cfg( any(
1011- target_os = "linux" ,
1012- target_os = "android" ,
1013- target_os = "dragonfly" ,
1000+ linux_android,
1001+ freebsdlike,
10141002 target_os = "emscripten" ,
10151003 target_os = "fuchsia" ,
10161004 target_os = "wasi" ,
1017- target_os = "freebsd"
10181005) ) ]
10191006pub fn posix_fallocate(
10201007 fd: RawFd ,
0 commit comments