Skip to content

Commit 59e5e0b

Browse files
committed
Avoid using pthread_condattr_setclock on Android.
The pthread_condattr_setclock is available only since Android 5.0 and API level 21.
1 parent 8dae1b6 commit 59e5e0b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/libstd/sys/unix/condvar.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ impl Condvar {
3030
Condvar { inner: UnsafeCell::new(libc::PTHREAD_COND_INITIALIZER) }
3131
}
3232

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

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

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

0 commit comments

Comments
 (0)