Skip to content

Commit a5f1a29

Browse files
committed
Add support for QNX Neutrino
1 parent ff79dee commit a5f1a29

File tree

3 files changed

+39
-8
lines changed

3 files changed

+39
-8
lines changed

src/sockaddr.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,8 @@ impl From<SocketAddrV4> for SockAddr {
234234
target_os = "ios",
235235
target_os = "macos",
236236
target_os = "netbsd",
237-
target_os = "openbsd"
237+
target_os = "openbsd",
238+
target_os = "nto",
238239
))]
239240
sin_len: 0,
240241
};
@@ -273,7 +274,8 @@ impl From<SocketAddrV6> for SockAddr {
273274
target_os = "ios",
274275
target_os = "macos",
275276
target_os = "netbsd",
276-
target_os = "openbsd"
277+
target_os = "openbsd",
278+
target_os = "nto",
277279
))]
278280
sin6_len: 0,
279281
#[cfg(any(target_os = "solaris", target_os = "illumos"))]
@@ -302,6 +304,7 @@ impl fmt::Debug for SockAddr {
302304
target_os = "netbsd",
303305
target_os = "openbsd",
304306
target_os = "vxworks",
307+
target_os = "nto",
305308
))]
306309
f.field("ss_len", &self.storage.ss_len);
307310
f.field("ss_family", &self.storage.ss_family)

src/socket.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,6 +1138,7 @@ impl Socket {
11381138
target_os = "openbsd",
11391139
target_os = "redox",
11401140
target_os = "solaris",
1141+
target_os = "nto",
11411142
)))]
11421143
pub fn join_multicast_v4_n(
11431144
&self,
@@ -1167,6 +1168,7 @@ impl Socket {
11671168
target_os = "openbsd",
11681169
target_os = "redox",
11691170
target_os = "solaris",
1171+
target_os = "nto",
11701172
)))]
11711173
pub fn leave_multicast_v4_n(
11721174
&self,
@@ -1198,6 +1200,7 @@ impl Socket {
11981200
target_os = "openbsd",
11991201
target_os = "redox",
12001202
target_os = "fuchsia",
1203+
target_os = "nto",
12011204
)))]
12021205
pub fn join_ssm_v4(
12031206
&self,
@@ -1232,6 +1235,7 @@ impl Socket {
12321235
target_os = "openbsd",
12331236
target_os = "redox",
12341237
target_os = "fuchsia",
1238+
target_os = "nto",
12351239
)))]
12361240
pub fn leave_ssm_v4(
12371241
&self,
@@ -1407,6 +1411,7 @@ impl Socket {
14071411
target_os = "redox",
14081412
target_os = "solaris",
14091413
target_os = "windows",
1414+
target_os = "nto",
14101415
)))]
14111416
pub fn set_recv_tos(&self, recv_tos: bool) -> io::Result<()> {
14121417
let recv_tos = if recv_tos { 1 } else { 0 };
@@ -1435,6 +1440,7 @@ impl Socket {
14351440
target_os = "redox",
14361441
target_os = "solaris",
14371442
target_os = "windows",
1443+
target_os = "nto",
14381444
)))]
14391445
pub fn recv_tos(&self) -> io::Result<bool> {
14401446
unsafe {

src/sys/unix.rs

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ pub(crate) use libc::IP_HDRINCL;
8585
target_os = "openbsd",
8686
target_os = "redox",
8787
target_os = "solaris",
88+
target_os = "nto",
8889
)))]
8990
pub(crate) use libc::IP_RECVTOS;
9091
#[cfg(not(any(
@@ -112,6 +113,7 @@ pub(crate) use libc::{
112113
target_os = "openbsd",
113114
target_os = "redox",
114115
target_os = "fuchsia",
116+
target_os = "nto",
115117
)))]
116118
pub(crate) use libc::{
117119
ip_mreq_source as IpMreqSource, IP_ADD_SOURCE_MEMBERSHIP, IP_DROP_SOURCE_MEMBERSHIP,
@@ -124,7 +126,8 @@ pub(crate) use libc::{
124126
target_os = "netbsd",
125127
target_os = "openbsd",
126128
target_os = "solaris",
127-
target_vendor = "apple"
129+
target_vendor = "apple",
130+
target_os = "nto",
128131
)))]
129132
pub(crate) use libc::{IPV6_ADD_MEMBERSHIP, IPV6_DROP_MEMBERSHIP};
130133
#[cfg(any(
@@ -136,6 +139,7 @@ pub(crate) use libc::{IPV6_ADD_MEMBERSHIP, IPV6_DROP_MEMBERSHIP};
136139
target_os = "openbsd",
137140
target_os = "solaris",
138141
target_vendor = "apple",
142+
target_os = "nto",
139143
))]
140144
pub(crate) use libc::{
141145
IPV6_JOIN_GROUP as IPV6_ADD_MEMBERSHIP, IPV6_LEAVE_GROUP as IPV6_DROP_MEMBERSHIP,
@@ -158,9 +162,14 @@ pub(crate) use libc::{TCP_KEEPCNT, TCP_KEEPINTVL};
158162
// See this type in the Windows file.
159163
pub(crate) type Bool = c_int;
160164

161-
#[cfg(target_vendor = "apple")]
165+
#[cfg(any(target_vendor = "apple", target_os = "nto"))]
162166
use libc::TCP_KEEPALIVE as KEEPALIVE_TIME;
163-
#[cfg(not(any(target_vendor = "apple", target_os = "haiku", target_os = "openbsd")))]
167+
#[cfg(not(any(
168+
target_vendor = "apple",
169+
target_os = "haiku",
170+
target_os = "openbsd",
171+
target_os = "nto"
172+
)))]
164173
use libc::TCP_KEEPIDLE as KEEPALIVE_TIME;
165174

166175
/// Helper macro to execute a system call that returns an `io::Result`.
@@ -220,6 +229,7 @@ type IovLen = usize;
220229
target_os = "openbsd",
221230
target_os = "solaris",
222231
target_vendor = "apple",
232+
target_os = "nto",
223233
))]
224234
type IovLen = c_int;
225235

@@ -316,7 +326,8 @@ impl Type {
316326
target_os = "illumos",
317327
target_os = "linux",
318328
target_os = "netbsd",
319-
target_os = "openbsd"
329+
target_os = "openbsd",
330+
target_os = "nto", /* From 7.0 up */
320331
)
321332
))]
322333
#[cfg_attr(
@@ -331,7 +342,8 @@ impl Type {
331342
target_os = "illumos",
332343
target_os = "linux",
333344
target_os = "netbsd",
334-
target_os = "openbsd"
345+
target_os = "openbsd",
346+
target_os = "nto",
335347
)
336348
)))
337349
)]
@@ -347,7 +359,8 @@ impl Type {
347359
target_os = "illumos",
348360
target_os = "linux",
349361
target_os = "netbsd",
350-
target_os = "openbsd"
362+
target_os = "openbsd",
363+
target_os = "nto",
351364
))]
352365
pub(crate) const fn _cloexec(self) -> Type {
353366
Type(self.0 | libc::SOCK_CLOEXEC)
@@ -930,6 +943,12 @@ pub(crate) fn set_tcp_keepalive(fd: Socket, keepalive: &TcpKeepalive) -> io::Res
930943
}
931944
}
932945

946+
#[cfg(target_os = "nto")]
947+
if let Some(time) = keepalive.time {
948+
let secs = into_timeval(Some(time));
949+
unsafe { setsockopt(fd, libc::IPPROTO_TCP, KEEPALIVE_TIME, secs)? }
950+
}
951+
933952
Ok(())
934953
}
935954

@@ -1028,6 +1047,7 @@ pub(crate) fn from_in6_addr(addr: in6_addr) -> Ipv6Addr {
10281047
target_os = "openbsd",
10291048
target_os = "redox",
10301049
target_os = "solaris",
1050+
target_os = "nto",
10311051
)))]
10321052
pub(crate) fn to_mreqn(
10331053
multiaddr: &Ipv4Addr,
@@ -1197,6 +1217,7 @@ impl crate::Socket {
11971217
target_os = "freebsd",
11981218
target_os = "fuchsia",
11991219
target_os = "linux",
1220+
target_os = "nto",
12001221
)
12011222
))]
12021223
#[cfg_attr(
@@ -1208,6 +1229,7 @@ impl crate::Socket {
12081229
target_os = "freebsd",
12091230
target_os = "fuchsia",
12101231
target_os = "linux",
1232+
target_os = "nto",
12111233
)
12121234
)))
12131235
)]

0 commit comments

Comments
 (0)