| 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_select! { |
| 28 | unix => { |
| 29 | mod unix; |
| 30 | pub use self::unix::*; |
| 31 | } |
| 32 | windows => { |
| 33 | mod windows; |
| 34 | pub use self::windows::*; |
| 35 | } |
| 36 | target_os = "solid_asp3" => { |
| 37 | mod solid; |
| 38 | pub use self::solid::*; |
| 39 | } |
| 40 | target_os = "hermit" => { |
| 41 | mod hermit; |
| 42 | pub use self::hermit::*; |
| 43 | } |
| 44 | target_os = "motor" => { |
| 45 | mod motor; |
| 46 | pub use self::motor::*; |
| 47 | } |
| 48 | target_os = "trusty" => { |
| 49 | mod trusty; |
| 50 | pub use self::trusty::*; |
| 51 | } |
| 52 | target_os = "vexos" => { |
| 53 | mod vexos; |
| 54 | pub use self::vexos::*; |
| 55 | } |
| 56 | all(target_os = "wasi" , any(target_env = "p2" , target_env = "p3" )) => { |
| 57 | mod wasip2; |
| 58 | pub use self::wasip2::*; |
| 59 | } |
| 60 | all(target_os = "wasi" , target_env = "p1" ) => { |
| 61 | mod wasip1; |
| 62 | pub use self::wasip1::*; |
| 63 | } |
| 64 | target_family = "wasm" => { |
| 65 | mod wasm; |
| 66 | pub use self::wasm::*; |
| 67 | } |
| 68 | target_os = "xous" => { |
| 69 | mod xous; |
| 70 | pub use self::xous::*; |
| 71 | } |
| 72 | target_os = "uefi" => { |
| 73 | mod uefi; |
| 74 | pub use self::uefi::*; |
| 75 | } |
| 76 | all(target_vendor = "fortanix" , target_env = "sgx" ) => { |
| 77 | mod sgx; |
| 78 | pub use self::sgx::*; |
| 79 | } |
| 80 | target_os = "teeos" => { |
| 81 | mod teeos; |
| 82 | pub use self::teeos::*; |
| 83 | } |
| 84 | target_os = "zkvm" => { |
| 85 | mod zkvm; |
| 86 | pub use self::zkvm::*; |
| 87 | } |
| 88 | _ => { |
| 89 | mod unsupported; |
| 90 | pub use self::unsupported::*; |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | pub const FULL_BACKTRACE_DEFAULT: bool = cfg_select! { |
| 95 | // Fuchsia components default to full backtrace. |
| 96 | target_os = "fuchsia" => true, |
| 97 | _ => false, |
| 98 | }; |
| 99 | |
| 100 | #[cfg (not(target_os = "uefi" ))] |
| 101 | pub type RawOsError = i32; |
| 102 | |