Skip to content

Commit

Permalink
clean unsafe op in unsafe fn
Browse files Browse the repository at this point in the history
  • Loading branch information
Sword-Destiny authored Jul 16, 2024
1 parent 9fd9c61 commit b597017
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions std/src/sys/sync/condvar/teeos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,24 +76,24 @@ impl Condvar {

#[inline]
pub unsafe fn wait(&self, mutex: &Mutex) {
let mutex = mutex::raw(mutex);
let mutex = unsafe { mutex::raw(mutex) };
self.verify(mutex);
let r = libc::pthread_cond_wait(raw(self), mutex);
let r = unsafe { libc::pthread_cond_wait(raw(self), mutex) };
debug_assert_eq!(r, 0);
}

pub unsafe fn wait_timeout(&self, mutex: &Mutex, dur: Duration) -> bool {
use crate::sys::time::Timespec;

let mutex = mutex::raw(mutex);
let mutex = unsafe { mutex::raw(mutex) };
self.verify(mutex);

let timeout = Timespec::now(libc::CLOCK_MONOTONIC)
.checked_add_duration(&dur)
.and_then(|t| t.to_timespec())
.unwrap_or(TIMESPEC_MAX);

let r = pthread_cond_timedwait(raw(self), mutex, &timeout);
let r = unsafe { pthread_cond_timedwait(raw(self), mutex, &timeout) };
assert!(r == libc::ETIMEDOUT || r == 0);
r == 0
}
Expand Down

0 comments on commit b597017

Please sign in to comment.