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 {
145145// include/dlfcn.h
146146
147147pub const POLL = struct {
148 pub const IN = 0x0001;
149 pub const ERR = 0x0004;
150 pub const NVAL = 0x1000;
151 pub const HUP = 0x0080;
148 /// input available
149 pub const IN = 70;
150 /// output available
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;
152160};
153161
154162pub const RTLD = struct {
155 /// Bind function calls lazily.
156 pub const LAZY = 1;
157 /// Bind function calls immediately.
158 pub const NOW = 2;
159 pub const MODEMASK = 0x3;
160 /// Make symbols globally available.
161 pub const GLOBAL = 0x100;
162 /// Opposite of GLOBAL, and the default.
163 /// relocations are performed as needed
164 pub const LAZY = 0;
165 /// the file gets relocated at load time
166 pub const NOW = 1;
167 /// all symbols are available
168 pub const GLOBAL = 2;
169 /// symbols are not available for relocating any other object
163170 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;
170171};
171172
172173pub const dl_phdr_info = extern struct {
......@@ -407,18 +408,11 @@ pub const sockaddr = extern struct {
407408 };
408409};
409410
410pub const CTL = struct {
411 pub const KERN = 1;
412 pub const DEBUG = 5;
413};
411pub const CTL = struct {};
414412
415pub 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};
413pub const KERN = struct {};
420414
421pub const IOV_MAX = KERN.IOV_MAX;
415pub const IOV_MAX = 1024;
422416
423417pub const PATH_MAX = 1024;
424418
......@@ -427,36 +421,46 @@ pub const STDOUT_FILENO = 1;
427421pub const STDERR_FILENO = 2;
428422
429423pub const PROT = struct {
430 pub const NONE = 0;
431 pub const READ = 1;
432 pub const WRITE = 2;
433 pub const EXEC = 4;
424 pub const READ = 0x01;
425 pub const WRITE = 0x02;
426 pub const EXEC = 0x04;
427 pub const NONE = 0x00;
434428};
435429
436430pub const CLOCK = struct {
431 /// system-wide monotonic clock (aka system time)
437432 pub const MONOTONIC = 0;
433 /// system-wide real time clock
438434 pub const REALTIME = -1;
435 /// clock measuring the used CPU time of the current process
439436 pub const PROCESS_CPUTIME_ID = -2;
437 /// clock measuring the used CPU time of the current thread
440438 pub const THREAD_CPUTIME_ID = -3;
441439};
442440
443441pub const MAP = struct {
442 /// mmap() error return code
444443 pub const FAILED = @intToPtr(*c_void, maxInt(usize));
445 pub const SHARED = 0x0001;
446 pub const PRIVATE = 0x0002;
447 pub const FIXED = 0x0004;
444 /// changes are seen by others
445 pub const SHARED = 0x01;
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
448451 pub const ANONYMOUS = 0x0008;
449452 pub const ANON = ANONYMOUS;
453 /// don't commit memory
450454 pub const NORESERVE = 0x10;
451455};
452456
453457pub const W = struct {
454458 pub const NOHANG = 0x1;
455459 pub const UNTRACED = 0x2;
456 pub const STOPPED = 0x10;
457460 pub const CONTINUED = 0x4;
458 pub const NOWAIT = 0x20;
459461 pub const EXITED = 0x08;
462 pub const STOPPED = 0x10;
463 pub const NOWAIT = 0x20;
460464
461465 pub fn EXITSTATUS(s: u32) u8 {
462466 return @intCast(u8, s & 0xff);
......@@ -467,11 +471,11 @@ pub const W = struct {
467471 }
468472
469473 pub fn STOPSIG(s: u32) u32 {
470 return EXITSTATUS(s);
474 return (s >> 16) & 0xff;
471475 }
472476
473477 pub fn IFEXITED(s: u32) bool {
474 return TERMSIG(s) == 0;
478 return (s & ~@as(u32, 0xff)) == 0;
475479 }
476480
477481 pub fn IFSTOPPED(s: u32) bool {
......@@ -535,28 +539,9 @@ pub const SIG = struct {
535539 pub const RESERVED1 = 31;
536540 pub const RESERVED2 = 32;
537541
538 // TODO: check
539 pub const RTMIN = 65;
540 pub const RTMAX = 126;
541
542542 pub const BLOCK = 1;
543543 pub const UNBLOCK = 2;
544544 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 }
560545};
561546
562547// access function
......@@ -570,57 +555,49 @@ pub const O = struct {
570555 pub const WRONLY = 0x0001;
571556 pub const RDWR = 0x0002;
572557 pub const ACCMODE = 0x0003;
558 pub const RWMASK = ACCMODE;
573559
560 pub const EXCL = 0x0100;
574561 pub const CREAT = 0x0200;
575 pub const EXCL = 0x0800;
576 pub const NOCTTY = 0x8000;
577562 pub const TRUNC = 0x0400;
578 pub const APPEND = 0x0008;
579 pub const NONBLOCK = 0x0004;
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;
563 pub const NOCTTY = 0x1000;
564 pub const NOTRAVERSE = 0x2000;
586565
587 pub const ASYNC = 0x0040;
588 pub const DIRECT = 0x00010000;
589 pub const NOATIME = 0o1000000;
590 pub const PATH = 0o10000000;
591 pub const TMPFILE = 0o20200000;
566 pub const CLOEXEC = 0x00000040;
567 pub const NONBLOCK = 0x00000080;
592568 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;
593577};
594578
595579pub const F = struct {
596 pub const DUPFD = 0;
597 pub const GETFD = 1;
598 pub const SETFD = 2;
599 pub const GETFL = 3;
600 pub const SETFL = 4;
601
602 pub const GETOWN = 5;
603 pub const SETOWN = 6;
604
605 pub const GETLK = 11;
606 pub const SETLK = 12;
607 pub const SETLKW = 13;
608
609 pub const RDLCK = 1;
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;
580 pub const DUPFD = 0x0001;
581 pub const GETFD = 0x0002;
582 pub const SETFD = 0x0004;
583 pub const GETFL = 0x0008;
584 pub const SETFL = 0x0010;
585
586 pub const GETLK = 0x0020;
587 pub const SETLK = 0x0080;
588 pub const SETLKW = 0x0100;
589 pub const DUPFD_CLOEXEC = 0x0200;
590
591 pub const RDLCK = 0x0040;
592 pub const UNLCK = 0x0200;
593 pub const WRLCK = 0x0400;
617594};
618595
619596pub const LOCK = struct {
620 pub const SH = 1;
621 pub const EX = 2;
622 pub const UN = 8;
623 pub const NB = 4;
597 pub const SH = 0x01;
598 pub const EX = 0x02;
599 pub const NB = 0x04;
600 pub const UN = 0x08;
624601};
625602
626603pub const FD_CLOEXEC = 1;
......@@ -635,161 +612,66 @@ pub const SOCK = struct {
635612 pub const STREAM = 1;
636613 pub const DGRAM = 2;
637614 pub const RAW = 3;
638 pub const RDM = 4;
639615 pub const SEQPACKET = 5;
640
641 pub const CLOEXEC = 0x10000000;
642 pub const NONBLOCK = 0x20000000;
643616};
644617
645618pub const SO = struct {
646 pub const DEBUG = 0x00000001;
647 pub const ACCEPTCONN = 0x00000002;
648 pub const REUSEADDR = 0x00000004;
649 pub const KEEPALIVE = 0x00000008;
650 pub const DONTROUTE = 0x00000010;
651 pub const BROADCAST = 0x00000020;
652 pub const USELOOPBACK = 0x00000040;
653 pub const LINGER = 0x00000080;
654 pub const OOBINLINE = 0x00000100;
655 pub const REUSEPORT = 0x00000200;
656 pub const TIMESTAMP = 0x00000400;
657 pub const NOSIGPIPE = 0x00000800;
658 pub const ACCEPTFILTER = 0x00001000;
659 pub const BINTIME = 0x00002000;
660 pub const NO_OFFLOAD = 0x00004000;
661 pub const NO_DDP = 0x00008000;
662 pub const REUSEPORT_LB = 0x00010000;
663
664 pub const SNDBUF = 0x1001;
665 pub const RCVBUF = 0x1002;
666 pub const SNDLOWAT = 0x1003;
667 pub const RCVLOWAT = 0x1004;
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;
619 pub const ACCEPTCONN = 0x00000001;
620 pub const BROADCAST = 0x00000002;
621 pub const DEBUG = 0x00000004;
622 pub const DONTROUTE = 0x00000008;
623 pub const KEEPALIVE = 0x00000010;
624 pub const OOBINLINE = 0x00000020;
625 pub const REUSEADDR = 0x00000040;
626 pub const REUSEPORT = 0x00000080;
627 pub const USELOOPBACK = 0x00000100;
628 pub const LINGER = 0x00000200;
629
630 pub const SNDBUF = 0x40000001;
631 pub const SNDLOWAT = 0x40000002;
632 pub const SNDTIMEO = 0x40000003;
633 pub const RCVBUF = 0x40000004;
634 pub const RCVLOWAT = 0x40000005;
635 pub const RCVTIMEO = 0x40000006;
636 pub const ERROR = 0x40000007;
637 pub const TYPE = 0x40000008;
638 pub const NONBLOCK = 0x40000009;
639 pub const BINDTODEVICE = 0x4000000a;
640 pub const PEERCRED = 0x4000000b;
684641};
685642
686643pub const SOL = struct {
687 pub const SOCKET = 0xffff;
644 pub const SOCKET = -1;
688645};
689646
690647pub const PF = struct {
691648 pub const UNSPEC = AF.UNSPEC;
692 pub const LOCAL = AF.LOCAL;
693 pub const UNIX = PF.LOCAL;
694649 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;
709650 pub const ROUTE = AF.ROUTE;
710651 pub const LINK = AF.LINK;
711 pub const XTP = AF.pseudo_XTP;
712 pub const COIP = AF.COIP;
713 pub const CNT = AF.CNT;
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;
652 pub const INET6 = AF.INET6;
653 pub const LOCAL = AF.LOCAL;
654 pub const UNIX = AF.UNIX;
727655 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;
732656};
733657
734658pub const AF = struct {
735659 pub const UNSPEC = 0;
736 pub const UNIX = 1;
737 pub const LOCAL = UNIX;
738 pub const FILE = LOCAL;
739 pub const INET = 2;
740 pub const IMPLINK = 3;
741 pub const PUP = 4;
742 pub const CHAOS = 5;
743 pub const NETBIOS = 6;
744 pub const ISO = 7;
745 pub const OSI = ISO;
746 pub const ECMA = 8;
747 pub const DATAKIT = 9;
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;
660 pub const INET = 1;
661 pub const APPLETALK = 2;
662 pub const ROUTE = 3;
663 pub const LINK = 4;
664 pub const INET6 = 5;
665 pub const DLI = 6;
666 pub const IPX = 7;
667 pub const NOTIFY = 8;
668 pub const LOCAL = 9;
669 pub const UNIX = LOCAL;
670 pub const BLUETOOTH = 10;
671 pub const MAX = 11;
780672};
781673
782pub 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};
674pub const DT = struct {};
793675
794676/// add event to kq (implies enable)
795677pub const EV_ADD = 0x0001;
......@@ -855,26 +737,32 @@ pub const EVFILT_EMPTY = -13;
855737pub const T = struct {
856738 pub const CGETA = 0x8000;
857739 pub const CSETA = 0x8001;
858 pub const CSETAW = 0x8004;
859 pub const CSETAF = 0x8003;
740 pub const CSETAF = 0x8002;
741 pub const CSETAW = 0x8003;
742 pub const CWAITEVENT = 0x8004;
860743 pub const CSBRK = 08005;
861 pub const CXONC = 0x8007;
862744 pub const CFLSH = 0x8006;
863
864 pub const IOCSCTTY = 0x8017;
865 pub const IOCGPGRP = 0x8015;
866 pub const IOCSPGRP = 0x8016;
745 pub const CXONC = 0x8007;
746 pub const CQUERYCONNECTED = 0x8008;
747 pub const CGETBITS = 0x8009;
748 pub const CSETDTR = 0x8010;
749 pub const CSETRTS = 0x8011;
867750 pub const IOCGWINSZ = 0x8012;
868751 pub const IOCSWINSZ = 0x8013;
752 pub const CVTIME = 0x8014;
753 pub const IOCGPGRP = 0x8015;
754 pub const IOCSPGRP = 0x8016;
755 pub const IOCSCTTY = 0x8017;
869756 pub const IOCMGET = 0x8018;
870 pub const IOCMBIS = 0x8022;
871 pub const IOCMBIC = 0x8023;
872757 pub const IOCMSET = 0x8019;
873 pub const FIONREAD = 0xbe000001;
874 pub const FIONBIO = 0xbe000000;
875758 pub const IOCSBRK = 0x8020;
876759 pub const IOCCBRK = 0x8021;
760 pub const IOCMBIS = 0x8022;
761 pub const IOCMBIC = 0x8023;
877762 pub const IOCGSID = 0x8024;
763
764 pub const FIONREAD = 0xbe000001;
765 pub const FIONBIO = 0xbe000000;
878766};
879767
880768pub const winsize = extern struct {
......@@ -904,140 +792,105 @@ pub const sigset_t = extern struct {
904792 __bits: [SIG.WORDS]u32,
905793};
906794
795const B_POSIX_ERROR_BASE = -2147454976;
796
907797pub const E = enum(i32) {
908 /// No error occurred.
909 SUCCESS = 0,
910 PERM = -0x7ffffff1, // Operation not permitted
911 NOENT = -0x7fff9ffd, // No such file or directory
912 SRCH = -0x7fff8ff3, // No such process
798 @"2BIG" = B_POSIX_ERROR_BASE + 1,
799 CHILD = B_POSIX_ERROR_BASE + 2,
800 DEADLK = B_POSIX_ERROR_BASE + 3,
801 FBIG = B_POSIX_ERROR_BASE + 4,
802 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
913862 INTR = -0x7ffffff6, // Interrupted system call
914863 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
923864 BUSY = -0x7ffffff2, // Device busy
865 FAULT = -0x7fffecff, // Bad address
866 TIMEDOUT = -2147483639, // Operation timed out
867 AGAIN = -0x7ffffff5,
868 BADF = -0x7fffa000, // Bad file descriptor
924869 EXIST = -0x7fff9ffe, // File exists
925 XDEV = -0x7fff9ff5, // Cross-device link
926 NODEV = -0x7fff8ff9, // Operation not supported by device
870 INVAL = -0x7ffffffb, // Invalid argument
871 NAMETOOLONG = -2147459068, // File name too long
872 NOENT = -0x7fff9ffd, // No such file or directory
873 PERM = -0x7ffffff1, // Operation not permitted
927874 NOTDIR = -0x7fff9ffb, // Not a directory
928875 ISDIR = -0x7fff9ff7, // Is a directory
929 INVAL = -0x7ffffffb, // Invalid argument
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
876 NOTEMPTY = -2147459066, // Directory not empty
935877 NOSPC = -0x7fff9ff9, // No space left on device
936 SPIPE = -0x7fff8ff4, // Illegal seek
937878 ROFS = -0x7fff9ff8, // Read-only filesystem
938 MLINK = -0x7fff8ffb, // Too many links
879 MFILE = -0x7fff9ff6, // Too many open files
880 XDEV = -0x7fff9ff5, // Cross-device link
881 NOEXEC = -0x7fffecfe, // Exec format error
939882 PIPE = -0x7fff9ff3, // Broken pipe
940 BADF = -0x7fffa000, // Bad file descriptor
941
942 // math software
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
883 NOMEM = -0x80000000, // Cannot allocate memory
884 LOOP = -2147459060, // Too many levels of symbolic links
885 SUCCESS = 0,
1029886 _,
1030887};
1031888
1032pub const MINSIGSTKSZ = switch (builtin.cpu.arch) {
1033 .i386, .x86_64 => 2048,
1034 .arm, .aarch64 => 4096,
1035 else => @compileError("MINSIGSTKSZ not defined for this architecture"),
1036};
1037pub const SIGSTKSZ = MINSIGSTKSZ + 32768;
889pub const MINSIGSTKSZ = 8192;
890pub const SIGSTKSZ = 16384;
1038891
1039pub const SS_ONSTACK = 1;
1040pub const SS_DISABLE = 4;
892pub const SS_ONSTACK = 0x1;
893pub const SS_DISABLE = 0x2;
1041894
1042895pub const stack_t = extern struct {
1043896 sp: [*]u8,
......@@ -1047,16 +900,16 @@ pub const stack_t = extern struct {
1047900
1048901pub const S = struct {
1049902 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;
1057903 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;
1060913 pub const ISUID = 0o4000;
1061914 pub const ISGID = 0o2000;
1062915 pub const ISVTX = 0o1000;
......@@ -1073,56 +926,47 @@ pub const S = struct {
1073926 pub const IWOTH = 0o002;
1074927 pub const IXOTH = 0o001;
1075928
1076 pub fn ISFIFO(m: u32) bool {
1077 return m & IFMT == IFIFO;
1078 }
1079
1080 pub fn ISCHR(m: u32) bool {
1081 return m & IFMT == IFCHR;
929 pub fn ISREG(m: u32) bool {
930 return m & IFMT == IFREG;
1082931 }
1083932
1084 pub fn ISDIR(m: u32) bool {
1085 return m & IFMT == IFDIR;
933 pub fn ISLNK(m: u32) bool {
934 return m & IFMT == IFLNK;
1086935 }
1087936
1088937 pub fn ISBLK(m: u32) bool {
1089938 return m & IFMT == IFBLK;
1090939 }
1091940
1092 pub fn ISREG(m: u32) bool {
1093 return m & IFMT == IFREG;
941 pub fn ISDIR(m: u32) bool {
942 return m & IFMT == IFDIR;
1094943 }
1095944
1096 pub fn ISLNK(m: u32) bool {
1097 return m & IFMT == IFLNK;
945 pub fn ISCHR(m: u32) bool {
946 return m & IFMT == IFCHR;
947 }
948
949 pub fn ISFIFO(m: u32) bool {
950 return m & IFMT == IFIFO;
1098951 }
1099952
1100953 pub fn ISSOCK(m: u32) bool {
1101954 return m & IFMT == IFSOCK;
1102955 }
1103956
1104 pub fn IWHT(m: u32) bool {
1105 return m & IFMT == IFWHT;
957 pub fn ISINDEX(m: u32) bool {
958 return m & INDEX_DIR == INDEX_DIR;
1106959 }
1107960};
1108961
1109962pub const HOST_NAME_MAX = 255;
1110963
1111964pub const AT = struct {
1112 /// Magic value that specify the use of the current working directory
1113 /// to determine the target of relative file paths in the openat() and
1114 /// similar syscalls.
1115 pub const FDCWD = -100;
1116 /// Check access using effective user and group ID
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;
965 pub const FDCWD = -1;
966 pub const SYMLINK_NOFOLLOW = 0x01;
967 pub const SYMLINK_FOLLOW = 0x02;
968 pub const REMOVEDIR = 0x04;
969 pub const EACCESS = 0x08;
1126970};
1127971
1128972pub const addrinfo = extern struct {
......@@ -1137,238 +981,23 @@ pub const addrinfo = extern struct {
1137981};
1138982
1139983pub const IPPROTO = struct {
1140 /// dummy for IP
1141984 pub const IP = 0;
1142 /// control message protocol
985 pub const HOPOPTS = 0;
1143986 pub const ICMP = 1;
1144 /// tcp
987 pub const IGMP = 2;
1145988 pub const TCP = 6;
1146 /// user datagram protocol
1147989 pub const UDP = 17;
1148 /// IP6 header
1149990 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
1231991 pub const ROUTING = 43;
1232 /// IP6 fragmentation header
1233992 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
1245993 pub const ESP = 50;
1246 /// IP6 Auth Header
1247994 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
1261995 pub const ICMPV6 = 58;
1262 /// IP6 no next header
1263996 pub const NONE = 59;
1264 /// IP6 destination option
1265997 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
1339998 pub const ETHERIP = 97;
1340 /// encapsulation header
1341 pub const ENCAP = 98;
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;
999 pub const RAW = 255;
1000 pub const MAX = 256;
13721001};
13731002
13741003pub const rlimit_resource = enum(c_int) {