diff options
author | Haibo Huang <hhb@google.com> | 2021-01-18 17:04:43 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2021-01-18 17:04:43 +0000 |
commit | a65efe206fc824d6f80aca5b39202dc35eb7a329 (patch) | |
tree | 61e3d214f22d7e636e67721c35c29b8de3d63372 | |
parent | 6ca4b2f1a1ea93fc7e1b10e7b40a14c355a2a2d1 (diff) | |
parent | b470646293718ecf86bdf80032200513e5b1a785 (diff) | |
download | spin-a65efe206fc824d6f80aca5b39202dc35eb7a329.tar.gz |
Upgrade rust/crates/spin to 0.7.1 am: 6c8867a181 am: 41675de0a4 am: b470646293
Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/spin/+/1546473
MUST ONLY BE SUBMITTED BY AUTOMERGER
Change-Id: Ie7d7c61d4c0892a042112a78cfae318348acc88c
-rw-r--r-- | .cargo_vcs_info.json | 2 | ||||
-rw-r--r-- | Android.bp | 5 | ||||
-rw-r--r-- | CHANGELOG.md | 8 | ||||
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | Cargo.toml.orig | 2 | ||||
-rw-r--r-- | METADATA | 10 | ||||
-rw-r--r-- | TEST_MAPPING | 49 | ||||
-rw-r--r-- | src/once.rs | 54 |
8 files changed, 121 insertions, 11 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json index 7969b12..07d5794 100644 --- a/.cargo_vcs_info.json +++ b/.cargo_vcs_info.json @@ -1,5 +1,5 @@ { "git": { - "sha1": "1547e243241430ba5cfff89951b82193a5c3c991" + "sha1": "7fe431c5f3af6a374812e9fdcb3c7059ca94175c" } } @@ -2,6 +2,7 @@ rust_library { name: "libspin", + // has rustc warnings host_supported: true, crate_name: "spin", srcs: ["src/lib.rs"], @@ -21,6 +22,7 @@ rust_library { rust_defaults { name: "spin_defaults", crate_name: "spin", + // has rustc warnings srcs: ["src/lib.rs"], test_suites: ["general-tests"], auto_gen_config: true, @@ -35,6 +37,9 @@ rust_defaults { rust_test_host { name: "spin_host_test_src_lib", defaults: ["spin_defaults"], + test_options: { + unit_test: true, + }, } rust_test { diff --git a/CHANGELOG.md b/CHANGELOG.md index b8fc9a9..462d3c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +### Fixed + +# [0.7.1] - 2021-01-12 + +### Fixed + +- Prevented `Once` leaking the inner value upon drop + # [0.7.0] - 2020-10-18 ### Added @@ -12,7 +12,7 @@ [package] name = "spin" -version = "0.7.0" +version = "0.7.1" authors = ["Mathijs van de Nes <git@mathijs.vd-nes.nl>", "John Ericson <git@JohnEricson.me>", "Joshua Barretto <joshua.s.barretto@gmail.com>"] description = "Spin-based synchronization primitives" keywords = ["spinlock", "mutex", "rwlock"] diff --git a/Cargo.toml.orig b/Cargo.toml.orig index 796ce50..ba4591d 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -1,6 +1,6 @@ [package] name = "spin" -version = "0.7.0" +version = "0.7.1" authors = [ "Mathijs van de Nes <git@mathijs.vd-nes.nl>", "John Ericson <git@JohnEricson.me>", @@ -7,13 +7,13 @@ third_party { } url { type: ARCHIVE - value: "https://static.crates.io/crates/spin/spin-0.7.0.crate" + value: "https://static.crates.io/crates/spin/spin-0.7.1.crate" } - version: "0.7.0" + version: "0.7.1" license_type: NOTICE last_upgrade_date { - year: 2020 - month: 11 - day: 26 + year: 2021 + month: 1 + day: 12 } } diff --git a/TEST_MAPPING b/TEST_MAPPING index 6e9bd8c..6d31624 100644 --- a/TEST_MAPPING +++ b/TEST_MAPPING @@ -1,12 +1,55 @@ -// Generated by cargo2android.py for tests in Android.bp +// Generated by cargo2android.py for tests that depend on this crate. { "presubmit": [ { - "host": true, - "name": "spin_host_test_src_lib" + "name": "ring_device_test_tests_rand_tests" + }, + { + "name": "ring_device_test_tests_signature_tests" + }, + { + "name": "ring_device_test_tests_hkdf_tests" + }, + { + "name": "ring_device_test_tests_hmac_tests" + }, + { + "name": "ring_device_test_tests_ecdsa_tests" + }, + { + "name": "ring_device_test_tests_agreement_tests" + }, + { + "name": "ring_device_test_tests_ed25519_tests" }, { "name": "spin_device_test_src_lib" + }, + { + "name": "ring_device_test_tests_rsa_tests" + }, + { + "name": "ring_device_test_tests_quic_tests" + }, + { + "name": "ring_device_test_tests_pbkdf2_tests" + }, + { + "name": "ring_device_test_tests_constant_time_tests" + }, + { + "name": "ring_device_test_src_lib" + }, + { + "name": "ring_device_test_tests_aead_tests" + }, + { + "name": "ring_device_test_tests_digest_tests", + "options": [ + { + "test-timeout": "600000" + } + ] } ] } diff --git a/src/once.rs b/src/once.rs index fbe3583..5d4b451 100644 --- a/src/once.rs +++ b/src/once.rs @@ -252,6 +252,17 @@ impl<T> From<T> for Once<T> { } } +impl<T> Drop for Once<T> { + fn drop(&mut self) { + if self.state.load(Ordering::SeqCst) == COMPLETE { + unsafe { + //TODO: Use MaybeUninit::assume_init_drop once stabilised + core::ptr::drop_in_place((*self.data.get()).as_mut_ptr()); + } + } + } +} + struct Finish<'a> { state: &'a AtomicUsize, panicked: bool, @@ -400,4 +411,47 @@ mod tests { O.call_once(|| a += 1); assert_eq!(a, 1); } + + static mut CALLED: bool = false; + + struct DropTest {} + + impl Drop for DropTest { + fn drop(&mut self) { + unsafe { + CALLED = true; + } + } + } + + #[test] + fn drop() { + unsafe { + CALLED = false; + } + + { + let once = Once::new(); + once.call_once(|| DropTest {}); + } + + assert!(unsafe { + CALLED + }); + } + + #[test] + fn skip_uninit_drop() { + unsafe { + CALLED = false; + } + + { + let once = Once::<DropTest>::new(); + } + + assert!(unsafe { + !CALLED + }); + } } |