Snap for 8730993 from 3d7279c7b3973433ce44028a3cad8801cc727586 to mainline-tzdata3-release
Change-Id: I4dd0bb2ec8cd7d75ecdc7355aa0eccfc9b5550fa
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json
index 8da2e20..14919dc 100644
--- a/.cargo_vcs_info.json
+++ b/.cargo_vcs_info.json
@@ -1,5 +1,5 @@
{
"git": {
- "sha1": "de247d6ac25d2e62d4cbd195f064ed4af35fd4eb"
+ "sha1": "08c79b5e2348a4b44cac8860612c9ee1f5518544"
}
}
diff --git a/.clippy.toml b/.clippy.toml
deleted file mode 100644
index 8e17d80..0000000
--- a/.clippy.toml
+++ /dev/null
@@ -1 +0,0 @@
-msrv = "1.0.0"
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index e0f8585..ec51099 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -43,11 +43,3 @@
- uses: actions/checkout@v2
- uses: dtolnay/rust-toolchain@1.0.0
- run: cargo build
-
- clippy:
- name: Clippy
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v2
- - uses: dtolnay/rust-toolchain@clippy
- - run: cargo clippy -- -Dclippy::all -Dclippy::pedantic
diff --git a/Android.bp b/Android.bp
index 6027693..f49b03d 100644
--- a/Android.bp
+++ b/Android.bp
@@ -38,34 +38,10 @@
],
}
-rust_test {
- name: "itoa_test_tests_test",
- host_supported: true,
- crate_name: "test",
- cargo_env_compat: true,
- cargo_pkg_version: "0.4.8",
- srcs: ["tests/test.rs"],
- test_suites: ["general-tests"],
- auto_gen_config: true,
- test_options: {
- unit_test: true,
- },
- edition: "2015",
- features: [
- "default",
- "std",
- ],
- rustlibs: [
- "libitoa",
- ],
-}
-
rust_library {
name: "libitoa",
host_supported: true,
crate_name: "itoa",
- cargo_env_compat: true,
- cargo_pkg_version: "0.4.8",
srcs: ["src/lib.rs"],
edition: "2015",
features: [
diff --git a/Cargo.toml b/Cargo.toml
index 02b4382..8900cdc 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -3,15 +3,16 @@
# When uploading crates to the registry Cargo will automatically
# "normalize" Cargo.toml files for maximal compatibility
# with all versions of Cargo and also rewrite `path` dependencies
-# to registry (e.g., crates.io) dependencies.
+# to registry (e.g., crates.io) dependencies
#
-# If you are reading this file be aware that the original Cargo.toml
-# will likely look very different (and much more reasonable).
-# See Cargo.toml.orig for the original contents.
+# 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 = "itoa"
-version = "0.4.8"
+version = "0.4.7"
authors = ["David Tolnay <dtolnay@gmail.com>"]
exclude = ["performance.png"]
description = "Fast functions for printing integer primitives to an io::Write"
diff --git a/Cargo.toml.orig b/Cargo.toml.orig
index 2781d7c..0192401 100644
--- a/Cargo.toml.orig
+++ b/Cargo.toml.orig
@@ -1,6 +1,6 @@
[package]
name = "itoa"
-version = "0.4.8" # remember to update html_root_url
+version = "0.4.7" # remember to update html_root_url
authors = ["David Tolnay <dtolnay@gmail.com>"]
license = "MIT OR Apache-2.0"
description = "Fast functions for printing integer primitives to an io::Write"
diff --git a/METADATA b/METADATA
index e9cdb68..8ced762 100644
--- a/METADATA
+++ b/METADATA
@@ -7,13 +7,13 @@
}
url {
type: ARCHIVE
- value: "https://static.crates.io/crates/itoa/itoa-0.4.8.crate"
+ value: "https://static.crates.io/crates/itoa/itoa-0.4.7.crate"
}
- version: "0.4.8"
+ version: "0.4.7"
license_type: NOTICE
last_upgrade_date {
- year: 2021
- month: 9
- day: 22
+ year: 2020
+ month: 12
+ day: 29
}
}
diff --git a/TEST_MAPPING b/TEST_MAPPING
index 9095ded..b4e52d2 100644
--- a/TEST_MAPPING
+++ b/TEST_MAPPING
@@ -1,63 +1,8 @@
-// Generated by update_crate_tests.py for tests that depend on this crate.
+// Generated by cargo2android.py for tests that depend on this crate.
{
- "imports": [
- {
- "path": "external/rust/crates/base64"
- },
- {
- "path": "external/rust/crates/bitflags"
- },
- {
- "path": "external/rust/crates/either"
- },
- {
- "path": "external/rust/crates/rand_chacha"
- },
- {
- "path": "external/rust/crates/tinytemplate"
- },
- {
- "path": "external/rust/crates/tinyvec"
- },
- {
- "path": "external/rust/crates/unicode-xid"
- },
- {
- "path": "external/rust/crates/url"
- }
- ],
"presubmit": [
{
- "name": "ZipFuseTest"
- },
- {
- "name": "authfs_device_test_src_lib"
- },
- {
- "name": "itoa_test_tests_test"
- },
- {
- "name": "microdroid_manager_test"
- },
- {
- "name": "virtualizationservice_device_test"
- }
- ],
- "presubmit-rust": [
- {
- "name": "ZipFuseTest"
- },
- {
- "name": "authfs_device_test_src_lib"
- },
- {
- "name": "itoa_test_tests_test"
- },
- {
- "name": "microdroid_manager_test"
- },
- {
- "name": "virtualizationservice_device_test"
+ "name": "url_device_test_src_lib"
}
]
}
diff --git a/cargo2android.json b/cargo2android.json
index ac56e26..42b7833 100644
--- a/cargo2android.json
+++ b/cargo2android.json
@@ -5,6 +5,5 @@
],
"dependencies": true,
"device": true,
- "run": true,
- "tests": true
+ "run": true
}
\ No newline at end of file
diff --git a/src/lib.rs b/src/lib.rs
index 8d4582e..d7bc81c 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -56,17 +56,12 @@
//! }
//! ```
-#![doc(html_root_url = "https://docs.rs/itoa/0.4.8")]
+#![doc(html_root_url = "https://docs.rs/itoa/0.4.7")]
#![cfg_attr(not(feature = "std"), no_std)]
#![cfg_attr(feature = "cargo-clippy", allow(renamed_and_removed_lints))]
#![cfg_attr(
feature = "cargo-clippy",
- allow(
- expl_impl_clone_on_copy,
- missing_errors_doc,
- must_use_candidate,
- transmute_ptr_to_ptr
- )
+ allow(const_static_lifetime, transmute_ptr_to_ptr)
)]
#[cfg(feature = "i128")]
diff --git a/src/udiv128.rs b/src/udiv128.rs
index 617c1c1..adbdce2 100644
--- a/src/udiv128.rs
+++ b/src/udiv128.rs
@@ -1,45 +1,61 @@
-/// Multiply unsigned 128 bit integers, return upper 128 bits of the result
-#[inline]
-fn u128_mulhi(x: u128, y: u128) -> u128 {
- let x_lo = x as u64;
- let x_hi = (x >> 64) as u64;
- let y_lo = y as u64;
- let y_hi = (y >> 64) as u64;
+// The code in this file is based on Rust's compiler-builtins crate. The Rust
+// compiler automatically links programs against this crate for target-specific
+// runtime support. We have copied the implementation of `__udivmodti4()` which
+// is an intrinsic implementing division with remainder for architectures
+// without 128-bit integers. This implementation works around some poor codegen
+// by LLVM (https://github.com/rust-lang/rust/issues/44545) and allows for
+// inlining which does not happen with the intrinsic.
+//
+// The compiler-builtins crate carries the following license, which is available
+// in full at:
+// https://github.com/rust-lang-nursery/compiler-builtins/blob/master/LICENSE.TXT
+//
+// ---
+//
+// Copyright 2009-2016 compiler-builtins Developers
+//
+// The compiler-builtins crate is dual licensed under both the University of
+// Illinois "BSD-Like" license and the MIT license. As a user of this code you
+// may choose to use it under either license. As a contributor, you agree to
+// allow your code to be used under both.
- // handle possibility of overflow
- let carry = (x_lo as u128 * y_lo as u128) >> 64;
- let m = x_lo as u128 * y_hi as u128 + carry;
- let high1 = m >> 64;
-
- let m_lo = m as u64;
- let high2 = x_hi as u128 * y_lo as u128 + m_lo as u128 >> 64;
-
- x_hi as u128 * y_hi as u128 + high1 + high2
-}
-
-/// Divide `n` by 1e19 and return quotient and remainder
-///
-/// Integer division algorithm is based on the following paper:
-///
-/// T. Granlund and P. Montgomery, “Division by Invariant Integers Using Multiplication”
-/// in Proc. of the SIGPLAN94 Conference on Programming Language Design and
-/// Implementation, 1994, pp. 61–72
-///
#[inline]
pub fn udivmod_1e19(n: u128) -> (u128, u64) {
let d = 10_000_000_000_000_000_000_u64; // 10^19
- let quot = if n < 1 << 83 {
- ((n >> 19) as u64 / (d >> 19)) as u128
- } else {
- let factor =
- (8507059173023461586_u64 as u128) << 64 | 10779635027931437427 as u128;
- u128_mulhi(n, factor) >> 62
- };
+ let high = (n >> 64) as u64;
+ if high == 0 {
+ let low = n as u64;
+ return ((low / d) as u128, low % d);
+ }
- let rem = (n - quot * d as u128) as u64;
- debug_assert_eq!(quot, n / d as u128);
- debug_assert_eq!(rem as u128, n % d as u128);
+ let sr = 65 - high.leading_zeros();
- (quot, rem)
+ // 2 <= sr <= 65
+ let mut q: u128 = n << (128 - sr);
+ let mut r: u128 = n >> sr;
+ let mut carry: u64 = 0;
+
+ // Don't use a range because they may generate references to memcpy in unoptimized code
+ //
+ // Loop invariants: r < d; carry is 0 or 1
+ let mut i = 0;
+ while i < sr {
+ i += 1;
+
+ // r:q = ((r:q) << 1) | carry
+ r = (r << 1) | (q >> 127);
+ q = (q << 1) | carry as u128;
+
+ // carry = 0
+ // if r >= d {
+ // r -= d;
+ // carry = 1;
+ // }
+ let s = (d as u128).wrapping_sub(r).wrapping_sub(1) as i128 >> 127;
+ carry = (s & 1) as u64;
+ r -= (d as u128) & s as u128;
+ }
+
+ ((q << 1) | carry as u128, r as u64)
}