X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flib%2Fuser%2Fsyscall.c;h=6fc26edcc333db9e66cbf0b458e252387336d9ef;hb=049fb46b7129283a37826e5dac6d4d589e4b98d0;hp=aaeb109314775c49f626e3bf9b27445a96d93416;hpb=fcb5d5ae90ae9d5319a3e4b7aed2c751e1dfaadf;p=pintos-anon diff --git a/src/lib/user/syscall.c b/src/lib/user/syscall.c index aaeb109..6fc26ed 100644 --- a/src/lib/user/syscall.c +++ b/src/lib/user/syscall.c @@ -3,45 +3,45 @@ /* Invokes syscall NUMBER, passing no arguments, and returns the return value as an `int'. */ -#define syscall0(NUMBER) \ - ({ \ - int retval; \ - asm volatile \ - ("push %[number]; int 0x30; add %%esp, 4" \ - : "=a" (retval) \ - : [number] "i" (NUMBER) \ - : "memory"); \ - retval; \ +#define syscall0(NUMBER) \ + ({ \ + int retval; \ + asm volatile \ + ("pushl %[number]; int $0x30; addl $4, %%esp" \ + : "=a" (retval) \ + : [number] "i" (NUMBER) \ + : "memory"); \ + retval; \ }) /* Invokes syscall NUMBER, passing argument ARG0, and returns the return value as an `int'. */ -#define syscall1(NUMBER, ARG0) \ - ({ \ - int retval; \ - asm volatile \ - ("push %[arg0]; push %[number]; int 0x30; add %%esp, 8" \ - : "=a" (retval) \ - : [number] "i" (NUMBER), \ - [arg0] "g" (ARG0) \ - : "memory"); \ - retval; \ +#define syscall1(NUMBER, ARG0) \ + ({ \ + int retval; \ + asm volatile \ + ("pushl %[arg0]; pushl %[number]; int $0x30; addl $8, %%esp" \ + : "=a" (retval) \ + : [number] "i" (NUMBER), \ + [arg0] "g" (ARG0) \ + : "memory"); \ + retval; \ }) /* Invokes syscall NUMBER, passing arguments ARG0 and ARG1, and returns the return value as an `int'. */ -#define syscall2(NUMBER, ARG0, ARG1) \ - ({ \ - int retval; \ - asm volatile \ - ("push %[arg1]; push %[arg0]; " \ - "push %[number]; int 0x30; add %%esp, 12" \ - : "=a" (retval) \ - : [number] "i" (NUMBER), \ - [arg0] "g" (ARG0), \ - [arg1] "g" (ARG1) \ - : "memory"); \ - retval; \ +#define syscall2(NUMBER, ARG0, ARG1) \ + ({ \ + int retval; \ + asm volatile \ + ("pushl %[arg1]; pushl %[arg0]; " \ + "pushl %[number]; int $0x30; addl $12, %%esp" \ + : "=a" (retval) \ + : [number] "i" (NUMBER), \ + [arg0] "g" (ARG0), \ + [arg1] "g" (ARG1) \ + : "memory"); \ + retval; \ }) /* Invokes syscall NUMBER, passing arguments ARG0, ARG1, and @@ -50,8 +50,8 @@ ({ \ int retval; \ asm volatile \ - ("push %[arg2]; push %[arg1]; push %[arg0]; " \ - "push %[number]; int 0x30; add %%esp, 16" \ + ("pushl %[arg2]; pushl %[arg1]; pushl %[arg0]; " \ + "pushl %[number]; int $0x30; addl $16, %%esp" \ : "=a" (retval) \ : [number] "i" (NUMBER), \ [arg0] "g" (ARG0), \ @@ -82,9 +82,9 @@ exec (const char *file) } int -join (pid_t pid) +wait (pid_t pid) { - return syscall1 (SYS_join, pid); + return syscall1 (SYS_wait, pid); } bool @@ -141,16 +141,16 @@ close (int fd) syscall1 (SYS_close, fd); } -bool -mmap (int fd, void *addr, unsigned length) +mapid_t +mmap (int fd, void *addr) { - return syscall3 (SYS_mmap, fd, addr, length); + return syscall2 (SYS_mmap, fd, addr); } -bool -munmap (void *addr, unsigned length) +void +munmap (mapid_t mapid) { - return syscall2 (SYS_munmap, addr, length); + syscall1 (SYS_munmap, mapid); } bool