]>
Commit | Line | Data |
---|---|---|
c30ab7b3 SL |
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 | |
8bb4bdeb | 6 | //! just Unix and Windows, and initial support for Redox. |
c30ab7b3 SL |
7 | //! |
8 | //! The centralization of platform-specific code in this module is | |
9 | //! enforced by the "platform abstraction layer" tidy script in | |
8bb4bdeb | 10 | //! `tools/tidy/src/pal.rs`. |
c30ab7b3 SL |
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 | //! | |
476ff2be | 16 | //! In the future it would be desirable for the independent |
c30ab7b3 SL |
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 | ||
32a655c1 SL |
23 | #![allow(missing_debug_implementations)] |
24 | ||
ff7c6d11 XL |
25 | cfg_if! { |
26 | if #[cfg(unix)] { | |
27 | mod unix; | |
28 | pub use self::unix::*; | |
29 | } else if #[cfg(windows)] { | |
30 | mod windows; | |
31 | pub use self::windows::*; | |
2c00a5a8 XL |
32 | } else if #[cfg(target_os = "cloudabi")] { |
33 | mod cloudabi; | |
34 | pub use self::cloudabi::*; | |
ff7c6d11 XL |
35 | } else if #[cfg(target_os = "redox")] { |
36 | mod redox; | |
37 | pub use self::redox::*; | |
38 | } else if #[cfg(target_arch = "wasm32")] { | |
39 | mod wasm; | |
40 | pub use self::wasm::*; | |
0731742a XL |
41 | } else if #[cfg(all(target_vendor = "fortanix", target_env = "sgx"))] { |
42 | mod sgx; | |
43 | pub use self::sgx::*; | |
ff7c6d11 XL |
44 | } else { |
45 | compile_error!("libstd doesn't compile for this platform yet"); | |
46 | } | |
47 | } | |
48 | ||
49 | // Import essential modules from both platforms when documenting. These are | |
50 | // then later used in the `std::os` module when documenting, for example, | |
51 | // Windows when we're compiling for Linux. | |
52 | ||
b7449926 | 53 | #[cfg(rustdoc)] |
ff7c6d11 XL |
54 | cfg_if! { |
55 | if #[cfg(any(unix, target_os = "redox"))] { | |
56 | // On unix we'll document what's already available | |
57 | pub use self::ext as unix_ext; | |
0731742a XL |
58 | } else if #[cfg(any(target_os = "cloudabi", |
59 | target_arch = "wasm32", | |
60 | all(target_vendor = "fortanix", target_env = "sgx")))] { | |
2c00a5a8 XL |
61 | // On CloudABI and wasm right now the module below doesn't compile |
62 | // (missing things in `libc` which is empty) so just omit everything | |
63 | // with an empty module | |
ff7c6d11 | 64 | #[unstable(issue = "0", feature = "std_internals")] |
8faf50e0 | 65 | #[allow(missing_docs)] |
ff7c6d11 XL |
66 | pub mod unix_ext {} |
67 | } else { | |
68 | // On other platforms like Windows document the bare bones of unix | |
69 | use os::linux as platform; | |
70 | #[path = "unix/ext/mod.rs"] | |
71 | pub mod unix_ext; | |
72 | } | |
73 | } | |
74 | ||
b7449926 | 75 | #[cfg(rustdoc)] |
ff7c6d11 XL |
76 | cfg_if! { |
77 | if #[cfg(windows)] { | |
78 | // On windows we'll just be documenting what's already available | |
8faf50e0 | 79 | #[allow(missing_docs)] |
ff7c6d11 | 80 | pub use self::ext as windows_ext; |
0731742a XL |
81 | } else if #[cfg(any(target_os = "cloudabi", |
82 | target_arch = "wasm32", | |
83 | all(target_vendor = "fortanix", target_env = "sgx")))] { | |
2c00a5a8 XL |
84 | // On CloudABI and wasm right now the shim below doesn't compile, so |
85 | // just omit it | |
ff7c6d11 | 86 | #[unstable(issue = "0", feature = "std_internals")] |
8faf50e0 | 87 | #[allow(missing_docs)] |
ff7c6d11 XL |
88 | pub mod windows_ext {} |
89 | } else { | |
90 | // On all other platforms (aka linux/osx/etc) then pull in a "minimal" | |
91 | // amount of windows goop which ends up compiling | |
92 | #[macro_use] | |
93 | #[path = "windows/compat.rs"] | |
94 | mod compat; | |
95 | ||
96 | #[path = "windows/c.rs"] | |
97 | mod c; | |
98 | ||
99 | #[path = "windows/ext/mod.rs"] | |
100 | pub mod windows_ext; | |
101 | } | |
102 | } |