Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit eb44275

Browse filesBrowse files
committed
Remove special casing for Redox as it is supported by unix target family
1 parent a183475 commit eb44275
Copy full SHA for eb44275

File tree

6 files changed

+12
-232
lines changed
Filter options

6 files changed

+12
-232
lines changed

‎Cargo.toml

Copy file name to clipboardExpand all lines: Cargo.toml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ include = [
2121
[target."cfg(windows)".dependencies]
2222
winapi = { version = "0.3", features = ["handleapi", "winsock2", "ws2def", "ws2ipdef", "ws2tcpip"] }
2323

24-
[target.'cfg(any(target_os="redox", unix, target_os="wasi"))'.dependencies]
24+
[target.'cfg(any(unix, target_os="wasi"))'.dependencies]
2525
libc = "0.2.54"
2626

2727
[dependencies]

‎src/ext.rs

Copy file name to clipboardExpand all lines: src/ext.rs
+9-104Lines changed: 9 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,9 @@ cfg_if! {
4040

4141
use std::time::Duration;
4242

43-
#[cfg(any(unix, target_os = "redox", target_os = "wasi"))] use libc::*;
44-
#[cfg(any(unix, target_os = "redox"))] use std::os::unix::prelude::*;
43+
#[cfg(any(unix, target_os = "wasi"))] use libc::*;
44+
#[cfg(any(unix))] use std::os::unix::prelude::*;
4545
#[cfg(target_os = "wasi")] use std::os::wasi::prelude::*;
46-
#[cfg(target_os = "redox")] pub type Socket = usize;
4746
#[cfg(unix)] pub type Socket = c_int;
4847
#[cfg(target_os = "wasi")] pub type Socket = std::os::wasi::io::RawFd;
4948
#[cfg(windows)] pub type Socket = SOCKET;
@@ -59,7 +58,7 @@ struct tcp_keepalive {
5958
keepaliveinterval: c_ulong,
6059
}
6160

62-
#[cfg(any(unix, target_os = "redox", target_os = "wasi"))] fn v(opt: c_int) -> c_int { opt }
61+
#[cfg(any(unix, target_os = "wasi"))] fn v(opt: c_int) -> c_int { opt }
6362
#[cfg(windows)] fn v(opt: IPPROTO) -> c_int { opt as c_int }
6463

6564
#[cfg(target_os = "wasi")]
@@ -73,8 +72,6 @@ pub fn set_opt<T: Copy>(sock: Socket, opt: c_int, val: c_int,
7372
payload: T) -> io::Result<()> {
7473
unsafe {
7574
let payload = &payload as *const T as *const c_void;
76-
#[cfg(target_os = "redox")]
77-
let sock = sock as c_int;
7875
try!(::cvt(setsockopt(sock, opt, val, payload as *const _,
7976
mem::size_of::<T>() as socklen_t)));
8077
}
@@ -90,8 +87,6 @@ pub fn get_opt<T: Copy>(sock: Socket, opt: c_int, val: c_int) -> io::Result<T> {
9087
unsafe {
9188
let mut slot: T = mem::zeroed();
9289
let mut len = mem::size_of::<T>() as socklen_t;
93-
#[cfg(target_os = "redox")]
94-
let sock = sock as c_int;
9590
try!(::cvt(getsockopt(sock, opt, val,
9691
&mut slot as *mut _ as *mut _,
9792
&mut len)));
@@ -656,7 +651,7 @@ pub trait AsSock {
656651
fn as_sock(&self) -> Socket;
657652
}
658653

659-
#[cfg(any(unix, target_os = "redox", target_os = "wasi"))]
654+
#[cfg(any(unix, target_os = "wasi"))]
660655
impl<T: AsRawFd> AsSock for T {
661656
fn as_sock(&self) -> Socket { self.as_raw_fd() }
662657
}
@@ -672,8 +667,6 @@ cfg_if! {
672667
use libc::SO_KEEPALIVE as KEEPALIVE_OPTION;
673668
} else if #[cfg(unix)] {
674669
use libc::TCP_KEEPIDLE as KEEPALIVE_OPTION;
675-
} else if #[cfg(target_os = "redox")] {
676-
use libc::TCP_KEEPIDLE as KEEPALIVE_OPTION;
677670
} else {
678671
// ...
679672
}
@@ -715,29 +708,6 @@ impl TcpStreamExt for TcpStream {
715708
self.keepalive_ms().map(|o| o.map(ms2dur))
716709
}
717710

718-
#[cfg(target_os = "redox")]
719-
fn set_keepalive_ms(&self, keepalive: Option<u32>) -> io::Result<()> {
720-
try!(set_opt(self.as_sock(), SOL_SOCKET, SO_KEEPALIVE,
721-
keepalive.is_some() as c_int));
722-
if let Some(dur) = keepalive {
723-
try!(set_opt(self.as_sock(), v(IPPROTO_TCP), KEEPALIVE_OPTION,
724-
(dur / 1000) as c_int));
725-
}
726-
Ok(())
727-
}
728-
729-
#[cfg(target_os = "redox")]
730-
fn keepalive_ms(&self) -> io::Result<Option<u32>> {
731-
let keepalive = try!(get_opt::<c_int>(self.as_sock(), SOL_SOCKET,
732-
SO_KEEPALIVE));
733-
if keepalive == 0 {
734-
return Ok(None)
735-
}
736-
let secs = try!(get_opt::<c_int>(self.as_sock(), v(IPPROTO_TCP),
737-
KEEPALIVE_OPTION));
738-
Ok(Some((secs as u32) * 1000))
739-
}
740-
741711
#[cfg(unix)]
742712
fn set_keepalive_ms(&self, keepalive: Option<u32>) -> io::Result<()> {
743713
try!(set_opt(self.as_sock(), SOL_SOCKET, SO_KEEPALIVE,
@@ -893,7 +863,7 @@ impl TcpStreamExt for TcpStream {
893863
}
894864
}
895865

896-
#[cfg(any(target_os = "redox", unix, target_os = "wasi"))]
866+
#[cfg(any(unix, target_os = "wasi"))]
897867
fn ms2timeout(dur: Option<u32>) -> timeval {
898868
// TODO: be more rigorous
899869
match dur {
@@ -905,7 +875,7 @@ fn ms2timeout(dur: Option<u32>) -> timeval {
905875
}
906876
}
907877

908-
#[cfg(any(target_os = "redox", unix, target_os = "wasi"))]
878+
#[cfg(any(unix, target_os = "wasi"))]
909879
fn timeout2ms(dur: timeval) -> Option<u32> {
910880
if dur.tv_sec == 0 && dur.tv_usec == 0 {
911881
None
@@ -950,7 +920,7 @@ fn dur2linger(dur: Option<Duration>) -> linger {
950920
}
951921
}
952922

953-
#[cfg(any(target_os = "redox", unix, target_os = "wasi"))]
923+
#[cfg(any(unix, target_os = "wasi"))]
954924
fn dur2linger(dur: Option<Duration>) -> linger {
955925
match dur {
956926
Some(d) => {
@@ -1027,24 +997,18 @@ impl UdpSocketExt for UdpSocket {
1027997
set_opt(self.as_sock(), IPPROTO_IP, IP_MULTICAST_TTL,
1028998
multicast_ttl_v4 as c_int)
1029999
}
1030-
1000+
10311001
fn multicast_ttl_v4(&self) -> io::Result<u32> {
10321002
get_opt::<c_int>(self.as_sock(), IPPROTO_IP, IP_MULTICAST_TTL)
10331003
.map(|b| b as u32)
10341004
}
10351005

10361006
fn set_multicast_hops_v6(&self, _hops: u32) -> io::Result<()> {
1037-
#[cfg(target_os = "redox")]
1038-
return Err(io::Error::new(io::ErrorKind::Other, "Not implemented yet"));
1039-
#[cfg(not(target_os = "redox"))]
10401007
set_opt(self.as_sock(), v(IPPROTO_IPV6), IPV6_MULTICAST_HOPS,
10411008
_hops as c_int)
10421009
}
10431010

10441011
fn multicast_hops_v6(&self) -> io::Result<u32> {
1045-
#[cfg(target_os = "redox")]
1046-
return Err(io::Error::new(io::ErrorKind::Other, "Not implemented yet"));
1047-
#[cfg(not(target_os = "redox"))]
10481012
get_opt::<c_int>(self.as_sock(), v(IPPROTO_IPV6), IPV6_MULTICAST_HOPS)
10491013
.map(|b| b as u32)
10501014
}
@@ -1059,30 +1023,18 @@ impl UdpSocketExt for UdpSocket {
10591023
}
10601024

10611025
fn set_multicast_if_v4(&self, _interface: &Ipv4Addr) -> io::Result<()> {
1062-
#[cfg(target_os = "redox")]
1063-
return Err(io::Error::new(io::ErrorKind::Other, "Not implemented yet"));
1064-
#[cfg(not(target_os = "redox"))]
10651026
set_opt(self.as_sock(), IPPROTO_IP, IP_MULTICAST_IF, ip2in_addr(_interface))
10661027
}
10671028

10681029
fn multicast_if_v4(&self) -> io::Result<Ipv4Addr> {
1069-
#[cfg(target_os = "redox")]
1070-
return Err(io::Error::new(io::ErrorKind::Other, "Not implemented yet"));
1071-
#[cfg(not(target_os = "redox"))]
10721030
get_opt(self.as_sock(), IPPROTO_IP, IP_MULTICAST_IF).map(in_addr2ip)
10731031
}
10741032

10751033
fn set_multicast_if_v6(&self, _interface: u32) -> io::Result<()> {
1076-
#[cfg(target_os = "redox")]
1077-
return Err(io::Error::new(io::ErrorKind::Other, "Not implemented yet"));
1078-
#[cfg(not(target_os = "redox"))]
10791034
set_opt(self.as_sock(), v(IPPROTO_IPV6), IPV6_MULTICAST_IF, to_ipv6mr_interface(_interface))
10801035
}
10811036

10821037
fn multicast_if_v6(&self) -> io::Result<u32> {
1083-
#[cfg(target_os = "redox")]
1084-
return Err(io::Error::new(io::ErrorKind::Other, "Not implemented yet"));
1085-
#[cfg(not(target_os = "redox"))]
10861038
get_opt::<c_int>(self.as_sock(), v(IPPROTO_IPV6), IPV6_MULTICAST_IF).map(|b| b as u32)
10871039
}
10881040

@@ -1096,16 +1048,10 @@ impl UdpSocketExt for UdpSocket {
10961048
}
10971049

10981050
fn set_unicast_hops_v6(&self, _ttl: u32) -> io::Result<()> {
1099-
#[cfg(target_os = "redox")]
1100-
return Err(io::Error::new(io::ErrorKind::Other, "Not implemented yet"));
1101-
#[cfg(not(target_os = "redox"))]
11021051
set_opt(self.as_sock(), v(IPPROTO_IPV6), IPV6_UNICAST_HOPS, _ttl as c_int)
11031052
}
11041053

11051054
fn unicast_hops_v6(&self) -> io::Result<u32> {
1106-
#[cfg(target_os = "redox")]
1107-
return Err(io::Error::new(io::ErrorKind::Other, "Not implemented yet"));
1108-
#[cfg(not(target_os = "redox"))]
11091055
get_opt::<c_int>(self.as_sock(), IPPROTO_IP, IPV6_UNICAST_HOPS)
11101056
.map(|b| b as u32)
11111057
}
@@ -1200,13 +1146,6 @@ impl UdpSocketExt for UdpSocket {
12001146
do_connect(self.as_sock(), addr)
12011147
}
12021148

1203-
#[cfg(target_os = "redox")]
1204-
fn send(&self, buf: &[u8]) -> io::Result<usize> {
1205-
unsafe {
1206-
::cvt(write(self.as_sock() as c_int, buf.as_ptr() as *const _, buf.len())).map(|n| n as usize)
1207-
}
1208-
}
1209-
12101149
#[cfg(unix)]
12111150
fn send(&self, buf: &[u8]) -> io::Result<usize> {
12121151
unsafe {
@@ -1240,14 +1179,6 @@ impl UdpSocketExt for UdpSocket {
12401179
}
12411180
}
12421181

1243-
#[cfg(target_os = "redox")]
1244-
fn recv(&self, buf: &mut [u8]) -> io::Result<usize> {
1245-
unsafe {
1246-
::cvt(read(self.as_sock() as c_int, buf.as_mut_ptr() as *mut _, buf.len()))
1247-
.map(|n| n as usize)
1248-
}
1249-
}
1250-
12511182
#[cfg(unix)]
12521183
fn recv(&self, buf: &mut [u8]) -> io::Result<usize> {
12531184
unsafe {
@@ -1302,21 +1233,6 @@ fn do_connect<A: ToSocketAddrs>(sock: Socket, addr: A) -> io::Result<()> {
13021233
return ret
13031234
}
13041235

1305-
#[cfg(target_os = "redox")]
1306-
fn set_nonblocking(sock: Socket, nonblocking: bool) -> io::Result<()> {
1307-
let mut flags = ::cvt(unsafe {
1308-
fcntl(sock as c_int, F_GETFL)
1309-
})?;
1310-
if nonblocking {
1311-
flags |= O_NONBLOCK;
1312-
} else {
1313-
flags &= !O_NONBLOCK;
1314-
}
1315-
::cvt(unsafe {
1316-
fcntl(sock as c_int, F_SETFL, flags)
1317-
}).and(Ok(()))
1318-
}
1319-
13201236
#[cfg(unix)]
13211237
fn set_nonblocking(sock: Socket, nonblocking: bool) -> io::Result<()> {
13221238
let mut nonblocking = nonblocking as c_ulong;
@@ -1338,17 +1254,6 @@ fn set_nonblocking(sock: Socket, nonblocking: bool) -> io::Result<()> {
13381254
}).map(|_| ())
13391255
}
13401256

1341-
#[cfg(target_os = "redox")]
1342-
fn ip2in_addr(ip: &Ipv4Addr) -> in_addr {
1343-
let oct = ip.octets();
1344-
in_addr {
1345-
s_addr: ::hton(((oct[0] as u32) << 24) |
1346-
((oct[1] as u32) << 16) |
1347-
((oct[2] as u32) << 8) |
1348-
((oct[3] as u32) << 0)),
1349-
}
1350-
}
1351-
13521257
#[cfg(any(unix, target_os = "wasi"))]
13531258
fn ip2in_addr(ip: &Ipv4Addr) -> in_addr {
13541259
let oct = ip.octets();
@@ -1377,7 +1282,7 @@ fn ip2in_addr(ip: &Ipv4Addr) -> in_addr {
13771282

13781283
fn in_addr2ip(ip: &in_addr) -> Ipv4Addr {
13791284
let h_addr = c::in_addr_to_u32(ip);
1380-
1285+
13811286
let a: u8 = (h_addr >> 24) as u8;
13821287
let b: u8 = (h_addr >> 16) as u8;
13831288
let c: u8 = (h_addr >> 8) as u8;

‎src/lib.rs

Copy file name to clipboardExpand all lines: src/lib.rs
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646

4747
#![cfg_attr(target_os = "wasi", feature(wasi_ext))]
4848

49-
#[cfg(any(target_os = "redox", target_os = "wasi", unix))] extern crate libc;
49+
#[cfg(any(target_os = "wasi", unix))] extern crate libc;
5050

5151
#[cfg(windows)] extern crate winapi;
5252

@@ -64,7 +64,6 @@ mod socket;
6464
mod ext;
6565
mod utils;
6666

67-
#[cfg(target_os="redox")] #[path = "sys/redox/mod.rs"] mod sys;
6867
#[cfg(unix)] #[path = "sys/unix/mod.rs"] mod sys;
6968
#[cfg(windows)] #[path = "sys/windows/mod.rs"] mod sys;
7069
#[cfg(target_os = "wasi")] #[path = "sys/wasi/mod.rs"] mod sys;

‎src/socket.rs

Copy file name to clipboardExpand all lines: src/socket.rs
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use std::fmt;
1212
use std::io;
1313
use std::mem;
1414
use std::net::{Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6};
15-
#[cfg(any(unix, target_os = "redox", target_os = "wasi"))]
15+
#[cfg(any(unix, target_os = "wasi"))]
1616
use libc::c_int;
1717
#[cfg(windows)]
1818
use winapi::ctypes::c_int;

‎src/sys/redox/impls.rs

Copy file name to clipboardExpand all lines: src/sys/redox/impls.rs
-43Lines changed: 0 additions & 43 deletions
This file was deleted.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.