From cf94bdc0742c13e2a0cac864c478b8626b266e1b Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:11:38 +0200 Subject: Merging upstream version 1.66.0+dfsg1. Signed-off-by: Daniel Baumann --- vendor/lock_api/.cargo-checksum.json | 2 +- vendor/lock_api/Cargo.toml | 2 +- vendor/lock_api/src/mutex.rs | 29 ++++++++++++++++++++++++++--- vendor/lock_api/src/remutex.rs | 8 ++++---- vendor/lock_api/src/rwlock.rs | 10 +++++----- 5 files changed, 37 insertions(+), 14 deletions(-) (limited to 'vendor/lock_api') diff --git a/vendor/lock_api/.cargo-checksum.json b/vendor/lock_api/.cargo-checksum.json index ceb83ada3..cf8df26fa 100644 --- a/vendor/lock_api/.cargo-checksum.json +++ b/vendor/lock_api/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"Cargo.toml":"f0fb3e65549d1353e2e199977db7825c29721bbeb71dee9bb3905437dd444dce","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"c9a75f18b9ab2927829a208fc6aa2cf4e63b8420887ba29cdb265d6619ae82d5","build.rs":"af84139c71d151adead0b4398c394a7dd16087bb2db44b14a0ed970ce868a6c6","src/lib.rs":"7b67c3b69c1b5e97248afe0f6c3bc353c793ed1ce4a5d5177e63f3f05d79c63b","src/mutex.rs":"dc4131ebf73e0474948d1849934ad5156e4a3dbd55f6881e60fd6c0acb6aa861","src/remutex.rs":"659454e66fa72e678e0aa1b83151c81c90321368dc6f4c31315230b969d4936e","src/rwlock.rs":"4f35072ca1fb476089d1548c40af775564bb7e763f86ec41a2190f8c659593cc"},"package":"327fa5b6a6940e4699ec49a9beae1ea4845c6bab9314e4f84ac68742139d8c53"} \ No newline at end of file +{"files":{"Cargo.toml":"15453a84e25ac6ed84c95e11e71d9bee5b360b6dc787a433b8416b91bf8e216c","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"c9a75f18b9ab2927829a208fc6aa2cf4e63b8420887ba29cdb265d6619ae82d5","build.rs":"af84139c71d151adead0b4398c394a7dd16087bb2db44b14a0ed970ce868a6c6","src/lib.rs":"7b67c3b69c1b5e97248afe0f6c3bc353c793ed1ce4a5d5177e63f3f05d79c63b","src/mutex.rs":"f5627b1269a9b0d116507af19b8619b9922b95b73a84ab5be3134620c97caadb","src/remutex.rs":"4fa5f0448591a32ac37f2cf9af89813f32e415d2a1ca426670a0cdaccbca66aa","src/rwlock.rs":"9160cbada7e3179bd8ec13769761437e90bfb616316947dc0cc5959f0bcdc5b9"},"package":"435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df"} \ No newline at end of file diff --git a/vendor/lock_api/Cargo.toml b/vendor/lock_api/Cargo.toml index c1ebdb7b7..b1ff8c4db 100644 --- a/vendor/lock_api/Cargo.toml +++ b/vendor/lock_api/Cargo.toml @@ -12,7 +12,7 @@ [package] edition = "2018" name = "lock_api" -version = "0.4.7" +version = "0.4.9" authors = ["Amanieu d'Antras "] description = "Wrappers to create fully-featured Mutex and RwLock types. Compatible with no_std." keywords = [ diff --git a/vendor/lock_api/src/mutex.rs b/vendor/lock_api/src/mutex.rs index 4e1b879e5..c97e5430b 100644 --- a/vendor/lock_api/src/mutex.rs +++ b/vendor/lock_api/src/mutex.rs @@ -681,15 +681,38 @@ unsafe impl<'a, R: RawMutex + 'a, T: ?Sized + 'a> StableAddress for MutexGuard<' #[must_use = "if unused the Mutex will immediately unlock"] pub struct ArcMutexGuard { mutex: Arc>, - marker: PhantomData, + marker: PhantomData<*const ()>, +} + +#[cfg(feature = "arc_lock")] +unsafe impl Send for ArcMutexGuard where + R::GuardMarker: Send +{ +} +#[cfg(feature = "arc_lock")] +unsafe impl Sync for ArcMutexGuard where + R::GuardMarker: Sync +{ } #[cfg(feature = "arc_lock")] impl ArcMutexGuard { /// Returns a reference to the `Mutex` this is guarding, contained in its `Arc`. #[inline] - pub fn mutex(&self) -> &Arc> { - &self.mutex + pub fn mutex(s: &Self) -> &Arc> { + &s.mutex + } + + /// Unlocks the mutex and returns the `Arc` that was held by the [`ArcMutexGuard`]. + #[inline] + pub fn into_arc(s: Self) -> Arc> { + // Safety: Skip our Drop impl and manually unlock the mutex. + let arc = unsafe { ptr::read(&s.mutex) }; + mem::forget(s); + unsafe { + arc.raw.unlock(); + } + arc } /// Temporarily unlocks the mutex to execute the given function. diff --git a/vendor/lock_api/src/remutex.rs b/vendor/lock_api/src/remutex.rs index fa0e934d1..3e2010f2b 100644 --- a/vendor/lock_api/src/remutex.rs +++ b/vendor/lock_api/src/remutex.rs @@ -646,7 +646,7 @@ impl<'a, R: RawMutex + 'a, G: GetThreadId + 'a, T: ?Sized + 'a> ReentrantMutexGu /// in already locked the mutex. /// /// This is an associated function that needs to be - /// used as `ReentrantMutexGuard::map(...)`. A method would interfere with methods of + /// used as `ReentrantMutexGuard::try_map(...)`. A method would interfere with methods of /// the same name on the contents of the locked data. #[inline] pub fn try_map( @@ -654,10 +654,10 @@ impl<'a, R: RawMutex + 'a, G: GetThreadId + 'a, T: ?Sized + 'a> ReentrantMutexGu f: F, ) -> Result, Self> where - F: FnOnce(&mut T) -> Option<&mut U>, + F: FnOnce(&T) -> Option<&U>, { let raw = &s.remutex.raw; - let data = match f(unsafe { &mut *s.remutex.data.get() }) { + let data = match f(unsafe { &*s.remutex.data.get() }) { Some(data) => data, None => return Err(s), }; @@ -942,7 +942,7 @@ impl<'a, R: RawMutex + 'a, G: GetThreadId + 'a, T: ?Sized + 'a> /// in already locked the mutex. /// /// This is an associated function that needs to be - /// used as `MappedReentrantMutexGuard::map(...)`. A method would interfere with methods of + /// used as `MappedReentrantMutexGuard::try_map(...)`. A method would interfere with methods of /// the same name on the contents of the locked data. #[inline] pub fn try_map( diff --git a/vendor/lock_api/src/rwlock.rs b/vendor/lock_api/src/rwlock.rs index e947f1ec0..c972fb6c6 100644 --- a/vendor/lock_api/src/rwlock.rs +++ b/vendor/lock_api/src/rwlock.rs @@ -1218,13 +1218,13 @@ impl<'a, R: RawRwLock + 'a, T: ?Sized + 'a> RwLockReadGuard<'a, R, T> { } /// Attempts to make a new `MappedRwLockReadGuard` for a component of the - /// locked data. The original guard is return if the closure returns `None`. + /// locked data. Returns the original guard if the closure returns `None`. /// /// This operation cannot fail as the `RwLockReadGuard` passed /// in already locked the data. /// /// This is an associated function that needs to be - /// used as `RwLockReadGuard::map(...)`. A method would interfere with methods of + /// used as `RwLockReadGuard::try_map(...)`. A method would interfere with methods of /// the same name on the contents of the locked data. #[inline] pub fn try_map(s: Self, f: F) -> Result, Self> @@ -1512,7 +1512,7 @@ impl<'a, R: RawRwLock + 'a, T: ?Sized + 'a> RwLockWriteGuard<'a, R, T> { /// in already locked the data. /// /// This is an associated function that needs to be - /// used as `RwLockWriteGuard::map(...)`. A method would interfere with methods of + /// used as `RwLockWriteGuard::try_map(...)`. A method would interfere with methods of /// the same name on the contents of the locked data. #[inline] pub fn try_map(s: Self, f: F) -> Result, Self> @@ -2374,7 +2374,7 @@ impl<'a, R: RawRwLock + 'a, T: ?Sized + 'a> MappedRwLockReadGuard<'a, R, T> { /// in already locked the data. /// /// This is an associated function that needs to be - /// used as `MappedRwLockReadGuard::map(...)`. A method would interfere with methods of + /// used as `MappedRwLockReadGuard::try_map(...)`. A method would interfere with methods of /// the same name on the contents of the locked data. #[inline] pub fn try_map(s: Self, f: F) -> Result, Self> @@ -2512,7 +2512,7 @@ impl<'a, R: RawRwLock + 'a, T: ?Sized + 'a> MappedRwLockWriteGuard<'a, R, T> { /// in already locked the data. /// /// This is an associated function that needs to be - /// used as `MappedRwLockWriteGuard::map(...)`. A method would interfere with methods of + /// used as `MappedRwLockWriteGuard::try_map(...)`. A method would interfere with methods of /// the same name on the contents of the locked data. #[inline] pub fn try_map(s: Self, f: F) -> Result, Self> -- cgit v1.2.3