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