summaryrefslogtreecommitdiff
path: root/syscall.c
diff options
context:
space:
mode:
authorrsc <rsc>2006-07-16 01:47:40 +0000
committerrsc <rsc>2006-07-16 01:47:40 +0000
commit856e1fc1ad22a24bd71c706bc06ba868e044ddc8 (patch)
tree203bf24aa99e2f50d4bca375231d3fb46332ba29 /syscall.c
parent65bd8e139a8368e987455a10ec59dd7b079b3af1 (diff)
downloadxv6-labs-856e1fc1ad22a24bd71c706bc06ba868e044ddc8.tar.gz
xv6-labs-856e1fc1ad22a24bd71c706bc06ba868e044ddc8.tar.bz2
xv6-labs-856e1fc1ad22a24bd71c706bc06ba868e044ddc8.zip
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.
Diffstat (limited to 'syscall.c')
-rw-r--r--syscall.c13
1 files changed, 5 insertions, 8 deletions
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