Skip to content

Commit 63b2758

Browse files
committed
vexos: move thread from sys::pal to sys::thread
1 parent e08dea6 commit 63b2758

File tree

4 files changed

+33
-79
lines changed

4 files changed

+33
-79
lines changed

library/std/src/sys/pal/vexos/mod.rs

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,16 @@
22
pub mod os;
33
#[path = "../unsupported/pipe.rs"]
44
pub mod pipe;
5-
pub mod thread;
65
pub mod time;
76

7+
#[expect(dead_code)]
8+
#[path = "../unsupported/common.rs"]
9+
mod unsupported_common;
10+
11+
pub use unsupported_common::{
12+
decode_error_kind, init, is_interrupted, unsupported, unsupported_err,
13+
};
14+
815
use crate::arch::global_asm;
916
use crate::ptr;
1017
use crate::sys::stdio;
@@ -45,10 +52,6 @@ pub unsafe extern "C" fn _start() -> ! {
4552
abort_internal()
4653
}
4754

48-
// SAFETY: must be called only once during runtime initialization.
49-
// NOTE: this is not guaranteed to run, for example when Rust code is called externally.
50-
pub unsafe fn init(_argc: isize, _argv: *const *const u8, _sigpipe: u8) {}
51-
5255
// SAFETY: must be called only once during runtime cleanup.
5356
// NOTE: this is not guaranteed to run, for example when the program aborts.
5457
pub unsafe fn cleanup() {
@@ -66,22 +69,6 @@ pub unsafe fn cleanup() {
6669
}
6770
}
6871

69-
pub fn unsupported<T>() -> crate::io::Result<T> {
70-
Err(unsupported_err())
71-
}
72-
73-
pub fn unsupported_err() -> crate::io::Error {
74-
crate::io::Error::UNSUPPORTED_PLATFORM
75-
}
76-
77-
pub fn is_interrupted(_code: i32) -> bool {
78-
false
79-
}
80-
81-
pub fn decode_error_kind(_code: i32) -> crate::io::ErrorKind {
82-
crate::io::ErrorKind::Uncategorized
83-
}
84-
8572
pub fn abort_internal() -> ! {
8673
unsafe {
8774
vex_sdk::vexSystemExitRequest();

library/std/src/sys/pal/vexos/thread.rs

Lines changed: 0 additions & 58 deletions
This file was deleted.

library/std/src/sys/thread/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,13 @@ cfg_select! {
8181
))]
8282
pub use unsupported::set_name;
8383
}
84+
target_os = "vexos" => {
85+
mod vexos;
86+
pub use vexos::{sleep, yield_now};
87+
#[expect(dead_code)]
88+
mod unsupported;
89+
pub use unsupported::{Thread, available_parallelism, current_os_id, set_name, DEFAULT_MIN_STACK_SIZE};
90+
}
8491
all(target_os = "wasi", target_env = "p1") => {
8592
mod wasip1;
8693
pub use wasip1::{DEFAULT_MIN_STACK_SIZE, sleep, yield_now};
@@ -138,6 +145,7 @@ cfg_select! {
138145
target_os = "dragonfly",
139146
target_os = "hurd",
140147
target_os = "fuchsia",
148+
target_os = "vexos",
141149
target_os = "vxworks",
142150
all(target_os = "wasi", target_env = "p2"),
143151
)))]
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
use crate::time::Duration;
2+
3+
pub fn yield_now() {
4+
unsafe {
5+
vex_sdk::vexTasksRun();
6+
}
7+
}
8+
9+
pub fn sleep(dur: Duration) {
10+
let start = Instant::now();
11+
12+
while start.elapsed() < dur {
13+
unsafe {
14+
vex_sdk::vexTasksRun();
15+
}
16+
}
17+
}

0 commit comments

Comments
 (0)