1 macro_rules! platforms { 2 ($($($platform:expr);* => $module:ident),*) => { 3 $( 4 #[cfg(any(test, $(target_os = $platform),*))] 5 #[cfg_attr(not(any($(target_os = $platform),*)), allow(dead_code))] 6 mod $module; 7 8 #[cfg(any($(target_os = $platform),*))] 9 pub use self::$module::*; 10 11 #[cfg(any($(target_os = $platform),*))] 12 pub const ENOATTR: ::libc::c_int = ::libc::ENOATTR; 13 )* 14 15 #[cfg(any(test, all(feature = "unsupported", not(any($($(target_os = $platform),*),*)))))] 16 #[cfg_attr(any($($(target_os = $platform),*),*), allow(dead_code))] 17 mod unsupported; 18 19 #[cfg(all(feature = "unsupported", not(any($($(target_os = $platform),*),*))))] 20 pub use self::unsupported::*; 21 #[cfg(all(feature = "unsupported", not(any($($(target_os = $platform),*),*))))] 22 pub const ENOATTR: ::libc::c_int = 0; 23 24 25 /// A constant indicating whether or not the target platform is supported. 26 /// 27 /// To make programmer's lives easier, this library builds on all platforms. 28 /// However, all function calls on unsupported platforms will return 29 /// `io::Error`s. 30 /// 31 /// Note: If you would like compilation to simply fail on unsupported platforms, 32 /// turn of the `unsupported` feature. 33 pub const SUPPORTED_PLATFORM: bool = cfg!(any($($(target_os = $platform),*),*)); 34 } 35 } 36 37 platforms! { 38 "linux"; "macos" => linux_macos, 39 "freebsd"; "netbsd" => bsd 40 } 41