diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2025-02-08 21:37:24 +0100 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-08 21:37:24 +0100 | 
| commit | 02b8bea0849f982a480d80487b376204f658942b (patch) | |
| tree | 75d253c22c5cfbf9b3ae5ed287cfa9a5a2a9030b /library/std/src/sys/io/mod.rs | |
| parent | 8ad2c9724d983cfb116baab0bb800edd17f31644 (diff) | |
| parent | 7433ba62b10126b0ae8b78d711f19402db663101 (diff) | |
| download | rust-02b8bea0849f982a480d80487b376204f658942b.tar.gz rust-02b8bea0849f982a480d80487b376204f658942b.zip | |
Rollup merge of #135696 - joboet:move_pal_io, r=Noratrieb
std: move `io` module out of `pal`, get rid of `sys_common::io` Part of #117276. This does two related things: 1. It moves the platform-specific definitions for `IoSlice`, `IoSliceMut` and `is_terminal` out of `pal` and into `sys` and unifies some of them. 2. It gets rid of `sys_common::io`, moving the non-platform-specific test helpers into `std::test_helpers` and the buffer size definition to the new `sys::io` module.
Diffstat (limited to 'library/std/src/sys/io/mod.rs')
| -rw-r--r-- | library/std/src/sys/io/mod.rs | 44 | 
1 files changed, 44 insertions, 0 deletions
| diff --git a/library/std/src/sys/io/mod.rs b/library/std/src/sys/io/mod.rs new file mode 100644 index 00000000000..e00b479109f --- /dev/null +++ b/library/std/src/sys/io/mod.rs @@ -0,0 +1,44 @@ +#![forbid(unsafe_op_in_unsafe_fn)] + +mod io_slice { + cfg_if::cfg_if! { + if #[cfg(any(target_family = "unix", target_os = "hermit", target_os = "solid_asp3"))] { + mod iovec; + pub use iovec::*; + } else if #[cfg(target_os = "windows")] { + mod windows; + pub use windows::*; + } else if #[cfg(target_os = "wasi")] { + mod wasi; + pub use wasi::*; + } else { + mod unsupported; + pub use unsupported::*; + } + } +} + +mod is_terminal { + cfg_if::cfg_if! { + if #[cfg(any(target_family = "unix", target_os = "wasi"))] { + mod isatty; + pub use isatty::*; + } else if #[cfg(target_os = "windows")] { + mod windows; + pub use windows::*; + } else if #[cfg(target_os = "hermit")] { + mod hermit; + pub use hermit::*; + } else { + mod unsupported; + pub use unsupported::*; + } + } +} + +pub use io_slice::{IoSlice, IoSliceMut}; +pub use is_terminal::is_terminal; + +// Bare metal platforms usually have very small amounts of RAM +// (in the order of hundreds of KB) +pub const DEFAULT_BUF_SIZE: usize = if cfg!(target_os = "espidf") { 512 } else { 8 * 1024 }; | 
