| author | |
| committer | |
| log | cca57042df374305390b5b0000be75ba6d24fb63 |
| tree | 5ccbc45ec714b1696bed58688a9b4a801e83eac9 |
| parent | 3940a1be18a8312dec9d521c6e30ec4d34c44bd6 |
Also move some usingnamespace test cases from compare_output to
behavior.44 files changed, 1406 insertions(+), 1542 deletions(-)
lib/std/c.zig+1-35| ... | ... | @@ -58,41 +58,7 @@ pub usingnamespace switch (builtin.os.tag) { |
| 58 | 58 | }; |
| 59 | 59 | |
| 60 | 60 | pub usingnamespace switch (builtin.os.tag) { |
| 61 | .netbsd => struct {}, | |
| 62 | .macos, .ios, .watchos, .tvos => struct { | |
| 63 | // XXX: close -> close$NOCANCEL | |
| 64 | // XXX: getdirentries -> _getdirentries64 | |
| 65 | pub extern "c" fn clock_getres(clk_id: c_int, tp: *c.timespec) c_int; | |
| 66 | pub extern "c" fn clock_gettime(clk_id: c_int, tp: *c.timespec) c_int; | |
| 67 | pub extern "c" fn getrusage(who: c_int, usage: *c.rusage) c_int; | |
| 68 | pub extern "c" fn gettimeofday(noalias tv: ?*c.timeval, noalias tz: ?*c.timezone) c_int; | |
| 69 | pub extern "c" fn nanosleep(rqtp: *const c.timespec, rmtp: ?*c.timespec) c_int; | |
| 70 | pub extern "c" fn sched_yield() c_int; | |
| 71 | pub extern "c" fn sigaction(sig: c_int, noalias act: ?*const c.Sigaction, noalias oact: ?*c.Sigaction) c_int; | |
| 72 | pub extern "c" fn sigprocmask(how: c_int, noalias set: ?*const c.sigset_t, noalias oset: ?*c.sigset_t) c_int; | |
| 73 | pub extern "c" fn socket(domain: c_uint, sock_type: c_uint, protocol: c_uint) c_int; | |
| 74 | pub extern "c" fn stat(noalias path: [*:0]const u8, noalias buf: *c.Stat) c_int; | |
| 75 | pub extern "c" fn sigfillset(set: ?*c.sigset_t) void; | |
| 76 | pub extern "c" fn alarm(seconds: c_uint) c_uint; | |
| 77 | pub extern "c" fn sigwait(set: ?*c.sigset_t, sig: ?*c_int) c_int; | |
| 78 | }, | |
| 79 | .windows => struct { | |
| 80 | // TODO: copied the else case and removed the socket function (because its in ws2_32) | |
| 81 | // need to verify which of these is actually supported on windows | |
| 82 | pub extern "c" fn clock_getres(clk_id: c_int, tp: *c.timespec) c_int; | |
| 83 | pub extern "c" fn clock_gettime(clk_id: c_int, tp: *c.timespec) c_int; | |
| 84 | pub extern "c" fn fstat(fd: c.fd_t, buf: *c.Stat) c_int; | |
| 85 | pub extern "c" fn getrusage(who: c_int, usage: *c.rusage) c_int; | |
| 86 | pub extern "c" fn gettimeofday(noalias tv: ?*c.timeval, noalias tz: ?*c.timezone) c_int; | |
| 87 | pub extern "c" fn nanosleep(rqtp: *const c.timespec, rmtp: ?*c.timespec) c_int; | |
| 88 | pub extern "c" fn sched_yield() c_int; | |
| 89 | pub extern "c" fn sigaction(sig: c_int, noalias act: ?*const c.Sigaction, noalias oact: ?*c.Sigaction) c_int; | |
| 90 | pub extern "c" fn sigprocmask(how: c_int, noalias set: ?*const c.sigset_t, noalias oset: ?*c.sigset_t) c_int; | |
| 91 | pub extern "c" fn stat(noalias path: [*:0]const u8, noalias buf: *c.Stat) c_int; | |
| 92 | pub extern "c" fn sigfillset(set: ?*c.sigset_t) void; | |
| 93 | pub extern "c" fn alarm(seconds: c_uint) c_uint; | |
| 94 | pub extern "c" fn sigwait(set: ?*c.sigset_t, sig: ?*c_int) c_int; | |
| 95 | }, | |
| 61 | .netbsd, .macos, .ios, .watchos, .tvos, .windows => struct {}, | |
| 96 | 62 | else => struct { |
| 97 | 63 | pub extern "c" fn clock_getres(clk_id: c_int, tp: *c.timespec) c_int; |
| 98 | 64 | pub extern "c" fn clock_gettime(clk_id: c_int, tp: *c.timespec) c_int; |
lib/std/c/darwin.zig+214-254| ... | ... | @@ -395,10 +395,85 @@ pub const timespec = extern struct { |
| 395 | 395 | pub const sigset_t = u32; |
| 396 | 396 | pub const empty_sigset: sigset_t = 0; |
| 397 | 397 | |
| 398 | pub const SIG_ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize)); | |
| 399 | pub const SIG_DFL = @intToPtr(?Sigaction.sigaction_fn, 0); | |
| 400 | pub const SIG_IGN = @intToPtr(?Sigaction.sigaction_fn, 1); | |
| 401 | pub const SIG_HOLD = @intToPtr(?Sigaction.sigaction_fn, 5); | |
| 398 | pub const SIG = struct { | |
| 399 | pub const ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize)); | |
| 400 | pub const DFL = @intToPtr(?Sigaction.sigaction_fn, 0); | |
| 401 | pub const IGN = @intToPtr(?Sigaction.sigaction_fn, 1); | |
| 402 | pub const HOLD = @intToPtr(?Sigaction.sigaction_fn, 5); | |
| 403 | ||
| 404 | /// block specified signal set | |
| 405 | pub const _BLOCK = 1; | |
| 406 | /// unblock specified signal set | |
| 407 | pub const _UNBLOCK = 2; | |
| 408 | /// set specified signal set | |
| 409 | pub const _SETMASK = 3; | |
| 410 | /// hangup | |
| 411 | pub const HUP = 1; | |
| 412 | /// interrupt | |
| 413 | pub const INT = 2; | |
| 414 | /// quit | |
| 415 | pub const QUIT = 3; | |
| 416 | /// illegal instruction (not reset when caught) | |
| 417 | pub const ILL = 4; | |
| 418 | /// trace trap (not reset when caught) | |
| 419 | pub const TRAP = 5; | |
| 420 | /// abort() | |
| 421 | pub const ABRT = 6; | |
| 422 | /// pollable event ([XSR] generated, not supported) | |
| 423 | pub const POLL = 7; | |
| 424 | /// compatibility | |
| 425 | pub const IOT = ABRT; | |
| 426 | /// EMT instruction | |
| 427 | pub const EMT = 7; | |
| 428 | /// floating point exception | |
| 429 | pub const FPE = 8; | |
| 430 | /// kill (cannot be caught or ignored) | |
| 431 | pub const KILL = 9; | |
| 432 | /// bus error | |
| 433 | pub const BUS = 10; | |
| 434 | /// segmentation violation | |
| 435 | pub const SEGV = 11; | |
| 436 | /// bad argument to system call | |
| 437 | pub const SYS = 12; | |
| 438 | /// write on a pipe with no one to read it | |
| 439 | pub const PIPE = 13; | |
| 440 | /// alarm clock | |
| 441 | pub const ALRM = 14; | |
| 442 | /// software termination signal from kill | |
| 443 | pub const TERM = 15; | |
| 444 | /// urgent condition on IO channel | |
| 445 | pub const URG = 16; | |
| 446 | /// sendable stop signal not from tty | |
| 447 | pub const STOP = 17; | |
| 448 | /// stop signal from tty | |
| 449 | pub const TSTP = 18; | |
| 450 | /// continue a stopped process | |
| 451 | pub const CONT = 19; | |
| 452 | /// to parent on child stop or exit | |
| 453 | pub const CHLD = 20; | |
| 454 | /// to readers pgrp upon background tty read | |
| 455 | pub const TTIN = 21; | |
| 456 | /// like TTIN for output if (tp->t_local&LTOSTOP) | |
| 457 | pub const TTOU = 22; | |
| 458 | /// input/output possible signal | |
| 459 | pub const IO = 23; | |
| 460 | /// exceeded CPU time limit | |
| 461 | pub const XCPU = 24; | |
| 462 | /// exceeded file size limit | |
| 463 | pub const XFSZ = 25; | |
| 464 | /// virtual time alarm | |
| 465 | pub const VTALRM = 26; | |
| 466 | /// profiling time alarm | |
| 467 | pub const PROF = 27; | |
| 468 | /// window size changes | |
| 469 | pub const WINCH = 28; | |
| 470 | /// information request | |
| 471 | pub const INFO = 29; | |
| 472 | /// user defined signal 1 | |
| 473 | pub const USR1 = 30; | |
| 474 | /// user defined signal 2 | |
| 475 | pub const USR2 = 31; | |
| 476 | }; | |
| 402 | 477 | |
| 403 | 478 | pub const siginfo_t = extern struct { |
| 404 | 479 | signo: c_int, |
| ... | ... | @@ -507,17 +582,16 @@ pub const STDIN_FILENO = 0; |
| 507 | 582 | pub const STDOUT_FILENO = 1; |
| 508 | 583 | pub const STDERR_FILENO = 2; |
| 509 | 584 | |
| 510 | /// [MC2] no permissions | |
| 511 | pub const PROT_NONE = 0x00; | |
| 512 | ||
| 513 | /// [MC2] pages can be read | |
| 514 | pub const PROT_READ = 0x01; | |
| 515 | ||
| 516 | /// [MC2] pages can be written | |
| 517 | pub const PROT_WRITE = 0x02; | |
| 518 | ||
| 519 | /// [MC2] pages can be executed | |
| 520 | pub const PROT_EXEC = 0x04; | |
| 585 | pub const PROT = struct { | |
| 586 | /// [MC2] no permissions | |
| 587 | pub const NONE = 0x00; | |
| 588 | /// [MC2] pages can be read | |
| 589 | pub const READ = 0x01; | |
| 590 | /// [MC2] pages can be written | |
| 591 | pub const WRITE = 0x02; | |
| 592 | /// [MC2] pages can be executed | |
| 593 | pub const EXEC = 0x04; | |
| 594 | }; | |
| 521 | 595 | |
| 522 | 596 | pub const MAP = struct { |
| 523 | 597 | /// allocated from memory, swap space |
| ... | ... | @@ -551,10 +625,10 @@ pub const SA_ONSTACK = 0x0001; |
| 551 | 625 | /// restart system on signal return |
| 552 | 626 | pub const SA_RESTART = 0x0002; |
| 553 | 627 | |
| 554 | /// reset to SIG_DFL when taking signal | |
| 628 | /// reset to SIG.DFL when taking signal | |
| 555 | 629 | pub const SA_RESETHAND = 0x0004; |
| 556 | 630 | |
| 557 | /// do not generate SIGCHLD on child stop | |
| 631 | /// do not generate SIG.CHLD on child stop | |
| 558 | 632 | pub const SA_NOCLDSTOP = 0x0008; |
| 559 | 633 | |
| 560 | 634 | /// don't mask the signal we're delivering |
| ... | ... | @@ -572,66 +646,53 @@ pub const SA_USERTRAMP = 0x0100; |
| 572 | 646 | /// signal handler with SA_SIGINFO args with 64bit regs information |
| 573 | 647 | pub const SA_64REGSET = 0x0200; |
| 574 | 648 | |
| 575 | pub const O_PATH = 0x0000; | |
| 576 | ||
| 577 | 649 | pub const F_OK = 0; |
| 578 | 650 | pub const X_OK = 1; |
| 579 | 651 | pub const W_OK = 2; |
| 580 | 652 | pub const R_OK = 4; |
| 581 | 653 | |
| 582 | /// open for reading only | |
| 583 | pub const O_RDONLY = 0x0000; | |
| 584 | ||
| 585 | /// open for writing only | |
| 586 | pub const O_WRONLY = 0x0001; | |
| 587 | ||
| 588 | /// open for reading and writing | |
| 589 | pub const O_RDWR = 0x0002; | |
| 590 | ||
| 591 | /// do not block on open or for data to become available | |
| 592 | pub const O_NONBLOCK = 0x0004; | |
| 593 | ||
| 594 | /// append on each write | |
| 595 | pub const O_APPEND = 0x0008; | |
| 596 | ||
| 597 | /// create file if it does not exist | |
| 598 | pub const O_CREAT = 0x0200; | |
| 599 | ||
| 600 | /// truncate size to 0 | |
| 601 | pub const O_TRUNC = 0x0400; | |
| 602 | ||
| 603 | /// error if O_CREAT and the file exists | |
| 604 | pub const O_EXCL = 0x0800; | |
| 605 | ||
| 606 | /// atomically obtain a shared lock | |
| 607 | pub const O_SHLOCK = 0x0010; | |
| 608 | ||
| 609 | /// atomically obtain an exclusive lock | |
| 610 | pub const O_EXLOCK = 0x0020; | |
| 611 | ||
| 612 | /// do not follow symlinks | |
| 613 | pub const O_NOFOLLOW = 0x0100; | |
| 614 | ||
| 615 | /// allow open of symlinks | |
| 616 | pub const O_SYMLINK = 0x200000; | |
| 617 | ||
| 618 | /// descriptor requested for event notifications only | |
| 619 | pub const O_EVTONLY = 0x8000; | |
| 620 | ||
| 621 | /// mark as close-on-exec | |
| 622 | pub const O_CLOEXEC = 0x1000000; | |
| 623 | ||
| 624 | pub const O_ACCMODE = 3; | |
| 625 | pub const O_ALERT = 536870912; | |
| 626 | pub const O_ASYNC = 64; | |
| 627 | pub const O_DIRECTORY = 1048576; | |
| 628 | pub const O_DP_GETRAWENCRYPTED = 1; | |
| 629 | pub const O_DP_GETRAWUNENCRYPTED = 2; | |
| 630 | pub const O_DSYNC = 4194304; | |
| 631 | pub const O_FSYNC = O_SYNC; | |
| 632 | pub const O_NOCTTY = 131072; | |
| 633 | pub const O_POPUP = 2147483648; | |
| 634 | pub const O_SYNC = 128; | |
| 654 | pub const O = struct { | |
| 655 | pub const PATH = 0x0000; | |
| 656 | /// open for reading only | |
| 657 | pub const RDONLY = 0x0000; | |
| 658 | /// open for writing only | |
| 659 | pub const WRONLY = 0x0001; | |
| 660 | /// open for reading and writing | |
| 661 | pub const RDWR = 0x0002; | |
| 662 | /// do not block on open or for data to become available | |
| 663 | pub const NONBLOCK = 0x0004; | |
| 664 | /// append on each write | |
| 665 | pub const APPEND = 0x0008; | |
| 666 | /// create file if it does not exist | |
| 667 | pub const CREAT = 0x0200; | |
| 668 | /// truncate size to 0 | |
| 669 | pub const TRUNC = 0x0400; | |
| 670 | /// error if CREAT and the file exists | |
| 671 | pub const EXCL = 0x0800; | |
| 672 | /// atomically obtain a shared lock | |
| 673 | pub const SHLOCK = 0x0010; | |
| 674 | /// atomically obtain an exclusive lock | |
| 675 | pub const EXLOCK = 0x0020; | |
| 676 | /// do not follow symlinks | |
| 677 | pub const NOFOLLOW = 0x0100; | |
| 678 | /// allow open of symlinks | |
| 679 | pub const SYMLINK = 0x200000; | |
| 680 | /// descriptor requested for event notifications only | |
| 681 | pub const EVTONLY = 0x8000; | |
| 682 | /// mark as close-on-exec | |
| 683 | pub const CLOEXEC = 0x1000000; | |
| 684 | pub const ACCMODE = 3; | |
| 685 | pub const ALERT = 536870912; | |
| 686 | pub const ASYNC = 64; | |
| 687 | pub const DIRECTORY = 1048576; | |
| 688 | pub const DP_GETRAWENCRYPTED = 1; | |
| 689 | pub const DP_GETRAWUNENCRYPTED = 2; | |
| 690 | pub const DSYNC = 4194304; | |
| 691 | pub const FSYNC = SYNC; | |
| 692 | pub const NOCTTY = 131072; | |
| 693 | pub const POPUP = 2147483648; | |
| 694 | pub const SYNC = 128; | |
| 695 | }; | |
| 635 | 696 | |
| 636 | 697 | pub const SEEK_SET = 0x0; |
| 637 | 698 | pub const SEEK_CUR = 0x1; |
| ... | ... | @@ -647,114 +708,6 @@ pub const DT_LNK = 10; |
| 647 | 708 | pub const DT_SOCK = 12; |
| 648 | 709 | pub const DT_WHT = 14; |
| 649 | 710 | |
| 650 | /// block specified signal set | |
| 651 | pub const SIG_BLOCK = 1; | |
| 652 | ||
| 653 | /// unblock specified signal set | |
| 654 | pub const SIG_UNBLOCK = 2; | |
| 655 | ||
| 656 | /// set specified signal set | |
| 657 | pub const SIG_SETMASK = 3; | |
| 658 | ||
| 659 | /// hangup | |
| 660 | pub const SIGHUP = 1; | |
| 661 | ||
| 662 | /// interrupt | |
| 663 | pub const SIGINT = 2; | |
| 664 | ||
| 665 | /// quit | |
| 666 | pub const SIGQUIT = 3; | |
| 667 | ||
| 668 | /// illegal instruction (not reset when caught) | |
| 669 | pub const SIGILL = 4; | |
| 670 | ||
| 671 | /// trace trap (not reset when caught) | |
| 672 | pub const SIGTRAP = 5; | |
| 673 | ||
| 674 | /// abort() | |
| 675 | pub const SIGABRT = 6; | |
| 676 | ||
| 677 | /// pollable event ([XSR] generated, not supported) | |
| 678 | pub const SIGPOLL = 7; | |
| 679 | ||
| 680 | /// compatibility | |
| 681 | pub const SIGIOT = SIGABRT; | |
| 682 | ||
| 683 | /// EMT instruction | |
| 684 | pub const SIGEMT = 7; | |
| 685 | ||
| 686 | /// floating point exception | |
| 687 | pub const SIGFPE = 8; | |
| 688 | ||
| 689 | /// kill (cannot be caught or ignored) | |
| 690 | pub const SIGKILL = 9; | |
| 691 | ||
| 692 | /// bus error | |
| 693 | pub const SIGBUS = 10; | |
| 694 | ||
| 695 | /// segmentation violation | |
| 696 | pub const SIGSEGV = 11; | |
| 697 | ||
| 698 | /// bad argument to system call | |
| 699 | pub const SIGSYS = 12; | |
| 700 | ||
| 701 | /// write on a pipe with no one to read it | |
| 702 | pub const SIGPIPE = 13; | |
| 703 | ||
| 704 | /// alarm clock | |
| 705 | pub const SIGALRM = 14; | |
| 706 | ||
| 707 | /// software termination signal from kill | |
| 708 | pub const SIGTERM = 15; | |
| 709 | ||
| 710 | /// urgent condition on IO channel | |
| 711 | pub const SIGURG = 16; | |
| 712 | ||
| 713 | /// sendable stop signal not from tty | |
| 714 | pub const SIGSTOP = 17; | |
| 715 | ||
| 716 | /// stop signal from tty | |
| 717 | pub const SIGTSTP = 18; | |
| 718 | ||
| 719 | /// continue a stopped process | |
| 720 | pub const SIGCONT = 19; | |
| 721 | ||
| 722 | /// to parent on child stop or exit | |
| 723 | pub const SIGCHLD = 20; | |
| 724 | ||
| 725 | /// to readers pgrp upon background tty read | |
| 726 | pub const SIGTTIN = 21; | |
| 727 | ||
| 728 | /// like TTIN for output if (tp->t_local&LTOSTOP) | |
| 729 | pub const SIGTTOU = 22; | |
| 730 | ||
| 731 | /// input/output possible signal | |
| 732 | pub const SIGIO = 23; | |
| 733 | ||
| 734 | /// exceeded CPU time limit | |
| 735 | pub const SIGXCPU = 24; | |
| 736 | ||
| 737 | /// exceeded file size limit | |
| 738 | pub const SIGXFSZ = 25; | |
| 739 | ||
| 740 | /// virtual time alarm | |
| 741 | pub const SIGVTALRM = 26; | |
| 742 | ||
| 743 | /// profiling time alarm | |
| 744 | pub const SIGPROF = 27; | |
| 745 | ||
| 746 | /// window size changes | |
| 747 | pub const SIGWINCH = 28; | |
| 748 | ||
| 749 | /// information request | |
| 750 | pub const SIGINFO = 29; | |
| 751 | ||
| 752 | /// user defined signal 1 | |
| 753 | pub const SIGUSR1 = 30; | |
| 754 | ||
| 755 | /// user defined signal 2 | |
| 756 | pub const SIGUSR2 = 31; | |
| 757 | ||
| 758 | 711 | /// no flag value |
| 759 | 712 | pub const KEVENT_FLAG_NONE = 0x000; |
| 760 | 713 | |
| ... | ... | @@ -1116,28 +1069,31 @@ pub const SO = struct { |
| 1116 | 1069 | pub const REUSESHAREUID = 0x1025; |
| 1117 | 1070 | }; |
| 1118 | 1071 | |
| 1119 | fn wstatus(x: u32) u32 { | |
| 1120 | return x & 0o177; | |
| 1121 | } | |
| 1122 | const wstopped = 0o177; | |
| 1123 | pub fn WEXITSTATUS(x: u32) u8 { | |
| 1124 | return @intCast(u8, x >> 8); | |
| 1125 | } | |
| 1126 | pub fn WTERMSIG(x: u32) u32 { | |
| 1127 | return wstatus(x); | |
| 1128 | } | |
| 1129 | pub fn WSTOPSIG(x: u32) u32 { | |
| 1130 | return x >> 8; | |
| 1131 | } | |
| 1132 | pub fn WIFEXITED(x: u32) bool { | |
| 1133 | return wstatus(x) == 0; | |
| 1134 | } | |
| 1135 | pub fn WIFSTOPPED(x: u32) bool { | |
| 1136 | return wstatus(x) == wstopped and WSTOPSIG(x) != 0x13; | |
| 1137 | } | |
| 1138 | pub fn WIFSIGNALED(x: u32) bool { | |
| 1139 | return wstatus(x) != wstopped and wstatus(x) != 0; | |
| 1140 | } | |
| 1072 | pub const W = struct { | |
| 1073 | pub fn EXITSTATUS(x: u32) u8 { | |
| 1074 | return @intCast(u8, x >> 8); | |
| 1075 | } | |
| 1076 | pub fn TERMSIG(x: u32) u32 { | |
| 1077 | return status(x); | |
| 1078 | } | |
| 1079 | pub fn STOPSIG(x: u32) u32 { | |
| 1080 | return x >> 8; | |
| 1081 | } | |
| 1082 | pub fn IFEXITED(x: u32) bool { | |
| 1083 | return status(x) == 0; | |
| 1084 | } | |
| 1085 | pub fn IFSTOPPED(x: u32) bool { | |
| 1086 | return status(x) == stopped and STOPSIG(x) != 0x13; | |
| 1087 | } | |
| 1088 | pub fn IFSIGNALED(x: u32) bool { | |
| 1089 | return status(x) != stopped and status(x) != 0; | |
| 1090 | } | |
| 1091 | ||
| 1092 | fn status(x: u32) u32 { | |
| 1093 | return x & 0o177; | |
| 1094 | } | |
| 1095 | const stopped = 0o177; | |
| 1096 | }; | |
| 1141 | 1097 | |
| 1142 | 1098 | pub const E = enum(u16) { |
| 1143 | 1099 | /// No error occurred. |
| ... | ... | @@ -1488,64 +1444,66 @@ pub const stack_t = extern struct { |
| 1488 | 1444 | ss_flags: i32, |
| 1489 | 1445 | }; |
| 1490 | 1446 | |
| 1491 | pub const S_IFMT = 0o170000; | |
| 1492 | ||
| 1493 | pub const S_IFIFO = 0o010000; | |
| 1494 | pub const S_IFCHR = 0o020000; | |
| 1495 | pub const S_IFDIR = 0o040000; | |
| 1496 | pub const S_IFBLK = 0o060000; | |
| 1497 | pub const S_IFREG = 0o100000; | |
| 1498 | pub const S_IFLNK = 0o120000; | |
| 1499 | pub const S_IFSOCK = 0o140000; | |
| 1500 | pub const S_IFWHT = 0o160000; | |
| 1501 | ||
| 1502 | pub const S_ISUID = 0o4000; | |
| 1503 | pub const S_ISGID = 0o2000; | |
| 1504 | pub const S_ISVTX = 0o1000; | |
| 1505 | pub const S_IRWXU = 0o700; | |
| 1506 | pub const S_IRUSR = 0o400; | |
| 1507 | pub const S_IWUSR = 0o200; | |
| 1508 | pub const S_IXUSR = 0o100; | |
| 1509 | pub const S_IRWXG = 0o070; | |
| 1510 | pub const S_IRGRP = 0o040; | |
| 1511 | pub const S_IWGRP = 0o020; | |
| 1512 | pub const S_IXGRP = 0o010; | |
| 1513 | pub const S_IRWXO = 0o007; | |
| 1514 | pub const S_IROTH = 0o004; | |
| 1515 | pub const S_IWOTH = 0o002; | |
| 1516 | pub const S_IXOTH = 0o001; | |
| 1517 | ||
| 1518 | pub fn S_ISFIFO(m: u32) bool { | |
| 1519 | return m & S_IFMT == S_IFIFO; | |
| 1520 | } | |
| 1447 | pub const S = struct { | |
| 1448 | pub const IFMT = 0o170000; | |
| 1449 | ||
| 1450 | pub const IFIFO = 0o010000; | |
| 1451 | pub const IFCHR = 0o020000; | |
| 1452 | pub const IFDIR = 0o040000; | |
| 1453 | pub const IFBLK = 0o060000; | |
| 1454 | pub const IFREG = 0o100000; | |
| 1455 | pub const IFLNK = 0o120000; | |
| 1456 | pub const IFSOCK = 0o140000; | |
| 1457 | pub const IFWHT = 0o160000; | |
| 1458 | ||
| 1459 | pub const ISUID = 0o4000; | |
| 1460 | pub const ISGID = 0o2000; | |
| 1461 | pub const ISVTX = 0o1000; | |
| 1462 | pub const IRWXU = 0o700; | |
| 1463 | pub const IRUSR = 0o400; | |
| 1464 | pub const IWUSR = 0o200; | |
| 1465 | pub const IXUSR = 0o100; | |
| 1466 | pub const IRWXG = 0o070; | |
| 1467 | pub const IRGRP = 0o040; | |
| 1468 | pub const IWGRP = 0o020; | |
| 1469 | pub const IXGRP = 0o010; | |
| 1470 | pub const IRWXO = 0o007; | |
| 1471 | pub const IROTH = 0o004; | |
| 1472 | pub const IWOTH = 0o002; | |
| 1473 | pub const IXOTH = 0o001; | |
| 1474 | ||
| 1475 | pub fn ISFIFO(m: u32) bool { | |
| 1476 | return m & IFMT == IFIFO; | |
| 1477 | } | |
| 1521 | 1478 | |
| 1522 | pub fn S_ISCHR(m: u32) bool { | |
| 1523 | return m & S_IFMT == S_IFCHR; | |
| 1524 | } | |
| 1479 | pub fn ISCHR(m: u32) bool { | |
| 1480 | return m & IFMT == IFCHR; | |
| 1481 | } | |
| 1525 | 1482 | |
| 1526 | pub fn S_ISDIR(m: u32) bool { | |
| 1527 | return m & S_IFMT == S_IFDIR; | |
| 1528 | } | |
| 1483 | pub fn ISDIR(m: u32) bool { | |
| 1484 | return m & IFMT == IFDIR; | |
| 1485 | } | |
| 1529 | 1486 | |
| 1530 | pub fn S_ISBLK(m: u32) bool { | |
| 1531 | return m & S_IFMT == S_IFBLK; | |
| 1532 | } | |
| 1487 | pub fn ISBLK(m: u32) bool { | |
| 1488 | return m & IFMT == IFBLK; | |
| 1489 | } | |
| 1533 | 1490 | |
| 1534 | pub fn S_ISREG(m: u32) bool { | |
| 1535 | return m & S_IFMT == S_IFREG; | |
| 1536 | } | |
| 1491 | pub fn ISREG(m: u32) bool { | |
| 1492 | return m & IFMT == IFREG; | |
| 1493 | } | |
| 1537 | 1494 | |
| 1538 | pub fn S_ISLNK(m: u32) bool { | |
| 1539 | return m & S_IFMT == S_IFLNK; | |
| 1540 | } | |
| 1495 | pub fn ISLNK(m: u32) bool { | |
| 1496 | return m & IFMT == IFLNK; | |
| 1497 | } | |
| 1541 | 1498 | |
| 1542 | pub fn S_ISSOCK(m: u32) bool { | |
| 1543 | return m & S_IFMT == S_IFSOCK; | |
| 1544 | } | |
| 1499 | pub fn ISSOCK(m: u32) bool { | |
| 1500 | return m & IFMT == IFSOCK; | |
| 1501 | } | |
| 1545 | 1502 | |
| 1546 | pub fn S_IWHT(m: u32) bool { | |
| 1547 | return m & S_IFMT == S_IFWHT; | |
| 1548 | } | |
| 1503 | pub fn IWHT(m: u32) bool { | |
| 1504 | return m & IFMT == IFWHT; | |
| 1505 | } | |
| 1506 | }; | |
| 1549 | 1507 | |
| 1550 | 1508 | pub const HOST_NAME_MAX = 72; |
| 1551 | 1509 | |
| ... | ... | @@ -1981,7 +1939,9 @@ pub const winsize = extern struct { |
| 1981 | 1939 | ws_ypixel: u16, |
| 1982 | 1940 | }; |
| 1983 | 1941 | |
| 1984 | pub const TIOCGWINSZ = ior(0x40000000, 't', 104, @sizeOf(winsize)); | |
| 1942 | pub const T = struct { | |
| 1943 | pub const IOCGWINSZ = ior(0x40000000, 't', 104, @sizeOf(winsize)); | |
| 1944 | }; | |
| 1985 | 1945 | pub const IOCPARM_MASK = 0x1fff; |
| 1986 | 1946 | |
| 1987 | 1947 | fn ior(inout: u32, group: usize, num: usize, len: usize) usize { |
lib/std/c/dragonfly.zig+118-109| ... | ... | @@ -33,10 +33,6 @@ pub const pthread_attr_t = extern struct { // copied from freebsd |
| 33 | 33 | |
| 34 | 34 | pub const sem_t = ?*opaque {}; |
| 35 | 35 | |
| 36 | pub fn S_ISCHR(m: u32) bool { | |
| 37 | return m & S_IFMT == S_IFCHR; | |
| 38 | } | |
| 39 | ||
| 40 | 36 | // See: |
| 41 | 37 | // - https://gitweb.dragonflybsd.org/dragonfly.git/blob/HEAD:/include/unistd.h |
| 42 | 38 | // - https://gitweb.dragonflybsd.org/dragonfly.git/blob/HEAD:/sys/sys/types.h |
| ... | ... | @@ -157,10 +153,12 @@ pub const STDIN_FILENO = 0; |
| 157 | 153 | pub const STDOUT_FILENO = 1; |
| 158 | 154 | pub const STDERR_FILENO = 2; |
| 159 | 155 | |
| 160 | pub const PROT_NONE = 0; | |
| 161 | pub const PROT_READ = 1; | |
| 162 | pub const PROT_WRITE = 2; | |
| 163 | pub const PROT_EXEC = 4; | |
| 156 | pub const PROT = struct { | |
| 157 | pub const NONE = 0; | |
| 158 | pub const READ = 1; | |
| 159 | pub const WRITE = 2; | |
| 160 | pub const EXEC = 4; | |
| 161 | }; | |
| 164 | 162 | |
| 165 | 163 | pub const MAP = struct { |
| 166 | 164 | pub const FILE = 0; |
| ... | ... | @@ -321,32 +319,34 @@ pub const X_OK = 1; // test for execute or search permission |
| 321 | 319 | pub const W_OK = 2; // test for write permission |
| 322 | 320 | pub const R_OK = 4; // test for read permission |
| 323 | 321 | |
| 324 | pub const O_RDONLY = 0; | |
| 325 | pub const O_NDELAY = O_NONBLOCK; | |
| 326 | pub const O_WRONLY = 1; | |
| 327 | pub const O_RDWR = 2; | |
| 328 | pub const O_ACCMODE = 3; | |
| 329 | pub const O_NONBLOCK = 4; | |
| 330 | pub const O_APPEND = 8; | |
| 331 | pub const O_SHLOCK = 16; | |
| 332 | pub const O_EXLOCK = 32; | |
| 333 | pub const O_ASYNC = 64; | |
| 334 | pub const O_FSYNC = 128; | |
| 335 | pub const O_SYNC = 128; | |
| 336 | pub const O_NOFOLLOW = 256; | |
| 337 | pub const O_CREAT = 512; | |
| 338 | pub const O_TRUNC = 1024; | |
| 339 | pub const O_EXCL = 2048; | |
| 340 | pub const O_NOCTTY = 32768; | |
| 341 | pub const O_DIRECT = 65536; | |
| 342 | pub const O_CLOEXEC = 131072; | |
| 343 | pub const O_FBLOCKING = 262144; | |
| 344 | pub const O_FNONBLOCKING = 524288; | |
| 345 | pub const O_FAPPEND = 1048576; | |
| 346 | pub const O_FOFFSET = 2097152; | |
| 347 | pub const O_FSYNCWRITE = 4194304; | |
| 348 | pub const O_FASYNCWRITE = 8388608; | |
| 349 | pub const O_DIRECTORY = 134217728; | |
| 322 | pub const O = struct { | |
| 323 | pub const RDONLY = 0; | |
| 324 | pub const NDELAY = NONBLOCK; | |
| 325 | pub const WRONLY = 1; | |
| 326 | pub const RDWR = 2; | |
| 327 | pub const ACCMODE = 3; | |
| 328 | pub const NONBLOCK = 4; | |
| 329 | pub const APPEND = 8; | |
| 330 | pub const SHLOCK = 16; | |
| 331 | pub const EXLOCK = 32; | |
| 332 | pub const ASYNC = 64; | |
| 333 | pub const FSYNC = 128; | |
| 334 | pub const SYNC = 128; | |
| 335 | pub const NOFOLLOW = 256; | |
| 336 | pub const CREAT = 512; | |
| 337 | pub const TRUNC = 1024; | |
| 338 | pub const EXCL = 2048; | |
| 339 | pub const NOCTTY = 32768; | |
| 340 | pub const DIRECT = 65536; | |
| 341 | pub const CLOEXEC = 131072; | |
| 342 | pub const FBLOCKING = 262144; | |
| 343 | pub const FNONBLOCKING = 524288; | |
| 344 | pub const FAPPEND = 1048576; | |
| 345 | pub const FOFFSET = 2097152; | |
| 346 | pub const FSYNCWRITE = 4194304; | |
| 347 | pub const FASYNCWRITE = 8388608; | |
| 348 | pub const DIRECTORY = 134217728; | |
| 349 | }; | |
| 350 | 350 | |
| 351 | 351 | pub const SEEK_SET = 0; |
| 352 | 352 | pub const SEEK_CUR = 1; |
| ... | ... | @@ -540,81 +540,90 @@ pub const stack_t = extern struct { |
| 540 | 540 | ss_flags: i32, |
| 541 | 541 | }; |
| 542 | 542 | |
| 543 | pub const S_IREAD = S_IRUSR; | |
| 544 | pub const S_IEXEC = S_IXUSR; | |
| 545 | pub const S_IWRITE = S_IWUSR; | |
| 546 | pub const S_IXOTH = 1; | |
| 547 | pub const S_IWOTH = 2; | |
| 548 | pub const S_IROTH = 4; | |
| 549 | pub const S_IRWXO = 7; | |
| 550 | pub const S_IXGRP = 8; | |
| 551 | pub const S_IWGRP = 16; | |
| 552 | pub const S_IRGRP = 32; | |
| 553 | pub const S_IRWXG = 56; | |
| 554 | pub const S_IXUSR = 64; | |
| 555 | pub const S_IWUSR = 128; | |
| 556 | pub const S_IRUSR = 256; | |
| 557 | pub const S_IRWXU = 448; | |
| 558 | pub const S_ISTXT = 512; | |
| 559 | pub const S_BLKSIZE = 512; | |
| 560 | pub const S_ISVTX = 512; | |
| 561 | pub const S_ISGID = 1024; | |
| 562 | pub const S_ISUID = 2048; | |
| 563 | pub const S_IFIFO = 4096; | |
| 564 | pub const S_IFCHR = 8192; | |
| 565 | pub const S_IFDIR = 16384; | |
| 566 | pub const S_IFBLK = 24576; | |
| 567 | pub const S_IFREG = 32768; | |
| 568 | pub const S_IFDB = 36864; | |
| 569 | pub const S_IFLNK = 40960; | |
| 570 | pub const S_IFSOCK = 49152; | |
| 571 | pub const S_IFWHT = 57344; | |
| 572 | pub const S_IFMT = 61440; | |
| 573 | ||
| 574 | pub const SIG_DFL = @intToPtr(?Sigaction.sigaction_fn, 0); | |
| 575 | pub const SIG_IGN = @intToPtr(?Sigaction.sigaction_fn, 1); | |
| 576 | pub const SIG_ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize)); | |
| 577 | pub const BADSIG = SIG_ERR; | |
| 578 | ||
| 579 | pub const SIG_BLOCK = 1; | |
| 580 | pub const SIG_UNBLOCK = 2; | |
| 581 | pub const SIG_SETMASK = 3; | |
| 582 | ||
| 583 | pub const SIGIOT = SIGABRT; | |
| 584 | pub const SIGHUP = 1; | |
| 585 | pub const SIGINT = 2; | |
| 586 | pub const SIGQUIT = 3; | |
| 587 | pub const SIGILL = 4; | |
| 588 | pub const SIGTRAP = 5; | |
| 589 | pub const SIGABRT = 6; | |
| 590 | pub const SIGEMT = 7; | |
| 591 | pub const SIGFPE = 8; | |
| 592 | pub const SIGKILL = 9; | |
| 593 | pub const SIGBUS = 10; | |
| 594 | pub const SIGSEGV = 11; | |
| 595 | pub const SIGSYS = 12; | |
| 596 | pub const SIGPIPE = 13; | |
| 597 | pub const SIGALRM = 14; | |
| 598 | pub const SIGTERM = 15; | |
| 599 | pub const SIGURG = 16; | |
| 600 | pub const SIGSTOP = 17; | |
| 601 | pub const SIGTSTP = 18; | |
| 602 | pub const SIGCONT = 19; | |
| 603 | pub const SIGCHLD = 20; | |
| 604 | pub const SIGTTIN = 21; | |
| 605 | pub const SIGTTOU = 22; | |
| 606 | pub const SIGIO = 23; | |
| 607 | pub const SIGXCPU = 24; | |
| 608 | pub const SIGXFSZ = 25; | |
| 609 | pub const SIGVTALRM = 26; | |
| 610 | pub const SIGPROF = 27; | |
| 611 | pub const SIGWINCH = 28; | |
| 612 | pub const SIGINFO = 29; | |
| 613 | pub const SIGUSR1 = 30; | |
| 614 | pub const SIGUSR2 = 31; | |
| 615 | pub const SIGTHR = 32; | |
| 616 | pub const SIGCKPT = 33; | |
| 617 | pub const SIGCKPTEXIT = 34; | |
| 543 | pub const S = struct { | |
| 544 | pub const IREAD = IRUSR; | |
| 545 | pub const IEXEC = IXUSR; | |
| 546 | pub const IWRITE = IWUSR; | |
| 547 | pub const IXOTH = 1; | |
| 548 | pub const IWOTH = 2; | |
| 549 | pub const IROTH = 4; | |
| 550 | pub const IRWXO = 7; | |
| 551 | pub const IXGRP = 8; | |
| 552 | pub const IWGRP = 16; | |
| 553 | pub const IRGRP = 32; | |
| 554 | pub const IRWXG = 56; | |
| 555 | pub const IXUSR = 64; | |
| 556 | pub const IWUSR = 128; | |
| 557 | pub const IRUSR = 256; | |
| 558 | pub const IRWXU = 448; | |
| 559 | pub const ISTXT = 512; | |
| 560 | pub const BLKSIZE = 512; | |
| 561 | pub const ISVTX = 512; | |
| 562 | pub const ISGID = 1024; | |
| 563 | pub const ISUID = 2048; | |
| 564 | pub const IFIFO = 4096; | |
| 565 | pub const IFCHR = 8192; | |
| 566 | pub const IFDIR = 16384; | |
| 567 | pub const IFBLK = 24576; | |
| 568 | pub const IFREG = 32768; | |
| 569 | pub const IFDB = 36864; | |
| 570 | pub const IFLNK = 40960; | |
| 571 | pub const IFSOCK = 49152; | |
| 572 | pub const IFWHT = 57344; | |
| 573 | pub const IFMT = 61440; | |
| 574 | ||
| 575 | pub fn ISCHR(m: u32) bool { | |
| 576 | return m & IFMT == IFCHR; | |
| 577 | } | |
| 578 | }; | |
| 579 | ||
| 580 | pub const BADSIG = SIG.ERR; | |
| 581 | ||
| 582 | pub const SIG = struct { | |
| 583 | pub const DFL = @intToPtr(?Sigaction.sigaction_fn, 0); | |
| 584 | pub const IGN = @intToPtr(?Sigaction.sigaction_fn, 1); | |
| 585 | pub const ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize)); | |
| 586 | ||
| 587 | pub const BLOCK = 1; | |
| 588 | pub const UNBLOCK = 2; | |
| 589 | pub const SETMASK = 3; | |
| 590 | ||
| 591 | pub const IOT = ABRT; | |
| 592 | pub const HUP = 1; | |
| 593 | pub const INT = 2; | |
| 594 | pub const QUIT = 3; | |
| 595 | pub const ILL = 4; | |
| 596 | pub const TRAP = 5; | |
| 597 | pub const ABRT = 6; | |
| 598 | pub const EMT = 7; | |
| 599 | pub const FPE = 8; | |
| 600 | pub const KILL = 9; | |
| 601 | pub const BUS = 10; | |
| 602 | pub const SEGV = 11; | |
| 603 | pub const SYS = 12; | |
| 604 | pub const PIPE = 13; | |
| 605 | pub const ALRM = 14; | |
| 606 | pub const TERM = 15; | |
| 607 | pub const URG = 16; | |
| 608 | pub const STOP = 17; | |
| 609 | pub const TSTP = 18; | |
| 610 | pub const CONT = 19; | |
| 611 | pub const CHLD = 20; | |
| 612 | pub const TTIN = 21; | |
| 613 | pub const TTOU = 22; | |
| 614 | pub const IO = 23; | |
| 615 | pub const XCPU = 24; | |
| 616 | pub const XFSZ = 25; | |
| 617 | pub const VTALRM = 26; | |
| 618 | pub const PROF = 27; | |
| 619 | pub const WINCH = 28; | |
| 620 | pub const INFO = 29; | |
| 621 | pub const USR1 = 30; | |
| 622 | pub const USR2 = 31; | |
| 623 | pub const THR = 32; | |
| 624 | pub const CKPT = 33; | |
| 625 | pub const CKPTEXIT = 34; | |
| 626 | }; | |
| 618 | 627 | |
| 619 | 628 | pub const siginfo_t = extern struct { |
| 620 | 629 | signo: c_int, |
lib/std/c/freebsd.zig+118-110| ... | ... | @@ -363,10 +363,12 @@ pub const STDIN_FILENO = 0; |
| 363 | 363 | pub const STDOUT_FILENO = 1; |
| 364 | 364 | pub const STDERR_FILENO = 2; |
| 365 | 365 | |
| 366 | pub const PROT_NONE = 0; | |
| 367 | pub const PROT_READ = 1; | |
| 368 | pub const PROT_WRITE = 2; | |
| 369 | pub const PROT_EXEC = 4; | |
| 366 | pub const PROT = struct { | |
| 367 | pub const NONE = 0; | |
| 368 | pub const READ = 1; | |
| 369 | pub const WRITE = 2; | |
| 370 | pub const EXEC = 4; | |
| 371 | }; | |
| 370 | 372 | |
| 371 | 373 | pub const CLOCK = struct { |
| 372 | 374 | pub const REALTIME = 0; |
| ... | ... | @@ -504,33 +506,35 @@ pub const X_OK = 1; // test for execute or search permission |
| 504 | 506 | pub const W_OK = 2; // test for write permission |
| 505 | 507 | pub const R_OK = 4; // test for read permission |
| 506 | 508 | |
| 507 | pub const O_RDONLY = 0x0000; | |
| 508 | pub const O_WRONLY = 0x0001; | |
| 509 | pub const O_RDWR = 0x0002; | |
| 510 | pub const O_ACCMODE = 0x0003; | |
| 511 | ||
| 512 | pub const O_SHLOCK = 0x0010; | |
| 513 | pub const O_EXLOCK = 0x0020; | |
| 514 | ||
| 515 | pub const O_CREAT = 0x0200; | |
| 516 | pub const O_EXCL = 0x0800; | |
| 517 | pub const O_NOCTTY = 0x8000; | |
| 518 | pub const O_TRUNC = 0x0400; | |
| 519 | pub const O_APPEND = 0x0008; | |
| 520 | pub const O_NONBLOCK = 0x0004; | |
| 521 | pub const O_DSYNC = 0o10000; | |
| 522 | pub const O_SYNC = 0x0080; | |
| 523 | pub const O_RSYNC = 0o4010000; | |
| 524 | pub const O_DIRECTORY = 0x20000; | |
| 525 | pub const O_NOFOLLOW = 0x0100; | |
| 526 | pub const O_CLOEXEC = 0x00100000; | |
| 527 | ||
| 528 | pub const O_ASYNC = 0x0040; | |
| 529 | pub const O_DIRECT = 0x00010000; | |
| 530 | pub const O_NOATIME = 0o1000000; | |
| 531 | pub const O_PATH = 0o10000000; | |
| 532 | pub const O_TMPFILE = 0o20200000; | |
| 533 | pub const O_NDELAY = O_NONBLOCK; | |
| 509 | pub const O = struct { | |
| 510 | pub const RDONLY = 0x0000; | |
| 511 | pub const WRONLY = 0x0001; | |
| 512 | pub const RDWR = 0x0002; | |
| 513 | pub const ACCMODE = 0x0003; | |
| 514 | ||
| 515 | pub const SHLOCK = 0x0010; | |
| 516 | pub const EXLOCK = 0x0020; | |
| 517 | ||
| 518 | pub const CREAT = 0x0200; | |
| 519 | pub const EXCL = 0x0800; | |
| 520 | pub const NOCTTY = 0x8000; | |
| 521 | pub const TRUNC = 0x0400; | |
| 522 | pub const APPEND = 0x0008; | |
| 523 | pub const NONBLOCK = 0x0004; | |
| 524 | pub const DSYNC = 0o10000; | |
| 525 | pub const SYNC = 0x0080; | |
| 526 | pub const RSYNC = 0o4010000; | |
| 527 | pub const DIRECTORY = 0x20000; | |
| 528 | pub const NOFOLLOW = 0x0100; | |
| 529 | pub const CLOEXEC = 0x00100000; | |
| 530 | ||
| 531 | pub const ASYNC = 0x0040; | |
| 532 | pub const DIRECT = 0x00010000; | |
| 533 | pub const NOATIME = 0o1000000; | |
| 534 | pub const PATH = 0o10000000; | |
| 535 | pub const TMPFILE = 0o20200000; | |
| 536 | pub const NDELAY = NONBLOCK; | |
| 537 | }; | |
| 534 | 538 | |
| 535 | 539 | pub const F = struct { |
| 536 | 540 | pub const DUPFD = 0; |
| ... | ... | @@ -877,31 +881,33 @@ pub const NOTE_NSECONDS = 0x00000008; |
| 877 | 881 | /// timeout is absolute |
| 878 | 882 | pub const NOTE_ABSTIME = 0x00000010; |
| 879 | 883 | |
| 880 | pub const TIOCEXCL = 0x2000740d; | |
| 881 | pub const TIOCNXCL = 0x2000740e; | |
| 882 | pub const TIOCSCTTY = 0x20007461; | |
| 883 | pub const TIOCGPGRP = 0x40047477; | |
| 884 | pub const TIOCSPGRP = 0x80047476; | |
| 885 | pub const TIOCOUTQ = 0x40047473; | |
| 886 | pub const TIOCSTI = 0x80017472; | |
| 887 | pub const TIOCGWINSZ = 0x40087468; | |
| 888 | pub const TIOCSWINSZ = 0x80087467; | |
| 889 | pub const TIOCMGET = 0x4004746a; | |
| 890 | pub const TIOCMBIS = 0x8004746c; | |
| 891 | pub const TIOCMBIC = 0x8004746b; | |
| 892 | pub const TIOCMSET = 0x8004746d; | |
| 893 | pub const FIONREAD = 0x4004667f; | |
| 894 | pub const TIOCCONS = 0x80047462; | |
| 895 | pub const TIOCPKT = 0x80047470; | |
| 896 | pub const FIONBIO = 0x8004667e; | |
| 897 | pub const TIOCNOTTY = 0x20007471; | |
| 898 | pub const TIOCSETD = 0x8004741b; | |
| 899 | pub const TIOCGETD = 0x4004741a; | |
| 900 | pub const TIOCSBRK = 0x2000747b; | |
| 901 | pub const TIOCCBRK = 0x2000747a; | |
| 902 | pub const TIOCGSID = 0x40047463; | |
| 903 | pub const TIOCGPTN = 0x4004740f; | |
| 904 | pub const TIOCSIG = 0x2004745f; | |
| 884 | pub const T = struct { | |
| 885 | pub const IOCEXCL = 0x2000740d; | |
| 886 | pub const IOCNXCL = 0x2000740e; | |
| 887 | pub const IOCSCTTY = 0x20007461; | |
| 888 | pub const IOCGPGRP = 0x40047477; | |
| 889 | pub const IOCSPGRP = 0x80047476; | |
| 890 | pub const IOCOUTQ = 0x40047473; | |
| 891 | pub const IOCSTI = 0x80017472; | |
| 892 | pub const IOCGWINSZ = 0x40087468; | |
| 893 | pub const IOCSWINSZ = 0x80087467; | |
| 894 | pub const IOCMGET = 0x4004746a; | |
| 895 | pub const IOCMBIS = 0x8004746c; | |
| 896 | pub const IOCMBIC = 0x8004746b; | |
| 897 | pub const IOCMSET = 0x8004746d; | |
| 898 | pub const FIONREAD = 0x4004667f; | |
| 899 | pub const IOCCONS = 0x80047462; | |
| 900 | pub const IOCPKT = 0x80047470; | |
| 901 | pub const FIONBIO = 0x8004667e; | |
| 902 | pub const IOCNOTTY = 0x20007471; | |
| 903 | pub const IOCSETD = 0x8004741b; | |
| 904 | pub const IOCGETD = 0x4004741a; | |
| 905 | pub const IOCSBRK = 0x2000747b; | |
| 906 | pub const IOCCBRK = 0x2000747a; | |
| 907 | pub const IOCGSID = 0x40047463; | |
| 908 | pub const IOCGPTN = 0x4004740f; | |
| 909 | pub const IOCSIG = 0x2004745f; | |
| 910 | }; | |
| 905 | 911 | |
| 906 | 912 | pub fn WEXITSTATUS(s: u32) u8 { |
| 907 | 913 | return @intCast(u8, (s & 0xff00) >> 8); |
| ... | ... | @@ -1166,69 +1172,71 @@ pub const SS_ONSTACK = 1; |
| 1166 | 1172 | pub const SS_DISABLE = 4; |
| 1167 | 1173 | |
| 1168 | 1174 | pub const stack_t = extern struct { |
| 1169 | ss_sp: [*]u8, | |
| 1170 | ss_size: isize, | |
| 1171 | ss_flags: i32, | |
| 1175 | sp: [*]u8, | |
| 1176 | size: isize, | |
| 1177 | flags: i32, | |
| 1172 | 1178 | }; |
| 1173 | 1179 | |
| 1174 | pub const S_IFMT = 0o170000; | |
| 1175 | ||
| 1176 | pub const S_IFIFO = 0o010000; | |
| 1177 | pub const S_IFCHR = 0o020000; | |
| 1178 | pub const S_IFDIR = 0o040000; | |
| 1179 | pub const S_IFBLK = 0o060000; | |
| 1180 | pub const S_IFREG = 0o100000; | |
| 1181 | pub const S_IFLNK = 0o120000; | |
| 1182 | pub const S_IFSOCK = 0o140000; | |
| 1183 | pub const S_IFWHT = 0o160000; | |
| 1184 | ||
| 1185 | pub const S_ISUID = 0o4000; | |
| 1186 | pub const S_ISGID = 0o2000; | |
| 1187 | pub const S_ISVTX = 0o1000; | |
| 1188 | pub const S_IRWXU = 0o700; | |
| 1189 | pub const S_IRUSR = 0o400; | |
| 1190 | pub const S_IWUSR = 0o200; | |
| 1191 | pub const S_IXUSR = 0o100; | |
| 1192 | pub const S_IRWXG = 0o070; | |
| 1193 | pub const S_IRGRP = 0o040; | |
| 1194 | pub const S_IWGRP = 0o020; | |
| 1195 | pub const S_IXGRP = 0o010; | |
| 1196 | pub const S_IRWXO = 0o007; | |
| 1197 | pub const S_IROTH = 0o004; | |
| 1198 | pub const S_IWOTH = 0o002; | |
| 1199 | pub const S_IXOTH = 0o001; | |
| 1200 | ||
| 1201 | pub fn S_ISFIFO(m: u32) bool { | |
| 1202 | return m & S_IFMT == S_IFIFO; | |
| 1203 | } | |
| 1180 | pub const S = struct { | |
| 1181 | pub const IFMT = 0o170000; | |
| 1182 | ||
| 1183 | pub const IFIFO = 0o010000; | |
| 1184 | pub const IFCHR = 0o020000; | |
| 1185 | pub const IFDIR = 0o040000; | |
| 1186 | pub const IFBLK = 0o060000; | |
| 1187 | pub const IFREG = 0o100000; | |
| 1188 | pub const IFLNK = 0o120000; | |
| 1189 | pub const IFSOCK = 0o140000; | |
| 1190 | pub const IFWHT = 0o160000; | |
| 1191 | ||
| 1192 | pub const ISUID = 0o4000; | |
| 1193 | pub const ISGID = 0o2000; | |
| 1194 | pub const ISVTX = 0o1000; | |
| 1195 | pub const IRWXU = 0o700; | |
| 1196 | pub const IRUSR = 0o400; | |
| 1197 | pub const IWUSR = 0o200; | |
| 1198 | pub const IXUSR = 0o100; | |
| 1199 | pub const IRWXG = 0o070; | |
| 1200 | pub const IRGRP = 0o040; | |
| 1201 | pub const IWGRP = 0o020; | |
| 1202 | pub const IXGRP = 0o010; | |
| 1203 | pub const IRWXO = 0o007; | |
| 1204 | pub const IROTH = 0o004; | |
| 1205 | pub const IWOTH = 0o002; | |
| 1206 | pub const IXOTH = 0o001; | |
| 1207 | ||
| 1208 | pub fn ISFIFO(m: u32) bool { | |
| 1209 | return m & IFMT == IFIFO; | |
| 1210 | } | |
| 1204 | 1211 | |
| 1205 | pub fn S_ISCHR(m: u32) bool { | |
| 1206 | return m & S_IFMT == S_IFCHR; | |
| 1207 | } | |
| 1212 | pub fn ISCHR(m: u32) bool { | |
| 1213 | return m & IFMT == IFCHR; | |
| 1214 | } | |
| 1208 | 1215 | |
| 1209 | pub fn S_ISDIR(m: u32) bool { | |
| 1210 | return m & S_IFMT == S_IFDIR; | |
| 1211 | } | |
| 1216 | pub fn ISDIR(m: u32) bool { | |
| 1217 | return m & IFMT == IFDIR; | |
| 1218 | } | |
| 1212 | 1219 | |
| 1213 | pub fn S_ISBLK(m: u32) bool { | |
| 1214 | return m & S_IFMT == S_IFBLK; | |
| 1215 | } | |
| 1220 | pub fn ISBLK(m: u32) bool { | |
| 1221 | return m & IFMT == IFBLK; | |
| 1222 | } | |
| 1216 | 1223 | |
| 1217 | pub fn S_ISREG(m: u32) bool { | |
| 1218 | return m & S_IFMT == S_IFREG; | |
| 1219 | } | |
| 1224 | pub fn ISREG(m: u32) bool { | |
| 1225 | return m & IFMT == IFREG; | |
| 1226 | } | |
| 1220 | 1227 | |
| 1221 | pub fn S_ISLNK(m: u32) bool { | |
| 1222 | return m & S_IFMT == S_IFLNK; | |
| 1223 | } | |
| 1228 | pub fn ISLNK(m: u32) bool { | |
| 1229 | return m & IFMT == IFLNK; | |
| 1230 | } | |
| 1224 | 1231 | |
| 1225 | pub fn S_ISSOCK(m: u32) bool { | |
| 1226 | return m & S_IFMT == S_IFSOCK; | |
| 1227 | } | |
| 1232 | pub fn ISSOCK(m: u32) bool { | |
| 1233 | return m & IFMT == IFSOCK; | |
| 1234 | } | |
| 1228 | 1235 | |
| 1229 | pub fn S_IWHT(m: u32) bool { | |
| 1230 | return m & S_IFMT == S_IFWHT; | |
| 1231 | } | |
| 1236 | pub fn IWHT(m: u32) bool { | |
| 1237 | return m & IFMT == IFWHT; | |
| 1238 | } | |
| 1239 | }; | |
| 1232 | 1240 | |
| 1233 | 1241 | pub const HOST_NAME_MAX = 255; |
| 1234 | 1242 |
lib/std/c/haiku.zig+149-139| ... | ... | @@ -377,10 +377,12 @@ pub const STDIN_FILENO = 0; |
| 377 | 377 | pub const STDOUT_FILENO = 1; |
| 378 | 378 | pub const STDERR_FILENO = 2; |
| 379 | 379 | |
| 380 | pub const PROT_NONE = 0; | |
| 381 | pub const PROT_READ = 1; | |
| 382 | pub const PROT_WRITE = 2; | |
| 383 | pub const PROT_EXEC = 4; | |
| 380 | pub const PROT = struct { | |
| 381 | pub const NONE = 0; | |
| 382 | pub const READ = 1; | |
| 383 | pub const WRITE = 2; | |
| 384 | pub const EXEC = 4; | |
| 385 | }; | |
| 384 | 386 | |
| 385 | 387 | pub const CLOCK = struct { |
| 386 | 388 | pub const MONOTONIC = 0; |
| ... | ... | @@ -425,6 +427,10 @@ pub const SA_STACK = SA_ONSTACK; |
| 425 | 427 | pub const SA_ONESHOT = SA_RESETHAND; |
| 426 | 428 | |
| 427 | 429 | pub const SIG = struct { |
| 430 | pub const ERR = @intToPtr(fn (i32) callconv(.C) void, maxInt(usize)); | |
| 431 | pub const DFL = @intToPtr(fn (i32) callconv(.C) void, 0); | |
| 432 | pub const IGN = @intToPtr(fn (i32) callconv(.C) void, 1); | |
| 433 | ||
| 428 | 434 | pub const HUP = 1; |
| 429 | 435 | pub const INT = 2; |
| 430 | 436 | pub const QUIT = 3; |
| ... | ... | @@ -489,33 +495,35 @@ pub const X_OK = 1; // test for execute or search permission |
| 489 | 495 | pub const W_OK = 2; // test for write permission |
| 490 | 496 | pub const R_OK = 4; // test for read permission |
| 491 | 497 | |
| 492 | pub const O_RDONLY = 0x0000; | |
| 493 | pub const O_WRONLY = 0x0001; | |
| 494 | pub const O_RDWR = 0x0002; | |
| 495 | pub const O_ACCMODE = 0x0003; | |
| 496 | ||
| 497 | pub const O_SHLOCK = 0x0010; | |
| 498 | pub const O_EXLOCK = 0x0020; | |
| 499 | ||
| 500 | pub const O_CREAT = 0x0200; | |
| 501 | pub const O_EXCL = 0x0800; | |
| 502 | pub const O_NOCTTY = 0x8000; | |
| 503 | pub const O_TRUNC = 0x0400; | |
| 504 | pub const O_APPEND = 0x0008; | |
| 505 | pub const O_NONBLOCK = 0x0004; | |
| 506 | pub const O_DSYNC = 0o10000; | |
| 507 | pub const O_SYNC = 0x0080; | |
| 508 | pub const O_RSYNC = 0o4010000; | |
| 509 | pub const O_DIRECTORY = 0x20000; | |
| 510 | pub const O_NOFOLLOW = 0x0100; | |
| 511 | pub const O_CLOEXEC = 0x00100000; | |
| 512 | ||
| 513 | pub const O_ASYNC = 0x0040; | |
| 514 | pub const O_DIRECT = 0x00010000; | |
| 515 | pub const O_NOATIME = 0o1000000; | |
| 516 | pub const O_PATH = 0o10000000; | |
| 517 | pub const O_TMPFILE = 0o20200000; | |
| 518 | pub const O_NDELAY = O_NONBLOCK; | |
| 498 | pub const O = struct { | |
| 499 | pub const RDONLY = 0x0000; | |
| 500 | pub const WRONLY = 0x0001; | |
| 501 | pub const RDWR = 0x0002; | |
| 502 | pub const ACCMODE = 0x0003; | |
| 503 | ||
| 504 | pub const SHLOCK = 0x0010; | |
| 505 | pub const EXLOCK = 0x0020; | |
| 506 | ||
| 507 | pub const CREAT = 0x0200; | |
| 508 | pub const EXCL = 0x0800; | |
| 509 | pub const NOCTTY = 0x8000; | |
| 510 | pub const TRUNC = 0x0400; | |
| 511 | pub const APPEND = 0x0008; | |
| 512 | pub const NONBLOCK = 0x0004; | |
| 513 | pub const DSYNC = 0o10000; | |
| 514 | pub const SYNC = 0x0080; | |
| 515 | pub const RSYNC = 0o4010000; | |
| 516 | pub const DIRECTORY = 0x20000; | |
| 517 | pub const NOFOLLOW = 0x0100; | |
| 518 | pub const CLOEXEC = 0x00100000; | |
| 519 | ||
| 520 | pub const ASYNC = 0x0040; | |
| 521 | pub const DIRECT = 0x00010000; | |
| 522 | pub const NOATIME = 0o1000000; | |
| 523 | pub const PATH = 0o10000000; | |
| 524 | pub const TMPFILE = 0o20200000; | |
| 525 | pub const NDELAY = NONBLOCK; | |
| 526 | }; | |
| 519 | 527 | |
| 520 | 528 | pub const F = struct { |
| 521 | 529 | pub const DUPFD = 0; |
| ... | ... | @@ -773,52 +781,56 @@ pub const EVFILT_SENDFILE = -12; |
| 773 | 781 | |
| 774 | 782 | pub const EVFILT_EMPTY = -13; |
| 775 | 783 | |
| 776 | pub const TCGETA = 0x8000; | |
| 777 | pub const TCSETA = 0x8001; | |
| 778 | pub const TCSETAW = 0x8004; | |
| 779 | pub const TCSETAF = 0x8003; | |
| 780 | pub const TCSBRK = 08005; | |
| 781 | pub const TCXONC = 0x8007; | |
| 782 | pub const TCFLSH = 0x8006; | |
| 783 | ||
| 784 | pub const TIOCSCTTY = 0x8017; | |
| 785 | pub const TIOCGPGRP = 0x8015; | |
| 786 | pub const TIOCSPGRP = 0x8016; | |
| 787 | pub const TIOCGWINSZ = 0x8012; | |
| 788 | pub const TIOCSWINSZ = 0x8013; | |
| 789 | pub const TIOCMGET = 0x8018; | |
| 790 | pub const TIOCMBIS = 0x8022; | |
| 791 | pub const TIOCMBIC = 0x8023; | |
| 792 | pub const TIOCMSET = 0x8019; | |
| 793 | pub const FIONREAD = 0xbe000001; | |
| 794 | pub const FIONBIO = 0xbe000000; | |
| 795 | pub const TIOCSBRK = 0x8020; | |
| 796 | pub const TIOCCBRK = 0x8021; | |
| 797 | pub const TIOCGSID = 0x8024; | |
| 798 | ||
| 799 | pub fn WEXITSTATUS(s: u32) u8 { | |
| 800 | return @intCast(u8, s & 0xff); | |
| 801 | } | |
| 802 | ||
| 803 | pub fn WTERMSIG(s: u32) u32 { | |
| 804 | return (s >> 8) & 0xff; | |
| 805 | } | |
| 806 | ||
| 807 | pub fn WSTOPSIG(s: u32) u32 { | |
| 808 | return WEXITSTATUS(s); | |
| 809 | } | |
| 810 | ||
| 811 | pub fn WIFEXITED(s: u32) bool { | |
| 812 | return WTERMSIG(s) == 0; | |
| 813 | } | |
| 814 | ||
| 815 | pub fn WIFSTOPPED(s: u32) bool { | |
| 816 | return ((s >> 16) & 0xff) != 0; | |
| 817 | } | |
| 818 | ||
| 819 | pub fn WIFSIGNALED(s: u32) bool { | |
| 820 | return ((s >> 8) & 0xff) != 0; | |
| 821 | } | |
| 784 | pub const T = struct { | |
| 785 | pub const CGETA = 0x8000; | |
| 786 | pub const CSETA = 0x8001; | |
| 787 | pub const CSETAW = 0x8004; | |
| 788 | pub const CSETAF = 0x8003; | |
| 789 | pub const CSBRK = 08005; | |
| 790 | pub const CXONC = 0x8007; | |
| 791 | pub const CFLSH = 0x8006; | |
| 792 | ||
| 793 | pub const IOCSCTTY = 0x8017; | |
| 794 | pub const IOCGPGRP = 0x8015; | |
| 795 | pub const IOCSPGRP = 0x8016; | |
| 796 | pub const IOCGWINSZ = 0x8012; | |
| 797 | pub const IOCSWINSZ = 0x8013; | |
| 798 | pub const IOCMGET = 0x8018; | |
| 799 | pub const IOCMBIS = 0x8022; | |
| 800 | pub const IOCMBIC = 0x8023; | |
| 801 | pub const IOCMSET = 0x8019; | |
| 802 | pub const FIONREAD = 0xbe000001; | |
| 803 | pub const FIONBIO = 0xbe000000; | |
| 804 | pub const IOCSBRK = 0x8020; | |
| 805 | pub const IOCCBRK = 0x8021; | |
| 806 | pub const IOCGSID = 0x8024; | |
| 807 | }; | |
| 808 | ||
| 809 | pub const W = struct { | |
| 810 | pub fn EXITSTATUS(s: u32) u8 { | |
| 811 | return @intCast(u8, s & 0xff); | |
| 812 | } | |
| 813 | ||
| 814 | pub fn TERMSIG(s: u32) u32 { | |
| 815 | return (s >> 8) & 0xff; | |
| 816 | } | |
| 817 | ||
| 818 | pub fn STOPSIG(s: u32) u32 { | |
| 819 | return EXITSTATUS(s); | |
| 820 | } | |
| 821 | ||
| 822 | pub fn IFEXITED(s: u32) bool { | |
| 823 | return TERMSIG(s) == 0; | |
| 824 | } | |
| 825 | ||
| 826 | pub fn IFSTOPPED(s: u32) bool { | |
| 827 | return ((s >> 16) & 0xff) != 0; | |
| 828 | } | |
| 829 | ||
| 830 | pub fn IFSIGNALED(s: u32) bool { | |
| 831 | return ((s >> 8) & 0xff) != 0; | |
| 832 | } | |
| 833 | }; | |
| 822 | 834 | |
| 823 | 835 | pub const winsize = extern struct { |
| 824 | 836 | ws_row: u16, |
| ... | ... | @@ -829,10 +841,6 @@ pub const winsize = extern struct { |
| 829 | 841 | |
| 830 | 842 | const NSIG = 32; |
| 831 | 843 | |
| 832 | pub const SIG_ERR = @intToPtr(fn (i32) callconv(.C) void, maxInt(usize)); | |
| 833 | pub const SIG_DFL = @intToPtr(fn (i32) callconv(.C) void, 0); | |
| 834 | pub const SIG_IGN = @intToPtr(fn (i32) callconv(.C) void, 1); | |
| 835 | ||
| 836 | 844 | /// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall. |
| 837 | 845 | pub const Sigaction = extern struct { |
| 838 | 846 | /// signal handler |
| ... | ... | @@ -992,64 +1000,66 @@ pub const stack_t = extern struct { |
| 992 | 1000 | ss_flags: i32, |
| 993 | 1001 | }; |
| 994 | 1002 | |
| 995 | pub const S_IFMT = 0o170000; | |
| 996 | ||
| 997 | pub const S_IFIFO = 0o010000; | |
| 998 | pub const S_IFCHR = 0o020000; | |
| 999 | pub const S_IFDIR = 0o040000; | |
| 1000 | pub const S_IFBLK = 0o060000; | |
| 1001 | pub const S_IFREG = 0o100000; | |
| 1002 | pub const S_IFLNK = 0o120000; | |
| 1003 | pub const S_IFSOCK = 0o140000; | |
| 1004 | pub const S_IFWHT = 0o160000; | |
| 1005 | ||
| 1006 | pub const S_ISUID = 0o4000; | |
| 1007 | pub const S_ISGID = 0o2000; | |
| 1008 | pub const S_ISVTX = 0o1000; | |
| 1009 | pub const S_IRWXU = 0o700; | |
| 1010 | pub const S_IRUSR = 0o400; | |
| 1011 | pub const S_IWUSR = 0o200; | |
| 1012 | pub const S_IXUSR = 0o100; | |
| 1013 | pub const S_IRWXG = 0o070; | |
| 1014 | pub const S_IRGRP = 0o040; | |
| 1015 | pub const S_IWGRP = 0o020; | |
| 1016 | pub const S_IXGRP = 0o010; | |
| 1017 | pub const S_IRWXO = 0o007; | |
| 1018 | pub const S_IROTH = 0o004; | |
| 1019 | pub const S_IWOTH = 0o002; | |
| 1020 | pub const S_IXOTH = 0o001; | |
| 1021 | ||
| 1022 | pub fn S_ISFIFO(m: u32) bool { | |
| 1023 | return m & S_IFMT == S_IFIFO; | |
| 1024 | } | |
| 1025 | ||
| 1026 | pub fn S_ISCHR(m: u32) bool { | |
| 1027 | return m & S_IFMT == S_IFCHR; | |
| 1028 | } | |
| 1029 | ||
| 1030 | pub fn S_ISDIR(m: u32) bool { | |
| 1031 | return m & S_IFMT == S_IFDIR; | |
| 1032 | } | |
| 1033 | ||
| 1034 | pub fn S_ISBLK(m: u32) bool { | |
| 1035 | return m & S_IFMT == S_IFBLK; | |
| 1036 | } | |
| 1037 | ||
| 1038 | pub fn S_ISREG(m: u32) bool { | |
| 1039 | return m & S_IFMT == S_IFREG; | |
| 1040 | } | |
| 1041 | ||
| 1042 | pub fn S_ISLNK(m: u32) bool { | |
| 1043 | return m & S_IFMT == S_IFLNK; | |
| 1044 | } | |
| 1045 | ||
| 1046 | pub fn S_ISSOCK(m: u32) bool { | |
| 1047 | return m & S_IFMT == S_IFSOCK; | |
| 1048 | } | |
| 1049 | ||
| 1050 | pub fn S_IWHT(m: u32) bool { | |
| 1051 | return m & S_IFMT == S_IFWHT; | |
| 1052 | } | |
| 1003 | pub const S = struct { | |
| 1004 | pub const IFMT = 0o170000; | |
| 1005 | ||
| 1006 | pub const IFIFO = 0o010000; | |
| 1007 | pub const IFCHR = 0o020000; | |
| 1008 | pub const IFDIR = 0o040000; | |
| 1009 | pub const IFBLK = 0o060000; | |
| 1010 | pub const IFREG = 0o100000; | |
| 1011 | pub const IFLNK = 0o120000; | |
| 1012 | pub const IFSOCK = 0o140000; | |
| 1013 | pub const IFWHT = 0o160000; | |
| 1014 | ||
| 1015 | pub const ISUID = 0o4000; | |
| 1016 | pub const ISGID = 0o2000; | |
| 1017 | pub const ISVTX = 0o1000; | |
| 1018 | pub const IRWXU = 0o700; | |
| 1019 | pub const IRUSR = 0o400; | |
| 1020 | pub const IWUSR = 0o200; | |
| 1021 | pub const IXUSR = 0o100; | |
| 1022 | pub const IRWXG = 0o070; | |
| 1023 | pub const IRGRP = 0o040; | |
| 1024 | pub const IWGRP = 0o020; | |
| 1025 | pub const IXGRP = 0o010; | |
| 1026 | pub const IRWXO = 0o007; | |
| 1027 | pub const IROTH = 0o004; | |
| 1028 | pub const IWOTH = 0o002; | |
| 1029 | pub const IXOTH = 0o001; | |
| 1030 | ||
| 1031 | pub fn ISFIFO(m: u32) bool { | |
| 1032 | return m & IFMT == IFIFO; | |
| 1033 | } | |
| 1034 | ||
| 1035 | pub fn ISCHR(m: u32) bool { | |
| 1036 | return m & IFMT == IFCHR; | |
| 1037 | } | |
| 1038 | ||
| 1039 | pub fn ISDIR(m: u32) bool { | |
| 1040 | return m & IFMT == IFDIR; | |
| 1041 | } | |
| 1042 | ||
| 1043 | pub fn ISBLK(m: u32) bool { | |
| 1044 | return m & IFMT == IFBLK; | |
| 1045 | } | |
| 1046 | ||
| 1047 | pub fn ISREG(m: u32) bool { | |
| 1048 | return m & IFMT == IFREG; | |
| 1049 | } | |
| 1050 | ||
| 1051 | pub fn ISLNK(m: u32) bool { | |
| 1052 | return m & IFMT == IFLNK; | |
| 1053 | } | |
| 1054 | ||
| 1055 | pub fn ISSOCK(m: u32) bool { | |
| 1056 | return m & IFMT == IFSOCK; | |
| 1057 | } | |
| 1058 | ||
| 1059 | pub fn IWHT(m: u32) bool { | |
| 1060 | return m & IFMT == IFWHT; | |
| 1061 | } | |
| 1062 | }; | |
| 1053 | 1063 | |
| 1054 | 1064 | pub const HOST_NAME_MAX = 255; |
| 1055 | 1065 |
lib/std/c/linux.zig+5-1| ... | ... | @@ -25,7 +25,11 @@ pub const IOV_MAX = linux.IOV_MAX; |
| 25 | 25 | pub const IPPROTO = linux.IPPROTO; |
| 26 | 26 | pub const LOCK = linux.LOCK; |
| 27 | 27 | pub const MADV = linux.MADV; |
| 28 | pub const MAP = linux.MAP; | |
| 28 | pub const MAP = struct { | |
| 29 | pub usingnamespace linux.MAP; | |
| 30 | /// Only used by libc to communicate failure. | |
| 31 | pub const FAILED = @intToPtr(*c_void, maxInt(usize)); | |
| 32 | }; | |
| 29 | 33 | pub const MMAP2_UNIT = linux.MMAP2_UNIT; |
| 30 | 34 | pub const NAME_MAX = linux.NAME_MAX; |
| 31 | 35 | pub const O = linux.O; |
lib/std/c/netbsd.zig+185-198| ... | ... | @@ -534,10 +534,12 @@ pub const STDIN_FILENO = 0; |
| 534 | 534 | pub const STDOUT_FILENO = 1; |
| 535 | 535 | pub const STDERR_FILENO = 2; |
| 536 | 536 | |
| 537 | pub const PROT_NONE = 0; | |
| 538 | pub const PROT_READ = 1; | |
| 539 | pub const PROT_WRITE = 2; | |
| 540 | pub const PROT_EXEC = 4; | |
| 537 | pub const PROT = struct { | |
| 538 | pub const NONE = 0; | |
| 539 | pub const READ = 1; | |
| 540 | pub const WRITE = 2; | |
| 541 | pub const EXEC = 4; | |
| 542 | }; | |
| 541 | 543 | |
| 542 | 544 | pub const CLOCK = struct { |
| 543 | 545 | pub const REALTIME = 0; |
| ... | ... | @@ -589,71 +591,52 @@ pub const X_OK = 1; // test for execute or search permission |
| 589 | 591 | pub const W_OK = 2; // test for write permission |
| 590 | 592 | pub const R_OK = 4; // test for read permission |
| 591 | 593 | |
| 592 | /// open for reading only | |
| 593 | pub const O_RDONLY = 0x00000000; | |
| 594 | ||
| 595 | /// open for writing only | |
| 596 | pub const O_WRONLY = 0x00000001; | |
| 597 | ||
| 598 | /// open for reading and writing | |
| 599 | pub const O_RDWR = 0x00000002; | |
| 600 | ||
| 601 | /// mask for above modes | |
| 602 | pub const O_ACCMODE = 0x00000003; | |
| 603 | ||
| 604 | /// no delay | |
| 605 | pub const O_NONBLOCK = 0x00000004; | |
| 606 | ||
| 607 | /// set append mode | |
| 608 | pub const O_APPEND = 0x00000008; | |
| 609 | ||
| 610 | /// open with shared file lock | |
| 611 | pub const O_SHLOCK = 0x00000010; | |
| 612 | ||
| 613 | /// open with exclusive file lock | |
| 614 | pub const O_EXLOCK = 0x00000020; | |
| 615 | ||
| 616 | /// signal pgrp when data ready | |
| 617 | pub const O_ASYNC = 0x00000040; | |
| 618 | ||
| 619 | /// synchronous writes | |
| 620 | pub const O_SYNC = 0x00000080; | |
| 621 | ||
| 622 | /// don't follow symlinks on the last | |
| 623 | pub const O_NOFOLLOW = 0x00000100; | |
| 624 | ||
| 625 | /// create if nonexistent | |
| 626 | pub const O_CREAT = 0x00000200; | |
| 627 | ||
| 628 | /// truncate to zero length | |
| 629 | pub const O_TRUNC = 0x00000400; | |
| 630 | ||
| 631 | /// error if already exists | |
| 632 | pub const O_EXCL = 0x00000800; | |
| 633 | ||
| 634 | /// don't assign controlling terminal | |
| 635 | pub const O_NOCTTY = 0x00008000; | |
| 636 | ||
| 637 | /// write: I/O data completion | |
| 638 | pub const O_DSYNC = 0x00010000; | |
| 639 | ||
| 640 | /// read: I/O completion as for write | |
| 641 | pub const O_RSYNC = 0x00020000; | |
| 642 | ||
| 643 | /// use alternate i/o semantics | |
| 644 | pub const O_ALT_IO = 0x00040000; | |
| 645 | ||
| 646 | /// direct I/O hint | |
| 647 | pub const O_DIRECT = 0x00080000; | |
| 648 | ||
| 649 | /// fail if not a directory | |
| 650 | pub const O_DIRECTORY = 0x00200000; | |
| 651 | ||
| 652 | /// set close on exec | |
| 653 | pub const O_CLOEXEC = 0x00400000; | |
| 654 | ||
| 655 | /// skip search permission checks | |
| 656 | pub const O_SEARCH = 0x00800000; | |
| 594 | pub const O = struct { | |
| 595 | /// open for reading only | |
| 596 | pub const RDONLY = 0x00000000; | |
| 597 | /// open for writing only | |
| 598 | pub const WRONLY = 0x00000001; | |
| 599 | /// open for reading and writing | |
| 600 | pub const RDWR = 0x00000002; | |
| 601 | /// mask for above modes | |
| 602 | pub const ACCMODE = 0x00000003; | |
| 603 | /// no delay | |
| 604 | pub const NONBLOCK = 0x00000004; | |
| 605 | /// set append mode | |
| 606 | pub const APPEND = 0x00000008; | |
| 607 | /// open with shared file lock | |
| 608 | pub const SHLOCK = 0x00000010; | |
| 609 | /// open with exclusive file lock | |
| 610 | pub const EXLOCK = 0x00000020; | |
| 611 | /// signal pgrp when data ready | |
| 612 | pub const ASYNC = 0x00000040; | |
| 613 | /// synchronous writes | |
| 614 | pub const SYNC = 0x00000080; | |
| 615 | /// don't follow symlinks on the last | |
| 616 | pub const NOFOLLOW = 0x00000100; | |
| 617 | /// create if nonexistent | |
| 618 | pub const CREAT = 0x00000200; | |
| 619 | /// truncate to zero length | |
| 620 | pub const TRUNC = 0x00000400; | |
| 621 | /// error if already exists | |
| 622 | pub const EXCL = 0x00000800; | |
| 623 | /// don't assign controlling terminal | |
| 624 | pub const NOCTTY = 0x00008000; | |
| 625 | /// write: I/O data completion | |
| 626 | pub const DSYNC = 0x00010000; | |
| 627 | /// read: I/O completion as for write | |
| 628 | pub const RSYNC = 0x00020000; | |
| 629 | /// use alternate i/o semantics | |
| 630 | pub const ALT_IO = 0x00040000; | |
| 631 | /// direct I/O hint | |
| 632 | pub const DIRECT = 0x00080000; | |
| 633 | /// fail if not a directory | |
| 634 | pub const DIRECTORY = 0x00200000; | |
| 635 | /// set close on exec | |
| 636 | pub const CLOEXEC = 0x00400000; | |
| 637 | /// skip search permission checks | |
| 638 | pub const SEARCH = 0x00800000; | |
| 639 | }; | |
| 657 | 640 | |
| 658 | 641 | pub const F = struct { |
| 659 | 642 | pub const DUPFD = 0; |
| ... | ... | @@ -687,10 +670,6 @@ pub const SEEK_SET = 0; |
| 687 | 670 | pub const SEEK_CUR = 1; |
| 688 | 671 | pub const SEEK_END = 2; |
| 689 | 672 | |
| 690 | pub const SIG_BLOCK = 1; | |
| 691 | pub const SIG_UNBLOCK = 2; | |
| 692 | pub const SIG_SETMASK = 3; | |
| 693 | ||
| 694 | 673 | pub const DT_UNKNOWN = 0; |
| 695 | 674 | pub const DT_FIFO = 1; |
| 696 | 675 | pub const DT_CHR = 2; |
| ... | ... | @@ -789,80 +768,82 @@ pub const NOTE_EXEC = 0x20000000; |
| 789 | 768 | pub const NOTE_PDATAMASK = 0x000fffff; |
| 790 | 769 | pub const NOTE_PCTRLMASK = 0xf0000000; |
| 791 | 770 | |
| 792 | pub const TIOCCBRK = 0x2000747a; | |
| 793 | pub const TIOCCDTR = 0x20007478; | |
| 794 | pub const TIOCCONS = 0x80047462; | |
| 795 | pub const TIOCDCDTIMESTAMP = 0x40107458; | |
| 796 | pub const TIOCDRAIN = 0x2000745e; | |
| 797 | pub const TIOCEXCL = 0x2000740d; | |
| 798 | pub const TIOCEXT = 0x80047460; | |
| 799 | pub const TIOCFLAG_CDTRCTS = 0x10; | |
| 800 | pub const TIOCFLAG_CLOCAL = 0x2; | |
| 801 | pub const TIOCFLAG_CRTSCTS = 0x4; | |
| 802 | pub const TIOCFLAG_MDMBUF = 0x8; | |
| 803 | pub const TIOCFLAG_SOFTCAR = 0x1; | |
| 804 | pub const TIOCFLUSH = 0x80047410; | |
| 805 | pub const TIOCGETA = 0x402c7413; | |
| 806 | pub const TIOCGETD = 0x4004741a; | |
| 807 | pub const TIOCGFLAGS = 0x4004745d; | |
| 808 | pub const TIOCGLINED = 0x40207442; | |
| 809 | pub const TIOCGPGRP = 0x40047477; | |
| 810 | pub const TIOCGQSIZE = 0x40047481; | |
| 811 | pub const TIOCGRANTPT = 0x20007447; | |
| 812 | pub const TIOCGSID = 0x40047463; | |
| 813 | pub const TIOCGSIZE = 0x40087468; | |
| 814 | pub const TIOCGWINSZ = 0x40087468; | |
| 815 | pub const TIOCMBIC = 0x8004746b; | |
| 816 | pub const TIOCMBIS = 0x8004746c; | |
| 817 | pub const TIOCMGET = 0x4004746a; | |
| 818 | pub const TIOCMSET = 0x8004746d; | |
| 819 | pub const TIOCM_CAR = 0x40; | |
| 820 | pub const TIOCM_CD = 0x40; | |
| 821 | pub const TIOCM_CTS = 0x20; | |
| 822 | pub const TIOCM_DSR = 0x100; | |
| 823 | pub const TIOCM_DTR = 0x2; | |
| 824 | pub const TIOCM_LE = 0x1; | |
| 825 | pub const TIOCM_RI = 0x80; | |
| 826 | pub const TIOCM_RNG = 0x80; | |
| 827 | pub const TIOCM_RTS = 0x4; | |
| 828 | pub const TIOCM_SR = 0x10; | |
| 829 | pub const TIOCM_ST = 0x8; | |
| 830 | pub const TIOCNOTTY = 0x20007471; | |
| 831 | pub const TIOCNXCL = 0x2000740e; | |
| 832 | pub const TIOCOUTQ = 0x40047473; | |
| 833 | pub const TIOCPKT = 0x80047470; | |
| 834 | pub const TIOCPKT_DATA = 0x0; | |
| 835 | pub const TIOCPKT_DOSTOP = 0x20; | |
| 836 | pub const TIOCPKT_FLUSHREAD = 0x1; | |
| 837 | pub const TIOCPKT_FLUSHWRITE = 0x2; | |
| 838 | pub const TIOCPKT_IOCTL = 0x40; | |
| 839 | pub const TIOCPKT_NOSTOP = 0x10; | |
| 840 | pub const TIOCPKT_START = 0x8; | |
| 841 | pub const TIOCPKT_STOP = 0x4; | |
| 842 | pub const TIOCPTMGET = 0x40287446; | |
| 843 | pub const TIOCPTSNAME = 0x40287448; | |
| 844 | pub const TIOCRCVFRAME = 0x80087445; | |
| 845 | pub const TIOCREMOTE = 0x80047469; | |
| 846 | pub const TIOCSBRK = 0x2000747b; | |
| 847 | pub const TIOCSCTTY = 0x20007461; | |
| 848 | pub const TIOCSDTR = 0x20007479; | |
| 849 | pub const TIOCSETA = 0x802c7414; | |
| 850 | pub const TIOCSETAF = 0x802c7416; | |
| 851 | pub const TIOCSETAW = 0x802c7415; | |
| 852 | pub const TIOCSETD = 0x8004741b; | |
| 853 | pub const TIOCSFLAGS = 0x8004745c; | |
| 854 | pub const TIOCSIG = 0x2000745f; | |
| 855 | pub const TIOCSLINED = 0x80207443; | |
| 856 | pub const TIOCSPGRP = 0x80047476; | |
| 857 | pub const TIOCSQSIZE = 0x80047480; | |
| 858 | pub const TIOCSSIZE = 0x80087467; | |
| 859 | pub const TIOCSTART = 0x2000746e; | |
| 860 | pub const TIOCSTAT = 0x80047465; | |
| 861 | pub const TIOCSTI = 0x80017472; | |
| 862 | pub const TIOCSTOP = 0x2000746f; | |
| 863 | pub const TIOCSWINSZ = 0x80087467; | |
| 864 | pub const TIOCUCNTL = 0x80047466; | |
| 865 | pub const TIOCXMTFRAME = 0x80087444; | |
| 771 | pub const T = struct { | |
| 772 | pub const IOCCBRK = 0x2000747a; | |
| 773 | pub const IOCCDTR = 0x20007478; | |
| 774 | pub const IOCCONS = 0x80047462; | |
| 775 | pub const IOCDCDTIMESTAMP = 0x40107458; | |
| 776 | pub const IOCDRAIN = 0x2000745e; | |
| 777 | pub const IOCEXCL = 0x2000740d; | |
| 778 | pub const IOCEXT = 0x80047460; | |
| 779 | pub const IOCFLAG_CDTRCTS = 0x10; | |
| 780 | pub const IOCFLAG_CLOCAL = 0x2; | |
| 781 | pub const IOCFLAG_CRTSCTS = 0x4; | |
| 782 | pub const IOCFLAG_MDMBUF = 0x8; | |
| 783 | pub const IOCFLAG_SOFTCAR = 0x1; | |
| 784 | pub const IOCFLUSH = 0x80047410; | |
| 785 | pub const IOCGETA = 0x402c7413; | |
| 786 | pub const IOCGETD = 0x4004741a; | |
| 787 | pub const IOCGFLAGS = 0x4004745d; | |
| 788 | pub const IOCGLINED = 0x40207442; | |
| 789 | pub const IOCGPGRP = 0x40047477; | |
| 790 | pub const IOCGQSIZE = 0x40047481; | |
| 791 | pub const IOCGRANTPT = 0x20007447; | |
| 792 | pub const IOCGSID = 0x40047463; | |
| 793 | pub const IOCGSIZE = 0x40087468; | |
| 794 | pub const IOCGWINSZ = 0x40087468; | |
| 795 | pub const IOCMBIC = 0x8004746b; | |
| 796 | pub const IOCMBIS = 0x8004746c; | |
| 797 | pub const IOCMGET = 0x4004746a; | |
| 798 | pub const IOCMSET = 0x8004746d; | |
| 799 | pub const IOCM_CAR = 0x40; | |
| 800 | pub const IOCM_CD = 0x40; | |
| 801 | pub const IOCM_CTS = 0x20; | |
| 802 | pub const IOCM_DSR = 0x100; | |
| 803 | pub const IOCM_DTR = 0x2; | |
| 804 | pub const IOCM_LE = 0x1; | |
| 805 | pub const IOCM_RI = 0x80; | |
| 806 | pub const IOCM_RNG = 0x80; | |
| 807 | pub const IOCM_RTS = 0x4; | |
| 808 | pub const IOCM_SR = 0x10; | |
| 809 | pub const IOCM_ST = 0x8; | |
| 810 | pub const IOCNOTTY = 0x20007471; | |
| 811 | pub const IOCNXCL = 0x2000740e; | |
| 812 | pub const IOCOUTQ = 0x40047473; | |
| 813 | pub const IOCPKT = 0x80047470; | |
| 814 | pub const IOCPKT_DATA = 0x0; | |
| 815 | pub const IOCPKT_DOSTOP = 0x20; | |
| 816 | pub const IOCPKT_FLUSHREAD = 0x1; | |
| 817 | pub const IOCPKT_FLUSHWRITE = 0x2; | |
| 818 | pub const IOCPKT_IOCTL = 0x40; | |
| 819 | pub const IOCPKT_NOSTOP = 0x10; | |
| 820 | pub const IOCPKT_START = 0x8; | |
| 821 | pub const IOCPKT_STOP = 0x4; | |
| 822 | pub const IOCPTMGET = 0x40287446; | |
| 823 | pub const IOCPTSNAME = 0x40287448; | |
| 824 | pub const IOCRCVFRAME = 0x80087445; | |
| 825 | pub const IOCREMOTE = 0x80047469; | |
| 826 | pub const IOCSBRK = 0x2000747b; | |
| 827 | pub const IOCSCTTY = 0x20007461; | |
| 828 | pub const IOCSDTR = 0x20007479; | |
| 829 | pub const IOCSETA = 0x802c7414; | |
| 830 | pub const IOCSETAF = 0x802c7416; | |
| 831 | pub const IOCSETAW = 0x802c7415; | |
| 832 | pub const IOCSETD = 0x8004741b; | |
| 833 | pub const IOCSFLAGS = 0x8004745c; | |
| 834 | pub const IOCSIG = 0x2000745f; | |
| 835 | pub const IOCSLINED = 0x80207443; | |
| 836 | pub const IOCSPGRP = 0x80047476; | |
| 837 | pub const IOCSQSIZE = 0x80047480; | |
| 838 | pub const IOCSSIZE = 0x80087467; | |
| 839 | pub const IOCSTART = 0x2000746e; | |
| 840 | pub const IOCSTAT = 0x80047465; | |
| 841 | pub const IOCSTI = 0x80017472; | |
| 842 | pub const IOCSTOP = 0x2000746f; | |
| 843 | pub const IOCSWINSZ = 0x80087467; | |
| 844 | pub const IOCUCNTL = 0x80047466; | |
| 845 | pub const IOCXMTFRAME = 0x80087444; | |
| 846 | }; | |
| 866 | 847 | |
| 867 | 848 | pub fn WEXITSTATUS(s: u32) u8 { |
| 868 | 849 | return @intCast(u8, (s >> 8) & 0xff); |
| ... | ... | @@ -906,6 +887,10 @@ pub const SIG = struct { |
| 906 | 887 | pub const WORDS = 4; |
| 907 | 888 | pub const MAXSIG = 128; |
| 908 | 889 | |
| 890 | pub const BLOCK = 1; | |
| 891 | pub const UNBLOCK = 2; | |
| 892 | pub const SETMASK = 3; | |
| 893 | ||
| 909 | 894 | pub const HUP = 1; |
| 910 | 895 | pub const INT = 2; |
| 911 | 896 | pub const QUIT = 3; |
| ... | ... | @@ -1213,64 +1198,66 @@ pub const stack_t = extern struct { |
| 1213 | 1198 | ss_flags: i32, |
| 1214 | 1199 | }; |
| 1215 | 1200 | |
| 1216 | pub const S_IFMT = 0o170000; | |
| 1217 | ||
| 1218 | pub const S_IFIFO = 0o010000; | |
| 1219 | pub const S_IFCHR = 0o020000; | |
| 1220 | pub const S_IFDIR = 0o040000; | |
| 1221 | pub const S_IFBLK = 0o060000; | |
| 1222 | pub const S_IFREG = 0o100000; | |
| 1223 | pub const S_IFLNK = 0o120000; | |
| 1224 | pub const S_IFSOCK = 0o140000; | |
| 1225 | pub const S_IFWHT = 0o160000; | |
| 1226 | ||
| 1227 | pub const S_ISUID = 0o4000; | |
| 1228 | pub const S_ISGID = 0o2000; | |
| 1229 | pub const S_ISVTX = 0o1000; | |
| 1230 | pub const S_IRWXU = 0o700; | |
| 1231 | pub const S_IRUSR = 0o400; | |
| 1232 | pub const S_IWUSR = 0o200; | |
| 1233 | pub const S_IXUSR = 0o100; | |
| 1234 | pub const S_IRWXG = 0o070; | |
| 1235 | pub const S_IRGRP = 0o040; | |
| 1236 | pub const S_IWGRP = 0o020; | |
| 1237 | pub const S_IXGRP = 0o010; | |
| 1238 | pub const S_IRWXO = 0o007; | |
| 1239 | pub const S_IROTH = 0o004; | |
| 1240 | pub const S_IWOTH = 0o002; | |
| 1241 | pub const S_IXOTH = 0o001; | |
| 1242 | ||
| 1243 | pub fn S_ISFIFO(m: u32) bool { | |
| 1244 | return m & S_IFMT == S_IFIFO; | |
| 1245 | } | |
| 1201 | pub const S = struct { | |
| 1202 | pub const IFMT = 0o170000; | |
| 1203 | ||
| 1204 | pub const IFIFO = 0o010000; | |
| 1205 | pub const IFCHR = 0o020000; | |
| 1206 | pub const IFDIR = 0o040000; | |
| 1207 | pub const IFBLK = 0o060000; | |
| 1208 | pub const IFREG = 0o100000; | |
| 1209 | pub const IFLNK = 0o120000; | |
| 1210 | pub const IFSOCK = 0o140000; | |
| 1211 | pub const IFWHT = 0o160000; | |
| 1212 | ||
| 1213 | pub const ISUID = 0o4000; | |
| 1214 | pub const ISGID = 0o2000; | |
| 1215 | pub const ISVTX = 0o1000; | |
| 1216 | pub const IRWXU = 0o700; | |
| 1217 | pub const IRUSR = 0o400; | |
| 1218 | pub const IWUSR = 0o200; | |
| 1219 | pub const IXUSR = 0o100; | |
| 1220 | pub const IRWXG = 0o070; | |
| 1221 | pub const IRGRP = 0o040; | |
| 1222 | pub const IWGRP = 0o020; | |
| 1223 | pub const IXGRP = 0o010; | |
| 1224 | pub const IRWXO = 0o007; | |
| 1225 | pub const IROTH = 0o004; | |
| 1226 | pub const IWOTH = 0o002; | |
| 1227 | pub const IXOTH = 0o001; | |
| 1228 | ||
| 1229 | pub fn ISFIFO(m: u32) bool { | |
| 1230 | return m & IFMT == IFIFO; | |
| 1231 | } | |
| 1246 | 1232 | |
| 1247 | pub fn S_ISCHR(m: u32) bool { | |
| 1248 | return m & S_IFMT == S_IFCHR; | |
| 1249 | } | |
| 1233 | pub fn ISCHR(m: u32) bool { | |
| 1234 | return m & IFMT == IFCHR; | |
| 1235 | } | |
| 1250 | 1236 | |
| 1251 | pub fn S_ISDIR(m: u32) bool { | |
| 1252 | return m & S_IFMT == S_IFDIR; | |
| 1253 | } | |
| 1237 | pub fn ISDIR(m: u32) bool { | |
| 1238 | return m & IFMT == IFDIR; | |
| 1239 | } | |
| 1254 | 1240 | |
| 1255 | pub fn S_ISBLK(m: u32) bool { | |
| 1256 | return m & S_IFMT == S_IFBLK; | |
| 1257 | } | |
| 1241 | pub fn ISBLK(m: u32) bool { | |
| 1242 | return m & IFMT == IFBLK; | |
| 1243 | } | |
| 1258 | 1244 | |
| 1259 | pub fn S_ISREG(m: u32) bool { | |
| 1260 | return m & S_IFMT == S_IFREG; | |
| 1261 | } | |
| 1245 | pub fn ISREG(m: u32) bool { | |
| 1246 | return m & IFMT == IFREG; | |
| 1247 | } | |
| 1262 | 1248 | |
| 1263 | pub fn S_ISLNK(m: u32) bool { | |
| 1264 | return m & S_IFMT == S_IFLNK; | |
| 1265 | } | |
| 1249 | pub fn ISLNK(m: u32) bool { | |
| 1250 | return m & IFMT == IFLNK; | |
| 1251 | } | |
| 1266 | 1252 | |
| 1267 | pub fn S_ISSOCK(m: u32) bool { | |
| 1268 | return m & S_IFMT == S_IFSOCK; | |
| 1269 | } | |
| 1253 | pub fn ISSOCK(m: u32) bool { | |
| 1254 | return m & IFMT == IFSOCK; | |
| 1255 | } | |
| 1270 | 1256 | |
| 1271 | pub fn S_IWHT(m: u32) bool { | |
| 1272 | return m & S_IFMT == S_IFWHT; | |
| 1273 | } | |
| 1257 | pub fn IWHT(m: u32) bool { | |
| 1258 | return m & IFMT == IFWHT; | |
| 1259 | } | |
| 1260 | }; | |
| 1274 | 1261 | |
| 1275 | 1262 | pub const AT = struct { |
| 1276 | 1263 | /// Magic value that specify the use of the current working directory |
lib/std/c/openbsd.zig+216-224| ... | ... | @@ -330,10 +330,12 @@ pub const STDIN_FILENO = 0; |
| 330 | 330 | pub const STDOUT_FILENO = 1; |
| 331 | 331 | pub const STDERR_FILENO = 2; |
| 332 | 332 | |
| 333 | pub const PROT_NONE = 0; | |
| 334 | pub const PROT_READ = 1; | |
| 335 | pub const PROT_WRITE = 2; | |
| 336 | pub const PROT_EXEC = 4; | |
| 333 | pub const PROT = struct { | |
| 334 | pub const NONE = 0; | |
| 335 | pub const READ = 1; | |
| 336 | pub const WRITE = 2; | |
| 337 | pub const EXEC = 4; | |
| 338 | }; | |
| 337 | 339 | |
| 338 | 340 | pub const CLOCK = struct { |
| 339 | 341 | pub const REALTIME = 0; |
| ... | ... | @@ -371,102 +373,52 @@ pub const SA_NODEFER = 0x0010; |
| 371 | 373 | pub const SA_NOCLDWAIT = 0x0020; |
| 372 | 374 | pub const SA_SIGINFO = 0x0040; |
| 373 | 375 | |
| 374 | pub const SIGHUP = 1; | |
| 375 | pub const SIGINT = 2; | |
| 376 | pub const SIGQUIT = 3; | |
| 377 | pub const SIGILL = 4; | |
| 378 | pub const SIGTRAP = 5; | |
| 379 | pub const SIGABRT = 6; | |
| 380 | pub const SIGIOT = SIGABRT; | |
| 381 | pub const SIGEMT = 7; | |
| 382 | pub const SIGFPE = 8; | |
| 383 | pub const SIGKILL = 9; | |
| 384 | pub const SIGBUS = 10; | |
| 385 | pub const SIGSEGV = 11; | |
| 386 | pub const SIGSYS = 12; | |
| 387 | pub const SIGPIPE = 13; | |
| 388 | pub const SIGALRM = 14; | |
| 389 | pub const SIGTERM = 15; | |
| 390 | pub const SIGURG = 16; | |
| 391 | pub const SIGSTOP = 17; | |
| 392 | pub const SIGTSTP = 18; | |
| 393 | pub const SIGCONT = 19; | |
| 394 | pub const SIGCHLD = 20; | |
| 395 | pub const SIGTTIN = 21; | |
| 396 | pub const SIGTTOU = 22; | |
| 397 | pub const SIGIO = 23; | |
| 398 | pub const SIGXCPU = 24; | |
| 399 | pub const SIGXFSZ = 25; | |
| 400 | pub const SIGVTALRM = 26; | |
| 401 | pub const SIGPROF = 27; | |
| 402 | pub const SIGWINCH = 28; | |
| 403 | pub const SIGINFO = 29; | |
| 404 | pub const SIGUSR1 = 30; | |
| 405 | pub const SIGUSR2 = 31; | |
| 406 | pub const SIGPWR = 32; | |
| 407 | ||
| 408 | 376 | // access function |
| 409 | 377 | pub const F_OK = 0; // test for existence of file |
| 410 | 378 | pub const X_OK = 1; // test for execute or search permission |
| 411 | 379 | pub const W_OK = 2; // test for write permission |
| 412 | 380 | pub const R_OK = 4; // test for read permission |
| 413 | 381 | |
| 414 | /// open for reading only | |
| 415 | pub const O_RDONLY = 0x00000000; | |
| 416 | ||
| 417 | /// open for writing only | |
| 418 | pub const O_WRONLY = 0x00000001; | |
| 419 | ||
| 420 | /// open for reading and writing | |
| 421 | pub const O_RDWR = 0x00000002; | |
| 422 | ||
| 423 | /// mask for above modes | |
| 424 | pub const O_ACCMODE = 0x00000003; | |
| 425 | ||
| 426 | /// no delay | |
| 427 | pub const O_NONBLOCK = 0x00000004; | |
| 428 | ||
| 429 | /// set append mode | |
| 430 | pub const O_APPEND = 0x00000008; | |
| 431 | ||
| 432 | /// open with shared file lock | |
| 433 | pub const O_SHLOCK = 0x00000010; | |
| 434 | ||
| 435 | /// open with exclusive file lock | |
| 436 | pub const O_EXLOCK = 0x00000020; | |
| 437 | ||
| 438 | /// signal pgrp when data ready | |
| 439 | pub const O_ASYNC = 0x00000040; | |
| 440 | ||
| 441 | /// synchronous writes | |
| 442 | pub const O_SYNC = 0x00000080; | |
| 443 | ||
| 444 | /// don't follow symlinks on the last | |
| 445 | pub const O_NOFOLLOW = 0x00000100; | |
| 446 | ||
| 447 | /// create if nonexistent | |
| 448 | pub const O_CREAT = 0x00000200; | |
| 449 | ||
| 450 | /// truncate to zero length | |
| 451 | pub const O_TRUNC = 0x00000400; | |
| 452 | ||
| 453 | /// error if already exists | |
| 454 | pub const O_EXCL = 0x00000800; | |
| 455 | ||
| 456 | /// don't assign controlling terminal | |
| 457 | pub const O_NOCTTY = 0x00008000; | |
| 458 | ||
| 459 | /// write: I/O data completion | |
| 460 | pub const O_DSYNC = O_SYNC; | |
| 461 | ||
| 462 | /// read: I/O completion as for write | |
| 463 | pub const O_RSYNC = O_SYNC; | |
| 464 | ||
| 465 | /// fail if not a directory | |
| 466 | pub const O_DIRECTORY = 0x20000; | |
| 467 | ||
| 468 | /// set close on exec | |
| 469 | pub const O_CLOEXEC = 0x10000; | |
| 382 | pub const O = struct { | |
| 383 | /// open for reading only | |
| 384 | pub const RDONLY = 0x00000000; | |
| 385 | /// open for writing only | |
| 386 | pub const WRONLY = 0x00000001; | |
| 387 | /// open for reading and writing | |
| 388 | pub const RDWR = 0x00000002; | |
| 389 | /// mask for above modes | |
| 390 | pub const ACCMODE = 0x00000003; | |
| 391 | /// no delay | |
| 392 | pub const NONBLOCK = 0x00000004; | |
| 393 | /// set append mode | |
| 394 | pub const APPEND = 0x00000008; | |
| 395 | /// open with shared file lock | |
| 396 | pub const SHLOCK = 0x00000010; | |
| 397 | /// open with exclusive file lock | |
| 398 | pub const EXLOCK = 0x00000020; | |
| 399 | /// signal pgrp when data ready | |
| 400 | pub const ASYNC = 0x00000040; | |
| 401 | /// synchronous writes | |
| 402 | pub const SYNC = 0x00000080; | |
| 403 | /// don't follow symlinks on the last | |
| 404 | pub const NOFOLLOW = 0x00000100; | |
| 405 | /// create if nonexistent | |
| 406 | pub const CREAT = 0x00000200; | |
| 407 | /// truncate to zero length | |
| 408 | pub const TRUNC = 0x00000400; | |
| 409 | /// error if already exists | |
| 410 | pub const EXCL = 0x00000800; | |
| 411 | /// don't assign controlling terminal | |
| 412 | pub const NOCTTY = 0x00008000; | |
| 413 | /// write: I/O data completion | |
| 414 | pub const DSYNC = SYNC; | |
| 415 | /// read: I/O completion as for write | |
| 416 | pub const RSYNC = SYNC; | |
| 417 | /// fail if not a directory | |
| 418 | pub const DIRECTORY = 0x20000; | |
| 419 | /// set close on exec | |
| 420 | pub const CLOEXEC = 0x10000; | |
| 421 | }; | |
| 470 | 422 | |
| 471 | 423 | pub const F = struct { |
| 472 | 424 | pub const DUPFD = 0; |
| ... | ... | @@ -500,10 +452,6 @@ pub const SEEK_SET = 0; |
| 500 | 452 | pub const SEEK_CUR = 1; |
| 501 | 453 | pub const SEEK_END = 2; |
| 502 | 454 | |
| 503 | pub const SIG_BLOCK = 1; | |
| 504 | pub const SIG_UNBLOCK = 2; | |
| 505 | pub const SIG_SETMASK = 3; | |
| 506 | ||
| 507 | 455 | pub const SOCK = struct { |
| 508 | 456 | pub const STREAM = 1; |
| 509 | 457 | pub const DGRAM = 2; |
| ... | ... | @@ -643,80 +591,82 @@ pub const NOTE_CHILD = 0x00000004; |
| 643 | 591 | // data/hint flags for EVFILT_DEVICE |
| 644 | 592 | pub const NOTE_CHANGE = 0x00000001; |
| 645 | 593 | |
| 646 | pub const TIOCCBRK = 0x2000747a; | |
| 647 | pub const TIOCCDTR = 0x20007478; | |
| 648 | pub const TIOCCONS = 0x80047462; | |
| 649 | pub const TIOCDCDTIMESTAMP = 0x40107458; | |
| 650 | pub const TIOCDRAIN = 0x2000745e; | |
| 651 | pub const TIOCEXCL = 0x2000740d; | |
| 652 | pub const TIOCEXT = 0x80047460; | |
| 653 | pub const TIOCFLAG_CDTRCTS = 0x10; | |
| 654 | pub const TIOCFLAG_CLOCAL = 0x2; | |
| 655 | pub const TIOCFLAG_CRTSCTS = 0x4; | |
| 656 | pub const TIOCFLAG_MDMBUF = 0x8; | |
| 657 | pub const TIOCFLAG_SOFTCAR = 0x1; | |
| 658 | pub const TIOCFLUSH = 0x80047410; | |
| 659 | pub const TIOCGETA = 0x402c7413; | |
| 660 | pub const TIOCGETD = 0x4004741a; | |
| 661 | pub const TIOCGFLAGS = 0x4004745d; | |
| 662 | pub const TIOCGLINED = 0x40207442; | |
| 663 | pub const TIOCGPGRP = 0x40047477; | |
| 664 | pub const TIOCGQSIZE = 0x40047481; | |
| 665 | pub const TIOCGRANTPT = 0x20007447; | |
| 666 | pub const TIOCGSID = 0x40047463; | |
| 667 | pub const TIOCGSIZE = 0x40087468; | |
| 668 | pub const TIOCGWINSZ = 0x40087468; | |
| 669 | pub const TIOCMBIC = 0x8004746b; | |
| 670 | pub const TIOCMBIS = 0x8004746c; | |
| 671 | pub const TIOCMGET = 0x4004746a; | |
| 672 | pub const TIOCMSET = 0x8004746d; | |
| 673 | pub const TIOCM_CAR = 0x40; | |
| 674 | pub const TIOCM_CD = 0x40; | |
| 675 | pub const TIOCM_CTS = 0x20; | |
| 676 | pub const TIOCM_DSR = 0x100; | |
| 677 | pub const TIOCM_DTR = 0x2; | |
| 678 | pub const TIOCM_LE = 0x1; | |
| 679 | pub const TIOCM_RI = 0x80; | |
| 680 | pub const TIOCM_RNG = 0x80; | |
| 681 | pub const TIOCM_RTS = 0x4; | |
| 682 | pub const TIOCM_SR = 0x10; | |
| 683 | pub const TIOCM_ST = 0x8; | |
| 684 | pub const TIOCNOTTY = 0x20007471; | |
| 685 | pub const TIOCNXCL = 0x2000740e; | |
| 686 | pub const TIOCOUTQ = 0x40047473; | |
| 687 | pub const TIOCPKT = 0x80047470; | |
| 688 | pub const TIOCPKT_DATA = 0x0; | |
| 689 | pub const TIOCPKT_DOSTOP = 0x20; | |
| 690 | pub const TIOCPKT_FLUSHREAD = 0x1; | |
| 691 | pub const TIOCPKT_FLUSHWRITE = 0x2; | |
| 692 | pub const TIOCPKT_IOCTL = 0x40; | |
| 693 | pub const TIOCPKT_NOSTOP = 0x10; | |
| 694 | pub const TIOCPKT_START = 0x8; | |
| 695 | pub const TIOCPKT_STOP = 0x4; | |
| 696 | pub const TIOCPTMGET = 0x40287446; | |
| 697 | pub const TIOCPTSNAME = 0x40287448; | |
| 698 | pub const TIOCRCVFRAME = 0x80087445; | |
| 699 | pub const TIOCREMOTE = 0x80047469; | |
| 700 | pub const TIOCSBRK = 0x2000747b; | |
| 701 | pub const TIOCSCTTY = 0x20007461; | |
| 702 | pub const TIOCSDTR = 0x20007479; | |
| 703 | pub const TIOCSETA = 0x802c7414; | |
| 704 | pub const TIOCSETAF = 0x802c7416; | |
| 705 | pub const TIOCSETAW = 0x802c7415; | |
| 706 | pub const TIOCSETD = 0x8004741b; | |
| 707 | pub const TIOCSFLAGS = 0x8004745c; | |
| 708 | pub const TIOCSIG = 0x2000745f; | |
| 709 | pub const TIOCSLINED = 0x80207443; | |
| 710 | pub const TIOCSPGRP = 0x80047476; | |
| 711 | pub const TIOCSQSIZE = 0x80047480; | |
| 712 | pub const TIOCSSIZE = 0x80087467; | |
| 713 | pub const TIOCSTART = 0x2000746e; | |
| 714 | pub const TIOCSTAT = 0x80047465; | |
| 715 | pub const TIOCSTI = 0x80017472; | |
| 716 | pub const TIOCSTOP = 0x2000746f; | |
| 717 | pub const TIOCSWINSZ = 0x80087467; | |
| 718 | pub const TIOCUCNTL = 0x80047466; | |
| 719 | pub const TIOCXMTFRAME = 0x80087444; | |
| 594 | pub const T = struct { | |
| 595 | pub const IOCCBRK = 0x2000747a; | |
| 596 | pub const IOCCDTR = 0x20007478; | |
| 597 | pub const IOCCONS = 0x80047462; | |
| 598 | pub const IOCDCDTIMESTAMP = 0x40107458; | |
| 599 | pub const IOCDRAIN = 0x2000745e; | |
| 600 | pub const IOCEXCL = 0x2000740d; | |
| 601 | pub const IOCEXT = 0x80047460; | |
| 602 | pub const IOCFLAG_CDTRCTS = 0x10; | |
| 603 | pub const IOCFLAG_CLOCAL = 0x2; | |
| 604 | pub const IOCFLAG_CRTSCTS = 0x4; | |
| 605 | pub const IOCFLAG_MDMBUF = 0x8; | |
| 606 | pub const IOCFLAG_SOFTCAR = 0x1; | |
| 607 | pub const IOCFLUSH = 0x80047410; | |
| 608 | pub const IOCGETA = 0x402c7413; | |
| 609 | pub const IOCGETD = 0x4004741a; | |
| 610 | pub const IOCGFLAGS = 0x4004745d; | |
| 611 | pub const IOCGLINED = 0x40207442; | |
| 612 | pub const IOCGPGRP = 0x40047477; | |
| 613 | pub const IOCGQSIZE = 0x40047481; | |
| 614 | pub const IOCGRANTPT = 0x20007447; | |
| 615 | pub const IOCGSID = 0x40047463; | |
| 616 | pub const IOCGSIZE = 0x40087468; | |
| 617 | pub const IOCGWINSZ = 0x40087468; | |
| 618 | pub const IOCMBIC = 0x8004746b; | |
| 619 | pub const IOCMBIS = 0x8004746c; | |
| 620 | pub const IOCMGET = 0x4004746a; | |
| 621 | pub const IOCMSET = 0x8004746d; | |
| 622 | pub const IOCM_CAR = 0x40; | |
| 623 | pub const IOCM_CD = 0x40; | |
| 624 | pub const IOCM_CTS = 0x20; | |
| 625 | pub const IOCM_DSR = 0x100; | |
| 626 | pub const IOCM_DTR = 0x2; | |
| 627 | pub const IOCM_LE = 0x1; | |
| 628 | pub const IOCM_RI = 0x80; | |
| 629 | pub const IOCM_RNG = 0x80; | |
| 630 | pub const IOCM_RTS = 0x4; | |
| 631 | pub const IOCM_SR = 0x10; | |
| 632 | pub const IOCM_ST = 0x8; | |
| 633 | pub const IOCNOTTY = 0x20007471; | |
| 634 | pub const IOCNXCL = 0x2000740e; | |
| 635 | pub const IOCOUTQ = 0x40047473; | |
| 636 | pub const IOCPKT = 0x80047470; | |
| 637 | pub const IOCPKT_DATA = 0x0; | |
| 638 | pub const IOCPKT_DOSTOP = 0x20; | |
| 639 | pub const IOCPKT_FLUSHREAD = 0x1; | |
| 640 | pub const IOCPKT_FLUSHWRITE = 0x2; | |
| 641 | pub const IOCPKT_IOCTL = 0x40; | |
| 642 | pub const IOCPKT_NOSTOP = 0x10; | |
| 643 | pub const IOCPKT_START = 0x8; | |
| 644 | pub const IOCPKT_STOP = 0x4; | |
| 645 | pub const IOCPTMGET = 0x40287446; | |
| 646 | pub const IOCPTSNAME = 0x40287448; | |
| 647 | pub const IOCRCVFRAME = 0x80087445; | |
| 648 | pub const IOCREMOTE = 0x80047469; | |
| 649 | pub const IOCSBRK = 0x2000747b; | |
| 650 | pub const IOCSCTTY = 0x20007461; | |
| 651 | pub const IOCSDTR = 0x20007479; | |
| 652 | pub const IOCSETA = 0x802c7414; | |
| 653 | pub const IOCSETAF = 0x802c7416; | |
| 654 | pub const IOCSETAW = 0x802c7415; | |
| 655 | pub const IOCSETD = 0x8004741b; | |
| 656 | pub const IOCSFLAGS = 0x8004745c; | |
| 657 | pub const IOCSIG = 0x2000745f; | |
| 658 | pub const IOCSLINED = 0x80207443; | |
| 659 | pub const IOCSPGRP = 0x80047476; | |
| 660 | pub const IOCSQSIZE = 0x80047480; | |
| 661 | pub const IOCSSIZE = 0x80087467; | |
| 662 | pub const IOCSTART = 0x2000746e; | |
| 663 | pub const IOCSTAT = 0x80047465; | |
| 664 | pub const IOCSTI = 0x80017472; | |
| 665 | pub const IOCSTOP = 0x2000746f; | |
| 666 | pub const IOCSWINSZ = 0x80087467; | |
| 667 | pub const IOCUCNTL = 0x80047466; | |
| 668 | pub const IOCXMTFRAME = 0x80087444; | |
| 669 | }; | |
| 720 | 670 | |
| 721 | 671 | pub fn WEXITSTATUS(s: u32) u8 { |
| 722 | 672 | return @intCast(u8, (s >> 8) & 0xff); |
| ... | ... | @@ -752,11 +702,51 @@ pub const winsize = extern struct { |
| 752 | 702 | |
| 753 | 703 | const NSIG = 33; |
| 754 | 704 | |
| 755 | pub const SIG_DFL = @intToPtr(?Sigaction.sigaction_fn, 0); | |
| 756 | pub const SIG_IGN = @intToPtr(?Sigaction.sigaction_fn, 1); | |
| 757 | pub const SIG_ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize)); | |
| 758 | pub const SIG_CATCH = @intToPtr(?Sigaction.sigaction_fn, 2); | |
| 759 | pub const SIG_HOLD = @intToPtr(?Sigaction.sigaction_fn, 3); | |
| 705 | pub const SIG = struct { | |
| 706 | pub const DFL = @intToPtr(?Sigaction.sigaction_fn, 0); | |
| 707 | pub const IGN = @intToPtr(?Sigaction.sigaction_fn, 1); | |
| 708 | pub const ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize)); | |
| 709 | pub const CATCH = @intToPtr(?Sigaction.sigaction_fn, 2); | |
| 710 | pub const HOLD = @intToPtr(?Sigaction.sigaction_fn, 3); | |
| 711 | ||
| 712 | pub const HUP = 1; | |
| 713 | pub const INT = 2; | |
| 714 | pub const QUIT = 3; | |
| 715 | pub const ILL = 4; | |
| 716 | pub const TRAP = 5; | |
| 717 | pub const ABRT = 6; | |
| 718 | pub const IOT = ABRT; | |
| 719 | pub const EMT = 7; | |
| 720 | pub const FPE = 8; | |
| 721 | pub const KILL = 9; | |
| 722 | pub const BUS = 10; | |
| 723 | pub const SEGV = 11; | |
| 724 | pub const SYS = 12; | |
| 725 | pub const PIPE = 13; | |
| 726 | pub const ALRM = 14; | |
| 727 | pub const TERM = 15; | |
| 728 | pub const URG = 16; | |
| 729 | pub const STOP = 17; | |
| 730 | pub const TSTP = 18; | |
| 731 | pub const CONT = 19; | |
| 732 | pub const CHLD = 20; | |
| 733 | pub const TTIN = 21; | |
| 734 | pub const TTOU = 22; | |
| 735 | pub const IO = 23; | |
| 736 | pub const XCPU = 24; | |
| 737 | pub const XFSZ = 25; | |
| 738 | pub const VTALRM = 26; | |
| 739 | pub const PROF = 27; | |
| 740 | pub const WINCH = 28; | |
| 741 | pub const INFO = 29; | |
| 742 | pub const USR1 = 30; | |
| 743 | pub const USR2 = 31; | |
| 744 | pub const PWR = 32; | |
| 745 | ||
| 746 | pub const BLOCK = 1; | |
| 747 | pub const UNBLOCK = 2; | |
| 748 | pub const SETMASK = 3; | |
| 749 | }; | |
| 760 | 750 | |
| 761 | 751 | /// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall. |
| 762 | 752 | pub const Sigaction = extern struct { |
| ... | ... | @@ -1013,59 +1003,61 @@ pub const stack_t = extern struct { |
| 1013 | 1003 | ss_flags: c_int, |
| 1014 | 1004 | }; |
| 1015 | 1005 | |
| 1016 | pub const S_IFMT = 0o170000; | |
| 1017 | ||
| 1018 | pub const S_IFIFO = 0o010000; | |
| 1019 | pub const S_IFCHR = 0o020000; | |
| 1020 | pub const S_IFDIR = 0o040000; | |
| 1021 | pub const S_IFBLK = 0o060000; | |
| 1022 | pub const S_IFREG = 0o100000; | |
| 1023 | pub const S_IFLNK = 0o120000; | |
| 1024 | pub const S_IFSOCK = 0o140000; | |
| 1025 | ||
| 1026 | pub const S_ISUID = 0o4000; | |
| 1027 | pub const S_ISGID = 0o2000; | |
| 1028 | pub const S_ISVTX = 0o1000; | |
| 1029 | pub const S_IRWXU = 0o700; | |
| 1030 | pub const S_IRUSR = 0o400; | |
| 1031 | pub const S_IWUSR = 0o200; | |
| 1032 | pub const S_IXUSR = 0o100; | |
| 1033 | pub const S_IRWXG = 0o070; | |
| 1034 | pub const S_IRGRP = 0o040; | |
| 1035 | pub const S_IWGRP = 0o020; | |
| 1036 | pub const S_IXGRP = 0o010; | |
| 1037 | pub const S_IRWXO = 0o007; | |
| 1038 | pub const S_IROTH = 0o004; | |
| 1039 | pub const S_IWOTH = 0o002; | |
| 1040 | pub const S_IXOTH = 0o001; | |
| 1041 | ||
| 1042 | pub fn S_ISFIFO(m: u32) bool { | |
| 1043 | return m & S_IFMT == S_IFIFO; | |
| 1044 | } | |
| 1006 | pub const S = struct { | |
| 1007 | pub const IFMT = 0o170000; | |
| 1008 | ||
| 1009 | pub const IFIFO = 0o010000; | |
| 1010 | pub const IFCHR = 0o020000; | |
| 1011 | pub const IFDIR = 0o040000; | |
| 1012 | pub const IFBLK = 0o060000; | |
| 1013 | pub const IFREG = 0o100000; | |
| 1014 | pub const IFLNK = 0o120000; | |
| 1015 | pub const IFSOCK = 0o140000; | |
| 1016 | ||
| 1017 | pub const ISUID = 0o4000; | |
| 1018 | pub const ISGID = 0o2000; | |
| 1019 | pub const ISVTX = 0o1000; | |
| 1020 | pub const IRWXU = 0o700; | |
| 1021 | pub const IRUSR = 0o400; | |
| 1022 | pub const IWUSR = 0o200; | |
| 1023 | pub const IXUSR = 0o100; | |
| 1024 | pub const IRWXG = 0o070; | |
| 1025 | pub const IRGRP = 0o040; | |
| 1026 | pub const IWGRP = 0o020; | |
| 1027 | pub const IXGRP = 0o010; | |
| 1028 | pub const IRWXO = 0o007; | |
| 1029 | pub const IROTH = 0o004; | |
| 1030 | pub const IWOTH = 0o002; | |
| 1031 | pub const IXOTH = 0o001; | |
| 1032 | ||
| 1033 | pub fn ISFIFO(m: u32) bool { | |
| 1034 | return m & IFMT == IFIFO; | |
| 1035 | } | |
| 1045 | 1036 | |
| 1046 | pub fn S_ISCHR(m: u32) bool { | |
| 1047 | return m & S_IFMT == S_IFCHR; | |
| 1048 | } | |
| 1037 | pub fn ISCHR(m: u32) bool { | |
| 1038 | return m & IFMT == IFCHR; | |
| 1039 | } | |
| 1049 | 1040 | |
| 1050 | pub fn S_ISDIR(m: u32) bool { | |
| 1051 | return m & S_IFMT == S_IFDIR; | |
| 1052 | } | |
| 1041 | pub fn ISDIR(m: u32) bool { | |
| 1042 | return m & IFMT == IFDIR; | |
| 1043 | } | |
| 1053 | 1044 | |
| 1054 | pub fn S_ISBLK(m: u32) bool { | |
| 1055 | return m & S_IFMT == S_IFBLK; | |
| 1056 | } | |
| 1045 | pub fn ISBLK(m: u32) bool { | |
| 1046 | return m & IFMT == IFBLK; | |
| 1047 | } | |
| 1057 | 1048 | |
| 1058 | pub fn S_ISREG(m: u32) bool { | |
| 1059 | return m & S_IFMT == S_IFREG; | |
| 1060 | } | |
| 1049 | pub fn ISREG(m: u32) bool { | |
| 1050 | return m & IFMT == IFREG; | |
| 1051 | } | |
| 1061 | 1052 | |
| 1062 | pub fn S_ISLNK(m: u32) bool { | |
| 1063 | return m & S_IFMT == S_IFLNK; | |
| 1064 | } | |
| 1053 | pub fn ISLNK(m: u32) bool { | |
| 1054 | return m & IFMT == IFLNK; | |
| 1055 | } | |
| 1065 | 1056 | |
| 1066 | pub fn S_ISSOCK(m: u32) bool { | |
| 1067 | return m & S_IFMT == S_IFSOCK; | |
| 1068 | } | |
| 1057 | pub fn ISSOCK(m: u32) bool { | |
| 1058 | return m & IFMT == IFSOCK; | |
| 1059 | } | |
| 1060 | }; | |
| 1069 | 1061 | |
| 1070 | 1062 | pub const AT = struct { |
| 1071 | 1063 | /// Magic value that specify the use of the current working directory |
lib/std/c/wasi.zig+5| ... | ... | @@ -17,6 +17,11 @@ pub const ino_t = wasi.ino_t; |
| 17 | 17 | pub const mode_t = wasi.mode_t; |
| 18 | 18 | pub const time_t = wasi.time_t; |
| 19 | 19 | pub const timespec = wasi.timespec; |
| 20 | pub const STDERR_FILENO = wasi.STDERR_FILENO; | |
| 21 | pub const STDIN_FILENO = wasi.STDIN_FILENO; | |
| 22 | pub const STDOUT_FILENO = wasi.STDOUT_FILENO; | |
| 23 | pub const E = wasi.E; | |
| 24 | pub const CLOCK = wasi.CLOCK; | |
| 20 | 25 | |
| 21 | 26 | pub const Stat = extern struct { |
| 22 | 27 | dev: i32, |
lib/std/debug.zig+1-1| ... | ... | @@ -1470,7 +1470,7 @@ fn getDebugInfoAllocator() *mem.Allocator { |
| 1470 | 1470 | pub const have_segfault_handling_support = switch (native_os) { |
| 1471 | 1471 | .linux, .netbsd => true, |
| 1472 | 1472 | .windows => true, |
| 1473 | .freebsd, .openbsd => @hasDecl(os, "ucontext_t"), | |
| 1473 | .freebsd, .openbsd => @hasDecl(os.system, "ucontext_t"), | |
| 1474 | 1474 | else => false, |
| 1475 | 1475 | }; |
| 1476 | 1476 | pub const enable_segfault_handler: bool = if (@hasDecl(root, "enable_segfault_handler")) |
lib/std/event/loop.zig+1-1| ... | ... | @@ -904,7 +904,7 @@ pub const Loop = struct { |
| 904 | 904 | addr_size: *os.socklen_t, |
| 905 | 905 | /// The following values can be bitwise ORed in flags to obtain different behavior: |
| 906 | 906 | /// * `SOCK.CLOEXEC` - Set the close-on-exec (`FD_CLOEXEC`) flag on the new file descriptor. See the |
| 907 | /// description of the `O_CLOEXEC` flag in `open` for reasons why this may be useful. | |
| 907 | /// description of the `O.CLOEXEC` flag in `open` for reasons why this may be useful. | |
| 908 | 908 | flags: u32, |
| 909 | 909 | ) os.AcceptError!os.socket_t { |
| 910 | 910 | while (true) { |
lib/std/fs.zig+25-25| ... | ... | @@ -479,15 +479,15 @@ pub const Dir = struct { |
| 479 | 479 | &stat_info, |
| 480 | 480 | 0, |
| 481 | 481 | ); |
| 482 | const statmode = stat_info.mode & os.S_IFMT; | |
| 482 | const statmode = stat_info.mode & os.S.IFMT; | |
| 483 | 483 | |
| 484 | 484 | const entry_kind = switch (statmode) { |
| 485 | os.S_IFDIR => Entry.Kind.Directory, | |
| 486 | os.S_IFBLK => Entry.Kind.BlockDevice, | |
| 487 | os.S_IFCHR => Entry.Kind.CharacterDevice, | |
| 488 | os.S_IFLNK => Entry.Kind.SymLink, | |
| 489 | os.S_IFREG => Entry.Kind.File, | |
| 490 | os.S_IFIFO => Entry.Kind.NamedPipe, | |
| 485 | os.S.IFDIR => Entry.Kind.Directory, | |
| 486 | os.S.IFBLK => Entry.Kind.BlockDevice, | |
| 487 | os.S.IFCHR => Entry.Kind.CharacterDevice, | |
| 488 | os.S.IFLNK => Entry.Kind.SymLink, | |
| 489 | os.S.IFREG => Entry.Kind.File, | |
| 490 | os.S.IFIFO => Entry.Kind.NamedPipe, | |
| 491 | 491 | else => Entry.Kind.Unknown, |
| 492 | 492 | }; |
| 493 | 493 | |
| ... | ... | @@ -678,12 +678,12 @@ pub const Dir = struct { |
| 678 | 678 | } |
| 679 | 679 | |
| 680 | 680 | const entry_kind = switch (entry.d_type) { |
| 681 | w.FILETYPE_BLOCK_DEVICE => Entry.Kind.BlockDevice, | |
| 682 | w.FILETYPE_CHARACTER_DEVICE => Entry.Kind.CharacterDevice, | |
| 683 | w.FILETYPE_DIRECTORY => Entry.Kind.Directory, | |
| 684 | w.FILETYPE_SYMBOLIC_LINK => Entry.Kind.SymLink, | |
| 685 | w.FILETYPE_REGULAR_FILE => Entry.Kind.File, | |
| 686 | w.FILETYPE_SOCKET_STREAM, wasi.FILETYPE_SOCKET_DGRAM => Entry.Kind.UnixDomainSocket, | |
| 681 | .BLOCK_DEVICE => Entry.Kind.BlockDevice, | |
| 682 | .CHARACTER_DEVICE => Entry.Kind.CharacterDevice, | |
| 683 | .DIRECTORY => Entry.Kind.Directory, | |
| 684 | .SYMBOLIC_LINK => Entry.Kind.SymLink, | |
| 685 | .REGULAR_FILE => Entry.Kind.File, | |
| 686 | .SOCKET_STREAM, .SOCKET_DGRAM => Entry.Kind.UnixDomainSocket, | |
| 687 | 687 | else => Entry.Kind.Unknown, |
| 688 | 688 | }; |
| 689 | 689 | return Entry{ |
| ... | ... | @@ -909,11 +909,11 @@ pub const Dir = struct { |
| 909 | 909 | } |
| 910 | 910 | |
| 911 | 911 | var os_flags: u32 = os.O.CLOEXEC; |
| 912 | // Use the O_ locking flags if the os supports them to acquire the lock | |
| 912 | // Use the O locking flags if the os supports them to acquire the lock | |
| 913 | 913 | // atomically. |
| 914 | 914 | const has_flock_open_flags = @hasDecl(os.O, "EXLOCK"); |
| 915 | 915 | if (has_flock_open_flags) { |
| 916 | // Note that the O_NONBLOCK flag is removed after the openat() call | |
| 916 | // Note that the O.NONBLOCK flag is removed after the openat() call | |
| 917 | 917 | // is successful. |
| 918 | 918 | const nonblocking_lock_flag: u32 = if (flags.lock_nonblocking) |
| 919 | 919 | os.O.NONBLOCK |
| ... | ... | @@ -1071,10 +1071,10 @@ pub const Dir = struct { |
| 1071 | 1071 | return self.createFileW(path_w.span(), flags); |
| 1072 | 1072 | } |
| 1073 | 1073 | |
| 1074 | // Use the O_ locking flags if the os supports them to acquire the lock | |
| 1074 | // Use the O locking flags if the os supports them to acquire the lock | |
| 1075 | 1075 | // atomically. |
| 1076 | 1076 | const has_flock_open_flags = @hasDecl(os.O, "EXLOCK"); |
| 1077 | // Note that the O_NONBLOCK flag is removed after the openat() call | |
| 1077 | // Note that the O.NONBLOCK flag is removed after the openat() call | |
| 1078 | 1078 | // is successful. |
| 1079 | 1079 | const nonblocking_lock_flag: u32 = if (has_flock_open_flags and flags.lock_nonblocking) |
| 1080 | 1080 | os.O.NONBLOCK |
| ... | ... | @@ -1427,9 +1427,9 @@ pub const Dir = struct { |
| 1427 | 1427 | const result = os.openatWasi(self.fd, sub_path, symlink_flags, w.O.DIRECTORY, 0x0, base, inheriting); |
| 1428 | 1428 | const fd = result catch |err| switch (err) { |
| 1429 | 1429 | error.FileTooBig => unreachable, // can't happen for directories |
| 1430 | error.IsDir => unreachable, // we're providing O_DIRECTORY | |
| 1431 | error.NoSpaceLeft => unreachable, // not providing O_CREAT | |
| 1432 | error.PathAlreadyExists => unreachable, // not providing O_CREAT | |
| 1430 | error.IsDir => unreachable, // we're providing O.DIRECTORY | |
| 1431 | error.NoSpaceLeft => unreachable, // not providing O.CREAT | |
| 1432 | error.PathAlreadyExists => unreachable, // not providing O.CREAT | |
| 1433 | 1433 | error.FileLocksNotSupported => unreachable, // locking folders is not supported |
| 1434 | 1434 | error.WouldBlock => unreachable, // can't happen for directories |
| 1435 | 1435 | else => |e| return e, |
| ... | ... | @@ -1463,7 +1463,7 @@ pub const Dir = struct { |
| 1463 | 1463 | return self.openDirAccessMaskW(sub_path_w, flags, args.no_follow); |
| 1464 | 1464 | } |
| 1465 | 1465 | |
| 1466 | /// `flags` must contain `os.O_DIRECTORY`. | |
| 1466 | /// `flags` must contain `os.O.DIRECTORY`. | |
| 1467 | 1467 | fn openDirFlagsZ(self: Dir, sub_path_c: [*:0]const u8, flags: u32) OpenError!Dir { |
| 1468 | 1468 | const result = if (need_async_thread) |
| 1469 | 1469 | std.event.Loop.instance.?.openatZ(self.fd, sub_path_c, flags, 0) |
| ... | ... | @@ -1471,9 +1471,9 @@ pub const Dir = struct { |
| 1471 | 1471 | os.openatZ(self.fd, sub_path_c, flags, 0); |
| 1472 | 1472 | const fd = result catch |err| switch (err) { |
| 1473 | 1473 | error.FileTooBig => unreachable, // can't happen for directories |
| 1474 | error.IsDir => unreachable, // we're providing O_DIRECTORY | |
| 1475 | error.NoSpaceLeft => unreachable, // not providing O_CREAT | |
| 1476 | error.PathAlreadyExists => unreachable, // not providing O_CREAT | |
| 1474 | error.IsDir => unreachable, // we're providing O.DIRECTORY | |
| 1475 | error.NoSpaceLeft => unreachable, // not providing O.CREAT | |
| 1476 | error.PathAlreadyExists => unreachable, // not providing O.CREAT | |
| 1477 | 1477 | error.FileLocksNotSupported => unreachable, // locking folders is not supported |
| 1478 | 1478 | error.WouldBlock => unreachable, // can't happen for directories |
| 1479 | 1479 | else => |e| return e, |
| ... | ... | @@ -1559,7 +1559,7 @@ pub const Dir = struct { |
| 1559 | 1559 | .macos, .ios, .freebsd, .netbsd, .dragonfly, .openbsd => { |
| 1560 | 1560 | // Don't follow symlinks to match unlinkat (which acts on symlinks rather than follows them) |
| 1561 | 1561 | const fstat = os.fstatatZ(self.fd, sub_path_c, os.AT.SYMLINK_NOFOLLOW) catch return e; |
| 1562 | const is_dir = fstat.mode & os.S_IFMT == os.S_IFDIR; | |
| 1562 | const is_dir = fstat.mode & os.S.IFMT == os.S.IFDIR; | |
| 1563 | 1563 | return if (is_dir) error.IsDir else e; |
| 1564 | 1564 | }, |
| 1565 | 1565 | else => return e, |
lib/std/fs/file.zig+8-8| ... | ... | @@ -106,7 +106,7 @@ pub const File = struct { |
| 106 | 106 | /// and `false` means `error.WouldBlock` is handled by the event loop. |
| 107 | 107 | lock_nonblocking: bool = false, |
| 108 | 108 | |
| 109 | /// Setting this to `.blocking` prevents `O_NONBLOCK` from being passed even | |
| 109 | /// Setting this to `.blocking` prevents `O.NONBLOCK` from being passed even | |
| 110 | 110 | /// if `std.io.is_async`. It allows the use of `nosuspend` when calling functions |
| 111 | 111 | /// related to opening the file, reading, writing, and locking. |
| 112 | 112 | intended_io_mode: io.ModeOverride = io.default_mode, |
| ... | ... | @@ -167,7 +167,7 @@ pub const File = struct { |
| 167 | 167 | /// be created with. |
| 168 | 168 | mode: Mode = default_mode, |
| 169 | 169 | |
| 170 | /// Setting this to `.blocking` prevents `O_NONBLOCK` from being passed even | |
| 170 | /// Setting this to `.blocking` prevents `O.NONBLOCK` from being passed even | |
| 171 | 171 | /// if `std.io.is_async`. It allows the use of `nosuspend` when calling functions |
| 172 | 172 | /// related to opening the file, reading, writing, and locking. |
| 173 | 173 | intended_io_mode: io.ModeOverride = io.default_mode, |
| ... | ... | @@ -325,12 +325,12 @@ pub const File = struct { |
| 325 | 325 | .size = @bitCast(u64, st.size), |
| 326 | 326 | .mode = st.mode, |
| 327 | 327 | .kind = if (builtin.os.tag == .wasi and !builtin.link_libc) switch (st.filetype) { |
| 328 | os.FILETYPE_BLOCK_DEVICE => Kind.BlockDevice, | |
| 329 | os.FILETYPE_CHARACTER_DEVICE => Kind.CharacterDevice, | |
| 330 | os.FILETYPE_DIRECTORY => Kind.Directory, | |
| 331 | os.FILETYPE_SYMBOLIC_LINK => Kind.SymLink, | |
| 332 | os.FILETYPE_REGULAR_FILE => Kind.File, | |
| 333 | os.FILETYPE_SOCKET_STREAM, os.FILETYPE_SOCKET_DGRAM => Kind.UnixDomainSocket, | |
| 328 | .BLOCK_DEVICE => Kind.BlockDevice, | |
| 329 | .CHARACTER_DEVICE => Kind.CharacterDevice, | |
| 330 | .DIRECTORY => Kind.Directory, | |
| 331 | .SYMBOLIC_LINK => Kind.SymLink, | |
| 332 | .REGULAR_FILE => Kind.File, | |
| 333 | .SOCKET_STREAM, .SOCKET_DGRAM => Kind.UnixDomainSocket, | |
| 334 | 334 | else => Kind.Unknown, |
| 335 | 335 | } else switch (st.mode & os.S.IFMT) { |
| 336 | 336 | os.S.IFBLK => Kind.BlockDevice, |
lib/std/fs/watch.zig+1-1| ... | ... | @@ -250,7 +250,7 @@ pub fn Watch(comptime V: type) type { |
| 250 | 250 | }; |
| 251 | 251 | |
| 252 | 252 | // @TODO Can I close this fd and get an error from bsdWaitKev? |
| 253 | const flags = if (comptime std.Target.current.isDarwin()) os.O_SYMLINK | os.O_EVTONLY else 0; | |
| 253 | const flags = if (comptime std.Target.current.isDarwin()) os.O.SYMLINK | os.O.EVTONLY else 0; | |
| 254 | 254 | const fd = try os.open(realpath, flags, 0); |
| 255 | 255 | gop.value_ptr.putter_frame = async self.kqPutEvents(fd, gop.key_ptr.*, gop.value_ptr.*); |
| 256 | 256 | return null; |
lib/std/os.zig+9-8| ... | ... | @@ -72,7 +72,6 @@ pub const E = system.E; |
| 72 | 72 | pub const Elf_Symndx = system.Elf_Symndx; |
| 73 | 73 | pub const F = system.F; |
| 74 | 74 | pub const FD_CLOEXEC = system.FD_CLOEXEC; |
| 75 | pub const F_OK = system.F_OK; | |
| 76 | 75 | pub const Flock = system.Flock; |
| 77 | 76 | pub const HOST_NAME_MAX = system.HOST_NAME_MAX; |
| 78 | 77 | pub const IFNAMESIZE = system.IFNAMESIZE; |
| ... | ... | @@ -96,7 +95,6 @@ pub const REG = system.REG; |
| 96 | 95 | pub const RIGHT = system.RIGHT; |
| 97 | 96 | pub const RLIM = system.RLIM; |
| 98 | 97 | pub const RR = system.RR; |
| 99 | pub const R_OK = system.R_OK; | |
| 100 | 98 | pub const S = system.S; |
| 101 | 99 | pub const SA = system.SA; |
| 102 | 100 | pub const SC = system.SC; |
| ... | ... | @@ -116,8 +114,6 @@ pub const Stat = system.Stat; |
| 116 | 114 | pub const TCSA = system.TCSA; |
| 117 | 115 | pub const VDSO = system.VDSO; |
| 118 | 116 | pub const W = system.W; |
| 119 | pub const W_OK = system.W_OK; | |
| 120 | pub const X_OK = system.X_OK; | |
| 121 | 117 | pub const addrinfo = system.addrinfo; |
| 122 | 118 | pub const blkcnt_t = system.blkcnt_t; |
| 123 | 119 | pub const blksize_t = system.blksize_t; |
| ... | ... | @@ -165,6 +161,11 @@ pub const uid_t = system.uid_t; |
| 165 | 161 | pub const user_desc = system.user_desc; |
| 166 | 162 | pub const utsname = system.utsname; |
| 167 | 163 | |
| 164 | pub const F_OK = system.F_OK; | |
| 165 | pub const R_OK = system.R_OK; | |
| 166 | pub const W_OK = system.W_OK; | |
| 167 | pub const X_OK = system.X_OK; | |
| 168 | ||
| 168 | 169 | pub const iovec = extern struct { |
| 169 | 170 | iov_base: [*]u8, |
| 170 | 171 | iov_len: usize, |
| ... | ... | @@ -4237,7 +4238,7 @@ pub fn lseek_SET(fd: fd_t, offset: u64) SeekError!void { |
| 4237 | 4238 | } |
| 4238 | 4239 | if (builtin.os.tag == .wasi and !builtin.link_libc) { |
| 4239 | 4240 | var new_offset: wasi.filesize_t = undefined; |
| 4240 | switch (wasi.fd_seek(fd, @bitCast(wasi.filedelta_t, offset), wasi.WHENCE_SET, &new_offset)) { | |
| 4241 | switch (wasi.fd_seek(fd, @bitCast(wasi.filedelta_t, offset), .SET, &new_offset)) { | |
| 4241 | 4242 | .SUCCESS => return, |
| 4242 | 4243 | .BADF => unreachable, // always a race condition |
| 4243 | 4244 | .INVAL => return error.Unseekable, |
| ... | ... | @@ -4285,7 +4286,7 @@ pub fn lseek_CUR(fd: fd_t, offset: i64) SeekError!void { |
| 4285 | 4286 | } |
| 4286 | 4287 | if (builtin.os.tag == .wasi and !builtin.link_libc) { |
| 4287 | 4288 | var new_offset: wasi.filesize_t = undefined; |
| 4288 | switch (wasi.fd_seek(fd, offset, wasi.WHENCE_CUR, &new_offset)) { | |
| 4289 | switch (wasi.fd_seek(fd, offset, .CUR, &new_offset)) { | |
| 4289 | 4290 | .SUCCESS => return, |
| 4290 | 4291 | .BADF => unreachable, // always a race condition |
| 4291 | 4292 | .INVAL => return error.Unseekable, |
| ... | ... | @@ -4332,7 +4333,7 @@ pub fn lseek_END(fd: fd_t, offset: i64) SeekError!void { |
| 4332 | 4333 | } |
| 4333 | 4334 | if (builtin.os.tag == .wasi and !builtin.link_libc) { |
| 4334 | 4335 | var new_offset: wasi.filesize_t = undefined; |
| 4335 | switch (wasi.fd_seek(fd, offset, wasi.WHENCE_END, &new_offset)) { | |
| 4336 | switch (wasi.fd_seek(fd, offset, .END, &new_offset)) { | |
| 4336 | 4337 | .SUCCESS => return, |
| 4337 | 4338 | .BADF => unreachable, // always a race condition |
| 4338 | 4339 | .INVAL => return error.Unseekable, |
| ... | ... | @@ -4379,7 +4380,7 @@ pub fn lseek_CUR_get(fd: fd_t) SeekError!u64 { |
| 4379 | 4380 | } |
| 4380 | 4381 | if (builtin.os.tag == .wasi and !builtin.link_libc) { |
| 4381 | 4382 | var new_offset: wasi.filesize_t = undefined; |
| 4382 | switch (wasi.fd_seek(fd, 0, wasi.WHENCE_CUR, &new_offset)) { | |
| 4383 | switch (wasi.fd_seek(fd, 0, .CUR, &new_offset)) { | |
| 4383 | 4384 | .SUCCESS => return new_offset, |
| 4384 | 4385 | .BADF => unreachable, // always a race condition |
| 4385 | 4386 | .INVAL => return error.Unseekable, |
lib/std/os/linux.zig+46-36| ... | ... | @@ -57,24 +57,23 @@ pub const socketcall = syscall_bits.socketcall; |
| 57 | 57 | pub const syscall_pipe = syscall_bits.syscall_pipe; |
| 58 | 58 | pub const syscall_fork = syscall_bits.syscall_fork; |
| 59 | 59 | |
| 60 | pub const clone = arch_bits.clone; | |
| 61 | 60 | pub const ARCH = arch_bits.ARCH; |
| 62 | 61 | pub const Elf_Symndx = arch_bits.Elf_Symndx; |
| 63 | 62 | pub const F = arch_bits.F; |
| 64 | 63 | pub const Flock = arch_bits.Flock; |
| 64 | pub const HWCAP = arch_bits.HWCAP; | |
| 65 | 65 | pub const LOCK = arch_bits.LOCK; |
| 66 | pub const MAP = arch_bits.MAP; | |
| 67 | 66 | pub const MMAP2_UNIT = arch_bits.MMAP2_UNIT; |
| 68 | pub const O = arch_bits.O; | |
| 69 | 67 | pub const REG = arch_bits.REG; |
| 70 | 68 | pub const SC = arch_bits.SC; |
| 71 | 69 | pub const SYS = arch_bits.SYS; |
| 70 | pub const Stat = arch_bits.Stat; | |
| 72 | 71 | pub const VDSO = arch_bits.VDSO; |
| 73 | 72 | pub const blkcnt_t = arch_bits.blkcnt_t; |
| 74 | 73 | pub const blksize_t = arch_bits.blksize_t; |
| 74 | pub const clone = arch_bits.clone; | |
| 75 | 75 | pub const dev_t = arch_bits.dev_t; |
| 76 | 76 | pub const ino_t = arch_bits.ino_t; |
| 77 | pub const Stat = arch_bits.Stat; | |
| 78 | 77 | pub const mcontext_t = arch_bits.mcontext_t; |
| 79 | 78 | pub const mode_t = arch_bits.mode_t; |
| 80 | 79 | pub const msghdr = arch_bits.msghdr; |
| ... | ... | @@ -92,29 +91,46 @@ pub const tls = @import("linux/tls.zig"); |
| 92 | 91 | pub const pie = @import("linux/start_pie.zig"); |
| 93 | 92 | pub const BPF = @import("linux/bpf.zig"); |
| 94 | 93 | |
| 95 | const io_uring = @import("linux/io_uring.zig"); | |
| 96 | pub const IO_Uring = io_uring.IO_Uring; | |
| 97 | pub const SubmissionQueue = io_uring.SubmissionQueue; | |
| 98 | pub const CompletionQueue = io_uring.CompletionQueue; | |
| 99 | pub const io_uring_prep_nop = io_uring.io_uring_prep_nop; | |
| 100 | pub const io_uring_prep_fsync = io_uring.io_uring_prep_fsync; | |
| 101 | pub const io_uring_prep_rw = io_uring.io_uring_prep_rw; | |
| 102 | pub const io_uring_prep_read = io_uring.io_uring_prep_read; | |
| 103 | pub const io_uring_prep_write = io_uring.io_uring_prep_write; | |
| 104 | pub const io_uring_prep_readv = io_uring.io_uring_prep_readv; | |
| 105 | pub const io_uring_prep_writev = io_uring.io_uring_prep_writev; | |
| 106 | pub const io_uring_prep_accept = io_uring.io_uring_prep_accept; | |
| 107 | pub const io_uring_prep_connect = io_uring.io_uring_prep_connect; | |
| 108 | pub const io_uring_prep_epoll_ctl = io_uring.io_uring_prep_epoll_ctl; | |
| 109 | pub const io_uring_prep_recv = io_uring.io_uring_prep_recv; | |
| 110 | pub const io_uring_prep_send = io_uring.io_uring_prep_send; | |
| 111 | pub const io_uring_prep_openat = io_uring.io_uring_prep_openat; | |
| 112 | pub const io_uring_prep_close = io_uring.io_uring_prep_close; | |
| 113 | pub const io_uring_prep_timeout = io_uring.io_uring_prep_timeout; | |
| 114 | pub const io_uring_prep_timeout_remove = io_uring.io_uring_prep_timeout_remove; | |
| 115 | pub const io_uring_prep_poll_add = io_uring.io_uring_prep_poll_add; | |
| 116 | pub const io_uring_prep_poll_remove = io_uring.io_uring_prep_poll_remove; | |
| 117 | pub const io_uring_prep_fallocate = io_uring.io_uring_prep_fallocate; | |
| 94 | pub const MAP = struct { | |
| 95 | pub usingnamespace arch_bits.MAP; | |
| 96 | ||
| 97 | /// Share changes | |
| 98 | pub const SHARED = 0x01; | |
| 99 | /// Changes are private | |
| 100 | pub const PRIVATE = 0x02; | |
| 101 | /// share + validate extension flags | |
| 102 | pub const SHARED_VALIDATE = 0x03; | |
| 103 | /// Mask for type of mapping | |
| 104 | pub const TYPE = 0x0f; | |
| 105 | /// Interpret addr exactly | |
| 106 | pub const FIXED = 0x10; | |
| 107 | /// don't use a file | |
| 108 | pub const ANONYMOUS = 0x20; | |
| 109 | /// populate (prefault) pagetables | |
| 110 | pub const POPULATE = 0x8000; | |
| 111 | /// do not block on IO | |
| 112 | pub const NONBLOCK = 0x10000; | |
| 113 | /// give out an address that is best suited for process/thread stacks | |
| 114 | pub const STACK = 0x20000; | |
| 115 | /// create a huge page mapping | |
| 116 | pub const HUGETLB = 0x40000; | |
| 117 | /// perform synchronous page faults for the mapping | |
| 118 | pub const SYNC = 0x80000; | |
| 119 | /// FIXED which doesn't unmap underlying mapping | |
| 120 | pub const FIXED_NOREPLACE = 0x100000; | |
| 121 | /// For anonymous mmap, memory could be uninitialized | |
| 122 | pub const UNINITIALIZED = 0x4000000; | |
| 123 | }; | |
| 124 | ||
| 125 | pub const O = struct { | |
| 126 | pub usingnamespace arch_bits.O; | |
| 127 | ||
| 128 | pub const RDONLY = 0o0; | |
| 129 | pub const WRONLY = 0o1; | |
| 130 | pub const RDWR = 0o2; | |
| 131 | }; | |
| 132 | ||
| 133 | pub usingnamespace @import("linux/io_uring.zig"); | |
| 118 | 134 | |
| 119 | 135 | /// Set by startup code, used by `getauxval`. |
| 120 | 136 | pub var elf_aux_maybe: ?[*]std.elf.Auxv = null; |
| ... | ... | @@ -1725,26 +1741,20 @@ pub const FUTEX = struct { |
| 1725 | 1741 | pub const PROT = struct { |
| 1726 | 1742 | /// page can not be accessed |
| 1727 | 1743 | pub const NONE = 0x0; |
| 1728 | ||
| 1729 | 1744 | /// page can be read |
| 1730 | 1745 | pub const READ = 0x1; |
| 1731 | ||
| 1732 | 1746 | /// page can be written |
| 1733 | 1747 | pub const WRITE = 0x2; |
| 1734 | ||
| 1735 | 1748 | /// page can be executed |
| 1736 | 1749 | pub const EXEC = 0x4; |
| 1737 | ||
| 1738 | 1750 | /// page may be used for atomic ops |
| 1739 | 1751 | pub const SEM = switch (native_arch) { |
| 1740 | 1752 | // TODO: also xtensa |
| 1741 | 1753 | .mips, .mipsel, .mips64, .mips64el => 0x10, |
| 1742 | 1754 | else => 0x8, |
| 1743 | 1755 | }; |
| 1744 | ||
| 1745 | 1756 | /// mprotect flag: extend change to start of growsdown vma |
| 1746 | 1757 | pub const GROWSDOWN = 0x01000000; |
| 1747 | ||
| 1748 | 1758 | /// mprotect flag: extend change to end of growsup vma |
| 1749 | 1759 | pub const GROWSUP = 0x02000000; |
| 1750 | 1760 | }; |
| ... | ... | @@ -1960,16 +1970,16 @@ pub const RWF = struct { |
| 1960 | 1970 | /// high priority request, poll if possible |
| 1961 | 1971 | pub const HIPRI: kernel_rwf = 0x00000001; |
| 1962 | 1972 | |
| 1963 | /// per-IO O_DSYNC | |
| 1973 | /// per-IO O.DSYNC | |
| 1964 | 1974 | pub const DSYNC: kernel_rwf = 0x00000002; |
| 1965 | 1975 | |
| 1966 | /// per-IO O_SYNC | |
| 1976 | /// per-IO O.SYNC | |
| 1967 | 1977 | pub const SYNC: kernel_rwf = 0x00000004; |
| 1968 | 1978 | |
| 1969 | 1979 | /// per-IO, return -EAGAIN if operation would block |
| 1970 | 1980 | pub const NOWAIT: kernel_rwf = 0x00000008; |
| 1971 | 1981 | |
| 1972 | /// per-IO O_APPEND | |
| 1982 | /// per-IO O.APPEND | |
| 1973 | 1983 | pub const APPEND: kernel_rwf = 0x00000010; |
| 1974 | 1984 | }; |
| 1975 | 1985 |
lib/std/os/linux/arm-eabi.zig+53-48| ... | ... | @@ -532,26 +532,28 @@ pub const SYS = enum(usize) { |
| 532 | 532 | |
| 533 | 533 | pub const MMAP2_UNIT = 4096; |
| 534 | 534 | |
| 535 | pub const O_CREAT = 0o100; | |
| 536 | pub const O_EXCL = 0o200; | |
| 537 | pub const O_NOCTTY = 0o400; | |
| 538 | pub const O_TRUNC = 0o1000; | |
| 539 | pub const O_APPEND = 0o2000; | |
| 540 | pub const O_NONBLOCK = 0o4000; | |
| 541 | pub const O_DSYNC = 0o10000; | |
| 542 | pub const O_SYNC = 0o4010000; | |
| 543 | pub const O_RSYNC = 0o4010000; | |
| 544 | pub const O_DIRECTORY = 0o40000; | |
| 545 | pub const O_NOFOLLOW = 0o100000; | |
| 546 | pub const O_CLOEXEC = 0o2000000; | |
| 547 | ||
| 548 | pub const O_ASYNC = 0o20000; | |
| 549 | pub const O_DIRECT = 0o200000; | |
| 550 | pub const O_LARGEFILE = 0o400000; | |
| 551 | pub const O_NOATIME = 0o1000000; | |
| 552 | pub const O_PATH = 0o10000000; | |
| 553 | pub const O_TMPFILE = 0o20040000; | |
| 554 | pub const O_NDELAY = O_NONBLOCK; | |
| 535 | pub const O = struct { | |
| 536 | pub const CREAT = 0o100; | |
| 537 | pub const EXCL = 0o200; | |
| 538 | pub const NOCTTY = 0o400; | |
| 539 | pub const TRUNC = 0o1000; | |
| 540 | pub const APPEND = 0o2000; | |
| 541 | pub const NONBLOCK = 0o4000; | |
| 542 | pub const DSYNC = 0o10000; | |
| 543 | pub const SYNC = 0o4010000; | |
| 544 | pub const RSYNC = 0o4010000; | |
| 545 | pub const DIRECTORY = 0o40000; | |
| 546 | pub const NOFOLLOW = 0o100000; | |
| 547 | pub const CLOEXEC = 0o2000000; | |
| 548 | ||
| 549 | pub const ASYNC = 0o20000; | |
| 550 | pub const DIRECT = 0o200000; | |
| 551 | pub const LARGEFILE = 0o400000; | |
| 552 | pub const NOATIME = 0o1000000; | |
| 553 | pub const PATH = 0o10000000; | |
| 554 | pub const TMPFILE = 0o20040000; | |
| 555 | pub const NDELAY = NONBLOCK; | |
| 556 | }; | |
| 555 | 557 | |
| 556 | 558 | pub const F = struct { |
| 557 | 559 | pub const DUPFD = 0; |
| ... | ... | @@ -597,35 +599,38 @@ pub const MAP = struct { |
| 597 | 599 | pub const LOCKED = 0x2000; |
| 598 | 600 | /// don't check for reservations |
| 599 | 601 | pub const NORESERVE = 0x4000; |
| 600 | /// Only used by libc to communicate failure. | |
| 601 | pub const FAILED = @intToPtr(*c_void, maxInt(usize)); | |
| 602 | 602 | }; |
| 603 | pub const VDSO_CGT_SYM = "__vdso_clock_gettime"; | |
| 604 | pub const VDSO_CGT_VER = "LINUX_2.6"; | |
| 605 | ||
| 606 | pub const HWCAP_SWP = 1 << 0; | |
| 607 | pub const HWCAP_HALF = 1 << 1; | |
| 608 | pub const HWCAP_THUMB = 1 << 2; | |
| 609 | pub const HWCAP_26BIT = 1 << 3; | |
| 610 | pub const HWCAP_FAST_MULT = 1 << 4; | |
| 611 | pub const HWCAP_FPA = 1 << 5; | |
| 612 | pub const HWCAP_VFP = 1 << 6; | |
| 613 | pub const HWCAP_EDSP = 1 << 7; | |
| 614 | pub const HWCAP_JAVA = 1 << 8; | |
| 615 | pub const HWCAP_IWMMXT = 1 << 9; | |
| 616 | pub const HWCAP_CRUNCH = 1 << 10; | |
| 617 | pub const HWCAP_THUMBEE = 1 << 11; | |
| 618 | pub const HWCAP_NEON = 1 << 12; | |
| 619 | pub const HWCAP_VFPv3 = 1 << 13; | |
| 620 | pub const HWCAP_VFPv3D16 = 1 << 14; | |
| 621 | pub const HWCAP_TLS = 1 << 15; | |
| 622 | pub const HWCAP_VFPv4 = 1 << 16; | |
| 623 | pub const HWCAP_IDIVA = 1 << 17; | |
| 624 | pub const HWCAP_IDIVT = 1 << 18; | |
| 625 | pub const HWCAP_VFPD32 = 1 << 19; | |
| 626 | pub const HWCAP_IDIV = HWCAP_IDIVA | HWCAP_IDIVT; | |
| 627 | pub const HWCAP_LPAE = 1 << 20; | |
| 628 | pub const HWCAP_EVTSTRM = 1 << 21; | |
| 603 | ||
| 604 | pub const VDSO = struct { | |
| 605 | pub const CGT_SYM = "__vdso_clock_gettime"; | |
| 606 | pub const CGT_VER = "LINUX_2.6"; | |
| 607 | }; | |
| 608 | ||
| 609 | pub const HWCAP = struct { | |
| 610 | pub const SWP = 1 << 0; | |
| 611 | pub const HALF = 1 << 1; | |
| 612 | pub const THUMB = 1 << 2; | |
| 613 | pub const @"26BIT" = 1 << 3; | |
| 614 | pub const FAST_MULT = 1 << 4; | |
| 615 | pub const FPA = 1 << 5; | |
| 616 | pub const VFP = 1 << 6; | |
| 617 | pub const EDSP = 1 << 7; | |
| 618 | pub const JAVA = 1 << 8; | |
| 619 | pub const IWMMXT = 1 << 9; | |
| 620 | pub const CRUNCH = 1 << 10; | |
| 621 | pub const THUMBEE = 1 << 11; | |
| 622 | pub const NEON = 1 << 12; | |
| 623 | pub const VFPv3 = 1 << 13; | |
| 624 | pub const VFPv3D16 = 1 << 14; | |
| 625 | pub const TLS = 1 << 15; | |
| 626 | pub const VFPv4 = 1 << 16; | |
| 627 | pub const IDIVA = 1 << 17; | |
| 628 | pub const IDIVT = 1 << 18; | |
| 629 | pub const VFPD32 = 1 << 19; | |
| 630 | pub const IDIV = IDIVA | IDIVT; | |
| 631 | pub const LPAE = 1 << 20; | |
| 632 | pub const EVTSTRM = 1 << 21; | |
| 633 | }; | |
| 629 | 634 | |
| 630 | 635 | pub const Flock = extern struct { |
| 631 | 636 | l_type: i16, |
lib/std/os/linux/arm64.zig+27-24| ... | ... | @@ -410,26 +410,28 @@ pub const SYS = enum(usize) { |
| 410 | 410 | _, |
| 411 | 411 | }; |
| 412 | 412 | |
| 413 | pub const O_CREAT = 0o100; | |
| 414 | pub const O_EXCL = 0o200; | |
| 415 | pub const O_NOCTTY = 0o400; | |
| 416 | pub const O_TRUNC = 0o1000; | |
| 417 | pub const O_APPEND = 0o2000; | |
| 418 | pub const O_NONBLOCK = 0o4000; | |
| 419 | pub const O_DSYNC = 0o10000; | |
| 420 | pub const O_SYNC = 0o4010000; | |
| 421 | pub const O_RSYNC = 0o4010000; | |
| 422 | pub const O_DIRECTORY = 0o40000; | |
| 423 | pub const O_NOFOLLOW = 0o100000; | |
| 424 | pub const O_CLOEXEC = 0o2000000; | |
| 425 | ||
| 426 | pub const O_ASYNC = 0o20000; | |
| 427 | pub const O_DIRECT = 0o200000; | |
| 428 | pub const O_LARGEFILE = 0o400000; | |
| 429 | pub const O_NOATIME = 0o1000000; | |
| 430 | pub const O_PATH = 0o10000000; | |
| 431 | pub const O_TMPFILE = 0o20040000; | |
| 432 | pub const O_NDELAY = O_NONBLOCK; | |
| 413 | pub const O = struct { | |
| 414 | pub const CREAT = 0o100; | |
| 415 | pub const EXCL = 0o200; | |
| 416 | pub const NOCTTY = 0o400; | |
| 417 | pub const TRUNC = 0o1000; | |
| 418 | pub const APPEND = 0o2000; | |
| 419 | pub const NONBLOCK = 0o4000; | |
| 420 | pub const DSYNC = 0o10000; | |
| 421 | pub const SYNC = 0o4010000; | |
| 422 | pub const RSYNC = 0o4010000; | |
| 423 | pub const DIRECTORY = 0o40000; | |
| 424 | pub const NOFOLLOW = 0o100000; | |
| 425 | pub const CLOEXEC = 0o2000000; | |
| 426 | ||
| 427 | pub const ASYNC = 0o20000; | |
| 428 | pub const DIRECT = 0o200000; | |
| 429 | pub const LARGEFILE = 0o400000; | |
| 430 | pub const NOATIME = 0o1000000; | |
| 431 | pub const PATH = 0o10000000; | |
| 432 | pub const TMPFILE = 0o20040000; | |
| 433 | pub const NDELAY = NONBLOCK; | |
| 434 | }; | |
| 433 | 435 | |
| 434 | 436 | pub const F = struct { |
| 435 | 437 | pub const DUPFD = 0; |
| ... | ... | @@ -475,11 +477,12 @@ pub const MAP = struct { |
| 475 | 477 | pub const LOCKED = 0x2000; |
| 476 | 478 | /// don't check for reservations |
| 477 | 479 | pub const NORESERVE = 0x4000; |
| 478 | /// Only used by libc to communicate failure. | |
| 479 | pub const FAILED = @intToPtr(*c_void, maxInt(usize)); | |
| 480 | 480 | }; |
| 481 | pub const VDSO_CGT_SYM = "__kernel_clock_gettime"; | |
| 482 | pub const VDSO_CGT_VER = "LINUX_2.6.39"; | |
| 481 | ||
| 482 | pub const VDSO = struct { | |
| 483 | pub const CGT_SYM = "__kernel_clock_gettime"; | |
| 484 | pub const CGT_VER = "LINUX_2.6.39"; | |
| 485 | }; | |
| 483 | 486 | |
| 484 | 487 | pub const Flock = extern struct { |
| 485 | 488 | l_type: i16, |
lib/std/os/linux/i386.zig-34| ... | ... | @@ -572,10 +572,6 @@ pub const SYS = enum(usize) { |
| 572 | 572 | }; |
| 573 | 573 | |
| 574 | 574 | pub const O = struct { |
| 575 | pub const RDONLY = 0o0; | |
| 576 | pub const WRONLY = 0o1; | |
| 577 | pub const RDWR = 0o2; | |
| 578 | ||
| 579 | 575 | pub const CREAT = 0o100; |
| 580 | 576 | pub const EXCL = 0o200; |
| 581 | 577 | pub const NOCTTY = 0o400; |
| ... | ... | @@ -628,42 +624,12 @@ pub const LOCK = struct { |
| 628 | 624 | }; |
| 629 | 625 | |
| 630 | 626 | pub const MAP = struct { |
| 631 | /// Share changes | |
| 632 | pub const SHARED = 0x01; | |
| 633 | /// Changes are private | |
| 634 | pub const PRIVATE = 0x02; | |
| 635 | /// share + validate extension flags | |
| 636 | pub const SHARED_VALIDATE = 0x03; | |
| 637 | /// Mask for type of mapping | |
| 638 | pub const TYPE = 0x0f; | |
| 639 | /// Interpret addr exactly | |
| 640 | pub const FIXED = 0x10; | |
| 641 | /// don't use a file | |
| 642 | pub const ANONYMOUS = 0x20; | |
| 643 | /// populate (prefault) pagetables | |
| 644 | pub const POPULATE = 0x8000; | |
| 645 | /// do not block on IO | |
| 646 | pub const NONBLOCK = 0x10000; | |
| 647 | /// give out an address that is best suited for process/thread stacks | |
| 648 | pub const STACK = 0x20000; | |
| 649 | /// create a huge page mapping | |
| 650 | pub const HUGETLB = 0x40000; | |
| 651 | /// perform synchronous page faults for the mapping | |
| 652 | pub const SYNC = 0x80000; | |
| 653 | /// FIXED which doesn't unmap underlying mapping | |
| 654 | pub const FIXED_NOREPLACE = 0x100000; | |
| 655 | /// For anonymous mmap, memory could be uninitialized | |
| 656 | pub const UNINITIALIZED = 0x4000000; | |
| 657 | ||
| 658 | 627 | pub const NORESERVE = 0x4000; |
| 659 | 628 | pub const GROWSDOWN = 0x0100; |
| 660 | 629 | pub const DENYWRITE = 0x0800; |
| 661 | 630 | pub const EXECUTABLE = 0x1000; |
| 662 | 631 | pub const LOCKED = 0x2000; |
| 663 | 632 | pub const @"32BIT" = 0x40; |
| 664 | ||
| 665 | /// Only used by libc to communicate failure. | |
| 666 | pub const FAILED = @intToPtr(*c_void, maxInt(usize)); | |
| 667 | 633 | }; |
| 668 | 634 | |
| 669 | 635 | pub const MMAP2_UNIT = 4096; |
lib/std/os/linux/io_uring.zig+7-7| ... | ... | @@ -539,7 +539,7 @@ pub const IO_Uring = struct { |
| 539 | 539 | pub fn timeout( |
| 540 | 540 | self: *IO_Uring, |
| 541 | 541 | user_data: u64, |
| 542 | ts: *const os.__kernel_timespec, | |
| 542 | ts: *const os.linux.timespec, | |
| 543 | 543 | count: u32, |
| 544 | 544 | flags: u32, |
| 545 | 545 | ) !*io_uring_sqe { |
| ... | ... | @@ -979,7 +979,7 @@ pub fn io_uring_prep_close(sqe: *io_uring_sqe, fd: os.fd_t) void { |
| 979 | 979 | |
| 980 | 980 | pub fn io_uring_prep_timeout( |
| 981 | 981 | sqe: *io_uring_sqe, |
| 982 | ts: *const os.__kernel_timespec, | |
| 982 | ts: *const os.linux.timespec, | |
| 983 | 983 | count: u32, |
| 984 | 984 | flags: u32, |
| 985 | 985 | ) void { |
| ... | ... | @@ -1136,7 +1136,7 @@ test "readv" { |
| 1136 | 1136 | }; |
| 1137 | 1137 | defer ring.deinit(); |
| 1138 | 1138 | |
| 1139 | const fd = try os.openZ("/dev/zero", os.O_RDONLY | os.O_CLOEXEC, 0); | |
| 1139 | const fd = try os.openZ("/dev/zero", os.O.RDONLY | os.O.CLOEXEC, 0); | |
| 1140 | 1140 | defer os.close(fd); |
| 1141 | 1141 | |
| 1142 | 1142 | // Linux Kernel 5.4 supports IORING_REGISTER_FILES but not sparse fd sets (i.e. an fd of -1). |
| ... | ... | @@ -1295,7 +1295,7 @@ test "openat" { |
| 1295 | 1295 | const path = "test_io_uring_openat"; |
| 1296 | 1296 | defer std.fs.cwd().deleteFile(path) catch {}; |
| 1297 | 1297 | |
| 1298 | const flags: u32 = os.O_CLOEXEC | os.O_RDWR | os.O_CREAT; | |
| 1298 | const flags: u32 = os.O.CLOEXEC | os.O.RDWR | os.O.CREAT; | |
| 1299 | 1299 | const mode: os.mode_t = 0o666; |
| 1300 | 1300 | const sqe_openat = try ring.openat(0x33333333, linux.AT.FDCWD, path, flags, mode); |
| 1301 | 1301 | try testing.expectEqual(io_uring_sqe{ |
| ... | ... | @@ -1450,7 +1450,7 @@ test "timeout (after a relative time)" { |
| 1450 | 1450 | |
| 1451 | 1451 | const ms = 10; |
| 1452 | 1452 | const margin = 5; |
| 1453 | const ts = os.__kernel_timespec{ .tv_sec = 0, .tv_nsec = ms * 1000000 }; | |
| 1453 | const ts = os.linux.timespec{ .tv_sec = 0, .tv_nsec = ms * 1000000 }; | |
| 1454 | 1454 | |
| 1455 | 1455 | const started = std.time.milliTimestamp(); |
| 1456 | 1456 | const sqe = try ring.timeout(0x55555555, &ts, 0, 0); |
| ... | ... | @@ -1479,7 +1479,7 @@ test "timeout (after a number of completions)" { |
| 1479 | 1479 | }; |
| 1480 | 1480 | defer ring.deinit(); |
| 1481 | 1481 | |
| 1482 | const ts = os.__kernel_timespec{ .tv_sec = 3, .tv_nsec = 0 }; | |
| 1482 | const ts = os.linux.timespec{ .tv_sec = 3, .tv_nsec = 0 }; | |
| 1483 | 1483 | const count_completions: u64 = 1; |
| 1484 | 1484 | const sqe_timeout = try ring.timeout(0x66666666, &ts, count_completions, 0); |
| 1485 | 1485 | try testing.expectEqual(linux.IORING_OP.TIMEOUT, sqe_timeout.opcode); |
| ... | ... | @@ -1512,7 +1512,7 @@ test "timeout_remove" { |
| 1512 | 1512 | }; |
| 1513 | 1513 | defer ring.deinit(); |
| 1514 | 1514 | |
| 1515 | const ts = os.__kernel_timespec{ .tv_sec = 3, .tv_nsec = 0 }; | |
| 1515 | const ts = os.linux.timespec{ .tv_sec = 3, .tv_nsec = 0 }; | |
| 1516 | 1516 | const sqe_timeout = try ring.timeout(0x88888888, &ts, 0, 0); |
| 1517 | 1517 | try testing.expectEqual(linux.IORING_OP.TIMEOUT, sqe_timeout.opcode); |
| 1518 | 1518 | try testing.expectEqual(@as(u64, 0x88888888), sqe_timeout.user_data); |
lib/std/os/linux/mips.zig+26-24| ... | ... | @@ -629,26 +629,28 @@ pub const SYS = enum(usize) { |
| 629 | 629 | _, |
| 630 | 630 | }; |
| 631 | 631 | |
| 632 | pub const O_CREAT = 0o0400; | |
| 633 | pub const O_EXCL = 0o02000; | |
| 634 | pub const O_NOCTTY = 0o04000; | |
| 635 | pub const O_TRUNC = 0o01000; | |
| 636 | pub const O_APPEND = 0o0010; | |
| 637 | pub const O_NONBLOCK = 0o0200; | |
| 638 | pub const O_DSYNC = 0o0020; | |
| 639 | pub const O_SYNC = 0o040020; | |
| 640 | pub const O_RSYNC = 0o040020; | |
| 641 | pub const O_DIRECTORY = 0o0200000; | |
| 642 | pub const O_NOFOLLOW = 0o0400000; | |
| 643 | pub const O_CLOEXEC = 0o02000000; | |
| 644 | ||
| 645 | pub const O_ASYNC = 0o010000; | |
| 646 | pub const O_DIRECT = 0o0100000; | |
| 647 | pub const O_LARGEFILE = 0o020000; | |
| 648 | pub const O_NOATIME = 0o01000000; | |
| 649 | pub const O_PATH = 0o010000000; | |
| 650 | pub const O_TMPFILE = 0o020200000; | |
| 651 | pub const O_NDELAY = O_NONBLOCK; | |
| 632 | pub const O = struct { | |
| 633 | pub const CREAT = 0o0400; | |
| 634 | pub const EXCL = 0o02000; | |
| 635 | pub const NOCTTY = 0o04000; | |
| 636 | pub const TRUNC = 0o01000; | |
| 637 | pub const APPEND = 0o0010; | |
| 638 | pub const NONBLOCK = 0o0200; | |
| 639 | pub const DSYNC = 0o0020; | |
| 640 | pub const SYNC = 0o040020; | |
| 641 | pub const RSYNC = 0o040020; | |
| 642 | pub const DIRECTORY = 0o0200000; | |
| 643 | pub const NOFOLLOW = 0o0400000; | |
| 644 | pub const CLOEXEC = 0o02000000; | |
| 645 | ||
| 646 | pub const ASYNC = 0o010000; | |
| 647 | pub const DIRECT = 0o0100000; | |
| 648 | pub const LARGEFILE = 0o020000; | |
| 649 | pub const NOATIME = 0o01000000; | |
| 650 | pub const PATH = 0o010000000; | |
| 651 | pub const TMPFILE = 0o020200000; | |
| 652 | pub const NDELAY = NONBLOCK; | |
| 653 | }; | |
| 652 | 654 | |
| 653 | 655 | pub const F = struct { |
| 654 | 656 | pub const DUPFD = 0; |
| ... | ... | @@ -692,8 +694,6 @@ pub const MAP = struct { |
| 692 | 694 | pub const EXECUTABLE = 0x4000; |
| 693 | 695 | pub const LOCKED = 0x8000; |
| 694 | 696 | pub const @"32BIT" = 0x40; |
| 695 | /// Only used by libc to communicate failure. | |
| 696 | pub const FAILED = @intToPtr(*c_void, maxInt(usize)); | |
| 697 | 697 | }; |
| 698 | 698 | |
| 699 | 699 | pub const SO = struct { |
| ... | ... | @@ -726,8 +726,10 @@ pub const SO = struct { |
| 726 | 726 | pub const RCVBUFFORCE = 33; |
| 727 | 727 | }; |
| 728 | 728 | |
| 729 | pub const VDSO_CGT_SYM = "__kernel_clock_gettime"; | |
| 730 | pub const VDSO_CGT_VER = "LINUX_2.6.39"; | |
| 729 | pub const VDSO = struct { | |
| 730 | pub const CGT_SYM = "__kernel_clock_gettime"; | |
| 731 | pub const CGT_VER = "LINUX_2.6.39"; | |
| 732 | }; | |
| 731 | 733 | |
| 732 | 734 | pub const Flock = extern struct { |
| 733 | 735 | l_type: i16, |
lib/std/os/linux/powerpc.zig+27-24| ... | ... | @@ -562,26 +562,28 @@ pub const SYS = enum(usize) { |
| 562 | 562 | process_madvise = 440, |
| 563 | 563 | }; |
| 564 | 564 | |
| 565 | pub const O_CREAT = 0o100; | |
| 566 | pub const O_EXCL = 0o200; | |
| 567 | pub const O_NOCTTY = 0o400; | |
| 568 | pub const O_TRUNC = 0o1000; | |
| 569 | pub const O_APPEND = 0o2000; | |
| 570 | pub const O_NONBLOCK = 0o4000; | |
| 571 | pub const O_DSYNC = 0o10000; | |
| 572 | pub const O_SYNC = 0o4010000; | |
| 573 | pub const O_RSYNC = 0o4010000; | |
| 574 | pub const O_DIRECTORY = 0o40000; | |
| 575 | pub const O_NOFOLLOW = 0o100000; | |
| 576 | pub const O_CLOEXEC = 0o2000000; | |
| 577 | ||
| 578 | pub const O_ASYNC = 0o20000; | |
| 579 | pub const O_DIRECT = 0o400000; | |
| 580 | pub const O_LARGEFILE = 0o200000; | |
| 581 | pub const O_NOATIME = 0o1000000; | |
| 582 | pub const O_PATH = 0o10000000; | |
| 583 | pub const O_TMPFILE = 0o20040000; | |
| 584 | pub const O_NDELAY = O_NONBLOCK; | |
| 565 | pub const O = struct { | |
| 566 | pub const CREAT = 0o100; | |
| 567 | pub const EXCL = 0o200; | |
| 568 | pub const NOCTTY = 0o400; | |
| 569 | pub const TRUNC = 0o1000; | |
| 570 | pub const APPEND = 0o2000; | |
| 571 | pub const NONBLOCK = 0o4000; | |
| 572 | pub const DSYNC = 0o10000; | |
| 573 | pub const SYNC = 0o4010000; | |
| 574 | pub const RSYNC = 0o4010000; | |
| 575 | pub const DIRECTORY = 0o40000; | |
| 576 | pub const NOFOLLOW = 0o100000; | |
| 577 | pub const CLOEXEC = 0o2000000; | |
| 578 | ||
| 579 | pub const ASYNC = 0o20000; | |
| 580 | pub const DIRECT = 0o400000; | |
| 581 | pub const LARGEFILE = 0o200000; | |
| 582 | pub const NOATIME = 0o1000000; | |
| 583 | pub const PATH = 0o10000000; | |
| 584 | pub const TMPFILE = 0o20040000; | |
| 585 | pub const NDELAY = NONBLOCK; | |
| 586 | }; | |
| 585 | 587 | |
| 586 | 588 | pub const F = struct { |
| 587 | 589 | pub const DUPFD = 0; |
| ... | ... | @@ -627,11 +629,12 @@ pub const MAP = struct { |
| 627 | 629 | pub const LOCKED = 0x0080; |
| 628 | 630 | /// don't check for reservations |
| 629 | 631 | pub const NORESERVE = 0x0040; |
| 630 | /// Only used by libc to communicate failure. | |
| 631 | pub const FAILED = @intToPtr(*c_void, maxInt(usize)); | |
| 632 | 632 | }; |
| 633 | pub const VDSO_CGT_SYM = "__kernel_clock_gettime"; | |
| 634 | pub const VDSO_CGT_VER = "LINUX_2.6.15"; | |
| 633 | ||
| 634 | pub const VDSO = struct { | |
| 635 | pub const CGT_SYM = "__kernel_clock_gettime"; | |
| 636 | pub const CGT_VER = "LINUX_2.6.15"; | |
| 637 | }; | |
| 635 | 638 | |
| 636 | 639 | pub const Flock = extern struct { |
| 637 | 640 | l_type: i16, |
lib/std/os/linux/powerpc64.zig+26-24| ... | ... | @@ -537,26 +537,28 @@ pub const SYS = enum(usize) { |
| 537 | 537 | _, |
| 538 | 538 | }; |
| 539 | 539 | |
| 540 | pub const O_CREAT = 0o100; | |
| 541 | pub const O_EXCL = 0o200; | |
| 542 | pub const O_NOCTTY = 0o400; | |
| 543 | pub const O_TRUNC = 0o1000; | |
| 544 | pub const O_APPEND = 0o2000; | |
| 545 | pub const O_NONBLOCK = 0o4000; | |
| 546 | pub const O_DSYNC = 0o10000; | |
| 547 | pub const O_SYNC = 0o4010000; | |
| 548 | pub const O_RSYNC = 0o4010000; | |
| 549 | pub const O_DIRECTORY = 0o40000; | |
| 550 | pub const O_NOFOLLOW = 0o100000; | |
| 551 | pub const O_CLOEXEC = 0o2000000; | |
| 552 | ||
| 553 | pub const O_ASYNC = 0o20000; | |
| 554 | pub const O_DIRECT = 0o400000; | |
| 555 | pub const O_LARGEFILE = 0o200000; | |
| 556 | pub const O_NOATIME = 0o1000000; | |
| 557 | pub const O_PATH = 0o10000000; | |
| 558 | pub const O_TMPFILE = 0o20200000; | |
| 559 | pub const O_NDELAY = O_NONBLOCK; | |
| 540 | pub const O = struct { | |
| 541 | pub const CREAT = 0o100; | |
| 542 | pub const EXCL = 0o200; | |
| 543 | pub const NOCTTY = 0o400; | |
| 544 | pub const TRUNC = 0o1000; | |
| 545 | pub const APPEND = 0o2000; | |
| 546 | pub const NONBLOCK = 0o4000; | |
| 547 | pub const DSYNC = 0o10000; | |
| 548 | pub const SYNC = 0o4010000; | |
| 549 | pub const RSYNC = 0o4010000; | |
| 550 | pub const DIRECTORY = 0o40000; | |
| 551 | pub const NOFOLLOW = 0o100000; | |
| 552 | pub const CLOEXEC = 0o2000000; | |
| 553 | ||
| 554 | pub const ASYNC = 0o20000; | |
| 555 | pub const DIRECT = 0o400000; | |
| 556 | pub const LARGEFILE = 0o200000; | |
| 557 | pub const NOATIME = 0o1000000; | |
| 558 | pub const PATH = 0o10000000; | |
| 559 | pub const TMPFILE = 0o20200000; | |
| 560 | pub const NDELAY = NONBLOCK; | |
| 561 | }; | |
| 560 | 562 | |
| 561 | 563 | pub const F = struct { |
| 562 | 564 | pub const DUPFD = 0; |
| ... | ... | @@ -602,12 +604,12 @@ pub const MAP = struct { |
| 602 | 604 | pub const LOCKED = 0x0080; |
| 603 | 605 | /// don't check for reservations |
| 604 | 606 | pub const NORESERVE = 0x0040; |
| 605 | /// Only used by libc to communicate failure. | |
| 606 | pub const FAILED = @intToPtr(*c_void, maxInt(usize)); | |
| 607 | 607 | }; |
| 608 | 608 | |
| 609 | pub const VDSO_CGT_SYM = "__kernel_clock_gettime"; | |
| 610 | pub const VDSO_CGT_VER = "LINUX_2.6.15"; | |
| 609 | pub const VDSO = struct { | |
| 610 | pub const CGT_SYM = "__kernel_clock_gettime"; | |
| 611 | pub const CGT_VER = "LINUX_2.6.15"; | |
| 612 | }; | |
| 611 | 613 | |
| 612 | 614 | pub const Flock = extern struct { |
| 613 | 615 | l_type: i16, |
lib/std/os/linux/riscv64.zig+24-19| ... | ... | @@ -406,26 +406,28 @@ pub const SYS = enum(usize) { |
| 406 | 406 | _, |
| 407 | 407 | }; |
| 408 | 408 | |
| 409 | pub const O_CREAT = 0o100; | |
| 410 | pub const O_EXCL = 0o200; | |
| 411 | pub const O_NOCTTY = 0o400; | |
| 412 | pub const O_TRUNC = 0o1000; | |
| 413 | pub const O_APPEND = 0o2000; | |
| 414 | pub const O_NONBLOCK = 0o4000; | |
| 415 | pub const O_DSYNC = 0o10000; | |
| 416 | pub const O_SYNC = 0o4010000; | |
| 417 | pub const O_RSYNC = 0o4010000; | |
| 418 | pub const O_DIRECTORY = 0o200000; | |
| 419 | pub const O_NOFOLLOW = 0o400000; | |
| 420 | pub const O_CLOEXEC = 0o2000000; | |
| 409 | pub const O = struct { | |
| 410 | pub const CREAT = 0o100; | |
| 411 | pub const EXCL = 0o200; | |
| 412 | pub const NOCTTY = 0o400; | |
| 413 | pub const TRUNC = 0o1000; | |
| 414 | pub const APPEND = 0o2000; | |
| 415 | pub const NONBLOCK = 0o4000; | |
| 416 | pub const DSYNC = 0o10000; | |
| 417 | pub const SYNC = 0o4010000; | |
| 418 | pub const RSYNC = 0o4010000; | |
| 419 | pub const DIRECTORY = 0o200000; | |
| 420 | pub const NOFOLLOW = 0o400000; | |
| 421 | pub const CLOEXEC = 0o2000000; | |
| 421 | 422 | |
| 422 | pub const O_ASYNC = 0o20000; | |
| 423 | pub const O_DIRECT = 0o40000; | |
| 424 | pub const O_LARGEFILE = 0o100000; | |
| 425 | pub const O_NOATIME = 0o1000000; | |
| 426 | pub const O_PATH = 0o10000000; | |
| 427 | pub const O_TMPFILE = 0o20200000; | |
| 428 | pub const O_NDELAY = O_NONBLOCK; | |
| 423 | pub const ASYNC = 0o20000; | |
| 424 | pub const DIRECT = 0o40000; | |
| 425 | pub const LARGEFILE = 0o100000; | |
| 426 | pub const NOATIME = 0o1000000; | |
| 427 | pub const PATH = 0o10000000; | |
| 428 | pub const TMPFILE = 0o20200000; | |
| 429 | pub const NDELAY = NONBLOCK; | |
| 430 | }; | |
| 429 | 431 | |
| 430 | 432 | pub const F = struct { |
| 431 | 433 | pub const DUPFD = 0; |
| ... | ... | @@ -518,3 +520,6 @@ pub const Stat = extern struct { |
| 518 | 520 | }; |
| 519 | 521 | |
| 520 | 522 | pub const Elf_Symndx = u32; |
| 523 | ||
| 524 | pub const VDSO = struct {}; | |
| 525 | pub const MAP = struct {}; |
lib/std/os/linux/sparc64.zig+27-24| ... | ... | @@ -571,26 +571,28 @@ pub const SYS = enum(usize) { |
| 571 | 571 | _, |
| 572 | 572 | }; |
| 573 | 573 | |
| 574 | pub const O_CREAT = 0x200; | |
| 575 | pub const O_EXCL = 0x800; | |
| 576 | pub const O_NOCTTY = 0x8000; | |
| 577 | pub const O_TRUNC = 0x400; | |
| 578 | pub const O_APPEND = 0x8; | |
| 579 | pub const O_NONBLOCK = 0x4000; | |
| 580 | pub const O_SYNC = 0x802000; | |
| 581 | pub const O_DSYNC = 0x2000; | |
| 582 | pub const O_RSYNC = O_SYNC; | |
| 583 | pub const O_DIRECTORY = 0x10000; | |
| 584 | pub const O_NOFOLLOW = 0x20000; | |
| 585 | pub const O_CLOEXEC = 0x400000; | |
| 586 | ||
| 587 | pub const O_ASYNC = 0x40; | |
| 588 | pub const O_DIRECT = 0x100000; | |
| 589 | pub const O_LARGEFILE = 0; | |
| 590 | pub const O_NOATIME = 0x200000; | |
| 591 | pub const O_PATH = 0x1000000; | |
| 592 | pub const O_TMPFILE = 0x2010000; | |
| 593 | pub const O_NDELAY = O_NONBLOCK | 0x4; | |
| 574 | pub const O = struct { | |
| 575 | pub const CREAT = 0x200; | |
| 576 | pub const EXCL = 0x800; | |
| 577 | pub const NOCTTY = 0x8000; | |
| 578 | pub const TRUNC = 0x400; | |
| 579 | pub const APPEND = 0x8; | |
| 580 | pub const NONBLOCK = 0x4000; | |
| 581 | pub const SYNC = 0x802000; | |
| 582 | pub const DSYNC = 0x2000; | |
| 583 | pub const RSYNC = SYNC; | |
| 584 | pub const DIRECTORY = 0x10000; | |
| 585 | pub const NOFOLLOW = 0x20000; | |
| 586 | pub const CLOEXEC = 0x400000; | |
| 587 | ||
| 588 | pub const ASYNC = 0x40; | |
| 589 | pub const DIRECT = 0x100000; | |
| 590 | pub const LARGEFILE = 0; | |
| 591 | pub const NOATIME = 0x200000; | |
| 592 | pub const PATH = 0x1000000; | |
| 593 | pub const TMPFILE = 0x2010000; | |
| 594 | pub const NDELAY = NONBLOCK | 0x4; | |
| 595 | }; | |
| 594 | 596 | |
| 595 | 597 | pub const F = struct { |
| 596 | 598 | pub const DUPFD = 0; |
| ... | ... | @@ -633,11 +635,12 @@ pub const MAP = struct { |
| 633 | 635 | pub const LOCKED = 0x0100; |
| 634 | 636 | /// don't check for reservations |
| 635 | 637 | pub const NORESERVE = 0x0040; |
| 636 | /// Only used by libc to communicate failure. | |
| 637 | pub const FAILED = @intToPtr(*c_void, maxInt(usize)); | |
| 638 | 638 | }; |
| 639 | pub const VDSO_CGT_SYM = "__vdso_clock_gettime"; | |
| 640 | pub const VDSO_CGT_VER = "LINUX_2.6"; | |
| 639 | ||
| 640 | pub const VDSO = struct { | |
| 641 | pub const CGT_SYM = "__vdso_clock_gettime"; | |
| 642 | pub const CGT_VER = "LINUX_2.6"; | |
| 643 | }; | |
| 641 | 644 | |
| 642 | 645 | pub const Flock = extern struct { |
| 643 | 646 | l_type: i16, |
lib/std/os/linux/x86_64.zig-32| ... | ... | @@ -476,10 +476,6 @@ pub const SYS = enum(usize) { |
| 476 | 476 | }; |
| 477 | 477 | |
| 478 | 478 | pub const O = struct { |
| 479 | pub const RDONLY = 0o0; | |
| 480 | pub const WRONLY = 0o1; | |
| 481 | pub const RDWR = 0o2; | |
| 482 | ||
| 483 | 479 | pub const CREAT = 0o100; |
| 484 | 480 | pub const EXCL = 0o200; |
| 485 | 481 | pub const NOCTTY = 0o400; |
| ... | ... | @@ -526,32 +522,6 @@ pub const F = struct { |
| 526 | 522 | }; |
| 527 | 523 | |
| 528 | 524 | pub const MAP = struct { |
| 529 | /// Share changes | |
| 530 | pub const SHARED = 0x01; | |
| 531 | /// Changes are private | |
| 532 | pub const PRIVATE = 0x02; | |
| 533 | /// share + validate extension flags | |
| 534 | pub const SHARED_VALIDATE = 0x03; | |
| 535 | /// Mask for type of mapping | |
| 536 | pub const TYPE = 0x0f; | |
| 537 | /// Interpret addr exactly | |
| 538 | pub const FIXED = 0x10; | |
| 539 | /// don't use a file | |
| 540 | pub const ANONYMOUS = 0x20; | |
| 541 | /// populate (prefault) pagetables | |
| 542 | pub const POPULATE = 0x8000; | |
| 543 | /// do not block on IO | |
| 544 | pub const NONBLOCK = 0x10000; | |
| 545 | /// give out an address that is best suited for process/thread stacks | |
| 546 | pub const STACK = 0x20000; | |
| 547 | /// create a huge page mapping | |
| 548 | pub const HUGETLB = 0x40000; | |
| 549 | /// perform synchronous page faults for the mapping | |
| 550 | pub const SYNC = 0x80000; | |
| 551 | /// FIXED which doesn't unmap underlying mapping | |
| 552 | pub const FIXED_NOREPLACE = 0x100000; | |
| 553 | /// For anonymous mmap, memory could be uninitialized | |
| 554 | pub const UNINITIALIZED = 0x4000000; | |
| 555 | 525 | /// only give out 32bit addresses |
| 556 | 526 | pub const @"32BIT" = 0x40; |
| 557 | 527 | /// stack-like segment |
| ... | ... | @@ -564,8 +534,6 @@ pub const MAP = struct { |
| 564 | 534 | pub const LOCKED = 0x2000; |
| 565 | 535 | /// don't check for reservations |
| 566 | 536 | pub const NORESERVE = 0x4000; |
| 567 | /// Only used by libc to communicate failure. | |
| 568 | pub const FAILED = @intToPtr(*c_void, maxInt(usize)); | |
| 569 | 537 | }; |
| 570 | 538 | |
| 571 | 539 | pub const VDSO = struct { |
lib/std/os/test.zig+2-2| ... | ... | @@ -401,7 +401,7 @@ test "sigaltstack" { |
| 401 | 401 | |
| 402 | 402 | // If the type is not available use void to avoid erroring out when `iter_fn` is |
| 403 | 403 | // analyzed |
| 404 | const dl_phdr_info = if (@hasDecl(os, "dl_phdr_info")) os.dl_phdr_info else c_void; | |
| 404 | const dl_phdr_info = if (@hasDecl(os.system, "dl_phdr_info")) os.dl_phdr_info else c_void; | |
| 405 | 405 | |
| 406 | 406 | const IterFnError = error{ |
| 407 | 407 | MissingPtLoadSegment, |
| ... | ... | @@ -676,7 +676,7 @@ test "fsync" { |
| 676 | 676 | } |
| 677 | 677 | |
| 678 | 678 | test "getrlimit and setrlimit" { |
| 679 | if (native_os == .windows) { | |
| 679 | if (!@hasDecl(os.system, "rlimit")) { | |
| 680 | 680 | return error.SkipZigTest; |
| 681 | 681 | } |
| 682 | 682 |
lib/std/os/wasi.zig+2| ... | ... | @@ -337,6 +337,7 @@ pub const filestat_t = extern struct { |
| 337 | 337 | } |
| 338 | 338 | }; |
| 339 | 339 | |
| 340 | /// Also known as `FILETYPE`. | |
| 340 | 341 | pub const filetype_t = enum(u8) { |
| 341 | 342 | UNKNOWN, |
| 342 | 343 | BLOCK_DEVICE, |
| ... | ... | @@ -532,6 +533,7 @@ pub const timestamp_t = u64; |
| 532 | 533 | |
| 533 | 534 | pub const userdata_t = u64; |
| 534 | 535 | |
| 536 | /// Also known as `WHENCE`. | |
| 535 | 537 | pub const whence_t = enum(u8) { SET, CUR, END }; |
| 536 | 538 | |
| 537 | 539 | pub const S = struct { |
lib/std/os/windows.zig+1-1| ... | ... | @@ -3192,7 +3192,7 @@ pub usingnamespace switch (native_arch) { |
| 3192 | 3192 | |
| 3193 | 3193 | pub const EXCEPTION_POINTERS = extern struct { |
| 3194 | 3194 | ExceptionRecord: *EXCEPTION_RECORD, |
| 3195 | ContextRecord: *@This().CONTEXT, | |
| 3195 | ContextRecord: *std.os.windows.CONTEXT, | |
| 3196 | 3196 | }; |
| 3197 | 3197 | |
| 3198 | 3198 | pub const VECTORED_EXCEPTION_HANDLER = fn (ExceptionInfo: *EXCEPTION_POINTERS) callconv(WINAPI) c_long; |
lib/std/special/ssp.zig+1-3| ... | ... | @@ -25,9 +25,7 @@ pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn |
| 25 | 25 | _ = msg; |
| 26 | 26 | _ = error_return_trace; |
| 27 | 27 | @setCold(true); |
| 28 | if (@hasDecl(std.os, "abort")) | |
| 29 | std.os.abort(); | |
| 30 | while (true) {} | |
| 28 | std.os.abort(); | |
| 31 | 29 | } |
| 32 | 30 | |
| 33 | 31 | export fn __stack_chk_fail() callconv(.C) noreturn { |
lib/std/start.zig+1-1| ... | ... | @@ -345,7 +345,7 @@ fn posixCallMainAndExit() noreturn { |
| 345 | 345 | // FIXME: Elide the check for targets >= ARMv7 when the target feature API |
| 346 | 346 | // becomes less verbose (and more usable). |
| 347 | 347 | if (comptime native_arch.isARM()) { |
| 348 | if (at_hwcap & std.os.linux.HWCAP_TLS == 0) { | |
| 348 | if (at_hwcap & std.os.linux.HWCAP.TLS == 0) { | |
| 349 | 349 | // FIXME: Make __aeabi_read_tp call the kernel helper kuser_get_tls |
| 350 | 350 | // For the time being use a simple abort instead of a @panic call to |
| 351 | 351 | // keep the binary bloat under control. |
lib/std/x/net/tcp.zig+3-3| ... | ... | @@ -193,7 +193,7 @@ pub const Client = struct { |
| 193 | 193 | /// Disable Nagle's algorithm on a TCP socket. It returns `error.UnsupportedSocketOption` if |
| 194 | 194 | /// the host does not support sockets disabling Nagle's algorithm. |
| 195 | 195 | pub fn setNoDelay(self: Client, enabled: bool) !void { |
| 196 | if (comptime @hasDecl(os, "TCP_NODELAY")) { | |
| 196 | if (@hasDecl(os.TCP, "NODELAY")) { | |
| 197 | 197 | const bytes = mem.asBytes(&@as(usize, @boolToInt(enabled))); |
| 198 | 198 | return self.socket.setOption(os.IPPROTO.TCP, os.TCP_NODELAY, bytes); |
| 199 | 199 | } |
| ... | ... | @@ -203,7 +203,7 @@ pub const Client = struct { |
| 203 | 203 | /// Enables TCP Quick ACK on a TCP socket to immediately send rather than delay ACKs when necessary. It returns |
| 204 | 204 | /// `error.UnsupportedSocketOption` if the host does not support TCP Quick ACK. |
| 205 | 205 | pub fn setQuickACK(self: Client, enabled: bool) !void { |
| 206 | if (comptime @hasDecl(os, "TCP_QUICKACK")) { | |
| 206 | if (@hasDecl(os.TCP, "QUICKACK")) { | |
| 207 | 207 | return self.socket.setOption(os.IPPROTO.TCP, os.TCP_QUICKACK, mem.asBytes(&@as(u32, @boolToInt(enabled)))); |
| 208 | 208 | } |
| 209 | 209 | return error.UnsupportedSocketOption; |
| ... | ... | @@ -304,7 +304,7 @@ pub const Listener = struct { |
| 304 | 304 | /// Enables TCP Fast Open (RFC 7413) on a TCP socket. It returns `error.UnsupportedSocketOption` if the host does not |
| 305 | 305 | /// support TCP Fast Open. |
| 306 | 306 | pub fn setFastOpen(self: Listener, enabled: bool) !void { |
| 307 | if (comptime @hasDecl(os, "TCP_FASTOPEN")) { | |
| 307 | if (@hasDecl(os.TCP, "FASTOPEN")) { | |
| 308 | 308 | return self.socket.setOption(os.IPPROTO.TCP, os.TCP_FASTOPEN, mem.asBytes(&@as(u32, @boolToInt(enabled)))); |
| 309 | 309 | } |
| 310 | 310 | return error.UnsupportedSocketOption; |
lib/std/x/os/net.zig+3-2| ... | ... | @@ -6,12 +6,13 @@ const mem = std.mem; |
| 6 | 6 | const math = std.math; |
| 7 | 7 | const testing = std.testing; |
| 8 | 8 | const native_os = std.Target.current.os; |
| 9 | const have_ifnamesize = @hasDecl(os.system, "IFNAMESIZE"); | |
| 9 | 10 | |
| 10 | 11 | /// Resolves a network interface name into a scope/zone ID. It returns |
| 11 | 12 | /// an error if either resolution fails, or if the interface name is |
| 12 | 13 | /// too long. |
| 13 | 14 | pub fn resolveScopeID(name: []const u8) !u32 { |
| 14 | if (@hasDecl(os, "IFNAMESIZE")) { | |
| 15 | if (have_ifnamesize) { | |
| 15 | 16 | if (name.len >= os.IFNAMESIZE - 1) return error.NameTooLong; |
| 16 | 17 | |
| 17 | 18 | if (native_os.tag == .windows) { |
| ... | ... | @@ -556,7 +557,7 @@ test "ipv6: parse & format" { |
| 556 | 557 | } |
| 557 | 558 | |
| 558 | 559 | test "ipv6: parse & format addresses with scope ids" { |
| 559 | if (!@hasDecl(os, "IFNAMESIZE")) return error.SkipZigTest; | |
| 560 | if (!have_ifnamesize) return error.SkipZigTest; | |
| 560 | 561 | |
| 561 | 562 | const inputs = [_][]const u8{ |
| 562 | 563 | "FF01::FB%lo", |
test/behavior/usingnamespace/a.zig created+7| ... | ... | @@ -0,0 +1,7 @@ |
| 1 | usingnamespace @import("b.zig"); | |
| 2 | ||
| 3 | pub const a_text = "OK\n"; | |
| 4 | ||
| 5 | pub fn ok() bool { | |
| 6 | return @import("std").mem.eql(u8, @This().b_text, "OK\n"); | |
| 7 | } |
test/behavior/usingnamespace/b.zig created+3| ... | ... | @@ -0,0 +1,3 @@ |
| 1 | usingnamespace @import("a.zig"); | |
| 2 | ||
| 3 | pub const b_text = @This().a_text; |
test/behavior/usingnamespace/bar.zig created+8| ... | ... | @@ -0,0 +1,8 @@ |
| 1 | usingnamespace @import("other.zig"); | |
| 2 | ||
| 3 | pub var saw_bar_function = false; | |
| 4 | pub fn bar_function() void { | |
| 5 | if (@This().foo_function()) { | |
| 6 | saw_bar_function = true; | |
| 7 | } | |
| 8 | } |
test/behavior/usingnamespace/foo.zig created+14| ... | ... | @@ -0,0 +1,14 @@ |
| 1 | // purposefully conflicting function with main source file | |
| 2 | // but it's private so it should be OK | |
| 3 | fn privateFunction() bool { | |
| 4 | return false; | |
| 5 | } | |
| 6 | ||
| 7 | pub fn printText() bool { | |
| 8 | return privateFunction(); | |
| 9 | } | |
| 10 | ||
| 11 | pub var saw_foo_function = false; | |
| 12 | pub fn foo_function() void { | |
| 13 | saw_foo_function = true; | |
| 14 | } |
test/behavior/usingnamespace/import_segregation.zig created+11| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | const expect = @import("std").testing.expect; | |
| 2 | ||
| 3 | usingnamespace @import("foo.zig"); | |
| 4 | usingnamespace @import("bar.zig"); | |
| 5 | ||
| 6 | test "no clobbering happened" { | |
| 7 | @This().foo_function(); | |
| 8 | @This().bar_function(); | |
| 9 | try expect(@This().saw_foo_function); | |
| 10 | try expect(@This().saw_bar_function); | |
| 11 | } |
test/behavior/usingnamespace/other.zig created+4| ... | ... | @@ -0,0 +1,4 @@ |
| 1 | pub fn foo_function() bool { | |
| 2 | // this one conflicts with the one from foo | |
| 3 | return true; | |
| 4 | } |
test/behavior/usingnamespace_stage1.zig+19| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const expect = std.testing.expect; | |
| 2 | 3 | |
| 3 | 4 | fn Foo(comptime T: type) type { |
| 4 | 5 | return struct { |
| ... | ... | @@ -20,3 +21,21 @@ usingnamespace struct { |
| 20 | 21 | test "usingnamespace does not redeclare an imported variable" { |
| 21 | 22 | comptime try std.testing.expect(@This().foo == 42); |
| 22 | 23 | } |
| 24 | ||
| 25 | usingnamespace @import("usingnamespace/foo.zig"); | |
| 26 | test "usingnamespace omits mixing in private functions" { | |
| 27 | try expect(@This().privateFunction()); | |
| 28 | try expect(!@This().printText()); | |
| 29 | } | |
| 30 | fn privateFunction() bool { | |
| 31 | return true; | |
| 32 | } | |
| 33 | ||
| 34 | test { | |
| 35 | _ = @import("usingnamespace/import_segregation.zig"); | |
| 36 | } | |
| 37 | ||
| 38 | usingnamespace @import("usingnamespace/a.zig"); | |
| 39 | test "two files usingnamespace import each other" { | |
| 40 | try expect(@This().ok()); | |
| 41 | } |
test/cases.zig+7-7| ... | ... | @@ -1073,37 +1073,37 @@ pub fn addCases(ctx: *TestContext) !void { |
| 1073 | 1073 | case.addError( |
| 1074 | 1074 | \\pub fn main() void { |
| 1075 | 1075 | \\ var i = 0; |
| 1076 | \\ for (n) |_, i| { | |
| 1076 | \\ for ("n") |_, i| { | |
| 1077 | 1077 | \\ } |
| 1078 | 1078 | \\} |
| 1079 | 1079 | , &[_][]const u8{ |
| 1080 | ":3:17: error: redeclaration of local variable 'i'", | |
| 1080 | ":3:19: error: redeclaration of local variable 'i'", | |
| 1081 | 1081 | ":2:9: note: previous declaration here", |
| 1082 | 1082 | }); |
| 1083 | 1083 | case.addError( |
| 1084 | 1084 | \\pub fn main() void { |
| 1085 | 1085 | \\ var i = 0; |
| 1086 | \\ for (n) |i| { | |
| 1086 | \\ for ("n") |i| { | |
| 1087 | 1087 | \\ } |
| 1088 | 1088 | \\} |
| 1089 | 1089 | , &[_][]const u8{ |
| 1090 | ":3:14: error: redeclaration of local variable 'i'", | |
| 1090 | ":3:16: error: redeclaration of local variable 'i'", | |
| 1091 | 1091 | ":2:9: note: previous declaration here", |
| 1092 | 1092 | }); |
| 1093 | 1093 | case.addError( |
| 1094 | 1094 | \\pub fn main() void { |
| 1095 | 1095 | \\ var i = 0; |
| 1096 | \\ while (n) |i| { | |
| 1096 | \\ while ("n") |i| { | |
| 1097 | 1097 | \\ } |
| 1098 | 1098 | \\} |
| 1099 | 1099 | , &[_][]const u8{ |
| 1100 | ":3:16: error: redeclaration of local variable 'i'", | |
| 1100 | ":3:18: error: redeclaration of local variable 'i'", | |
| 1101 | 1101 | ":2:9: note: previous declaration here", |
| 1102 | 1102 | }); |
| 1103 | 1103 | case.addError( |
| 1104 | 1104 | \\pub fn main() void { |
| 1105 | 1105 | \\ var i = 0; |
| 1106 | \\ while (n) |bruh| { | |
| 1106 | \\ while ("n") |bruh| { | |
| 1107 | 1107 | \\ _ = bruh; |
| 1108 | 1108 | \\ } else |i| { |
| 1109 | 1109 | \\ |
test/cli.zig-7| ... | ... | @@ -45,13 +45,6 @@ pub fn main() !void { |
| 45 | 45 | } |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | fn unwrapArg(arg: UnwrapArgError![]u8) UnwrapArgError![]u8 { | |
| 49 | return arg catch |err| { | |
| 50 | warn("Unable to parse command line: {}\n", .{err}); | |
| 51 | return err; | |
| 52 | }; | |
| 53 | } | |
| 54 | ||
| 55 | 48 | fn printCmd(cwd: []const u8, argv: []const []const u8) void { |
| 56 | 49 | std.debug.warn("cd {s} && ", .{cwd}); |
| 57 | 50 | for (argv) |arg| { |
test/compare_output.zig-105| ... | ... | @@ -17,111 +17,6 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 17 | 17 | \\} |
| 18 | 18 | , "Hello, world!" ++ std.cstr.line_sep); |
| 19 | 19 | |
| 20 | cases.addCase(x: { | |
| 21 | var tc = cases.create("multiple files with private function", | |
| 22 | \\usingnamespace @import("std").io; | |
| 23 | \\usingnamespace @import("foo.zig"); | |
| 24 | \\ | |
| 25 | \\pub fn main() void { | |
| 26 | \\ privateFunction(); | |
| 27 | \\ const stdout = getStdOut().writer(); | |
| 28 | \\ stdout.print("OK 2\n", .{}) catch unreachable; | |
| 29 | \\} | |
| 30 | \\ | |
| 31 | \\fn privateFunction() void { | |
| 32 | \\ printText(); | |
| 33 | \\} | |
| 34 | , "OK 1\nOK 2\n"); | |
| 35 | ||
| 36 | tc.addSourceFile("foo.zig", | |
| 37 | \\usingnamespace @import("std").io; | |
| 38 | \\ | |
| 39 | \\// purposefully conflicting function with main.zig | |
| 40 | \\// but it's private so it should be OK | |
| 41 | \\fn privateFunction() void { | |
| 42 | \\ const stdout = getStdOut().writer(); | |
| 43 | \\ stdout.print("OK 1\n", .{}) catch unreachable; | |
| 44 | \\} | |
| 45 | \\ | |
| 46 | \\pub fn printText() void { | |
| 47 | \\ privateFunction(); | |
| 48 | \\} | |
| 49 | ); | |
| 50 | ||
| 51 | break :x tc; | |
| 52 | }); | |
| 53 | ||
| 54 | cases.addCase(x: { | |
| 55 | var tc = cases.create("import segregation", | |
| 56 | \\usingnamespace @import("foo.zig"); | |
| 57 | \\usingnamespace @import("bar.zig"); | |
| 58 | \\ | |
| 59 | \\pub fn main() void { | |
| 60 | \\ foo_function(); | |
| 61 | \\ bar_function(); | |
| 62 | \\} | |
| 63 | , "OK\nOK\n"); | |
| 64 | ||
| 65 | tc.addSourceFile("foo.zig", | |
| 66 | \\usingnamespace @import("std").io; | |
| 67 | \\pub fn foo_function() void { | |
| 68 | \\ const stdout = getStdOut().writer(); | |
| 69 | \\ stdout.print("OK\n", .{}) catch unreachable; | |
| 70 | \\} | |
| 71 | ); | |
| 72 | ||
| 73 | tc.addSourceFile("bar.zig", | |
| 74 | \\usingnamespace @import("other.zig"); | |
| 75 | \\usingnamespace @import("std").io; | |
| 76 | \\ | |
| 77 | \\pub fn bar_function() void { | |
| 78 | \\ if (foo_function()) { | |
| 79 | \\ const stdout = getStdOut().writer(); | |
| 80 | \\ stdout.print("OK\n", .{}) catch unreachable; | |
| 81 | \\ } | |
| 82 | \\} | |
| 83 | ); | |
| 84 | ||
| 85 | tc.addSourceFile("other.zig", | |
| 86 | \\pub fn foo_function() bool { | |
| 87 | \\ // this one conflicts with the one from foo | |
| 88 | \\ return true; | |
| 89 | \\} | |
| 90 | ); | |
| 91 | ||
| 92 | break :x tc; | |
| 93 | }); | |
| 94 | ||
| 95 | cases.addCase(x: { | |
| 96 | var tc = cases.create("two files usingnamespace import each other", | |
| 97 | \\usingnamespace @import("a.zig"); | |
| 98 | \\ | |
| 99 | \\pub fn main() void { | |
| 100 | \\ ok(); | |
| 101 | \\} | |
| 102 | , "OK\n"); | |
| 103 | ||
| 104 | tc.addSourceFile("a.zig", | |
| 105 | \\usingnamespace @import("b.zig"); | |
| 106 | \\const io = @import("std").io; | |
| 107 | \\ | |
| 108 | \\pub const a_text = "OK\n"; | |
| 109 | \\ | |
| 110 | \\pub fn ok() void { | |
| 111 | \\ const stdout = io.getStdOut().writer(); | |
| 112 | \\ stdout.print(b_text, .{}) catch unreachable; | |
| 113 | \\} | |
| 114 | ); | |
| 115 | ||
| 116 | tc.addSourceFile("b.zig", | |
| 117 | \\usingnamespace @import("a.zig"); | |
| 118 | \\ | |
| 119 | \\pub const b_text = a_text; | |
| 120 | ); | |
| 121 | ||
| 122 | break :x tc; | |
| 123 | }); | |
| 124 | ||
| 125 | 20 | cases.add("hello world without libc", |
| 126 | 21 | \\const io = @import("std").io; |
| 127 | 22 | \\ |
test/standalone/brace_expansion/main.zig+1-1| ... | ... | @@ -234,7 +234,7 @@ pub fn main() !void { |
| 234 | 234 | var result_buf = ArrayList(u8).init(global_allocator); |
| 235 | 235 | defer result_buf.deinit(); |
| 236 | 236 | |
| 237 | try expandString(stdin_buf.items, &result_buf); | |
| 237 | try expandString(stdin.items, &result_buf); | |
| 238 | 238 | try stdout_file.write(result_buf.items); |
| 239 | 239 | } |
| 240 | 240 |