Skip to content

Commit 663e7ab

Browse files
committed
xous: thread: mark thread_main() as divergent
The thread wrapper function never returns, so we can mark it as divergent. Signed-off-by: Sean Cross <sean@xobs.io>
1 parent bb93b45 commit 663e7ab

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

library/std/src/sys/xous/thread.rs

+11-5
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,20 @@ impl Thread {
6868
)
6969
.map_err(|code| io::Error::from_raw_os_error(code as i32))?;
7070

71-
extern "C" fn thread_start(main: *mut usize, guard_page_pre: usize, stack_size: usize) {
72-
unsafe {
73-
// Finally, let's run some code.
74-
Box::from_raw(main as *mut Box<dyn FnOnce()>)();
71+
extern "C" fn thread_start(
72+
main: *mut usize,
73+
guard_page_pre: usize,
74+
stack_size: usize,
75+
) -> ! {
76+
{
77+
unsafe {
78+
// Run the contents of the new thread.
79+
Box::from_raw(main as *mut Box<dyn FnOnce()>)();
80+
}
7581
}
7682

7783
// Destroy TLS, which will free the TLS page and call the destructor for
78-
// any thread local storage.
84+
// any thread local storage (if any).
7985
unsafe {
8086
crate::sys::thread_local_key::destroy_tls();
8187
}

0 commit comments

Comments
 (0)