| ... | @@ -5,28 +5,18 @@ const maxInt = std.math.maxInt; | ... | @@ -5,28 +5,18 @@ const maxInt = std.math.maxInt; |
| 5 | const iovec = std.posix.iovec; | 5 | const iovec = std.posix.iovec; |
| 6 | const iovec_const = std.posix.iovec_const; | 6 | const iovec_const = std.posix.iovec_const; |
| 7 | | 7 | |
| 8 | extern "c" fn _errnop() *c_int; | 8 | pub extern "root" fn find_directory(which: directory_which, volume: i32, createIt: bool, path_ptr: [*]u8, length: i32) u64; |
| 9 | | 9 | |
| 10 | pub const _errno = _errnop; | 10 | pub extern "root" fn find_thread(thread_name: ?*anyopaque) i32; |
| 11 | | | |
| 12 | pub extern "c" fn find_directory(which: directory_which, volume: i32, createIt: bool, path_ptr: [*]u8, length: i32) u64; | | |
| 13 | | 11 | |
| 14 | pub extern "c" fn find_thread(thread_name: ?*anyopaque) i32; | 12 | pub extern "root" fn get_system_info(system_info: *system_info) usize; |
| 15 | | 13 | |
| 16 | pub extern "c" fn get_system_info(system_info: *system_info) usize; | 14 | pub extern "root" fn _get_team_info(team: i32, team_info: *team_info, size: usize) i32; |
| 17 | | 15 | |
| 18 | pub extern "c" fn _get_team_info(team: c_int, team_info: *team_info, size: usize) i32; | 16 | pub extern "root" fn _get_next_area_info(team: i32, cookie: *i64, area_info: *area_info, size: usize) i32; |
| 19 | | | |
| 20 | pub extern "c" fn _get_next_area_info(team: c_int, cookie: *i64, area_info: *area_info, size: usize) i32; | | |
| 21 | | 17 | |
| 22 | // TODO revisit if abi changes or better option becomes apparent | 18 | // TODO revisit if abi changes or better option becomes apparent |
| 23 | pub extern "c" fn _get_next_image_info(team: c_int, cookie: *i32, image_info: *image_info, size: usize) i32; | 19 | pub extern "root" fn _get_next_image_info(team: i32, cookie: *i32, image_info: *image_info, size: usize) i32; |
| 24 | | | |
| 25 | pub extern "c" fn _kern_read_dir(fd: c_int, buf_ptr: [*]u8, nbytes: usize, maxcount: u32) usize; | | |
| 26 | | | |
| 27 | pub extern "c" fn _kern_read_stat(fd: c_int, path_ptr: [*]u8, traverse_link: bool, st: *Stat, stat_size: i32) usize; | | |
| 28 | | | |
| 29 | pub extern "c" fn _kern_get_current_team() i32; | | |
| 30 | | 20 | |
| 31 | pub const sem_t = extern struct { | 21 | pub const sem_t = extern struct { |
| 32 | type: i32, | 22 | type: i32, |
| ... | @@ -45,7 +35,7 @@ pub const pthread_attr_t = extern struct { | ... | @@ -45,7 +35,7 @@ pub const pthread_attr_t = extern struct { |
| 45 | __stack_address: ?*anyopaque, | 35 | __stack_address: ?*anyopaque, |
| 46 | }; | 36 | }; |
| 47 | | 37 | |
| 48 | pub const EAI = enum(c_int) { | 38 | pub const EAI = enum(i32) { |
| 49 | /// address family for hostname not supported | 39 | /// address family for hostname not supported |
| 50 | ADDRFAMILY = 1, | 40 | ADDRFAMILY = 1, |
| 51 | | 41 | |
| ... | @@ -99,11 +89,7 @@ pub const AI = struct { | ... | @@ -99,11 +89,7 @@ pub const AI = struct { |
| 99 | | 89 | |
| 100 | pub const AI_NUMERICSERV = AI.NUMERICSERV; | 90 | pub const AI_NUMERICSERV = AI.NUMERICSERV; |
| 101 | | 91 | |
| 102 | pub const fd_t = c_int; | 92 | pub const fd_t = i32; |
| 103 | pub const pid_t = c_int; | | |
| 104 | pub const uid_t = u32; | | |
| 105 | pub const gid_t = u32; | | |
| 106 | pub const mode_t = c_uint; | | |
| 107 | | 93 | |
| 108 | pub const socklen_t = u32; | 94 | pub const socklen_t = u32; |
| 109 | | 95 | |
| ... | @@ -129,8 +115,8 @@ pub const dl_phdr_info = extern struct { | ... | @@ -129,8 +115,8 @@ pub const dl_phdr_info = extern struct { |
| 129 | }; | 115 | }; |
| 130 | | 116 | |
| 131 | pub const Flock = extern struct { | 117 | pub const Flock = extern struct { |
| 132 | type: c_short, | 118 | type: i16, |
| 133 | whence: c_short, | 119 | whence: i16, |
| 134 | start: off_t, | 120 | start: off_t, |
| 135 | len: off_t, | 121 | len: off_t, |
| 136 | pid: pid_t, | 122 | pid: pid_t, |
| ... | @@ -159,54 +145,6 @@ pub const msghdr = extern struct { | ... | @@ -159,54 +145,6 @@ pub const msghdr = extern struct { |
| 159 | msg_flags: i32, | 145 | msg_flags: i32, |
| 160 | }; | 146 | }; |
| 161 | | 147 | |
| 162 | pub const off_t = i64; | | |
| 163 | pub const ino_t = u64; | | |
| 164 | | | |
| 165 | pub const Stat = extern struct { | | |
| 166 | dev: i32, | | |
| 167 | ino: u64, | | |
| 168 | mode: u32, | | |
| 169 | nlink: i32, | | |
| 170 | uid: i32, | | |
| 171 | gid: i32, | | |
| 172 | size: i64, | | |
| 173 | rdev: i32, | | |
| 174 | blksize: i32, | | |
| 175 | atim: timespec, | | |
| 176 | mtim: timespec, | | |
| 177 | ctim: timespec, | | |
| 178 | crtim: timespec, | | |
| 179 | st_type: u32, | | |
| 180 | blocks: i64, | | |
| 181 | | | |
| 182 | pub fn atime(self: @This()) timespec { | | |
| 183 | return self.atim; | | |
| 184 | } | | |
| 185 | pub fn mtime(self: @This()) timespec { | | |
| 186 | return self.mtim; | | |
| 187 | } | | |
| 188 | pub fn ctime(self: @This()) timespec { | | |
| 189 | return self.ctim; | | |
| 190 | } | | |
| 191 | pub fn birthtime(self: @This()) timespec { | | |
| 192 | return self.crtim; | | |
| 193 | } | | |
| 194 | }; | | |
| 195 | | | |
| 196 | pub const timespec = extern struct { | | |
| 197 | tv_sec: isize, | | |
| 198 | tv_nsec: isize, | | |
| 199 | }; | | |
| 200 | | | |
| 201 | pub const dirent = extern struct { | | |
| 202 | dev: i32, | | |
| 203 | pdev: i32, | | |
| 204 | ino: i64, | | |
| 205 | pino: i64, | | |
| 206 | reclen: u16, | | |
| 207 | name: [256]u8, | | |
| 208 | }; | | |
| 209 | | | |
| 210 | pub const B_OS_NAME_LENGTH = 32; // OS.h | 148 | pub const B_OS_NAME_LENGTH = 32; // OS.h |
| 211 | | 149 | |
| 212 | pub const area_info = extern struct { | 150 | pub const area_info = extern struct { |
| ... | @@ -354,17 +292,6 @@ pub const PROT = struct { | ... | @@ -354,17 +292,6 @@ pub const PROT = struct { |
| 354 | pub const NONE = 0x00; | 292 | pub const NONE = 0x00; |
| 355 | }; | 293 | }; |
| 356 | | 294 | |
| 357 | pub const CLOCK = struct { | | |
| 358 | /// system-wide monotonic clock (aka system time) | | |
| 359 | pub const MONOTONIC = 0; | | |
| 360 | /// system-wide real time clock | | |
| 361 | pub const REALTIME = -1; | | |
| 362 | /// clock measuring the used CPU time of the current process | | |
| 363 | pub const PROCESS_CPUTIME_ID = -2; | | |
| 364 | /// clock measuring the used CPU time of the current thread | | |
| 365 | pub const THREAD_CPUTIME_ID = -3; | | |
| 366 | }; | | |
| 367 | | | |
| 368 | pub const MSF = struct { | 295 | pub const MSF = struct { |
| 369 | pub const ASYNC = 1; | 296 | pub const ASYNC = 1; |
| 370 | pub const INVALIDATE = 2; | 297 | pub const INVALIDATE = 2; |
| ... | @@ -404,159 +331,526 @@ pub const W = struct { | ... | @@ -404,159 +331,526 @@ pub const W = struct { |
| 404 | } | 331 | } |
| 405 | }; | 332 | }; |
| 406 | | 333 | |
| 407 | // /system/develop/headers/posix/poll.h | 334 | // access function |
| 408 | | 335 | pub const F_OK = 0; // test for existence of file |
| 409 | pub const nfds_t = usize; | 336 | pub const X_OK = 1; // test for execute or search permission |
| | 337 | pub const W_OK = 2; // test for write permission |
| | 338 | pub const R_OK = 4; // test for read permission |
| 410 | | 339 | |
| 411 | pub const pollfd = extern struct { | 340 | pub const F = struct { |
| 412 | fd: i32, | 341 | pub const DUPFD = 0x0001; |
| 413 | events: i16, | 342 | pub const GETFD = 0x0002; |
| 414 | revents: i16, | 343 | pub const SETFD = 0x0004; |
| 415 | }; | 344 | pub const GETFL = 0x0008; |
| | 345 | pub const SETFL = 0x0010; |
| 416 | | 346 | |
| 417 | pub const POLL = struct { | 347 | pub const GETLK = 0x0020; |
| 418 | /// any readable data available | 348 | pub const SETLK = 0x0080; |
| 419 | pub const IN = 0x0001; | 349 | pub const SETLKW = 0x0100; |
| 420 | /// file descriptor is writeable | 350 | pub const DUPFD_CLOEXEC = 0x0200; |
| 421 | pub const OUT = 0x0002; | | |
| 422 | pub const RDNORM = IN; | | |
| 423 | pub const WRNORM = OUT; | | |
| 424 | /// priority readable data | | |
| 425 | pub const RDBAND = 0x0008; | | |
| 426 | /// priority data can be written | | |
| 427 | pub const WRBAND = 0x0010; | | |
| 428 | /// high priority readable data | | |
| 429 | pub const PRI = 0x0020; | | |
| 430 | | 351 | |
| 431 | /// errors pending | 352 | pub const RDLCK = 0x0040; |
| 432 | pub const ERR = 0x0004; | 353 | pub const UNLCK = 0x0200; |
| 433 | /// disconnected | 354 | pub const WRLCK = 0x0400; |
| 434 | pub const HUP = 0x0080; | | |
| 435 | /// invalid file descriptor | | |
| 436 | pub const NVAL = 0x1000; | | |
| 437 | }; | 355 | }; |
| 438 | | 356 | |
| 439 | // /system/develop/headers/posix/signal.h | 357 | pub const LOCK = struct { |
| 440 | | 358 | pub const SH = 0x01; |
| 441 | pub const sigset_t = u64; | 359 | pub const EX = 0x02; |
| 442 | pub const empty_sigset: sigset_t = 0; | 360 | pub const NB = 0x04; |
| 443 | pub const filled_sigset = ~@as(sigset_t, 0); | 361 | pub const UN = 0x08; |
| 444 | | | |
| 445 | pub const SIG = struct { | | |
| 446 | pub const DFL: ?Sigaction.handler_fn = @ptrFromInt(0); | | |
| 447 | pub const IGN: ?Sigaction.handler_fn = @ptrFromInt(1); | | |
| 448 | pub const ERR: ?Sigaction.handler_fn = @ptrFromInt(maxInt(usize)); | | |
| 449 | | | |
| 450 | pub const HOLD: ?Sigaction.handler_fn = @ptrFromInt(3); | | |
| 451 | | | |
| 452 | pub const HUP = 1; | | |
| 453 | pub const INT = 2; | | |
| 454 | pub const QUIT = 3; | | |
| 455 | pub const ILL = 4; | | |
| 456 | pub const CHLD = 5; | | |
| 457 | pub const ABRT = 6; | | |
| 458 | pub const IOT = ABRT; | | |
| 459 | pub const PIPE = 7; | | |
| 460 | pub const FPE = 8; | | |
| 461 | pub const KILL = 9; | | |
| 462 | pub const STOP = 10; | | |
| 463 | pub const SEGV = 11; | | |
| 464 | pub const CONT = 12; | | |
| 465 | pub const TSTP = 13; | | |
| 466 | pub const ALRM = 14; | | |
| 467 | pub const TERM = 15; | | |
| 468 | pub const TTIN = 16; | | |
| 469 | pub const TTOU = 17; | | |
| 470 | pub const USR1 = 18; | | |
| 471 | pub const USR2 = 19; | | |
| 472 | pub const WINCH = 20; | | |
| 473 | pub const KILLTHR = 21; | | |
| 474 | pub const TRAP = 22; | | |
| 475 | pub const POLL = 23; | | |
| 476 | pub const PROF = 24; | | |
| 477 | pub const SYS = 25; | | |
| 478 | pub const URG = 26; | | |
| 479 | pub const VTALRM = 27; | | |
| 480 | pub const XCPU = 28; | | |
| 481 | pub const XFSZ = 29; | | |
| 482 | pub const BUS = 30; | | |
| 483 | pub const RESERVED1 = 31; | | |
| 484 | pub const RESERVED2 = 32; | | |
| 485 | | | |
| 486 | pub const BLOCK = 1; | | |
| 487 | pub const UNBLOCK = 2; | | |
| 488 | pub const SETMASK = 3; | | |
| 489 | }; | 362 | }; |
| 490 | | 363 | |
| 491 | pub const siginfo_t = extern struct { | 364 | pub const FD_CLOEXEC = 1; |
| 492 | signo: c_int, | | |
| 493 | code: c_int, | | |
| 494 | errno: c_int, | | |
| 495 | | 365 | |
| 496 | pid: pid_t, | 366 | pub const SEEK = struct { |
| 497 | uid: uid_t, | 367 | pub const SET = 0; |
| 498 | addr: *allowzero anyopaque, | 368 | pub const CUR = 1; |
| | 369 | pub const END = 2; |
| 499 | }; | 370 | }; |
| 500 | | 371 | |
| 501 | /// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall. | 372 | pub const SOCK = struct { |
| 502 | pub const Sigaction = extern struct { | 373 | pub const STREAM = 1; |
| 503 | pub const handler_fn = *align(1) const fn (i32) callconv(.C) void; | 374 | pub const DGRAM = 2; |
| 504 | pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void; | 375 | pub const RAW = 3; |
| 505 | | 376 | pub const SEQPACKET = 5; |
| 506 | /// signal handler | | |
| 507 | handler: extern union { | | |
| 508 | handler: handler_fn, | | |
| 509 | sigaction: sigaction_fn, | | |
| 510 | }, | | |
| 511 | | 377 | |
| 512 | /// signal mask to apply | 378 | /// WARNING: this flag is not supported by windows socket functions directly, |
| 513 | mask: sigset_t, | 379 | /// it is only supported by std.os.socket. Be sure that this value does |
| | 380 | /// not share any bits with any of the `SOCK` values. |
| | 381 | pub const CLOEXEC = 0x10000; |
| | 382 | /// WARNING: this flag is not supported by windows socket functions directly, |
| | 383 | /// it is only supported by std.os.socket. Be sure that this value does |
| | 384 | /// not share any bits with any of the `SOCK` values. |
| | 385 | pub const NONBLOCK = 0x20000; |
| | 386 | }; |
| 514 | | 387 | |
| 515 | /// see signal options | 388 | pub const SO = struct { |
| 516 | flags: c_int, | 389 | pub const ACCEPTCONN = 0x00000001; |
| | 390 | pub const BROADCAST = 0x00000002; |
| | 391 | pub const DEBUG = 0x00000004; |
| | 392 | pub const DONTROUTE = 0x00000008; |
| | 393 | pub const KEEPALIVE = 0x00000010; |
| | 394 | pub const OOBINLINE = 0x00000020; |
| | 395 | pub const REUSEADDR = 0x00000040; |
| | 396 | pub const REUSEPORT = 0x00000080; |
| | 397 | pub const USELOOPBACK = 0x00000100; |
| | 398 | pub const LINGER = 0x00000200; |
| 517 | | 399 | |
| 518 | /// will be passed to the signal handler, BeOS extension | 400 | pub const SNDBUF = 0x40000001; |
| 519 | userdata: *allowzero anyopaque = undefined, | 401 | pub const SNDLOWAT = 0x40000002; |
| | 402 | pub const SNDTIMEO = 0x40000003; |
| | 403 | pub const RCVBUF = 0x40000004; |
| | 404 | pub const RCVLOWAT = 0x40000005; |
| | 405 | pub const RCVTIMEO = 0x40000006; |
| | 406 | pub const ERROR = 0x40000007; |
| | 407 | pub const TYPE = 0x40000008; |
| | 408 | pub const NONBLOCK = 0x40000009; |
| | 409 | pub const BINDTODEVICE = 0x4000000a; |
| | 410 | pub const PEERCRED = 0x4000000b; |
| 520 | }; | 411 | }; |
| 521 | | 412 | |
| 522 | pub const SA = struct { | 413 | pub const SOL = struct { |
| 523 | pub const NOCLDSTOP = 0x01; | 414 | pub const SOCKET = -1; |
| 524 | pub const NOCLDWAIT = 0x02; | | |
| 525 | pub const RESETHAND = 0x04; | | |
| 526 | pub const NODEFER = 0x08; | | |
| 527 | pub const RESTART = 0x10; | | |
| 528 | pub const ONSTACK = 0x20; | | |
| 529 | pub const SIGINFO = 0x40; | | |
| 530 | pub const NOMASK = NODEFER; | | |
| 531 | pub const STACK = ONSTACK; | | |
| 532 | pub const ONESHOT = RESETHAND; | | |
| 533 | }; | 415 | }; |
| 534 | | 416 | |
| 535 | pub const SS = struct { | 417 | pub const PF = struct { |
| 536 | pub const ONSTACK = 0x1; | 418 | pub const UNSPEC = AF.UNSPEC; |
| 537 | pub const DISABLE = 0x2; | 419 | pub const INET = AF.INET; |
| | 420 | pub const ROUTE = AF.ROUTE; |
| | 421 | pub const LINK = AF.LINK; |
| | 422 | pub const INET6 = AF.INET6; |
| | 423 | pub const LOCAL = AF.LOCAL; |
| | 424 | pub const UNIX = AF.UNIX; |
| | 425 | pub const BLUETOOTH = AF.BLUETOOTH; |
| 538 | }; | 426 | }; |
| 539 | | 427 | |
| 540 | pub const MINSIGSTKSZ = 8192; | 428 | pub const AF = struct { |
| 541 | pub const SIGSTKSZ = 16384; | 429 | pub const UNSPEC = 0; |
| 542 | | 430 | pub const INET = 1; |
| 543 | pub const stack_t = extern struct { | 431 | pub const APPLETALK = 2; |
| 544 | sp: [*]u8, | 432 | pub const ROUTE = 3; |
| 545 | size: isize, | 433 | pub const LINK = 4; |
| 546 | flags: i32, | 434 | pub const INET6 = 5; |
| | 435 | pub const DLI = 6; |
| | 436 | pub const IPX = 7; |
| | 437 | pub const NOTIFY = 8; |
| | 438 | pub const LOCAL = 9; |
| | 439 | pub const UNIX = LOCAL; |
| | 440 | pub const BLUETOOTH = 10; |
| | 441 | pub const MAX = 11; |
| 547 | }; | 442 | }; |
| 548 | | 443 | |
| 549 | pub const NSIG = 65; | 444 | pub const DT = struct {}; |
| 550 | | 445 | |
| 551 | pub const mcontext_t = vregs; | 446 | /// add event to kq (implies enable) |
| | 447 | pub const EV_ADD = 0x0001; |
| 552 | | 448 | |
| 553 | pub const ucontext_t = extern struct { | 449 | /// delete event from kq |
| 554 | link: ?*ucontext_t, | 450 | pub const EV_DELETE = 0x0002; |
| 555 | sigmask: sigset_t, | 451 | |
| 556 | stack: stack_t, | 452 | /// enable event |
| 557 | mcontext: mcontext_t, | 453 | pub const EV_ENABLE = 0x0004; |
| | 454 | |
| | 455 | /// disable event (not reported) |
| | 456 | pub const EV_DISABLE = 0x0008; |
| | 457 | |
| | 458 | /// only report one occurrence |
| | 459 | pub const EV_ONESHOT = 0x0010; |
| | 460 | |
| | 461 | /// clear event state after reporting |
| | 462 | pub const EV_CLEAR = 0x0020; |
| | 463 | |
| | 464 | /// force immediate event output |
| | 465 | /// ... with or without EV_ERROR |
| | 466 | /// ... use KEVENT_FLAG_ERROR_EVENTS |
| | 467 | /// on syscalls supporting flags |
| | 468 | pub const EV_RECEIPT = 0x0040; |
| | 469 | |
| | 470 | /// disable event after reporting |
| | 471 | pub const EV_DISPATCH = 0x0080; |
| | 472 | |
| | 473 | pub const EVFILT_READ = -1; |
| | 474 | pub const EVFILT_WRITE = -2; |
| | 475 | |
| | 476 | /// attached to aio requests |
| | 477 | pub const EVFILT_AIO = -3; |
| | 478 | |
| | 479 | /// attached to vnodes |
| | 480 | pub const EVFILT_VNODE = -4; |
| | 481 | |
| | 482 | /// attached to struct proc |
| | 483 | pub const EVFILT_PROC = -5; |
| | 484 | |
| | 485 | /// attached to struct proc |
| | 486 | pub const EVFILT_SIGNAL = -6; |
| | 487 | |
| | 488 | /// timers |
| | 489 | pub const EVFILT_TIMER = -7; |
| | 490 | |
| | 491 | /// Process descriptors |
| | 492 | pub const EVFILT_PROCDESC = -8; |
| | 493 | |
| | 494 | /// Filesystem events |
| | 495 | pub const EVFILT_FS = -9; |
| | 496 | |
| | 497 | pub const EVFILT_LIO = -10; |
| | 498 | |
| | 499 | /// User events |
| | 500 | pub const EVFILT_USER = -11; |
| | 501 | |
| | 502 | /// Sendfile events |
| | 503 | pub const EVFILT_SENDFILE = -12; |
| | 504 | |
| | 505 | pub const EVFILT_EMPTY = -13; |
| | 506 | |
| | 507 | pub const T = struct { |
| | 508 | pub const CGETA = 0x8000; |
| | 509 | pub const CSETA = 0x8001; |
| | 510 | pub const CSETAF = 0x8002; |
| | 511 | pub const CSETAW = 0x8003; |
| | 512 | pub const CWAITEVENT = 0x8004; |
| | 513 | pub const CSBRK = 0x8005; |
| | 514 | pub const CFLSH = 0x8006; |
| | 515 | pub const CXONC = 0x8007; |
| | 516 | pub const CQUERYCONNECTED = 0x8008; |
| | 517 | pub const CGETBITS = 0x8009; |
| | 518 | pub const CSETDTR = 0x8010; |
| | 519 | pub const CSETRTS = 0x8011; |
| | 520 | pub const IOCGWINSZ = 0x8012; |
| | 521 | pub const IOCSWINSZ = 0x8013; |
| | 522 | pub const CVTIME = 0x8014; |
| | 523 | pub const IOCGPGRP = 0x8015; |
| | 524 | pub const IOCSPGRP = 0x8016; |
| | 525 | pub const IOCSCTTY = 0x8017; |
| | 526 | pub const IOCMGET = 0x8018; |
| | 527 | pub const IOCMSET = 0x8019; |
| | 528 | pub const IOCSBRK = 0x8020; |
| | 529 | pub const IOCCBRK = 0x8021; |
| | 530 | pub const IOCMBIS = 0x8022; |
| | 531 | pub const IOCMBIC = 0x8023; |
| | 532 | pub const IOCGSID = 0x8024; |
| | 533 | |
| | 534 | pub const FIONREAD = 0xbe000001; |
| | 535 | pub const FIONBIO = 0xbe000000; |
| | 536 | }; |
| | 537 | |
| | 538 | pub const winsize = extern struct { |
| | 539 | ws_row: u16, |
| | 540 | ws_col: u16, |
| | 541 | ws_xpixel: u16, |
| | 542 | ws_ypixel: u16, |
| | 543 | }; |
| | 544 | |
| | 545 | pub const S = struct { |
| | 546 | pub const IFMT = 0o170000; |
| | 547 | pub const IFSOCK = 0o140000; |
| | 548 | pub const IFLNK = 0o120000; |
| | 549 | pub const IFREG = 0o100000; |
| | 550 | pub const IFBLK = 0o060000; |
| | 551 | pub const IFDIR = 0o040000; |
| | 552 | pub const IFCHR = 0o020000; |
| | 553 | pub const IFIFO = 0o010000; |
| | 554 | pub const INDEX_DIR = 0o4000000000; |
| | 555 | |
| | 556 | pub const IUMSK = 0o7777; |
| | 557 | pub const ISUID = 0o4000; |
| | 558 | pub const ISGID = 0o2000; |
| | 559 | pub const ISVTX = 0o1000; |
| | 560 | pub const IRWXU = 0o700; |
| | 561 | pub const IRUSR = 0o400; |
| | 562 | pub const IWUSR = 0o200; |
| | 563 | pub const IXUSR = 0o100; |
| | 564 | pub const IRWXG = 0o070; |
| | 565 | pub const IRGRP = 0o040; |
| | 566 | pub const IWGRP = 0o020; |
| | 567 | pub const IXGRP = 0o010; |
| | 568 | pub const IRWXO = 0o007; |
| | 569 | pub const IROTH = 0o004; |
| | 570 | pub const IWOTH = 0o002; |
| | 571 | pub const IXOTH = 0o001; |
| | 572 | |
| | 573 | pub fn ISREG(m: u32) bool { |
| | 574 | return m & IFMT == IFREG; |
| | 575 | } |
| | 576 | |
| | 577 | pub fn ISLNK(m: u32) bool { |
| | 578 | return m & IFMT == IFLNK; |
| | 579 | } |
| | 580 | |
| | 581 | pub fn ISBLK(m: u32) bool { |
| | 582 | return m & IFMT == IFBLK; |
| | 583 | } |
| | 584 | |
| | 585 | pub fn ISDIR(m: u32) bool { |
| | 586 | return m & IFMT == IFDIR; |
| | 587 | } |
| | 588 | |
| | 589 | pub fn ISCHR(m: u32) bool { |
| | 590 | return m & IFMT == IFCHR; |
| | 591 | } |
| | 592 | |
| | 593 | pub fn ISFIFO(m: u32) bool { |
| | 594 | return m & IFMT == IFIFO; |
| | 595 | } |
| | 596 | |
| | 597 | pub fn ISSOCK(m: u32) bool { |
| | 598 | return m & IFMT == IFSOCK; |
| | 599 | } |
| | 600 | |
| | 601 | pub fn ISINDEX(m: u32) bool { |
| | 602 | return m & INDEX_DIR == INDEX_DIR; |
| | 603 | } |
| | 604 | }; |
| | 605 | |
| | 606 | pub const HOST_NAME_MAX = 255; |
| | 607 | |
| | 608 | pub const addrinfo = extern struct { |
| | 609 | flags: i32, |
| | 610 | family: i32, |
| | 611 | socktype: i32, |
| | 612 | protocol: i32, |
| | 613 | addrlen: socklen_t, |
| | 614 | canonname: ?[*:0]u8, |
| | 615 | addr: ?*sockaddr, |
| | 616 | next: ?*addrinfo, |
| | 617 | }; |
| | 618 | |
| | 619 | pub const IPPROTO = struct { |
| | 620 | pub const IP = 0; |
| | 621 | pub const HOPOPTS = 0; |
| | 622 | pub const ICMP = 1; |
| | 623 | pub const IGMP = 2; |
| | 624 | pub const TCP = 6; |
| | 625 | pub const UDP = 17; |
| | 626 | pub const IPV6 = 41; |
| | 627 | pub const ROUTING = 43; |
| | 628 | pub const FRAGMENT = 44; |
| | 629 | pub const ESP = 50; |
| | 630 | pub const AH = 51; |
| | 631 | pub const ICMPV6 = 58; |
| | 632 | pub const NONE = 59; |
| | 633 | pub const DSTOPTS = 60; |
| | 634 | pub const ETHERIP = 97; |
| | 635 | pub const RAW = 255; |
| | 636 | pub const MAX = 256; |
| | 637 | }; |
| | 638 | |
| | 639 | pub const rlimit_resource = enum(i32) { |
| | 640 | CORE = 0, |
| | 641 | CPU = 1, |
| | 642 | DATA = 2, |
| | 643 | FSIZE = 3, |
| | 644 | NOFILE = 4, |
| | 645 | STACK = 5, |
| | 646 | AS = 6, |
| | 647 | NOVMON = 7, |
| | 648 | _, |
| | 649 | }; |
| | 650 | |
| | 651 | pub const rlim_t = i64; |
| | 652 | |
| | 653 | pub const RLIM = struct { |
| | 654 | /// No limit |
| | 655 | pub const INFINITY: rlim_t = (1 << 63) - 1; |
| | 656 | |
| | 657 | pub const SAVED_MAX = INFINITY; |
| | 658 | pub const SAVED_CUR = INFINITY; |
| | 659 | }; |
| | 660 | |
| | 661 | pub const rlimit = extern struct { |
| | 662 | /// Soft limit |
| | 663 | cur: rlim_t, |
| | 664 | /// Hard limit |
| | 665 | max: rlim_t, |
| | 666 | }; |
| | 667 | |
| | 668 | pub const SHUT = struct { |
| | 669 | pub const RD = 0; |
| | 670 | pub const WR = 1; |
| | 671 | pub const RDWR = 2; |
| | 672 | }; |
| | 673 | |
| | 674 | // TODO fill out if needed |
| | 675 | pub const directory_which = enum(i32) { |
| | 676 | B_USER_SETTINGS_DIRECTORY = 0xbbe, |
| | 677 | |
| | 678 | _, |
| | 679 | }; |
| | 680 | |
| | 681 | pub const MSG_NOSIGNAL = 0x0800; |
| | 682 | |
| | 683 | // /system/develop/headers/os/kernel/OS.h |
| | 684 | |
| | 685 | pub const area_id = i32; |
| | 686 | pub const port_id = i32; |
| | 687 | pub const sem_id = i32; |
| | 688 | pub const team_id = i32; |
| | 689 | pub const thread_id = i32; |
| | 690 | |
| | 691 | // /system/develop/headers/os/support/Errors.h |
| | 692 | |
| | 693 | pub const E = enum(i32) { |
| | 694 | pub const B_GENERAL_ERROR_BASE: i32 = std.math.minInt(i32); |
| | 695 | pub const B_OS_ERROR_BASE = B_GENERAL_ERROR_BASE + 0x1000; |
| | 696 | pub const B_APP_ERROR_BASE = B_GENERAL_ERROR_BASE + 0x2000; |
| | 697 | pub const B_INTERFACE_ERROR_BASE = B_GENERAL_ERROR_BASE + 0x3000; |
| | 698 | pub const B_MEDIA_ERROR_BASE = B_GENERAL_ERROR_BASE + 0x4000; |
| | 699 | pub const B_TRANSLATION_ERROR_BASE = B_GENERAL_ERROR_BASE + 0x4800; |
| | 700 | pub const B_MIDI_ERROR_BASE = B_GENERAL_ERROR_BASE + 0x5000; |
| | 701 | pub const B_STORAGE_ERROR_BASE = B_GENERAL_ERROR_BASE + 0x6000; |
| | 702 | pub const B_POSIX_ERROR_BASE = B_GENERAL_ERROR_BASE + 0x7000; |
| | 703 | pub const B_MAIL_ERROR_BASE = B_GENERAL_ERROR_BASE + 0x8000; |
| | 704 | pub const B_PRINT_ERROR_BASE = B_GENERAL_ERROR_BASE + 0x9000; |
| | 705 | pub const B_DEVICE_ERROR_BASE = B_GENERAL_ERROR_BASE + 0xa000; |
| | 706 | |
| | 707 | pub const B_ERRORS_END = B_GENERAL_ERROR_BASE + 0xffff; |
| | 708 | |
| | 709 | pub const B_NO_MEMORY = B_GENERAL_ERROR_BASE + 0; |
| | 710 | pub const B_IO_ERROR = B_GENERAL_ERROR_BASE + 1; |
| | 711 | pub const B_PERMISSION_DENIED = B_GENERAL_ERROR_BASE + 2; |
| | 712 | pub const B_BAD_INDEX = B_GENERAL_ERROR_BASE + 3; |
| | 713 | pub const B_BAD_TYPE = B_GENERAL_ERROR_BASE + 4; |
| | 714 | pub const B_BAD_VALUE = B_GENERAL_ERROR_BASE + 5; |
| | 715 | pub const B_MISMATCHED_VALUES = B_GENERAL_ERROR_BASE + 6; |
| | 716 | pub const B_NAME_NOT_FOUND = B_GENERAL_ERROR_BASE + 7; |
| | 717 | pub const B_NAME_IN_USE = B_GENERAL_ERROR_BASE + 8; |
| | 718 | pub const B_TIMED_OUT = B_GENERAL_ERROR_BASE + 9; |
| | 719 | pub const B_INTERRUPTED = B_GENERAL_ERROR_BASE + 10; |
| | 720 | pub const B_WOULD_BLOCK = B_GENERAL_ERROR_BASE + 11; |
| | 721 | pub const B_CANCELED = B_GENERAL_ERROR_BASE + 12; |
| | 722 | pub const B_NO_INIT = B_GENERAL_ERROR_BASE + 13; |
| | 723 | pub const B_NOT_INITIALIZED = B_GENERAL_ERROR_BASE + 13; |
| | 724 | pub const B_BUSY = B_GENERAL_ERROR_BASE + 14; |
| | 725 | pub const B_NOT_ALLOWED = B_GENERAL_ERROR_BASE + 15; |
| | 726 | pub const B_BAD_DATA = B_GENERAL_ERROR_BASE + 16; |
| | 727 | pub const B_DONT_DO_THAT = B_GENERAL_ERROR_BASE + 17; |
| | 728 | |
| | 729 | pub const B_BAD_IMAGE_ID = B_OS_ERROR_BASE + 0x300; |
| | 730 | pub const B_BAD_ADDRESS = B_OS_ERROR_BASE + 0x301; |
| | 731 | pub const B_NOT_AN_EXECUTABLE = B_OS_ERROR_BASE + 0x302; |
| | 732 | pub const B_MISSING_LIBRARY = B_OS_ERROR_BASE + 0x303; |
| | 733 | pub const B_MISSING_SYMBOL = B_OS_ERROR_BASE + 0x304; |
| | 734 | pub const B_UNKNOWN_EXECUTABLE = B_OS_ERROR_BASE + 0x305; |
| | 735 | pub const B_LEGACY_EXECUTABLE = B_OS_ERROR_BASE + 0x306; |
| | 736 | |
| | 737 | pub const B_FILE_ERROR = B_STORAGE_ERROR_BASE + 0; |
| | 738 | pub const B_FILE_EXISTS = B_STORAGE_ERROR_BASE + 2; |
| | 739 | pub const B_ENTRY_NOT_FOUND = B_STORAGE_ERROR_BASE + 3; |
| | 740 | pub const B_NAME_TOO_LONG = B_STORAGE_ERROR_BASE + 4; |
| | 741 | pub const B_NOT_A_DIRECTORY = B_STORAGE_ERROR_BASE + 5; |
| | 742 | pub const B_DIRECTORY_NOT_EMPTY = B_STORAGE_ERROR_BASE + 6; |
| | 743 | pub const B_DEVICE_FULL = B_STORAGE_ERROR_BASE + 7; |
| | 744 | pub const B_READ_ONLY_DEVICE = B_STORAGE_ERROR_BASE + 8; |
| | 745 | pub const B_IS_A_DIRECTORY = B_STORAGE_ERROR_BASE + 9; |
| | 746 | pub const B_NO_MORE_FDS = B_STORAGE_ERROR_BASE + 10; |
| | 747 | pub const B_CROSS_DEVICE_LINK = B_STORAGE_ERROR_BASE + 11; |
| | 748 | pub const B_LINK_LIMIT = B_STORAGE_ERROR_BASE + 12; |
| | 749 | pub const B_BUSTED_PIPE = B_STORAGE_ERROR_BASE + 13; |
| | 750 | pub const B_UNSUPPORTED = B_STORAGE_ERROR_BASE + 14; |
| | 751 | pub const B_PARTITION_TOO_SMALL = B_STORAGE_ERROR_BASE + 15; |
| | 752 | pub const B_PARTIAL_READ = B_STORAGE_ERROR_BASE + 16; |
| | 753 | pub const B_PARTIAL_WRITE = B_STORAGE_ERROR_BASE + 17; |
| | 754 | |
| | 755 | SUCCESS = 0, |
| | 756 | |
| | 757 | @"2BIG" = B_POSIX_ERROR_BASE + 1, |
| | 758 | CHILD = B_POSIX_ERROR_BASE + 2, |
| | 759 | DEADLK = B_POSIX_ERROR_BASE + 3, |
| | 760 | FBIG = B_POSIX_ERROR_BASE + 4, |
| | 761 | MLINK = B_POSIX_ERROR_BASE + 5, |
| | 762 | NFILE = B_POSIX_ERROR_BASE + 6, |
| | 763 | NODEV = B_POSIX_ERROR_BASE + 7, |
| | 764 | NOLCK = B_POSIX_ERROR_BASE + 8, |
| | 765 | NOSYS = B_POSIX_ERROR_BASE + 9, |
| | 766 | NOTTY = B_POSIX_ERROR_BASE + 10, |
| | 767 | NXIO = B_POSIX_ERROR_BASE + 11, |
| | 768 | SPIPE = B_POSIX_ERROR_BASE + 12, |
| | 769 | SRCH = B_POSIX_ERROR_BASE + 13, |
| | 770 | FPOS = B_POSIX_ERROR_BASE + 14, |
| | 771 | SIGPARM = B_POSIX_ERROR_BASE + 15, |
| | 772 | DOM = B_POSIX_ERROR_BASE + 16, |
| | 773 | RANGE = B_POSIX_ERROR_BASE + 17, |
| | 774 | PROTOTYPE = B_POSIX_ERROR_BASE + 18, |
| | 775 | PROTONOSUPPORT = B_POSIX_ERROR_BASE + 19, |
| | 776 | PFNOSUPPORT = B_POSIX_ERROR_BASE + 20, |
| | 777 | AFNOSUPPORT = B_POSIX_ERROR_BASE + 21, |
| | 778 | ADDRINUSE = B_POSIX_ERROR_BASE + 22, |
| | 779 | ADDRNOTAVAIL = B_POSIX_ERROR_BASE + 23, |
| | 780 | NETDOWN = B_POSIX_ERROR_BASE + 24, |
| | 781 | NETUNREACH = B_POSIX_ERROR_BASE + 25, |
| | 782 | NETRESET = B_POSIX_ERROR_BASE + 26, |
| | 783 | CONNABORTED = B_POSIX_ERROR_BASE + 27, |
| | 784 | CONNRESET = B_POSIX_ERROR_BASE + 28, |
| | 785 | ISCONN = B_POSIX_ERROR_BASE + 29, |
| | 786 | NOTCONN = B_POSIX_ERROR_BASE + 30, |
| | 787 | SHUTDOWN = B_POSIX_ERROR_BASE + 31, |
| | 788 | CONNREFUSED = B_POSIX_ERROR_BASE + 32, |
| | 789 | HOSTUNREACH = B_POSIX_ERROR_BASE + 33, |
| | 790 | NOPROTOOPT = B_POSIX_ERROR_BASE + 34, |
| | 791 | NOBUFS = B_POSIX_ERROR_BASE + 35, |
| | 792 | INPROGRESS = B_POSIX_ERROR_BASE + 36, |
| | 793 | ALREADY = B_POSIX_ERROR_BASE + 37, |
| | 794 | ILSEQ = B_POSIX_ERROR_BASE + 38, |
| | 795 | NOMSG = B_POSIX_ERROR_BASE + 39, |
| | 796 | STALE = B_POSIX_ERROR_BASE + 40, |
| | 797 | OVERFLOW = B_POSIX_ERROR_BASE + 41, |
| | 798 | MSGSIZE = B_POSIX_ERROR_BASE + 42, |
| | 799 | OPNOTSUPP = B_POSIX_ERROR_BASE + 43, |
| | 800 | NOTSOCK = B_POSIX_ERROR_BASE + 44, |
| | 801 | HOSTDOWN = B_POSIX_ERROR_BASE + 45, |
| | 802 | BADMSG = B_POSIX_ERROR_BASE + 46, |
| | 803 | CANCELED = B_POSIX_ERROR_BASE + 47, |
| | 804 | DESTADDRREQ = B_POSIX_ERROR_BASE + 48, |
| | 805 | DQUOT = B_POSIX_ERROR_BASE + 49, |
| | 806 | IDRM = B_POSIX_ERROR_BASE + 50, |
| | 807 | MULTIHOP = B_POSIX_ERROR_BASE + 51, |
| | 808 | NODATA = B_POSIX_ERROR_BASE + 52, |
| | 809 | NOLINK = B_POSIX_ERROR_BASE + 53, |
| | 810 | NOSR = B_POSIX_ERROR_BASE + 54, |
| | 811 | NOSTR = B_POSIX_ERROR_BASE + 55, |
| | 812 | NOTSUP = B_POSIX_ERROR_BASE + 56, |
| | 813 | PROTO = B_POSIX_ERROR_BASE + 57, |
| | 814 | TIME = B_POSIX_ERROR_BASE + 58, |
| | 815 | TXTBSY = B_POSIX_ERROR_BASE + 59, |
| | 816 | NOATTR = B_POSIX_ERROR_BASE + 60, |
| | 817 | NOTRECOVERABLE = B_POSIX_ERROR_BASE + 61, |
| | 818 | OWNERDEAD = B_POSIX_ERROR_BASE + 62, |
| | 819 | |
| | 820 | NOMEM = B_NO_MEMORY, |
| | 821 | |
| | 822 | ACCES = B_PERMISSION_DENIED, |
| | 823 | INTR = B_INTERRUPTED, |
| | 824 | IO = B_IO_ERROR, |
| | 825 | BUSY = B_BUSY, |
| | 826 | FAULT = B_BAD_ADDRESS, |
| | 827 | TIMEDOUT = B_TIMED_OUT, |
| | 828 | /// Also used for WOULDBLOCK |
| | 829 | AGAIN = B_WOULD_BLOCK, |
| | 830 | BADF = B_FILE_ERROR, |
| | 831 | EXIST = B_FILE_EXISTS, |
| | 832 | INVAL = B_BAD_VALUE, |
| | 833 | NAMETOOLONG = B_NAME_TOO_LONG, |
| | 834 | NOENT = B_ENTRY_NOT_FOUND, |
| | 835 | PERM = B_NOT_ALLOWED, |
| | 836 | NOTDIR = B_NOT_A_DIRECTORY, |
| | 837 | ISDIR = B_IS_A_DIRECTORY, |
| | 838 | NOTEMPTY = B_DIRECTORY_NOT_EMPTY, |
| | 839 | NOSPC = B_DEVICE_FULL, |
| | 840 | ROFS = B_READ_ONLY_DEVICE, |
| | 841 | MFILE = B_NO_MORE_FDS, |
| | 842 | XDEV = B_CROSS_DEVICE_LINK, |
| | 843 | LOOP = B_LINK_LIMIT, |
| | 844 | NOEXEC = B_NOT_AN_EXECUTABLE, |
| | 845 | PIPE = B_BUSTED_PIPE, |
| | 846 | |
| | 847 | _, |
| 558 | }; | 848 | }; |
| 559 | | 849 | |
| | 850 | // /system/develop/headers/os/support/SupportDefs.h |
| | 851 | |
| | 852 | pub const status_t = i32; |
| | 853 | |
| 560 | // /system/develop/headers/posix/arch/*/signal.h | 854 | // /system/develop/headers/posix/arch/*/signal.h |
| 561 | | 855 | |
| 562 | pub const vregs = switch (builtin.cpu.arch) { | 856 | pub const vregs = switch (builtin.cpu.arch) { |
| ... | @@ -736,531 +1030,364 @@ pub const vregs = switch (builtin.cpu.arch) { | ... | @@ -736,531 +1030,364 @@ pub const vregs = switch (builtin.cpu.arch) { |
| 736 | reserved2: u16, | 1030 | reserved2: u16, |
| 737 | mxcsr: u32, | 1031 | mxcsr: u32, |
| 738 | reserved3: u32, | 1032 | reserved3: u32, |
| 739 | fp_mmx: [8]fp_register, | 1033 | fp_mmx: [8]fp_register, |
| 740 | xmmx: [8]xmm_register, | 1034 | xmmx: [8]xmm_register, |
| 741 | reserved4: [224]u8, | 1035 | reserved4: [224]u8, |
| 742 | }; | 1036 | }; |
| 743 | | | |
| 744 | pub const extended_regs = extern struct { | | |
| 745 | state: extern union { | | |
| 746 | old_format: old_extended_regs, | | |
| 747 | new_format: new_extended_regs, | | |
| 748 | }, | | |
| 749 | format: u32, | | |
| 750 | }; | | |
| 751 | | | |
| 752 | eip: u32, | | |
| 753 | eflags: u32, | | |
| 754 | eax: u32, | | |
| 755 | ecx: u32, | | |
| 756 | edx: u32, | | |
| 757 | esp: u32, | | |
| 758 | ebp: u32, | | |
| 759 | reserved: u32, | | |
| 760 | xregs: extended_regs, | | |
| 761 | edi: u32, | | |
| 762 | esi: u32, | | |
| 763 | ebx: u32, | | |
| 764 | }, | | |
| 765 | .x86_64 => extern struct { | | |
| 766 | pub const fp_register = extern struct { | | |
| 767 | value: [10]u8, | | |
| 768 | reserved: [6]u8, | | |
| 769 | }; | | |
| 770 | | | |
| 771 | pub const xmm_register = extern struct { | | |
| 772 | value: [16]u8, | | |
| 773 | }; | | |
| 774 | | | |
| 775 | pub const fpu_state = extern struct { | | |
| 776 | control: u16, | | |
| 777 | status: u16, | | |
| 778 | tag: u16, | | |
| 779 | opcode: u16, | | |
| 780 | rip: u64, | | |
| 781 | rdp: u64, | | |
| 782 | mxcsr: u32, | | |
| 783 | mscsr_mask: u32, | | |
| 784 | | | |
| 785 | fp_mmx: [8]fp_register, | | |
| 786 | xmm: [16]xmm_register, | | |
| 787 | reserved: [96]u8, | | |
| 788 | }; | | |
| 789 | | | |
| 790 | pub const xstate_hdr = extern struct { | | |
| 791 | bv: u64, | | |
| 792 | xcomp_bv: u64, | | |
| 793 | reserved: [48]u8, | | |
| 794 | }; | | |
| 795 | | | |
| 796 | pub const savefpu = extern struct { | | |
| 797 | fxsave: fpu_state, | | |
| 798 | xstate: xstate_hdr, | | |
| 799 | ymm: [16]xmm_register, | | |
| 800 | }; | | |
| 801 | | | |
| 802 | rax: u64, | | |
| 803 | rbx: u64, | | |
| 804 | rcx: u64, | | |
| 805 | rdx: u64, | | |
| 806 | rdi: u64, | | |
| 807 | rsi: u64, | | |
| 808 | rbp: u64, | | |
| 809 | r8: u64, | | |
| 810 | r9: u64, | | |
| 811 | r10: u64, | | |
| 812 | r11: u64, | | |
| 813 | r12: u64, | | |
| 814 | r13: u64, | | |
| 815 | r14: u64, | | |
| 816 | r15: u64, | | |
| 817 | rsp: u64, | | |
| 818 | rip: u64, | | |
| 819 | rflags: u64, | | |
| 820 | fpu: savefpu, | | |
| 821 | }, | | |
| 822 | else => void, | | |
| 823 | }; | | |
| 824 | | | |
| 825 | // access function | | |
| 826 | pub const F_OK = 0; // test for existence of file | | |
| 827 | pub const X_OK = 1; // test for execute or search permission | | |
| 828 | pub const W_OK = 2; // test for write permission | | |
| 829 | pub const R_OK = 4; // test for read permission | | |
| 830 | | | |
| 831 | pub const F = struct { | | |
| 832 | pub const DUPFD = 0x0001; | | |
| 833 | pub const GETFD = 0x0002; | | |
| 834 | pub const SETFD = 0x0004; | | |
| 835 | pub const GETFL = 0x0008; | | |
| 836 | pub const SETFL = 0x0010; | | |
| 837 | | | |
| 838 | pub const GETLK = 0x0020; | | |
| 839 | pub const SETLK = 0x0080; | | |
| 840 | pub const SETLKW = 0x0100; | | |
| 841 | pub const DUPFD_CLOEXEC = 0x0200; | | |
| 842 | | | |
| 843 | pub const RDLCK = 0x0040; | | |
| 844 | pub const UNLCK = 0x0200; | | |
| 845 | pub const WRLCK = 0x0400; | | |
| 846 | }; | | |
| 847 | | | |
| 848 | pub const LOCK = struct { | | |
| 849 | pub const SH = 0x01; | | |
| 850 | pub const EX = 0x02; | | |
| 851 | pub const NB = 0x04; | | |
| 852 | pub const UN = 0x08; | | |
| 853 | }; | | |
| 854 | | | |
| 855 | pub const FD_CLOEXEC = 1; | | |
| 856 | | | |
| 857 | pub const SEEK = struct { | | |
| 858 | pub const SET = 0; | | |
| 859 | pub const CUR = 1; | | |
| 860 | pub const END = 2; | | |
| 861 | }; | | |
| 862 | | | |
| 863 | pub const SOCK = struct { | | |
| 864 | pub const STREAM = 1; | | |
| 865 | pub const DGRAM = 2; | | |
| 866 | pub const RAW = 3; | | |
| 867 | pub const SEQPACKET = 5; | | |
| 868 | | | |
| 869 | /// WARNING: this flag is not supported by windows socket functions directly, | | |
| 870 | /// it is only supported by std.os.socket. Be sure that this value does | | |
| 871 | /// not share any bits with any of the `SOCK` values. | | |
| 872 | pub const CLOEXEC = 0x10000; | | |
| 873 | /// WARNING: this flag is not supported by windows socket functions directly, | | |
| 874 | /// it is only supported by std.os.socket. Be sure that this value does | | |
| 875 | /// not share any bits with any of the `SOCK` values. | | |
| 876 | pub const NONBLOCK = 0x20000; | | |
| 877 | }; | | |
| 878 | | | |
| 879 | pub const SO = struct { | | |
| 880 | pub const ACCEPTCONN = 0x00000001; | | |
| 881 | pub const BROADCAST = 0x00000002; | | |
| 882 | pub const DEBUG = 0x00000004; | | |
| 883 | pub const DONTROUTE = 0x00000008; | | |
| 884 | pub const KEEPALIVE = 0x00000010; | | |
| 885 | pub const OOBINLINE = 0x00000020; | | |
| 886 | pub const REUSEADDR = 0x00000040; | | |
| 887 | pub const REUSEPORT = 0x00000080; | | |
| 888 | pub const USELOOPBACK = 0x00000100; | | |
| 889 | pub const LINGER = 0x00000200; | | |
| 890 | | | |
| 891 | pub const SNDBUF = 0x40000001; | | |
| 892 | pub const SNDLOWAT = 0x40000002; | | |
| 893 | pub const SNDTIMEO = 0x40000003; | | |
| 894 | pub const RCVBUF = 0x40000004; | | |
| 895 | pub const RCVLOWAT = 0x40000005; | | |
| 896 | pub const RCVTIMEO = 0x40000006; | | |
| 897 | pub const ERROR = 0x40000007; | | |
| 898 | pub const TYPE = 0x40000008; | | |
| 899 | pub const NONBLOCK = 0x40000009; | | |
| 900 | pub const BINDTODEVICE = 0x4000000a; | | |
| 901 | pub const PEERCRED = 0x4000000b; | | |
| 902 | }; | | |
| 903 | | 1037 | |
| 904 | pub const SOL = struct { | 1038 | pub const extended_regs = extern struct { |
| 905 | pub const SOCKET = -1; | 1039 | state: extern union { |
| 906 | }; | 1040 | old_format: old_extended_regs, |
| | 1041 | new_format: new_extended_regs, |
| | 1042 | }, |
| | 1043 | format: u32, |
| | 1044 | }; |
| 907 | | 1045 | |
| 908 | pub const PF = struct { | 1046 | eip: u32, |
| 909 | pub const UNSPEC = AF.UNSPEC; | 1047 | eflags: u32, |
| 910 | pub const INET = AF.INET; | 1048 | eax: u32, |
| 911 | pub const ROUTE = AF.ROUTE; | 1049 | ecx: u32, |
| 912 | pub const LINK = AF.LINK; | 1050 | edx: u32, |
| 913 | pub const INET6 = AF.INET6; | 1051 | esp: u32, |
| 914 | pub const LOCAL = AF.LOCAL; | 1052 | ebp: u32, |
| 915 | pub const UNIX = AF.UNIX; | 1053 | reserved: u32, |
| 916 | pub const BLUETOOTH = AF.BLUETOOTH; | 1054 | xregs: extended_regs, |
| 917 | }; | 1055 | edi: u32, |
| | 1056 | esi: u32, |
| | 1057 | ebx: u32, |
| | 1058 | }, |
| | 1059 | .x86_64 => extern struct { |
| | 1060 | pub const fp_register = extern struct { |
| | 1061 | value: [10]u8, |
| | 1062 | reserved: [6]u8, |
| | 1063 | }; |
| 918 | | 1064 | |
| 919 | pub const AF = struct { | 1065 | pub const xmm_register = extern struct { |
| 920 | pub const UNSPEC = 0; | 1066 | value: [16]u8, |
| 921 | pub const INET = 1; | 1067 | }; |
| 922 | pub const APPLETALK = 2; | | |
| 923 | pub const ROUTE = 3; | | |
| 924 | pub const LINK = 4; | | |
| 925 | pub const INET6 = 5; | | |
| 926 | pub const DLI = 6; | | |
| 927 | pub const IPX = 7; | | |
| 928 | pub const NOTIFY = 8; | | |
| 929 | pub const LOCAL = 9; | | |
| 930 | pub const UNIX = LOCAL; | | |
| 931 | pub const BLUETOOTH = 10; | | |
| 932 | pub const MAX = 11; | | |
| 933 | }; | | |
| 934 | | 1068 | |
| 935 | pub const DT = struct {}; | 1069 | pub const fpu_state = extern struct { |
| | 1070 | control: u16, |
| | 1071 | status: u16, |
| | 1072 | tag: u16, |
| | 1073 | opcode: u16, |
| | 1074 | rip: u64, |
| | 1075 | rdp: u64, |
| | 1076 | mxcsr: u32, |
| | 1077 | mscsr_mask: u32, |
| 936 | | 1078 | |
| 937 | /// add event to kq (implies enable) | 1079 | fp_mmx: [8]fp_register, |
| 938 | pub const EV_ADD = 0x0001; | 1080 | xmm: [16]xmm_register, |
| | 1081 | reserved: [96]u8, |
| | 1082 | }; |
| 939 | | 1083 | |
| 940 | /// delete event from kq | 1084 | pub const xstate_hdr = extern struct { |
| 941 | pub const EV_DELETE = 0x0002; | 1085 | bv: u64, |
| | 1086 | xcomp_bv: u64, |
| | 1087 | reserved: [48]u8, |
| | 1088 | }; |
| 942 | | 1089 | |
| 943 | /// enable event | 1090 | pub const savefpu = extern struct { |
| 944 | pub const EV_ENABLE = 0x0004; | 1091 | fxsave: fpu_state, |
| | 1092 | xstate: xstate_hdr, |
| | 1093 | ymm: [16]xmm_register, |
| | 1094 | }; |
| 945 | | 1095 | |
| 946 | /// disable event (not reported) | 1096 | rax: u64, |
| 947 | pub const EV_DISABLE = 0x0008; | 1097 | rbx: u64, |
| | 1098 | rcx: u64, |
| | 1099 | rdx: u64, |
| | 1100 | rdi: u64, |
| | 1101 | rsi: u64, |
| | 1102 | rbp: u64, |
| | 1103 | r8: u64, |
| | 1104 | r9: u64, |
| | 1105 | r10: u64, |
| | 1106 | r11: u64, |
| | 1107 | r12: u64, |
| | 1108 | r13: u64, |
| | 1109 | r14: u64, |
| | 1110 | r15: u64, |
| | 1111 | rsp: u64, |
| | 1112 | rip: u64, |
| | 1113 | rflags: u64, |
| | 1114 | fpu: savefpu, |
| | 1115 | }, |
| | 1116 | else => void, |
| | 1117 | }; |
| 948 | | 1118 | |
| 949 | /// only report one occurrence | 1119 | // /system/develop/headers/posix/dirent.h |
| 950 | pub const EV_ONESHOT = 0x0010; | 1120 | |
| | 1121 | pub const DirEnt = extern struct { |
| | 1122 | /// device |
| | 1123 | dev: dev_t, |
| | 1124 | /// parent device (only for queries) |
| | 1125 | pdev: dev_t, |
| | 1126 | /// inode number |
| | 1127 | ino: ino_t, |
| | 1128 | /// parent inode (only for queries) |
| | 1129 | pino: ino_t, |
| | 1130 | /// length of this record, not the name |
| | 1131 | reclen: u16, |
| | 1132 | /// name of the entry (null byte terminated) |
| | 1133 | name: [0]u8, |
| | 1134 | pub fn getName(dirent: *const DirEnt) [*:0]const u8 { |
| | 1135 | return @ptrCast(&dirent.name); |
| | 1136 | } |
| | 1137 | }; |
| 951 | | 1138 | |
| 952 | /// clear event state after reporting | 1139 | // /system/develop/headers/posix/errno.h |
| 953 | pub const EV_CLEAR = 0x0020; | | |
| 954 | | 1140 | |
| 955 | /// force immediate event output | 1141 | extern "root" fn _errnop() *i32; |
| 956 | /// ... with or without EV_ERROR | 1142 | pub const _errno = _errnop; |
| 957 | /// ... use KEVENT_FLAG_ERROR_EVENTS | | |
| 958 | /// on syscalls supporting flags | | |
| 959 | pub const EV_RECEIPT = 0x0040; | | |
| 960 | | 1143 | |
| 961 | /// disable event after reporting | 1144 | // /system/develop/headers/posix/poll.h |
| 962 | pub const EV_DISPATCH = 0x0080; | | |
| 963 | | 1145 | |
| 964 | pub const EVFILT_READ = -1; | 1146 | pub const nfds_t = usize; |
| 965 | pub const EVFILT_WRITE = -2; | | |
| 966 | | 1147 | |
| 967 | /// attached to aio requests | 1148 | pub const pollfd = extern struct { |
| 968 | pub const EVFILT_AIO = -3; | 1149 | fd: i32, |
| | 1150 | events: i16, |
| | 1151 | revents: i16, |
| | 1152 | }; |
| 969 | | 1153 | |
| 970 | /// attached to vnodes | 1154 | pub const POLL = struct { |
| 971 | pub const EVFILT_VNODE = -4; | 1155 | /// any readable data available |
| | 1156 | pub const IN = 0x0001; |
| | 1157 | /// file descriptor is writeable |
| | 1158 | pub const OUT = 0x0002; |
| | 1159 | pub const RDNORM = IN; |
| | 1160 | pub const WRNORM = OUT; |
| | 1161 | /// priority readable data |
| | 1162 | pub const RDBAND = 0x0008; |
| | 1163 | /// priority data can be written |
| | 1164 | pub const WRBAND = 0x0010; |
| | 1165 | /// high priority readable data |
| | 1166 | pub const PRI = 0x0020; |
| 972 | | 1167 | |
| 973 | /// attached to struct proc | 1168 | /// errors pending |
| 974 | pub const EVFILT_PROC = -5; | 1169 | pub const ERR = 0x0004; |
| | 1170 | /// disconnected |
| | 1171 | pub const HUP = 0x0080; |
| | 1172 | /// invalid file descriptor |
| | 1173 | pub const NVAL = 0x1000; |
| | 1174 | }; |
| 975 | | 1175 | |
| 976 | /// attached to struct proc | 1176 | // /system/develop/headers/posix/signal.h |
| 977 | pub const EVFILT_SIGNAL = -6; | | |
| 978 | | 1177 | |
| 979 | /// timers | 1178 | pub const sigset_t = u64; |
| 980 | pub const EVFILT_TIMER = -7; | 1179 | pub const empty_sigset: sigset_t = 0; |
| | 1180 | pub const filled_sigset = ~@as(sigset_t, 0); |
| 981 | | 1181 | |
| 982 | /// Process descriptors | 1182 | pub const SIG = struct { |
| 983 | pub const EVFILT_PROCDESC = -8; | 1183 | pub const DFL: ?Sigaction.handler_fn = @ptrFromInt(0); |
| | 1184 | pub const IGN: ?Sigaction.handler_fn = @ptrFromInt(1); |
| | 1185 | pub const ERR: ?Sigaction.handler_fn = @ptrFromInt(maxInt(usize)); |
| 984 | | 1186 | |
| 985 | /// Filesystem events | 1187 | pub const HOLD: ?Sigaction.handler_fn = @ptrFromInt(3); |
| 986 | pub const EVFILT_FS = -9; | | |
| 987 | | 1188 | |
| 988 | pub const EVFILT_LIO = -10; | 1189 | pub const HUP = 1; |
| | 1190 | pub const INT = 2; |
| | 1191 | pub const QUIT = 3; |
| | 1192 | pub const ILL = 4; |
| | 1193 | pub const CHLD = 5; |
| | 1194 | pub const ABRT = 6; |
| | 1195 | pub const IOT = ABRT; |
| | 1196 | pub const PIPE = 7; |
| | 1197 | pub const FPE = 8; |
| | 1198 | pub const KILL = 9; |
| | 1199 | pub const STOP = 10; |
| | 1200 | pub const SEGV = 11; |
| | 1201 | pub const CONT = 12; |
| | 1202 | pub const TSTP = 13; |
| | 1203 | pub const ALRM = 14; |
| | 1204 | pub const TERM = 15; |
| | 1205 | pub const TTIN = 16; |
| | 1206 | pub const TTOU = 17; |
| | 1207 | pub const USR1 = 18; |
| | 1208 | pub const USR2 = 19; |
| | 1209 | pub const WINCH = 20; |
| | 1210 | pub const KILLTHR = 21; |
| | 1211 | pub const TRAP = 22; |
| | 1212 | pub const POLL = 23; |
| | 1213 | pub const PROF = 24; |
| | 1214 | pub const SYS = 25; |
| | 1215 | pub const URG = 26; |
| | 1216 | pub const VTALRM = 27; |
| | 1217 | pub const XCPU = 28; |
| | 1218 | pub const XFSZ = 29; |
| | 1219 | pub const BUS = 30; |
| | 1220 | pub const RESERVED1 = 31; |
| | 1221 | pub const RESERVED2 = 32; |
| 989 | | 1222 | |
| 990 | /// User events | 1223 | pub const BLOCK = 1; |
| 991 | pub const EVFILT_USER = -11; | 1224 | pub const UNBLOCK = 2; |
| | 1225 | pub const SETMASK = 3; |
| | 1226 | }; |
| 992 | | 1227 | |
| 993 | /// Sendfile events | 1228 | pub const siginfo_t = extern struct { |
| 994 | pub const EVFILT_SENDFILE = -12; | 1229 | signo: i32, |
| | 1230 | code: i32, |
| | 1231 | errno: i32, |
| 995 | | 1232 | |
| 996 | pub const EVFILT_EMPTY = -13; | 1233 | pid: pid_t, |
| | 1234 | uid: uid_t, |
| | 1235 | addr: *allowzero anyopaque, |
| | 1236 | }; |
| 997 | | 1237 | |
| 998 | pub const T = struct { | 1238 | /// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall. |
| 999 | pub const CGETA = 0x8000; | 1239 | pub const Sigaction = extern struct { |
| 1000 | pub const CSETA = 0x8001; | 1240 | pub const handler_fn = *align(1) const fn (i32) callconv(.C) void; |
| 1001 | pub const CSETAF = 0x8002; | 1241 | pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void; |
| 1002 | pub const CSETAW = 0x8003; | | |
| 1003 | pub const CWAITEVENT = 0x8004; | | |
| 1004 | pub const CSBRK = 0x8005; | | |
| 1005 | pub const CFLSH = 0x8006; | | |
| 1006 | pub const CXONC = 0x8007; | | |
| 1007 | pub const CQUERYCONNECTED = 0x8008; | | |
| 1008 | pub const CGETBITS = 0x8009; | | |
| 1009 | pub const CSETDTR = 0x8010; | | |
| 1010 | pub const CSETRTS = 0x8011; | | |
| 1011 | pub const IOCGWINSZ = 0x8012; | | |
| 1012 | pub const IOCSWINSZ = 0x8013; | | |
| 1013 | pub const CVTIME = 0x8014; | | |
| 1014 | pub const IOCGPGRP = 0x8015; | | |
| 1015 | pub const IOCSPGRP = 0x8016; | | |
| 1016 | pub const IOCSCTTY = 0x8017; | | |
| 1017 | pub const IOCMGET = 0x8018; | | |
| 1018 | pub const IOCMSET = 0x8019; | | |
| 1019 | pub const IOCSBRK = 0x8020; | | |
| 1020 | pub const IOCCBRK = 0x8021; | | |
| 1021 | pub const IOCMBIS = 0x8022; | | |
| 1022 | pub const IOCMBIC = 0x8023; | | |
| 1023 | pub const IOCGSID = 0x8024; | | |
| 1024 | | 1242 | |
| 1025 | pub const FIONREAD = 0xbe000001; | 1243 | /// signal handler |
| 1026 | pub const FIONBIO = 0xbe000000; | 1244 | handler: extern union { |
| | 1245 | handler: handler_fn, |
| | 1246 | sigaction: sigaction_fn, |
| | 1247 | }, |
| | 1248 | |
| | 1249 | /// signal mask to apply |
| | 1250 | mask: sigset_t, |
| | 1251 | |
| | 1252 | /// see signal options |
| | 1253 | flags: i32, |
| | 1254 | |
| | 1255 | /// will be passed to the signal handler, BeOS extension |
| | 1256 | userdata: *allowzero anyopaque = undefined, |
| 1027 | }; | 1257 | }; |
| 1028 | | 1258 | |
| 1029 | pub const winsize = extern struct { | 1259 | pub const SA = struct { |
| 1030 | ws_row: u16, | 1260 | pub const NOCLDSTOP = 0x01; |
| 1031 | ws_col: u16, | 1261 | pub const NOCLDWAIT = 0x02; |
| 1032 | ws_xpixel: u16, | 1262 | pub const RESETHAND = 0x04; |
| 1033 | ws_ypixel: u16, | 1263 | pub const NODEFER = 0x08; |
| | 1264 | pub const RESTART = 0x10; |
| | 1265 | pub const ONSTACK = 0x20; |
| | 1266 | pub const SIGINFO = 0x40; |
| | 1267 | pub const NOMASK = NODEFER; |
| | 1268 | pub const STACK = ONSTACK; |
| | 1269 | pub const ONESHOT = RESETHAND; |
| 1034 | }; | 1270 | }; |
| 1035 | | 1271 | |
| 1036 | const B_POSIX_ERROR_BASE = -2147454976; | 1272 | pub const SS = struct { |
| | 1273 | pub const ONSTACK = 0x1; |
| | 1274 | pub const DISABLE = 0x2; |
| | 1275 | }; |
| 1037 | | 1276 | |
| 1038 | pub const E = enum(i32) { | 1277 | pub const MINSIGSTKSZ = 8192; |
| 1039 | @"2BIG" = B_POSIX_ERROR_BASE + 1, | 1278 | pub const SIGSTKSZ = 16384; |
| 1040 | CHILD = B_POSIX_ERROR_BASE + 2, | | |
| 1041 | DEADLK = B_POSIX_ERROR_BASE + 3, | | |
| 1042 | FBIG = B_POSIX_ERROR_BASE + 4, | | |
| 1043 | MLINK = B_POSIX_ERROR_BASE + 5, | | |
| 1044 | NFILE = B_POSIX_ERROR_BASE + 6, | | |
| 1045 | NODEV = B_POSIX_ERROR_BASE + 7, | | |
| 1046 | NOLCK = B_POSIX_ERROR_BASE + 8, | | |
| 1047 | NOSYS = B_POSIX_ERROR_BASE + 9, | | |
| 1048 | NOTTY = B_POSIX_ERROR_BASE + 10, | | |
| 1049 | NXIO = B_POSIX_ERROR_BASE + 11, | | |
| 1050 | SPIPE = B_POSIX_ERROR_BASE + 12, | | |
| 1051 | SRCH = B_POSIX_ERROR_BASE + 13, | | |
| 1052 | FPOS = B_POSIX_ERROR_BASE + 14, | | |
| 1053 | SIGPARM = B_POSIX_ERROR_BASE + 15, | | |
| 1054 | DOM = B_POSIX_ERROR_BASE + 16, | | |
| 1055 | RANGE = B_POSIX_ERROR_BASE + 17, | | |
| 1056 | PROTOTYPE = B_POSIX_ERROR_BASE + 18, | | |
| 1057 | PROTONOSUPPORT = B_POSIX_ERROR_BASE + 19, | | |
| 1058 | PFNOSUPPORT = B_POSIX_ERROR_BASE + 20, | | |
| 1059 | AFNOSUPPORT = B_POSIX_ERROR_BASE + 21, | | |
| 1060 | ADDRINUSE = B_POSIX_ERROR_BASE + 22, | | |
| 1061 | ADDRNOTAVAIL = B_POSIX_ERROR_BASE + 23, | | |
| 1062 | NETDOWN = B_POSIX_ERROR_BASE + 24, | | |
| 1063 | NETUNREACH = B_POSIX_ERROR_BASE + 25, | | |
| 1064 | NETRESET = B_POSIX_ERROR_BASE + 26, | | |
| 1065 | CONNABORTED = B_POSIX_ERROR_BASE + 27, | | |
| 1066 | CONNRESET = B_POSIX_ERROR_BASE + 28, | | |
| 1067 | ISCONN = B_POSIX_ERROR_BASE + 29, | | |
| 1068 | NOTCONN = B_POSIX_ERROR_BASE + 30, | | |
| 1069 | SHUTDOWN = B_POSIX_ERROR_BASE + 31, | | |
| 1070 | CONNREFUSED = B_POSIX_ERROR_BASE + 32, | | |
| 1071 | HOSTUNREACH = B_POSIX_ERROR_BASE + 33, | | |
| 1072 | NOPROTOOPT = B_POSIX_ERROR_BASE + 34, | | |
| 1073 | NOBUFS = B_POSIX_ERROR_BASE + 35, | | |
| 1074 | INPROGRESS = B_POSIX_ERROR_BASE + 36, | | |
| 1075 | ALREADY = B_POSIX_ERROR_BASE + 37, | | |
| 1076 | ILSEQ = B_POSIX_ERROR_BASE + 38, | | |
| 1077 | NOMSG = B_POSIX_ERROR_BASE + 39, | | |
| 1078 | STALE = B_POSIX_ERROR_BASE + 40, | | |
| 1079 | OVERFLOW = B_POSIX_ERROR_BASE + 41, | | |
| 1080 | MSGSIZE = B_POSIX_ERROR_BASE + 42, | | |
| 1081 | OPNOTSUPP = B_POSIX_ERROR_BASE + 43, | | |
| 1082 | NOTSOCK = B_POSIX_ERROR_BASE + 44, | | |
| 1083 | HOSTDOWN = B_POSIX_ERROR_BASE + 45, | | |
| 1084 | BADMSG = B_POSIX_ERROR_BASE + 46, | | |
| 1085 | CANCELED = B_POSIX_ERROR_BASE + 47, | | |
| 1086 | DESTADDRREQ = B_POSIX_ERROR_BASE + 48, | | |
| 1087 | DQUOT = B_POSIX_ERROR_BASE + 49, | | |
| 1088 | IDRM = B_POSIX_ERROR_BASE + 50, | | |
| 1089 | MULTIHOP = B_POSIX_ERROR_BASE + 51, | | |
| 1090 | NODATA = B_POSIX_ERROR_BASE + 52, | | |
| 1091 | NOLINK = B_POSIX_ERROR_BASE + 53, | | |
| 1092 | NOSR = B_POSIX_ERROR_BASE + 54, | | |
| 1093 | NOSTR = B_POSIX_ERROR_BASE + 55, | | |
| 1094 | NOTSUP = B_POSIX_ERROR_BASE + 56, | | |
| 1095 | PROTO = B_POSIX_ERROR_BASE + 57, | | |
| 1096 | TIME = B_POSIX_ERROR_BASE + 58, | | |
| 1097 | TXTBSY = B_POSIX_ERROR_BASE + 59, | | |
| 1098 | NOATTR = B_POSIX_ERROR_BASE + 60, | | |
| 1099 | NOTRECOVERABLE = B_POSIX_ERROR_BASE + 61, | | |
| 1100 | OWNERDEAD = B_POSIX_ERROR_BASE + 62, | | |
| 1101 | | 1279 | |
| 1102 | ACCES = -0x7ffffffe, // Permission denied | 1280 | pub const stack_t = extern struct { |
| 1103 | INTR = -0x7ffffff6, // Interrupted system call | 1281 | sp: [*]u8, |
| 1104 | IO = -0x7fffffff, // Input/output error | 1282 | size: isize, |
| 1105 | BUSY = -0x7ffffff2, // Device busy | 1283 | flags: i32, |
| 1106 | FAULT = -0x7fffecff, // Bad address | | |
| 1107 | TIMEDOUT = -2147483639, // Operation timed out | | |
| 1108 | AGAIN = -0x7ffffff5, | | |
| 1109 | BADF = -0x7fffa000, // Bad file descriptor | | |
| 1110 | EXIST = -0x7fff9ffe, // File exists | | |
| 1111 | INVAL = -0x7ffffffb, // Invalid argument | | |
| 1112 | NAMETOOLONG = -2147459068, // File name too long | | |
| 1113 | NOENT = -0x7fff9ffd, // No such file or directory | | |
| 1114 | PERM = -0x7ffffff1, // Operation not permitted | | |
| 1115 | NOTDIR = -0x7fff9ffb, // Not a directory | | |
| 1116 | ISDIR = -0x7fff9ff7, // Is a directory | | |
| 1117 | NOTEMPTY = -2147459066, // Directory not empty | | |
| 1118 | NOSPC = -0x7fff9ff9, // No space left on device | | |
| 1119 | ROFS = -0x7fff9ff8, // Read-only filesystem | | |
| 1120 | MFILE = -0x7fff9ff6, // Too many open files | | |
| 1121 | XDEV = -0x7fff9ff5, // Cross-device link | | |
| 1122 | NOEXEC = -0x7fffecfe, // Exec format error | | |
| 1123 | PIPE = -0x7fff9ff3, // Broken pipe | | |
| 1124 | NOMEM = -0x80000000, // Cannot allocate memory | | |
| 1125 | LOOP = -2147459060, // Too many levels of symbolic links | | |
| 1126 | SUCCESS = 0, | | |
| 1127 | _, | | |
| 1128 | }; | 1284 | }; |
| 1129 | | 1285 | |
| 1130 | pub const S = struct { | 1286 | pub const NSIG = 65; |
| 1131 | pub const IFMT = 0o170000; | | |
| 1132 | pub const IFSOCK = 0o140000; | | |
| 1133 | pub const IFLNK = 0o120000; | | |
| 1134 | pub const IFREG = 0o100000; | | |
| 1135 | pub const IFBLK = 0o060000; | | |
| 1136 | pub const IFDIR = 0o040000; | | |
| 1137 | pub const IFCHR = 0o020000; | | |
| 1138 | pub const IFIFO = 0o010000; | | |
| 1139 | pub const INDEX_DIR = 0o4000000000; | | |
| 1140 | | | |
| 1141 | pub const IUMSK = 0o7777; | | |
| 1142 | pub const ISUID = 0o4000; | | |
| 1143 | pub const ISGID = 0o2000; | | |
| 1144 | pub const ISVTX = 0o1000; | | |
| 1145 | pub const IRWXU = 0o700; | | |
| 1146 | pub const IRUSR = 0o400; | | |
| 1147 | pub const IWUSR = 0o200; | | |
| 1148 | pub const IXUSR = 0o100; | | |
| 1149 | pub const IRWXG = 0o070; | | |
| 1150 | pub const IRGRP = 0o040; | | |
| 1151 | pub const IWGRP = 0o020; | | |
| 1152 | pub const IXGRP = 0o010; | | |
| 1153 | pub const IRWXO = 0o007; | | |
| 1154 | pub const IROTH = 0o004; | | |
| 1155 | pub const IWOTH = 0o002; | | |
| 1156 | pub const IXOTH = 0o001; | | |
| 1157 | | 1287 | |
| 1158 | pub fn ISREG(m: u32) bool { | 1288 | pub const mcontext_t = vregs; |
| 1159 | return m & IFMT == IFREG; | | |
| 1160 | } | | |
| 1161 | | 1289 | |
| 1162 | pub fn ISLNK(m: u32) bool { | 1290 | pub const ucontext_t = extern struct { |
| 1163 | return m & IFMT == IFLNK; | 1291 | link: ?*ucontext_t, |
| 1164 | } | 1292 | sigmask: sigset_t, |
| | 1293 | stack: stack_t, |
| | 1294 | mcontext: mcontext_t, |
| | 1295 | }; |
| 1165 | | 1296 | |
| 1166 | pub fn ISBLK(m: u32) bool { | 1297 | // /system/develop/headers/posix/sys/stat.h |
| 1167 | return m & IFMT == IFBLK; | | |
| 1168 | } | | |
| 1169 | | 1298 | |
| 1170 | pub fn ISDIR(m: u32) bool { | 1299 | pub const Stat = extern struct { |
| 1171 | return m & IFMT == IFDIR; | 1300 | dev: dev_t, |
| 1172 | } | 1301 | ino: ino_t, |
| | 1302 | mode: mode_t, |
| | 1303 | nlink: nlink_t, |
| | 1304 | uid: uid_t, |
| | 1305 | gid: gid_t, |
| | 1306 | size: off_t, |
| | 1307 | rdev: dev_t, |
| | 1308 | blksize: blksize_t, |
| | 1309 | atim: timespec, |
| | 1310 | mtim: timespec, |
| | 1311 | ctim: timespec, |
| | 1312 | crtim: timespec, |
| | 1313 | type: u32, |
| | 1314 | blocks: blkcnt_t, |
| 1173 | | 1315 | |
| 1174 | pub fn ISCHR(m: u32) bool { | 1316 | pub fn atime(self: @This()) timespec { |
| 1175 | return m & IFMT == IFCHR; | 1317 | return self.atim; |
| 1176 | } | 1318 | } |
| 1177 | | 1319 | pub fn mtime(self: @This()) timespec { |
| 1178 | pub fn ISFIFO(m: u32) bool { | 1320 | return self.mtim; |
| 1179 | return m & IFMT == IFIFO; | | |
| 1180 | } | 1321 | } |
| 1181 | | 1322 | pub fn ctime(self: @This()) timespec { |
| 1182 | pub fn ISSOCK(m: u32) bool { | 1323 | return self.ctim; |
| 1183 | return m & IFMT == IFSOCK; | | |
| 1184 | } | 1324 | } |
| 1185 | | 1325 | pub fn birthtime(self: @This()) timespec { |
| 1186 | pub fn ISINDEX(m: u32) bool { | 1326 | return self.crtim; |
| 1187 | return m & INDEX_DIR == INDEX_DIR; | | |
| 1188 | } | 1327 | } |
| 1189 | }; | 1328 | }; |
| 1190 | | 1329 | |
| 1191 | pub const HOST_NAME_MAX = 255; | 1330 | // /system/develop/headers/posix/sys/types.h |
| 1192 | | 1331 | |
| 1193 | pub const addrinfo = extern struct { | 1332 | pub const blkcnt_t = i64; |
| 1194 | flags: i32, | 1333 | pub const blksize_t = i32; |
| 1195 | family: i32, | 1334 | pub const fsblkcnt_t = i64; |
| 1196 | socktype: i32, | 1335 | pub const fsfilcnt_t = i64; |
| 1197 | protocol: i32, | 1336 | pub const off_t = i64; |
| 1198 | addrlen: socklen_t, | 1337 | pub const ino_t = i64; |
| 1199 | canonname: ?[*:0]u8, | 1338 | pub const cnt_t = i32; |
| 1200 | addr: ?*sockaddr, | 1339 | pub const dev_t = i32; |
| 1201 | next: ?*addrinfo, | 1340 | pub const pid_t = i32; |
| 1202 | }; | 1341 | pub const id_t = i32; |
| 1203 | | 1342 | |
| 1204 | pub const IPPROTO = struct { | 1343 | pub const uid_t = u32; |
| 1205 | pub const IP = 0; | 1344 | pub const gid_t = u32; |
| 1206 | pub const HOPOPTS = 0; | 1345 | pub const mode_t = u32; |
| 1207 | pub const ICMP = 1; | 1346 | pub const umode_t = u32; |
| 1208 | pub const IGMP = 2; | 1347 | pub const nlink_t = i32; |
| 1209 | pub const TCP = 6; | | |
| 1210 | pub const UDP = 17; | | |
| 1211 | pub const IPV6 = 41; | | |
| 1212 | pub const ROUTING = 43; | | |
| 1213 | pub const FRAGMENT = 44; | | |
| 1214 | pub const ESP = 50; | | |
| 1215 | pub const AH = 51; | | |
| 1216 | pub const ICMPV6 = 58; | | |
| 1217 | pub const NONE = 59; | | |
| 1218 | pub const DSTOPTS = 60; | | |
| 1219 | pub const ETHERIP = 97; | | |
| 1220 | pub const RAW = 255; | | |
| 1221 | pub const MAX = 256; | | |
| 1222 | }; | | |
| 1223 | | 1348 | |
| 1224 | pub const rlimit_resource = enum(c_int) { | 1349 | pub const clockid_t = i32; |
| 1225 | CORE = 0, | 1350 | pub const timer_t = *opaque {}; |
| 1226 | CPU = 1, | | |
| 1227 | DATA = 2, | | |
| 1228 | FSIZE = 3, | | |
| 1229 | NOFILE = 4, | | |
| 1230 | STACK = 5, | | |
| 1231 | AS = 6, | | |
| 1232 | NOVMON = 7, | | |
| 1233 | _, | | |
| 1234 | }; | | |
| 1235 | | 1351 | |
| 1236 | pub const rlim_t = i64; | 1352 | // /system/develop/headers/posix/time.h |
| 1237 | | 1353 | |
| 1238 | pub const RLIM = struct { | 1354 | pub const clock_t = i32; |
| 1239 | /// No limit | 1355 | pub const suseconds_t = i32; |
| 1240 | pub const INFINITY: rlim_t = (1 << 63) - 1; | 1356 | pub const useconds_t = u32; |
| 1241 | | 1357 | |
| 1242 | pub const SAVED_MAX = INFINITY; | 1358 | pub const time_t = isize; |
| 1243 | pub const SAVED_CUR = INFINITY; | | |
| 1244 | }; | | |
| 1245 | | 1359 | |
| 1246 | pub const rlimit = extern struct { | 1360 | pub const CLOCKS_PER_SEC = 1_000_000; |
| 1247 | /// Soft limit | 1361 | pub const CLK_TCK = CLOCKS_PER_SEC; |
| 1248 | cur: rlim_t, | 1362 | pub const TIME_UTC = 1; |
| 1249 | /// Hard limit | | |
| 1250 | max: rlim_t, | | |
| 1251 | }; | | |
| 1252 | | 1363 | |
| 1253 | pub const SHUT = struct { | 1364 | pub const CLOCK = struct { |
| 1254 | pub const RD = 0; | 1365 | /// system-wide monotonic clock (aka system time) |
| 1255 | pub const WR = 1; | 1366 | pub const MONOTONIC: clockid_t = 0; |
| 1256 | pub const RDWR = 2; | 1367 | /// system-wide real time clock |
| | 1368 | pub const REALTIME: clockid_t = -1; |
| | 1369 | /// clock measuring the used CPU time of the current process |
| | 1370 | pub const PROCESS_CPUTIME_ID: clockid_t = -2; |
| | 1371 | /// clock measuring the used CPU time of the current thread |
| | 1372 | pub const THREAD_CPUTIME_ID: clockid_t = -3; |
| 1257 | }; | 1373 | }; |
| 1258 | | 1374 | |
| 1259 | // TODO fill out if needed | 1375 | pub const timespec = extern struct { |
| 1260 | pub const directory_which = enum(c_int) { | 1376 | /// seconds |
| 1261 | B_USER_SETTINGS_DIRECTORY = 0xbbe, | 1377 | tv_sec: time_t, |
| | 1378 | /// and nanoseconds |
| | 1379 | tv_nsec: isize, |
| | 1380 | }; |
| 1262 | | 1381 | |
| 1263 | _, | 1382 | pub const itimerspec = extern struct { |
| | 1383 | interval: timespec, |
| | 1384 | value: timespec, |
| 1264 | }; | 1385 | }; |
| 1265 | | 1386 | |
| 1266 | pub const MSG_NOSIGNAL = 0x0800; | 1387 | // /system/develop/headers/private/system/syscalls.h |
| | 1388 | |
| | 1389 | pub extern "root" fn _kern_get_current_team() team_id; |
| | 1390 | pub extern "root" fn _kern_open_dir(fd: fd_t, path: [*:0]const u8) fd_t; |
| | 1391 | pub extern "root" fn _kern_read_dir(fd: fd_t, buffer: [*]u8, bufferSize: usize, maxCount: u32) isize; |
| | 1392 | pub extern "root" fn _kern_rewind_dir(fd: fd_t) status_t; |
| | 1393 | pub extern "root" fn _kern_read_stat(fd: fd_t, path: [*:0]const u8, traverseLink: bool, stat: *Stat, statSize: usize) status_t; |