authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-08-30 22:02:34-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-09-01 17:54:07-07:00
logcca57042df374305390b5b0000be75ba6d24fb63
tree5ccbc45ec714b1696bed58688a9b4a801e83eac9
parent3940a1be18a8312dec9d521c6e30ec4d34c44bd6

std: fix regressions from this branch

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};
5959
60pub usingnamespace switch (builtin.os.tag) {60pub 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 {
395pub const sigset_t = u32;395pub const sigset_t = u32;
396pub const empty_sigset: sigset_t = 0;396pub const empty_sigset: sigset_t = 0;
397397
398pub const SIG_ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize));398pub const SIG = struct {
399pub const SIG_DFL = @intToPtr(?Sigaction.sigaction_fn, 0);399 pub const ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize));
400pub const SIG_IGN = @intToPtr(?Sigaction.sigaction_fn, 1);400 pub const DFL = @intToPtr(?Sigaction.sigaction_fn, 0);
401pub 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};
402477
403pub const siginfo_t = extern struct {478pub 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;
507pub const STDOUT_FILENO = 1;582pub const STDOUT_FILENO = 1;
508pub const STDERR_FILENO = 2;583pub const STDERR_FILENO = 2;
509584
510/// [MC2] no permissions585pub const PROT = struct {
511pub const PROT_NONE = 0x00;586 /// [MC2] no permissions
512587 pub const NONE = 0x00;
513/// [MC2] pages can be read588 /// [MC2] pages can be read
514pub const PROT_READ = 0x01;589 pub const READ = 0x01;
515590 /// [MC2] pages can be written
516/// [MC2] pages can be written591 pub const WRITE = 0x02;
517pub const PROT_WRITE = 0x02;592 /// [MC2] pages can be executed
518593 pub const EXEC = 0x04;
519/// [MC2] pages can be executed594};
520pub const PROT_EXEC = 0x04;
521595
522pub const MAP = struct {596pub const MAP = struct {
523 /// allocated from memory, swap space597 /// 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 return625/// restart system on signal return
552pub const SA_RESTART = 0x0002;626pub const SA_RESTART = 0x0002;
553627
554/// reset to SIG_DFL when taking signal628/// reset to SIG.DFL when taking signal
555pub const SA_RESETHAND = 0x0004;629pub const SA_RESETHAND = 0x0004;
556630
557/// do not generate SIGCHLD on child stop631/// do not generate SIG.CHLD on child stop
558pub const SA_NOCLDSTOP = 0x0008;632pub const SA_NOCLDSTOP = 0x0008;
559633
560/// don't mask the signal we're delivering634/// 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 information646/// signal handler with SA_SIGINFO args with 64bit regs information
573pub const SA_64REGSET = 0x0200;647pub const SA_64REGSET = 0x0200;
574648
575pub const O_PATH = 0x0000;
576
577pub const F_OK = 0;649pub const F_OK = 0;
578pub const X_OK = 1;650pub const X_OK = 1;
579pub const W_OK = 2;651pub const W_OK = 2;
580pub const R_OK = 4;652pub const R_OK = 4;
581653
582/// open for reading only654pub const O = struct {
583pub const O_RDONLY = 0x0000;655 pub const PATH = 0x0000;
584656 /// open for reading only
585/// open for writing only657 pub const RDONLY = 0x0000;
586pub const O_WRONLY = 0x0001;658 /// open for writing only
587659 pub const WRONLY = 0x0001;
588/// open for reading and writing660 /// open for reading and writing
589pub const O_RDWR = 0x0002;661 pub const RDWR = 0x0002;
590662 /// do not block on open or for data to become available
591/// do not block on open or for data to become available663 pub const NONBLOCK = 0x0004;
592pub const O_NONBLOCK = 0x0004;664 /// append on each write
593665 pub const APPEND = 0x0008;
594/// append on each write666 /// create file if it does not exist
595pub const O_APPEND = 0x0008;667 pub const CREAT = 0x0200;
596668 /// truncate size to 0
597/// create file if it does not exist669 pub const TRUNC = 0x0400;
598pub const O_CREAT = 0x0200;670 /// error if CREAT and the file exists
599671 pub const EXCL = 0x0800;
600/// truncate size to 0672 /// atomically obtain a shared lock
601pub const O_TRUNC = 0x0400;673 pub const SHLOCK = 0x0010;
602674 /// atomically obtain an exclusive lock
603/// error if O_CREAT and the file exists675 pub const EXLOCK = 0x0020;
604pub const O_EXCL = 0x0800;676 /// do not follow symlinks
605677 pub const NOFOLLOW = 0x0100;
606/// atomically obtain a shared lock678 /// allow open of symlinks
607pub const O_SHLOCK = 0x0010;679 pub const SYMLINK = 0x200000;
608680 /// descriptor requested for event notifications only
609/// atomically obtain an exclusive lock681 pub const EVTONLY = 0x8000;
610pub const O_EXLOCK = 0x0020;682 /// mark as close-on-exec
611683 pub const CLOEXEC = 0x1000000;
612/// do not follow symlinks684 pub const ACCMODE = 3;
613pub const O_NOFOLLOW = 0x0100;685 pub const ALERT = 536870912;
614686 pub const ASYNC = 64;
615/// allow open of symlinks687 pub const DIRECTORY = 1048576;
616pub const O_SYMLINK = 0x200000;688 pub const DP_GETRAWENCRYPTED = 1;
617689 pub const DP_GETRAWUNENCRYPTED = 2;
618/// descriptor requested for event notifications only690 pub const DSYNC = 4194304;
619pub const O_EVTONLY = 0x8000;691 pub const FSYNC = SYNC;
620692 pub const NOCTTY = 131072;
621/// mark as close-on-exec693 pub const POPUP = 2147483648;
622pub const O_CLOEXEC = 0x1000000;694 pub const SYNC = 128;
623695};
624pub const O_ACCMODE = 3;
625pub const O_ALERT = 536870912;
626pub const O_ASYNC = 64;
627pub const O_DIRECTORY = 1048576;
628pub const O_DP_GETRAWENCRYPTED = 1;
629pub const O_DP_GETRAWUNENCRYPTED = 2;
630pub const O_DSYNC = 4194304;
631pub const O_FSYNC = O_SYNC;
632pub const O_NOCTTY = 131072;
633pub const O_POPUP = 2147483648;
634pub const O_SYNC = 128;
635696
636pub const SEEK_SET = 0x0;697pub const SEEK_SET = 0x0;
637pub const SEEK_CUR = 0x1;698pub const SEEK_CUR = 0x1;
...@@ -647,114 +708,6 @@ pub const DT_LNK = 10;...@@ -647,114 +708,6 @@ pub const DT_LNK = 10;
647pub const DT_SOCK = 12;708pub const DT_SOCK = 12;
648pub const DT_WHT = 14;709pub const DT_WHT = 14;
649710
650/// block specified signal set
651pub const SIG_BLOCK = 1;
652
653/// unblock specified signal set
654pub const SIG_UNBLOCK = 2;
655
656/// set specified signal set
657pub const SIG_SETMASK = 3;
658
659/// hangup
660pub const SIGHUP = 1;
661
662/// interrupt
663pub const SIGINT = 2;
664
665/// quit
666pub const SIGQUIT = 3;
667
668/// illegal instruction (not reset when caught)
669pub const SIGILL = 4;
670
671/// trace trap (not reset when caught)
672pub const SIGTRAP = 5;
673
674/// abort()
675pub const SIGABRT = 6;
676
677/// pollable event ([XSR] generated, not supported)
678pub const SIGPOLL = 7;
679
680/// compatibility
681pub const SIGIOT = SIGABRT;
682
683/// EMT instruction
684pub const SIGEMT = 7;
685
686/// floating point exception
687pub const SIGFPE = 8;
688
689/// kill (cannot be caught or ignored)
690pub const SIGKILL = 9;
691
692/// bus error
693pub const SIGBUS = 10;
694
695/// segmentation violation
696pub const SIGSEGV = 11;
697
698/// bad argument to system call
699pub const SIGSYS = 12;
700
701/// write on a pipe with no one to read it
702pub const SIGPIPE = 13;
703
704/// alarm clock
705pub const SIGALRM = 14;
706
707/// software termination signal from kill
708pub const SIGTERM = 15;
709
710/// urgent condition on IO channel
711pub const SIGURG = 16;
712
713/// sendable stop signal not from tty
714pub const SIGSTOP = 17;
715
716/// stop signal from tty
717pub const SIGTSTP = 18;
718
719/// continue a stopped process
720pub const SIGCONT = 19;
721
722/// to parent on child stop or exit
723pub const SIGCHLD = 20;
724
725/// to readers pgrp upon background tty read
726pub const SIGTTIN = 21;
727
728/// like TTIN for output if (tp->t_local&LTOSTOP)
729pub const SIGTTOU = 22;
730
731/// input/output possible signal
732pub const SIGIO = 23;
733
734/// exceeded CPU time limit
735pub const SIGXCPU = 24;
736
737/// exceeded file size limit
738pub const SIGXFSZ = 25;
739
740/// virtual time alarm
741pub const SIGVTALRM = 26;
742
743/// profiling time alarm
744pub const SIGPROF = 27;
745
746/// window size changes
747pub const SIGWINCH = 28;
748
749/// information request
750pub const SIGINFO = 29;
751
752/// user defined signal 1
753pub const SIGUSR1 = 30;
754
755/// user defined signal 2
756pub const SIGUSR2 = 31;
757
758/// no flag value711/// no flag value
759pub const KEVENT_FLAG_NONE = 0x000;712pub const KEVENT_FLAG_NONE = 0x000;
760713
...@@ -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};
11181071
1119fn wstatus(x: u32) u32 {1072pub const W = struct {
1120 return x & 0o177;1073 pub fn EXITSTATUS(x: u32) u8 {
1121}1074 return @intCast(u8, x >> 8);
1122const wstopped = 0o177;1075 }
1123pub fn WEXITSTATUS(x: u32) u8 {1076 pub fn TERMSIG(x: u32) u32 {
1124 return @intCast(u8, x >> 8);1077 return status(x);
1125}1078 }
1126pub fn WTERMSIG(x: u32) u32 {1079 pub fn STOPSIG(x: u32) u32 {
1127 return wstatus(x);1080 return x >> 8;
1128}1081 }
1129pub fn WSTOPSIG(x: u32) u32 {1082 pub fn IFEXITED(x: u32) bool {
1130 return x >> 8;1083 return status(x) == 0;
1131}1084 }
1132pub 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 }
1135pub 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 }
1138pub 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};
11411097
1142pub const E = enum(u16) {1098pub 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};
14901446
1491pub const S_IFMT = 0o170000;1447pub const S = struct {
14921448 pub const IFMT = 0o170000;
1493pub const S_IFIFO = 0o010000;1449
1494pub const S_IFCHR = 0o020000;1450 pub const IFIFO = 0o010000;
1495pub const S_IFDIR = 0o040000;1451 pub const IFCHR = 0o020000;
1496pub const S_IFBLK = 0o060000;1452 pub const IFDIR = 0o040000;
1497pub const S_IFREG = 0o100000;1453 pub const IFBLK = 0o060000;
1498pub const S_IFLNK = 0o120000;1454 pub const IFREG = 0o100000;
1499pub const S_IFSOCK = 0o140000;1455 pub const IFLNK = 0o120000;
1500pub const S_IFWHT = 0o160000;1456 pub const IFSOCK = 0o140000;
15011457 pub const IFWHT = 0o160000;
1502pub const S_ISUID = 0o4000;1458
1503pub const S_ISGID = 0o2000;1459 pub const ISUID = 0o4000;
1504pub const S_ISVTX = 0o1000;1460 pub const ISGID = 0o2000;
1505pub const S_IRWXU = 0o700;1461 pub const ISVTX = 0o1000;
1506pub const S_IRUSR = 0o400;1462 pub const IRWXU = 0o700;
1507pub const S_IWUSR = 0o200;1463 pub const IRUSR = 0o400;
1508pub const S_IXUSR = 0o100;1464 pub const IWUSR = 0o200;
1509pub const S_IRWXG = 0o070;1465 pub const IXUSR = 0o100;
1510pub const S_IRGRP = 0o040;1466 pub const IRWXG = 0o070;
1511pub const S_IWGRP = 0o020;1467 pub const IRGRP = 0o040;
1512pub const S_IXGRP = 0o010;1468 pub const IWGRP = 0o020;
1513pub const S_IRWXO = 0o007;1469 pub const IXGRP = 0o010;
1514pub const S_IROTH = 0o004;1470 pub const IRWXO = 0o007;
1515pub const S_IWOTH = 0o002;1471 pub const IROTH = 0o004;
1516pub const S_IXOTH = 0o001;1472 pub const IWOTH = 0o002;
15171473 pub const IXOTH = 0o001;
1518pub 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 }
15211478
1522pub 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 }
15251482
1526pub 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 }
15291486
1530pub 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 }
15331490
1534pub 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 }
15371494
1538pub 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 }
15411498
1542pub 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 }
15451502
1546pub 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};
15491507
1550pub const HOST_NAME_MAX = 72;1508pub const HOST_NAME_MAX = 72;
15511509
...@@ -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};
19831941
1984pub const TIOCGWINSZ = ior(0x40000000, 't', 104, @sizeOf(winsize));1942pub const T = struct {
1943 pub const IOCGWINSZ = ior(0x40000000, 't', 104, @sizeOf(winsize));
1944};
1985pub const IOCPARM_MASK = 0x1fff;1945pub const IOCPARM_MASK = 0x1fff;
19861946
1987fn ior(inout: u32, group: usize, num: usize, len: usize) usize {1947fn 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
3333
34pub const sem_t = ?*opaque {};34pub const sem_t = ?*opaque {};
3535
36pub 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.h37// - https://gitweb.dragonflybsd.org/dragonfly.git/blob/HEAD:/include/unistd.h
42// - https://gitweb.dragonflybsd.org/dragonfly.git/blob/HEAD:/sys/sys/types.h38// - 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;
157pub const STDOUT_FILENO = 1;153pub const STDOUT_FILENO = 1;
158pub const STDERR_FILENO = 2;154pub const STDERR_FILENO = 2;
159155
160pub const PROT_NONE = 0;156pub const PROT = struct {
161pub const PROT_READ = 1;157 pub const NONE = 0;
162pub const PROT_WRITE = 2;158 pub const READ = 1;
163pub const PROT_EXEC = 4;159 pub const WRITE = 2;
160 pub const EXEC = 4;
161};
164162
165pub const MAP = struct {163pub 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
321pub const W_OK = 2; // test for write permission319pub const W_OK = 2; // test for write permission
322pub const R_OK = 4; // test for read permission320pub const R_OK = 4; // test for read permission
323321
324pub const O_RDONLY = 0;322pub const O = struct {
325pub const O_NDELAY = O_NONBLOCK;323 pub const RDONLY = 0;
326pub const O_WRONLY = 1;324 pub const NDELAY = NONBLOCK;
327pub const O_RDWR = 2;325 pub const WRONLY = 1;
328pub const O_ACCMODE = 3;326 pub const RDWR = 2;
329pub const O_NONBLOCK = 4;327 pub const ACCMODE = 3;
330pub const O_APPEND = 8;328 pub const NONBLOCK = 4;
331pub const O_SHLOCK = 16;329 pub const APPEND = 8;
332pub const O_EXLOCK = 32;330 pub const SHLOCK = 16;
333pub const O_ASYNC = 64;331 pub const EXLOCK = 32;
334pub const O_FSYNC = 128;332 pub const ASYNC = 64;
335pub const O_SYNC = 128;333 pub const FSYNC = 128;
336pub const O_NOFOLLOW = 256;334 pub const SYNC = 128;
337pub const O_CREAT = 512;335 pub const NOFOLLOW = 256;
338pub const O_TRUNC = 1024;336 pub const CREAT = 512;
339pub const O_EXCL = 2048;337 pub const TRUNC = 1024;
340pub const O_NOCTTY = 32768;338 pub const EXCL = 2048;
341pub const O_DIRECT = 65536;339 pub const NOCTTY = 32768;
342pub const O_CLOEXEC = 131072;340 pub const DIRECT = 65536;
343pub const O_FBLOCKING = 262144;341 pub const CLOEXEC = 131072;
344pub const O_FNONBLOCKING = 524288;342 pub const FBLOCKING = 262144;
345pub const O_FAPPEND = 1048576;343 pub const FNONBLOCKING = 524288;
346pub const O_FOFFSET = 2097152;344 pub const FAPPEND = 1048576;
347pub const O_FSYNCWRITE = 4194304;345 pub const FOFFSET = 2097152;
348pub const O_FASYNCWRITE = 8388608;346 pub const FSYNCWRITE = 4194304;
349pub const O_DIRECTORY = 134217728;347 pub const FASYNCWRITE = 8388608;
348 pub const DIRECTORY = 134217728;
349};
350350
351pub const SEEK_SET = 0;351pub const SEEK_SET = 0;
352pub const SEEK_CUR = 1;352pub 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};
542542
543pub const S_IREAD = S_IRUSR;543pub const S = struct {
544pub const S_IEXEC = S_IXUSR;544 pub const IREAD = IRUSR;
545pub const S_IWRITE = S_IWUSR;545 pub const IEXEC = IXUSR;
546pub const S_IXOTH = 1;546 pub const IWRITE = IWUSR;
547pub const S_IWOTH = 2;547 pub const IXOTH = 1;
548pub const S_IROTH = 4;548 pub const IWOTH = 2;
549pub const S_IRWXO = 7;549 pub const IROTH = 4;
550pub const S_IXGRP = 8;550 pub const IRWXO = 7;
551pub const S_IWGRP = 16;551 pub const IXGRP = 8;
552pub const S_IRGRP = 32;552 pub const IWGRP = 16;
553pub const S_IRWXG = 56;553 pub const IRGRP = 32;
554pub const S_IXUSR = 64;554 pub const IRWXG = 56;
555pub const S_IWUSR = 128;555 pub const IXUSR = 64;
556pub const S_IRUSR = 256;556 pub const IWUSR = 128;
557pub const S_IRWXU = 448;557 pub const IRUSR = 256;
558pub const S_ISTXT = 512;558 pub const IRWXU = 448;
559pub const S_BLKSIZE = 512;559 pub const ISTXT = 512;
560pub const S_ISVTX = 512;560 pub const BLKSIZE = 512;
561pub const S_ISGID = 1024;561 pub const ISVTX = 512;
562pub const S_ISUID = 2048;562 pub const ISGID = 1024;
563pub const S_IFIFO = 4096;563 pub const ISUID = 2048;
564pub const S_IFCHR = 8192;564 pub const IFIFO = 4096;
565pub const S_IFDIR = 16384;565 pub const IFCHR = 8192;
566pub const S_IFBLK = 24576;566 pub const IFDIR = 16384;
567pub const S_IFREG = 32768;567 pub const IFBLK = 24576;
568pub const S_IFDB = 36864;568 pub const IFREG = 32768;
569pub const S_IFLNK = 40960;569 pub const IFDB = 36864;
570pub const S_IFSOCK = 49152;570 pub const IFLNK = 40960;
571pub const S_IFWHT = 57344;571 pub const IFSOCK = 49152;
572pub const S_IFMT = 61440;572 pub const IFWHT = 57344;
573573 pub const IFMT = 61440;
574pub const SIG_DFL = @intToPtr(?Sigaction.sigaction_fn, 0);574
575pub const SIG_IGN = @intToPtr(?Sigaction.sigaction_fn, 1);575 pub fn ISCHR(m: u32) bool {
576pub const SIG_ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize));576 return m & IFMT == IFCHR;
577pub const BADSIG = SIG_ERR;577 }
578578};
579pub const SIG_BLOCK = 1;579
580pub const SIG_UNBLOCK = 2;580pub const BADSIG = SIG.ERR;
581pub const SIG_SETMASK = 3;581
582582pub const SIG = struct {
583pub const SIGIOT = SIGABRT;583 pub const DFL = @intToPtr(?Sigaction.sigaction_fn, 0);
584pub const SIGHUP = 1;584 pub const IGN = @intToPtr(?Sigaction.sigaction_fn, 1);
585pub const SIGINT = 2;585 pub const ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize));
586pub const SIGQUIT = 3;586
587pub const SIGILL = 4;587 pub const BLOCK = 1;
588pub const SIGTRAP = 5;588 pub const UNBLOCK = 2;
589pub const SIGABRT = 6;589 pub const SETMASK = 3;
590pub const SIGEMT = 7;590
591pub const SIGFPE = 8;591 pub const IOT = ABRT;
592pub const SIGKILL = 9;592 pub const HUP = 1;
593pub const SIGBUS = 10;593 pub const INT = 2;
594pub const SIGSEGV = 11;594 pub const QUIT = 3;
595pub const SIGSYS = 12;595 pub const ILL = 4;
596pub const SIGPIPE = 13;596 pub const TRAP = 5;
597pub const SIGALRM = 14;597 pub const ABRT = 6;
598pub const SIGTERM = 15;598 pub const EMT = 7;
599pub const SIGURG = 16;599 pub const FPE = 8;
600pub const SIGSTOP = 17;600 pub const KILL = 9;
601pub const SIGTSTP = 18;601 pub const BUS = 10;
602pub const SIGCONT = 19;602 pub const SEGV = 11;
603pub const SIGCHLD = 20;603 pub const SYS = 12;
604pub const SIGTTIN = 21;604 pub const PIPE = 13;
605pub const SIGTTOU = 22;605 pub const ALRM = 14;
606pub const SIGIO = 23;606 pub const TERM = 15;
607pub const SIGXCPU = 24;607 pub const URG = 16;
608pub const SIGXFSZ = 25;608 pub const STOP = 17;
609pub const SIGVTALRM = 26;609 pub const TSTP = 18;
610pub const SIGPROF = 27;610 pub const CONT = 19;
611pub const SIGWINCH = 28;611 pub const CHLD = 20;
612pub const SIGINFO = 29;612 pub const TTIN = 21;
613pub const SIGUSR1 = 30;613 pub const TTOU = 22;
614pub const SIGUSR2 = 31;614 pub const IO = 23;
615pub const SIGTHR = 32;615 pub const XCPU = 24;
616pub const SIGCKPT = 33;616 pub const XFSZ = 25;
617pub 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};
618627
619pub const siginfo_t = extern struct {628pub 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;
363pub const STDOUT_FILENO = 1;363pub const STDOUT_FILENO = 1;
364pub const STDERR_FILENO = 2;364pub const STDERR_FILENO = 2;
365365
366pub const PROT_NONE = 0;366pub const PROT = struct {
367pub const PROT_READ = 1;367 pub const NONE = 0;
368pub const PROT_WRITE = 2;368 pub const READ = 1;
369pub const PROT_EXEC = 4;369 pub const WRITE = 2;
370 pub const EXEC = 4;
371};
370372
371pub const CLOCK = struct {373pub 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
504pub const W_OK = 2; // test for write permission506pub const W_OK = 2; // test for write permission
505pub const R_OK = 4; // test for read permission507pub const R_OK = 4; // test for read permission
506508
507pub const O_RDONLY = 0x0000;509pub const O = struct {
508pub const O_WRONLY = 0x0001;510 pub const RDONLY = 0x0000;
509pub const O_RDWR = 0x0002;511 pub const WRONLY = 0x0001;
510pub const O_ACCMODE = 0x0003;512 pub const RDWR = 0x0002;
511513 pub const ACCMODE = 0x0003;
512pub const O_SHLOCK = 0x0010;514
513pub const O_EXLOCK = 0x0020;515 pub const SHLOCK = 0x0010;
514516 pub const EXLOCK = 0x0020;
515pub const O_CREAT = 0x0200;517
516pub const O_EXCL = 0x0800;518 pub const CREAT = 0x0200;
517pub const O_NOCTTY = 0x8000;519 pub const EXCL = 0x0800;
518pub const O_TRUNC = 0x0400;520 pub const NOCTTY = 0x8000;
519pub const O_APPEND = 0x0008;521 pub const TRUNC = 0x0400;
520pub const O_NONBLOCK = 0x0004;522 pub const APPEND = 0x0008;
521pub const O_DSYNC = 0o10000;523 pub const NONBLOCK = 0x0004;
522pub const O_SYNC = 0x0080;524 pub const DSYNC = 0o10000;
523pub const O_RSYNC = 0o4010000;525 pub const SYNC = 0x0080;
524pub const O_DIRECTORY = 0x20000;526 pub const RSYNC = 0o4010000;
525pub const O_NOFOLLOW = 0x0100;527 pub const DIRECTORY = 0x20000;
526pub const O_CLOEXEC = 0x00100000;528 pub const NOFOLLOW = 0x0100;
527529 pub const CLOEXEC = 0x00100000;
528pub const O_ASYNC = 0x0040;530
529pub const O_DIRECT = 0x00010000;531 pub const ASYNC = 0x0040;
530pub const O_NOATIME = 0o1000000;532 pub const DIRECT = 0x00010000;
531pub const O_PATH = 0o10000000;533 pub const NOATIME = 0o1000000;
532pub const O_TMPFILE = 0o20200000;534 pub const PATH = 0o10000000;
533pub const O_NDELAY = O_NONBLOCK;535 pub const TMPFILE = 0o20200000;
536 pub const NDELAY = NONBLOCK;
537};
534538
535pub const F = struct {539pub 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 absolute881/// timeout is absolute
878pub const NOTE_ABSTIME = 0x00000010;882pub const NOTE_ABSTIME = 0x00000010;
879883
880pub const TIOCEXCL = 0x2000740d;884pub const T = struct {
881pub const TIOCNXCL = 0x2000740e;885 pub const IOCEXCL = 0x2000740d;
882pub const TIOCSCTTY = 0x20007461;886 pub const IOCNXCL = 0x2000740e;
883pub const TIOCGPGRP = 0x40047477;887 pub const IOCSCTTY = 0x20007461;
884pub const TIOCSPGRP = 0x80047476;888 pub const IOCGPGRP = 0x40047477;
885pub const TIOCOUTQ = 0x40047473;889 pub const IOCSPGRP = 0x80047476;
886pub const TIOCSTI = 0x80017472;890 pub const IOCOUTQ = 0x40047473;
887pub const TIOCGWINSZ = 0x40087468;891 pub const IOCSTI = 0x80017472;
888pub const TIOCSWINSZ = 0x80087467;892 pub const IOCGWINSZ = 0x40087468;
889pub const TIOCMGET = 0x4004746a;893 pub const IOCSWINSZ = 0x80087467;
890pub const TIOCMBIS = 0x8004746c;894 pub const IOCMGET = 0x4004746a;
891pub const TIOCMBIC = 0x8004746b;895 pub const IOCMBIS = 0x8004746c;
892pub const TIOCMSET = 0x8004746d;896 pub const IOCMBIC = 0x8004746b;
893pub const FIONREAD = 0x4004667f;897 pub const IOCMSET = 0x8004746d;
894pub const TIOCCONS = 0x80047462;898 pub const FIONREAD = 0x4004667f;
895pub const TIOCPKT = 0x80047470;899 pub const IOCCONS = 0x80047462;
896pub const FIONBIO = 0x8004667e;900 pub const IOCPKT = 0x80047470;
897pub const TIOCNOTTY = 0x20007471;901 pub const FIONBIO = 0x8004667e;
898pub const TIOCSETD = 0x8004741b;902 pub const IOCNOTTY = 0x20007471;
899pub const TIOCGETD = 0x4004741a;903 pub const IOCSETD = 0x8004741b;
900pub const TIOCSBRK = 0x2000747b;904 pub const IOCGETD = 0x4004741a;
901pub const TIOCCBRK = 0x2000747a;905 pub const IOCSBRK = 0x2000747b;
902pub const TIOCGSID = 0x40047463;906 pub const IOCCBRK = 0x2000747a;
903pub const TIOCGPTN = 0x4004740f;907 pub const IOCGSID = 0x40047463;
904pub const TIOCSIG = 0x2004745f;908 pub const IOCGPTN = 0x4004740f;
909 pub const IOCSIG = 0x2004745f;
910};
905911
906pub fn WEXITSTATUS(s: u32) u8 {912pub 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;
1166pub const SS_DISABLE = 4;1172pub const SS_DISABLE = 4;
11671173
1168pub const stack_t = extern struct {1174pub 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};
11731179
1174pub const S_IFMT = 0o170000;1180pub const S = struct {
11751181 pub const IFMT = 0o170000;
1176pub const S_IFIFO = 0o010000;1182
1177pub const S_IFCHR = 0o020000;1183 pub const IFIFO = 0o010000;
1178pub const S_IFDIR = 0o040000;1184 pub const IFCHR = 0o020000;
1179pub const S_IFBLK = 0o060000;1185 pub const IFDIR = 0o040000;
1180pub const S_IFREG = 0o100000;1186 pub const IFBLK = 0o060000;
1181pub const S_IFLNK = 0o120000;1187 pub const IFREG = 0o100000;
1182pub const S_IFSOCK = 0o140000;1188 pub const IFLNK = 0o120000;
1183pub const S_IFWHT = 0o160000;1189 pub const IFSOCK = 0o140000;
11841190 pub const IFWHT = 0o160000;
1185pub const S_ISUID = 0o4000;1191
1186pub const S_ISGID = 0o2000;1192 pub const ISUID = 0o4000;
1187pub const S_ISVTX = 0o1000;1193 pub const ISGID = 0o2000;
1188pub const S_IRWXU = 0o700;1194 pub const ISVTX = 0o1000;
1189pub const S_IRUSR = 0o400;1195 pub const IRWXU = 0o700;
1190pub const S_IWUSR = 0o200;1196 pub const IRUSR = 0o400;
1191pub const S_IXUSR = 0o100;1197 pub const IWUSR = 0o200;
1192pub const S_IRWXG = 0o070;1198 pub const IXUSR = 0o100;
1193pub const S_IRGRP = 0o040;1199 pub const IRWXG = 0o070;
1194pub const S_IWGRP = 0o020;1200 pub const IRGRP = 0o040;
1195pub const S_IXGRP = 0o010;1201 pub const IWGRP = 0o020;
1196pub const S_IRWXO = 0o007;1202 pub const IXGRP = 0o010;
1197pub const S_IROTH = 0o004;1203 pub const IRWXO = 0o007;
1198pub const S_IWOTH = 0o002;1204 pub const IROTH = 0o004;
1199pub const S_IXOTH = 0o001;1205 pub const IWOTH = 0o002;
12001206 pub const IXOTH = 0o001;
1201pub 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 }
12041211
1205pub 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 }
12081215
1209pub 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 }
12121219
1213pub 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 }
12161223
1217pub 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 }
12201227
1221pub 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 }
12241231
1225pub 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 }
12281235
1229pub 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};
12321240
1233pub const HOST_NAME_MAX = 255;1241pub const HOST_NAME_MAX = 255;
12341242
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;
377pub const STDOUT_FILENO = 1;377pub const STDOUT_FILENO = 1;
378pub const STDERR_FILENO = 2;378pub const STDERR_FILENO = 2;
379379
380pub const PROT_NONE = 0;380pub const PROT = struct {
381pub const PROT_READ = 1;381 pub const NONE = 0;
382pub const PROT_WRITE = 2;382 pub const READ = 1;
383pub const PROT_EXEC = 4;383 pub const WRITE = 2;
384 pub const EXEC = 4;
385};
384386
385pub const CLOCK = struct {387pub 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;
425pub const SA_ONESHOT = SA_RESETHAND;427pub const SA_ONESHOT = SA_RESETHAND;
426428
427pub const SIG = struct {429pub 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
489pub const W_OK = 2; // test for write permission495pub const W_OK = 2; // test for write permission
490pub const R_OK = 4; // test for read permission496pub const R_OK = 4; // test for read permission
491497
492pub const O_RDONLY = 0x0000;498pub const O = struct {
493pub const O_WRONLY = 0x0001;499 pub const RDONLY = 0x0000;
494pub const O_RDWR = 0x0002;500 pub const WRONLY = 0x0001;
495pub const O_ACCMODE = 0x0003;501 pub const RDWR = 0x0002;
496502 pub const ACCMODE = 0x0003;
497pub const O_SHLOCK = 0x0010;503
498pub const O_EXLOCK = 0x0020;504 pub const SHLOCK = 0x0010;
499505 pub const EXLOCK = 0x0020;
500pub const O_CREAT = 0x0200;506
501pub const O_EXCL = 0x0800;507 pub const CREAT = 0x0200;
502pub const O_NOCTTY = 0x8000;508 pub const EXCL = 0x0800;
503pub const O_TRUNC = 0x0400;509 pub const NOCTTY = 0x8000;
504pub const O_APPEND = 0x0008;510 pub const TRUNC = 0x0400;
505pub const O_NONBLOCK = 0x0004;511 pub const APPEND = 0x0008;
506pub const O_DSYNC = 0o10000;512 pub const NONBLOCK = 0x0004;
507pub const O_SYNC = 0x0080;513 pub const DSYNC = 0o10000;
508pub const O_RSYNC = 0o4010000;514 pub const SYNC = 0x0080;
509pub const O_DIRECTORY = 0x20000;515 pub const RSYNC = 0o4010000;
510pub const O_NOFOLLOW = 0x0100;516 pub const DIRECTORY = 0x20000;
511pub const O_CLOEXEC = 0x00100000;517 pub const NOFOLLOW = 0x0100;
512518 pub const CLOEXEC = 0x00100000;
513pub const O_ASYNC = 0x0040;519
514pub const O_DIRECT = 0x00010000;520 pub const ASYNC = 0x0040;
515pub const O_NOATIME = 0o1000000;521 pub const DIRECT = 0x00010000;
516pub const O_PATH = 0o10000000;522 pub const NOATIME = 0o1000000;
517pub const O_TMPFILE = 0o20200000;523 pub const PATH = 0o10000000;
518pub const O_NDELAY = O_NONBLOCK;524 pub const TMPFILE = 0o20200000;
525 pub const NDELAY = NONBLOCK;
526};
519527
520pub const F = struct {528pub 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;
773781
774pub const EVFILT_EMPTY = -13;782pub const EVFILT_EMPTY = -13;
775783
776pub const TCGETA = 0x8000;784pub const T = struct {
777pub const TCSETA = 0x8001;785 pub const CGETA = 0x8000;
778pub const TCSETAW = 0x8004;786 pub const CSETA = 0x8001;
779pub const TCSETAF = 0x8003;787 pub const CSETAW = 0x8004;
780pub const TCSBRK = 08005;788 pub const CSETAF = 0x8003;
781pub const TCXONC = 0x8007;789 pub const CSBRK = 08005;
782pub const TCFLSH = 0x8006;790 pub const CXONC = 0x8007;
783791 pub const CFLSH = 0x8006;
784pub const TIOCSCTTY = 0x8017;792
785pub const TIOCGPGRP = 0x8015;793 pub const IOCSCTTY = 0x8017;
786pub const TIOCSPGRP = 0x8016;794 pub const IOCGPGRP = 0x8015;
787pub const TIOCGWINSZ = 0x8012;795 pub const IOCSPGRP = 0x8016;
788pub const TIOCSWINSZ = 0x8013;796 pub const IOCGWINSZ = 0x8012;
789pub const TIOCMGET = 0x8018;797 pub const IOCSWINSZ = 0x8013;
790pub const TIOCMBIS = 0x8022;798 pub const IOCMGET = 0x8018;
791pub const TIOCMBIC = 0x8023;799 pub const IOCMBIS = 0x8022;
792pub const TIOCMSET = 0x8019;800 pub const IOCMBIC = 0x8023;
793pub const FIONREAD = 0xbe000001;801 pub const IOCMSET = 0x8019;
794pub const FIONBIO = 0xbe000000;802 pub const FIONREAD = 0xbe000001;
795pub const TIOCSBRK = 0x8020;803 pub const FIONBIO = 0xbe000000;
796pub const TIOCCBRK = 0x8021;804 pub const IOCSBRK = 0x8020;
797pub const TIOCGSID = 0x8024;805 pub const IOCCBRK = 0x8021;
798806 pub const IOCGSID = 0x8024;
799pub fn WEXITSTATUS(s: u32) u8 {807};
800 return @intCast(u8, s & 0xff);808
801}809pub const W = struct {
802810 pub fn EXITSTATUS(s: u32) u8 {
803pub fn WTERMSIG(s: u32) u32 {811 return @intCast(u8, s & 0xff);
804 return (s >> 8) & 0xff;812 }
805}813
806814 pub fn TERMSIG(s: u32) u32 {
807pub fn WSTOPSIG(s: u32) u32 {815 return (s >> 8) & 0xff;
808 return WEXITSTATUS(s);816 }
809}817
810818 pub fn STOPSIG(s: u32) u32 {
811pub fn WIFEXITED(s: u32) bool {819 return EXITSTATUS(s);
812 return WTERMSIG(s) == 0;820 }
813}821
814822 pub fn IFEXITED(s: u32) bool {
815pub fn WIFSTOPPED(s: u32) bool {823 return TERMSIG(s) == 0;
816 return ((s >> 16) & 0xff) != 0;824 }
817}825
818826 pub fn IFSTOPPED(s: u32) bool {
819pub 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};
822834
823pub const winsize = extern struct {835pub 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 {
829841
830const NSIG = 32;842const NSIG = 32;
831843
832pub const SIG_ERR = @intToPtr(fn (i32) callconv(.C) void, maxInt(usize));
833pub const SIG_DFL = @intToPtr(fn (i32) callconv(.C) void, 0);
834pub 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.
837pub const Sigaction = extern struct {845pub const Sigaction = extern struct {
838 /// signal handler846 /// 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};
9941002
995pub const S_IFMT = 0o170000;1003pub const S = struct {
9961004 pub const IFMT = 0o170000;
997pub const S_IFIFO = 0o010000;1005
998pub const S_IFCHR = 0o020000;1006 pub const IFIFO = 0o010000;
999pub const S_IFDIR = 0o040000;1007 pub const IFCHR = 0o020000;
1000pub const S_IFBLK = 0o060000;1008 pub const IFDIR = 0o040000;
1001pub const S_IFREG = 0o100000;1009 pub const IFBLK = 0o060000;
1002pub const S_IFLNK = 0o120000;1010 pub const IFREG = 0o100000;
1003pub const S_IFSOCK = 0o140000;1011 pub const IFLNK = 0o120000;
1004pub const S_IFWHT = 0o160000;1012 pub const IFSOCK = 0o140000;
10051013 pub const IFWHT = 0o160000;
1006pub const S_ISUID = 0o4000;1014
1007pub const S_ISGID = 0o2000;1015 pub const ISUID = 0o4000;
1008pub const S_ISVTX = 0o1000;1016 pub const ISGID = 0o2000;
1009pub const S_IRWXU = 0o700;1017 pub const ISVTX = 0o1000;
1010pub const S_IRUSR = 0o400;1018 pub const IRWXU = 0o700;
1011pub const S_IWUSR = 0o200;1019 pub const IRUSR = 0o400;
1012pub const S_IXUSR = 0o100;1020 pub const IWUSR = 0o200;
1013pub const S_IRWXG = 0o070;1021 pub const IXUSR = 0o100;
1014pub const S_IRGRP = 0o040;1022 pub const IRWXG = 0o070;
1015pub const S_IWGRP = 0o020;1023 pub const IRGRP = 0o040;
1016pub const S_IXGRP = 0o010;1024 pub const IWGRP = 0o020;
1017pub const S_IRWXO = 0o007;1025 pub const IXGRP = 0o010;
1018pub const S_IROTH = 0o004;1026 pub const IRWXO = 0o007;
1019pub const S_IWOTH = 0o002;1027 pub const IROTH = 0o004;
1020pub const S_IXOTH = 0o001;1028 pub const IWOTH = 0o002;
10211029 pub const IXOTH = 0o001;
1022pub 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;
10251033 }
1026pub 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;
10291037 }
1030pub 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;
10331041 }
1034pub 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;
10371045 }
1038pub 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;
10411049 }
1042pub 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;
10451053 }
1046pub 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;
10491057 }
1050pub 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};
10531063
1054pub const HOST_NAME_MAX = 255;1064pub const HOST_NAME_MAX = 255;
10551065
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;
25pub const IPPROTO = linux.IPPROTO;25pub const IPPROTO = linux.IPPROTO;
26pub const LOCK = linux.LOCK;26pub const LOCK = linux.LOCK;
27pub const MADV = linux.MADV;27pub const MADV = linux.MADV;
28pub const MAP = linux.MAP;28pub 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};
29pub const MMAP2_UNIT = linux.MMAP2_UNIT;33pub const MMAP2_UNIT = linux.MMAP2_UNIT;
30pub const NAME_MAX = linux.NAME_MAX;34pub const NAME_MAX = linux.NAME_MAX;
31pub const O = linux.O;35pub 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;
534pub const STDOUT_FILENO = 1;534pub const STDOUT_FILENO = 1;
535pub const STDERR_FILENO = 2;535pub const STDERR_FILENO = 2;
536536
537pub const PROT_NONE = 0;537pub const PROT = struct {
538pub const PROT_READ = 1;538 pub const NONE = 0;
539pub const PROT_WRITE = 2;539 pub const READ = 1;
540pub const PROT_EXEC = 4;540 pub const WRITE = 2;
541 pub const EXEC = 4;
542};
541543
542pub const CLOCK = struct {544pub 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
589pub const W_OK = 2; // test for write permission591pub const W_OK = 2; // test for write permission
590pub const R_OK = 4; // test for read permission592pub const R_OK = 4; // test for read permission
591593
592/// open for reading only594pub const O = struct {
593pub const O_RDONLY = 0x00000000;595 /// open for reading only
594596 pub const RDONLY = 0x00000000;
595/// open for writing only597 /// open for writing only
596pub const O_WRONLY = 0x00000001;598 pub const WRONLY = 0x00000001;
597599 /// open for reading and writing
598/// open for reading and writing600 pub const RDWR = 0x00000002;
599pub const O_RDWR = 0x00000002;601 /// mask for above modes
600602 pub const ACCMODE = 0x00000003;
601/// mask for above modes603 /// no delay
602pub const O_ACCMODE = 0x00000003;604 pub const NONBLOCK = 0x00000004;
603605 /// set append mode
604/// no delay606 pub const APPEND = 0x00000008;
605pub const O_NONBLOCK = 0x00000004;607 /// open with shared file lock
606608 pub const SHLOCK = 0x00000010;
607/// set append mode609 /// open with exclusive file lock
608pub const O_APPEND = 0x00000008;610 pub const EXLOCK = 0x00000020;
609611 /// signal pgrp when data ready
610/// open with shared file lock612 pub const ASYNC = 0x00000040;
611pub const O_SHLOCK = 0x00000010;613 /// synchronous writes
612614 pub const SYNC = 0x00000080;
613/// open with exclusive file lock615 /// don't follow symlinks on the last
614pub const O_EXLOCK = 0x00000020;616 pub const NOFOLLOW = 0x00000100;
615617 /// create if nonexistent
616/// signal pgrp when data ready618 pub const CREAT = 0x00000200;
617pub const O_ASYNC = 0x00000040;619 /// truncate to zero length
618620 pub const TRUNC = 0x00000400;
619/// synchronous writes621 /// error if already exists
620pub const O_SYNC = 0x00000080;622 pub const EXCL = 0x00000800;
621623 /// don't assign controlling terminal
622/// don't follow symlinks on the last624 pub const NOCTTY = 0x00008000;
623pub const O_NOFOLLOW = 0x00000100;625 /// write: I/O data completion
624626 pub const DSYNC = 0x00010000;
625/// create if nonexistent627 /// read: I/O completion as for write
626pub const O_CREAT = 0x00000200;628 pub const RSYNC = 0x00020000;
627629 /// use alternate i/o semantics
628/// truncate to zero length630 pub const ALT_IO = 0x00040000;
629pub const O_TRUNC = 0x00000400;631 /// direct I/O hint
630632 pub const DIRECT = 0x00080000;
631/// error if already exists633 /// fail if not a directory
632pub const O_EXCL = 0x00000800;634 pub const DIRECTORY = 0x00200000;
633635 /// set close on exec
634/// don't assign controlling terminal636 pub const CLOEXEC = 0x00400000;
635pub const O_NOCTTY = 0x00008000;637 /// skip search permission checks
636638 pub const SEARCH = 0x00800000;
637/// write: I/O data completion639};
638pub const O_DSYNC = 0x00010000;
639
640/// read: I/O completion as for write
641pub const O_RSYNC = 0x00020000;
642
643/// use alternate i/o semantics
644pub const O_ALT_IO = 0x00040000;
645
646/// direct I/O hint
647pub const O_DIRECT = 0x00080000;
648
649/// fail if not a directory
650pub const O_DIRECTORY = 0x00200000;
651
652/// set close on exec
653pub const O_CLOEXEC = 0x00400000;
654
655/// skip search permission checks
656pub const O_SEARCH = 0x00800000;
657640
658pub const F = struct {641pub 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;
687pub const SEEK_CUR = 1;670pub const SEEK_CUR = 1;
688pub const SEEK_END = 2;671pub const SEEK_END = 2;
689672
690pub const SIG_BLOCK = 1;
691pub const SIG_UNBLOCK = 2;
692pub const SIG_SETMASK = 3;
693
694pub const DT_UNKNOWN = 0;673pub const DT_UNKNOWN = 0;
695pub const DT_FIFO = 1;674pub const DT_FIFO = 1;
696pub const DT_CHR = 2;675pub const DT_CHR = 2;
...@@ -789,80 +768,82 @@ pub const NOTE_EXEC = 0x20000000;...@@ -789,80 +768,82 @@ pub const NOTE_EXEC = 0x20000000;
789pub const NOTE_PDATAMASK = 0x000fffff;768pub const NOTE_PDATAMASK = 0x000fffff;
790pub const NOTE_PCTRLMASK = 0xf0000000;769pub const NOTE_PCTRLMASK = 0xf0000000;
791770
792pub const TIOCCBRK = 0x2000747a;771pub const T = struct {
793pub const TIOCCDTR = 0x20007478;772 pub const IOCCBRK = 0x2000747a;
794pub const TIOCCONS = 0x80047462;773 pub const IOCCDTR = 0x20007478;
795pub const TIOCDCDTIMESTAMP = 0x40107458;774 pub const IOCCONS = 0x80047462;
796pub const TIOCDRAIN = 0x2000745e;775 pub const IOCDCDTIMESTAMP = 0x40107458;
797pub const TIOCEXCL = 0x2000740d;776 pub const IOCDRAIN = 0x2000745e;
798pub const TIOCEXT = 0x80047460;777 pub const IOCEXCL = 0x2000740d;
799pub const TIOCFLAG_CDTRCTS = 0x10;778 pub const IOCEXT = 0x80047460;
800pub const TIOCFLAG_CLOCAL = 0x2;779 pub const IOCFLAG_CDTRCTS = 0x10;
801pub const TIOCFLAG_CRTSCTS = 0x4;780 pub const IOCFLAG_CLOCAL = 0x2;
802pub const TIOCFLAG_MDMBUF = 0x8;781 pub const IOCFLAG_CRTSCTS = 0x4;
803pub const TIOCFLAG_SOFTCAR = 0x1;782 pub const IOCFLAG_MDMBUF = 0x8;
804pub const TIOCFLUSH = 0x80047410;783 pub const IOCFLAG_SOFTCAR = 0x1;
805pub const TIOCGETA = 0x402c7413;784 pub const IOCFLUSH = 0x80047410;
806pub const TIOCGETD = 0x4004741a;785 pub const IOCGETA = 0x402c7413;
807pub const TIOCGFLAGS = 0x4004745d;786 pub const IOCGETD = 0x4004741a;
808pub const TIOCGLINED = 0x40207442;787 pub const IOCGFLAGS = 0x4004745d;
809pub const TIOCGPGRP = 0x40047477;788 pub const IOCGLINED = 0x40207442;
810pub const TIOCGQSIZE = 0x40047481;789 pub const IOCGPGRP = 0x40047477;
811pub const TIOCGRANTPT = 0x20007447;790 pub const IOCGQSIZE = 0x40047481;
812pub const TIOCGSID = 0x40047463;791 pub const IOCGRANTPT = 0x20007447;
813pub const TIOCGSIZE = 0x40087468;792 pub const IOCGSID = 0x40047463;
814pub const TIOCGWINSZ = 0x40087468;793 pub const IOCGSIZE = 0x40087468;
815pub const TIOCMBIC = 0x8004746b;794 pub const IOCGWINSZ = 0x40087468;
816pub const TIOCMBIS = 0x8004746c;795 pub const IOCMBIC = 0x8004746b;
817pub const TIOCMGET = 0x4004746a;796 pub const IOCMBIS = 0x8004746c;
818pub const TIOCMSET = 0x8004746d;797 pub const IOCMGET = 0x4004746a;
819pub const TIOCM_CAR = 0x40;798 pub const IOCMSET = 0x8004746d;
820pub const TIOCM_CD = 0x40;799 pub const IOCM_CAR = 0x40;
821pub const TIOCM_CTS = 0x20;800 pub const IOCM_CD = 0x40;
822pub const TIOCM_DSR = 0x100;801 pub const IOCM_CTS = 0x20;
823pub const TIOCM_DTR = 0x2;802 pub const IOCM_DSR = 0x100;
824pub const TIOCM_LE = 0x1;803 pub const IOCM_DTR = 0x2;
825pub const TIOCM_RI = 0x80;804 pub const IOCM_LE = 0x1;
826pub const TIOCM_RNG = 0x80;805 pub const IOCM_RI = 0x80;
827pub const TIOCM_RTS = 0x4;806 pub const IOCM_RNG = 0x80;
828pub const TIOCM_SR = 0x10;807 pub const IOCM_RTS = 0x4;
829pub const TIOCM_ST = 0x8;808 pub const IOCM_SR = 0x10;
830pub const TIOCNOTTY = 0x20007471;809 pub const IOCM_ST = 0x8;
831pub const TIOCNXCL = 0x2000740e;810 pub const IOCNOTTY = 0x20007471;
832pub const TIOCOUTQ = 0x40047473;811 pub const IOCNXCL = 0x2000740e;
833pub const TIOCPKT = 0x80047470;812 pub const IOCOUTQ = 0x40047473;
834pub const TIOCPKT_DATA = 0x0;813 pub const IOCPKT = 0x80047470;
835pub const TIOCPKT_DOSTOP = 0x20;814 pub const IOCPKT_DATA = 0x0;
836pub const TIOCPKT_FLUSHREAD = 0x1;815 pub const IOCPKT_DOSTOP = 0x20;
837pub const TIOCPKT_FLUSHWRITE = 0x2;816 pub const IOCPKT_FLUSHREAD = 0x1;
838pub const TIOCPKT_IOCTL = 0x40;817 pub const IOCPKT_FLUSHWRITE = 0x2;
839pub const TIOCPKT_NOSTOP = 0x10;818 pub const IOCPKT_IOCTL = 0x40;
840pub const TIOCPKT_START = 0x8;819 pub const IOCPKT_NOSTOP = 0x10;
841pub const TIOCPKT_STOP = 0x4;820 pub const IOCPKT_START = 0x8;
842pub const TIOCPTMGET = 0x40287446;821 pub const IOCPKT_STOP = 0x4;
843pub const TIOCPTSNAME = 0x40287448;822 pub const IOCPTMGET = 0x40287446;
844pub const TIOCRCVFRAME = 0x80087445;823 pub const IOCPTSNAME = 0x40287448;
845pub const TIOCREMOTE = 0x80047469;824 pub const IOCRCVFRAME = 0x80087445;
846pub const TIOCSBRK = 0x2000747b;825 pub const IOCREMOTE = 0x80047469;
847pub const TIOCSCTTY = 0x20007461;826 pub const IOCSBRK = 0x2000747b;
848pub const TIOCSDTR = 0x20007479;827 pub const IOCSCTTY = 0x20007461;
849pub const TIOCSETA = 0x802c7414;828 pub const IOCSDTR = 0x20007479;
850pub const TIOCSETAF = 0x802c7416;829 pub const IOCSETA = 0x802c7414;
851pub const TIOCSETAW = 0x802c7415;830 pub const IOCSETAF = 0x802c7416;
852pub const TIOCSETD = 0x8004741b;831 pub const IOCSETAW = 0x802c7415;
853pub const TIOCSFLAGS = 0x8004745c;832 pub const IOCSETD = 0x8004741b;
854pub const TIOCSIG = 0x2000745f;833 pub const IOCSFLAGS = 0x8004745c;
855pub const TIOCSLINED = 0x80207443;834 pub const IOCSIG = 0x2000745f;
856pub const TIOCSPGRP = 0x80047476;835 pub const IOCSLINED = 0x80207443;
857pub const TIOCSQSIZE = 0x80047480;836 pub const IOCSPGRP = 0x80047476;
858pub const TIOCSSIZE = 0x80087467;837 pub const IOCSQSIZE = 0x80047480;
859pub const TIOCSTART = 0x2000746e;838 pub const IOCSSIZE = 0x80087467;
860pub const TIOCSTAT = 0x80047465;839 pub const IOCSTART = 0x2000746e;
861pub const TIOCSTI = 0x80017472;840 pub const IOCSTAT = 0x80047465;
862pub const TIOCSTOP = 0x2000746f;841 pub const IOCSTI = 0x80017472;
863pub const TIOCSWINSZ = 0x80087467;842 pub const IOCSTOP = 0x2000746f;
864pub const TIOCUCNTL = 0x80047466;843 pub const IOCSWINSZ = 0x80087467;
865pub const TIOCXMTFRAME = 0x80087444;844 pub const IOCUCNTL = 0x80047466;
845 pub const IOCXMTFRAME = 0x80087444;
846};
866847
867pub fn WEXITSTATUS(s: u32) u8 {848pub 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;
908889
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};
12151200
1216pub const S_IFMT = 0o170000;1201pub const S = struct {
12171202 pub const IFMT = 0o170000;
1218pub const S_IFIFO = 0o010000;1203
1219pub const S_IFCHR = 0o020000;1204 pub const IFIFO = 0o010000;
1220pub const S_IFDIR = 0o040000;1205 pub const IFCHR = 0o020000;
1221pub const S_IFBLK = 0o060000;1206 pub const IFDIR = 0o040000;
1222pub const S_IFREG = 0o100000;1207 pub const IFBLK = 0o060000;
1223pub const S_IFLNK = 0o120000;1208 pub const IFREG = 0o100000;
1224pub const S_IFSOCK = 0o140000;1209 pub const IFLNK = 0o120000;
1225pub const S_IFWHT = 0o160000;1210 pub const IFSOCK = 0o140000;
12261211 pub const IFWHT = 0o160000;
1227pub const S_ISUID = 0o4000;1212
1228pub const S_ISGID = 0o2000;1213 pub const ISUID = 0o4000;
1229pub const S_ISVTX = 0o1000;1214 pub const ISGID = 0o2000;
1230pub const S_IRWXU = 0o700;1215 pub const ISVTX = 0o1000;
1231pub const S_IRUSR = 0o400;1216 pub const IRWXU = 0o700;
1232pub const S_IWUSR = 0o200;1217 pub const IRUSR = 0o400;
1233pub const S_IXUSR = 0o100;1218 pub const IWUSR = 0o200;
1234pub const S_IRWXG = 0o070;1219 pub const IXUSR = 0o100;
1235pub const S_IRGRP = 0o040;1220 pub const IRWXG = 0o070;
1236pub const S_IWGRP = 0o020;1221 pub const IRGRP = 0o040;
1237pub const S_IXGRP = 0o010;1222 pub const IWGRP = 0o020;
1238pub const S_IRWXO = 0o007;1223 pub const IXGRP = 0o010;
1239pub const S_IROTH = 0o004;1224 pub const IRWXO = 0o007;
1240pub const S_IWOTH = 0o002;1225 pub const IROTH = 0o004;
1241pub const S_IXOTH = 0o001;1226 pub const IWOTH = 0o002;
12421227 pub const IXOTH = 0o001;
1243pub 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 }
12461232
1247pub 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 }
12501236
1251pub 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 }
12541240
1255pub 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 }
12581244
1259pub 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 }
12621248
1263pub 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 }
12661252
1267pub 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 }
12701256
1271pub 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};
12741261
1275pub const AT = struct {1262pub const AT = struct {
1276 /// Magic value that specify the use of the current working directory1263 /// 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;
330pub const STDOUT_FILENO = 1;330pub const STDOUT_FILENO = 1;
331pub const STDERR_FILENO = 2;331pub const STDERR_FILENO = 2;
332332
333pub const PROT_NONE = 0;333pub const PROT = struct {
334pub const PROT_READ = 1;334 pub const NONE = 0;
335pub const PROT_WRITE = 2;335 pub const READ = 1;
336pub const PROT_EXEC = 4;336 pub const WRITE = 2;
337 pub const EXEC = 4;
338};
337339
338pub const CLOCK = struct {340pub 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;
371pub const SA_NOCLDWAIT = 0x0020;373pub const SA_NOCLDWAIT = 0x0020;
372pub const SA_SIGINFO = 0x0040;374pub const SA_SIGINFO = 0x0040;
373375
374pub const SIGHUP = 1;
375pub const SIGINT = 2;
376pub const SIGQUIT = 3;
377pub const SIGILL = 4;
378pub const SIGTRAP = 5;
379pub const SIGABRT = 6;
380pub const SIGIOT = SIGABRT;
381pub const SIGEMT = 7;
382pub const SIGFPE = 8;
383pub const SIGKILL = 9;
384pub const SIGBUS = 10;
385pub const SIGSEGV = 11;
386pub const SIGSYS = 12;
387pub const SIGPIPE = 13;
388pub const SIGALRM = 14;
389pub const SIGTERM = 15;
390pub const SIGURG = 16;
391pub const SIGSTOP = 17;
392pub const SIGTSTP = 18;
393pub const SIGCONT = 19;
394pub const SIGCHLD = 20;
395pub const SIGTTIN = 21;
396pub const SIGTTOU = 22;
397pub const SIGIO = 23;
398pub const SIGXCPU = 24;
399pub const SIGXFSZ = 25;
400pub const SIGVTALRM = 26;
401pub const SIGPROF = 27;
402pub const SIGWINCH = 28;
403pub const SIGINFO = 29;
404pub const SIGUSR1 = 30;
405pub const SIGUSR2 = 31;
406pub const SIGPWR = 32;
407
408// access function376// access function
409pub const F_OK = 0; // test for existence of file377pub const F_OK = 0; // test for existence of file
410pub const X_OK = 1; // test for execute or search permission378pub const X_OK = 1; // test for execute or search permission
411pub const W_OK = 2; // test for write permission379pub const W_OK = 2; // test for write permission
412pub const R_OK = 4; // test for read permission380pub const R_OK = 4; // test for read permission
413381
414/// open for reading only382pub const O = struct {
415pub const O_RDONLY = 0x00000000;383 /// open for reading only
416384 pub const RDONLY = 0x00000000;
417/// open for writing only385 /// open for writing only
418pub const O_WRONLY = 0x00000001;386 pub const WRONLY = 0x00000001;
419387 /// open for reading and writing
420/// open for reading and writing388 pub const RDWR = 0x00000002;
421pub const O_RDWR = 0x00000002;389 /// mask for above modes
422390 pub const ACCMODE = 0x00000003;
423/// mask for above modes391 /// no delay
424pub const O_ACCMODE = 0x00000003;392 pub const NONBLOCK = 0x00000004;
425393 /// set append mode
426/// no delay394 pub const APPEND = 0x00000008;
427pub const O_NONBLOCK = 0x00000004;395 /// open with shared file lock
428396 pub const SHLOCK = 0x00000010;
429/// set append mode397 /// open with exclusive file lock
430pub const O_APPEND = 0x00000008;398 pub const EXLOCK = 0x00000020;
431399 /// signal pgrp when data ready
432/// open with shared file lock400 pub const ASYNC = 0x00000040;
433pub const O_SHLOCK = 0x00000010;401 /// synchronous writes
434402 pub const SYNC = 0x00000080;
435/// open with exclusive file lock403 /// don't follow symlinks on the last
436pub const O_EXLOCK = 0x00000020;404 pub const NOFOLLOW = 0x00000100;
437405 /// create if nonexistent
438/// signal pgrp when data ready406 pub const CREAT = 0x00000200;
439pub const O_ASYNC = 0x00000040;407 /// truncate to zero length
440408 pub const TRUNC = 0x00000400;
441/// synchronous writes409 /// error if already exists
442pub const O_SYNC = 0x00000080;410 pub const EXCL = 0x00000800;
443411 /// don't assign controlling terminal
444/// don't follow symlinks on the last412 pub const NOCTTY = 0x00008000;
445pub const O_NOFOLLOW = 0x00000100;413 /// write: I/O data completion
446414 pub const DSYNC = SYNC;
447/// create if nonexistent415 /// read: I/O completion as for write
448pub const O_CREAT = 0x00000200;416 pub const RSYNC = SYNC;
449417 /// fail if not a directory
450/// truncate to zero length418 pub const DIRECTORY = 0x20000;
451pub const O_TRUNC = 0x00000400;419 /// set close on exec
452420 pub const CLOEXEC = 0x10000;
453/// error if already exists421};
454pub const O_EXCL = 0x00000800;
455
456/// don't assign controlling terminal
457pub const O_NOCTTY = 0x00008000;
458
459/// write: I/O data completion
460pub const O_DSYNC = O_SYNC;
461
462/// read: I/O completion as for write
463pub const O_RSYNC = O_SYNC;
464
465/// fail if not a directory
466pub const O_DIRECTORY = 0x20000;
467
468/// set close on exec
469pub const O_CLOEXEC = 0x10000;
470422
471pub const F = struct {423pub 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;
500pub const SEEK_CUR = 1;452pub const SEEK_CUR = 1;
501pub const SEEK_END = 2;453pub const SEEK_END = 2;
502454
503pub const SIG_BLOCK = 1;
504pub const SIG_UNBLOCK = 2;
505pub const SIG_SETMASK = 3;
506
507pub const SOCK = struct {455pub 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_DEVICE591// data/hint flags for EVFILT_DEVICE
644pub const NOTE_CHANGE = 0x00000001;592pub const NOTE_CHANGE = 0x00000001;
645593
646pub const TIOCCBRK = 0x2000747a;594pub const T = struct {
647pub const TIOCCDTR = 0x20007478;595 pub const IOCCBRK = 0x2000747a;
648pub const TIOCCONS = 0x80047462;596 pub const IOCCDTR = 0x20007478;
649pub const TIOCDCDTIMESTAMP = 0x40107458;597 pub const IOCCONS = 0x80047462;
650pub const TIOCDRAIN = 0x2000745e;598 pub const IOCDCDTIMESTAMP = 0x40107458;
651pub const TIOCEXCL = 0x2000740d;599 pub const IOCDRAIN = 0x2000745e;
652pub const TIOCEXT = 0x80047460;600 pub const IOCEXCL = 0x2000740d;
653pub const TIOCFLAG_CDTRCTS = 0x10;601 pub const IOCEXT = 0x80047460;
654pub const TIOCFLAG_CLOCAL = 0x2;602 pub const IOCFLAG_CDTRCTS = 0x10;
655pub const TIOCFLAG_CRTSCTS = 0x4;603 pub const IOCFLAG_CLOCAL = 0x2;
656pub const TIOCFLAG_MDMBUF = 0x8;604 pub const IOCFLAG_CRTSCTS = 0x4;
657pub const TIOCFLAG_SOFTCAR = 0x1;605 pub const IOCFLAG_MDMBUF = 0x8;
658pub const TIOCFLUSH = 0x80047410;606 pub const IOCFLAG_SOFTCAR = 0x1;
659pub const TIOCGETA = 0x402c7413;607 pub const IOCFLUSH = 0x80047410;
660pub const TIOCGETD = 0x4004741a;608 pub const IOCGETA = 0x402c7413;
661pub const TIOCGFLAGS = 0x4004745d;609 pub const IOCGETD = 0x4004741a;
662pub const TIOCGLINED = 0x40207442;610 pub const IOCGFLAGS = 0x4004745d;
663pub const TIOCGPGRP = 0x40047477;611 pub const IOCGLINED = 0x40207442;
664pub const TIOCGQSIZE = 0x40047481;612 pub const IOCGPGRP = 0x40047477;
665pub const TIOCGRANTPT = 0x20007447;613 pub const IOCGQSIZE = 0x40047481;
666pub const TIOCGSID = 0x40047463;614 pub const IOCGRANTPT = 0x20007447;
667pub const TIOCGSIZE = 0x40087468;615 pub const IOCGSID = 0x40047463;
668pub const TIOCGWINSZ = 0x40087468;616 pub const IOCGSIZE = 0x40087468;
669pub const TIOCMBIC = 0x8004746b;617 pub const IOCGWINSZ = 0x40087468;
670pub const TIOCMBIS = 0x8004746c;618 pub const IOCMBIC = 0x8004746b;
671pub const TIOCMGET = 0x4004746a;619 pub const IOCMBIS = 0x8004746c;
672pub const TIOCMSET = 0x8004746d;620 pub const IOCMGET = 0x4004746a;
673pub const TIOCM_CAR = 0x40;621 pub const IOCMSET = 0x8004746d;
674pub const TIOCM_CD = 0x40;622 pub const IOCM_CAR = 0x40;
675pub const TIOCM_CTS = 0x20;623 pub const IOCM_CD = 0x40;
676pub const TIOCM_DSR = 0x100;624 pub const IOCM_CTS = 0x20;
677pub const TIOCM_DTR = 0x2;625 pub const IOCM_DSR = 0x100;
678pub const TIOCM_LE = 0x1;626 pub const IOCM_DTR = 0x2;
679pub const TIOCM_RI = 0x80;627 pub const IOCM_LE = 0x1;
680pub const TIOCM_RNG = 0x80;628 pub const IOCM_RI = 0x80;
681pub const TIOCM_RTS = 0x4;629 pub const IOCM_RNG = 0x80;
682pub const TIOCM_SR = 0x10;630 pub const IOCM_RTS = 0x4;
683pub const TIOCM_ST = 0x8;631 pub const IOCM_SR = 0x10;
684pub const TIOCNOTTY = 0x20007471;632 pub const IOCM_ST = 0x8;
685pub const TIOCNXCL = 0x2000740e;633 pub const IOCNOTTY = 0x20007471;
686pub const TIOCOUTQ = 0x40047473;634 pub const IOCNXCL = 0x2000740e;
687pub const TIOCPKT = 0x80047470;635 pub const IOCOUTQ = 0x40047473;
688pub const TIOCPKT_DATA = 0x0;636 pub const IOCPKT = 0x80047470;
689pub const TIOCPKT_DOSTOP = 0x20;637 pub const IOCPKT_DATA = 0x0;
690pub const TIOCPKT_FLUSHREAD = 0x1;638 pub const IOCPKT_DOSTOP = 0x20;
691pub const TIOCPKT_FLUSHWRITE = 0x2;639 pub const IOCPKT_FLUSHREAD = 0x1;
692pub const TIOCPKT_IOCTL = 0x40;640 pub const IOCPKT_FLUSHWRITE = 0x2;
693pub const TIOCPKT_NOSTOP = 0x10;641 pub const IOCPKT_IOCTL = 0x40;
694pub const TIOCPKT_START = 0x8;642 pub const IOCPKT_NOSTOP = 0x10;
695pub const TIOCPKT_STOP = 0x4;643 pub const IOCPKT_START = 0x8;
696pub const TIOCPTMGET = 0x40287446;644 pub const IOCPKT_STOP = 0x4;
697pub const TIOCPTSNAME = 0x40287448;645 pub const IOCPTMGET = 0x40287446;
698pub const TIOCRCVFRAME = 0x80087445;646 pub const IOCPTSNAME = 0x40287448;
699pub const TIOCREMOTE = 0x80047469;647 pub const IOCRCVFRAME = 0x80087445;
700pub const TIOCSBRK = 0x2000747b;648 pub const IOCREMOTE = 0x80047469;
701pub const TIOCSCTTY = 0x20007461;649 pub const IOCSBRK = 0x2000747b;
702pub const TIOCSDTR = 0x20007479;650 pub const IOCSCTTY = 0x20007461;
703pub const TIOCSETA = 0x802c7414;651 pub const IOCSDTR = 0x20007479;
704pub const TIOCSETAF = 0x802c7416;652 pub const IOCSETA = 0x802c7414;
705pub const TIOCSETAW = 0x802c7415;653 pub const IOCSETAF = 0x802c7416;
706pub const TIOCSETD = 0x8004741b;654 pub const IOCSETAW = 0x802c7415;
707pub const TIOCSFLAGS = 0x8004745c;655 pub const IOCSETD = 0x8004741b;
708pub const TIOCSIG = 0x2000745f;656 pub const IOCSFLAGS = 0x8004745c;
709pub const TIOCSLINED = 0x80207443;657 pub const IOCSIG = 0x2000745f;
710pub const TIOCSPGRP = 0x80047476;658 pub const IOCSLINED = 0x80207443;
711pub const TIOCSQSIZE = 0x80047480;659 pub const IOCSPGRP = 0x80047476;
712pub const TIOCSSIZE = 0x80087467;660 pub const IOCSQSIZE = 0x80047480;
713pub const TIOCSTART = 0x2000746e;661 pub const IOCSSIZE = 0x80087467;
714pub const TIOCSTAT = 0x80047465;662 pub const IOCSTART = 0x2000746e;
715pub const TIOCSTI = 0x80017472;663 pub const IOCSTAT = 0x80047465;
716pub const TIOCSTOP = 0x2000746f;664 pub const IOCSTI = 0x80017472;
717pub const TIOCSWINSZ = 0x80087467;665 pub const IOCSTOP = 0x2000746f;
718pub const TIOCUCNTL = 0x80047466;666 pub const IOCSWINSZ = 0x80087467;
719pub const TIOCXMTFRAME = 0x80087444;667 pub const IOCUCNTL = 0x80047466;
668 pub const IOCXMTFRAME = 0x80087444;
669};
720670
721pub fn WEXITSTATUS(s: u32) u8 {671pub 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 {
752702
753const NSIG = 33;703const NSIG = 33;
754704
755pub const SIG_DFL = @intToPtr(?Sigaction.sigaction_fn, 0);705pub const SIG = struct {
756pub const SIG_IGN = @intToPtr(?Sigaction.sigaction_fn, 1);706 pub const DFL = @intToPtr(?Sigaction.sigaction_fn, 0);
757pub const SIG_ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize));707 pub const IGN = @intToPtr(?Sigaction.sigaction_fn, 1);
758pub const SIG_CATCH = @intToPtr(?Sigaction.sigaction_fn, 2);708 pub const ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize));
759pub 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};
760750
761/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.751/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.
762pub const Sigaction = extern struct {752pub 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};
10151005
1016pub const S_IFMT = 0o170000;1006pub const S = struct {
10171007 pub const IFMT = 0o170000;
1018pub const S_IFIFO = 0o010000;1008
1019pub const S_IFCHR = 0o020000;1009 pub const IFIFO = 0o010000;
1020pub const S_IFDIR = 0o040000;1010 pub const IFCHR = 0o020000;
1021pub const S_IFBLK = 0o060000;1011 pub const IFDIR = 0o040000;
1022pub const S_IFREG = 0o100000;1012 pub const IFBLK = 0o060000;
1023pub const S_IFLNK = 0o120000;1013 pub const IFREG = 0o100000;
1024pub const S_IFSOCK = 0o140000;1014 pub const IFLNK = 0o120000;
10251015 pub const IFSOCK = 0o140000;
1026pub const S_ISUID = 0o4000;1016
1027pub const S_ISGID = 0o2000;1017 pub const ISUID = 0o4000;
1028pub const S_ISVTX = 0o1000;1018 pub const ISGID = 0o2000;
1029pub const S_IRWXU = 0o700;1019 pub const ISVTX = 0o1000;
1030pub const S_IRUSR = 0o400;1020 pub const IRWXU = 0o700;
1031pub const S_IWUSR = 0o200;1021 pub const IRUSR = 0o400;
1032pub const S_IXUSR = 0o100;1022 pub const IWUSR = 0o200;
1033pub const S_IRWXG = 0o070;1023 pub const IXUSR = 0o100;
1034pub const S_IRGRP = 0o040;1024 pub const IRWXG = 0o070;
1035pub const S_IWGRP = 0o020;1025 pub const IRGRP = 0o040;
1036pub const S_IXGRP = 0o010;1026 pub const IWGRP = 0o020;
1037pub const S_IRWXO = 0o007;1027 pub const IXGRP = 0o010;
1038pub const S_IROTH = 0o004;1028 pub const IRWXO = 0o007;
1039pub const S_IWOTH = 0o002;1029 pub const IROTH = 0o004;
1040pub const S_IXOTH = 0o001;1030 pub const IWOTH = 0o002;
10411031 pub const IXOTH = 0o001;
1042pub 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 }
10451036
1046pub 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 }
10491040
1050pub 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 }
10531044
1054pub 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 }
10571048
1058pub 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 }
10611052
1062pub 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 }
10651056
1066pub 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};
10691061
1070pub const AT = struct {1062pub const AT = struct {
1071 /// Magic value that specify the use of the current working directory1063 /// 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;
17pub const mode_t = wasi.mode_t;17pub const mode_t = wasi.mode_t;
18pub const time_t = wasi.time_t;18pub const time_t = wasi.time_t;
19pub const timespec = wasi.timespec;19pub const timespec = wasi.timespec;
20pub const STDERR_FILENO = wasi.STDERR_FILENO;
21pub const STDIN_FILENO = wasi.STDIN_FILENO;
22pub const STDOUT_FILENO = wasi.STDOUT_FILENO;
23pub const E = wasi.E;
24pub const CLOCK = wasi.CLOCK;
2025
21pub const Stat = extern struct {26pub 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 {
1470pub const have_segfault_handling_support = switch (native_os) {1470pub 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};
1476pub const enable_segfault_handler: bool = if (@hasDecl(root, "enable_segfault_handler"))1476pub 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 the906 /// * `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;
483483
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 };
493493
...@@ -678,12 +678,12 @@ pub const Dir = struct {...@@ -678,12 +678,12 @@ pub const Dir = struct {
678 }678 }
679679
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 }
910910
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 lock912 // 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() call916 // 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.NONBLOCK919 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 }
10731073
1074 // Use the O_ locking flags if the os supports them to acquire the lock1074 // 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() call1077 // 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.NONBLOCK1080 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 directories1429 error.FileTooBig => unreachable, // can't happen for directories
1430 error.IsDir => unreachable, // we're providing O_DIRECTORY1430 error.IsDir => unreachable, // we're providing O.DIRECTORY
1431 error.NoSpaceLeft => unreachable, // not providing O_CREAT1431 error.NoSpaceLeft => unreachable, // not providing O.CREAT
1432 error.PathAlreadyExists => unreachable, // not providing O_CREAT1432 error.PathAlreadyExists => unreachable, // not providing O.CREAT
1433 error.FileLocksNotSupported => unreachable, // locking folders is not supported1433 error.FileLocksNotSupported => unreachable, // locking folders is not supported
1434 error.WouldBlock => unreachable, // can't happen for directories1434 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 }
14651465
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 directories1473 error.FileTooBig => unreachable, // can't happen for directories
1474 error.IsDir => unreachable, // we're providing O_DIRECTORY1474 error.IsDir => unreachable, // we're providing O.DIRECTORY
1475 error.NoSpaceLeft => unreachable, // not providing O_CREAT1475 error.NoSpaceLeft => unreachable, // not providing O.CREAT
1476 error.PathAlreadyExists => unreachable, // not providing O_CREAT1476 error.PathAlreadyExists => unreachable, // not providing O.CREAT
1477 error.FileLocksNotSupported => unreachable, // locking folders is not supported1477 error.FileLocksNotSupported => unreachable, // locking folders is not supported
1478 error.WouldBlock => unreachable, // can't happen for directories1478 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,
108108
109 /// Setting this to `.blocking` prevents `O_NONBLOCK` from being passed even109 /// 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 functions110 /// 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,
169169
170 /// Setting this to `.blocking` prevents `O_NONBLOCK` from being passed even170 /// 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 functions171 /// 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 };
251251
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;
72pub const Elf_Symndx = system.Elf_Symndx;72pub const Elf_Symndx = system.Elf_Symndx;
73pub const F = system.F;73pub const F = system.F;
74pub const FD_CLOEXEC = system.FD_CLOEXEC;74pub const FD_CLOEXEC = system.FD_CLOEXEC;
75pub const F_OK = system.F_OK;
76pub const Flock = system.Flock;75pub const Flock = system.Flock;
77pub const HOST_NAME_MAX = system.HOST_NAME_MAX;76pub const HOST_NAME_MAX = system.HOST_NAME_MAX;
78pub const IFNAMESIZE = system.IFNAMESIZE;77pub const IFNAMESIZE = system.IFNAMESIZE;
...@@ -96,7 +95,6 @@ pub const REG = system.REG;...@@ -96,7 +95,6 @@ pub const REG = system.REG;
96pub const RIGHT = system.RIGHT;95pub const RIGHT = system.RIGHT;
97pub const RLIM = system.RLIM;96pub const RLIM = system.RLIM;
98pub const RR = system.RR;97pub const RR = system.RR;
99pub const R_OK = system.R_OK;
100pub const S = system.S;98pub const S = system.S;
101pub const SA = system.SA;99pub const SA = system.SA;
102pub const SC = system.SC;100pub const SC = system.SC;
...@@ -116,8 +114,6 @@ pub const Stat = system.Stat;...@@ -116,8 +114,6 @@ pub const Stat = system.Stat;
116pub const TCSA = system.TCSA;114pub const TCSA = system.TCSA;
117pub const VDSO = system.VDSO;115pub const VDSO = system.VDSO;
118pub const W = system.W;116pub const W = system.W;
119pub const W_OK = system.W_OK;
120pub const X_OK = system.X_OK;
121pub const addrinfo = system.addrinfo;117pub const addrinfo = system.addrinfo;
122pub const blkcnt_t = system.blkcnt_t;118pub const blkcnt_t = system.blkcnt_t;
123pub const blksize_t = system.blksize_t;119pub 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;
165pub const user_desc = system.user_desc;161pub const user_desc = system.user_desc;
166pub const utsname = system.utsname;162pub const utsname = system.utsname;
167163
164pub const F_OK = system.F_OK;
165pub const R_OK = system.R_OK;
166pub const W_OK = system.W_OK;
167pub const X_OK = system.X_OK;
168
168pub const iovec = extern struct {169pub 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 condition4243 .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 condition4291 .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 condition4338 .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 condition4385 .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;
57pub const syscall_pipe = syscall_bits.syscall_pipe;57pub const syscall_pipe = syscall_bits.syscall_pipe;
58pub const syscall_fork = syscall_bits.syscall_fork;58pub const syscall_fork = syscall_bits.syscall_fork;
5959
60pub const clone = arch_bits.clone;
61pub const ARCH = arch_bits.ARCH;60pub const ARCH = arch_bits.ARCH;
62pub const Elf_Symndx = arch_bits.Elf_Symndx;61pub const Elf_Symndx = arch_bits.Elf_Symndx;
63pub const F = arch_bits.F;62pub const F = arch_bits.F;
64pub const Flock = arch_bits.Flock;63pub const Flock = arch_bits.Flock;
64pub const HWCAP = arch_bits.HWCAP;
65pub const LOCK = arch_bits.LOCK;65pub const LOCK = arch_bits.LOCK;
66pub const MAP = arch_bits.MAP;
67pub const MMAP2_UNIT = arch_bits.MMAP2_UNIT;66pub const MMAP2_UNIT = arch_bits.MMAP2_UNIT;
68pub const O = arch_bits.O;
69pub const REG = arch_bits.REG;67pub const REG = arch_bits.REG;
70pub const SC = arch_bits.SC;68pub const SC = arch_bits.SC;
71pub const SYS = arch_bits.SYS;69pub const SYS = arch_bits.SYS;
70pub const Stat = arch_bits.Stat;
72pub const VDSO = arch_bits.VDSO;71pub const VDSO = arch_bits.VDSO;
73pub const blkcnt_t = arch_bits.blkcnt_t;72pub const blkcnt_t = arch_bits.blkcnt_t;
74pub const blksize_t = arch_bits.blksize_t;73pub const blksize_t = arch_bits.blksize_t;
74pub const clone = arch_bits.clone;
75pub const dev_t = arch_bits.dev_t;75pub const dev_t = arch_bits.dev_t;
76pub const ino_t = arch_bits.ino_t;76pub const ino_t = arch_bits.ino_t;
77pub const Stat = arch_bits.Stat;
78pub const mcontext_t = arch_bits.mcontext_t;77pub const mcontext_t = arch_bits.mcontext_t;
79pub const mode_t = arch_bits.mode_t;78pub const mode_t = arch_bits.mode_t;
80pub const msghdr = arch_bits.msghdr;79pub 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");
92pub const pie = @import("linux/start_pie.zig");91pub const pie = @import("linux/start_pie.zig");
93pub const BPF = @import("linux/bpf.zig");92pub const BPF = @import("linux/bpf.zig");
9493
95const io_uring = @import("linux/io_uring.zig");94pub const MAP = struct {
96pub const IO_Uring = io_uring.IO_Uring;95 pub usingnamespace arch_bits.MAP;
97pub const SubmissionQueue = io_uring.SubmissionQueue;96
98pub const CompletionQueue = io_uring.CompletionQueue;97 /// Share changes
99pub const io_uring_prep_nop = io_uring.io_uring_prep_nop;98 pub const SHARED = 0x01;
100pub const io_uring_prep_fsync = io_uring.io_uring_prep_fsync;99 /// Changes are private
101pub const io_uring_prep_rw = io_uring.io_uring_prep_rw;100 pub const PRIVATE = 0x02;
102pub const io_uring_prep_read = io_uring.io_uring_prep_read;101 /// share + validate extension flags
103pub const io_uring_prep_write = io_uring.io_uring_prep_write;102 pub const SHARED_VALIDATE = 0x03;
104pub const io_uring_prep_readv = io_uring.io_uring_prep_readv;103 /// Mask for type of mapping
105pub const io_uring_prep_writev = io_uring.io_uring_prep_writev;104 pub const TYPE = 0x0f;
106pub const io_uring_prep_accept = io_uring.io_uring_prep_accept;105 /// Interpret addr exactly
107pub const io_uring_prep_connect = io_uring.io_uring_prep_connect;106 pub const FIXED = 0x10;
108pub const io_uring_prep_epoll_ctl = io_uring.io_uring_prep_epoll_ctl;107 /// don't use a file
109pub const io_uring_prep_recv = io_uring.io_uring_prep_recv;108 pub const ANONYMOUS = 0x20;
110pub const io_uring_prep_send = io_uring.io_uring_prep_send;109 /// populate (prefault) pagetables
111pub const io_uring_prep_openat = io_uring.io_uring_prep_openat;110 pub const POPULATE = 0x8000;
112pub const io_uring_prep_close = io_uring.io_uring_prep_close;111 /// do not block on IO
113pub const io_uring_prep_timeout = io_uring.io_uring_prep_timeout;112 pub const NONBLOCK = 0x10000;
114pub 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
115pub const io_uring_prep_poll_add = io_uring.io_uring_prep_poll_add;114 pub const STACK = 0x20000;
116pub const io_uring_prep_poll_remove = io_uring.io_uring_prep_poll_remove;115 /// create a huge page mapping
117pub 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
125pub 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
133pub usingnamespace @import("linux/io_uring.zig");
118134
119/// Set by startup code, used by `getauxval`.135/// Set by startup code, used by `getauxval`.
120pub var elf_aux_maybe: ?[*]std.elf.Auxv = null;136pub var elf_aux_maybe: ?[*]std.elf.Auxv = null;
...@@ -1725,26 +1741,20 @@ pub const FUTEX = struct {...@@ -1725,26 +1741,20 @@ pub const FUTEX = struct {
1725pub const PROT = struct {1741pub const PROT = struct {
1726 /// page can not be accessed1742 /// page can not be accessed
1727 pub const NONE = 0x0;1743 pub const NONE = 0x0;
1728
1729 /// page can be read1744 /// page can be read
1730 pub const READ = 0x1;1745 pub const READ = 0x1;
1731
1732 /// page can be written1746 /// page can be written
1733 pub const WRITE = 0x2;1747 pub const WRITE = 0x2;
1734
1735 /// page can be executed1748 /// page can be executed
1736 pub const EXEC = 0x4;1749 pub const EXEC = 0x4;
1737
1738 /// page may be used for atomic ops1750 /// page may be used for atomic ops
1739 pub const SEM = switch (native_arch) {1751 pub const SEM = switch (native_arch) {
1740 // TODO: also xtensa1752 // 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 vma1756 /// 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 vma1758 /// 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 possible1970 /// high priority request, poll if possible
1961 pub const HIPRI: kernel_rwf = 0x00000001;1971 pub const HIPRI: kernel_rwf = 0x00000001;
19621972
1963 /// per-IO O_DSYNC1973 /// per-IO O.DSYNC
1964 pub const DSYNC: kernel_rwf = 0x00000002;1974 pub const DSYNC: kernel_rwf = 0x00000002;
19651975
1966 /// per-IO O_SYNC1976 /// per-IO O.SYNC
1967 pub const SYNC: kernel_rwf = 0x00000004;1977 pub const SYNC: kernel_rwf = 0x00000004;
19681978
1969 /// per-IO, return -EAGAIN if operation would block1979 /// per-IO, return -EAGAIN if operation would block
1970 pub const NOWAIT: kernel_rwf = 0x00000008;1980 pub const NOWAIT: kernel_rwf = 0x00000008;
19711981
1972 /// per-IO O_APPEND1982 /// per-IO O.APPEND
1973 pub const APPEND: kernel_rwf = 0x00000010;1983 pub const APPEND: kernel_rwf = 0x00000010;
1974};1984};
19751985
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) {
532532
533pub const MMAP2_UNIT = 4096;533pub const MMAP2_UNIT = 4096;
534534
535pub const O_CREAT = 0o100;535pub const O = struct {
536pub const O_EXCL = 0o200;536 pub const CREAT = 0o100;
537pub const O_NOCTTY = 0o400;537 pub const EXCL = 0o200;
538pub const O_TRUNC = 0o1000;538 pub const NOCTTY = 0o400;
539pub const O_APPEND = 0o2000;539 pub const TRUNC = 0o1000;
540pub const O_NONBLOCK = 0o4000;540 pub const APPEND = 0o2000;
541pub const O_DSYNC = 0o10000;541 pub const NONBLOCK = 0o4000;
542pub const O_SYNC = 0o4010000;542 pub const DSYNC = 0o10000;
543pub const O_RSYNC = 0o4010000;543 pub const SYNC = 0o4010000;
544pub const O_DIRECTORY = 0o40000;544 pub const RSYNC = 0o4010000;
545pub const O_NOFOLLOW = 0o100000;545 pub const DIRECTORY = 0o40000;
546pub const O_CLOEXEC = 0o2000000;546 pub const NOFOLLOW = 0o100000;
547547 pub const CLOEXEC = 0o2000000;
548pub const O_ASYNC = 0o20000;548
549pub const O_DIRECT = 0o200000;549 pub const ASYNC = 0o20000;
550pub const O_LARGEFILE = 0o400000;550 pub const DIRECT = 0o200000;
551pub const O_NOATIME = 0o1000000;551 pub const LARGEFILE = 0o400000;
552pub const O_PATH = 0o10000000;552 pub const NOATIME = 0o1000000;
553pub const O_TMPFILE = 0o20040000;553 pub const PATH = 0o10000000;
554pub const O_NDELAY = O_NONBLOCK;554 pub const TMPFILE = 0o20040000;
555 pub const NDELAY = NONBLOCK;
556};
555557
556pub const F = struct {558pub 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 reservations600 /// 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};
603pub const VDSO_CGT_SYM = "__vdso_clock_gettime";603
604pub const VDSO_CGT_VER = "LINUX_2.6";604pub const VDSO = struct {
605605 pub const CGT_SYM = "__vdso_clock_gettime";
606pub const HWCAP_SWP = 1 << 0;606 pub const CGT_VER = "LINUX_2.6";
607pub const HWCAP_HALF = 1 << 1;607};
608pub const HWCAP_THUMB = 1 << 2;608
609pub const HWCAP_26BIT = 1 << 3;609pub const HWCAP = struct {
610pub const HWCAP_FAST_MULT = 1 << 4;610 pub const SWP = 1 << 0;
611pub const HWCAP_FPA = 1 << 5;611 pub const HALF = 1 << 1;
612pub const HWCAP_VFP = 1 << 6;612 pub const THUMB = 1 << 2;
613pub const HWCAP_EDSP = 1 << 7;613 pub const @"26BIT" = 1 << 3;
614pub const HWCAP_JAVA = 1 << 8;614 pub const FAST_MULT = 1 << 4;
615pub const HWCAP_IWMMXT = 1 << 9;615 pub const FPA = 1 << 5;
616pub const HWCAP_CRUNCH = 1 << 10;616 pub const VFP = 1 << 6;
617pub const HWCAP_THUMBEE = 1 << 11;617 pub const EDSP = 1 << 7;
618pub const HWCAP_NEON = 1 << 12;618 pub const JAVA = 1 << 8;
619pub const HWCAP_VFPv3 = 1 << 13;619 pub const IWMMXT = 1 << 9;
620pub const HWCAP_VFPv3D16 = 1 << 14;620 pub const CRUNCH = 1 << 10;
621pub const HWCAP_TLS = 1 << 15;621 pub const THUMBEE = 1 << 11;
622pub const HWCAP_VFPv4 = 1 << 16;622 pub const NEON = 1 << 12;
623pub const HWCAP_IDIVA = 1 << 17;623 pub const VFPv3 = 1 << 13;
624pub const HWCAP_IDIVT = 1 << 18;624 pub const VFPv3D16 = 1 << 14;
625pub const HWCAP_VFPD32 = 1 << 19;625 pub const TLS = 1 << 15;
626pub const HWCAP_IDIV = HWCAP_IDIVA | HWCAP_IDIVT;626 pub const VFPv4 = 1 << 16;
627pub const HWCAP_LPAE = 1 << 20;627 pub const IDIVA = 1 << 17;
628pub 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};
629634
630pub const Flock = extern struct {635pub 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};
412412
413pub const O_CREAT = 0o100;413pub const O = struct {
414pub const O_EXCL = 0o200;414 pub const CREAT = 0o100;
415pub const O_NOCTTY = 0o400;415 pub const EXCL = 0o200;
416pub const O_TRUNC = 0o1000;416 pub const NOCTTY = 0o400;
417pub const O_APPEND = 0o2000;417 pub const TRUNC = 0o1000;
418pub const O_NONBLOCK = 0o4000;418 pub const APPEND = 0o2000;
419pub const O_DSYNC = 0o10000;419 pub const NONBLOCK = 0o4000;
420pub const O_SYNC = 0o4010000;420 pub const DSYNC = 0o10000;
421pub const O_RSYNC = 0o4010000;421 pub const SYNC = 0o4010000;
422pub const O_DIRECTORY = 0o40000;422 pub const RSYNC = 0o4010000;
423pub const O_NOFOLLOW = 0o100000;423 pub const DIRECTORY = 0o40000;
424pub const O_CLOEXEC = 0o2000000;424 pub const NOFOLLOW = 0o100000;
425425 pub const CLOEXEC = 0o2000000;
426pub const O_ASYNC = 0o20000;426
427pub const O_DIRECT = 0o200000;427 pub const ASYNC = 0o20000;
428pub const O_LARGEFILE = 0o400000;428 pub const DIRECT = 0o200000;
429pub const O_NOATIME = 0o1000000;429 pub const LARGEFILE = 0o400000;
430pub const O_PATH = 0o10000000;430 pub const NOATIME = 0o1000000;
431pub const O_TMPFILE = 0o20040000;431 pub const PATH = 0o10000000;
432pub const O_NDELAY = O_NONBLOCK;432 pub const TMPFILE = 0o20040000;
433 pub const NDELAY = NONBLOCK;
434};
433435
434pub const F = struct {436pub 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 reservations478 /// 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};
481pub const VDSO_CGT_SYM = "__kernel_clock_gettime";481
482pub const VDSO_CGT_VER = "LINUX_2.6.39";482pub const VDSO = struct {
483 pub const CGT_SYM = "__kernel_clock_gettime";
484 pub const CGT_VER = "LINUX_2.6.39";
485};
483486
484pub const Flock = extern struct {487pub 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};
573573
574pub const O = struct {574pub 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};
629625
630pub const MAP = struct {626pub 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};
668634
669pub const MMAP2_UNIT = 4096;635pub 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 {
979979
980pub fn io_uring_prep_timeout(980pub 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();
11381138
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);
11411141
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 {};
12971297
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)" {
14501450
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 };
14541454
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();
14811481
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();
15141514
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};
631631
632pub const O_CREAT = 0o0400;632pub const O = struct {
633pub const O_EXCL = 0o02000;633 pub const CREAT = 0o0400;
634pub const O_NOCTTY = 0o04000;634 pub const EXCL = 0o02000;
635pub const O_TRUNC = 0o01000;635 pub const NOCTTY = 0o04000;
636pub const O_APPEND = 0o0010;636 pub const TRUNC = 0o01000;
637pub const O_NONBLOCK = 0o0200;637 pub const APPEND = 0o0010;
638pub const O_DSYNC = 0o0020;638 pub const NONBLOCK = 0o0200;
639pub const O_SYNC = 0o040020;639 pub const DSYNC = 0o0020;
640pub const O_RSYNC = 0o040020;640 pub const SYNC = 0o040020;
641pub const O_DIRECTORY = 0o0200000;641 pub const RSYNC = 0o040020;
642pub const O_NOFOLLOW = 0o0400000;642 pub const DIRECTORY = 0o0200000;
643pub const O_CLOEXEC = 0o02000000;643 pub const NOFOLLOW = 0o0400000;
644644 pub const CLOEXEC = 0o02000000;
645pub const O_ASYNC = 0o010000;645
646pub const O_DIRECT = 0o0100000;646 pub const ASYNC = 0o010000;
647pub const O_LARGEFILE = 0o020000;647 pub const DIRECT = 0o0100000;
648pub const O_NOATIME = 0o01000000;648 pub const LARGEFILE = 0o020000;
649pub const O_PATH = 0o010000000;649 pub const NOATIME = 0o01000000;
650pub const O_TMPFILE = 0o020200000;650 pub const PATH = 0o010000000;
651pub const O_NDELAY = O_NONBLOCK;651 pub const TMPFILE = 0o020200000;
652 pub const NDELAY = NONBLOCK;
653};
652654
653pub const F = struct {655pub 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};
698698
699pub const SO = struct {699pub 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};
728728
729pub const VDSO_CGT_SYM = "__kernel_clock_gettime";729pub const VDSO = struct {
730pub 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};
731733
732pub const Flock = extern struct {734pub 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};
564564
565pub const O_CREAT = 0o100;565pub const O = struct {
566pub const O_EXCL = 0o200;566 pub const CREAT = 0o100;
567pub const O_NOCTTY = 0o400;567 pub const EXCL = 0o200;
568pub const O_TRUNC = 0o1000;568 pub const NOCTTY = 0o400;
569pub const O_APPEND = 0o2000;569 pub const TRUNC = 0o1000;
570pub const O_NONBLOCK = 0o4000;570 pub const APPEND = 0o2000;
571pub const O_DSYNC = 0o10000;571 pub const NONBLOCK = 0o4000;
572pub const O_SYNC = 0o4010000;572 pub const DSYNC = 0o10000;
573pub const O_RSYNC = 0o4010000;573 pub const SYNC = 0o4010000;
574pub const O_DIRECTORY = 0o40000;574 pub const RSYNC = 0o4010000;
575pub const O_NOFOLLOW = 0o100000;575 pub const DIRECTORY = 0o40000;
576pub const O_CLOEXEC = 0o2000000;576 pub const NOFOLLOW = 0o100000;
577577 pub const CLOEXEC = 0o2000000;
578pub const O_ASYNC = 0o20000;578
579pub const O_DIRECT = 0o400000;579 pub const ASYNC = 0o20000;
580pub const O_LARGEFILE = 0o200000;580 pub const DIRECT = 0o400000;
581pub const O_NOATIME = 0o1000000;581 pub const LARGEFILE = 0o200000;
582pub const O_PATH = 0o10000000;582 pub const NOATIME = 0o1000000;
583pub const O_TMPFILE = 0o20040000;583 pub const PATH = 0o10000000;
584pub const O_NDELAY = O_NONBLOCK;584 pub const TMPFILE = 0o20040000;
585 pub const NDELAY = NONBLOCK;
586};
585587
586pub const F = struct {588pub 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 reservations630 /// 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};
633pub const VDSO_CGT_SYM = "__kernel_clock_gettime";633
634pub const VDSO_CGT_VER = "LINUX_2.6.15";634pub const VDSO = struct {
635 pub const CGT_SYM = "__kernel_clock_gettime";
636 pub const CGT_VER = "LINUX_2.6.15";
637};
635638
636pub const Flock = extern struct {639pub 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};
539539
540pub const O_CREAT = 0o100;540pub const O = struct {
541pub const O_EXCL = 0o200;541 pub const CREAT = 0o100;
542pub const O_NOCTTY = 0o400;542 pub const EXCL = 0o200;
543pub const O_TRUNC = 0o1000;543 pub const NOCTTY = 0o400;
544pub const O_APPEND = 0o2000;544 pub const TRUNC = 0o1000;
545pub const O_NONBLOCK = 0o4000;545 pub const APPEND = 0o2000;
546pub const O_DSYNC = 0o10000;546 pub const NONBLOCK = 0o4000;
547pub const O_SYNC = 0o4010000;547 pub const DSYNC = 0o10000;
548pub const O_RSYNC = 0o4010000;548 pub const SYNC = 0o4010000;
549pub const O_DIRECTORY = 0o40000;549 pub const RSYNC = 0o4010000;
550pub const O_NOFOLLOW = 0o100000;550 pub const DIRECTORY = 0o40000;
551pub const O_CLOEXEC = 0o2000000;551 pub const NOFOLLOW = 0o100000;
552552 pub const CLOEXEC = 0o2000000;
553pub const O_ASYNC = 0o20000;553
554pub const O_DIRECT = 0o400000;554 pub const ASYNC = 0o20000;
555pub const O_LARGEFILE = 0o200000;555 pub const DIRECT = 0o400000;
556pub const O_NOATIME = 0o1000000;556 pub const LARGEFILE = 0o200000;
557pub const O_PATH = 0o10000000;557 pub const NOATIME = 0o1000000;
558pub const O_TMPFILE = 0o20200000;558 pub const PATH = 0o10000000;
559pub const O_NDELAY = O_NONBLOCK;559 pub const TMPFILE = 0o20200000;
560 pub const NDELAY = NONBLOCK;
561};
560562
561pub const F = struct {563pub 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 reservations605 /// 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};
608608
609pub const VDSO_CGT_SYM = "__kernel_clock_gettime";609pub const VDSO = struct {
610pub 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};
611613
612pub const Flock = extern struct {614pub 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};
408408
409pub const O_CREAT = 0o100;409pub const O = struct {
410pub const O_EXCL = 0o200;410 pub const CREAT = 0o100;
411pub const O_NOCTTY = 0o400;411 pub const EXCL = 0o200;
412pub const O_TRUNC = 0o1000;412 pub const NOCTTY = 0o400;
413pub const O_APPEND = 0o2000;413 pub const TRUNC = 0o1000;
414pub const O_NONBLOCK = 0o4000;414 pub const APPEND = 0o2000;
415pub const O_DSYNC = 0o10000;415 pub const NONBLOCK = 0o4000;
416pub const O_SYNC = 0o4010000;416 pub const DSYNC = 0o10000;
417pub const O_RSYNC = 0o4010000;417 pub const SYNC = 0o4010000;
418pub const O_DIRECTORY = 0o200000;418 pub const RSYNC = 0o4010000;
419pub const O_NOFOLLOW = 0o400000;419 pub const DIRECTORY = 0o200000;
420pub const O_CLOEXEC = 0o2000000;420 pub const NOFOLLOW = 0o400000;
421 pub const CLOEXEC = 0o2000000;
421422
422pub const O_ASYNC = 0o20000;423 pub const ASYNC = 0o20000;
423pub const O_DIRECT = 0o40000;424 pub const DIRECT = 0o40000;
424pub const O_LARGEFILE = 0o100000;425 pub const LARGEFILE = 0o100000;
425pub const O_NOATIME = 0o1000000;426 pub const NOATIME = 0o1000000;
426pub const O_PATH = 0o10000000;427 pub const PATH = 0o10000000;
427pub const O_TMPFILE = 0o20200000;428 pub const TMPFILE = 0o20200000;
428pub const O_NDELAY = O_NONBLOCK;429 pub const NDELAY = NONBLOCK;
430};
429431
430pub const F = struct {432pub 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};
519521
520pub const Elf_Symndx = u32;522pub const Elf_Symndx = u32;
523
524pub const VDSO = struct {};
525pub 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};
573573
574pub const O_CREAT = 0x200;574pub const O = struct {
575pub const O_EXCL = 0x800;575 pub const CREAT = 0x200;
576pub const O_NOCTTY = 0x8000;576 pub const EXCL = 0x800;
577pub const O_TRUNC = 0x400;577 pub const NOCTTY = 0x8000;
578pub const O_APPEND = 0x8;578 pub const TRUNC = 0x400;
579pub const O_NONBLOCK = 0x4000;579 pub const APPEND = 0x8;
580pub const O_SYNC = 0x802000;580 pub const NONBLOCK = 0x4000;
581pub const O_DSYNC = 0x2000;581 pub const SYNC = 0x802000;
582pub const O_RSYNC = O_SYNC;582 pub const DSYNC = 0x2000;
583pub const O_DIRECTORY = 0x10000;583 pub const RSYNC = SYNC;
584pub const O_NOFOLLOW = 0x20000;584 pub const DIRECTORY = 0x10000;
585pub const O_CLOEXEC = 0x400000;585 pub const NOFOLLOW = 0x20000;
586586 pub const CLOEXEC = 0x400000;
587pub const O_ASYNC = 0x40;587
588pub const O_DIRECT = 0x100000;588 pub const ASYNC = 0x40;
589pub const O_LARGEFILE = 0;589 pub const DIRECT = 0x100000;
590pub const O_NOATIME = 0x200000;590 pub const LARGEFILE = 0;
591pub const O_PATH = 0x1000000;591 pub const NOATIME = 0x200000;
592pub const O_TMPFILE = 0x2010000;592 pub const PATH = 0x1000000;
593pub const O_NDELAY = O_NONBLOCK | 0x4;593 pub const TMPFILE = 0x2010000;
594 pub const NDELAY = NONBLOCK | 0x4;
595};
594596
595pub const F = struct {597pub 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 reservations636 /// 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};
639pub const VDSO_CGT_SYM = "__vdso_clock_gettime";639
640pub const VDSO_CGT_VER = "LINUX_2.6";640pub const VDSO = struct {
641 pub const CGT_SYM = "__vdso_clock_gettime";
642 pub const CGT_VER = "LINUX_2.6";
643};
641644
642pub const Flock = extern struct {645pub 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};
477477
478pub const O = struct {478pub 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};
527523
528pub const MAP = struct {524pub 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 addresses525 /// only give out 32bit addresses
556 pub const @"32BIT" = 0x40;526 pub const @"32BIT" = 0x40;
557 /// stack-like segment527 /// 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 reservations535 /// 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};
570538
571pub const VDSO = struct {539pub const VDSO = struct {
lib/std/os/test.zig+2-2
...@@ -401,7 +401,7 @@ test "sigaltstack" {...@@ -401,7 +401,7 @@ test "sigaltstack" {
401401
402// If the type is not available use void to avoid erroring out when `iter_fn` is402// If the type is not available use void to avoid erroring out when `iter_fn` is
403// analyzed403// analyzed
404const dl_phdr_info = if (@hasDecl(os, "dl_phdr_info")) os.dl_phdr_info else c_void;404const dl_phdr_info = if (@hasDecl(os.system, "dl_phdr_info")) os.dl_phdr_info else c_void;
405405
406const IterFnError = error{406const IterFnError = error{
407 MissingPtLoadSegment,407 MissingPtLoadSegment,
...@@ -676,7 +676,7 @@ test "fsync" {...@@ -676,7 +676,7 @@ test "fsync" {
676}676}
677677
678test "getrlimit and setrlimit" {678test "getrlimit and setrlimit" {
679 if (native_os == .windows) {679 if (!@hasDecl(os.system, "rlimit")) {
680 return error.SkipZigTest;680 return error.SkipZigTest;
681 }681 }
682682
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};
339339
340/// Also known as `FILETYPE`.
340pub const filetype_t = enum(u8) {341pub 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;
532533
533pub const userdata_t = u64;534pub const userdata_t = u64;
534535
536/// Also known as `WHENCE`.
535pub const whence_t = enum(u8) { SET, CUR, END };537pub const whence_t = enum(u8) { SET, CUR, END };
536538
537pub const S = struct {539pub 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) {
31923192
3193pub const EXCEPTION_POINTERS = extern struct {3193pub 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};
31973197
3198pub const VECTORED_EXCEPTION_HANDLER = fn (ExceptionInfo: *EXCEPTION_POINTERS) callconv(WINAPI) c_long;3198pub 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}
3230
33export fn __stack_chk_fail() callconv(.C) noreturn {31export 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 API345 // 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_tls349 // 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 to350 // 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` if193 /// 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 returns203 /// 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 not304 /// 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;
6const math = std.math;6const math = std.math;
7const testing = std.testing;7const testing = std.testing;
8const native_os = std.Target.current.os;8const native_os = std.Target.current.os;
9const have_ifnamesize = @hasDecl(os.system, "IFNAMESIZE");
910
10/// Resolves a network interface name into a scope/zone ID. It returns11/// Resolves a network interface name into a scope/zone ID. It returns
11/// an error if either resolution fails, or if the interface name is12/// an error if either resolution fails, or if the interface name is
12/// too long.13/// too long.
13pub fn resolveScopeID(name: []const u8) !u32 {14pub 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;
1617
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}
557558
558test "ipv6: parse & format addresses with scope ids" {559test "ipv6: parse & format addresses with scope ids" {
559 if (!@hasDecl(os, "IFNAMESIZE")) return error.SkipZigTest;560 if (!have_ifnamesize) return error.SkipZigTest;
560561
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 @@
1usingnamespace @import("b.zig");
2
3pub const a_text = "OK\n";
4
5pub 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 @@
1usingnamespace @import("a.zig");
2
3pub const b_text = @This().a_text;
test/behavior/usingnamespace/bar.zig created+8
...@@ -0,0 +1,8 @@
1usingnamespace @import("other.zig");
2
3pub var saw_bar_function = false;
4pub 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
3fn privateFunction() bool {
4 return false;
5}
6
7pub fn printText() bool {
8 return privateFunction();
9}
10
11pub var saw_foo_function = false;
12pub fn foo_function() void {
13 saw_foo_function = true;
14}
test/behavior/usingnamespace/import_segregation.zig created+11
...@@ -0,0 +1,11 @@
1const expect = @import("std").testing.expect;
2
3usingnamespace @import("foo.zig");
4usingnamespace @import("bar.zig");
5
6test "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 @@
1pub 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 @@
1const std = @import("std");1const std = @import("std");
2const expect = std.testing.expect;
23
3fn Foo(comptime T: type) type {4fn Foo(comptime T: type) type {
4 return struct {5 return struct {
...@@ -20,3 +21,21 @@ usingnamespace struct {...@@ -20,3 +21,21 @@ usingnamespace struct {
20test "usingnamespace does not redeclare an imported variable" {21test "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
25usingnamespace @import("usingnamespace/foo.zig");
26test "usingnamespace omits mixing in private functions" {
27 try expect(@This().privateFunction());
28 try expect(!@This().printText());
29}
30fn privateFunction() bool {
31 return true;
32}
33
34test {
35 _ = @import("usingnamespace/import_segregation.zig");
36}
37
38usingnamespace @import("usingnamespace/a.zig");
39test "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}
4747
48fn 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
55fn printCmd(cwd: []const u8, argv: []const []const u8) void {48fn 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);
1919
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();
236236
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}
240240