diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:59:35 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:59:35 +0000 |
commit | d1b2d29528b7794b41e66fc2136e395a02f8529b (patch) | |
tree | a4a17504b260206dec3cf55b2dca82929a348ac2 /vendor/rustix/src/termios | |
parent | Releasing progress-linux version 1.72.1+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-d1b2d29528b7794b41e66fc2136e395a02f8529b.tar.xz rustc-d1b2d29528b7794b41e66fc2136e395a02f8529b.zip |
Merging upstream version 1.73.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/rustix/src/termios')
-rw-r--r-- | vendor/rustix/src/termios/ioctl.rs | 4 | ||||
-rw-r--r-- | vendor/rustix/src/termios/mod.rs | 8 | ||||
-rw-r--r-- | vendor/rustix/src/termios/tc.rs | 10 | ||||
-rw-r--r-- | vendor/rustix/src/termios/types.rs | 297 |
4 files changed, 238 insertions, 81 deletions
diff --git a/vendor/rustix/src/termios/ioctl.rs b/vendor/rustix/src/termios/ioctl.rs index 2e8a28ed6..1c60cb9a4 100644 --- a/vendor/rustix/src/termios/ioctl.rs +++ b/vendor/rustix/src/termios/ioctl.rs @@ -15,7 +15,7 @@ use crate::{backend, io}; /// [FreeBSD]: https://man.freebsd.org/cgi/man.cgi?query=tty&sektion=4 /// [NetBSD]: https://man.netbsd.org/tty.4 /// [OpenBSD]: https://man.openbsd.org/tty.4 -#[cfg(not(any(windows, target_os = "haiku", target_os = "redox", target_os = "wasi")))] +#[cfg(not(any(windows, target_os = "redox", target_os = "wasi")))] #[inline] #[doc(alias = "TIOCEXCL")] pub fn ioctl_tiocexcl<Fd: AsFd>(fd: Fd) -> io::Result<()> { @@ -34,7 +34,7 @@ pub fn ioctl_tiocexcl<Fd: AsFd>(fd: Fd) -> io::Result<()> { /// [FreeBSD]: https://man.freebsd.org/cgi/man.cgi?query=tty&sektion=4 /// [NetBSD]: https://man.netbsd.org/tty.4 /// [OpenBSD]: https://man.openbsd.org/tty.4 -#[cfg(not(any(windows, target_os = "haiku", target_os = "redox", target_os = "wasi")))] +#[cfg(not(any(windows, target_os = "redox", target_os = "wasi")))] #[inline] #[doc(alias = "TIOCNXCL")] pub fn ioctl_tiocnxcl<Fd: AsFd>(fd: Fd) -> io::Result<()> { diff --git a/vendor/rustix/src/termios/mod.rs b/vendor/rustix/src/termios/mod.rs index 28abc0488..c61d3f12a 100644 --- a/vendor/rustix/src/termios/mod.rs +++ b/vendor/rustix/src/termios/mod.rs @@ -8,20 +8,20 @@ //! [`Termios::set_input_speed`], and it will simply fail if the speed is not //! supported by the platform. -#[cfg(not(target_os = "wasi"))] +#[cfg(not(any(target_os = "espidf", target_os = "haiku", target_os = "wasi")))] mod ioctl; #[cfg(not(target_os = "wasi"))] mod tc; #[cfg(not(windows))] mod tty; -#[cfg(not(target_os = "wasi"))] +#[cfg(not(any(target_os = "espidf", target_os = "wasi")))] mod types; -#[cfg(not(target_os = "wasi"))] +#[cfg(not(any(target_os = "espidf", target_os = "haiku", target_os = "wasi")))] pub use ioctl::*; #[cfg(not(target_os = "wasi"))] pub use tc::*; #[cfg(not(windows))] pub use tty::*; -#[cfg(not(target_os = "wasi"))] +#[cfg(not(any(target_os = "espidf", target_os = "wasi")))] pub use types::*; diff --git a/vendor/rustix/src/termios/tc.rs b/vendor/rustix/src/termios/tc.rs index 9deb7798c..cd5902c1a 100644 --- a/vendor/rustix/src/termios/tc.rs +++ b/vendor/rustix/src/termios/tc.rs @@ -1,5 +1,6 @@ use crate::fd::AsFd; use crate::pid::Pid; +#[cfg(not(target_os = "espidf"))] use crate::termios::{Action, OptionalActions, QueueSelector, Termios, Winsize}; use crate::{backend, io}; @@ -15,7 +16,7 @@ use crate::{backend, io}; /// [POSIX `tcgetattr`]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/tcgetattr.html /// [Linux `ioctl_tty`]: https://man7.org/linux/man-pages/man4/tty_ioctl.4.html /// [Linux `termios`]: https://man7.org/linux/man-pages/man3/termios.3.html -#[cfg(not(any(windows, target_os = "wasi")))] +#[cfg(not(any(windows, target_os = "espidf", target_os = "wasi")))] #[inline] #[doc(alias = "TCGETS")] #[doc(alias = "TCGETS2")] @@ -32,7 +33,7 @@ pub fn tcgetattr<Fd: AsFd>(fd: Fd) -> io::Result<Termios> { /// - [Linux] /// /// [Linux]: https://man7.org/linux/man-pages/man4/tty_ioctl.4.html -#[cfg(not(any(windows, target_os = "wasi")))] +#[cfg(not(any(windows, target_os = "espidf", target_os = "wasi")))] #[inline] #[doc(alias = "TIOCGWINSZ")] pub fn tcgetwinsize<Fd: AsFd>(fd: Fd) -> io::Result<Winsize> { @@ -85,6 +86,7 @@ pub fn tcsetpgrp<Fd: AsFd>(fd: Fd, pid: Pid) -> io::Result<()> { /// [POSIX `tcsetattr`]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/tcsetattr.html /// [Linux `ioctl_tty`]: https://man7.org/linux/man-pages/man4/tty_ioctl.4.html /// [Linux `termios`]: https://man7.org/linux/man-pages/man3/termios.3.html +#[cfg(not(target_os = "espidf"))] #[inline] #[doc(alias = "TCSETS")] #[doc(alias = "TCSETS2")] @@ -129,6 +131,7 @@ pub fn tcsendbreak<Fd: AsFd>(fd: Fd) -> io::Result<()> { /// [POSIX `tcsetattr`]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/tcdrain.html /// [Linux `ioctl_tty`]: https://man7.org/linux/man-pages/man4/tty_ioctl.4.html /// [Linux `termios`]: https://man7.org/linux/man-pages/man3/termios.3.html +#[cfg(not(target_os = "espidf"))] #[inline] pub fn tcdrain<Fd: AsFd>(fd: Fd) -> io::Result<()> { backend::termios::syscalls::tcdrain(fd.as_fd()) @@ -145,6 +148,7 @@ pub fn tcdrain<Fd: AsFd>(fd: Fd) -> io::Result<()> { /// [POSIX `tcflush`]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/tcflush.html /// [Linux `ioctl_tty`]: https://man7.org/linux/man-pages/man4/tty_ioctl.4.html /// [Linux `termios`]: https://man7.org/linux/man-pages/man3/termios.3.html +#[cfg(not(target_os = "espidf"))] #[inline] #[doc(alias = "TCFLSH")] pub fn tcflush<Fd: AsFd>(fd: Fd, queue_selector: QueueSelector) -> io::Result<()> { @@ -161,6 +165,7 @@ pub fn tcflush<Fd: AsFd>(fd: Fd, queue_selector: QueueSelector) -> io::Result<() /// [POSIX `tcflow`]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/tcflow.html /// [Linux `ioctl_tty`]: https://man7.org/linux/man-pages/man4/tty_ioctl.4.html /// [Linux `termios`]: https://man7.org/linux/man-pages/man3/termios.3.html +#[cfg(not(target_os = "espidf"))] #[inline] #[doc(alias = "TCXONC")] pub fn tcflow<Fd: AsFd>(fd: Fd, action: Action) -> io::Result<()> { @@ -190,6 +195,7 @@ pub fn tcgetsid<Fd: AsFd>(fd: Fd) -> io::Result<Pid> { /// - [Linux] /// /// [Linux]: https://man7.org/linux/man-pages/man4/tty_ioctl.4.html +#[cfg(not(target_os = "espidf"))] #[inline] #[doc(alias = "TIOCSWINSZ")] pub fn tcsetwinsize<Fd: AsFd>(fd: Fd, winsize: Winsize) -> io::Result<()> { diff --git a/vendor/rustix/src/termios/types.rs b/vendor/rustix/src/termios/types.rs index d978bfcca..8b7d473cf 100644 --- a/vendor/rustix/src/termios/types.rs +++ b/vendor/rustix/src/termios/types.rs @@ -31,16 +31,20 @@ pub struct Termios { #[cfg(any( linux_like, target_env = "newlib", - target_os = "haiku", target_os = "fuchsia", + target_os = "haiku", target_os = "redox" ))] pub line_discipline: c::cc_t, /// How are various special control codes handled? #[doc(alias = "c_cc")] + #[cfg(not(target_os = "haiku"))] pub special_codes: SpecialCodes, + #[cfg(target_os = "nto")] + pub(crate) __reserved: [c::c_uint; 3], + /// Line discipline. // On PowerPC, this field comes after `c_cc`. #[doc(alias = "c_line")] @@ -51,20 +55,28 @@ pub struct Termios { /// /// On Linux and BSDs, this is the arbitrary integer speed value. On all /// other platforms, this is the encoded speed value. + #[cfg(not(any(solarish, all(libc, target_env = "newlib"), target_os = "aix")))] pub(crate) input_speed: c::speed_t, /// See the `output_speed` and `set_output_seed` functions. /// /// On Linux and BSDs, this is the integer speed value. On all other /// platforms, this is the encoded speed value. + #[cfg(not(any(solarish, all(libc, target_env = "newlib"), target_os = "aix")))] pub(crate) output_speed: c::speed_t, + + /// How are various special control codes handled? + #[doc(alias = "c_cc")] + #[cfg(target_os = "haiku")] + pub special_codes: SpecialCodes, } impl Termios { - /// `cfmakeraw(self)`—Set a `Termios` value to the settings for "raw" mode. + /// `cfmakeraw(self)`—Set a `Termios` value to the settings for “raw” mode. /// /// In raw mode, input is available a byte at a time, echoing is disabled, /// and special terminal input and output codes are disabled. + #[cfg(not(target_os = "nto"))] #[doc(alias = "cfmakeraw")] #[inline] pub fn make_raw(&mut self) { @@ -88,8 +100,20 @@ impl Termios { self.input_speed as u32 } + // On illumos, `input_speed` is not present. + #[cfg(any(solarish, all(libc, target_env = "newlib"), target_os = "aix"))] + unsafe { + speed::decode(c::cfgetispeed(crate::utils::as_ptr(self).cast())).unwrap() + } + // On other platforms, it's the encoded speed. - #[cfg(not(any(linux_kernel, bsd)))] + #[cfg(not(any( + linux_kernel, + bsd, + solarish, + all(libc, target_env = "newlib"), + target_os = "aix" + )))] { speed::decode(self.input_speed).unwrap() } @@ -109,8 +133,20 @@ impl Termios { self.output_speed as u32 } + // On illumos, `output_speed` is not present. + #[cfg(any(solarish, all(libc, target_env = "newlib"), target_os = "aix"))] + unsafe { + speed::decode(c::cfgetospeed(crate::utils::as_ptr(self).cast())).unwrap() + } + // On other platforms, it's the encoded speed. - #[cfg(not(any(linux_kernel, bsd)))] + #[cfg(not(any( + linux_kernel, + bsd, + solarish, + all(libc, target_env = "newlib"), + target_os = "aix" + )))] { speed::decode(self.output_speed).unwrap() } @@ -123,6 +159,7 @@ impl Termios { /// encoded constant value. Not all implementations support all integer /// values; use the constants in the [`speed`] module for likely-supported /// speeds. + #[cfg(not(target_os = "nto"))] #[doc(alias = "cfsetspeed")] #[doc(alias = "CBAUD")] #[doc(alias = "CBAUDEX")] @@ -180,8 +217,8 @@ impl core::fmt::Debug for Termios { #[cfg(any( linux_like, target_env = "newlib", - target_os = "haiku", target_os = "fuchsia", + target_os = "haiku", target_os = "redox" ))] { @@ -227,7 +264,7 @@ bitflags! { const ICRNL = c::ICRNL; /// `IUCLC` - #[cfg(any(linux_kernel, solarish, target_os = "haiku"))] + #[cfg(any(linux_kernel, solarish, target_os = "aix", target_os = "haiku", target_os = "nto"))] const IUCLC = c::IUCLC; /// `IXON` @@ -246,14 +283,12 @@ bitflags! { /// `IUTF8` #[cfg(not(any( + freebsdlike, + netbsdlike, 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", )))] const IUTF8 = c::IUTF8; @@ -271,9 +306,8 @@ bitflags! { /// `OLCUC` #[cfg(not(any( apple, + freebsdlike, target_os = "aix", - target_os = "dragonfly", - target_os = "freebsd", target_os = "netbsd", target_os = "redox", )))] @@ -516,7 +550,7 @@ bitflags! { const CLOCAL = c::CLOCAL; /// `CRTSCTS` - #[cfg(not(any(target_os = "aix", target_os = "redox")))] + #[cfg(not(any(target_os = "aix", target_os = "nto", target_os = "redox")))] const CRTSCTS = c::CRTSCTS; /// `CMSPAR` @@ -526,6 +560,7 @@ bitflags! { target_os = "aix", target_os = "emscripten", target_os = "haiku", + target_os = "nto", target_os = "redox", )))] const CMSPAR = c::CMSPAR; @@ -533,7 +568,7 @@ bitflags! { } bitflags! { - /// Flags controlling "local" terminal modes. + /// Flags controlling “local” terminal modes. #[repr(transparent)] #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] pub struct LocalModes: c::tcflag_t { @@ -546,7 +581,7 @@ bitflags! { const ECHOCTL = c::ECHOCTL; /// `ECHOPRT` - #[cfg(not(target_os = "redox"))] + #[cfg(not(any(target_os = "nto", target_os = "redox")))] const ECHOPRT = c::ECHOPRT; /// `ECHOKE` @@ -554,15 +589,15 @@ bitflags! { const ECHOKE = c::ECHOKE; /// `FLUSHO` - #[cfg(not(target_os = "redox"))] + #[cfg(not(any(target_os = "nto", target_os = "redox")))] const FLUSHO = c::FLUSHO; /// `PENDIN` - #[cfg(not(target_os = "redox"))] + #[cfg(not(any(target_os = "nto", target_os = "redox")))] const PENDIN = c::PENDIN; /// `EXTPROC` - #[cfg(not(any(target_os = "aix", target_os = "haiku", target_os = "redox")))] + #[cfg(not(any(target_os = "aix", target_os = "haiku", target_os = "nto", target_os = "redox")))] const EXTPROC = c::EXTPROC; /// `ISIG` @@ -760,7 +795,7 @@ pub mod speed { /// Translate from a `c::speed_t` code to an arbitrary integer speed value /// `u32`. #[cfg(not(any(linux_kernel, bsd)))] - pub(crate) fn decode(encoded_speed: c::speed_t) -> Option<u32> { + pub(crate) const fn decode(encoded_speed: c::speed_t) -> Option<u32> { match encoded_speed { c::B0 => Some(0), c::B50 => Some(50), @@ -782,35 +817,73 @@ pub mod speed { c::B57600 => Some(57600), #[cfg(not(target_os = "aix"))] c::B115200 => Some(115_200), - #[cfg(not(target_os = "aix"))] + #[cfg(not(any(target_os = "aix", target_os = "nto")))] c::B230400 => Some(230_400), #[cfg(not(any( apple, target_os = "aix", target_os = "dragonfly", target_os = "haiku", + target_os = "nto", target_os = "openbsd" )))] c::B460800 => Some(460_800), - #[cfg(not(any(bsd, solarish, target_os = "aix", target_os = "haiku")))] + #[cfg(not(any( + bsd, + solarish, + target_os = "aix", + target_os = "haiku", + target_os = "nto" + )))] c::B500000 => Some(500_000), - #[cfg(not(any(bsd, solarish, target_os = "aix", target_os = "haiku")))] + #[cfg(not(any( + bsd, + solarish, + target_os = "aix", + target_os = "haiku", + target_os = "nto" + )))] c::B576000 => Some(576_000), #[cfg(not(any( apple, target_os = "aix", target_os = "dragonfly", target_os = "haiku", + target_os = "nto", target_os = "openbsd" )))] c::B921600 => Some(921_600), - #[cfg(not(any(bsd, target_os = "aix", target_os = "haiku", target_os = "solaris")))] + #[cfg(not(any( + bsd, + target_os = "aix", + target_os = "haiku", + target_os = "nto", + target_os = "solaris" + )))] c::B1000000 => Some(1_000_000), - #[cfg(not(any(bsd, target_os = "aix", target_os = "haiku", target_os = "solaris")))] + #[cfg(not(any( + bsd, + target_os = "aix", + target_os = "haiku", + target_os = "nto", + target_os = "solaris" + )))] c::B1152000 => Some(1_152_000), - #[cfg(not(any(bsd, target_os = "aix", target_os = "haiku", target_os = "solaris")))] + #[cfg(not(any( + bsd, + target_os = "aix", + target_os = "haiku", + target_os = "nto", + target_os = "solaris" + )))] c::B1500000 => Some(1_500_000), - #[cfg(not(any(bsd, target_os = "aix", target_os = "haiku", target_os = "solaris")))] + #[cfg(not(any( + bsd, + target_os = "aix", + target_os = "haiku", + target_os = "nto", + target_os = "solaris" + )))] c::B2000000 => Some(2_000_000), #[cfg(not(any( target_arch = "sparc", @@ -818,6 +891,7 @@ pub mod speed { bsd, target_os = "aix", target_os = "haiku", + target_os = "nto", target_os = "solaris", )))] c::B2500000 => Some(2_500_000), @@ -827,6 +901,7 @@ pub mod speed { bsd, target_os = "aix", target_os = "haiku", + target_os = "nto", target_os = "solaris", )))] c::B3000000 => Some(3_000_000), @@ -836,6 +911,7 @@ pub mod speed { bsd, target_os = "aix", target_os = "haiku", + target_os = "nto", target_os = "solaris", )))] c::B3500000 => Some(3_500_000), @@ -845,6 +921,7 @@ pub mod speed { bsd, target_os = "aix", target_os = "haiku", + target_os = "nto", target_os = "solaris", )))] c::B4000000 => Some(4_000_000), @@ -855,7 +932,7 @@ pub mod speed { /// Translate from an arbitrary `u32` arbitrary integer speed value to a /// `c::speed_t` code. #[cfg(not(bsd))] - pub(crate) fn encode(speed: u32) -> Option<c::speed_t> { + pub(crate) const fn encode(speed: u32) -> Option<c::speed_t> { match speed { 0 => Some(c::B0), 50 => Some(c::B50), @@ -877,35 +954,73 @@ pub mod speed { 57600 => Some(c::B57600), #[cfg(not(target_os = "aix"))] 115_200 => Some(c::B115200), - #[cfg(not(target_os = "aix"))] + #[cfg(not(any(target_os = "aix", target_os = "nto")))] 230_400 => Some(c::B230400), #[cfg(not(any( apple, target_os = "aix", target_os = "dragonfly", target_os = "haiku", - target_os = "openbsd" + target_os = "nto", + target_os = "openbsd", )))] 460_800 => Some(c::B460800), - #[cfg(not(any(bsd, solarish, target_os = "aix", target_os = "haiku")))] + #[cfg(not(any( + bsd, + solarish, + target_os = "aix", + target_os = "haiku", + target_os = "nto" + )))] 500_000 => Some(c::B500000), - #[cfg(not(any(bsd, solarish, target_os = "aix", target_os = "haiku")))] + #[cfg(not(any( + bsd, + solarish, + target_os = "aix", + target_os = "haiku", + target_os = "nto" + )))] 576_000 => Some(c::B576000), #[cfg(not(any( apple, target_os = "aix", target_os = "dragonfly", target_os = "haiku", + target_os = "nto", target_os = "openbsd" )))] 921_600 => Some(c::B921600), - #[cfg(not(any(bsd, target_os = "aix", target_os = "haiku", target_os = "solaris")))] + #[cfg(not(any( + bsd, + target_os = "aix", + target_os = "haiku", + target_os = "nto", + target_os = "solaris" + )))] 1_000_000 => Some(c::B1000000), - #[cfg(not(any(bsd, target_os = "aix", target_os = "haiku", target_os = "solaris")))] + #[cfg(not(any( + bsd, + target_os = "aix", + target_os = "haiku", + target_os = "nto", + target_os = "solaris" + )))] 1_152_000 => Some(c::B1152000), - #[cfg(not(any(bsd, target_os = "aix", target_os = "haiku", target_os = "solaris")))] + #[cfg(not(any( + bsd, + target_os = "aix", + target_os = "haiku", + target_os = "nto", + target_os = "solaris" + )))] 1_500_000 => Some(c::B1500000), - #[cfg(not(any(bsd, target_os = "aix", target_os = "haiku", target_os = "solaris")))] + #[cfg(not(any( + bsd, + target_os = "aix", + target_os = "haiku", + target_os = "nto", + target_os = "solaris" + )))] 2_000_000 => Some(c::B2000000), #[cfg(not(any( target_arch = "sparc", @@ -913,6 +1028,7 @@ pub mod speed { bsd, target_os = "aix", target_os = "haiku", + target_os = "nto", target_os = "solaris", )))] 2_500_000 => Some(c::B2500000), @@ -922,6 +1038,7 @@ pub mod speed { bsd, target_os = "aix", target_os = "haiku", + target_os = "nto", target_os = "solaris", )))] 3_000_000 => Some(c::B3000000), @@ -931,6 +1048,7 @@ pub mod speed { bsd, target_os = "aix", target_os = "haiku", + target_os = "nto", target_os = "solaris", )))] 3_500_000 => Some(c::B3500000), @@ -940,6 +1058,7 @@ pub mod speed { bsd, target_os = "aix", target_os = "haiku", + target_os = "nto", target_os = "solaris", )))] 4_000_000 => Some(c::B4000000), @@ -996,14 +1115,11 @@ impl SpecialCodeIndex { /// `VSWTC` #[cfg(not(any( - apple, + bsd, solarish, target_os = "aix", - target_os = "dragonfly", - target_os = "freebsd", target_os = "haiku", - target_os = "netbsd", - target_os = "openbsd", + target_os = "nto", )))] pub const VSWTC: Self = Self(c::VSWTC as usize); @@ -1138,31 +1254,51 @@ fn termios_layouts() { // On everything except PowerPC, `termios` matches `termios2` except for // the addition of `c_ispeed` and `c_ospeed`. #[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))] - assert_eq!( + const_assert_eq!( memoffset::offset_of!(Termios, input_speed), core::mem::size_of::<c::termios>() ); // On PowerPC, `termios2` is `termios`. #[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))] - assert_eq!( - core::mem::size_of::<c::termios2>(), - core::mem::size_of::<c::termios>() - ); + assert_eq_size!(c::termios2, c::termios); } #[cfg(not(linux_raw))] { + // On Mips, Sparc, and Android, the libc lacks the ospeed and ispeed + // fields. + #[cfg(all( + not(all( + target_env = "gnu", + any( + target_arch = "mips", + target_arch = "mips32r6", + target_arch = "mips64", + target_arch = "mips64r6", + target_arch = "sparc", + target_arch = "sparc64" + ) + )), + not(all(libc, target_os = "android")) + ))] + check_renamed_type!(Termios, termios); #[cfg(not(all( - target_env = "gnu", - any( - target_arch = "sparc", - target_arch = "sparc64", - target_arch = "mips", - target_arch = "mips64" - ) + not(all( + target_env = "gnu", + any( + target_arch = "mips", + target_arch = "mips32r6", + target_arch = "mips64", + target_arch = "mips64r6", + target_arch = "sparc", + target_arch = "sparc64" + ) + )), + not(all(libc, target_os = "android")) )))] - check_renamed_type!(Termios, termios); + const_assert!(core::mem::size_of::<Termios>() >= core::mem::size_of::<c::termios>()); + check_renamed_struct_renamed_field!(Termios, termios, input_modes, c_iflag); check_renamed_struct_renamed_field!(Termios, termios, output_modes, c_oflag); check_renamed_struct_renamed_field!(Termios, termios, control_modes, c_cflag); @@ -1170,8 +1306,8 @@ fn termios_layouts() { #[cfg(any( linux_like, target_env = "newlib", - target_os = "haiku", target_os = "fuchsia", + target_os = "haiku", target_os = "redox" ))] check_renamed_struct_renamed_field!(Termios, termios, line_discipline, c_line); @@ -1199,11 +1335,16 @@ fn termios_layouts() { } #[test] -#[cfg(not(any(solarish, target_os = "emscripten")))] +#[cfg(not(any( + solarish, + target_os = "emscripten", + target_os = "haiku", + target_os = "redox" +)))] fn termios_legacy() { // Check that our doc aliases above are correct. - assert_eq!(c::EXTA, c::B19200); - assert_eq!(c::EXTB, c::B38400); + const_assert_eq!(c::EXTA, c::B19200); + const_assert_eq!(c::EXTB, c::B38400); } #[cfg(bsd)] @@ -1211,10 +1352,10 @@ fn termios_legacy() { fn termios_bsd() { // On BSD platforms we can assume that the `B*` constants have their // arbitrary integer speed value. Confirm this. - assert_eq!(c::B0, 0); - assert_eq!(c::B50, 50); - assert_eq!(c::B19200, 19200); - assert_eq!(c::B38400, 38400); + const_assert_eq!(c::B0, 0); + const_assert_eq!(c::B50, 50); + const_assert_eq!(c::B19200, 19200); + const_assert_eq!(c::B38400, 38400); } #[test] @@ -1242,26 +1383,36 @@ fn termios_ioctl_contiguity() { // When using `termios2`, we assume that we can add the optional actions // value to the ioctl request code. Test this assumption. - assert_eq!(c::TCSETS2, c::TCSETS2 + 0); - assert_eq!(c::TCSETSW2, c::TCSETS2 + 1); - assert_eq!(c::TCSETSF2, c::TCSETS2 + 2); + const_assert_eq!(c::TCSETS2, c::TCSETS2 + 0); + const_assert_eq!(c::TCSETSW2, c::TCSETS2 + 1); + const_assert_eq!(c::TCSETSF2, c::TCSETS2 + 2); - assert_eq!(c::TCSANOW - c::TCSANOW, 0); - assert_eq!(c::TCSADRAIN - c::TCSANOW, 1); - assert_eq!(c::TCSAFLUSH - c::TCSANOW, 2); + const_assert_eq!(c::TCSANOW - c::TCSANOW, 0); + const_assert_eq!(c::TCSADRAIN - c::TCSANOW, 1); + const_assert_eq!(c::TCSAFLUSH - c::TCSANOW, 2); // MIPS is different here. - #[cfg(any(target_arch = "mips", target_arch = "mips64"))] + #[cfg(any( + target_arch = "mips", + target_arch = "mips32r6", + target_arch = "mips64", + target_arch = "mips64r6" + ))] { assert_eq!(i128::from(c::TCSANOW) - i128::from(c::TCSETS), 0); assert_eq!(i128::from(c::TCSADRAIN) - i128::from(c::TCSETS), 1); assert_eq!(i128::from(c::TCSAFLUSH) - i128::from(c::TCSETS), 2); } - #[cfg(not(any(target_arch = "mips", target_arch = "mips64")))] + #[cfg(not(any( + target_arch = "mips", + target_arch = "mips32r6", + target_arch = "mips64", + target_arch = "mips64r6" + )))] { - assert_eq!(c::TCSANOW, 0); - assert_eq!(c::TCSADRAIN, 1); - assert_eq!(c::TCSAFLUSH, 2); + const_assert_eq!(c::TCSANOW, 0); + const_assert_eq!(c::TCSADRAIN, 1); + const_assert_eq!(c::TCSAFLUSH, 2); } } @@ -1269,5 +1420,5 @@ fn termios_ioctl_contiguity() { #[test] fn termios_cibaud() { // Test an assumption. - assert_eq!(c::CIBAUD, c::CBAUD << c::IBSHIFT); + const_assert_eq!(c::CIBAUD, c::CBAUD << c::IBSHIFT); } |