pub fn sys_clone(
        &self,
        flags: usize,
        newsp: usize,
        mut parent_tid: UserOutPtr<i32>,
        mut child_tid: UserOutPtr<i32>,
        newtls: usize,
    ) -> SysResult {
        let _flags = CloneFlags::from_bits_truncate(flags);
        info!(
            "clone: flags={:#x}, newsp={:#x}, parent_tid={:?}, child_tid={:?}, newtls={:#x}",
            flags, newsp, parent_tid, child_tid, newtls
        );
        if flags == 0x4111 || flags == 0x11 {
            warn!("sys_clone is calling sys_fork instead, ignoring other args");
            //unimplemented!()
            return self.sys_fork();
        }
        if flags != 0x7d_0f00 && flags != 0x5d_0f00 {
            // 0x5d0f00: gcc of alpine linux
            // 0x7d0f00: pthread_create of alpine linux
            // warn!("sys_clone only support musl pthread_create");
            panic!("unsupported sys_clone flags: {:#x}", flags);
        }
        let new_thread = Thread::create_linux(self.zircon_process())?;
        #[cfg(not(target_arch = "riscv64"))]
        {
            let regs = GeneralRegs::new_clone(self.regs, newsp, newtls);
            new_thread.start_with_regs(regs, self.thread_fn)?;
        }

        #[cfg(target_arch = "riscv64")]
        new_thread.start_with_context(self.context, self.thread_fn)?;

        let tid = new_thread.id();
        info!("clone: {} -> {}", self.thread.id(), tid);
        parent_tid.write(tid as i32)?;
        child_tid.write(tid as i32)?;
        new_thread.set_tid_address(child_tid);
        Ok(tid as usize)
    }
/// Create a new thread in the current process.
/// The new thread's stack pointer will be set to `newsp`,
/// and thread pointer will be set to `newtls`.
/// The child tid will be stored at both `parent_tid` and `child_tid`.
/// This is partially implemented for musl only.
Create a new thread in the current process.
The new thread's stack pointer will be set to `newsp`,
and thread pointer will be set to `newtls`.
The child tid will be stored at both `parent_tid` and `child_tid`.
This is partially implemented for musl only.
Create a new thread in the current process . The new thread ' s stack pointer will be set to ` newsp ` and thread pointer will be set to ` newtls ` . The child tid will be stored at both ` parent_tid ` and ` child_tid ` . This is partially implemented for musl only .
pub fn sys_clone(
        &self,
        flags: usize,
        newsp: usize,
        mut parent_tid: UserOutPtr<i32>,
        mut child_tid: UserOutPtr<i32>,
        newtls: usize,
    ) -> SysResult {
        let _flags = CloneFlags::from_bits_truncate(flags);
        info!(
            "clone: flags={:#x}, newsp={:#x}, parent_tid={:?}, child_tid={:?}, newtls={:#x}",
            flags, newsp, parent_tid, child_tid, newtls
        );
        if flags == 0x4111 || flags == 0x11 {
            warn!("sys_clone is calling sys_fork instead, ignoring other args");
            //unimplemented!()
            return self.sys_fork();
        }
        if flags != 0x7d_0f00 && flags != 0x5d_0f00 {
            // 0x5d0f00: gcc of alpine linux
            // 0x7d0f00: pthread_create of alpine linux
            // warn!("sys_clone only support musl pthread_create");
            panic!("unsupported sys_clone flags: {:#x}", flags);
        }
        let new_thread = Thread::create_linux(self.zircon_process())?;
        #[cfg(not(target_arch = "riscv64"))]
        {
            let regs = GeneralRegs::new_clone(self.regs, newsp, newtls);
            new_thread.start_with_regs(regs, self.thread_fn)?;
        }
        #[cfg(target_arch = "riscv64")]
        new_thread.start_with_context(self.context, self.thread_fn)?;
        let tid = new_thread.id();
        info!("clone: {} -> {}", self.thread.id(), tid);
        parent_tid.write(tid as i32)?;
        child_tid.write(tid as i32)?;
        new_thread.set_tid_address(child_tid);
        Ok(tid as usize)
    }
pub fn sys_clone ( & self , flags : usize , newsp : usize , mut parent_tid : UserOutPtr < i32 > , mut child_tid : UserOutPtr < i32 > , newtls : usize , ) -> SysResult { let _flags = CloneFlags :: from_bits_truncate ( flags ) ; info ! ( " " flags newsp parent_tid child_tid newtls ) ; if flags == 0x4111 || flags == 0x11 { warn ! ( " " ) ; //unimplemented!() return self . sys_fork ( ) ; } if flags != 0x7d_0f00 && flags != 0x5d_0f00 { // 0x5d0f00: gcc of alpine linux // 0x7d0f00: pthread_create of alpine linux // warn!("sys_clone only support musl pthread_create"); panic ! ( " " flags ) ; } let new_thread = Thread :: create_linux ( self . zircon_process ( ) ) ? ; # [ cfg ( not ( target_arch " " ) ) ] { let regs = GeneralRegs :: new_clone ( self . regs , newsp , newtls ) ; new_thread . start_with_regs ( regs , self . thread_fn ) ? ; } # [ cfg ( target_arch " " ) ] new_thread . start_with_context ( self . context , self . thread_fn ) ? ; let tid = new_thread . id ( ) ; info ! ( " " self thread id ( ) tid ) ; parent_tid . write ( tid as i32 ) ? ; child_tid . write ( tid as i32 ) ? ; new_thread . set_tid_address ( child_tid ) ; Ok ( tid as usize ) }
Create a new thread in the current process.
Create a new thread in the current process .
&self
flags
usize
newsp
usize
parent_tid
UserOutPtr<i32>
child_tid
UserOutPtr<i32>
newtls
usize
&self
flags
usize
newsp
usize
parent_tid
UserOutPtr<i32>
child_tid
UserOutPtr<i32>
newtls
usize