Skip to main content

abi_definitions/
lib.rs

1#![no_std]
2
3extern crate alloc;
4
5use synchronization::once_lock::OnceLock;
6
7pub struct RuntimeContext {
8    pub virtual_file_system: &'static virtual_file_system::VirtualFileSystem,
9    pub time_manager: &'static ::time::Manager<'static>,
10}
11
12static RUNTIME_CONTEXT: OnceLock<RuntimeContext> = OnceLock::new();
13
14/// Install the process-wide context used only by C ABI entry points.
15pub fn initialize(runtime_context: RuntimeContext) {
16    RUNTIME_CONTEXT.get_or_init(|| runtime_context);
17}
18
19pub(crate) fn runtime_context() -> &'static RuntimeContext {
20    RUNTIME_CONTEXT
21        .try_get()
22        .expect("ABI runtime context not initialized")
23}
24
25mod file_system;
26mod memory;
27mod string;
28mod task;
29mod time;
30mod user;
31
32pub use file_system::*;
33pub use memory::*;
34pub use string::*;
35pub use task::*;
36pub use time::*;
37pub use user::*;
38
39#[cfg(test)]
40mod tests {
41    #[cfg(any(target_os = "linux", target_os = "macos", target_os = "windows"))]
42    drivers_std::memory::instantiate_global_allocator!();
43}