diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:57:31 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:57:31 +0000 |
commit | dc0db358abe19481e475e10c32149b53370f1a1c (patch) | |
tree | ab8ce99c4b255ce46f99ef402c27916055b899ee /vendor/rustix/src/backend/libc/termios | |
parent | Releasing progress-linux version 1.71.1+dfsg1-2~progress7.99u1. (diff) | |
download | rustc-dc0db358abe19481e475e10c32149b53370f1a1c.tar.xz rustc-dc0db358abe19481e475e10c32149b53370f1a1c.zip |
Merging upstream version 1.72.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/rustix/src/backend/libc/termios')
-rw-r--r-- | vendor/rustix/src/backend/libc/termios/mod.rs | 2 | ||||
-rw-r--r-- | vendor/rustix/src/backend/libc/termios/syscalls.rs | 297 | ||||
-rw-r--r-- | vendor/rustix/src/backend/libc/termios/types.rs | 736 |
3 files changed, 219 insertions, 816 deletions
diff --git a/vendor/rustix/src/backend/libc/termios/mod.rs b/vendor/rustix/src/backend/libc/termios/mod.rs index c82c95958..ef944f04d 100644 --- a/vendor/rustix/src/backend/libc/termios/mod.rs +++ b/vendor/rustix/src/backend/libc/termios/mod.rs @@ -1,3 +1 @@ pub(crate) mod syscalls; -#[cfg(not(target_os = "wasi"))] -pub(crate) mod types; diff --git a/vendor/rustix/src/backend/libc/termios/syscalls.rs b/vendor/rustix/src/backend/libc/termios/syscalls.rs index dba73c960..d4182f4fe 100644 --- a/vendor/rustix/src/backend/libc/termios/syscalls.rs +++ b/vendor/rustix/src/backend/libc/termios/syscalls.rs @@ -4,46 +4,62 @@ //! //! See the `rustix::backend::syscalls` module documentation for details. -use super::super::c; -use super::super::conv::{borrowed_fd, ret, ret_pid_t}; +use crate::backend::c; +use crate::backend::conv::{borrowed_fd, ret, ret_pid_t}; use crate::fd::BorrowedFd; #[cfg(feature = "procfs")] #[cfg(not(any(target_os = "fuchsia", target_os = "wasi")))] use crate::ffi::CStr; -#[cfg(not(target_os = "wasi"))] -use crate::io; -#[cfg(not(target_os = "wasi"))] -use crate::process::{Pid, RawNonZeroPid}; -#[cfg(not(target_os = "wasi"))] -use crate::termios::{Action, OptionalActions, QueueSelector, Speed, Termios, Winsize}; use core::mem::MaybeUninit; +#[cfg(not(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"))] pub(crate) fn tcgetattr(fd: BorrowedFd<'_>) -> io::Result<Termios> { - let mut result = MaybeUninit::<Termios>::uninit(); + // If we have `TCGETS2`, use it, so that we fill in the `c_ispeed` and + // `c_ospeed` fields. + #[cfg(linux_kernel)] unsafe { - ret(c::tcgetattr(borrowed_fd(fd), result.as_mut_ptr()))?; - Ok(result.assume_init()) + use crate::termios::{ControlModes, InputModes, LocalModes, OutputModes, SpecialCodes}; + use core::mem::zeroed; + + let mut termios2 = MaybeUninit::<c::termios2>::uninit(); + + ret(c::ioctl( + borrowed_fd(fd), + c::TCGETS2.into(), + termios2.as_mut_ptr(), + ))?; + + let termios2 = termios2.assume_init(); + + // Convert from the Linux `termios2` to our `Termios`. + let mut result = Termios { + input_modes: InputModes::from_bits_retain(termios2.c_iflag), + output_modes: OutputModes::from_bits_retain(termios2.c_oflag), + control_modes: ControlModes::from_bits_retain(termios2.c_cflag), + local_modes: LocalModes::from_bits_retain(termios2.c_lflag), + line_discipline: termios2.c_line, + special_codes: SpecialCodes(zeroed()), + input_speed: termios2.c_ispeed, + output_speed: termios2.c_ospeed, + }; + result.special_codes.0[..termios2.c_cc.len()].copy_from_slice(&termios2.c_cc); + + Ok(result) } -} -#[cfg(all( - any(target_os = "android", target_os = "linux"), - 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> { - let mut result = MaybeUninit::<crate::termios::Termios2>::uninit(); + #[cfg(not(linux_kernel))] unsafe { - ret(c::ioctl(borrowed_fd(fd), c::TCGETS2, result.as_mut_ptr()))?; + let mut result = MaybeUninit::<Termios>::uninit(); + + ret(c::tcgetattr(borrowed_fd(fd), result.as_mut_ptr().cast()))?; + Ok(result.assume_init()) } } @@ -52,8 +68,7 @@ pub(crate) fn tcgetattr2(fd: BorrowedFd<'_>) -> io::Result<crate::termios::Termi pub(crate) fn tcgetpgrp(fd: BorrowedFd<'_>) -> io::Result<Pid> { unsafe { let pid = ret_pid_t(c::tcgetpgrp(borrowed_fd(fd)))?; - debug_assert_ne!(pid, 0); - Ok(Pid::from_raw_nonzero(RawNonZeroPid::new_unchecked(pid))) + Ok(Pid::from_raw_unchecked(pid)) } } @@ -68,38 +83,65 @@ pub(crate) fn tcsetattr( optional_actions: OptionalActions, termios: &Termios, ) -> io::Result<()> { + // If we have `TCSETS2`, use it, so that we use the `c_ispeed` and + // `c_ospeed` fields. + #[cfg(linux_kernel)] unsafe { - ret(c::tcsetattr( - borrowed_fd(fd), - optional_actions as _, - termios, - )) + use crate::termios::speed; + use core::mem::zeroed; + use linux_raw_sys::general::{termios2, BOTHER, CBAUD, IBSHIFT}; + + #[cfg(not(any(target_arch = "sparc", target_arch = "sparc64")))] + use linux_raw_sys::ioctl::{TCSETS, TCSETS2}; + + // linux-raw-sys' ioctl-generation script for sparc isn't working yet, + // so as a temporary workaround, declare these manually. + #[cfg(any(target_arch = "sparc", target_arch = "sparc64"))] + const TCSETS: u32 = 0x80245409; + #[cfg(any(target_arch = "sparc", target_arch = "sparc64"))] + const TCSETS2: u32 = 0x802c540d; + + // 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")) { + optional_actions as u32 - TCSETS + } else { + optional_actions as u32 + }; + + let input_speed = termios.input_speed(); + let output_speed = termios.output_speed(); + let mut termios2 = termios2 { + c_iflag: termios.input_modes.bits(), + c_oflag: termios.output_modes.bits(), + c_cflag: termios.control_modes.bits(), + c_lflag: termios.local_modes.bits(), + c_line: termios.line_discipline, + c_cc: zeroed(), + c_ispeed: input_speed, + c_ospeed: output_speed, + }; + // Ensure that our input and output speeds are set, as `libc` + // routines don't always support setting these separately. + termios2.c_cflag &= !CBAUD; + termios2.c_cflag |= speed::encode(output_speed).unwrap_or(BOTHER); + termios2.c_cflag &= !(CBAUD << IBSHIFT); + termios2.c_cflag |= speed::encode(input_speed).unwrap_or(BOTHER) << IBSHIFT; + let nccs = termios2.c_cc.len(); + termios2 + .c_cc + .copy_from_slice(&termios.special_codes.0[..nccs]); + + ret(c::ioctl(borrowed_fd(fd), request as _, &termios2)) } -} -#[cfg(all( - any(target_os = "android", target_os = "linux"), - 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<()> { + #[cfg(not(linux_kernel))] unsafe { - ret(c::ioctl( + ret(c::tcsetattr( borrowed_fd(fd), - (c::TCSETS2 as u32 + optional_actions as u32) as _, - termios, + optional_actions as _, + crate::utils::as_ptr(termios).cast(), )) } } @@ -128,8 +170,7 @@ pub(crate) fn tcflow(fd: BorrowedFd, action: Action) -> io::Result<()> { pub(crate) fn tcgetsid(fd: BorrowedFd) -> io::Result<Pid> { unsafe { let pid = ret_pid_t(c::tcgetsid(borrowed_fd(fd)))?; - debug_assert_ne!(pid, 0); - Ok(Pid::from_raw_nonzero(RawNonZeroPid::new_unchecked(pid))) + Ok(Pid::from_raw_unchecked(pid)) } } @@ -151,42 +192,142 @@ pub(crate) fn tcgetwinsize(fd: BorrowedFd) -> io::Result<Winsize> { } } -#[cfg(not(target_os = "wasi"))] -#[inline] -#[must_use] -pub(crate) fn cfgetospeed(termios: &Termios) -> Speed { - unsafe { c::cfgetospeed(termios) } +#[cfg(not(any(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(target_os = "wasi"))] -#[inline] -#[must_use] -pub(crate) fn cfgetispeed(termios: &Termios) -> Speed { - unsafe { c::cfgetispeed(termios) } +#[cfg(not(any(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"))] #[inline] -pub(crate) fn cfmakeraw(termios: &mut Termios) { - unsafe { c::cfmakeraw(termios) } +pub(crate) fn set_speed(termios: &mut Termios, arbitrary_speed: u32) -> io::Result<()> { + #[cfg(bsd)] + let encoded_speed = arbitrary_speed; + + #[cfg(not(bsd))] + let encoded_speed = match crate::termios::speed::encode(arbitrary_speed) { + Some(encoded_speed) => encoded_speed, + #[cfg(linux_kernel)] + None => c::BOTHER, + #[cfg(not(linux_kernel))] + None => return Err(io::Errno::INVAL), + }; + + #[cfg(not(linux_kernel))] + unsafe { + ret(c::cfsetspeed( + as_mut_ptr(termios).cast(), + encoded_speed.into(), + )) + } + + // Linux libc implementations don't support arbitrary speeds, so we encode + // the speed manually. + #[cfg(linux_kernel)] + { + use crate::termios::ControlModes; + + debug_assert_eq!(encoded_speed & !c::CBAUD, 0); + + termios.control_modes -= ControlModes::from_bits_retain(c::CBAUD | c::CIBAUD); + termios.control_modes |= + ControlModes::from_bits_retain(encoded_speed | (encoded_speed << c::IBSHIFT)); + + termios.input_speed = arbitrary_speed; + termios.output_speed = arbitrary_speed; + + Ok(()) + } } #[cfg(not(target_os = "wasi"))] #[inline] -pub(crate) fn cfsetospeed(termios: &mut Termios, speed: Speed) -> io::Result<()> { - unsafe { ret(c::cfsetospeed(termios, speed)) } +pub(crate) fn set_output_speed(termios: &mut Termios, arbitrary_speed: u32) -> io::Result<()> { + #[cfg(bsd)] + let encoded_speed = arbitrary_speed; + + #[cfg(not(bsd))] + let encoded_speed = match crate::termios::speed::encode(arbitrary_speed) { + Some(encoded_speed) => encoded_speed, + #[cfg(linux_kernel)] + None => c::BOTHER, + #[cfg(not(linux_kernel))] + None => return Err(io::Errno::INVAL), + }; + + #[cfg(not(linux_kernel))] + unsafe { + ret(c::cfsetospeed( + as_mut_ptr(termios).cast(), + encoded_speed.into(), + )) + } + + // Linux libc implementations don't support arbitrary speeds or setting the + // input and output speeds separately, so we encode the speed manually. + #[cfg(linux_kernel)] + { + use crate::termios::ControlModes; + + debug_assert_eq!(encoded_speed & !c::CBAUD, 0); + + termios.control_modes -= ControlModes::from_bits_retain(c::CBAUD); + termios.control_modes |= ControlModes::from_bits_retain(encoded_speed); + + termios.output_speed = arbitrary_speed; + + Ok(()) + } } #[cfg(not(target_os = "wasi"))] #[inline] -pub(crate) fn cfsetispeed(termios: &mut Termios, speed: Speed) -> io::Result<()> { - unsafe { ret(c::cfsetispeed(termios, speed)) } +pub(crate) fn set_input_speed(termios: &mut Termios, arbitrary_speed: u32) -> io::Result<()> { + #[cfg(bsd)] + let encoded_speed = arbitrary_speed; + + #[cfg(not(bsd))] + let encoded_speed = match crate::termios::speed::encode(arbitrary_speed) { + Some(encoded_speed) => encoded_speed, + #[cfg(linux_kernel)] + None => c::BOTHER, + #[cfg(not(linux_kernel))] + None => return Err(io::Errno::INVAL), + }; + + #[cfg(not(linux_kernel))] + unsafe { + ret(c::cfsetispeed( + as_mut_ptr(termios).cast(), + encoded_speed.into(), + )) + } + + // Linux libc implementations don't support arbitrary speeds or setting the + // input and output speeds separately, so we encode the speed manually. + #[cfg(linux_kernel)] + { + use crate::termios::ControlModes; + + debug_assert_eq!(encoded_speed & !c::CBAUD, 0); + + termios.control_modes -= ControlModes::from_bits_retain(c::CIBAUD); + termios.control_modes |= ControlModes::from_bits_retain(encoded_speed << c::IBSHIFT); + + termios.input_speed = arbitrary_speed; + + Ok(()) + } } #[cfg(not(target_os = "wasi"))] #[inline] -pub(crate) fn cfsetspeed(termios: &mut Termios, speed: Speed) -> io::Result<()> { - unsafe { ret(c::cfsetspeed(termios, speed)) } +pub(crate) fn cfmakeraw(termios: &mut Termios) { + unsafe { c::cfmakeraw(as_mut_ptr(termios).cast()) } } pub(crate) fn isatty(fd: BorrowedFd<'_>) -> bool { @@ -200,7 +341,7 @@ pub(crate) fn isatty(fd: BorrowedFd<'_>) -> bool { #[cfg(feature = "procfs")] #[cfg(not(any(target_os = "fuchsia", target_os = "wasi")))] -pub(crate) fn ttyname(dirfd: BorrowedFd<'_>, buf: &mut [u8]) -> io::Result<usize> { +pub(crate) fn ttyname(dirfd: BorrowedFd<'_>, buf: &mut [MaybeUninit<u8>]) -> io::Result<usize> { unsafe { // `ttyname_r` returns its error status rather than using `errno`. match c::ttyname_r(borrowed_fd(dirfd), buf.as_mut_ptr().cast(), buf.len()) { diff --git a/vendor/rustix/src/backend/libc/termios/types.rs b/vendor/rustix/src/backend/libc/termios/types.rs deleted file mode 100644 index fdb7fc644..000000000 --- a/vendor/rustix/src/backend/libc/termios/types.rs +++ /dev/null @@ -1,736 +0,0 @@ -use super::super::c; - -/// `TCSA*` values for use with [`tcsetattr`]. -/// -/// [`tcsetattr`]: crate::termios::tcsetattr -#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)] -#[repr(i32)] -pub enum OptionalActions { - /// `TCSANOW`—Make the change immediately. - #[doc(alias = "TCSANOW")] - Now = c::TCSANOW, - - /// `TCSADRAIN`—Make the change after all output has been transmitted. - #[doc(alias = "TCSADRAIN")] - Drain = c::TCSADRAIN, - - /// `TCSAFLUSH`—Discard any pending input and then make the change - /// after all output has been transmitted. - #[doc(alias = "TCSAFLUSH")] - Flush = c::TCSAFLUSH, -} - -/// `TC*` values for use with [`tcflush`]. -/// -/// [`tcflush`]: crate::termios::tcflush -#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)] -#[repr(i32)] -pub enum QueueSelector { - /// `TCIFLUSH`—Flush data received but not read. - #[doc(alias = "TCIFLUSH")] - IFlush = c::TCIFLUSH, - - /// `TCOFLUSH`—Flush data written but not transmitted. - #[doc(alias = "TCOFLUSH")] - OFlush = c::TCOFLUSH, - - /// `TCIOFLUSH`—`IFlush` and `OFlush` combined. - #[doc(alias = "TCIOFLUSH")] - IOFlush = c::TCIOFLUSH, -} - -/// `TC*` values for use with [`tcflow`]. -/// -/// [`tcflow`]: crate::termios::tcflow -#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)] -#[repr(i32)] -pub enum Action { - /// `TCOOFF`—Suspend output. - #[doc(alias = "TCOOFF")] - OOff = c::TCOOFF, - - /// `TCOON`—Restart suspended output. - #[doc(alias = "TCOON")] - OOn = c::TCOON, - - /// `TCIOFF`—Transmits a STOP byte. - #[doc(alias = "TCIOFF")] - IOff = c::TCIOFF, - - /// `TCION`—Transmits a START byte. - #[doc(alias = "TCION")] - IOn = c::TCION, -} - -/// `struct termios` for use with [`tcgetattr`] and [`tcsetattr`]. -/// -/// [`tcgetattr`]: crate::termios::tcgetattr -/// [`tcsetattr`]: crate::termios::tcsetattr -#[doc(alias = "termios")] -pub type Termios = c::termios; - -/// `struct termios2` for use with [`tcgetattr2`] and [`tcsetattr2`]. -/// -/// [`tcgetattr2`]: crate::termios::tcgetattr2 -/// [`tcsetattr2`]: crate::termios::tcsetattr2 -#[cfg(all( - any(target_os = "android", target_os = "linux"), - 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 = c::termios2; - -/// `struct winsize` for use with [`tcgetwinsize`]. -/// -/// [`tcgetwinsize`]: crate::termios::tcgetwinsize -#[doc(alias = "winsize")] -pub type Winsize = c::winsize; - -/// `tcflag_t`—A type for the flags fields of [`Termios`]. -#[doc(alias = "tcflag_t")] -pub type Tcflag = c::tcflag_t; - -/// `speed_t`—A return type for [`cfsetspeed`] and similar. -/// -/// [`cfsetspeed`]: crate::termios::cfsetspeed -#[doc(alias = "speed_t")] -pub type Speed = c::speed_t; - -/// `VINTR` -pub const VINTR: usize = c::VINTR as usize; - -/// `VQUIT` -pub const VQUIT: usize = c::VQUIT as usize; - -/// `VERASE` -pub const VERASE: usize = c::VERASE as usize; - -/// `VKILL` -pub const VKILL: usize = c::VKILL as usize; - -/// `VEOF` -pub const VEOF: usize = c::VEOF as usize; - -/// `VTIME` -pub const VTIME: usize = c::VTIME as usize; - -/// `VMIN` -pub const VMIN: usize = c::VMIN as usize; - -/// `VSWTC` -#[cfg(not(any( - apple, - solarish, - target_os = "aix", - target_os = "dragonfly", - target_os = "freebsd", - target_os = "haiku", - target_os = "netbsd", - target_os = "openbsd", -)))] -pub const VSWTC: usize = c::VSWTC as usize; - -/// `VSTART` -pub const VSTART: usize = c::VSTART as usize; - -/// `VSTOP` -pub const VSTOP: usize = c::VSTOP as usize; - -/// `VSUSP` -pub const VSUSP: usize = c::VSUSP as usize; - -/// `VEOL` -pub const VEOL: usize = c::VEOL as usize; - -/// `VREPRINT` -#[cfg(not(target_os = "haiku"))] -pub const VREPRINT: usize = c::VREPRINT as usize; - -/// `VDISCARD` -#[cfg(not(any(target_os = "aix", target_os = "haiku")))] -pub const VDISCARD: usize = c::VDISCARD as usize; - -/// `VWERASE` -#[cfg(not(any(target_os = "aix", target_os = "haiku")))] -pub const VWERASE: usize = c::VWERASE as usize; - -/// `VLNEXT` -#[cfg(not(target_os = "haiku"))] -pub const VLNEXT: usize = c::VLNEXT as usize; - -/// `VEOL2` -pub const VEOL2: usize = c::VEOL2 as usize; - -/// `IGNBRK` -pub const IGNBRK: Tcflag = c::IGNBRK; - -/// `BRKINT` -pub const BRKINT: Tcflag = c::BRKINT; - -/// `IGNPAR` -pub const IGNPAR: Tcflag = c::IGNPAR; - -/// `PARMRK` -pub const PARMRK: Tcflag = c::PARMRK; - -/// `INPCK` -pub const INPCK: Tcflag = c::INPCK; - -/// `ISTRIP` -pub const ISTRIP: Tcflag = c::ISTRIP; - -/// `INLCR` -pub const INLCR: Tcflag = c::INLCR; - -/// `IGNCR` -pub const IGNCR: Tcflag = c::IGNCR; - -/// `ICRNL` -pub const ICRNL: Tcflag = c::ICRNL; - -/// `IUCLC` -#[cfg(any(solarish, target_os = "haiku"))] -pub const IUCLC: Tcflag = c::IUCLC; - -/// `IXON` -pub const IXON: Tcflag = c::IXON; - -/// `IXANY` -#[cfg(not(target_os = "redox"))] -pub const IXANY: Tcflag = c::IXANY; - -/// `IXOFF` -pub const IXOFF: Tcflag = c::IXOFF; - -/// `IMAXBEL` -#[cfg(not(any(target_os = "haiku", target_os = "redox")))] -pub const IMAXBEL: Tcflag = c::IMAXBEL; - -/// `IUTF8` -#[cfg(not(any( - solarish, - target_os = "aix", - target_os = "dragonfly", - target_os = "emscripten", - target_os = "freebsd", - target_os = "haiku", - target_os = "netbsd", - target_os = "openbsd", - target_os = "redox", -)))] -pub const IUTF8: Tcflag = c::IUTF8; - -/// `OPOST` -pub const OPOST: Tcflag = c::OPOST; - -/// `OLCUC` -#[cfg(not(any( - apple, - target_os = "aix", - target_os = "dragonfly", - target_os = "freebsd", - target_os = "netbsd", - target_os = "redox", -)))] -pub const OLCUC: Tcflag = c::OLCUC; - -/// `ONLCR` -pub const ONLCR: Tcflag = c::ONLCR; - -/// `OCRNL` -pub const OCRNL: Tcflag = c::OCRNL; - -/// `ONOCR` -pub const ONOCR: Tcflag = c::ONOCR; - -/// `ONLRET` -pub const ONLRET: Tcflag = c::ONLRET; - -/// `OFILL` -#[cfg(not(bsd))] -pub const OFILL: Tcflag = c::OFILL; - -/// `OFDEL` -#[cfg(not(bsd))] -pub const OFDEL: Tcflag = c::OFDEL; - -/// `NLDLY` -#[cfg(not(any(bsd, solarish, target_os = "redox")))] -pub const NLDLY: Tcflag = c::NLDLY; - -/// `NL0` -#[cfg(not(any(bsd, solarish, target_os = "fuchsia", target_os = "redox")))] -pub const NL0: Tcflag = c::NL0; - -/// `NL1` -#[cfg(not(any(bsd, solarish, target_os = "fuchsia", target_os = "redox")))] -pub const NL1: Tcflag = c::NL1; - -/// `CRDLY` -#[cfg(not(any(bsd, solarish, target_os = "redox")))] -pub const CRDLY: Tcflag = c::CRDLY; - -/// `CR0` -#[cfg(not(any(bsd, solarish, target_os = "fuchsia", target_os = "redox")))] -pub const CR0: Tcflag = c::CR0; - -/// `CR1` -#[cfg(not(any( - target_env = "musl", - bsd, - solarish, - target_os = "emscripten", - target_os = "fuchsia", - target_os = "redox", -)))] -pub const CR1: Tcflag = c::CR1; - -/// `CR2` -#[cfg(not(any( - target_env = "musl", - bsd, - solarish, - target_os = "emscripten", - target_os = "fuchsia", - target_os = "redox", -)))] -pub const CR2: Tcflag = c::CR2; - -/// `CR3` -#[cfg(not(any( - target_env = "musl", - bsd, - solarish, - target_os = "emscripten", - target_os = "fuchsia", - target_os = "redox", -)))] -pub const CR3: Tcflag = c::CR3; - -/// `TABDLY` -#[cfg(not(any(netbsdlike, solarish, target_os = "dragonfly", target_os = "redox",)))] -pub const TABDLY: Tcflag = c::TABDLY; - -/// `TAB0` -#[cfg(not(any( - netbsdlike, - solarish, - target_os = "dragonfly", - target_os = "fuchsia", - target_os = "redox", -)))] -pub const TAB0: Tcflag = c::TAB0; - -/// `TAB1` -#[cfg(not(any( - target_env = "musl", - bsd, - solarish, - target_os = "emscripten", - target_os = "fuchsia", - target_os = "redox", -)))] -pub const TAB1: Tcflag = c::TAB1; - -/// `TAB2` -#[cfg(not(any( - target_env = "musl", - bsd, - solarish, - target_os = "emscripten", - target_os = "fuchsia", - target_os = "redox", -)))] -pub const TAB2: Tcflag = c::TAB2; - -/// `TAB3` -#[cfg(not(any( - target_env = "musl", - bsd, - solarish, - target_os = "emscripten", - target_os = "fuchsia", - target_os = "redox", -)))] -pub const TAB3: Tcflag = c::TAB3; - -/// `BSDLY` -#[cfg(not(any(bsd, solarish, target_os = "redox")))] -pub const BSDLY: Tcflag = c::BSDLY; - -/// `BS0` -#[cfg(not(any(bsd, solarish, target_os = "fuchsia", target_os = "redox")))] -pub const BS0: Tcflag = c::BS0; - -/// `BS1` -#[cfg(not(any( - target_env = "musl", - bsd, - solarish, - target_os = "emscripten", - target_os = "fuchsia", - target_os = "redox", -)))] -pub const BS1: Tcflag = c::BS1; - -/// `FFDLY` -#[cfg(not(any(target_env = "musl", bsd, solarish, target_os = "redox")))] -pub const FFDLY: Tcflag = c::FFDLY; - -/// `FF0` -#[cfg(not(any(bsd, solarish, target_os = "fuchsia", target_os = "redox")))] -pub const FF0: Tcflag = c::FF0; - -/// `FF1` -#[cfg(not(any( - target_env = "musl", - bsd, - solarish, - target_os = "emscripten", - target_os = "fuchsia", - target_os = "redox", -)))] -pub const FF1: Tcflag = c::FF1; - -/// `VTDLY` -#[cfg(not(any(target_env = "musl", bsd, solarish, target_os = "redox")))] -pub const VTDLY: Tcflag = c::VTDLY; - -/// `VT0` -#[cfg(not(any(bsd, solarish, target_os = "fuchsia", target_os = "redox")))] -pub const VT0: Tcflag = c::VT0; - -/// `VT1` -#[cfg(not(any( - target_env = "musl", - bsd, - solarish, - target_os = "emscripten", - target_os = "fuchsia", - target_os = "redox", -)))] -pub const VT1: Tcflag = c::VT1; - -/// `B0` -pub const B0: Speed = c::B0; - -/// `B50` -pub const B50: Speed = c::B50; - -/// `B75` -pub const B75: Speed = c::B75; - -/// `B110` -pub const B110: Speed = c::B110; - -/// `B134` -pub const B134: Speed = c::B134; - -/// `B150` -pub const B150: Speed = c::B150; - -/// `B200` -pub const B200: Speed = c::B200; - -/// `B300` -pub const B300: Speed = c::B300; - -/// `B600` -pub const B600: Speed = c::B600; - -/// `B1200` -pub const B1200: Speed = c::B1200; - -/// `B1800` -pub const B1800: Speed = c::B1800; - -/// `B2400` -pub const B2400: Speed = c::B2400; - -/// `B4800` -pub const B4800: Speed = c::B4800; - -/// `B9600` -pub const B9600: Speed = c::B9600; - -/// `B19200` -pub const B19200: Speed = c::B19200; - -/// `B38400` -pub const B38400: Speed = c::B38400; - -/// `B57600` -#[cfg(not(target_os = "aix"))] -pub const B57600: Speed = c::B57600; - -/// `B115200` -#[cfg(not(target_os = "aix"))] -pub const B115200: Speed = c::B115200; - -/// `B230400` -#[cfg(not(target_os = "aix"))] -pub const B230400: Speed = c::B230400; - -/// `B460800` -#[cfg(not(any( - apple, - target_os = "aix", - target_os = "dragonfly", - target_os = "haiku", - target_os = "openbsd" -)))] -pub const B460800: Speed = c::B460800; - -/// `B500000` -#[cfg(not(any(bsd, solarish, target_os = "aix", target_os = "haiku")))] -pub const B500000: Speed = c::B500000; - -/// `B576000` -#[cfg(not(any(bsd, solarish, target_os = "aix", target_os = "haiku")))] -pub const B576000: Speed = c::B576000; - -/// `B921600` -#[cfg(not(any( - apple, - target_os = "aix", - target_os = "dragonfly", - target_os = "haiku", - target_os = "openbsd" -)))] -pub const B921600: Speed = c::B921600; - -/// `B1000000` -#[cfg(not(any(bsd, target_os = "aix", target_os = "haiku", target_os = "solaris")))] -pub const B1000000: Speed = c::B1000000; - -/// `B1152000` -#[cfg(not(any(bsd, target_os = "aix", target_os = "haiku", target_os = "solaris")))] -pub const B1152000: Speed = c::B1152000; - -/// `B1500000` -#[cfg(not(any(bsd, target_os = "aix", target_os = "haiku", target_os = "solaris")))] -pub const B1500000: Speed = c::B1500000; - -/// `B2000000` -#[cfg(not(any(bsd, target_os = "aix", target_os = "haiku", target_os = "solaris")))] -pub const B2000000: Speed = c::B2000000; - -/// `B2500000` -#[cfg(not(any( - target_arch = "sparc", - target_arch = "sparc64", - bsd, - target_os = "aix", - target_os = "haiku", - target_os = "solaris", -)))] -pub const B2500000: Speed = c::B2500000; - -/// `B3000000` -#[cfg(not(any( - target_arch = "sparc", - target_arch = "sparc64", - bsd, - target_os = "aix", - target_os = "haiku", - target_os = "solaris", -)))] -pub const B3000000: Speed = c::B3000000; - -/// `B3500000` -#[cfg(not(any( - target_arch = "sparc", - target_arch = "sparc64", - bsd, - target_os = "aix", - target_os = "haiku", - target_os = "solaris", -)))] -pub const B3500000: Speed = c::B3500000; - -/// `B4000000` -#[cfg(not(any( - target_arch = "sparc", - target_arch = "sparc64", - bsd, - target_os = "aix", - target_os = "haiku", - target_os = "solaris", -)))] -pub const B4000000: Speed = c::B4000000; - -/// `BOTHER` -#[cfg(any(target_os = "android", target_os = "linux"))] -pub const BOTHER: Speed = c::BOTHER; - -/// `CSIZE` -pub const CSIZE: Tcflag = c::CSIZE; - -/// `CS5` -pub const CS5: Tcflag = c::CS5; - -/// `CS6` -pub const CS6: Tcflag = c::CS6; - -/// `CS7` -pub const CS7: Tcflag = c::CS7; - -/// `CS8` -pub const CS8: Tcflag = c::CS8; - -/// `CSTOPB` -pub const CSTOPB: Tcflag = c::CSTOPB; - -/// `CREAD` -pub const CREAD: Tcflag = c::CREAD; - -/// `PARENB` -pub const PARENB: Tcflag = c::PARENB; - -/// `PARODD` -pub const PARODD: Tcflag = c::PARODD; - -/// `HUPCL` -pub const HUPCL: Tcflag = c::HUPCL; - -/// `CLOCAL` -pub const CLOCAL: Tcflag = c::CLOCAL; - -/// `ISIG` -pub const ISIG: Tcflag = c::ISIG; - -/// `ICANON`—A flag for the `c_lflag` field of [`Termios`] indicating -/// canonical mode. -pub const ICANON: Tcflag = c::ICANON; - -/// `ECHO` -pub const ECHO: Tcflag = c::ECHO; - -/// `ECHOE` -pub const ECHOE: Tcflag = c::ECHOE; - -/// `ECHOK` -pub const ECHOK: Tcflag = c::ECHOK; - -/// `ECHONL` -pub const ECHONL: Tcflag = c::ECHONL; - -/// `NOFLSH` -pub const NOFLSH: Tcflag = c::NOFLSH; - -/// `TOSTOP` -pub const TOSTOP: Tcflag = c::TOSTOP; - -/// `IEXTEN` -pub const IEXTEN: Tcflag = c::IEXTEN; - -/// `EXTA` -#[cfg(not(any( - solarish, - target_os = "emscripten", - target_os = "haiku", - target_os = "redox", -)))] -pub const EXTA: Speed = c::EXTA; - -/// `EXTB` -#[cfg(not(any( - solarish, - target_os = "emscripten", - target_os = "haiku", - target_os = "redox", -)))] -pub const EXTB: Speed = c::EXTB; - -/// `CBAUD` -#[cfg(not(any(bsd, target_os = "haiku", target_os = "redox")))] -pub const CBAUD: Tcflag = c::CBAUD; - -/// `CBAUDEX` -#[cfg(not(any( - bsd, - solarish, - target_os = "aix", - target_os = "haiku", - target_os = "redox", -)))] -pub const CBAUDEX: Tcflag = c::CBAUDEX; - -/// `CIBAUD` -#[cfg(not(any( - target_arch = "powerpc", - target_arch = "powerpc64", - bsd, - target_os = "emscripten", - target_os = "haiku", - target_os = "redox", -)))] -pub const CIBAUD: Tcflag = c::CIBAUD; - -/// `CIBAUD` -// glibc on powerpc lacks a definition for `CIBAUD`, even though the Linux -// headers and Musl on powerpc both have one. So define it manually. -#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))] -pub const CIBAUD: Tcflag = 0o77600000; - -/// `CMSPAR` -#[cfg(not(any( - bsd, - solarish, - target_os = "aix", - target_os = "emscripten", - target_os = "haiku", - target_os = "redox", -)))] -pub const CMSPAR: Tcflag = c::CMSPAR; - -/// `CRTSCTS` -#[cfg(not(any(target_os = "aix", target_os = "redox")))] -pub const CRTSCTS: Tcflag = c::CRTSCTS; - -/// `XCASE` -#[cfg(any(target_arch = "s390x", target_os = "haiku"))] -pub const XCASE: Tcflag = c::XCASE; - -/// `ECHOCTL` -#[cfg(not(any(target_os = "redox")))] -pub const ECHOCTL: Tcflag = c::ECHOCTL; - -/// `ECHOPRT` -#[cfg(not(any(target_os = "redox")))] -pub const ECHOPRT: Tcflag = c::ECHOPRT; - -/// `ECHOKE` -#[cfg(not(any(target_os = "redox")))] -pub const ECHOKE: Tcflag = c::ECHOKE; - -/// `FLUSHO` -#[cfg(not(any(target_os = "redox")))] -pub const FLUSHO: Tcflag = c::FLUSHO; - -/// `PENDIN` -#[cfg(not(any(target_os = "redox")))] -pub const PENDIN: Tcflag = c::PENDIN; - -/// `EXTPROC` -#[cfg(not(any(target_os = "aix", target_os = "haiku", target_os = "redox")))] -pub const EXTPROC: Tcflag = c::EXTPROC; - -/// `XTABS` -#[cfg(not(any( - bsd, - solarish, - target_os = "aix", - target_os = "haiku", - target_os = "redox", -)))] -pub const XTABS: Tcflag = c::XTABS; |