Skip to content

Commit

Permalink
Avoid using pthread_condattr_setclock on Android.
Browse files Browse the repository at this point in the history
The pthread_condattr_setclock is available only since
Android 5.0 and API level 21.
  • Loading branch information
tmiasko committed Aug 29, 2016
1 parent 8dae1b6 commit 59e5e0b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/libstd/sys/unix/condvar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ impl Condvar {
Condvar { inner: UnsafeCell::new(libc::PTHREAD_COND_INITIALIZER) }
}

#[cfg(any(target_os = "macos", target_os = "ios"))]
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "android"))]
pub unsafe fn init(&mut self) {}

#[cfg(not(any(target_os = "macos", target_os = "ios")))]
#[cfg(not(any(target_os = "macos", target_os = "ios", target_os = "android")))]
pub unsafe fn init(&mut self) {
use mem;
let mut attr: libc::pthread_condattr_t = mem::uninitialized();
Expand Down Expand Up @@ -69,7 +69,7 @@ impl Condvar {
// where we configure condition variable to use monotonic clock (instead of
// default system clock). This approach avoids all problems that result
// from changes made to the system time.
#[cfg(not(any(target_os = "macos", target_os = "ios")))]
#[cfg(not(any(target_os = "macos", target_os = "ios", target_os = "android")))]
pub unsafe fn wait_timeout(&self, mutex: &Mutex, dur: Duration) -> bool {
use mem;

Expand Down Expand Up @@ -99,7 +99,7 @@ impl Condvar {
// This implementation is modeled after libcxx's condition_variable
// https://github.com/llvm-mirror/libcxx/blob/release_35/src/condition_variable.cpp#L46
// https://github.com/llvm-mirror/libcxx/blob/release_35/include/__mutex_base#L367
#[cfg(any(target_os = "macos", target_os = "ios"))]
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "android"))]
pub unsafe fn wait_timeout(&self, mutex: &Mutex, dur: Duration) -> bool {
use ptr;
use time::Instant;
Expand Down

0 comments on commit 59e5e0b

Please sign in to comment.