diff --git a/kernel/syscall.c b/kernel/syscall.c index ca34f2c..ff10f9c 100644 --- a/kernel/syscall.c +++ b/kernel/syscall.c @@ -116,29 +116,29 @@ argstr(int n, char *buf, int max) return fetchstr(addr, buf, max); } -extern int sys_chdir(void); -extern int sys_close(void); -extern int sys_dup(void); -extern int sys_exec(void); -extern int sys_exit(void); -extern int sys_fork(void); -extern int sys_fstat(void); -extern int sys_getpid(void); -extern int sys_kill(void); -extern int sys_link(void); -extern int sys_mkdir(void); -extern int sys_mknod(void); -extern int sys_open(void); -extern int sys_pipe(void); -extern int sys_read(void); -extern int sys_sbrk(void); -extern int sys_sleep(void); -extern int sys_unlink(void); -extern int sys_wait(void); -extern int sys_write(void); -extern int sys_uptime(void); +extern uint64 sys_chdir(void); +extern uint64 sys_close(void); +extern uint64 sys_dup(void); +extern uint64 sys_exec(void); +extern uint64 sys_exit(void); +extern uint64 sys_fork(void); +extern uint64 sys_fstat(void); +extern uint64 sys_getpid(void); +extern uint64 sys_kill(void); +extern uint64 sys_link(void); +extern uint64 sys_mkdir(void); +extern uint64 sys_mknod(void); +extern uint64 sys_open(void); +extern uint64 sys_pipe(void); +extern uint64 sys_read(void); +extern uint64 sys_sbrk(void); +extern uint64 sys_sleep(void); +extern uint64 sys_unlink(void); +extern uint64 sys_wait(void); +extern uint64 sys_write(void); +extern uint64 sys_uptime(void); -static int (*syscalls[])(void) = { +static uint64 (*syscalls[])(void) = { [SYS_fork] sys_fork, [SYS_exit] sys_exit, [SYS_wait] sys_wait, diff --git a/kernel/sysfile.c b/kernel/sysfile.c index 7788de3..77e273f 100644 --- a/kernel/sysfile.c +++ b/kernel/sysfile.c @@ -52,7 +52,7 @@ fdalloc(struct file *f) return -1; } -int +uint64 sys_dup(void) { struct file *f; @@ -66,7 +66,7 @@ sys_dup(void) return fd; } -int +uint64 sys_read(void) { struct file *f; @@ -78,7 +78,7 @@ sys_read(void) return fileread(f, p, n); } -int +uint64 sys_write(void) { struct file *f; @@ -91,7 +91,7 @@ sys_write(void) return filewrite(f, p, n); } -int +uint64 sys_close(void) { int fd; @@ -104,7 +104,7 @@ sys_close(void) return 0; } -int +uint64 sys_fstat(void) { struct file *f; @@ -116,7 +116,7 @@ sys_fstat(void) } // Create the path new as a link to the same inode as old. -int +uint64 sys_link(void) { char name[DIRSIZ], new[MAXPATH], old[MAXPATH]; @@ -182,7 +182,7 @@ isdirempty(struct inode *dp) } //PAGEBREAK! -int +uint64 sys_unlink(void) { struct inode *ip, *dp; @@ -284,7 +284,7 @@ create(char *path, short type, short major, short minor) return ip; } -int +uint64 sys_open(void) { char path[MAXPATH]; @@ -347,7 +347,7 @@ sys_open(void) return fd; } -int +uint64 sys_mkdir(void) { char path[MAXPATH]; @@ -363,7 +363,7 @@ sys_mkdir(void) return 0; } -int +uint64 sys_mknod(void) { struct inode *ip; @@ -383,7 +383,7 @@ sys_mknod(void) return 0; } -int +uint64 sys_chdir(void) { char path[MAXPATH]; @@ -408,7 +408,7 @@ sys_chdir(void) return 0; } -int +uint64 sys_exec(void) { char path[MAXPATH], *argv[MAXARG]; @@ -446,7 +446,7 @@ sys_exec(void) return ret; } -int +uint64 sys_pipe(void) { uint64 fdarray; // user pointer to array of two integers diff --git a/kernel/sysproc.c b/kernel/sysproc.c index e57e045..93ea9bc 100644 --- a/kernel/sysproc.c +++ b/kernel/sysproc.c @@ -6,32 +6,32 @@ #include "memlayout.h" #include "proc.h" -int +uint64 sys_exit(void) { exit(); return 0; // not reached } -int +uint64 sys_getpid(void) { return myproc()->pid; } -int +uint64 sys_fork(void) { return fork(); } -int +uint64 sys_wait(void) { return wait(); } -int +uint64 sys_sbrk(void) { int addr; @@ -45,7 +45,7 @@ sys_sbrk(void) return addr; } -int +uint64 sys_sleep(void) { int n; @@ -66,7 +66,7 @@ sys_sleep(void) return 0; } -int +uint64 sys_kill(void) { int pid; @@ -78,7 +78,7 @@ sys_kill(void) // return how many clock tick interrupts have occurred // since start. -int +uint64 sys_uptime(void) { uint xticks; diff --git a/user/usertests.c b/user/usertests.c index beca8f9..0aafe73 100644 --- a/user/usertests.c +++ b/user/usertests.c @@ -1438,6 +1438,13 @@ sbrktest(void) printf(stdout, "sbrk test\n"); oldbrk = sbrk(0); + // does sbrk() return the expected failure value? + a = sbrk(1024*1024*1024); + if(a != (char*)0xffffffffffffffffL){ + printf(stdout, "sbrk() returned %p\n", a); + exit(); + } + // can one sbrk() less than a page? a = sbrk(0); for(i = 0; i < 5000; i++){ @@ -1478,7 +1485,7 @@ sbrktest(void) // can one de-allocate? a = sbrk(0); c = sbrk(-4096); - if(c == (char*)0xffffffff){ + if(c == (char*)0xffffffffffffffffL){ printf(stdout, "sbrk could not deallocate\n"); exit(); } @@ -1551,7 +1558,7 @@ sbrktest(void) kill(pids[i]); wait(); } - if(c == (char*)0xffffffff){ + if(c == (char*)0xffffffffffffffffL){ printf(stdout, "failed sbrk leaked memory\n"); exit(); }