feat: add Rust userspace support; fix TLS layout for p_align < 16; kill whole process on sibling-thread faults

This commit is contained in:
daniel committed 2026-10-14 07:16:42 +02:00
1 parent a81298fb24
commit f8b8f9610f
31 files changed
+1076 -38

No files matched your search

+35
View File
@@ -0,0 +1,35 @@
//! Process control.
use crate::sys;
unsafe extern "C" {
// libc exit(): runs atexit handlers (and .fini_array), then SYS_EXIT.
#[link_name = "exit"]
fn libc_exit(code: i32) -> !;
}
/// Exit the process. From a sibling thread this ends only that thread
/// (kernel semantics); use [`abort`] to take the whole process down.
pub fn exit(code: i32) -> ! {
unsafe { libc_exit(code) }
}
pub fn id() -> u32 {
unsafe { sys::syscall0(sys::SYS_GETPID) as u32 }
}
/// Terminate the whole process from any thread.
pub fn abort() -> ! {
unsafe {
if crate::thread::current_id() == id() {
sys::syscall1(sys::SYS_EXIT, 134);
} else {
// Sibling: SYS_EXIT would end only this thread. Self-kill flags
// every thread; park here until the kernel reaps us.
sys::syscall1(sys::SYS_KILL, id() as u64);
}
loop {
sys::syscall0(sys::SYS_YIELD);
}
}
}