1 // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 //! Platform-dependent platform abstraction
13 //! The `std::sys` module is the abstracted interface through which
14 //! `std` talks to the underlying operating system. It has different
15 //! implementations for different operating system families, today
16 //! just Unix and Windows, and initial support for Redox.
18 //! The centralization of platform-specific code in this module is
19 //! enforced by the "platform abstraction layer" tidy script in
20 //! `tools/tidy/src/pal.rs`.
22 //! This module is closely related to the platform-independent system
23 //! integration code in `std::sys_common`. See that module's
24 //! documentation for details.
26 //! In the future it would be desirable for the independent
27 //! implementations of this module to be extracted to their own crates
28 //! that `std` can link to, thus enabling their implementation
29 //! out-of-tree via crate replacement. Though due to the complex
30 //! inter-dependencies within `std` that will be a challenging goal to
33 #![allow(missing_debug_implementations)]
38 pub use self::unix::*;
39 } else if #[cfg(windows)] {
41 pub use self::windows::*;
42 } else if #[cfg(target_os = "cloudabi")] {
44 pub use self::cloudabi::*;
45 } else if #[cfg(target_os = "redox")] {
47 pub use self::redox::*;
48 } else if #[cfg(target_arch = "wasm32")] {
50 pub use self::wasm::*;
52 compile_error!("libstd doesn't compile for this platform yet");
56 // Import essential modules from both platforms when documenting. These are
57 // then later used in the `std::os` module when documenting, for example,
58 // Windows when we're compiling for Linux.
62 if #[cfg(any(unix, target_os = "redox"))] {
63 // On unix we'll document what's already available
64 pub use self::ext as unix_ext;
65 } else if #[cfg(any(target_os = "cloudabi", target_arch = "wasm32"))] {
66 // On CloudABI and wasm right now the module below doesn't compile
67 // (missing things in `libc` which is empty) so just omit everything
68 // with an empty module
69 #[unstable(issue = "0", feature = "std_internals")]
70 #[allow(missing_docs)]
73 // On other platforms like Windows document the bare bones of unix
74 use os::linux as platform;
75 #[path = "unix/ext/mod.rs"]
83 // On windows we'll just be documenting what's already available
84 #[allow(missing_docs)]
85 pub use self::ext as windows_ext;
86 } else if #[cfg(any(target_os = "cloudabi", target_arch = "wasm32"))] {
87 // On CloudABI and wasm right now the shim below doesn't compile, so
89 #[unstable(issue = "0", feature = "std_internals")]
90 #[allow(missing_docs)]
91 pub mod windows_ext {}
93 // On all other platforms (aka linux/osx/etc) then pull in a "minimal"
94 // amount of windows goop which ends up compiling
96 #[path = "windows/compat.rs"]
99 #[path = "windows/c.rs"]
102 #[path = "windows/ext/mod.rs"]