1use core::ffi::{c_char, c_void};
2
3use crate::os::TimeSpanType;
4
5#[repr(C)]
6#[repr(align(16))]
7pub struct ThreadType {
8 reserved: [u8; 0x1C0],
9}
10
11pub type ThreadFn = unsafe extern "C" fn(arg: *mut c_void);
12
13unsafe extern "C" {
14 pub fn nnosCreateThread(
15 t: *mut ThreadType,
16 entry: ThreadFn,
17 arg: *mut c_void,
18 stack: *mut c_void,
19 stack_size: usize,
20 priority: i32,
21 ) -> u32;
22
23 pub fn nnosCreateThreadWithCoreNumber(
24 t: *mut ThreadType,
25 entry: ThreadFn,
26 arg: *mut c_void,
27 stack: *mut c_void,
28 stack_size: usize,
29 priority: i32,
30 ideal_core: i32,
31 ) -> u32;
32
33 pub fn nnosDestroyThread(t: *mut ThreadType);
34 pub fn nnosStartThread(t: *mut ThreadType);
35 pub fn nnosGetCurrentThread() -> *mut ThreadType;
36 pub fn nnosTryWaitThread(t: *mut ThreadType) -> bool;
37 pub fn nnosWaitThread(t: *mut ThreadType);
38 pub fn nnosYieldThread();
39 pub fn nnosSleepThread(time: TimeSpanType);
40 pub fn nnosChangeThreadPriority(t: *const ThreadType, priority: i32) -> i32;
41 pub fn nnosGetThreadPriority(t: *const ThreadType) -> i32;
42 pub fn nnosGetThreadCurrentPriority(t: *const ThreadType) -> i32;
43 pub fn nnosSetThreadName(t: *mut ThreadType, name: *const c_char);
44 pub fn nnosSetThreadNamePointer(t: *mut ThreadType, name: *const c_char);
45 pub fn nnosGetThreadNamePointer(t: *const ThreadType) -> *const c_char;
46 pub fn nnosGetCurrentProcessorNumber() -> i32;
47 pub fn nnosGetCurrentCoreNumber() -> i32;
48
49 #[link_name = "_ZN2nn2os11GetThreadIdEPKNS0_10ThreadTypeE"]
50 pub fn nnosGetThreadId(t: *const ThreadType) -> u64;
51}