abi/
time.rs

1use core::ffi::{c_int, c_void};
2
3use time::get_instance;
4
5pub type XilaTime = u64;
6
7#[repr(u8)]
8pub enum XilaTimeClockIdentifier {
9    Monotonic,
10    Realtime,
11}
12
13#[repr(u8)]
14pub enum XilaTimerFlags {
15    Absolute,
16}
17
18/// Retrieve the current time since the system startup in microseconds.
19///
20/// # Returns
21///
22/// The current time since the system startup in microseconds.
23#[unsafe(no_mangle)]
24pub extern "C" fn xila_time_get_time_since_startup_microseconds() -> u64 {
25    get_instance()
26        .get_current_time_since_startup()
27        .unwrap_or_default()
28        .as_micros() as u64
29}
30
31#[unsafe(no_mangle)]
32pub extern "C" fn xila_time_get_cpu() -> u64 {
33    todo!()
34}
35
36/// Retrieve the current time since the system startup in milliseconds.
37///
38/// # Safety
39///
40/// This function is unsafe because it dereferences raw pointers.
41#[unsafe(no_mangle)]
42pub unsafe extern "C" fn xila_time_get_resolution(
43    _clock_identifier: XilaTimeClockIdentifier,
44    _resolution: *mut XilaTime,
45) -> u32 {
46    todo!()
47}
48
49/// Retrieve the current time since the system startup in milliseconds.
50///
51/// # Safety
52///
53/// This function is unsafe because it dereferences raw pointers.
54#[unsafe(no_mangle)]
55pub extern "C" fn xila_time_get_time(
56    _clock_identifier: XilaTimeClockIdentifier,
57    _precision: u64,
58    _time: *mut XilaTime,
59) -> u32 {
60    todo!()
61}
62
63#[unsafe(no_mangle)]
64pub extern "C" fn xila_time_nano_sleep(
65    _clock_identifier: XilaTimeClockIdentifier,
66    _flags: XilaTimerFlags,
67    _time: *const c_void,
68    _remaining: *mut XilaTime,
69) -> c_int {
70    0
71}