authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-11-24 18:42:30-08:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2021-11-24 18:42:30-08:00
log36c8adf58922d8e357bbaf7ce914cfd4b7b56354
treed2be6015196ab16e6029304b032df1468fb69973
parente266ede6e310b64adcf3912b8ef2b9e2397fde7b
parentbe541ca5e102614c8d86b86affcda44df828d8fb
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #10073 from hoanga/haiku-support-build2

more haiku support

6 files changed, 344 insertions(+), 712 deletions(-)

lib/std/Thread.zig+6-5
......@@ -577,11 +577,12 @@ const PosixThreadImpl = struct {
577577 };
578578 },
579579 .haiku => {
580 var count: u32 = undefined;
581 var system_info: os.system_info = undefined;
582 _ = os.system.get_system_info(&system_info); // always returns B_OK
583 count = system_info.cpu_count;
584 return @intCast(usize, count);
580 var system_info: os.system.system_info = undefined;
581 const rc = os.system.get_system_info(&system_info); // always returns B_OK
582 return switch (os.errno(rc)) {
583 .SUCCESS => @intCast(usize, system_info.cpu_count),
584 else => |err| os.unexpectedErrno(err),
585 };
585586 },
586587 else => {
587588 var count: c_int = undefined;
lib/std/c/haiku.zig+315-704
......@@ -14,8 +14,12 @@ pub extern "c" fn find_thread(thread_name: ?*c_void) i32;
1414
1515pub extern "c" fn get_system_info(system_info: *system_info) usize;
1616
17pub extern "c" fn _get_team_info(team: c_int, team_info: *team_info, size: usize) i32;
18
19pub extern "c" fn _get_next_area_info(team: c_int, cookie: *i64, area_info: *area_info, size: usize) i32;
20
1721// TODO revisit if abi changes or better option becomes apparent
18pub extern "c" fn _get_next_image_info(team: c_int, cookie: *i32, image_info: *image_info) usize;
22pub extern "c" fn _get_next_image_info(team: c_int, cookie: *i32, image_info: *image_info, size: usize) i32;
1923
2024pub extern "c" fn _kern_read_dir(fd: c_int, buf_ptr: [*]u8, nbytes: usize, maxcount: u32) usize;
2125
......@@ -24,12 +28,12 @@ pub extern "c" fn _kern_read_stat(fd: c_int, path_ptr: [*]u8, traverse_link: boo
2428pub extern "c" fn _kern_get_current_team() i32;
2529
2630pub const sem_t = extern struct {
27 _magic: u32,
28 _kern: extern struct {
29 _count: u32,
30 _flags: u32,
31 type: i32,
32 u: extern union {
33 named_sem_id: ?i32,
34 unnamed_sem: ?i32,
3135 },
32 _padding: u32,
36 padding: [2]i32,
3337};
3438
3539pub const pthread_attr_t = extern struct {
......@@ -47,6 +51,7 @@ pub const pthread_mutex_t = extern struct {
4751 owner: i32 = -1,
4852 owner_count: i32 = 0,
4953};
54
5055pub const pthread_cond_t = extern struct {
5156 flags: u32 = 0,
5257 unused: i32 = -42,
......@@ -54,15 +59,6 @@ pub const pthread_cond_t = extern struct {
5459 waiter_count: i32 = 0,
5560 lock: i32 = 0,
5661};
57pub const pthread_rwlock_t = extern struct {
58 flags: u32 = 0,
59 owner: i32 = -1,
60 lock_sem: i32 = 0,
61 lock_count: i32 = 0,
62 reader_count: i32 = 0,
63 writer_count: i32 = 0,
64 waiters: [2]?*c_void = [_]?*c_void{ null, null },
65};
6662
6763pub const EAI = enum(c_int) {
6864 /// address family for hostname not supported
......@@ -112,6 +108,12 @@ pub const EAI = enum(c_int) {
112108
113109pub const EAI_MAX = 15;
114110
111pub const AI = struct {
112 pub const NUMERICSERV = 0x00000008;
113};
114
115pub const AI_NUMERICSERV = AI.NUMERICSERV;
116
115117pub const fd_t = c_int;
116118pub const pid_t = c_int;
117119pub const uid_t = u32;
......@@ -120,43 +122,33 @@ pub const mode_t = c_uint;
120122
121123pub const socklen_t = u32;
122124
123/// Renamed from `kevent` to `Kevent` to avoid conflict with function name.
124pub const Kevent = extern struct {
125 ident: usize,
126 filter: i16,
127 flags: u16,
128 fflags: u32,
129 data: i64,
130 udata: usize,
131 // TODO ext
132};
133
134125// Modes and flags for dlopen()
135126// include/dlfcn.h
136127
137128pub const POLL = struct {
138 pub const IN = 0x0001;
139 pub const ERR = 0x0004;
140 pub const NVAL = 0x1000;
141 pub const HUP = 0x0080;
129 /// input available
130 pub const IN = 70;
131 /// output available
132 pub const OUT = 71;
133 /// input message available
134 pub const MSG = 72;
135 /// I/O error
136 pub const ERR = 73;
137 /// high priority input available
138 pub const PRI = 74;
139 /// device disconnected
140 pub const HUP = 75;
142141};
143142
144143pub const RTLD = struct {
145 /// Bind function calls lazily.
146 pub const LAZY = 1;
147 /// Bind function calls immediately.
148 pub const NOW = 2;
149 pub const MODEMASK = 0x3;
150 /// Make symbols globally available.
151 pub const GLOBAL = 0x100;
152 /// Opposite of GLOBAL, and the default.
144 /// relocations are performed as needed
145 pub const LAZY = 0;
146 /// the file gets relocated at load time
147 pub const NOW = 1;
148 /// all symbols are available
149 pub const GLOBAL = 2;
150 /// symbols are not available for relocating any other object
153151 pub const LOCAL = 0;
154 /// Trace loaded objects and exit.
155 pub const TRACE = 0x200;
156 /// Do not remove members.
157 pub const NODELETE = 0x01000;
158 /// Do not load if not already loaded.
159 pub const NOLOAD = 0x02000;
160152};
161153
162154pub const dl_phdr_info = extern struct {
......@@ -167,13 +159,11 @@ pub const dl_phdr_info = extern struct {
167159};
168160
169161pub const Flock = extern struct {
162 l_type: c_short,
163 l_whence: c_short,
170164 l_start: off_t,
171165 l_len: off_t,
172166 l_pid: pid_t,
173 l_type: i16,
174 l_whence: i16,
175 l_sysid: i32,
176 __unused: [4]u8,
177167};
178168
179169pub const msghdr = extern struct {
......@@ -199,29 +189,6 @@ pub const msghdr = extern struct {
199189 msg_flags: i32,
200190};
201191
202pub const msghdr_const = extern struct {
203 /// optional address
204 msg_name: ?*const sockaddr,
205
206 /// size of address
207 msg_namelen: socklen_t,
208
209 /// scatter/gather array
210 msg_iov: [*]iovec_const,
211
212 /// # elements in msg_iov
213 msg_iovlen: i32,
214
215 /// ancillary data
216 msg_control: ?*c_void,
217
218 /// ancillary data buffer len
219 msg_controllen: socklen_t,
220
221 /// flags on received message
222 msg_flags: i32,
223};
224
225192pub const off_t = i64;
226193pub const ino_t = u64;
227194
......@@ -282,16 +249,34 @@ pub const dirent = extern struct {
282249 }
283250};
284251
252pub const B_OS_NAME_LENGTH = 32; // OS.h
253
254pub const area_info = extern struct {
255 area: u32,
256 name: [B_OS_NAME_LENGTH]u8,
257 size: usize,
258 lock: u32,
259 protection: u32,
260 team_id: i32,
261 ram_size: u32,
262 copy_count: u32,
263 in_count: u32,
264 out_count: u32,
265 address: *c_void,
266};
267
268pub const MAXPATHLEN = PATH_MAX;
269
285270pub const image_info = extern struct {
286271 id: u32,
287 type: u32,
272 image_type: u32,
288273 sequence: i32,
289274 init_order: i32,
290275 init_routine: *c_void,
291276 term_routine: *c_void,
292277 device: i32,
293 node: i32,
294 name: [1024]u8,
278 node: i64,
279 name: [MAXPATHLEN]u8,
295280 text: *c_void,
296281 data: *c_void,
297282 text_size: i32,
......@@ -328,6 +313,19 @@ pub const system_info = extern struct {
328313 abi: u32,
329314};
330315
316pub const team_info = extern struct {
317 team_id: i32,
318 thread_count: i32,
319 image_count: i32,
320 area_count: i32,
321 debugger_nub_thread: i32,
322 debugger_nub_port: i32,
323 argc: i32,
324 args: [64]u8,
325 uid: uid_t,
326 gid: gid_t,
327};
328
331329pub const in_port_t = u16;
332330pub const sa_family_t = u8;
333331
......@@ -366,15 +364,11 @@ pub const sockaddr = extern struct {
366364 };
367365};
368366
369pub const CTL = struct {
370 pub const KERN = 1;
371 pub const DEBUG = 5;
372};
367pub const CTL = struct {};
373368
374pub const KERN = struct {
375 pub const PROC = 14; // struct: process entries
376 pub const PROC_PATHNAME = 12; // path to executable
377};
369pub const KERN = struct {};
370
371pub const IOV_MAX = 1024;
378372
379373pub const PATH_MAX = 1024;
380374
......@@ -383,44 +377,46 @@ pub const STDOUT_FILENO = 1;
383377pub const STDERR_FILENO = 2;
384378
385379pub const PROT = struct {
386 pub const NONE = 0;
387 pub const READ = 1;
388 pub const WRITE = 2;
389 pub const EXEC = 4;
380 pub const READ = 0x01;
381 pub const WRITE = 0x02;
382 pub const EXEC = 0x04;
383 pub const NONE = 0x00;
390384};
391385
392386pub const CLOCK = struct {
387 /// system-wide monotonic clock (aka system time)
393388 pub const MONOTONIC = 0;
389 /// system-wide real time clock
394390 pub const REALTIME = -1;
391 /// clock measuring the used CPU time of the current process
395392 pub const PROCESS_CPUTIME_ID = -2;
393 /// clock measuring the used CPU time of the current thread
396394 pub const THREAD_CPUTIME_ID = -3;
397395};
398396
399397pub const MAP = struct {
398 /// mmap() error return code
400399 pub const FAILED = @intToPtr(*c_void, maxInt(usize));
401 pub const SHARED = 0x0001;
402 pub const PRIVATE = 0x0002;
403 pub const FIXED = 0x0010;
404 pub const STACK = 0x0400;
405 pub const NOSYNC = 0x0800;
406 pub const ANON = 0x1000;
407 pub const ANONYMOUS = ANON;
408 pub const FILE = 0;
409
410 pub const GUARD = 0x00002000;
411 pub const EXCL = 0x00004000;
412 pub const NOCORE = 0x00020000;
413 pub const PREFAULT_READ = 0x00040000;
414 pub const @"32BIT" = 0x00080000;
400 /// changes are seen by others
401 pub const SHARED = 0x01;
402 /// changes are only seen by caller
403 pub const PRIVATE = 0x02;
404 /// require mapping to specified addr
405 pub const FIXED = 0x04;
406 /// no underlying object
407 pub const ANONYMOUS = 0x0008;
408 pub const ANON = ANONYMOUS;
409 /// don't commit memory
410 pub const NORESERVE = 0x10;
415411};
416412
417413pub const W = struct {
418414 pub const NOHANG = 0x1;
419415 pub const UNTRACED = 0x2;
420 pub const STOPPED = 0x10;
421416 pub const CONTINUED = 0x4;
422 pub const NOWAIT = 0x20;
423417 pub const EXITED = 0x08;
418 pub const STOPPED = 0x10;
419 pub const NOWAIT = 0x20;
424420
425421 pub fn EXITSTATUS(s: u32) u8 {
426422 return @intCast(u8, s & 0xff);
......@@ -431,11 +427,11 @@ pub const W = struct {
431427 }
432428
433429 pub fn STOPSIG(s: u32) u32 {
434 return EXITSTATUS(s);
430 return (s >> 16) & 0xff;
435431 }
436432
437433 pub fn IFEXITED(s: u32) bool {
438 return TERMSIG(s) == 0;
434 return (s & ~@as(u32, 0xff)) == 0;
439435 }
440436
441437 pub fn IFSTOPPED(s: u32) bool {
......@@ -499,28 +495,9 @@ pub const SIG = struct {
499495 pub const RESERVED1 = 31;
500496 pub const RESERVED2 = 32;
501497
502 // TODO: check
503 pub const RTMIN = 65;
504 pub const RTMAX = 126;
505
506498 pub const BLOCK = 1;
507499 pub const UNBLOCK = 2;
508500 pub const SETMASK = 3;
509
510 pub const WORDS = 4;
511 pub const MAXSIG = 128;
512 pub inline fn IDX(sig: usize) usize {
513 return sig - 1;
514 }
515 pub inline fn WORD(sig: usize) usize {
516 return IDX(sig) >> 5;
517 }
518 pub inline fn BIT(sig: usize) usize {
519 return 1 << (IDX(sig) & 31);
520 }
521 pub inline fn VALID(sig: usize) usize {
522 return sig <= MAXSIG and sig > 0;
523 }
524501};
525502
526503// access function
......@@ -534,60 +511,49 @@ pub const O = struct {
534511 pub const WRONLY = 0x0001;
535512 pub const RDWR = 0x0002;
536513 pub const ACCMODE = 0x0003;
514 pub const RWMASK = ACCMODE;
537515
538 pub const SHLOCK = 0x0010;
539 pub const EXLOCK = 0x0020;
540
516 pub const EXCL = 0x0100;
541517 pub const CREAT = 0x0200;
542 pub const EXCL = 0x0800;
543 pub const NOCTTY = 0x8000;
544518 pub const TRUNC = 0x0400;
545 pub const APPEND = 0x0008;
546 pub const NONBLOCK = 0x0004;
547 pub const DSYNC = 0o10000;
548 pub const SYNC = 0x0080;
549 pub const RSYNC = 0o4010000;
550 pub const DIRECTORY = 0x20000;
551 pub const NOFOLLOW = 0x0100;
552 pub const CLOEXEC = 0x00100000;
553
554 pub const ASYNC = 0x0040;
555 pub const DIRECT = 0x00010000;
556 pub const NOATIME = 0o1000000;
557 pub const PATH = 0o10000000;
558 pub const TMPFILE = 0o20200000;
519 pub const NOCTTY = 0x1000;
520 pub const NOTRAVERSE = 0x2000;
521
522 pub const CLOEXEC = 0x00000040;
523 pub const NONBLOCK = 0x00000080;
559524 pub const NDELAY = NONBLOCK;
525 pub const APPEND = 0x00000800;
526 pub const SYNC = 0x00010000;
527 pub const RSYNC = 0x00020000;
528 pub const DSYNC = 0x00040000;
529 pub const NOFOLLOW = 0x00080000;
530 pub const DIRECT = 0x00100000;
531 pub const NOCACHE = DIRECT;
532 pub const DIRECTORY = 0x00200000;
560533};
561534
562535pub const F = struct {
563 pub const DUPFD = 0;
564 pub const GETFD = 1;
565 pub const SETFD = 2;
566 pub const GETFL = 3;
567 pub const SETFL = 4;
568
569 pub const GETOWN = 5;
570 pub const SETOWN = 6;
571
572 pub const GETLK = 11;
573 pub const SETLK = 12;
574 pub const SETLKW = 13;
536 pub const DUPFD = 0x0001;
537 pub const GETFD = 0x0002;
538 pub const SETFD = 0x0004;
539 pub const GETFL = 0x0008;
540 pub const SETFL = 0x0010;
575541
576 pub const RDLCK = 1;
577 pub const WRLCK = 3;
578 pub const UNLCK = 2;
542 pub const GETLK = 0x0020;
543 pub const SETLK = 0x0080;
544 pub const SETLKW = 0x0100;
545 pub const DUPFD_CLOEXEC = 0x0200;
579546
580 pub const SETOWN_EX = 15;
581 pub const GETOWN_EX = 16;
582
583 pub const GETOWNER_UIDS = 17;
547 pub const RDLCK = 0x0040;
548 pub const UNLCK = 0x0200;
549 pub const WRLCK = 0x0400;
584550};
585551
586552pub const LOCK = struct {
587 pub const SH = 1;
588 pub const EX = 2;
589 pub const UN = 8;
590 pub const NB = 4;
553 pub const SH = 0x01;
554 pub const EX = 0x02;
555 pub const NB = 0x04;
556 pub const UN = 0x08;
591557};
592558
593559pub const FD_CLOEXEC = 1;
......@@ -602,161 +568,66 @@ pub const SOCK = struct {
602568 pub const STREAM = 1;
603569 pub const DGRAM = 2;
604570 pub const RAW = 3;
605 pub const RDM = 4;
606571 pub const SEQPACKET = 5;
607
608 pub const CLOEXEC = 0x10000000;
609 pub const NONBLOCK = 0x20000000;
610572};
611573
612574pub const SO = struct {
613 pub const DEBUG = 0x00000001;
614 pub const ACCEPTCONN = 0x00000002;
615 pub const REUSEADDR = 0x00000004;
616 pub const KEEPALIVE = 0x00000008;
617 pub const DONTROUTE = 0x00000010;
618 pub const BROADCAST = 0x00000020;
619 pub const USELOOPBACK = 0x00000040;
620 pub const LINGER = 0x00000080;
621 pub const OOBINLINE = 0x00000100;
622 pub const REUSEPORT = 0x00000200;
623 pub const TIMESTAMP = 0x00000400;
624 pub const NOSIGPIPE = 0x00000800;
625 pub const ACCEPTFILTER = 0x00001000;
626 pub const BINTIME = 0x00002000;
627 pub const NO_OFFLOAD = 0x00004000;
628 pub const NO_DDP = 0x00008000;
629 pub const REUSEPORT_LB = 0x00010000;
630
631 pub const SNDBUF = 0x1001;
632 pub const RCVBUF = 0x1002;
633 pub const SNDLOWAT = 0x1003;
634 pub const RCVLOWAT = 0x1004;
635 pub const SNDTIMEO = 0x1005;
636 pub const RCVTIMEO = 0x1006;
637 pub const ERROR = 0x1007;
638 pub const TYPE = 0x1008;
639 pub const LABEL = 0x1009;
640 pub const PEERLABEL = 0x1010;
641 pub const LISTENQLIMIT = 0x1011;
642 pub const LISTENQLEN = 0x1012;
643 pub const LISTENINCQLEN = 0x1013;
644 pub const SETFIB = 0x1014;
645 pub const USER_COOKIE = 0x1015;
646 pub const PROTOCOL = 0x1016;
647 pub const PROTOTYPE = PROTOCOL;
648 pub const TS_CLOCK = 0x1017;
649 pub const MAX_PACING_RATE = 0x1018;
650 pub const DOMAIN = 0x1019;
575 pub const ACCEPTCONN = 0x00000001;
576 pub const BROADCAST = 0x00000002;
577 pub const DEBUG = 0x00000004;
578 pub const DONTROUTE = 0x00000008;
579 pub const KEEPALIVE = 0x00000010;
580 pub const OOBINLINE = 0x00000020;
581 pub const REUSEADDR = 0x00000040;
582 pub const REUSEPORT = 0x00000080;
583 pub const USELOOPBACK = 0x00000100;
584 pub const LINGER = 0x00000200;
585
586 pub const SNDBUF = 0x40000001;
587 pub const SNDLOWAT = 0x40000002;
588 pub const SNDTIMEO = 0x40000003;
589 pub const RCVBUF = 0x40000004;
590 pub const RCVLOWAT = 0x40000005;
591 pub const RCVTIMEO = 0x40000006;
592 pub const ERROR = 0x40000007;
593 pub const TYPE = 0x40000008;
594 pub const NONBLOCK = 0x40000009;
595 pub const BINDTODEVICE = 0x4000000a;
596 pub const PEERCRED = 0x4000000b;
651597};
652598
653599pub const SOL = struct {
654 pub const SOCKET = 0xffff;
600 pub const SOCKET = -1;
655601};
656602
657603pub const PF = struct {
658604 pub const UNSPEC = AF.UNSPEC;
659 pub const LOCAL = AF.LOCAL;
660 pub const UNIX = PF.LOCAL;
661605 pub const INET = AF.INET;
662 pub const IMPLINK = AF.IMPLINK;
663 pub const PUP = AF.PUP;
664 pub const CHAOS = AF.CHAOS;
665 pub const NETBIOS = AF.NETBIOS;
666 pub const ISO = AF.ISO;
667 pub const OSI = AF.ISO;
668 pub const ECMA = AF.ECMA;
669 pub const DATAKIT = AF.DATAKIT;
670 pub const CCITT = AF.CCITT;
671 pub const DECnet = AF.DECnet;
672 pub const DLI = AF.DLI;
673 pub const LAT = AF.LAT;
674 pub const HYLINK = AF.HYLINK;
675 pub const APPLETALK = AF.APPLETALK;
676606 pub const ROUTE = AF.ROUTE;
677607 pub const LINK = AF.LINK;
678 pub const XTP = AF.pseudo_XTP;
679 pub const COIP = AF.COIP;
680 pub const CNT = AF.CNT;
681 pub const SIP = AF.SIP;
682 pub const IPX = AF.IPX;
683 pub const RTIP = AF.pseudo_RTIP;
684 pub const PIP = AF.pseudo_PIP;
685 pub const ISDN = AF.ISDN;
686 pub const KEY = AF.pseudo_KEY;
687 pub const INET6 = AF.pseudo_INET6;
688 pub const NATM = AF.NATM;
689 pub const ATM = AF.ATM;
690 pub const NETGRAPH = AF.NETGRAPH;
691 pub const SLOW = AF.SLOW;
692 pub const SCLUSTER = AF.SCLUSTER;
693 pub const ARP = AF.ARP;
608 pub const INET6 = AF.INET6;
609 pub const LOCAL = AF.LOCAL;
610 pub const UNIX = AF.UNIX;
694611 pub const BLUETOOTH = AF.BLUETOOTH;
695 pub const IEEE80211 = AF.IEEE80211;
696 pub const INET_SDP = AF.INET_SDP;
697 pub const INET6_SDP = AF.INET6_SDP;
698 pub const MAX = AF.MAX;
699612};
700613
701614pub const AF = struct {
702615 pub const UNSPEC = 0;
703 pub const UNIX = 1;
704 pub const LOCAL = UNIX;
705 pub const FILE = LOCAL;
706 pub const INET = 2;
707 pub const IMPLINK = 3;
708 pub const PUP = 4;
709 pub const CHAOS = 5;
710 pub const NETBIOS = 6;
711 pub const ISO = 7;
712 pub const OSI = ISO;
713 pub const ECMA = 8;
714 pub const DATAKIT = 9;
715 pub const CCITT = 10;
716 pub const SNA = 11;
717 pub const DECnet = 12;
718 pub const DLI = 13;
719 pub const LAT = 14;
720 pub const HYLINK = 15;
721 pub const APPLETALK = 16;
722 pub const ROUTE = 17;
723 pub const LINK = 18;
724 pub const pseudo_XTP = 19;
725 pub const COIP = 20;
726 pub const CNT = 21;
727 pub const pseudo_RTIP = 22;
728 pub const IPX = 23;
729 pub const SIP = 24;
730 pub const pseudo_PIP = 25;
731 pub const ISDN = 26;
732 pub const E164 = ISDN;
733 pub const pseudo_KEY = 27;
734 pub const INET6 = 28;
735 pub const NATM = 29;
736 pub const ATM = 30;
737 pub const pseudo_HDRCMPLT = 31;
738 pub const NETGRAPH = 32;
739 pub const SLOW = 33;
740 pub const SCLUSTER = 34;
741 pub const ARP = 35;
742 pub const BLUETOOTH = 36;
743 pub const IEEE80211 = 37;
744 pub const INET_SDP = 40;
745 pub const INET6_SDP = 42;
746 pub const MAX = 42;
747};
748
749pub const DT = struct {
750 pub const UNKNOWN = 0;
751 pub const FIFO = 1;
752 pub const CHR = 2;
753 pub const DIR = 4;
754 pub const BLK = 6;
755 pub const REG = 8;
756 pub const LNK = 10;
757 pub const SOCK = 12;
758 pub const WHT = 14;
759};
616 pub const INET = 1;
617 pub const APPLETALK = 2;
618 pub const ROUTE = 3;
619 pub const LINK = 4;
620 pub const INET6 = 5;
621 pub const DLI = 6;
622 pub const IPX = 7;
623 pub const NOTIFY = 8;
624 pub const LOCAL = 9;
625 pub const UNIX = LOCAL;
626 pub const BLUETOOTH = 10;
627 pub const MAX = 11;
628};
629
630pub const DT = struct {};
760631
761632/// add event to kq (implies enable)
762633pub const EV_ADD = 0x0001;
......@@ -822,26 +693,32 @@ pub const EVFILT_EMPTY = -13;
822693pub const T = struct {
823694 pub const CGETA = 0x8000;
824695 pub const CSETA = 0x8001;
825 pub const CSETAW = 0x8004;
826 pub const CSETAF = 0x8003;
696 pub const CSETAF = 0x8002;
697 pub const CSETAW = 0x8003;
698 pub const CWAITEVENT = 0x8004;
827699 pub const CSBRK = 08005;
828 pub const CXONC = 0x8007;
829700 pub const CFLSH = 0x8006;
830
831 pub const IOCSCTTY = 0x8017;
832 pub const IOCGPGRP = 0x8015;
833 pub const IOCSPGRP = 0x8016;
701 pub const CXONC = 0x8007;
702 pub const CQUERYCONNECTED = 0x8008;
703 pub const CGETBITS = 0x8009;
704 pub const CSETDTR = 0x8010;
705 pub const CSETRTS = 0x8011;
834706 pub const IOCGWINSZ = 0x8012;
835707 pub const IOCSWINSZ = 0x8013;
708 pub const CVTIME = 0x8014;
709 pub const IOCGPGRP = 0x8015;
710 pub const IOCSPGRP = 0x8016;
711 pub const IOCSCTTY = 0x8017;
836712 pub const IOCMGET = 0x8018;
837 pub const IOCMBIS = 0x8022;
838 pub const IOCMBIC = 0x8023;
839713 pub const IOCMSET = 0x8019;
840 pub const FIONREAD = 0xbe000001;
841 pub const FIONBIO = 0xbe000000;
842714 pub const IOCSBRK = 0x8020;
843715 pub const IOCCBRK = 0x8021;
716 pub const IOCMBIS = 0x8022;
717 pub const IOCMBIC = 0x8023;
844718 pub const IOCGSID = 0x8024;
719
720 pub const FIONREAD = 0xbe000001;
721 pub const FIONBIO = 0xbe000000;
845722};
846723
847724pub const winsize = extern struct {
......@@ -871,140 +748,105 @@ pub const sigset_t = extern struct {
871748 __bits: [SIG.WORDS]u32,
872749};
873750
751const B_POSIX_ERROR_BASE = -2147454976;
752
874753pub const E = enum(i32) {
875 /// No error occurred.
876 SUCCESS = 0,
877 PERM = -0x7ffffff1, // Operation not permitted
878 NOENT = -0x7fff9ffd, // No such file or directory
879 SRCH = -0x7fff8ff3, // No such process
754 @"2BIG" = B_POSIX_ERROR_BASE + 1,
755 CHILD = B_POSIX_ERROR_BASE + 2,
756 DEADLK = B_POSIX_ERROR_BASE + 3,
757 FBIG = B_POSIX_ERROR_BASE + 4,
758 MLINK = B_POSIX_ERROR_BASE + 5,
759 NFILE = B_POSIX_ERROR_BASE + 6,
760 NODEV = B_POSIX_ERROR_BASE + 7,
761 NOLCK = B_POSIX_ERROR_BASE + 8,
762 NOSYS = B_POSIX_ERROR_BASE + 9,
763 NOTTY = B_POSIX_ERROR_BASE + 10,
764 NXIO = B_POSIX_ERROR_BASE + 11,
765 SPIPE = B_POSIX_ERROR_BASE + 12,
766 SRCH = B_POSIX_ERROR_BASE + 13,
767 FPOS = B_POSIX_ERROR_BASE + 14,
768 SIGPARM = B_POSIX_ERROR_BASE + 15,
769 DOM = B_POSIX_ERROR_BASE + 16,
770 RANGE = B_POSIX_ERROR_BASE + 17,
771 PROTOTYPE = B_POSIX_ERROR_BASE + 18,
772 PROTONOSUPPORT = B_POSIX_ERROR_BASE + 19,
773 PFNOSUPPORT = B_POSIX_ERROR_BASE + 20,
774 AFNOSUPPORT = B_POSIX_ERROR_BASE + 21,
775 ADDRINUSE = B_POSIX_ERROR_BASE + 22,
776 ADDRNOTAVAIL = B_POSIX_ERROR_BASE + 23,
777 NETDOWN = B_POSIX_ERROR_BASE + 24,
778 NETUNREACH = B_POSIX_ERROR_BASE + 25,
779 NETRESET = B_POSIX_ERROR_BASE + 26,
780 CONNABORTED = B_POSIX_ERROR_BASE + 27,
781 CONNRESET = B_POSIX_ERROR_BASE + 28,
782 ISCONN = B_POSIX_ERROR_BASE + 29,
783 NOTCONN = B_POSIX_ERROR_BASE + 30,
784 SHUTDOWN = B_POSIX_ERROR_BASE + 31,
785 CONNREFUSED = B_POSIX_ERROR_BASE + 32,
786 HOSTUNREACH = B_POSIX_ERROR_BASE + 33,
787 NOPROTOOPT = B_POSIX_ERROR_BASE + 34,
788 NOBUFS = B_POSIX_ERROR_BASE + 35,
789 INPROGRESS = B_POSIX_ERROR_BASE + 36,
790 ALREADY = B_POSIX_ERROR_BASE + 37,
791 ILSEQ = B_POSIX_ERROR_BASE + 38,
792 NOMSG = B_POSIX_ERROR_BASE + 39,
793 STALE = B_POSIX_ERROR_BASE + 40,
794 OVERFLOW = B_POSIX_ERROR_BASE + 41,
795 MSGSIZE = B_POSIX_ERROR_BASE + 42,
796 OPNOTSUPP = B_POSIX_ERROR_BASE + 43,
797 NOTSOCK = B_POSIX_ERROR_BASE + 44,
798 HOSTDOWN = B_POSIX_ERROR_BASE + 45,
799 BADMSG = B_POSIX_ERROR_BASE + 46,
800 CANCELED = B_POSIX_ERROR_BASE + 47,
801 DESTADDRREQ = B_POSIX_ERROR_BASE + 48,
802 DQUOT = B_POSIX_ERROR_BASE + 49,
803 IDRM = B_POSIX_ERROR_BASE + 50,
804 MULTIHOP = B_POSIX_ERROR_BASE + 51,
805 NODATA = B_POSIX_ERROR_BASE + 52,
806 NOLINK = B_POSIX_ERROR_BASE + 53,
807 NOSR = B_POSIX_ERROR_BASE + 54,
808 NOSTR = B_POSIX_ERROR_BASE + 55,
809 NOTSUP = B_POSIX_ERROR_BASE + 56,
810 PROTO = B_POSIX_ERROR_BASE + 57,
811 TIME = B_POSIX_ERROR_BASE + 58,
812 TXTBSY = B_POSIX_ERROR_BASE + 59,
813 NOATTR = B_POSIX_ERROR_BASE + 60,
814 NOTRECOVERABLE = B_POSIX_ERROR_BASE + 61,
815 OWNERDEAD = B_POSIX_ERROR_BASE + 62,
816
817 ACCES = -0x7ffffffe, // Permission denied
880818 INTR = -0x7ffffff6, // Interrupted system call
881819 IO = -0x7fffffff, // Input/output error
882 NXIO = -0x7fff8ff5, // Device not configured
883 @"2BIG" = -0x7fff8fff, // Argument list too long
884 NOEXEC = -0x7fffecfe, // Exec format error
885 CHILD = -0x7fff8ffe, // No child processes
886 DEADLK = -0x7fff8ffd, // Resource deadlock avoided
887 NOMEM = -0x80000000, // Cannot allocate memory
888 ACCES = -0x7ffffffe, // Permission denied
889 FAULT = -0x7fffecff, // Bad address
890820 BUSY = -0x7ffffff2, // Device busy
821 FAULT = -0x7fffecff, // Bad address
822 TIMEDOUT = -2147483639, // Operation timed out
823 AGAIN = -0x7ffffff5,
824 BADF = -0x7fffa000, // Bad file descriptor
891825 EXIST = -0x7fff9ffe, // File exists
892 XDEV = -0x7fff9ff5, // Cross-device link
893 NODEV = -0x7fff8ff9, // Operation not supported by device
826 INVAL = -0x7ffffffb, // Invalid argument
827 NAMETOOLONG = -2147459068, // File name too long
828 NOENT = -0x7fff9ffd, // No such file or directory
829 PERM = -0x7ffffff1, // Operation not permitted
894830 NOTDIR = -0x7fff9ffb, // Not a directory
895831 ISDIR = -0x7fff9ff7, // Is a directory
896 INVAL = -0x7ffffffb, // Invalid argument
897 NFILE = -0x7fff8ffa, // Too many open files in system
898 MFILE = -0x7fff9ff6, // Too many open files
899 NOTTY = -0x7fff8ff6, // Inappropriate ioctl for device
900 TXTBSY = -0x7fff8fc5, // Text file busy
901 FBIG = -0x7fff8ffc, // File too large
832 NOTEMPTY = -2147459066, // Directory not empty
902833 NOSPC = -0x7fff9ff9, // No space left on device
903 SPIPE = -0x7fff8ff4, // Illegal seek
904834 ROFS = -0x7fff9ff8, // Read-only filesystem
905 MLINK = -0x7fff8ffb, // Too many links
835 MFILE = -0x7fff9ff6, // Too many open files
836 XDEV = -0x7fff9ff5, // Cross-device link
837 NOEXEC = -0x7fffecfe, // Exec format error
906838 PIPE = -0x7fff9ff3, // Broken pipe
907 BADF = -0x7fffa000, // Bad file descriptor
908
909 // math software
910 DOM = 33, // Numerical argument out of domain
911 RANGE = 34, // Result too large
912
913 // non-blocking and interrupt i/o
914
915 /// Also used for `WOULDBLOCK`.
916 AGAIN = -0x7ffffff5,
917 INPROGRESS = -0x7fff8fdc,
918 ALREADY = -0x7fff8fdb,
919
920 // ipc/network software -- argument errors
921 NOTSOCK = 38, // Socket operation on non-socket
922 DESTADDRREQ = 39, // Destination address required
923 MSGSIZE = 40, // Message too long
924 PROTOTYPE = 41, // Protocol wrong type for socket
925 NOPROTOOPT = 42, // Protocol not available
926 PROTONOSUPPORT = 43, // Protocol not supported
927 SOCKTNOSUPPORT = 44, // Socket type not supported
928 /// Also used for `NOTSUP`.
929 OPNOTSUPP = 45, // Operation not supported
930 PFNOSUPPORT = 46, // Protocol family not supported
931 AFNOSUPPORT = 47, // Address family not supported by protocol family
932 ADDRINUSE = 48, // Address already in use
933 ADDRNOTAVAIL = 49, // Can't assign requested address
934
935 // ipc/network software -- operational errors
936 NETDOWN = 50, // Network is down
937 NETUNREACH = 51, // Network is unreachable
938 NETRESET = 52, // Network dropped connection on reset
939 CONNABORTED = 53, // Software caused connection abort
940 CONNRESET = 54, // Connection reset by peer
941 NOBUFS = 55, // No buffer space available
942 ISCONN = 56, // Socket is already connected
943 NOTCONN = 57, // Socket is not connected
944 SHUTDOWN = 58, // Can't send after socket shutdown
945 TOOMANYREFS = 59, // Too many references: can't splice
946 TIMEDOUT = 60, // Operation timed out
947 CONNREFUSED = 61, // Connection refused
948
949 LOOP = 62, // Too many levels of symbolic links
950 NAMETOOLONG = 63, // File name too long
951
952 // should be rearranged
953 HOSTDOWN = 64, // Host is down
954 HOSTUNREACH = 65, // No route to host
955 NOTEMPTY = 66, // Directory not empty
956
957 // quotas & mush
958 PROCLIM = 67, // Too many processes
959 USERS = 68, // Too many users
960 DQUOT = 69, // Disc quota exceeded
961
962 // Network File System
963 STALE = 70, // Stale NFS file handle
964 REMOTE = 71, // Too many levels of remote in path
965 BADRPC = 72, // RPC struct is bad
966 RPCMISMATCH = 73, // RPC version wrong
967 PROGUNAVAIL = 74, // RPC prog. not avail
968 PROGMISMATCH = 75, // Program version wrong
969 PROCUNAVAIL = 76, // Bad procedure for program
970
971 NOLCK = 77, // No locks available
972 NOSYS = 78, // Function not implemented
973
974 FTYPE = 79, // Inappropriate file type or format
975 AUTH = 80, // Authentication error
976 NEEDAUTH = 81, // Need authenticator
977 IDRM = 82, // Identifier removed
978 NOMSG = 83, // No message of desired type
979 OVERFLOW = 84, // Value too large to be stored in data type
980 CANCELED = 85, // Operation canceled
981 ILSEQ = 86, // Illegal byte sequence
982 NOATTR = 87, // Attribute not found
983
984 DOOFUS = 88, // Programming error
985
986 BADMSG = 89, // Bad message
987 MULTIHOP = 90, // Multihop attempted
988 NOLINK = 91, // Link has been severed
989 PROTO = 92, // Protocol error
990
991 NOTCAPABLE = 93, // Capabilities insufficient
992 CAPMODE = 94, // Not permitted in capability mode
993 NOTRECOVERABLE = 95, // State not recoverable
994 OWNERDEAD = 96, // Previous owner died
995
839 NOMEM = -0x80000000, // Cannot allocate memory
840 LOOP = -2147459060, // Too many levels of symbolic links
841 SUCCESS = 0,
996842 _,
997843};
998844
999pub const MINSIGSTKSZ = switch (builtin.cpu.arch) {
1000 .i386, .x86_64 => 2048,
1001 .arm, .aarch64 => 4096,
1002 else => @compileError("MINSIGSTKSZ not defined for this architecture"),
1003};
1004pub const SIGSTKSZ = MINSIGSTKSZ + 32768;
845pub const MINSIGSTKSZ = 8192;
846pub const SIGSTKSZ = 16384;
1005847
1006pub const SS_ONSTACK = 1;
1007pub const SS_DISABLE = 4;
848pub const SS_ONSTACK = 0x1;
849pub const SS_DISABLE = 0x2;
1008850
1009851pub const stack_t = extern struct {
1010852 sp: [*]u8,
......@@ -1014,16 +856,16 @@ pub const stack_t = extern struct {
1014856
1015857pub const S = struct {
1016858 pub const IFMT = 0o170000;
1017
1018 pub const IFIFO = 0o010000;
1019 pub const IFCHR = 0o020000;
1020 pub const IFDIR = 0o040000;
1021 pub const IFBLK = 0o060000;
1022 pub const IFREG = 0o100000;
1023 pub const IFLNK = 0o120000;
1024859 pub const IFSOCK = 0o140000;
1025 pub const IFWHT = 0o160000;
860 pub const IFLNK = 0o120000;
861 pub const IFREG = 0o100000;
862 pub const IFBLK = 0o060000;
863 pub const IFDIR = 0o040000;
864 pub const IFCHR = 0o020000;
865 pub const IFIFO = 0o010000;
866 pub const INDEX_DIR = 04000000000;
1026867
868 pub const IUMSK = 0o7777;
1027869 pub const ISUID = 0o4000;
1028870 pub const ISGID = 0o2000;
1029871 pub const ISVTX = 0o1000;
......@@ -1040,56 +882,47 @@ pub const S = struct {
1040882 pub const IWOTH = 0o002;
1041883 pub const IXOTH = 0o001;
1042884
1043 pub fn ISFIFO(m: u32) bool {
1044 return m & IFMT == IFIFO;
1045 }
1046
1047 pub fn ISCHR(m: u32) bool {
1048 return m & IFMT == IFCHR;
885 pub fn ISREG(m: u32) bool {
886 return m & IFMT == IFREG;
1049887 }
1050888
1051 pub fn ISDIR(m: u32) bool {
1052 return m & IFMT == IFDIR;
889 pub fn ISLNK(m: u32) bool {
890 return m & IFMT == IFLNK;
1053891 }
1054892
1055893 pub fn ISBLK(m: u32) bool {
1056894 return m & IFMT == IFBLK;
1057895 }
1058896
1059 pub fn ISREG(m: u32) bool {
1060 return m & IFMT == IFREG;
897 pub fn ISDIR(m: u32) bool {
898 return m & IFMT == IFDIR;
1061899 }
1062900
1063 pub fn ISLNK(m: u32) bool {
1064 return m & IFMT == IFLNK;
901 pub fn ISCHR(m: u32) bool {
902 return m & IFMT == IFCHR;
903 }
904
905 pub fn ISFIFO(m: u32) bool {
906 return m & IFMT == IFIFO;
1065907 }
1066908
1067909 pub fn ISSOCK(m: u32) bool {
1068910 return m & IFMT == IFSOCK;
1069911 }
1070912
1071 pub fn IWHT(m: u32) bool {
1072 return m & IFMT == IFWHT;
913 pub fn ISINDEX(m: u32) bool {
914 return m & INDEX_DIR == INDEX_DIR;
1073915 }
1074916};
1075917
1076918pub const HOST_NAME_MAX = 255;
1077919
1078920pub const AT = struct {
1079 /// Magic value that specify the use of the current working directory
1080 /// to determine the target of relative file paths in the openat() and
1081 /// similar syscalls.
1082 pub const FDCWD = -100;
1083 /// Check access using effective user and group ID
1084 pub const EACCESS = 0x0100;
1085 /// Do not follow symbolic links
1086 pub const SYMLINK_NOFOLLOW = 0x0200;
1087 /// Follow symbolic link
1088 pub const SYMLINK_FOLLOW = 0x0400;
1089 /// Remove directory instead of file
1090 pub const REMOVEDIR = 0x0800;
1091 /// Fail if not under dirfd
1092 pub const BENEATH = 0x1000;
921 pub const FDCWD = -1;
922 pub const SYMLINK_NOFOLLOW = 0x01;
923 pub const SYMLINK_FOLLOW = 0x02;
924 pub const REMOVEDIR = 0x04;
925 pub const EACCESS = 0x08;
1093926};
1094927
1095928pub const addrinfo = extern struct {
......@@ -1104,259 +937,35 @@ pub const addrinfo = extern struct {
1104937};
1105938
1106939pub const IPPROTO = struct {
1107 /// dummy for IP
1108940 pub const IP = 0;
1109 /// control message protocol
941 pub const HOPOPTS = 0;
1110942 pub const ICMP = 1;
1111 /// tcp
943 pub const IGMP = 2;
1112944 pub const TCP = 6;
1113 /// user datagram protocol
1114945 pub const UDP = 17;
1115 /// IP6 header
1116946 pub const IPV6 = 41;
1117 /// raw IP packet
1118 pub const RAW = 255;
1119 /// IP6 hop-by-hop options
1120 pub const HOPOPTS = 0;
1121 /// group mgmt protocol
1122 pub const IGMP = 2;
1123 /// gateway^2 (deprecated)
1124 pub const GGP = 3;
1125 /// IPv4 encapsulation
1126 pub const IPV4 = 4;
1127 /// for compatibility
1128 pub const IPIP = IPV4;
1129 /// Stream protocol II
1130 pub const ST = 7;
1131 /// exterior gateway protocol
1132 pub const EGP = 8;
1133 /// private interior gateway
1134 pub const PIGP = 9;
1135 /// BBN RCC Monitoring
1136 pub const RCCMON = 10;
1137 /// network voice protocol
1138 pub const NVPII = 11;
1139 /// pup
1140 pub const PUP = 12;
1141 /// Argus
1142 pub const ARGUS = 13;
1143 /// EMCON
1144 pub const EMCON = 14;
1145 /// Cross Net Debugger
1146 pub const XNET = 15;
1147 /// Chaos
1148 pub const CHAOS = 16;
1149 /// Multiplexing
1150 pub const MUX = 18;
1151 /// DCN Measurement Subsystems
1152 pub const MEAS = 19;
1153 /// Host Monitoring
1154 pub const HMP = 20;
1155 /// Packet Radio Measurement
1156 pub const PRM = 21;
1157 /// xns idp
1158 pub const IDP = 22;
1159 /// Trunk-1
1160 pub const TRUNK1 = 23;
1161 /// Trunk-2
1162 pub const TRUNK2 = 24;
1163 /// Leaf-1
1164 pub const LEAF1 = 25;
1165 /// Leaf-2
1166 pub const LEAF2 = 26;
1167 /// Reliable Data
1168 pub const RDP = 27;
1169 /// Reliable Transaction
1170 pub const IRTP = 28;
1171 /// tp-4 w/ class negotiation
1172 pub const TP = 29;
1173 /// Bulk Data Transfer
1174 pub const BLT = 30;
1175 /// Network Services
1176 pub const NSP = 31;
1177 /// Merit Internodal
1178 pub const INP = 32;
1179 /// Datagram Congestion Control Protocol
1180 pub const DCCP = 33;
1181 /// Third Party Connect
1182 pub const @"3PC" = 34;
1183 /// InterDomain Policy Routing
1184 pub const IDPR = 35;
1185 /// XTP
1186 pub const XTP = 36;
1187 /// Datagram Delivery
1188 pub const DDP = 37;
1189 /// Control Message Transport
1190 pub const CMTP = 38;
1191 /// TP++ Transport
1192 pub const TPXX = 39;
1193 /// IL transport protocol
1194 pub const IL = 40;
1195 /// Source Demand Routing
1196 pub const SDRP = 42;
1197 /// IP6 routing header
1198947 pub const ROUTING = 43;
1199 /// IP6 fragmentation header
1200948 pub const FRAGMENT = 44;
1201 /// InterDomain Routing
1202 pub const IDRP = 45;
1203 /// resource reservation
1204 pub const RSVP = 46;
1205 /// General Routing Encap.
1206 pub const GRE = 47;
1207 /// Mobile Host Routing
1208 pub const MHRP = 48;
1209 /// BHA
1210 pub const BHA = 49;
1211 /// IP6 Encap Sec. Payload
1212949 pub const ESP = 50;
1213 /// IP6 Auth Header
1214950 pub const AH = 51;
1215 /// Integ. Net Layer Security
1216 pub const INLSP = 52;
1217 /// IP with encryption
1218 pub const SWIPE = 53;
1219 /// Next Hop Resolution
1220 pub const NHRP = 54;
1221 /// IP Mobility
1222 pub const MOBILE = 55;
1223 /// Transport Layer Security
1224 pub const TLSP = 56;
1225 /// SKIP
1226 pub const SKIP = 57;
1227 /// ICMP6
1228951 pub const ICMPV6 = 58;
1229 /// IP6 no next header
1230952 pub const NONE = 59;
1231 /// IP6 destination option
1232953 pub const DSTOPTS = 60;
1233 /// any host internal protocol
1234 pub const AHIP = 61;
1235 /// CFTP
1236 pub const CFTP = 62;
1237 /// "hello" routing protocol
1238 pub const HELLO = 63;
1239 /// SATNET/Backroom EXPAK
1240 pub const SATEXPAK = 64;
1241 /// Kryptolan
1242 pub const KRYPTOLAN = 65;
1243 /// Remote Virtual Disk
1244 pub const RVD = 66;
1245 /// Pluribus Packet Core
1246 pub const IPPC = 67;
1247 /// Any distributed FS
1248 pub const ADFS = 68;
1249 /// Satnet Monitoring
1250 pub const SATMON = 69;
1251 /// VISA Protocol
1252 pub const VISA = 70;
1253 /// Packet Core Utility
1254 pub const IPCV = 71;
1255 /// Comp. Prot. Net. Executive
1256 pub const CPNX = 72;
1257 /// Comp. Prot. HeartBeat
1258 pub const CPHB = 73;
1259 /// Wang Span Network
1260 pub const WSN = 74;
1261 /// Packet Video Protocol
1262 pub const PVP = 75;
1263 /// BackRoom SATNET Monitoring
1264 pub const BRSATMON = 76;
1265 /// Sun net disk proto (temp.)
1266 pub const ND = 77;
1267 /// WIDEBAND Monitoring
1268 pub const WBMON = 78;
1269 /// WIDEBAND EXPAK
1270 pub const WBEXPAK = 79;
1271 /// ISO cnlp
1272 pub const EON = 80;
1273 /// VMTP
1274 pub const VMTP = 81;
1275 /// Secure VMTP
1276 pub const SVMTP = 82;
1277 /// Banyon VINES
1278 pub const VINES = 83;
1279 /// TTP
1280 pub const TTP = 84;
1281 /// NSFNET-IGP
1282 pub const IGP = 85;
1283 /// dissimilar gateway prot.
1284 pub const DGP = 86;
1285 /// TCF
1286 pub const TCF = 87;
1287 /// Cisco/GXS IGRP
1288 pub const IGRP = 88;
1289 /// OSPFIGP
1290 pub const OSPFIGP = 89;
1291 /// Strite RPC protocol
1292 pub const SRPC = 90;
1293 /// Locus Address Resoloution
1294 pub const LARP = 91;
1295 /// Multicast Transport
1296 pub const MTP = 92;
1297 /// AX.25 Frames
1298 pub const AX25 = 93;
1299 /// IP encapsulated in IP
1300 pub const IPEIP = 94;
1301 /// Mobile Int.ing control
1302 pub const MICP = 95;
1303 /// Semaphore Comm. security
1304 pub const SCCSP = 96;
1305 /// Ethernet IP encapsulation
1306954 pub const ETHERIP = 97;
1307 /// encapsulation header
1308 pub const ENCAP = 98;
1309 /// any private encr. scheme
1310 pub const APES = 99;
1311 /// GMTP
1312 pub const GMTP = 100;
1313 /// payload compression (IPComp)
1314 pub const IPCOMP = 108;
1315 /// SCTP
1316 pub const SCTP = 132;
1317 /// IPv6 Mobility Header
1318 pub const MH = 135;
1319 /// UDP-Lite
1320 pub const UDPLITE = 136;
1321 /// IP6 Host Identity Protocol
1322 pub const HIP = 139;
1323 /// IP6 Shim6 Protocol
1324 pub const SHIM6 = 140;
1325 /// Protocol Independent Mcast
1326 pub const PIM = 103;
1327 /// CARP
1328 pub const CARP = 112;
1329 /// PGM
1330 pub const PGM = 113;
1331 /// MPLS-in-IP
1332 pub const MPLS = 137;
1333 /// PFSYNC
1334 pub const PFSYNC = 240;
1335 /// Reserved
1336 pub const RESERVED_253 = 253;
1337 /// Reserved
1338 pub const RESERVED_254 = 254;
955 pub const RAW = 255;
956 pub const MAX = 256;
1339957};
1340958
1341959pub const rlimit_resource = enum(c_int) {
1342 CPU = 0,
1343 FSIZE = 1,
960 CORE = 0,
961 CPU = 1,
1344962 DATA = 2,
1345 STACK = 3,
1346 CORE = 4,
1347 RSS = 5,
1348 MEMLOCK = 6,
1349 NPROC = 7,
1350 NOFILE = 8,
1351 SBSIZE = 9,
1352 VMEM = 10,
1353 NPTS = 11,
1354 SWAP = 12,
1355 KQUEUES = 13,
1356 UMTXP = 14,
963 FSIZE = 3,
964 NOFILE = 4,
965 STACK = 5,
966 AS = 6,
967 NOVMON = 7,
1357968 _,
1358
1359 pub const AS: rlimit_resource = .VMEM;
1360969};
1361970
1362971pub const rlim_t = i64;
......@@ -1393,7 +1002,7 @@ pub const cc_t = u8;
13931002pub const speed_t = u8;
13941003pub const tcflag_t = u32;
13951004
1396pub const NCCS = 32;
1005pub const NCCS = 11;
13971006
13981007pub const termios = extern struct {
13991008 c_iflag: tcflag_t,
......@@ -1405,3 +1014,5 @@ pub const termios = extern struct {
14051014 c_ospeed: speed_t,
14061015 cc_t: [NCCS]cc_t,
14071016};
1017
1018pub const MSG_NOSIGNAL = 0x0800;
lib/std/crypto/tlcsprng.zig+2-1
......@@ -40,6 +40,7 @@ const maybe_have_wipe_on_fork = builtin.os.isAtLeast(.linux, .{
4040 .major = 4,
4141 .minor = 14,
4242}) orelse true;
43const is_haiku = builtin.os.tag == .haiku;
4344
4445const Context = struct {
4546 init_state: enum(u8) { uninitialized = 0, initialized, failed },
......@@ -72,7 +73,7 @@ fn tlsCsprngFill(_: *c_void, buffer: []u8) void {
7273
7374 if (wipe_mem.len == 0) {
7475 // Not initialized yet.
75 if (want_fork_safety and maybe_have_wipe_on_fork) {
76 if (want_fork_safety and maybe_have_wipe_on_fork or is_haiku) {
7677 // Allocate a per-process page, madvise operates with page
7778 // granularity.
7879 wipe_mem = os.mmap(
lib/std/fs.zig+11-1
......@@ -527,13 +527,23 @@ pub const Dir = struct {
527527 }
528528
529529 var stat_info: os.Stat = undefined;
530 _ = os.system._kern_read_stat(
530 const rc = os.system._kern_read_stat(
531531 self.dir.fd,
532532 &haiku_entry.d_name,
533533 false,
534534 &stat_info,
535535 0,
536536 );
537 if (rc != 0) {
538 switch (os.errno(rc)) {
539 .SUCCESS => {},
540 .BADF => unreachable, // Dir is invalid or was opened without iteration ability
541 .FAULT => unreachable,
542 .NOTDIR => unreachable,
543 .INVAL => unreachable,
544 else => |err| return os.unexpectedErrno(err),
545 }
546 }
537547 const statmode = stat_info.mode & os.S.IFMT;
538548
539549 const entry_kind = switch (statmode) {
src/Compilation.zig+9
......@@ -3885,6 +3885,15 @@ fn detectLibCFromLibCInstallation(arena: *Allocator, target: Target, lci: *const
38853885 list.appendAssumeCapacity(shared_dir);
38863886 }
38873887 }
3888 if (target.os.tag == .haiku) {
3889 const include_dir_path = lci.include_dir orelse return error.LibCInstallationNotAvailable;
3890 const os_dir = try std.fs.path.join(arena, &[_][]const u8{ include_dir_path, "os" });
3891 list.appendAssumeCapacity(os_dir);
3892
3893 const config_dir = try std.fs.path.join(arena, &[_][]const u8{ include_dir_path, "config" });
3894 list.appendAssumeCapacity(config_dir);
3895 }
3896
38883897 return LibCDirs{
38893898 .libc_include_dir_list = list.items,
38903899 .libc_installation = lci,
src/libc_installation.zig+1-1
......@@ -321,7 +321,7 @@ pub const LibCInstallation = struct {
321321 const sys_include_dir_example_file = if (is_windows)
322322 "sys\\types.h"
323323 else if (is_haiku)
324 "posix/errno.h"
324 "errno.h"
325325 else
326326 "sys/errno.h";
327327