diff options
Diffstat (limited to 'vendor/rustix/src/backend/libc/termios/syscalls.rs')
-rw-r--r-- | vendor/rustix/src/backend/libc/termios/syscalls.rs | 62 |
1 files changed, 44 insertions, 18 deletions
diff --git a/vendor/rustix/src/backend/libc/termios/syscalls.rs b/vendor/rustix/src/backend/libc/termios/syscalls.rs index d4182f4fe..ea284927f 100644 --- a/vendor/rustix/src/backend/libc/termios/syscalls.rs +++ b/vendor/rustix/src/backend/libc/termios/syscalls.rs @@ -5,21 +5,30 @@ //! See the `rustix::backend::syscalls` module documentation for details. use crate::backend::c; -use crate::backend::conv::{borrowed_fd, ret, ret_pid_t}; +#[cfg(not(target_os = "wasi"))] +use crate::backend::conv::ret_pid_t; +use crate::backend::conv::{borrowed_fd, ret}; use crate::fd::BorrowedFd; #[cfg(feature = "procfs")] #[cfg(not(any(target_os = "fuchsia", target_os = "wasi")))] use crate::ffi::CStr; +#[cfg(any( + not(target_os = "espidf"), + all( + feature = "procfs", + not(any(target_os = "fuchsia", target_os = "wasi")) + ) +))] use core::mem::MaybeUninit; #[cfg(not(target_os = "wasi"))] +use {crate::io, crate::pid::Pid}; +#[cfg(not(any(target_os = "espidf", target_os = "wasi")))] use { - crate::io, - crate::pid::Pid, crate::termios::{Action, OptionalActions, QueueSelector, Termios, Winsize}, crate::utils::as_mut_ptr, }; -#[cfg(not(target_os = "wasi"))] +#[cfg(not(any(target_os = "espidf", target_os = "wasi")))] pub(crate) fn tcgetattr(fd: BorrowedFd<'_>) -> io::Result<Termios> { // If we have `TCGETS2`, use it, so that we fill in the `c_ispeed` and // `c_ospeed` fields. @@ -32,7 +41,7 @@ pub(crate) fn tcgetattr(fd: BorrowedFd<'_>) -> io::Result<Termios> { ret(c::ioctl( borrowed_fd(fd), - c::TCGETS2.into(), + c::TCGETS2 as _, termios2.as_mut_ptr(), ))?; @@ -58,6 +67,8 @@ pub(crate) fn tcgetattr(fd: BorrowedFd<'_>) -> io::Result<Termios> { unsafe { let mut result = MaybeUninit::<Termios>::uninit(); + // `result` is a `Termios` which starts with the same layout as + // `libc::termios`, so we can cast the pointer. ret(c::tcgetattr(borrowed_fd(fd), result.as_mut_ptr().cast()))?; Ok(result.assume_init()) @@ -77,7 +88,7 @@ pub(crate) fn tcsetpgrp(fd: BorrowedFd<'_>, pid: Pid) -> io::Result<()> { unsafe { ret(c::tcsetpgrp(borrowed_fd(fd), pid.as_raw_nonzero().get())) } } -#[cfg(not(target_os = "wasi"))] +#[cfg(not(any(target_os = "espidf", target_os = "wasi")))] pub(crate) fn tcsetattr( fd: BorrowedFd, optional_actions: OptionalActions, @@ -104,7 +115,12 @@ pub(crate) fn tcsetattr( // Translate from `optional_actions` into an ioctl request code. On MIPS, // `optional_actions` already has `TCGETS` added to it. let request = TCSETS2 - + if cfg!(any(target_arch = "mips", target_arch = "mips64")) { + + if cfg!(any( + target_arch = "mips", + target_arch = "mips32r6", + target_arch = "mips64", + target_arch = "mips64r6" + )) { optional_actions as u32 - TCSETS } else { optional_actions as u32 @@ -151,17 +167,17 @@ pub(crate) fn tcsendbreak(fd: BorrowedFd) -> io::Result<()> { unsafe { ret(c::tcsendbreak(borrowed_fd(fd), 0)) } } -#[cfg(not(target_os = "wasi"))] +#[cfg(not(any(target_os = "espidf", target_os = "wasi")))] pub(crate) fn tcdrain(fd: BorrowedFd) -> io::Result<()> { unsafe { ret(c::tcdrain(borrowed_fd(fd))) } } -#[cfg(not(target_os = "wasi"))] +#[cfg(not(any(target_os = "espidf", target_os = "wasi")))] pub(crate) fn tcflush(fd: BorrowedFd, queue_selector: QueueSelector) -> io::Result<()> { unsafe { ret(c::tcflush(borrowed_fd(fd), queue_selector as _)) } } -#[cfg(not(target_os = "wasi"))] +#[cfg(not(any(target_os = "espidf", target_os = "wasi")))] pub(crate) fn tcflow(fd: BorrowedFd, action: Action) -> io::Result<()> { unsafe { ret(c::tcflow(borrowed_fd(fd), action as _)) } } @@ -174,12 +190,12 @@ pub(crate) fn tcgetsid(fd: BorrowedFd) -> io::Result<Pid> { } } -#[cfg(not(target_os = "wasi"))] +#[cfg(not(any(target_os = "espidf", target_os = "wasi")))] pub(crate) fn tcsetwinsize(fd: BorrowedFd, winsize: Winsize) -> io::Result<()> { unsafe { ret(c::ioctl(borrowed_fd(fd), c::TIOCSWINSZ, &winsize)) } } -#[cfg(not(target_os = "wasi"))] +#[cfg(not(any(target_os = "espidf", target_os = "wasi")))] pub(crate) fn tcgetwinsize(fd: BorrowedFd) -> io::Result<Winsize> { unsafe { let mut buf = MaybeUninit::<Winsize>::uninit(); @@ -192,17 +208,27 @@ pub(crate) fn tcgetwinsize(fd: BorrowedFd) -> io::Result<Winsize> { } } -#[cfg(not(any(target_os = "haiku", target_os = "redox", target_os = "wasi")))] +#[cfg(not(any( + target_os = "espidf", + target_os = "haiku", + target_os = "redox", + target_os = "wasi" +)))] pub(crate) fn ioctl_tiocexcl(fd: BorrowedFd) -> io::Result<()> { unsafe { ret(c::ioctl(borrowed_fd(fd), c::TIOCEXCL as _)) } } -#[cfg(not(any(target_os = "haiku", target_os = "redox", target_os = "wasi")))] +#[cfg(not(any( + target_os = "espidf", + target_os = "haiku", + target_os = "redox", + target_os = "wasi" +)))] pub(crate) fn ioctl_tiocnxcl(fd: BorrowedFd) -> io::Result<()> { unsafe { ret(c::ioctl(borrowed_fd(fd), c::TIOCNXCL as _)) } } -#[cfg(not(target_os = "wasi"))] +#[cfg(not(any(target_os = "espidf", target_os = "nto", target_os = "wasi")))] #[inline] pub(crate) fn set_speed(termios: &mut Termios, arbitrary_speed: u32) -> io::Result<()> { #[cfg(bsd)] @@ -244,7 +270,7 @@ pub(crate) fn set_speed(termios: &mut Termios, arbitrary_speed: u32) -> io::Resu } } -#[cfg(not(target_os = "wasi"))] +#[cfg(not(any(target_os = "espidf", target_os = "wasi")))] #[inline] pub(crate) fn set_output_speed(termios: &mut Termios, arbitrary_speed: u32) -> io::Result<()> { #[cfg(bsd)] @@ -284,7 +310,7 @@ pub(crate) fn set_output_speed(termios: &mut Termios, arbitrary_speed: u32) -> i } } -#[cfg(not(target_os = "wasi"))] +#[cfg(not(any(target_os = "espidf", target_os = "wasi")))] #[inline] pub(crate) fn set_input_speed(termios: &mut Termios, arbitrary_speed: u32) -> io::Result<()> { #[cfg(bsd)] @@ -324,7 +350,7 @@ pub(crate) fn set_input_speed(termios: &mut Termios, arbitrary_speed: u32) -> io } } -#[cfg(not(target_os = "wasi"))] +#[cfg(not(any(target_os = "espidf", target_os = "nto", target_os = "wasi")))] #[inline] pub(crate) fn cfmakeraw(termios: &mut Termios) { unsafe { c::cfmakeraw(as_mut_ptr(termios).cast()) } |