Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move to 2024-05-18 nightly #6

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
Fix as_mut
xinyu committed May 7, 2024
commit c99537be779e01531253bfce8e6424218e8ce0fc
5 changes: 5 additions & 0 deletions src/cell/tcell.rs
Original file line number Diff line number Diff line change
@@ -77,6 +77,11 @@ impl<T: Default + VSafe, A: MemPool> TCell<T, A> {
}
}

#[inline]
pub(crate) fn as_mut(&self) -> &mut T {
unsafe { utils::as_mut(self).force() }
}

#[inline]
/// Create a new invalid cell to be used in const functions
pub const fn new_invalid(v: T) -> Self {
2 changes: 1 addition & 1 deletion src/cell/vcell.rs
Original file line number Diff line number Diff line change
@@ -60,7 +60,7 @@ impl<T: Default + VSafe, A: MemPool> VCell<T, A> {

#[inline]
pub(crate) fn as_mut(&self) -> &mut T {
unsafe { &mut *self.value.get() }
unsafe { utils::as_mut(self).force() }
}

#[inline]
4 changes: 2 additions & 2 deletions src/sync/mutex.rs
Original file line number Diff line number Diff line change
@@ -262,7 +262,7 @@ impl<T, A: MemPool> PMutex<T, A> {
#[cfg(any(feature = "no_pthread", windows))]
let result = {
let tid = std::thread::current().id().as_u64().get();
intrinsics::atomic_cxchg_acqrel(lock, 0, tid).0 == tid
intrinsics::atomic_cxchg_acqrel_acquire(lock, 0, tid).0 == tid
};

if result {
@@ -274,7 +274,7 @@ impl<T, A: MemPool> PMutex<T, A> {
libc::pthread_mutex_unlock(lock);

#[cfg(any(feature = "no_pthread", windows))]
intrinsics::atomic_store_rel(lock, 0);
intrinsics::atomic_store_release(lock, 0);

panic!("Cannot have multiple instances of MutexGuard");
}