Merge github.com:/cloudflare/quiche into 040

Change-Id: Idfde2cd6a4726ab34b6ae711537c4631720d85af
diff --git a/src/ffi.rs b/src/ffi.rs
index 9985272..981ebab 100644
--- a/src/ffi.rs
+++ b/src/ffi.rs
@@ -40,11 +40,11 @@
 
 use crate::*;
 
-#[no_mangle]
-pub extern fn quiche_version() -> *const u8 {
-    static VERSION: &str = concat!(env!("CARGO_PKG_VERSION"), "\0");
-    VERSION.as_ptr()
-}
+// #[no_mangle]
+// pub extern fn quiche_version() -> *const u8 {
+//     static VERSION: &str = concat!(env!("CARGO_PKG_VERSION"), "\0");
+//     VERSION.as_ptr()
+// }
 
 struct Logger {
     cb: extern fn(line: *const u8, argp: *mut c_void),
diff --git a/src/stream.rs b/src/stream.rs
index 696e2a6..6664398 100644
--- a/src/stream.rs
+++ b/src/stream.rs
@@ -27,6 +27,7 @@
 use std::cmp;
 
 use std::collections::hash_map;
+use std::collections::BTreeSet;
 use std::collections::BinaryHeap;
 use std::collections::HashMap;
 use std::collections::HashSet;
@@ -88,19 +89,19 @@
     /// Set of stream IDs corresponding to streams that have outstanding data
     /// to read. This is used to generate a `StreamIter` of streams without
     /// having to iterate over the full list of streams.
-    readable: HashSet<u64>,
+    readable: BTreeSet<u64>,
 
     /// Set of stream IDs corresponding to streams that have enough flow control
     /// capacity to be written to, and is not finished. This is used to generate
     /// a `StreamIter` of streams without having to iterate over the full list
     /// of streams.
-    writable: HashSet<u64>,
+    writable: BTreeSet<u64>,
 
     /// Set of stream IDs corresponding to streams that are almost out of flow
     /// control credit and need to send MAX_STREAM_DATA. This is used to
     /// generate a `StreamIter` of streams without having to iterate over the
     /// full list of streams.
-    almost_full: HashSet<u64>,
+    almost_full: BTreeSet<u64>,
 
     /// Set of stream IDs corresponding to streams that are blocked. The value
     /// of the map elements represents the offset of the stream at which the
@@ -511,9 +512,9 @@
 }
 
 impl StreamIter {
-    fn from(streams: &HashSet<u64>) -> Self {
+    fn from(streams: &BTreeSet<u64>) -> Self {
         StreamIter {
-            streams: streams.iter().copied().collect(),
+            streams: streams.iter().rev().copied().collect(),
         }
     }
 }
diff --git a/src/tls.rs b/src/tls.rs
index dbad6a2..1321644 100644
--- a/src/tls.rs
+++ b/src/tls.rs
@@ -888,6 +888,12 @@
     trace!("{}", std::str::from_utf8(&err).unwrap());
 }
 
+#[cfg(not(target_os = "fuchsia"))]
+#[link(name = "stdc++")]
+extern {}
+
+#[link(name = "ssl")]
+#[link(name = "crypto")]
 extern {
     // SSL_METHOD
     fn TLS_method() -> *const SSL_METHOD;