about summary refs log tree commit diff
path: root/library/std/src/sys/stdio
AgeCommit message (Collapse)AuthorLines
2025-09-25std: fix warning in VEXos stdio moduleTropical-1/+1
2025-09-24std: add support for armv7a-vex-v5 targetTropical-0/+104
Co-authored-by: Lewis McClelland <lewis@lewismcclelland.me>
2025-09-04std: Implement WASIp2-specific stdio routinesAlex Crichton-3/+127
This commit is an extension of previous libstd support but applied to stdio specifically. The stdio routines are updated away from WASIp1 APIs to using WASIp2 APIs natively. The end goal is to eventually drop the dependency on WASIp1 APIs in the standard library entirely in favor of exclusively depending on WASIp2.
2025-08-16library: Migrate from `cfg_if` to `cfg_select`Josh Triplett-15/+22
Migrate the standard library from using the external `cfg_if` crate to using the now-built-in `cfg_select` macro. This does not yet eliminate the dependency from `library/std/Cargo.toml`, because while the standard library itself no longer uses `cfg_if`, it also incorporates the `backtrace` crate, which does. Migration assisted by the following vim command (after selecting the full `cfg_if!` invocation): ``` '<,'>s/\(cfg_if::\)\?cfg_if/cfg_select/ | '<,'>s/^\( *\)} else {/\1}\r\1_ => {/c | '<,'>s/^\( *\)} else if #\[cfg(\(.*\))\] /\1}\r\1\2 => /e | '<,'>s/if #\[cfg(\(.*\))\] {/\1 => {/e ``` This is imperfect, but substantially accelerated the process. This prompts for confirmation on the `} else {` since that can also appear inside one of the arms. This also requires manual intervention to handle any multi-line conditions.
2025-04-15Rollup merge of #139517 - Ayush1325:uefi-cmd-stdin-null, r=joboetStuart Cook-2/+6
std: sys: process: uefi: Use NULL stdin by default According to the docs in `Command::output`: > By default, stdout and stderr are captured (and used to provide the resulting output). Stdin is not inherited from the parent and any attempt by the child process to read from the stdin stream will result in the stream immediately closing. This was being violated by UEFI which was inheriting stdin by default. While the docs don't explicitly state that the default should be NULL, the behaviour seems like reading from NULL. UEFI however, has a bit of a problem. The `EFI_SIMPLE_TEXT_INPUT_PROTOCOL` only provides support for reading 1 key press. This means that you either get an error, or it is assumed that the keypress was read successfully. So there is no way to have a successful read of length 0. Currently, I am returning UNSUPPORTED error when trying to read from NULL stdin. On linux however, you will get a read of length 0 for Null stdin. One possible way to get around this is to translate one of the UEFI errors to a read 0 (Maybe unsupported?). It is also possible to have a non-standard error code, but well, not sure if we go that route. Alternatively, if meaning of Stdio::Null is platform dependent, it should be fine to keep the current behaviour of returning an error. cc ```@nicholasbishop``` ```@dvdhrm```
2025-04-13std: sys: stdio: uefi: Tread UNSUPPORTED Status as read(0)Ayush Singh-2/+6
Allows implementing Stdio::Null for Command in a deterministic manner. Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2025-04-06Rollup merge of #138876 - thaliaarchi:trusty-stdio, r=NoratriebGuillaume Gomez-36/+47
Trusty: Implement `write_vectored` for stdio Currently, `write` for stdout and stderr on Trusty is implemented with the semantics of `write_all`. Instead, call the underlying syscall only once in `write` and use the default implementation of `write_all` like other platforms. Also, implement `write_vectored` by adding support for `IoSlice`. Refactor stdin to reuse the unsupported type like https://github.com/rust-lang/rust/pull/136769. It requires #138875 to fix the build for Trusty, though they do not conflict and can merge in either order. cc `@randomPoison`
2025-04-04Move fd into sysThalia Archibald-1/+1
2025-03-27Trusty: Implement write_vectored for stdioThalia Archibald-36/+47
Currently, `write` for stdout and stderr on Trusty is implemented with the semantics of `write_all`. Instead, call the underlying syscall only once in `write` and use the default implementation of `write_all` like other platforms. Also, implement `write_vectored` by adding support for `IoSlice`. Refactor stdin to reuse the unsupported type like #136769.
2025-03-23Auto merge of #136769 - thaliaarchi:io-optional-methods/stdio, r=joboetbors-133/+101
Provide optional `Read`/`Write` methods for stdio Override more of the default methods for `io::Read` and `io::Write` for stdio types, when efficient to do so, and deduplicate unsupported types. Tracked in https://github.com/rust-lang/rust/issues/136756. try-job: x86_64-msvc-1
2025-03-22Use unit structs for stateless stdioThalia Archibald-12/+12
This seems to be the pattern for newer pal stdio types.
2025-03-22Implement optional methods for unsupported stdioThalia Archibald-1/+64
Match what `std::io::Empty` does, since it is very similar. However, still evaluate the `fmt::Arguments` in `write_fmt` to be consistent with other platforms.
2025-03-18Rollup merge of #138301 - thaliaarchi:io-optional-methods/hermit, r=tgross35Matthias Krüger-4/+1
Implement `read_buf` for Hermit Following https://github.com/hermit-os/kernel/pull/1606, it is now safe to implement `Read::read_buf` for file descriptors on Hermit. cc ```@mkroening```
2025-03-17Implement read_buf for HermitThalia Archibald-4/+1
2025-03-13Rollup merge of #137355 - thaliaarchi:io-optional-methods/sgx, r=ChrisDentonMatthias Krüger-1/+32
Implement `read_buf` and vectored read/write for SGX stdio Implement `read_buf`, `read_vectored`, and `write_vectored` for the SGX stdio types. Additionally, extend `User<T>::copy_to_enclave` to work for copying to uninitialized values and fix unsoundness in `UserRef<[T]>::copy_to_enclave_vec`. cc ``@jethrogb`` Tracked in https://github.com/rust-lang/rust/issues/136756
2025-03-11Deduplicate platform stdio typesThalia Archibald-126/+31
2025-03-10Update Trusty support to account for recent libstd reorganizationNicole L-0/+84
2025-03-10Implement read_buf and vectored read/write for SGX stdioThalia Archibald-1/+32
2025-03-09std: move stdio to `sys`joboet-0/+1461
As per #117276, this moves the platform definitions of `Stdout` and friends into `sys`. This PR also unifies the UNIX and Hermit implementations and moves the `__rust_print_err` function needed by libunwind on SGX into the dedicated module for such helper functions.