#![allow(clippy::inline_always)]
pub use rticx_spsc::Queue;
#[cfg(feature = "async")]
pub use rticx_async as async_rt;
#[cfg(feature = "slic")]
pub use slic_export::*;
#[cfg(feature = "slic")]
mod slic_export;
#[cfg(feature = "esp32c3")]
pub use esp32c3_export::*;
#[cfg(feature = "esp32c3")]
#[allow(clippy::module_inception)]
mod esp32c3_export;
#[cfg(feature = "esp32c6")]
pub use esp32c6_export::*;
#[cfg(feature = "esp32c6")]
#[allow(clippy::module_inception)]
mod esp32c6_export;
#[inline]
pub fn interrupt_free<F, R>(f: F) -> R
where
F: FnOnce() -> R,
{
riscv::interrupt::free(f)
}
#[inline(always)]
pub fn read_sp() -> u32 {
let r;
unsafe { core::arch::asm!("mv {}, sp", out(reg) r, options(nomem, nostack, preserves_flags)) };
r
}
#[inline(never)]
pub fn check_stack_overflow() {
unsafe extern "C" {
static _stack_start: u32;
#[cfg(feature = "slic")]
static _ebss: u32;
#[cfg(any(feature = "esp32c3", feature = "esp32c6"))]
static _bss_end: u32;
}
let stack_start = unsafe { &_stack_start as *const _ as u32 };
#[cfg(feature = "slic")]
let bss_end = unsafe { &_ebss as *const _ as u32 };
#[cfg(any(feature = "esp32c3", feature = "esp32c6"))]
let bss_end = unsafe { &_bss_end as *const _ as u32 };
if stack_start > bss_end {
if read_sp() <= bss_end {
::core::panic!("Stack overflow after allocating executors");
}
}
}