Mark Android R (rvc-dev-plus-aosp-without-vendor@6692709) as merged

Bug: 166295507
Merged-In: I3517a34dde28744a67cdc1fe6b744eda1b7ec40c
Change-Id: I440ad72e33fa46bba7b299b499841bc2aeab8ea8
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json
index dbd911b..0cd0fb1 100644
--- a/.cargo_vcs_info.json
+++ b/.cargo_vcs_info.json
@@ -1,5 +1,5 @@
 {
   "git": {
-    "sha1": "5f35a9f923de2beb56ea3d376bd47e095fad277c"
+    "sha1": "99df5dba5fa2471d51f58e3691621e5cd22d464d"
   }
 }
diff --git a/Cargo.toml b/Cargo.toml
index 9a82142..6b87ae6 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,7 +13,7 @@
 [package]
 edition = "2018"
 name = "ppv-lite86"
-version = "0.2.8"
+version = "0.2.9"
 authors = ["The CryptoCorrosion Contributors"]
 description = "Implementation of the crypto-simd API for x86"
 keywords = ["crypto", "simd", "x86"]
diff --git a/Cargo.toml.orig b/Cargo.toml.orig
index 008543e..84a59ad 100644
--- a/Cargo.toml.orig
+++ b/Cargo.toml.orig
@@ -1,6 +1,6 @@
 [package]
 name = "ppv-lite86"
-version = "0.2.8"
+version = "0.2.9"
 authors = ["The CryptoCorrosion Contributors"]
 edition = "2018"
 license = "MIT/Apache-2.0"
diff --git a/METADATA b/METADATA
index cab335b..06bd08c 100644
--- a/METADATA
+++ b/METADATA
@@ -1,7 +1,5 @@
 name: "ppv-lite86"
-description:
-    "Implementation of the crypto-simd API for x86"
-
+description: "Implementation of the crypto-simd API for x86"
 third_party {
   url {
     type: HOMEPAGE
@@ -11,7 +9,11 @@
     type: GIT
     value: "https://github.com/cryptocorrosion/cryptocorrosion"
   }
-  version: "0.2.8"
-  last_upgrade_date { year: 2020 month: 6 day: 18 }
+  version: "0.2.9"
   license_type: NOTICE
+  last_upgrade_date {
+    year: 2020
+    month: 8
+    day: 21
+  }
 }
diff --git a/patches/std.diff b/patches/std.diff
new file mode 100644
index 0000000..cdb5b08
--- /dev/null
+++ b/patches/std.diff
@@ -0,0 +1,14 @@
+Index: ppv-lite86/src/lib.rs
+===================================================================
+--- ppv-lite86.orig/src/lib.rs
++++ ppv-lite86/src/lib.rs
+@@ -5,6 +5,9 @@
+ //   Machine (which is a ZST + Copy type), which can only by created unsafely or safely
+ //   through feature detection (e.g. fn AVX2::try_get() -> Option<Machine>).
+ 
++// ANDROID: Use std to allow building as a dylib.
++extern crate std;
++
+ mod soft;
+ mod types;
+ pub use self::types::*;
diff --git a/src/generic.rs b/src/generic.rs
index 4f4113f..d26266c 100644
--- a/src/generic.rs
+++ b/src/generic.rs
@@ -4,11 +4,11 @@
 use crate::soft::{x2, x4};
 use crate::types::*;
 
+#[repr(C)]
 #[derive(Clone, Copy)]
 pub union vec128_storage {
     d: [u32; 4],
     q: [u64; 2],
-    o: [u128; 1],
 }
 impl From<[u32; 4]> for vec128_storage {
     #[inline]
@@ -37,14 +37,14 @@
 impl Default for vec128_storage {
     #[inline]
     fn default() -> Self {
-        Self { o: [0] }
+        Self { q: [0, 0] }
     }
 }
 impl Eq for vec128_storage {}
 impl PartialEq<vec128_storage> for vec128_storage {
     #[inline]
     fn eq(&self, rhs: &Self) -> bool {
-        unsafe { self.o == rhs.o }
+        unsafe { self.q == rhs.q }
     }
 }
 #[derive(Clone, Copy, PartialEq, Eq, Default)]
@@ -151,14 +151,22 @@
     unsafe { T::unpack(q) }
 }
 
+fn o_of_q(q: [u64; 2]) -> u128 {
+    u128::from(q[0]) | (u128::from(q[1]) << 64)
+}
+
+fn q_of_o(o: u128) -> [u64; 2] {
+    [o as u64, (o >> 64) as u64]
+}
+
 fn omap<T, F>(a: T, f: F) -> T
 where
     T: Store<vec128_storage> + Into<vec128_storage>,
     F: Fn(u128) -> u128,
 {
     let a: vec128_storage = a.into();
-    let ao = unsafe { a.o };
-    let o = vec128_storage { o: [f(ao[0])] };
+    let ao = o_of_q(unsafe { a.q });
+    let o = vec128_storage { q: q_of_o(f(ao)) };
     unsafe { T::unpack(o) }
 }
 
@@ -169,10 +177,10 @@
 {
     let a: vec128_storage = a.into();
     let b: vec128_storage = b.into();
-    let ao = unsafe { a.o };
-    let bo = unsafe { b.o };
+    let ao = o_of_q(unsafe { a.q });
+    let bo = o_of_q(unsafe { b.q });
     let o = vec128_storage {
-        o: [f(ao[0], bo[0])],
+        q: q_of_o(f(ao, bo)),
     };
     unsafe { T::unpack(o) }
 }
@@ -456,7 +464,7 @@
 impl From<u128x1_generic> for vec128_storage {
     #[inline(always)]
     fn from(o: u128x1_generic) -> Self {
-        Self { o: o.0 }
+        Self { q: q_of_o(o.0[0]) }
     }
 }
 
@@ -475,7 +483,7 @@
 impl Store<vec128_storage> for u128x1_generic {
     #[inline(always)]
     unsafe fn unpack(s: vec128_storage) -> Self {
-        Self(s.o)
+        Self([o_of_q(s.q); 1])
     }
 }