Snap for 6877830 from 4b0aa95ee1bd580b46878da4e8fe7581622f4f78 to sdk-release

Change-Id: I18d23d2b53b933c47b1e564ff7e348df705e7a7c
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/Android.bp b/Android.bp
index e8a4749..5a1adfe 100644
--- a/Android.bp
+++ b/Android.bp
@@ -1,4 +1,4 @@
-// This file is generated by cargo2android.py --device --run --dependencies.
+// This file is generated by cargo2android.py --device --run --dependencies --tests.
 
 rust_library {
     name: "libppv_lite86",
@@ -12,3 +12,27 @@
         "std",
     ],
 }
+
+rust_defaults {
+    name: "ppv-lite86_defaults",
+    crate_name: "ppv_lite86",
+    // has rustc warnings
+    srcs: ["src/lib.rs"],
+    test_suites: ["general-tests"],
+    auto_gen_config: true,
+    edition: "2018",
+    features: [
+        "default",
+        "std",
+    ],
+}
+
+rust_test_host {
+    name: "ppv-lite86_host_test_src_lib",
+    defaults: ["ppv-lite86_defaults"],
+}
+
+rust_test {
+    name: "ppv-lite86_device_test_src_lib",
+    defaults: ["ppv-lite86_defaults"],
+}
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..6fc2138 100644
--- a/METADATA
+++ b/METADATA
@@ -1,17 +1,19 @@
 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
     value: "https://crates.io/crates/ppv-lite86"
   }
   url {
-    type: GIT
-    value: "https://github.com/cryptocorrosion/cryptocorrosion"
+    type: ARCHIVE
+    value: "https://static.crates.io/crates/ppv-lite86/ppv-lite86-0.2.9.crate"
   }
-  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/OWNERS b/OWNERS
new file mode 100644
index 0000000..46fc303
--- /dev/null
+++ b/OWNERS
@@ -0,0 +1 @@
+include platform/prebuilts/rust:/OWNERS
diff --git a/TEST_MAPPING b/TEST_MAPPING
new file mode 100644
index 0000000..c2b3791
--- /dev/null
+++ b/TEST_MAPPING
@@ -0,0 +1,12 @@
+// Generated by cargo2android.py for tests in Android.bp
+{
+  "presubmit": [
+    {
+      "name": "ppv-lite86_host_test_src_lib",
+      "host": true
+    },
+    {
+      "name": "ppv-lite86_device_test_src_lib"
+    }
+  ]
+}
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])
     }
 }