fix sys_wait arg type: isize -> i32

master
WangRunji 6 years ago
parent 61dfcb5558
commit f0ea48126d

@ -30,7 +30,7 @@ pub fn syscall(id: usize, args: [usize; 6], tf: &mut TrapFrame) -> isize {
// process // process
001 => sys_exit(args[0] as isize), 001 => sys_exit(args[0] as isize),
002 => sys_fork(tf), 002 => sys_fork(tf),
003 => sys_wait(args[0], args[1] as *mut isize), 003 => sys_wait(args[0], args[1] as *mut i32),
004 => sys_exec(args[0] as *const u8, args[1] as usize, args[2] as *const *const u8, tf), 004 => sys_exec(args[0] as *const u8, args[1] as usize, args[2] as *const *const u8, tf),
// 005 => sys_clone(), // 005 => sys_clone(),
010 => sys_yield(), 010 => sys_yield(),
@ -142,16 +142,14 @@ fn sys_dup(fd1: usize, fd2: usize) -> SysResult {
/// Fork the current process. Return the child's PID. /// Fork the current process. Return the child's PID.
fn sys_fork(tf: &TrapFrame) -> SysResult { fn sys_fork(tf: &TrapFrame) -> SysResult {
let context = process().fork(tf); let context = process().fork(tf);
//memory_set_map_swappable(context.get_memory_set_mut());
let pid = processor().manager().add(context, thread::current().id()); let pid = processor().manager().add(context, thread::current().id());
//memory_set_map_swappable(processor.get_context_mut(pid).get_memory_set_mut());
info!("fork: {} -> {}", thread::current().id(), pid); info!("fork: {} -> {}", thread::current().id(), pid);
Ok(pid as isize) Ok(pid as isize)
} }
/// Wait the process exit. /// Wait the process exit.
/// Return the PID. Store exit code to `code` if it's not null. /// Return the PID. Store exit code to `code` if it's not null.
fn sys_wait(pid: usize, code: *mut isize) -> SysResult { fn sys_wait(pid: usize, code: *mut i32) -> SysResult {
// TODO: check ptr // TODO: check ptr
loop { loop {
use alloc::vec; use alloc::vec;
@ -166,7 +164,7 @@ fn sys_wait(pid: usize, code: *mut isize) -> SysResult {
match processor().manager().get_status(pid) { match processor().manager().get_status(pid) {
Some(Status::Exited(exit_code)) => { Some(Status::Exited(exit_code)) => {
if !code.is_null() { if !code.is_null() {
unsafe { code.write(exit_code as isize); } unsafe { code.write(exit_code as i32); }
} }
processor().manager().remove(pid); processor().manager().remove(pid);
info!("wait: {} -> {}", thread::current().id(), pid); info!("wait: {} -> {}", thread::current().id(), pid);

Loading…
Cancel
Save