authorgravatar for 3811822-hoanga@users.noreply.gitlab.comAl Hoang <3811822-hoanga@users.noreply.gitlab.com> 2021-11-13 23:29:53-06:00
committergravatar for 3811822-hoanga@users.noreply.gitlab.comAl Hoang <3811822-hoanga@users.noreply.gitlab.com> 2021-11-15 00:29:27-06:00
log4ec83133e9ee9bf5de97175c27881cc6e93d17c1
tree20a0920425482113ba3d87cf24a3f9048f7692d1
parentcfb9bf59c1388541bf3646836e5fc1e2af5505bc

haiku constants cleanup and update


1 files changed, 247 insertions(+), 618 deletions(-)

lib/std/c/haiku.zig+247-618
...@@ -145,28 +145,29 @@ pub const Kevent = extern struct {...@@ -145,28 +145,29 @@ pub const Kevent = extern struct {
145// include/dlfcn.h145// include/dlfcn.h
146146
147pub const POLL = struct {147pub const POLL = struct {
148 pub const IN = 0x0001;148 /// input available
149 pub const ERR = 0x0004;149 pub const IN = 70;
150 pub const NVAL = 0x1000;150 /// output available
151 pub const HUP = 0x0080;151 pub const OUT = 71;
152 /// input message available
153 pub const MSG = 72;
154 /// I/O error
155 pub const ERR = 73;
156 /// high priority input available
157 pub const PRI = 74;
158 /// device disconnected
159 pub const HUP = 75;
152};160};
153161
154pub const RTLD = struct {162pub const RTLD = struct {
155 /// Bind function calls lazily.163 /// relocations are performed as needed
156 pub const LAZY = 1;164 pub const LAZY = 0;
157 /// Bind function calls immediately.165 /// the file gets relocated at load time
158 pub const NOW = 2;166 pub const NOW = 1;
159 pub const MODEMASK = 0x3;167 /// all symbols are available
160 /// Make symbols globally available.168 pub const GLOBAL = 2;
161 pub const GLOBAL = 0x100;169 /// symbols are not available for relocating any other object
162 /// Opposite of GLOBAL, and the default.
163 pub const LOCAL = 0;170 pub const LOCAL = 0;
164 /// Trace loaded objects and exit.
165 pub const TRACE = 0x200;
166 /// Do not remove members.
167 pub const NODELETE = 0x01000;
168 /// Do not load if not already loaded.
169 pub const NOLOAD = 0x02000;
170};171};
171172
172pub const dl_phdr_info = extern struct {173pub const dl_phdr_info = extern struct {
...@@ -407,18 +408,11 @@ pub const sockaddr = extern struct {...@@ -407,18 +408,11 @@ pub const sockaddr = extern struct {
407 };408 };
408};409};
409410
410pub const CTL = struct {411pub const CTL = struct {};
411 pub const KERN = 1;
412 pub const DEBUG = 5;
413};
414412
415pub const KERN = struct {413pub const KERN = struct {};
416 pub const PROC = 14; // struct: process entries
417 pub const PROC_PATHNAME = 12; // path to executable
418 pub const IOV_MAX = 1024;
419};
420414
421pub const IOV_MAX = KERN.IOV_MAX;415pub const IOV_MAX = 1024;
422416
423pub const PATH_MAX = 1024;417pub const PATH_MAX = 1024;
424418
...@@ -427,36 +421,46 @@ pub const STDOUT_FILENO = 1;...@@ -427,36 +421,46 @@ pub const STDOUT_FILENO = 1;
427pub const STDERR_FILENO = 2;421pub const STDERR_FILENO = 2;
428422
429pub const PROT = struct {423pub const PROT = struct {
430 pub const NONE = 0;424 pub const READ = 0x01;
431 pub const READ = 1;425 pub const WRITE = 0x02;
432 pub const WRITE = 2;426 pub const EXEC = 0x04;
433 pub const EXEC = 4;427 pub const NONE = 0x00;
434};428};
435429
436pub const CLOCK = struct {430pub const CLOCK = struct {
431 /// system-wide monotonic clock (aka system time)
437 pub const MONOTONIC = 0;432 pub const MONOTONIC = 0;
433 /// system-wide real time clock
438 pub const REALTIME = -1;434 pub const REALTIME = -1;
435 /// clock measuring the used CPU time of the current process
439 pub const PROCESS_CPUTIME_ID = -2;436 pub const PROCESS_CPUTIME_ID = -2;
437 /// clock measuring the used CPU time of the current thread
440 pub const THREAD_CPUTIME_ID = -3;438 pub const THREAD_CPUTIME_ID = -3;
441};439};
442440
443pub const MAP = struct {441pub const MAP = struct {
442 /// mmap() error return code
444 pub const FAILED = @intToPtr(*c_void, maxInt(usize));443 pub const FAILED = @intToPtr(*c_void, maxInt(usize));
445 pub const SHARED = 0x0001;444 /// changes are seen by others
446 pub const PRIVATE = 0x0002;445 pub const SHARED = 0x01;
447 pub const FIXED = 0x0004;446 /// changes are only seen by caller
447 pub const PRIVATE = 0x02;
448 /// require mapping to specified addr
449 pub const FIXED = 0x04;
450 /// no underlying object
448 pub const ANONYMOUS = 0x0008;451 pub const ANONYMOUS = 0x0008;
449 pub const ANON = ANONYMOUS;452 pub const ANON = ANONYMOUS;
453 /// don't commit memory
450 pub const NORESERVE = 0x10;454 pub const NORESERVE = 0x10;
451};455};
452456
453pub const W = struct {457pub const W = struct {
454 pub const NOHANG = 0x1;458 pub const NOHANG = 0x1;
455 pub const UNTRACED = 0x2;459 pub const UNTRACED = 0x2;
456 pub const STOPPED = 0x10;
457 pub const CONTINUED = 0x4;460 pub const CONTINUED = 0x4;
458 pub const NOWAIT = 0x20;
459 pub const EXITED = 0x08;461 pub const EXITED = 0x08;
462 pub const STOPPED = 0x10;
463 pub const NOWAIT = 0x20;
460464
461 pub fn EXITSTATUS(s: u32) u8 {465 pub fn EXITSTATUS(s: u32) u8 {
462 return @intCast(u8, s & 0xff);466 return @intCast(u8, s & 0xff);
...@@ -467,11 +471,11 @@ pub const W = struct {...@@ -467,11 +471,11 @@ pub const W = struct {
467 }471 }
468472
469 pub fn STOPSIG(s: u32) u32 {473 pub fn STOPSIG(s: u32) u32 {
470 return EXITSTATUS(s);474 return (s >> 16) & 0xff;
471 }475 }
472476
473 pub fn IFEXITED(s: u32) bool {477 pub fn IFEXITED(s: u32) bool {
474 return TERMSIG(s) == 0;478 return (s & ~@as(u32, 0xff)) == 0;
475 }479 }
476480
477 pub fn IFSTOPPED(s: u32) bool {481 pub fn IFSTOPPED(s: u32) bool {
...@@ -535,28 +539,9 @@ pub const SIG = struct {...@@ -535,28 +539,9 @@ pub const SIG = struct {
535 pub const RESERVED1 = 31;539 pub const RESERVED1 = 31;
536 pub const RESERVED2 = 32;540 pub const RESERVED2 = 32;
537541
538 // TODO: check
539 pub const RTMIN = 65;
540 pub const RTMAX = 126;
541
542 pub const BLOCK = 1;542 pub const BLOCK = 1;
543 pub const UNBLOCK = 2;543 pub const UNBLOCK = 2;
544 pub const SETMASK = 3;544 pub const SETMASK = 3;
545
546 pub const WORDS = 4;
547 pub const MAXSIG = 128;
548 pub inline fn IDX(sig: usize) usize {
549 return sig - 1;
550 }
551 pub inline fn WORD(sig: usize) usize {
552 return IDX(sig) >> 5;
553 }
554 pub inline fn BIT(sig: usize) usize {
555 return 1 << (IDX(sig) & 31);
556 }
557 pub inline fn VALID(sig: usize) usize {
558 return sig <= MAXSIG and sig > 0;
559 }
560};545};
561546
562// access function547// access function
...@@ -570,57 +555,49 @@ pub const O = struct {...@@ -570,57 +555,49 @@ pub const O = struct {
570 pub const WRONLY = 0x0001;555 pub const WRONLY = 0x0001;
571 pub const RDWR = 0x0002;556 pub const RDWR = 0x0002;
572 pub const ACCMODE = 0x0003;557 pub const ACCMODE = 0x0003;
558 pub const RWMASK = ACCMODE;
573559
560 pub const EXCL = 0x0100;
574 pub const CREAT = 0x0200;561 pub const CREAT = 0x0200;
575 pub const EXCL = 0x0800;
576 pub const NOCTTY = 0x8000;
577 pub const TRUNC = 0x0400;562 pub const TRUNC = 0x0400;
578 pub const APPEND = 0x0008;563 pub const NOCTTY = 0x1000;
579 pub const NONBLOCK = 0x0004;564 pub const NOTRAVERSE = 0x2000;
580 pub const DSYNC = 0o10000;
581 pub const SYNC = 0x0080;
582 pub const RSYNC = 0o4010000;
583 pub const DIRECTORY = 0x20000;
584 pub const NOFOLLOW = 0x0100;
585 pub const CLOEXEC = 0x00000040;
586565
587 pub const ASYNC = 0x0040;566 pub const CLOEXEC = 0x00000040;
588 pub const DIRECT = 0x00010000;567 pub const NONBLOCK = 0x00000080;
589 pub const NOATIME = 0o1000000;
590 pub const PATH = 0o10000000;
591 pub const TMPFILE = 0o20200000;
592 pub const NDELAY = NONBLOCK;568 pub const NDELAY = NONBLOCK;
569 pub const APPEND = 0x00000800;
570 pub const SYNC = 0x00010000;
571 pub const RSYNC = 0x00020000;
572 pub const DSYNC = 0x00040000;
573 pub const NOFOLLOW = 0x00080000;
574 pub const DIRECT = 0x00100000;
575 pub const NOCACHE = DIRECT;
576 pub const DIRECTORY = 0x00200000;
593};577};
594578
595pub const F = struct {579pub const F = struct {
596 pub const DUPFD = 0;580 pub const DUPFD = 0x0001;
597 pub const GETFD = 1;581 pub const GETFD = 0x0002;
598 pub const SETFD = 2;582 pub const SETFD = 0x0004;
599 pub const GETFL = 3;583 pub const GETFL = 0x0008;
600 pub const SETFL = 4;584 pub const SETFL = 0x0010;
601585
602 pub const GETOWN = 5;586 pub const GETLK = 0x0020;
603 pub const SETOWN = 6;587 pub const SETLK = 0x0080;
604588 pub const SETLKW = 0x0100;
605 pub const GETLK = 11;589 pub const DUPFD_CLOEXEC = 0x0200;
606 pub const SETLK = 12;590
607 pub const SETLKW = 13;591 pub const RDLCK = 0x0040;
608592 pub const UNLCK = 0x0200;
609 pub const RDLCK = 1;593 pub const WRLCK = 0x0400;
610 pub const WRLCK = 3;
611 pub const UNLCK = 2;
612
613 pub const SETOWN_EX = 15;
614 pub const GETOWN_EX = 16;
615
616 pub const GETOWNER_UIDS = 17;
617};594};
618595
619pub const LOCK = struct {596pub const LOCK = struct {
620 pub const SH = 1;597 pub const SH = 0x01;
621 pub const EX = 2;598 pub const EX = 0x02;
622 pub const UN = 8;599 pub const NB = 0x04;
623 pub const NB = 4;600 pub const UN = 0x08;
624};601};
625602
626pub const FD_CLOEXEC = 1;603pub const FD_CLOEXEC = 1;
...@@ -635,161 +612,66 @@ pub const SOCK = struct {...@@ -635,161 +612,66 @@ pub const SOCK = struct {
635 pub const STREAM = 1;612 pub const STREAM = 1;
636 pub const DGRAM = 2;613 pub const DGRAM = 2;
637 pub const RAW = 3;614 pub const RAW = 3;
638 pub const RDM = 4;
639 pub const SEQPACKET = 5;615 pub const SEQPACKET = 5;
640
641 pub const CLOEXEC = 0x10000000;
642 pub const NONBLOCK = 0x20000000;
643};616};
644617
645pub const SO = struct {618pub const SO = struct {
646 pub const DEBUG = 0x00000001;619 pub const ACCEPTCONN = 0x00000001;
647 pub const ACCEPTCONN = 0x00000002;620 pub const BROADCAST = 0x00000002;
648 pub const REUSEADDR = 0x00000004;621 pub const DEBUG = 0x00000004;
649 pub const KEEPALIVE = 0x00000008;622 pub const DONTROUTE = 0x00000008;
650 pub const DONTROUTE = 0x00000010;623 pub const KEEPALIVE = 0x00000010;
651 pub const BROADCAST = 0x00000020;624 pub const OOBINLINE = 0x00000020;
652 pub const USELOOPBACK = 0x00000040;625 pub const REUSEADDR = 0x00000040;
653 pub const LINGER = 0x00000080;626 pub const REUSEPORT = 0x00000080;
654 pub const OOBINLINE = 0x00000100;627 pub const USELOOPBACK = 0x00000100;
655 pub const REUSEPORT = 0x00000200;628 pub const LINGER = 0x00000200;
656 pub const TIMESTAMP = 0x00000400;629
657 pub const NOSIGPIPE = 0x00000800;630 pub const SNDBUF = 0x40000001;
658 pub const ACCEPTFILTER = 0x00001000;631 pub const SNDLOWAT = 0x40000002;
659 pub const BINTIME = 0x00002000;632 pub const SNDTIMEO = 0x40000003;
660 pub const NO_OFFLOAD = 0x00004000;633 pub const RCVBUF = 0x40000004;
661 pub const NO_DDP = 0x00008000;634 pub const RCVLOWAT = 0x40000005;
662 pub const REUSEPORT_LB = 0x00010000;635 pub const RCVTIMEO = 0x40000006;
663636 pub const ERROR = 0x40000007;
664 pub const SNDBUF = 0x1001;637 pub const TYPE = 0x40000008;
665 pub const RCVBUF = 0x1002;638 pub const NONBLOCK = 0x40000009;
666 pub const SNDLOWAT = 0x1003;639 pub const BINDTODEVICE = 0x4000000a;
667 pub const RCVLOWAT = 0x1004;640 pub const PEERCRED = 0x4000000b;
668 pub const SNDTIMEO = 0x1005;
669 pub const RCVTIMEO = 0x1006;
670 pub const ERROR = 0x1007;
671 pub const TYPE = 0x1008;
672 pub const LABEL = 0x1009;
673 pub const PEERLABEL = 0x1010;
674 pub const LISTENQLIMIT = 0x1011;
675 pub const LISTENQLEN = 0x1012;
676 pub const LISTENINCQLEN = 0x1013;
677 pub const SETFIB = 0x1014;
678 pub const USER_COOKIE = 0x1015;
679 pub const PROTOCOL = 0x1016;
680 pub const PROTOTYPE = PROTOCOL;
681 pub const TS_CLOCK = 0x1017;
682 pub const MAX_PACING_RATE = 0x1018;
683 pub const DOMAIN = 0x1019;
684};641};
685642
686pub const SOL = struct {643pub const SOL = struct {
687 pub const SOCKET = 0xffff;644 pub const SOCKET = -1;
688};645};
689646
690pub const PF = struct {647pub const PF = struct {
691 pub const UNSPEC = AF.UNSPEC;648 pub const UNSPEC = AF.UNSPEC;
692 pub const LOCAL = AF.LOCAL;
693 pub const UNIX = PF.LOCAL;
694 pub const INET = AF.INET;649 pub const INET = AF.INET;
695 pub const IMPLINK = AF.IMPLINK;
696 pub const PUP = AF.PUP;
697 pub const CHAOS = AF.CHAOS;
698 pub const NETBIOS = AF.NETBIOS;
699 pub const ISO = AF.ISO;
700 pub const OSI = AF.ISO;
701 pub const ECMA = AF.ECMA;
702 pub const DATAKIT = AF.DATAKIT;
703 pub const CCITT = AF.CCITT;
704 pub const DECnet = AF.DECnet;
705 pub const DLI = AF.DLI;
706 pub const LAT = AF.LAT;
707 pub const HYLINK = AF.HYLINK;
708 pub const APPLETALK = AF.APPLETALK;
709 pub const ROUTE = AF.ROUTE;650 pub const ROUTE = AF.ROUTE;
710 pub const LINK = AF.LINK;651 pub const LINK = AF.LINK;
711 pub const XTP = AF.pseudo_XTP;652 pub const INET6 = AF.INET6;
712 pub const COIP = AF.COIP;653 pub const LOCAL = AF.LOCAL;
713 pub const CNT = AF.CNT;654 pub const UNIX = AF.UNIX;
714 pub const SIP = AF.SIP;
715 pub const IPX = AF.IPX;
716 pub const RTIP = AF.pseudo_RTIP;
717 pub const PIP = AF.pseudo_PIP;
718 pub const ISDN = AF.ISDN;
719 pub const KEY = AF.pseudo_KEY;
720 pub const INET6 = AF.pseudo_INET6;
721 pub const NATM = AF.NATM;
722 pub const ATM = AF.ATM;
723 pub const NETGRAPH = AF.NETGRAPH;
724 pub const SLOW = AF.SLOW;
725 pub const SCLUSTER = AF.SCLUSTER;
726 pub const ARP = AF.ARP;
727 pub const BLUETOOTH = AF.BLUETOOTH;655 pub const BLUETOOTH = AF.BLUETOOTH;
728 pub const IEEE80211 = AF.IEEE80211;
729 pub const INET_SDP = AF.INET_SDP;
730 pub const INET6_SDP = AF.INET6_SDP;
731 pub const MAX = AF.MAX;
732};656};
733657
734pub const AF = struct {658pub const AF = struct {
735 pub const UNSPEC = 0;659 pub const UNSPEC = 0;
736 pub const UNIX = 1;660 pub const INET = 1;
737 pub const LOCAL = UNIX;661 pub const APPLETALK = 2;
738 pub const FILE = LOCAL;662 pub const ROUTE = 3;
739 pub const INET = 2;663 pub const LINK = 4;
740 pub const IMPLINK = 3;664 pub const INET6 = 5;
741 pub const PUP = 4;665 pub const DLI = 6;
742 pub const CHAOS = 5;666 pub const IPX = 7;
743 pub const NETBIOS = 6;667 pub const NOTIFY = 8;
744 pub const ISO = 7;668 pub const LOCAL = 9;
745 pub const OSI = ISO;669 pub const UNIX = LOCAL;
746 pub const ECMA = 8;670 pub const BLUETOOTH = 10;
747 pub const DATAKIT = 9;671 pub const MAX = 11;
748 pub const CCITT = 10;
749 pub const SNA = 11;
750 pub const DECnet = 12;
751 pub const DLI = 13;
752 pub const LAT = 14;
753 pub const HYLINK = 15;
754 pub const APPLETALK = 16;
755 pub const ROUTE = 17;
756 pub const LINK = 18;
757 pub const pseudo_XTP = 19;
758 pub const COIP = 20;
759 pub const CNT = 21;
760 pub const pseudo_RTIP = 22;
761 pub const IPX = 23;
762 pub const SIP = 24;
763 pub const pseudo_PIP = 25;
764 pub const ISDN = 26;
765 pub const E164 = ISDN;
766 pub const pseudo_KEY = 27;
767 pub const INET6 = 28;
768 pub const NATM = 29;
769 pub const ATM = 30;
770 pub const pseudo_HDRCMPLT = 31;
771 pub const NETGRAPH = 32;
772 pub const SLOW = 33;
773 pub const SCLUSTER = 34;
774 pub const ARP = 35;
775 pub const BLUETOOTH = 36;
776 pub const IEEE80211 = 37;
777 pub const INET_SDP = 40;
778 pub const INET6_SDP = 42;
779 pub const MAX = 42;
780};672};
781673
782pub const DT = struct {674pub const DT = struct {};
783 pub const UNKNOWN = 0;
784 pub const FIFO = 1;
785 pub const CHR = 2;
786 pub const DIR = 4;
787 pub const BLK = 6;
788 pub const REG = 8;
789 pub const LNK = 10;
790 pub const SOCK = 12;
791 pub const WHT = 14;
792};
793675
794/// add event to kq (implies enable)676/// add event to kq (implies enable)
795pub const EV_ADD = 0x0001;677pub const EV_ADD = 0x0001;
...@@ -855,26 +737,32 @@ pub const EVFILT_EMPTY = -13;...@@ -855,26 +737,32 @@ pub const EVFILT_EMPTY = -13;
855pub const T = struct {737pub const T = struct {
856 pub const CGETA = 0x8000;738 pub const CGETA = 0x8000;
857 pub const CSETA = 0x8001;739 pub const CSETA = 0x8001;
858 pub const CSETAW = 0x8004;740 pub const CSETAF = 0x8002;
859 pub const CSETAF = 0x8003;741 pub const CSETAW = 0x8003;
742 pub const CWAITEVENT = 0x8004;
860 pub const CSBRK = 08005;743 pub const CSBRK = 08005;
861 pub const CXONC = 0x8007;
862 pub const CFLSH = 0x8006;744 pub const CFLSH = 0x8006;
863745 pub const CXONC = 0x8007;
864 pub const IOCSCTTY = 0x8017;746 pub const CQUERYCONNECTED = 0x8008;
865 pub const IOCGPGRP = 0x8015;747 pub const CGETBITS = 0x8009;
866 pub const IOCSPGRP = 0x8016;748 pub const CSETDTR = 0x8010;
749 pub const CSETRTS = 0x8011;
867 pub const IOCGWINSZ = 0x8012;750 pub const IOCGWINSZ = 0x8012;
868 pub const IOCSWINSZ = 0x8013;751 pub const IOCSWINSZ = 0x8013;
752 pub const CVTIME = 0x8014;
753 pub const IOCGPGRP = 0x8015;
754 pub const IOCSPGRP = 0x8016;
755 pub const IOCSCTTY = 0x8017;
869 pub const IOCMGET = 0x8018;756 pub const IOCMGET = 0x8018;
870 pub const IOCMBIS = 0x8022;
871 pub const IOCMBIC = 0x8023;
872 pub const IOCMSET = 0x8019;757 pub const IOCMSET = 0x8019;
873 pub const FIONREAD = 0xbe000001;
874 pub const FIONBIO = 0xbe000000;
875 pub const IOCSBRK = 0x8020;758 pub const IOCSBRK = 0x8020;
876 pub const IOCCBRK = 0x8021;759 pub const IOCCBRK = 0x8021;
760 pub const IOCMBIS = 0x8022;
761 pub const IOCMBIC = 0x8023;
877 pub const IOCGSID = 0x8024;762 pub const IOCGSID = 0x8024;
763
764 pub const FIONREAD = 0xbe000001;
765 pub const FIONBIO = 0xbe000000;
878};766};
879767
880pub const winsize = extern struct {768pub const winsize = extern struct {
...@@ -904,140 +792,105 @@ pub const sigset_t = extern struct {...@@ -904,140 +792,105 @@ pub const sigset_t = extern struct {
904 __bits: [SIG.WORDS]u32,792 __bits: [SIG.WORDS]u32,
905};793};
906794
795const B_POSIX_ERROR_BASE = -2147454976;
796
907pub const E = enum(i32) {797pub const E = enum(i32) {
908 /// No error occurred.798 @"2BIG" = B_POSIX_ERROR_BASE + 1,
909 SUCCESS = 0,799 CHILD = B_POSIX_ERROR_BASE + 2,
910 PERM = -0x7ffffff1, // Operation not permitted800 DEADLK = B_POSIX_ERROR_BASE + 3,
911 NOENT = -0x7fff9ffd, // No such file or directory801 FBIG = B_POSIX_ERROR_BASE + 4,
912 SRCH = -0x7fff8ff3, // No such process802 MLINK = B_POSIX_ERROR_BASE + 5,
803 NFILE = B_POSIX_ERROR_BASE + 6,
804 NODEV = B_POSIX_ERROR_BASE + 7,
805 NOLCK = B_POSIX_ERROR_BASE + 8,
806 NOSYS = B_POSIX_ERROR_BASE + 9,
807 NOTTY = B_POSIX_ERROR_BASE + 10,
808 NXIO = B_POSIX_ERROR_BASE + 11,
809 SPIPE = B_POSIX_ERROR_BASE + 12,
810 SRCH = B_POSIX_ERROR_BASE + 13,
811 FPOS = B_POSIX_ERROR_BASE + 14,
812 SIGPARM = B_POSIX_ERROR_BASE + 15,
813 DOM = B_POSIX_ERROR_BASE + 16,
814 RANGE = B_POSIX_ERROR_BASE + 17,
815 PROTOTYPE = B_POSIX_ERROR_BASE + 18,
816 PROTONOSUPPORT = B_POSIX_ERROR_BASE + 19,
817 PFNOSUPPORT = B_POSIX_ERROR_BASE + 20,
818 AFNOSUPPORT = B_POSIX_ERROR_BASE + 21,
819 ADDRINUSE = B_POSIX_ERROR_BASE + 22,
820 ADDRNOTAVAIL = B_POSIX_ERROR_BASE + 23,
821 NETDOWN = B_POSIX_ERROR_BASE + 24,
822 NETUNREACH = B_POSIX_ERROR_BASE + 25,
823 NETRESET = B_POSIX_ERROR_BASE + 26,
824 CONNABORTED = B_POSIX_ERROR_BASE + 27,
825 CONNRESET = B_POSIX_ERROR_BASE + 28,
826 ISCONN = B_POSIX_ERROR_BASE + 29,
827 NOTCONN = B_POSIX_ERROR_BASE + 30,
828 SHUTDOWN = B_POSIX_ERROR_BASE + 31,
829 CONNREFUSED = B_POSIX_ERROR_BASE + 32,
830 HOSTUNREACH = B_POSIX_ERROR_BASE + 33,
831 NOPROTOOPT = B_POSIX_ERROR_BASE + 34,
832 NOBUFS = B_POSIX_ERROR_BASE + 35,
833 INPROGRESS = B_POSIX_ERROR_BASE + 36,
834 ALREADY = B_POSIX_ERROR_BASE + 37,
835 ILSEQ = B_POSIX_ERROR_BASE + 38,
836 NOMSG = B_POSIX_ERROR_BASE + 39,
837 STALE = B_POSIX_ERROR_BASE + 40,
838 OVERFLOW = B_POSIX_ERROR_BASE + 41,
839 MSGSIZE = B_POSIX_ERROR_BASE + 42,
840 OPNOTSUPP = B_POSIX_ERROR_BASE + 43,
841 NOTSOCK = B_POSIX_ERROR_BASE + 44,
842 HOSTDOWN = B_POSIX_ERROR_BASE + 45,
843 BADMSG = B_POSIX_ERROR_BASE + 46,
844 CANCELED = B_POSIX_ERROR_BASE + 47,
845 DESTADDRREQ = B_POSIX_ERROR_BASE + 48,
846 DQUOT = B_POSIX_ERROR_BASE + 49,
847 IDRM = B_POSIX_ERROR_BASE + 50,
848 MULTIHOP = B_POSIX_ERROR_BASE + 51,
849 NODATA = B_POSIX_ERROR_BASE + 52,
850 NOLINK = B_POSIX_ERROR_BASE + 53,
851 NOSR = B_POSIX_ERROR_BASE + 54,
852 NOSTR = B_POSIX_ERROR_BASE + 55,
853 NOTSUP = B_POSIX_ERROR_BASE + 56,
854 PROTO = B_POSIX_ERROR_BASE + 57,
855 TIME = B_POSIX_ERROR_BASE + 58,
856 TXTBSY = B_POSIX_ERROR_BASE + 59,
857 NOATTR = B_POSIX_ERROR_BASE + 60,
858 NOTRECOVERABLE = B_POSIX_ERROR_BASE + 61,
859 OWNERDEAD = B_POSIX_ERROR_BASE + 62,
860
861 ACCES = -0x7ffffffe, // Permission denied
913 INTR = -0x7ffffff6, // Interrupted system call862 INTR = -0x7ffffff6, // Interrupted system call
914 IO = -0x7fffffff, // Input/output error863 IO = -0x7fffffff, // Input/output error
915 NXIO = -0x7fff8ff5, // Device not configured
916 @"2BIG" = -0x7fff8fff, // Argument list too long
917 NOEXEC = -0x7fffecfe, // Exec format error
918 CHILD = -0x7fff8ffe, // No child processes
919 DEADLK = -0x7fff8ffd, // Resource deadlock avoided
920 NOMEM = -0x80000000, // Cannot allocate memory
921 ACCES = -0x7ffffffe, // Permission denied
922 FAULT = -0x7fffecff, // Bad address
923 BUSY = -0x7ffffff2, // Device busy864 BUSY = -0x7ffffff2, // Device busy
865 FAULT = -0x7fffecff, // Bad address
866 TIMEDOUT = -2147483639, // Operation timed out
867 AGAIN = -0x7ffffff5,
868 BADF = -0x7fffa000, // Bad file descriptor
924 EXIST = -0x7fff9ffe, // File exists869 EXIST = -0x7fff9ffe, // File exists
925 XDEV = -0x7fff9ff5, // Cross-device link870 INVAL = -0x7ffffffb, // Invalid argument
926 NODEV = -0x7fff8ff9, // Operation not supported by device871 NAMETOOLONG = -2147459068, // File name too long
872 NOENT = -0x7fff9ffd, // No such file or directory
873 PERM = -0x7ffffff1, // Operation not permitted
927 NOTDIR = -0x7fff9ffb, // Not a directory874 NOTDIR = -0x7fff9ffb, // Not a directory
928 ISDIR = -0x7fff9ff7, // Is a directory875 ISDIR = -0x7fff9ff7, // Is a directory
929 INVAL = -0x7ffffffb, // Invalid argument876 NOTEMPTY = -2147459066, // Directory not empty
930 NFILE = -0x7fff8ffa, // Too many open files in system
931 MFILE = -0x7fff9ff6, // Too many open files
932 NOTTY = -0x7fff8ff6, // Inappropriate ioctl for device
933 TXTBSY = -0x7fff8fc5, // Text file busy
934 FBIG = -0x7fff8ffc, // File too large
935 NOSPC = -0x7fff9ff9, // No space left on device877 NOSPC = -0x7fff9ff9, // No space left on device
936 SPIPE = -0x7fff8ff4, // Illegal seek
937 ROFS = -0x7fff9ff8, // Read-only filesystem878 ROFS = -0x7fff9ff8, // Read-only filesystem
938 MLINK = -0x7fff8ffb, // Too many links879 MFILE = -0x7fff9ff6, // Too many open files
880 XDEV = -0x7fff9ff5, // Cross-device link
881 NOEXEC = -0x7fffecfe, // Exec format error
939 PIPE = -0x7fff9ff3, // Broken pipe882 PIPE = -0x7fff9ff3, // Broken pipe
940 BADF = -0x7fffa000, // Bad file descriptor883 NOMEM = -0x80000000, // Cannot allocate memory
941884 LOOP = -2147459060, // Too many levels of symbolic links
942 // math software885 SUCCESS = 0,
943 DOM = 33, // Numerical argument out of domain
944 RANGE = 34, // Result too large
945
946 // non-blocking and interrupt i/o
947
948 /// Also used for `WOULDBLOCK`.
949 AGAIN = -0x7ffffff5,
950 INPROGRESS = -0x7fff8fdc,
951 ALREADY = -0x7fff8fdb,
952
953 // ipc/network software -- argument errors
954 NOTSOCK = 38, // Socket operation on non-socket
955 DESTADDRREQ = 39, // Destination address required
956 MSGSIZE = 40, // Message too long
957 PROTOTYPE = 41, // Protocol wrong type for socket
958 NOPROTOOPT = 42, // Protocol not available
959 PROTONOSUPPORT = 43, // Protocol not supported
960 SOCKTNOSUPPORT = 44, // Socket type not supported
961 /// Also used for `NOTSUP`.
962 OPNOTSUPP = 45, // Operation not supported
963 PFNOSUPPORT = 46, // Protocol family not supported
964 AFNOSUPPORT = 47, // Address family not supported by protocol family
965 ADDRINUSE = 48, // Address already in use
966 ADDRNOTAVAIL = 49, // Can't assign requested address
967
968 // ipc/network software -- operational errors
969 NETDOWN = 50, // Network is down
970 NETUNREACH = 51, // Network is unreachable
971 NETRESET = 52, // Network dropped connection on reset
972 CONNABORTED = 53, // Software caused connection abort
973 CONNRESET = 54, // Connection reset by peer
974 NOBUFS = 55, // No buffer space available
975 ISCONN = 56, // Socket is already connected
976 NOTCONN = 57, // Socket is not connected
977 SHUTDOWN = 58, // Can't send after socket shutdown
978 TOOMANYREFS = 59, // Too many references: can't splice
979 TIMEDOUT = 60, // Operation timed out
980 CONNREFUSED = 61, // Connection refused
981
982 LOOP = 62, // Too many levels of symbolic links
983 NAMETOOLONG = 63, // File name too long
984
985 // should be rearranged
986 HOSTDOWN = 64, // Host is down
987 HOSTUNREACH = 65, // No route to host
988 NOTEMPTY = 66, // Directory not empty
989
990 // quotas & mush
991 PROCLIM = 67, // Too many processes
992 USERS = 68, // Too many users
993 DQUOT = 69, // Disc quota exceeded
994
995 // Network File System
996 STALE = 70, // Stale NFS file handle
997 REMOTE = 71, // Too many levels of remote in path
998 BADRPC = 72, // RPC struct is bad
999 RPCMISMATCH = 73, // RPC version wrong
1000 PROGUNAVAIL = 74, // RPC prog. not avail
1001 PROGMISMATCH = 75, // Program version wrong
1002 PROCUNAVAIL = 76, // Bad procedure for program
1003
1004 NOLCK = 77, // No locks available
1005 NOSYS = 78, // Function not implemented
1006
1007 FTYPE = 79, // Inappropriate file type or format
1008 AUTH = 80, // Authentication error
1009 NEEDAUTH = 81, // Need authenticator
1010 IDRM = 82, // Identifier removed
1011 NOMSG = 83, // No message of desired type
1012 OVERFLOW = 84, // Value too large to be stored in data type
1013 CANCELED = 85, // Operation canceled
1014 ILSEQ = 86, // Illegal byte sequence
1015 NOATTR = 87, // Attribute not found
1016
1017 DOOFUS = 88, // Programming error
1018
1019 BADMSG = 89, // Bad message
1020 MULTIHOP = 90, // Multihop attempted
1021 NOLINK = 91, // Link has been severed
1022 PROTO = 92, // Protocol error
1023
1024 NOTCAPABLE = 93, // Capabilities insufficient
1025 CAPMODE = 94, // Not permitted in capability mode
1026 NOTRECOVERABLE = 95, // State not recoverable
1027 OWNERDEAD = 96, // Previous owner died
1028
1029 _,886 _,
1030};887};
1031888
1032pub const MINSIGSTKSZ = switch (builtin.cpu.arch) {889pub const MINSIGSTKSZ = 8192;
1033 .i386, .x86_64 => 2048,890pub const SIGSTKSZ = 16384;
1034 .arm, .aarch64 => 4096,
1035 else => @compileError("MINSIGSTKSZ not defined for this architecture"),
1036};
1037pub const SIGSTKSZ = MINSIGSTKSZ + 32768;
1038891
1039pub const SS_ONSTACK = 1;892pub const SS_ONSTACK = 0x1;
1040pub const SS_DISABLE = 4;893pub const SS_DISABLE = 0x2;
1041894
1042pub const stack_t = extern struct {895pub const stack_t = extern struct {
1043 sp: [*]u8,896 sp: [*]u8,
...@@ -1047,16 +900,16 @@ pub const stack_t = extern struct {...@@ -1047,16 +900,16 @@ pub const stack_t = extern struct {
1047900
1048pub const S = struct {901pub const S = struct {
1049 pub const IFMT = 0o170000;902 pub const IFMT = 0o170000;
1050
1051 pub const IFIFO = 0o010000;
1052 pub const IFCHR = 0o020000;
1053 pub const IFDIR = 0o040000;
1054 pub const IFBLK = 0o060000;
1055 pub const IFREG = 0o100000;
1056 pub const IFLNK = 0o120000;
1057 pub const IFSOCK = 0o140000;903 pub const IFSOCK = 0o140000;
1058 pub const IFWHT = 0o160000;904 pub const IFLNK = 0o120000;
905 pub const IFREG = 0o100000;
906 pub const IFBLK = 0o060000;
907 pub const IFDIR = 0o040000;
908 pub const IFCHR = 0o020000;
909 pub const IFIFO = 0o010000;
910 pub const INDEX_DIR = 04000000000;
1059911
912 pub const IUMSK = 0o7777;
1060 pub const ISUID = 0o4000;913 pub const ISUID = 0o4000;
1061 pub const ISGID = 0o2000;914 pub const ISGID = 0o2000;
1062 pub const ISVTX = 0o1000;915 pub const ISVTX = 0o1000;
...@@ -1073,56 +926,47 @@ pub const S = struct {...@@ -1073,56 +926,47 @@ pub const S = struct {
1073 pub const IWOTH = 0o002;926 pub const IWOTH = 0o002;
1074 pub const IXOTH = 0o001;927 pub const IXOTH = 0o001;
1075928
1076 pub fn ISFIFO(m: u32) bool {929 pub fn ISREG(m: u32) bool {
1077 return m & IFMT == IFIFO;930 return m & IFMT == IFREG;
1078 }
1079
1080 pub fn ISCHR(m: u32) bool {
1081 return m & IFMT == IFCHR;
1082 }931 }
1083932
1084 pub fn ISDIR(m: u32) bool {933 pub fn ISLNK(m: u32) bool {
1085 return m & IFMT == IFDIR;934 return m & IFMT == IFLNK;
1086 }935 }
1087936
1088 pub fn ISBLK(m: u32) bool {937 pub fn ISBLK(m: u32) bool {
1089 return m & IFMT == IFBLK;938 return m & IFMT == IFBLK;
1090 }939 }
1091940
1092 pub fn ISREG(m: u32) bool {941 pub fn ISDIR(m: u32) bool {
1093 return m & IFMT == IFREG;942 return m & IFMT == IFDIR;
1094 }943 }
1095944
1096 pub fn ISLNK(m: u32) bool {945 pub fn ISCHR(m: u32) bool {
1097 return m & IFMT == IFLNK;946 return m & IFMT == IFCHR;
947 }
948
949 pub fn ISFIFO(m: u32) bool {
950 return m & IFMT == IFIFO;
1098 }951 }
1099952
1100 pub fn ISSOCK(m: u32) bool {953 pub fn ISSOCK(m: u32) bool {
1101 return m & IFMT == IFSOCK;954 return m & IFMT == IFSOCK;
1102 }955 }
1103956
1104 pub fn IWHT(m: u32) bool {957 pub fn ISINDEX(m: u32) bool {
1105 return m & IFMT == IFWHT;958 return m & INDEX_DIR == INDEX_DIR;
1106 }959 }
1107};960};
1108961
1109pub const HOST_NAME_MAX = 255;962pub const HOST_NAME_MAX = 255;
1110963
1111pub const AT = struct {964pub const AT = struct {
1112 /// Magic value that specify the use of the current working directory965 pub const FDCWD = -1;
1113 /// to determine the target of relative file paths in the openat() and966 pub const SYMLINK_NOFOLLOW = 0x01;
1114 /// similar syscalls.967 pub const SYMLINK_FOLLOW = 0x02;
1115 pub const FDCWD = -100;968 pub const REMOVEDIR = 0x04;
1116 /// Check access using effective user and group ID969 pub const EACCESS = 0x08;
1117 pub const EACCESS = 0x0100;
1118 /// Do not follow symbolic links
1119 pub const SYMLINK_NOFOLLOW = 0x0200;
1120 /// Follow symbolic link
1121 pub const SYMLINK_FOLLOW = 0x0400;
1122 /// Remove directory instead of file
1123 pub const REMOVEDIR = 0x0800;
1124 /// Fail if not under dirfd
1125 pub const BENEATH = 0x1000;
1126};970};
1127971
1128pub const addrinfo = extern struct {972pub const addrinfo = extern struct {
...@@ -1137,238 +981,23 @@ pub const addrinfo = extern struct {...@@ -1137,238 +981,23 @@ pub const addrinfo = extern struct {
1137};981};
1138982
1139pub const IPPROTO = struct {983pub const IPPROTO = struct {
1140 /// dummy for IP
1141 pub const IP = 0;984 pub const IP = 0;
1142 /// control message protocol985 pub const HOPOPTS = 0;
1143 pub const ICMP = 1;986 pub const ICMP = 1;
1144 /// tcp987 pub const IGMP = 2;
1145 pub const TCP = 6;988 pub const TCP = 6;
1146 /// user datagram protocol
1147 pub const UDP = 17;989 pub const UDP = 17;
1148 /// IP6 header
1149 pub const IPV6 = 41;990 pub const IPV6 = 41;
1150 /// raw IP packet
1151 pub const RAW = 255;
1152 /// IP6 hop-by-hop options
1153 pub const HOPOPTS = 0;
1154 /// group mgmt protocol
1155 pub const IGMP = 2;
1156 /// gateway^2 (deprecated)
1157 pub const GGP = 3;
1158 /// IPv4 encapsulation
1159 pub const IPV4 = 4;
1160 /// for compatibility
1161 pub const IPIP = IPV4;
1162 /// Stream protocol II
1163 pub const ST = 7;
1164 /// exterior gateway protocol
1165 pub const EGP = 8;
1166 /// private interior gateway
1167 pub const PIGP = 9;
1168 /// BBN RCC Monitoring
1169 pub const RCCMON = 10;
1170 /// network voice protocol
1171 pub const NVPII = 11;
1172 /// pup
1173 pub const PUP = 12;
1174 /// Argus
1175 pub const ARGUS = 13;
1176 /// EMCON
1177 pub const EMCON = 14;
1178 /// Cross Net Debugger
1179 pub const XNET = 15;
1180 /// Chaos
1181 pub const CHAOS = 16;
1182 /// Multiplexing
1183 pub const MUX = 18;
1184 /// DCN Measurement Subsystems
1185 pub const MEAS = 19;
1186 /// Host Monitoring
1187 pub const HMP = 20;
1188 /// Packet Radio Measurement
1189 pub const PRM = 21;
1190 /// xns idp
1191 pub const IDP = 22;
1192 /// Trunk-1
1193 pub const TRUNK1 = 23;
1194 /// Trunk-2
1195 pub const TRUNK2 = 24;
1196 /// Leaf-1
1197 pub const LEAF1 = 25;
1198 /// Leaf-2
1199 pub const LEAF2 = 26;
1200 /// Reliable Data
1201 pub const RDP = 27;
1202 /// Reliable Transaction
1203 pub const IRTP = 28;
1204 /// tp-4 w/ class negotiation
1205 pub const TP = 29;
1206 /// Bulk Data Transfer
1207 pub const BLT = 30;
1208 /// Network Services
1209 pub const NSP = 31;
1210 /// Merit Internodal
1211 pub const INP = 32;
1212 /// Datagram Congestion Control Protocol
1213 pub const DCCP = 33;
1214 /// Third Party Connect
1215 pub const @"3PC" = 34;
1216 /// InterDomain Policy Routing
1217 pub const IDPR = 35;
1218 /// XTP
1219 pub const XTP = 36;
1220 /// Datagram Delivery
1221 pub const DDP = 37;
1222 /// Control Message Transport
1223 pub const CMTP = 38;
1224 /// TP++ Transport
1225 pub const TPXX = 39;
1226 /// IL transport protocol
1227 pub const IL = 40;
1228 /// Source Demand Routing
1229 pub const SDRP = 42;
1230 /// IP6 routing header
1231 pub const ROUTING = 43;991 pub const ROUTING = 43;
1232 /// IP6 fragmentation header
1233 pub const FRAGMENT = 44;992 pub const FRAGMENT = 44;
1234 /// InterDomain Routing
1235 pub const IDRP = 45;
1236 /// resource reservation
1237 pub const RSVP = 46;
1238 /// General Routing Encap.
1239 pub const GRE = 47;
1240 /// Mobile Host Routing
1241 pub const MHRP = 48;
1242 /// BHA
1243 pub const BHA = 49;
1244 /// IP6 Encap Sec. Payload
1245 pub const ESP = 50;993 pub const ESP = 50;
1246 /// IP6 Auth Header
1247 pub const AH = 51;994 pub const AH = 51;
1248 /// Integ. Net Layer Security
1249 pub const INLSP = 52;
1250 /// IP with encryption
1251 pub const SWIPE = 53;
1252 /// Next Hop Resolution
1253 pub const NHRP = 54;
1254 /// IP Mobility
1255 pub const MOBILE = 55;
1256 /// Transport Layer Security
1257 pub const TLSP = 56;
1258 /// SKIP
1259 pub const SKIP = 57;
1260 /// ICMP6
1261 pub const ICMPV6 = 58;995 pub const ICMPV6 = 58;
1262 /// IP6 no next header
1263 pub const NONE = 59;996 pub const NONE = 59;
1264 /// IP6 destination option
1265 pub const DSTOPTS = 60;997 pub const DSTOPTS = 60;
1266 /// any host internal protocol
1267 pub const AHIP = 61;
1268 /// CFTP
1269 pub const CFTP = 62;
1270 /// "hello" routing protocol
1271 pub const HELLO = 63;
1272 /// SATNET/Backroom EXPAK
1273 pub const SATEXPAK = 64;
1274 /// Kryptolan
1275 pub const KRYPTOLAN = 65;
1276 /// Remote Virtual Disk
1277 pub const RVD = 66;
1278 /// Pluribus Packet Core
1279 pub const IPPC = 67;
1280 /// Any distributed FS
1281 pub const ADFS = 68;
1282 /// Satnet Monitoring
1283 pub const SATMON = 69;
1284 /// VISA Protocol
1285 pub const VISA = 70;
1286 /// Packet Core Utility
1287 pub const IPCV = 71;
1288 /// Comp. Prot. Net. Executive
1289 pub const CPNX = 72;
1290 /// Comp. Prot. HeartBeat
1291 pub const CPHB = 73;
1292 /// Wang Span Network
1293 pub const WSN = 74;
1294 /// Packet Video Protocol
1295 pub const PVP = 75;
1296 /// BackRoom SATNET Monitoring
1297 pub const BRSATMON = 76;
1298 /// Sun net disk proto (temp.)
1299 pub const ND = 77;
1300 /// WIDEBAND Monitoring
1301 pub const WBMON = 78;
1302 /// WIDEBAND EXPAK
1303 pub const WBEXPAK = 79;
1304 /// ISO cnlp
1305 pub const EON = 80;
1306 /// VMTP
1307 pub const VMTP = 81;
1308 /// Secure VMTP
1309 pub const SVMTP = 82;
1310 /// Banyon VINES
1311 pub const VINES = 83;
1312 /// TTP
1313 pub const TTP = 84;
1314 /// NSFNET-IGP
1315 pub const IGP = 85;
1316 /// dissimilar gateway prot.
1317 pub const DGP = 86;
1318 /// TCF
1319 pub const TCF = 87;
1320 /// Cisco/GXS IGRP
1321 pub const IGRP = 88;
1322 /// OSPFIGP
1323 pub const OSPFIGP = 89;
1324 /// Strite RPC protocol
1325 pub const SRPC = 90;
1326 /// Locus Address Resoloution
1327 pub const LARP = 91;
1328 /// Multicast Transport
1329 pub const MTP = 92;
1330 /// AX.25 Frames
1331 pub const AX25 = 93;
1332 /// IP encapsulated in IP
1333 pub const IPEIP = 94;
1334 /// Mobile Int.ing control
1335 pub const MICP = 95;
1336 /// Semaphore Comm. security
1337 pub const SCCSP = 96;
1338 /// Ethernet IP encapsulation
1339 pub const ETHERIP = 97;998 pub const ETHERIP = 97;
1340 /// encapsulation header999 pub const RAW = 255;
1341 pub const ENCAP = 98;1000 pub const MAX = 256;
1342 /// any private encr. scheme
1343 pub const APES = 99;
1344 /// GMTP
1345 pub const GMTP = 100;
1346 /// payload compression (IPComp)
1347 pub const IPCOMP = 108;
1348 /// SCTP
1349 pub const SCTP = 132;
1350 /// IPv6 Mobility Header
1351 pub const MH = 135;
1352 /// UDP-Lite
1353 pub const UDPLITE = 136;
1354 /// IP6 Host Identity Protocol
1355 pub const HIP = 139;
1356 /// IP6 Shim6 Protocol
1357 pub const SHIM6 = 140;
1358 /// Protocol Independent Mcast
1359 pub const PIM = 103;
1360 /// CARP
1361 pub const CARP = 112;
1362 /// PGM
1363 pub const PGM = 113;
1364 /// MPLS-in-IP
1365 pub const MPLS = 137;
1366 /// PFSYNC
1367 pub const PFSYNC = 240;
1368 /// Reserved
1369 pub const RESERVED_253 = 253;
1370 /// Reserved
1371 pub const RESERVED_254 = 254;
1372};1001};
13731002
1374pub const rlimit_resource = enum(c_int) {1003pub const rlimit_resource = enum(c_int) {