Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 06eae30

Browse files
committed
Use the right wait_timeout implementation
Our condvar doesn't support setting attributes, like pthread_condattr_setclock, which the current wait_timeout expects to have configured. Switch to a different implementation, following espidf.
1 parent be8b88f commit 06eae30

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

library/std/src/sys/unix/locks/pthread_condvar.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,7 @@ const TIMESPEC_MAX: libc::timespec =
1616
libc::timespec { tv_sec: <libc::time_t>::MAX, tv_nsec: 1_000_000_000 - 1 };
1717

1818
fn saturating_cast_to_time_t(value: u64) -> libc::time_t {
19-
if value > <libc::time_t>::MAX as u64 {
20-
<libc::time_t>::MAX
21-
} else {
22-
value as libc::time_t
23-
}
19+
if value > <libc::time_t>::MAX as u64 { <libc::time_t>::MAX } else { value as libc::time_t }
2420
}
2521

2622
impl LazyInit for Condvar {
@@ -51,6 +47,8 @@ impl Condvar {
5147
// So on that platform, init() should always be called
5248
// Moreover, that platform does not have pthread_condattr_setclock support,
5349
// hence that initialization should be skipped as well
50+
//
51+
// Similar story for the 3DS (horizon).
5452
#[cfg(any(target_os = "espidf", target_os = "horizon"))]
5553
unsafe fn init(&mut self) {
5654
let r = libc::pthread_cond_init(self.inner.get(), crate::ptr::null());
@@ -105,7 +103,8 @@ impl Condvar {
105103
target_os = "macos",
106104
target_os = "ios",
107105
target_os = "android",
108-
target_os = "espidf"
106+
target_os = "espidf",
107+
target_os = "horizon"
109108
)))]
110109
pub unsafe fn wait_timeout(&self, mutex: &Mutex, dur: Duration) -> bool {
111110
use crate::mem;
@@ -137,7 +136,8 @@ impl Condvar {
137136
target_os = "macos",
138137
target_os = "ios",
139138
target_os = "android",
140-
target_os = "espidf"
139+
target_os = "espidf",
140+
target_os = "horizon"
141141
))]
142142
pub unsafe fn wait_timeout(&self, mutex: &Mutex, mut dur: Duration) -> bool {
143143
use crate::ptr;

0 commit comments

Comments
 (0)