use crate::bindings::{RT_STACK_FP_MIN, RT_STACK_MIN};
#[cfg(not(feature = "task-mpu"))]
use crate::cell::SyncUnsafeCell;
#[cfg(feature = "task-mpu")]
pub use crate::mpu::Stack;
pub const MIN: usize = RT_STACK_MIN as usize;
pub const FP_MIN: usize = RT_STACK_FP_MIN as usize;
#[cfg(all(target_arch = "arm", target_os = "none", not(feature = "task-mpu")))]
#[repr(align(8))]
pub struct Stack<const N: usize> {
pub buf: SyncUnsafeCell<[u8; N]>,
}
#[cfg(all(target_arch = "riscv32", target_os = "none", not(feature = "task-mpu")))]
#[repr(align(16))]
pub struct Stack<const N: usize> {
pub buf: SyncUnsafeCell<[u8; N]>,
}
#[cfg(all(target_arch = "aarch64", target_os = "none"))]
#[repr(align(16))]
pub struct Stack<const N: usize> {
pub buf: SyncUnsafeCell<[u8; N]>,
}
#[cfg(any(target_os = "linux", target_os = "macos"))]
pub struct Stack<const N: usize> {
pub buf: SyncUnsafeCell<[u8; 0]>,
}
#[cfg(not(feature = "task-mpu"))]
impl<const N: usize> Stack<N> {
pub const fn new() -> Stack<N> {
#[cfg(target_os = "none")]
{
Stack {
buf: SyncUnsafeCell::new([0u8; N]),
}
}
#[cfg(any(target_os = "linux", target_os = "macos"))]
{
Stack {
buf: SyncUnsafeCell::new([]),
}
}
}
}
#[cfg(not(feature = "task-mpu"))]
impl<const N: usize> Default for Stack<N> {
fn default() -> Self {
Self::new()
}
}