1//! OS-specific functionality.
2
3#![stable(feature = "os", since = "1.0.0")]
4#![allow(missing_docs, nonstandard_style, missing_debug_implementations)]
5
6pub 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")]
26pub 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")]
35pub 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")]
44pub 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")]
53pub 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)))]
64pub 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))]
75pub 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))]
86pub mod wasi;
87
88#[cfg(any(all(target_os = "wasi", target_env = "p2"), doc))]
89pub 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))]
100pub mod windows;
101
102// Others.
103#[cfg(target_os = "aix")]
104pub mod aix;
105#[cfg(target_os = "android")]
106pub mod android;
107#[cfg(target_os = "dragonfly")]
108pub mod dragonfly;
109#[cfg(target_os = "emscripten")]
110pub mod emscripten;
111#[cfg(target_os = "espidf")]
112pub mod espidf;
113#[cfg(all(target_vendor = "fortanix", target_env = "sgx"))]
114pub mod fortanix_sgx;
115#[cfg(target_os = "freebsd")]
116pub mod freebsd;
117#[cfg(target_os = "fuchsia")]
118pub mod fuchsia;
119#[cfg(target_os = "haiku")]
120pub mod haiku;
121#[cfg(target_os = "hermit")]
122pub mod hermit;
123#[cfg(target_os = "horizon")]
124pub mod horizon;
125#[cfg(target_os = "hurd")]
126pub mod hurd;
127#[cfg(target_os = "illumos")]
128pub mod illumos;
129#[cfg(target_os = "ios")]
130pub mod ios;
131#[cfg(target_os = "l4re")]
132pub mod l4re;
133#[cfg(target_os = "macos")]
134pub mod macos;
135#[cfg(target_os = "netbsd")]
136pub mod netbsd;
137#[cfg(target_os = "nto")]
138pub mod nto;
139#[cfg(target_os = "openbsd")]
140pub mod openbsd;
141#[cfg(target_os = "redox")]
142pub mod redox;
143#[cfg(target_os = "solaris")]
144pub mod solaris;
145#[cfg(target_os = "solid_asp3")]
146pub mod solid;
147#[cfg(target_os = "tvos")]
148#[path = "ios/mod.rs"]
149pub(crate) mod tvos;
150#[cfg(target_os = "uefi")]
151pub mod uefi;
152#[cfg(target_os = "visionos")]
153pub(crate) mod visionos;
154#[cfg(target_os = "vita")]
155pub mod vita;
156#[cfg(target_os = "vxworks")]
157pub mod vxworks;
158#[cfg(target_os = "watchos")]
159pub(crate) mod watchos;
160#[cfg(target_os = "xous")]
161pub mod xous;
162
163#[cfg(any(unix, target_os = "wasi", doc))]
164pub mod fd;
165
166#[cfg(any(target_os = "linux", target_os = "android", doc))]
167mod net;
168