syscall.x86_64.om (3978B)
1 enum { 2 O_RDONLY = 0, 3 O_WRONLY = 1, 4 O_RDWR = 2, 5 O_CREAT = 64, 6 O_TRUNC = 512, 7 O_APPEND = 1024, 8 O_DIRECTORY = 0x1000, 9 10 EINTR = 4, 11 EPIPE = 32, 12 13 AF_INET = 2, 14 SOCK_STREAM = 1, 15 16 POLLIN = 0x01, 17 POLLPRI = 0x02, 18 POLLOUT = 0x04, 19 POLLERR = 0x08, 20 POLLHUP = 0x10, 21 POLLNVAL = 0x20, 22 23 PROT_NONE = 0, 24 PROT_READ = 1, 25 PROT_WRITE = 2, 26 PROT_EXEC = 4, 27 28 MAP_PRIVATE = 2, 29 MAP_ANON = 32, 30 31 WNOHANG = 1, 32 33 SIG_DFL = 0, 34 SIG_IGN = 1, 35 36 SIGINT = 2, 37 SIGPIPE = 13, 38 SIGALRM = 14, 39 SIGCHLD = 17, 40 SIGWINCH = 28, 41 } 42 43 struct stat_x86_64 { 44 dev: int; 45 46 ino: int; 47 nlink: int; 48 uid_mode: int; 49 gid: int; 50 rdev: int; 51 size: int; 52 blksize: int; 53 blocks: int; 54 atime: int; 55 atime_nsec: int; 56 mtime: int; 57 mtime_nsec: int; 58 ctime: int; 59 ctime_nsec: int; 60 pad0: int; 61 pad1: int; 62 pad2: int; 63 } 64 65 func get_machine(): int { 66 return 0x3e; 67 } 68 69 func read(fd: int, buf: *byte, n: int): int { 70 return syscall(0, fd, buf as int, n, 0, 0, 0); 71 } 72 73 func write(fd: int, buf: *byte, n: int): int { 74 return syscall(1, fd, buf as int, n, 0, 0, 0); 75 } 76 77 func open(name: *byte, flags: int, mode: int): int { 78 return syscall(2, name as int, flags, mode, 0, 0, 0); 79 } 80 81 func close(fd: int): int { 82 return syscall(3, fd, 0, 0, 0, 0, 0); 83 } 84 85 func fstat(fd: int, sb: *stat): int { 86 var s: stat_x86_64; 87 var ret: int; 88 ret = syscall(5, fd, (&s) as int, 0, 0, 0, 0); 89 if ret == 0 { 90 sb.dev = s.dev; 91 sb.ino = s.ino; 92 sb.nlink = s.nlink; 93 sb.mode = s.uid_mode & (-1 >> 32); 94 sb.uid = s.uid_mode >> 32; 95 sb.gid = s.gid; 96 sb.rdev = s.rdev; 97 sb.size = s.size; 98 sb.blksize = s.blksize; 99 sb.blocks = s.blocks; 100 sb.atime = s.atime; 101 sb.atime_nsec = s.atime_nsec; 102 sb.mtime = s.mtime; 103 sb.mtime_nsec = s.mtime_nsec; 104 sb.ctime = s.ctime; 105 sb.ctime_nsec = s.ctime_nsec; 106 sb.pad1 = 0; 107 sb.pad2 = 0; 108 } 109 return ret; 110 } 111 112 func getrandom(buf: *byte, len: int, flags: int): int { 113 return syscall(318, buf as int, len, flags, 0, 0, 0); 114 } 115 116 func poll(pfd: *int, nfd: int, timeout: int): int { 117 return syscall(7, pfd as int, nfd, timeout, 0, 0, 0); 118 } 119 120 func lseek(fd: int, off: int, whence: int): int { 121 return syscall(8, fd, off, whence, 0, 0, 0); 122 } 123 124 func mmap(addr: int, len: int, prot: int, flags: int, fd: int, off: int): int { 125 return syscall(9, addr, len, prot, flags, fd, off); 126 } 127 128 func munmap(addr: int, len: int): int { 129 return syscall(11, addr, len, 0, 0, 0, 0); 130 } 131 132 func sigaction(sig: int, act: *sigaction, oact: *sigaction): int { 133 return syscall(13, sig, act as int, oact as int, 8, 0, 0); 134 } 135 136 func pipe(rfd: *int, wfd: *int): int { 137 var buf: int; 138 var ret: int; 139 ret = syscall(22, (&buf) as int, 0, 0, 0, 0, 0); 140 if ret == 0 { 141 *rfd = buf & (-1 >> 32); 142 *wfd = buf >> 32; 143 } 144 return ret; 145 } 146 147 func dup2(old: int, new: int): int { 148 return syscall(33, old, new, 0, 0, 0, 0); 149 } 150 151 func socket(pf: int, ty: int, pc: int): int { 152 return syscall(41, pf, ty, pc, 0, 0, 0); 153 } 154 155 func accept(fd: int, addr: *byte, len: *int): int { 156 return syscall(43, fd, addr as int, len as int, 0, 0, 0); 157 } 158 159 func bind(fd: int, addr: *byte, len: int): int { 160 return syscall(49, fd, addr as int, len as int, 0, 0, 0); 161 } 162 163 func listen(fd: int, backlog: int): int { 164 return syscall(50, fd, backlog, 0, 0, 0, 0); 165 } 166 167 func fork(): int { 168 return syscall(57, 0, 0, 0, 0, 0, 0); 169 } 170 171 func exec(cmd: *byte, argv: **byte, envp: **byte): int { 172 return syscall(59, cmd as int, argv as int, envp as int, 0, 0, 0); 173 } 174 175 func exit(n: int) { 176 syscall(60, n, 0, 0, 0, 0, 0); 177 } 178 179 func wait(pid: int, status: *int, flags: int): int { 180 var s: int; 181 var ret: int; 182 s = 0; 183 ret = syscall(61, pid, s as int, flags, 0, 0, 0); 184 if status { 185 *status = s & (-1 >> 32); 186 } 187 return ret; 188 } 189 190 func rename(oldname: *byte, newname: *byte): int { 191 return syscall(82, oldname as int, newname as int, 0, 0, 0, 0); 192 } 193 194 func mkdir(name: *byte): int { 195 return syscall(83, name as int, 0, 0, 0, 0, 0); 196 } 197 198 func unlink(name: *byte): int { 199 return syscall(87, name as int, 0, 0, 0, 0, 0); 200 } 201 202 func getdirents(fd: int, buf: *byte, len: int): int { 203 return syscall(217, fd, buf as int, len, 0, 0, 0); 204 }