1 //! OS-specific functionality. 2 3 #![allow(missing_docs, nonstandard_style, missing_debug_implementations)] 4 5 pub mod raw; 6 7 // The code below could be written clearer using `cfg_if!`. However, the items below are 8 // publicly exported by `std` and external tools can have trouble analysing them because of the use 9 // of a macro that is not vendored by Rust and included in the toolchain. 10 // See https://github.com/rust-analyzer/rust-analyzer/issues/6038. 11 12 // On certain platforms right now the "main modules" modules that are 13 // documented don't compile (missing things in `libc` which is empty), 14 // so just omit them with an empty module and add the "unstable" attribute. 15 16 // Unix, linux, wasi and windows are handled a bit differently. 17 #[cfg(all( 18 doc, 19 any( 20 all(target_arch = "wasm32", not(target_os = "wasi")), 21 all(target_vendor = "fortanix", target_env = "sgx") 22 ) 23 ))] 24 pub mod unix {} 25 #[cfg(all( 26 doc, 27 any( 28 all(target_arch = "wasm32", not(target_os = "wasi")), 29 all(target_vendor = "fortanix", target_env = "sgx") 30 ) 31 ))] 32 pub mod linux {} 33 #[cfg(all( 34 doc, 35 any( 36 all(target_arch = "wasm32", not(target_os = "wasi")), 37 all(target_vendor = "fortanix", target_env = "sgx") 38 ) 39 ))] 40 pub mod wasi {} 41 #[cfg(all( 42 doc, 43 any( 44 all(target_arch = "wasm32", not(target_os = "wasi")), 45 all(target_vendor = "fortanix", target_env = "sgx") 46 ) 47 ))] 48 pub mod windows {} 49 50 // unix 51 #[cfg(not(all( 52 doc, 53 any( 54 all(target_arch = "wasm32", not(target_os = "wasi")), 55 all(target_vendor = "fortanix", target_env = "sgx") 56 ) 57 )))] 58 #[cfg(all(not(target_os = "hermit"), any(unix, doc)))] 59 pub mod unix; 60 61 // linux 62 #[cfg(not(all( 63 doc, 64 any( 65 all(target_arch = "wasm32", not(target_os = "wasi")), 66 all(target_vendor = "fortanix", target_env = "sgx") 67 ) 68 )))] 69 #[cfg(any(target_os = "linux", doc))] 70 pub mod linux; 71 72 // wasi 73 #[cfg(not(all( 74 doc, 75 any( 76 all(target_arch = "wasm32", not(target_os = "wasi")), 77 all(target_vendor = "fortanix", target_env = "sgx") 78 ) 79 )))] 80 #[cfg(any(target_os = "wasi", doc))] 81 pub mod wasi; 82 83 // windows 84 #[cfg(not(all( 85 doc, 86 any( 87 all(target_arch = "wasm32", not(target_os = "wasi")), 88 all(target_vendor = "fortanix", target_env = "sgx") 89 ) 90 )))] 91 #[cfg(any(windows, doc))] 92 pub mod windows; 93 94 // Others. 95 #[cfg(target_os = "android")] 96 pub mod android; 97 #[cfg(target_os = "dragonfly")] 98 pub mod dragonfly; 99 #[cfg(target_os = "emscripten")] 100 pub mod emscripten; 101 #[cfg(target_os = "espidf")] 102 pub mod espidf; 103 #[cfg(all(target_vendor = "fortanix", target_env = "sgx"))] 104 pub mod fortanix_sgx; 105 #[cfg(target_os = "freebsd")] 106 pub mod freebsd; 107 #[cfg(target_os = "fuchsia")] 108 pub mod fuchsia; 109 #[cfg(target_os = "haiku")] 110 pub mod haiku; 111 #[cfg(target_os = "hermit")] 112 pub mod hermit; 113 #[cfg(target_os = "horizon")] 114 pub mod horizon; 115 #[cfg(target_os = "illumos")] 116 pub mod illumos; 117 #[cfg(target_os = "ios")] 118 pub mod ios; 119 #[cfg(target_os = "l4re")] 120 pub mod l4re; 121 #[cfg(target_os = "macos")] 122 pub mod macos; 123 #[cfg(target_os = "netbsd")] 124 pub mod netbsd; 125 #[cfg(target_os = "nto")] 126 pub mod nto; 127 #[cfg(target_os = "openbsd")] 128 pub mod openbsd; 129 #[cfg(target_os = "redox")] 130 pub mod redox; 131 #[cfg(target_os = "solaris")] 132 pub mod solaris; 133 #[cfg(target_os = "solid_asp3")] 134 pub mod solid; 135 #[cfg(target_os = "tvos")] 136 #[path = "ios/mod.rs"] 137 pub(crate) mod tvos; 138 #[cfg(target_os = "vita")] 139 pub mod vita; 140 #[cfg(target_os = "vxworks")] 141 pub mod vxworks; 142 #[cfg(target_os = "watchos")] 143 pub(crate) mod watchos; 144 145 #[cfg(any(unix, target_os = "wasi", doc, target_os = "dragonos"))] 146 pub mod fd; 147 #[cfg(any( 148 target_os = "linux", 149 target_os = "android", 150 target_os = "dragonos", 151 doc 152 ))] 153 mod net; 154 155 #[cfg(target_os = "dragonos")] 156 pub mod linux; 157