]> git.lizzy.rs Git - rust.git/blob - library/std/src/os/mod.rs
Merge commit '3a31c6d8272c14388a34622193baf553636fe470' into sync_cg_clif-2021-07-07
[rust.git] / library / std / src / 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
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 #[cfg(all(
14     doc,
15     not(any(
16         all(target_arch = "wasm32", not(target_os = "wasi")),
17         all(target_vendor = "fortanix", target_env = "sgx")
18     ))
19 ))]
20 #[path = "."]
21 mod doc {
22     // When documenting std we want to show the `unix`, `windows`, `linux` and `wasi`
23     // modules as these are the "main modules" that are used across platforms,
24     // so these modules are enabled when `cfg(doc)` is set.
25     // This should help show platform-specific functionality in a hopefully cross-platform
26     // way in the documentation.
27
28     pub mod unix;
29
30     pub mod linux;
31
32     pub mod wasi;
33
34     pub mod windows;
35 }
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 mod doc {
44     // On certain platforms right now the "main modules" modules that are
45     // documented don't compile (missing things in `libc` which is empty),
46     // so just omit them with an empty module.
47
48     #[unstable(issue = "none", feature = "std_internals")]
49     pub mod unix {}
50
51     #[unstable(issue = "none", feature = "std_internals")]
52     pub mod linux {}
53
54     #[unstable(issue = "none", feature = "std_internals")]
55     pub mod wasi {}
56
57     #[unstable(issue = "none", feature = "std_internals")]
58     pub mod windows {}
59 }
60 #[cfg(doc)]
61 #[stable(feature = "os", since = "1.0.0")]
62 pub use doc::*;
63
64 #[cfg(not(doc))]
65 #[path = "."]
66 mod imp {
67     // If we're not documenting std then we only expose modules appropriate for the
68     // current platform.
69
70     #[cfg(all(target_vendor = "fortanix", target_env = "sgx"))]
71     pub mod fortanix_sgx;
72
73     #[cfg(target_os = "hermit")]
74     #[path = "hermit/mod.rs"]
75     pub mod unix;
76
77     #[cfg(target_os = "android")]
78     pub mod android;
79     #[cfg(target_os = "dragonfly")]
80     pub mod dragonfly;
81     #[cfg(target_os = "emscripten")]
82     pub mod emscripten;
83     #[cfg(target_os = "freebsd")]
84     pub mod freebsd;
85     #[cfg(target_os = "fuchsia")]
86     pub mod fuchsia;
87     #[cfg(target_os = "haiku")]
88     pub mod haiku;
89     #[cfg(target_os = "illumos")]
90     pub mod illumos;
91     #[cfg(target_os = "ios")]
92     pub mod ios;
93     #[cfg(target_os = "l4re")]
94     pub mod linux;
95     #[cfg(target_os = "linux")]
96     pub mod linux;
97     #[cfg(target_os = "macos")]
98     pub mod macos;
99     #[cfg(target_os = "netbsd")]
100     pub mod netbsd;
101     #[cfg(target_os = "openbsd")]
102     pub mod openbsd;
103     #[cfg(target_os = "redox")]
104     pub mod redox;
105     #[cfg(target_os = "solaris")]
106     pub mod solaris;
107     #[cfg(unix)]
108     pub mod unix;
109
110     #[cfg(target_os = "vxworks")]
111     pub mod vxworks;
112
113     #[cfg(target_os = "wasi")]
114     pub mod wasi;
115
116     #[cfg(windows)]
117     pub mod windows;
118 }
119 #[cfg(not(doc))]
120 #[stable(feature = "os", since = "1.0.0")]
121 pub use imp::*;