2 #include "syscall-stub.h"
3 #include "../syscall-nr.h"
5 /* Invokes syscall NUMBER, passing no arguments, and returns the
6 return value as an `int'. */
7 #define syscall0(NUMBER) \
11 ("push %[number]; int 0x30; add %%esp, 4" \
13 : [number] "i" (NUMBER) \
18 /* Invokes syscall NUMBER, passing argument ARG0, and returns the
19 return value as an `int'. */
20 #define syscall1(NUMBER, ARG0) \
24 ("push %[arg0]; push %[number]; int 0x30; add %%esp, 8" \
26 : [number] "i" (NUMBER), \
32 /* Invokes syscall NUMBER, passing arguments ARG0 and ARG1, and
33 returns the return value as an `int'. */
34 #define syscall2(NUMBER, ARG0, ARG1) \
38 ("push %[arg1]; push %[arg0]; " \
39 "push %[number]; int 0x30; add %%esp, 12" \
41 : [number] "i" (NUMBER), \
48 /* Invokes syscall NUMBER, passing arguments ARG0, ARG1, and
49 ARG2, and returns the return value as an `int'. */
50 #define syscall3(NUMBER, ARG0, ARG1, ARG2) \
54 ("push %[arg2]; push %[arg1]; push %[arg0]; " \
55 "push %[number]; int 0x30; add %%esp, 16" \
57 : [number] "i" (NUMBER), \
75 syscall1 (SYS_exit, status);
80 exec (const char *file)
82 return (pid_t) syscall1 (SYS_exec, file);
88 return syscall1 (SYS_join, pid);
92 create (const char *file, unsigned initial_size)
94 return syscall2 (SYS_create, file, initial_size);
98 remove (const char *file)
100 return syscall1 (SYS_remove, file);
104 open (const char *file)
106 return syscall1 (SYS_open, file);
112 return syscall1 (SYS_filesize, fd);
116 read (int fd, void *buffer, unsigned size)
118 return syscall3 (SYS_read, fd, buffer, size);
122 write (int fd, const void *buffer, unsigned size)
124 return syscall3 (SYS_write, fd, buffer, size);
128 seek (int fd, unsigned position)
130 syscall2 (SYS_seek, fd, position);
136 return syscall1 (SYS_tell, fd);
142 syscall1 (SYS_close, fd);
146 mmap (int fd, void *addr, unsigned length)
148 return syscall3 (SYS_mmap, fd, addr, length);
152 munmap (void *addr, unsigned length)
154 return syscall2 (SYS_munmap, addr, length);
158 chdir (const char *dir)
160 return syscall1 (SYS_chdir, dir);
164 mkdir (const char *dir)
166 return syscall1 (SYS_mkdir, dir);
172 syscall0 (SYS_lsdir);