std/os/
mod.rs

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
7pub 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")]
27pub 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")]
36pub 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")]
45pub 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")]
54pub 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")]
63pub 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))]
74pub 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)))]
85pub 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))]
96pub 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))]
107pub mod wasi;
108
109#[cfg(any(all(target_os = "wasi", target_env = "p2"), doc))]
110pub 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))]
121pub mod windows;
122
123// Others.
124#[cfg(target_os = "aix")]
125pub mod aix;
126#[cfg(target_os = "android")]
127pub mod android;
128#[cfg(target_os = "dragonfly")]
129pub mod dragonfly;
130#[cfg(target_os = "emscripten")]
131pub mod emscripten;
132#[cfg(target_os = "espidf")]
133pub mod espidf;
134#[cfg(all(target_vendor = "fortanix", target_env = "sgx"))]
135pub mod fortanix_sgx;
136#[cfg(target_os = "freebsd")]
137pub mod freebsd;
138#[cfg(target_os = "fuchsia")]
139pub mod fuchsia;
140#[cfg(target_os = "haiku")]
141pub mod haiku;
142#[cfg(target_os = "hermit")]
143pub mod hermit;
144#[cfg(target_os = "horizon")]
145pub mod horizon;
146#[cfg(target_os = "hurd")]
147pub mod hurd;
148#[cfg(target_os = "illumos")]
149pub mod illumos;
150#[cfg(target_os = "ios")]
151pub mod ios;
152#[cfg(target_os = "l4re")]
153pub mod l4re;
154#[cfg(target_os = "macos")]
155pub mod macos;
156#[cfg(target_os = "netbsd")]
157pub mod netbsd;
158#[cfg(target_os = "nto")]
159pub mod nto;
160#[cfg(target_os = "nuttx")]
161pub mod nuttx;
162#[cfg(target_os = "openbsd")]
163pub mod openbsd;
164#[cfg(target_os = "redox")]
165pub mod redox;
166#[cfg(target_os = "rtems")]
167pub mod rtems;
168#[cfg(target_os = "solaris")]
169pub mod solaris;
170#[cfg(target_os = "solid_asp3")]
171pub mod solid;
172#[cfg(target_os = "uefi")]
173pub mod uefi;
174#[cfg(target_os = "vita")]
175pub mod vita;
176#[cfg(target_os = "vxworks")]
177pub mod vxworks;
178#[cfg(target_os = "xous")]
179pub mod xous;
180
181#[cfg(any(unix, target_os = "hermit", target_os = "wasi", doc))]
182pub mod fd;
183
184#[cfg(any(target_os = "linux", target_os = "android", doc))]
185mod net;