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

Fix compilation with 1.51 #71

Merged
merged 2 commits into from
Sep 21, 2021
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
9 changes: 7 additions & 2 deletions src/imp/linux_raw/syscalls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3126,7 +3126,9 @@ pub(crate) fn is_read_write(fd: BorrowedFd<'_>) -> io::Result<(bool, bool)> {
// the write side is shut down.
#[allow(unreachable_patterns)] // EAGAIN equals EWOULDBLOCK
match send(fd, &[], SendFlags::DONTWAIT) {
Err(io::Error::AGAIN | io::Error::WOULDBLOCK) => (),
// TODO or-patterns when we don't need 1.51
Err(io::Error::AGAIN) => (),
Err(io::Error::WOULDBLOCK) => (),
Err(io::Error::NOTSOCK) => (),
Err(io::Error::PIPE) => write = false,
Err(err) => return Err(err),
Expand Down Expand Up @@ -3336,6 +3338,9 @@ pub(crate) mod sockopt {
use std::os::raw::{c_int, c_uint};
use std::time::Duration;

// TODO use Duration::ZERO when we don't need 1.51 support
const DURATION_ZERO: Duration = Duration::from_secs(0);

#[inline]
fn getsockopt<T>(fd: BorrowedFd<'_>, level: u32, optname: u32) -> io::Result<T> {
use super::*;
Expand Down Expand Up @@ -3506,7 +3511,7 @@ pub(crate) mod sockopt {
) -> io::Result<()> {
let timeout = match timeout {
Some(timeout) => {
if timeout == Duration::ZERO {
if timeout == DURATION_ZERO {
return Err(io::Error::INVAL);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/io/eventfd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ fn test_eventfd() {
let efd = eventfd(0, EventfdFlags::CLOEXEC).unwrap();

let child = thread::spawn(move || {
for u in [1_u64, 3, 6, 11, 5000] {
for u in [1_u64, 3, 6, 11, 5000].iter() {
assert_eq!(write(&efd, &u.to_ne_bytes()).unwrap(), size_of::<u64>());
}
efd
Expand Down
10 changes: 8 additions & 2 deletions tests/process/membarrier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ fn test_membarrier() {
MembarrierCommand::RegisterPrivateExpedited,
MembarrierCommand::RegisterPrivateExpeditedSyncCore,
MembarrierCommand::RegisterPrivateExpeditedRseq,
] {
]
.iter()
.copied()
{
if query.contains_command(cmd) {
membarrier(cmd).unwrap();
}
Expand All @@ -24,7 +27,10 @@ fn test_membarrier() {
MembarrierCommand::PrivateExpedited,
MembarrierCommand::PrivateExpeditedSyncCore,
MembarrierCommand::PrivateExpeditedRseq,
] {
]
.iter()
.copied()
{
if query.contains_command(cmd) {
membarrier(cmd).unwrap();
} else {
Expand Down