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