Skip to content

Commit

Permalink
Fix compilation on Redox
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomasdezeeuw committed Dec 22, 2020
1 parent e9df5ba commit 9c4a404
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 11 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ jobs:
- name: Install Rust
run: rustup update nightly && rustup default nightly
- run: rustup target add ${{ matrix.target }}
- run: cargo check --target ${{ matrix.target }}
- run: cargo check --target ${{ matrix.target }} --features all
- run: cargo check --target ${{ matrix.target }} --all-targets --examples --bins --tests --no-default-features
- run: cargo check --target ${{ matrix.target }} --all-targets --examples --bins --tests --all-features
continue-on-error: true

publish_docs:
Expand Down
2 changes: 1 addition & 1 deletion src/sockaddr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl SockAddr {
}

/// Returns a raw pointer to the address storage.
#[cfg(unix)]
#[cfg(all(unix, not(target_os = "redox")))]
pub(crate) const fn as_storage_ptr(&self) -> *const sockaddr_storage {
&self.storage
}
Expand Down
4 changes: 2 additions & 2 deletions src/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ use std::os::windows::io::{FromRawSocket, IntoRawSocket};
use std::time::Duration;

use crate::sys::{self, c_int, getsockopt, setsockopt, Bool};
use crate::{Domain, Protocol, SockAddr, TcpKeepalive, Type};
#[cfg(not(target_os = "redox"))]
use crate::RecvFlags;
use crate::{Domain, MaybeUninitSlice, Protocol, SockAddr, TcpKeepalive, Type};
use crate::{MaybeUninitSlice, RecvFlags};

/// Owned wrapper around a system socket.
///
Expand Down
8 changes: 5 additions & 3 deletions src/sys/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ use std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd};
use std::os::unix::net::{UnixDatagram, UnixListener, UnixStream};
#[cfg(feature = "all")]
use std::path::Path;
#[cfg(not(all(target_os = "redox", not(feature = "all"))))]
use std::ptr;
use std::time::Duration;
use std::{io, ptr, slice};
use std::{io, slice};

#[cfg(not(target_vendor = "apple"))]
use libc::ssize_t;
Expand Down Expand Up @@ -51,14 +53,14 @@ pub(crate) use libc::{
};
// Used in `RecvFlags`.
#[cfg(not(target_os = "redox"))]
pub(crate) use libc::MSG_TRUNC;
pub(crate) use libc::{MSG_TRUNC, SO_OOBINLINE};
// Used in `Socket`.
pub(crate) use libc::{
ip_mreq as IpMreq, ipv6_mreq as Ipv6Mreq, linger, IPPROTO_IP, IPPROTO_IPV6,
IPV6_MULTICAST_HOPS, IPV6_MULTICAST_IF, IPV6_MULTICAST_LOOP, IPV6_UNICAST_HOPS, IPV6_V6ONLY,
IP_ADD_MEMBERSHIP, IP_DROP_MEMBERSHIP, IP_MULTICAST_IF, IP_MULTICAST_LOOP, IP_MULTICAST_TTL,
IP_TTL, MSG_OOB, MSG_PEEK, SOL_SOCKET, SO_BROADCAST, SO_ERROR, SO_KEEPALIVE, SO_LINGER,
SO_OOBINLINE, SO_RCVBUF, SO_RCVTIMEO, SO_REUSEADDR, SO_SNDBUF, SO_SNDTIMEO, TCP_NODELAY,
SO_RCVBUF, SO_RCVTIMEO, SO_REUSEADDR, SO_SNDBUF, SO_SNDTIMEO, TCP_NODELAY,
};
#[cfg(not(any(
target_os = "dragonfly",
Expand Down
10 changes: 7 additions & 3 deletions tests/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ use std::io::IoSlice;
use std::io::Read;
use std::io::Write;
use std::mem::MaybeUninit;
use std::net::{Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6};
use std::net::{Ipv4Addr, SocketAddr, SocketAddrV4};
#[cfg(not(target_os = "redox"))]
use std::net::{Ipv6Addr, SocketAddrV6};
#[cfg(unix)]
use std::os::unix::io::AsRawFd;
#[cfg(windows)]
Expand All @@ -26,7 +28,9 @@ use winapi::um::handleapi::GetHandleInformation;
#[cfg(windows)]
use winapi::um::winbase::HANDLE_FLAG_INHERIT;

use socket2::{Domain, MaybeUninitSlice, Protocol, SockAddr, Socket, TcpKeepalive, Type};
#[cfg(not(target_os = "redox"))]
use socket2::MaybeUninitSlice;
use socket2::{Domain, Protocol, SockAddr, Socket, TcpKeepalive, Type};

#[test]
fn domain_for_address() {
Expand Down Expand Up @@ -722,7 +726,7 @@ test!(reuse_address, set_reuse_address(true));
not(any(windows, target_os = "solaris", target_os = "illumos"))
))]
test!(reuse_port, set_reuse_port(true));
#[cfg(all(feature = "all", unix))]
#[cfg(all(feature = "all", unix, not(target_os = "redox")))]
test!(
#[cfg_attr(target_os = "linux", ignore = "Different value returned")]
mss,
Expand Down

0 comments on commit 9c4a404

Please sign in to comment.