@@ -22,11 +22,7 @@ use std::os::unix::io::RawFd;
22
22
all( target_os = "freebsd" , target_arch = "x86_64" ) ,
23
23
) ) ]
24
24
use 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" ) ) ]
30
26
use std:: {
31
27
os:: unix:: io:: { AsFd , AsRawFd } ,
32
28
ptr,
@@ -36,8 +32,7 @@ use std::{
36
32
use crate :: { sys:: stat:: Mode , NixPath , Result } ;
37
33
38
34
#[ cfg( any(
39
- target_os = "linux" ,
40
- target_os = "android" ,
35
+ linux_android,
41
36
target_os = "emscripten" ,
42
37
target_os = "fuchsia" ,
43
38
target_os = "wasi" ,
@@ -81,10 +76,11 @@ libc_bitflags!(
81
76
/// Open the file in append-only mode.
82
77
O_APPEND ;
83
78
/// 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
+ ) ) ) ]
88
84
O_ASYNC ;
89
85
/// Closes the file descriptor once an `execve` call is made.
90
86
///
@@ -93,19 +89,18 @@ libc_bitflags!(
93
89
/// Create the file if it does not exist.
94
90
O_CREAT ;
95
91
/// 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
+ ) ) ]
101
97
O_DIRECT ;
102
98
/// If the specified path isn't a directory, fail.
103
99
#[ cfg( not( solarish) ) ]
104
100
O_DIRECTORY ;
105
101
/// Implicitly follow each `write()` with an `fdatasync()`.
106
- #[ cfg( any( target_os = "android" ,
102
+ #[ cfg( any( linux_android ,
107
103
apple_targets,
108
- target_os = "linux" ,
109
104
target_os = "netbsd" ,
110
105
target_os = "openbsd" ) ) ]
111
106
O_DSYNC ;
@@ -144,7 +139,7 @@ libc_bitflags!(
144
139
/// Obtain a file descriptor for low-level access.
145
140
///
146
141
/// 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" ) ) ]
148
143
O_PATH ;
149
144
/// Only allow reading.
150
145
///
@@ -184,7 +179,7 @@ libc_bitflags!(
184
179
/// Computes the raw fd consumed by a function of the form `*at`.
185
180
#[ cfg( any(
186
181
all( feature = "fs" , not( target_os = "redox" ) ) ,
187
- all( feature = "process" , any ( target_os = "android" , target_os = "linux" ) ) ,
182
+ all( feature = "process" , linux_android ) ,
188
183
all( feature = "fanotify" , target_os = "linux" )
189
184
) ) ]
190
185
pub ( crate ) fn at_rawfd ( fd : Option < RawFd > ) -> raw:: c_int {
@@ -346,8 +341,7 @@ fn inner_readlink<P: ?Sized + NixPath>(
346
341
)
347
342
}
348
343
#[ cfg( not( any(
349
- target_os = "android" ,
350
- target_os = "linux" ,
344
+ linux_android,
351
345
target_os = "redox"
352
346
) ) ) ]
353
347
Some ( dirfd) => super :: sys:: stat:: fstatat(
@@ -406,7 +400,7 @@ pub fn readlinkat<P: ?Sized + NixPath>(
406
400
}
407
401
}
408
402
409
- #[ cfg( any( target_os = "android" , target_os = "linux" , target_os = "freebsd" ) ) ]
403
+ #[ cfg( any( linux_android , target_os = "freebsd" ) ) ]
410
404
#[ cfg( feature = "fs" ) ]
411
405
libc_bitflags ! (
412
406
/// Additional flags for file sealing, which allows for limiting operations on a file.
@@ -460,14 +454,12 @@ pub enum FcntlArg<'a> {
460
454
#[ cfg( linux_android) ]
461
455
F_OFD_GETLK ( & ' a mut libc:: flock) ,
462
456
#[ cfg( any(
463
- target_os = "android" ,
464
- target_os = "linux" ,
457
+ linux_android,
465
458
target_os = "freebsd"
466
459
) ) ]
467
460
F_ADD_SEALS ( SealFlag ) ,
468
461
#[ cfg( any(
469
- target_os = "android" ,
470
- target_os = "linux" ,
462
+ linux_android,
471
463
target_os = "freebsd"
472
464
) ) ]
473
465
F_GET_SEALS ,
@@ -530,16 +522,14 @@ pub fn fcntl(fd: RawFd, arg: FcntlArg) -> Result<c_int> {
530
522
#[ cfg( linux_android) ]
531
523
F_OFD_GETLK ( flock) => libc:: fcntl( fd, libc:: F_OFD_GETLK , flock) ,
532
524
#[ cfg( any(
533
- target_os = "android" ,
534
- target_os = "linux" ,
525
+ linux_android,
535
526
target_os = "freebsd"
536
527
) ) ]
537
528
F_ADD_SEALS ( flag) => {
538
529
libc:: fcntl( fd, libc:: F_ADD_SEALS , flag. bits( ) )
539
530
}
540
531
#[ cfg( any(
541
- target_os = "android" ,
542
- target_os = "linux" ,
532
+ linux_android,
543
533
target_os = "freebsd"
544
534
) ) ]
545
535
F_GET_SEALS => libc:: fcntl( fd, libc:: F_GET_SEALS ) ,
@@ -672,7 +662,7 @@ feature! {
672
662
// Note: FreeBSD defines the offset argument as "off_t". Linux and Android
673
663
// define it as "loff_t". But on both OSes, on all supported platforms, those
674
664
// 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" ) ) ]
676
666
pub fn copy_file_range<Fd1 : AsFd , Fd2 : AsFd >(
677
667
fd_in: Fd1 ,
678
668
off_in: Option <& mut i64 >,
@@ -960,8 +950,7 @@ pub fn fspacectl_all(
960
950
}
961
951
962
952
#[ cfg( any(
963
- target_os = "linux" ,
964
- target_os = "android" ,
953
+ linux_android,
965
954
target_os = "emscripten" ,
966
955
target_os = "fuchsia" ,
967
956
target_os = "wasi" ,
@@ -1008,13 +997,11 @@ mod posix_fadvise {
1008
997
}
1009
998
1010
999
#[ cfg( any(
1011
- target_os = "linux" ,
1012
- target_os = "android" ,
1013
- target_os = "dragonfly" ,
1000
+ linux_android,
1001
+ freebsdlike,
1014
1002
target_os = "emscripten" ,
1015
1003
target_os = "fuchsia" ,
1016
1004
target_os = "wasi" ,
1017
- target_os = "freebsd"
1018
1005
) ) ]
1019
1006
pub fn posix_fallocate(
1020
1007
fd: RawFd ,
0 commit comments