From 856e1fc1ad22a24bd71c706bc06ba868e044ddc8 Mon Sep 17 00:00:00 2001 From: rsc Date: Sun, 16 Jul 2006 01:47:40 +0000 Subject: Attempt to clean up newproc somewhat. Also remove all calls to memcpy in favor of memmove, which has defined semantics when the ranges overlap. The fact that memcpy was working in console.c to scroll the screen is not guaranteed by all implementations. --- syscall.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'syscall.c') diff --git a/syscall.c b/syscall.c index 420a578..6ac739f 100644 --- a/syscall.c +++ b/syscall.c @@ -30,7 +30,7 @@ fetchint(struct proc *p, unsigned addr, int *ip) if(addr > p->sz - 4) return -1; - memcpy(ip, p->mem + addr, 4); + memmove(ip, p->mem + addr, 4); return 0; } @@ -49,7 +49,7 @@ putint(struct proc *p, unsigned addr, int ip) { if(addr > p->sz - 4) return -1; - memcpy(p->mem + addr, &ip, 4); + memmove(p->mem + addr, &ip, 4); return 0; } @@ -150,13 +150,10 @@ sys_fork(void) { struct proc *np; - np = newproc(); - if(np){ - np->state = RUNNABLE; - return np->pid; - } else { + if((np = copyproc(curproc[cpu()])) == 0) return -1; - } + np->state = RUNNABLE; + return np->pid; } int -- cgit v1.2.3