diff options
Diffstat (limited to 'vendor/rustix/src/backend/linux_raw/termios')
-rw-r--r-- | vendor/rustix/src/backend/linux_raw/termios/syscalls.rs | 50 | ||||
-rw-r--r-- | vendor/rustix/src/backend/linux_raw/termios/types.rs | 37 |
2 files changed, 86 insertions, 1 deletions
diff --git a/vendor/rustix/src/backend/linux_raw/termios/syscalls.rs b/vendor/rustix/src/backend/linux_raw/termios/syscalls.rs index a8dda5f81..f5643f3c3 100644 --- a/vendor/rustix/src/backend/linux_raw/termios/syscalls.rs +++ b/vendor/rustix/src/backend/linux_raw/termios/syscalls.rs @@ -42,6 +42,30 @@ pub(crate) fn tcgetattr(fd: BorrowedFd<'_>) -> io::Result<Termios> { } #[inline] +#[cfg(any( + target_arch = "x86", + target_arch = "x86_64", + target_arch = "x32", + target_arch = "riscv64", + target_arch = "aarch64", + target_arch = "arm", + target_arch = "mips", + target_arch = "mips64", +))] +pub(crate) fn tcgetattr2(fd: BorrowedFd<'_>) -> io::Result<crate::termios::Termios2> { + unsafe { + let mut result = MaybeUninit::<crate::termios::Termios2>::uninit(); + ret(syscall!( + __NR_ioctl, + fd, + c_uint(linux_raw_sys::ioctl::TCGETS2), + &mut result + ))?; + Ok(result.assume_init()) + } +} + +#[inline] pub(crate) fn tcgetpgrp(fd: BorrowedFd<'_>) -> io::Result<Pid> { unsafe { let mut result = MaybeUninit::<__kernel_pid_t>::uninit(); @@ -78,6 +102,32 @@ pub(crate) fn tcsetattr( } #[inline] +#[cfg(any( + target_arch = "x86", + target_arch = "x86_64", + target_arch = "x32", + target_arch = "riscv64", + target_arch = "aarch64", + target_arch = "arm", + target_arch = "mips", + target_arch = "mips64", +))] +pub(crate) fn tcsetattr2( + fd: BorrowedFd, + optional_actions: OptionalActions, + termios: &crate::termios::Termios2, +) -> io::Result<()> { + unsafe { + ret(syscall_readonly!( + __NR_ioctl, + fd, + c_uint(linux_raw_sys::ioctl::TCSETS2 + optional_actions as u32), + by_ref(termios) + )) + } +} + +#[inline] pub(crate) fn tcsendbreak(fd: BorrowedFd) -> io::Result<()> { unsafe { ret(syscall_readonly!(__NR_ioctl, fd, c_uint(TCSBRK), c_uint(0))) } } diff --git a/vendor/rustix/src/backend/linux_raw/termios/types.rs b/vendor/rustix/src/backend/linux_raw/termios/types.rs index a44f1eda5..3fe45af98 100644 --- a/vendor/rustix/src/backend/linux_raw/termios/types.rs +++ b/vendor/rustix/src/backend/linux_raw/termios/types.rs @@ -7,13 +7,16 @@ use super::super::c; #[repr(u32)] pub enum OptionalActions { /// `TCSANOW`—Make the change immediately. + #[doc(alias = "TCSANOW")] Now = linux_raw_sys::general::TCSANOW, /// `TCSADRAIN`—Make the change after all output has been transmitted. + #[doc(alias = "TCSADRAIN")] Drain = linux_raw_sys::general::TCSADRAIN, /// `TCSAFLUSH`—Discard any pending input and then make the change /// after all output has been transmitted. + #[doc(alias = "TCSAFLUSH")] Flush = linux_raw_sys::general::TCSAFLUSH, } @@ -24,12 +27,15 @@ pub enum OptionalActions { #[repr(u32)] pub enum QueueSelector { /// `TCIFLUSH`—Flush data received but not read. + #[doc(alias = "TCIFLUSH")] IFlush = linux_raw_sys::general::TCIFLUSH, /// `TCOFLUSH`—Flush data written but not transmitted. + #[doc(alias = "TCOFLUSH")] OFlush = linux_raw_sys::general::TCOFLUSH, /// `TCIOFLUSH`—`IFlush` and `OFlush` combined. + #[doc(alias = "TCIOFLUSH")] IOFlush = linux_raw_sys::general::TCIOFLUSH, } @@ -40,34 +46,60 @@ pub enum QueueSelector { #[repr(u32)] pub enum Action { /// `TCOOFF`—Suspend output. + #[doc(alias = "TCOOFF")] OOff = linux_raw_sys::general::TCOOFF, /// `TCOON`—Restart suspended output. + #[doc(alias = "TCOON")] OOn = linux_raw_sys::general::TCOON, /// `TCIOFF`—Transmits a STOP byte. + #[doc(alias = "TCIOFF")] IOff = linux_raw_sys::general::TCIOFF, /// `TCION`—Transmits a START byte. + #[doc(alias = "TCION")] IOn = linux_raw_sys::general::TCION, } -/// `struct termios` for use with [`tcgetattr`]. +/// `struct termios` for use with [`tcgetattr`] and [`tcsetattr`]. /// /// [`tcgetattr`]: crate::termios::tcgetattr +/// [`tcsetattr`]: crate::termios::tcsetattr +#[doc(alias = "termios")] pub type Termios = linux_raw_sys::general::termios; +/// `struct termios2` for use with [`tcgetattr2`] and [`tcsetattr2`]. +/// +/// [`tcgetattr2`]: crate::termios::tcgetattr2 +/// [`tcsetattr2`]: crate::termios::tcsetattr2 +#[cfg(any( + target_arch = "x86", + target_arch = "x86_64", + target_arch = "x32", + target_arch = "riscv64", + target_arch = "aarch64", + target_arch = "arm", + target_arch = "mips", + target_arch = "mips64", +))] +#[doc(alias = "termios2")] +pub type Termios2 = linux_raw_sys::general::termios2; + /// `struct winsize` for use with [`tcgetwinsize`]. /// /// [`tcgetwinsize`]: crate::termios::tcgetwinsize +#[doc(alias = "winsize")] pub type Winsize = linux_raw_sys::general::winsize; /// `tcflag_t`—A type for the flags fields of [`Termios`]. +#[doc(alias = "tcflag_t")] pub type Tcflag = linux_raw_sys::general::tcflag_t; /// `speed_t`—A return type for [`cfsetspeed`] and similar. /// /// [`cfsetspeed`]: crate::termios::cfsetspeed +#[doc(alias = "speed_t")] pub type Speed = linux_raw_sys::general::speed_t; /// `VINTR` @@ -353,6 +385,9 @@ pub const B3500000: Speed = linux_raw_sys::general::B3500000; #[cfg(not(any(target_arch = "sparc", target_arch = "sparc64")))] pub const B4000000: Speed = linux_raw_sys::general::B4000000; +/// `BOTHER` +pub const BOTHER: c::c_uint = linux_raw_sys::general::BOTHER; + /// `CSIZE` pub const CSIZE: c::c_uint = linux_raw_sys::general::CSIZE; |