66#[ cfg( test) ]
77mod tests;
88
9- #[ cfg( all( target_os = "linux" , target_env = "gnu" ) ) ]
9+ #[ cfg( all(
10+ target_os = "linux" ,
11+ any( target_env = "gnu" , target_env = "musl" , )
12+ ) ) ]
1013use libc:: c_char;
1114#[ cfg( any(
1215 all( target_os = "linux" , not( target_env = "musl" ) ) ,
@@ -93,7 +96,7 @@ use crate::sys::fd::FileDesc;
9396pub use crate :: sys:: fs:: common:: exists;
9497use crate :: sys:: helpers:: run_path_with_cstr;
9598use crate :: sys:: time:: SystemTime ;
96- #[ cfg( all( target_os = "linux" , target_env = "gnu" ) ) ]
99+ #[ cfg( all( target_os = "linux" , any ( target_env = "gnu" , target_env = "musl" ) ) ) ]
97100use crate :: sys:: weak:: syscall;
98101#[ cfg( target_os = "android" ) ]
99102use crate :: sys:: weak:: weak;
@@ -102,14 +105,17 @@ use crate::{mem, ptr};
102105
103106pub struct File ( FileDesc ) ;
104107
105- // FIXME: This should be available on Linux with all `target_env`.
106- // But currently only glibc exposes `statx` fn and structs.
107- // We don't want to import unverified raw C structs here directly.
108+ // statx is available on Linux when:
109+ // - target_env = "gnu": added in glibc >= 2.28
110+ // - target_env = "musl": added in musl >= 1.2.5
108111// https://github.com/rust-lang/rust/pull/67774
109112macro_rules! cfg_has_statx {
110113 ( { $( $then_tt: tt) * } else { $( $else_tt: tt) * } ) => {
111114 cfg_select! {
112- all( target_os = "linux" , target_env = "gnu" ) => {
115+ all( target_os = "linux" , any(
116+ target_env = "gnu" ,
117+ target_env = "musl" ,
118+ ) ) => {
113119 $( $then_tt) *
114120 }
115121 _ => {
@@ -118,7 +124,10 @@ macro_rules! cfg_has_statx {
118124 }
119125 } ;
120126 ( $( $block_inner: tt) * ) => {
121- #[ cfg( all( target_os = "linux" , target_env = "gnu" ) ) ]
127+ #[ cfg( all( target_os = "linux" , any(
128+ target_env = "gnu" ,
129+ target_env = "musl" ,
130+ ) ) ) ]
122131 {
123132 $( $block_inner) *
124133 }
0 commit comments