Bug 1542826 - Bump net2 to a version that builds on 64-bit android. r=froydnj
authorKartikaya Gupta <kgupta@mozilla.com>
Thu, 25 Apr 2019 19:28:42 +0000
changeset 530180 459c9408935dee772b87c51edcf2eda470ad495c
parent 530179 59a08c05c327a26a92386a1f0da29f585994c1a3
child 530181 004c7b730f409df214eca1aa529100f13a8d04a3
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1542826
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1542826 - Bump net2 to a version that builds on 64-bit android. r=froydnj Differential Revision: https://phabricator.services.mozilla.com/D28888
Cargo.lock
third_party/rust/net2/.cargo-checksum.json
third_party/rust/net2/Cargo.toml
third_party/rust/net2/README.md
third_party/rust/net2/src/ext.rs
third_party/rust/net2/src/lib.rs
third_party/rust/net2/src/socket.rs
third_party/rust/net2/src/sys/redox/impls.rs
third_party/rust/net2/src/sys/redox/mod.rs
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1365,17 +1365,17 @@ dependencies = [
  "futures 0.1.23 (registry+https://github.com/rust-lang/crates.io-index)",
  "futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
  "h2 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
  "http 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
  "httparse 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
  "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "itoa 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
- "net2 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)",
+ "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
  "time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
  "tokio 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
  "tokio-executor 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
  "tokio-io 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
  "tokio-reactor 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
  "tokio-tcp 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "tokio-timer 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
  "want 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1720,17 +1720,17 @@ dependencies = [
  "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
  "fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
  "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "lazycell 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "net2 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)",
+ "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
  "slab 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
 name = "mio-named-pipes"
 version = "0.1.5"
 source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1752,17 +1752,17 @@ dependencies = [
 ]
 
 [[package]]
 name = "miow"
 version = "0.2.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "net2 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)",
+ "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
  "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
  "ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
 name = "moz_cbor"
 version = "0.1.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1875,17 +1875,17 @@ version = "0.1.6"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
  "winapi 0.3.6 (git+https://github.com/froydnj/winapi-rs?branch=aarch64)",
 ]
 
 [[package]]
 name = "net2"
-version = "0.2.32"
+version = "0.2.33"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
  "winapi 0.3.6 (git+https://github.com/froydnj/winapi-rs?branch=aarch64)",
 ]
 
 [[package]]
@@ -3628,17 +3628,17 @@ dependencies = [
 "checksum miniz_oxide_c_api 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "92d98fdbd6145645828069b37ea92ca3de225e000d80702da25c20d3584b38a5"
 "checksum mio 0.6.15 (registry+https://github.com/rust-lang/crates.io-index)" = "4fcfcb32d63961fb6f367bfd5d21e4600b92cd310f71f9dca25acae196eb1560"
 "checksum mio-named-pipes 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "82f43a815b57d2d652550f3d20cec88a495bb2d0956aa873dc43040278455677"
 "checksum mio-uds 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "1731a873077147b626d89cc6c2a0db6288d607496c5d10c0cfcf3adc697ec673"
 "checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919"
 "checksum moz_cbor 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20c82a57087fd5990d7122dbff1607c3b20c3d2958e9d9ad9765aab415e2c91c"
 "checksum mp4parse_fallible 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6626c2aef76eb8f984eef02e475883d3fe9112e114720446c5810fc5f045cd30"
 "checksum msdos_time 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "aad9dfe950c057b1bfe9c1f2aa51583a8468ef2a5baba2ebbe06d775efeb7729"
-"checksum net2 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)" = "9044faf1413a1057267be51b5afba8eb1090bd2231c693664aa1db716fe1eae0"
+"checksum net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88"
 "checksum new_debug_unreachable 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0cdc457076c78ab54d5e0d6fa7c47981757f1e34dc39ff92787f217dede586c4"
 "checksum nodrop 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "9a2228dca57108069a5262f2ed8bd2e82496d2e074a06d1ccc7ce1687b6ae0a2"
 "checksum nom 3.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05aec50c70fd288702bcd93284a8444607f3292dbdf2a30de5ea5dcdbe72287b"
 "checksum nom 4.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9c349f68f25f596b9f44cf0e7c69752a5c633b0550c3ff849518bfba0233774a"
 "checksum num-derive 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0d2c31b75c36a993d30c7a13d70513cb93f02acafdd5b7ba250f9b0e18615de7"
 "checksum num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)" = "e83d528d2677f0518c570baf2b7abdcf0cd2d248860b68507bdcb3e91d4c0cea"
 "checksum num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)" = "92e5113e9fd4cc14ded8e499429f396a20f98c772a47cc8622a736e1ec843c31"
 "checksum num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0b3a5d7cc97d6d30d8b9bc8fa19bf45349ffe46241e8816f50f62f6d6aaabee1"
--- a/third_party/rust/net2/.cargo-checksum.json
+++ b/third_party/rust/net2/.cargo-checksum.json
@@ -1,1 +1,1 @@
-{"files":{"Cargo.toml":"b545fbbaf6d6a66d31e0c47edf28489e160c29bff3f8e1df01c43efeebc9cfe6","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"6485b8ed310d3f0340bf1ad1f47645069ce4069dcc6bb46c7d5c6faf41de1fdb","README.md":"07bdbd3752d286b8993d0954657485521f2a9da96cc54c7c298965a65c3d2b3e","appveyor.yml":"6e3173d907ccfa65e289c99042cb29d4a23b9d1f4ec5bf7afa6c0d65365bab54","src/ext.rs":"8b58f79463ab528b7c28734d27feb7e1bb9893a120881a567d7ed709afe0360d","src/lib.rs":"db08d8dcd2dcf0323b7f6bdd597827982ed2ccf377572a0db722de376597a7e9","src/socket.rs":"541c8f2d92074758d9c30802963870e0dc813795141a466c039061af14652dba","src/sys/unix/impls.rs":"05f123226e8fe7559317d50864021650b2455d25d01a9aff1c65c01ae26cf4ef","src/sys/unix/mod.rs":"bb28a7275eac021132b01206d134802902d616c0be3e82100b45a3ff1eba4c02","src/sys/windows/impls.rs":"bee70b7cd45055c4eaa1967f7aad7ec46639de458c71ed6f3e97a2f7b2c49281","src/sys/windows/mod.rs":"0706f1587af0f693f75e8597e4196075a3f673c89727dd865447da306974bf35","src/tcp.rs":"0bebf5cca75714151de30c8f2d7697ca519c57da065e93ba81796bce04673f8d","src/udp.rs":"8af5a55a4ae5e4120ffe18dcc4dc24072e18da34bf3591a02b18653e5d3e8ac8","src/unix.rs":"fe9cdbd75ef2e1fafc128d1abb5f32500eaf0b674aa618d837e06ab1d0dc6687","src/utils.rs":"d31de5333a6fa2f5c99b64cc937be596888d9863264632e6bc6b36b30197fa5b","tests/all.rs":"12cb4616c842f655ece1b477664d41821f95b3051053da641b1d85026ee18274"},"package":"9044faf1413a1057267be51b5afba8eb1090bd2231c693664aa1db716fe1eae0"}
\ No newline at end of file
+{"files":{"Cargo.toml":"c18ec02a8566f054a27e18df2ac53856a74864fad952a41abda096c91caae106","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"6485b8ed310d3f0340bf1ad1f47645069ce4069dcc6bb46c7d5c6faf41de1fdb","README.md":"c13834771aa1973a02dfbf99c282850ea1d6974269ebe9081cd2853a5ac59c93","appveyor.yml":"6e3173d907ccfa65e289c99042cb29d4a23b9d1f4ec5bf7afa6c0d65365bab54","src/ext.rs":"b9300ae246e9ac451889f146ece8bb6ed4a95482edf806373de5af759cd09360","src/lib.rs":"8d8a171090b75e86e7505921460fba072db0077942edd11c4a3c8a70e9164eef","src/socket.rs":"a033d04061d95c4fea3eb78ce25f147d3b669034681e4119d00bc78b817a8096","src/sys/redox/impls.rs":"90059116f0514bd44dbf282a3e8d7b192c99e1a78a34ebacb00f2d325ca0f8b0","src/sys/redox/mod.rs":"137013d409fd174fed0ceb3eceb2c17d15f34a3af70c7d237c06dd3a144affc1","src/sys/unix/impls.rs":"05f123226e8fe7559317d50864021650b2455d25d01a9aff1c65c01ae26cf4ef","src/sys/unix/mod.rs":"bb28a7275eac021132b01206d134802902d616c0be3e82100b45a3ff1eba4c02","src/sys/windows/impls.rs":"bee70b7cd45055c4eaa1967f7aad7ec46639de458c71ed6f3e97a2f7b2c49281","src/sys/windows/mod.rs":"0706f1587af0f693f75e8597e4196075a3f673c89727dd865447da306974bf35","src/tcp.rs":"0bebf5cca75714151de30c8f2d7697ca519c57da065e93ba81796bce04673f8d","src/udp.rs":"8af5a55a4ae5e4120ffe18dcc4dc24072e18da34bf3591a02b18653e5d3e8ac8","src/unix.rs":"fe9cdbd75ef2e1fafc128d1abb5f32500eaf0b674aa618d837e06ab1d0dc6687","src/utils.rs":"d31de5333a6fa2f5c99b64cc937be596888d9863264632e6bc6b36b30197fa5b","tests/all.rs":"12cb4616c842f655ece1b477664d41821f95b3051053da641b1d85026ee18274"},"package":"42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88"}
\ No newline at end of file
--- a/third_party/rust/net2/Cargo.toml
+++ b/third_party/rust/net2/Cargo.toml
@@ -7,36 +7,28 @@
 #
 # If you believe there's an error in this file please file an
 # issue against the rust-lang/cargo repository. If you're
 # editing this file be aware that the upstream Cargo.toml
 # will likely look very different (and much more reasonable)
 
 [package]
 name = "net2"
-version = "0.2.32"
+version = "0.2.33"
 authors = ["Alex Crichton <alex@alexcrichton.com>"]
 description = "Extensions to the standard library's networking types as proposed in RFC 1158.\n"
 homepage = "https://github.com/rust-lang-nursery/net2-rs"
 documentation = "https://doc.rust-lang.org/net2-rs/"
 readme = "README.md"
 license = "MIT/Apache-2.0"
 repository = "https://github.com/rust-lang-nursery/net2-rs"
 [dependencies.cfg-if]
 version = "0.1"
 
 [features]
 default = ["duration"]
 duration = []
 nightly = []
-[target."cfg(unix)".dependencies.libc]
-version = "0.2.37"
+[target."cfg(any(target_os=\"redox\", unix))".dependencies.libc]
+version = "0.2.42"
 [target."cfg(windows)".dependencies.winapi]
 version = "0.3"
 features = ["handleapi", "winsock2", "ws2def", "ws2ipdef", "ws2tcpip"]
-[target.i686-apple-darwin.dependencies.libc]
-version = "0.2.37"
-[target.i686-unknown-linux-gnu.dependencies.libc]
-version = "0.2.37"
-[target.x86_64-apple-darwin.dependencies.libc]
-version = "0.2.37"
-[target.x86_64-unknown-linux-gnu.dependencies.libc]
-version = "0.2.37"
--- a/third_party/rust/net2/README.md
+++ b/third_party/rust/net2/README.md
@@ -1,14 +1,14 @@
 # net2
 
 [![Build Status](https://travis-ci.org/rust-lang-nursery/net2-rs.svg?branch=master)](https://travis-ci.org/rust-lang-nursery/net2-rs)
 [![Build status](https://ci.appveyor.com/api/projects/status/ns78f02jt2uvd2lp?svg=true)](https://ci.appveyor.com/project/alexcrichton/net2-rs)
 
-[Documentation](https://doc.rust-lang.org/net2-rs/)
+[Documentation](https://docs.rs/net2/0.2.32/net2/)
 
 Extensions to the standard library's networking types, proposed in [RFC
 1158][rfc].
 
 
 [rfc]: https://github.com/alexcrichton/rfcs/blob/net2.1/text/0000-io-net-2.1.md
 
 ```toml
--- a/third_party/rust/net2/src/ext.rs
+++ b/third_party/rust/net2/src/ext.rs
@@ -33,49 +33,55 @@ cfg_if! {
         use libc::IPV6_LEAVE_GROUP as IPV6_DROP_MEMBERSHIP;
     } else {
         // ...
     }
 }
 
 use std::time::Duration;
 
+#[cfg(any(unix, target_os = "redox"))] use libc::*;
+#[cfg(any(unix, target_os = "redox"))] use std::os::unix::prelude::*;
+#[cfg(target_os = "redox")] pub type Socket = usize;
 #[cfg(unix)] pub type Socket = c_int;
-#[cfg(unix)] use std::os::unix::prelude::*;
-#[cfg(unix)] use libc::*;
 #[cfg(windows)] pub type Socket = SOCKET;
 #[cfg(windows)] use std::os::windows::prelude::*;
 #[cfg(windows)] use sys::c::*;
 
 #[cfg(windows)] const SIO_KEEPALIVE_VALS: DWORD = 0x98000004;
 #[cfg(windows)]
 #[repr(C)]
 struct tcp_keepalive {
     onoff: c_ulong,
     keepalivetime: c_ulong,
     keepaliveinterval: c_ulong,
 }
 
+#[cfg(target_os = "redox")] fn v(opt: c_int) -> c_int { opt }
+#[cfg(unix)] fn v(opt: c_int) -> c_int { opt }
 #[cfg(windows)] fn v(opt: IPPROTO) -> c_int { opt as c_int }
-#[cfg(unix)] fn v(opt: c_int) -> c_int { opt }
 
 pub fn set_opt<T: Copy>(sock: Socket, opt: c_int, val: c_int,
                        payload: T) -> io::Result<()> {
     unsafe {
         let payload = &payload as *const T as *const c_void;
+        #[cfg(target_os = "redox")]
+        let sock = sock as c_int;
         try!(::cvt(setsockopt(sock, opt, val, payload as *const _,
                               mem::size_of::<T>() as socklen_t)));
         Ok(())
     }
 }
 
 pub fn get_opt<T: Copy>(sock: Socket, opt: c_int, val: c_int) -> io::Result<T> {
     unsafe {
         let mut slot: T = mem::zeroed();
         let mut len = mem::size_of::<T>() as socklen_t;
+        #[cfg(target_os = "redox")]
+        let sock = sock as c_int;
         try!(::cvt(getsockopt(sock, opt, val,
                               &mut slot as *mut _ as *mut _,
                               &mut len)));
         assert_eq!(len as usize, mem::size_of::<T>());
         Ok(slot)
     }
 }
 
@@ -630,32 +636,38 @@ pub trait UdpSocketExt {
     fn set_nonblocking(&self, nonblocking: bool) -> io::Result<()>;
 }
 
 #[doc(hidden)]
 pub trait AsSock {
     fn as_sock(&self) -> Socket;
 }
 
+#[cfg(target_os = "redox")]
+impl<T: AsRawFd> AsSock for T {
+    fn as_sock(&self) -> Socket { self.as_raw_fd() }
+}
 #[cfg(unix)]
 impl<T: AsRawFd> AsSock for T {
     fn as_sock(&self) -> Socket { self.as_raw_fd() }
 }
 #[cfg(windows)]
 impl<T: AsRawSocket> AsSock for T {
     fn as_sock(&self) -> Socket { self.as_raw_socket() as Socket }
 }
 
 cfg_if! {
     if #[cfg(any(target_os = "macos", target_os = "ios"))] {
         use libc::TCP_KEEPALIVE as KEEPALIVE_OPTION;
     } else if #[cfg(any(target_os = "openbsd", target_os = "netbsd"))] {
         use libc::SO_KEEPALIVE as KEEPALIVE_OPTION;
     } else if #[cfg(unix)] {
         use libc::TCP_KEEPIDLE as KEEPALIVE_OPTION;
+    } else if #[cfg(target_os = "redox")] {
+        use libc::TCP_KEEPIDLE as KEEPALIVE_OPTION;
     } else {
         // ...
     }
 }
 
 impl TcpStreamExt for TcpStream {
 
     fn set_recv_buffer_size(&self, size: usize) -> io::Result<()> {
@@ -687,16 +699,39 @@ impl TcpStreamExt for TcpStream {
     fn set_keepalive(&self, keepalive: Option<Duration>) -> io::Result<()> {
         self.set_keepalive_ms(keepalive.map(dur2ms))
     }
 
     fn keepalive(&self) -> io::Result<Option<Duration>> {
         self.keepalive_ms().map(|o| o.map(ms2dur))
     }
 
+    #[cfg(target_os = "redox")]
+    fn set_keepalive_ms(&self, keepalive: Option<u32>) -> io::Result<()> {
+        try!(set_opt(self.as_sock(), SOL_SOCKET, SO_KEEPALIVE,
+                    keepalive.is_some() as c_int));
+        if let Some(dur) = keepalive {
+            try!(set_opt(self.as_sock(), v(IPPROTO_TCP), KEEPALIVE_OPTION,
+                        (dur / 1000) as c_int));
+        }
+        Ok(())
+    }
+
+    #[cfg(target_os = "redox")]
+    fn keepalive_ms(&self) -> io::Result<Option<u32>> {
+        let keepalive = try!(get_opt::<c_int>(self.as_sock(), SOL_SOCKET,
+                                             SO_KEEPALIVE));
+        if keepalive == 0 {
+            return Ok(None)
+        }
+        let secs = try!(get_opt::<c_int>(self.as_sock(), v(IPPROTO_TCP),
+                                        KEEPALIVE_OPTION));
+        Ok(Some((secs as u32) * 1000))
+    }
+
     #[cfg(unix)]
     fn set_keepalive_ms(&self, keepalive: Option<u32>) -> io::Result<()> {
         try!(set_opt(self.as_sock(), SOL_SOCKET, SO_KEEPALIVE,
                     keepalive.is_some() as c_int));
         if let Some(dur) = keepalive {
             try!(set_opt(self.as_sock(), v(IPPROTO_TCP), KEEPALIVE_OPTION,
                         (dur / 1000) as c_int));
         }
@@ -832,29 +867,29 @@ impl TcpStreamExt for TcpStream {
         set_opt(self.as_sock(), SOL_SOCKET, SO_LINGER, dur2linger(dur))
     }
 
     fn linger(&self) -> io::Result<Option<Duration>> {
         get_opt(self.as_sock(), SOL_SOCKET, SO_LINGER).map(linger2dur)
     }
 }
 
-#[cfg(unix)]
+#[cfg(any(target_os = "redox", unix))]
 fn ms2timeout(dur: Option<u32>) -> timeval {
     // TODO: be more rigorous
     match dur {
         Some(d) => timeval {
             tv_sec: (d / 1000) as time_t,
             tv_usec: (d % 1000) as suseconds_t,
         },
         None => timeval { tv_sec: 0, tv_usec: 0 },
     }
 }
 
-#[cfg(unix)]
+#[cfg(any(target_os = "redox", unix))]
 fn timeout2ms(dur: timeval) -> Option<u32> {
     if dur.tv_sec == 0 && dur.tv_usec == 0 {
         None
     } else {
         Some(dur.tv_sec as u32 * 1000 + dur.tv_usec as u32 / 1000)
     }
 }
 
@@ -889,17 +924,17 @@ fn dur2linger(dur: Option<Duration>) -> 
                 l_onoff: 1,
                 l_linger: d.as_secs() as u16,
             }
         },
         None => linger { l_onoff: 0, l_linger: 0 },
     }
 }
 
-#[cfg(unix)]
+#[cfg(any(target_os = "redox", unix))]
 fn dur2linger(dur: Option<Duration>) -> linger {
     match dur {
         Some(d) => {
             linger {
                 l_onoff: 1,
                 l_linger: d.as_secs() as c_int,
             }
         },
@@ -972,65 +1007,89 @@ impl UdpSocketExt for UdpSocket {
                multicast_ttl_v4 as c_int)
     }
     
     fn multicast_ttl_v4(&self) -> io::Result<u32> {
         get_opt::<c_int>(self.as_sock(), IPPROTO_IP, IP_MULTICAST_TTL)
             .map(|b| b as u32)
     }
 
-    fn set_multicast_hops_v6(&self, hops: u32) -> io::Result<()> {
+    fn set_multicast_hops_v6(&self, _hops: u32) -> io::Result<()> {
+        #[cfg(target_os = "redox")]
+        return Err(io::Error::new(io::ErrorKind::Other, "Not implemented yet"));
+        #[cfg(not(target_os = "redox"))]
         set_opt(self.as_sock(), v(IPPROTO_IPV6), IPV6_MULTICAST_HOPS,
-               hops as c_int)
+               _hops as c_int)
     }
 
     fn multicast_hops_v6(&self) -> io::Result<u32> {
+        #[cfg(target_os = "redox")]
+        return Err(io::Error::new(io::ErrorKind::Other, "Not implemented yet"));
+        #[cfg(not(target_os = "redox"))]
         get_opt::<c_int>(self.as_sock(), v(IPPROTO_IPV6), IPV6_MULTICAST_HOPS)
             .map(|b| b as u32)
     }
 
     fn set_multicast_loop_v6(&self, multicast_loop_v6: bool) -> io::Result<()> {
         set_opt(self.as_sock(), v(IPPROTO_IPV6), IPV6_MULTICAST_LOOP,
                multicast_loop_v6 as c_int)
     }
     fn multicast_loop_v6(&self) -> io::Result<bool> {
         get_opt(self.as_sock(), v(IPPROTO_IPV6), IPV6_MULTICAST_LOOP)
             .map(int2bool)
     }
 
-    fn set_multicast_if_v4(&self, interface: &Ipv4Addr) -> io::Result<()> {
-        set_opt(self.as_sock(), IPPROTO_IP, IP_MULTICAST_IF, ip2in_addr(interface))
+    fn set_multicast_if_v4(&self, _interface: &Ipv4Addr) -> io::Result<()> {
+        #[cfg(target_os = "redox")]
+        return Err(io::Error::new(io::ErrorKind::Other, "Not implemented yet"));
+        #[cfg(not(target_os = "redox"))]
+        set_opt(self.as_sock(), IPPROTO_IP, IP_MULTICAST_IF, ip2in_addr(_interface))
     }
 
     fn multicast_if_v4(&self) -> io::Result<Ipv4Addr> {
+        #[cfg(target_os = "redox")]
+        return Err(io::Error::new(io::ErrorKind::Other, "Not implemented yet"));
+        #[cfg(not(target_os = "redox"))]
         get_opt(self.as_sock(), IPPROTO_IP, IP_MULTICAST_IF).map(in_addr2ip)
     }
 
-    fn set_multicast_if_v6(&self, interface: u32) -> io::Result<()> {
-        set_opt(self.as_sock(), v(IPPROTO_IPV6), IPV6_MULTICAST_IF, to_ipv6mr_interface(interface))
+    fn set_multicast_if_v6(&self, _interface: u32) -> io::Result<()> {
+        #[cfg(target_os = "redox")]
+        return Err(io::Error::new(io::ErrorKind::Other, "Not implemented yet"));
+        #[cfg(not(target_os = "redox"))]
+        set_opt(self.as_sock(), v(IPPROTO_IPV6), IPV6_MULTICAST_IF, to_ipv6mr_interface(_interface))
     }
 
     fn multicast_if_v6(&self) -> io::Result<u32> {
+        #[cfg(target_os = "redox")]
+        return Err(io::Error::new(io::ErrorKind::Other, "Not implemented yet"));
+        #[cfg(not(target_os = "redox"))]
         get_opt::<c_int>(self.as_sock(), v(IPPROTO_IPV6), IPV6_MULTICAST_IF).map(|b| b as u32)
     }
 
     fn set_ttl(&self, ttl: u32) -> io::Result<()> {
         set_opt(self.as_sock(), IPPROTO_IP, IP_TTL, ttl as c_int)
     }
 
     fn ttl(&self) -> io::Result<u32> {
         get_opt::<c_int>(self.as_sock(), IPPROTO_IP, IP_TTL)
             .map(|b| b as u32)
     }
 
-    fn set_unicast_hops_v6(&self, ttl: u32) -> io::Result<()> {
-        set_opt(self.as_sock(), v(IPPROTO_IPV6), IPV6_UNICAST_HOPS, ttl as c_int)
+    fn set_unicast_hops_v6(&self, _ttl: u32) -> io::Result<()> {
+        #[cfg(target_os = "redox")]
+        return Err(io::Error::new(io::ErrorKind::Other, "Not implemented yet"));
+        #[cfg(not(target_os = "redox"))]
+        set_opt(self.as_sock(), v(IPPROTO_IPV6), IPV6_UNICAST_HOPS, _ttl as c_int)
     }
 
     fn unicast_hops_v6(&self) -> io::Result<u32> {
+        #[cfg(target_os = "redox")]
+        return Err(io::Error::new(io::ErrorKind::Other, "Not implemented yet"));
+        #[cfg(not(target_os = "redox"))]
         get_opt::<c_int>(self.as_sock(), IPPROTO_IP, IPV6_UNICAST_HOPS)
             .map(|b| b as u32)
     }
 
     fn set_only_v6(&self, only_v6: bool) -> io::Result<()> {
         set_opt(self.as_sock(), v(IPPROTO_IPV6), IPV6_V6ONLY, only_v6 as c_int)
     }
 
@@ -1115,33 +1174,48 @@ impl UdpSocketExt for UdpSocket {
     fn take_error(&self) -> io::Result<Option<io::Error>> {
         get_opt(self.as_sock(), SOL_SOCKET, SO_ERROR).map(int2err)
     }
 
     fn connect<A: ToSocketAddrs>(&self, addr: A) -> io::Result<()> {
         do_connect(self.as_sock(), addr)
     }
 
+    #[cfg(target_os = "redox")]
+    fn send(&self, buf: &[u8]) -> io::Result<usize> {
+        unsafe {
+            ::cvt(write(self.as_sock() as c_int, buf.as_ptr() as *const _, buf.len())).map(|n| n as usize)
+        }
+    }
+
     #[cfg(unix)]
     fn send(&self, buf: &[u8]) -> io::Result<usize> {
         unsafe {
-            ::cvt(send(self.as_sock(), buf.as_ptr() as *const _, buf.len(), 0)).map(|n| n as usize)
+            ::cvt(send(self.as_sock() as c_int, buf.as_ptr() as *const _, buf.len(), 0)).map(|n| n as usize)
         }
     }
 
     #[cfg(windows)]
     fn send(&self, buf: &[u8]) -> io::Result<usize> {
         let len = ::std::cmp::min(buf.len(), c_int::max_value() as usize);
         let buf = &buf[..len];
         unsafe {
             ::cvt(send(self.as_sock(), buf.as_ptr() as *const _, len as c_int, 0))
                 .map(|n| n as usize)
         }
     }
 
+    #[cfg(target_os = "redox")]
+    fn recv(&self, buf: &mut [u8]) -> io::Result<usize> {
+        unsafe {
+            ::cvt(read(self.as_sock() as c_int, buf.as_mut_ptr() as *mut _, buf.len()))
+                .map(|n| n as usize)
+        }
+    }
+
     #[cfg(unix)]
     fn recv(&self, buf: &mut [u8]) -> io::Result<usize> {
         unsafe {
             ::cvt(recv(self.as_sock(), buf.as_mut_ptr() as *mut _, buf.len(), 0))
                 .map(|n| n as usize)
         }
     }
 
@@ -1168,32 +1242,58 @@ fn do_connect<A: ToSocketAddrs>(sock: So
     let sock = socket::Socket::from_inner(sys);
     let ret = addrs.fold(Err(err), |prev, addr| {
         prev.or_else(|_| sock.connect(&addr))
     });
     mem::forget(sock);
     return ret
 }
 
+#[cfg(target_os = "redox")]
+fn set_nonblocking(sock: Socket, nonblocking: bool) -> io::Result<()> {
+    let mut flags = ::cvt(unsafe {
+        fcntl(sock as c_int, F_GETFL)
+    })?;
+    if nonblocking {
+        flags |= O_NONBLOCK;
+    } else {
+        flags &= !O_NONBLOCK;
+    }
+    ::cvt(unsafe {
+        fcntl(sock as c_int, F_SETFL, flags)
+    }).and(Ok(()))
+}
+
 #[cfg(unix)]
 fn set_nonblocking(sock: Socket, nonblocking: bool) -> io::Result<()> {
     let mut nonblocking = nonblocking as c_ulong;
     ::cvt(unsafe {
         ioctl(sock, FIONBIO, &mut nonblocking)
     }).map(|_| ())
 }
 
 #[cfg(windows)]
 fn set_nonblocking(sock: Socket, nonblocking: bool) -> io::Result<()> {
     let mut nonblocking = nonblocking as c_ulong;
     ::cvt(unsafe {
         ioctlsocket(sock, FIONBIO as c_int, &mut nonblocking)
     }).map(|_| ())
 }
 
+#[cfg(target_os = "redox")]
+fn ip2in_addr(ip: &Ipv4Addr) -> in_addr {
+    let oct = ip.octets();
+    in_addr {
+        s_addr: ::hton(((oct[0] as u32) << 24) |
+                       ((oct[1] as u32) << 16) |
+                       ((oct[2] as u32) <<  8) |
+                       ((oct[3] as u32) <<  0)),
+    }
+}
+
 #[cfg(unix)]
 fn ip2in_addr(ip: &Ipv4Addr) -> in_addr {
     let oct = ip.octets();
     in_addr {
         s_addr: ::hton(((oct[0] as u32) << 24) |
                        ((oct[1] as u32) << 16) |
                        ((oct[2] as u32) <<  8) |
                        ((oct[3] as u32) <<  0)),
--- a/third_party/rust/net2/src/lib.rs
+++ b/third_party/rust/net2/src/lib.rs
@@ -37,17 +37,17 @@
 //! ```
 
 #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
        html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
        html_root_url = "https://doc.rust-lang.org/net2-rs")]
 #![deny(missing_docs, warnings)]
 
 
-#[cfg(unix)] extern crate libc;
+#[cfg(any(target_os="redox", unix))] extern crate libc;
 
 #[cfg(windows)] extern crate winapi;
 
 #[macro_use] extern crate cfg_if;
 
 use std::io;
 use std::ops::Neg;
 use std::net::{ToSocketAddrs, SocketAddr};
@@ -55,16 +55,17 @@ use std::net::{ToSocketAddrs, SocketAddr
 use utils::{One, NetInt};
 
 mod tcp;
 mod udp;
 mod socket;
 mod ext;
 mod utils;
 
+#[cfg(target_os="redox")] #[path = "sys/redox/mod.rs"] mod sys;
 #[cfg(unix)] #[path = "sys/unix/mod.rs"] mod sys;
 #[cfg(windows)] #[path = "sys/windows/mod.rs"] mod sys;
 #[cfg(all(unix, not(any(target_os = "solaris"))))] pub mod unix;
 
 pub use tcp::TcpBuilder;
 pub use udp::UdpBuilder;
 pub use ext::{TcpStreamExt, TcpListenerExt, UdpSocketExt};
 
--- a/third_party/rust/net2/src/socket.rs
+++ b/third_party/rust/net2/src/socket.rs
@@ -7,16 +7,18 @@
 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
 use std::fmt;
 use std::io;
 use std::mem;
 use std::net::{Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6};
+#[cfg(target_os = "redox")]
+use libc::c_int;
 #[cfg(unix)]
 use libc::c_int;
 #[cfg(windows)]
 use winapi::ctypes::c_int;
 
 use sys;
 use sys::c;
 
@@ -25,24 +27,19 @@ pub struct Socket {
 }
 
 impl Socket {
     pub fn new(family: c_int, ty: c_int) -> io::Result<Socket> {
         Ok(Socket { inner: try!(sys::Socket::new(family, ty)) })
     }
 
     pub fn bind(&self, addr: &SocketAddr) -> io::Result<()> {
-        #[cfg(not(all(any(target_arch = "aarch64", target_arch = "x86_64"), target_os = "android")))]
-        use sys::c::socklen_t as len_t;
-        #[cfg(all(any(target_arch = "aarch64", target_arch = "x86_64"), target_os = "android"))]
-        use libc::c_int as len_t;
-
         let (addr, len) = addr2raw(addr);
         unsafe {
-            ::cvt(c::bind(self.inner.raw(), addr, len as len_t)).map(|_| ())
+            ::cvt(c::bind(self.inner.raw(), addr, len as c::socklen_t)).map(|_| ())
         }
     }
 
     pub fn listen(&self, backlog: i32) -> io::Result<()> {
         unsafe {
             ::cvt(c::listen(self.inner.raw(), backlog)).map(|_| ())
         }
     }
new file mode 100644
--- /dev/null
+++ b/third_party/rust/net2/src/sys/redox/impls.rs
@@ -0,0 +1,43 @@
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use std::os::unix::io::{FromRawFd, AsRawFd};
+
+use {TcpBuilder, UdpBuilder, FromInner, AsInner};
+use socket::Socket;
+use sys;
+
+impl FromRawFd for TcpBuilder {
+    unsafe fn from_raw_fd(fd: usize) -> TcpBuilder {
+        let sock = sys::Socket::from_inner(fd);
+        TcpBuilder::from_inner(Socket::from_inner(sock))
+    }
+}
+
+impl AsRawFd for TcpBuilder {
+    fn as_raw_fd(&self) -> usize {
+        // TODO: this unwrap() is very bad
+        self.as_inner().borrow().as_ref().unwrap().as_inner().raw() as usize
+    }
+}
+
+impl FromRawFd for UdpBuilder {
+    unsafe fn from_raw_fd(fd: usize) -> UdpBuilder {
+        let sock = sys::Socket::from_inner(fd);
+        UdpBuilder::from_inner(Socket::from_inner(sock))
+    }
+}
+
+impl AsRawFd for UdpBuilder {
+    fn as_raw_fd(&self) -> usize {
+        // TODO: this unwrap() is very bad
+        self.as_inner().borrow().as_ref().unwrap().as_inner().raw() as usize
+    }
+}
new file mode 100644
--- /dev/null
+++ b/third_party/rust/net2/src/sys/redox/mod.rs
@@ -0,0 +1,81 @@
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+
+use std::io;
+use std::mem;
+use std::net::{TcpListener, TcpStream, UdpSocket};
+use std::os::unix::io::FromRawFd;
+use libc::{self, c_int};
+
+mod impls;
+
+pub mod c {
+    pub use libc::*;
+
+    pub fn sockaddr_in_u32(sa: &sockaddr_in) -> u32 {
+        ::ntoh((*sa).sin_addr.s_addr)
+    }
+
+    pub fn in_addr_to_u32(addr: &in_addr) -> u32 {
+        ::ntoh(addr.s_addr)
+    }
+}
+
+pub struct Socket {
+    fd: c_int,
+}
+
+impl Socket {
+    pub fn new(family: c_int, ty: c_int) -> io::Result<Socket> {
+        unsafe {
+            let fd = ::cvt(libc::socket(family, ty, 0))?;
+            let mut flags = ::cvt(libc::fcntl(fd, libc::F_GETFD))?;
+            flags |= libc::O_CLOEXEC;
+            ::cvt(libc::fcntl(fd, libc::F_SETFD, flags))?;
+            Ok(Socket { fd: fd })
+        }
+    }
+
+    pub fn raw(&self) -> c_int { self.fd }
+
+    fn into_fd(self) -> c_int {
+        let fd = self.fd;
+        mem::forget(self);
+        fd
+    }
+
+    pub fn into_tcp_listener(self) -> TcpListener {
+        unsafe { TcpListener::from_raw_fd(self.into_fd() as usize) }
+    }
+
+    pub fn into_tcp_stream(self) -> TcpStream {
+        unsafe { TcpStream::from_raw_fd(self.into_fd() as usize) }
+    }
+
+    pub fn into_udp_socket(self) -> UdpSocket {
+        unsafe { UdpSocket::from_raw_fd(self.into_fd() as usize) }
+    }
+}
+
+impl ::FromInner for Socket {
+    type Inner = usize;
+    fn from_inner(fd: usize) -> Socket {
+        Socket { fd: fd as c_int }
+    }
+}
+
+impl Drop for Socket {
+    fn drop(&mut self) {
+        unsafe {
+            let _ = libc::close(self.fd);
+        }
+    }
+}