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