]> git.lizzy.rs Git - rust.git/blob - library/std/src/sys/mod.rs
Auto merge of #107843 - bjorn3:sync_cg_clif-2023-02-09, r=bjorn3
[rust.git] / library / std / src / sys / mod.rs
1 //! Platform-dependent platform abstraction.
2 //!
3 //! The `std::sys` module is the abstracted interface through which
4 //! `std` talks to the underlying operating system. It has different
5 //! implementations for different operating system families, today
6 //! just Unix and Windows, and initial support for Redox.
7 //!
8 //! The centralization of platform-specific code in this module is
9 //! enforced by the "platform abstraction layer" tidy script in
10 //! `tools/tidy/src/pal.rs`.
11 //!
12 //! This module is closely related to the platform-independent system
13 //! integration code in `std::sys_common`. See that module's
14 //! documentation for details.
15 //!
16 //! In the future it would be desirable for the independent
17 //! implementations of this module to be extracted to their own crates
18 //! that `std` can link to, thus enabling their implementation
19 //! out-of-tree via crate replacement. Though due to the complex
20 //! inter-dependencies within `std` that will be a challenging goal to
21 //! achieve.
22
23 #![allow(missing_debug_implementations)]
24
25 pub mod common;
26
27 cfg_if::cfg_if! {
28     if #[cfg(unix)] {
29         mod unix;
30         pub use self::unix::*;
31     } else if #[cfg(windows)] {
32         mod windows;
33         pub use self::windows::*;
34     } else if #[cfg(target_os = "solid_asp3")] {
35         mod solid;
36         pub use self::solid::*;
37     } else if #[cfg(target_os = "hermit")] {
38         mod hermit;
39         pub use self::hermit::*;
40     } else if #[cfg(target_os = "wasi")] {
41         mod wasi;
42         pub use self::wasi::*;
43     } else if #[cfg(target_family = "wasm")] {
44         mod wasm;
45         pub use self::wasm::*;
46     } else if #[cfg(all(target_vendor = "fortanix", target_env = "sgx"))] {
47         mod sgx;
48         pub use self::sgx::*;
49     } else {
50         mod unsupported;
51         pub use self::unsupported::*;
52     }
53 }
54
55 // Import essential modules from platforms used in `std::os` when documenting.
56 //
57 // Note that on some platforms those modules don't compile
58 // (missing things in `libc` which is empty), so they are not included in `std::os` and can be
59 // omitted here as well.
60
61 #[cfg(doc)]
62 #[cfg(not(any(
63     all(target_arch = "wasm32", not(target_os = "wasi")),
64     all(target_vendor = "fortanix", target_env = "sgx")
65 )))]
66 cfg_if::cfg_if! {
67     if #[cfg(not(windows))] {
68         // On non-Windows platforms (aka linux/osx/etc) pull in a "minimal"
69         // amount of windows goop which ends up compiling
70
71         #[macro_use]
72         #[path = "windows/compat.rs"]
73         pub mod compat;
74
75         #[path = "windows/c.rs"]
76         pub mod c;
77     }
78 }