Skip to content

Add support for QNX Neutrino to 0.4 branch #381

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

Closed
wants to merge 2 commits into from
Closed
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
20 changes: 16 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,13 +329,19 @@ impl<'a> DerefMut for MaybeUninitSlice<'a> {
pub struct TcpKeepalive {
#[cfg_attr(target_os = "openbsd", allow(dead_code))]
time: Option<Duration>,
#[cfg(not(any(target_os = "openbsd", target_os = "redox", target_os = "solaris")))]
#[cfg(not(any(
target_os = "openbsd",
target_os = "redox",
target_os = "solaris",
target_os = "nto",
)))]
interval: Option<Duration>,
#[cfg(not(any(
target_os = "openbsd",
target_os = "redox",
target_os = "solaris",
target_os = "windows"
target_os = "windows",
target_os = "nto",
)))]
retries: Option<u32>,
}
Expand All @@ -345,13 +351,19 @@ impl TcpKeepalive {
pub const fn new() -> TcpKeepalive {
TcpKeepalive {
time: None,
#[cfg(not(any(target_os = "openbsd", target_os = "redox", target_os = "solaris")))]
#[cfg(not(any(
target_os = "openbsd",
target_os = "redox",
target_os = "solaris",
target_os = "nto",
)))]
interval: None,
#[cfg(not(any(
target_os = "openbsd",
target_os = "redox",
target_os = "solaris",
target_os = "windows"
target_os = "windows",
target_os = "nto",
)))]
retries: None,
}
Expand Down
7 changes: 5 additions & 2 deletions src/sockaddr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,8 @@ impl From<SocketAddrV4> for SockAddr {
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
target_os = "openbsd"
target_os = "openbsd",
target_os = "nto",
))]
sin_len: 0,
};
Expand Down Expand Up @@ -273,7 +274,8 @@ impl From<SocketAddrV6> for SockAddr {
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
target_os = "openbsd"
target_os = "openbsd",
target_os = "nto",
))]
sin6_len: 0,
#[cfg(any(target_os = "solaris", target_os = "illumos"))]
Expand Down Expand Up @@ -302,6 +304,7 @@ impl fmt::Debug for SockAddr {
target_os = "netbsd",
target_os = "openbsd",
target_os = "vxworks",
target_os = "nto",
))]
f.field("ss_len", &self.storage.ss_len);
f.field("ss_family", &self.storage.ss_family)
Expand Down
6 changes: 6 additions & 0 deletions src/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1138,6 +1138,7 @@ impl Socket {
target_os = "openbsd",
target_os = "redox",
target_os = "solaris",
target_os = "nto",
)))]
pub fn join_multicast_v4_n(
&self,
Expand Down Expand Up @@ -1167,6 +1168,7 @@ impl Socket {
target_os = "openbsd",
target_os = "redox",
target_os = "solaris",
target_os = "nto",
)))]
pub fn leave_multicast_v4_n(
&self,
Expand Down Expand Up @@ -1198,6 +1200,7 @@ impl Socket {
target_os = "openbsd",
target_os = "redox",
target_os = "fuchsia",
target_os = "nto",
)))]
pub fn join_ssm_v4(
&self,
Expand Down Expand Up @@ -1232,6 +1235,7 @@ impl Socket {
target_os = "openbsd",
target_os = "redox",
target_os = "fuchsia",
target_os = "nto",
)))]
pub fn leave_ssm_v4(
&self,
Expand Down Expand Up @@ -1407,6 +1411,7 @@ impl Socket {
target_os = "redox",
target_os = "solaris",
target_os = "windows",
target_os = "nto",
)))]
pub fn set_recv_tos(&self, recv_tos: bool) -> io::Result<()> {
let recv_tos = if recv_tos { 1 } else { 0 };
Expand Down Expand Up @@ -1435,6 +1440,7 @@ impl Socket {
target_os = "redox",
target_os = "solaris",
target_os = "windows",
target_os = "nto",
)))]
pub fn recv_tos(&self) -> io::Result<bool> {
unsafe {
Expand Down
34 changes: 28 additions & 6 deletions src/sys/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ pub(crate) use libc::IP_HDRINCL;
target_os = "openbsd",
target_os = "redox",
target_os = "solaris",
target_os = "nto",
)))]
pub(crate) use libc::IP_RECVTOS;
#[cfg(not(any(
Expand Down Expand Up @@ -112,6 +113,7 @@ pub(crate) use libc::{
target_os = "openbsd",
target_os = "redox",
target_os = "fuchsia",
target_os = "nto",
)))]
pub(crate) use libc::{
ip_mreq_source as IpMreqSource, IP_ADD_SOURCE_MEMBERSHIP, IP_DROP_SOURCE_MEMBERSHIP,
Expand All @@ -124,7 +126,8 @@ pub(crate) use libc::{
target_os = "netbsd",
target_os = "openbsd",
target_os = "solaris",
target_vendor = "apple"
target_vendor = "apple",
target_os = "nto",
)))]
pub(crate) use libc::{IPV6_ADD_MEMBERSHIP, IPV6_DROP_MEMBERSHIP};
#[cfg(any(
Expand All @@ -136,6 +139,7 @@ pub(crate) use libc::{IPV6_ADD_MEMBERSHIP, IPV6_DROP_MEMBERSHIP};
target_os = "openbsd",
target_os = "solaris",
target_vendor = "apple",
target_os = "nto",
))]
pub(crate) use libc::{
IPV6_JOIN_GROUP as IPV6_ADD_MEMBERSHIP, IPV6_LEAVE_GROUP as IPV6_DROP_MEMBERSHIP,
Expand All @@ -158,9 +162,14 @@ pub(crate) use libc::{TCP_KEEPCNT, TCP_KEEPINTVL};
// See this type in the Windows file.
pub(crate) type Bool = c_int;

#[cfg(target_vendor = "apple")]
#[cfg(any(target_vendor = "apple", target_os = "nto"))]
use libc::TCP_KEEPALIVE as KEEPALIVE_TIME;
#[cfg(not(any(target_vendor = "apple", target_os = "haiku", target_os = "openbsd")))]
#[cfg(not(any(
target_vendor = "apple",
target_os = "haiku",
target_os = "openbsd",
target_os = "nto"
)))]
use libc::TCP_KEEPIDLE as KEEPALIVE_TIME;

/// Helper macro to execute a system call that returns an `io::Result`.
Expand Down Expand Up @@ -220,6 +229,7 @@ type IovLen = usize;
target_os = "openbsd",
target_os = "solaris",
target_vendor = "apple",
target_os = "nto",
))]
type IovLen = c_int;

Expand Down Expand Up @@ -316,7 +326,8 @@ impl Type {
target_os = "illumos",
target_os = "linux",
target_os = "netbsd",
target_os = "openbsd"
target_os = "openbsd",
target_os = "nto", /* From 7.0 up */
)
))]
#[cfg_attr(
Expand All @@ -331,7 +342,8 @@ impl Type {
target_os = "illumos",
target_os = "linux",
target_os = "netbsd",
target_os = "openbsd"
target_os = "openbsd",
target_os = "nto",
)
)))
)]
Expand All @@ -347,7 +359,8 @@ impl Type {
target_os = "illumos",
target_os = "linux",
target_os = "netbsd",
target_os = "openbsd"
target_os = "openbsd",
target_os = "nto",
))]
pub(crate) const fn _cloexec(self) -> Type {
Type(self.0 | libc::SOCK_CLOEXEC)
Expand Down Expand Up @@ -930,6 +943,12 @@ pub(crate) fn set_tcp_keepalive(fd: Socket, keepalive: &TcpKeepalive) -> io::Res
}
}

#[cfg(target_os = "nto")]
if let Some(time) = keepalive.time {
let secs = into_timeval(Some(time));
unsafe { setsockopt(fd, libc::IPPROTO_TCP, KEEPALIVE_TIME, secs)? }
}

Ok(())
}

Expand Down Expand Up @@ -1028,6 +1047,7 @@ pub(crate) fn from_in6_addr(addr: in6_addr) -> Ipv6Addr {
target_os = "openbsd",
target_os = "redox",
target_os = "solaris",
target_os = "nto",
)))]
pub(crate) fn to_mreqn(
multiaddr: &Ipv4Addr,
Expand Down Expand Up @@ -1197,6 +1217,7 @@ impl crate::Socket {
target_os = "freebsd",
target_os = "fuchsia",
target_os = "linux",
target_os = "nto",
)
))]
#[cfg_attr(
Expand All @@ -1208,6 +1229,7 @@ impl crate::Socket {
target_os = "freebsd",
target_os = "fuchsia",
target_os = "linux",
target_os = "nto",
)
)))
)]
Expand Down