diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-07-07 05:06:20 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-07-07 05:06:20 +0000 |
commit | 812217eef4f1a9a642540ae297abc0932755d2f0 (patch) | |
tree | b03b0c7a663f9ebe439f34fe3011e30a64229d43 | |
parent | 1f73b4e47f2d09a252cb8a24a33e601de0f5cd2c (diff) | |
parent | cf429fc25bb4a0447a1f23a3e9c5b06ab4edbf12 (diff) | |
download | parking_lot_core-android14-mainline-os-statsd-release.tar.gz |
Snap for 10453563 from cf429fc25bb4a0447a1f23a3e9c5b06ab4edbf12 to mainline-os-statsd-releaseaml_sta_341615000aml_sta_341511040aml_sta_341410000aml_sta_341311010aml_sta_341114000aml_sta_341111000aml_sta_341010020aml_sta_340912000aml_sta_340911000aml_net_341111030android14-mainline-os-statsd-release
Change-Id: I7323e81fb154840d4d0570a9cc4652714d413cfb
-rw-r--r-- | .cargo_vcs_info.json | 2 | ||||
-rw-r--r-- | Android.bp | 10 | ||||
-rw-r--r-- | Cargo.toml | 33 | ||||
-rw-r--r-- | Cargo.toml.orig | 8 | ||||
-rw-r--r-- | METADATA | 14 | ||||
-rw-r--r-- | cargo2android.json | 2 | ||||
-rw-r--r-- | src/parking_lot.rs | 8 | ||||
-rw-r--r-- | src/thread_parker/generic.rs | 2 | ||||
-rw-r--r-- | src/thread_parker/linux.rs | 8 | ||||
-rw-r--r-- | src/thread_parker/unix.rs | 22 | ||||
-rw-r--r-- | src/thread_parker/windows/keyed_event.rs | 66 | ||||
-rw-r--r-- | src/thread_parker/windows/waitaddress.rs | 29 |
12 files changed, 123 insertions, 81 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json index ec3f28f..bba71f7 100644 --- a/.cargo_vcs_info.json +++ b/.cargo_vcs_info.json @@ -1,6 +1,6 @@ { "git": { - "sha1": "847b5cab64fe3a87f853de0cac479d78e5a7ee77" + "sha1": "f549eacc36168db632f63731c701ac0521b58e50" }, "path_in_vcs": "core" }
\ No newline at end of file @@ -41,10 +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.9.1", + cargo_pkg_version: "0.9.7", srcs: ["src/lib.rs"], edition: "2018", rustlibs: [ @@ -54,18 +55,21 @@ rust_library { ], apex_available: [ "//apex_available:platform", - "com.android.bluetooth", + "com.android.btservices", "com.android.virt", ], + product_available: true, + vendor_available: true, min_sdk_version: "29", } rust_test { name: "parking_lot_core_test_src_lib", + // has rustc warnings host_supported: true, crate_name: "parking_lot_core", cargo_env_compat: true, - cargo_pkg_version: "0.9.1", + cargo_pkg_version: "0.9.7", srcs: ["src/lib.rs"], test_suites: ["general-tests"], auto_gen_config: true, @@ -12,13 +12,20 @@ [package] edition = "2018" name = "parking_lot_core" -version = "0.9.1" +version = "0.9.7" authors = ["Amanieu d'Antras <amanieu@gmail.com>"] description = "An advanced API for creating custom synchronization primitives." -keywords = ["mutex", "condvar", "rwlock", "once", "thread"] +keywords = [ + "mutex", + "condvar", + "rwlock", + "once", + "thread", +] categories = ["concurrency"] -license = "Apache-2.0/MIT" +license = "MIT OR Apache-2.0" repository = "https://github.com/Amanieu/parking_lot" + [dependencies.backtrace] version = "0.3.60" optional = true @@ -27,7 +34,7 @@ optional = true version = "1.0.0" [dependencies.petgraph] -version = "0.5.1" +version = "0.6.0" optional = true [dependencies.smallvec] @@ -38,12 +45,24 @@ version = "4.0.0" optional = true [features] -deadlock_detection = ["petgraph", "thread-id", "backtrace"] +deadlock_detection = [ + "petgraph", + "thread-id", + "backtrace", +] nightly = [] + [target."cfg(target_os = \"redox\")".dependencies.redox_syscall] version = "0.2.8" + [target."cfg(unix)".dependencies.libc] version = "0.2.95" + [target."cfg(windows)".dependencies.windows-sys] -version = "0.32" -features = ["Win32_Foundation", "Win32_System_LibraryLoader", "Win32_System_SystemServices", "Win32_System_WindowsProgramming"] +version = "0.45.0" +features = [ + "Win32_Foundation", + "Win32_System_LibraryLoader", + "Win32_System_SystemServices", + "Win32_System_WindowsProgramming", +] diff --git a/Cargo.toml.orig b/Cargo.toml.orig index f053e45..c1fd530 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -1,9 +1,9 @@ [package] name = "parking_lot_core" -version = "0.9.1" +version = "0.9.7" authors = ["Amanieu d'Antras <amanieu@gmail.com>"] description = "An advanced API for creating custom synchronization primitives." -license = "Apache-2.0/MIT" +license = "MIT OR Apache-2.0" repository = "https://github.com/Amanieu/parking_lot" keywords = ["mutex", "condvar", "rwlock", "once", "thread"] categories = ["concurrency"] @@ -12,7 +12,7 @@ edition = "2018" [dependencies] cfg-if = "1.0.0" smallvec = "1.6.1" -petgraph = { version = "0.5.1", optional = true } +petgraph = { version = "0.6.0", optional = true } thread-id = { version = "4.0.0", optional = true } backtrace = { version = "0.3.60", optional = true } @@ -23,7 +23,7 @@ libc = "0.2.95" redox_syscall = "0.2.8" [target.'cfg(windows)'.dependencies] -windows-sys = { version = "0.32", features = [ +windows-sys = { version = "0.45.0", features = [ "Win32_Foundation", "Win32_System_LibraryLoader", "Win32_System_SystemServices", @@ -1,3 +1,7 @@ +# This project was upgraded with external_updater. +# Usage: tools/external_updater/updater.sh update rust/crates/parking_lot_core +# For more info, check https://cs.android.com/android/platform/superproject/+/master:tools/external_updater/README.md + name: "parking_lot_core" description: "An advanced API for creating custom synchronization primitives." third_party { @@ -7,13 +11,13 @@ third_party { } url { type: ARCHIVE - value: "https://static.crates.io/crates/parking_lot_core/parking_lot_core-0.9.1.crate" + value: "https://static.crates.io/crates/parking_lot_core/parking_lot_core-0.9.7.crate" } - version: "0.9.1" + version: "0.9.7" license_type: NOTICE last_upgrade_date { - year: 2022 - month: 3 - day: 1 + year: 2023 + month: 2 + day: 3 } } diff --git a/cargo2android.json b/cargo2android.json index 22531ba..da746ae 100644 --- a/cargo2android.json +++ b/cargo2android.json @@ -1,7 +1,7 @@ { "apex-available": [ "//apex_available:platform", - "com.android.bluetooth", + "com.android.btservices", "com.android.virt" ], "device": true, diff --git a/src/parking_lot.rs b/src/parking_lot.rs index 9b84525..b388619 100644 --- a/src/parking_lot.rs +++ b/src/parking_lot.rs @@ -724,6 +724,10 @@ pub unsafe fn park( /// /// The `callback` function is called while the queue is locked and must not /// panic or call into any function in `parking_lot`. +/// +/// The `parking_lot` functions are not re-entrant and calling this method +/// from the context of an asynchronous signal handler may result in undefined +/// behavior, including corruption of internal state and/or deadlocks. #[inline] pub unsafe fn unpark_one( key: usize, @@ -801,6 +805,10 @@ pub unsafe fn unpark_one( /// You should only call this function with an address that you control, since /// you could otherwise interfere with the operation of other synchronization /// primitives. +/// +/// The `parking_lot` functions are not re-entrant and calling this method +/// from the context of an asynchronous signal handler may result in undefined +/// behavior, including corruption of internal state and/or deadlocks. #[inline] pub unsafe fn unpark_all(key: usize, unpark_token: UnparkToken) -> usize { // Lock the bucket for the given key diff --git a/src/thread_parker/generic.rs b/src/thread_parker/generic.rs index 990bcb7..93c94fa 100644 --- a/src/thread_parker/generic.rs +++ b/src/thread_parker/generic.rs @@ -8,8 +8,8 @@ //! A simple spin lock based thread parker. Used on platforms without better //! parking facilities available. -use core::sync::atomic::{AtomicBool, Ordering}; use core::hint::spin_loop; +use core::sync::atomic::{AtomicBool, Ordering}; use std::thread; use std::time::Instant; diff --git a/src/thread_parker/linux.rs b/src/thread_parker/linux.rs index 5d4e229..92601f6 100644 --- a/src/thread_parker/linux.rs +++ b/src/thread_parker/linux.rs @@ -80,10 +80,10 @@ impl super::ThreadParkerT for ThreadParker { self.park(); return true; } - let ts = libc::timespec { - tv_sec: diff.as_secs() as libc::time_t, - tv_nsec: diff.subsec_nanos() as tv_nsec_t, - }; + // SAFETY: libc::timespec is zero initializable. + let mut ts: libc::timespec = std::mem::zeroed(); + ts.tv_sec = diff.as_secs() as libc::time_t; + ts.tv_nsec = diff.subsec_nanos() as tv_nsec_t; self.futex_wait(Some(ts)); } true diff --git a/src/thread_parker/unix.rs b/src/thread_parker/unix.rs index c52ead9..7f28603 100644 --- a/src/thread_parker/unix.rs +++ b/src/thread_parker/unix.rs @@ -5,7 +5,7 @@ // http://opensource.org/licenses/MIT>, at your option. This file may not be // copied, modified, or distributed except according to those terms. -#[cfg(any(target_os = "macos", target_os = "ios"))] +#[cfg(any(target_os = "macos", target_os = "ios", target_os = "watchos"))] use core::ptr; use core::{ cell::{Cell, UnsafeCell}, @@ -127,12 +127,24 @@ impl super::ThreadParkerT for ThreadParker { impl ThreadParker { /// Initializes the condvar to use CLOCK_MONOTONIC instead of CLOCK_REALTIME. - #[cfg(any(target_os = "macos", target_os = "ios", target_os = "android"))] + #[cfg(any( + target_os = "macos", + target_os = "ios", + target_os = "watchos", + target_os = "android", + target_os = "espidf" + ))] #[inline] unsafe fn init(&self) {} /// Initializes the condvar to use CLOCK_MONOTONIC instead of CLOCK_REALTIME. - #[cfg(not(any(target_os = "macos", target_os = "ios", target_os = "android")))] + #[cfg(not(any( + target_os = "macos", + target_os = "ios", + target_os = "watchos", + target_os = "android", + target_os = "espidf" + )))] #[inline] unsafe fn init(&self) { let mut attr = MaybeUninit::<libc::pthread_condattr_t>::uninit(); @@ -183,7 +195,7 @@ impl super::UnparkHandleT for UnparkHandle { } // Returns the current time on the clock used by pthread_cond_t as a timespec. -#[cfg(any(target_os = "macos", target_os = "ios"))] +#[cfg(any(target_os = "macos", target_os = "ios", target_os = "watchos"))] #[inline] fn timespec_now() -> libc::timespec { let mut now = MaybeUninit::<libc::timeval>::uninit(); @@ -196,7 +208,7 @@ fn timespec_now() -> libc::timespec { tv_nsec: now.tv_usec as tv_nsec_t * 1000, } } -#[cfg(not(any(target_os = "macos", target_os = "ios")))] +#[cfg(not(any(target_os = "macos", target_os = "ios", target_os = "watchos")))] #[inline] fn timespec_now() -> libc::timespec { let mut now = MaybeUninit::<libc::timespec>::uninit(); diff --git a/src/thread_parker/windows/keyed_event.rs b/src/thread_parker/windows/keyed_event.rs index bbe45a4..302bab5 100644 --- a/src/thread_parker/windows/keyed_event.rs +++ b/src/thread_parker/windows/keyed_event.rs @@ -55,42 +55,40 @@ impl KeyedEvent { #[allow(non_snake_case)] pub fn create() -> Option<KeyedEvent> { - unsafe { - let ntdll = GetModuleHandleA(b"ntdll.dll\0".as_ptr()); - if ntdll == 0 { - return None; - } - - let NtCreateKeyedEvent = - GetProcAddress(ntdll, b"NtCreateKeyedEvent\0".as_ptr())?; - let NtReleaseKeyedEvent = - GetProcAddress(ntdll, b"NtReleaseKeyedEvent\0".as_ptr())?; - let NtWaitForKeyedEvent = - GetProcAddress(ntdll, b"NtWaitForKeyedEvent\0".as_ptr())?; - - let NtCreateKeyedEvent: extern "system" fn( - KeyedEventHandle: *mut HANDLE, - DesiredAccess: u32, - ObjectAttributes: *mut ffi::c_void, - Flags: u32, - ) -> NTSTATUS = mem::transmute(NtCreateKeyedEvent); - let mut handle = MaybeUninit::uninit(); - let status = NtCreateKeyedEvent( - handle.as_mut_ptr(), - GENERIC_READ | GENERIC_WRITE, - ptr::null_mut(), - 0, - ); - if status != STATUS_SUCCESS { - return None; - } + let ntdll = unsafe { GetModuleHandleA(b"ntdll.dll\0".as_ptr()) }; + if ntdll == 0 { + return None; + } - Some(KeyedEvent { - handle: handle.assume_init(), - NtReleaseKeyedEvent: mem::transmute(NtReleaseKeyedEvent), - NtWaitForKeyedEvent: mem::transmute(NtWaitForKeyedEvent), - }) + let NtCreateKeyedEvent = + unsafe { GetProcAddress(ntdll, b"NtCreateKeyedEvent\0".as_ptr())? }; + let NtReleaseKeyedEvent = + unsafe { GetProcAddress(ntdll, b"NtReleaseKeyedEvent\0".as_ptr())? }; + let NtWaitForKeyedEvent = + unsafe { GetProcAddress(ntdll, b"NtWaitForKeyedEvent\0".as_ptr())? }; + + let NtCreateKeyedEvent: extern "system" fn( + KeyedEventHandle: *mut HANDLE, + DesiredAccess: u32, + ObjectAttributes: *mut ffi::c_void, + Flags: u32, + ) -> NTSTATUS = unsafe { mem::transmute(NtCreateKeyedEvent) }; + let mut handle = MaybeUninit::uninit(); + let status = NtCreateKeyedEvent( + handle.as_mut_ptr(), + GENERIC_READ | GENERIC_WRITE, + ptr::null_mut(), + 0, + ); + if status != STATUS_SUCCESS { + return None; } + + Some(KeyedEvent { + handle: unsafe { handle.assume_init() }, + NtReleaseKeyedEvent: unsafe { mem::transmute(NtReleaseKeyedEvent) }, + NtWaitForKeyedEvent: unsafe { mem::transmute(NtWaitForKeyedEvent) }, + }) } #[inline] diff --git a/src/thread_parker/windows/waitaddress.rs b/src/thread_parker/windows/waitaddress.rs index dde0db7..ef6cb44 100644 --- a/src/thread_parker/windows/waitaddress.rs +++ b/src/thread_parker/windows/waitaddress.rs @@ -32,24 +32,21 @@ pub struct WaitAddress { impl WaitAddress { #[allow(non_snake_case)] pub fn create() -> Option<WaitAddress> { - unsafe { - // MSDN claims that that WaitOnAddress and WakeByAddressSingle are - // located in kernel32.dll, but they are lying... - let synch_dll = - GetModuleHandleA(b"api-ms-win-core-synch-l1-2-0.dll\0".as_ptr()); - if synch_dll == 0 { - return None; - } + // MSDN claims that that WaitOnAddress and WakeByAddressSingle are + // located in kernel32.dll, but they are lying... + let synch_dll = unsafe { GetModuleHandleA(b"api-ms-win-core-synch-l1-2-0.dll\0".as_ptr()) }; + if synch_dll == 0 { + return None; + } - let WaitOnAddress = GetProcAddress(synch_dll, b"WaitOnAddress\0".as_ptr())?; - let WakeByAddressSingle = - GetProcAddress(synch_dll, b"WakeByAddressSingle\0".as_ptr())?; + let WaitOnAddress = unsafe { GetProcAddress(synch_dll, b"WaitOnAddress\0".as_ptr())? }; + let WakeByAddressSingle = + unsafe { GetProcAddress(synch_dll, b"WakeByAddressSingle\0".as_ptr())? }; - Some(WaitAddress { - WaitOnAddress: mem::transmute(WaitOnAddress), - WakeByAddressSingle: mem::transmute(WakeByAddressSingle), - }) - } + Some(WaitAddress { + WaitOnAddress: unsafe { mem::transmute(WaitOnAddress) }, + WakeByAddressSingle: unsafe { mem::transmute(WakeByAddressSingle) }, + }) } #[inline] |