2 #include "../syscall-nr.h"
4 /* Invokes syscall NUMBER, passing no arguments, and returns the
5 return value as an `int'. */
6 #define syscall0(NUMBER) \
10 ("push %[number]; int 0x30; add %%esp, 4" \
12 : [number] "i" (NUMBER) \
17 /* Invokes syscall NUMBER, passing argument ARG0, and returns the
18 return value as an `int'. */
19 #define syscall1(NUMBER, ARG0) \
23 ("push %[arg0]; push %[number]; int 0x30; add %%esp, 8" \
25 : [number] "i" (NUMBER), \
31 /* Invokes syscall NUMBER, passing arguments ARG0 and ARG1, and
32 returns the return value as an `int'. */
33 #define syscall2(NUMBER, ARG0, ARG1) \
37 ("push %[arg1]; push %[arg0]; " \
38 "push %[number]; int 0x30; add %%esp, 12" \
40 : [number] "i" (NUMBER), \
47 /* Invokes syscall NUMBER, passing arguments ARG0, ARG1, and
48 ARG2, and returns the return value as an `int'. */
49 #define syscall3(NUMBER, ARG0, ARG1, ARG2) \
53 ("push %[arg2]; push %[arg1]; push %[arg0]; " \
54 "push %[number]; int 0x30; add %%esp, 16" \
56 : [number] "i" (NUMBER), \
74 syscall1 (SYS_exit, status);
79 exec (const char *file)
81 return (pid_t) syscall1 (SYS_exec, file);
87 return syscall1 (SYS_wait, pid);
91 create (const char *file, unsigned initial_size)
93 return syscall2 (SYS_create, file, initial_size);
97 remove (const char *file)
99 return syscall1 (SYS_remove, file);
103 open (const char *file)
105 return syscall1 (SYS_open, file);
111 return syscall1 (SYS_filesize, fd);
115 read (int fd, void *buffer, unsigned size)
117 return syscall3 (SYS_read, fd, buffer, size);
121 write (int fd, const void *buffer, unsigned size)
123 return syscall3 (SYS_write, fd, buffer, size);
127 seek (int fd, unsigned position)
129 syscall2 (SYS_seek, fd, position);
135 return syscall1 (SYS_tell, fd);
141 syscall1 (SYS_close, fd);
145 mmap (int fd, void *addr)
147 return syscall2 (SYS_mmap, fd, addr);
151 munmap (mapid_t mapid)
153 syscall1 (SYS_munmap, mapid);
157 chdir (const char *dir)
159 return syscall1 (SYS_chdir, dir);
163 mkdir (const char *dir)
165 return syscall1 (SYS_mkdir, dir);
171 syscall0 (SYS_lsdir);