authorgravatar for 3811822-hoanga@users.noreply.gitlab.comAl Hoang <3811822-hoanga@users.noreply.gitlab.com> 2021-04-23 23:40:42-05:00
committergravatar for 3811822-hoanga@users.noreply.gitlab.comAl Hoang <3811822-hoanga@users.noreply.gitlab.com> 2021-04-23 23:40:42-05:00
log762d4a959cc4e61fb88f68ba067ec97c5e2fe869
tree28bb7b1194e94b897eb561aabceb6b53fbd0733b
parent914d57a1a64dd08983aeaa3e1eeb286043211b58

update haiku system constants


2 files changed, 176 insertions(+), 206 deletions(-)

lib/std/c/haiku.zig+48
...@@ -69,3 +69,51 @@ pub const pthread_rwlock_t = extern struct {...@@ -69,3 +69,51 @@ pub const pthread_rwlock_t = extern struct {
69 writer_count: i32 = 0,69 writer_count: i32 = 0,
70 waiters: [2]?*c_void = [_]?*c_void{ null, null },70 waiters: [2]?*c_void = [_]?*c_void{ null, null },
71};71};
72
73pub const EAI = extern enum(c_int) {
74 /// address family for hostname not supported
75 ADDRFAMILY = 1,
76
77 /// name could not be resolved at this time
78 AGAIN = 2,
79
80 /// flags parameter had an invalid value
81 BADFLAGS = 3,
82
83 /// non-recoverable failure in name resolution
84 FAIL = 4,
85
86 /// address family not recognized
87 FAMILY = 5,
88
89 /// memory allocation failure
90 MEMORY = 6,
91
92 /// no address associated with hostname
93 NODATA = 7,
94
95 /// name does not resolve
96 NONAME = 8,
97
98 /// service not recognized for socket type
99 SERVICE = 9,
100
101 /// intended socket type was not recognized
102 SOCKTYPE = 10,
103
104 /// system error returned in errno
105 SYSTEM = 11,
106
107 /// invalid value for hints
108 BADHINTS = 12,
109
110 /// resolved protocol is unknown
111 PROTOCOL = 13,
112
113 /// argument buffer overflow
114 OVERFLOW = 14,
115
116 _,
117};
118
119pub const EAI_MAX = 15;
lib/std/os/bits/haiku.zig+128-206
...@@ -279,20 +279,10 @@ pub const PROT_READ = 1;...@@ -279,20 +279,10 @@ pub const PROT_READ = 1;
279pub const PROT_WRITE = 2;279pub const PROT_WRITE = 2;
280pub const PROT_EXEC = 4;280pub const PROT_EXEC = 4;
281281
282pub const CLOCK_REALTIME = 0;282pub const CLOCK_MONOTONIC = 0;
283pub const CLOCK_VIRTUAL = 1;283pub const CLOCK_REALTIME = -1;
284pub const CLOCK_PROF = 2;284pub const CLOCK_PROCESS_CPUTIME_ID = -2;
285pub const CLOCK_MONOTONIC = 4;285pub const CLOCK_THREAD_CPUTIME_ID = -3;
286pub const CLOCK_UPTIME = 5;
287pub const CLOCK_UPTIME_PRECISE = 7;
288pub const CLOCK_UPTIME_FAST = 8;
289pub const CLOCK_REALTIME_PRECISE = 9;
290pub const CLOCK_REALTIME_FAST = 10;
291pub const CLOCK_MONOTONIC_PRECISE = 11;
292pub const CLOCK_MONOTONIC_FAST = 12;
293pub const CLOCK_SECOND = 13;
294pub const CLOCK_THREAD_CPUTIME_ID = 14;
295pub const CLOCK_PROCESS_CPUTIME_ID = 15;
296286
297pub const MAP_FAILED = @intToPtr(*c_void, maxInt(usize));287pub const MAP_FAILED = @intToPtr(*c_void, maxInt(usize));
298pub const MAP_SHARED = 0x0001;288pub const MAP_SHARED = 0x0001;
...@@ -310,58 +300,59 @@ pub const MAP_NOCORE = 0x00020000;...@@ -310,58 +300,59 @@ pub const MAP_NOCORE = 0x00020000;
310pub const MAP_PREFAULT_READ = 0x00040000;300pub const MAP_PREFAULT_READ = 0x00040000;
311pub const MAP_32BIT = 0x00080000;301pub const MAP_32BIT = 0x00080000;
312302
313pub const WNOHANG = 1;303pub const WNOHANG = 0x1;
314pub const WUNTRACED = 2;304pub const WUNTRACED = 0x2;
315pub const WSTOPPED = WUNTRACED;305pub const WSTOPPED = 0x10;
316pub const WCONTINUED = 4;306pub const WCONTINUED = 0x4;
317pub const WNOWAIT = 8;307pub const WNOWAIT = 0x20;
318pub const WEXITED = 16;308pub const WEXITED = 0x08;
319pub const WTRAPPED = 32;309
320310pub const SA_ONSTACK = 0x20;
321pub const SA_ONSTACK = 0x0001;311pub const SA_RESTART = 0x10;
322pub const SA_RESTART = 0x0002;312pub const SA_RESETHAND = 0x04;
323pub const SA_RESETHAND = 0x0004;313pub const SA_NOCLDSTOP = 0x01;
324pub const SA_NOCLDSTOP = 0x0008;314pub const SA_NODEFER = 0x08;
325pub const SA_NODEFER = 0x0010;315pub const SA_NOCLDWAIT = 0x02;
326pub const SA_NOCLDWAIT = 0x0020;316pub const SA_SIGINFO = 0x40;
327pub const SA_SIGINFO = 0x0040;317pub const SA_NOMASK = SA_NODEFER;
318pub const SA_STACK = SA_ONSTACK;
319pub const SA_ONESHOT = SA_RESETHAND;
328320
329pub const SIGHUP = 1;321pub const SIGHUP = 1;
330pub const SIGINT = 2;322pub const SIGINT = 2;
331pub const SIGQUIT = 3;323pub const SIGQUIT = 3;
332pub const SIGILL = 4;324pub const SIGILL = 4;
333pub const SIGTRAP = 5;325pub const SIGCHLD = 5;
334pub const SIGABRT = 6;326pub const SIGABRT = 6;
335pub const SIGIOT = SIGABRT;327pub const SIGIOT = SIGABRT;
336pub const SIGEMT = 7;328pub const SIGPIPE = 7;
337pub const SIGFPE = 8;329pub const SIGFPE = 8;
338pub const SIGKILL = 9;330pub const SIGKILL = 9;
339pub const SIGBUS = 10;331pub const SIGSTOP = 10;
340pub const SIGSEGV = 11;332pub const SIGSEGV = 11;
341pub const SIGSYS = 12;333pub const SIGCONT = 12;
342pub const SIGPIPE = 13;334pub const SIGTSTP = 13;
343pub const SIGALRM = 14;335pub const SIGALRM = 14;
344pub const SIGTERM = 15;336pub const SIGTERM = 15;
345pub const SIGURG = 16;337pub const SIGTTIN = 16;
346pub const SIGSTOP = 17;338pub const SIGTTOU = 17;
347pub const SIGTSTP = 18;339pub const SIGUSR1 = 18;
348pub const SIGCONT = 19;340pub const SIGUSR2 = 19;
349pub const SIGCHLD = 20;341pub const SIGWINCH = 20;
350pub const SIGTTIN = 21;342pub const SIGKILLTHR = 21;
351pub const SIGTTOU = 22;343pub const SIGTRAP = 22;
352pub const SIGIO = 23;344pub const SIGPOLL = 23;
353pub const SIGXCPU = 24;345pub const SIGPROF = 24;
354pub const SIGXFSZ = 25;346pub const SIGSYS = 25;
355pub const SIGVTALRM = 26;347pub const SIGURG = 26;
356pub const SIGPROF = 27;348pub const SIGVTALRM = 27;
357pub const SIGWINCH = 28;349pub const SIGXCPU = 28;
358pub const SIGINFO = 29;350pub const SIGXFSZ = 29;
359pub const SIGUSR1 = 30;351pub const SIGBUS = 30;
360pub const SIGUSR2 = 31;352pub const SIGRESERVED1 = 31;
361pub const SIGTHR = 32;353pub const SIGRESERVED2 = 32;
362pub const SIGLWP = SIGTHR;354
363pub const SIGLIBRT = 33;355// TODO: check
364
365pub const SIGRTMIN = 65;356pub const SIGRTMIN = 65;
366pub const SIGRTMAX = 126;357pub const SIGRTMAX = 126;
367358
...@@ -645,135 +636,51 @@ pub const EVFILT_SENDFILE = -12;...@@ -645,135 +636,51 @@ pub const EVFILT_SENDFILE = -12;
645636
646pub const EVFILT_EMPTY = -13;637pub const EVFILT_EMPTY = -13;
647638
648/// On input, NOTE_TRIGGER causes the event to be triggered for output.639pub const TCGETA = 0x8000;
649pub const NOTE_TRIGGER = 0x01000000;640pub const TCSETA = 0x8001;
650641pub const TCSETAW = 0x8004;
651/// ignore input fflags642pub const TCSETAF = 0x8003;
652pub const NOTE_FFNOP = 0x00000000;643pub const TCSBRK = 08005;
653644pub const TCXONC = 0x8007;
654/// and fflags645pub const TCFLSH = 0x8006;
655pub const NOTE_FFAND = 0x40000000;646
656647pub const TIOCSCTTY = 0x8017;
657/// or fflags648pub const TIOCGPGRP = 0x8015;
658pub const NOTE_FFOR = 0x80000000;649pub const TIOCSPGRP = 0x8016;
659650pub const TIOCGWINSZ = 0x8012;
660/// copy fflags651pub const TIOCSWINSZ = 0x8013;
661pub const NOTE_FFCOPY = 0xc0000000;652pub const TIOCMGET = 0x8018;
662653pub const TIOCMBIS = 0x8022;
663/// mask for operations654pub const TIOCMBIC = 0x8023;
664pub const NOTE_FFCTRLMASK = 0xc0000000;655pub const TIOCMSET = 0x8019;
665pub const NOTE_FFLAGSMASK = 0x00ffffff;656pub const FIONREAD = 0xbe000001;
666657pub const FIONBIO = 0xbe000000;
667/// low water mark658pub const TIOCSBRK = 0x8020;
668pub const NOTE_LOWAT = 0x00000001;659pub const TIOCCBRK = 0x8021;
669660pub const TIOCGSID = 0x8024;
670/// behave like poll()
671pub const NOTE_FILE_POLL = 0x00000002;
672
673/// vnode was removed
674pub const NOTE_DELETE = 0x00000001;
675
676/// data contents changed
677pub const NOTE_WRITE = 0x00000002;
678
679/// size increased
680pub const NOTE_EXTEND = 0x00000004;
681
682/// attributes changed
683pub const NOTE_ATTRIB = 0x00000008;
684
685/// link count changed
686pub const NOTE_LINK = 0x00000010;
687
688/// vnode was renamed
689pub const NOTE_RENAME = 0x00000020;
690
691/// vnode access was revoked
692pub const NOTE_REVOKE = 0x00000040;
693
694/// vnode was opened
695pub const NOTE_OPEN = 0x00000080;
696
697/// file closed, fd did not allow write
698pub const NOTE_CLOSE = 0x00000100;
699
700/// file closed, fd did allow write
701pub const NOTE_CLOSE_WRITE = 0x00000200;
702
703/// file was read
704pub const NOTE_READ = 0x00000400;
705
706/// process exited
707pub const NOTE_EXIT = 0x80000000;
708
709/// process forked
710pub const NOTE_FORK = 0x40000000;
711
712/// process exec'd
713pub const NOTE_EXEC = 0x20000000;
714
715/// mask for signal & exit status
716pub const NOTE_PDATAMASK = 0x000fffff;
717pub const NOTE_PCTRLMASK = (~NOTE_PDATAMASK);
718
719/// data is seconds
720pub const NOTE_SECONDS = 0x00000001;
721
722/// data is milliseconds
723pub const NOTE_MSECONDS = 0x00000002;
724
725/// data is microseconds
726pub const NOTE_USECONDS = 0x00000004;
727
728/// data is nanoseconds
729pub const NOTE_NSECONDS = 0x00000008;
730
731/// timeout is absolute
732pub const NOTE_ABSTIME = 0x00000010;
733
734pub const TIOCEXCL = 0x2000740d;
735pub const TIOCNXCL = 0x2000740e;
736pub const TIOCSCTTY = 0x20007461;
737pub const TIOCGPGRP = 0x40047477;
738pub const TIOCSPGRP = 0x80047476;
739pub const TIOCOUTQ = 0x40047473;
740pub const TIOCSTI = 0x80017472;
741pub const TIOCGWINSZ = 0x40087468;
742pub const TIOCSWINSZ = 0x80087467;
743pub const TIOCMGET = 0x4004746a;
744pub const TIOCMBIS = 0x8004746c;
745pub const TIOCMBIC = 0x8004746b;
746pub const TIOCMSET = 0x8004746d;
747pub const FIONREAD = 0x4004667f;
748pub const TIOCCONS = 0x80047462;
749pub const TIOCPKT = 0x80047470;
750pub const FIONBIO = 0x8004667e;
751pub const TIOCNOTTY = 0x20007471;
752pub const TIOCSETD = 0x8004741b;
753pub const TIOCGETD = 0x4004741a;
754pub const TIOCSBRK = 0x2000747b;
755pub const TIOCCBRK = 0x2000747a;
756pub const TIOCGSID = 0x40047463;
757pub const TIOCGPTN = 0x4004740f;
758pub const TIOCSIG = 0x2004745f;
759661
760pub fn WEXITSTATUS(s: u32) u32 {662pub fn WEXITSTATUS(s: u32) u32 {
761 return (s & 0xff00) >> 8;663 return (s & 0xff);
762}664}
665
763pub fn WTERMSIG(s: u32) u32 {666pub fn WTERMSIG(s: u32) u32 {
764 return s & 0x7f;667 return (s >> 8) & 0xff;
765}668}
669
766pub fn WSTOPSIG(s: u32) u32 {670pub fn WSTOPSIG(s: u32) u32 {
767 return WEXITSTATUS(s);671 return WEXITSTATUS(s);
768}672}
673
769pub fn WIFEXITED(s: u32) bool {674pub fn WIFEXITED(s: u32) bool {
770 return WTERMSIG(s) == 0;675 return WTERMSIG(s) == 0;
771}676}
677
772pub fn WIFSTOPPED(s: u32) bool {678pub fn WIFSTOPPED(s: u32) bool {
773 return @intCast(u16, (((s & 0xffff) *% 0x10001) >> 8)) > 0x7f00;679 return ((s >> 16) & 0xff) != 0;
774}680}
681
775pub fn WIFSIGNALED(s: u32) bool {682pub fn WIFSIGNALED(s: u32) bool {
776 return (s & 0xffff) -% 1 < 0xff;683 return ((s >> 8) & 0xff) != 0;
777}684}
778685
779pub const winsize = extern struct {686pub const winsize = extern struct {
...@@ -823,49 +730,47 @@ pub const sigset_t = extern struct {...@@ -823,49 +730,47 @@ pub const sigset_t = extern struct {
823 __bits: [_SIG_WORDS]u32,730 __bits: [_SIG_WORDS]u32,
824};731};
825732
826pub const EPERM = 1; // Operation not permitted733pub const EPERM = -0x7ffffff1; // Operation not permitted
827pub const ENOENT = 2; // No such file or directory734pub const ENOENT = -0x7fff9ffd; // No such file or directory
828pub const ESRCH = 3; // No such process735pub const ESRCH = -0x7fff8ff3; // No such process
829pub const EINTR = 4; // Interrupted system call736pub const EINTR = -0x7ffffff6; // Interrupted system call
830pub const EIO = 5; // Input/output error737pub const EIO = -0x7fffffff; // Input/output error
831pub const ENXIO = 6; // Device not configured738pub const ENXIO = -0x7fff8ff5; // Device not configured
832pub const E2BIG = 7; // Argument list too long739pub const E2BIG = -0x7fff8fff; // Argument list too long
833pub const ENOEXEC = 8; // Exec format error740pub const ENOEXEC = -0x7fffecfe; // Exec format error
834pub const EBADF = 9; // Bad file descriptor741pub const ECHILD = -0x7fff8ffe; // No child processes
835pub const ECHILD = 10; // No child processes742pub const EDEADLK = -0x7fff8ffd; // Resource deadlock avoided
836pub const EDEADLK = 11; // Resource deadlock avoided743pub const ENOMEM = -0x80000000; // Cannot allocate memory
837// 11 was EAGAIN744pub const EACCES = -0x7ffffffe; // Permission denied
838pub const ENOMEM = 12; // Cannot allocate memory745pub const EFAULT = -0x7fffecff; // Bad address
839pub const EACCES = 13; // Permission denied746pub const EBUSY = -0x7ffffff2; // Device busy
840pub const EFAULT = 14; // Bad address747pub const EEXIST = -0x7fff9ffe; // File exists
841pub const ENOTBLK = 15; // Block device required748pub const EXDEV = -0x7fff9ff5; // Cross-device link
842pub const EBUSY = 16; // Device busy749pub const ENODEV = -0x7fff8ff9; // Operation not supported by device
843pub const EEXIST = 17; // File exists750pub const ENOTDIR = -0x7fff9ffb; // Not a directory
844pub const EXDEV = 18; // Cross-device link751pub const EISDIR = -0x7fff9ff7; // Is a directory
845pub const ENODEV = 19; // Operation not supported by device752pub const EINVAL = -0x7ffffffb; // Invalid argument
846pub const ENOTDIR = 20; // Not a directory753pub const ENFILE = -0x7fff8ffa; // Too many open files in system
847pub const EISDIR = 21; // Is a directory754pub const EMFILE = -0x7fff9ff6; // Too many open files
848pub const EINVAL = 22; // Invalid argument755pub const ENOTTY = -0x7fff8ff6; // Inappropriate ioctl for device
849pub const ENFILE = 23; // Too many open files in system756pub const ETXTBSY = -0x7fff8fc5; // Text file busy
850pub const EMFILE = 24; // Too many open files757pub const EFBIG = -0x7fff8ffc; // File too large
851pub const ENOTTY = 25; // Inappropriate ioctl for device758pub const ENOSPC = -0x7fff9ff9; // No space left on device
852pub const ETXTBSY = 26; // Text file busy759pub const ESPIPE = -0x7fff8ff4; // Illegal seek
853pub const EFBIG = 27; // File too large760pub const EROFS = -0x7fff9ff8; // Read-only filesystem
854pub const ENOSPC = 28; // No space left on device761pub const EMLINK = -0x7fff8ffb; // Too many links
855pub const ESPIPE = 29; // Illegal seek762pub const EPIPE = -0x7fff9ff3; // Broken pipe
856pub const EROFS = 30; // Read-only filesystem763pub const EBADF = -0x7fffa000; // Bad file descriptor
857pub const EMLINK = 31; // Too many links
858pub const EPIPE = 32; // Broken pipe
859764
860// math software765// math software
861pub const EDOM = 33; // Numerical argument out of domain766pub const EDOM = 33; // Numerical argument out of domain
862pub const ERANGE = 34; // Result too large767pub const ERANGE = 34; // Result too large
863768
864// non-blocking and interrupt i/o769// non-blocking and interrupt i/o
865pub const EAGAIN = 35; // Resource temporarily unavailable770pub const EAGAIN = -0x7ffffff5;
866pub const EWOULDBLOCK = EAGAIN; // Operation would block771pub const EWOULDBLOCK = -0x7ffffff5;
867pub const EINPROGRESS = 36; // Operation now in progress772pub const EINPROGRESS = -0x7fff8fdc;
868pub const EALREADY = 37; // Operation already in progress773pub const EALREADY = -0x7fff8fdb;
869774
870// ipc/network software -- argument errors775// ipc/network software -- argument errors
871pub const ENOTSOCK = 38; // Socket operation on non-socket776pub const ENOTSOCK = 38; // Socket operation on non-socket
...@@ -1447,3 +1352,20 @@ pub const directory_which = extern enum(c_int) {...@@ -1447,3 +1352,20 @@ pub const directory_which = extern enum(c_int) {
14471352
1448 _,1353 _,
1449};1354};
1355
1356pub const cc_t = u8;
1357pub const speed_t = u8;
1358pub const tcflag_t = u32;
1359
1360pub const NCCS = 32;
1361
1362pub const termios = extern struct {
1363 c_iflag: tcflag_t,
1364 c_oflag: tcflag_t,
1365 c_cflag: tcflag_t,
1366 c_lflag: tcflag_t,
1367 c_line: cc_t,
1368 c_ispeed: speed_t,
1369 c_ospeed: speed_t,
1370 cc_t: [NCCS]cc_t,
1371};