diff options
Diffstat (limited to 'src/include/unistd.h')
-rw-r--r-- | src/include/unistd.h | 254 |
1 files changed, 254 insertions, 0 deletions
diff --git a/src/include/unistd.h b/src/include/unistd.h new file mode 100644 index 0000000..956554a --- /dev/null +++ b/src/include/unistd.h | |||
@@ -0,0 +1,254 @@ | |||
1 | #ifndef _UNISTD_H | ||
2 | #define _UNISTD_H | ||
3 | |||
4 | /* ok, this may be a joke, but I'm working on it */ | ||
5 | #define _POSIX_VERSION 198808L | ||
6 | |||
7 | #define _POSIX_CHOWN_RESTRICTED /* only root can do a chown (I think..) */ | ||
8 | #define _POSIX_NO_TRUNC /* no pathname truncation (but see in kernel) */ | ||
9 | #define _POSIX_VDISABLE '\0' /* character to disable things like ^C */ | ||
10 | /*#define _POSIX_SAVED_IDS */ /* we'll get to this yet */ | ||
11 | /*#define _POSIX_JOB_CONTROL */ /* we aren't there quite yet. Soon hopefully */ | ||
12 | |||
13 | #define STDIN_FILENO 0 | ||
14 | #define STDOUT_FILENO 1 | ||
15 | #define STDERR_FILENO 2 | ||
16 | |||
17 | #ifndef NULL | ||
18 | #define NULL ((void *)0) | ||
19 | #endif | ||
20 | |||
21 | /* access */ | ||
22 | #define F_OK 0 | ||
23 | #define X_OK 1 | ||
24 | #define W_OK 2 | ||
25 | #define R_OK 4 | ||
26 | |||
27 | /* lseek */ | ||
28 | #define SEEK_SET 0 | ||
29 | #define SEEK_CUR 1 | ||
30 | #define SEEK_END 2 | ||
31 | |||
32 | /* _SC stands for System Configuration. We don't use them much */ | ||
33 | #define _SC_ARG_MAX 1 | ||
34 | #define _SC_CHILD_MAX 2 | ||
35 | #define _SC_CLOCKS_PER_SEC 3 | ||
36 | #define _SC_NGROUPS_MAX 4 | ||
37 | #define _SC_OPEN_MAX 5 | ||
38 | #define _SC_JOB_CONTROL 6 | ||
39 | #define _SC_SAVED_IDS 7 | ||
40 | #define _SC_VERSION 8 | ||
41 | |||
42 | /* more (possibly) configurable things - now pathnames */ | ||
43 | #define _PC_LINK_MAX 1 | ||
44 | #define _PC_MAX_CANON 2 | ||
45 | #define _PC_MAX_INPUT 3 | ||
46 | #define _PC_NAME_MAX 4 | ||
47 | #define _PC_PATH_MAX 5 | ||
48 | #define _PC_PIPE_BUF 6 | ||
49 | #define _PC_NO_TRUNC 7 | ||
50 | #define _PC_VDISABLE 8 | ||
51 | #define _PC_CHOWN_RESTRICTED 9 | ||
52 | |||
53 | #include <sys/stat.h> | ||
54 | #include <sys/times.h> | ||
55 | #include <sys/utsname.h> | ||
56 | #include <utime.h> | ||
57 | |||
58 | #ifdef __LIBRARY__ | ||
59 | |||
60 | #define __NR_setup 0 /* used only by init, to get system going */ | ||
61 | #define __NR_exit 1 | ||
62 | #define __NR_fork 2 | ||
63 | #define __NR_read 3 | ||
64 | #define __NR_write 4 | ||
65 | #define __NR_open 5 | ||
66 | #define __NR_close 6 | ||
67 | #define __NR_waitpid 7 | ||
68 | #define __NR_creat 8 | ||
69 | #define __NR_link 9 | ||
70 | #define __NR_unlink 10 | ||
71 | #define __NR_execve 11 | ||
72 | #define __NR_chdir 12 | ||
73 | #define __NR_time 13 | ||
74 | #define __NR_mknod 14 | ||
75 | #define __NR_chmod 15 | ||
76 | #define __NR_chown 16 | ||
77 | #define __NR_break 17 | ||
78 | #define __NR_stat 18 | ||
79 | #define __NR_lseek 19 | ||
80 | #define __NR_getpid 20 | ||
81 | #define __NR_mount 21 | ||
82 | #define __NR_umount 22 | ||
83 | #define __NR_setuid 23 | ||
84 | #define __NR_getuid 24 | ||
85 | #define __NR_stime 25 | ||
86 | #define __NR_ptrace 26 | ||
87 | #define __NR_alarm 27 | ||
88 | #define __NR_fstat 28 | ||
89 | #define __NR_pause 29 | ||
90 | #define __NR_utime 30 | ||
91 | #define __NR_stty 31 | ||
92 | #define __NR_gtty 32 | ||
93 | #define __NR_access 33 | ||
94 | #define __NR_nice 34 | ||
95 | #define __NR_ftime 35 | ||
96 | #define __NR_sync 36 | ||
97 | #define __NR_kill 37 | ||
98 | #define __NR_rename 38 | ||
99 | #define __NR_mkdir 39 | ||
100 | #define __NR_rmdir 40 | ||
101 | #define __NR_dup 41 | ||
102 | #define __NR_pipe 42 | ||
103 | #define __NR_times 43 | ||
104 | #define __NR_prof 44 | ||
105 | #define __NR_brk 45 | ||
106 | #define __NR_setgid 46 | ||
107 | #define __NR_getgid 47 | ||
108 | #define __NR_signal 48 | ||
109 | #define __NR_geteuid 49 | ||
110 | #define __NR_getegid 50 | ||
111 | #define __NR_acct 51 | ||
112 | #define __NR_phys 52 | ||
113 | #define __NR_lock 53 | ||
114 | #define __NR_ioctl 54 | ||
115 | #define __NR_fcntl 55 | ||
116 | #define __NR_mpx 56 | ||
117 | #define __NR_setpgid 57 | ||
118 | #define __NR_ulimit 58 | ||
119 | #define __NR_uname 59 | ||
120 | #define __NR_umask 60 | ||
121 | #define __NR_chroot 61 | ||
122 | #define __NR_ustat 62 | ||
123 | #define __NR_dup2 63 | ||
124 | #define __NR_getppid 64 | ||
125 | #define __NR_getpgrp 65 | ||
126 | #define __NR_setsid 66 | ||
127 | #define __NR_sigaction 67 | ||
128 | #define __NR_sgetmask 68 | ||
129 | #define __NR_ssetmask 69 | ||
130 | #define __NR_setreuid 70 | ||
131 | #define __NR_setregid 71 | ||
132 | |||
133 | #define _syscall0(type,name) \ | ||
134 | type name(void) \ | ||
135 | { \ | ||
136 | long __res; \ | ||
137 | __asm__ volatile ("int $0x80" \ | ||
138 | : "=a" (__res) \ | ||
139 | : "0" (__NR_##name)); \ | ||
140 | if (__res >= 0) \ | ||
141 | return (type) __res; \ | ||
142 | errno = -__res; \ | ||
143 | return -1; \ | ||
144 | } | ||
145 | |||
146 | #define _syscall1(type,name,atype,a) \ | ||
147 | type name(atype a) \ | ||
148 | { \ | ||
149 | long __res; \ | ||
150 | __asm__ volatile ("int $0x80" \ | ||
151 | : "=a" (__res) \ | ||
152 | : "0" (__NR_##name),"b" ((long)(a))); \ | ||
153 | if (__res >= 0) \ | ||
154 | return (type) __res; \ | ||
155 | errno = -__res; \ | ||
156 | return -1; \ | ||
157 | } | ||
158 | |||
159 | #define _syscall2(type,name,atype,a,btype,b) \ | ||
160 | type name(atype a,btype b) \ | ||
161 | { \ | ||
162 | long __res; \ | ||
163 | __asm__ volatile ("int $0x80" \ | ||
164 | : "=a" (__res) \ | ||
165 | : "0" (__NR_##name),"b" ((long)(a)),"c" ((long)(b))); \ | ||
166 | if (__res >= 0) \ | ||
167 | return (type) __res; \ | ||
168 | errno = -__res; \ | ||
169 | return -1; \ | ||
170 | } | ||
171 | |||
172 | #define _syscall3(type,name,atype,a,btype,b,ctype,c) \ | ||
173 | type name(atype a,btype b,ctype c) \ | ||
174 | { \ | ||
175 | long __res; \ | ||
176 | __asm__ volatile ("int $0x80" \ | ||
177 | : "=a" (__res) \ | ||
178 | : "0" (__NR_##name),"b" ((long)(a)),"c" ((long)(b)),"d" ((long)(c))); \ | ||
179 | if (__res>=0) \ | ||
180 | return (type) __res; \ | ||
181 | errno=-__res; \ | ||
182 | return -1; \ | ||
183 | } | ||
184 | |||
185 | #endif /* __LIBRARY__ */ | ||
186 | |||
187 | extern int errno; | ||
188 | |||
189 | int access(const char * filename, mode_t mode); | ||
190 | int acct(const char * filename); | ||
191 | int alarm(int sec); | ||
192 | int brk(void * end_data_segment); | ||
193 | void * sbrk(ptrdiff_t increment); | ||
194 | int chdir(const char * filename); | ||
195 | int chmod(const char * filename, mode_t mode); | ||
196 | int chown(const char * filename, uid_t owner, gid_t group); | ||
197 | int chroot(const char * filename); | ||
198 | int close(int fildes); | ||
199 | int creat(const char * filename, mode_t mode); | ||
200 | int dup(int fildes); | ||
201 | int execve(const char * filename, char ** argv, char ** envp); | ||
202 | int execv(const char * pathname, char ** argv); | ||
203 | int execvp(const char * file, char ** argv); | ||
204 | int execl(const char * pathname, char * arg0, ...); | ||
205 | int execlp(const char * file, char * arg0, ...); | ||
206 | int execle(const char * pathname, char * arg0, ...); | ||
207 | //volatile void exit(int status); | ||
208 | void _exit(int status); | ||
209 | //volatile void _exit(int status); | ||
210 | int fcntl(int fildes, int cmd, ...); | ||
211 | static int fork(void); | ||
212 | int getpid(void); | ||
213 | int getuid(void); | ||
214 | int geteuid(void); | ||
215 | int getgid(void); | ||
216 | int getegid(void); | ||
217 | int ioctl(int fildes, int cmd, ...); | ||
218 | int kill(pid_t pid, int signal); | ||
219 | int link(const char * filename1, const char * filename2); | ||
220 | int lseek(int fildes, off_t offset, int origin); | ||
221 | int mknod(const char * filename, mode_t mode, dev_t dev); | ||
222 | int mount(const char * specialfile, const char * dir, int rwflag); | ||
223 | int nice(int val); | ||
224 | int open(const char * filename, int flag, ...); | ||
225 | static int pause(void); | ||
226 | int pipe(int * fildes); | ||
227 | int read(int fildes, char * buf, off_t count); | ||
228 | int setpgrp(void); | ||
229 | int setpgid(pid_t pid,pid_t pgid); | ||
230 | int setuid(uid_t uid); | ||
231 | int setgid(gid_t gid); | ||
232 | void (*signal(int sig, void (*fn)(int)))(int); | ||
233 | int stat(const char * filename, struct stat * stat_buf); | ||
234 | int fstat(int fildes, struct stat * stat_buf); | ||
235 | int stime(time_t * tptr); | ||
236 | static int sync(void); | ||
237 | time_t time(time_t * tloc); | ||
238 | time_t times(struct tms * tbuf); | ||
239 | int ulimit(int cmd, long limit); | ||
240 | mode_t umask(mode_t mask); | ||
241 | int umount(const char * specialfile); | ||
242 | int uname(struct utsname * name); | ||
243 | int unlink(const char * filename); | ||
244 | int ustat(dev_t dev, struct ustat * ubuf); | ||
245 | int utime(const char * filename, struct utimbuf * times); | ||
246 | pid_t waitpid(pid_t pid,int * wait_stat,int options); | ||
247 | pid_t wait(int * wait_stat); | ||
248 | int write(int fildes, const char * buf, off_t count); | ||
249 | int dup2(int oldfd, int newfd); | ||
250 | int getppid(void); | ||
251 | pid_t getpgrp(void); | ||
252 | pid_t setsid(void); | ||
253 | |||
254 | #endif | ||