* added compilers lcc and bcc (linux86)
[mascara-docs.git] / i86 / mtx / mtx / samples / LAST / USER / ucode.c
blobece7ecd763762e99a1c0c23e86ac28809ec9dea2
1 // ucode.c file : Interface to MTX kernel: syscall functions
3 #include "type.h"
5 #include "uio.c" // YOUR prints, printi, printx, printf functions
7 int getc()
9 int c;
10 read(0, &c, 1);
11 if (c==4) return 0;
12 return (c&0x7F);
15 int putc(c) int c;
17 write(1, &c, 1);
18 if (c=='\n')
19 putc('\r');
23 int getpid()
25 return syscall(0,0,0);
28 int fork()
30 return syscall(5, 0, 0);
33 int exec(file) char *file;
35 return syscall(6, file, 0);
39 int wait(status) int *status;
41 return syscall(20, status, 0);
44 int mkdir(name) char *name;
46 return syscall(21, name, 0);
49 int rmdir(name) char *name;
51 return syscall(22, name, 0);
54 int creat(name) char *name;
56 return syscall(23, name, 0);
59 int rm(name) char *name;
61 return syscall(24, name[1], 0);
65 int chdir(name) char *name;
67 return syscall(26, name, 0);
70 int open(file, mode) char *file; int mode;
72 return syscall(28, file, mode);
75 int close(fd) int fd;
77 return syscall(29, fd);
80 long lseek(fd, offset, ww) int fd; ulong offset
82 return syscall(30, fd, (ulong)offset);
85 int chmod(mode, filename) int mode; char *filename // mode=0xxx in Octal form
87 return syscall(33, mode, filename);
90 int chown(uid, filename) int uid; char *filename;
92 return syscall(34, uid, filename);
95 int read(fd, buf, nbytes) int fd, nbytes; char *buf;
97 return syscall(35, fd, buf, nbytes);
100 int write(fd, buf, nbytes) int fd, nbytes; char *buf;
102 return syscall(36, fd, buf, nbytes);
105 int stat(filename, sPtr) char *filename; struct stat *sPtr;
107 return syscall(38, filename, sPtr);
110 int getcwd(cwdname) char *cwdname;
112 syscall(39, cwdname, 0);
115 int pipe(pd) int *pd;
117 return syscall(40, pd, 0);
120 int dup(fd) int fd;
122 return syscall(41, fd, 0);
125 int dup2(fd,gd) int fd, gd;
127 return syscall(42, fd, gd);
130 int ps()
132 return syscall(43,0,0);
135 int getuid()
137 return syscall(44, 0);
140 int setuid(uid) int uid;
142 return syscall(45, uid);
145 int gettty(s) char *s;
147 return syscall(46, s, 0,0);
150 int settty(s) char *s;
152 return syscall(47, s, 0,0);
155 int fstat(fd, sPtr) int fd; struct stat *sPtr;
157 return syscall(48, fd, sPtr);
161 int kill(sig, pid) int sig, pid;
163 return syscall(50, sig, pid);
166 int signal(sig, catcher) ushort sig, catcher;
168 return syscall(51, sig, catcher);
171 int sleep(t) ushort t;
173 return syscall(52, t);
176 int settimer(t) ushort t;
178 return syscall(53, t);
182 int exit(ecode) ushort ecode;
184 syscall(99, ecode, 0);