summaryrefslogtreecommitdiffstats
path: root/library/std/src/sys/itron/thread_parking.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:41 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:41 +0000
commit4f9fe856a25ab29345b90e7725509e9ee38a37be (patch)
treee4ffd8a9374cae7b21f7cbfb352927e0e074aff6 /library/std/src/sys/itron/thread_parking.rs
parentAdding upstream version 1.68.2+dfsg1. (diff)
downloadrustc-4f9fe856a25ab29345b90e7725509e9ee38a37be.tar.xz
rustc-4f9fe856a25ab29345b90e7725509e9ee38a37be.zip
Adding upstream version 1.69.0+dfsg1.upstream/1.69.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--library/std/src/sys/itron/thread_parking.rs37
1 files changed, 37 insertions, 0 deletions
diff --git a/library/std/src/sys/itron/thread_parking.rs b/library/std/src/sys/itron/thread_parking.rs
new file mode 100644
index 000000000..fe9934439
--- /dev/null
+++ b/library/std/src/sys/itron/thread_parking.rs
@@ -0,0 +1,37 @@
+use super::abi;
+use super::error::expect_success_aborting;
+use super::time::with_tmos;
+use crate::time::Duration;
+
+pub type ThreadId = abi::ID;
+
+pub use super::task::current_task_id_aborting as current;
+
+pub fn park(_hint: usize) {
+ match unsafe { abi::slp_tsk() } {
+ abi::E_OK | abi::E_RLWAI => {}
+ err => {
+ expect_success_aborting(err, &"slp_tsk");
+ }
+ }
+}
+
+pub fn park_timeout(dur: Duration, _hint: usize) {
+ match with_tmos(dur, |tmo| unsafe { abi::tslp_tsk(tmo) }) {
+ abi::E_OK | abi::E_RLWAI | abi::E_TMOUT => {}
+ err => {
+ expect_success_aborting(err, &"tslp_tsk");
+ }
+ }
+}
+
+pub fn unpark(id: ThreadId, _hint: usize) {
+ match unsafe { abi::wup_tsk(id) } {
+ // It is allowed to try to wake up a destroyed or unrelated task, so we ignore all
+ // errors that could result from that situation.
+ abi::E_OK | abi::E_NOEXS | abi::E_OBJ | abi::E_QOVR => {}
+ err => {
+ expect_success_aborting(err, &"wup_tsk");
+ }
+ }
+}