#[cfg(feature = "context")]
pub use crate::arch::current::context::TaskContext;
pub use crate::arch::current::{context::TrapFrame as UserRegisters, trap::KernelTrapFrame};
#[repr(transparent)]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct TaskAnchor(core::ptr::NonNull<()>);
impl TaskAnchor {
pub const fn new<T>(pointer: core::ptr::NonNull<T>) -> Self {
Self(pointer.cast())
}
pub const fn as_ptr(self) -> *mut () {
self.0.as_ptr()
}
}
#[repr(transparent)]
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
pub struct KernelTlsBase(usize);
impl KernelTlsBase {
pub const fn new(address: usize) -> Self {
Self(address)
}
pub const fn as_usize(self) -> usize {
self.0
}
#[cfg(feature = "context")]
pub(crate) fn for_task_context(requested: Self) -> Self {
if cfg!(kernel_tls) {
requested
} else {
assert!(
requested.0 == 0,
"LinuxCurrent task contexts must not own a kernel TLS register"
);
Self(0)
}
}
}