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) {
5858};
5959
6060pub usingnamespace switch (builtin.os.tag) {
61 .netbsd => struct {},
62 .macos, .ios, .watchos, .tvos => struct {
63 // XXX: close -> close$NOCANCEL
64 // XXX: getdirentries -> _getdirentries64
65 pub extern "c" fn clock_getres(clk_id: c_int, tp: *c.timespec) c_int;
66 pub extern "c" fn clock_gettime(clk_id: c_int, tp: *c.timespec) c_int;
67 pub extern "c" fn getrusage(who: c_int, usage: *c.rusage) c_int;
68 pub extern "c" fn gettimeofday(noalias tv: ?*c.timeval, noalias tz: ?*c.timezone) c_int;
69 pub extern "c" fn nanosleep(rqtp: *const c.timespec, rmtp: ?*c.timespec) c_int;
70 pub extern "c" fn sched_yield() c_int;
71 pub extern "c" fn sigaction(sig: c_int, noalias act: ?*const c.Sigaction, noalias oact: ?*c.Sigaction) c_int;
72 pub extern "c" fn sigprocmask(how: c_int, noalias set: ?*const c.sigset_t, noalias oset: ?*c.sigset_t) c_int;
73 pub extern "c" fn socket(domain: c_uint, sock_type: c_uint, protocol: c_uint) c_int;
74 pub extern "c" fn stat(noalias path: [*:0]const u8, noalias buf: *c.Stat) c_int;
75 pub extern "c" fn sigfillset(set: ?*c.sigset_t) void;
76 pub extern "c" fn alarm(seconds: c_uint) c_uint;
77 pub extern "c" fn sigwait(set: ?*c.sigset_t, sig: ?*c_int) c_int;
78 },
79 .windows => struct {
80 // TODO: copied the else case and removed the socket function (because its in ws2_32)
81 // need to verify which of these is actually supported on windows
82 pub extern "c" fn clock_getres(clk_id: c_int, tp: *c.timespec) c_int;
83 pub extern "c" fn clock_gettime(clk_id: c_int, tp: *c.timespec) c_int;
84 pub extern "c" fn fstat(fd: c.fd_t, buf: *c.Stat) c_int;
85 pub extern "c" fn getrusage(who: c_int, usage: *c.rusage) c_int;
86 pub extern "c" fn gettimeofday(noalias tv: ?*c.timeval, noalias tz: ?*c.timezone) c_int;
87 pub extern "c" fn nanosleep(rqtp: *const c.timespec, rmtp: ?*c.timespec) c_int;
88 pub extern "c" fn sched_yield() c_int;
89 pub extern "c" fn sigaction(sig: c_int, noalias act: ?*const c.Sigaction, noalias oact: ?*c.Sigaction) c_int;
90 pub extern "c" fn sigprocmask(how: c_int, noalias set: ?*const c.sigset_t, noalias oset: ?*c.sigset_t) c_int;
91 pub extern "c" fn stat(noalias path: [*:0]const u8, noalias buf: *c.Stat) c_int;
92 pub extern "c" fn sigfillset(set: ?*c.sigset_t) void;
93 pub extern "c" fn alarm(seconds: c_uint) c_uint;
94 pub extern "c" fn sigwait(set: ?*c.sigset_t, sig: ?*c_int) c_int;
95 },
61 .netbsd, .macos, .ios, .watchos, .tvos, .windows => struct {},
9662 else => struct {
9763 pub extern "c" fn clock_getres(clk_id: c_int, tp: *c.timespec) c_int;
9864 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 {
395395pub const sigset_t = u32;
396396pub const empty_sigset: sigset_t = 0;
397397
398pub const SIG_ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize));
399pub const SIG_DFL = @intToPtr(?Sigaction.sigaction_fn, 0);
400pub const SIG_IGN = @intToPtr(?Sigaction.sigaction_fn, 1);
401pub const SIG_HOLD = @intToPtr(?Sigaction.sigaction_fn, 5);
398pub const SIG = struct {
399 pub const ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize));
400 pub const DFL = @intToPtr(?Sigaction.sigaction_fn, 0);
401 pub const IGN = @intToPtr(?Sigaction.sigaction_fn, 1);
402 pub const HOLD = @intToPtr(?Sigaction.sigaction_fn, 5);
403
404 /// block specified signal set
405 pub const _BLOCK = 1;
406 /// unblock specified signal set
407 pub const _UNBLOCK = 2;
408 /// set specified signal set
409 pub const _SETMASK = 3;
410 /// hangup
411 pub const HUP = 1;
412 /// interrupt
413 pub const INT = 2;
414 /// quit
415 pub const QUIT = 3;
416 /// illegal instruction (not reset when caught)
417 pub const ILL = 4;
418 /// trace trap (not reset when caught)
419 pub const TRAP = 5;
420 /// abort()
421 pub const ABRT = 6;
422 /// pollable event ([XSR] generated, not supported)
423 pub const POLL = 7;
424 /// compatibility
425 pub const IOT = ABRT;
426 /// EMT instruction
427 pub const EMT = 7;
428 /// floating point exception
429 pub const FPE = 8;
430 /// kill (cannot be caught or ignored)
431 pub const KILL = 9;
432 /// bus error
433 pub const BUS = 10;
434 /// segmentation violation
435 pub const SEGV = 11;
436 /// bad argument to system call
437 pub const SYS = 12;
438 /// write on a pipe with no one to read it
439 pub const PIPE = 13;
440 /// alarm clock
441 pub const ALRM = 14;
442 /// software termination signal from kill
443 pub const TERM = 15;
444 /// urgent condition on IO channel
445 pub const URG = 16;
446 /// sendable stop signal not from tty
447 pub const STOP = 17;
448 /// stop signal from tty
449 pub const TSTP = 18;
450 /// continue a stopped process
451 pub const CONT = 19;
452 /// to parent on child stop or exit
453 pub const CHLD = 20;
454 /// to readers pgrp upon background tty read
455 pub const TTIN = 21;
456 /// like TTIN for output if (tp->t_local&LTOSTOP)
457 pub const TTOU = 22;
458 /// input/output possible signal
459 pub const IO = 23;
460 /// exceeded CPU time limit
461 pub const XCPU = 24;
462 /// exceeded file size limit
463 pub const XFSZ = 25;
464 /// virtual time alarm
465 pub const VTALRM = 26;
466 /// profiling time alarm
467 pub const PROF = 27;
468 /// window size changes
469 pub const WINCH = 28;
470 /// information request
471 pub const INFO = 29;
472 /// user defined signal 1
473 pub const USR1 = 30;
474 /// user defined signal 2
475 pub const USR2 = 31;
476};
402477
403478pub const siginfo_t = extern struct {
404479 signo: c_int,
......@@ -507,17 +582,16 @@ pub const STDIN_FILENO = 0;
507582pub const STDOUT_FILENO = 1;
508583pub const STDERR_FILENO = 2;
509584
510/// [MC2] no permissions
511pub const PROT_NONE = 0x00;
512
513/// [MC2] pages can be read
514pub const PROT_READ = 0x01;
515
516/// [MC2] pages can be written
517pub const PROT_WRITE = 0x02;
518
519/// [MC2] pages can be executed
520pub const PROT_EXEC = 0x04;
585pub const PROT = struct {
586 /// [MC2] no permissions
587 pub const NONE = 0x00;
588 /// [MC2] pages can be read
589 pub const READ = 0x01;
590 /// [MC2] pages can be written
591 pub const WRITE = 0x02;
592 /// [MC2] pages can be executed
593 pub const EXEC = 0x04;
594};
521595
522596pub const MAP = struct {
523597 /// allocated from memory, swap space
......@@ -551,10 +625,10 @@ pub const SA_ONSTACK = 0x0001;
551625/// restart system on signal return
552626pub const SA_RESTART = 0x0002;
553627
554/// reset to SIG_DFL when taking signal
628/// reset to SIG.DFL when taking signal
555629pub const SA_RESETHAND = 0x0004;
556630
557/// do not generate SIGCHLD on child stop
631/// do not generate SIG.CHLD on child stop
558632pub const SA_NOCLDSTOP = 0x0008;
559633
560634/// don't mask the signal we're delivering
......@@ -572,66 +646,53 @@ pub const SA_USERTRAMP = 0x0100;
572646/// signal handler with SA_SIGINFO args with 64bit regs information
573647pub const SA_64REGSET = 0x0200;
574648
575pub const O_PATH = 0x0000;
576
577649pub const F_OK = 0;
578650pub const X_OK = 1;
579651pub const W_OK = 2;
580652pub const R_OK = 4;
581653
582/// open for reading only
583pub const O_RDONLY = 0x0000;
584
585/// open for writing only
586pub const O_WRONLY = 0x0001;
587
588/// open for reading and writing
589pub const O_RDWR = 0x0002;
590
591/// do not block on open or for data to become available
592pub const O_NONBLOCK = 0x0004;
593
594/// append on each write
595pub const O_APPEND = 0x0008;
596
597/// create file if it does not exist
598pub const O_CREAT = 0x0200;
599
600/// truncate size to 0
601pub const O_TRUNC = 0x0400;
602
603/// error if O_CREAT and the file exists
604pub const O_EXCL = 0x0800;
605
606/// atomically obtain a shared lock
607pub const O_SHLOCK = 0x0010;
608
609/// atomically obtain an exclusive lock
610pub const O_EXLOCK = 0x0020;
611
612/// do not follow symlinks
613pub const O_NOFOLLOW = 0x0100;
614
615/// allow open of symlinks
616pub const O_SYMLINK = 0x200000;
617
618/// descriptor requested for event notifications only
619pub const O_EVTONLY = 0x8000;
620
621/// mark as close-on-exec
622pub const O_CLOEXEC = 0x1000000;
623
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;
654pub const O = struct {
655 pub const PATH = 0x0000;
656 /// open for reading only
657 pub const RDONLY = 0x0000;
658 /// open for writing only
659 pub const WRONLY = 0x0001;
660 /// open for reading and writing
661 pub const RDWR = 0x0002;
662 /// do not block on open or for data to become available
663 pub const NONBLOCK = 0x0004;
664 /// append on each write
665 pub const APPEND = 0x0008;
666 /// create file if it does not exist
667 pub const CREAT = 0x0200;
668 /// truncate size to 0
669 pub const TRUNC = 0x0400;
670 /// error if CREAT and the file exists
671 pub const EXCL = 0x0800;
672 /// atomically obtain a shared lock
673 pub const SHLOCK = 0x0010;
674 /// atomically obtain an exclusive lock
675 pub const EXLOCK = 0x0020;
676 /// do not follow symlinks
677 pub const NOFOLLOW = 0x0100;
678 /// allow open of symlinks
679 pub const SYMLINK = 0x200000;
680 /// descriptor requested for event notifications only
681 pub const EVTONLY = 0x8000;
682 /// mark as close-on-exec
683 pub const CLOEXEC = 0x1000000;
684 pub const ACCMODE = 3;
685 pub const ALERT = 536870912;
686 pub const ASYNC = 64;
687 pub const DIRECTORY = 1048576;
688 pub const DP_GETRAWENCRYPTED = 1;
689 pub const DP_GETRAWUNENCRYPTED = 2;
690 pub const DSYNC = 4194304;
691 pub const FSYNC = SYNC;
692 pub const NOCTTY = 131072;
693 pub const POPUP = 2147483648;
694 pub const SYNC = 128;
695};
635696
636697pub const SEEK_SET = 0x0;
637698pub const SEEK_CUR = 0x1;
......@@ -647,114 +708,6 @@ pub const DT_LNK = 10;
647708pub const DT_SOCK = 12;
648709pub 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
758711/// no flag value
759712pub const KEVENT_FLAG_NONE = 0x000;
760713
......@@ -1116,28 +1069,31 @@ pub const SO = struct {
11161069 pub const REUSESHAREUID = 0x1025;
11171070};
11181071
1119fn wstatus(x: u32) u32 {
1120 return x & 0o177;
1121}
1122const wstopped = 0o177;
1123pub fn WEXITSTATUS(x: u32) u8 {
1124 return @intCast(u8, x >> 8);
1125}
1126pub fn WTERMSIG(x: u32) u32 {
1127 return wstatus(x);
1128}
1129pub fn WSTOPSIG(x: u32) u32 {
1130 return x >> 8;
1131}
1132pub fn WIFEXITED(x: u32) bool {
1133 return wstatus(x) == 0;
1134}
1135pub fn WIFSTOPPED(x: u32) bool {
1136 return wstatus(x) == wstopped and WSTOPSIG(x) != 0x13;
1137}
1138pub fn WIFSIGNALED(x: u32) bool {
1139 return wstatus(x) != wstopped and wstatus(x) != 0;
1140}
1072pub const W = struct {
1073 pub fn EXITSTATUS(x: u32) u8 {
1074 return @intCast(u8, x >> 8);
1075 }
1076 pub fn TERMSIG(x: u32) u32 {
1077 return status(x);
1078 }
1079 pub fn STOPSIG(x: u32) u32 {
1080 return x >> 8;
1081 }
1082 pub fn IFEXITED(x: u32) bool {
1083 return status(x) == 0;
1084 }
1085 pub fn IFSTOPPED(x: u32) bool {
1086 return status(x) == stopped and STOPSIG(x) != 0x13;
1087 }
1088 pub fn IFSIGNALED(x: u32) bool {
1089 return status(x) != stopped and status(x) != 0;
1090 }
1091
1092 fn status(x: u32) u32 {
1093 return x & 0o177;
1094 }
1095 const stopped = 0o177;
1096};
11411097
11421098pub const E = enum(u16) {
11431099 /// No error occurred.
......@@ -1488,64 +1444,66 @@ pub const stack_t = extern struct {
14881444 ss_flags: i32,
14891445};
14901446
1491pub const S_IFMT = 0o170000;
1492
1493pub const S_IFIFO = 0o010000;
1494pub const S_IFCHR = 0o020000;
1495pub const S_IFDIR = 0o040000;
1496pub const S_IFBLK = 0o060000;
1497pub const S_IFREG = 0o100000;
1498pub const S_IFLNK = 0o120000;
1499pub const S_IFSOCK = 0o140000;
1500pub const S_IFWHT = 0o160000;
1501
1502pub const S_ISUID = 0o4000;
1503pub const S_ISGID = 0o2000;
1504pub const S_ISVTX = 0o1000;
1505pub const S_IRWXU = 0o700;
1506pub const S_IRUSR = 0o400;
1507pub const S_IWUSR = 0o200;
1508pub const S_IXUSR = 0o100;
1509pub const S_IRWXG = 0o070;
1510pub const S_IRGRP = 0o040;
1511pub const S_IWGRP = 0o020;
1512pub const S_IXGRP = 0o010;
1513pub const S_IRWXO = 0o007;
1514pub const S_IROTH = 0o004;
1515pub const S_IWOTH = 0o002;
1516pub const S_IXOTH = 0o001;
1517
1518pub fn S_ISFIFO(m: u32) bool {
1519 return m & S_IFMT == S_IFIFO;
1520}
1447pub const S = struct {
1448 pub const IFMT = 0o170000;
1449
1450 pub const IFIFO = 0o010000;
1451 pub const IFCHR = 0o020000;
1452 pub const IFDIR = 0o040000;
1453 pub const IFBLK = 0o060000;
1454 pub const IFREG = 0o100000;
1455 pub const IFLNK = 0o120000;
1456 pub const IFSOCK = 0o140000;
1457 pub const IFWHT = 0o160000;
1458
1459 pub const ISUID = 0o4000;
1460 pub const ISGID = 0o2000;
1461 pub const ISVTX = 0o1000;
1462 pub const IRWXU = 0o700;
1463 pub const IRUSR = 0o400;
1464 pub const IWUSR = 0o200;
1465 pub const IXUSR = 0o100;
1466 pub const IRWXG = 0o070;
1467 pub const IRGRP = 0o040;
1468 pub const IWGRP = 0o020;
1469 pub const IXGRP = 0o010;
1470 pub const IRWXO = 0o007;
1471 pub const IROTH = 0o004;
1472 pub const IWOTH = 0o002;
1473 pub const IXOTH = 0o001;
1474
1475 pub fn ISFIFO(m: u32) bool {
1476 return m & IFMT == IFIFO;
1477 }
15211478
1522pub fn S_ISCHR(m: u32) bool {
1523 return m & S_IFMT == S_IFCHR;
1524}
1479 pub fn ISCHR(m: u32) bool {
1480 return m & IFMT == IFCHR;
1481 }
15251482
1526pub fn S_ISDIR(m: u32) bool {
1527 return m & S_IFMT == S_IFDIR;
1528}
1483 pub fn ISDIR(m: u32) bool {
1484 return m & IFMT == IFDIR;
1485 }
15291486
1530pub fn S_ISBLK(m: u32) bool {
1531 return m & S_IFMT == S_IFBLK;
1532}
1487 pub fn ISBLK(m: u32) bool {
1488 return m & IFMT == IFBLK;
1489 }
15331490
1534pub fn S_ISREG(m: u32) bool {
1535 return m & S_IFMT == S_IFREG;
1536}
1491 pub fn ISREG(m: u32) bool {
1492 return m & IFMT == IFREG;
1493 }
15371494
1538pub fn S_ISLNK(m: u32) bool {
1539 return m & S_IFMT == S_IFLNK;
1540}
1495 pub fn ISLNK(m: u32) bool {
1496 return m & IFMT == IFLNK;
1497 }
15411498
1542pub fn S_ISSOCK(m: u32) bool {
1543 return m & S_IFMT == S_IFSOCK;
1544}
1499 pub fn ISSOCK(m: u32) bool {
1500 return m & IFMT == IFSOCK;
1501 }
15451502
1546pub fn S_IWHT(m: u32) bool {
1547 return m & S_IFMT == S_IFWHT;
1548}
1503 pub fn IWHT(m: u32) bool {
1504 return m & IFMT == IFWHT;
1505 }
1506};
15491507
15501508pub const HOST_NAME_MAX = 72;
15511509
......@@ -1981,7 +1939,9 @@ pub const winsize = extern struct {
19811939 ws_ypixel: u16,
19821940};
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};
19851945pub const IOCPARM_MASK = 0x1fff;
19861946
19871947fn 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
3333
3434pub const sem_t = ?*opaque {};
3535
36pub fn S_ISCHR(m: u32) bool {
37 return m & S_IFMT == S_IFCHR;
38}
39
4036// See:
4137// - https://gitweb.dragonflybsd.org/dragonfly.git/blob/HEAD:/include/unistd.h
4238// - https://gitweb.dragonflybsd.org/dragonfly.git/blob/HEAD:/sys/sys/types.h
......@@ -157,10 +153,12 @@ pub const STDIN_FILENO = 0;
157153pub const STDOUT_FILENO = 1;
158154pub const STDERR_FILENO = 2;
159155
160pub const PROT_NONE = 0;
161pub const PROT_READ = 1;
162pub const PROT_WRITE = 2;
163pub const PROT_EXEC = 4;
156pub const PROT = struct {
157 pub const NONE = 0;
158 pub const READ = 1;
159 pub const WRITE = 2;
160 pub const EXEC = 4;
161};
164162
165163pub const MAP = struct {
166164 pub const FILE = 0;
......@@ -321,32 +319,34 @@ pub const X_OK = 1; // test for execute or search permission
321319pub const W_OK = 2; // test for write permission
322320pub const R_OK = 4; // test for read permission
323321
324pub const O_RDONLY = 0;
325pub const O_NDELAY = O_NONBLOCK;
326pub const O_WRONLY = 1;
327pub const O_RDWR = 2;
328pub const O_ACCMODE = 3;
329pub const O_NONBLOCK = 4;
330pub const O_APPEND = 8;
331pub const O_SHLOCK = 16;
332pub const O_EXLOCK = 32;
333pub const O_ASYNC = 64;
334pub const O_FSYNC = 128;
335pub const O_SYNC = 128;
336pub const O_NOFOLLOW = 256;
337pub const O_CREAT = 512;
338pub const O_TRUNC = 1024;
339pub const O_EXCL = 2048;
340pub const O_NOCTTY = 32768;
341pub const O_DIRECT = 65536;
342pub const O_CLOEXEC = 131072;
343pub const O_FBLOCKING = 262144;
344pub const O_FNONBLOCKING = 524288;
345pub const O_FAPPEND = 1048576;
346pub const O_FOFFSET = 2097152;
347pub const O_FSYNCWRITE = 4194304;
348pub const O_FASYNCWRITE = 8388608;
349pub const O_DIRECTORY = 134217728;
322pub const O = struct {
323 pub const RDONLY = 0;
324 pub const NDELAY = NONBLOCK;
325 pub const WRONLY = 1;
326 pub const RDWR = 2;
327 pub const ACCMODE = 3;
328 pub const NONBLOCK = 4;
329 pub const APPEND = 8;
330 pub const SHLOCK = 16;
331 pub const EXLOCK = 32;
332 pub const ASYNC = 64;
333 pub const FSYNC = 128;
334 pub const SYNC = 128;
335 pub const NOFOLLOW = 256;
336 pub const CREAT = 512;
337 pub const TRUNC = 1024;
338 pub const EXCL = 2048;
339 pub const NOCTTY = 32768;
340 pub const DIRECT = 65536;
341 pub const CLOEXEC = 131072;
342 pub const FBLOCKING = 262144;
343 pub const FNONBLOCKING = 524288;
344 pub const FAPPEND = 1048576;
345 pub const FOFFSET = 2097152;
346 pub const FSYNCWRITE = 4194304;
347 pub const FASYNCWRITE = 8388608;
348 pub const DIRECTORY = 134217728;
349};
350350
351351pub const SEEK_SET = 0;
352352pub const SEEK_CUR = 1;
......@@ -540,81 +540,90 @@ pub const stack_t = extern struct {
540540 ss_flags: i32,
541541};
542542
543pub const S_IREAD = S_IRUSR;
544pub const S_IEXEC = S_IXUSR;
545pub const S_IWRITE = S_IWUSR;
546pub const S_IXOTH = 1;
547pub const S_IWOTH = 2;
548pub const S_IROTH = 4;
549pub const S_IRWXO = 7;
550pub const S_IXGRP = 8;
551pub const S_IWGRP = 16;
552pub const S_IRGRP = 32;
553pub const S_IRWXG = 56;
554pub const S_IXUSR = 64;
555pub const S_IWUSR = 128;
556pub const S_IRUSR = 256;
557pub const S_IRWXU = 448;
558pub const S_ISTXT = 512;
559pub const S_BLKSIZE = 512;
560pub const S_ISVTX = 512;
561pub const S_ISGID = 1024;
562pub const S_ISUID = 2048;
563pub const S_IFIFO = 4096;
564pub const S_IFCHR = 8192;
565pub const S_IFDIR = 16384;
566pub const S_IFBLK = 24576;
567pub const S_IFREG = 32768;
568pub const S_IFDB = 36864;
569pub const S_IFLNK = 40960;
570pub const S_IFSOCK = 49152;
571pub const S_IFWHT = 57344;
572pub const S_IFMT = 61440;
573
574pub const SIG_DFL = @intToPtr(?Sigaction.sigaction_fn, 0);
575pub const SIG_IGN = @intToPtr(?Sigaction.sigaction_fn, 1);
576pub const SIG_ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize));
577pub const BADSIG = SIG_ERR;
578
579pub const SIG_BLOCK = 1;
580pub const SIG_UNBLOCK = 2;
581pub const SIG_SETMASK = 3;
582
583pub const SIGIOT = SIGABRT;
584pub const SIGHUP = 1;
585pub const SIGINT = 2;
586pub const SIGQUIT = 3;
587pub const SIGILL = 4;
588pub const SIGTRAP = 5;
589pub const SIGABRT = 6;
590pub const SIGEMT = 7;
591pub const SIGFPE = 8;
592pub const SIGKILL = 9;
593pub const SIGBUS = 10;
594pub const SIGSEGV = 11;
595pub const SIGSYS = 12;
596pub const SIGPIPE = 13;
597pub const SIGALRM = 14;
598pub const SIGTERM = 15;
599pub const SIGURG = 16;
600pub const SIGSTOP = 17;
601pub const SIGTSTP = 18;
602pub const SIGCONT = 19;
603pub const SIGCHLD = 20;
604pub const SIGTTIN = 21;
605pub const SIGTTOU = 22;
606pub const SIGIO = 23;
607pub const SIGXCPU = 24;
608pub const SIGXFSZ = 25;
609pub const SIGVTALRM = 26;
610pub const SIGPROF = 27;
611pub const SIGWINCH = 28;
612pub const SIGINFO = 29;
613pub const SIGUSR1 = 30;
614pub const SIGUSR2 = 31;
615pub const SIGTHR = 32;
616pub const SIGCKPT = 33;
617pub const SIGCKPTEXIT = 34;
543pub const S = struct {
544 pub const IREAD = IRUSR;
545 pub const IEXEC = IXUSR;
546 pub const IWRITE = IWUSR;
547 pub const IXOTH = 1;
548 pub const IWOTH = 2;
549 pub const IROTH = 4;
550 pub const IRWXO = 7;
551 pub const IXGRP = 8;
552 pub const IWGRP = 16;
553 pub const IRGRP = 32;
554 pub const IRWXG = 56;
555 pub const IXUSR = 64;
556 pub const IWUSR = 128;
557 pub const IRUSR = 256;
558 pub const IRWXU = 448;
559 pub const ISTXT = 512;
560 pub const BLKSIZE = 512;
561 pub const ISVTX = 512;
562 pub const ISGID = 1024;
563 pub const ISUID = 2048;
564 pub const IFIFO = 4096;
565 pub const IFCHR = 8192;
566 pub const IFDIR = 16384;
567 pub const IFBLK = 24576;
568 pub const IFREG = 32768;
569 pub const IFDB = 36864;
570 pub const IFLNK = 40960;
571 pub const IFSOCK = 49152;
572 pub const IFWHT = 57344;
573 pub const IFMT = 61440;
574
575 pub fn ISCHR(m: u32) bool {
576 return m & IFMT == IFCHR;
577 }
578};
579
580pub const BADSIG = SIG.ERR;
581
582pub const SIG = struct {
583 pub const DFL = @intToPtr(?Sigaction.sigaction_fn, 0);
584 pub const IGN = @intToPtr(?Sigaction.sigaction_fn, 1);
585 pub const ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize));
586
587 pub const BLOCK = 1;
588 pub const UNBLOCK = 2;
589 pub const SETMASK = 3;
590
591 pub const IOT = ABRT;
592 pub const HUP = 1;
593 pub const INT = 2;
594 pub const QUIT = 3;
595 pub const ILL = 4;
596 pub const TRAP = 5;
597 pub const ABRT = 6;
598 pub const EMT = 7;
599 pub const FPE = 8;
600 pub const KILL = 9;
601 pub const BUS = 10;
602 pub const SEGV = 11;
603 pub const SYS = 12;
604 pub const PIPE = 13;
605 pub const ALRM = 14;
606 pub const TERM = 15;
607 pub const URG = 16;
608 pub const STOP = 17;
609 pub const TSTP = 18;
610 pub const CONT = 19;
611 pub const CHLD = 20;
612 pub const TTIN = 21;
613 pub const TTOU = 22;
614 pub const IO = 23;
615 pub const XCPU = 24;
616 pub const XFSZ = 25;
617 pub const VTALRM = 26;
618 pub const PROF = 27;
619 pub const WINCH = 28;
620 pub const INFO = 29;
621 pub const USR1 = 30;
622 pub const USR2 = 31;
623 pub const THR = 32;
624 pub const CKPT = 33;
625 pub const CKPTEXIT = 34;
626};
618627
619628pub const siginfo_t = extern struct {
620629 signo: c_int,
lib/std/c/freebsd.zig+118-110
......@@ -363,10 +363,12 @@ pub const STDIN_FILENO = 0;
363363pub const STDOUT_FILENO = 1;
364364pub const STDERR_FILENO = 2;
365365
366pub const PROT_NONE = 0;
367pub const PROT_READ = 1;
368pub const PROT_WRITE = 2;
369pub const PROT_EXEC = 4;
366pub const PROT = struct {
367 pub const NONE = 0;
368 pub const READ = 1;
369 pub const WRITE = 2;
370 pub const EXEC = 4;
371};
370372
371373pub const CLOCK = struct {
372374 pub const REALTIME = 0;
......@@ -504,33 +506,35 @@ pub const X_OK = 1; // test for execute or search permission
504506pub const W_OK = 2; // test for write permission
505507pub const R_OK = 4; // test for read permission
506508
507pub const O_RDONLY = 0x0000;
508pub const O_WRONLY = 0x0001;
509pub const O_RDWR = 0x0002;
510pub const O_ACCMODE = 0x0003;
511
512pub const O_SHLOCK = 0x0010;
513pub const O_EXLOCK = 0x0020;
514
515pub const O_CREAT = 0x0200;
516pub const O_EXCL = 0x0800;
517pub const O_NOCTTY = 0x8000;
518pub const O_TRUNC = 0x0400;
519pub const O_APPEND = 0x0008;
520pub const O_NONBLOCK = 0x0004;
521pub const O_DSYNC = 0o10000;
522pub const O_SYNC = 0x0080;
523pub const O_RSYNC = 0o4010000;
524pub const O_DIRECTORY = 0x20000;
525pub const O_NOFOLLOW = 0x0100;
526pub const O_CLOEXEC = 0x00100000;
527
528pub const O_ASYNC = 0x0040;
529pub const O_DIRECT = 0x00010000;
530pub const O_NOATIME = 0o1000000;
531pub const O_PATH = 0o10000000;
532pub const O_TMPFILE = 0o20200000;
533pub const O_NDELAY = O_NONBLOCK;
509pub const O = struct {
510 pub const RDONLY = 0x0000;
511 pub const WRONLY = 0x0001;
512 pub const RDWR = 0x0002;
513 pub const ACCMODE = 0x0003;
514
515 pub const SHLOCK = 0x0010;
516 pub const EXLOCK = 0x0020;
517
518 pub const CREAT = 0x0200;
519 pub const EXCL = 0x0800;
520 pub const NOCTTY = 0x8000;
521 pub const TRUNC = 0x0400;
522 pub const APPEND = 0x0008;
523 pub const NONBLOCK = 0x0004;
524 pub const DSYNC = 0o10000;
525 pub const SYNC = 0x0080;
526 pub const RSYNC = 0o4010000;
527 pub const DIRECTORY = 0x20000;
528 pub const NOFOLLOW = 0x0100;
529 pub const CLOEXEC = 0x00100000;
530
531 pub const ASYNC = 0x0040;
532 pub const DIRECT = 0x00010000;
533 pub const NOATIME = 0o1000000;
534 pub const PATH = 0o10000000;
535 pub const TMPFILE = 0o20200000;
536 pub const NDELAY = NONBLOCK;
537};
534538
535539pub const F = struct {
536540 pub const DUPFD = 0;
......@@ -877,31 +881,33 @@ pub const NOTE_NSECONDS = 0x00000008;
877881/// timeout is absolute
878882pub const NOTE_ABSTIME = 0x00000010;
879883
880pub const TIOCEXCL = 0x2000740d;
881pub const TIOCNXCL = 0x2000740e;
882pub const TIOCSCTTY = 0x20007461;
883pub const TIOCGPGRP = 0x40047477;
884pub const TIOCSPGRP = 0x80047476;
885pub const TIOCOUTQ = 0x40047473;
886pub const TIOCSTI = 0x80017472;
887pub const TIOCGWINSZ = 0x40087468;
888pub const TIOCSWINSZ = 0x80087467;
889pub const TIOCMGET = 0x4004746a;
890pub const TIOCMBIS = 0x8004746c;
891pub const TIOCMBIC = 0x8004746b;
892pub const TIOCMSET = 0x8004746d;
893pub const FIONREAD = 0x4004667f;
894pub const TIOCCONS = 0x80047462;
895pub const TIOCPKT = 0x80047470;
896pub const FIONBIO = 0x8004667e;
897pub const TIOCNOTTY = 0x20007471;
898pub const TIOCSETD = 0x8004741b;
899pub const TIOCGETD = 0x4004741a;
900pub const TIOCSBRK = 0x2000747b;
901pub const TIOCCBRK = 0x2000747a;
902pub const TIOCGSID = 0x40047463;
903pub const TIOCGPTN = 0x4004740f;
904pub const TIOCSIG = 0x2004745f;
884pub const T = struct {
885 pub const IOCEXCL = 0x2000740d;
886 pub const IOCNXCL = 0x2000740e;
887 pub const IOCSCTTY = 0x20007461;
888 pub const IOCGPGRP = 0x40047477;
889 pub const IOCSPGRP = 0x80047476;
890 pub const IOCOUTQ = 0x40047473;
891 pub const IOCSTI = 0x80017472;
892 pub const IOCGWINSZ = 0x40087468;
893 pub const IOCSWINSZ = 0x80087467;
894 pub const IOCMGET = 0x4004746a;
895 pub const IOCMBIS = 0x8004746c;
896 pub const IOCMBIC = 0x8004746b;
897 pub const IOCMSET = 0x8004746d;
898 pub const FIONREAD = 0x4004667f;
899 pub const IOCCONS = 0x80047462;
900 pub const IOCPKT = 0x80047470;
901 pub const FIONBIO = 0x8004667e;
902 pub const IOCNOTTY = 0x20007471;
903 pub const IOCSETD = 0x8004741b;
904 pub const IOCGETD = 0x4004741a;
905 pub const IOCSBRK = 0x2000747b;
906 pub const IOCCBRK = 0x2000747a;
907 pub const IOCGSID = 0x40047463;
908 pub const IOCGPTN = 0x4004740f;
909 pub const IOCSIG = 0x2004745f;
910};
905911
906912pub fn WEXITSTATUS(s: u32) u8 {
907913 return @intCast(u8, (s & 0xff00) >> 8);
......@@ -1166,69 +1172,71 @@ pub const SS_ONSTACK = 1;
11661172pub const SS_DISABLE = 4;
11671173
11681174pub const stack_t = extern struct {
1169 ss_sp: [*]u8,
1170 ss_size: isize,
1171 ss_flags: i32,
1175 sp: [*]u8,
1176 size: isize,
1177 flags: i32,
11721178};
11731179
1174pub const S_IFMT = 0o170000;
1175
1176pub const S_IFIFO = 0o010000;
1177pub const S_IFCHR = 0o020000;
1178pub const S_IFDIR = 0o040000;
1179pub const S_IFBLK = 0o060000;
1180pub const S_IFREG = 0o100000;
1181pub const S_IFLNK = 0o120000;
1182pub const S_IFSOCK = 0o140000;
1183pub const S_IFWHT = 0o160000;
1184
1185pub const S_ISUID = 0o4000;
1186pub const S_ISGID = 0o2000;
1187pub const S_ISVTX = 0o1000;
1188pub const S_IRWXU = 0o700;
1189pub const S_IRUSR = 0o400;
1190pub const S_IWUSR = 0o200;
1191pub const S_IXUSR = 0o100;
1192pub const S_IRWXG = 0o070;
1193pub const S_IRGRP = 0o040;
1194pub const S_IWGRP = 0o020;
1195pub const S_IXGRP = 0o010;
1196pub const S_IRWXO = 0o007;
1197pub const S_IROTH = 0o004;
1198pub const S_IWOTH = 0o002;
1199pub const S_IXOTH = 0o001;
1200
1201pub fn S_ISFIFO(m: u32) bool {
1202 return m & S_IFMT == S_IFIFO;
1203}
1180pub const S = struct {
1181 pub const IFMT = 0o170000;
1182
1183 pub const IFIFO = 0o010000;
1184 pub const IFCHR = 0o020000;
1185 pub const IFDIR = 0o040000;
1186 pub const IFBLK = 0o060000;
1187 pub const IFREG = 0o100000;
1188 pub const IFLNK = 0o120000;
1189 pub const IFSOCK = 0o140000;
1190 pub const IFWHT = 0o160000;
1191
1192 pub const ISUID = 0o4000;
1193 pub const ISGID = 0o2000;
1194 pub const ISVTX = 0o1000;
1195 pub const IRWXU = 0o700;
1196 pub const IRUSR = 0o400;
1197 pub const IWUSR = 0o200;
1198 pub const IXUSR = 0o100;
1199 pub const IRWXG = 0o070;
1200 pub const IRGRP = 0o040;
1201 pub const IWGRP = 0o020;
1202 pub const IXGRP = 0o010;
1203 pub const IRWXO = 0o007;
1204 pub const IROTH = 0o004;
1205 pub const IWOTH = 0o002;
1206 pub const IXOTH = 0o001;
1207
1208 pub fn ISFIFO(m: u32) bool {
1209 return m & IFMT == IFIFO;
1210 }
12041211
1205pub fn S_ISCHR(m: u32) bool {
1206 return m & S_IFMT == S_IFCHR;
1207}
1212 pub fn ISCHR(m: u32) bool {
1213 return m & IFMT == IFCHR;
1214 }
12081215
1209pub fn S_ISDIR(m: u32) bool {
1210 return m & S_IFMT == S_IFDIR;
1211}
1216 pub fn ISDIR(m: u32) bool {
1217 return m & IFMT == IFDIR;
1218 }
12121219
1213pub fn S_ISBLK(m: u32) bool {
1214 return m & S_IFMT == S_IFBLK;
1215}
1220 pub fn ISBLK(m: u32) bool {
1221 return m & IFMT == IFBLK;
1222 }
12161223
1217pub fn S_ISREG(m: u32) bool {
1218 return m & S_IFMT == S_IFREG;
1219}
1224 pub fn ISREG(m: u32) bool {
1225 return m & IFMT == IFREG;
1226 }
12201227
1221pub fn S_ISLNK(m: u32) bool {
1222 return m & S_IFMT == S_IFLNK;
1223}
1228 pub fn ISLNK(m: u32) bool {
1229 return m & IFMT == IFLNK;
1230 }
12241231
1225pub fn S_ISSOCK(m: u32) bool {
1226 return m & S_IFMT == S_IFSOCK;
1227}
1232 pub fn ISSOCK(m: u32) bool {
1233 return m & IFMT == IFSOCK;
1234 }
12281235
1229pub fn S_IWHT(m: u32) bool {
1230 return m & S_IFMT == S_IFWHT;
1231}
1236 pub fn IWHT(m: u32) bool {
1237 return m & IFMT == IFWHT;
1238 }
1239};
12321240
12331241pub const HOST_NAME_MAX = 255;
12341242
lib/std/c/haiku.zig+149-139
......@@ -377,10 +377,12 @@ pub const STDIN_FILENO = 0;
377377pub const STDOUT_FILENO = 1;
378378pub const STDERR_FILENO = 2;
379379
380pub const PROT_NONE = 0;
381pub const PROT_READ = 1;
382pub const PROT_WRITE = 2;
383pub const PROT_EXEC = 4;
380pub const PROT = struct {
381 pub const NONE = 0;
382 pub const READ = 1;
383 pub const WRITE = 2;
384 pub const EXEC = 4;
385};
384386
385387pub const CLOCK = struct {
386388 pub const MONOTONIC = 0;
......@@ -425,6 +427,10 @@ pub const SA_STACK = SA_ONSTACK;
425427pub const SA_ONESHOT = SA_RESETHAND;
426428
427429pub 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
428434 pub const HUP = 1;
429435 pub const INT = 2;
430436 pub const QUIT = 3;
......@@ -489,33 +495,35 @@ pub const X_OK = 1; // test for execute or search permission
489495pub const W_OK = 2; // test for write permission
490496pub const R_OK = 4; // test for read permission
491497
492pub const O_RDONLY = 0x0000;
493pub const O_WRONLY = 0x0001;
494pub const O_RDWR = 0x0002;
495pub const O_ACCMODE = 0x0003;
496
497pub const O_SHLOCK = 0x0010;
498pub const O_EXLOCK = 0x0020;
499
500pub const O_CREAT = 0x0200;
501pub const O_EXCL = 0x0800;
502pub const O_NOCTTY = 0x8000;
503pub const O_TRUNC = 0x0400;
504pub const O_APPEND = 0x0008;
505pub const O_NONBLOCK = 0x0004;
506pub const O_DSYNC = 0o10000;
507pub const O_SYNC = 0x0080;
508pub const O_RSYNC = 0o4010000;
509pub const O_DIRECTORY = 0x20000;
510pub const O_NOFOLLOW = 0x0100;
511pub const O_CLOEXEC = 0x00100000;
512
513pub const O_ASYNC = 0x0040;
514pub const O_DIRECT = 0x00010000;
515pub const O_NOATIME = 0o1000000;
516pub const O_PATH = 0o10000000;
517pub const O_TMPFILE = 0o20200000;
518pub const O_NDELAY = O_NONBLOCK;
498pub const O = struct {
499 pub const RDONLY = 0x0000;
500 pub const WRONLY = 0x0001;
501 pub const RDWR = 0x0002;
502 pub const ACCMODE = 0x0003;
503
504 pub const SHLOCK = 0x0010;
505 pub const EXLOCK = 0x0020;
506
507 pub const CREAT = 0x0200;
508 pub const EXCL = 0x0800;
509 pub const NOCTTY = 0x8000;
510 pub const TRUNC = 0x0400;
511 pub const APPEND = 0x0008;
512 pub const NONBLOCK = 0x0004;
513 pub const DSYNC = 0o10000;
514 pub const SYNC = 0x0080;
515 pub const RSYNC = 0o4010000;
516 pub const DIRECTORY = 0x20000;
517 pub const NOFOLLOW = 0x0100;
518 pub const CLOEXEC = 0x00100000;
519
520 pub const ASYNC = 0x0040;
521 pub const DIRECT = 0x00010000;
522 pub const NOATIME = 0o1000000;
523 pub const PATH = 0o10000000;
524 pub const TMPFILE = 0o20200000;
525 pub const NDELAY = NONBLOCK;
526};
519527
520528pub const F = struct {
521529 pub const DUPFD = 0;
......@@ -773,52 +781,56 @@ pub const EVFILT_SENDFILE = -12;
773781
774782pub const EVFILT_EMPTY = -13;
775783
776pub const TCGETA = 0x8000;
777pub const TCSETA = 0x8001;
778pub const TCSETAW = 0x8004;
779pub const TCSETAF = 0x8003;
780pub const TCSBRK = 08005;
781pub const TCXONC = 0x8007;
782pub const TCFLSH = 0x8006;
783
784pub const TIOCSCTTY = 0x8017;
785pub const TIOCGPGRP = 0x8015;
786pub const TIOCSPGRP = 0x8016;
787pub const TIOCGWINSZ = 0x8012;
788pub const TIOCSWINSZ = 0x8013;
789pub const TIOCMGET = 0x8018;
790pub const TIOCMBIS = 0x8022;
791pub const TIOCMBIC = 0x8023;
792pub const TIOCMSET = 0x8019;
793pub const FIONREAD = 0xbe000001;
794pub const FIONBIO = 0xbe000000;
795pub const TIOCSBRK = 0x8020;
796pub const TIOCCBRK = 0x8021;
797pub const TIOCGSID = 0x8024;
798
799pub fn WEXITSTATUS(s: u32) u8 {
800 return @intCast(u8, s & 0xff);
801}
802
803pub fn WTERMSIG(s: u32) u32 {
804 return (s >> 8) & 0xff;
805}
806
807pub fn WSTOPSIG(s: u32) u32 {
808 return WEXITSTATUS(s);
809}
810
811pub fn WIFEXITED(s: u32) bool {
812 return WTERMSIG(s) == 0;
813}
814
815pub fn WIFSTOPPED(s: u32) bool {
816 return ((s >> 16) & 0xff) != 0;
817}
818
819pub fn WIFSIGNALED(s: u32) bool {
820 return ((s >> 8) & 0xff) != 0;
821}
784pub const T = struct {
785 pub const CGETA = 0x8000;
786 pub const CSETA = 0x8001;
787 pub const CSETAW = 0x8004;
788 pub const CSETAF = 0x8003;
789 pub const CSBRK = 08005;
790 pub const CXONC = 0x8007;
791 pub const CFLSH = 0x8006;
792
793 pub const IOCSCTTY = 0x8017;
794 pub const IOCGPGRP = 0x8015;
795 pub const IOCSPGRP = 0x8016;
796 pub const IOCGWINSZ = 0x8012;
797 pub const IOCSWINSZ = 0x8013;
798 pub const IOCMGET = 0x8018;
799 pub const IOCMBIS = 0x8022;
800 pub const IOCMBIC = 0x8023;
801 pub const IOCMSET = 0x8019;
802 pub const FIONREAD = 0xbe000001;
803 pub const FIONBIO = 0xbe000000;
804 pub const IOCSBRK = 0x8020;
805 pub const IOCCBRK = 0x8021;
806 pub const IOCGSID = 0x8024;
807};
808
809pub const W = struct {
810 pub fn EXITSTATUS(s: u32) u8 {
811 return @intCast(u8, s & 0xff);
812 }
813
814 pub fn TERMSIG(s: u32) u32 {
815 return (s >> 8) & 0xff;
816 }
817
818 pub fn STOPSIG(s: u32) u32 {
819 return EXITSTATUS(s);
820 }
821
822 pub fn IFEXITED(s: u32) bool {
823 return TERMSIG(s) == 0;
824 }
825
826 pub fn IFSTOPPED(s: u32) bool {
827 return ((s >> 16) & 0xff) != 0;
828 }
829
830 pub fn IFSIGNALED(s: u32) bool {
831 return ((s >> 8) & 0xff) != 0;
832 }
833};
822834
823835pub const winsize = extern struct {
824836 ws_row: u16,
......@@ -829,10 +841,6 @@ pub const winsize = extern struct {
829841
830842const 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
836844/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.
837845pub const Sigaction = extern struct {
838846 /// signal handler
......@@ -992,64 +1000,66 @@ pub const stack_t = extern struct {
9921000 ss_flags: i32,
9931001};
9941002
995pub const S_IFMT = 0o170000;
996
997pub const S_IFIFO = 0o010000;
998pub const S_IFCHR = 0o020000;
999pub const S_IFDIR = 0o040000;
1000pub const S_IFBLK = 0o060000;
1001pub const S_IFREG = 0o100000;
1002pub const S_IFLNK = 0o120000;
1003pub const S_IFSOCK = 0o140000;
1004pub const S_IFWHT = 0o160000;
1005
1006pub const S_ISUID = 0o4000;
1007pub const S_ISGID = 0o2000;
1008pub const S_ISVTX = 0o1000;
1009pub const S_IRWXU = 0o700;
1010pub const S_IRUSR = 0o400;
1011pub const S_IWUSR = 0o200;
1012pub const S_IXUSR = 0o100;
1013pub const S_IRWXG = 0o070;
1014pub const S_IRGRP = 0o040;
1015pub const S_IWGRP = 0o020;
1016pub const S_IXGRP = 0o010;
1017pub const S_IRWXO = 0o007;
1018pub const S_IROTH = 0o004;
1019pub const S_IWOTH = 0o002;
1020pub const S_IXOTH = 0o001;
1021
1022pub fn S_ISFIFO(m: u32) bool {
1023 return m & S_IFMT == S_IFIFO;
1024}
1025
1026pub fn S_ISCHR(m: u32) bool {
1027 return m & S_IFMT == S_IFCHR;
1028}
1029
1030pub fn S_ISDIR(m: u32) bool {
1031 return m & S_IFMT == S_IFDIR;
1032}
1033
1034pub fn S_ISBLK(m: u32) bool {
1035 return m & S_IFMT == S_IFBLK;
1036}
1037
1038pub fn S_ISREG(m: u32) bool {
1039 return m & S_IFMT == S_IFREG;
1040}
1041
1042pub fn S_ISLNK(m: u32) bool {
1043 return m & S_IFMT == S_IFLNK;
1044}
1045
1046pub fn S_ISSOCK(m: u32) bool {
1047 return m & S_IFMT == S_IFSOCK;
1048}
1049
1050pub fn S_IWHT(m: u32) bool {
1051 return m & S_IFMT == S_IFWHT;
1052}
1003pub const S = struct {
1004 pub const IFMT = 0o170000;
1005
1006 pub const IFIFO = 0o010000;
1007 pub const IFCHR = 0o020000;
1008 pub const IFDIR = 0o040000;
1009 pub const IFBLK = 0o060000;
1010 pub const IFREG = 0o100000;
1011 pub const IFLNK = 0o120000;
1012 pub const IFSOCK = 0o140000;
1013 pub const IFWHT = 0o160000;
1014
1015 pub const ISUID = 0o4000;
1016 pub const ISGID = 0o2000;
1017 pub const ISVTX = 0o1000;
1018 pub const IRWXU = 0o700;
1019 pub const IRUSR = 0o400;
1020 pub const IWUSR = 0o200;
1021 pub const IXUSR = 0o100;
1022 pub const IRWXG = 0o070;
1023 pub const IRGRP = 0o040;
1024 pub const IWGRP = 0o020;
1025 pub const IXGRP = 0o010;
1026 pub const IRWXO = 0o007;
1027 pub const IROTH = 0o004;
1028 pub const IWOTH = 0o002;
1029 pub const IXOTH = 0o001;
1030
1031 pub fn ISFIFO(m: u32) bool {
1032 return m & IFMT == IFIFO;
1033 }
1034
1035 pub fn ISCHR(m: u32) bool {
1036 return m & IFMT == IFCHR;
1037 }
1038
1039 pub fn ISDIR(m: u32) bool {
1040 return m & IFMT == IFDIR;
1041 }
1042
1043 pub fn ISBLK(m: u32) bool {
1044 return m & IFMT == IFBLK;
1045 }
1046
1047 pub fn ISREG(m: u32) bool {
1048 return m & IFMT == IFREG;
1049 }
1050
1051 pub fn ISLNK(m: u32) bool {
1052 return m & IFMT == IFLNK;
1053 }
1054
1055 pub fn ISSOCK(m: u32) bool {
1056 return m & IFMT == IFSOCK;
1057 }
1058
1059 pub fn IWHT(m: u32) bool {
1060 return m & IFMT == IFWHT;
1061 }
1062};
10531063
10541064pub const HOST_NAME_MAX = 255;
10551065
lib/std/c/linux.zig+5-1
......@@ -25,7 +25,11 @@ pub const IOV_MAX = linux.IOV_MAX;
2525pub const IPPROTO = linux.IPPROTO;
2626pub const LOCK = linux.LOCK;
2727pub 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};
2933pub const MMAP2_UNIT = linux.MMAP2_UNIT;
3034pub const NAME_MAX = linux.NAME_MAX;
3135pub const O = linux.O;
lib/std/c/netbsd.zig+185-198
......@@ -534,10 +534,12 @@ pub const STDIN_FILENO = 0;
534534pub const STDOUT_FILENO = 1;
535535pub const STDERR_FILENO = 2;
536536
537pub const PROT_NONE = 0;
538pub const PROT_READ = 1;
539pub const PROT_WRITE = 2;
540pub const PROT_EXEC = 4;
537pub const PROT = struct {
538 pub const NONE = 0;
539 pub const READ = 1;
540 pub const WRITE = 2;
541 pub const EXEC = 4;
542};
541543
542544pub const CLOCK = struct {
543545 pub const REALTIME = 0;
......@@ -589,71 +591,52 @@ pub const X_OK = 1; // test for execute or search permission
589591pub const W_OK = 2; // test for write permission
590592pub const R_OK = 4; // test for read permission
591593
592/// open for reading only
593pub const O_RDONLY = 0x00000000;
594
595/// open for writing only
596pub const O_WRONLY = 0x00000001;
597
598/// open for reading and writing
599pub const O_RDWR = 0x00000002;
600
601/// mask for above modes
602pub const O_ACCMODE = 0x00000003;
603
604/// no delay
605pub const O_NONBLOCK = 0x00000004;
606
607/// set append mode
608pub const O_APPEND = 0x00000008;
609
610/// open with shared file lock
611pub const O_SHLOCK = 0x00000010;
612
613/// open with exclusive file lock
614pub const O_EXLOCK = 0x00000020;
615
616/// signal pgrp when data ready
617pub const O_ASYNC = 0x00000040;
618
619/// synchronous writes
620pub const O_SYNC = 0x00000080;
621
622/// don't follow symlinks on the last
623pub const O_NOFOLLOW = 0x00000100;
624
625/// create if nonexistent
626pub const O_CREAT = 0x00000200;
627
628/// truncate to zero length
629pub const O_TRUNC = 0x00000400;
630
631/// error if already exists
632pub const O_EXCL = 0x00000800;
633
634/// don't assign controlling terminal
635pub const O_NOCTTY = 0x00008000;
636
637/// write: I/O data completion
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;
594pub const O = struct {
595 /// open for reading only
596 pub const RDONLY = 0x00000000;
597 /// open for writing only
598 pub const WRONLY = 0x00000001;
599 /// open for reading and writing
600 pub const RDWR = 0x00000002;
601 /// mask for above modes
602 pub const ACCMODE = 0x00000003;
603 /// no delay
604 pub const NONBLOCK = 0x00000004;
605 /// set append mode
606 pub const APPEND = 0x00000008;
607 /// open with shared file lock
608 pub const SHLOCK = 0x00000010;
609 /// open with exclusive file lock
610 pub const EXLOCK = 0x00000020;
611 /// signal pgrp when data ready
612 pub const ASYNC = 0x00000040;
613 /// synchronous writes
614 pub const SYNC = 0x00000080;
615 /// don't follow symlinks on the last
616 pub const NOFOLLOW = 0x00000100;
617 /// create if nonexistent
618 pub const CREAT = 0x00000200;
619 /// truncate to zero length
620 pub const TRUNC = 0x00000400;
621 /// error if already exists
622 pub const EXCL = 0x00000800;
623 /// don't assign controlling terminal
624 pub const NOCTTY = 0x00008000;
625 /// write: I/O data completion
626 pub const DSYNC = 0x00010000;
627 /// read: I/O completion as for write
628 pub const RSYNC = 0x00020000;
629 /// use alternate i/o semantics
630 pub const ALT_IO = 0x00040000;
631 /// direct I/O hint
632 pub const DIRECT = 0x00080000;
633 /// fail if not a directory
634 pub const DIRECTORY = 0x00200000;
635 /// set close on exec
636 pub const CLOEXEC = 0x00400000;
637 /// skip search permission checks
638 pub const SEARCH = 0x00800000;
639};
657640
658641pub const F = struct {
659642 pub const DUPFD = 0;
......@@ -687,10 +670,6 @@ pub const SEEK_SET = 0;
687670pub const SEEK_CUR = 1;
688671pub const SEEK_END = 2;
689672
690pub const SIG_BLOCK = 1;
691pub const SIG_UNBLOCK = 2;
692pub const SIG_SETMASK = 3;
693
694673pub const DT_UNKNOWN = 0;
695674pub const DT_FIFO = 1;
696675pub const DT_CHR = 2;
......@@ -789,80 +768,82 @@ pub const NOTE_EXEC = 0x20000000;
789768pub const NOTE_PDATAMASK = 0x000fffff;
790769pub const NOTE_PCTRLMASK = 0xf0000000;
791770
792pub const TIOCCBRK = 0x2000747a;
793pub const TIOCCDTR = 0x20007478;
794pub const TIOCCONS = 0x80047462;
795pub const TIOCDCDTIMESTAMP = 0x40107458;
796pub const TIOCDRAIN = 0x2000745e;
797pub const TIOCEXCL = 0x2000740d;
798pub const TIOCEXT = 0x80047460;
799pub const TIOCFLAG_CDTRCTS = 0x10;
800pub const TIOCFLAG_CLOCAL = 0x2;
801pub const TIOCFLAG_CRTSCTS = 0x4;
802pub const TIOCFLAG_MDMBUF = 0x8;
803pub const TIOCFLAG_SOFTCAR = 0x1;
804pub const TIOCFLUSH = 0x80047410;
805pub const TIOCGETA = 0x402c7413;
806pub const TIOCGETD = 0x4004741a;
807pub const TIOCGFLAGS = 0x4004745d;
808pub const TIOCGLINED = 0x40207442;
809pub const TIOCGPGRP = 0x40047477;
810pub const TIOCGQSIZE = 0x40047481;
811pub const TIOCGRANTPT = 0x20007447;
812pub const TIOCGSID = 0x40047463;
813pub const TIOCGSIZE = 0x40087468;
814pub const TIOCGWINSZ = 0x40087468;
815pub const TIOCMBIC = 0x8004746b;
816pub const TIOCMBIS = 0x8004746c;
817pub const TIOCMGET = 0x4004746a;
818pub const TIOCMSET = 0x8004746d;
819pub const TIOCM_CAR = 0x40;
820pub const TIOCM_CD = 0x40;
821pub const TIOCM_CTS = 0x20;
822pub const TIOCM_DSR = 0x100;
823pub const TIOCM_DTR = 0x2;
824pub const TIOCM_LE = 0x1;
825pub const TIOCM_RI = 0x80;
826pub const TIOCM_RNG = 0x80;
827pub const TIOCM_RTS = 0x4;
828pub const TIOCM_SR = 0x10;
829pub const TIOCM_ST = 0x8;
830pub const TIOCNOTTY = 0x20007471;
831pub const TIOCNXCL = 0x2000740e;
832pub const TIOCOUTQ = 0x40047473;
833pub const TIOCPKT = 0x80047470;
834pub const TIOCPKT_DATA = 0x0;
835pub const TIOCPKT_DOSTOP = 0x20;
836pub const TIOCPKT_FLUSHREAD = 0x1;
837pub const TIOCPKT_FLUSHWRITE = 0x2;
838pub const TIOCPKT_IOCTL = 0x40;
839pub const TIOCPKT_NOSTOP = 0x10;
840pub const TIOCPKT_START = 0x8;
841pub const TIOCPKT_STOP = 0x4;
842pub const TIOCPTMGET = 0x40287446;
843pub const TIOCPTSNAME = 0x40287448;
844pub const TIOCRCVFRAME = 0x80087445;
845pub const TIOCREMOTE = 0x80047469;
846pub const TIOCSBRK = 0x2000747b;
847pub const TIOCSCTTY = 0x20007461;
848pub const TIOCSDTR = 0x20007479;
849pub const TIOCSETA = 0x802c7414;
850pub const TIOCSETAF = 0x802c7416;
851pub const TIOCSETAW = 0x802c7415;
852pub const TIOCSETD = 0x8004741b;
853pub const TIOCSFLAGS = 0x8004745c;
854pub const TIOCSIG = 0x2000745f;
855pub const TIOCSLINED = 0x80207443;
856pub const TIOCSPGRP = 0x80047476;
857pub const TIOCSQSIZE = 0x80047480;
858pub const TIOCSSIZE = 0x80087467;
859pub const TIOCSTART = 0x2000746e;
860pub const TIOCSTAT = 0x80047465;
861pub const TIOCSTI = 0x80017472;
862pub const TIOCSTOP = 0x2000746f;
863pub const TIOCSWINSZ = 0x80087467;
864pub const TIOCUCNTL = 0x80047466;
865pub const TIOCXMTFRAME = 0x80087444;
771pub const T = struct {
772 pub const IOCCBRK = 0x2000747a;
773 pub const IOCCDTR = 0x20007478;
774 pub const IOCCONS = 0x80047462;
775 pub const IOCDCDTIMESTAMP = 0x40107458;
776 pub const IOCDRAIN = 0x2000745e;
777 pub const IOCEXCL = 0x2000740d;
778 pub const IOCEXT = 0x80047460;
779 pub const IOCFLAG_CDTRCTS = 0x10;
780 pub const IOCFLAG_CLOCAL = 0x2;
781 pub const IOCFLAG_CRTSCTS = 0x4;
782 pub const IOCFLAG_MDMBUF = 0x8;
783 pub const IOCFLAG_SOFTCAR = 0x1;
784 pub const IOCFLUSH = 0x80047410;
785 pub const IOCGETA = 0x402c7413;
786 pub const IOCGETD = 0x4004741a;
787 pub const IOCGFLAGS = 0x4004745d;
788 pub const IOCGLINED = 0x40207442;
789 pub const IOCGPGRP = 0x40047477;
790 pub const IOCGQSIZE = 0x40047481;
791 pub const IOCGRANTPT = 0x20007447;
792 pub const IOCGSID = 0x40047463;
793 pub const IOCGSIZE = 0x40087468;
794 pub const IOCGWINSZ = 0x40087468;
795 pub const IOCMBIC = 0x8004746b;
796 pub const IOCMBIS = 0x8004746c;
797 pub const IOCMGET = 0x4004746a;
798 pub const IOCMSET = 0x8004746d;
799 pub const IOCM_CAR = 0x40;
800 pub const IOCM_CD = 0x40;
801 pub const IOCM_CTS = 0x20;
802 pub const IOCM_DSR = 0x100;
803 pub const IOCM_DTR = 0x2;
804 pub const IOCM_LE = 0x1;
805 pub const IOCM_RI = 0x80;
806 pub const IOCM_RNG = 0x80;
807 pub const IOCM_RTS = 0x4;
808 pub const IOCM_SR = 0x10;
809 pub const IOCM_ST = 0x8;
810 pub const IOCNOTTY = 0x20007471;
811 pub const IOCNXCL = 0x2000740e;
812 pub const IOCOUTQ = 0x40047473;
813 pub const IOCPKT = 0x80047470;
814 pub const IOCPKT_DATA = 0x0;
815 pub const IOCPKT_DOSTOP = 0x20;
816 pub const IOCPKT_FLUSHREAD = 0x1;
817 pub const IOCPKT_FLUSHWRITE = 0x2;
818 pub const IOCPKT_IOCTL = 0x40;
819 pub const IOCPKT_NOSTOP = 0x10;
820 pub const IOCPKT_START = 0x8;
821 pub const IOCPKT_STOP = 0x4;
822 pub const IOCPTMGET = 0x40287446;
823 pub const IOCPTSNAME = 0x40287448;
824 pub const IOCRCVFRAME = 0x80087445;
825 pub const IOCREMOTE = 0x80047469;
826 pub const IOCSBRK = 0x2000747b;
827 pub const IOCSCTTY = 0x20007461;
828 pub const IOCSDTR = 0x20007479;
829 pub const IOCSETA = 0x802c7414;
830 pub const IOCSETAF = 0x802c7416;
831 pub const IOCSETAW = 0x802c7415;
832 pub const IOCSETD = 0x8004741b;
833 pub const IOCSFLAGS = 0x8004745c;
834 pub const IOCSIG = 0x2000745f;
835 pub const IOCSLINED = 0x80207443;
836 pub const IOCSPGRP = 0x80047476;
837 pub const IOCSQSIZE = 0x80047480;
838 pub const IOCSSIZE = 0x80087467;
839 pub const IOCSTART = 0x2000746e;
840 pub const IOCSTAT = 0x80047465;
841 pub const IOCSTI = 0x80017472;
842 pub const IOCSTOP = 0x2000746f;
843 pub const IOCSWINSZ = 0x80087467;
844 pub const IOCUCNTL = 0x80047466;
845 pub const IOCXMTFRAME = 0x80087444;
846};
866847
867848pub fn WEXITSTATUS(s: u32) u8 {
868849 return @intCast(u8, (s >> 8) & 0xff);
......@@ -906,6 +887,10 @@ pub const SIG = struct {
906887 pub const WORDS = 4;
907888 pub const MAXSIG = 128;
908889
890 pub const BLOCK = 1;
891 pub const UNBLOCK = 2;
892 pub const SETMASK = 3;
893
909894 pub const HUP = 1;
910895 pub const INT = 2;
911896 pub const QUIT = 3;
......@@ -1213,64 +1198,66 @@ pub const stack_t = extern struct {
12131198 ss_flags: i32,
12141199};
12151200
1216pub const S_IFMT = 0o170000;
1217
1218pub const S_IFIFO = 0o010000;
1219pub const S_IFCHR = 0o020000;
1220pub const S_IFDIR = 0o040000;
1221pub const S_IFBLK = 0o060000;
1222pub const S_IFREG = 0o100000;
1223pub const S_IFLNK = 0o120000;
1224pub const S_IFSOCK = 0o140000;
1225pub const S_IFWHT = 0o160000;
1226
1227pub const S_ISUID = 0o4000;
1228pub const S_ISGID = 0o2000;
1229pub const S_ISVTX = 0o1000;
1230pub const S_IRWXU = 0o700;
1231pub const S_IRUSR = 0o400;
1232pub const S_IWUSR = 0o200;
1233pub const S_IXUSR = 0o100;
1234pub const S_IRWXG = 0o070;
1235pub const S_IRGRP = 0o040;
1236pub const S_IWGRP = 0o020;
1237pub const S_IXGRP = 0o010;
1238pub const S_IRWXO = 0o007;
1239pub const S_IROTH = 0o004;
1240pub const S_IWOTH = 0o002;
1241pub const S_IXOTH = 0o001;
1242
1243pub fn S_ISFIFO(m: u32) bool {
1244 return m & S_IFMT == S_IFIFO;
1245}
1201pub const S = struct {
1202 pub const IFMT = 0o170000;
1203
1204 pub const IFIFO = 0o010000;
1205 pub const IFCHR = 0o020000;
1206 pub const IFDIR = 0o040000;
1207 pub const IFBLK = 0o060000;
1208 pub const IFREG = 0o100000;
1209 pub const IFLNK = 0o120000;
1210 pub const IFSOCK = 0o140000;
1211 pub const IFWHT = 0o160000;
1212
1213 pub const ISUID = 0o4000;
1214 pub const ISGID = 0o2000;
1215 pub const ISVTX = 0o1000;
1216 pub const IRWXU = 0o700;
1217 pub const IRUSR = 0o400;
1218 pub const IWUSR = 0o200;
1219 pub const IXUSR = 0o100;
1220 pub const IRWXG = 0o070;
1221 pub const IRGRP = 0o040;
1222 pub const IWGRP = 0o020;
1223 pub const IXGRP = 0o010;
1224 pub const IRWXO = 0o007;
1225 pub const IROTH = 0o004;
1226 pub const IWOTH = 0o002;
1227 pub const IXOTH = 0o001;
1228
1229 pub fn ISFIFO(m: u32) bool {
1230 return m & IFMT == IFIFO;
1231 }
12461232
1247pub fn S_ISCHR(m: u32) bool {
1248 return m & S_IFMT == S_IFCHR;
1249}
1233 pub fn ISCHR(m: u32) bool {
1234 return m & IFMT == IFCHR;
1235 }
12501236
1251pub fn S_ISDIR(m: u32) bool {
1252 return m & S_IFMT == S_IFDIR;
1253}
1237 pub fn ISDIR(m: u32) bool {
1238 return m & IFMT == IFDIR;
1239 }
12541240
1255pub fn S_ISBLK(m: u32) bool {
1256 return m & S_IFMT == S_IFBLK;
1257}
1241 pub fn ISBLK(m: u32) bool {
1242 return m & IFMT == IFBLK;
1243 }
12581244
1259pub fn S_ISREG(m: u32) bool {
1260 return m & S_IFMT == S_IFREG;
1261}
1245 pub fn ISREG(m: u32) bool {
1246 return m & IFMT == IFREG;
1247 }
12621248
1263pub fn S_ISLNK(m: u32) bool {
1264 return m & S_IFMT == S_IFLNK;
1265}
1249 pub fn ISLNK(m: u32) bool {
1250 return m & IFMT == IFLNK;
1251 }
12661252
1267pub fn S_ISSOCK(m: u32) bool {
1268 return m & S_IFMT == S_IFSOCK;
1269}
1253 pub fn ISSOCK(m: u32) bool {
1254 return m & IFMT == IFSOCK;
1255 }
12701256
1271pub fn S_IWHT(m: u32) bool {
1272 return m & S_IFMT == S_IFWHT;
1273}
1257 pub fn IWHT(m: u32) bool {
1258 return m & IFMT == IFWHT;
1259 }
1260};
12741261
12751262pub const AT = struct {
12761263 /// 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;
330330pub const STDOUT_FILENO = 1;
331331pub const STDERR_FILENO = 2;
332332
333pub const PROT_NONE = 0;
334pub const PROT_READ = 1;
335pub const PROT_WRITE = 2;
336pub const PROT_EXEC = 4;
333pub const PROT = struct {
334 pub const NONE = 0;
335 pub const READ = 1;
336 pub const WRITE = 2;
337 pub const EXEC = 4;
338};
337339
338340pub const CLOCK = struct {
339341 pub const REALTIME = 0;
......@@ -371,102 +373,52 @@ pub const SA_NODEFER = 0x0010;
371373pub const SA_NOCLDWAIT = 0x0020;
372374pub 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
408376// access function
409377pub const F_OK = 0; // test for existence of file
410378pub const X_OK = 1; // test for execute or search permission
411379pub const W_OK = 2; // test for write permission
412380pub const R_OK = 4; // test for read permission
413381
414/// open for reading only
415pub const O_RDONLY = 0x00000000;
416
417/// open for writing only
418pub const O_WRONLY = 0x00000001;
419
420/// open for reading and writing
421pub const O_RDWR = 0x00000002;
422
423/// mask for above modes
424pub const O_ACCMODE = 0x00000003;
425
426/// no delay
427pub const O_NONBLOCK = 0x00000004;
428
429/// set append mode
430pub const O_APPEND = 0x00000008;
431
432/// open with shared file lock
433pub const O_SHLOCK = 0x00000010;
434
435/// open with exclusive file lock
436pub const O_EXLOCK = 0x00000020;
437
438/// signal pgrp when data ready
439pub const O_ASYNC = 0x00000040;
440
441/// synchronous writes
442pub const O_SYNC = 0x00000080;
443
444/// don't follow symlinks on the last
445pub const O_NOFOLLOW = 0x00000100;
446
447/// create if nonexistent
448pub const O_CREAT = 0x00000200;
449
450/// truncate to zero length
451pub const O_TRUNC = 0x00000400;
452
453/// error if already exists
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;
382pub const O = struct {
383 /// open for reading only
384 pub const RDONLY = 0x00000000;
385 /// open for writing only
386 pub const WRONLY = 0x00000001;
387 /// open for reading and writing
388 pub const RDWR = 0x00000002;
389 /// mask for above modes
390 pub const ACCMODE = 0x00000003;
391 /// no delay
392 pub const NONBLOCK = 0x00000004;
393 /// set append mode
394 pub const APPEND = 0x00000008;
395 /// open with shared file lock
396 pub const SHLOCK = 0x00000010;
397 /// open with exclusive file lock
398 pub const EXLOCK = 0x00000020;
399 /// signal pgrp when data ready
400 pub const ASYNC = 0x00000040;
401 /// synchronous writes
402 pub const SYNC = 0x00000080;
403 /// don't follow symlinks on the last
404 pub const NOFOLLOW = 0x00000100;
405 /// create if nonexistent
406 pub const CREAT = 0x00000200;
407 /// truncate to zero length
408 pub const TRUNC = 0x00000400;
409 /// error if already exists
410 pub const EXCL = 0x00000800;
411 /// don't assign controlling terminal
412 pub const NOCTTY = 0x00008000;
413 /// write: I/O data completion
414 pub const DSYNC = SYNC;
415 /// read: I/O completion as for write
416 pub const RSYNC = SYNC;
417 /// fail if not a directory
418 pub const DIRECTORY = 0x20000;
419 /// set close on exec
420 pub const CLOEXEC = 0x10000;
421};
470422
471423pub const F = struct {
472424 pub const DUPFD = 0;
......@@ -500,10 +452,6 @@ pub const SEEK_SET = 0;
500452pub const SEEK_CUR = 1;
501453pub const SEEK_END = 2;
502454
503pub const SIG_BLOCK = 1;
504pub const SIG_UNBLOCK = 2;
505pub const SIG_SETMASK = 3;
506
507455pub const SOCK = struct {
508456 pub const STREAM = 1;
509457 pub const DGRAM = 2;
......@@ -643,80 +591,82 @@ pub const NOTE_CHILD = 0x00000004;
643591// data/hint flags for EVFILT_DEVICE
644592pub const NOTE_CHANGE = 0x00000001;
645593
646pub const TIOCCBRK = 0x2000747a;
647pub const TIOCCDTR = 0x20007478;
648pub const TIOCCONS = 0x80047462;
649pub const TIOCDCDTIMESTAMP = 0x40107458;
650pub const TIOCDRAIN = 0x2000745e;
651pub const TIOCEXCL = 0x2000740d;
652pub const TIOCEXT = 0x80047460;
653pub const TIOCFLAG_CDTRCTS = 0x10;
654pub const TIOCFLAG_CLOCAL = 0x2;
655pub const TIOCFLAG_CRTSCTS = 0x4;
656pub const TIOCFLAG_MDMBUF = 0x8;
657pub const TIOCFLAG_SOFTCAR = 0x1;
658pub const TIOCFLUSH = 0x80047410;
659pub const TIOCGETA = 0x402c7413;
660pub const TIOCGETD = 0x4004741a;
661pub const TIOCGFLAGS = 0x4004745d;
662pub const TIOCGLINED = 0x40207442;
663pub const TIOCGPGRP = 0x40047477;
664pub const TIOCGQSIZE = 0x40047481;
665pub const TIOCGRANTPT = 0x20007447;
666pub const TIOCGSID = 0x40047463;
667pub const TIOCGSIZE = 0x40087468;
668pub const TIOCGWINSZ = 0x40087468;
669pub const TIOCMBIC = 0x8004746b;
670pub const TIOCMBIS = 0x8004746c;
671pub const TIOCMGET = 0x4004746a;
672pub const TIOCMSET = 0x8004746d;
673pub const TIOCM_CAR = 0x40;
674pub const TIOCM_CD = 0x40;
675pub const TIOCM_CTS = 0x20;
676pub const TIOCM_DSR = 0x100;
677pub const TIOCM_DTR = 0x2;
678pub const TIOCM_LE = 0x1;
679pub const TIOCM_RI = 0x80;
680pub const TIOCM_RNG = 0x80;
681pub const TIOCM_RTS = 0x4;
682pub const TIOCM_SR = 0x10;
683pub const TIOCM_ST = 0x8;
684pub const TIOCNOTTY = 0x20007471;
685pub const TIOCNXCL = 0x2000740e;
686pub const TIOCOUTQ = 0x40047473;
687pub const TIOCPKT = 0x80047470;
688pub const TIOCPKT_DATA = 0x0;
689pub const TIOCPKT_DOSTOP = 0x20;
690pub const TIOCPKT_FLUSHREAD = 0x1;
691pub const TIOCPKT_FLUSHWRITE = 0x2;
692pub const TIOCPKT_IOCTL = 0x40;
693pub const TIOCPKT_NOSTOP = 0x10;
694pub const TIOCPKT_START = 0x8;
695pub const TIOCPKT_STOP = 0x4;
696pub const TIOCPTMGET = 0x40287446;
697pub const TIOCPTSNAME = 0x40287448;
698pub const TIOCRCVFRAME = 0x80087445;
699pub const TIOCREMOTE = 0x80047469;
700pub const TIOCSBRK = 0x2000747b;
701pub const TIOCSCTTY = 0x20007461;
702pub const TIOCSDTR = 0x20007479;
703pub const TIOCSETA = 0x802c7414;
704pub const TIOCSETAF = 0x802c7416;
705pub const TIOCSETAW = 0x802c7415;
706pub const TIOCSETD = 0x8004741b;
707pub const TIOCSFLAGS = 0x8004745c;
708pub const TIOCSIG = 0x2000745f;
709pub const TIOCSLINED = 0x80207443;
710pub const TIOCSPGRP = 0x80047476;
711pub const TIOCSQSIZE = 0x80047480;
712pub const TIOCSSIZE = 0x80087467;
713pub const TIOCSTART = 0x2000746e;
714pub const TIOCSTAT = 0x80047465;
715pub const TIOCSTI = 0x80017472;
716pub const TIOCSTOP = 0x2000746f;
717pub const TIOCSWINSZ = 0x80087467;
718pub const TIOCUCNTL = 0x80047466;
719pub const TIOCXMTFRAME = 0x80087444;
594pub const T = struct {
595 pub const IOCCBRK = 0x2000747a;
596 pub const IOCCDTR = 0x20007478;
597 pub const IOCCONS = 0x80047462;
598 pub const IOCDCDTIMESTAMP = 0x40107458;
599 pub const IOCDRAIN = 0x2000745e;
600 pub const IOCEXCL = 0x2000740d;
601 pub const IOCEXT = 0x80047460;
602 pub const IOCFLAG_CDTRCTS = 0x10;
603 pub const IOCFLAG_CLOCAL = 0x2;
604 pub const IOCFLAG_CRTSCTS = 0x4;
605 pub const IOCFLAG_MDMBUF = 0x8;
606 pub const IOCFLAG_SOFTCAR = 0x1;
607 pub const IOCFLUSH = 0x80047410;
608 pub const IOCGETA = 0x402c7413;
609 pub const IOCGETD = 0x4004741a;
610 pub const IOCGFLAGS = 0x4004745d;
611 pub const IOCGLINED = 0x40207442;
612 pub const IOCGPGRP = 0x40047477;
613 pub const IOCGQSIZE = 0x40047481;
614 pub const IOCGRANTPT = 0x20007447;
615 pub const IOCGSID = 0x40047463;
616 pub const IOCGSIZE = 0x40087468;
617 pub const IOCGWINSZ = 0x40087468;
618 pub const IOCMBIC = 0x8004746b;
619 pub const IOCMBIS = 0x8004746c;
620 pub const IOCMGET = 0x4004746a;
621 pub const IOCMSET = 0x8004746d;
622 pub const IOCM_CAR = 0x40;
623 pub const IOCM_CD = 0x40;
624 pub const IOCM_CTS = 0x20;
625 pub const IOCM_DSR = 0x100;
626 pub const IOCM_DTR = 0x2;
627 pub const IOCM_LE = 0x1;
628 pub const IOCM_RI = 0x80;
629 pub const IOCM_RNG = 0x80;
630 pub const IOCM_RTS = 0x4;
631 pub const IOCM_SR = 0x10;
632 pub const IOCM_ST = 0x8;
633 pub const IOCNOTTY = 0x20007471;
634 pub const IOCNXCL = 0x2000740e;
635 pub const IOCOUTQ = 0x40047473;
636 pub const IOCPKT = 0x80047470;
637 pub const IOCPKT_DATA = 0x0;
638 pub const IOCPKT_DOSTOP = 0x20;
639 pub const IOCPKT_FLUSHREAD = 0x1;
640 pub const IOCPKT_FLUSHWRITE = 0x2;
641 pub const IOCPKT_IOCTL = 0x40;
642 pub const IOCPKT_NOSTOP = 0x10;
643 pub const IOCPKT_START = 0x8;
644 pub const IOCPKT_STOP = 0x4;
645 pub const IOCPTMGET = 0x40287446;
646 pub const IOCPTSNAME = 0x40287448;
647 pub const IOCRCVFRAME = 0x80087445;
648 pub const IOCREMOTE = 0x80047469;
649 pub const IOCSBRK = 0x2000747b;
650 pub const IOCSCTTY = 0x20007461;
651 pub const IOCSDTR = 0x20007479;
652 pub const IOCSETA = 0x802c7414;
653 pub const IOCSETAF = 0x802c7416;
654 pub const IOCSETAW = 0x802c7415;
655 pub const IOCSETD = 0x8004741b;
656 pub const IOCSFLAGS = 0x8004745c;
657 pub const IOCSIG = 0x2000745f;
658 pub const IOCSLINED = 0x80207443;
659 pub const IOCSPGRP = 0x80047476;
660 pub const IOCSQSIZE = 0x80047480;
661 pub const IOCSSIZE = 0x80087467;
662 pub const IOCSTART = 0x2000746e;
663 pub const IOCSTAT = 0x80047465;
664 pub const IOCSTI = 0x80017472;
665 pub const IOCSTOP = 0x2000746f;
666 pub const IOCSWINSZ = 0x80087467;
667 pub const IOCUCNTL = 0x80047466;
668 pub const IOCXMTFRAME = 0x80087444;
669};
720670
721671pub fn WEXITSTATUS(s: u32) u8 {
722672 return @intCast(u8, (s >> 8) & 0xff);
......@@ -752,11 +702,51 @@ pub const winsize = extern struct {
752702
753703const NSIG = 33;
754704
755pub const SIG_DFL = @intToPtr(?Sigaction.sigaction_fn, 0);
756pub const SIG_IGN = @intToPtr(?Sigaction.sigaction_fn, 1);
757pub const SIG_ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize));
758pub const SIG_CATCH = @intToPtr(?Sigaction.sigaction_fn, 2);
759pub const SIG_HOLD = @intToPtr(?Sigaction.sigaction_fn, 3);
705pub const SIG = struct {
706 pub const DFL = @intToPtr(?Sigaction.sigaction_fn, 0);
707 pub const IGN = @intToPtr(?Sigaction.sigaction_fn, 1);
708 pub const ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize));
709 pub const CATCH = @intToPtr(?Sigaction.sigaction_fn, 2);
710 pub const HOLD = @intToPtr(?Sigaction.sigaction_fn, 3);
711
712 pub const HUP = 1;
713 pub const INT = 2;
714 pub const QUIT = 3;
715 pub const ILL = 4;
716 pub const TRAP = 5;
717 pub const ABRT = 6;
718 pub const IOT = ABRT;
719 pub const EMT = 7;
720 pub const FPE = 8;
721 pub const KILL = 9;
722 pub const BUS = 10;
723 pub const SEGV = 11;
724 pub const SYS = 12;
725 pub const PIPE = 13;
726 pub const ALRM = 14;
727 pub const TERM = 15;
728 pub const URG = 16;
729 pub const STOP = 17;
730 pub const TSTP = 18;
731 pub const CONT = 19;
732 pub const CHLD = 20;
733 pub const TTIN = 21;
734 pub const TTOU = 22;
735 pub const IO = 23;
736 pub const XCPU = 24;
737 pub const XFSZ = 25;
738 pub const VTALRM = 26;
739 pub const PROF = 27;
740 pub const WINCH = 28;
741 pub const INFO = 29;
742 pub const USR1 = 30;
743 pub const USR2 = 31;
744 pub const PWR = 32;
745
746 pub const BLOCK = 1;
747 pub const UNBLOCK = 2;
748 pub const SETMASK = 3;
749};
760750
761751/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.
762752pub const Sigaction = extern struct {
......@@ -1013,59 +1003,61 @@ pub const stack_t = extern struct {
10131003 ss_flags: c_int,
10141004};
10151005
1016pub const S_IFMT = 0o170000;
1017
1018pub const S_IFIFO = 0o010000;
1019pub const S_IFCHR = 0o020000;
1020pub const S_IFDIR = 0o040000;
1021pub const S_IFBLK = 0o060000;
1022pub const S_IFREG = 0o100000;
1023pub const S_IFLNK = 0o120000;
1024pub const S_IFSOCK = 0o140000;
1025
1026pub const S_ISUID = 0o4000;
1027pub const S_ISGID = 0o2000;
1028pub const S_ISVTX = 0o1000;
1029pub const S_IRWXU = 0o700;
1030pub const S_IRUSR = 0o400;
1031pub const S_IWUSR = 0o200;
1032pub const S_IXUSR = 0o100;
1033pub const S_IRWXG = 0o070;
1034pub const S_IRGRP = 0o040;
1035pub const S_IWGRP = 0o020;
1036pub const S_IXGRP = 0o010;
1037pub const S_IRWXO = 0o007;
1038pub const S_IROTH = 0o004;
1039pub const S_IWOTH = 0o002;
1040pub const S_IXOTH = 0o001;
1041
1042pub fn S_ISFIFO(m: u32) bool {
1043 return m & S_IFMT == S_IFIFO;
1044}
1006pub const S = struct {
1007 pub const IFMT = 0o170000;
1008
1009 pub const IFIFO = 0o010000;
1010 pub const IFCHR = 0o020000;
1011 pub const IFDIR = 0o040000;
1012 pub const IFBLK = 0o060000;
1013 pub const IFREG = 0o100000;
1014 pub const IFLNK = 0o120000;
1015 pub const IFSOCK = 0o140000;
1016
1017 pub const ISUID = 0o4000;
1018 pub const ISGID = 0o2000;
1019 pub const ISVTX = 0o1000;
1020 pub const IRWXU = 0o700;
1021 pub const IRUSR = 0o400;
1022 pub const IWUSR = 0o200;
1023 pub const IXUSR = 0o100;
1024 pub const IRWXG = 0o070;
1025 pub const IRGRP = 0o040;
1026 pub const IWGRP = 0o020;
1027 pub const IXGRP = 0o010;
1028 pub const IRWXO = 0o007;
1029 pub const IROTH = 0o004;
1030 pub const IWOTH = 0o002;
1031 pub const IXOTH = 0o001;
1032
1033 pub fn ISFIFO(m: u32) bool {
1034 return m & IFMT == IFIFO;
1035 }
10451036
1046pub fn S_ISCHR(m: u32) bool {
1047 return m & S_IFMT == S_IFCHR;
1048}
1037 pub fn ISCHR(m: u32) bool {
1038 return m & IFMT == IFCHR;
1039 }
10491040
1050pub fn S_ISDIR(m: u32) bool {
1051 return m & S_IFMT == S_IFDIR;
1052}
1041 pub fn ISDIR(m: u32) bool {
1042 return m & IFMT == IFDIR;
1043 }
10531044
1054pub fn S_ISBLK(m: u32) bool {
1055 return m & S_IFMT == S_IFBLK;
1056}
1045 pub fn ISBLK(m: u32) bool {
1046 return m & IFMT == IFBLK;
1047 }
10571048
1058pub fn S_ISREG(m: u32) bool {
1059 return m & S_IFMT == S_IFREG;
1060}
1049 pub fn ISREG(m: u32) bool {
1050 return m & IFMT == IFREG;
1051 }
10611052
1062pub fn S_ISLNK(m: u32) bool {
1063 return m & S_IFMT == S_IFLNK;
1064}
1053 pub fn ISLNK(m: u32) bool {
1054 return m & IFMT == IFLNK;
1055 }
10651056
1066pub fn S_ISSOCK(m: u32) bool {
1067 return m & S_IFMT == S_IFSOCK;
1068}
1057 pub fn ISSOCK(m: u32) bool {
1058 return m & IFMT == IFSOCK;
1059 }
1060};
10691061
10701062pub const AT = struct {
10711063 /// 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;
1717pub const mode_t = wasi.mode_t;
1818pub const time_t = wasi.time_t;
1919pub 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
2126pub const Stat = extern struct {
2227 dev: i32,
lib/std/debug.zig+1-1
......@@ -1470,7 +1470,7 @@ fn getDebugInfoAllocator() *mem.Allocator {
14701470pub const have_segfault_handling_support = switch (native_os) {
14711471 .linux, .netbsd => true,
14721472 .windows => true,
1473 .freebsd, .openbsd => @hasDecl(os, "ucontext_t"),
1473 .freebsd, .openbsd => @hasDecl(os.system, "ucontext_t"),
14741474 else => false,
14751475};
14761476pub 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 {
904904 addr_size: *os.socklen_t,
905905 /// The following values can be bitwise ORed in flags to obtain different behavior:
906906 /// * `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.
908908 flags: u32,
909909 ) os.AcceptError!os.socket_t {
910910 while (true) {
lib/std/fs.zig+25-25
......@@ -479,15 +479,15 @@ pub const Dir = struct {
479479 &stat_info,
480480 0,
481481 );
482 const statmode = stat_info.mode & os.S_IFMT;
482 const statmode = stat_info.mode & os.S.IFMT;
483483
484484 const entry_kind = switch (statmode) {
485 os.S_IFDIR => Entry.Kind.Directory,
486 os.S_IFBLK => Entry.Kind.BlockDevice,
487 os.S_IFCHR => Entry.Kind.CharacterDevice,
488 os.S_IFLNK => Entry.Kind.SymLink,
489 os.S_IFREG => Entry.Kind.File,
490 os.S_IFIFO => Entry.Kind.NamedPipe,
485 os.S.IFDIR => Entry.Kind.Directory,
486 os.S.IFBLK => Entry.Kind.BlockDevice,
487 os.S.IFCHR => Entry.Kind.CharacterDevice,
488 os.S.IFLNK => Entry.Kind.SymLink,
489 os.S.IFREG => Entry.Kind.File,
490 os.S.IFIFO => Entry.Kind.NamedPipe,
491491 else => Entry.Kind.Unknown,
492492 };
493493
......@@ -678,12 +678,12 @@ pub const Dir = struct {
678678 }
679679
680680 const entry_kind = switch (entry.d_type) {
681 w.FILETYPE_BLOCK_DEVICE => Entry.Kind.BlockDevice,
682 w.FILETYPE_CHARACTER_DEVICE => Entry.Kind.CharacterDevice,
683 w.FILETYPE_DIRECTORY => Entry.Kind.Directory,
684 w.FILETYPE_SYMBOLIC_LINK => Entry.Kind.SymLink,
685 w.FILETYPE_REGULAR_FILE => Entry.Kind.File,
686 w.FILETYPE_SOCKET_STREAM, wasi.FILETYPE_SOCKET_DGRAM => Entry.Kind.UnixDomainSocket,
681 .BLOCK_DEVICE => Entry.Kind.BlockDevice,
682 .CHARACTER_DEVICE => Entry.Kind.CharacterDevice,
683 .DIRECTORY => Entry.Kind.Directory,
684 .SYMBOLIC_LINK => Entry.Kind.SymLink,
685 .REGULAR_FILE => Entry.Kind.File,
686 .SOCKET_STREAM, .SOCKET_DGRAM => Entry.Kind.UnixDomainSocket,
687687 else => Entry.Kind.Unknown,
688688 };
689689 return Entry{
......@@ -909,11 +909,11 @@ pub const Dir = struct {
909909 }
910910
911911 var os_flags: u32 = os.O.CLOEXEC;
912 // Use the O_ locking flags if the os supports them to acquire the lock
912 // Use the O locking flags if the os supports them to acquire the lock
913913 // atomically.
914914 const has_flock_open_flags = @hasDecl(os.O, "EXLOCK");
915915 if (has_flock_open_flags) {
916 // Note that the O_NONBLOCK flag is removed after the openat() call
916 // Note that the O.NONBLOCK flag is removed after the openat() call
917917 // is successful.
918918 const nonblocking_lock_flag: u32 = if (flags.lock_nonblocking)
919919 os.O.NONBLOCK
......@@ -1071,10 +1071,10 @@ pub const Dir = struct {
10711071 return self.createFileW(path_w.span(), flags);
10721072 }
10731073
1074 // Use the O_ locking flags if the os supports them to acquire the lock
1074 // Use the O locking flags if the os supports them to acquire the lock
10751075 // atomically.
10761076 const has_flock_open_flags = @hasDecl(os.O, "EXLOCK");
1077 // Note that the O_NONBLOCK flag is removed after the openat() call
1077 // Note that the O.NONBLOCK flag is removed after the openat() call
10781078 // is successful.
10791079 const nonblocking_lock_flag: u32 = if (has_flock_open_flags and flags.lock_nonblocking)
10801080 os.O.NONBLOCK
......@@ -1427,9 +1427,9 @@ pub const Dir = struct {
14271427 const result = os.openatWasi(self.fd, sub_path, symlink_flags, w.O.DIRECTORY, 0x0, base, inheriting);
14281428 const fd = result catch |err| switch (err) {
14291429 error.FileTooBig => unreachable, // can't happen for directories
1430 error.IsDir => unreachable, // we're providing O_DIRECTORY
1431 error.NoSpaceLeft => unreachable, // not providing O_CREAT
1432 error.PathAlreadyExists => unreachable, // not providing O_CREAT
1430 error.IsDir => unreachable, // we're providing O.DIRECTORY
1431 error.NoSpaceLeft => unreachable, // not providing O.CREAT
1432 error.PathAlreadyExists => unreachable, // not providing O.CREAT
14331433 error.FileLocksNotSupported => unreachable, // locking folders is not supported
14341434 error.WouldBlock => unreachable, // can't happen for directories
14351435 else => |e| return e,
......@@ -1463,7 +1463,7 @@ pub const Dir = struct {
14631463 return self.openDirAccessMaskW(sub_path_w, flags, args.no_follow);
14641464 }
14651465
1466 /// `flags` must contain `os.O_DIRECTORY`.
1466 /// `flags` must contain `os.O.DIRECTORY`.
14671467 fn openDirFlagsZ(self: Dir, sub_path_c: [*:0]const u8, flags: u32) OpenError!Dir {
14681468 const result = if (need_async_thread)
14691469 std.event.Loop.instance.?.openatZ(self.fd, sub_path_c, flags, 0)
......@@ -1471,9 +1471,9 @@ pub const Dir = struct {
14711471 os.openatZ(self.fd, sub_path_c, flags, 0);
14721472 const fd = result catch |err| switch (err) {
14731473 error.FileTooBig => unreachable, // can't happen for directories
1474 error.IsDir => unreachable, // we're providing O_DIRECTORY
1475 error.NoSpaceLeft => unreachable, // not providing O_CREAT
1476 error.PathAlreadyExists => unreachable, // not providing O_CREAT
1474 error.IsDir => unreachable, // we're providing O.DIRECTORY
1475 error.NoSpaceLeft => unreachable, // not providing O.CREAT
1476 error.PathAlreadyExists => unreachable, // not providing O.CREAT
14771477 error.FileLocksNotSupported => unreachable, // locking folders is not supported
14781478 error.WouldBlock => unreachable, // can't happen for directories
14791479 else => |e| return e,
......@@ -1559,7 +1559,7 @@ pub const Dir = struct {
15591559 .macos, .ios, .freebsd, .netbsd, .dragonfly, .openbsd => {
15601560 // Don't follow symlinks to match unlinkat (which acts on symlinks rather than follows them)
15611561 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;
15631563 return if (is_dir) error.IsDir else e;
15641564 },
15651565 else => return e,
lib/std/fs/file.zig+8-8
......@@ -106,7 +106,7 @@ pub const File = struct {
106106 /// and `false` means `error.WouldBlock` is handled by the event loop.
107107 lock_nonblocking: bool = false,
108108
109 /// Setting this to `.blocking` prevents `O_NONBLOCK` from being passed even
109 /// Setting this to `.blocking` prevents `O.NONBLOCK` from being passed even
110110 /// if `std.io.is_async`. It allows the use of `nosuspend` when calling functions
111111 /// related to opening the file, reading, writing, and locking.
112112 intended_io_mode: io.ModeOverride = io.default_mode,
......@@ -167,7 +167,7 @@ pub const File = struct {
167167 /// be created with.
168168 mode: Mode = default_mode,
169169
170 /// Setting this to `.blocking` prevents `O_NONBLOCK` from being passed even
170 /// Setting this to `.blocking` prevents `O.NONBLOCK` from being passed even
171171 /// if `std.io.is_async`. It allows the use of `nosuspend` when calling functions
172172 /// related to opening the file, reading, writing, and locking.
173173 intended_io_mode: io.ModeOverride = io.default_mode,
......@@ -325,12 +325,12 @@ pub const File = struct {
325325 .size = @bitCast(u64, st.size),
326326 .mode = st.mode,
327327 .kind = if (builtin.os.tag == .wasi and !builtin.link_libc) switch (st.filetype) {
328 os.FILETYPE_BLOCK_DEVICE => Kind.BlockDevice,
329 os.FILETYPE_CHARACTER_DEVICE => Kind.CharacterDevice,
330 os.FILETYPE_DIRECTORY => Kind.Directory,
331 os.FILETYPE_SYMBOLIC_LINK => Kind.SymLink,
332 os.FILETYPE_REGULAR_FILE => Kind.File,
333 os.FILETYPE_SOCKET_STREAM, os.FILETYPE_SOCKET_DGRAM => Kind.UnixDomainSocket,
328 .BLOCK_DEVICE => Kind.BlockDevice,
329 .CHARACTER_DEVICE => Kind.CharacterDevice,
330 .DIRECTORY => Kind.Directory,
331 .SYMBOLIC_LINK => Kind.SymLink,
332 .REGULAR_FILE => Kind.File,
333 .SOCKET_STREAM, .SOCKET_DGRAM => Kind.UnixDomainSocket,
334334 else => Kind.Unknown,
335335 } else switch (st.mode & os.S.IFMT) {
336336 os.S.IFBLK => Kind.BlockDevice,
lib/std/fs/watch.zig+1-1
......@@ -250,7 +250,7 @@ pub fn Watch(comptime V: type) type {
250250 };
251251
252252 // @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;
254254 const fd = try os.open(realpath, flags, 0);
255255 gop.value_ptr.putter_frame = async self.kqPutEvents(fd, gop.key_ptr.*, gop.value_ptr.*);
256256 return null;
lib/std/os.zig+9-8
......@@ -72,7 +72,6 @@ pub const E = system.E;
7272pub const Elf_Symndx = system.Elf_Symndx;
7373pub const F = system.F;
7474pub const FD_CLOEXEC = system.FD_CLOEXEC;
75pub const F_OK = system.F_OK;
7675pub const Flock = system.Flock;
7776pub const HOST_NAME_MAX = system.HOST_NAME_MAX;
7877pub const IFNAMESIZE = system.IFNAMESIZE;
......@@ -96,7 +95,6 @@ pub const REG = system.REG;
9695pub const RIGHT = system.RIGHT;
9796pub const RLIM = system.RLIM;
9897pub const RR = system.RR;
99pub const R_OK = system.R_OK;
10098pub const S = system.S;
10199pub const SA = system.SA;
102100pub const SC = system.SC;
......@@ -116,8 +114,6 @@ pub const Stat = system.Stat;
116114pub const TCSA = system.TCSA;
117115pub const VDSO = system.VDSO;
118116pub const W = system.W;
119pub const W_OK = system.W_OK;
120pub const X_OK = system.X_OK;
121117pub const addrinfo = system.addrinfo;
122118pub const blkcnt_t = system.blkcnt_t;
123119pub const blksize_t = system.blksize_t;
......@@ -165,6 +161,11 @@ pub const uid_t = system.uid_t;
165161pub const user_desc = system.user_desc;
166162pub 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
168169pub const iovec = extern struct {
169170 iov_base: [*]u8,
170171 iov_len: usize,
......@@ -4237,7 +4238,7 @@ pub fn lseek_SET(fd: fd_t, offset: u64) SeekError!void {
42374238 }
42384239 if (builtin.os.tag == .wasi and !builtin.link_libc) {
42394240 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)) {
42414242 .SUCCESS => return,
42424243 .BADF => unreachable, // always a race condition
42434244 .INVAL => return error.Unseekable,
......@@ -4285,7 +4286,7 @@ pub fn lseek_CUR(fd: fd_t, offset: i64) SeekError!void {
42854286 }
42864287 if (builtin.os.tag == .wasi and !builtin.link_libc) {
42874288 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)) {
42894290 .SUCCESS => return,
42904291 .BADF => unreachable, // always a race condition
42914292 .INVAL => return error.Unseekable,
......@@ -4332,7 +4333,7 @@ pub fn lseek_END(fd: fd_t, offset: i64) SeekError!void {
43324333 }
43334334 if (builtin.os.tag == .wasi and !builtin.link_libc) {
43344335 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)) {
43364337 .SUCCESS => return,
43374338 .BADF => unreachable, // always a race condition
43384339 .INVAL => return error.Unseekable,
......@@ -4379,7 +4380,7 @@ pub fn lseek_CUR_get(fd: fd_t) SeekError!u64 {
43794380 }
43804381 if (builtin.os.tag == .wasi and !builtin.link_libc) {
43814382 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)) {
43834384 .SUCCESS => return new_offset,
43844385 .BADF => unreachable, // always a race condition
43854386 .INVAL => return error.Unseekable,
lib/std/os/linux.zig+46-36
......@@ -57,24 +57,23 @@ pub const socketcall = syscall_bits.socketcall;
5757pub const syscall_pipe = syscall_bits.syscall_pipe;
5858pub const syscall_fork = syscall_bits.syscall_fork;
5959
60pub const clone = arch_bits.clone;
6160pub const ARCH = arch_bits.ARCH;
6261pub const Elf_Symndx = arch_bits.Elf_Symndx;
6362pub const F = arch_bits.F;
6463pub const Flock = arch_bits.Flock;
64pub const HWCAP = arch_bits.HWCAP;
6565pub const LOCK = arch_bits.LOCK;
66pub const MAP = arch_bits.MAP;
6766pub const MMAP2_UNIT = arch_bits.MMAP2_UNIT;
68pub const O = arch_bits.O;
6967pub const REG = arch_bits.REG;
7068pub const SC = arch_bits.SC;
7169pub const SYS = arch_bits.SYS;
70pub const Stat = arch_bits.Stat;
7271pub const VDSO = arch_bits.VDSO;
7372pub const blkcnt_t = arch_bits.blkcnt_t;
7473pub const blksize_t = arch_bits.blksize_t;
74pub const clone = arch_bits.clone;
7575pub const dev_t = arch_bits.dev_t;
7676pub const ino_t = arch_bits.ino_t;
77pub const Stat = arch_bits.Stat;
7877pub const mcontext_t = arch_bits.mcontext_t;
7978pub const mode_t = arch_bits.mode_t;
8079pub const msghdr = arch_bits.msghdr;
......@@ -92,29 +91,46 @@ pub const tls = @import("linux/tls.zig");
9291pub const pie = @import("linux/start_pie.zig");
9392pub const BPF = @import("linux/bpf.zig");
9493
95const io_uring = @import("linux/io_uring.zig");
96pub const IO_Uring = io_uring.IO_Uring;
97pub const SubmissionQueue = io_uring.SubmissionQueue;
98pub const CompletionQueue = io_uring.CompletionQueue;
99pub const io_uring_prep_nop = io_uring.io_uring_prep_nop;
100pub const io_uring_prep_fsync = io_uring.io_uring_prep_fsync;
101pub const io_uring_prep_rw = io_uring.io_uring_prep_rw;
102pub const io_uring_prep_read = io_uring.io_uring_prep_read;
103pub const io_uring_prep_write = io_uring.io_uring_prep_write;
104pub const io_uring_prep_readv = io_uring.io_uring_prep_readv;
105pub const io_uring_prep_writev = io_uring.io_uring_prep_writev;
106pub const io_uring_prep_accept = io_uring.io_uring_prep_accept;
107pub const io_uring_prep_connect = io_uring.io_uring_prep_connect;
108pub const io_uring_prep_epoll_ctl = io_uring.io_uring_prep_epoll_ctl;
109pub const io_uring_prep_recv = io_uring.io_uring_prep_recv;
110pub const io_uring_prep_send = io_uring.io_uring_prep_send;
111pub const io_uring_prep_openat = io_uring.io_uring_prep_openat;
112pub const io_uring_prep_close = io_uring.io_uring_prep_close;
113pub const io_uring_prep_timeout = io_uring.io_uring_prep_timeout;
114pub const io_uring_prep_timeout_remove = io_uring.io_uring_prep_timeout_remove;
115pub const io_uring_prep_poll_add = io_uring.io_uring_prep_poll_add;
116pub const io_uring_prep_poll_remove = io_uring.io_uring_prep_poll_remove;
117pub const io_uring_prep_fallocate = io_uring.io_uring_prep_fallocate;
94pub const MAP = struct {
95 pub usingnamespace arch_bits.MAP;
96
97 /// Share changes
98 pub const SHARED = 0x01;
99 /// Changes are private
100 pub const PRIVATE = 0x02;
101 /// share + validate extension flags
102 pub const SHARED_VALIDATE = 0x03;
103 /// Mask for type of mapping
104 pub const TYPE = 0x0f;
105 /// Interpret addr exactly
106 pub const FIXED = 0x10;
107 /// don't use a file
108 pub const ANONYMOUS = 0x20;
109 /// populate (prefault) pagetables
110 pub const POPULATE = 0x8000;
111 /// do not block on IO
112 pub const NONBLOCK = 0x10000;
113 /// give out an address that is best suited for process/thread stacks
114 pub const STACK = 0x20000;
115 /// create a huge page mapping
116 pub const HUGETLB = 0x40000;
117 /// perform synchronous page faults for the mapping
118 pub const SYNC = 0x80000;
119 /// FIXED which doesn't unmap underlying mapping
120 pub const FIXED_NOREPLACE = 0x100000;
121 /// For anonymous mmap, memory could be uninitialized
122 pub const UNINITIALIZED = 0x4000000;
123};
124
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
119135/// Set by startup code, used by `getauxval`.
120136pub var elf_aux_maybe: ?[*]std.elf.Auxv = null;
......@@ -1725,26 +1741,20 @@ pub const FUTEX = struct {
17251741pub const PROT = struct {
17261742 /// page can not be accessed
17271743 pub const NONE = 0x0;
1728
17291744 /// page can be read
17301745 pub const READ = 0x1;
1731
17321746 /// page can be written
17331747 pub const WRITE = 0x2;
1734
17351748 /// page can be executed
17361749 pub const EXEC = 0x4;
1737
17381750 /// page may be used for atomic ops
17391751 pub const SEM = switch (native_arch) {
17401752 // TODO: also xtensa
17411753 .mips, .mipsel, .mips64, .mips64el => 0x10,
17421754 else => 0x8,
17431755 };
1744
17451756 /// mprotect flag: extend change to start of growsdown vma
17461757 pub const GROWSDOWN = 0x01000000;
1747
17481758 /// mprotect flag: extend change to end of growsup vma
17491759 pub const GROWSUP = 0x02000000;
17501760};
......@@ -1960,16 +1970,16 @@ pub const RWF = struct {
19601970 /// high priority request, poll if possible
19611971 pub const HIPRI: kernel_rwf = 0x00000001;
19621972
1963 /// per-IO O_DSYNC
1973 /// per-IO O.DSYNC
19641974 pub const DSYNC: kernel_rwf = 0x00000002;
19651975
1966 /// per-IO O_SYNC
1976 /// per-IO O.SYNC
19671977 pub const SYNC: kernel_rwf = 0x00000004;
19681978
19691979 /// per-IO, return -EAGAIN if operation would block
19701980 pub const NOWAIT: kernel_rwf = 0x00000008;
19711981
1972 /// per-IO O_APPEND
1982 /// per-IO O.APPEND
19731983 pub const APPEND: kernel_rwf = 0x00000010;
19741984};
19751985
lib/std/os/linux/arm-eabi.zig+53-48
......@@ -532,26 +532,28 @@ pub const SYS = enum(usize) {
532532
533533pub const MMAP2_UNIT = 4096;
534534
535pub const O_CREAT = 0o100;
536pub const O_EXCL = 0o200;
537pub const O_NOCTTY = 0o400;
538pub const O_TRUNC = 0o1000;
539pub const O_APPEND = 0o2000;
540pub const O_NONBLOCK = 0o4000;
541pub const O_DSYNC = 0o10000;
542pub const O_SYNC = 0o4010000;
543pub const O_RSYNC = 0o4010000;
544pub const O_DIRECTORY = 0o40000;
545pub const O_NOFOLLOW = 0o100000;
546pub const O_CLOEXEC = 0o2000000;
547
548pub const O_ASYNC = 0o20000;
549pub const O_DIRECT = 0o200000;
550pub const O_LARGEFILE = 0o400000;
551pub const O_NOATIME = 0o1000000;
552pub const O_PATH = 0o10000000;
553pub const O_TMPFILE = 0o20040000;
554pub const O_NDELAY = O_NONBLOCK;
535pub const O = struct {
536 pub const CREAT = 0o100;
537 pub const EXCL = 0o200;
538 pub const NOCTTY = 0o400;
539 pub const TRUNC = 0o1000;
540 pub const APPEND = 0o2000;
541 pub const NONBLOCK = 0o4000;
542 pub const DSYNC = 0o10000;
543 pub const SYNC = 0o4010000;
544 pub const RSYNC = 0o4010000;
545 pub const DIRECTORY = 0o40000;
546 pub const NOFOLLOW = 0o100000;
547 pub const CLOEXEC = 0o2000000;
548
549 pub const ASYNC = 0o20000;
550 pub const DIRECT = 0o200000;
551 pub const LARGEFILE = 0o400000;
552 pub const NOATIME = 0o1000000;
553 pub const PATH = 0o10000000;
554 pub const TMPFILE = 0o20040000;
555 pub const NDELAY = NONBLOCK;
556};
555557
556558pub const F = struct {
557559 pub const DUPFD = 0;
......@@ -597,35 +599,38 @@ pub const MAP = struct {
597599 pub const LOCKED = 0x2000;
598600 /// don't check for reservations
599601 pub const NORESERVE = 0x4000;
600 /// Only used by libc to communicate failure.
601 pub const FAILED = @intToPtr(*c_void, maxInt(usize));
602602};
603pub const VDSO_CGT_SYM = "__vdso_clock_gettime";
604pub const VDSO_CGT_VER = "LINUX_2.6";
605
606pub const HWCAP_SWP = 1 << 0;
607pub const HWCAP_HALF = 1 << 1;
608pub const HWCAP_THUMB = 1 << 2;
609pub const HWCAP_26BIT = 1 << 3;
610pub const HWCAP_FAST_MULT = 1 << 4;
611pub const HWCAP_FPA = 1 << 5;
612pub const HWCAP_VFP = 1 << 6;
613pub const HWCAP_EDSP = 1 << 7;
614pub const HWCAP_JAVA = 1 << 8;
615pub const HWCAP_IWMMXT = 1 << 9;
616pub const HWCAP_CRUNCH = 1 << 10;
617pub const HWCAP_THUMBEE = 1 << 11;
618pub const HWCAP_NEON = 1 << 12;
619pub const HWCAP_VFPv3 = 1 << 13;
620pub const HWCAP_VFPv3D16 = 1 << 14;
621pub const HWCAP_TLS = 1 << 15;
622pub const HWCAP_VFPv4 = 1 << 16;
623pub const HWCAP_IDIVA = 1 << 17;
624pub const HWCAP_IDIVT = 1 << 18;
625pub const HWCAP_VFPD32 = 1 << 19;
626pub const HWCAP_IDIV = HWCAP_IDIVA | HWCAP_IDIVT;
627pub const HWCAP_LPAE = 1 << 20;
628pub const HWCAP_EVTSTRM = 1 << 21;
603
604pub const VDSO = struct {
605 pub const CGT_SYM = "__vdso_clock_gettime";
606 pub const CGT_VER = "LINUX_2.6";
607};
608
609pub const HWCAP = struct {
610 pub const SWP = 1 << 0;
611 pub const HALF = 1 << 1;
612 pub const THUMB = 1 << 2;
613 pub const @"26BIT" = 1 << 3;
614 pub const FAST_MULT = 1 << 4;
615 pub const FPA = 1 << 5;
616 pub const VFP = 1 << 6;
617 pub const EDSP = 1 << 7;
618 pub const JAVA = 1 << 8;
619 pub const IWMMXT = 1 << 9;
620 pub const CRUNCH = 1 << 10;
621 pub const THUMBEE = 1 << 11;
622 pub const NEON = 1 << 12;
623 pub const VFPv3 = 1 << 13;
624 pub const VFPv3D16 = 1 << 14;
625 pub const TLS = 1 << 15;
626 pub const VFPv4 = 1 << 16;
627 pub const IDIVA = 1 << 17;
628 pub const IDIVT = 1 << 18;
629 pub const VFPD32 = 1 << 19;
630 pub const IDIV = IDIVA | IDIVT;
631 pub const LPAE = 1 << 20;
632 pub const EVTSTRM = 1 << 21;
633};
629634
630635pub const Flock = extern struct {
631636 l_type: i16,
lib/std/os/linux/arm64.zig+27-24
......@@ -410,26 +410,28 @@ pub const SYS = enum(usize) {
410410 _,
411411};
412412
413pub const O_CREAT = 0o100;
414pub const O_EXCL = 0o200;
415pub const O_NOCTTY = 0o400;
416pub const O_TRUNC = 0o1000;
417pub const O_APPEND = 0o2000;
418pub const O_NONBLOCK = 0o4000;
419pub const O_DSYNC = 0o10000;
420pub const O_SYNC = 0o4010000;
421pub const O_RSYNC = 0o4010000;
422pub const O_DIRECTORY = 0o40000;
423pub const O_NOFOLLOW = 0o100000;
424pub const O_CLOEXEC = 0o2000000;
425
426pub const O_ASYNC = 0o20000;
427pub const O_DIRECT = 0o200000;
428pub const O_LARGEFILE = 0o400000;
429pub const O_NOATIME = 0o1000000;
430pub const O_PATH = 0o10000000;
431pub const O_TMPFILE = 0o20040000;
432pub const O_NDELAY = O_NONBLOCK;
413pub const O = struct {
414 pub const CREAT = 0o100;
415 pub const EXCL = 0o200;
416 pub const NOCTTY = 0o400;
417 pub const TRUNC = 0o1000;
418 pub const APPEND = 0o2000;
419 pub const NONBLOCK = 0o4000;
420 pub const DSYNC = 0o10000;
421 pub const SYNC = 0o4010000;
422 pub const RSYNC = 0o4010000;
423 pub const DIRECTORY = 0o40000;
424 pub const NOFOLLOW = 0o100000;
425 pub const CLOEXEC = 0o2000000;
426
427 pub const ASYNC = 0o20000;
428 pub const DIRECT = 0o200000;
429 pub const LARGEFILE = 0o400000;
430 pub const NOATIME = 0o1000000;
431 pub const PATH = 0o10000000;
432 pub const TMPFILE = 0o20040000;
433 pub const NDELAY = NONBLOCK;
434};
433435
434436pub const F = struct {
435437 pub const DUPFD = 0;
......@@ -475,11 +477,12 @@ pub const MAP = struct {
475477 pub const LOCKED = 0x2000;
476478 /// don't check for reservations
477479 pub const NORESERVE = 0x4000;
478 /// Only used by libc to communicate failure.
479 pub const FAILED = @intToPtr(*c_void, maxInt(usize));
480480};
481pub const VDSO_CGT_SYM = "__kernel_clock_gettime";
482pub const VDSO_CGT_VER = "LINUX_2.6.39";
481
482pub const VDSO = struct {
483 pub const CGT_SYM = "__kernel_clock_gettime";
484 pub const CGT_VER = "LINUX_2.6.39";
485};
483486
484487pub const Flock = extern struct {
485488 l_type: i16,
lib/std/os/linux/i386.zig-34
......@@ -572,10 +572,6 @@ pub const SYS = enum(usize) {
572572};
573573
574574pub const O = struct {
575 pub const RDONLY = 0o0;
576 pub const WRONLY = 0o1;
577 pub const RDWR = 0o2;
578
579575 pub const CREAT = 0o100;
580576 pub const EXCL = 0o200;
581577 pub const NOCTTY = 0o400;
......@@ -628,42 +624,12 @@ pub const LOCK = struct {
628624};
629625
630626pub 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
658627 pub const NORESERVE = 0x4000;
659628 pub const GROWSDOWN = 0x0100;
660629 pub const DENYWRITE = 0x0800;
661630 pub const EXECUTABLE = 0x1000;
662631 pub const LOCKED = 0x2000;
663632 pub const @"32BIT" = 0x40;
664
665 /// Only used by libc to communicate failure.
666 pub const FAILED = @intToPtr(*c_void, maxInt(usize));
667633};
668634
669635pub const MMAP2_UNIT = 4096;
lib/std/os/linux/io_uring.zig+7-7
......@@ -539,7 +539,7 @@ pub const IO_Uring = struct {
539539 pub fn timeout(
540540 self: *IO_Uring,
541541 user_data: u64,
542 ts: *const os.__kernel_timespec,
542 ts: *const os.linux.timespec,
543543 count: u32,
544544 flags: u32,
545545 ) !*io_uring_sqe {
......@@ -979,7 +979,7 @@ pub fn io_uring_prep_close(sqe: *io_uring_sqe, fd: os.fd_t) void {
979979
980980pub fn io_uring_prep_timeout(
981981 sqe: *io_uring_sqe,
982 ts: *const os.__kernel_timespec,
982 ts: *const os.linux.timespec,
983983 count: u32,
984984 flags: u32,
985985) void {
......@@ -1136,7 +1136,7 @@ test "readv" {
11361136 };
11371137 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);
11401140 defer os.close(fd);
11411141
11421142 // 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" {
12951295 const path = "test_io_uring_openat";
12961296 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;
12991299 const mode: os.mode_t = 0o666;
13001300 const sqe_openat = try ring.openat(0x33333333, linux.AT.FDCWD, path, flags, mode);
13011301 try testing.expectEqual(io_uring_sqe{
......@@ -1450,7 +1450,7 @@ test "timeout (after a relative time)" {
14501450
14511451 const ms = 10;
14521452 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
14551455 const started = std.time.milliTimestamp();
14561456 const sqe = try ring.timeout(0x55555555, &ts, 0, 0);
......@@ -1479,7 +1479,7 @@ test "timeout (after a number of completions)" {
14791479 };
14801480 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 };
14831483 const count_completions: u64 = 1;
14841484 const sqe_timeout = try ring.timeout(0x66666666, &ts, count_completions, 0);
14851485 try testing.expectEqual(linux.IORING_OP.TIMEOUT, sqe_timeout.opcode);
......@@ -1512,7 +1512,7 @@ test "timeout_remove" {
15121512 };
15131513 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 };
15161516 const sqe_timeout = try ring.timeout(0x88888888, &ts, 0, 0);
15171517 try testing.expectEqual(linux.IORING_OP.TIMEOUT, sqe_timeout.opcode);
15181518 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) {
629629 _,
630630};
631631
632pub const O_CREAT = 0o0400;
633pub const O_EXCL = 0o02000;
634pub const O_NOCTTY = 0o04000;
635pub const O_TRUNC = 0o01000;
636pub const O_APPEND = 0o0010;
637pub const O_NONBLOCK = 0o0200;
638pub const O_DSYNC = 0o0020;
639pub const O_SYNC = 0o040020;
640pub const O_RSYNC = 0o040020;
641pub const O_DIRECTORY = 0o0200000;
642pub const O_NOFOLLOW = 0o0400000;
643pub const O_CLOEXEC = 0o02000000;
644
645pub const O_ASYNC = 0o010000;
646pub const O_DIRECT = 0o0100000;
647pub const O_LARGEFILE = 0o020000;
648pub const O_NOATIME = 0o01000000;
649pub const O_PATH = 0o010000000;
650pub const O_TMPFILE = 0o020200000;
651pub const O_NDELAY = O_NONBLOCK;
632pub const O = struct {
633 pub const CREAT = 0o0400;
634 pub const EXCL = 0o02000;
635 pub const NOCTTY = 0o04000;
636 pub const TRUNC = 0o01000;
637 pub const APPEND = 0o0010;
638 pub const NONBLOCK = 0o0200;
639 pub const DSYNC = 0o0020;
640 pub const SYNC = 0o040020;
641 pub const RSYNC = 0o040020;
642 pub const DIRECTORY = 0o0200000;
643 pub const NOFOLLOW = 0o0400000;
644 pub const CLOEXEC = 0o02000000;
645
646 pub const ASYNC = 0o010000;
647 pub const DIRECT = 0o0100000;
648 pub const LARGEFILE = 0o020000;
649 pub const NOATIME = 0o01000000;
650 pub const PATH = 0o010000000;
651 pub const TMPFILE = 0o020200000;
652 pub const NDELAY = NONBLOCK;
653};
652654
653655pub const F = struct {
654656 pub const DUPFD = 0;
......@@ -692,8 +694,6 @@ pub const MAP = struct {
692694 pub const EXECUTABLE = 0x4000;
693695 pub const LOCKED = 0x8000;
694696 pub const @"32BIT" = 0x40;
695 /// Only used by libc to communicate failure.
696 pub const FAILED = @intToPtr(*c_void, maxInt(usize));
697697};
698698
699699pub const SO = struct {
......@@ -726,8 +726,10 @@ pub const SO = struct {
726726 pub const RCVBUFFORCE = 33;
727727};
728728
729pub const VDSO_CGT_SYM = "__kernel_clock_gettime";
730pub const VDSO_CGT_VER = "LINUX_2.6.39";
729pub const VDSO = struct {
730 pub const CGT_SYM = "__kernel_clock_gettime";
731 pub const CGT_VER = "LINUX_2.6.39";
732};
731733
732734pub const Flock = extern struct {
733735 l_type: i16,
lib/std/os/linux/powerpc.zig+27-24
......@@ -562,26 +562,28 @@ pub const SYS = enum(usize) {
562562 process_madvise = 440,
563563};
564564
565pub const O_CREAT = 0o100;
566pub const O_EXCL = 0o200;
567pub const O_NOCTTY = 0o400;
568pub const O_TRUNC = 0o1000;
569pub const O_APPEND = 0o2000;
570pub const O_NONBLOCK = 0o4000;
571pub const O_DSYNC = 0o10000;
572pub const O_SYNC = 0o4010000;
573pub const O_RSYNC = 0o4010000;
574pub const O_DIRECTORY = 0o40000;
575pub const O_NOFOLLOW = 0o100000;
576pub const O_CLOEXEC = 0o2000000;
577
578pub const O_ASYNC = 0o20000;
579pub const O_DIRECT = 0o400000;
580pub const O_LARGEFILE = 0o200000;
581pub const O_NOATIME = 0o1000000;
582pub const O_PATH = 0o10000000;
583pub const O_TMPFILE = 0o20040000;
584pub const O_NDELAY = O_NONBLOCK;
565pub const O = struct {
566 pub const CREAT = 0o100;
567 pub const EXCL = 0o200;
568 pub const NOCTTY = 0o400;
569 pub const TRUNC = 0o1000;
570 pub const APPEND = 0o2000;
571 pub const NONBLOCK = 0o4000;
572 pub const DSYNC = 0o10000;
573 pub const SYNC = 0o4010000;
574 pub const RSYNC = 0o4010000;
575 pub const DIRECTORY = 0o40000;
576 pub const NOFOLLOW = 0o100000;
577 pub const CLOEXEC = 0o2000000;
578
579 pub const ASYNC = 0o20000;
580 pub const DIRECT = 0o400000;
581 pub const LARGEFILE = 0o200000;
582 pub const NOATIME = 0o1000000;
583 pub const PATH = 0o10000000;
584 pub const TMPFILE = 0o20040000;
585 pub const NDELAY = NONBLOCK;
586};
585587
586588pub const F = struct {
587589 pub const DUPFD = 0;
......@@ -627,11 +629,12 @@ pub const MAP = struct {
627629 pub const LOCKED = 0x0080;
628630 /// don't check for reservations
629631 pub const NORESERVE = 0x0040;
630 /// Only used by libc to communicate failure.
631 pub const FAILED = @intToPtr(*c_void, maxInt(usize));
632632};
633pub const VDSO_CGT_SYM = "__kernel_clock_gettime";
634pub const VDSO_CGT_VER = "LINUX_2.6.15";
633
634pub const VDSO = struct {
635 pub const CGT_SYM = "__kernel_clock_gettime";
636 pub const CGT_VER = "LINUX_2.6.15";
637};
635638
636639pub const Flock = extern struct {
637640 l_type: i16,
lib/std/os/linux/powerpc64.zig+26-24
......@@ -537,26 +537,28 @@ pub const SYS = enum(usize) {
537537 _,
538538};
539539
540pub const O_CREAT = 0o100;
541pub const O_EXCL = 0o200;
542pub const O_NOCTTY = 0o400;
543pub const O_TRUNC = 0o1000;
544pub const O_APPEND = 0o2000;
545pub const O_NONBLOCK = 0o4000;
546pub const O_DSYNC = 0o10000;
547pub const O_SYNC = 0o4010000;
548pub const O_RSYNC = 0o4010000;
549pub const O_DIRECTORY = 0o40000;
550pub const O_NOFOLLOW = 0o100000;
551pub const O_CLOEXEC = 0o2000000;
552
553pub const O_ASYNC = 0o20000;
554pub const O_DIRECT = 0o400000;
555pub const O_LARGEFILE = 0o200000;
556pub const O_NOATIME = 0o1000000;
557pub const O_PATH = 0o10000000;
558pub const O_TMPFILE = 0o20200000;
559pub const O_NDELAY = O_NONBLOCK;
540pub const O = struct {
541 pub const CREAT = 0o100;
542 pub const EXCL = 0o200;
543 pub const NOCTTY = 0o400;
544 pub const TRUNC = 0o1000;
545 pub const APPEND = 0o2000;
546 pub const NONBLOCK = 0o4000;
547 pub const DSYNC = 0o10000;
548 pub const SYNC = 0o4010000;
549 pub const RSYNC = 0o4010000;
550 pub const DIRECTORY = 0o40000;
551 pub const NOFOLLOW = 0o100000;
552 pub const CLOEXEC = 0o2000000;
553
554 pub const ASYNC = 0o20000;
555 pub const DIRECT = 0o400000;
556 pub const LARGEFILE = 0o200000;
557 pub const NOATIME = 0o1000000;
558 pub const PATH = 0o10000000;
559 pub const TMPFILE = 0o20200000;
560 pub const NDELAY = NONBLOCK;
561};
560562
561563pub const F = struct {
562564 pub const DUPFD = 0;
......@@ -602,12 +604,12 @@ pub const MAP = struct {
602604 pub const LOCKED = 0x0080;
603605 /// don't check for reservations
604606 pub const NORESERVE = 0x0040;
605 /// Only used by libc to communicate failure.
606 pub const FAILED = @intToPtr(*c_void, maxInt(usize));
607607};
608608
609pub const VDSO_CGT_SYM = "__kernel_clock_gettime";
610pub const VDSO_CGT_VER = "LINUX_2.6.15";
609pub const VDSO = struct {
610 pub const CGT_SYM = "__kernel_clock_gettime";
611 pub const CGT_VER = "LINUX_2.6.15";
612};
611613
612614pub const Flock = extern struct {
613615 l_type: i16,
lib/std/os/linux/riscv64.zig+24-19
......@@ -406,26 +406,28 @@ pub const SYS = enum(usize) {
406406 _,
407407};
408408
409pub const O_CREAT = 0o100;
410pub const O_EXCL = 0o200;
411pub const O_NOCTTY = 0o400;
412pub const O_TRUNC = 0o1000;
413pub const O_APPEND = 0o2000;
414pub const O_NONBLOCK = 0o4000;
415pub const O_DSYNC = 0o10000;
416pub const O_SYNC = 0o4010000;
417pub const O_RSYNC = 0o4010000;
418pub const O_DIRECTORY = 0o200000;
419pub const O_NOFOLLOW = 0o400000;
420pub const O_CLOEXEC = 0o2000000;
409pub const O = struct {
410 pub const CREAT = 0o100;
411 pub const EXCL = 0o200;
412 pub const NOCTTY = 0o400;
413 pub const TRUNC = 0o1000;
414 pub const APPEND = 0o2000;
415 pub const NONBLOCK = 0o4000;
416 pub const DSYNC = 0o10000;
417 pub const SYNC = 0o4010000;
418 pub const RSYNC = 0o4010000;
419 pub const DIRECTORY = 0o200000;
420 pub const NOFOLLOW = 0o400000;
421 pub const CLOEXEC = 0o2000000;
421422
422pub const O_ASYNC = 0o20000;
423pub const O_DIRECT = 0o40000;
424pub const O_LARGEFILE = 0o100000;
425pub const O_NOATIME = 0o1000000;
426pub const O_PATH = 0o10000000;
427pub const O_TMPFILE = 0o20200000;
428pub const O_NDELAY = O_NONBLOCK;
423 pub const ASYNC = 0o20000;
424 pub const DIRECT = 0o40000;
425 pub const LARGEFILE = 0o100000;
426 pub const NOATIME = 0o1000000;
427 pub const PATH = 0o10000000;
428 pub const TMPFILE = 0o20200000;
429 pub const NDELAY = NONBLOCK;
430};
429431
430432pub const F = struct {
431433 pub const DUPFD = 0;
......@@ -518,3 +520,6 @@ pub const Stat = extern struct {
518520};
519521
520522pub 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) {
571571 _,
572572};
573573
574pub const O_CREAT = 0x200;
575pub const O_EXCL = 0x800;
576pub const O_NOCTTY = 0x8000;
577pub const O_TRUNC = 0x400;
578pub const O_APPEND = 0x8;
579pub const O_NONBLOCK = 0x4000;
580pub const O_SYNC = 0x802000;
581pub const O_DSYNC = 0x2000;
582pub const O_RSYNC = O_SYNC;
583pub const O_DIRECTORY = 0x10000;
584pub const O_NOFOLLOW = 0x20000;
585pub const O_CLOEXEC = 0x400000;
586
587pub const O_ASYNC = 0x40;
588pub const O_DIRECT = 0x100000;
589pub const O_LARGEFILE = 0;
590pub const O_NOATIME = 0x200000;
591pub const O_PATH = 0x1000000;
592pub const O_TMPFILE = 0x2010000;
593pub const O_NDELAY = O_NONBLOCK | 0x4;
574pub const O = struct {
575 pub const CREAT = 0x200;
576 pub const EXCL = 0x800;
577 pub const NOCTTY = 0x8000;
578 pub const TRUNC = 0x400;
579 pub const APPEND = 0x8;
580 pub const NONBLOCK = 0x4000;
581 pub const SYNC = 0x802000;
582 pub const DSYNC = 0x2000;
583 pub const RSYNC = SYNC;
584 pub const DIRECTORY = 0x10000;
585 pub const NOFOLLOW = 0x20000;
586 pub const CLOEXEC = 0x400000;
587
588 pub const ASYNC = 0x40;
589 pub const DIRECT = 0x100000;
590 pub const LARGEFILE = 0;
591 pub const NOATIME = 0x200000;
592 pub const PATH = 0x1000000;
593 pub const TMPFILE = 0x2010000;
594 pub const NDELAY = NONBLOCK | 0x4;
595};
594596
595597pub const F = struct {
596598 pub const DUPFD = 0;
......@@ -633,11 +635,12 @@ pub const MAP = struct {
633635 pub const LOCKED = 0x0100;
634636 /// don't check for reservations
635637 pub const NORESERVE = 0x0040;
636 /// Only used by libc to communicate failure.
637 pub const FAILED = @intToPtr(*c_void, maxInt(usize));
638638};
639pub const VDSO_CGT_SYM = "__vdso_clock_gettime";
640pub const VDSO_CGT_VER = "LINUX_2.6";
639
640pub const VDSO = struct {
641 pub const CGT_SYM = "__vdso_clock_gettime";
642 pub const CGT_VER = "LINUX_2.6";
643};
641644
642645pub const Flock = extern struct {
643646 l_type: i16,
lib/std/os/linux/x86_64.zig-32
......@@ -476,10 +476,6 @@ pub const SYS = enum(usize) {
476476};
477477
478478pub const O = struct {
479 pub const RDONLY = 0o0;
480 pub const WRONLY = 0o1;
481 pub const RDWR = 0o2;
482
483479 pub const CREAT = 0o100;
484480 pub const EXCL = 0o200;
485481 pub const NOCTTY = 0o400;
......@@ -526,32 +522,6 @@ pub const F = struct {
526522};
527523
528524pub 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;
555525 /// only give out 32bit addresses
556526 pub const @"32BIT" = 0x40;
557527 /// stack-like segment
......@@ -564,8 +534,6 @@ pub const MAP = struct {
564534 pub const LOCKED = 0x2000;
565535 /// don't check for reservations
566536 pub const NORESERVE = 0x4000;
567 /// Only used by libc to communicate failure.
568 pub const FAILED = @intToPtr(*c_void, maxInt(usize));
569537};
570538
571539pub const VDSO = struct {
lib/std/os/test.zig+2-2
......@@ -401,7 +401,7 @@ test "sigaltstack" {
401401
402402// If the type is not available use void to avoid erroring out when `iter_fn` is
403403// 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
406406const IterFnError = error{
407407 MissingPtLoadSegment,
......@@ -676,7 +676,7 @@ test "fsync" {
676676}
677677
678678test "getrlimit and setrlimit" {
679 if (native_os == .windows) {
679 if (!@hasDecl(os.system, "rlimit")) {
680680 return error.SkipZigTest;
681681 }
682682
lib/std/os/wasi.zig+2
......@@ -337,6 +337,7 @@ pub const filestat_t = extern struct {
337337 }
338338};
339339
340/// Also known as `FILETYPE`.
340341pub const filetype_t = enum(u8) {
341342 UNKNOWN,
342343 BLOCK_DEVICE,
......@@ -532,6 +533,7 @@ pub const timestamp_t = u64;
532533
533534pub const userdata_t = u64;
534535
536/// Also known as `WHENCE`.
535537pub const whence_t = enum(u8) { SET, CUR, END };
536538
537539pub const S = struct {
lib/std/os/windows.zig+1-1
......@@ -3192,7 +3192,7 @@ pub usingnamespace switch (native_arch) {
31923192
31933193pub const EXCEPTION_POINTERS = extern struct {
31943194 ExceptionRecord: *EXCEPTION_RECORD,
3195 ContextRecord: *@This().CONTEXT,
3195 ContextRecord: *std.os.windows.CONTEXT,
31963196};
31973197
31983198pub 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
2525 _ = msg;
2626 _ = error_return_trace;
2727 @setCold(true);
28 if (@hasDecl(std.os, "abort"))
29 std.os.abort();
30 while (true) {}
28 std.os.abort();
3129}
3230
3331export fn __stack_chk_fail() callconv(.C) noreturn {
lib/std/start.zig+1-1
......@@ -345,7 +345,7 @@ fn posixCallMainAndExit() noreturn {
345345 // FIXME: Elide the check for targets >= ARMv7 when the target feature API
346346 // becomes less verbose (and more usable).
347347 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) {
349349 // FIXME: Make __aeabi_read_tp call the kernel helper kuser_get_tls
350350 // For the time being use a simple abort instead of a @panic call to
351351 // keep the binary bloat under control.
lib/std/x/net/tcp.zig+3-3
......@@ -193,7 +193,7 @@ pub const Client = struct {
193193 /// Disable Nagle's algorithm on a TCP socket. It returns `error.UnsupportedSocketOption` if
194194 /// the host does not support sockets disabling Nagle's algorithm.
195195 pub fn setNoDelay(self: Client, enabled: bool) !void {
196 if (comptime @hasDecl(os, "TCP_NODELAY")) {
196 if (@hasDecl(os.TCP, "NODELAY")) {
197197 const bytes = mem.asBytes(&@as(usize, @boolToInt(enabled)));
198198 return self.socket.setOption(os.IPPROTO.TCP, os.TCP_NODELAY, bytes);
199199 }
......@@ -203,7 +203,7 @@ pub const Client = struct {
203203 /// Enables TCP Quick ACK on a TCP socket to immediately send rather than delay ACKs when necessary. It returns
204204 /// `error.UnsupportedSocketOption` if the host does not support TCP Quick ACK.
205205 pub fn setQuickACK(self: Client, enabled: bool) !void {
206 if (comptime @hasDecl(os, "TCP_QUICKACK")) {
206 if (@hasDecl(os.TCP, "QUICKACK")) {
207207 return self.socket.setOption(os.IPPROTO.TCP, os.TCP_QUICKACK, mem.asBytes(&@as(u32, @boolToInt(enabled))));
208208 }
209209 return error.UnsupportedSocketOption;
......@@ -304,7 +304,7 @@ pub const Listener = struct {
304304 /// Enables TCP Fast Open (RFC 7413) on a TCP socket. It returns `error.UnsupportedSocketOption` if the host does not
305305 /// support TCP Fast Open.
306306 pub fn setFastOpen(self: Listener, enabled: bool) !void {
307 if (comptime @hasDecl(os, "TCP_FASTOPEN")) {
307 if (@hasDecl(os.TCP, "FASTOPEN")) {
308308 return self.socket.setOption(os.IPPROTO.TCP, os.TCP_FASTOPEN, mem.asBytes(&@as(u32, @boolToInt(enabled))));
309309 }
310310 return error.UnsupportedSocketOption;
lib/std/x/os/net.zig+3-2
......@@ -6,12 +6,13 @@ const mem = std.mem;
66const math = std.math;
77const testing = std.testing;
88const native_os = std.Target.current.os;
9const have_ifnamesize = @hasDecl(os.system, "IFNAMESIZE");
910
1011/// Resolves a network interface name into a scope/zone ID. It returns
1112/// an error if either resolution fails, or if the interface name is
1213/// too long.
1314pub fn resolveScopeID(name: []const u8) !u32 {
14 if (@hasDecl(os, "IFNAMESIZE")) {
15 if (have_ifnamesize) {
1516 if (name.len >= os.IFNAMESIZE - 1) return error.NameTooLong;
1617
1718 if (native_os.tag == .windows) {
......@@ -556,7 +557,7 @@ test "ipv6: parse & format" {
556557}
557558
558559test "ipv6: parse & format addresses with scope ids" {
559 if (!@hasDecl(os, "IFNAMESIZE")) return error.SkipZigTest;
560 if (!have_ifnamesize) return error.SkipZigTest;
560561
561562 const inputs = [_][]const u8{
562563 "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 @@
11const std = @import("std");
2const expect = std.testing.expect;
23
34fn Foo(comptime T: type) type {
45 return struct {
......@@ -20,3 +21,21 @@ usingnamespace struct {
2021test "usingnamespace does not redeclare an imported variable" {
2122 comptime try std.testing.expect(@This().foo == 42);
2223}
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 {
10731073 case.addError(
10741074 \\pub fn main() void {
10751075 \\ var i = 0;
1076 \\ for (n) |_, i| {
1076 \\ for ("n") |_, i| {
10771077 \\ }
10781078 \\}
10791079 , &[_][]const u8{
1080 ":3:17: error: redeclaration of local variable 'i'",
1080 ":3:19: error: redeclaration of local variable 'i'",
10811081 ":2:9: note: previous declaration here",
10821082 });
10831083 case.addError(
10841084 \\pub fn main() void {
10851085 \\ var i = 0;
1086 \\ for (n) |i| {
1086 \\ for ("n") |i| {
10871087 \\ }
10881088 \\}
10891089 , &[_][]const u8{
1090 ":3:14: error: redeclaration of local variable 'i'",
1090 ":3:16: error: redeclaration of local variable 'i'",
10911091 ":2:9: note: previous declaration here",
10921092 });
10931093 case.addError(
10941094 \\pub fn main() void {
10951095 \\ var i = 0;
1096 \\ while (n) |i| {
1096 \\ while ("n") |i| {
10971097 \\ }
10981098 \\}
10991099 , &[_][]const u8{
1100 ":3:16: error: redeclaration of local variable 'i'",
1100 ":3:18: error: redeclaration of local variable 'i'",
11011101 ":2:9: note: previous declaration here",
11021102 });
11031103 case.addError(
11041104 \\pub fn main() void {
11051105 \\ var i = 0;
1106 \\ while (n) |bruh| {
1106 \\ while ("n") |bruh| {
11071107 \\ _ = bruh;
11081108 \\ } else |i| {
11091109 \\
test/cli.zig-7
......@@ -45,13 +45,6 @@ pub fn main() !void {
4545 }
4646}
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
5548fn printCmd(cwd: []const u8, argv: []const []const u8) void {
5649 std.debug.warn("cd {s} && ", .{cwd});
5750 for (argv) |arg| {
test/compare_output.zig-105
......@@ -17,111 +17,6 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
1717 \\}
1818 , "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
12520 cases.add("hello world without libc",
12621 \\const io = @import("std").io;
12722 \\
test/standalone/brace_expansion/main.zig+1-1
......@@ -234,7 +234,7 @@ pub fn main() !void {
234234 var result_buf = ArrayList(u8).init(global_allocator);
235235 defer result_buf.deinit();
236236
237 try expandString(stdin_buf.items, &result_buf);
237 try expandString(stdin.items, &result_buf);
238238 try stdout_file.write(result_buf.items);
239239}
240240