Skip to content

Commit 9c4a404

Browse files
committed
Fix compilation on Redox
1 parent e9df5ba commit 9c4a404

File tree

5 files changed

+17
-11
lines changed

5 files changed

+17
-11
lines changed

.github/workflows/main.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ jobs:
5555
- name: Install Rust
5656
run: rustup update nightly && rustup default nightly
5757
- run: rustup target add ${{ matrix.target }}
58-
- run: cargo check --target ${{ matrix.target }}
59-
- run: cargo check --target ${{ matrix.target }} --features all
58+
- run: cargo check --target ${{ matrix.target }} --all-targets --examples --bins --tests --no-default-features
59+
- run: cargo check --target ${{ matrix.target }} --all-targets --examples --bins --tests --all-features
6060
continue-on-error: true
6161

6262
publish_docs:

src/sockaddr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ impl SockAddr {
7878
}
7979

8080
/// Returns a raw pointer to the address storage.
81-
#[cfg(unix)]
81+
#[cfg(all(unix, not(target_os = "redox")))]
8282
pub(crate) const fn as_storage_ptr(&self) -> *const sockaddr_storage {
8383
&self.storage
8484
}

src/socket.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ use std::os::windows::io::{FromRawSocket, IntoRawSocket};
1919
use std::time::Duration;
2020

2121
use crate::sys::{self, c_int, getsockopt, setsockopt, Bool};
22+
use crate::{Domain, Protocol, SockAddr, TcpKeepalive, Type};
2223
#[cfg(not(target_os = "redox"))]
23-
use crate::RecvFlags;
24-
use crate::{Domain, MaybeUninitSlice, Protocol, SockAddr, TcpKeepalive, Type};
24+
use crate::{MaybeUninitSlice, RecvFlags};
2525

2626
/// Owned wrapper around a system socket.
2727
///

src/sys/unix.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ use std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd};
2222
use std::os::unix::net::{UnixDatagram, UnixListener, UnixStream};
2323
#[cfg(feature = "all")]
2424
use std::path::Path;
25+
#[cfg(not(all(target_os = "redox", not(feature = "all"))))]
26+
use std::ptr;
2527
use std::time::Duration;
26-
use std::{io, ptr, slice};
28+
use std::{io, slice};
2729

2830
#[cfg(not(target_vendor = "apple"))]
2931
use libc::ssize_t;
@@ -51,14 +53,14 @@ pub(crate) use libc::{
5153
};
5254
// Used in `RecvFlags`.
5355
#[cfg(not(target_os = "redox"))]
54-
pub(crate) use libc::MSG_TRUNC;
56+
pub(crate) use libc::{MSG_TRUNC, SO_OOBINLINE};
5557
// Used in `Socket`.
5658
pub(crate) use libc::{
5759
ip_mreq as IpMreq, ipv6_mreq as Ipv6Mreq, linger, IPPROTO_IP, IPPROTO_IPV6,
5860
IPV6_MULTICAST_HOPS, IPV6_MULTICAST_IF, IPV6_MULTICAST_LOOP, IPV6_UNICAST_HOPS, IPV6_V6ONLY,
5961
IP_ADD_MEMBERSHIP, IP_DROP_MEMBERSHIP, IP_MULTICAST_IF, IP_MULTICAST_LOOP, IP_MULTICAST_TTL,
6062
IP_TTL, MSG_OOB, MSG_PEEK, SOL_SOCKET, SO_BROADCAST, SO_ERROR, SO_KEEPALIVE, SO_LINGER,
61-
SO_OOBINLINE, SO_RCVBUF, SO_RCVTIMEO, SO_REUSEADDR, SO_SNDBUF, SO_SNDTIMEO, TCP_NODELAY,
63+
SO_RCVBUF, SO_RCVTIMEO, SO_REUSEADDR, SO_SNDBUF, SO_SNDTIMEO, TCP_NODELAY,
6264
};
6365
#[cfg(not(any(
6466
target_os = "dragonfly",

tests/socket.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ use std::io::IoSlice;
88
use std::io::Read;
99
use std::io::Write;
1010
use std::mem::MaybeUninit;
11-
use std::net::{Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6};
11+
use std::net::{Ipv4Addr, SocketAddr, SocketAddrV4};
12+
#[cfg(not(target_os = "redox"))]
13+
use std::net::{Ipv6Addr, SocketAddrV6};
1214
#[cfg(unix)]
1315
use std::os::unix::io::AsRawFd;
1416
#[cfg(windows)]
@@ -26,7 +28,9 @@ use winapi::um::handleapi::GetHandleInformation;
2628
#[cfg(windows)]
2729
use winapi::um::winbase::HANDLE_FLAG_INHERIT;
2830

29-
use socket2::{Domain, MaybeUninitSlice, Protocol, SockAddr, Socket, TcpKeepalive, Type};
31+
#[cfg(not(target_os = "redox"))]
32+
use socket2::MaybeUninitSlice;
33+
use socket2::{Domain, Protocol, SockAddr, Socket, TcpKeepalive, Type};
3034

3135
#[test]
3236
fn domain_for_address() {
@@ -722,7 +726,7 @@ test!(reuse_address, set_reuse_address(true));
722726
not(any(windows, target_os = "solaris", target_os = "illumos"))
723727
))]
724728
test!(reuse_port, set_reuse_port(true));
725-
#[cfg(all(feature = "all", unix))]
729+
#[cfg(all(feature = "all", unix, not(target_os = "redox")))]
726730
test!(
727731
#[cfg_attr(target_os = "linux", ignore = "Different value returned")]
728732
mss,

0 commit comments

Comments
 (0)