From 537a8d79624959551fbb6ea81457a2bc0e6c1e3d Mon Sep 17 00:00:00 2001 From: "U. Lasiotus" Date: Wed, 3 Dec 2025 04:48:26 +0000 Subject: [PATCH] Motor OS: fix compile error [PR 148765](https://github.com/rust-lang/rust/pull/148765) changed the expected signature of Thread::new(), which broke Motor OS target. Also set thread name. --- library/std/src/sys/thread/motor.rs | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/library/std/src/sys/thread/motor.rs b/library/std/src/sys/thread/motor.rs index 0457d8818f326..4c6d3ccb84ec9 100644 --- a/library/std/src/sys/thread/motor.rs +++ b/library/std/src/sys/thread/motor.rs @@ -2,6 +2,7 @@ use crate::ffi::CStr; use crate::io; use crate::num::NonZeroUsize; use crate::sys::map_motor_error; +use crate::thread::ThreadInit; use crate::time::Duration; pub const DEFAULT_MIN_STACK_SIZE: usize = 1024 * 256; @@ -14,21 +15,21 @@ unsafe impl Send for Thread {} unsafe impl Sync for Thread {} impl Thread { - pub unsafe fn new( - stack: usize, - _name: Option<&str>, - p: Box, - ) -> io::Result { + pub unsafe fn new(stack: usize, init: Box) -> io::Result { extern "C" fn __moto_rt_thread_fn(thread_arg: u64) { unsafe { - Box::from_raw( - core::ptr::with_exposed_provenance::>(thread_arg as usize) - .cast_mut(), - )(); + let init = Box::from_raw(core::ptr::with_exposed_provenance_mut::( + thread_arg as usize, + )); + let rust_start = init.init(); + if let Some(name) = crate::thread::current().name() { + let _ = moto_rt::thread::set_name(name); + } + rust_start(); } } - let thread_arg = Box::into_raw(Box::new(p)).expose_provenance() as u64; + let thread_arg = Box::into_raw(init).expose_provenance() as u64; let sys_thread = moto_rt::thread::spawn(__moto_rt_thread_fn, stack, thread_arg) .map_err(map_motor_error)?; Ok(Self { sys_thread })