diff options
author | Joel Galenson <jgalenson@google.com> | 2021-09-23 14:49:25 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2021-09-23 14:49:25 +0000 |
commit | 1b4fbc20df57acf9ee5208a5d998f7afa62cc599 (patch) | |
tree | eabda872e663a08047a7f79095ff8114c0f1618b | |
parent | e4e90b75b2a19119310d692656de377db83f563d (diff) | |
parent | 8fbdc9d44061559967570b379c12c8e32ec41ace (diff) | |
download | parking_lot_core-1b4fbc20df57acf9ee5208a5d998f7afa62cc599.tar.gz |
Upgrade rust/crates/parking_lot_core to 0.8.5 am: e339207ab6 am: 8fbdc9d440
Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/parking_lot_core/+/1833675
Change-Id: I683b0acf40f4b5ae4cdb657abf806a0b99863dd6
-rw-r--r-- | .cargo_vcs_info.json | 2 | ||||
-rw-r--r-- | Android.bp | 21 | ||||
-rw-r--r-- | Cargo.toml | 23 | ||||
-rw-r--r-- | Cargo.toml.orig | 14 | ||||
-rw-r--r-- | METADATA | 8 | ||||
-rw-r--r-- | build.rs | 10 | ||||
-rw-r--r-- | src/word_lock.rs | 17 |
7 files changed, 58 insertions, 37 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json index b278af6..7e564f3 100644 --- a/.cargo_vcs_info.json +++ b/.cargo_vcs_info.json @@ -1,5 +1,5 @@ { "git": { - "sha1": "f3ea9e2082735525e84b30acd39c3f1d9d845c9a" + "sha1": "aecb031e795391025d33f3f26f83ab24102ca42f" } } @@ -1,4 +1,5 @@ -// This file is generated by cargo2android.py --run --device --dependencies --tests. +// This file is generated by cargo2android.py --run --device --tests. +// Do not modify this file as changes will be overridden on upgrade. package { default_applicable_licenses: [ @@ -40,8 +41,11 @@ license { rust_library { name: "libparking_lot_core", + // has rustc warnings host_supported: true, crate_name: "parking_lot_core", + cargo_env_compat: true, + cargo_pkg_version: "0.8.5", srcs: ["src/lib.rs"], edition: "2018", rustlibs: [ @@ -53,9 +57,12 @@ rust_library { } rust_defaults { - name: "parking_lot_core_defaults", + name: "parking_lot_core_test_defaults", crate_name: "parking_lot_core", + // has rustc warnings srcs: ["src/lib.rs"], + cargo_env_compat: true, + cargo_pkg_version: "0.8.5", test_suites: ["general-tests"], auto_gen_config: true, edition: "2018", @@ -69,7 +76,7 @@ rust_defaults { rust_test_host { name: "parking_lot_core_host_test_src_lib", - defaults: ["parking_lot_core_defaults"], + defaults: ["parking_lot_core_test_defaults"], test_options: { unit_test: true, }, @@ -77,11 +84,5 @@ rust_test_host { rust_test { name: "parking_lot_core_device_test_src_lib", - defaults: ["parking_lot_core_defaults"], + defaults: ["parking_lot_core_test_defaults"], } - -// dependent_library ["feature_list"] -// cfg-if-1.0.0 -// instant-0.1.9 -// libc-0.2.86 "default,std" -// smallvec-1.6.1 @@ -3,17 +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 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) +# 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. [package] edition = "2018" name = "parking_lot_core" -version = "0.8.3" +version = "0.8.5" authors = ["Amanieu d'Antras <amanieu@gmail.com>"] description = "An advanced API for creating custom synchronization primitives." keywords = ["mutex", "condvar", "rwlock", "once", "thread"] @@ -21,14 +20,14 @@ categories = ["concurrency"] license = "Apache-2.0/MIT" repository = "https://github.com/Amanieu/parking_lot" [dependencies.backtrace] -version = "0.3.49" +version = "0.3.60" optional = true [dependencies.cfg-if] version = "1.0.0" [dependencies.instant] -version = "0.1.4" +version = "0.1.9" [dependencies.petgraph] version = "0.5.1" @@ -38,16 +37,16 @@ optional = true version = "1.6.1" [dependencies.thread-id] -version = "3.3.0" +version = "4.0.0" optional = true [features] deadlock_detection = ["petgraph", "thread-id", "backtrace"] nightly = [] [target."cfg(target_os = \"redox\")".dependencies.redox_syscall] -version = "0.2.4" +version = "0.2.8" [target."cfg(unix)".dependencies.libc] -version = "0.2.71" +version = "0.2.95" [target."cfg(windows)".dependencies.winapi] -version = "0.3.8" +version = "0.3.9" features = ["winnt", "ntstatus", "minwindef", "winerror", "winbase", "errhandlingapi", "handleapi"] diff --git a/Cargo.toml.orig b/Cargo.toml.orig index e4af2fc..2585329 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -1,6 +1,6 @@ [package] name = "parking_lot_core" -version = "0.8.3" +version = "0.8.5" authors = ["Amanieu d'Antras <amanieu@gmail.com>"] description = "An advanced API for creating custom synchronization primitives." license = "Apache-2.0/MIT" @@ -13,18 +13,18 @@ edition = "2018" cfg-if = "1.0.0" smallvec = "1.6.1" petgraph = { version = "0.5.1", optional = true } -thread-id = { version = "3.3.0", optional = true } -backtrace = { version = "0.3.49", optional = true } -instant = "0.1.4" +thread-id = { version = "4.0.0", optional = true } +backtrace = { version = "0.3.60", optional = true } +instant = "0.1.9" [target.'cfg(unix)'.dependencies] -libc = "0.2.71" +libc = "0.2.95" [target.'cfg(target_os = "redox")'.dependencies] -redox_syscall = "0.2.4" +redox_syscall = "0.2.8" [target.'cfg(windows)'.dependencies] -winapi = { version = "0.3.8", features = ["winnt", "ntstatus", "minwindef", +winapi = { version = "0.3.9", features = ["winnt", "ntstatus", "minwindef", "winerror", "winbase", "errhandlingapi", "handleapi"] } [features] @@ -7,13 +7,13 @@ third_party { } url { type: ARCHIVE - value: "https://static.crates.io/crates/parking_lot_core/parking_lot_core-0.8.3.crate" + value: "https://static.crates.io/crates/parking_lot_core/parking_lot_core-0.8.5.crate" } - version: "0.8.3" + version: "0.8.5" license_type: NOTICE last_upgrade_date { year: 2021 - month: 2 - day: 12 + month: 9 + day: 22 } } diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..d29c769 --- /dev/null +++ b/build.rs @@ -0,0 +1,10 @@ +// Automatically detect tsan in a way that's compatible with both stable (which +// doesn't support sanitizers) and nightly (which does). Works because build +// scripts gets `cfg` info, even if the cfg is unstable. +fn main() { + println!("cargo:rerun-if-changed=build.rs"); + let santizer_list = std::env::var("CARGO_CFG_SANITIZE").unwrap_or_default(); + if santizer_list.contains("thread") { + println!("cargo:rustc-cfg=tsan_enabled"); + } +} diff --git a/src/word_lock.rs b/src/word_lock.rs index 450e985..1109401 100644 --- a/src/word_lock.rs +++ b/src/word_lock.rs @@ -154,7 +154,7 @@ impl WordLock { if let Err(x) = self.state.compare_exchange_weak( state, state.with_queue_head(thread_data), - Ordering::Release, + Ordering::AcqRel, Ordering::Relaxed, ) { return x; @@ -238,7 +238,7 @@ impl WordLock { } // Need an acquire fence before reading the new queue - fence(Ordering::Acquire); + fence_acquire(&self.state); continue; } @@ -263,7 +263,7 @@ impl WordLock { continue; } else { // Need an acquire fence before reading the new queue - fence(Ordering::Acquire); + fence_acquire(&self.state); continue 'outer; } } @@ -286,6 +286,17 @@ impl WordLock { } } +// Thread-Sanitizer only has partial fence support, so when running under it, we +// try and avoid false positives by using a discarded acquire load instead. +#[inline] +fn fence_acquire(a: &AtomicUsize) { + if cfg!(tsan_enabled) { + let _ = a.load(Ordering::Acquire); + } else { + fence(Ordering::Acquire); + } +} + trait LockState { fn is_locked(self) -> bool; fn is_queue_locked(self) -> bool; |