about summary refs log tree commit diff
path: root/library/std/src/sys
diff options
context:
space:
mode:
authorAzureMarker <mark.drobnak@gmail.com>2022-02-03 19:29:20 -0800
committerMark Drobnak <mark.drobnak@gmail.com>2022-06-13 20:44:57 -0700
commit06eae300347447545f5d0e8e94c673da69a1d7fd (patch)
tree195912d5b1d984b49c1887a2d6842453eda188b9 /library/std/src/sys
parentbe8b88f2b6929a09e0f147cd1fa027298f19cc5b (diff)
downloadrust-06eae300347447545f5d0e8e94c673da69a1d7fd.tar.gz
rust-06eae300347447545f5d0e8e94c673da69a1d7fd.zip
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.
Diffstat (limited to 'library/std/src/sys')
-rw-r--r--library/std/src/sys/unix/locks/pthread_condvar.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/library/std/src/sys/unix/locks/pthread_condvar.rs b/library/std/src/sys/unix/locks/pthread_condvar.rs
index b4e480be80e..78f10f0534c 100644
--- a/library/std/src/sys/unix/locks/pthread_condvar.rs
+++ b/library/std/src/sys/unix/locks/pthread_condvar.rs
@@ -16,11 +16,7 @@ const TIMESPEC_MAX: libc::timespec =
     libc::timespec { tv_sec: <libc::time_t>::MAX, tv_nsec: 1_000_000_000 - 1 };
 
 fn saturating_cast_to_time_t(value: u64) -> libc::time_t {
-    if value > <libc::time_t>::MAX as u64 {
-        <libc::time_t>::MAX
-    } else {
-        value as libc::time_t
-    }
+    if value > <libc::time_t>::MAX as u64 { <libc::time_t>::MAX } else { value as libc::time_t }
 }
 
 impl LazyInit for Condvar {
@@ -51,6 +47,8 @@ impl Condvar {
     // So on that platform, init() should always be called
     // Moreover, that platform does not have pthread_condattr_setclock support,
     // hence that initialization should be skipped as well
+    //
+    // Similar story for the 3DS (horizon).
     #[cfg(any(target_os = "espidf", target_os = "horizon"))]
     unsafe fn init(&mut self) {
         let r = libc::pthread_cond_init(self.inner.get(), crate::ptr::null());
@@ -105,7 +103,8 @@ impl Condvar {
         target_os = "macos",
         target_os = "ios",
         target_os = "android",
-        target_os = "espidf"
+        target_os = "espidf",
+        target_os = "horizon"
     )))]
     pub unsafe fn wait_timeout(&self, mutex: &Mutex, dur: Duration) -> bool {
         use crate::mem;
@@ -137,7 +136,8 @@ impl Condvar {
         target_os = "macos",
         target_os = "ios",
         target_os = "android",
-        target_os = "espidf"
+        target_os = "espidf",
+        target_os = "horizon"
     ))]
     pub unsafe fn wait_timeout(&self, mutex: &Mutex, mut dur: Duration) -> bool {
         use crate::ptr;