Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
clean unsafe op in unsafe fn
  • Loading branch information
Sword-Destiny authored Jul 16, 2024
commit 00fff8ac648d486b777c4345ba589be1f5643c59
8 changes: 4 additions & 4 deletions library/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