1 //! Platform-dependent platform abstraction.
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.
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`.
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.
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
23 #![allow(missing_debug_implementations)]
28 pub use self::unix::*;
29 } else if #[cfg(windows)] {
31 pub use self::windows::*;
32 } else if #[cfg(target_os = "cloudabi")] {
34 pub use self::cloudabi::*;
35 } else if #[cfg(target_os = "redox")] {
37 pub use self::redox::*;
38 } else if #[cfg(target_env = "wasi")] {
40 pub use self::wasi::*;
41 } else if #[cfg(target_arch = "wasm32")] {
43 pub use self::wasm::*;
44 } else if #[cfg(all(target_vendor = "fortanix", target_env = "sgx"))] {
48 compile_error!("libstd doesn't compile for this platform yet");
52 // Import essential modules from both platforms when documenting. These are
53 // then later used in the `std::os` module when documenting, for example,
54 // Windows when we're compiling for Linux.
58 if #[cfg(any(unix, target_os = "redox"))] {
59 // On unix we'll document what's already available
60 #[stable(feature = "rust1", since = "1.0.0")]
61 pub use self::ext as unix_ext;
62 } else if #[cfg(any(target_os = "cloudabi",
63 target_arch = "wasm32",
64 all(target_vendor = "fortanix", target_env = "sgx")))] {
65 // On CloudABI and wasm right now the module below doesn't compile
66 // (missing things in `libc` which is empty) so just omit everything
67 // with an empty module
68 #[unstable(issue = "0", feature = "std_internals")]
69 #[allow(missing_docs)]
72 // On other platforms like Windows document the bare bones of unix
73 use crate::os::linux as platform;
74 #[path = "unix/ext/mod.rs"]
82 // On windows we'll just be documenting what's already available
83 #[allow(missing_docs)]
84 #[stable(feature = "rust1", since = "1.0.0")]
85 pub use self::ext as windows_ext;
86 } else if #[cfg(any(target_os = "cloudabi",
87 target_arch = "wasm32",
88 all(target_vendor = "fortanix", target_env = "sgx")))] {
89 // On CloudABI and wasm right now the shim below doesn't compile, so
91 #[unstable(issue = "0", feature = "std_internals")]
92 #[allow(missing_docs)]
93 pub mod windows_ext {}
95 // On all other platforms (aka linux/osx/etc) then pull in a "minimal"
96 // amount of windows goop which ends up compiling
98 #[path = "windows/compat.rs"]
101 #[path = "windows/c.rs"]
104 #[path = "windows/ext/mod.rs"]