]>
Commit | Line | Data |
---|---|---|
9fa01778 | 1 | //! Platform-dependent platform abstraction. |
c30ab7b3 SL |
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 | ||
dc9dc135 | 25 | cfg_if::cfg_if! { |
416331ca XL |
26 | if #[cfg(target_os = "vxworks")] { |
27 | mod vxworks; | |
28 | pub use self::vxworks::*; | |
29 | } else if #[cfg(unix)] { | |
ff7c6d11 XL |
30 | mod unix; |
31 | pub use self::unix::*; | |
32 | } else if #[cfg(windows)] { | |
33 | mod windows; | |
34 | pub use self::windows::*; | |
e74abb32 XL |
35 | } else if #[cfg(target_os = "hermit")] { |
36 | mod hermit; | |
37 | pub use self::hermit::*; | |
48663c56 | 38 | } else if #[cfg(target_os = "wasi")] { |
532ac7d7 XL |
39 | mod wasi; |
40 | pub use self::wasi::*; | |
ff7c6d11 XL |
41 | } else if #[cfg(target_arch = "wasm32")] { |
42 | mod wasm; | |
43 | pub use self::wasm::*; | |
0731742a XL |
44 | } else if #[cfg(all(target_vendor = "fortanix", target_env = "sgx"))] { |
45 | mod sgx; | |
46 | pub use self::sgx::*; | |
ff7c6d11 | 47 | } else { |
3dfed10e XL |
48 | mod unsupported; |
49 | pub use self::unsupported::*; | |
ff7c6d11 XL |
50 | } |
51 | } | |
52 | ||
53 | // Import essential modules from both platforms when documenting. These are | |
54 | // then later used in the `std::os` module when documenting, for example, | |
55 | // Windows when we're compiling for Linux. | |
56 | ||
60c5eb7d | 57 | #[cfg(doc)] |
dc9dc135 | 58 | cfg_if::cfg_if! { |
416331ca | 59 | if #[cfg(unix)] { |
ff7c6d11 | 60 | // On unix we'll document what's already available |
9fa01778 | 61 | #[stable(feature = "rust1", since = "1.0.0")] |
ff7c6d11 | 62 | pub use self::ext as unix_ext; |
fc512014 | 63 | } else if #[cfg(any(target_os = "hermit", |
0731742a XL |
64 | target_arch = "wasm32", |
65 | all(target_vendor = "fortanix", target_env = "sgx")))] { | |
fc512014 | 66 | // On wasm right now the module below doesn't compile |
2c00a5a8 XL |
67 | // (missing things in `libc` which is empty) so just omit everything |
68 | // with an empty module | |
dfeec247 | 69 | #[unstable(issue = "none", feature = "std_internals")] |
8faf50e0 | 70 | #[allow(missing_docs)] |
ff7c6d11 XL |
71 | pub mod unix_ext {} |
72 | } else { | |
73 | // On other platforms like Windows document the bare bones of unix | |
532ac7d7 | 74 | use crate::os::linux as platform; |
ff7c6d11 XL |
75 | #[path = "unix/ext/mod.rs"] |
76 | pub mod unix_ext; | |
77 | } | |
78 | } | |
79 | ||
60c5eb7d | 80 | #[cfg(doc)] |
dc9dc135 | 81 | cfg_if::cfg_if! { |
ff7c6d11 XL |
82 | if #[cfg(windows)] { |
83 | // On windows we'll just be documenting what's already available | |
8faf50e0 | 84 | #[allow(missing_docs)] |
9fa01778 | 85 | #[stable(feature = "rust1", since = "1.0.0")] |
ff7c6d11 | 86 | pub use self::ext as windows_ext; |
fc512014 | 87 | } else if #[cfg(any(target_os = "hermit", |
0731742a XL |
88 | target_arch = "wasm32", |
89 | all(target_vendor = "fortanix", target_env = "sgx")))] { | |
fc512014 | 90 | // On wasm right now the shim below doesn't compile, so |
2c00a5a8 | 91 | // just omit it |
dfeec247 | 92 | #[unstable(issue = "none", feature = "std_internals")] |
8faf50e0 | 93 | #[allow(missing_docs)] |
ff7c6d11 XL |
94 | pub mod windows_ext {} |
95 | } else { | |
96 | // On all other platforms (aka linux/osx/etc) then pull in a "minimal" | |
97 | // amount of windows goop which ends up compiling | |
98 | #[macro_use] | |
99 | #[path = "windows/compat.rs"] | |
100 | mod compat; | |
101 | ||
102 | #[path = "windows/c.rs"] | |
103 | mod c; | |
104 | ||
105 | #[path = "windows/ext/mod.rs"] | |
106 | pub mod windows_ext; | |
107 | } | |
108 | } |