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