Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport patches to 0.38 #1161

Merged
merged 3 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ jobs:
- run: cargo check -Zbuild-std=core,alloc --target=powerpc64-ibm-aix --features=all-apis --no-default-features
- run: cargo check -Z build-std --target=mipsel-unknown-linux-gnu --features=all-apis
- run: cargo check -Z build-std --target=mips64el-unknown-linux-gnuabi64 --features=all-apis
- run: cargo check -Z build-std --target=powerpc64le-unknown-linux-musl --features=all-apis


test:
Expand Down
2 changes: 1 addition & 1 deletion src/backend/libc/io/errno.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use libc_errno::errno;
/// - [illumos]
/// - [glibc]
///
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/errno.html
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9799919799/functions/errno.html
/// [Linux]: https://man7.org/linux/man-pages/man3/errno.3.html
/// [Winsock]: https://learn.microsoft.com/en-us/windows/win32/winsock/windows-sockets-error-codes-2
/// [FreeBSD]: https://man.freebsd.org/cgi/man.cgi?errno
Expand Down
43 changes: 43 additions & 0 deletions src/backend/libc/termios/syscalls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,29 @@ pub(crate) fn tcgetattr(fd: BorrowedFd<'_>) -> io::Result<Termios> {
local_modes: LocalModes::from_bits_retain(termios2.c_lflag),
line_discipline: termios2.c_line,
special_codes: SpecialCodes(Default::default()),

// On PowerPC musl targets, `c_ispeed`/`c_ospeed` are named
// `__c_ispeed`/`__c_ospeed`.
#[cfg(not(all(
target_env = "musl",
any(target_arch = "powerpc", target_arch = "powerpc64")
)))]
input_speed: termios2.c_ispeed,
#[cfg(not(all(
target_env = "musl",
any(target_arch = "powerpc", target_arch = "powerpc64")
)))]
output_speed: termios2.c_ospeed,
#[cfg(all(
target_env = "musl",
any(target_arch = "powerpc", target_arch = "powerpc64")
))]
input_speed: termios2.__c_ispeed,
#[cfg(all(
target_env = "musl",
any(target_arch = "powerpc", target_arch = "powerpc64")
))]
output_speed: termios2.__c_ospeed,
};

// Copy in the control codes, since libc's `c_cc` array may have a
Expand Down Expand Up @@ -179,15 +200,37 @@ pub(crate) fn tcsetattr(

let output_speed = termios.output_speed();
let input_speed = termios.input_speed();

let mut termios2 = c::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: Default::default(),

// On PowerPC musl targets, `c_ispeed`/`c_ospeed` are named
// `__c_ispeed`/`__c_ospeed`.
#[cfg(not(all(
target_env = "musl",
any(target_arch = "powerpc", target_arch = "powerpc64")
)))]
c_ispeed: input_speed,
#[cfg(not(all(
target_env = "musl",
any(target_arch = "powerpc", target_arch = "powerpc64")
)))]
c_ospeed: output_speed,
#[cfg(all(
target_env = "musl",
any(target_arch = "powerpc", target_arch = "powerpc64")
))]
__c_ispeed: input_speed,
#[cfg(all(
target_env = "musl",
any(target_arch = "powerpc", target_arch = "powerpc64")
))]
__c_ospeed: output_speed,
};

// Ensure that our input and output speeds are set, as `libc`
Expand Down
2 changes: 1 addition & 1 deletion src/backend/linux_raw/io/errno.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use linux_raw_sys::errno;
/// - [illumos]
/// - [glibc]
///
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/errno.html
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9799919799/functions/errno.html
/// [Linux]: https://man7.org/linux/man-pages/man3/errno.3.html
/// [Winsock]: https://learn.microsoft.com/en-us/windows/win32/winsock/windows-sockets-error-codes-2
/// [FreeBSD]: https://man.freebsd.org/cgi/man.cgi?errno
Expand Down
23 changes: 14 additions & 9 deletions src/event/epoll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -435,13 +435,18 @@ impl<'a> IntoIterator for &'a EventVec {
}
}

#[test]
fn test_epoll_layouts() {
check_renamed_type!(Event, epoll_event);
check_renamed_type!(Event, epoll_event);
check_renamed_struct_renamed_field!(Event, epoll_event, flags, events);
#[cfg(libc)]
check_renamed_struct_renamed_field!(Event, epoll_event, data, u64);
#[cfg(not(libc))]
check_renamed_struct_renamed_field!(Event, epoll_event, data, data);
#[cfg(test)]
mod tests {
use super::*;

#[test]
fn test_epoll_layouts() {
check_renamed_type!(Event, epoll_event);
check_renamed_type!(Event, epoll_event);
check_renamed_struct_renamed_field!(Event, epoll_event, flags, events);
#[cfg(libc)]
check_renamed_struct_renamed_field!(Event, epoll_event, data, u64);
#[cfg(not(libc))]
check_renamed_struct_renamed_field!(Event, epoll_event, data, data);
}
}
2 changes: 1 addition & 1 deletion src/event/pause.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use crate::backend;
/// - [DragonFly BSD]
/// - [illumos]
///
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/pause.html
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9799919799/functions/pause.html
/// [Linux]: https://man7.org/linux/man-pages/man2/pause.2.html
/// [Apple]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/pause.3.html
/// [FreeBSD]: https://man.freebsd.org/cgi/man.cgi?query=pause&sektion=3
Expand Down
2 changes: 1 addition & 1 deletion src/event/poll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub use backend::event::poll_fd::{PollFd, PollFlags};
/// - [illumos]
///
/// [Beej's Guide to Network Programming]: https://beej.us/guide/bgnet/html/split/slightly-advanced-techniques.html#poll
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/poll.html
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9799919799/functions/poll.html
/// [Linux]: https://man7.org/linux/man-pages/man2/poll.2.html
/// [Apple]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/poll.2.html
/// [Winsock]: https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsapoll
Expand Down
28 changes: 14 additions & 14 deletions src/fs/abs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ use {
/// - [POSIX]
/// - [Linux]
///
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/open.html
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9799919799/functions/open.html
/// [Linux]: https://man7.org/linux/man-pages/man2/open.2.html
#[inline]
pub fn open<P: path::Arg>(path: P, flags: OFlags, mode: Mode) -> io::Result<OwnedFd> {
Expand All @@ -52,7 +52,7 @@ pub fn open<P: path::Arg>(path: P, flags: OFlags, mode: Mode) -> io::Result<Owne
/// - [POSIX]
/// - [Linux]
///
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/chmod.html
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9799919799/functions/chmod.html
/// [Linux]: https://man7.org/linux/man-pages/man2/chmod.2.html
#[cfg(not(target_os = "wasi"))]
#[inline]
Expand All @@ -69,7 +69,7 @@ pub fn chmod<P: path::Arg>(path: P, mode: Mode) -> io::Result<()> {
/// - [POSIX]
/// - [Linux]
///
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/stat.html
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9799919799/functions/stat.html
/// [Linux]: https://man7.org/linux/man-pages/man2/stat.2.html
/// [`Mode::from_raw_mode`]: crate::fs::Mode::from_raw_mode
/// [`FileType::from_raw_mode`]: crate::fs::FileType::from_raw_mode
Expand All @@ -88,7 +88,7 @@ pub fn stat<P: path::Arg>(path: P) -> io::Result<Stat> {
/// - [POSIX]
/// - [Linux]
///
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/lstat.html
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9799919799/functions/lstat.html
/// [Linux]: https://man7.org/linux/man-pages/man2/lstat.2.html
/// [`Mode::from_raw_mode`]: crate::fs::Mode::from_raw_mode
/// [`FileType::from_raw_mode`]: crate::fs::FileType::from_raw_mode
Expand All @@ -105,7 +105,7 @@ pub fn lstat<P: path::Arg>(path: P) -> io::Result<Stat> {
/// - [POSIX]
/// - [Linux]
///
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/readlink.html
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9799919799/functions/readlink.html
/// [Linux]: https://man7.org/linux/man-pages/man2/readlink.2.html
#[cfg(feature = "alloc")]
#[inline]
Expand Down Expand Up @@ -142,7 +142,7 @@ fn _readlink(path: &CStr, mut buffer: Vec<u8>) -> io::Result<CString> {
/// - [POSIX]
/// - [Linux]
///
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/rename.html
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9799919799/functions/rename.html
/// [Linux]: https://man7.org/linux/man-pages/man2/rename.2.html
#[inline]
pub fn rename<P: path::Arg, Q: path::Arg>(old_path: P, new_path: Q) -> io::Result<()> {
Expand All @@ -157,7 +157,7 @@ pub fn rename<P: path::Arg, Q: path::Arg>(old_path: P, new_path: Q) -> io::Resul
/// - [POSIX]
/// - [Linux]
///
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/unlink.html
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9799919799/functions/unlink.html
/// [Linux]: https://man7.org/linux/man-pages/man2/unlink.2.html
#[inline]
pub fn unlink<P: path::Arg>(path: P) -> io::Result<()> {
Expand All @@ -170,7 +170,7 @@ pub fn unlink<P: path::Arg>(path: P) -> io::Result<()> {
/// - [POSIX]
/// - [Linux]
///
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/rmdir.html
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9799919799/functions/rmdir.html
/// [Linux]: https://man7.org/linux/man-pages/man2/rmdir.2.html
#[inline]
pub fn rmdir<P: path::Arg>(path: P) -> io::Result<()> {
Expand All @@ -189,7 +189,7 @@ pub fn rmdir<P: path::Arg>(path: P) -> io::Result<()> {
/// - [POSIX]
/// - [Linux]
///
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/link.html
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9799919799/functions/link.html
/// [Linux]: https://man7.org/linux/man-pages/man2/link.2.html
/// [`linkat`]: crate::fs::linkat
/// [`AtFlags`]: crate::fs::AtFlags
Expand All @@ -207,7 +207,7 @@ pub fn link<P: path::Arg, Q: path::Arg>(old_path: P, new_path: Q) -> io::Result<
/// - [POSIX]
/// - [Linux]
///
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/symlink.html
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9799919799/functions/symlink.html
/// [Linux]: https://man7.org/linux/man-pages/man2/symlink.2.html
#[inline]
pub fn symlink<P: path::Arg, Q: path::Arg>(old_path: P, new_path: Q) -> io::Result<()> {
Expand All @@ -222,7 +222,7 @@ pub fn symlink<P: path::Arg, Q: path::Arg>(old_path: P, new_path: Q) -> io::Resu
/// - [POSIX]
/// - [Linux]
///
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/mkdir.html
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9799919799/functions/mkdir.html
/// [Linux]: https://man7.org/linux/man-pages/man2/mkdir.2.html
#[inline]
pub fn mkdir<P: path::Arg>(path: P, mode: Mode) -> io::Result<()> {
Expand All @@ -235,7 +235,7 @@ pub fn mkdir<P: path::Arg>(path: P, mode: Mode) -> io::Result<()> {
/// - [POSIX]
/// - [Linux]
///
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/access.html
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9799919799/functions/access.html
/// [Linux]: https://man7.org/linux/man-pages/man2/access.2.html
#[cfg(not(any(target_os = "espidf", target_os = "vita")))]
#[inline]
Expand Down Expand Up @@ -278,7 +278,7 @@ pub fn statfs<P: path::Arg>(path: P) -> io::Result<StatFs> {
/// - [POSIX]
/// - [Linux]
///
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/statvfs.html
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9799919799/functions/statvfs.html
/// [Linux]: https://man7.org/linux/man-pages/man2/statvfs.2.html
#[cfg(not(any(target_os = "haiku", target_os = "redox", target_os = "wasi")))]
#[inline]
Expand All @@ -292,7 +292,7 @@ pub fn statvfs<P: path::Arg>(path: P) -> io::Result<StatVfs> {
/// - [POSIX]
/// - [Linux]
///
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/chown.html
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9799919799/functions/chown.html
/// [Linux]: https://man7.org/linux/man-pages/man2/chown.2.html
#[cfg(not(target_os = "wasi"))]
#[inline]
Expand Down
Loading
Loading