Snap for 10453563 from cf429fc25bb4a0447a1f23a3e9c5b06ab4edbf12 to mainline-art-release

Change-Id: I5425abecee91b808bb2aad645b06734231327c9b
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
diff --git a/Android.bp b/Android.bp
index 8ae1551..31025f1 100644
--- a/Android.bp
+++ b/Android.bp
@@ -41,10 +41,11 @@
 
 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 @@
     ],
     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,
diff --git a/Cargo.toml b/Cargo.toml
index 2fdf5e8..361186b 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -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 @@
 version = "1.0.0"
 
 [dependencies.petgraph]
-version = "0.5.1"
+version = "0.6.0"
 optional = true
 
 [dependencies.smallvec]
@@ -38,12 +45,24 @@
 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 @@
 [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 @@
 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",
diff --git a/METADATA b/METADATA
index 138cd87..7d7a997 100644
--- a/METADATA
+++ b/METADATA
@@ -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 @@
   }
   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 @@
 ///
 /// 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 @@
 /// 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 @@
                 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 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 @@
 }
 
 // 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 @@
         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 @@
 
     #[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;
-            }
-
-            Some(KeyedEvent {
-                handle: handle.assume_init(),
-                NtReleaseKeyedEvent: mem::transmute(NtReleaseKeyedEvent),
-                NtWaitForKeyedEvent: mem::transmute(NtWaitForKeyedEvent),
-            })
+        let ntdll = unsafe { GetModuleHandleA(b"ntdll.dll\0".as_ptr()) };
+        if ntdll == 0 {
+            return None;
         }
+
+        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 @@
 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;
-            }
-
-            let WaitOnAddress = GetProcAddress(synch_dll, b"WaitOnAddress\0".as_ptr())?;
-            let WakeByAddressSingle =
-                GetProcAddress(synch_dll, b"WakeByAddressSingle\0".as_ptr())?;
-
-            Some(WaitAddress {
-                WaitOnAddress: mem::transmute(WaitOnAddress),
-                WakeByAddressSingle: mem::transmute(WakeByAddressSingle),
-            })
+        // 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 = unsafe { GetProcAddress(synch_dll, b"WaitOnAddress\0".as_ptr())? };
+        let WakeByAddressSingle =
+            unsafe { GetProcAddress(synch_dll, b"WakeByAddressSingle\0".as_ptr())? };
+
+        Some(WaitAddress {
+            WaitOnAddress: unsafe { mem::transmute(WaitOnAddress) },
+            WakeByAddressSingle: unsafe { mem::transmute(WakeByAddressSingle) },
+        })
     }
 
     #[inline]