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 ("pushl %[number]; int $0x30; addl $4, %%esp" \
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 ("pushl %[arg0]; pushl %[number]; int $0x30; addl $8, %%esp" \
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 ("pushl %[arg1]; pushl %[arg0]; " \
38 "pushl %[number]; int $0x30; addl $12, %%esp" \
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 ("pushl %[arg2]; pushl %[arg1]; pushl %[arg0]; " \
54 "pushl %[number]; int $0x30; addl $16, %%esp" \
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);
169 readdir (int fd, char name[READDIR_MAX_LEN + 1])
171 return syscall2 (SYS_READDIR, fd, name);
177 return syscall1 (SYS_ISDIR, fd);