1use core::ffi::c_int;
2use core::ptr::null_mut;
3use core::{ffi::c_void, time::Duration};
4
5use futures::block_on;
6use task::Manager;
7
8use crate::context;
9
10pub type XilaThreadIdentifier = usize;
11
12#[unsafe(no_mangle)]
13pub extern "C" fn xila_get_current_thread_identifier() -> usize {
14 context::get_instance()
15 .get_current_task_identifier()
16 .into_inner() as usize
17}
18
19#[unsafe(no_mangle)]
20pub extern "C" fn xila_thread_sleep(duration: u64) {
21 block_on(Manager::sleep(Duration::from_millis(duration)));
22}
23
24#[unsafe(no_mangle)]
25pub extern "C" fn xila_thread_sleep_exact(_duration: u32) {
26 todo!()
27}
28
29#[unsafe(no_mangle)]
30pub extern "C" fn xila_thread_join(_thread: usize) -> u32 {
31 todo!()
32}
33
34#[unsafe(no_mangle)]
35pub extern "C" fn xila_thread_detach(_thread: usize) -> u32 {
36 todo!()
37}
38
39#[unsafe(no_mangle)]
40pub extern "C" fn xila_thread_exit() {
41 unreachable!("Thread exit is not supported in this environment");
42}
43
44#[unsafe(no_mangle)]
45pub extern "C" fn xila_thread_get_stack_boundary() -> *mut u8 {
46 null_mut()
47}
48
49#[unsafe(no_mangle)]
50pub extern "C" fn xila_thread_create(
51 _function: extern "C" fn(*mut c_void) -> *mut c_void,
52 _argument: *mut u8,
53 _stack_size: usize,
54 _thread_identifier: *mut XilaThreadIdentifier,
55) -> u32 {
56 todo!()
57}
58
59#[unsafe(no_mangle)]
60pub extern "C" fn xila_thread_begin_blocking_operation() {
61 todo!()
62}
63
64#[unsafe(no_mangle)]
65pub extern "C" fn xila_thread_end_blocking_operation() {
66 todo!()
67}
68
69#[unsafe(no_mangle)]
70pub extern "C" fn xila_thread_wake_up(_thread: XilaThreadIdentifier) -> u32 {
71 todo!()
72}
73
74#[unsafe(no_mangle)]
75pub extern "C" fn xila_thread_yield() -> c_int {
76 todo!()
77}