frontend_syscall now accepts NULL for &errno
authorAndrew Waterman <waterman@ros-dev.(none)>
Fri, 26 Mar 2010 22:15:32 +0000 (15:15 -0700)
committerKevin Klues <klueska@cs.berkeley.edu>
Thu, 3 Nov 2011 00:35:38 +0000 (17:35 -0700)
This reduces lots of typing when we don't actually care about errno

kern/arch/sparc/console.c
kern/src/frontend.c

index e828617..3350158 100644 (file)
@@ -11,8 +11,7 @@ cons_init(void)
 void
 cputbuf(const char*COUNT(len) buf, int len)
 {
-       int32_t errno;
-       frontend_syscall(0,APPSERVER_SYSCALL_write,1,PADDR((int32_t)buf),len,0,&errno);
+       frontend_syscall(0,APPSERVER_SYSCALL_write,1,PADDR((int32_t)buf),len,0,0);
 }
 
 // Low-level console I/O
@@ -43,8 +42,8 @@ int
 cons_getc()
 {
        char ch;
-       int32_t errno;
-       int32_t ret = frontend_syscall(0,APPSERVER_SYSCALL_read,0,PADDR((int32_t)&ch),1,0,&errno);
+       uintptr_t paddr = PADDR((uintptr_t)&ch);
+       int32_t ret = frontend_syscall(0,APPSERVER_SYSCALL_read,0,paddr,1,0,0);
        if(ch == 0x7F)
                ch = '\b';
        return ret <= 0 ? 0 : ch;
index 75e6f80..9a2bcba 100644 (file)
@@ -126,9 +126,8 @@ void* kmalloc_errno(int len)
 
 error_t read_page(struct proc* p, int fd, physaddr_t pa, int pgoff)
 {
-       int errno;
-       int ret = frontend_syscall(p->pid,APPSERVER_SYSCALL_pread,fd,
-                               pa,PGSIZE,pgoff*PGSIZE,&errno);
+       int ret = frontend_syscall(p ? p->pid : 0,APPSERVER_SYSCALL_pread,fd,
+                               pa,PGSIZE,pgoff*PGSIZE,NULL);
 
        if(ret >= 0)
                memset(KADDR(pa)+ret,0,PGSIZE-ret);
@@ -137,15 +136,13 @@ error_t read_page(struct proc* p, int fd, physaddr_t pa, int pgoff)
 
 error_t open_file(struct proc* p, const char* path, int oflag, int mode)
 {
-       int errno;
        return frontend_syscall(p->pid,APPSERVER_SYSCALL_open,PADDR(path),
-                               oflag,mode,0,&errno);
+                               oflag,mode,0,NULL);
 }
 
 error_t close_file(struct proc* p, int fd)
 {
-       int errno;
-       return frontend_syscall(p->pid,APPSERVER_SYSCALL_close,fd,0,0,0,&errno);
+       return frontend_syscall(p->pid,APPSERVER_SYSCALL_close,fd,0,0,0,NULL);
 }
 
 int frontend_syscall_errno(struct proc* p, int n, int a0, int a1, int a2, int a3)
@@ -183,7 +180,8 @@ int32_t frontend_syscall(pid_t pid, int32_t syscall_num,
                ;
 
        ret = magic_mem[1];
-       *errno = magic_mem[2];
+       if(errno)
+               *errno = magic_mem[2];
 
        spin_unlock_irqsave(&lock);