diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:18:25 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:18:25 +0000 |
commit | 5363f350887b1e5b5dd21a86f88c8af9d7fea6da (patch) | |
tree | 35ca005eb6e0e9a1ba3bb5dbc033209ad445dc17 /vendor/rustix/src/io/stdio.rs | |
parent | Adding debian version 1.66.0+dfsg1-1. (diff) | |
download | rustc-5363f350887b1e5b5dd21a86f88c8af9d7fea6da.tar.xz rustc-5363f350887b1e5b5dd21a86f88c8af9d7fea6da.zip |
Merging upstream version 1.67.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/rustix/src/io/stdio.rs')
-rw-r--r-- | vendor/rustix/src/io/stdio.rs | 96 |
1 files changed, 78 insertions, 18 deletions
diff --git a/vendor/rustix/src/io/stdio.rs b/vendor/rustix/src/io/stdio.rs index f9d03a701..caa8183c2 100644 --- a/vendor/rustix/src/io/stdio.rs +++ b/vendor/rustix/src/io/stdio.rs @@ -8,9 +8,9 @@ //! stdio streams. #![allow(unsafe_code)] -use crate::imp; -use crate::io::OwnedFd; -use imp::fd::{BorrowedFd, FromRawFd, RawFd}; +use crate::backend; +use crate::fd::OwnedFd; +use backend::fd::{BorrowedFd, FromRawFd, RawFd}; /// `STDIN_FILENO`—Standard input, borrowed. /// @@ -36,9 +36,10 @@ use imp::fd::{BorrowedFd, FromRawFd, RawFd}; /// /// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/stdin.html /// [Linux]: https://man7.org/linux/man-pages/man3/stdin.3.html +#[doc(alias = "STDIN_FILENO")] #[inline] -pub unsafe fn stdin() -> BorrowedFd<'static> { - BorrowedFd::borrow_raw(imp::io::types::STDIN_FILENO as RawFd) +pub const unsafe fn stdin() -> BorrowedFd<'static> { + BorrowedFd::borrow_raw(backend::io::types::STDIN_FILENO as RawFd) } /// `STDIN_FILENO`—Standard input, owned. @@ -65,11 +66,10 @@ pub unsafe fn stdin() -> BorrowedFd<'static> { /// /// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/stdin.html /// [Linux]: https://man7.org/linux/man-pages/man3/stdin.3.html +#[doc(alias = "STDIN_FILENO")] #[inline] pub unsafe fn take_stdin() -> OwnedFd { - OwnedFd::from(imp::fd::OwnedFd::from_raw_fd( - imp::io::types::STDIN_FILENO as RawFd, - )) + backend::fd::OwnedFd::from_raw_fd(backend::io::types::STDIN_FILENO as RawFd) } /// `STDOUT_FILENO`—Standard output, borrowed. @@ -97,9 +97,10 @@ pub unsafe fn take_stdin() -> OwnedFd { /// /// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/stdout.html /// [Linux]: https://man7.org/linux/man-pages/man3/stdout.3.html +#[doc(alias = "STDOUT_FILENO")] #[inline] -pub unsafe fn stdout() -> BorrowedFd<'static> { - BorrowedFd::borrow_raw(imp::io::types::STDOUT_FILENO as RawFd) +pub const unsafe fn stdout() -> BorrowedFd<'static> { + BorrowedFd::borrow_raw(backend::io::types::STDOUT_FILENO as RawFd) } /// `STDOUT_FILENO`—Standard output, owned. @@ -126,11 +127,10 @@ pub unsafe fn stdout() -> BorrowedFd<'static> { /// /// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/stdout.html /// [Linux]: https://man7.org/linux/man-pages/man3/stdout.3.html +#[doc(alias = "STDOUT_FILENO")] #[inline] pub unsafe fn take_stdout() -> OwnedFd { - OwnedFd::from(imp::fd::OwnedFd::from_raw_fd( - imp::io::types::STDOUT_FILENO as RawFd, - )) + backend::fd::OwnedFd::from_raw_fd(backend::io::types::STDOUT_FILENO as RawFd) } /// `STDERR_FILENO`—Standard error, borrowed. @@ -157,9 +157,10 @@ pub unsafe fn take_stdout() -> OwnedFd { /// /// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/stderr.html /// [Linux]: https://man7.org/linux/man-pages/man3/stderr.3.html +#[doc(alias = "STDERR_FILENO")] #[inline] -pub unsafe fn stderr() -> BorrowedFd<'static> { - BorrowedFd::borrow_raw(imp::io::types::STDERR_FILENO as RawFd) +pub const unsafe fn stderr() -> BorrowedFd<'static> { + BorrowedFd::borrow_raw(backend::io::types::STDERR_FILENO as RawFd) } /// `STDERR_FILENO`—Standard error, owned. @@ -186,9 +187,68 @@ pub unsafe fn stderr() -> BorrowedFd<'static> { /// /// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/stderr.html /// [Linux]: https://man7.org/linux/man-pages/man3/stderr.3.html +#[doc(alias = "STDERR_FILENO")] #[inline] pub unsafe fn take_stderr() -> OwnedFd { - OwnedFd::from(imp::fd::OwnedFd::from_raw_fd( - imp::io::types::STDERR_FILENO as RawFd, - )) + backend::fd::OwnedFd::from_raw_fd(backend::io::types::STDERR_FILENO as RawFd) +} + +/// `STDIN_FILENO`—Standard input, raw. +/// +/// This is similar to [`stdin`], however it returns a `RawFd`. +/// +/// # Other hazards +/// +/// This has the same hazards as [`stdin`]. +/// +/// # References +/// - [POSIX] +/// - [Linux] +/// +/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/stdin.html +/// [Linux]: https://man7.org/linux/man-pages/man3/stdin.3.html +#[doc(alias = "STDIN_FILENO")] +#[inline] +pub const fn raw_stdin() -> RawFd { + backend::io::types::STDIN_FILENO as RawFd +} + +/// `STDOUT_FILENO`—Standard output, raw. +/// +/// This is similar to [`stdout`], however it returns a `RawFd`. +/// +/// # Other hazards +/// +/// This has the same hazards as [`stdout`]. +/// +/// # References +/// - [POSIX] +/// - [Linux] +/// +/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/stdout.html +/// [Linux]: https://man7.org/linux/man-pages/man3/stdout.3.html +#[doc(alias = "STDOUT_FILENO")] +#[inline] +pub const fn raw_stdout() -> RawFd { + backend::io::types::STDOUT_FILENO as RawFd +} + +/// `STDERR_FILENO`—Standard error, raw. +/// +/// This is similar to [`stderr`], however it returns a `RawFd`. +/// +/// # Other hazards +/// +/// This has the same hazards as [`stderr`]. +/// +/// # References +/// - [POSIX] +/// - [Linux] +/// +/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/stderr.html +/// [Linux]: https://man7.org/linux/man-pages/man3/stderr.3.html +#[doc(alias = "STDERR_FILENO")] +#[inline] +pub const fn raw_stderr() -> RawFd { + backend::io::types::STDERR_FILENO as RawFd } |