set deny(unsafe_op_in_unsafe_fn) for
This commit is contained in:
+5
-2
@@ -1,3 +1,6 @@
|
||||
// TODO: set this for entire crate when possible
|
||||
#![deny(unsafe_op_in_unsafe_fn)]
|
||||
|
||||
pub mod barrier;
|
||||
pub mod cond;
|
||||
// TODO: Merge with pthread_mutex
|
||||
@@ -95,14 +98,14 @@ impl FutexAtomicTy for AtomicI32 {
|
||||
|
||||
pub unsafe fn futex_wake_ptr(ptr: *mut impl FutexTy, n: i32) -> usize {
|
||||
// TODO: unwrap_unchecked?
|
||||
Sys::futex_wake(ptr.cast(), n as u32).unwrap() as usize
|
||||
unsafe { Sys::futex_wake(ptr.cast(), n as u32) }.unwrap() as usize
|
||||
}
|
||||
pub unsafe fn futex_wait_ptr<T: FutexTy>(
|
||||
ptr: *mut T,
|
||||
value: T,
|
||||
deadline_opt: Option<×pec>,
|
||||
) -> FutexWaitResult {
|
||||
match Sys::futex_wait(ptr.cast(), value.conv(), deadline_opt) {
|
||||
match unsafe { Sys::futex_wait(ptr.cast(), value.conv(), deadline_opt) } {
|
||||
Ok(()) => FutexWaitResult::Waited,
|
||||
Err(Errno(EAGAIN)) => FutexWaitResult::Stale,
|
||||
Err(Errno(ETIMEDOUT)) if deadline_opt.is_some() => FutexWaitResult::TimedOut,
|
||||
|
||||
+5
-5
@@ -76,8 +76,8 @@ impl<T> Mutex<T> {
|
||||
/// on failure. You should probably not worry about this, it's used for
|
||||
/// internal optimizations.
|
||||
pub unsafe fn manual_try_lock(&self) -> Result<&mut T, c_int> {
|
||||
if manual_try_lock_generic(&self.lock) {
|
||||
Ok(&mut *self.content.get())
|
||||
if unsafe { manual_try_lock_generic(&self.lock) } {
|
||||
Ok(unsafe { &mut *self.content.get() })
|
||||
} else {
|
||||
Err(0)
|
||||
}
|
||||
@@ -86,12 +86,12 @@ impl<T> Mutex<T> {
|
||||
/// your responsibility to unlock it after usage. Mostly useful for FFI:
|
||||
/// Prefer normal .lock() where possible.
|
||||
pub unsafe fn manual_lock(&self) -> &mut T {
|
||||
manual_lock_generic(&self.lock);
|
||||
&mut *self.content.get()
|
||||
unsafe { manual_lock_generic(&self.lock) };
|
||||
unsafe { &mut *self.content.get() }
|
||||
}
|
||||
/// Unlock the mutex, if it's locked.
|
||||
pub unsafe fn manual_unlock(&self) {
|
||||
manual_unlock_generic(&self.lock)
|
||||
unsafe { manual_unlock_generic(&self.lock) }
|
||||
}
|
||||
pub fn as_ptr(&self) -> *mut T {
|
||||
self.content.get()
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ impl<T> Waitval<T> {
|
||||
// SAFETY: Caller must ensure both (1) that the value has not yet been initialized, and (2)
|
||||
// that this is never run by more than one thread simultaneously.
|
||||
pub unsafe fn post(&self, value: T) {
|
||||
self.value.get().write(MaybeUninit::new(value));
|
||||
unsafe { self.value.get().write(MaybeUninit::new(value)) };
|
||||
self.state.store(1, Ordering::Release);
|
||||
crate::sync::futex_wake(&self.state, i32::MAX);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user