| author | |
| committer | |
| log | 1829c093032764ef397a02d0d7512254f5bb4ad0 |
| tree | 4c379ce394993fc72da16058978d0ce98e74b7da |
| parent | 19659c3bd347471d3d55597bdc1c141e9e4a1ae1 |
8 files changed, 1346 insertions(+), 1957 deletions(-)
CMakeLists.txt+3| ... | ... | @@ -580,6 +580,9 @@ set(ZIG_STD_FILES |
| 580 | 580 | "os/linux/vdso.zig" |
| 581 | 581 | "os/linux/x86_64.zig" |
| 582 | 582 | "os/linux/arm64.zig" |
| 583 | "os/freebsd/errno.zig" | |
| 584 | "os/freebsd/index.zig" | |
| 585 | "os/freebsd/x86_64.zig" | |
| 583 | 586 | "os/path.zig" |
| 584 | 587 | "os/time.zig" |
| 585 | 588 | "os/windows/advapi32.zig" |
std/os/freebsd.zig deleted-572| ... | ... | @@ -1,572 +0,0 @@ |
| 1 | const c = @import("../c/index.zig"); | |
| 2 | const assert = @import("../debug.zig").assert; | |
| 3 | const builtin = @import("builtin"); | |
| 4 | const arch = switch (builtin.arch) { | |
| 5 | builtin.Arch.x86_64 => @import("x86_64.zig"), | |
| 6 | else => @compileError("unsupported arch"), | |
| 7 | }; | |
| 8 | pub use @import("errno.zig"); | |
| 9 | ||
| 10 | pub const PATH_MAX = 1024; | |
| 11 | ||
| 12 | pub const STDIN_FILENO = 0; | |
| 13 | pub const STDOUT_FILENO = 1; | |
| 14 | pub const STDERR_FILENO = 2; | |
| 15 | ||
| 16 | pub const PROT_NONE = 0; | |
| 17 | pub const PROT_READ = 1; | |
| 18 | pub const PROT_WRITE = 2; | |
| 19 | pub const PROT_EXEC = 4; | |
| 20 | ||
| 21 | pub const MAP_FAILED = @maxValue(usize); | |
| 22 | pub const MAP_SHARED = 0x0001; | |
| 23 | pub const MAP_PRIVATE = 0x0002; | |
| 24 | pub const MAP_FIXED = 0x0010; | |
| 25 | pub const MAP_STACK = 0x0400; | |
| 26 | pub const MAP_NOSYNC = 0x0800; | |
| 27 | pub const MAP_ANON = 0x1000; | |
| 28 | pub const MAP_ANONYMOUS = MAP_ANON; | |
| 29 | pub const MAP_FILE = 0; | |
| 30 | pub const MAP_NORESERVE = 0; | |
| 31 | ||
| 32 | pub const MAP_GUARD = 0x00002000; | |
| 33 | pub const MAP_EXCL = 0x00004000; | |
| 34 | pub const MAP_NOCORE = 0x00020000; | |
| 35 | pub const MAP_PREFAULT_READ = 0x00040000; | |
| 36 | pub const MAP_32BIT = 0x00080000; | |
| 37 | ||
| 38 | pub const WNOHANG = 1; | |
| 39 | pub const WUNTRACED = 2; | |
| 40 | pub const WSTOPPED = WUNTRACED; | |
| 41 | pub const WCONTINUED = 4; | |
| 42 | pub const WNOWAIT = 8; | |
| 43 | pub const WEXITED = 16; | |
| 44 | pub const WTRAPPED = 32; | |
| 45 | ||
| 46 | pub const SA_ONSTACK = 0x0001; | |
| 47 | pub const SA_RESTART = 0x0002; | |
| 48 | pub const SA_RESETHAND = 0x0004; | |
| 49 | pub const SA_NOCLDSTOP = 0x0008; | |
| 50 | pub const SA_NODEFER = 0x0010; | |
| 51 | pub const SA_NOCLDWAIT = 0x0020; | |
| 52 | pub const SA_SIGINFO = 0x0040; | |
| 53 | ||
| 54 | pub const SIGHUP = 1; | |
| 55 | pub const SIGINT = 2; | |
| 56 | pub const SIGQUIT = 3; | |
| 57 | pub const SIGILL = 4; | |
| 58 | pub const SIGTRAP = 5; | |
| 59 | pub const SIGABRT = 6; | |
| 60 | pub const SIGIOT = SIGABRT; | |
| 61 | pub const SIGEMT = 7; | |
| 62 | pub const SIGFPE = 8; | |
| 63 | pub const SIGKILL = 9; | |
| 64 | pub const SIGBUS = 10; | |
| 65 | pub const SIGSEGV = 11; | |
| 66 | pub const SIGSYS = 12; | |
| 67 | pub const SIGPIPE = 13; | |
| 68 | pub const SIGALRM = 14; | |
| 69 | pub const SIGTERM = 15; | |
| 70 | pub const SIGURG = 16; | |
| 71 | pub const SIGSTOP = 17; | |
| 72 | pub const SIGTSTP = 18; | |
| 73 | pub const SIGCONT = 19; | |
| 74 | pub const SIGCHLD = 20; | |
| 75 | pub const SIGTTIN = 21; | |
| 76 | pub const SIGTTOU = 22; | |
| 77 | pub const SIGIO = 23; | |
| 78 | pub const SIGXCPU = 24; | |
| 79 | pub const SIGXFSZ = 25; | |
| 80 | pub const SIGVTALRM = 26; | |
| 81 | pub const SIGPROF = 27; | |
| 82 | pub const SIGWINCH = 28; | |
| 83 | pub const SIGINFO = 29; | |
| 84 | pub const SIGUSR1 = 30; | |
| 85 | pub const SIGUSR2 = 31; | |
| 86 | pub const SIGTHR = 32; | |
| 87 | pub const SIGLWP = SIGTHR; | |
| 88 | pub const SIGLIBRT = 33; | |
| 89 | ||
| 90 | pub const SIGRTMIN = 65; | |
| 91 | pub const SIGRTMAX = 126; | |
| 92 | ||
| 93 | pub const O_RDONLY = 0o0; | |
| 94 | pub const O_WRONLY = 0o1; | |
| 95 | pub const O_RDWR = 0o2; | |
| 96 | pub const O_ACCMODE = 0o3; | |
| 97 | ||
| 98 | pub const O_CREAT = arch.O_CREAT; | |
| 99 | pub const O_EXCL = arch.O_EXCL; | |
| 100 | pub const O_NOCTTY = arch.O_NOCTTY; | |
| 101 | pub const O_TRUNC = arch.O_TRUNC; | |
| 102 | pub const O_APPEND = arch.O_APPEND; | |
| 103 | pub const O_NONBLOCK = arch.O_NONBLOCK; | |
| 104 | pub const O_DSYNC = arch.O_DSYNC; | |
| 105 | pub const O_SYNC = arch.O_SYNC; | |
| 106 | pub const O_RSYNC = arch.O_RSYNC; | |
| 107 | pub const O_DIRECTORY = arch.O_DIRECTORY; | |
| 108 | pub const O_NOFOLLOW = arch.O_NOFOLLOW; | |
| 109 | pub const O_CLOEXEC = arch.O_CLOEXEC; | |
| 110 | ||
| 111 | pub const O_ASYNC = arch.O_ASYNC; | |
| 112 | pub const O_DIRECT = arch.O_DIRECT; | |
| 113 | pub const O_LARGEFILE = arch.O_LARGEFILE; | |
| 114 | pub const O_NOATIME = arch.O_NOATIME; | |
| 115 | pub const O_PATH = arch.O_PATH; | |
| 116 | pub const O_TMPFILE = arch.O_TMPFILE; | |
| 117 | pub const O_NDELAY = arch.O_NDELAY; | |
| 118 | ||
| 119 | pub const SEEK_SET = 0; | |
| 120 | pub const SEEK_CUR = 1; | |
| 121 | pub const SEEK_END = 2; | |
| 122 | ||
| 123 | pub const SIG_BLOCK = 1; | |
| 124 | pub const SIG_UNBLOCK = 2; | |
| 125 | pub const SIG_SETMASK = 3; | |
| 126 | ||
| 127 | pub const SOCK_STREAM = 1; | |
| 128 | pub const SOCK_DGRAM = 2; | |
| 129 | pub const SOCK_RAW = 3; | |
| 130 | pub const SOCK_RDM = 4; | |
| 131 | pub const SOCK_SEQPACKET = 5; | |
| 132 | ||
| 133 | pub const SOCK_CLOEXEC = 0x10000000; | |
| 134 | pub const SOCK_NONBLOCK = 0x20000000; | |
| 135 | ||
| 136 | // TODO: From here | |
| 137 | pub const PROTO_ip = 0o000; | |
| 138 | pub const PROTO_icmp = 0o001; | |
| 139 | pub const PROTO_igmp = 0o002; | |
| 140 | pub const PROTO_ggp = 0o003; | |
| 141 | pub const PROTO_ipencap = 0o004; | |
| 142 | pub const PROTO_st = 0o005; | |
| 143 | pub const PROTO_tcp = 0o006; | |
| 144 | pub const PROTO_egp = 0o010; | |
| 145 | pub const PROTO_pup = 0o014; | |
| 146 | pub const PROTO_udp = 0o021; | |
| 147 | pub const PROTO_hmp = 0o024; | |
| 148 | pub const PROTO_xns_idp = 0o026; | |
| 149 | pub const PROTO_rdp = 0o033; | |
| 150 | pub const PROTO_iso_tp4 = 0o035; | |
| 151 | pub const PROTO_xtp = 0o044; | |
| 152 | pub const PROTO_ddp = 0o045; | |
| 153 | pub const PROTO_idpr_cmtp = 0o046; | |
| 154 | pub const PROTO_ipv6 = 0o051; | |
| 155 | pub const PROTO_ipv6_route = 0o053; | |
| 156 | pub const PROTO_ipv6_frag = 0o054; | |
| 157 | pub const PROTO_idrp = 0o055; | |
| 158 | pub const PROTO_rsvp = 0o056; | |
| 159 | pub const PROTO_gre = 0o057; | |
| 160 | pub const PROTO_esp = 0o062; | |
| 161 | pub const PROTO_ah = 0o063; | |
| 162 | pub const PROTO_skip = 0o071; | |
| 163 | pub const PROTO_ipv6_icmp = 0o072; | |
| 164 | pub const PROTO_ipv6_nonxt = 0o073; | |
| 165 | pub const PROTO_ipv6_opts = 0o074; | |
| 166 | pub const PROTO_rspf = 0o111; | |
| 167 | pub const PROTO_vmtp = 0o121; | |
| 168 | pub const PROTO_ospf = 0o131; | |
| 169 | pub const PROTO_ipip = 0o136; | |
| 170 | pub const PROTO_encap = 0o142; | |
| 171 | pub const PROTO_pim = 0o147; | |
| 172 | pub const PROTO_raw = 0o377; | |
| 173 | ||
| 174 | pub const PF_UNSPEC = 0; | |
| 175 | pub const PF_LOCAL = 1; | |
| 176 | pub const PF_UNIX = PF_LOCAL; | |
| 177 | pub const PF_FILE = PF_LOCAL; | |
| 178 | pub const PF_INET = 2; | |
| 179 | pub const PF_AX25 = 3; | |
| 180 | pub const PF_IPX = 4; | |
| 181 | pub const PF_APPLETALK = 5; | |
| 182 | pub const PF_NETROM = 6; | |
| 183 | pub const PF_BRIDGE = 7; | |
| 184 | pub const PF_ATMPVC = 8; | |
| 185 | pub const PF_X25 = 9; | |
| 186 | pub const PF_INET6 = 10; | |
| 187 | pub const PF_ROSE = 11; | |
| 188 | pub const PF_DECnet = 12; | |
| 189 | pub const PF_NETBEUI = 13; | |
| 190 | pub const PF_SECURITY = 14; | |
| 191 | pub const PF_KEY = 15; | |
| 192 | pub const PF_NETLINK = 16; | |
| 193 | pub const PF_ROUTE = PF_NETLINK; | |
| 194 | pub const PF_PACKET = 17; | |
| 195 | pub const PF_ASH = 18; | |
| 196 | pub const PF_ECONET = 19; | |
| 197 | pub const PF_ATMSVC = 20; | |
| 198 | pub const PF_RDS = 21; | |
| 199 | pub const PF_SNA = 22; | |
| 200 | pub const PF_IRDA = 23; | |
| 201 | pub const PF_PPPOX = 24; | |
| 202 | pub const PF_WANPIPE = 25; | |
| 203 | pub const PF_LLC = 26; | |
| 204 | pub const PF_IB = 27; | |
| 205 | pub const PF_MPLS = 28; | |
| 206 | pub const PF_CAN = 29; | |
| 207 | pub const PF_TIPC = 30; | |
| 208 | pub const PF_BLUETOOTH = 31; | |
| 209 | pub const PF_IUCV = 32; | |
| 210 | pub const PF_RXRPC = 33; | |
| 211 | pub const PF_ISDN = 34; | |
| 212 | pub const PF_PHONET = 35; | |
| 213 | pub const PF_IEEE802154 = 36; | |
| 214 | pub const PF_CAIF = 37; | |
| 215 | pub const PF_ALG = 38; | |
| 216 | pub const PF_NFC = 39; | |
| 217 | pub const PF_VSOCK = 40; | |
| 218 | pub const PF_MAX = 41; | |
| 219 | ||
| 220 | pub const AF_UNSPEC = PF_UNSPEC; | |
| 221 | pub const AF_LOCAL = PF_LOCAL; | |
| 222 | pub const AF_UNIX = AF_LOCAL; | |
| 223 | pub const AF_FILE = AF_LOCAL; | |
| 224 | pub const AF_INET = PF_INET; | |
| 225 | pub const AF_AX25 = PF_AX25; | |
| 226 | pub const AF_IPX = PF_IPX; | |
| 227 | pub const AF_APPLETALK = PF_APPLETALK; | |
| 228 | pub const AF_NETROM = PF_NETROM; | |
| 229 | pub const AF_BRIDGE = PF_BRIDGE; | |
| 230 | pub const AF_ATMPVC = PF_ATMPVC; | |
| 231 | pub const AF_X25 = PF_X25; | |
| 232 | pub const AF_INET6 = PF_INET6; | |
| 233 | pub const AF_ROSE = PF_ROSE; | |
| 234 | pub const AF_DECnet = PF_DECnet; | |
| 235 | pub const AF_NETBEUI = PF_NETBEUI; | |
| 236 | pub const AF_SECURITY = PF_SECURITY; | |
| 237 | pub const AF_KEY = PF_KEY; | |
| 238 | pub const AF_NETLINK = PF_NETLINK; | |
| 239 | pub const AF_ROUTE = PF_ROUTE; | |
| 240 | pub const AF_PACKET = PF_PACKET; | |
| 241 | pub const AF_ASH = PF_ASH; | |
| 242 | pub const AF_ECONET = PF_ECONET; | |
| 243 | pub const AF_ATMSVC = PF_ATMSVC; | |
| 244 | pub const AF_RDS = PF_RDS; | |
| 245 | pub const AF_SNA = PF_SNA; | |
| 246 | pub const AF_IRDA = PF_IRDA; | |
| 247 | pub const AF_PPPOX = PF_PPPOX; | |
| 248 | pub const AF_WANPIPE = PF_WANPIPE; | |
| 249 | pub const AF_LLC = PF_LLC; | |
| 250 | pub const AF_IB = PF_IB; | |
| 251 | pub const AF_MPLS = PF_MPLS; | |
| 252 | pub const AF_CAN = PF_CAN; | |
| 253 | pub const AF_TIPC = PF_TIPC; | |
| 254 | pub const AF_BLUETOOTH = PF_BLUETOOTH; | |
| 255 | pub const AF_IUCV = PF_IUCV; | |
| 256 | pub const AF_RXRPC = PF_RXRPC; | |
| 257 | pub const AF_ISDN = PF_ISDN; | |
| 258 | pub const AF_PHONET = PF_PHONET; | |
| 259 | pub const AF_IEEE802154 = PF_IEEE802154; | |
| 260 | pub const AF_CAIF = PF_CAIF; | |
| 261 | pub const AF_ALG = PF_ALG; | |
| 262 | pub const AF_NFC = PF_NFC; | |
| 263 | pub const AF_VSOCK = PF_VSOCK; | |
| 264 | pub const AF_MAX = PF_MAX; | |
| 265 | ||
| 266 | pub const DT_UNKNOWN = 0; | |
| 267 | pub const DT_FIFO = 1; | |
| 268 | pub const DT_CHR = 2; | |
| 269 | pub const DT_DIR = 4; | |
| 270 | pub const DT_BLK = 6; | |
| 271 | pub const DT_REG = 8; | |
| 272 | pub const DT_LNK = 10; | |
| 273 | pub const DT_SOCK = 12; | |
| 274 | pub const DT_WHT = 14; | |
| 275 | ||
| 276 | pub const TCGETS = 0x5401; | |
| 277 | pub const TCSETS = 0x5402; | |
| 278 | pub const TCSETSW = 0x5403; | |
| 279 | pub const TCSETSF = 0x5404; | |
| 280 | pub const TCGETA = 0x5405; | |
| 281 | pub const TCSETA = 0x5406; | |
| 282 | pub const TCSETAW = 0x5407; | |
| 283 | pub const TCSETAF = 0x5408; | |
| 284 | pub const TCSBRK = 0x5409; | |
| 285 | pub const TCXONC = 0x540A; | |
| 286 | pub const TCFLSH = 0x540B; | |
| 287 | pub const TIOCEXCL = 0x540C; | |
| 288 | pub const TIOCNXCL = 0x540D; | |
| 289 | pub const TIOCSCTTY = 0x540E; | |
| 290 | pub const TIOCGPGRP = 0x540F; | |
| 291 | pub const TIOCSPGRP = 0x5410; | |
| 292 | pub const TIOCOUTQ = 0x5411; | |
| 293 | pub const TIOCSTI = 0x5412; | |
| 294 | pub const TIOCGWINSZ = 0x5413; | |
| 295 | pub const TIOCSWINSZ = 0x5414; | |
| 296 | pub const TIOCMGET = 0x5415; | |
| 297 | pub const TIOCMBIS = 0x5416; | |
| 298 | pub const TIOCMBIC = 0x5417; | |
| 299 | pub const TIOCMSET = 0x5418; | |
| 300 | pub const TIOCGSOFTCAR = 0x5419; | |
| 301 | pub const TIOCSSOFTCAR = 0x541A; | |
| 302 | pub const FIONREAD = 0x541B; | |
| 303 | pub const TIOCINQ = FIONREAD; | |
| 304 | pub const TIOCLINUX = 0x541C; | |
| 305 | pub const TIOCCONS = 0x541D; | |
| 306 | pub const TIOCGSERIAL = 0x541E; | |
| 307 | pub const TIOCSSERIAL = 0x541F; | |
| 308 | pub const TIOCPKT = 0x5420; | |
| 309 | pub const FIONBIO = 0x5421; | |
| 310 | pub const TIOCNOTTY = 0x5422; | |
| 311 | pub const TIOCSETD = 0x5423; | |
| 312 | pub const TIOCGETD = 0x5424; | |
| 313 | pub const TCSBRKP = 0x5425; | |
| 314 | pub const TIOCSBRK = 0x5427; | |
| 315 | pub const TIOCCBRK = 0x5428; | |
| 316 | pub const TIOCGSID = 0x5429; | |
| 317 | pub const TIOCGRS485 = 0x542E; | |
| 318 | pub const TIOCSRS485 = 0x542F; | |
| 319 | pub const TIOCGPTN = 0x80045430; | |
| 320 | pub const TIOCSPTLCK = 0x40045431; | |
| 321 | pub const TIOCGDEV = 0x80045432; | |
| 322 | pub const TCGETX = 0x5432; | |
| 323 | pub const TCSETX = 0x5433; | |
| 324 | pub const TCSETXF = 0x5434; | |
| 325 | pub const TCSETXW = 0x5435; | |
| 326 | pub const TIOCSIG = 0x40045436; | |
| 327 | pub const TIOCVHANGUP = 0x5437; | |
| 328 | pub const TIOCGPKT = 0x80045438; | |
| 329 | pub const TIOCGPTLCK = 0x80045439; | |
| 330 | pub const TIOCGEXCL = 0x80045440; | |
| 331 | ||
| 332 | fn unsigned(s: i32) u32 { | |
| 333 | return @bitCast(u32, s); | |
| 334 | } | |
| 335 | fn signed(s: u32) i32 { | |
| 336 | return @bitCast(i32, s); | |
| 337 | } | |
| 338 | pub fn WEXITSTATUS(s: i32) i32 { | |
| 339 | return signed((unsigned(s) & 0xff00) >> 8); | |
| 340 | } | |
| 341 | pub fn WTERMSIG(s: i32) i32 { | |
| 342 | return signed(unsigned(s) & 0x7f); | |
| 343 | } | |
| 344 | pub fn WSTOPSIG(s: i32) i32 { | |
| 345 | return WEXITSTATUS(s); | |
| 346 | } | |
| 347 | pub fn WIFEXITED(s: i32) bool { | |
| 348 | return WTERMSIG(s) == 0; | |
| 349 | } | |
| 350 | pub fn WIFSTOPPED(s: i32) bool { | |
| 351 | return @intCast(u16, ((unsigned(s) & 0xffff) *% 0x10001) >> 8) > 0x7f00; | |
| 352 | } | |
| 353 | pub fn WIFSIGNALED(s: i32) bool { | |
| 354 | return (unsigned(s) & 0xffff) -% 1 < 0xff; | |
| 355 | } | |
| 356 | ||
| 357 | pub const winsize = extern struct { | |
| 358 | ws_row: u16, | |
| 359 | ws_col: u16, | |
| 360 | ws_xpixel: u16, | |
| 361 | ws_ypixel: u16, | |
| 362 | }; | |
| 363 | ||
| 364 | /// Get the errno from a syscall return value, or 0 for no error. | |
| 365 | pub fn getErrno(r: usize) usize { | |
| 366 | const signed_r = @bitCast(isize, r); | |
| 367 | return if (signed_r > -4096 and signed_r < 0) @intCast(usize, -signed_r) else 0; | |
| 368 | } | |
| 369 | ||
| 370 | pub fn dup2(old: i32, new: i32) usize { | |
| 371 | return arch.syscall2(arch.SYS_dup2, @intCast(usize, old), @intCast(usize, new)); | |
| 372 | } | |
| 373 | ||
| 374 | pub fn chdir(path: [*]const u8) usize { | |
| 375 | return arch.syscall1(arch.SYS_chdir, @ptrToInt(path)); | |
| 376 | } | |
| 377 | ||
| 378 | pub fn execve(path: [*]const u8, argv: [*]const ?[*]const u8, envp: [*]const ?[*]const u8) usize { | |
| 379 | return arch.syscall3(arch.SYS_execve, @ptrToInt(path), @ptrToInt(argv), @ptrToInt(envp)); | |
| 380 | } | |
| 381 | ||
| 382 | pub fn fork() usize { | |
| 383 | return arch.syscall0(arch.SYS_fork); | |
| 384 | } | |
| 385 | ||
| 386 | pub fn getcwd(buf: [*]u8, size: usize) usize { | |
| 387 | return arch.syscall2(arch.SYS___getcwd, @ptrToInt(buf), size); | |
| 388 | } | |
| 389 | ||
| 390 | pub fn getdents(fd: i32, dirp: [*]u8, count: usize) usize { | |
| 391 | return arch.syscall3(arch.SYS_getdents, @intCast(usize, fd), @ptrToInt(dirp), count); | |
| 392 | } | |
| 393 | ||
| 394 | pub fn isatty(fd: i32) bool { | |
| 395 | var wsz: winsize = undefined; | |
| 396 | return arch.syscall3(arch.SYS_ioctl, @intCast(usize, fd), TIOCGWINSZ, @ptrToInt(&wsz)) == 0; | |
| 397 | } | |
| 398 | ||
| 399 | pub fn readlink(noalias path: [*]const u8, noalias buf_ptr: [*]u8, buf_len: usize) usize { | |
| 400 | return arch.syscall3(arch.SYS_readlink, @ptrToInt(path), @ptrToInt(buf_ptr), buf_len); | |
| 401 | } | |
| 402 | ||
| 403 | pub fn mkdir(path: [*]const u8, mode: u32) usize { | |
| 404 | return arch.syscall2(arch.SYS_mkdir, @ptrToInt(path), mode); | |
| 405 | } | |
| 406 | ||
| 407 | pub fn mmap(address: ?*u8, length: usize, prot: usize, flags: usize, fd: i32, offset: isize) usize { | |
| 408 | return arch.syscall6(arch.SYS_mmap, @ptrToInt(address), length, prot, flags, @intCast(usize, fd), @bitCast(usize, offset)); | |
| 409 | } | |
| 410 | ||
| 411 | pub fn munmap(address: usize, length: usize) usize { | |
| 412 | return arch.syscall2(arch.SYS_munmap, address, length); | |
| 413 | } | |
| 414 | ||
| 415 | pub fn read(fd: i32, buf: [*]u8, count: usize) usize { | |
| 416 | return arch.syscall3(arch.SYS_read, @intCast(usize, fd), @ptrToInt(buf), count); | |
| 417 | } | |
| 418 | ||
| 419 | pub fn rmdir(path: [*]const u8) usize { | |
| 420 | return arch.syscall1(arch.SYS_rmdir, @ptrToInt(path)); | |
| 421 | } | |
| 422 | ||
| 423 | pub fn symlink(existing: [*]const u8, new: [*]const u8) usize { | |
| 424 | return arch.syscall2(arch.SYS_symlink, @ptrToInt(existing), @ptrToInt(new)); | |
| 425 | } | |
| 426 | ||
| 427 | pub fn pread(fd: i32, buf: [*]u8, count: usize, offset: usize) usize { | |
| 428 | return arch.syscall4(arch.SYS_pread, @intCast(usize, fd), @ptrToInt(buf), count, offset); | |
| 429 | } | |
| 430 | ||
| 431 | pub fn pipe(fd: *[2]i32) usize { | |
| 432 | return pipe2(fd, 0); | |
| 433 | } | |
| 434 | ||
| 435 | pub fn pipe2(fd: *[2]i32, flags: usize) usize { | |
| 436 | return arch.syscall2(arch.SYS_pipe2, @ptrToInt(fd), flags); | |
| 437 | } | |
| 438 | ||
| 439 | pub fn write(fd: i32, buf: [*]const u8, count: usize) usize { | |
| 440 | return arch.syscall3(arch.SYS_write, @intCast(usize, fd), @ptrToInt(buf), count); | |
| 441 | } | |
| 442 | ||
| 443 | pub fn pwrite(fd: i32, buf: [*]const u8, count: usize, offset: usize) usize { | |
| 444 | return arch.syscall4(arch.SYS_pwrite, @intCast(usize, fd), @ptrToInt(buf), count, offset); | |
| 445 | } | |
| 446 | ||
| 447 | pub fn rename(old: [*]const u8, new: [*]const u8) usize { | |
| 448 | return arch.syscall2(arch.SYS_rename, @ptrToInt(old), @ptrToInt(new)); | |
| 449 | } | |
| 450 | ||
| 451 | pub fn open(path: [*]const u8, flags: u32, perm: usize) usize { | |
| 452 | return arch.syscall3(arch.SYS_open, @ptrToInt(path), flags, perm); | |
| 453 | } | |
| 454 | ||
| 455 | pub fn create(path: [*]const u8, perm: usize) usize { | |
| 456 | return arch.syscall2(arch.SYS_creat, @ptrToInt(path), perm); | |
| 457 | } | |
| 458 | ||
| 459 | pub fn openat(dirfd: i32, path: [*]const u8, flags: usize, mode: usize) usize { | |
| 460 | return arch.syscall4(arch.SYS_openat, @intCast(usize, dirfd), @ptrToInt(path), flags, mode); | |
| 461 | } | |
| 462 | ||
| 463 | pub fn close(fd: i32) usize { | |
| 464 | return arch.syscall1(arch.SYS_close, @intCast(usize, fd)); | |
| 465 | } | |
| 466 | ||
| 467 | pub fn lseek(fd: i32, offset: isize, ref_pos: usize) usize { | |
| 468 | return arch.syscall3(arch.SYS_lseek, @intCast(usize, fd), @bitCast(usize, offset), ref_pos); | |
| 469 | } | |
| 470 | ||
| 471 | pub fn exit(status: i32) noreturn { | |
| 472 | _ = arch.syscall1(arch.SYS_exit, @bitCast(usize, isize(status))); | |
| 473 | unreachable; | |
| 474 | } | |
| 475 | ||
| 476 | pub fn getrandom(buf: &u8, count: usize, flags: u32) usize { | |
| 477 | return arch.syscall3(arch.SYS_getrandom, @ptrToInt(buf), count, @bitCast(usize, flags)); | |
| 478 | } | |
| 479 | ||
| 480 | pub fn kill(pid: i32, sig: i32) usize { | |
| 481 | return arch.syscall2(arch.SYS_kill, @bitCast(usize, @intCast(isize, pid)), @intCast(usize, sig)); | |
| 482 | } | |
| 483 | ||
| 484 | pub fn unlink(path: [*]const u8) usize { | |
| 485 | return arch.syscall1(arch.SYS_unlink, @ptrToInt(path)); | |
| 486 | } | |
| 487 | ||
| 488 | pub fn waitpid(pid: i32, status: *i32, options: i32) usize { | |
| 489 | return arch.syscall4(arch.SYS_wait4, @bitCast(usize, isize(pid)), @ptrToInt(status), @bitCast(usize, isize(options)), 0); | |
| 490 | } | |
| 491 | ||
| 492 | pub fn nanosleep(req: *const timespec, rem: ?*timespec) usize { | |
| 493 | return arch.syscall2(arch.SYS_nanosleep, @ptrToInt(req), @ptrToInt(rem)); | |
| 494 | } | |
| 495 | ||
| 496 | pub fn setuid(uid: u32) usize { | |
| 497 | return arch.syscall1(arch.SYS_setuid, uid); | |
| 498 | } | |
| 499 | ||
| 500 | pub fn setgid(gid: u32) usize { | |
| 501 | return arch.syscall1(arch.SYS_setgid, gid); | |
| 502 | } | |
| 503 | ||
| 504 | pub fn setreuid(ruid: u32, euid: u32) usize { | |
| 505 | return arch.syscall2(arch.SYS_setreuid, ruid, euid); | |
| 506 | } | |
| 507 | ||
| 508 | pub fn setregid(rgid: u32, egid: u32) usize { | |
| 509 | return arch.syscall2(arch.SYS_setregid, rgid, egid); | |
| 510 | } | |
| 511 | ||
| 512 | pub fn sigprocmask(flags: u32, noalias set: *const sigset_t, noalias oldset: ?*sigset_t) usize { | |
| 513 | // TODO: Implement | |
| 514 | return 0; | |
| 515 | } | |
| 516 | ||
| 517 | pub fn sigaction(sig: u6, noalias act: *const Sigaction, noalias oact: ?*Sigaction) usize { | |
| 518 | // TODO: Implement | |
| 519 | return 0; | |
| 520 | } | |
| 521 | ||
| 522 | const NSIG = 65; | |
| 523 | const sigset_t = [128 / @sizeOf(usize)]usize; | |
| 524 | const all_mask = []usize{@maxValue(usize)}; | |
| 525 | const app_mask = []usize{0xfffffffc7fffffff}; | |
| 526 | ||
| 527 | /// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall. | |
| 528 | pub const Sigaction = struct { | |
| 529 | // TODO: Adjust to use freebsd struct layout | |
| 530 | handler: extern fn (i32) void, | |
| 531 | mask: sigset_t, | |
| 532 | flags: u32, | |
| 533 | }; | |
| 534 | ||
| 535 | pub const SIG_ERR = @intToPtr(extern fn (i32) void, @maxValue(usize)); | |
| 536 | pub const SIG_DFL = @intToPtr(extern fn (i32) void, 0); | |
| 537 | pub const SIG_IGN = @intToPtr(extern fn (i32) void, 1); | |
| 538 | pub const empty_sigset = []usize{0} ** sigset_t.len; | |
| 539 | ||
| 540 | pub fn raise(sig: i32) usize { | |
| 541 | // TODO implement, see linux equivalent for what we want to try and do | |
| 542 | return 0; | |
| 543 | } | |
| 544 | ||
| 545 | fn blockAllSignals(set: *sigset_t) void { | |
| 546 | // TODO implement | |
| 547 | } | |
| 548 | ||
| 549 | fn blockAppSignals(set: *sigset_t) void { | |
| 550 | // TODO implement | |
| 551 | } | |
| 552 | ||
| 553 | fn restoreSignals(set: *sigset_t) void { | |
| 554 | // TODO implement | |
| 555 | } | |
| 556 | ||
| 557 | pub fn sigaddset(set: *sigset_t, sig: u6) void { | |
| 558 | const s = sig - 1; | |
| 559 | (*set)[usize(s) / usize.bit_count] |= usize(1) << (s & (usize.bit_count - 1)); | |
| 560 | } | |
| 561 | ||
| 562 | pub fn sigismember(set: *const sigset_t, sig: u6) bool { | |
| 563 | const s = sig - 1; | |
| 564 | return ((*set)[usize(s) / usize.bit_count] & (usize(1) << (s & (usize.bit_count - 1)))) != 0; | |
| 565 | } | |
| 566 | ||
| 567 | pub const Stat = arch.Stat; | |
| 568 | pub const timespec = arch.timespec; | |
| 569 | ||
| 570 | pub fn fstat(fd: i32, stat_buf: *Stat) usize { | |
| 571 | return arch.syscall2(arch.SYS_fstat, @intCast(usize, fd), @ptrToInt(stat_buf)); | |
| 572 | } |
std/os/freebsd/errno.zig created+121| ... | ... | @@ -0,0 +1,121 @@ |
| 1 | pub const EPERM = 1; // Operation not permitted | |
| 2 | pub const ENOENT = 2; // No such file or directory | |
| 3 | pub const ESRCH = 3; // No such process | |
| 4 | pub const EINTR = 4; // Interrupted system call | |
| 5 | pub const EIO = 5; // Input/output error | |
| 6 | pub const ENXIO = 6; // Device not configured | |
| 7 | pub const E2BIG = 7; // Argument list too long | |
| 8 | pub const ENOEXEC = 8; // Exec format error | |
| 9 | pub const EBADF = 9; // Bad file descriptor | |
| 10 | pub const ECHILD = 10; // No child processes | |
| 11 | pub const EDEADLK = 11; // Resource deadlock avoided | |
| 12 | // 11 was EAGAIN | |
| 13 | pub const ENOMEM = 12; // Cannot allocate memory | |
| 14 | pub const EACCES = 13; // Permission denied | |
| 15 | pub const EFAULT = 14; // Bad address | |
| 16 | pub const ENOTBLK = 15; // Block device required | |
| 17 | pub const EBUSY = 16; // Device busy | |
| 18 | pub const EEXIST = 17; // File exists | |
| 19 | pub const EXDEV = 18; // Cross-device link | |
| 20 | pub const ENODEV = 19; // Operation not supported by device | |
| 21 | pub const ENOTDIR = 20; // Not a directory | |
| 22 | pub const EISDIR = 21; // Is a directory | |
| 23 | pub const EINVAL = 22; // Invalid argument | |
| 24 | pub const ENFILE = 23; // Too many open files in system | |
| 25 | pub const EMFILE = 24; // Too many open files | |
| 26 | pub const ENOTTY = 25; // Inappropriate ioctl for device | |
| 27 | pub const ETXTBSY = 26; // Text file busy | |
| 28 | pub const EFBIG = 27; // File too large | |
| 29 | pub const ENOSPC = 28; // No space left on device | |
| 30 | pub const ESPIPE = 29; // Illegal seek | |
| 31 | pub const EROFS = 30; // Read-only filesystem | |
| 32 | pub const EMLINK = 31; // Too many links | |
| 33 | pub const EPIPE = 32; // Broken pipe | |
| 34 | ||
| 35 | // math software | |
| 36 | pub const EDOM = 33; // Numerical argument out of domain | |
| 37 | pub const ERANGE = 34; // Result too large | |
| 38 | ||
| 39 | // non-blocking and interrupt i/o | |
| 40 | pub const EAGAIN = 35; // Resource temporarily unavailable | |
| 41 | pub const EWOULDBLOCK = EAGAIN; // Operation would block | |
| 42 | pub const EINPROGRESS = 36; // Operation now in progress | |
| 43 | pub const EALREADY = 37; // Operation already in progress | |
| 44 | ||
| 45 | // ipc/network software -- argument errors | |
| 46 | pub const ENOTSOCK = 38; // Socket operation on non-socket | |
| 47 | pub const EDESTADDRREQ = 39; // Destination address required | |
| 48 | pub const EMSGSIZE = 40; // Message too long | |
| 49 | pub const EPROTOTYPE = 41; // Protocol wrong type for socket | |
| 50 | pub const ENOPROTOOPT = 42; // Protocol not available | |
| 51 | pub const EPROTONOSUPPORT = 43; // Protocol not supported | |
| 52 | pub const ESOCKTNOSUPPORT = 44; // Socket type not supported | |
| 53 | pub const EOPNOTSUPP = 45; // Operation not supported | |
| 54 | pub const ENOTSUP = EOPNOTSUPP; // Operation not supported | |
| 55 | pub const EPFNOSUPPORT = 46; // Protocol family not supported | |
| 56 | pub const EAFNOSUPPORT = 47; // Address family not supported by protocol family | |
| 57 | pub const EADDRINUSE = 48; // Address already in use | |
| 58 | pub const EADDRNOTAVAIL = 49; // Can't assign requested address | |
| 59 | ||
| 60 | // ipc/network software -- operational errors | |
| 61 | pub const ENETDOWN = 50; // Network is down | |
| 62 | pub const ENETUNREACH = 51; // Network is unreachable | |
| 63 | pub const ENETRESET = 52; // Network dropped connection on reset | |
| 64 | pub const ECONNABORTED = 53; // Software caused connection abort | |
| 65 | pub const ECONNRESET = 54; // Connection reset by peer | |
| 66 | pub const ENOBUFS = 55; // No buffer space available | |
| 67 | pub const EISCONN = 56; // Socket is already connected | |
| 68 | pub const ENOTCONN = 57; // Socket is not connected | |
| 69 | pub const ESHUTDOWN = 58; // Can't send after socket shutdown | |
| 70 | pub const ETOOMANYREFS = 59; // Too many references: can't splice | |
| 71 | pub const ETIMEDOUT = 60; // Operation timed out | |
| 72 | pub const ECONNREFUSED = 61; // Connection refused | |
| 73 | ||
| 74 | pub const ELOOP = 62; // Too many levels of symbolic links | |
| 75 | pub const ENAMETOOLONG = 63; // File name too long | |
| 76 | ||
| 77 | // should be rearranged | |
| 78 | pub const EHOSTDOWN = 64; // Host is down | |
| 79 | pub const EHOSTUNREACH = 65; // No route to host | |
| 80 | pub const ENOTEMPTY = 66; // Directory not empty | |
| 81 | ||
| 82 | // quotas & mush | |
| 83 | pub const EPROCLIM = 67; // Too many processes | |
| 84 | pub const EUSERS = 68; // Too many users | |
| 85 | pub const EDQUOT = 69; // Disc quota exceeded | |
| 86 | ||
| 87 | // Network File System | |
| 88 | pub const ESTALE = 70; // Stale NFS file handle | |
| 89 | pub const EREMOTE = 71; // Too many levels of remote in path | |
| 90 | pub const EBADRPC = 72; // RPC struct is bad | |
| 91 | pub const ERPCMISMATCH = 73; // RPC version wrong | |
| 92 | pub const EPROGUNAVAIL = 74; // RPC prog. not avail | |
| 93 | pub const EPROGMISMATCH = 75; // Program version wrong | |
| 94 | pub const EPROCUNAVAIL = 76; // Bad procedure for program | |
| 95 | ||
| 96 | pub const ENOLCK = 77; // No locks available | |
| 97 | pub const ENOSYS = 78; // Function not implemented | |
| 98 | ||
| 99 | pub const EFTYPE = 79; // Inappropriate file type or format | |
| 100 | pub const EAUTH = 80; // Authentication error | |
| 101 | pub const ENEEDAUTH = 81; // Need authenticator | |
| 102 | pub const EIDRM = 82; // Identifier removed | |
| 103 | pub const ENOMSG = 83; // No message of desired type | |
| 104 | pub const EOVERFLOW = 84; // Value too large to be stored in data type | |
| 105 | pub const ECANCELED = 85; // Operation canceled | |
| 106 | pub const EILSEQ = 86; // Illegal byte sequence | |
| 107 | pub const ENOATTR = 87; // Attribute not found | |
| 108 | ||
| 109 | pub const EDOOFUS = 88; // Programming error | |
| 110 | ||
| 111 | pub const EBADMSG = 89; // Bad message | |
| 112 | pub const EMULTIHOP = 90; // Multihop attempted | |
| 113 | pub const ENOLINK = 91; // Link has been severed | |
| 114 | pub const EPROTO = 92; // Protocol error | |
| 115 | ||
| 116 | pub const ENOTCAPABLE = 93; // Capabilities insufficient | |
| 117 | pub const ECAPMODE = 94; // Not permitted in capability mode | |
| 118 | pub const ENOTRECOVERABLE = 95; // State not recoverable | |
| 119 | pub const EOWNERDEAD = 96; // Previous owner died | |
| 120 | ||
| 121 | pub const ELAST = 96; // Must be equal largest errno |
std/os/freebsd/index.zig created+571| ... | ... | @@ -0,0 +1,571 @@ |
| 1 | const assert = @import("../debug.zig").assert; | |
| 2 | const builtin = @import("builtin"); | |
| 3 | const arch = switch (builtin.arch) { | |
| 4 | builtin.Arch.x86_64 => @import("x86_64.zig"), | |
| 5 | else => @compileError("unsupported arch"), | |
| 6 | }; | |
| 7 | pub use @import("errno.zig"); | |
| 8 | ||
| 9 | pub const PATH_MAX = 1024; | |
| 10 | ||
| 11 | pub const STDIN_FILENO = 0; | |
| 12 | pub const STDOUT_FILENO = 1; | |
| 13 | pub const STDERR_FILENO = 2; | |
| 14 | ||
| 15 | pub const PROT_NONE = 0; | |
| 16 | pub const PROT_READ = 1; | |
| 17 | pub const PROT_WRITE = 2; | |
| 18 | pub const PROT_EXEC = 4; | |
| 19 | ||
| 20 | pub const MAP_FAILED = @maxValue(usize); | |
| 21 | pub const MAP_SHARED = 0x0001; | |
| 22 | pub const MAP_PRIVATE = 0x0002; | |
| 23 | pub const MAP_FIXED = 0x0010; | |
| 24 | pub const MAP_STACK = 0x0400; | |
| 25 | pub const MAP_NOSYNC = 0x0800; | |
| 26 | pub const MAP_ANON = 0x1000; | |
| 27 | pub const MAP_ANONYMOUS = MAP_ANON; | |
| 28 | pub const MAP_FILE = 0; | |
| 29 | pub const MAP_NORESERVE = 0; | |
| 30 | ||
| 31 | pub const MAP_GUARD = 0x00002000; | |
| 32 | pub const MAP_EXCL = 0x00004000; | |
| 33 | pub const MAP_NOCORE = 0x00020000; | |
| 34 | pub const MAP_PREFAULT_READ = 0x00040000; | |
| 35 | pub const MAP_32BIT = 0x00080000; | |
| 36 | ||
| 37 | pub const WNOHANG = 1; | |
| 38 | pub const WUNTRACED = 2; | |
| 39 | pub const WSTOPPED = WUNTRACED; | |
| 40 | pub const WCONTINUED = 4; | |
| 41 | pub const WNOWAIT = 8; | |
| 42 | pub const WEXITED = 16; | |
| 43 | pub const WTRAPPED = 32; | |
| 44 | ||
| 45 | pub const SA_ONSTACK = 0x0001; | |
| 46 | pub const SA_RESTART = 0x0002; | |
| 47 | pub const SA_RESETHAND = 0x0004; | |
| 48 | pub const SA_NOCLDSTOP = 0x0008; | |
| 49 | pub const SA_NODEFER = 0x0010; | |
| 50 | pub const SA_NOCLDWAIT = 0x0020; | |
| 51 | pub const SA_SIGINFO = 0x0040; | |
| 52 | ||
| 53 | pub const SIGHUP = 1; | |
| 54 | pub const SIGINT = 2; | |
| 55 | pub const SIGQUIT = 3; | |
| 56 | pub const SIGILL = 4; | |
| 57 | pub const SIGTRAP = 5; | |
| 58 | pub const SIGABRT = 6; | |
| 59 | pub const SIGIOT = SIGABRT; | |
| 60 | pub const SIGEMT = 7; | |
| 61 | pub const SIGFPE = 8; | |
| 62 | pub const SIGKILL = 9; | |
| 63 | pub const SIGBUS = 10; | |
| 64 | pub const SIGSEGV = 11; | |
| 65 | pub const SIGSYS = 12; | |
| 66 | pub const SIGPIPE = 13; | |
| 67 | pub const SIGALRM = 14; | |
| 68 | pub const SIGTERM = 15; | |
| 69 | pub const SIGURG = 16; | |
| 70 | pub const SIGSTOP = 17; | |
| 71 | pub const SIGTSTP = 18; | |
| 72 | pub const SIGCONT = 19; | |
| 73 | pub const SIGCHLD = 20; | |
| 74 | pub const SIGTTIN = 21; | |
| 75 | pub const SIGTTOU = 22; | |
| 76 | pub const SIGIO = 23; | |
| 77 | pub const SIGXCPU = 24; | |
| 78 | pub const SIGXFSZ = 25; | |
| 79 | pub const SIGVTALRM = 26; | |
| 80 | pub const SIGPROF = 27; | |
| 81 | pub const SIGWINCH = 28; | |
| 82 | pub const SIGINFO = 29; | |
| 83 | pub const SIGUSR1 = 30; | |
| 84 | pub const SIGUSR2 = 31; | |
| 85 | pub const SIGTHR = 32; | |
| 86 | pub const SIGLWP = SIGTHR; | |
| 87 | pub const SIGLIBRT = 33; | |
| 88 | ||
| 89 | pub const SIGRTMIN = 65; | |
| 90 | pub const SIGRTMAX = 126; | |
| 91 | ||
| 92 | pub const O_RDONLY = 0o0; | |
| 93 | pub const O_WRONLY = 0o1; | |
| 94 | pub const O_RDWR = 0o2; | |
| 95 | pub const O_ACCMODE = 0o3; | |
| 96 | ||
| 97 | pub const O_CREAT = arch.O_CREAT; | |
| 98 | pub const O_EXCL = arch.O_EXCL; | |
| 99 | pub const O_NOCTTY = arch.O_NOCTTY; | |
| 100 | pub const O_TRUNC = arch.O_TRUNC; | |
| 101 | pub const O_APPEND = arch.O_APPEND; | |
| 102 | pub const O_NONBLOCK = arch.O_NONBLOCK; | |
| 103 | pub const O_DSYNC = arch.O_DSYNC; | |
| 104 | pub const O_SYNC = arch.O_SYNC; | |
| 105 | pub const O_RSYNC = arch.O_RSYNC; | |
| 106 | pub const O_DIRECTORY = arch.O_DIRECTORY; | |
| 107 | pub const O_NOFOLLOW = arch.O_NOFOLLOW; | |
| 108 | pub const O_CLOEXEC = arch.O_CLOEXEC; | |
| 109 | ||
| 110 | pub const O_ASYNC = arch.O_ASYNC; | |
| 111 | pub const O_DIRECT = arch.O_DIRECT; | |
| 112 | pub const O_LARGEFILE = arch.O_LARGEFILE; | |
| 113 | pub const O_NOATIME = arch.O_NOATIME; | |
| 114 | pub const O_PATH = arch.O_PATH; | |
| 115 | pub const O_TMPFILE = arch.O_TMPFILE; | |
| 116 | pub const O_NDELAY = arch.O_NDELAY; | |
| 117 | ||
| 118 | pub const SEEK_SET = 0; | |
| 119 | pub const SEEK_CUR = 1; | |
| 120 | pub const SEEK_END = 2; | |
| 121 | ||
| 122 | pub const SIG_BLOCK = 1; | |
| 123 | pub const SIG_UNBLOCK = 2; | |
| 124 | pub const SIG_SETMASK = 3; | |
| 125 | ||
| 126 | pub const SOCK_STREAM = 1; | |
| 127 | pub const SOCK_DGRAM = 2; | |
| 128 | pub const SOCK_RAW = 3; | |
| 129 | pub const SOCK_RDM = 4; | |
| 130 | pub const SOCK_SEQPACKET = 5; | |
| 131 | ||
| 132 | pub const SOCK_CLOEXEC = 0x10000000; | |
| 133 | pub const SOCK_NONBLOCK = 0x20000000; | |
| 134 | ||
| 135 | // TODO: From here | |
| 136 | pub const PROTO_ip = 0o000; | |
| 137 | pub const PROTO_icmp = 0o001; | |
| 138 | pub const PROTO_igmp = 0o002; | |
| 139 | pub const PROTO_ggp = 0o003; | |
| 140 | pub const PROTO_ipencap = 0o004; | |
| 141 | pub const PROTO_st = 0o005; | |
| 142 | pub const PROTO_tcp = 0o006; | |
| 143 | pub const PROTO_egp = 0o010; | |
| 144 | pub const PROTO_pup = 0o014; | |
| 145 | pub const PROTO_udp = 0o021; | |
| 146 | pub const PROTO_hmp = 0o024; | |
| 147 | pub const PROTO_xns_idp = 0o026; | |
| 148 | pub const PROTO_rdp = 0o033; | |
| 149 | pub const PROTO_iso_tp4 = 0o035; | |
| 150 | pub const PROTO_xtp = 0o044; | |
| 151 | pub const PROTO_ddp = 0o045; | |
| 152 | pub const PROTO_idpr_cmtp = 0o046; | |
| 153 | pub const PROTO_ipv6 = 0o051; | |
| 154 | pub const PROTO_ipv6_route = 0o053; | |
| 155 | pub const PROTO_ipv6_frag = 0o054; | |
| 156 | pub const PROTO_idrp = 0o055; | |
| 157 | pub const PROTO_rsvp = 0o056; | |
| 158 | pub const PROTO_gre = 0o057; | |
| 159 | pub const PROTO_esp = 0o062; | |
| 160 | pub const PROTO_ah = 0o063; | |
| 161 | pub const PROTO_skip = 0o071; | |
| 162 | pub const PROTO_ipv6_icmp = 0o072; | |
| 163 | pub const PROTO_ipv6_nonxt = 0o073; | |
| 164 | pub const PROTO_ipv6_opts = 0o074; | |
| 165 | pub const PROTO_rspf = 0o111; | |
| 166 | pub const PROTO_vmtp = 0o121; | |
| 167 | pub const PROTO_ospf = 0o131; | |
| 168 | pub const PROTO_ipip = 0o136; | |
| 169 | pub const PROTO_encap = 0o142; | |
| 170 | pub const PROTO_pim = 0o147; | |
| 171 | pub const PROTO_raw = 0o377; | |
| 172 | ||
| 173 | pub const PF_UNSPEC = 0; | |
| 174 | pub const PF_LOCAL = 1; | |
| 175 | pub const PF_UNIX = PF_LOCAL; | |
| 176 | pub const PF_FILE = PF_LOCAL; | |
| 177 | pub const PF_INET = 2; | |
| 178 | pub const PF_AX25 = 3; | |
| 179 | pub const PF_IPX = 4; | |
| 180 | pub const PF_APPLETALK = 5; | |
| 181 | pub const PF_NETROM = 6; | |
| 182 | pub const PF_BRIDGE = 7; | |
| 183 | pub const PF_ATMPVC = 8; | |
| 184 | pub const PF_X25 = 9; | |
| 185 | pub const PF_INET6 = 10; | |
| 186 | pub const PF_ROSE = 11; | |
| 187 | pub const PF_DECnet = 12; | |
| 188 | pub const PF_NETBEUI = 13; | |
| 189 | pub const PF_SECURITY = 14; | |
| 190 | pub const PF_KEY = 15; | |
| 191 | pub const PF_NETLINK = 16; | |
| 192 | pub const PF_ROUTE = PF_NETLINK; | |
| 193 | pub const PF_PACKET = 17; | |
| 194 | pub const PF_ASH = 18; | |
| 195 | pub const PF_ECONET = 19; | |
| 196 | pub const PF_ATMSVC = 20; | |
| 197 | pub const PF_RDS = 21; | |
| 198 | pub const PF_SNA = 22; | |
| 199 | pub const PF_IRDA = 23; | |
| 200 | pub const PF_PPPOX = 24; | |
| 201 | pub const PF_WANPIPE = 25; | |
| 202 | pub const PF_LLC = 26; | |
| 203 | pub const PF_IB = 27; | |
| 204 | pub const PF_MPLS = 28; | |
| 205 | pub const PF_CAN = 29; | |
| 206 | pub const PF_TIPC = 30; | |
| 207 | pub const PF_BLUETOOTH = 31; | |
| 208 | pub const PF_IUCV = 32; | |
| 209 | pub const PF_RXRPC = 33; | |
| 210 | pub const PF_ISDN = 34; | |
| 211 | pub const PF_PHONET = 35; | |
| 212 | pub const PF_IEEE802154 = 36; | |
| 213 | pub const PF_CAIF = 37; | |
| 214 | pub const PF_ALG = 38; | |
| 215 | pub const PF_NFC = 39; | |
| 216 | pub const PF_VSOCK = 40; | |
| 217 | pub const PF_MAX = 41; | |
| 218 | ||
| 219 | pub const AF_UNSPEC = PF_UNSPEC; | |
| 220 | pub const AF_LOCAL = PF_LOCAL; | |
| 221 | pub const AF_UNIX = AF_LOCAL; | |
| 222 | pub const AF_FILE = AF_LOCAL; | |
| 223 | pub const AF_INET = PF_INET; | |
| 224 | pub const AF_AX25 = PF_AX25; | |
| 225 | pub const AF_IPX = PF_IPX; | |
| 226 | pub const AF_APPLETALK = PF_APPLETALK; | |
| 227 | pub const AF_NETROM = PF_NETROM; | |
| 228 | pub const AF_BRIDGE = PF_BRIDGE; | |
| 229 | pub const AF_ATMPVC = PF_ATMPVC; | |
| 230 | pub const AF_X25 = PF_X25; | |
| 231 | pub const AF_INET6 = PF_INET6; | |
| 232 | pub const AF_ROSE = PF_ROSE; | |
| 233 | pub const AF_DECnet = PF_DECnet; | |
| 234 | pub const AF_NETBEUI = PF_NETBEUI; | |
| 235 | pub const AF_SECURITY = PF_SECURITY; | |
| 236 | pub const AF_KEY = PF_KEY; | |
| 237 | pub const AF_NETLINK = PF_NETLINK; | |
| 238 | pub const AF_ROUTE = PF_ROUTE; | |
| 239 | pub const AF_PACKET = PF_PACKET; | |
| 240 | pub const AF_ASH = PF_ASH; | |
| 241 | pub const AF_ECONET = PF_ECONET; | |
| 242 | pub const AF_ATMSVC = PF_ATMSVC; | |
| 243 | pub const AF_RDS = PF_RDS; | |
| 244 | pub const AF_SNA = PF_SNA; | |
| 245 | pub const AF_IRDA = PF_IRDA; | |
| 246 | pub const AF_PPPOX = PF_PPPOX; | |
| 247 | pub const AF_WANPIPE = PF_WANPIPE; | |
| 248 | pub const AF_LLC = PF_LLC; | |
| 249 | pub const AF_IB = PF_IB; | |
| 250 | pub const AF_MPLS = PF_MPLS; | |
| 251 | pub const AF_CAN = PF_CAN; | |
| 252 | pub const AF_TIPC = PF_TIPC; | |
| 253 | pub const AF_BLUETOOTH = PF_BLUETOOTH; | |
| 254 | pub const AF_IUCV = PF_IUCV; | |
| 255 | pub const AF_RXRPC = PF_RXRPC; | |
| 256 | pub const AF_ISDN = PF_ISDN; | |
| 257 | pub const AF_PHONET = PF_PHONET; | |
| 258 | pub const AF_IEEE802154 = PF_IEEE802154; | |
| 259 | pub const AF_CAIF = PF_CAIF; | |
| 260 | pub const AF_ALG = PF_ALG; | |
| 261 | pub const AF_NFC = PF_NFC; | |
| 262 | pub const AF_VSOCK = PF_VSOCK; | |
| 263 | pub const AF_MAX = PF_MAX; | |
| 264 | ||
| 265 | pub const DT_UNKNOWN = 0; | |
| 266 | pub const DT_FIFO = 1; | |
| 267 | pub const DT_CHR = 2; | |
| 268 | pub const DT_DIR = 4; | |
| 269 | pub const DT_BLK = 6; | |
| 270 | pub const DT_REG = 8; | |
| 271 | pub const DT_LNK = 10; | |
| 272 | pub const DT_SOCK = 12; | |
| 273 | pub const DT_WHT = 14; | |
| 274 | ||
| 275 | pub const TCGETS = 0x5401; | |
| 276 | pub const TCSETS = 0x5402; | |
| 277 | pub const TCSETSW = 0x5403; | |
| 278 | pub const TCSETSF = 0x5404; | |
| 279 | pub const TCGETA = 0x5405; | |
| 280 | pub const TCSETA = 0x5406; | |
| 281 | pub const TCSETAW = 0x5407; | |
| 282 | pub const TCSETAF = 0x5408; | |
| 283 | pub const TCSBRK = 0x5409; | |
| 284 | pub const TCXONC = 0x540A; | |
| 285 | pub const TCFLSH = 0x540B; | |
| 286 | pub const TIOCEXCL = 0x540C; | |
| 287 | pub const TIOCNXCL = 0x540D; | |
| 288 | pub const TIOCSCTTY = 0x540E; | |
| 289 | pub const TIOCGPGRP = 0x540F; | |
| 290 | pub const TIOCSPGRP = 0x5410; | |
| 291 | pub const TIOCOUTQ = 0x5411; | |
| 292 | pub const TIOCSTI = 0x5412; | |
| 293 | pub const TIOCGWINSZ = 0x5413; | |
| 294 | pub const TIOCSWINSZ = 0x5414; | |
| 295 | pub const TIOCMGET = 0x5415; | |
| 296 | pub const TIOCMBIS = 0x5416; | |
| 297 | pub const TIOCMBIC = 0x5417; | |
| 298 | pub const TIOCMSET = 0x5418; | |
| 299 | pub const TIOCGSOFTCAR = 0x5419; | |
| 300 | pub const TIOCSSOFTCAR = 0x541A; | |
| 301 | pub const FIONREAD = 0x541B; | |
| 302 | pub const TIOCINQ = FIONREAD; | |
| 303 | pub const TIOCLINUX = 0x541C; | |
| 304 | pub const TIOCCONS = 0x541D; | |
| 305 | pub const TIOCGSERIAL = 0x541E; | |
| 306 | pub const TIOCSSERIAL = 0x541F; | |
| 307 | pub const TIOCPKT = 0x5420; | |
| 308 | pub const FIONBIO = 0x5421; | |
| 309 | pub const TIOCNOTTY = 0x5422; | |
| 310 | pub const TIOCSETD = 0x5423; | |
| 311 | pub const TIOCGETD = 0x5424; | |
| 312 | pub const TCSBRKP = 0x5425; | |
| 313 | pub const TIOCSBRK = 0x5427; | |
| 314 | pub const TIOCCBRK = 0x5428; | |
| 315 | pub const TIOCGSID = 0x5429; | |
| 316 | pub const TIOCGRS485 = 0x542E; | |
| 317 | pub const TIOCSRS485 = 0x542F; | |
| 318 | pub const TIOCGPTN = 0x80045430; | |
| 319 | pub const TIOCSPTLCK = 0x40045431; | |
| 320 | pub const TIOCGDEV = 0x80045432; | |
| 321 | pub const TCGETX = 0x5432; | |
| 322 | pub const TCSETX = 0x5433; | |
| 323 | pub const TCSETXF = 0x5434; | |
| 324 | pub const TCSETXW = 0x5435; | |
| 325 | pub const TIOCSIG = 0x40045436; | |
| 326 | pub const TIOCVHANGUP = 0x5437; | |
| 327 | pub const TIOCGPKT = 0x80045438; | |
| 328 | pub const TIOCGPTLCK = 0x80045439; | |
| 329 | pub const TIOCGEXCL = 0x80045440; | |
| 330 | ||
| 331 | fn unsigned(s: i32) u32 { | |
| 332 | return @bitCast(u32, s); | |
| 333 | } | |
| 334 | fn signed(s: u32) i32 { | |
| 335 | return @bitCast(i32, s); | |
| 336 | } | |
| 337 | pub fn WEXITSTATUS(s: i32) i32 { | |
| 338 | return signed((unsigned(s) & 0xff00) >> 8); | |
| 339 | } | |
| 340 | pub fn WTERMSIG(s: i32) i32 { | |
| 341 | return signed(unsigned(s) & 0x7f); | |
| 342 | } | |
| 343 | pub fn WSTOPSIG(s: i32) i32 { | |
| 344 | return WEXITSTATUS(s); | |
| 345 | } | |
| 346 | pub fn WIFEXITED(s: i32) bool { | |
| 347 | return WTERMSIG(s) == 0; | |
| 348 | } | |
| 349 | pub fn WIFSTOPPED(s: i32) bool { | |
| 350 | return @intCast(u16, (((unsigned(s) & 0xffff) *% 0x10001) >> 8)) > 0x7f00; | |
| 351 | } | |
| 352 | pub fn WIFSIGNALED(s: i32) bool { | |
| 353 | return (unsigned(s) & 0xffff) -% 1 < 0xff; | |
| 354 | } | |
| 355 | ||
| 356 | pub const winsize = extern struct.{ | |
| 357 | ws_row: u16, | |
| 358 | ws_col: u16, | |
| 359 | ws_xpixel: u16, | |
| 360 | ws_ypixel: u16, | |
| 361 | }; | |
| 362 | ||
| 363 | /// Get the errno from a syscall return value, or 0 for no error. | |
| 364 | pub fn getErrno(r: usize) usize { | |
| 365 | const signed_r = @bitCast(isize, r); | |
| 366 | return if (signed_r > -4096 and signed_r < 0) @intCast(usize, -signed_r) else 0; | |
| 367 | } | |
| 368 | ||
| 369 | pub fn dup2(old: i32, new: i32) usize { | |
| 370 | return arch.syscall2(arch.SYS_dup2, @intCast(usize, old), @intCast(usize, new)); | |
| 371 | } | |
| 372 | ||
| 373 | pub fn chdir(path: [*]const u8) usize { | |
| 374 | return arch.syscall1(arch.SYS_chdir, @ptrToInt(path)); | |
| 375 | } | |
| 376 | ||
| 377 | pub fn execve(path: [*]const u8, argv: [*]const ?[*]const u8, envp: [*]const ?[*]const u8) usize { | |
| 378 | return arch.syscall3(arch.SYS_execve, @ptrToInt(path), @ptrToInt(argv), @ptrToInt(envp)); | |
| 379 | } | |
| 380 | ||
| 381 | pub fn fork() usize { | |
| 382 | return arch.syscall0(arch.SYS_fork); | |
| 383 | } | |
| 384 | ||
| 385 | pub fn getcwd(buf: [*]u8, size: usize) usize { | |
| 386 | return arch.syscall2(arch.SYS___getcwd, @ptrToInt(buf), size); | |
| 387 | } | |
| 388 | ||
| 389 | pub fn getdents(fd: i32, dirp: [*]u8, count: usize) usize { | |
| 390 | return arch.syscall3(arch.SYS_getdents, @intCast(usize, fd), @ptrToInt(dirp), count); | |
| 391 | } | |
| 392 | ||
| 393 | pub fn isatty(fd: i32) bool { | |
| 394 | var wsz: winsize = undefined; | |
| 395 | return arch.syscall3(arch.SYS_ioctl, @intCast(usize, fd), TIOCGWINSZ, @ptrToInt(&wsz)) == 0; | |
| 396 | } | |
| 397 | ||
| 398 | pub fn readlink(noalias path: [*]const u8, noalias buf_ptr: [*]u8, buf_len: usize) usize { | |
| 399 | return arch.syscall3(arch.SYS_readlink, @ptrToInt(path), @ptrToInt(buf_ptr), buf_len); | |
| 400 | } | |
| 401 | ||
| 402 | pub fn mkdir(path: [*]const u8, mode: u32) usize { | |
| 403 | return arch.syscall2(arch.SYS_mkdir, @ptrToInt(path), mode); | |
| 404 | } | |
| 405 | ||
| 406 | pub fn mmap(address: ?*u8, length: usize, prot: usize, flags: usize, fd: i32, offset: isize) usize { | |
| 407 | return arch.syscall6(arch.SYS_mmap, @ptrToInt(address), length, prot, flags, @intCast(usize, fd), @bitCast(usize, offset)); | |
| 408 | } | |
| 409 | ||
| 410 | pub fn munmap(address: usize, length: usize) usize { | |
| 411 | return arch.syscall2(arch.SYS_munmap, address, length); | |
| 412 | } | |
| 413 | ||
| 414 | pub fn read(fd: i32, buf: [*]u8, count: usize) usize { | |
| 415 | return arch.syscall3(arch.SYS_read, @intCast(usize, fd), @ptrToInt(buf), count); | |
| 416 | } | |
| 417 | ||
| 418 | pub fn rmdir(path: [*]const u8) usize { | |
| 419 | return arch.syscall1(arch.SYS_rmdir, @ptrToInt(path)); | |
| 420 | } | |
| 421 | ||
| 422 | pub fn symlink(existing: [*]const u8, new: [*]const u8) usize { | |
| 423 | return arch.syscall2(arch.SYS_symlink, @ptrToInt(existing), @ptrToInt(new)); | |
| 424 | } | |
| 425 | ||
| 426 | pub fn pread(fd: i32, buf: [*]u8, count: usize, offset: usize) usize { | |
| 427 | return arch.syscall4(arch.SYS_pread, usize(fd), @ptrToInt(buf), count, offset); | |
| 428 | } | |
| 429 | ||
| 430 | pub fn pipe(fd: *[2]i32) usize { | |
| 431 | return pipe2(fd, 0); | |
| 432 | } | |
| 433 | ||
| 434 | pub fn pipe2(fd: *[2]i32, flags: usize) usize { | |
| 435 | return arch.syscall2(arch.SYS_pipe2, @ptrToInt(fd), flags); | |
| 436 | } | |
| 437 | ||
| 438 | pub fn write(fd: i32, buf: [*]const u8, count: usize) usize { | |
| 439 | return arch.syscall3(arch.SYS_write, @intCast(usize, fd), @ptrToInt(buf), count); | |
| 440 | } | |
| 441 | ||
| 442 | pub fn pwrite(fd: i32, buf: [*]const u8, count: usize, offset: usize) usize { | |
| 443 | return arch.syscall4(arch.SYS_pwrite, @intCast(usize, fd), @ptrToInt(buf), count, offset); | |
| 444 | } | |
| 445 | ||
| 446 | pub fn rename(old: [*]const u8, new: [*]const u8) usize { | |
| 447 | return arch.syscall2(arch.SYS_rename, @ptrToInt(old), @ptrToInt(new)); | |
| 448 | } | |
| 449 | ||
| 450 | pub fn open(path: [*]const u8, flags: u32, perm: usize) usize { | |
| 451 | return arch.syscall3(arch.SYS_open, @ptrToInt(path), flags, perm); | |
| 452 | } | |
| 453 | ||
| 454 | pub fn create(path: [*]const u8, perm: usize) usize { | |
| 455 | return arch.syscall2(arch.SYS_creat, @ptrToInt(path), perm); | |
| 456 | } | |
| 457 | ||
| 458 | pub fn openat(dirfd: i32, path: [*]const u8, flags: usize, mode: usize) usize { | |
| 459 | return arch.syscall4(arch.SYS_openat, @intCast(usize, dirfd), @ptrToInt(path), flags, mode); | |
| 460 | } | |
| 461 | ||
| 462 | pub fn close(fd: i32) usize { | |
| 463 | return arch.syscall1(arch.SYS_close, @intCast(usize, fd)); | |
| 464 | } | |
| 465 | ||
| 466 | pub fn lseek(fd: i32, offset: isize, ref_pos: usize) usize { | |
| 467 | return arch.syscall3(arch.SYS_lseek, @intCast(usize, fd), @bitCast(usize, offset), ref_pos); | |
| 468 | } | |
| 469 | ||
| 470 | pub fn exit(status: i32) noreturn { | |
| 471 | _ = arch.syscall1(arch.SYS_exit, @bitCast(usize, isize(status))); | |
| 472 | unreachable; | |
| 473 | } | |
| 474 | ||
| 475 | pub fn getrandom(buf: [*]u8, count: usize, flags: u32) usize { | |
| 476 | return arch.syscall3(arch.SYS_getrandom, @ptrToInt(buf), count, @intCast(usize, flags)); | |
| 477 | } | |
| 478 | ||
| 479 | pub fn kill(pid: i32, sig: i32) usize { | |
| 480 | return arch.syscall2(arch.SYS_kill, @bitCast(usize, @intCast(isize, pid)), @intCast(usize, sig)); | |
| 481 | } | |
| 482 | ||
| 483 | pub fn unlink(path: [*]const u8) usize { | |
| 484 | return arch.syscall1(arch.SYS_unlink, @ptrToInt(path)); | |
| 485 | } | |
| 486 | ||
| 487 | pub fn waitpid(pid: i32, status: *i32, options: i32) usize { | |
| 488 | return arch.syscall4(arch.SYS_wait4, @bitCast(usize, isize(pid)), @ptrToInt(status), @bitCast(usize, isize(options)), 0); | |
| 489 | } | |
| 490 | ||
| 491 | pub fn nanosleep(req: *const timespec, rem: ?*timespec) usize { | |
| 492 | return arch.syscall2(arch.SYS_nanosleep, @ptrToInt(req), @ptrToInt(rem)); | |
| 493 | } | |
| 494 | ||
| 495 | pub fn setuid(uid: u32) usize { | |
| 496 | return arch.syscall1(arch.SYS_setuid, uid); | |
| 497 | } | |
| 498 | ||
| 499 | pub fn setgid(gid: u32) usize { | |
| 500 | return arch.syscall1(arch.SYS_setgid, gid); | |
| 501 | } | |
| 502 | ||
| 503 | pub fn setreuid(ruid: u32, euid: u32) usize { | |
| 504 | return arch.syscall2(arch.SYS_setreuid, ruid, euid); | |
| 505 | } | |
| 506 | ||
| 507 | pub fn setregid(rgid: u32, egid: u32) usize { | |
| 508 | return arch.syscall2(arch.SYS_setregid, rgid, egid); | |
| 509 | } | |
| 510 | ||
| 511 | pub fn sigprocmask(flags: u32, noalias set: *const sigset_t, noalias oldset: ?*sigset_t) usize { | |
| 512 | // TODO: Implement | |
| 513 | return 0; | |
| 514 | } | |
| 515 | ||
| 516 | pub fn sigaction(sig: u6, noalias act: *const Sigaction, noalias oact: ?*Sigaction) usize { | |
| 517 | // TODO: Implement | |
| 518 | return 0; | |
| 519 | } | |
| 520 | ||
| 521 | const NSIG = 65; | |
| 522 | const sigset_t = [128 / @sizeOf(usize)]usize; | |
| 523 | const all_mask = []usize.{@maxValue(usize)}; | |
| 524 | const app_mask = []usize.{0xfffffffc7fffffff}; | |
| 525 | ||
| 526 | /// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall. | |
| 527 | pub const Sigaction = struct.{ | |
| 528 | // TODO: Adjust to use freebsd struct layout | |
| 529 | handler: extern fn (i32) void, | |
| 530 | mask: sigset_t, | |
| 531 | flags: u32, | |
| 532 | }; | |
| 533 | ||
| 534 | pub const SIG_ERR = @intToPtr(extern fn (i32) void, @maxValue(usize)); | |
| 535 | pub const SIG_DFL = @intToPtr(extern fn (i32) void, 0); | |
| 536 | pub const SIG_IGN = @intToPtr(extern fn (i32) void, 1); | |
| 537 | pub const empty_sigset = []usize.{0} ** sigset_t.len; | |
| 538 | ||
| 539 | pub fn raise(sig: i32) usize { | |
| 540 | // TODO implement, see linux equivalent for what we want to try and do | |
| 541 | return 0; | |
| 542 | } | |
| 543 | ||
| 544 | fn blockAllSignals(set: *sigset_t) void { | |
| 545 | // TODO implement | |
| 546 | } | |
| 547 | ||
| 548 | fn blockAppSignals(set: *sigset_t) void { | |
| 549 | // TODO implement | |
| 550 | } | |
| 551 | ||
| 552 | fn restoreSignals(set: *sigset_t) void { | |
| 553 | // TODO implement | |
| 554 | } | |
| 555 | ||
| 556 | pub fn sigaddset(set: *sigset_t, sig: u6) void { | |
| 557 | const s = sig - 1; | |
| 558 | (*set)[usize(s) / usize.bit_count] |= usize(1) << (s & (usize.bit_count - 1)); | |
| 559 | } | |
| 560 | ||
| 561 | pub fn sigismember(set: *const sigset_t, sig: u6) bool { | |
| 562 | const s = sig - 1; | |
| 563 | return ((*set)[usize(s) / usize.bit_count] & (usize(1) << (s & (usize.bit_count - 1)))) != 0; | |
| 564 | } | |
| 565 | ||
| 566 | pub const Stat = arch.Stat; | |
| 567 | pub const timespec = arch.timespec; | |
| 568 | ||
| 569 | pub fn fstat(fd: i32, stat_buf: *Stat) usize { | |
| 570 | return arch.syscall2(arch.SYS_fstat, @intCast(usize, fd), @ptrToInt(stat_buf)); | |
| 571 | } |
std/os/freebsd/x86_64.zig created+651| ... | ... | @@ -0,0 +1,651 @@ |
| 1 | const freebsd = @import("index.zig"); | |
| 2 | const socklen_t = freebsd.socklen_t; | |
| 3 | const iovec = freebsd.iovec; | |
| 4 | ||
| 5 | pub const SYS_syscall = 0; | |
| 6 | pub const SYS_exit = 1; | |
| 7 | pub const SYS_fork = 2; | |
| 8 | pub const SYS_read = 3; | |
| 9 | pub const SYS_write = 4; | |
| 10 | pub const SYS_open = 5; | |
| 11 | pub const SYS_close = 6; | |
| 12 | pub const SYS_wait4 = 7; | |
| 13 | // 8 is old creat | |
| 14 | pub const SYS_link = 9; | |
| 15 | pub const SYS_unlink = 10; | |
| 16 | // 11 is obsolete execv | |
| 17 | pub const SYS_chdir = 12; | |
| 18 | pub const SYS_fchdir = 13; | |
| 19 | pub const SYS_freebsd11_mknod = 14; | |
| 20 | pub const SYS_chmod = 15; | |
| 21 | pub const SYS_chown = 16; | |
| 22 | pub const SYS_break = 17; | |
| 23 | // 18 is freebsd4 getfsstat | |
| 24 | // 19 is old lseek | |
| 25 | pub const SYS_getpid = 20; | |
| 26 | pub const SYS_mount = 21; | |
| 27 | pub const SYS_unmount = 22; | |
| 28 | pub const SYS_setuid = 23; | |
| 29 | pub const SYS_getuid = 24; | |
| 30 | pub const SYS_geteuid = 25; | |
| 31 | pub const SYS_ptrace = 26; | |
| 32 | pub const SYS_recvmsg = 27; | |
| 33 | pub const SYS_sendmsg = 28; | |
| 34 | pub const SYS_recvfrom = 29; | |
| 35 | pub const SYS_accept = 30; | |
| 36 | pub const SYS_getpeername = 31; | |
| 37 | pub const SYS_getsockname = 32; | |
| 38 | pub const SYS_access = 33; | |
| 39 | pub const SYS_chflags = 34; | |
| 40 | pub const SYS_fchflags = 35; | |
| 41 | pub const SYS_sync = 36; | |
| 42 | pub const SYS_kill = 37; | |
| 43 | // 38 is old stat | |
| 44 | pub const SYS_getppid = 39; | |
| 45 | // 40 is old lstat | |
| 46 | pub const SYS_dup = 41; | |
| 47 | pub const SYS_freebsd10_pipe = 42; | |
| 48 | pub const SYS_getegid = 43; | |
| 49 | pub const SYS_profil = 44; | |
| 50 | pub const SYS_ktrace = 45; | |
| 51 | // 46 is old sigaction | |
| 52 | pub const SYS_getgid = 47; | |
| 53 | // 48 is old sigprocmask | |
| 54 | pub const SYS_getlogin = 49; | |
| 55 | pub const SYS_setlogin = 50; | |
| 56 | pub const SYS_acct = 51; | |
| 57 | // 52 is old sigpending | |
| 58 | pub const SYS_sigaltstack = 53; | |
| 59 | pub const SYS_ioctl = 54; | |
| 60 | pub const SYS_reboot = 55; | |
| 61 | pub const SYS_revoke = 56; | |
| 62 | pub const SYS_symlink = 57; | |
| 63 | pub const SYS_readlink = 58; | |
| 64 | pub const SYS_execve = 59; | |
| 65 | pub const SYS_umask = 60; | |
| 66 | pub const SYS_chroot = 61; | |
| 67 | // 62 is old fstat | |
| 68 | // 63 is old getkerninfo | |
| 69 | // 64 is old getpagesize | |
| 70 | pub const SYS_msync = 65; | |
| 71 | pub const SYS_vfork = 66; | |
| 72 | // 67 is obsolete vread | |
| 73 | // 68 is obsolete vwrite | |
| 74 | pub const SYS_sbrk = 69; | |
| 75 | pub const SYS_sstk = 70; | |
| 76 | // 71 is old mmap | |
| 77 | pub const SYS_vadvise = 72; | |
| 78 | pub const SYS_munmap = 73; | |
| 79 | pub const SYS_mprotect = 74; | |
| 80 | pub const SYS_madvise = 75; | |
| 81 | // 76 is obsolete vhangup | |
| 82 | // 77 is obsolete vlimit | |
| 83 | pub const SYS_mincore = 78; | |
| 84 | pub const SYS_getgroups = 79; | |
| 85 | pub const SYS_setgroups = 80; | |
| 86 | pub const SYS_getpgrp = 81; | |
| 87 | pub const SYS_setpgid = 82; | |
| 88 | pub const SYS_setitimer = 83; | |
| 89 | // 84 is old wait | |
| 90 | pub const SYS_swapon = 85; | |
| 91 | pub const SYS_getitimer = 86; | |
| 92 | // 87 is old gethostname | |
| 93 | // 88 is old sethostname | |
| 94 | pub const SYS_getdtablesize = 89; | |
| 95 | pub const SYS_dup2 = 90; | |
| 96 | pub const SYS_fcntl = 92; | |
| 97 | pub const SYS_select = 93; | |
| 98 | pub const SYS_fsync = 95; | |
| 99 | pub const SYS_setpriority = 96; | |
| 100 | pub const SYS_socket = 97; | |
| 101 | pub const SYS_connect = 98; | |
| 102 | // 99 is old accept | |
| 103 | pub const SYS_getpriority = 100; | |
| 104 | // 101 is old send | |
| 105 | // 102 is old recv | |
| 106 | // 103 is old sigreturn | |
| 107 | pub const SYS_bind = 104; | |
| 108 | pub const SYS_setsockopt = 105; | |
| 109 | pub const SYS_listen = 106; | |
| 110 | // 107 is obsolete vtimes | |
| 111 | // 108 is old sigvec | |
| 112 | // 109 is old sigblock | |
| 113 | // 110 is old sigsetmask | |
| 114 | // 111 is old sigsuspend | |
| 115 | // 112 is old sigstack | |
| 116 | // 113 is old recvmsg | |
| 117 | // 114 is old sendmsg | |
| 118 | // 115 is obsolete vtrace | |
| 119 | pub const SYS_gettimeofday = 116; | |
| 120 | pub const SYS_getrusage = 117; | |
| 121 | pub const SYS_getsockopt = 118; | |
| 122 | pub const SYS_readv = 120; | |
| 123 | pub const SYS_writev = 121; | |
| 124 | pub const SYS_settimeofday = 122; | |
| 125 | pub const SYS_fchown = 123; | |
| 126 | pub const SYS_fchmod = 124; | |
| 127 | // 125 is old recvfrom | |
| 128 | pub const SYS_setreuid = 126; | |
| 129 | pub const SYS_setregid = 127; | |
| 130 | pub const SYS_rename = 128; | |
| 131 | // 129 is old truncate | |
| 132 | // 130 is old ftruncate | |
| 133 | pub const SYS_flock = 131; | |
| 134 | pub const SYS_mkfifo = 132; | |
| 135 | pub const SYS_sendto = 133; | |
| 136 | pub const SYS_shutdown = 134; | |
| 137 | pub const SYS_socketpair = 135; | |
| 138 | pub const SYS_mkdir = 136; | |
| 139 | pub const SYS_rmdir = 137; | |
| 140 | pub const SYS_utimes = 138; | |
| 141 | // 139 is obsolete 4.2 sigreturn | |
| 142 | pub const SYS_adjtime = 140; | |
| 143 | // 141 is old getpeername | |
| 144 | // 142 is old gethostid | |
| 145 | // 143 is old sethostid | |
| 146 | // 144 is old getrlimit | |
| 147 | // 145 is old setrlimit | |
| 148 | // 146 is old killpg | |
| 149 | pub const SYS_setsid = 147; | |
| 150 | pub const SYS_quotactl = 148; | |
| 151 | // 149 is old quota | |
| 152 | // 150 is old getsockname | |
| 153 | pub const SYS_nlm_syscall = 154; | |
| 154 | pub const SYS_nfssvc = 155; | |
| 155 | // 156 is old getdirentries | |
| 156 | // 157 is freebsd4 statfs | |
| 157 | // 158 is freebsd4 fstatfs | |
| 158 | pub const SYS_lgetfh = 160; | |
| 159 | pub const SYS_getfh = 161; | |
| 160 | // 162 is freebsd4 getdomainname | |
| 161 | // 163 is freebsd4 setdomainname | |
| 162 | // 164 is freebsd4 uname | |
| 163 | pub const SYS_sysarch = 165; | |
| 164 | pub const SYS_rtprio = 166; | |
| 165 | pub const SYS_semsys = 169; | |
| 166 | pub const SYS_msgsys = 170; | |
| 167 | pub const SYS_shmsys = 171; | |
| 168 | // 173 is freebsd6 pread | |
| 169 | // 174 is freebsd6 pwrite | |
| 170 | pub const SYS_setfib = 175; | |
| 171 | pub const SYS_ntp_adjtime = 176; | |
| 172 | pub const SYS_setgid = 181; | |
| 173 | pub const SYS_setegid = 182; | |
| 174 | pub const SYS_seteuid = 183; | |
| 175 | pub const SYS_freebsd11_stat = 188; | |
| 176 | pub const SYS_freebsd11_fstat = 189; | |
| 177 | pub const SYS_freebsd11_lstat = 190; | |
| 178 | pub const SYS_pathconf = 191; | |
| 179 | pub const SYS_fpathconf = 192; | |
| 180 | pub const SYS_getrlimit = 194; | |
| 181 | pub const SYS_setrlimit = 195; | |
| 182 | pub const SYS_freebsd11_getdirentries = 196; | |
| 183 | // 197 is freebsd6 mmap | |
| 184 | pub const SYS___syscall = 198; | |
| 185 | // 199 is freebsd6 lseek | |
| 186 | // 200 is freebsd6 truncate | |
| 187 | // 201 is freebsd6 ftruncate | |
| 188 | pub const SYS___sysctl = 202; | |
| 189 | pub const SYS_mlock = 203; | |
| 190 | pub const SYS_munlock = 204; | |
| 191 | pub const SYS_undelete = 205; | |
| 192 | pub const SYS_futimes = 206; | |
| 193 | pub const SYS_getpgid = 207; | |
| 194 | pub const SYS_poll = 209; | |
| 195 | pub const SYS_freebsd7___semctl = 220; | |
| 196 | pub const SYS_semget = 221; | |
| 197 | pub const SYS_semop = 222; | |
| 198 | pub const SYS_freebsd7_msgctl = 224; | |
| 199 | pub const SYS_msgget = 225; | |
| 200 | pub const SYS_msgsnd = 226; | |
| 201 | pub const SYS_msgrcv = 227; | |
| 202 | pub const SYS_shmat = 228; | |
| 203 | pub const SYS_freebsd7_shmctl = 229; | |
| 204 | pub const SYS_shmdt = 230; | |
| 205 | pub const SYS_shmget = 231; | |
| 206 | pub const SYS_clock_gettime = 232; | |
| 207 | pub const SYS_clock_settime = 233; | |
| 208 | pub const SYS_clock_getres = 234; | |
| 209 | pub const SYS_ktimer_create = 235; | |
| 210 | pub const SYS_ktimer_delete = 236; | |
| 211 | pub const SYS_ktimer_settime = 237; | |
| 212 | pub const SYS_ktimer_gettime = 238; | |
| 213 | pub const SYS_ktimer_getoverrun = 239; | |
| 214 | pub const SYS_nanosleep = 240; | |
| 215 | pub const SYS_ffclock_getcounter = 241; | |
| 216 | pub const SYS_ffclock_setestimate = 242; | |
| 217 | pub const SYS_ffclock_getestimate = 243; | |
| 218 | pub const SYS_clock_nanosleep = 244; | |
| 219 | pub const SYS_clock_getcpuclockid2 = 247; | |
| 220 | pub const SYS_ntp_gettime = 248; | |
| 221 | pub const SYS_minherit = 250; | |
| 222 | pub const SYS_rfork = 251; | |
| 223 | // 252 is obsolete openbsd_poll | |
| 224 | pub const SYS_issetugid = 253; | |
| 225 | pub const SYS_lchown = 254; | |
| 226 | pub const SYS_aio_read = 255; | |
| 227 | pub const SYS_aio_write = 256; | |
| 228 | pub const SYS_lio_listio = 257; | |
| 229 | pub const SYS_freebsd11_getdents = 272; | |
| 230 | pub const SYS_lchmod = 274; | |
| 231 | pub const SYS_netbsd_lchown = 275; | |
| 232 | pub const SYS_lutimes = 276; | |
| 233 | pub const SYS_netbsd_msync = 277; | |
| 234 | pub const SYS_freebsd11_nstat = 278; | |
| 235 | pub const SYS_freebsd11_nfstat = 279; | |
| 236 | pub const SYS_freebsd11_nlstat = 280; | |
| 237 | pub const SYS_preadv = 289; | |
| 238 | pub const SYS_pwritev = 290; | |
| 239 | // 297 is freebsd4 fhstatfs | |
| 240 | pub const SYS_fhopen = 298; | |
| 241 | pub const SYS_freebsd11_fhstat = 299; | |
| 242 | pub const SYS_modnext = 300; | |
| 243 | pub const SYS_modstat = 301; | |
| 244 | pub const SYS_modfnext = 302; | |
| 245 | pub const SYS_modfind = 303; | |
| 246 | pub const SYS_kldload = 304; | |
| 247 | pub const SYS_kldunload = 305; | |
| 248 | pub const SYS_kldfind = 306; | |
| 249 | pub const SYS_kldnext = 307; | |
| 250 | pub const SYS_kldstat = 308; | |
| 251 | pub const SYS_kldfirstmod = 309; | |
| 252 | pub const SYS_getsid = 310; | |
| 253 | pub const SYS_setresuid = 311; | |
| 254 | pub const SYS_setresgid = 312; | |
| 255 | // 313 is obsolete signanosleep | |
| 256 | pub const SYS_aio_return = 314; | |
| 257 | pub const SYS_aio_suspend = 315; | |
| 258 | pub const SYS_aio_cancel = 316; | |
| 259 | pub const SYS_aio_error = 317; | |
| 260 | // 318 is freebsd6 aio_read | |
| 261 | // 319 is freebsd6 aio_write | |
| 262 | // 320 is freebsd6 lio_listio | |
| 263 | pub const SYS_yield = 321; | |
| 264 | // 322 is obsolete thr_sleep | |
| 265 | // 323 is obsolete thr_wakeup | |
| 266 | pub const SYS_mlockall = 324; | |
| 267 | pub const SYS_munlockall = 325; | |
| 268 | pub const SYS___getcwd = 326; | |
| 269 | pub const SYS_sched_setparam = 327; | |
| 270 | pub const SYS_sched_getparam = 328; | |
| 271 | pub const SYS_sched_setscheduler = 329; | |
| 272 | pub const SYS_sched_getscheduler = 330; | |
| 273 | pub const SYS_sched_yield = 331; | |
| 274 | pub const SYS_sched_get_priority_max = 332; | |
| 275 | pub const SYS_sched_get_priority_min = 333; | |
| 276 | pub const SYS_sched_rr_get_interval = 334; | |
| 277 | pub const SYS_utrace = 335; | |
| 278 | // 336 is freebsd4 sendfile | |
| 279 | pub const SYS_kldsym = 337; | |
| 280 | pub const SYS_jail = 338; | |
| 281 | pub const SYS_nnpfs_syscall = 339; | |
| 282 | pub const SYS_sigprocmask = 340; | |
| 283 | pub const SYS_sigsuspend = 341; | |
| 284 | // 342 is freebsd4 sigaction | |
| 285 | pub const SYS_sigpending = 343; | |
| 286 | // 344 is freebsd4 sigreturn | |
| 287 | pub const SYS_sigtimedwait = 345; | |
| 288 | pub const SYS_sigwaitinfo = 346; | |
| 289 | pub const SYS___acl_get_file = 347; | |
| 290 | pub const SYS___acl_set_file = 348; | |
| 291 | pub const SYS___acl_get_fd = 349; | |
| 292 | pub const SYS___acl_set_fd = 350; | |
| 293 | pub const SYS___acl_delete_file = 351; | |
| 294 | pub const SYS___acl_delete_fd = 352; | |
| 295 | pub const SYS___acl_aclcheck_file = 353; | |
| 296 | pub const SYS___acl_aclcheck_fd = 354; | |
| 297 | pub const SYS_extattrctl = 355; | |
| 298 | pub const SYS_extattr_set_file = 356; | |
| 299 | pub const SYS_extattr_get_file = 357; | |
| 300 | pub const SYS_extattr_delete_file = 358; | |
| 301 | pub const SYS_aio_waitcomplete = 359; | |
| 302 | pub const SYS_getresuid = 360; | |
| 303 | pub const SYS_getresgid = 361; | |
| 304 | pub const SYS_kqueue = 362; | |
| 305 | pub const SYS_freebsd11_kevent = 363; | |
| 306 | pub const SYS_extattr_set_fd = 371; | |
| 307 | pub const SYS_extattr_get_fd = 372; | |
| 308 | pub const SYS_extattr_delete_fd = 373; | |
| 309 | pub const SYS___setugid = 374; | |
| 310 | pub const SYS_eaccess = 376; | |
| 311 | pub const SYS_afs3_syscall = 377; | |
| 312 | pub const SYS_nmount = 378; | |
| 313 | pub const SYS___mac_get_proc = 384; | |
| 314 | pub const SYS___mac_set_proc = 385; | |
| 315 | pub const SYS___mac_get_fd = 386; | |
| 316 | pub const SYS___mac_get_file = 387; | |
| 317 | pub const SYS___mac_set_fd = 388; | |
| 318 | pub const SYS___mac_set_file = 389; | |
| 319 | pub const SYS_kenv = 390; | |
| 320 | pub const SYS_lchflags = 391; | |
| 321 | pub const SYS_uuidgen = 392; | |
| 322 | pub const SYS_sendfile = 393; | |
| 323 | pub const SYS_mac_syscall = 394; | |
| 324 | pub const SYS_freebsd11_getfsstat = 395; | |
| 325 | pub const SYS_freebsd11_statfs = 396; | |
| 326 | pub const SYS_freebsd11_fstatfs = 397; | |
| 327 | pub const SYS_freebsd11_fhstatfs = 398; | |
| 328 | pub const SYS_ksem_close = 400; | |
| 329 | pub const SYS_ksem_post = 401; | |
| 330 | pub const SYS_ksem_wait = 402; | |
| 331 | pub const SYS_ksem_trywait = 403; | |
| 332 | pub const SYS_ksem_init = 404; | |
| 333 | pub const SYS_ksem_open = 405; | |
| 334 | pub const SYS_ksem_unlink = 406; | |
| 335 | pub const SYS_ksem_getvalue = 407; | |
| 336 | pub const SYS_ksem_destroy = 408; | |
| 337 | pub const SYS___mac_get_pid = 409; | |
| 338 | pub const SYS___mac_get_link = 410; | |
| 339 | pub const SYS___mac_set_link = 411; | |
| 340 | pub const SYS_extattr_set_link = 412; | |
| 341 | pub const SYS_extattr_get_link = 413; | |
| 342 | pub const SYS_extattr_delete_link = 414; | |
| 343 | pub const SYS___mac_execve = 415; | |
| 344 | pub const SYS_sigaction = 416; | |
| 345 | pub const SYS_sigreturn = 417; | |
| 346 | pub const SYS_getcontext = 421; | |
| 347 | pub const SYS_setcontext = 422; | |
| 348 | pub const SYS_swapcontext = 423; | |
| 349 | pub const SYS_swapoff = 424; | |
| 350 | pub const SYS___acl_get_link = 425; | |
| 351 | pub const SYS___acl_set_link = 426; | |
| 352 | pub const SYS___acl_delete_link = 427; | |
| 353 | pub const SYS___acl_aclcheck_link = 428; | |
| 354 | pub const SYS_sigwait = 429; | |
| 355 | pub const SYS_thr_create = 430; | |
| 356 | pub const SYS_thr_exit = 431; | |
| 357 | pub const SYS_thr_self = 432; | |
| 358 | pub const SYS_thr_kill = 433; | |
| 359 | pub const SYS_jail_attach = 436; | |
| 360 | pub const SYS_extattr_list_fd = 437; | |
| 361 | pub const SYS_extattr_list_file = 438; | |
| 362 | pub const SYS_extattr_list_link = 439; | |
| 363 | pub const SYS_ksem_timedwait = 441; | |
| 364 | pub const SYS_thr_suspend = 442; | |
| 365 | pub const SYS_thr_wake = 443; | |
| 366 | pub const SYS_kldunloadf = 444; | |
| 367 | pub const SYS_audit = 445; | |
| 368 | pub const SYS_auditon = 446; | |
| 369 | pub const SYS_getauid = 447; | |
| 370 | pub const SYS_setauid = 448; | |
| 371 | pub const SYS_getaudit = 449; | |
| 372 | pub const SYS_setaudit = 450; | |
| 373 | pub const SYS_getaudit_addr = 451; | |
| 374 | pub const SYS_setaudit_addr = 452; | |
| 375 | pub const SYS_auditctl = 453; | |
| 376 | pub const SYS__umtx_op = 454; | |
| 377 | pub const SYS_thr_new = 455; | |
| 378 | pub const SYS_sigqueue = 456; | |
| 379 | pub const SYS_kmq_open = 457; | |
| 380 | pub const SYS_kmq_setattr = 458; | |
| 381 | pub const SYS_kmq_timedreceive = 459; | |
| 382 | pub const SYS_kmq_timedsend = 460; | |
| 383 | pub const SYS_kmq_notify = 461; | |
| 384 | pub const SYS_kmq_unlink = 462; | |
| 385 | pub const SYS_abort2 = 463; | |
| 386 | pub const SYS_thr_set_name = 464; | |
| 387 | pub const SYS_aio_fsync = 465; | |
| 388 | pub const SYS_rtprio_thread = 466; | |
| 389 | pub const SYS_sctp_peeloff = 471; | |
| 390 | pub const SYS_sctp_generic_sendmsg = 472; | |
| 391 | pub const SYS_sctp_generic_sendmsg_iov = 473; | |
| 392 | pub const SYS_sctp_generic_recvmsg = 474; | |
| 393 | pub const SYS_pread = 475; | |
| 394 | pub const SYS_pwrite = 476; | |
| 395 | pub const SYS_mmap = 477; | |
| 396 | pub const SYS_lseek = 478; | |
| 397 | pub const SYS_truncate = 479; | |
| 398 | pub const SYS_ftruncate = 480; | |
| 399 | pub const SYS_thr_kill2 = 481; | |
| 400 | pub const SYS_shm_open = 482; | |
| 401 | pub const SYS_shm_unlink = 483; | |
| 402 | pub const SYS_cpuset = 484; | |
| 403 | pub const SYS_cpuset_setid = 485; | |
| 404 | pub const SYS_cpuset_getid = 486; | |
| 405 | pub const SYS_cpuset_getaffinity = 487; | |
| 406 | pub const SYS_cpuset_setaffinity = 488; | |
| 407 | pub const SYS_faccessat = 489; | |
| 408 | pub const SYS_fchmodat = 490; | |
| 409 | pub const SYS_fchownat = 491; | |
| 410 | pub const SYS_fexecve = 492; | |
| 411 | pub const SYS_freebsd11_fstatat = 493; | |
| 412 | pub const SYS_futimesat = 494; | |
| 413 | pub const SYS_linkat = 495; | |
| 414 | pub const SYS_mkdirat = 496; | |
| 415 | pub const SYS_mkfifoat = 497; | |
| 416 | pub const SYS_freebsd11_mknodat = 498; | |
| 417 | pub const SYS_openat = 499; | |
| 418 | pub const SYS_readlinkat = 500; | |
| 419 | pub const SYS_renameat = 501; | |
| 420 | pub const SYS_symlinkat = 502; | |
| 421 | pub const SYS_unlinkat = 503; | |
| 422 | pub const SYS_posix_openpt = 504; | |
| 423 | pub const SYS_gssd_syscall = 505; | |
| 424 | pub const SYS_jail_get = 506; | |
| 425 | pub const SYS_jail_set = 507; | |
| 426 | pub const SYS_jail_remove = 508; | |
| 427 | pub const SYS_closefrom = 509; | |
| 428 | pub const SYS___semctl = 510; | |
| 429 | pub const SYS_msgctl = 511; | |
| 430 | pub const SYS_shmctl = 512; | |
| 431 | pub const SYS_lpathconf = 513; | |
| 432 | // 514 is obsolete cap_new | |
| 433 | pub const SYS___cap_rights_get = 515; | |
| 434 | pub const SYS_cap_enter = 516; | |
| 435 | pub const SYS_cap_getmode = 517; | |
| 436 | pub const SYS_pdfork = 518; | |
| 437 | pub const SYS_pdkill = 519; | |
| 438 | pub const SYS_pdgetpid = 520; | |
| 439 | pub const SYS_pselect = 522; | |
| 440 | pub const SYS_getloginclass = 523; | |
| 441 | pub const SYS_setloginclass = 524; | |
| 442 | pub const SYS_rctl_get_racct = 525; | |
| 443 | pub const SYS_rctl_get_rules = 526; | |
| 444 | pub const SYS_rctl_get_limits = 527; | |
| 445 | pub const SYS_rctl_add_rule = 528; | |
| 446 | pub const SYS_rctl_remove_rule = 529; | |
| 447 | pub const SYS_posix_fallocate = 530; | |
| 448 | pub const SYS_posix_fadvise = 531; | |
| 449 | pub const SYS_wait6 = 532; | |
| 450 | pub const SYS_cap_rights_limit = 533; | |
| 451 | pub const SYS_cap_ioctls_limit = 534; | |
| 452 | pub const SYS_cap_ioctls_get = 535; | |
| 453 | pub const SYS_cap_fcntls_limit = 536; | |
| 454 | pub const SYS_cap_fcntls_get = 537; | |
| 455 | pub const SYS_bindat = 538; | |
| 456 | pub const SYS_connectat = 539; | |
| 457 | pub const SYS_chflagsat = 540; | |
| 458 | pub const SYS_accept4 = 541; | |
| 459 | pub const SYS_pipe2 = 542; | |
| 460 | pub const SYS_aio_mlock = 543; | |
| 461 | pub const SYS_procctl = 544; | |
| 462 | pub const SYS_ppoll = 545; | |
| 463 | pub const SYS_futimens = 546; | |
| 464 | pub const SYS_utimensat = 547; | |
| 465 | pub const SYS_numa_getaffinity = 548; | |
| 466 | pub const SYS_numa_setaffinity = 549; | |
| 467 | pub const SYS_fdatasync = 550; | |
| 468 | pub const SYS_fstat = 551; | |
| 469 | pub const SYS_fstatat = 552; | |
| 470 | pub const SYS_fhstat = 553; | |
| 471 | pub const SYS_getdirentries = 554; | |
| 472 | pub const SYS_statfs = 555; | |
| 473 | pub const SYS_fstatfs = 556; | |
| 474 | pub const SYS_getfsstat = 557; | |
| 475 | pub const SYS_fhstatfs = 558; | |
| 476 | pub const SYS_mknodat = 559; | |
| 477 | pub const SYS_kevent = 560; | |
| 478 | pub const SYS_MAXSYSCALL = 561; | |
| 479 | pub const SYS_getrandom = 563; | |
| 480 | ||
| 481 | pub const O_CREAT = 0o100; | |
| 482 | pub const O_EXCL = 0o200; | |
| 483 | pub const O_NOCTTY = 0o400; | |
| 484 | pub const O_TRUNC = 0o1000; | |
| 485 | pub const O_APPEND = 0o2000; | |
| 486 | pub const O_NONBLOCK = 0o4000; | |
| 487 | pub const O_DSYNC = 0o10000; | |
| 488 | pub const O_SYNC = 0o4010000; | |
| 489 | pub const O_RSYNC = 0o4010000; | |
| 490 | pub const O_DIRECTORY = 0o200000; | |
| 491 | pub const O_NOFOLLOW = 0o400000; | |
| 492 | pub const O_CLOEXEC = 0o2000000; | |
| 493 | ||
| 494 | pub const O_ASYNC = 0o20000; | |
| 495 | pub const O_DIRECT = 0o40000; | |
| 496 | pub const O_LARGEFILE = 0; | |
| 497 | pub const O_NOATIME = 0o1000000; | |
| 498 | pub const O_PATH = 0o10000000; | |
| 499 | pub const O_TMPFILE = 0o20200000; | |
| 500 | pub const O_NDELAY = O_NONBLOCK; | |
| 501 | ||
| 502 | pub const F_DUPFD = 0; | |
| 503 | pub const F_GETFD = 1; | |
| 504 | pub const F_SETFD = 2; | |
| 505 | pub const F_GETFL = 3; | |
| 506 | pub const F_SETFL = 4; | |
| 507 | ||
| 508 | pub const F_SETOWN = 8; | |
| 509 | pub const F_GETOWN = 9; | |
| 510 | pub const F_SETSIG = 10; | |
| 511 | pub const F_GETSIG = 11; | |
| 512 | ||
| 513 | pub const F_GETLK = 5; | |
| 514 | pub const F_SETLK = 6; | |
| 515 | pub const F_SETLKW = 7; | |
| 516 | ||
| 517 | pub const F_SETOWN_EX = 15; | |
| 518 | pub const F_GETOWN_EX = 16; | |
| 519 | ||
| 520 | pub const F_GETOWNER_UIDS = 17; | |
| 521 | ||
| 522 | pub fn syscall0(number: usize) usize { | |
| 523 | return asm volatile ("syscall" | |
| 524 | : [ret] "={rax}" (-> usize) | |
| 525 | : [number] "{rax}" (number) | |
| 526 | : "rcx", "r11" | |
| 527 | ); | |
| 528 | } | |
| 529 | ||
| 530 | pub fn syscall1(number: usize, arg1: usize) usize { | |
| 531 | return asm volatile ("syscall" | |
| 532 | : [ret] "={rax}" (-> usize) | |
| 533 | : [number] "{rax}" (number), | |
| 534 | [arg1] "{rdi}" (arg1) | |
| 535 | : "rcx", "r11" | |
| 536 | ); | |
| 537 | } | |
| 538 | ||
| 539 | pub fn syscall2(number: usize, arg1: usize, arg2: usize) usize { | |
| 540 | return asm volatile ("syscall" | |
| 541 | : [ret] "={rax}" (-> usize) | |
| 542 | : [number] "{rax}" (number), | |
| 543 | [arg1] "{rdi}" (arg1), | |
| 544 | [arg2] "{rsi}" (arg2) | |
| 545 | : "rcx", "r11" | |
| 546 | ); | |
| 547 | } | |
| 548 | ||
| 549 | pub fn syscall3(number: usize, arg1: usize, arg2: usize, arg3: usize) usize { | |
| 550 | return asm volatile ("syscall" | |
| 551 | : [ret] "={rax}" (-> usize) | |
| 552 | : [number] "{rax}" (number), | |
| 553 | [arg1] "{rdi}" (arg1), | |
| 554 | [arg2] "{rsi}" (arg2), | |
| 555 | [arg3] "{rdx}" (arg3) | |
| 556 | : "rcx", "r11" | |
| 557 | ); | |
| 558 | } | |
| 559 | ||
| 560 | pub fn syscall4(number: usize, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize { | |
| 561 | return asm volatile ("syscall" | |
| 562 | : [ret] "={rax}" (-> usize) | |
| 563 | : [number] "{rax}" (number), | |
| 564 | [arg1] "{rdi}" (arg1), | |
| 565 | [arg2] "{rsi}" (arg2), | |
| 566 | [arg3] "{rdx}" (arg3), | |
| 567 | [arg4] "{r10}" (arg4) | |
| 568 | : "rcx", "r11" | |
| 569 | ); | |
| 570 | } | |
| 571 | ||
| 572 | pub fn syscall5(number: usize, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize { | |
| 573 | return asm volatile ("syscall" | |
| 574 | : [ret] "={rax}" (-> usize) | |
| 575 | : [number] "{rax}" (number), | |
| 576 | [arg1] "{rdi}" (arg1), | |
| 577 | [arg2] "{rsi}" (arg2), | |
| 578 | [arg3] "{rdx}" (arg3), | |
| 579 | [arg4] "{r10}" (arg4), | |
| 580 | [arg5] "{r8}" (arg5) | |
| 581 | : "rcx", "r11" | |
| 582 | ); | |
| 583 | } | |
| 584 | ||
| 585 | pub fn syscall6( | |
| 586 | number: usize, | |
| 587 | arg1: usize, | |
| 588 | arg2: usize, | |
| 589 | arg3: usize, | |
| 590 | arg4: usize, | |
| 591 | arg5: usize, | |
| 592 | arg6: usize, | |
| 593 | ) usize { | |
| 594 | return asm volatile ("syscall" | |
| 595 | : [ret] "={rax}" (-> usize) | |
| 596 | : [number] "{rax}" (number), | |
| 597 | [arg1] "{rdi}" (arg1), | |
| 598 | [arg2] "{rsi}" (arg2), | |
| 599 | [arg3] "{rdx}" (arg3), | |
| 600 | [arg4] "{r10}" (arg4), | |
| 601 | [arg5] "{r8}" (arg5), | |
| 602 | [arg6] "{r9}" (arg6) | |
| 603 | : "rcx", "r11" | |
| 604 | ); | |
| 605 | } | |
| 606 | ||
| 607 | pub nakedcc fn restore_rt() void { | |
| 608 | asm volatile ("syscall" | |
| 609 | : | |
| 610 | : [number] "{rax}" (usize(SYS_rt_sigreturn)) | |
| 611 | : "rcx", "r11" | |
| 612 | ); | |
| 613 | } | |
| 614 | ||
| 615 | pub const msghdr = extern struct.{ | |
| 616 | msg_name: &u8, | |
| 617 | msg_namelen: socklen_t, | |
| 618 | msg_iov: &iovec, | |
| 619 | msg_iovlen: i32, | |
| 620 | __pad1: i32, | |
| 621 | msg_control: &u8, | |
| 622 | msg_controllen: socklen_t, | |
| 623 | __pad2: socklen_t, | |
| 624 | msg_flags: i32, | |
| 625 | }; | |
| 626 | ||
| 627 | /// Renamed to Stat to not conflict with the stat function. | |
| 628 | pub const Stat = extern struct.{ | |
| 629 | dev: u64, | |
| 630 | ino: u64, | |
| 631 | nlink: usize, | |
| 632 | ||
| 633 | mode: u32, | |
| 634 | uid: u32, | |
| 635 | gid: u32, | |
| 636 | __pad0: u32, | |
| 637 | rdev: u64, | |
| 638 | size: i64, | |
| 639 | blksize: isize, | |
| 640 | blocks: i64, | |
| 641 | ||
| 642 | atim: timespec, | |
| 643 | mtim: timespec, | |
| 644 | ctim: timespec, | |
| 645 | __unused: [3]isize, | |
| 646 | }; | |
| 647 | ||
| 648 | pub const timespec = extern struct.{ | |
| 649 | tv_sec: isize, | |
| 650 | tv_nsec: isize, | |
| 651 | }; |
std/os/freebsd_errno.zig deleted-121| ... | ... | @@ -1,121 +0,0 @@ |
| 1 | pub const EPERM = 1; // Operation not permitted | |
| 2 | pub const ENOENT = 2; // No such file or directory | |
| 3 | pub const ESRCH = 3; // No such process | |
| 4 | pub const EINTR = 4; // Interrupted system call | |
| 5 | pub const EIO = 5; // Input/output error | |
| 6 | pub const ENXIO = 6; // Device not configured | |
| 7 | pub const E2BIG = 7; // Argument list too long | |
| 8 | pub const ENOEXEC = 8; // Exec format error | |
| 9 | pub const EBADF = 9; // Bad file descriptor | |
| 10 | pub const ECHILD = 10; // No child processes | |
| 11 | pub const EDEADLK = 11; // Resource deadlock avoided | |
| 12 | // 11 was EAGAIN | |
| 13 | pub const ENOMEM = 12; // Cannot allocate memory | |
| 14 | pub const EACCES = 13; // Permission denied | |
| 15 | pub const EFAULT = 14; // Bad address | |
| 16 | pub const ENOTBLK = 15; // Block device required | |
| 17 | pub const EBUSY = 16; // Device busy | |
| 18 | pub const EEXIST = 17; // File exists | |
| 19 | pub const EXDEV = 18; // Cross-device link | |
| 20 | pub const ENODEV = 19; // Operation not supported by device | |
| 21 | pub const ENOTDIR = 20; // Not a directory | |
| 22 | pub const EISDIR = 21; // Is a directory | |
| 23 | pub const EINVAL = 22; // Invalid argument | |
| 24 | pub const ENFILE = 23; // Too many open files in system | |
| 25 | pub const EMFILE = 24; // Too many open files | |
| 26 | pub const ENOTTY = 25; // Inappropriate ioctl for device | |
| 27 | pub const ETXTBSY = 26; // Text file busy | |
| 28 | pub const EFBIG = 27; // File too large | |
| 29 | pub const ENOSPC = 28; // No space left on device | |
| 30 | pub const ESPIPE = 29; // Illegal seek | |
| 31 | pub const EROFS = 30; // Read-only filesystem | |
| 32 | pub const EMLINK = 31; // Too many links | |
| 33 | pub const EPIPE = 32; // Broken pipe | |
| 34 | ||
| 35 | // math software | |
| 36 | pub const EDOM = 33; // Numerical argument out of domain | |
| 37 | pub const ERANGE = 34; // Result too large | |
| 38 | ||
| 39 | // non-blocking and interrupt i/o | |
| 40 | pub const EAGAIN = 35; // Resource temporarily unavailable | |
| 41 | pub const EWOULDBLOCK = EAGAIN; // Operation would block | |
| 42 | pub const EINPROGRESS = 36; // Operation now in progress | |
| 43 | pub const EALREADY = 37; // Operation already in progress | |
| 44 | ||
| 45 | // ipc/network software -- argument errors | |
| 46 | pub const ENOTSOCK = 38; // Socket operation on non-socket | |
| 47 | pub const EDESTADDRREQ = 39; // Destination address required | |
| 48 | pub const EMSGSIZE = 40; // Message too long | |
| 49 | pub const EPROTOTYPE = 41; // Protocol wrong type for socket | |
| 50 | pub const ENOPROTOOPT = 42; // Protocol not available | |
| 51 | pub const EPROTONOSUPPORT = 43; // Protocol not supported | |
| 52 | pub const ESOCKTNOSUPPORT = 44; // Socket type not supported | |
| 53 | pub const EOPNOTSUPP = 45; // Operation not supported | |
| 54 | pub const ENOTSUP = EOPNOTSUPP; // Operation not supported | |
| 55 | pub const EPFNOSUPPORT = 46; // Protocol family not supported | |
| 56 | pub const EAFNOSUPPORT = 47; // Address family not supported by protocol family | |
| 57 | pub const EADDRINUSE = 48; // Address already in use | |
| 58 | pub const EADDRNOTAVAIL = 49; // Can't assign requested address | |
| 59 | ||
| 60 | // ipc/network software -- operational errors | |
| 61 | pub const ENETDOWN = 50; // Network is down | |
| 62 | pub const ENETUNREACH = 51; // Network is unreachable | |
| 63 | pub const ENETRESET = 52; // Network dropped connection on reset | |
| 64 | pub const ECONNABORTED = 53; // Software caused connection abort | |
| 65 | pub const ECONNRESET = 54; // Connection reset by peer | |
| 66 | pub const ENOBUFS = 55; // No buffer space available | |
| 67 | pub const EISCONN = 56; // Socket is already connected | |
| 68 | pub const ENOTCONN = 57; // Socket is not connected | |
| 69 | pub const ESHUTDOWN = 58; // Can't send after socket shutdown | |
| 70 | pub const ETOOMANYREFS = 59; // Too many references: can't splice | |
| 71 | pub const ETIMEDOUT = 60; // Operation timed out | |
| 72 | pub const ECONNREFUSED = 61; // Connection refused | |
| 73 | ||
| 74 | pub const ELOOP = 62; // Too many levels of symbolic links | |
| 75 | pub const ENAMETOOLONG = 63; // File name too long | |
| 76 | ||
| 77 | // should be rearranged | |
| 78 | pub const EHOSTDOWN = 64; // Host is down | |
| 79 | pub const EHOSTUNREACH = 65; // No route to host | |
| 80 | pub const ENOTEMPTY = 66; // Directory not empty | |
| 81 | ||
| 82 | // quotas & mush | |
| 83 | pub const EPROCLIM = 67; // Too many processes | |
| 84 | pub const EUSERS = 68; // Too many users | |
| 85 | pub const EDQUOT = 69; // Disc quota exceeded | |
| 86 | ||
| 87 | // Network File System | |
| 88 | pub const ESTALE = 70; // Stale NFS file handle | |
| 89 | pub const EREMOTE = 71; // Too many levels of remote in path | |
| 90 | pub const EBADRPC = 72; // RPC struct is bad | |
| 91 | pub const ERPCMISMATCH = 73; // RPC version wrong | |
| 92 | pub const EPROGUNAVAIL = 74; // RPC prog. not avail | |
| 93 | pub const EPROGMISMATCH = 75; // Program version wrong | |
| 94 | pub const EPROCUNAVAIL = 76; // Bad procedure for program | |
| 95 | ||
| 96 | pub const ENOLCK = 77; // No locks available | |
| 97 | pub const ENOSYS = 78; // Function not implemented | |
| 98 | ||
| 99 | pub const EFTYPE = 79; // Inappropriate file type or format | |
| 100 | pub const EAUTH = 80; // Authentication error | |
| 101 | pub const ENEEDAUTH = 81; // Need authenticator | |
| 102 | pub const EIDRM = 82; // Identifier removed | |
| 103 | pub const ENOMSG = 83; // No message of desired type | |
| 104 | pub const EOVERFLOW = 84; // Value too large to be stored in data type | |
| 105 | pub const ECANCELED = 85; // Operation canceled | |
| 106 | pub const EILSEQ = 86; // Illegal byte sequence | |
| 107 | pub const ENOATTR = 87; // Attribute not found | |
| 108 | ||
| 109 | pub const EDOOFUS = 88; // Programming error | |
| 110 | ||
| 111 | pub const EBADMSG = 89; // Bad message | |
| 112 | pub const EMULTIHOP = 90; // Multihop attempted | |
| 113 | pub const ENOLINK = 91; // Link has been severed | |
| 114 | pub const EPROTO = 92; // Protocol error | |
| 115 | ||
| 116 | pub const ENOTCAPABLE = 93; // Capabilities insufficient | |
| 117 | pub const ECAPMODE = 94; // Not permitted in capability mode | |
| 118 | pub const ENOTRECOVERABLE = 95; // State not recoverable | |
| 119 | pub const EOWNERDEAD = 96; // Previous owner died | |
| 120 | ||
| 121 | pub const ELAST = 96; // Must be equal largest errno |
std/os/freebsd_i386.zig deleted-614| ... | ... | @@ -1,614 +0,0 @@ |
| 1 | const freebsd = @import("freebsd.zig"); | |
| 2 | const socklen_t = freebsd.socklen_t; | |
| 3 | const iovec = freebsd.iovec; | |
| 4 | ||
| 5 | pub const SYS_syscall = 0; | |
| 6 | pub const SYS_exit = 1; | |
| 7 | pub const SYS_fork = 2; | |
| 8 | pub const SYS_read = 3; | |
| 9 | pub const SYS_write = 4; | |
| 10 | pub const SYS_open = 5; | |
| 11 | pub const SYS_close = 6; | |
| 12 | pub const SYS_wait4 = 7; | |
| 13 | // 8 is old creat | |
| 14 | pub const SYS_link = 9; | |
| 15 | pub const SYS_unlink = 10; | |
| 16 | // 11 is obsolete execv | |
| 17 | pub const SYS_chdir = 12; | |
| 18 | pub const SYS_fchdir = 13; | |
| 19 | pub const SYS_freebsd11_mknod = 14; | |
| 20 | pub const SYS_chmod = 15; | |
| 21 | pub const SYS_chown = 16; | |
| 22 | pub const SYS_break = 17; | |
| 23 | // 18 is freebsd4 getfsstat | |
| 24 | // 19 is old lseek | |
| 25 | pub const SYS_getpid = 20; | |
| 26 | pub const SYS_mount = 21; | |
| 27 | pub const SYS_unmount = 22; | |
| 28 | pub const SYS_setuid = 23; | |
| 29 | pub const SYS_getuid = 24; | |
| 30 | pub const SYS_geteuid = 25; | |
| 31 | pub const SYS_ptrace = 26; | |
| 32 | pub const SYS_recvmsg = 27; | |
| 33 | pub const SYS_sendmsg = 28; | |
| 34 | pub const SYS_recvfrom = 29; | |
| 35 | pub const SYS_accept = 30; | |
| 36 | pub const SYS_getpeername = 31; | |
| 37 | pub const SYS_getsockname = 32; | |
| 38 | pub const SYS_access = 33; | |
| 39 | pub const SYS_chflags = 34; | |
| 40 | pub const SYS_fchflags = 35; | |
| 41 | pub const SYS_sync = 36; | |
| 42 | pub const SYS_kill = 37; | |
| 43 | // 38 is old stat | |
| 44 | pub const SYS_getppid = 39; | |
| 45 | // 40 is old lstat | |
| 46 | pub const SYS_dup = 41; | |
| 47 | pub const SYS_freebsd10_pipe = 42; | |
| 48 | pub const SYS_getegid = 43; | |
| 49 | pub const SYS_profil = 44; | |
| 50 | pub const SYS_ktrace = 45; | |
| 51 | // 46 is old sigaction | |
| 52 | pub const SYS_getgid = 47; | |
| 53 | // 48 is old sigprocmask | |
| 54 | pub const SYS_getlogin = 49; | |
| 55 | pub const SYS_setlogin = 50; | |
| 56 | pub const SYS_acct = 51; | |
| 57 | // 52 is old sigpending | |
| 58 | pub const SYS_sigaltstack = 53; | |
| 59 | pub const SYS_ioctl = 54; | |
| 60 | pub const SYS_reboot = 55; | |
| 61 | pub const SYS_revoke = 56; | |
| 62 | pub const SYS_symlink = 57; | |
| 63 | pub const SYS_readlink = 58; | |
| 64 | pub const SYS_execve = 59; | |
| 65 | pub const SYS_umask = 60; | |
| 66 | pub const SYS_chroot = 61; | |
| 67 | // 62 is old fstat | |
| 68 | // 63 is old getkerninfo | |
| 69 | // 64 is old getpagesize | |
| 70 | pub const SYS_msync = 65; | |
| 71 | pub const SYS_vfork = 66; | |
| 72 | // 67 is obsolete vread | |
| 73 | // 68 is obsolete vwrite | |
| 74 | pub const SYS_sbrk = 69; | |
| 75 | pub const SYS_sstk = 70; | |
| 76 | // 71 is old mmap | |
| 77 | pub const SYS_vadvise = 72; | |
| 78 | pub const SYS_munmap = 73; | |
| 79 | pub const SYS_mprotect = 74; | |
| 80 | pub const SYS_madvise = 75; | |
| 81 | // 76 is obsolete vhangup | |
| 82 | // 77 is obsolete vlimit | |
| 83 | pub const SYS_mincore = 78; | |
| 84 | pub const SYS_getgroups = 79; | |
| 85 | pub const SYS_setgroups = 80; | |
| 86 | pub const SYS_getpgrp = 81; | |
| 87 | pub const SYS_setpgid = 82; | |
| 88 | pub const SYS_setitimer = 83; | |
| 89 | // 84 is old wait | |
| 90 | pub const SYS_swapon = 85; | |
| 91 | pub const SYS_getitimer = 86; | |
| 92 | // 87 is old gethostname | |
| 93 | // 88 is old sethostname | |
| 94 | pub const SYS_getdtablesize = 89; | |
| 95 | pub const SYS_dup2 = 90; | |
| 96 | pub const SYS_fcntl = 92; | |
| 97 | pub const SYS_select = 93; | |
| 98 | pub const SYS_fsync = 95; | |
| 99 | pub const SYS_setpriority = 96; | |
| 100 | pub const SYS_socket = 97; | |
| 101 | pub const SYS_connect = 98; | |
| 102 | // 99 is old accept | |
| 103 | pub const SYS_getpriority = 100; | |
| 104 | // 101 is old send | |
| 105 | // 102 is old recv | |
| 106 | // 103 is old sigreturn | |
| 107 | pub const SYS_bind = 104; | |
| 108 | pub const SYS_setsockopt = 105; | |
| 109 | pub const SYS_listen = 106; | |
| 110 | // 107 is obsolete vtimes | |
| 111 | // 108 is old sigvec | |
| 112 | // 109 is old sigblock | |
| 113 | // 110 is old sigsetmask | |
| 114 | // 111 is old sigsuspend | |
| 115 | // 112 is old sigstack | |
| 116 | // 113 is old recvmsg | |
| 117 | // 114 is old sendmsg | |
| 118 | // 115 is obsolete vtrace | |
| 119 | pub const SYS_gettimeofday = 116; | |
| 120 | pub const SYS_getrusage = 117; | |
| 121 | pub const SYS_getsockopt = 118; | |
| 122 | pub const SYS_readv = 120; | |
| 123 | pub const SYS_writev = 121; | |
| 124 | pub const SYS_settimeofday = 122; | |
| 125 | pub const SYS_fchown = 123; | |
| 126 | pub const SYS_fchmod = 124; | |
| 127 | // 125 is old recvfrom | |
| 128 | pub const SYS_setreuid = 126; | |
| 129 | pub const SYS_setregid = 127; | |
| 130 | pub const SYS_rename = 128; | |
| 131 | // 129 is old truncate | |
| 132 | // 130 is old ftruncate | |
| 133 | pub const SYS_flock = 131; | |
| 134 | pub const SYS_mkfifo = 132; | |
| 135 | pub const SYS_sendto = 133; | |
| 136 | pub const SYS_shutdown = 134; | |
| 137 | pub const SYS_socketpair = 135; | |
| 138 | pub const SYS_mkdir = 136; | |
| 139 | pub const SYS_rmdir = 137; | |
| 140 | pub const SYS_utimes = 138; | |
| 141 | // 139 is obsolete 4.2 sigreturn | |
| 142 | pub const SYS_adjtime = 140; | |
| 143 | // 141 is old getpeername | |
| 144 | // 142 is old gethostid | |
| 145 | // 143 is old sethostid | |
| 146 | // 144 is old getrlimit | |
| 147 | // 145 is old setrlimit | |
| 148 | // 146 is old killpg | |
| 149 | pub const SYS_setsid = 147; | |
| 150 | pub const SYS_quotactl = 148; | |
| 151 | // 149 is old quota | |
| 152 | // 150 is old getsockname | |
| 153 | pub const SYS_nlm_syscall = 154; | |
| 154 | pub const SYS_nfssvc = 155; | |
| 155 | // 156 is old getdirentries | |
| 156 | // 157 is freebsd4 statfs | |
| 157 | // 158 is freebsd4 fstatfs | |
| 158 | pub const SYS_lgetfh = 160; | |
| 159 | pub const SYS_getfh = 161; | |
| 160 | // 162 is freebsd4 getdomainname | |
| 161 | // 163 is freebsd4 setdomainname | |
| 162 | // 164 is freebsd4 uname | |
| 163 | pub const SYS_sysarch = 165; | |
| 164 | pub const SYS_rtprio = 166; | |
| 165 | pub const SYS_semsys = 169; | |
| 166 | pub const SYS_msgsys = 170; | |
| 167 | pub const SYS_shmsys = 171; | |
| 168 | // 173 is freebsd6 pread | |
| 169 | // 174 is freebsd6 pwrite | |
| 170 | pub const SYS_setfib = 175; | |
| 171 | pub const SYS_ntp_adjtime = 176; | |
| 172 | pub const SYS_setgid = 181; | |
| 173 | pub const SYS_setegid = 182; | |
| 174 | pub const SYS_seteuid = 183; | |
| 175 | pub const SYS_freebsd11_stat = 188; | |
| 176 | pub const SYS_freebsd11_fstat = 189; | |
| 177 | pub const SYS_freebsd11_lstat = 190; | |
| 178 | pub const SYS_pathconf = 191; | |
| 179 | pub const SYS_fpathconf = 192; | |
| 180 | pub const SYS_getrlimit = 194; | |
| 181 | pub const SYS_setrlimit = 195; | |
| 182 | pub const SYS_freebsd11_getdirentries = 196; | |
| 183 | // 197 is freebsd6 mmap | |
| 184 | pub const SYS___syscall = 198; | |
| 185 | // 199 is freebsd6 lseek | |
| 186 | // 200 is freebsd6 truncate | |
| 187 | // 201 is freebsd6 ftruncate | |
| 188 | pub const SYS___sysctl = 202; | |
| 189 | pub const SYS_mlock = 203; | |
| 190 | pub const SYS_munlock = 204; | |
| 191 | pub const SYS_undelete = 205; | |
| 192 | pub const SYS_futimes = 206; | |
| 193 | pub const SYS_getpgid = 207; | |
| 194 | pub const SYS_poll = 209; | |
| 195 | pub const SYS_freebsd7___semctl = 220; | |
| 196 | pub const SYS_semget = 221; | |
| 197 | pub const SYS_semop = 222; | |
| 198 | pub const SYS_freebsd7_msgctl = 224; | |
| 199 | pub const SYS_msgget = 225; | |
| 200 | pub const SYS_msgsnd = 226; | |
| 201 | pub const SYS_msgrcv = 227; | |
| 202 | pub const SYS_shmat = 228; | |
| 203 | pub const SYS_freebsd7_shmctl = 229; | |
| 204 | pub const SYS_shmdt = 230; | |
| 205 | pub const SYS_shmget = 231; | |
| 206 | pub const SYS_clock_gettime = 232; | |
| 207 | pub const SYS_clock_settime = 233; | |
| 208 | pub const SYS_clock_getres = 234; | |
| 209 | pub const SYS_ktimer_create = 235; | |
| 210 | pub const SYS_ktimer_delete = 236; | |
| 211 | pub const SYS_ktimer_settime = 237; | |
| 212 | pub const SYS_ktimer_gettime = 238; | |
| 213 | pub const SYS_ktimer_getoverrun = 239; | |
| 214 | pub const SYS_nanosleep = 240; | |
| 215 | pub const SYS_ffclock_getcounter = 241; | |
| 216 | pub const SYS_ffclock_setestimate = 242; | |
| 217 | pub const SYS_ffclock_getestimate = 243; | |
| 218 | pub const SYS_clock_nanosleep = 244; | |
| 219 | pub const SYS_clock_getcpuclockid2 = 247; | |
| 220 | pub const SYS_ntp_gettime = 248; | |
| 221 | pub const SYS_minherit = 250; | |
| 222 | pub const SYS_rfork = 251; | |
| 223 | // 252 is obsolete openbsd_poll | |
| 224 | pub const SYS_issetugid = 253; | |
| 225 | pub const SYS_lchown = 254; | |
| 226 | pub const SYS_aio_read = 255; | |
| 227 | pub const SYS_aio_write = 256; | |
| 228 | pub const SYS_lio_listio = 257; | |
| 229 | pub const SYS_freebsd11_getdents = 272; | |
| 230 | pub const SYS_lchmod = 274; | |
| 231 | pub const SYS_netbsd_lchown = 275; | |
| 232 | pub const SYS_lutimes = 276; | |
| 233 | pub const SYS_netbsd_msync = 277; | |
| 234 | pub const SYS_freebsd11_nstat = 278; | |
| 235 | pub const SYS_freebsd11_nfstat = 279; | |
| 236 | pub const SYS_freebsd11_nlstat = 280; | |
| 237 | pub const SYS_preadv = 289; | |
| 238 | pub const SYS_pwritev = 290; | |
| 239 | // 297 is freebsd4 fhstatfs | |
| 240 | pub const SYS_fhopen = 298; | |
| 241 | pub const SYS_freebsd11_fhstat = 299; | |
| 242 | pub const SYS_modnext = 300; | |
| 243 | pub const SYS_modstat = 301; | |
| 244 | pub const SYS_modfnext = 302; | |
| 245 | pub const SYS_modfind = 303; | |
| 246 | pub const SYS_kldload = 304; | |
| 247 | pub const SYS_kldunload = 305; | |
| 248 | pub const SYS_kldfind = 306; | |
| 249 | pub const SYS_kldnext = 307; | |
| 250 | pub const SYS_kldstat = 308; | |
| 251 | pub const SYS_kldfirstmod = 309; | |
| 252 | pub const SYS_getsid = 310; | |
| 253 | pub const SYS_setresuid = 311; | |
| 254 | pub const SYS_setresgid = 312; | |
| 255 | // 313 is obsolete signanosleep | |
| 256 | pub const SYS_aio_return = 314; | |
| 257 | pub const SYS_aio_suspend = 315; | |
| 258 | pub const SYS_aio_cancel = 316; | |
| 259 | pub const SYS_aio_error = 317; | |
| 260 | // 318 is freebsd6 aio_read | |
| 261 | // 319 is freebsd6 aio_write | |
| 262 | // 320 is freebsd6 lio_listio | |
| 263 | pub const SYS_yield = 321; | |
| 264 | // 322 is obsolete thr_sleep | |
| 265 | // 323 is obsolete thr_wakeup | |
| 266 | pub const SYS_mlockall = 324; | |
| 267 | pub const SYS_munlockall = 325; | |
| 268 | pub const SYS___getcwd = 326; | |
| 269 | pub const SYS_sched_setparam = 327; | |
| 270 | pub const SYS_sched_getparam = 328; | |
| 271 | pub const SYS_sched_setscheduler = 329; | |
| 272 | pub const SYS_sched_getscheduler = 330; | |
| 273 | pub const SYS_sched_yield = 331; | |
| 274 | pub const SYS_sched_get_priority_max = 332; | |
| 275 | pub const SYS_sched_get_priority_min = 333; | |
| 276 | pub const SYS_sched_rr_get_interval = 334; | |
| 277 | pub const SYS_utrace = 335; | |
| 278 | // 336 is freebsd4 sendfile | |
| 279 | pub const SYS_kldsym = 337; | |
| 280 | pub const SYS_jail = 338; | |
| 281 | pub const SYS_nnpfs_syscall = 339; | |
| 282 | pub const SYS_sigprocmask = 340; | |
| 283 | pub const SYS_sigsuspend = 341; | |
| 284 | // 342 is freebsd4 sigaction | |
| 285 | pub const SYS_sigpending = 343; | |
| 286 | // 344 is freebsd4 sigreturn | |
| 287 | pub const SYS_sigtimedwait = 345; | |
| 288 | pub const SYS_sigwaitinfo = 346; | |
| 289 | pub const SYS___acl_get_file = 347; | |
| 290 | pub const SYS___acl_set_file = 348; | |
| 291 | pub const SYS___acl_get_fd = 349; | |
| 292 | pub const SYS___acl_set_fd = 350; | |
| 293 | pub const SYS___acl_delete_file = 351; | |
| 294 | pub const SYS___acl_delete_fd = 352; | |
| 295 | pub const SYS___acl_aclcheck_file = 353; | |
| 296 | pub const SYS___acl_aclcheck_fd = 354; | |
| 297 | pub const SYS_extattrctl = 355; | |
| 298 | pub const SYS_extattr_set_file = 356; | |
| 299 | pub const SYS_extattr_get_file = 357; | |
| 300 | pub const SYS_extattr_delete_file = 358; | |
| 301 | pub const SYS_aio_waitcomplete = 359; | |
| 302 | pub const SYS_getresuid = 360; | |
| 303 | pub const SYS_getresgid = 361; | |
| 304 | pub const SYS_kqueue = 362; | |
| 305 | pub const SYS_freebsd11_kevent = 363; | |
| 306 | pub const SYS_extattr_set_fd = 371; | |
| 307 | pub const SYS_extattr_get_fd = 372; | |
| 308 | pub const SYS_extattr_delete_fd = 373; | |
| 309 | pub const SYS___setugid = 374; | |
| 310 | pub const SYS_eaccess = 376; | |
| 311 | pub const SYS_afs3_syscall = 377; | |
| 312 | pub const SYS_nmount = 378; | |
| 313 | pub const SYS___mac_get_proc = 384; | |
| 314 | pub const SYS___mac_set_proc = 385; | |
| 315 | pub const SYS___mac_get_fd = 386; | |
| 316 | pub const SYS___mac_get_file = 387; | |
| 317 | pub const SYS___mac_set_fd = 388; | |
| 318 | pub const SYS___mac_set_file = 389; | |
| 319 | pub const SYS_kenv = 390; | |
| 320 | pub const SYS_lchflags = 391; | |
| 321 | pub const SYS_uuidgen = 392; | |
| 322 | pub const SYS_sendfile = 393; | |
| 323 | pub const SYS_mac_syscall = 394; | |
| 324 | pub const SYS_freebsd11_getfsstat = 395; | |
| 325 | pub const SYS_freebsd11_statfs = 396; | |
| 326 | pub const SYS_freebsd11_fstatfs = 397; | |
| 327 | pub const SYS_freebsd11_fhstatfs = 398; | |
| 328 | pub const SYS_ksem_close = 400; | |
| 329 | pub const SYS_ksem_post = 401; | |
| 330 | pub const SYS_ksem_wait = 402; | |
| 331 | pub const SYS_ksem_trywait = 403; | |
| 332 | pub const SYS_ksem_init = 404; | |
| 333 | pub const SYS_ksem_open = 405; | |
| 334 | pub const SYS_ksem_unlink = 406; | |
| 335 | pub const SYS_ksem_getvalue = 407; | |
| 336 | pub const SYS_ksem_destroy = 408; | |
| 337 | pub const SYS___mac_get_pid = 409; | |
| 338 | pub const SYS___mac_get_link = 410; | |
| 339 | pub const SYS___mac_set_link = 411; | |
| 340 | pub const SYS_extattr_set_link = 412; | |
| 341 | pub const SYS_extattr_get_link = 413; | |
| 342 | pub const SYS_extattr_delete_link = 414; | |
| 343 | pub const SYS___mac_execve = 415; | |
| 344 | pub const SYS_sigaction = 416; | |
| 345 | pub const SYS_sigreturn = 417; | |
| 346 | pub const SYS_getcontext = 421; | |
| 347 | pub const SYS_setcontext = 422; | |
| 348 | pub const SYS_swapcontext = 423; | |
| 349 | pub const SYS_swapoff = 424; | |
| 350 | pub const SYS___acl_get_link = 425; | |
| 351 | pub const SYS___acl_set_link = 426; | |
| 352 | pub const SYS___acl_delete_link = 427; | |
| 353 | pub const SYS___acl_aclcheck_link = 428; | |
| 354 | pub const SYS_sigwait = 429; | |
| 355 | pub const SYS_thr_create = 430; | |
| 356 | pub const SYS_thr_exit = 431; | |
| 357 | pub const SYS_thr_self = 432; | |
| 358 | pub const SYS_thr_kill = 433; | |
| 359 | pub const SYS_jail_attach = 436; | |
| 360 | pub const SYS_extattr_list_fd = 437; | |
| 361 | pub const SYS_extattr_list_file = 438; | |
| 362 | pub const SYS_extattr_list_link = 439; | |
| 363 | pub const SYS_ksem_timedwait = 441; | |
| 364 | pub const SYS_thr_suspend = 442; | |
| 365 | pub const SYS_thr_wake = 443; | |
| 366 | pub const SYS_kldunloadf = 444; | |
| 367 | pub const SYS_audit = 445; | |
| 368 | pub const SYS_auditon = 446; | |
| 369 | pub const SYS_getauid = 447; | |
| 370 | pub const SYS_setauid = 448; | |
| 371 | pub const SYS_getaudit = 449; | |
| 372 | pub const SYS_setaudit = 450; | |
| 373 | pub const SYS_getaudit_addr = 451; | |
| 374 | pub const SYS_setaudit_addr = 452; | |
| 375 | pub const SYS_auditctl = 453; | |
| 376 | pub const SYS__umtx_op = 454; | |
| 377 | pub const SYS_thr_new = 455; | |
| 378 | pub const SYS_sigqueue = 456; | |
| 379 | pub const SYS_kmq_open = 457; | |
| 380 | pub const SYS_kmq_setattr = 458; | |
| 381 | pub const SYS_kmq_timedreceive = 459; | |
| 382 | pub const SYS_kmq_timedsend = 460; | |
| 383 | pub const SYS_kmq_notify = 461; | |
| 384 | pub const SYS_kmq_unlink = 462; | |
| 385 | pub const SYS_abort2 = 463; | |
| 386 | pub const SYS_thr_set_name = 464; | |
| 387 | pub const SYS_aio_fsync = 465; | |
| 388 | pub const SYS_rtprio_thread = 466; | |
| 389 | pub const SYS_sctp_peeloff = 471; | |
| 390 | pub const SYS_sctp_generic_sendmsg = 472; | |
| 391 | pub const SYS_sctp_generic_sendmsg_iov = 473; | |
| 392 | pub const SYS_sctp_generic_recvmsg = 474; | |
| 393 | pub const SYS_pread = 475; | |
| 394 | pub const SYS_pwrite = 476; | |
| 395 | pub const SYS_mmap = 477; | |
| 396 | pub const SYS_lseek = 478; | |
| 397 | pub const SYS_truncate = 479; | |
| 398 | pub const SYS_ftruncate = 480; | |
| 399 | pub const SYS_thr_kill2 = 481; | |
| 400 | pub const SYS_shm_open = 482; | |
| 401 | pub const SYS_shm_unlink = 483; | |
| 402 | pub const SYS_cpuset = 484; | |
| 403 | pub const SYS_cpuset_setid = 485; | |
| 404 | pub const SYS_cpuset_getid = 486; | |
| 405 | pub const SYS_cpuset_getaffinity = 487; | |
| 406 | pub const SYS_cpuset_setaffinity = 488; | |
| 407 | pub const SYS_faccessat = 489; | |
| 408 | pub const SYS_fchmodat = 490; | |
| 409 | pub const SYS_fchownat = 491; | |
| 410 | pub const SYS_fexecve = 492; | |
| 411 | pub const SYS_freebsd11_fstatat = 493; | |
| 412 | pub const SYS_futimesat = 494; | |
| 413 | pub const SYS_linkat = 495; | |
| 414 | pub const SYS_mkdirat = 496; | |
| 415 | pub const SYS_mkfifoat = 497; | |
| 416 | pub const SYS_freebsd11_mknodat = 498; | |
| 417 | pub const SYS_openat = 499; | |
| 418 | pub const SYS_readlinkat = 500; | |
| 419 | pub const SYS_renameat = 501; | |
| 420 | pub const SYS_symlinkat = 502; | |
| 421 | pub const SYS_unlinkat = 503; | |
| 422 | pub const SYS_posix_openpt = 504; | |
| 423 | pub const SYS_gssd_syscall = 505; | |
| 424 | pub const SYS_jail_get = 506; | |
| 425 | pub const SYS_jail_set = 507; | |
| 426 | pub const SYS_jail_remove = 508; | |
| 427 | pub const SYS_closefrom = 509; | |
| 428 | pub const SYS___semctl = 510; | |
| 429 | pub const SYS_msgctl = 511; | |
| 430 | pub const SYS_shmctl = 512; | |
| 431 | pub const SYS_lpathconf = 513; | |
| 432 | // 514 is obsolete cap_new | |
| 433 | pub const SYS___cap_rights_get = 515; | |
| 434 | pub const SYS_cap_enter = 516; | |
| 435 | pub const SYS_cap_getmode = 517; | |
| 436 | pub const SYS_pdfork = 518; | |
| 437 | pub const SYS_pdkill = 519; | |
| 438 | pub const SYS_pdgetpid = 520; | |
| 439 | pub const SYS_pselect = 522; | |
| 440 | pub const SYS_getloginclass = 523; | |
| 441 | pub const SYS_setloginclass = 524; | |
| 442 | pub const SYS_rctl_get_racct = 525; | |
| 443 | pub const SYS_rctl_get_rules = 526; | |
| 444 | pub const SYS_rctl_get_limits = 527; | |
| 445 | pub const SYS_rctl_add_rule = 528; | |
| 446 | pub const SYS_rctl_remove_rule = 529; | |
| 447 | pub const SYS_posix_fallocate = 530; | |
| 448 | pub const SYS_posix_fadvise = 531; | |
| 449 | pub const SYS_wait6 = 532; | |
| 450 | pub const SYS_cap_rights_limit = 533; | |
| 451 | pub const SYS_cap_ioctls_limit = 534; | |
| 452 | pub const SYS_cap_ioctls_get = 535; | |
| 453 | pub const SYS_cap_fcntls_limit = 536; | |
| 454 | pub const SYS_cap_fcntls_get = 537; | |
| 455 | pub const SYS_bindat = 538; | |
| 456 | pub const SYS_connectat = 539; | |
| 457 | pub const SYS_chflagsat = 540; | |
| 458 | pub const SYS_accept4 = 541; | |
| 459 | pub const SYS_pipe2 = 542; | |
| 460 | pub const SYS_aio_mlock = 543; | |
| 461 | pub const SYS_procctl = 544; | |
| 462 | pub const SYS_ppoll = 545; | |
| 463 | pub const SYS_futimens = 546; | |
| 464 | pub const SYS_utimensat = 547; | |
| 465 | pub const SYS_numa_getaffinity = 548; | |
| 466 | pub const SYS_numa_setaffinity = 549; | |
| 467 | pub const SYS_fdatasync = 550; | |
| 468 | pub const SYS_fstat = 551; | |
| 469 | pub const SYS_fstatat = 552; | |
| 470 | pub const SYS_fhstat = 553; | |
| 471 | pub const SYS_getdirentries = 554; | |
| 472 | pub const SYS_statfs = 555; | |
| 473 | pub const SYS_fstatfs = 556; | |
| 474 | pub const SYS_getfsstat = 557; | |
| 475 | pub const SYS_fhstatfs = 558; | |
| 476 | pub const SYS_mknodat = 559; | |
| 477 | pub const SYS_kevent = 560; | |
| 478 | pub const SYS_MAXSYSCALL = 561; | |
| 479 | ||
| 480 | // From here | |
| 481 | pub const O_CREAT = 0o100; | |
| 482 | pub const O_EXCL = 0o200; | |
| 483 | pub const O_NOCTTY = 0o400; | |
| 484 | pub const O_TRUNC = 0o1000; | |
| 485 | pub const O_APPEND = 0o2000; | |
| 486 | pub const O_NONBLOCK = 0o4000; | |
| 487 | pub const O_DSYNC = 0o10000; | |
| 488 | pub const O_SYNC = 0o4010000; | |
| 489 | pub const O_RSYNC = 0o4010000; | |
| 490 | pub const O_DIRECTORY = 0o200000; | |
| 491 | pub const O_NOFOLLOW = 0o400000; | |
| 492 | pub const O_CLOEXEC = 0o2000000; | |
| 493 | ||
| 494 | pub const O_ASYNC = 0o20000; | |
| 495 | pub const O_DIRECT = 0o40000; | |
| 496 | pub const O_LARGEFILE = 0o100000; | |
| 497 | pub const O_NOATIME = 0o1000000; | |
| 498 | pub const O_PATH = 0o10000000; | |
| 499 | pub const O_TMPFILE = 0o20200000; | |
| 500 | pub const O_NDELAY = O_NONBLOCK; | |
| 501 | ||
| 502 | pub const F_DUPFD = 0; | |
| 503 | pub const F_GETFD = 1; | |
| 504 | pub const F_SETFD = 2; | |
| 505 | pub const F_GETFL = 3; | |
| 506 | pub const F_SETFL = 4; | |
| 507 | ||
| 508 | pub const F_SETOWN = 8; | |
| 509 | pub const F_GETOWN = 9; | |
| 510 | pub const F_SETSIG = 10; | |
| 511 | pub const F_GETSIG = 11; | |
| 512 | ||
| 513 | pub const F_GETLK = 12; | |
| 514 | pub const F_SETLK = 13; | |
| 515 | pub const F_SETLKW = 14; | |
| 516 | ||
| 517 | pub const F_SETOWN_EX = 15; | |
| 518 | pub const F_GETOWN_EX = 16; | |
| 519 | ||
| 520 | pub const F_GETOWNER_UIDS = 17; | |
| 521 | ||
| 522 | pub inline fn syscall0(number: usize) -> usize { | |
| 523 | asm volatile ("int $0x80" | |
| 524 | : [ret] "={eax}" (-> usize) | |
| 525 | : [number] "{eax}" (number)) | |
| 526 | } | |
| 527 | ||
| 528 | pub inline fn syscall1(number: usize, arg1: usize) -> usize { | |
| 529 | asm volatile ("int $0x80" | |
| 530 | : [ret] "={eax}" (-> usize) | |
| 531 | : [number] "{eax}" (number), | |
| 532 | [arg1] "{ebx}" (arg1)) | |
| 533 | } | |
| 534 | ||
| 535 | pub inline fn syscall2(number: usize, arg1: usize, arg2: usize) -> usize { | |
| 536 | asm volatile ("int $0x80" | |
| 537 | : [ret] "={eax}" (-> usize) | |
| 538 | : [number] "{eax}" (number), | |
| 539 | [arg1] "{ebx}" (arg1), | |
| 540 | [arg2] "{ecx}" (arg2)) | |
| 541 | } | |
| 542 | ||
| 543 | pub inline fn syscall3(number: usize, arg1: usize, arg2: usize, arg3: usize) -> usize { | |
| 544 | asm volatile ("int $0x80" | |
| 545 | : [ret] "={eax}" (-> usize) | |
| 546 | : [number] "{eax}" (number), | |
| 547 | [arg1] "{ebx}" (arg1), | |
| 548 | [arg2] "{ecx}" (arg2), | |
| 549 | [arg3] "{edx}" (arg3)) | |
| 550 | } | |
| 551 | ||
| 552 | pub inline fn syscall4(number: usize, arg1: usize, arg2: usize, arg3: usize, arg4: usize) -> usize { | |
| 553 | asm volatile ("int $0x80" | |
| 554 | : [ret] "={eax}" (-> usize) | |
| 555 | : [number] "{eax}" (number), | |
| 556 | [arg1] "{ebx}" (arg1), | |
| 557 | [arg2] "{ecx}" (arg2), | |
| 558 | [arg3] "{edx}" (arg3), | |
| 559 | [arg4] "{esi}" (arg4)) | |
| 560 | } | |
| 561 | ||
| 562 | pub inline fn syscall5(number: usize, arg1: usize, arg2: usize, arg3: usize, | |
| 563 | arg4: usize, arg5: usize) -> usize | |
| 564 | { | |
| 565 | asm volatile ("int $0x80" | |
| 566 | : [ret] "={eax}" (-> usize) | |
| 567 | : [number] "{eax}" (number), | |
| 568 | [arg1] "{ebx}" (arg1), | |
| 569 | [arg2] "{ecx}" (arg2), | |
| 570 | [arg3] "{edx}" (arg3), | |
| 571 | [arg4] "{esi}" (arg4), | |
| 572 | [arg5] "{edi}" (arg5)) | |
| 573 | } | |
| 574 | ||
| 575 | pub inline fn syscall6(number: usize, arg1: usize, arg2: usize, arg3: usize, | |
| 576 | arg4: usize, arg5: usize, arg6: usize) -> usize | |
| 577 | { | |
| 578 | asm volatile ("int $0x80" | |
| 579 | : [ret] "={eax}" (-> usize) | |
| 580 | : [number] "{eax}" (number), | |
| 581 | [arg1] "{ebx}" (arg1), | |
| 582 | [arg2] "{ecx}" (arg2), | |
| 583 | [arg3] "{edx}" (arg3), | |
| 584 | [arg4] "{esi}" (arg4), | |
| 585 | [arg5] "{edi}" (arg5), | |
| 586 | [arg6] "{ebp}" (arg6)) | |
| 587 | } | |
| 588 | ||
| 589 | pub nakedcc fn restore() { | |
| 590 | asm volatile ( | |
| 591 | \\popl %%eax | |
| 592 | \\movl $119, %%eax | |
| 593 | \\int $0x80 | |
| 594 | : | |
| 595 | : | |
| 596 | : "rcx", "r11") | |
| 597 | } | |
| 598 | ||
| 599 | pub nakedcc fn restore_rt() { | |
| 600 | asm volatile ("int $0x80" | |
| 601 | : | |
| 602 | : [number] "{eax}" (usize(SYS_rt_sigreturn)) | |
| 603 | : "rcx", "r11") | |
| 604 | } | |
| 605 | ||
| 606 | export struct msghdr { | |
| 607 | msg_name: &u8, | |
| 608 | msg_namelen: socklen_t, | |
| 609 | msg_iov: &iovec, | |
| 610 | msg_iovlen: i32, | |
| 611 | msg_control: &u8, | |
| 612 | msg_controllen: socklen_t, | |
| 613 | msg_flags: i32, | |
| 614 | } |
std/os/freebsd_x86_64.zig deleted-650| ... | ... | @@ -1,650 +0,0 @@ |
| 1 | const freebsd = @import("index.zig"); | |
| 2 | const socklen_t = freebsd.socklen_t; | |
| 3 | const iovec = freebsd.iovec; | |
| 4 | ||
| 5 | pub const SYS_syscall = 0; | |
| 6 | pub const SYS_exit = 1; | |
| 7 | pub const SYS_fork = 2; | |
| 8 | pub const SYS_read = 3; | |
| 9 | pub const SYS_write = 4; | |
| 10 | pub const SYS_open = 5; | |
| 11 | pub const SYS_close = 6; | |
| 12 | pub const SYS_wait4 = 7; | |
| 13 | // 8 is old creat | |
| 14 | pub const SYS_link = 9; | |
| 15 | pub const SYS_unlink = 10; | |
| 16 | // 11 is obsolete execv | |
| 17 | pub const SYS_chdir = 12; | |
| 18 | pub const SYS_fchdir = 13; | |
| 19 | pub const SYS_freebsd11_mknod = 14; | |
| 20 | pub const SYS_chmod = 15; | |
| 21 | pub const SYS_chown = 16; | |
| 22 | pub const SYS_break = 17; | |
| 23 | // 18 is freebsd4 getfsstat | |
| 24 | // 19 is old lseek | |
| 25 | pub const SYS_getpid = 20; | |
| 26 | pub const SYS_mount = 21; | |
| 27 | pub const SYS_unmount = 22; | |
| 28 | pub const SYS_setuid = 23; | |
| 29 | pub const SYS_getuid = 24; | |
| 30 | pub const SYS_geteuid = 25; | |
| 31 | pub const SYS_ptrace = 26; | |
| 32 | pub const SYS_recvmsg = 27; | |
| 33 | pub const SYS_sendmsg = 28; | |
| 34 | pub const SYS_recvfrom = 29; | |
| 35 | pub const SYS_accept = 30; | |
| 36 | pub const SYS_getpeername = 31; | |
| 37 | pub const SYS_getsockname = 32; | |
| 38 | pub const SYS_access = 33; | |
| 39 | pub const SYS_chflags = 34; | |
| 40 | pub const SYS_fchflags = 35; | |
| 41 | pub const SYS_sync = 36; | |
| 42 | pub const SYS_kill = 37; | |
| 43 | // 38 is old stat | |
| 44 | pub const SYS_getppid = 39; | |
| 45 | // 40 is old lstat | |
| 46 | pub const SYS_dup = 41; | |
| 47 | pub const SYS_freebsd10_pipe = 42; | |
| 48 | pub const SYS_getegid = 43; | |
| 49 | pub const SYS_profil = 44; | |
| 50 | pub const SYS_ktrace = 45; | |
| 51 | // 46 is old sigaction | |
| 52 | pub const SYS_getgid = 47; | |
| 53 | // 48 is old sigprocmask | |
| 54 | pub const SYS_getlogin = 49; | |
| 55 | pub const SYS_setlogin = 50; | |
| 56 | pub const SYS_acct = 51; | |
| 57 | // 52 is old sigpending | |
| 58 | pub const SYS_sigaltstack = 53; | |
| 59 | pub const SYS_ioctl = 54; | |
| 60 | pub const SYS_reboot = 55; | |
| 61 | pub const SYS_revoke = 56; | |
| 62 | pub const SYS_symlink = 57; | |
| 63 | pub const SYS_readlink = 58; | |
| 64 | pub const SYS_execve = 59; | |
| 65 | pub const SYS_umask = 60; | |
| 66 | pub const SYS_chroot = 61; | |
| 67 | // 62 is old fstat | |
| 68 | // 63 is old getkerninfo | |
| 69 | // 64 is old getpagesize | |
| 70 | pub const SYS_msync = 65; | |
| 71 | pub const SYS_vfork = 66; | |
| 72 | // 67 is obsolete vread | |
| 73 | // 68 is obsolete vwrite | |
| 74 | pub const SYS_sbrk = 69; | |
| 75 | pub const SYS_sstk = 70; | |
| 76 | // 71 is old mmap | |
| 77 | pub const SYS_vadvise = 72; | |
| 78 | pub const SYS_munmap = 73; | |
| 79 | pub const SYS_mprotect = 74; | |
| 80 | pub const SYS_madvise = 75; | |
| 81 | // 76 is obsolete vhangup | |
| 82 | // 77 is obsolete vlimit | |
| 83 | pub const SYS_mincore = 78; | |
| 84 | pub const SYS_getgroups = 79; | |
| 85 | pub const SYS_setgroups = 80; | |
| 86 | pub const SYS_getpgrp = 81; | |
| 87 | pub const SYS_setpgid = 82; | |
| 88 | pub const SYS_setitimer = 83; | |
| 89 | // 84 is old wait | |
| 90 | pub const SYS_swapon = 85; | |
| 91 | pub const SYS_getitimer = 86; | |
| 92 | // 87 is old gethostname | |
| 93 | // 88 is old sethostname | |
| 94 | pub const SYS_getdtablesize = 89; | |
| 95 | pub const SYS_dup2 = 90; | |
| 96 | pub const SYS_fcntl = 92; | |
| 97 | pub const SYS_select = 93; | |
| 98 | pub const SYS_fsync = 95; | |
| 99 | pub const SYS_setpriority = 96; | |
| 100 | pub const SYS_socket = 97; | |
| 101 | pub const SYS_connect = 98; | |
| 102 | // 99 is old accept | |
| 103 | pub const SYS_getpriority = 100; | |
| 104 | // 101 is old send | |
| 105 | // 102 is old recv | |
| 106 | // 103 is old sigreturn | |
| 107 | pub const SYS_bind = 104; | |
| 108 | pub const SYS_setsockopt = 105; | |
| 109 | pub const SYS_listen = 106; | |
| 110 | // 107 is obsolete vtimes | |
| 111 | // 108 is old sigvec | |
| 112 | // 109 is old sigblock | |
| 113 | // 110 is old sigsetmask | |
| 114 | // 111 is old sigsuspend | |
| 115 | // 112 is old sigstack | |
| 116 | // 113 is old recvmsg | |
| 117 | // 114 is old sendmsg | |
| 118 | // 115 is obsolete vtrace | |
| 119 | pub const SYS_gettimeofday = 116; | |
| 120 | pub const SYS_getrusage = 117; | |
| 121 | pub const SYS_getsockopt = 118; | |
| 122 | pub const SYS_readv = 120; | |
| 123 | pub const SYS_writev = 121; | |
| 124 | pub const SYS_settimeofday = 122; | |
| 125 | pub const SYS_fchown = 123; | |
| 126 | pub const SYS_fchmod = 124; | |
| 127 | // 125 is old recvfrom | |
| 128 | pub const SYS_setreuid = 126; | |
| 129 | pub const SYS_setregid = 127; | |
| 130 | pub const SYS_rename = 128; | |
| 131 | // 129 is old truncate | |
| 132 | // 130 is old ftruncate | |
| 133 | pub const SYS_flock = 131; | |
| 134 | pub const SYS_mkfifo = 132; | |
| 135 | pub const SYS_sendto = 133; | |
| 136 | pub const SYS_shutdown = 134; | |
| 137 | pub const SYS_socketpair = 135; | |
| 138 | pub const SYS_mkdir = 136; | |
| 139 | pub const SYS_rmdir = 137; | |
| 140 | pub const SYS_utimes = 138; | |
| 141 | // 139 is obsolete 4.2 sigreturn | |
| 142 | pub const SYS_adjtime = 140; | |
| 143 | // 141 is old getpeername | |
| 144 | // 142 is old gethostid | |
| 145 | // 143 is old sethostid | |
| 146 | // 144 is old getrlimit | |
| 147 | // 145 is old setrlimit | |
| 148 | // 146 is old killpg | |
| 149 | pub const SYS_setsid = 147; | |
| 150 | pub const SYS_quotactl = 148; | |
| 151 | // 149 is old quota | |
| 152 | // 150 is old getsockname | |
| 153 | pub const SYS_nlm_syscall = 154; | |
| 154 | pub const SYS_nfssvc = 155; | |
| 155 | // 156 is old getdirentries | |
| 156 | // 157 is freebsd4 statfs | |
| 157 | // 158 is freebsd4 fstatfs | |
| 158 | pub const SYS_lgetfh = 160; | |
| 159 | pub const SYS_getfh = 161; | |
| 160 | // 162 is freebsd4 getdomainname | |
| 161 | // 163 is freebsd4 setdomainname | |
| 162 | // 164 is freebsd4 uname | |
| 163 | pub const SYS_sysarch = 165; | |
| 164 | pub const SYS_rtprio = 166; | |
| 165 | pub const SYS_semsys = 169; | |
| 166 | pub const SYS_msgsys = 170; | |
| 167 | pub const SYS_shmsys = 171; | |
| 168 | // 173 is freebsd6 pread | |
| 169 | // 174 is freebsd6 pwrite | |
| 170 | pub const SYS_setfib = 175; | |
| 171 | pub const SYS_ntp_adjtime = 176; | |
| 172 | pub const SYS_setgid = 181; | |
| 173 | pub const SYS_setegid = 182; | |
| 174 | pub const SYS_seteuid = 183; | |
| 175 | pub const SYS_freebsd11_stat = 188; | |
| 176 | pub const SYS_freebsd11_fstat = 189; | |
| 177 | pub const SYS_freebsd11_lstat = 190; | |
| 178 | pub const SYS_pathconf = 191; | |
| 179 | pub const SYS_fpathconf = 192; | |
| 180 | pub const SYS_getrlimit = 194; | |
| 181 | pub const SYS_setrlimit = 195; | |
| 182 | pub const SYS_freebsd11_getdirentries = 196; | |
| 183 | // 197 is freebsd6 mmap | |
| 184 | pub const SYS___syscall = 198; | |
| 185 | // 199 is freebsd6 lseek | |
| 186 | // 200 is freebsd6 truncate | |
| 187 | // 201 is freebsd6 ftruncate | |
| 188 | pub const SYS___sysctl = 202; | |
| 189 | pub const SYS_mlock = 203; | |
| 190 | pub const SYS_munlock = 204; | |
| 191 | pub const SYS_undelete = 205; | |
| 192 | pub const SYS_futimes = 206; | |
| 193 | pub const SYS_getpgid = 207; | |
| 194 | pub const SYS_poll = 209; | |
| 195 | pub const SYS_freebsd7___semctl = 220; | |
| 196 | pub const SYS_semget = 221; | |
| 197 | pub const SYS_semop = 222; | |
| 198 | pub const SYS_freebsd7_msgctl = 224; | |
| 199 | pub const SYS_msgget = 225; | |
| 200 | pub const SYS_msgsnd = 226; | |
| 201 | pub const SYS_msgrcv = 227; | |
| 202 | pub const SYS_shmat = 228; | |
| 203 | pub const SYS_freebsd7_shmctl = 229; | |
| 204 | pub const SYS_shmdt = 230; | |
| 205 | pub const SYS_shmget = 231; | |
| 206 | pub const SYS_clock_gettime = 232; | |
| 207 | pub const SYS_clock_settime = 233; | |
| 208 | pub const SYS_clock_getres = 234; | |
| 209 | pub const SYS_ktimer_create = 235; | |
| 210 | pub const SYS_ktimer_delete = 236; | |
| 211 | pub const SYS_ktimer_settime = 237; | |
| 212 | pub const SYS_ktimer_gettime = 238; | |
| 213 | pub const SYS_ktimer_getoverrun = 239; | |
| 214 | pub const SYS_nanosleep = 240; | |
| 215 | pub const SYS_ffclock_getcounter = 241; | |
| 216 | pub const SYS_ffclock_setestimate = 242; | |
| 217 | pub const SYS_ffclock_getestimate = 243; | |
| 218 | pub const SYS_clock_nanosleep = 244; | |
| 219 | pub const SYS_clock_getcpuclockid2 = 247; | |
| 220 | pub const SYS_ntp_gettime = 248; | |
| 221 | pub const SYS_minherit = 250; | |
| 222 | pub const SYS_rfork = 251; | |
| 223 | // 252 is obsolete openbsd_poll | |
| 224 | pub const SYS_issetugid = 253; | |
| 225 | pub const SYS_lchown = 254; | |
| 226 | pub const SYS_aio_read = 255; | |
| 227 | pub const SYS_aio_write = 256; | |
| 228 | pub const SYS_lio_listio = 257; | |
| 229 | pub const SYS_freebsd11_getdents = 272; | |
| 230 | pub const SYS_lchmod = 274; | |
| 231 | pub const SYS_netbsd_lchown = 275; | |
| 232 | pub const SYS_lutimes = 276; | |
| 233 | pub const SYS_netbsd_msync = 277; | |
| 234 | pub const SYS_freebsd11_nstat = 278; | |
| 235 | pub const SYS_freebsd11_nfstat = 279; | |
| 236 | pub const SYS_freebsd11_nlstat = 280; | |
| 237 | pub const SYS_preadv = 289; | |
| 238 | pub const SYS_pwritev = 290; | |
| 239 | // 297 is freebsd4 fhstatfs | |
| 240 | pub const SYS_fhopen = 298; | |
| 241 | pub const SYS_freebsd11_fhstat = 299; | |
| 242 | pub const SYS_modnext = 300; | |
| 243 | pub const SYS_modstat = 301; | |
| 244 | pub const SYS_modfnext = 302; | |
| 245 | pub const SYS_modfind = 303; | |
| 246 | pub const SYS_kldload = 304; | |
| 247 | pub const SYS_kldunload = 305; | |
| 248 | pub const SYS_kldfind = 306; | |
| 249 | pub const SYS_kldnext = 307; | |
| 250 | pub const SYS_kldstat = 308; | |
| 251 | pub const SYS_kldfirstmod = 309; | |
| 252 | pub const SYS_getsid = 310; | |
| 253 | pub const SYS_setresuid = 311; | |
| 254 | pub const SYS_setresgid = 312; | |
| 255 | // 313 is obsolete signanosleep | |
| 256 | pub const SYS_aio_return = 314; | |
| 257 | pub const SYS_aio_suspend = 315; | |
| 258 | pub const SYS_aio_cancel = 316; | |
| 259 | pub const SYS_aio_error = 317; | |
| 260 | // 318 is freebsd6 aio_read | |
| 261 | // 319 is freebsd6 aio_write | |
| 262 | // 320 is freebsd6 lio_listio | |
| 263 | pub const SYS_yield = 321; | |
| 264 | // 322 is obsolete thr_sleep | |
| 265 | // 323 is obsolete thr_wakeup | |
| 266 | pub const SYS_mlockall = 324; | |
| 267 | pub const SYS_munlockall = 325; | |
| 268 | pub const SYS___getcwd = 326; | |
| 269 | pub const SYS_sched_setparam = 327; | |
| 270 | pub const SYS_sched_getparam = 328; | |
| 271 | pub const SYS_sched_setscheduler = 329; | |
| 272 | pub const SYS_sched_getscheduler = 330; | |
| 273 | pub const SYS_sched_yield = 331; | |
| 274 | pub const SYS_sched_get_priority_max = 332; | |
| 275 | pub const SYS_sched_get_priority_min = 333; | |
| 276 | pub const SYS_sched_rr_get_interval = 334; | |
| 277 | pub const SYS_utrace = 335; | |
| 278 | // 336 is freebsd4 sendfile | |
| 279 | pub const SYS_kldsym = 337; | |
| 280 | pub const SYS_jail = 338; | |
| 281 | pub const SYS_nnpfs_syscall = 339; | |
| 282 | pub const SYS_sigprocmask = 340; | |
| 283 | pub const SYS_sigsuspend = 341; | |
| 284 | // 342 is freebsd4 sigaction | |
| 285 | pub const SYS_sigpending = 343; | |
| 286 | // 344 is freebsd4 sigreturn | |
| 287 | pub const SYS_sigtimedwait = 345; | |
| 288 | pub const SYS_sigwaitinfo = 346; | |
| 289 | pub const SYS___acl_get_file = 347; | |
| 290 | pub const SYS___acl_set_file = 348; | |
| 291 | pub const SYS___acl_get_fd = 349; | |
| 292 | pub const SYS___acl_set_fd = 350; | |
| 293 | pub const SYS___acl_delete_file = 351; | |
| 294 | pub const SYS___acl_delete_fd = 352; | |
| 295 | pub const SYS___acl_aclcheck_file = 353; | |
| 296 | pub const SYS___acl_aclcheck_fd = 354; | |
| 297 | pub const SYS_extattrctl = 355; | |
| 298 | pub const SYS_extattr_set_file = 356; | |
| 299 | pub const SYS_extattr_get_file = 357; | |
| 300 | pub const SYS_extattr_delete_file = 358; | |
| 301 | pub const SYS_aio_waitcomplete = 359; | |
| 302 | pub const SYS_getresuid = 360; | |
| 303 | pub const SYS_getresgid = 361; | |
| 304 | pub const SYS_kqueue = 362; | |
| 305 | pub const SYS_freebsd11_kevent = 363; | |
| 306 | pub const SYS_extattr_set_fd = 371; | |
| 307 | pub const SYS_extattr_get_fd = 372; | |
| 308 | pub const SYS_extattr_delete_fd = 373; | |
| 309 | pub const SYS___setugid = 374; | |
| 310 | pub const SYS_eaccess = 376; | |
| 311 | pub const SYS_afs3_syscall = 377; | |
| 312 | pub const SYS_nmount = 378; | |
| 313 | pub const SYS___mac_get_proc = 384; | |
| 314 | pub const SYS___mac_set_proc = 385; | |
| 315 | pub const SYS___mac_get_fd = 386; | |
| 316 | pub const SYS___mac_get_file = 387; | |
| 317 | pub const SYS___mac_set_fd = 388; | |
| 318 | pub const SYS___mac_set_file = 389; | |
| 319 | pub const SYS_kenv = 390; | |
| 320 | pub const SYS_lchflags = 391; | |
| 321 | pub const SYS_uuidgen = 392; | |
| 322 | pub const SYS_sendfile = 393; | |
| 323 | pub const SYS_mac_syscall = 394; | |
| 324 | pub const SYS_freebsd11_getfsstat = 395; | |
| 325 | pub const SYS_freebsd11_statfs = 396; | |
| 326 | pub const SYS_freebsd11_fstatfs = 397; | |
| 327 | pub const SYS_freebsd11_fhstatfs = 398; | |
| 328 | pub const SYS_ksem_close = 400; | |
| 329 | pub const SYS_ksem_post = 401; | |
| 330 | pub const SYS_ksem_wait = 402; | |
| 331 | pub const SYS_ksem_trywait = 403; | |
| 332 | pub const SYS_ksem_init = 404; | |
| 333 | pub const SYS_ksem_open = 405; | |
| 334 | pub const SYS_ksem_unlink = 406; | |
| 335 | pub const SYS_ksem_getvalue = 407; | |
| 336 | pub const SYS_ksem_destroy = 408; | |
| 337 | pub const SYS___mac_get_pid = 409; | |
| 338 | pub const SYS___mac_get_link = 410; | |
| 339 | pub const SYS___mac_set_link = 411; | |
| 340 | pub const SYS_extattr_set_link = 412; | |
| 341 | pub const SYS_extattr_get_link = 413; | |
| 342 | pub const SYS_extattr_delete_link = 414; | |
| 343 | pub const SYS___mac_execve = 415; | |
| 344 | pub const SYS_sigaction = 416; | |
| 345 | pub const SYS_sigreturn = 417; | |
| 346 | pub const SYS_getcontext = 421; | |
| 347 | pub const SYS_setcontext = 422; | |
| 348 | pub const SYS_swapcontext = 423; | |
| 349 | pub const SYS_swapoff = 424; | |
| 350 | pub const SYS___acl_get_link = 425; | |
| 351 | pub const SYS___acl_set_link = 426; | |
| 352 | pub const SYS___acl_delete_link = 427; | |
| 353 | pub const SYS___acl_aclcheck_link = 428; | |
| 354 | pub const SYS_sigwait = 429; | |
| 355 | pub const SYS_thr_create = 430; | |
| 356 | pub const SYS_thr_exit = 431; | |
| 357 | pub const SYS_thr_self = 432; | |
| 358 | pub const SYS_thr_kill = 433; | |
| 359 | pub const SYS_jail_attach = 436; | |
| 360 | pub const SYS_extattr_list_fd = 437; | |
| 361 | pub const SYS_extattr_list_file = 438; | |
| 362 | pub const SYS_extattr_list_link = 439; | |
| 363 | pub const SYS_ksem_timedwait = 441; | |
| 364 | pub const SYS_thr_suspend = 442; | |
| 365 | pub const SYS_thr_wake = 443; | |
| 366 | pub const SYS_kldunloadf = 444; | |
| 367 | pub const SYS_audit = 445; | |
| 368 | pub const SYS_auditon = 446; | |
| 369 | pub const SYS_getauid = 447; | |
| 370 | pub const SYS_setauid = 448; | |
| 371 | pub const SYS_getaudit = 449; | |
| 372 | pub const SYS_setaudit = 450; | |
| 373 | pub const SYS_getaudit_addr = 451; | |
| 374 | pub const SYS_setaudit_addr = 452; | |
| 375 | pub const SYS_auditctl = 453; | |
| 376 | pub const SYS__umtx_op = 454; | |
| 377 | pub const SYS_thr_new = 455; | |
| 378 | pub const SYS_sigqueue = 456; | |
| 379 | pub const SYS_kmq_open = 457; | |
| 380 | pub const SYS_kmq_setattr = 458; | |
| 381 | pub const SYS_kmq_timedreceive = 459; | |
| 382 | pub const SYS_kmq_timedsend = 460; | |
| 383 | pub const SYS_kmq_notify = 461; | |
| 384 | pub const SYS_kmq_unlink = 462; | |
| 385 | pub const SYS_abort2 = 463; | |
| 386 | pub const SYS_thr_set_name = 464; | |
| 387 | pub const SYS_aio_fsync = 465; | |
| 388 | pub const SYS_rtprio_thread = 466; | |
| 389 | pub const SYS_sctp_peeloff = 471; | |
| 390 | pub const SYS_sctp_generic_sendmsg = 472; | |
| 391 | pub const SYS_sctp_generic_sendmsg_iov = 473; | |
| 392 | pub const SYS_sctp_generic_recvmsg = 474; | |
| 393 | pub const SYS_pread = 475; | |
| 394 | pub const SYS_pwrite = 476; | |
| 395 | pub const SYS_mmap = 477; | |
| 396 | pub const SYS_lseek = 478; | |
| 397 | pub const SYS_truncate = 479; | |
| 398 | pub const SYS_ftruncate = 480; | |
| 399 | pub const SYS_thr_kill2 = 481; | |
| 400 | pub const SYS_shm_open = 482; | |
| 401 | pub const SYS_shm_unlink = 483; | |
| 402 | pub const SYS_cpuset = 484; | |
| 403 | pub const SYS_cpuset_setid = 485; | |
| 404 | pub const SYS_cpuset_getid = 486; | |
| 405 | pub const SYS_cpuset_getaffinity = 487; | |
| 406 | pub const SYS_cpuset_setaffinity = 488; | |
| 407 | pub const SYS_faccessat = 489; | |
| 408 | pub const SYS_fchmodat = 490; | |
| 409 | pub const SYS_fchownat = 491; | |
| 410 | pub const SYS_fexecve = 492; | |
| 411 | pub const SYS_freebsd11_fstatat = 493; | |
| 412 | pub const SYS_futimesat = 494; | |
| 413 | pub const SYS_linkat = 495; | |
| 414 | pub const SYS_mkdirat = 496; | |
| 415 | pub const SYS_mkfifoat = 497; | |
| 416 | pub const SYS_freebsd11_mknodat = 498; | |
| 417 | pub const SYS_openat = 499; | |
| 418 | pub const SYS_readlinkat = 500; | |
| 419 | pub const SYS_renameat = 501; | |
| 420 | pub const SYS_symlinkat = 502; | |
| 421 | pub const SYS_unlinkat = 503; | |
| 422 | pub const SYS_posix_openpt = 504; | |
| 423 | pub const SYS_gssd_syscall = 505; | |
| 424 | pub const SYS_jail_get = 506; | |
| 425 | pub const SYS_jail_set = 507; | |
| 426 | pub const SYS_jail_remove = 508; | |
| 427 | pub const SYS_closefrom = 509; | |
| 428 | pub const SYS___semctl = 510; | |
| 429 | pub const SYS_msgctl = 511; | |
| 430 | pub const SYS_shmctl = 512; | |
| 431 | pub const SYS_lpathconf = 513; | |
| 432 | // 514 is obsolete cap_new | |
| 433 | pub const SYS___cap_rights_get = 515; | |
| 434 | pub const SYS_cap_enter = 516; | |
| 435 | pub const SYS_cap_getmode = 517; | |
| 436 | pub const SYS_pdfork = 518; | |
| 437 | pub const SYS_pdkill = 519; | |
| 438 | pub const SYS_pdgetpid = 520; | |
| 439 | pub const SYS_pselect = 522; | |
| 440 | pub const SYS_getloginclass = 523; | |
| 441 | pub const SYS_setloginclass = 524; | |
| 442 | pub const SYS_rctl_get_racct = 525; | |
| 443 | pub const SYS_rctl_get_rules = 526; | |
| 444 | pub const SYS_rctl_get_limits = 527; | |
| 445 | pub const SYS_rctl_add_rule = 528; | |
| 446 | pub const SYS_rctl_remove_rule = 529; | |
| 447 | pub const SYS_posix_fallocate = 530; | |
| 448 | pub const SYS_posix_fadvise = 531; | |
| 449 | pub const SYS_wait6 = 532; | |
| 450 | pub const SYS_cap_rights_limit = 533; | |
| 451 | pub const SYS_cap_ioctls_limit = 534; | |
| 452 | pub const SYS_cap_ioctls_get = 535; | |
| 453 | pub const SYS_cap_fcntls_limit = 536; | |
| 454 | pub const SYS_cap_fcntls_get = 537; | |
| 455 | pub const SYS_bindat = 538; | |
| 456 | pub const SYS_connectat = 539; | |
| 457 | pub const SYS_chflagsat = 540; | |
| 458 | pub const SYS_accept4 = 541; | |
| 459 | pub const SYS_pipe2 = 542; | |
| 460 | pub const SYS_aio_mlock = 543; | |
| 461 | pub const SYS_procctl = 544; | |
| 462 | pub const SYS_ppoll = 545; | |
| 463 | pub const SYS_futimens = 546; | |
| 464 | pub const SYS_utimensat = 547; | |
| 465 | pub const SYS_numa_getaffinity = 548; | |
| 466 | pub const SYS_numa_setaffinity = 549; | |
| 467 | pub const SYS_fdatasync = 550; | |
| 468 | pub const SYS_fstat = 551; | |
| 469 | pub const SYS_fstatat = 552; | |
| 470 | pub const SYS_fhstat = 553; | |
| 471 | pub const SYS_getdirentries = 554; | |
| 472 | pub const SYS_statfs = 555; | |
| 473 | pub const SYS_fstatfs = 556; | |
| 474 | pub const SYS_getfsstat = 557; | |
| 475 | pub const SYS_fhstatfs = 558; | |
| 476 | pub const SYS_mknodat = 559; | |
| 477 | pub const SYS_kevent = 560; | |
| 478 | pub const SYS_MAXSYSCALL = 561; | |
| 479 | ||
| 480 | pub const O_CREAT = 0o100; | |
| 481 | pub const O_EXCL = 0o200; | |
| 482 | pub const O_NOCTTY = 0o400; | |
| 483 | pub const O_TRUNC = 0o1000; | |
| 484 | pub const O_APPEND = 0o2000; | |
| 485 | pub const O_NONBLOCK = 0o4000; | |
| 486 | pub const O_DSYNC = 0o10000; | |
| 487 | pub const O_SYNC = 0o4010000; | |
| 488 | pub const O_RSYNC = 0o4010000; | |
| 489 | pub const O_DIRECTORY = 0o200000; | |
| 490 | pub const O_NOFOLLOW = 0o400000; | |
| 491 | pub const O_CLOEXEC = 0o2000000; | |
| 492 | ||
| 493 | pub const O_ASYNC = 0o20000; | |
| 494 | pub const O_DIRECT = 0o40000; | |
| 495 | pub const O_LARGEFILE = 0; | |
| 496 | pub const O_NOATIME = 0o1000000; | |
| 497 | pub const O_PATH = 0o10000000; | |
| 498 | pub const O_TMPFILE = 0o20200000; | |
| 499 | pub const O_NDELAY = O_NONBLOCK; | |
| 500 | ||
| 501 | pub const F_DUPFD = 0; | |
| 502 | pub const F_GETFD = 1; | |
| 503 | pub const F_SETFD = 2; | |
| 504 | pub const F_GETFL = 3; | |
| 505 | pub const F_SETFL = 4; | |
| 506 | ||
| 507 | pub const F_SETOWN = 8; | |
| 508 | pub const F_GETOWN = 9; | |
| 509 | pub const F_SETSIG = 10; | |
| 510 | pub const F_GETSIG = 11; | |
| 511 | ||
| 512 | pub const F_GETLK = 5; | |
| 513 | pub const F_SETLK = 6; | |
| 514 | pub const F_SETLKW = 7; | |
| 515 | ||
| 516 | pub const F_SETOWN_EX = 15; | |
| 517 | pub const F_GETOWN_EX = 16; | |
| 518 | ||
| 519 | pub const F_GETOWNER_UIDS = 17; | |
| 520 | ||
| 521 | pub fn syscall0(number: usize) usize { | |
| 522 | return asm volatile ("syscall" | |
| 523 | : [ret] "={rax}" (-> usize) | |
| 524 | : [number] "{rax}" (number) | |
| 525 | : "rcx", "r11" | |
| 526 | ); | |
| 527 | } | |
| 528 | ||
| 529 | pub fn syscall1(number: usize, arg1: usize) usize { | |
| 530 | return asm volatile ("syscall" | |
| 531 | : [ret] "={rax}" (-> usize) | |
| 532 | : [number] "{rax}" (number), | |
| 533 | [arg1] "{rdi}" (arg1) | |
| 534 | : "rcx", "r11" | |
| 535 | ); | |
| 536 | } | |
| 537 | ||
| 538 | pub fn syscall2(number: usize, arg1: usize, arg2: usize) usize { | |
| 539 | return asm volatile ("syscall" | |
| 540 | : [ret] "={rax}" (-> usize) | |
| 541 | : [number] "{rax}" (number), | |
| 542 | [arg1] "{rdi}" (arg1), | |
| 543 | [arg2] "{rsi}" (arg2) | |
| 544 | : "rcx", "r11" | |
| 545 | ); | |
| 546 | } | |
| 547 | ||
| 548 | pub fn syscall3(number: usize, arg1: usize, arg2: usize, arg3: usize) usize { | |
| 549 | return asm volatile ("syscall" | |
| 550 | : [ret] "={rax}" (-> usize) | |
| 551 | : [number] "{rax}" (number), | |
| 552 | [arg1] "{rdi}" (arg1), | |
| 553 | [arg2] "{rsi}" (arg2), | |
| 554 | [arg3] "{rdx}" (arg3) | |
| 555 | : "rcx", "r11" | |
| 556 | ); | |
| 557 | } | |
| 558 | ||
| 559 | pub fn syscall4(number: usize, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize { | |
| 560 | return asm volatile ("syscall" | |
| 561 | : [ret] "={rax}" (-> usize) | |
| 562 | : [number] "{rax}" (number), | |
| 563 | [arg1] "{rdi}" (arg1), | |
| 564 | [arg2] "{rsi}" (arg2), | |
| 565 | [arg3] "{rdx}" (arg3), | |
| 566 | [arg4] "{r10}" (arg4) | |
| 567 | : "rcx", "r11" | |
| 568 | ); | |
| 569 | } | |
| 570 | ||
| 571 | pub fn syscall5(number: usize, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize { | |
| 572 | return asm volatile ("syscall" | |
| 573 | : [ret] "={rax}" (-> usize) | |
| 574 | : [number] "{rax}" (number), | |
| 575 | [arg1] "{rdi}" (arg1), | |
| 576 | [arg2] "{rsi}" (arg2), | |
| 577 | [arg3] "{rdx}" (arg3), | |
| 578 | [arg4] "{r10}" (arg4), | |
| 579 | [arg5] "{r8}" (arg5) | |
| 580 | : "rcx", "r11" | |
| 581 | ); | |
| 582 | } | |
| 583 | ||
| 584 | pub fn syscall6( | |
| 585 | number: usize, | |
| 586 | arg1: usize, | |
| 587 | arg2: usize, | |
| 588 | arg3: usize, | |
| 589 | arg4: usize, | |
| 590 | arg5: usize, | |
| 591 | arg6: usize, | |
| 592 | ) usize { | |
| 593 | return asm volatile ("syscall" | |
| 594 | : [ret] "={rax}" (-> usize) | |
| 595 | : [number] "{rax}" (number), | |
| 596 | [arg1] "{rdi}" (arg1), | |
| 597 | [arg2] "{rsi}" (arg2), | |
| 598 | [arg3] "{rdx}" (arg3), | |
| 599 | [arg4] "{r10}" (arg4), | |
| 600 | [arg5] "{r8}" (arg5), | |
| 601 | [arg6] "{r9}" (arg6) | |
| 602 | : "rcx", "r11" | |
| 603 | ); | |
| 604 | } | |
| 605 | ||
| 606 | pub nakedcc fn restore_rt() void { | |
| 607 | asm volatile ("syscall" | |
| 608 | : | |
| 609 | : [number] "{rax}" (usize(SYS_rt_sigreturn)) | |
| 610 | : "rcx", "r11" | |
| 611 | ); | |
| 612 | } | |
| 613 | ||
| 614 | pub const msghdr = extern struct { | |
| 615 | msg_name: &u8, | |
| 616 | msg_namelen: socklen_t, | |
| 617 | msg_iov: &iovec, | |
| 618 | msg_iovlen: i32, | |
| 619 | __pad1: i32, | |
| 620 | msg_control: &u8, | |
| 621 | msg_controllen: socklen_t, | |
| 622 | __pad2: socklen_t, | |
| 623 | msg_flags: i32, | |
| 624 | }; | |
| 625 | ||
| 626 | /// Renamed to Stat to not conflict with the stat function. | |
| 627 | pub const Stat = extern struct { | |
| 628 | dev: u64, | |
| 629 | ino: u64, | |
| 630 | nlink: usize, | |
| 631 | ||
| 632 | mode: u32, | |
| 633 | uid: u32, | |
| 634 | gid: u32, | |
| 635 | __pad0: u32, | |
| 636 | rdev: u64, | |
| 637 | size: i64, | |
| 638 | blksize: isize, | |
| 639 | blocks: i64, | |
| 640 | ||
| 641 | atim: timespec, | |
| 642 | mtim: timespec, | |
| 643 | ctim: timespec, | |
| 644 | __unused: [3]isize, | |
| 645 | }; | |
| 646 | ||
| 647 | pub const timespec = extern struct { | |
| 648 | tv_sec: isize, | |
| 649 | tv_nsec: isize, | |
| 650 | }; |