osal_rs/
lib.rs

1/***************************************************************************
2 *
3 * osal-rs
4 * Copyright (C) 2023/2026 Antonio Salsi <passy.linux@zresa.it>
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 *
18 ***************************************************************************/
19
20#![cfg_attr(not(feature = "std"), no_std)]
21
22// Suppress warnings from FreeRTOS FFI bindings being included in multiple modules
23#![allow(clashing_extern_declarations)]
24#![allow(dead_code)]
25#![allow(unused_imports)]
26extern crate alloc;
27
28#[cfg(feature = "freertos")]
29mod freertos;
30
31#[cfg(feature = "posix")]
32mod posix;
33
34pub mod log;
35
36mod traits;
37
38pub mod utils;
39
40#[cfg(feature = "freertos")]
41use crate::freertos as osal;
42
43#[cfg(feature = "posix")]
44use crate::posix as osal;
45
46pub mod os {
47
48    #[cfg(not(feature = "disable_panic"))]
49    use crate::osal::allocator::Allocator;
50
51
52    #[cfg(not(feature = "disable_panic"))]
53    #[global_allocator]
54    pub static ALLOCATOR: Allocator = Allocator;
55
56    
57    pub use crate::osal::duration::*;
58    pub use crate::osal::event_group::*;
59    pub use crate::osal::mutex::*;
60    pub use crate::osal::queue::*;
61    pub use crate::osal::semaphore::*;
62    pub use crate::osal::system::*;
63    pub use crate::osal::thread::*;
64    pub use crate::osal::timer::*;
65    pub use crate::traits::*;
66    pub use crate::osal::config as config;
67    pub use crate::osal::types as types;
68    
69}
70
71
72// Panic handler for no_std library - only when building as final binary
73// Examples with std will provide their own
74#[cfg(not(feature = "disable_panic"))]
75#[panic_handler]
76
77fn panic(info: &core::panic::PanicInfo) -> ! {
78    println!("Panic occurred: {}", info);
79    #[allow(clippy::empty_loop)]
80    loop {}
81}
82