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 | #[cfg (any(all(target_os = "wasi" , target_env = "p2" ), doc))] |
89 | pub mod wasip2; |
90 | |
91 | // windows |
92 | #[cfg (not(all( |
93 | doc, |
94 | any( |
95 | all(target_arch = "wasm32" , not(target_os = "wasi" )), |
96 | all(target_vendor = "fortanix" , target_env = "sgx" ) |
97 | ) |
98 | )))] |
99 | #[cfg (any(windows, doc))] |
100 | pub mod windows; |
101 | |
102 | // Others. |
103 | #[cfg (target_os = "aix" )] |
104 | pub mod aix; |
105 | #[cfg (target_os = "android" )] |
106 | pub mod android; |
107 | #[cfg (target_os = "dragonfly" )] |
108 | pub mod dragonfly; |
109 | #[cfg (target_os = "emscripten" )] |
110 | pub mod emscripten; |
111 | #[cfg (target_os = "espidf" )] |
112 | pub mod espidf; |
113 | #[cfg (all(target_vendor = "fortanix" , target_env = "sgx" ))] |
114 | pub mod fortanix_sgx; |
115 | #[cfg (target_os = "freebsd" )] |
116 | pub mod freebsd; |
117 | #[cfg (target_os = "fuchsia" )] |
118 | pub mod fuchsia; |
119 | #[cfg (target_os = "haiku" )] |
120 | pub mod haiku; |
121 | #[cfg (target_os = "hermit" )] |
122 | pub mod hermit; |
123 | #[cfg (target_os = "horizon" )] |
124 | pub mod horizon; |
125 | #[cfg (target_os = "hurd" )] |
126 | pub mod hurd; |
127 | #[cfg (target_os = "illumos" )] |
128 | pub mod illumos; |
129 | #[cfg (target_os = "ios" )] |
130 | pub mod ios; |
131 | #[cfg (target_os = "l4re" )] |
132 | pub mod l4re; |
133 | #[cfg (target_os = "macos" )] |
134 | pub mod macos; |
135 | #[cfg (target_os = "netbsd" )] |
136 | pub mod netbsd; |
137 | #[cfg (target_os = "nto" )] |
138 | pub mod nto; |
139 | #[cfg (target_os = "openbsd" )] |
140 | pub mod openbsd; |
141 | #[cfg (target_os = "redox" )] |
142 | pub mod redox; |
143 | #[cfg (target_os = "solaris" )] |
144 | pub mod solaris; |
145 | #[cfg (target_os = "solid_asp3" )] |
146 | pub mod solid; |
147 | #[cfg (target_os = "tvos" )] |
148 | #[path = "ios/mod.rs" ] |
149 | pub(crate) mod tvos; |
150 | #[cfg (target_os = "uefi" )] |
151 | pub mod uefi; |
152 | #[cfg (target_os = "visionos" )] |
153 | pub(crate) mod visionos; |
154 | #[cfg (target_os = "vita" )] |
155 | pub mod vita; |
156 | #[cfg (target_os = "vxworks" )] |
157 | pub mod vxworks; |
158 | #[cfg (target_os = "watchos" )] |
159 | pub(crate) mod watchos; |
160 | #[cfg (target_os = "xous" )] |
161 | pub mod xous; |
162 | |
163 | #[cfg (any(unix, target_os = "wasi" , doc))] |
164 | pub mod fd; |
165 | |
166 | #[cfg (any(target_os = "linux" , target_os = "android" , doc))] |
167 | mod net; |
168 | |