1const std = @import("std");
2const linux = std.os.linux;
3const builtin = @import("builtin");
4const arch = builtin.target.cpu.arch;
5
6comptime {
7 std.debug.assert(builtin.target.os.tag == .linux);
8 std.debug.assert(@bitSizeOf(usize) == 64);
9}
10
11pub const errno = struct {
12 pub const Error = error{
13 Unexpected,
14 EPERM,
15 ENOENT,
16 ESRCH,
17 EINTR,
18 EIO,
19 ENXIO,
20 E2BIG,
21 ENOEXEC,
22 EBADF,
23 ECHILD,
24 EAGAIN,
25 ENOMEM,
26 EACCES,
27 EFAULT,
28 ENOTBLK,
29 EBUSY,
30 EEXIST,
31 EXDEV,
32 ENODEV,
33 ENOTDIR,
34 EISDIR,
35 EINVAL,
36 ENFILE,
37 EMFILE,
38 ENOTTY,
39 ETXTBSY,
40 EFBIG,
41 ENOSPC,
42 ESPIPE,
43 EROFS,
44 EMLINK,
45 EPIPE,
46 EDOM,
47 ERANGE,
48 EDEADLK,
49 ENAMETOOLONG,
50 ENOLCK,
51 ENOSYS,
52 ENOTEMPTY,
53 ELOOP,
54 ENOMSG,
55 EIDRM,
56 ECHRNG,
57 EL2NSYNC,
58 EL3HLT,
59 EL3RST,
60 ELNRNG,
61 EUNATCH,
62 ENOCSI,
63 EL2HLT,
64 EBADE,
65 EBADR,
66 EXFULL,
67 ENOANO,
68 EBADRQC,
69 EBADSLT,
70 EDEADLOCK,
71 EBFONT,
72 ENOSTR,
73 ENODATA,
74 ETIME,
75 ENOSR,
76 ENONET,
77 ENOPKG,
78 EREMOTE,
79 ENOLINK,
80 EADV,
81 ESRMNT,
82 ECOMM,
83 EPROTO,
84 EMULTIHOP,
85 EDOTDOT,
86 EBADMSG,
87 EOVERFLOW,
88 ENOTUNIQ,
89 EBADFD,
90 EREMCHG,
91 ELIBACC,
92 ELIBBAD,
93 ELIBSCN,
94 ELIBMAX,
95 ELIBEXEC,
96 EILSEQ,
97 ERESTART,
98 ESTRPIPE,
99 EUSERS,
100 ENOTSOCK,
101 EDESTADDRREQ,
102 EMSGSIZE,
103 EPROTOTYPE,
104 ENOPROTOOPT,
105 EPROTONOSUPPORT,
106 ESOCKTNOSUPPORT,
107 EOPNOTSUPP,
108 EPFNOSUPPORT,
109 EAFNOSUPPORT,
110 EADDRINUSE,
111 EADDRNOTAVAIL,
112 ENETDOWN,
113 ENETUNREACH,
114 ENETRESET,
115 ECONNABORTED,
116 ECONNRESET,
117 ENOBUFS,
118 EISCONN,
119 ENOTCONN,
120 ESHUTDOWN,
121 ETOOMANYREFS,
122 ETIMEDOUT,
123 ECONNREFUSED,
124 EHOSTDOWN,
125 EHOSTUNREACH,
126 EALREADY,
127 EINPROGRESS,
128 ESTALE,
129 EUCLEAN,
130 ENOTNAM,
131 ENAVAIL,
132 EISNAM,
133 EREMOTEIO,
134 EDQUOT,
135 ENOMEDIUM,
136 EMEDIUMTYPE,
137 ECANCELED,
138 ENOKEY,
139 EKEYEXPIRED,
140 EKEYREVOKED,
141 EKEYREJECTED,
142 EOWNERDEAD,
143 ENOTRECOVERABLE,
144 ERFKILL,
145 EHWPOISON,
146 };
147
148 pub const Enum = switch (builtin.target.cpu.arch) {
149 .arc,
150 .arceb,
151 .arm,
152 .armeb,
153 .aarch64,
154 .aarch64_be,
155 .csky,
156 .hexagon,
157 .loongarch32,
158 .loongarch64,
159 .m68k,
160 .riscv32,
161 .riscv32be,
162 .riscv64,
163 .riscv64be,
164 .s390x,
165 .sparc,
166 .sparc64,
167 .x86_16,
168 .x86,
169 .x86_64,
170 .xtensa,
171 .xtensaeb,
172 => enum(c_ushort) {
173 EPERM = 1,
174 ENOENT = 2,
175 ESRCH = 3,
176 EINTR = 4,
177 EIO = 5,
178 ENXIO = 6,
179 E2BIG = 7,
180 ENOEXEC = 8,
181 EBADF = 9,
182 ECHILD = 10,
183 EAGAIN = 11,
184 ENOMEM = 12,
185 EACCES = 13,
186 EFAULT = 14,
187 ENOTBLK = 15,
188 EBUSY = 16,
189 EEXIST = 17,
190 EXDEV = 18,
191 ENODEV = 19,
192 ENOTDIR = 20,
193 EISDIR = 21,
194 EINVAL = 22,
195 ENFILE = 23,
196 EMFILE = 24,
197 ENOTTY = 25,
198 ETXTBSY = 26,
199 EFBIG = 27,
200 ENOSPC = 28,
201 ESPIPE = 29,
202 EROFS = 30,
203 EMLINK = 31,
204 EPIPE = 32,
205 EDOM = 33,
206 ERANGE = 34,
207 EDEADLK = 35,
208 ENAMETOOLONG = 36,
209 ENOLCK = 37,
210 ENOSYS = 38,
211 ENOTEMPTY = 39,
212 ELOOP = 40,
213 //
214 ENOMSG = 42,
215 EIDRM = 43,
216 ECHRNG = 44,
217 EL2NSYNC = 45,
218 EL3HLT = 46,
219 EL3RST = 47,
220 ELNRNG = 48,
221 EUNATCH = 49,
222 ENOCSI = 50,
223 EL2HLT = 51,
224 EBADE = 52,
225 EBADR = 53,
226 EXFULL = 54,
227 ENOANO = 55,
228 EBADRQC = 56,
229 EBADSLT = 57,
230 //
231 EBFONT = 59,
232 ENOSTR = 60,
233 ENODATA = 61,
234 ETIME = 62,
235 ENOSR = 63,
236 ENONET = 64,
237 ENOPKG = 65,
238 EREMOTE = 66,
239 ENOLINK = 67,
240 EADV = 68,
241 ESRMNT = 69,
242 ECOMM = 70,
243 EPROTO = 71,
244 EMULTIHOP = 72,
245 EDOTDOT = 73,
246 EBADMSG = 74,
247 EOVERFLOW = 75,
248 ENOTUNIQ = 76,
249 EBADFD = 77,
250 EREMCHG = 78,
251 ELIBACC = 79,
252 ELIBBAD = 80,
253 ELIBSCN = 81,
254 ELIBMAX = 82,
255 ELIBEXEC = 83,
256 EILSEQ = 84,
257 ERESTART = 85,
258 ESTRPIPE = 86,
259 EUSERS = 87,
260 ENOTSOCK = 88,
261 EDESTADDRREQ = 89,
262 EMSGSIZE = 90,
263 EPROTOTYPE = 91,
264 ENOPROTOOPT = 92,
265 EPROTONOSUPPORT = 93,
266 ESOCKTNOSUPPORT = 94,
267 EOPNOTSUPP = 95,
268 EPFNOSUPPORT = 96,
269 EAFNOSUPPORT = 97,
270 EADDRINUSE = 98,
271 EADDRNOTAVAIL = 99,
272 ENETDOWN = 100,
273 ENETUNREACH = 101,
274 ENETRESET = 102,
275 ECONNABORTED = 103,
276 ECONNRESET = 104,
277 ENOBUFS = 105,
278 EISCONN = 106,
279 ENOTCONN = 107,
280 ESHUTDOWN = 108,
281 ETOOMANYREFS = 109,
282 ETIMEDOUT = 110,
283 ECONNREFUSED = 111,
284 EHOSTDOWN = 112,
285 EHOSTUNREACH = 113,
286 EALREADY = 114,
287 EINPROGRESS = 115,
288 ESTALE = 116,
289 EUCLEAN = 117,
290 ENOTNAM = 118,
291 ENAVAIL = 119,
292 EISNAM = 120,
293 EREMOTEIO = 121,
294 EDQUOT = 122,
295 ENOMEDIUM = 123,
296 EMEDIUMTYPE = 124,
297 ECANCELED = 125,
298 ENOKEY = 126,
299 EKEYEXPIRED = 127,
300 EKEYREVOKED = 128,
301 EKEYREJECTED = 129,
302 EOWNERDEAD = 130,
303 ENOTRECOVERABLE = 131,
304 ERFKILL = 132,
305 EHWPOISON = 133,
306 _,
307 pub const EWOULDBLOCK: Enum = .EAGAIN;
308 pub const EDEADLOCK: Enum = .EDEADLK;
309 pub const ENOTSUP: Enum = .EOPNOTSUPP;
310 },
311 .mips,
312 .mipsel,
313 => enum(c_ushort) {
314 EPERM = 1,
315 ENOENT = 2,
316 ESRCH = 3,
317 EINTR = 4,
318 EIO = 5,
319 ENXIO = 6,
320 E2BIG = 7,
321 ENOEXEC = 8,
322 EBADF = 9,
323 ECHILD = 10,
324 EAGAIN = 11,
325 ENOMEM = 12,
326 EACCES = 13,
327 EFAULT = 14,
328 ENOTBLK = 15,
329 EBUSY = 16,
330 EEXIST = 17,
331 EXDEV = 18,
332 ENODEV = 19,
333 ENOTDIR = 20,
334 EISDIR = 21,
335 EINVAL = 22,
336 ENFILE = 23,
337 EMFILE = 24,
338 ENOTTY = 25,
339 ETXTBSY = 26,
340 EFBIG = 27,
341 ENOSPC = 28,
342 ESPIPE = 29,
343 EROFS = 30,
344 EMLINK = 31,
345 EPIPE = 32,
346 EDOM = 33,
347 ERANGE = 34,
348 ENOMSG = 35,
349 EIDRM = 36,
350 ECHRNG = 37,
351 EL2NSYNC = 38,
352 EL3HLT = 39,
353 EL3RST = 40,
354 ELNRNG = 41,
355 EUNATCH = 42,
356 ENOCSI = 43,
357 EL2HLT = 44,
358 EDEADLK = 45,
359 ENOLCK = 46,
360 EBADE = 50,
361 EBADR = 51,
362 EXFULL = 52,
363 ENOANO = 53,
364 EBADRQC = 54,
365 EBADSLT = 55,
366 EDEADLOCK = 56,
367 EBFONT = 59,
368 ENOSTR = 60,
369 ENODATA = 61,
370 ETIME = 62,
371 ENOSR = 63,
372 ENONET = 64,
373 ENOPKG = 65,
374 EREMOTE = 66,
375 ENOLINK = 67,
376 EADV = 68,
377 ESRMNT = 69,
378 ECOMM = 70,
379 EPROTO = 71,
380 EDOTDOT = 73,
381 EMULTIHOP = 74,
382 EBADMSG = 77,
383 ENAMETOOLONG = 78,
384 EOVERFLOW = 79,
385 ENOTUNIQ = 80,
386 EBADFD = 81,
387 EREMCHG = 82,
388 ELIBACC = 83,
389 ELIBBAD = 84,
390 ELIBSCN = 85,
391 ELIBMAX = 86,
392 ELIBEXEC = 87,
393 EILSEQ = 88,
394 ENOSYS = 89,
395 ELOOP = 90,
396 ERESTART = 91,
397 ESTRPIPE = 92,
398 ENOTEMPTY = 93,
399 EUSERS = 94,
400 ENOTSOCK = 95,
401 EDESTADDRREQ = 96,
402 EMSGSIZE = 97,
403 EPROTOTYPE = 98,
404 ENOPROTOOPT = 99,
405 EPROTONOSUPPORT = 120,
406 ESOCKTNOSUPPORT = 121,
407 EOPNOTSUPP = 122,
408 EPFNOSUPPORT = 123,
409 EAFNOSUPPORT = 124,
410 EADDRINUSE = 125,
411 EADDRNOTAVAIL = 126,
412 ENETDOWN = 127,
413 ENETUNREACH = 128,
414 ENETRESET = 129,
415 ECONNABORTED = 130,
416 ECONNRESET = 131,
417 ENOBUFS = 132,
418 EISCONN = 133,
419 ENOTCONN = 134,
420 EUCLEAN = 135,
421 ENOTNAM = 137,
422 ENAVAIL = 138,
423 EISNAM = 139,
424 EREMOTEIO = 140,
425 ESHUTDOWN = 143,
426 ETOOMANYREFS = 144,
427 ETIMEDOUT = 145,
428 ECONNREFUSED = 146,
429 EHOSTDOWN = 147,
430 EHOSTUNREACH = 148,
431 EALREADY = 149,
432 EINPROGRESS = 150,
433 ESTALE = 151,
434 ECANCELED = 158,
435 ENOMEDIUM = 159,
436 EMEDIUMTYPE = 160,
437 ENOKEY = 161,
438 EKEYEXPIRED = 162,
439 EKEYREVOKED = 163,
440 EKEYREJECTED = 164,
441 EOWNERDEAD = 165,
442 ENOTRECOVERABLE = 166,
443 ERFKILL = 167,
444 EHWPOISON = 168,
445 EDQUOT = 1133,
446 _,
447 pub const ENOTSUP: Enum = .EOPNOTSUPP;
448 pub const EWOULDBLOCK: Enum = .EAGAIN;
449 },
450 .mips64,
451 .mips64el,
452 => enum(c_ushort) {
453 EPERM = 1,
454 ENOENT = 2,
455 ESRCH = 3,
456 EINTR = 4,
457 EIO = 5,
458 ENXIO = 6,
459 E2BIG = 7,
460 ENOEXEC = 8,
461 EBADF = 9,
462 ECHILD = 10,
463 EAGAIN = 11,
464 ENOMEM = 12,
465 EACCES = 13,
466 EFAULT = 14,
467 ENOTBLK = 15,
468 EBUSY = 16,
469 EEXIST = 17,
470 EXDEV = 18,
471 ENODEV = 19,
472 ENOTDIR = 20,
473 EISDIR = 21,
474 EINVAL = 22,
475 ENFILE = 23,
476 EMFILE = 24,
477 ENOTTY = 25,
478 ETXTBSY = 26,
479 EFBIG = 27,
480 ENOSPC = 28,
481 ESPIPE = 29,
482 EROFS = 30,
483 EMLINK = 31,
484 EPIPE = 32,
485 EDOM = 33,
486 ERANGE = 34,
487 ENOMSG = 35,
488 EIDRM = 36,
489 ECHRNG = 37,
490 EL2NSYNC = 38,
491 EL3HLT = 39,
492 EL3RST = 40,
493 ELNRNG = 41,
494 EUNATCH = 42,
495 ENOCSI = 43,
496 EL2HLT = 44,
497 EDEADLK = 45,
498 ENOLCK = 46,
499 EBADE = 50,
500 EBADR = 51,
501 EXFULL = 52,
502 ENOANO = 53,
503 EBADRQC = 54,
504 EBADSLT = 55,
505 EDEADLOCK = 56,
506 EBFONT = 59,
507 ENOSTR = 60,
508 ENODATA = 61,
509 ETIME = 62,
510 ENOSR = 63,
511 ENONET = 64,
512 ENOPKG = 65,
513 EREMOTE = 66,
514 ENOLINK = 67,
515 EADV = 68,
516 ESRMNT = 69,
517 ECOMM = 70,
518 EPROTO = 71,
519 EDOTDOT = 73,
520 EMULTIHOP = 74,
521 EBADMSG = 77,
522 ENAMETOOLONG = 78,
523 EOVERFLOW = 79,
524 ENOTUNIQ = 80,
525 EBADFD = 81,
526 EREMCHG = 82,
527 ELIBACC = 83,
528 ELIBBAD = 84,
529 ELIBSCN = 85,
530 ELIBMAX = 86,
531 ELIBEXEC = 87,
532 EILSEQ = 88,
533 ENOSYS = 89,
534 ELOOP = 90,
535 ERESTART = 91,
536 ESTRPIPE = 92,
537 ENOTEMPTY = 93,
538 EUSERS = 94,
539 ENOTSOCK = 95,
540 EDESTADDRREQ = 96,
541 EMSGSIZE = 97,
542 EPROTOTYPE = 98,
543 ENOPROTOOPT = 99,
544 EPROTONOSUPPORT = 120,
545 ESOCKTNOSUPPORT = 121,
546 EOPNOTSUPP = 122,
547 EPFNOSUPPORT = 123,
548 EAFNOSUPPORT = 124,
549 EADDRINUSE = 125,
550 EADDRNOTAVAIL = 126,
551 ENETDOWN = 127,
552 ENETUNREACH = 128,
553 ENETRESET = 129,
554 ECONNABORTED = 130,
555 ECONNRESET = 131,
556 ENOBUFS = 132,
557 EISCONN = 133,
558 ENOTCONN = 134,
559 EUCLEAN = 135,
560 ENOTNAM = 137,
561 ENAVAIL = 138,
562 EISNAM = 139,
563 EREMOTEIO = 140,
564 ESHUTDOWN = 143,
565 ETOOMANYREFS = 144,
566 ETIMEDOUT = 145,
567 ECONNREFUSED = 146,
568 EHOSTDOWN = 147,
569 EHOSTUNREACH = 148,
570 EALREADY = 149,
571 EINPROGRESS = 150,
572 ESTALE = 151,
573 ECANCELED = 158,
574 ENOMEDIUM = 159,
575 EMEDIUMTYPE = 160,
576 ENOKEY = 161,
577 EKEYEXPIRED = 162,
578 EKEYREVOKED = 163,
579 EKEYREJECTED = 164,
580 EOWNERDEAD = 165,
581 ENOTRECOVERABLE = 166,
582 ERFKILL = 167,
583 EHWPOISON = 168,
584 EDQUOT = 1133,
585 _,
586 pub const ENOTSUP: Enum = .EOPNOTSUPP;
587 pub const EWOULDBLOCK: Enum = .EAGAIN;
588 },
589 .powerpc,
590 .powerpcle,
591 => enum(c_ushort) {
592 EPERM = 1,
593 ENOENT = 2,
594 ESRCH = 3,
595 EINTR = 4,
596 EIO = 5,
597 ENXIO = 6,
598 E2BIG = 7,
599 ENOEXEC = 8,
600 EBADF = 9,
601 ECHILD = 10,
602 EAGAIN = 11,
603 ENOMEM = 12,
604 EACCES = 13,
605 EFAULT = 14,
606 ENOTBLK = 15,
607 EBUSY = 16,
608 EEXIST = 17,
609 EXDEV = 18,
610 ENODEV = 19,
611 ENOTDIR = 20,
612 EISDIR = 21,
613 EINVAL = 22,
614 ENFILE = 23,
615 EMFILE = 24,
616 ENOTTY = 25,
617 ETXTBSY = 26,
618 EFBIG = 27,
619 ENOSPC = 28,
620 ESPIPE = 29,
621 EROFS = 30,
622 EMLINK = 31,
623 EPIPE = 32,
624 EDOM = 33,
625 ERANGE = 34,
626 EDEADLK = 35,
627 ENAMETOOLONG = 36,
628 ENOLCK = 37,
629 ENOSYS = 38,
630 ENOTEMPTY = 39,
631 ELOOP = 40,
632 ENOMSG = 42,
633 EIDRM = 43,
634 ECHRNG = 44,
635 EL2NSYNC = 45,
636 EL3HLT = 46,
637 EL3RST = 47,
638 ELNRNG = 48,
639 EUNATCH = 49,
640 ENOCSI = 50,
641 EL2HLT = 51,
642 EBADE = 52,
643 EBADR = 53,
644 EXFULL = 54,
645 ENOANO = 55,
646 EBADRQC = 56,
647 EBADSLT = 57,
648 EDEADLOCK = 58,
649 EBFONT = 59,
650 ENOSTR = 60,
651 ENODATA = 61,
652 ETIME = 62,
653 ENOSR = 63,
654 ENONET = 64,
655 ENOPKG = 65,
656 EREMOTE = 66,
657 ENOLINK = 67,
658 EADV = 68,
659 ESRMNT = 69,
660 ECOMM = 70,
661 EPROTO = 71,
662 EMULTIHOP = 72,
663 EDOTDOT = 73,
664 EBADMSG = 74,
665 EOVERFLOW = 75,
666 ENOTUNIQ = 76,
667 EBADFD = 77,
668 EREMCHG = 78,
669 ELIBACC = 79,
670 ELIBBAD = 80,
671 ELIBSCN = 81,
672 ELIBMAX = 82,
673 ELIBEXEC = 83,
674 EILSEQ = 84,
675 ERESTART = 85,
676 ESTRPIPE = 86,
677 EUSERS = 87,
678 ENOTSOCK = 88,
679 EDESTADDRREQ = 89,
680 EMSGSIZE = 90,
681 EPROTOTYPE = 91,
682 ENOPROTOOPT = 92,
683 EPROTONOSUPPORT = 93,
684 ESOCKTNOSUPPORT = 94,
685 EOPNOTSUPP = 95,
686 EPFNOSUPPORT = 96,
687 EAFNOSUPPORT = 97,
688 EADDRINUSE = 98,
689 EADDRNOTAVAIL = 99,
690 ENETDOWN = 100,
691 ENETUNREACH = 101,
692 ENETRESET = 102,
693 ECONNABORTED = 103,
694 ECONNRESET = 104,
695 ENOBUFS = 105,
696 EISCONN = 106,
697 ENOTCONN = 107,
698 ESHUTDOWN = 108,
699 ETOOMANYREFS = 109,
700 ETIMEDOUT = 110,
701 ECONNREFUSED = 111,
702 EHOSTDOWN = 112,
703 EHOSTUNREACH = 113,
704 EALREADY = 114,
705 EINPROGRESS = 115,
706 ESTALE = 116,
707 EUCLEAN = 117,
708 ENOTNAM = 118,
709 ENAVAIL = 119,
710 EISNAM = 120,
711 EREMOTEIO = 121,
712 EDQUOT = 122,
713 ENOMEDIUM = 123,
714 EMEDIUMTYPE = 124,
715 ECANCELED = 125,
716 ENOKEY = 126,
717 EKEYEXPIRED = 127,
718 EKEYREVOKED = 128,
719 EKEYREJECTED = 129,
720 EOWNERDEAD = 130,
721 ENOTRECOVERABLE = 131,
722 ERFKILL = 132,
723 EHWPOISON = 133,
724 _,
725 pub const EWOULDBLOCK: Enum = .EAGAIN;
726 pub const ENOTSUP: Enum = .EOPNOTSUPP;
727 },
728 .powerpc64,
729 .powerpc64le,
730 => enum(c_ushort) {
731 EPERM = 1,
732 ENOENT = 2,
733 ESRCH = 3,
734 EINTR = 4,
735 EIO = 5,
736 ENXIO = 6,
737 E2BIG = 7,
738 ENOEXEC = 8,
739 EBADF = 9,
740 ECHILD = 10,
741 EAGAIN = 11,
742 ENOMEM = 12,
743 EACCES = 13,
744 EFAULT = 14,
745 ENOTBLK = 15,
746 EBUSY = 16,
747 EEXIST = 17,
748 EXDEV = 18,
749 ENODEV = 19,
750 ENOTDIR = 20,
751 EISDIR = 21,
752 EINVAL = 22,
753 ENFILE = 23,
754 EMFILE = 24,
755 ENOTTY = 25,
756 ETXTBSY = 26,
757 EFBIG = 27,
758 ENOSPC = 28,
759 ESPIPE = 29,
760 EROFS = 30,
761 EMLINK = 31,
762 EPIPE = 32,
763 EDOM = 33,
764 ERANGE = 34,
765 EDEADLK = 35,
766 ENAMETOOLONG = 36,
767 ENOLCK = 37,
768 ENOSYS = 38,
769 ENOTEMPTY = 39,
770 ELOOP = 40,
771 ENOMSG = 42,
772 EIDRM = 43,
773 ECHRNG = 44,
774 EL2NSYNC = 45,
775 EL3HLT = 46,
776 EL3RST = 47,
777 ELNRNG = 48,
778 EUNATCH = 49,
779 ENOCSI = 50,
780 EL2HLT = 51,
781 EBADE = 52,
782 EBADR = 53,
783 EXFULL = 54,
784 ENOANO = 55,
785 EBADRQC = 56,
786 EBADSLT = 57,
787 EDEADLOCK = 58,
788 EBFONT = 59,
789 ENOSTR = 60,
790 ENODATA = 61,
791 ETIME = 62,
792 ENOSR = 63,
793 ENONET = 64,
794 ENOPKG = 65,
795 EREMOTE = 66,
796 ENOLINK = 67,
797 EADV = 68,
798 ESRMNT = 69,
799 ECOMM = 70,
800 EPROTO = 71,
801 EMULTIHOP = 72,
802 EDOTDOT = 73,
803 EBADMSG = 74,
804 EOVERFLOW = 75,
805 ENOTUNIQ = 76,
806 EBADFD = 77,
807 EREMCHG = 78,
808 ELIBACC = 79,
809 ELIBBAD = 80,
810 ELIBSCN = 81,
811 ELIBMAX = 82,
812 ELIBEXEC = 83,
813 EILSEQ = 84,
814 ERESTART = 85,
815 ESTRPIPE = 86,
816 EUSERS = 87,
817 ENOTSOCK = 88,
818 EDESTADDRREQ = 89,
819 EMSGSIZE = 90,
820 EPROTOTYPE = 91,
821 ENOPROTOOPT = 92,
822 EPROTONOSUPPORT = 93,
823 ESOCKTNOSUPPORT = 94,
824 EOPNOTSUPP = 95,
825 EPFNOSUPPORT = 96,
826 EAFNOSUPPORT = 97,
827 EADDRINUSE = 98,
828 EADDRNOTAVAIL = 99,
829 ENETDOWN = 100,
830 ENETUNREACH = 101,
831 ENETRESET = 102,
832 ECONNABORTED = 103,
833 ECONNRESET = 104,
834 ENOBUFS = 105,
835 EISCONN = 106,
836 ENOTCONN = 107,
837 ESHUTDOWN = 108,
838 ETOOMANYREFS = 109,
839 ETIMEDOUT = 110,
840 ECONNREFUSED = 111,
841 EHOSTDOWN = 112,
842 EHOSTUNREACH = 113,
843 EALREADY = 114,
844 EINPROGRESS = 115,
845 ESTALE = 116,
846 EUCLEAN = 117,
847 ENOTNAM = 118,
848 ENAVAIL = 119,
849 EISNAM = 120,
850 EREMOTEIO = 121,
851 EDQUOT = 122,
852 ENOMEDIUM = 123,
853 EMEDIUMTYPE = 124,
854 ECANCELED = 125,
855 ENOKEY = 126,
856 EKEYEXPIRED = 127,
857 EKEYREVOKED = 128,
858 EKEYREJECTED = 129,
859 EOWNERDEAD = 130,
860 ENOTRECOVERABLE = 131,
861 ERFKILL = 132,
862 EHWPOISON = 133,
863 _,
864 pub const EWOULDBLOCK: Enum = .EAGAIN;
865 pub const ENOTSUP: Enum = .EOPNOTSUPP;
866 },
867 .alpha => unreachable,
868 .microblaze, .microblazeel => unreachable,
869 .sh, .sheb => unreachable,
870 // nios2
871 // openrisc
872 // parisc
873 // um
874 // @compileError("TODO: " ++ @tagName(v)),
875 .avr,
876 .bpfel,
877 .bpfeb,
878 .msp430,
879 .amdgcn,
880 .thumb,
881 .thumbeb,
882 .propeller,
883 .xcore,
884 .nvptx,
885 .nvptx64,
886 .spirv32,
887 .spirv64,
888 .kalimba,
889 .lanai,
890 .wasm32,
891 .wasm64,
892 .ve,
893 .or1k,
894 .hppa,
895 .hppa64,
896 .kvx,
897 .ez80,
898 .m88k,
899 .spork8,
900 => unreachable,
901 };
902
903 pub fn byName(name: []const u8) ?Error {
904 inline for (comptime std.meta.fieldNames(Error)) |field_name| {
905 if (std.mem.eql(u8, name, field_name)) {
906 return @field(Error, field_name);
907 }
908 }
909 return null;
910 }
911
912 comptime {
913 // assert Enum is sequential
914 var value: c_ushort = 0; // SUCCESS
915 for (std.enums.values(Enum)) |val| {
916 std.debug.assert(@backingInt(val) > value);
917 value = @backingInt(val);
918 }
919 }
920 comptime {
921 // sanity test
922 std.debug.assert(@backingInt(Enum.EPERM) == 1);
923 }
924 const list = blk: {
925 const values = std.enums.values(Enum);
926 const len = @backingInt(values[values.len - 1]) + 1;
927 var errors: [len]Error = @splat(error.Unexpected);
928 for (values) |f| errors[@backingInt(f)] = @field(Error, @tagName(f));
929 const final = errors;
930 break :blk final;
931 };
932
933 pub fn fromInt(code: c_int) Error {
934 @setRuntimeSafety(false);
935 if (code >= list.len) return error.Unexpected;
936 if (code <= 0) return error.Unexpected;
937 return list[@intCast(code)];
938 }
939
940 pub fn fromLibC() c_int {
941 return libc.__errno_location().*;
942 }
943};
944
945pub const eai = struct {
946 pub const Error = error{
947 EAI_BADFLAGS,
948 EAI_NONAME,
949 EAI_AGAIN,
950 EAI_FAIL,
951 EAI_NODATA,
952 EAI_FAMILY,
953 EAI_SOCKTYPE,
954 EAI_SERVICE,
955 EAI_MEMORY,
956 EAI_SYSTEM,
957 EAI_OVERFLOW,
958 };
959
960 pub const Enum = enum(c_int) {
961 EAI_BADFLAGS = -1,
962 EAI_NONAME = -2,
963 EAI_AGAIN = -3,
964 EAI_FAIL = -4,
965 EAI_NODATA = -5,
966 EAI_FAMILY = -6,
967 EAI_SOCKTYPE = -7,
968 EAI_SERVICE = -8,
969 EAI_MEMORY = -10,
970 EAI_SYSTEM = -11,
971 EAI_OVERFLOW = -12,
972 };
973
974 pub fn fromInt(code: c_int) Error {
975 return switch (@as(Enum, @fromBackingInt(@intCast(code)))) {
976 .EAI_BADFLAGS => error.EAI_BADFLAGS,
977 .EAI_NONAME => error.EAI_NONAME,
978 .EAI_AGAIN => error.EAI_AGAIN,
979 .EAI_FAIL => error.EAI_FAIL,
980 .EAI_NODATA => error.EAI_NODATA,
981 .EAI_FAMILY => error.EAI_FAMILY,
982 .EAI_SOCKTYPE => error.EAI_SOCKTYPE,
983 .EAI_SERVICE => error.EAI_SERVICE,
984 .EAI_MEMORY => error.EAI_MEMORY,
985 .EAI_SYSTEM => error.EAI_SYSTEM,
986 .EAI_OVERFLOW => error.EAI_OVERFLOW,
987 };
988 }
989};
990
991pub const libc = struct {
992 /// void _Exit(int status);
993 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/_Exit.html
994 pub extern fn _Exit(status: c_int) noreturn;
995
996 /// void _exit(int status);
997 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/_exit.html
998 pub extern fn _exit(status: c_int) noreturn;
999
1000 /// long a64l(const char *s);
1001 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/a64l.html
1002 pub extern fn a64l(s: [*]const u8) c_long;
1003
1004 /// void abort(void);
1005 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/abort.html
1006 pub extern fn abort() void;
1007
1008 /// int abs(int i);
1009 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/abs.html
1010 pub extern fn abs(i: c_int) c_int;
1011
1012 /// int accept(int socket, struct sockaddr *restrict address, socklen_t *restrict address_len);
1013 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/accept.html
1014 pub extern fn accept(socket: c_int, noalias address: ?*struct_sockaddr, noalias address_len: *socklen_t) c_int;
1015
1016 /// int access(const char *path, int amode);
1017 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/access.html
1018 pub extern fn access(path: [*:0]const u8, amode: c_int) c_int;
1019
1020 /// double acos(double x);
1021 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/acos.html
1022 pub extern fn acos(x: f64) f64;
1023
1024 /// float acosf(float x);
1025 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/acosf.html
1026 pub extern fn acosf(x: f32) f32;
1027
1028 /// double acosh(double x);
1029 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/acosh.html
1030 pub extern fn acosh(x: f64) f64;
1031
1032 /// float acoshf(float x);
1033 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/acoshf.html
1034 pub extern fn acoshf(x: f32) f32;
1035
1036 /// long double acoshl(long double x);
1037 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/acoshl.html
1038 pub extern fn acoshl(x: c_longdouble) c_longdouble;
1039
1040 /// long double acosl(long double x);
1041 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/acosl.html
1042 pub extern fn acosl(x: c_longdouble) c_longdouble;
1043
1044 /// unsigned alarm(unsigned seconds);
1045 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/alarm.html
1046 pub extern fn alarm(seconds: c_uint) c_uint;
1047
1048 /// double asin(double x);
1049 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/asin.html
1050 pub extern fn asin(x: f64) f64;
1051
1052 /// float asinf(float x);
1053 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/asinf.html
1054 pub extern fn asinf(x: f32) f32;
1055
1056 /// double asinh(double x);
1057 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/asinh.html
1058 pub extern fn asinh(x: f64) f64;
1059
1060 /// float asinhf(float x);
1061 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/asinhf.html
1062 pub extern fn asinhf(x: f32) f32;
1063
1064 /// long double asinhl(long double x);
1065 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/asinhl.html
1066 pub extern fn asinhl(x: c_longdouble) c_longdouble;
1067
1068 /// long double asinl(long double x);
1069 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/asinl.html
1070 pub extern fn asinl(x: c_longdouble) c_longdouble;
1071
1072 /// double atan(double x);
1073 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/atan.html
1074 pub extern fn atan(x: f64) f64;
1075
1076 /// double atan2(double y, double x);
1077 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/atan2.html
1078 pub extern fn atan2(y: f64, x: f64) f64;
1079
1080 /// float atan2f(float y, float x);
1081 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/atan2f.html
1082 pub extern fn atan2f(y: f32, x: f32) f32;
1083
1084 /// long double atan2l(long double y, long double x);
1085 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/atan2l.html
1086 pub extern fn atan2l(y: c_longdouble, x: c_longdouble) c_longdouble;
1087
1088 /// float atanf(float x);
1089 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/atanf.html
1090 pub extern fn atanf(x: f32) f32;
1091
1092 /// double atanh(double x);
1093 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/atanh.html
1094 pub extern fn atanh(x: f64) f64;
1095
1096 /// float atanhf(float x);
1097 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/atanhf.html
1098 pub extern fn atanhf(x: f32) f32;
1099
1100 /// long double atanhl(long double x);
1101 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/atanhl.html
1102 pub extern fn atanhl(x: c_longdouble) c_longdouble;
1103
1104 /// long double atanl(long double x);
1105 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/atanl.html
1106 pub extern fn atanl(x: c_longdouble) c_longdouble;
1107
1108 /// int bind(int socket, const struct sockaddr *address, socklen_t address_len);
1109 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/bind.html
1110 pub extern fn bind(socket: c_int, address: *const struct_sockaddr, address_len: socklen_t) c_int;
1111
1112 /// double cbrt(double x);
1113 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/cbrt.html
1114 pub extern fn cbrt(x: f64) f64;
1115
1116 /// float cbrtf(float x);
1117 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/cbrtf.html
1118 pub extern fn cbrtf(x: f32) f32;
1119
1120 /// long double cbrtl(long double x);
1121 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/cbrtl.html
1122 pub extern fn cbrtl(x: c_longdouble) c_longdouble;
1123
1124 /// double ceil(double x);
1125 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/ceil.html
1126 pub extern fn ceil(x: f64) f64;
1127
1128 /// float ceilf(float x);
1129 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/ceilf.html
1130 pub extern fn ceilf(x: f32) f32;
1131
1132 /// long double ceill(long double x);
1133 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/ceill.html
1134 pub extern fn ceill(x: c_longdouble) c_longdouble;
1135
1136 /// int chdir(const char *path);
1137 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/chdir.html
1138 pub extern fn chdir(path: [*:0]const u8) c_int;
1139
1140 /// int chmod(const char *path, mode_t mode);
1141 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/chmod.html
1142 pub extern fn chmod(path: [*:0]const u8, mode: mode_t) c_int;
1143
1144 /// int chown(const char *path, uid_t owner, gid_t group);
1145 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/chown.html
1146 pub extern fn chown(path: [*:0]const u8, owner: uid_t, group: gid_t) c_int;
1147
1148 /// clock_t clock(void);
1149 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/clock.html
1150 pub extern fn clock() clock_t;
1151
1152 /// int clock_getcpuclockid(pid_t pid, clockid_t *clock_id);
1153 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/clock_getcpuclockid.html
1154 pub extern fn clock_getcpuclockid(pid: pid_t, clock_id: *clockid_t) c_int;
1155
1156 /// int clock_getres(clockid_t clock_id, struct timespec *res);
1157 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/clock_getres.html
1158 pub extern fn clock_getres(clock_id: clockid_t, res: ?*struct_timespec) c_int;
1159
1160 /// int clock_gettime(clockid_t clock_id, struct timespec *tp);
1161 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/clock_gettime.html
1162 pub extern fn clock_gettime(clock_id: clockid_t, tp: *struct_timespec) c_int;
1163
1164 /// int close(int fildes);
1165 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/close.html
1166 pub extern fn close(fildes: c_int) c_int;
1167
1168 /// void closelog(void);
1169 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/closelog.html
1170 pub extern fn closelog() void;
1171
1172 /// int connect(int socket, const struct sockaddr *address, socklen_t address_len);
1173 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/connect.html
1174 pub extern fn connect(socket: c_int, address: *const struct_sockaddr, address_len: socklen_t) c_int;
1175
1176 /// double copysign(double x, double y);
1177 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/copysign.html
1178 pub extern fn copysign(x: f64, y: f64) f64;
1179
1180 /// float copysignf(float x, float y);
1181 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/copysignf.html
1182 pub extern fn copysignf(x: f32, y: f32) f32;
1183
1184 /// long double copysignl(long double x, long double y);
1185 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/copysignl.html
1186 pub extern fn copysignl(x: c_longdouble, y: c_longdouble) c_longdouble;
1187
1188 /// double cos(double x);
1189 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/cos.html
1190 pub extern fn cos(x: f64) f64;
1191
1192 /// float cosf(float x);
1193 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/cosf.html
1194 pub extern fn cosf(x: f32) f32;
1195
1196 /// double cosh(double x);
1197 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/cosh.html
1198 pub extern fn cosh(x: f64) f64;
1199
1200 /// float coshf(float x);
1201 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/coshf.html
1202 pub extern fn coshf(x: f32) f32;
1203
1204 /// long double coshl(long double x);
1205 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/coshl.html
1206 pub extern fn coshl(x: c_longdouble) c_longdouble;
1207
1208 /// long double cosl(long double x);
1209 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/cosl.html
1210 pub extern fn cosl(x: c_longdouble) c_longdouble;
1211
1212 /// div_t div(int numer, int denom);
1213 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/div.html
1214 pub extern fn div(numer: c_int, denom: c_int) div_t;
1215
1216 /// char *dlerror(void);
1217 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/dlerror.html
1218 pub extern fn dlerror() ?[*:0]u8;
1219
1220 /// double drand48(void);
1221 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/drand48.html
1222 pub extern fn drand48() f64;
1223
1224 /// int dup(int fildes);
1225 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/dup.html
1226 pub extern fn dup(fildes: c_int) c_int;
1227
1228 /// int dup2(int fildes, int fildes2);
1229 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/dup2.html
1230 pub extern fn dup2(fildes: c_int, fildes2: c_int) c_int;
1231
1232 /// void endgrent(void);
1233 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/endgrent.html
1234 pub extern fn endgrent() void;
1235
1236 /// void endhostent(void);
1237 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/endhostent.html
1238 pub extern fn endhostent() void;
1239
1240 /// void endnetent(void);
1241 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/endnetent.html
1242 pub extern fn endnetent() void;
1243
1244 /// void endprotoent(void);
1245 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/endprotoent.html
1246 pub extern fn endprotoent() void;
1247
1248 /// void endpwent(void);
1249 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/endpwent.html
1250 pub extern fn endpwent() void;
1251
1252 /// void endservent(void);
1253 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/endservent.html
1254 pub extern fn endservent() void;
1255
1256 /// void endutxent(void);
1257 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/endutxent.html
1258 pub extern fn endutxent() void;
1259
1260 /// double erand48(unsigned short xsubi[3]);
1261 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/erand48.html
1262 pub extern fn erand48(xsubi: *[3]c_ushort) f64;
1263
1264 /// double erf(double x);
1265 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/erf.html
1266 pub extern fn erf(x: f64) f64;
1267
1268 /// double erfc(double x);
1269 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/erfc.html
1270 pub extern fn erfc(x: f64) f64;
1271
1272 /// float erfcf(float x);
1273 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/erfcf.html
1274 pub extern fn erfcf(x: f32) f32;
1275
1276 /// long double erfcl(long double x);
1277 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/erfcl.html
1278 pub extern fn erfcl(x: c_longdouble) c_longdouble;
1279
1280 /// float erff(float x);
1281 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/erff.html
1282 pub extern fn erff(x: f32) f32;
1283
1284 /// long double erfl(long double x);
1285 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/erfl.html
1286 pub extern fn erfl(x: c_longdouble) c_longdouble;
1287
1288 /// int execvp(const char *file, char *const argv[]);
1289 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/execvp.html
1290 pub extern fn execvp(file: [*:0]const u8, argv: [*:null]const ?[*:0]const u8) c_int;
1291
1292 /// void exit(int status);
1293 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/exit.html
1294 pub extern fn exit(status: c_int) noreturn;
1295
1296 /// double exp(double x);
1297 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/exp.html
1298 pub extern fn exp(x: f64) f64;
1299
1300 /// double exp2(double x);
1301 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/exp2.html
1302 pub extern fn exp2(x: f64) f64;
1303
1304 /// float exp2f(float x);
1305 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/exp2f.html
1306 pub extern fn exp2f(x: f32) f32;
1307
1308 /// long double exp2l(long double x);
1309 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/exp2l.html
1310 pub extern fn exp2l(x: c_longdouble) c_longdouble;
1311
1312 /// float expf(float x);
1313 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/expf.html
1314 pub extern fn expf(x: f32) f32;
1315
1316 /// long double expl(long double x);
1317 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/expl.html
1318 pub extern fn expl(x: c_longdouble) c_longdouble;
1319
1320 /// double expm1(double x);
1321 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/expm1.html
1322 pub extern fn expm1(x: f64) f64;
1323
1324 /// float expm1f(float x);
1325 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/expm1f.html
1326 pub extern fn expm1f(x: f32) f32;
1327
1328 /// long double expm1l(long double x);
1329 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/expm1l.html
1330 pub extern fn expm1l(x: c_longdouble) c_longdouble;
1331
1332 /// double fabs(double x);
1333 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/fabs.html
1334 pub extern fn fabs(x: f64) f64;
1335
1336 /// float fabsf(float x);
1337 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/fabsf.html
1338 pub extern fn fabsf(x: f32) f32;
1339
1340 /// long double fabsl(long double x);
1341 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/fabsl.html
1342 pub extern fn fabsl(x: c_longdouble) c_longdouble;
1343
1344 /// int faccessat(int fd, const char *path, int amode, int flag);
1345 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/faccessat.html
1346 pub extern fn faccessat(fd: c_int, path: [*:0]const u8, amode: c_int, flag: c_int) c_int;
1347
1348 /// int fchdir(int fildes);
1349 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/fchdir.html
1350 pub extern fn fchdir(fildes: c_int) c_int;
1351
1352 /// int fchmod(int fildes, mode_t mode);
1353 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/fchmod.html
1354 pub extern fn fchmod(fildes: c_int, mode: mode_t) c_int;
1355
1356 /// int fchmodat(int fd, const char *path, mode_t mode, int flag);
1357 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/fchmodat.html
1358 pub extern fn fchmodat(fd: c_int, path: [*:0]const u8, mode: mode_t, flag: c_int) c_int;
1359
1360 /// int fchown(int fildes, uid_t owner, gid_t group);
1361 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/fchown.html
1362 pub extern fn fchown(fildes: c_int, owner: uid_t, group: gid_t) c_int;
1363
1364 /// int fchownat(int fd, const char *path, uid_t owner, gid_t group, int flag);
1365 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/fchownat.html
1366 pub extern fn fchownat(fd: c_int, path: [*:0]const u8, owner: uid_t, group: gid_t, flag: c_int) c_int;
1367
1368 /// int fdatasync(int fildes);
1369 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/fdatasync.html
1370 pub extern fn fdatasync(fildes: c_int) c_int;
1371
1372 /// double fdim(double x, double y);
1373 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/fdim.html
1374 pub extern fn fdim(x: f64, y: f64) f64;
1375
1376 /// float fdimf(float x, float y);
1377 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/fdimf.html
1378 pub extern fn fdimf(x: f32, y: f32) f32;
1379
1380 /// long double fdiml(long double x, long double y);
1381 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/fdiml.html
1382 pub extern fn fdiml(x: c_longdouble, y: c_longdouble) c_longdouble;
1383
1384 /// int fegetround(void);
1385 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/fegetround.html
1386 pub extern fn fegetround() c_int;
1387
1388 /// int fesetround(int round);
1389 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/fesetround.html
1390 pub extern fn fesetround(round: c_int) c_int;
1391
1392 /// int fetestexcept(int excepts);
1393 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/fetestexcept.html
1394 pub extern fn fetestexcept(excepts: c_int) c_int;
1395
1396 /// int ffs(int i);
1397 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/ffs.html
1398 pub extern fn ffs(i: c_int) c_int;
1399
1400 /// double floor(double x);
1401 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/floor.html
1402 pub extern fn floor(x: f64) f64;
1403
1404 /// float floorf(float x);
1405 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/floorf.html
1406 pub extern fn floorf(x: f32) f32;
1407
1408 /// long double floorl(long double x);
1409 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/floorl.html
1410 pub extern fn floorl(x: c_longdouble) c_longdouble;
1411
1412 /// double fma(double x, double y, double z);
1413 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/fma.html
1414 pub extern fn fma(x: f64, y: f64, z: f64) f64;
1415
1416 /// float fmaf(float x, float y, float z);
1417 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/fmaf.html
1418 pub extern fn fmaf(x: f32, y: f32, z: f32) f32;
1419
1420 /// long double fmal(long double x, long double y, long double z);
1421 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/fmal.html
1422 pub extern fn fmal(x: c_longdouble, y: c_longdouble, z: c_longdouble) c_longdouble;
1423
1424 /// double fmax(double x, double y);
1425 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/fmax.html
1426 pub extern fn fmax(x: f64, y: f64) f64;
1427
1428 /// float fmaxf(float x, float y);
1429 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/fmaxf.html
1430 pub extern fn fmaxf(x: f32, y: f32) f32;
1431
1432 /// long double fmaxl(long double x, long double y);
1433 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/fmaxl.html
1434 pub extern fn fmaxl(x: c_longdouble, y: c_longdouble) c_longdouble;
1435
1436 /// double fmin(double x, double y);
1437 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/fmin.html
1438 pub extern fn fmin(x: f64, y: f64) f64;
1439
1440 /// float fminf(float x, float y);
1441 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/fminf.html
1442 pub extern fn fminf(x: f32, y: f32) f32;
1443
1444 /// long double fminl(long double x, long double y);
1445 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/fminl.html
1446 pub extern fn fminl(x: c_longdouble, y: c_longdouble) c_longdouble;
1447
1448 /// double fmod(double x, double y);
1449 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/fmod.html
1450 pub extern fn fmod(x: f64, y: f64) f64;
1451
1452 /// float fmodf(float x, float y);
1453 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/fmodf.html
1454 pub extern fn fmodf(x: f32, y: f32) f32;
1455
1456 /// long double fmodl(long double x, long double y);
1457 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/fmodl.html
1458 pub extern fn fmodl(x: c_longdouble, y: c_longdouble) c_longdouble;
1459
1460 /// pid_t fork(void);
1461 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/fork.html
1462 pub extern fn fork() pid_t;
1463
1464 /// long fpathconf(int fildes, int name);
1465 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/fpathconf.html
1466 pub extern fn fpathconf(fildes: c_int, name: c_int) c_long;
1467
1468 /// void free(void *ptr);
1469 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/free.html
1470 pub extern fn free(ptr: ?*anyopaque) void;
1471
1472 /// void freeaddrinfo(struct addrinfo *ai);
1473 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/freeaddrinfo.html
1474 pub extern fn freeaddrinfo(ai: *const struct_addrinfo) void;
1475
1476 /// void freelocale(locale_t locobj);
1477 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/freelocale.html
1478 pub extern fn freelocale(locobj: locale_t) void;
1479
1480 /// double frexp(double num, int *exp);
1481 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/frexp.html
1482 pub extern fn frexp(x: f64, exp: *c_int) f64;
1483
1484 /// float frexpf(float num, int *exp);
1485 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/frexpf.html
1486 pub extern fn frexpf(x: f32, exp: *c_int) f32;
1487
1488 /// long double frexpl(long double num, int *exp);
1489 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/frexpl.html
1490 pub extern fn frexpl(x: c_longdouble, exp: *c_int) c_longdouble;
1491
1492 /// int fstat(int fildes, struct stat *buf);
1493 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/fstat.html
1494 pub extern fn fstat(fd: c_int, buf: *struct_stat) c_int;
1495
1496 /// int fstatat(int fd, const char *restrict path, struct stat *restrict buf, int flag);
1497 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/fstatat.html
1498 pub extern fn fstatat(fd: c_int, noalias path: [*:0]const u8, noalias buf: *struct_stat, flag: c_int) c_int;
1499
1500 /// int fsync(int fildes);
1501 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/fsync.html
1502 pub extern fn fsync(fd: c_int) c_int;
1503
1504 /// int futimens(int fd, const struct timespec times[2]);
1505 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/futimens.html
1506 pub extern fn futimens(fd: c_int, times: *const [2]struct_timespec) c_int;
1507
1508 /// int getaddrinfo(const char *restrict nodename, const char *restrict servname, const struct addrinfo *restrict hints, struct addrinfo **restrict res);
1509 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/getaddrinfo.html
1510 pub extern fn getaddrinfo(noalias nodename: ?[*:0]const u8, noalias servname: ?[*:0]const u8, noalias req: ?*const struct_addrinfo, noalias pai: **const struct_addrinfo) c_int;
1511
1512 /// int getchar(void);
1513 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/getchar.html
1514 pub extern fn getchar() c_int;
1515
1516 /// int getchar_unlocked(void);
1517 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/getchar_unlocked.html
1518 pub extern fn getchar_unlocked() c_int;
1519
1520 /// char *getcwd(char *buf, size_t size);
1521 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/getcwd.html
1522 pub extern fn getcwd(buf: [*]u8, size: usize) ?[*:0]u8;
1523
1524 /// gid_t getegid(void);
1525 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/getegid.html
1526 pub extern fn getegid() gid_t;
1527
1528 /// char *getenv(const char *name);
1529 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/getenv.html
1530 pub extern fn getenv(name: [*:0]const u8) ?[*:0]u8;
1531
1532 /// uid_t geteuid(void);
1533 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/geteuid.html
1534 pub extern fn geteuid() uid_t;
1535
1536 /// gid_t getgid(void);
1537 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/getgid.html
1538 pub extern fn getgid() gid_t;
1539
1540 /// struct group *getgrent(void);
1541 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/getgrent.html
1542 pub extern fn getgrent() ?*struct_group;
1543
1544 /// struct group *getgrgid(gid_t gid);
1545 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/getgrgid.html
1546 pub extern fn getgrgid(gid: gid_t) ?*struct_group;
1547
1548 /// struct group *getgrnam(const char *name);
1549 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/getgrnam.html
1550 pub extern fn getgrnam(name: [*:0]const u8) ?*struct_group;
1551
1552 /// struct hostent *gethostent(void);
1553 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/gethostent.html
1554 pub extern fn gethostent() ?*struct_hostent;
1555
1556 /// long gethostid(void);
1557 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/gethostid.html
1558 pub extern fn gethostid() c_long;
1559
1560 /// int gethostname(char *name, size_t namelen);
1561 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/gethostname.html
1562 pub extern fn gethostname(name: [*:0]u8, len: usize) c_int;
1563
1564 /// struct netent *getnetbyaddr(uint32_t net, int type);
1565 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/getnetbyaddr.html
1566 pub extern fn getnetbyaddr(net: u32, type: c_int) ?*struct_netent;
1567
1568 /// struct netent *getnetbyname(const char *name);
1569 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/getnetbyname.html
1570 pub extern fn getnetbyname(name: [*:0]const u8) ?*struct_netent;
1571
1572 /// struct netent *getnetent(void);
1573 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/getnetent.html
1574 pub extern fn getnetent() ?*struct_netent;
1575
1576 /// pid_t getpgid(pid_t pid);
1577 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/getpgid.html
1578 pub extern fn getpgid(pid: pid_t) pid_t;
1579
1580 /// pid_t getpgrp(void);
1581 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/getpgrp.html
1582 pub extern fn getpgrp() pid_t;
1583
1584 /// pid_t getpid(void);
1585 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/getpid.html
1586 pub extern fn getpid() pid_t;
1587
1588 /// pid_t getppid(void);
1589 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/getppid.html
1590 pub extern fn getppid() pid_t;
1591
1592 /// struct protoent *getprotobyname(const char *name);
1593 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/getprotobyname.html
1594 pub extern fn getprotobyname(name: [*:0]const u8) ?*struct_protoent;
1595
1596 /// struct protoent *getprotobynumber(int proto);
1597 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/getprotobynumber.html
1598 pub extern fn getprotobynumber(proto: c_int) ?*struct_protoent;
1599
1600 /// struct protoent *getprotoent(void);
1601 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/getprotoent.html
1602 pub extern fn getprotoent() ?*struct_protoent;
1603
1604 /// struct passwd *getpwent(void);
1605 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/getpwent.html
1606 pub extern fn getpwent() ?*struct_passwd;
1607
1608 /// struct passwd *getpwnam(const char *name);
1609 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/getpwnam.html
1610 pub extern fn getpwnam(name: [*:0]const u8) ?*struct_passwd;
1611
1612 /// struct passwd *getpwuid(uid_t uid);
1613 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/getpwuid.html
1614 pub extern fn getpwuid(uid: uid_t) ?*struct_passwd;
1615
1616 /// char *gets(char *s);
1617 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/gets.html
1618 pub extern fn gets(s: [*]u8) [*:0]u8;
1619
1620 /// struct servent *getservent(void);
1621 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/getservent.html
1622 pub extern fn getservent() ?*struct_servent;
1623
1624 /// pid_t getsid(pid_t pid);
1625 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/getsid.html
1626 pub extern fn getsid(pid: pid_t) pid_t;
1627
1628 /// int getsockname(int socket, struct sockaddr *restrict address, socklen_t *restrict address_len);
1629 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/getsockname.html
1630 pub extern fn getsockname(fd: c_int, noalias addr: *struct_sockaddr, noalias len: *socklen_t) c_int;
1631
1632 /// uid_t getuid(void);
1633 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/getuid.html
1634 pub extern fn getuid() uid_t;
1635
1636 /// struct utmpx *getutxent(void);
1637 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/getutxent.html
1638 pub extern fn getutxent() ?*struct_utmpx;
1639
1640 /// wint_t getwchar(void);
1641 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/getwchar.html
1642 pub extern fn getwchar() wint_t;
1643
1644 /// int grantpt(int fildes);
1645 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/grantpt.html
1646 pub extern fn grantpt(fd: c_int) c_int;
1647
1648 /// void hdestroy(void);
1649 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/hdestroy.html
1650 pub extern fn hdestroy() void;
1651
1652 /// uint32_t htonl(uint32_t hostlong);
1653 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/htonl.html
1654 pub extern fn htonl(hostlong: u32) u32;
1655
1656 /// uint16_t htons(uint16_t hostshort);
1657 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/htons.html
1658 pub extern fn htons(hostshort: u16) u16;
1659
1660 /// double hypot(double x, double y);
1661 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/hypot.html
1662 pub extern fn hypot(x: f64, y: f64) f64;
1663
1664 /// float hypotf(float x, float y);
1665 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/hypotf.html
1666 pub extern fn hypotf(x: f32, y: f32) f32;
1667
1668 /// long double hypotl(long double x, long double y);
1669 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/hypotl.html
1670 pub extern fn hypotl(x: c_longdouble, y: c_longdouble) c_longdouble;
1671
1672 /// void if_freenameindex(struct if_nameindex *ptr);
1673 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/if_freenameindex.html
1674 pub extern fn if_freenameindex(ptr: *struct_if_nameindex) void;
1675
1676 /// struct if_nameindex *if_nameindex(void);
1677 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/if_nameindex.html
1678 pub extern fn if_nameindex() ?*struct_if_nameindex;
1679
1680 /// unsigned if_nametoindex(const char *ifname);
1681 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/if_nametoindex.html
1682 pub extern fn if_nametoindex(ifname: [*:0]const u8) c_uint;
1683
1684 /// int ilogb(double x);
1685 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/ilogb.html
1686 pub extern fn ilogb(x: f64) c_int;
1687
1688 /// int ilogbf(float x);
1689 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/ilogbf.html
1690 pub extern fn ilogbf(x: f32) c_int;
1691
1692 /// int ilogbl(long double x);
1693 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/ilogbl.html
1694 pub extern fn ilogbl(x: c_longdouble) c_int;
1695
1696 /// intmax_t imaxabs(intmax_t j);
1697 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/imaxabs.html
1698 pub extern fn imaxabs(j: intmax_t) intmax_t;
1699
1700 /// void insque(void *element, void *pred);
1701 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/insque.html
1702 pub extern fn insque(elem: *anyopaque, prev: ?*anyopaque) void;
1703
1704 /// int isalnum(int c);
1705 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/isalnum.html
1706 pub extern fn isalnum(c: c_int) c_int;
1707
1708 /// int isalnum_l(int c, locale_t locale);
1709 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/isalnum_l.html
1710 pub extern fn isalnum_l(c: c_int, locale: locale_t) c_int;
1711
1712 /// int isalpha(int c);
1713 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/isalpha.html
1714 pub extern fn isalpha(c: c_int) c_int;
1715
1716 /// int isalpha_l(int c, locale_t locale);
1717 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/isalpha_l.html
1718 pub extern fn isalpha_l(c: c_int, locale: locale_t) c_int;
1719
1720 /// int isascii(int c);
1721 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/isascii.html
1722 pub extern fn isascii(c: c_int) c_int;
1723
1724 /// int isastream(int fildes);
1725 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/isastream.html
1726 pub extern fn isastream(fd: c_int) c_int;
1727
1728 /// int isatty(int fildes);
1729 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/isatty.html
1730 pub extern fn isatty(fd: c_int) c_int;
1731
1732 /// int isblank(int c);
1733 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/isblank.html
1734 pub extern fn isblank(c: c_int) c_int;
1735
1736 /// int isblank_l(int c, locale_t locale);
1737 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/isblank_l.html
1738 pub extern fn isblank_l(c: c_int, locale: locale_t) c_int;
1739
1740 /// int iscntrl(int c);
1741 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/iscntrl.html
1742 pub extern fn iscntrl(c: c_int) c_int;
1743
1744 /// int iscntrl_l(int c, locale_t locale);
1745 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/iscntrl_l.html
1746 pub extern fn iscntrl_l(c: c_int, locale: locale_t) c_int;
1747
1748 /// int isdigit(int c);
1749 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/isdigit.html
1750 pub extern fn isdigit(c: c_int) c_int;
1751
1752 /// int isdigit_l(int c, locale_t locale);
1753 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/isdigit_l.html
1754 pub extern fn isdigit_l(c: c_int, locale: locale_t) c_int;
1755
1756 /// int isgraph(int c);
1757 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/isgraph.html
1758 pub extern fn isgraph(c: c_int) c_int;
1759
1760 /// int isgraph_l(int c, locale_t locale);
1761 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/isgraph_l.html
1762 pub extern fn isgraph_l(c: c_int, locale: locale_t) c_int;
1763
1764 /// int islower(int c);
1765 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/islower.html
1766 pub extern fn islower(c: c_int) c_int;
1767
1768 /// int islower_l(int c, locale_t locale);
1769 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/islower_l.html
1770 pub extern fn islower_l(c: c_int, locale: locale_t) c_int;
1771
1772 /// int isprint(int c);
1773 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/isprint.html
1774 pub extern fn isprint(c: c_int) c_int;
1775
1776 /// int isprint_l(int c, locale_t locale);
1777 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/isprint_l.html
1778 pub extern fn isprint_l(c: c_int, locale: locale_t) c_int;
1779
1780 /// int ispunct(int c);
1781 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/ispunct.html
1782 pub extern fn ispunct(c: c_int) c_int;
1783
1784 /// int ispunct_l(int c, locale_t locale);
1785 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/ispunct_l.html
1786 pub extern fn ispunct_l(c: c_int, locale: locale_t) c_int;
1787
1788 /// int isspace(int c);
1789 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/isspace.html
1790 pub extern fn isspace(c: c_int) c_int;
1791
1792 /// int isspace_l(int c, locale_t locale);
1793 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/isspace_l.html
1794 pub extern fn isspace_l(c: c_int, locale: locale_t) c_int;
1795
1796 /// int isupper(int c);
1797 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/isupper.html
1798 pub extern fn isupper(c: c_int) c_int;
1799
1800 /// int isupper_l(int c, locale_t locale);
1801 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/isupper_l.html
1802 pub extern fn isupper_l(c: c_int, locale: locale_t) c_int;
1803
1804 /// int iswalnum(wint_t wc);
1805 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/iswalnum.html
1806 pub extern fn iswalnum(wc: wint_t) c_int;
1807
1808 /// int iswalnum_l(wint_t wc, locale_t locale);
1809 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/iswalnum_l.html
1810 pub extern fn iswalnum_l(wc: wint_t, locale: locale_t) c_int;
1811
1812 /// int iswalpha(wint_t wc);
1813 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/iswalpha.html
1814 pub extern fn iswalpha(wc: wint_t) c_int;
1815
1816 /// int iswalpha_l(wint_t wc, locale_t locale);
1817 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/iswalpha_l.html
1818 pub extern fn iswalpha_l(wc: wint_t, locale: locale_t) c_int;
1819
1820 /// int iswblank(wint_t wc);
1821 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/iswblank.html
1822 pub extern fn iswblank(wc: wint_t) c_int;
1823
1824 /// int iswblank_l(wint_t wc, locale_t locale);
1825 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/iswblank_l.html
1826 pub extern fn iswblank_l(wc: wint_t, locale: locale_t) c_int;
1827
1828 /// int iswcntrl(wint_t wc);
1829 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/iswcntrl.html
1830 pub extern fn iswcntrl(wc: wint_t) c_int;
1831
1832 /// int iswcntrl_l(wint_t wc, locale_t locale);
1833 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/iswcntrl_l.html
1834 pub extern fn iswcntrl_l(wc: wint_t, locale: locale_t) c_int;
1835
1836 /// int iswdigit(wint_t wc);
1837 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/iswdigit.html
1838 pub extern fn iswdigit(wc: wint_t) c_int;
1839
1840 /// int iswdigit_l(wint_t wc, locale_t locale);
1841 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/iswdigit_l.html
1842 pub extern fn iswdigit_l(wc: wint_t, locale: locale_t) c_int;
1843
1844 /// int iswgraph(wint_t wc);
1845 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/iswgraph.html
1846 pub extern fn iswgraph(wc: wint_t) c_int;
1847
1848 /// int iswgraph_l(wint_t wc, locale_t locale);
1849 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/iswgraph_l.html
1850 pub extern fn iswgraph_l(wc: wint_t, locale: locale_t) c_int;
1851
1852 /// int iswlower(wint_t wc);
1853 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/iswlower.html
1854 pub extern fn iswlower(wc: wint_t) c_int;
1855
1856 /// int iswlower_l(wint_t wc, locale_t locale);
1857 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/iswlower_l.html
1858 pub extern fn iswlower_l(wc: wint_t, locale: locale_t) c_int;
1859
1860 /// int iswprint(wint_t wc);
1861 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/iswprint.html
1862 pub extern fn iswprint(wc: wint_t) c_int;
1863
1864 /// int iswprint_l(wint_t wc, locale_t locale);
1865 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/iswprint_l.html
1866 pub extern fn iswprint_l(wc: wint_t, locale: locale_t) c_int;
1867
1868 /// int iswpunct(wint_t wc);
1869 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/iswpunct.html
1870 pub extern fn iswpunct(wc: wint_t) c_int;
1871
1872 /// int iswpunct_l(wint_t wc, locale_t locale);
1873 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/iswpunct_l.html
1874 pub extern fn iswpunct_l(wc: wint_t, locale: locale_t) c_int;
1875
1876 /// int iswspace(wint_t wc);
1877 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/iswspace.html
1878 pub extern fn iswspace(wc: wint_t) c_int;
1879
1880 /// int iswspace_l(wint_t wc, locale_t locale);
1881 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/iswspace_l.html
1882 pub extern fn iswspace_l(wc: wint_t, locale: locale_t) c_int;
1883
1884 /// int iswupper(wint_t wc);
1885 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/iswupper.html
1886 pub extern fn iswupper(wc: wint_t) c_int;
1887
1888 /// int iswupper_l(wint_t wc, locale_t locale);
1889 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/iswupper_l.html
1890 pub extern fn iswupper_l(wc: wint_t, locale: locale_t) c_int;
1891
1892 /// int iswxdigit(wint_t wc);
1893 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/iswxdigit.html
1894 pub extern fn iswxdigit(wc: wint_t) c_int;
1895
1896 /// int iswxdigit_l(wint_t wc, locale_t locale);
1897 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/iswxdigit_l.html
1898 pub extern fn iswxdigit_l(wc: wint_t, locale: locale_t) c_int;
1899
1900 /// int isxdigit(int c);
1901 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/isxdigit.html
1902 pub extern fn isxdigit(c: c_int) c_int;
1903
1904 /// int isxdigit_l(int c, locale_t locale);
1905 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/isxdigit_l.html
1906 pub extern fn isxdigit_l(c: c_int, locale: locale_t) c_int;
1907
1908 /// double j0(double x);
1909 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/j0.html
1910 pub extern fn j0(x: f64) f64;
1911
1912 /// double j1(double x);
1913 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/j1.html
1914 pub extern fn j1(x: f64) f64;
1915
1916 /// double jn(int n, double x);
1917 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/jn.html
1918 pub extern fn jn(n: c_int, x: f64) f64;
1919
1920 /// int kill(pid_t pid, int sig);
1921 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/kill.html
1922 pub extern fn kill(pid: pid_t, sig: c_int) c_int;
1923
1924 /// long labs(long i);
1925 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/labs.html
1926 pub extern fn labs(i: c_long) c_long;
1927
1928 /// double ldexp(double x, int exp);
1929 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/ldexp.html
1930 pub extern fn ldexp(x: f64, exp: c_int) f64;
1931
1932 /// float ldexpf(float x, int exp);
1933 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/ldexpf.html
1934 pub extern fn ldexpf(x: f32, exp: c_int) f32;
1935
1936 /// double lgamma(double x);
1937 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/lgamma.html
1938 pub extern fn lgamma(x: f64) f64;
1939
1940 /// float lgammaf(float x);
1941 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/lgammaf.html
1942 pub extern fn lgammaf(x: f32) f32;
1943
1944 /// long double lgammal(long double x);
1945 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/lgammal.html
1946 pub extern fn lgammal(x: c_longdouble) c_longdouble;
1947
1948 /// int listen(int socket, int backlog);
1949 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/listen.html
1950 pub extern fn listen(socket: c_int, backlog: c_int) c_int;
1951
1952 /// long long llabs(long long i);
1953 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/llabs.html
1954 pub extern fn llabs(x: c_longlong) c_longlong;
1955
1956 /// long long llrint(double x);
1957 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/llrint.html
1958 pub extern fn llrint(x: f64) c_longlong;
1959
1960 /// long long llrintf(float x);
1961 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/llrintf.html
1962 pub extern fn llrintf(x: f32) c_longlong;
1963
1964 /// long long llrintl(long double x);
1965 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/llrintl.html
1966 pub extern fn llrintl(x: c_longdouble) c_longlong;
1967
1968 /// long long llround(double x);
1969 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/llround.html
1970 pub extern fn llround(x: f64) c_longlong;
1971
1972 /// long long llroundf(float x);
1973 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/llroundf.html
1974 pub extern fn llroundf(x: f32) c_longlong;
1975
1976 /// long long llroundl(long double x);
1977 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/llroundl.html
1978 pub extern fn llroundl(x: c_longdouble) c_longlong;
1979
1980 /// struct lconv *localeconv(void);
1981 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/localeconv.html
1982 pub extern fn localeconv() *struct_lconv;
1983
1984 /// double log(double x);
1985 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/log.html
1986 pub extern fn log(x: f64) f64;
1987
1988 /// double log1p(double x);
1989 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/log1p.html
1990 pub extern fn log1p(x: f64) f64;
1991
1992 /// float log1pf(float x);
1993 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/log1pf.html
1994 pub extern fn log1pf(x: f32) f32;
1995
1996 /// long double log1pl(long double x);
1997 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/log1pl.html
1998 pub extern fn log1pl(x: c_longdouble) c_longdouble;
1999
2000 /// double log2(double x);
2001 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/log2.html
2002 pub extern fn log2(x: f64) f64;
2003
2004 /// float log2f(float x);
2005 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/log2f.html
2006 pub extern fn log2f(x: f32) f32;
2007
2008 /// long double log2l(long double x);
2009 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/log2l.html
2010 pub extern fn log2l(x: c_longdouble) c_longdouble;
2011
2012 /// double log10(double x);
2013 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/log10.html
2014 pub extern fn log10(x: f64) f64;
2015
2016 /// float log10f(float x);
2017 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/log10f.html
2018 pub extern fn log10f(x: f32) f32;
2019
2020 /// long double log10l(long double x);
2021 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/log10l.html
2022 pub extern fn log10l(x: c_longdouble) c_longdouble;
2023
2024 /// double logb(double x);
2025 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/logb.html
2026 pub extern fn logb(x: f64) f64;
2027
2028 /// float logbf(float x);
2029 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/logbf.html
2030 pub extern fn logbf(x: f32) f32;
2031
2032 /// long double logbl(long double x);
2033 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/logbl.html
2034 pub extern fn logbl(x: c_longdouble) c_longdouble;
2035
2036 /// float logf(float x);
2037 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/logf.html
2038 pub extern fn logf(x: f32) f32;
2039
2040 /// long double logl(long double x);
2041 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/logl.html
2042 pub extern fn logl(x: c_longdouble) c_longdouble;
2043
2044 /// long lrand48(void);
2045 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/lrand48.html
2046 pub extern fn lrand48() c_long;
2047
2048 /// long lrint(double x);
2049 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/lrint.html
2050 pub extern fn lrint(x: f64) c_long;
2051
2052 /// long lrintf(float x);
2053 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/lrintf.html
2054 pub extern fn lrintf(x: f32) c_long;
2055
2056 /// long lrintl(long double x);
2057 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/lrintl.html
2058 pub extern fn lrintl(x: c_longdouble) c_long;
2059
2060 /// long lround(double x);
2061 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/lround.html
2062 pub extern fn lround(x: f64) c_long;
2063
2064 /// long lroundf(float x);
2065 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/lroundf.html
2066 pub extern fn lroundf(x: f32) c_long;
2067
2068 /// long lroundl(long double x);
2069 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/lroundl.html
2070 pub extern fn lroundl(x: c_longdouble) c_long;
2071
2072 /// off_t lseek(int fildes, off_t offset, int whence);
2073 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/lseek.html
2074 pub extern fn lseek(fd: c_int, offset: off_t, whence: c_int) off_t;
2075
2076 /// void *malloc(size_t size);
2077 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/malloc.html
2078 pub extern fn malloc(size: usize) ?*anyopaque;
2079
2080 /// int mkdir(const char *path, mode_t mode);
2081 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/mkdir.html
2082 pub extern fn mkdir(path: [*:0]const u8, __mode: mode_t) c_int;
2083
2084 /// int mkdirat(int fd, const char *path, mode_t mode);
2085 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/mkdirat.html
2086 pub extern fn mkdirat(fd: c_int, path: [*:0]const u8, mode: mode_t) c_int;
2087
2088 /// char *mkdtemp(char *template);
2089 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/mkdtemp.html
2090 pub extern fn mkdtemp(template: [*:0]u8) ?[*:0]u8;
2091
2092 /// int mkfifo(const char *path, mode_t mode);
2093 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/mkfifo.html
2094 pub extern fn mkfifo(path: [*:0]const u8, mode: mode_t) c_int;
2095
2096 /// int mkfifoat(int fd, const char *path, mode_t mode);
2097 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/mkfifoat.html
2098 pub extern fn mkfifoat(fd: c_int, path: [*:0]const u8, mode: mode_t) c_int;
2099
2100 /// int mkstemp(char *template);
2101 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/mkstemp.html
2102 pub extern fn mkstemp(template: [*:0]u8) c_int;
2103
2104 /// int mlockall(int flags);
2105 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/mlockall.html
2106 pub extern fn mlockall(flags: c_int) c_int;
2107
2108 /// void *mmap(void *addr, size_t len, int prot, int flags, int fildes, off_t off);
2109 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/mmap.html
2110 pub extern fn mmap(addr: ?*anyopaque, len: usize, prot: c_int, flags: c_int, fd: c_int, offset: off_t) *allowzero anyopaque;
2111
2112 /// int mq_unlink(const char *name);
2113 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/mq_unlink.html
2114 pub extern fn mq_unlink(name: [*:0]const u8) c_int;
2115
2116 /// long mrand48(void);
2117 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/mrand48.html
2118 pub extern fn mrand48() c_long;
2119
2120 /// int munlockall(void);
2121 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/munlockall.html
2122 pub extern fn munlockall() void;
2123
2124 /// int munmap(void *addr, size_t len);
2125 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/munmap.html
2126 pub extern fn munmap(addr: *const anyopaque, len: usize) c_int;
2127
2128 /// double nearbyint(double x);
2129 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/nearbyint.html
2130 pub extern fn nearbyint(x: f64) f64;
2131
2132 /// float nearbyintf(float x);
2133 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/nearbyintf.html
2134 pub extern fn nearbyintf(x: f32) f32;
2135
2136 /// long double nearbyintl(long double x);
2137 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/nearbyintl.html
2138 pub extern fn nearbyintl(x: c_longdouble) c_longdouble;
2139
2140 /// double nextafter(double x, double y);
2141 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/nextafter.html
2142 pub extern fn nextafter(x: f64, y: f64) f64;
2143
2144 /// float nextafterf(float x, float y);
2145 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/nextafterf.html
2146 pub extern fn nextafterf(x: f32, y: f32) f32;
2147
2148 /// long double nextafterl(long double x, long double y);
2149 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/nextafterl.html
2150 pub extern fn nextafterl(x: c_longdouble, y: c_longdouble) c_longdouble;
2151
2152 /// double nexttoward(double x, long double y);
2153 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/nexttoward.html
2154 pub extern fn nexttoward(x: f64, y: c_longdouble) f64;
2155
2156 /// float nexttowardf(float x, long double y);
2157 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/nexttowardf.html
2158 pub extern fn nexttowardf(x: f32, y: c_longdouble) f32;
2159
2160 /// long double nexttowardl(long double x, long double y);
2161 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/nexttowardl.html
2162 pub extern fn nexttowardl(x: c_longdouble, y: c_longdouble) c_longdouble;
2163
2164 /// int nice(int incr);
2165 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/nice.html
2166 pub extern fn nice(incr: c_int) c_int;
2167
2168 /// uint32_t ntohl(uint32_t netlong);
2169 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/ntohl.html
2170 pub extern fn ntohl(netlong: u32) u32;
2171
2172 /// uint16_t ntohs(uint16_t netshort);
2173 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/ntohs.html
2174 pub extern fn ntohs(netshort: u16) u16;
2175
2176 /// int openat(int fd, const char *path, int oflag, ...);
2177 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/openat.html
2178 pub extern fn openat(fd: c_int, file: [*:0]const u8, oflag: c_int, ...) c_int;
2179
2180 /// int pause(void);
2181 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/pause.html
2182 pub extern fn pause() c_int;
2183
2184 /// int pipe2(int fildes[2], int flag);
2185 /// https://pubs.opengroup.org/onlinepubs/9799919799/functions/pipe.html
2186 pub extern fn pipe2(pipefd: *[2]c_int, flag: c_int) c_int;
2187
2188 /// int poll(struct pollfd fds[], nfds_t nfds, int timeout);
2189 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/poll.html
2190 pub extern fn poll(fds: [*]struct_pollfd, nfds: nfds_t, timeout: c_int) c_int;
2191
2192 /// double pow(double x, double y);
2193 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/pow.html
2194 pub extern fn pow(x: f64, y: f64) f64;
2195
2196 /// float powf(float x, float y);
2197 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/powf.html
2198 pub extern fn powf(x: f32, y: f32) f32;
2199
2200 /// long double powl(long double x, long double y);
2201 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/powl.html
2202 pub extern fn powl(x: c_longdouble, y: c_longdouble) c_longdouble;
2203
2204 /// int pthread_attr_destroy(pthread_attr_t *attr);
2205 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/pthread_attr_destroy.html
2206 pub extern fn pthread_attr_destroy(attr: *pthread_attr_t) c_int;
2207
2208 /// int pthread_attr_init(pthread_attr_t *attr);
2209 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/pthread_attr_init.html
2210 pub extern fn pthread_attr_init(attr: *pthread_attr_t) c_int;
2211
2212 /// int pthread_attr_setguardsize(pthread_attr_t *attr, size_t guardsize);
2213 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/pthread_attr_setguardsize.html
2214 pub extern fn pthread_attr_setguardsize(attr: *pthread_attr_t, guardsize: usize) c_int;
2215
2216 /// int pthread_attr_setstacksize(pthread_attr_t *attr, size_t stacksize);
2217 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/pthread_attr_setstacksize.html
2218 pub extern fn pthread_attr_setstacksize(attr: *pthread_attr_t, stacksize: usize) c_int;
2219
2220 /// int pthread_cancel(pthread_t thread);
2221 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/pthread_cancel.html
2222 pub extern fn pthread_cancel(thread: pthread_t) c_int;
2223
2224 /// int pthread_cond_broadcast(pthread_cond_t *cond);
2225 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/pthread_cond_broadcast.html
2226 pub extern fn pthread_cond_broadcast(cond: *pthread_cond_t) c_int;
2227
2228 /// int pthread_cond_destroy(pthread_cond_t *cond);
2229 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/pthread_cond_destroy.html
2230 pub extern fn pthread_cond_destroy(cond: *pthread_cond_t) c_int;
2231
2232 /// int pthread_cond_init(pthread_cond_t *restrict cond, const pthread_condattr_t *restrict attr);
2233 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/pthread_cond_init.html
2234 pub extern fn pthread_cond_init(noalias cond: *pthread_cond_t, noalias attr: ?*const pthread_condattr_t) c_int;
2235
2236 /// int pthread_cond_signal(pthread_cond_t *cond);
2237 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/pthread_cond_signal.html
2238 pub extern fn pthread_cond_signal(cond: *pthread_cond_t) c_int;
2239
2240 /// int pthread_cond_timedwait(pthread_cond_t *restrict cond, pthread_mutex_t *restrict mutex, const struct timespec *restrict abstime);
2241 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/pthread_cond_timedwait.html
2242 pub extern fn pthread_cond_timedwait(noalias cond: *pthread_cond_t, noalias mutex: *pthread_mutex_t, noalias abstime: *const struct_timespec) c_int;
2243
2244 /// int pthread_cond_wait(pthread_cond_t *restrict cond, pthread_mutex_t *restrict mutex);
2245 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/pthread_cond_wait.html
2246 pub extern fn pthread_cond_wait(noalias cond: *pthread_cond_t, noalias mutex: *pthread_mutex_t) c_int;
2247
2248 /// int pthread_condattr_destroy(pthread_condattr_t *attr);
2249 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/pthread_condattr_destroy.html
2250 pub extern fn pthread_condattr_destroy(attr: *pthread_condattr_t) c_int;
2251
2252 /// int pthread_condattr_init(pthread_condattr_t *attr);
2253 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/pthread_condattr_init.html
2254 pub extern fn pthread_condattr_init(attr: *pthread_condattr_t) c_int;
2255
2256 /// int pthread_create(pthread_t *restrict thread, const pthread_attr_t *restrict attr, void *(*start_routine)(void*), void *restrict arg);
2257 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/pthread_create.html
2258 pub extern fn pthread_create(noalias newthread: *pthread_t, noalias attr: *const pthread_attr_t, start_routine: *const fn (*anyopaque) callconv(.c) ?*anyopaque, noalias arg: *anyopaque) c_int;
2259
2260 /// int pthread_detach(pthread_t thread);
2261 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/pthread_detach.html
2262 pub extern fn pthread_detach(thread: pthread_t) c_int;
2263
2264 /// int pthread_equal(pthread_t t1, pthread_t t2);
2265 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/pthread_equal.html
2266 pub extern fn pthread_equal(thread1: pthread_t, thread2: pthread_t) c_int;
2267
2268 /// int pthread_getconcurrency(void);
2269 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/pthread_getconcurrency.html
2270 pub extern fn pthread_getconcurrency() c_int;
2271
2272 /// int pthread_join(pthread_t thread, void **value_ptr);
2273 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/pthread_join.html
2274 pub extern fn pthread_join(thread: pthread_t, retval: ?*?*anyopaque) c_int;
2275
2276 /// int pthread_kill(pthread_t thread, int sig);
2277 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/pthread_kill.html
2278 pub extern fn pthread_kill(thread: pthread_t, sig: c_int) c_int;
2279
2280 /// int pthread_mutex_destroy(pthread_mutex_t *mutex);
2281 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/pthread_mutex_destroy.html
2282 pub extern fn pthread_mutex_destroy(mutex: *pthread_mutex_t) c_int;
2283
2284 /// int pthread_mutex_init(pthread_mutex_t *restrict mutex, const pthread_mutexattr_t *restrict attr);
2285 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/pthread_mutex_init.html
2286 pub extern fn pthread_mutex_init(mutex: *pthread_mutex_t, attr: ?*const pthread_mutexattr_t) c_int;
2287
2288 /// int pthread_mutex_lock(pthread_mutex_t *mutex);
2289 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/pthread_mutex_lock.html
2290 pub extern fn pthread_mutex_lock(mutex: *pthread_mutex_t) c_int;
2291
2292 /// int pthread_mutex_trylock(pthread_mutex_t *mutex);
2293 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/pthread_mutex_trylock.html
2294 pub extern fn pthread_mutex_trylock(mutex: *pthread_mutex_t) c_int;
2295
2296 /// int pthread_mutex_unlock(pthread_mutex_t *mutex);
2297 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/pthread_mutex_unlock.html
2298 pub extern fn pthread_mutex_unlock(mutex: *pthread_mutex_t) c_int;
2299
2300 /// int pthread_mutexattr_destroy(pthread_mutexattr_t *attr);
2301 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/pthread_mutexattr_destroy.html
2302 pub extern fn pthread_mutexattr_destroy(attr: *pthread_mutexattr_t) c_int;
2303
2304 /// int pthread_mutexattr_init(pthread_mutexattr_t *attr);
2305 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/pthread_mutexattr_init.html
2306 pub extern fn pthread_mutexattr_init(attr: *pthread_mutexattr_t) c_int;
2307
2308 /// int pthread_rwlock_destroy(pthread_rwlock_t *rwlock);
2309 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/pthread_rwlock_destroy.html
2310 pub extern fn pthread_rwlock_destroy(rwlock: *pthread_rwlock_t) c_int;
2311
2312 /// int pthread_rwlock_init(pthread_rwlock_t *restrict rwlock, const pthread_rwlockattr_t *restrict attr);
2313 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/pthread_rwlock_init.html
2314 pub extern fn pthread_rwlock_init(noalias rwlock: *pthread_rwlock_t, noalias attr: ?*const pthread_rwlockattr_t) c_int;
2315
2316 /// int pthread_rwlock_rdlock(pthread_rwlock_t *rwlock);
2317 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/pthread_rwlock_rdlock.html
2318 pub extern fn pthread_rwlock_rdlock(rwlock: *pthread_rwlock_t) c_int;
2319
2320 /// int pthread_rwlock_tryrdlock(pthread_rwlock_t *rwlock);
2321 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/pthread_rwlock_tryrdlock.html
2322 pub extern fn pthread_rwlock_tryrdlock(rwlock: *pthread_rwlock_t) c_int;
2323
2324 /// int pthread_rwlock_trywrlock(pthread_rwlock_t *rwlock);
2325 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/pthread_rwlock_trywrlock.html
2326 pub extern fn pthread_rwlock_trywrlock(rwlock: *pthread_rwlock_t) c_int;
2327
2328 /// int pthread_rwlock_unlock(pthread_rwlock_t *rwlock);
2329 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/pthread_rwlock_unlock.html
2330 pub extern fn pthread_rwlock_unlock(rwlock: *pthread_rwlock_t) c_int;
2331
2332 /// int pthread_rwlock_wrlock(pthread_rwlock_t *rwlock);
2333 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/pthread_rwlock_wrlock.html
2334 pub extern fn pthread_rwlock_wrlock(rwlock: *pthread_rwlock_t) c_int;
2335
2336 /// pthread_t pthread_self(void);
2337 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/pthread_self.html
2338 pub extern fn pthread_self() pthread_t;
2339
2340 /// void pthread_testcancel(void);
2341 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/pthread_testcancel.html
2342 pub extern fn pthread_testcancel() void;
2343
2344 /// int putchar(int c);
2345 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/putchar.html
2346 pub extern fn putchar(c: c_int) c_int;
2347
2348 /// int putchar_unlocked(int c);
2349 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/putchar_unlocked.html
2350 pub extern fn putchar_unlocked(c: c_int) c_int;
2351
2352 /// wint_t putwchar(wchar_t wc);
2353 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/putwchar.html
2354 pub extern fn putwchar(wc: wchar_t) wint_t;
2355
2356 /// int raise(int sig);
2357 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/raise.html
2358 pub extern fn raise(sig: c_int) c_int;
2359
2360 /// int rand(void);
2361 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/rand.html
2362 pub extern fn rand() c_int;
2363
2364 /// long random(void);
2365 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/random.html
2366 pub extern fn random() c_long;
2367
2368 /// ssize_t read(int fildes, void *buf, size_t nbyte);
2369 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/read.html
2370 pub extern fn read(fd: c_int, buf: [*]u8, count: usize) isize;
2371
2372 /// ssize_t readlink(const char *restrict path, char *restrict buf, size_t bufsize);
2373 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/readlink.html
2374 pub extern fn readlink(noalias path: [*:0]const u8, noalias buf: [*]u8, len: usize) isize;
2375
2376 /// ssize_t readlinkat(int fd, const char *restrict path, char *restrict buf, size_t bufsize);
2377 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/readlinkat.html
2378 pub extern fn readlinkat(fd: c_int, noalias path: [*:0]const u8, noalias buf: [*]u8, len: usize) isize;
2379
2380 /// ssize_t readv(int fildes, const struct iovec *iov, int iovcnt);
2381 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/readv.html
2382 pub extern fn readv(fd: c_int, iovec: [*]const struct_iovec, count: c_int) isize;
2383
2384 /// ssize_t recv(int socket, void *buffer, size_t length, int flags);
2385 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/recv.html
2386 pub extern fn recv(fd: c_int, buffer: [*]u8, length: usize, flags: c_int) isize;
2387
2388 /// double remainder(double x, double y);
2389 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/remainder.html
2390 pub extern fn remainder(x: f64, y: f64) f64;
2391
2392 /// float remainderf(float x, float y);
2393 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/remainderf.html
2394 pub extern fn remainderf(x: f32, y: f32) f32;
2395
2396 /// long double remainderl(long double x, long double y);
2397 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/remainderl.html
2398 pub extern fn remainderl(x: c_longdouble, y: c_longdouble) c_longdouble;
2399
2400 /// int renameat(int oldfd, const char *old, int newfd, const char *new);
2401 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/renameat.html
2402 pub extern fn renameat(oldfd: c_int, old: [*:0]const u8, newfd: c_int, new: [*:0]const u8) c_int;
2403
2404 /// double rint(double x);
2405 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/rint.html
2406 pub extern fn rint(x: f64) f64;
2407
2408 /// float rintf(float x);
2409 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/rintf.html
2410 pub extern fn rintf(x: f32) f32;
2411
2412 /// long double rintl(long double x);
2413 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/rintl.html
2414 pub extern fn rintl(x: c_longdouble) c_longdouble;
2415
2416 /// int rmdir(const char *path);
2417 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/rmdir.html
2418 pub extern fn rmdir(path: [*:0]const u8) c_int;
2419
2420 /// double round(double x);
2421 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/round.html
2422 pub extern fn round(x: f64) f64;
2423
2424 /// float roundf(float x);
2425 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/roundf.html
2426 pub extern fn roundf(x: f32) f32;
2427
2428 /// long double roundl(long double x);
2429 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/roundl.html
2430 pub extern fn roundl(x: c_longdouble) c_longdouble;
2431
2432 /// double scalbln(double x, long n);
2433 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/scalbln.html
2434 pub extern fn scalbln(x: f64, n: c_long) f64;
2435
2436 /// float scalblnf(float x, long n);
2437 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/scalblnf.html
2438 pub extern fn scalblnf(x: f32, n: c_long) f32;
2439
2440 /// long double scalblnl(long double x, long n);
2441 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/scalblnl.html
2442 pub extern fn scalblnl(x: c_longdouble, n: c_long) c_longdouble;
2443
2444 /// double scalbn(double x, int n);
2445 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/scalbn.html
2446 pub extern fn scalbn(x: f64, n: c_int) f64;
2447
2448 /// float scalbnf(float x, int n);
2449 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/scalbnf.html
2450 pub extern fn scalbnf(x: f32, n: c_int) f32;
2451
2452 /// long double scalbnl(long double x, int n);
2453 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/scalbnl.html
2454 pub extern fn scalbnl(x: c_longdouble, n: c_int) c_longdouble;
2455
2456 /// int sched_get_priority_max(int policy);
2457 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/sched_get_priority_max.html
2458 pub extern fn sched_get_priority_max(policy: c_int) c_int;
2459
2460 /// int sched_get_priority_min(int policy);
2461 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/sched_get_priority_min.html
2462 pub extern fn sched_get_priority_min(policy: c_int) c_int;
2463
2464 /// int sched_getscheduler(pid_t pid);
2465 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/sched_getscheduler.html
2466 pub extern fn sched_getscheduler(pid: pid_t) c_int;
2467
2468 /// int sched_yield(void);
2469 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/sched_yield.html
2470 pub extern fn sched_yield() c_int;
2471
2472 /// int sem_unlink(const char *name);
2473 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/sem_unlink.html
2474 pub extern fn sem_unlink(name: [*:0]const u8) c_int;
2475
2476 /// int semctl(int semid, int semnum, int cmd, ...);
2477 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/semctl.html
2478 pub extern fn semctl(semid: c_int, semnum: c_int, cmd: c_int, ...) c_int;
2479
2480 /// ssize_t send(int socket, const void *buffer, size_t length, int flags);
2481 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/send.html
2482 pub extern fn send(fd: c_int, buffer: [*]const u8, length: usize, flags: c_int) isize;
2483
2484 /// int setegid(gid_t gid);
2485 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/setegid.html
2486 pub extern fn setegid(gid: gid_t) c_int;
2487
2488 /// int seteuid(uid_t uid);
2489 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/seteuid.html
2490 pub extern fn seteuid(uid: uid_t) c_int;
2491
2492 /// int setgid(gid_t gid);
2493 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/setgid.html
2494 pub extern fn setgid(gid: gid_t) c_int;
2495
2496 /// void setgrent(void);
2497 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/setgrent.html
2498 pub extern fn setgrent() void;
2499
2500 /// void sethostent(int stayopen);
2501 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/sethostent.html
2502 pub extern fn sethostent(stayopen: c_int) void;
2503
2504 /// int setlogmask(int maskpri);
2505 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/setlogmask.html
2506 pub extern fn setlogmask(maskpri: c_int) c_int;
2507
2508 /// void setnetent(int stayopen);
2509 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/setnetent.html
2510 pub extern fn setnetent(stayopen: c_int) void;
2511
2512 /// pid_t setpgrp(void);
2513 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/setpgrp.html
2514 pub extern fn setpgrp() pid_t;
2515
2516 /// void setprotoent(int stayopen);
2517 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/setprotoent.html
2518 pub extern fn setprotoent(stayopen: c_int) void;
2519
2520 /// void setpwent(void);
2521 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/setpwent.html
2522 pub extern fn setpwent() void;
2523
2524 /// int setregid(gid_t rgid, gid_t egid);
2525 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/setregid.html
2526 pub extern fn setregid(rgid: gid_t, egid: gid_t) c_int;
2527
2528 /// int setreuid(uid_t ruid, uid_t euid);
2529 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/setreuid.html
2530 pub extern fn setreuid(ruid: uid_t, euid: uid_t) c_int;
2531
2532 /// void setservent(int stayopen);
2533 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/setservent.html
2534 pub extern fn setservent(stayopen: c_int) void;
2535
2536 /// pid_t setsid(void);
2537 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/setsid.html
2538 pub extern fn setsid() pid_t;
2539
2540 /// int setsockopt(int socket, int level, int option_name, const void *option_value, socklen_t option_len);
2541 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/setsockopt.html
2542 pub extern fn setsockopt(fd: c_int, level: c_int, optname: c_int, optval: *const anyopaque, optlen: socklen_t) c_int;
2543
2544 /// int setuid(uid_t uid);
2545 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/setuid.html
2546 pub extern fn setuid(uid: uid_t) c_int;
2547
2548 /// void setutxent(void);
2549 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/setutxent.html
2550 pub extern fn setutxent() void;
2551
2552 /// int shm_unlink(const char *name);
2553 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/shm_unlink.html
2554 pub extern fn shm_unlink(name: [*:0]const u8) c_int;
2555
2556 /// int shutdown(int socket, int how);
2557 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/shutdown.html
2558 pub extern fn shutdown(socket: c_int, how: c_int) c_int;
2559
2560 /// int sighold(int sig);
2561 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/sighold.html
2562 pub extern fn sighold(sig: c_int) c_int;
2563
2564 /// int sigignore(int sig);
2565 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/sigignore.html
2566 pub extern fn sigignore(sig: c_int) c_int;
2567
2568 /// int siginterrupt(int sig, int flag);
2569 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/siginterrupt.html
2570 pub extern fn siginterrupt(sig: c_int, flag: c_int) c_int;
2571
2572 /// int sigpause(int sig);
2573 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/sigpause.html
2574 pub extern fn sigpause(sig: c_int) c_int;
2575
2576 /// int sigrelse(int sig);
2577 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/sigrelse.html
2578 pub extern fn sigrelse(sig: c_int) c_int;
2579
2580 /// double sin(double x);
2581 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/sin.html
2582 pub extern fn sin(x: f64) f64;
2583
2584 /// float sinf(float x);
2585 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/sinf.html
2586 pub extern fn sinf(x: f32) f32;
2587
2588 /// double sinh(double x);
2589 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/sinh.html
2590 pub extern fn sinh(x: f64) f64;
2591
2592 /// float sinhf(float x);
2593 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/sinhf.html
2594 pub extern fn sinhf(x: f32) f32;
2595
2596 /// long double sinhl(long double x);
2597 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/sinhl.html
2598 pub extern fn sinhl(x: c_longdouble) c_longdouble;
2599
2600 /// long double sinl(long double x);
2601 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/sinl.html
2602 pub extern fn sinl(x: c_longdouble) c_longdouble;
2603
2604 /// unsigned sleep(unsigned seconds);
2605 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/sleep.html
2606 pub extern fn sleep(seconds: c_uint) c_uint;
2607
2608 /// int sockatmark(int s);
2609 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/sockatmark.html
2610 pub extern fn sockatmark(s: c_int) c_int;
2611
2612 /// int socket(int domain, int type, int protocol);
2613 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/socket.html
2614 pub extern fn socket(domain: c_int, type: c_int, protocol: c_int) c_int;
2615
2616 /// int socketpair(int domain, int type, int protocol, int socket_vector[2]);
2617 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/socketpair.html
2618 pub extern fn socketpair(domain: c_int, type: c_int, protocol: c_int, fds: *[2]c_int) c_int;
2619
2620 /// double sqrt(double x);
2621 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/sqrt.html
2622 pub extern fn sqrt(x: f64) f64;
2623
2624 /// float sqrtf(float x);
2625 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/sqrtf.html
2626 pub extern fn sqrtf(x: f32) f32;
2627
2628 /// long double sqrtl(long double x);
2629 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/sqrtl.html
2630 pub extern fn sqrtl(x: c_longdouble) c_longdouble;
2631
2632 /// void srand(unsigned seed);
2633 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/srand.html
2634 pub extern fn srand(seed: c_uint) void;
2635
2636 /// void srand48(long seedval);
2637 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/srand48.html
2638 pub extern fn srand48(seedval: c_long) void;
2639
2640 /// void srandom(unsigned seed);
2641 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/srandom.html
2642 pub extern fn srandom(seed: c_uint) void;
2643
2644 /// size_t strlen(const char *s);
2645 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/strlen.html
2646 pub extern fn strlen(s: [*:0]const u8) c_ulong;
2647
2648 /// void sync(void);
2649 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/sync.html
2650 pub extern fn sync() void;
2651
2652 /// long sysconf(int name);
2653 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/sysconf.html
2654 pub extern fn sysconf(name: c_int) c_long;
2655
2656 /// double tan(double x);
2657 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/tan.html
2658 pub extern fn tan(x: f64) f64;
2659
2660 /// float tanf(float x);
2661 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/tanf.html
2662 pub extern fn tanf(x: f32) f32;
2663
2664 /// double tanh(double x);
2665 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/tanh.html
2666 pub extern fn tanh(x: f64) f64;
2667
2668 /// float tanhf(float x);
2669 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/tanhf.html
2670 pub extern fn tanhf(x: f32) f32;
2671
2672 /// long double tanhl(long double x);
2673 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/tanhl.html
2674 pub extern fn tanhl(x: c_longdouble) c_longdouble;
2675
2676 /// long double tanl(long double x);
2677 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/tanl.html
2678 pub extern fn tanl(x: c_longdouble) c_longdouble;
2679
2680 /// int tcdrain(int fildes);
2681 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/tcdrain.html
2682 pub extern fn tcdrain(fd: c_int) c_int;
2683
2684 /// int tcflow(int fildes, int action);
2685 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/tcflow.html
2686 pub extern fn tcflow(fd: c_int, action: c_int) c_int;
2687
2688 /// int tcflush(int fildes, int queue_selector);
2689 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/tcflush.html
2690 pub extern fn tcflush(fd: c_int, queue_selector: c_int) c_int;
2691
2692 /// pid_t tcgetpgrp(int fildes);
2693 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/tcgetpgrp.html
2694 pub extern fn tcgetpgrp(fd: c_int) pid_t;
2695
2696 /// pid_t tcgetsid(int fildes);
2697 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/tcgetsid.html
2698 pub extern fn tcgetsid(fd: c_int) pid_t;
2699
2700 /// int tcsendbreak(int fildes, int duration);
2701 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/tcsendbreak.html
2702 pub extern fn tcsendbreak(fd: c_int, duration: c_int) c_int;
2703
2704 /// double tgamma(double x);
2705 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/tgamma.html
2706 pub extern fn tgamma(x: f64) f64;
2707
2708 /// float tgammaf(float x);
2709 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/tgammaf.html
2710 pub extern fn tgammaf(x: f32) f32;
2711
2712 /// long double tgammal(long double x);
2713 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/tgammal.html
2714 pub extern fn tgammal(x: c_longdouble) c_longdouble;
2715
2716 /// int toascii(int c);
2717 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/toascii.html
2718 pub extern fn toascii(c: c_int) c_int;
2719
2720 /// int tolower(int c);
2721 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/tolower.html
2722 pub extern fn tolower(c: c_int) c_int;
2723
2724 /// int tolower_l(int c, locale_t locale);
2725 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/tolower_l.html
2726 pub extern fn tolower_l(c: c_int, locale: locale_t) c_int;
2727
2728 /// int toupper(int c);
2729 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/toupper.html
2730 pub extern fn toupper(c: c_int) c_int;
2731
2732 /// int toupper_l(int c, locale_t locale);
2733 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/toupper_l.html
2734 pub extern fn toupper_l(c: c_int, locale: locale_t) c_int;
2735
2736 /// wint_t towlower(wint_t wc);
2737 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/towlower.html
2738 pub extern fn towlower(wc: wint_t) wint_t;
2739
2740 /// wint_t towlower_l(wint_t wc, locale_t locale);
2741 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/towlower_l.html
2742 pub extern fn towlower_l(wc: wint_t, locale: locale_t) wint_t;
2743
2744 /// wint_t towupper(wint_t wc);
2745 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/towupper.html
2746 pub extern fn towupper(wc: wint_t) wint_t;
2747
2748 /// wint_t towupper_l(wint_t wc, locale_t locale);
2749 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/towupper_l.html
2750 pub extern fn towupper_l(wc: wint_t, locale: locale_t) wint_t;
2751
2752 /// double trunc(double x);
2753 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/trunc.html
2754 pub extern fn trunc(x: f64) f64;
2755
2756 /// float truncf(float x);
2757 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/truncf.html
2758 pub extern fn truncf(x: f32) f32;
2759
2760 /// long double truncl(long double x);
2761 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/truncl.html
2762 pub extern fn truncl(x: c_longdouble) c_longdouble;
2763
2764 /// void tzset(void);
2765 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/tzset.html
2766 pub extern fn tzset() void;
2767
2768 /// long ulimit(int cmd, ...);
2769 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/ulimit.html
2770 pub extern fn ulimit(cmd: c_int, ...) c_long;
2771
2772 /// mode_t umask(mode_t cmask);
2773 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/umask.html
2774 pub extern fn umask(cmask: mode_t) mode_t;
2775
2776 /// int unlinkat(int fd, const char *path, int flag);
2777 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/unlinkat.html
2778 pub extern fn unlinkat(fd: c_int, name: [*:0]const u8, flag: c_int) c_int;
2779
2780 /// int unlockpt(int fildes);
2781 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/unlockpt.html
2782 pub extern fn unlockpt(fd: c_int) c_int;
2783
2784 /// locale_t uselocale(locale_t newloc);
2785 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/uselocale.html
2786 pub extern fn uselocale(newloc: locale_t) locale_t;
2787
2788 /// pid_t waitpid(pid_t pid, int *stat_loc, int options);
2789 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/waitpid.html
2790 pub extern fn waitpid(pid: pid_t, stat_loc: ?*c_int, options: c_int) pid_t;
2791
2792 /// int wctob(wint_t c);
2793 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/wctob.html
2794 pub extern fn wctob(c: wint_t) c_int;
2795
2796 /// int wcwidth(wchar_t wc);
2797 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/wcwidth.html
2798 pub extern fn wcwidth(wc: wchar_t) c_int;
2799
2800 /// ssize_t write(int fildes, const void *buf, size_t nbyte);
2801 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/write.html
2802 pub extern fn write(fd: c_int, buf: *const anyopaque, n: usize) isize;
2803
2804 /// ssize_t writev(int fildes, const struct iovec *iov, int iovcnt);
2805 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/writev.html
2806 pub extern fn writev(fd: c_int, iovec: [*]const struct_iovec, count: c_int) isize;
2807
2808 /// double y0(double x);
2809 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/y0.html
2810 pub extern fn y0(x: f64) f64;
2811
2812 /// double y1(double x);
2813 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/y1.html
2814 pub extern fn y1(x: f64) f64;
2815
2816 /// double yn(int n, double x);
2817 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/yn.html
2818 pub extern fn yn(n: c_int, x: f64) f64;
2819
2820 //
2821 //
2822
2823 pub extern fn __errno_location() *c_int;
2824 pub extern fn gettid() pid_t;
2825 pub extern fn accept4(socket: c_int, noalias address: ?*struct_sockaddr, noalias address_len: *socklen_t, flags: c_int) c_int;
2826 pub extern fn memfd_create(name: [*:0]const u8, flags: c_uint) c_int;
2827 pub extern fn sendfile(out_fd: c_int, in_fd: c_int, offset: ?*const off_t, count: usize) isize;
2828 pub extern fn getdents(dirfd: c_int, buf: [*]u8, nbytes: usize) c_int;
2829 pub extern fn sched_getaffinity(pid: pid_t, cpusetsize: usize, mask: *cpu_set_t) c_int;
2830 pub extern fn getrandom(buf: [*]u8, size: usize, flags: c_uint) isize;
2831 pub extern fn flock(fd: c_int, op: c_int) c_int;
2832 pub extern fn copy_file_range(fd_int: c_int, off_in: ?*off_t, fd_out: c_int, off_out: ?*off_t, size: usize, flags: c_uint) isize;
2833 pub extern fn arc4random_buf(buf: [*]u8, n: usize) void;
2834};
2835
2836comptime {
2837 const C = struct {
2838 fn getdents(dirfd: c_int, buf: [*]u8, nbytes: usize) callconv(.c) c_int {
2839 const rc = std.os.linux.syscall3(.getdents64, @intCast(dirfd), @intFromPtr(buf), nbytes);
2840 const signed_r: isize = @bitCast(rc);
2841 if (signed_r < 0 and signed_r > -4096) {
2842 libc.__errno_location().* = @intCast(-signed_r);
2843 return -1;
2844 }
2845 return @intCast(rc);
2846 }
2847 };
2848 if (builtin.abi.isGnu()) @export(&C.getdents, .{ .name = "getdents", .linkage = .weak }); // glibc chooses to only expose this as getdents64
2849}
2850
2851pub const clock_t = c_long;
2852pub const pid_t = c_int;
2853pub const gid_t = c_uint;
2854pub const uid_t = c_uint;
2855pub const struct_group = opaque {};
2856pub const struct_hostent = opaque {};
2857pub const struct_netent = opaque {};
2858pub const struct_protoent = opaque {};
2859pub const struct_passwd = opaque {};
2860pub const struct_servent = opaque {};
2861pub const struct_utmpx = opaque {};
2862pub const wint_t = c_uint;
2863pub const struct_if_nameindex = opaque {};
2864pub const struct_lconv = opaque {};
2865pub const FILE = opaque {};
2866pub const locale_t = *const opaque {};
2867pub const nl_catd = *const opaque {};
2868pub const intmax_t = i64;
2869pub const wchar_t = c_int;
2870pub const mode_t = c_uint;
2871pub const socklen_t = c_uint;
2872pub const clockid_t = c_int;
2873pub const struct_timespec = extern struct { sec: isize, nsec: isize };
2874pub const struct_timeval = linux.timeval;
2875pub const DIR = opaque {};
2876pub const time_t = i64;
2877pub const div_t = extern struct { quot: c_int, rem: c_int };
2878pub const off_t = i64;
2879pub const ino_t = u64;
2880pub const dev_t = u64;
2881pub const nlink_t = c_ulong;
2882pub const blksize_t = c_long;
2883pub const blkcnt_t = i64;
2884pub const struct_stat = switch (arch) {
2885 .mips64, .mips64el => extern struct { dev: dev_t, __pad1: [3]c_int, ino: ino_t, mode: mode_t, nlink: nlink_t, uid: uid_t, gid: gid_t, rdev: dev_t, __pad2: [2]c_uint, size: off_t, __pad3: c_int, atim: struct_timespec, mtim: struct_timespec, ctim: struct_timespec, blksize: blksize_t, __pad4: c_uint, blocks: blkcnt_t, __pad5: [14]c_int },
2886 .powerpc64, .powerpc64le => extern struct { dev: dev_t, ino: ino_t, nlink: nlink_t, mode: mode_t, uid: uid_t, gid: gid_t, rdev: dev_t, size: off_t, blksize: blksize_t, blocks: blkcnt_t, atim: struct_timespec, mtim: struct_timespec, ctim: struct_timespec, __unused: [3]c_ulong },
2887 .s390x => extern struct { dev: dev_t, ino: ino_t, nlink: nlink_t, mode: mode_t, uid: uid_t, gid: gid_t, rdev: dev_t, size: off_t, atim: struct_timespec, mtim: struct_timespec, ctim: struct_timespec, blksize: blksize_t, blocks: blkcnt_t, __unused: [3]c_ulong },
2888 .x86_64 => extern struct { dev: dev_t, ino: ino_t, nlink: nlink_t, mode: mode_t, uid: uid_t, gid: gid_t, __pad0: c_uint, rdev: dev_t, size: off_t, blksize: blksize_t, blocks: blkcnt_t, atim: struct_timespec, mtim: struct_timespec, ctim: struct_timespec, __unused: [3]c_long },
2889 // generic
2890 .aarch64,
2891 .riscv64,
2892 => extern struct { dev: dev_t, ino: ino_t, mode: mode_t, nlink: nlink_t, uid: uid_t, gid: gid_t, rdev: dev_t, __pad: c_ulonglong, size: off_t, blksize: blksize_t, __pad2: c_int, blocks: blkcnt_t, atim: struct_timespec, mtim: struct_timespec, ctim: struct_timespec, __unused: [2]c_uint },
2893 else => unreachable,
2894};
2895pub const struct_iovec = extern struct { base: [*]u8, len: usize };
2896pub const in_addr_t = u32;
2897pub const in_port_t = u16;
2898pub const sa_family_t = c_ushort;
2899pub const struct_in_addr = extern struct { addr: in_addr_t };
2900pub const struct_in6_addr = extern struct { addr: [16]u8 };
2901pub const struct_sockaddr = extern struct { family: AF, data: [14]u8 };
2902pub const struct_sockaddr_in = extern struct { family: AF = .INET, port: in_port_t, addr: struct_in_addr, zero: [8]u8 = @splat(0) };
2903pub const struct_sockaddr_in6 = extern struct { family: AF = .INET6, port: in_port_t, flowinfo: u32, addr: struct_in6_addr, scope_id: u32 };
2904pub const struct_sockaddr_un = extern struct { family: AF = .UNIX, path: [108]u8 };
2905pub const struct_addrinfo = extern struct { flags: c_int, family: c_int, socktype: c_int, protocol: c_int, addrlen: socklen_t, addr: ?*struct_sockaddr, canonname: ?[*:0]u8, next: ?*struct_addrinfo };
2906pub const struct_dirent = extern struct { ino: ino_t, off: off_t, reclen: c_ushort, type: DT, name: [NAME_MAX + 1]u8 };
2907pub const cpu_set_t = [1024 / 8 / @sizeOf(c_ulong)]c_ulong;
2908pub const nfds_t = c_ulong;
2909pub const struct_pollfd = extern struct { fd: c_int, events: c_short, revents: c_short };
2910pub const struct_tm = extern struct { sec: c_int, min: c_int, hour: c_int, mday: c_int, mon: c_int, year: c_int, wday: c_int, yday: c_int, isdst: c_int, gmtoff: c_long, zone: [*:0]const u8 };
2911
2912const impdef = @import("c");
2913pub const pthread_t = impdef.pthread_t;
2914pub const pthread_attr_t = impdef.pthread_attr_t;
2915pub const pthread_mutexattr_t = impdef.pthread_mutexattr_t;
2916pub const pthread_mutex_t = impdef.pthread_mutex_t;
2917pub const pthread_condattr_t = impdef.pthread_condattr_t;
2918pub const pthread_cond_t = impdef.pthread_cond_t;
2919pub const pthread_rwlockattr_t = impdef.pthread_rwlockattr_t;
2920pub const pthread_rwlock_t = impdef.pthread_rwlock_t;
2921
2922pub const AT = struct {
2923 pub const FDCWD = -100;
2924 pub const SYMLINK_NOFOLLOW = 0x100;
2925 pub const REMOVEDIR = 0x200;
2926 pub const SYMLINK_FOLLOW = 0x400;
2927 pub const EACCESS = 0x200;
2928};
2929
2930pub const O = struct {
2931 pub const CREAT = if (arch != .mips64el) 0o100 else 0o400;
2932 pub const EXCL = if (arch != .mips64el) 0o200 else 0o2000;
2933 pub const NOCTTY = if (arch != .mips64el) 0o400 else 0o4000;
2934 pub const TRUNC = 0o1000;
2935 pub const APPEND = if (arch != .mips64el) 0o2000 else 0o010;
2936 pub const NONBLOCK = if (arch != .mips64el) 0o4000 else 0o200;
2937 pub const DSYNC = if (arch != .mips64el) 0o10000 else 0o020;
2938 pub const SYNC = if (arch != .mips64el) 0o4010000 else 0o40020;
2939 pub const RSYNC = if (arch != .mips64el) 0o4010000 else 0o40020;
2940 pub const DIRECTORY = if (arch == .aarch64 or arch == .powerpc64le) 0o40000 else 0o200000;
2941 pub const NOFOLLOW = if (arch == .aarch64 or arch == .powerpc64le) 0o100000 else 0o400000;
2942 pub const CLOEXEC = 0o2000000;
2943 pub const ASYNC = if (arch != .mips64el) 0o20000 else 0o10000;
2944 pub const DIRECT = switch (arch) {
2945 .x86_64, .riscv64 => 0o40000, // generic
2946 .aarch64 => 0o200000,
2947 .powerpc64le => 0o400000,
2948 .mips64el => 0o100000,
2949 else => @compileError("TODO"),
2950 };
2951 pub const LARGEFILE = switch (arch) {
2952 .x86_64, .riscv64 => 0o100000, // generic
2953 .aarch64 => 0o400000,
2954 .powerpc64le => 0o200000,
2955 .mips64el => 0o20000,
2956 else => @compileError("TODO"),
2957 };
2958 pub const NOATIME = 0o1000000;
2959 pub const PATH = 0o10000000;
2960 pub const TMPFILE = if (arch == .aarch64 or arch == .powerpc64le) 0o20040000 else 0o20200000;
2961 pub const NDELAY = O.NONBLOCK;
2962 pub const SEARCH = O.PATH;
2963 pub const EXEC = O.PATH;
2964 pub const TTY_INIT = 0;
2965 pub const ACCMODE = (3 | O.SEARCH);
2966 pub const RDONLY = 0;
2967 pub const WRONLY = 1;
2968 pub const RDWR = 2;
2969};
2970
2971pub const S = struct {
2972 pub const IFMT = 0o170000;
2973 pub const IFDIR = 0o040000;
2974 pub const IFCHR = 0o020000;
2975 pub const IFBLK = 0o060000;
2976 pub const IFREG = 0o100000;
2977 pub const IFIFO = 0o010000;
2978 pub const IFLNK = 0o120000;
2979 pub const IFSOCK = 0o140000;
2980 pub const IFWHT = 0o160000; //unused
2981
2982 pub const ISUID = 0o4000;
2983 pub const ISGID = 0o2000;
2984 pub const ISVTX = 0o1000;
2985 pub const IRUSR = 0o400;
2986 pub const IWUSR = 0o200;
2987 pub const IXUSR = 0o100;
2988 pub const IRWXU = 0o700;
2989 pub const IRGRP = 0o040;
2990 pub const IWGRP = 0o020;
2991 pub const IXGRP = 0o010;
2992 pub const IRWXG = 0o070;
2993 pub const IROTH = 0o004;
2994 pub const IWOTH = 0o002;
2995 pub const IXOTH = 0o001;
2996 pub const IRWXO = 0o007;
2997};
2998
2999pub const CLOCK = struct {
3000 pub const REALTIME = 0;
3001 pub const MONOTONIC = 1;
3002 pub const PROCESS_CPUTIME_ID = 2;
3003 pub const THREAD_CPUTIME_ID = 3;
3004 pub const MONOTONIC_RAW = 4;
3005 pub const REALTIME_COARSE = 5;
3006 pub const MONOTONIC_COARSE = 6;
3007 pub const BOOTTIME = 7;
3008 pub const REALTIME_ALARM = 8;
3009 pub const BOOTTIME_ALARM = 9;
3010 pub const SGI_CYCLE = 10;
3011 pub const TAI = 11;
3012};
3013
3014pub const MAP = struct {
3015 pub const FAILED = -1;
3016
3017 pub const SHARED = 0x01;
3018 pub const PRIVATE = 0x02;
3019 pub const SHARED_VALIDATE = 0x03;
3020 pub const TYPE = 0x0f;
3021 pub const FIXED = 0x10;
3022 pub const ANON = 0x20;
3023 pub const ANONYMOUS = ANON;
3024 pub const NORESERVE = 0x4000;
3025 pub const GROWSDOWN = 0x0100;
3026 pub const DENYWRITE = 0x0800;
3027 pub const EXECUTABLE = 0x1000;
3028 pub const LOCKED = 0x2000;
3029 pub const POPULATE = 0x8000;
3030 pub const NONBLOCK = 0x10000;
3031 pub const STACK = 0x20000;
3032 pub const HUGETLB = 0x40000;
3033 pub const SYNC = 0x80000;
3034 pub const FIXED_NOREPLACE = 0x100000;
3035 pub const FILE = 0;
3036
3037 pub const MAP_HUGE_SHIFT = 26;
3038 pub const MAP_HUGE_MASK = 0x3f;
3039 pub const MAP_HUGE_16KB = 14 << 26;
3040 pub const MAP_HUGE_64KB = 16 << 26;
3041 pub const MAP_HUGE_512KB = 19 << 26;
3042 pub const MAP_HUGE_1MB = 20 << 26;
3043 pub const MAP_HUGE_2MB = 21 << 26;
3044 pub const MAP_HUGE_8MB = 23 << 26;
3045 pub const MAP_HUGE_16MB = 24 << 26;
3046 pub const MAP_HUGE_32MB = 25 << 26;
3047 pub const MAP_HUGE_256MB = 28 << 26;
3048 pub const MAP_HUGE_512MB = 29 << 26;
3049 pub const MAP_HUGE_1GB = 30 << 26;
3050 pub const MAP_HUGE_2GB = 31 << 26;
3051 pub const MAP_HUGE_16GB = 34 << 26;
3052};
3053
3054pub const PROT = struct {
3055 pub const NONE = 0;
3056 pub const READ = 1;
3057 pub const WRITE = 2;
3058 pub const EXEC = 4;
3059 pub const GROWSDOWN = 0x01000000;
3060 pub const GROWSUP = 0x02000000;
3061};
3062
3063pub const NAME_MAX = 255;
3064pub const PATH_MAX = 4096;
3065pub const NGROUPS_MAX = 32;
3066pub const ARG_MAX = 131072;
3067pub const IOV_MAX = 1024;
3068pub const SYMLOOP_MAX = 40;
3069pub const TZNAME_MAX = 6;
3070pub const TTY_NAME_MAX = 32;
3071pub const HOST_NAME_MAX = 255;
3072
3073pub const AF = enum(sa_family_t) {
3074 UNSPEC = 0,
3075 LOCAL = 1,
3076 INET = 2,
3077 AX25 = 3,
3078 IPX = 4,
3079 APPLETALK = 5,
3080 NETROM = 6,
3081 BRIDGE = 7,
3082 ATMPVC = 8,
3083 X25 = 9,
3084 INET6 = 10,
3085 ROSE = 11,
3086 DECnet = 12,
3087 NETBEUI = 13,
3088 SECURITY = 14,
3089 KEY = 15,
3090 NETLINK = 16,
3091 PACKET = 17,
3092 ASH = 18,
3093 ECONET = 19,
3094 ATMSVC = 20,
3095 RDS = 21,
3096 SNA = 22,
3097 IRDA = 23,
3098 PPPOX = 24,
3099 WANPIPE = 25,
3100 LLC = 26,
3101 IB = 27,
3102 MPLS = 28,
3103 CAN = 29,
3104 TIPC = 30,
3105 BLUETOOTH = 31,
3106 IUCV = 32,
3107 RXRPC = 33,
3108 ISDN = 34,
3109 PHONET = 35,
3110 IEEE802154 = 36,
3111 CAIF = 37,
3112 ALG = 38,
3113 NFC = 39,
3114 VSOCK = 40,
3115 KCM = 41,
3116 QIPCRTR = 42,
3117 SMC = 43,
3118 XDP = 44,
3119
3120 pub const UNIX: AF = .LOCAL;
3121 pub const FILE: AF = .LOCAL;
3122 pub const ROUTE: AF = .NETLINK;
3123};
3124
3125pub const SOCK = struct {
3126 pub const STREAM = 1;
3127 pub const DGRAM = 2;
3128 pub const RAW = 3;
3129 pub const RDM = 4;
3130 pub const SEQPACKET = 5;
3131 pub const DCCP = 6;
3132 pub const PACKET = 10;
3133 pub const CLOEXEC = 0o2000000;
3134 pub const NONBLOCK = 0o4000;
3135};
3136
3137pub const SHUT = enum(c_int) {
3138 RD = 0,
3139 WR = 1,
3140 RDWR = 2,
3141};
3142
3143pub const IPPROTO = struct {
3144 pub const IP = 0;
3145 pub const HOPOPTS = 0;
3146 pub const ICMP = 1;
3147 pub const IGMP = 2;
3148 pub const IPIP = 4;
3149 pub const TCP = 6;
3150 pub const EGP = 8;
3151 pub const PUP = 12;
3152 pub const UDP = 17;
3153 pub const IDP = 22;
3154 pub const TP = 29;
3155 pub const DCCP = 33;
3156 pub const IPV6 = 41;
3157 pub const ROUTING = 43;
3158 pub const FRAGMENT = 44;
3159 pub const RSVP = 46;
3160 pub const GRE = 47;
3161 pub const ESP = 50;
3162 pub const AH = 51;
3163 pub const ICMPV6 = 58;
3164 pub const NONE = 59;
3165 pub const DSTOPTS = 60;
3166 pub const MTP = 92;
3167 pub const BEETPH = 94;
3168 pub const ENCAP = 98;
3169 pub const PIM = 103;
3170 pub const COMP = 108;
3171 pub const SCTP = 132;
3172 pub const MH = 135;
3173 pub const UDPLITE = 136;
3174 pub const MPLS = 137;
3175 pub const ETHERNET = 143;
3176 pub const RAW = 255;
3177 pub const MPTCP = 262;
3178};
3179
3180pub const SOL = struct {
3181 pub const SOCKET = 1;
3182 pub const IP = 0;
3183 pub const IPV6 = 41;
3184 pub const ICMPV6 = 58;
3185 pub const RAW = 255;
3186 pub const DECNET = 261;
3187 pub const X25 = 262;
3188 pub const PACKET = 263;
3189 pub const ATM = 264;
3190 pub const AAL = 265;
3191 pub const IRDA = 266;
3192 pub const NETBEUI = 267;
3193 pub const LLC = 268;
3194 pub const DCCP = 269;
3195 pub const NETLINK = 270;
3196 pub const TIPC = 271;
3197 pub const RXRPC = 272;
3198 pub const PPPOL2TP = 273;
3199 pub const BLUETOOTH = 274;
3200 pub const PNPIPE = 275;
3201 pub const RDS = 276;
3202 pub const IUCV = 277;
3203 pub const CAIF = 278;
3204 pub const ALG = 279;
3205 pub const NFC = 280;
3206 pub const KCM = 281;
3207 pub const TLS = 282;
3208 pub const XDP = 283;
3209};
3210
3211pub const SO = struct {
3212 pub const DEBUG = 1;
3213 pub const REUSEADDR = 2;
3214 pub const TYPE = 3;
3215 pub const ERROR = 4;
3216 pub const DONTROUTE = 5;
3217 pub const BROADCAST = 6;
3218 pub const SNDBUF = 7;
3219 pub const RCVBUF = 8;
3220 pub const KEEPALIVE = 9;
3221 pub const OOBINLINE = 10;
3222 pub const NO_CHECK = 11;
3223 pub const PRIORITY = 12;
3224 pub const LINGER = 13;
3225 pub const BSDCOMPAT = 14;
3226 pub const REUSEPORT = 15;
3227 pub const PASSCRED = 16;
3228 pub const PEERCRED = 17;
3229 pub const RCVLOWAT = 18;
3230 pub const SNDLOWAT = 19;
3231
3232 pub const RCVTIMEO = 20;
3233 pub const SNDTIMEO = 21;
3234
3235 pub const ACCEPTCONN = 30;
3236 pub const PEERSEC = 31;
3237 pub const SNDBUFFORCE = 32;
3238 pub const RCVBUFFORCE = 33;
3239 pub const PROTOCOL = 38;
3240 pub const DOMAIN = 39;
3241};
3242
3243pub const DT = enum(u8) {
3244 UNKNOWN = 0,
3245 FIFO = 1,
3246 CHR = 2,
3247 DIR = 4,
3248 BLK = 6,
3249 REG = 8,
3250 LNK = 10,
3251 SOCK = 12,
3252 WHT = 14,
3253};
3254
3255pub const GRND = struct {
3256 pub const NONBLOCK = 0x0001;
3257 pub const RANDOM = 0x0002;
3258 pub const INSECURE = 0x0004;
3259};
3260
3261pub const LOCK = struct {
3262 pub const SH = 1;
3263 pub const EX = 2;
3264 pub const NB = 4;
3265 pub const UN = 8;
3266};
3267
3268pub const SIG = struct {
3269 pub const HUP = 1;
3270 pub const INT = 2;
3271 pub const QUIT = 3;
3272 pub const ILL = 4;
3273 pub const TRAP = 5;
3274 pub const ABRT = 6;
3275 pub const IOT = ABRT;
3276 pub const BUS = 7;
3277 pub const FPE = 8;
3278 pub const KILL = 9;
3279 pub const USR1 = 10;
3280 pub const SEGV = 11;
3281 pub const USR2 = 12;
3282 pub const PIPE = 13;
3283 pub const ALRM = 14;
3284 pub const TERM = 15;
3285 pub const STKFLT = 16;
3286 pub const CHLD = 17;
3287 pub const CONT = 18;
3288 pub const STOP = 19;
3289 pub const TSTP = 20;
3290 pub const TTIN = 21;
3291 pub const TTOU = 22;
3292 pub const URG = 23;
3293 pub const XCPU = 24;
3294 pub const XFSZ = 25;
3295 pub const VTALRM = 26;
3296 pub const PROF = 27;
3297 pub const WINCH = 28;
3298 pub const IO = 29;
3299 pub const POLL = 29;
3300 pub const PWR = 30;
3301 pub const SYS = 31;
3302 pub const UNUSED = SYS;
3303};
3304
3305pub const POLL = struct {
3306 pub const IN = 0x001;
3307 pub const PRI = 0x002;
3308 pub const OUT = 0x004;
3309 pub const ERR = 0x008;
3310 pub const HUP = 0x010;
3311 pub const NVAL = 0x020;
3312 pub const RDNORM = 0x040;
3313 pub const RDBAND = 0x080;
3314 pub const WRNORM = if (arch.isMIPS()) OUT else 0x100;
3315 pub const WRBAND = if (arch.isMIPS()) 0x100 else 0x200;
3316 pub const MSG = 0x400;
3317 pub const RDHUP = 0x2000;
3318};
3319
3320pub const W = struct {
3321 pub const NOHANG = 1;
3322 pub const UNTRACED = 2;
3323 pub const STOPPED = 2;
3324 pub const EXITED = 4;
3325 pub const CONTINUED = 8;
3326 pub const NOWAIT = 0x1000000;
3327
3328 pub fn EXITSTATUS(s: c_int) u8 {
3329 return @intCast((s & 0xff00) >> 8);
3330 }
3331 pub fn TERMSIG(s: c_int) u8 {
3332 return @intCast(s & 0x7f);
3333 }
3334 pub fn STOPSIG(s: c_int) u8 {
3335 return EXITSTATUS(s);
3336 }
3337 pub fn COREDUMP(s: c_int) c_uint {
3338 return s & 0x80;
3339 }
3340 pub fn IFEXITED(s: c_int) bool {
3341 return TERMSIG(s) == 0;
3342 }
3343 pub fn IFSTOPPED(s: c_int) bool {
3344 return ((s & 0xffff) *% 0x10001) >> 8 > 0x7f00;
3345 }
3346 pub fn IFSIGNALED(s: c_int) bool {
3347 return s & 0xffff -% 1 < 0xff;
3348 }
3349 pub fn IFCONTINUED(s: c_int) bool {
3350 return s == 0xffff;
3351 }
3352};
3353
3354pub const SEEK = struct {
3355 pub const SET = 0;
3356 pub const CUR = 1;
3357 pub const END = 2;
3358 pub const DATA = 3;
3359 pub const HOLE = 4;
3360};
3361
3362pub const IPV6 = struct {
3363 pub const ADDRFORM = 1;
3364 pub const @"2292PKTINFO" = 2;
3365 pub const @"2292HOPOPTS" = 3;
3366 pub const @"2292DSTOPTS" = 4;
3367 pub const @"2292RTHDR" = 5;
3368 pub const @"2292PKTOPTIONS" = 6;
3369 pub const CHECKSUM = 7;
3370 pub const @"2292HOPLIMIT" = 8;
3371 pub const NEXTHOP = 9;
3372 pub const AUTHHDR = 10;
3373 pub const UNICAST_HOPS = 16;
3374 pub const MULTICAST_IF = 17;
3375 pub const MULTICAST_HOPS = 18;
3376 pub const MULTICAST_LOOP = 19;
3377 pub const JOIN_GROUP = 20;
3378 pub const LEAVE_GROUP = 21;
3379 pub const ROUTER_ALERT = 22;
3380 pub const MTU_DISCOVER = 23;
3381 pub const MTU = 24;
3382 pub const RECVERR = 25;
3383 pub const V6ONLY = 26;
3384 pub const JOIN_ANYCAST = 27;
3385 pub const LEAVE_ANYCAST = 28;
3386 pub const MULTICAST_ALL = 29;
3387 pub const ROUTER_ALERT_ISOLATE = 30;
3388 pub const IPSEC_POLICY = 34;
3389 pub const XFRM_POLICY = 35;
3390 pub const HDRINCL = 36;
3391 pub const RECVPKTINFO = 49;
3392 pub const PKTINFO = 50;
3393 pub const RECVHOPLIMIT = 51;
3394 pub const HOPLIMIT = 52;
3395 pub const RECVHOPOPTS = 53;
3396 pub const HOPOPTS = 54;
3397 pub const RTHDRDSTOPTS = 55;
3398 pub const RECVRTHDR = 56;
3399 pub const RTHDR = 57;
3400 pub const RECVDSTOPTS = 58;
3401 pub const DSTOPTS = 59;
3402 pub const RECVPATHMTU = 60;
3403 pub const PATHMTU = 61;
3404 pub const DONTFRAG = 62;
3405 pub const RECVTCLASS = 66;
3406 pub const TCLASS = 67;
3407 pub const AUTOFLOWLABEL = 70;
3408 pub const ADDR_PREFERENCES = 72;
3409 pub const MINHOPCOUNT = 73;
3410 pub const ORIGDSTADDR = 74;
3411 pub const RECVORIGDSTADDR = ORIGDSTADDR;
3412 pub const TRANSPARENT = 75;
3413 pub const UNICAST_IF = 76;
3414 pub const RECVFRAGSIZE = 77;
3415 pub const FREEBIND = 78;
3416};
3417
3418pub fn getpid() pid_t {
3419 return libc.getpid();
3420}
3421pub fn exit(status: c_int) noreturn {
3422 return libc.exit(status);
3423}
3424pub fn getenv(name: [:0]const u8) ?[:0]u8 {
3425 return std.mem.sliceTo(libc.getenv(name.ptr) orelse return null, 0);
3426}
3427pub fn openat(fd: c_int, file: [*:0]const u8, oflag: c_int) errno.Error!c_int {
3428 const rc = libc.openat(fd, file, oflag);
3429 if (rc == -1) return errno.fromInt(errno.fromLibC());
3430 return rc;
3431}
3432pub fn openat4(fd: c_int, file: [*:0]const u8, oflag: c_int, mode: mode_t) errno.Error!c_int {
3433 const rc = libc.openat(fd, file, oflag, mode);
3434 if (rc == -1) return errno.fromInt(errno.fromLibC());
3435 return rc;
3436}
3437pub fn close(fd: c_int) errno.Error!void {
3438 const rc = libc.close(fd);
3439 if (rc == -1) return errno.fromInt(errno.fromLibC());
3440 std.debug.assert(rc == 0);
3441}
3442pub fn read(fd: c_int, buf: []u8) errno.Error!usize {
3443 const rc = libc.read(fd, buf.ptr, buf.len);
3444 if (rc == -1) return errno.fromInt(errno.fromLibC());
3445 std.debug.assert(rc >= 0);
3446 return @intCast(rc);
3447}
3448pub fn fstat(fd: c_int) errno.Error!struct_stat {
3449 var buf: struct_stat = undefined;
3450 const rc = libc.fstat(fd, &buf);
3451 if (rc == -1) return errno.fromInt(errno.fromLibC());
3452 std.debug.assert(rc == 0);
3453 return buf;
3454}
3455pub fn readv(fd: c_int, bufs: []const struct_iovec) errno.Error!usize {
3456 std.debug.assert(bufs.len > 0);
3457 std.debug.assert(bufs.len <= IOV_MAX);
3458 const rc = libc.readv(fd, bufs.ptr, @intCast(bufs.len));
3459 if (rc == -1) return errno.fromInt(errno.fromLibC());
3460 std.debug.assert(rc >= 0);
3461 return @intCast(rc);
3462}
3463pub fn mkdirat(fd: c_int, path: [*:0]const u8, mode: mode_t) errno.Error!void {
3464 const rc = libc.mkdirat(fd, path, mode);
3465 if (rc == -1) return errno.fromInt(errno.fromLibC());
3466 std.debug.assert(rc == 0);
3467}
3468pub fn pthread_self() pthread_t {
3469 return libc.pthread_self();
3470}
3471pub fn gettid() pid_t {
3472 return libc.gettid();
3473}
3474pub fn fstatat(fd: c_int, path: [*:0]const u8, flag: c_int) errno.Error!struct_stat {
3475 var buf: struct_stat = undefined;
3476 const rc = libc.fstatat(fd, path, &buf, flag);
3477 if (rc == -1) return errno.fromInt(errno.fromLibC());
3478 std.debug.assert(rc == 0);
3479 return buf;
3480}
3481pub fn socket(domain: AF, ty: c_int, protocol: c_int) errno.Error!c_uint {
3482 const rc = libc.socket(@backingInt(domain), ty, protocol);
3483 if (rc == -1) return errno.fromInt(errno.fromLibC());
3484 std.debug.assert(rc > 0);
3485 return @intCast(rc);
3486}
3487pub fn listen(socketfd: c_uint, backlog: c_int) errno.Error!void {
3488 const rc = libc.listen(@intCast(socketfd), backlog);
3489 if (rc == -1) return errno.fromInt(errno.fromLibC());
3490 std.debug.assert(rc == 0);
3491}
3492pub fn bind(socketfd: c_uint, address: *const struct_sockaddr, address_len: socklen_t) errno.Error!void {
3493 const rc = libc.bind(@intCast(socketfd), address, address_len);
3494 if (rc == -1) return errno.fromInt(errno.fromLibC());
3495 std.debug.assert(rc == 0);
3496}
3497pub fn connect(socketfd: c_uint, address: *const struct_sockaddr, address_len: socklen_t) errno.Error!void {
3498 const rc = libc.connect(@intCast(socketfd), address, address_len);
3499 if (rc == -1) return errno.fromInt(errno.fromLibC());
3500 std.debug.assert(rc == 0);
3501}
3502pub fn shutdown(socketfd: c_uint, how: SHUT) errno.Error!void {
3503 const rc = libc.shutdown(@intCast(socketfd), @backingInt(how));
3504 if (rc == -1) return errno.fromInt(errno.fromLibC());
3505 std.debug.assert(rc == 0);
3506}
3507pub fn setsockopt(socketfd: c_uint, level: c_int, optname: c_int, opaque_opt: []const u8) errno.Error!void {
3508 const rc = libc.setsockopt(@intCast(socketfd), level, optname, opaque_opt.ptr, @intCast(opaque_opt.len));
3509 if (rc == -1) return errno.fromInt(errno.fromLibC());
3510 std.debug.assert(rc == 0);
3511}
3512pub fn accept4(socketfd: c_uint, noalias address: ?*struct_sockaddr, noalias address_len: *socklen_t, flags: c_int) errno.Error!c_uint {
3513 const rc = libc.accept4(@intCast(socketfd), address, address_len, flags);
3514 if (rc == -1) return errno.fromInt(errno.fromLibC());
3515 std.debug.assert(rc > 0);
3516 return @intCast(rc);
3517}
3518pub fn send(socketfd: c_uint, buffer: []const u8, flags: c_int) errno.Error!usize {
3519 const rc = libc.send(@intCast(socketfd), buffer.ptr, buffer.len, flags);
3520 if (rc == -1) return errno.fromInt(errno.fromLibC());
3521 std.debug.assert(rc >= 0);
3522 return @intCast(rc);
3523}
3524pub fn recv(socketfd: c_uint, buffer: []u8, flags: c_int) errno.Error!usize {
3525 const rc = libc.recv(@intCast(socketfd), buffer.ptr, buffer.len, flags);
3526 if (rc == -1) return errno.fromInt(errno.fromLibC());
3527 std.debug.assert(rc >= 0);
3528 return @intCast(rc);
3529}
3530pub fn getaddrinfo(noalias nodename: ?[*:0]const u8, noalias servname: ?[*:0]const u8, noalias req: ?*const struct_addrinfo) eai.Error!*const struct_addrinfo {
3531 var pai: *const struct_addrinfo = undefined;
3532 var hints = std.mem.zeroes(struct_addrinfo);
3533 const rc = libc.getaddrinfo(nodename, servname, req orelse &hints, &pai);
3534 if (rc < 0) return eai.fromInt(rc);
3535 std.debug.assert(rc == 0);
3536 return pai;
3537}
3538pub fn freeaddrinfo(ai: *const struct_addrinfo) void {
3539 return libc.freeaddrinfo(ai);
3540}
3541pub fn clock_gettime(clock_id: clockid_t) !struct_timespec {
3542 var tp: struct_timespec = undefined;
3543 const rc = libc.clock_gettime(clock_id, &tp);
3544 if (rc == -1) return errno.fromInt(errno.fromLibC());
3545 std.debug.assert(rc == 0);
3546 return tp;
3547}
3548pub fn memfd_create(name: [*:0]const u8, flags: c_uint) !c_int {
3549 const rc = libc.memfd_create(name, flags);
3550 if (rc == -1) return errno.fromInt(errno.fromLibC());
3551 std.debug.assert(rc >= 0);
3552 return rc;
3553}
3554pub fn readlinkat(dirfd: c_int, noalias path: [*:0]const u8, noalias buf: []u8) ![:0]u8 {
3555 const rc = libc.readlinkat(dirfd, path, buf.ptr, buf.len);
3556 if (rc == -1) return errno.fromInt(errno.fromLibC());
3557 std.debug.assert(rc >= 0);
3558 buf[@intCast(rc)] = 0;
3559 return buf[0..@intCast(rc) :0];
3560}
3561pub fn write(fd: c_int, buf: []const u8) !usize {
3562 const rc = libc.write(fd, buf.ptr, buf.len);
3563 if (rc == -1) return errno.fromInt(errno.fromLibC());
3564 std.debug.assert(rc >= 0);
3565 return @intCast(rc);
3566}
3567pub fn writev(fd: c_int, iovec: []const struct_iovec) !usize {
3568 const rc = libc.writev(fd, iovec.ptr, @intCast(iovec.len));
3569 if (rc == -1) return errno.fromInt(errno.fromLibC());
3570 std.debug.assert(rc >= 0);
3571 return @intCast(rc);
3572}
3573pub fn getsockname(socketfd: c_uint, noalias address: *struct_sockaddr, noalias address_len: *socklen_t) errno.Error!void {
3574 const rc = libc.getsockname(@intCast(socketfd), address, address_len);
3575 if (rc == -1) return errno.fromInt(errno.fromLibC());
3576 std.debug.assert(rc == 0);
3577}
3578pub fn sendfile(out_fd: c_int, in_fd: c_int, offset: ?*const off_t, count: usize) errno.Error!usize {
3579 const rc = libc.sendfile(out_fd, in_fd, offset, count);
3580 if (rc == -1) return errno.fromInt(errno.fromLibC());
3581 std.debug.assert(rc >= 0);
3582 return @intCast(rc);
3583}
3584pub fn getdents(dirfd: c_int, buf: []u8) errno.Error!usize {
3585 const rc = libc.getdents(dirfd, buf.ptr, buf.len);
3586 if (rc == -1) return errno.fromInt(errno.fromLibC());
3587 std.debug.assert(rc >= 0);
3588 return @intCast(rc);
3589}
3590pub fn renameat(oldfd: c_int, old: [*:0]const u8, newfd: c_int, new: [*:0]const u8) !void {
3591 const rc = libc.renameat(oldfd, old, newfd, new);
3592 if (rc == -1) return errno.fromInt(errno.fromLibC());
3593 std.debug.assert(rc == 0);
3594}
3595pub fn mmap(addr: ?*anyopaque, len: usize, prot: c_int, flags: c_int, fd: c_int, offset: off_t) errno.Error![]u8 {
3596 const rc = libc.mmap(addr, len, prot, flags, fd, offset);
3597 if (@intFromPtr(rc) == MAP.FAILED) return errno.fromInt(errno.fromLibC());
3598 const ptr: [*]u8 = @ptrCast(rc);
3599 return ptr[0..len];
3600}
3601pub fn munmap(addr: *const anyopaque, len: usize) errno.Error!void {
3602 const rc = libc.munmap(addr, len);
3603 if (rc == -1) return errno.fromInt(errno.fromLibC());
3604 std.debug.assert(rc == 0);
3605}
3606pub fn sched_getaffinity(pid: pid_t) !cpu_set_t {
3607 var cpuset: cpu_set_t = undefined;
3608 const rc = libc.sched_getaffinity(pid, @sizeOf(cpu_set_t), &cpuset);
3609 if (rc == -1) return errno.fromInt(errno.fromLibC());
3610 std.debug.assert(rc == 0);
3611 return cpuset;
3612}
3613pub fn mkdtemp(template: [*:0]u8) ![*:0]u8 {
3614 const rc = libc.mkdtemp(template);
3615 if (rc == null) return errno.fromInt(errno.fromLibC());
3616 return rc.?;
3617}
3618pub fn getrandom(buf: []u8, flags: c_uint) ![]u8 {
3619 const rc = libc.getrandom(buf.ptr, buf.len, flags);
3620 if (rc == -1) return errno.fromInt(errno.fromLibC());
3621 std.debug.assert(rc >= 0);
3622 return buf[0..@intCast(rc)];
3623}
3624pub fn flock(fd: c_int, op: c_int) !void {
3625 const rc = libc.flock(fd, op);
3626 if (rc == -1) return errno.fromInt(errno.fromLibC());
3627 std.debug.assert(rc == 0);
3628}
3629pub fn futimens(fd: c_int, times: [2]struct_timespec) !void {
3630 const rc = libc.futimens(fd, &times);
3631 if (rc == -1) return errno.fromInt(errno.fromLibC());
3632 std.debug.assert(rc == 0);
3633}
3634pub fn faccessat(fd: c_int, path: [*:0]const u8, amode: c_int, flag: c_int) !void {
3635 const rc = libc.faccessat(fd, path, amode, flag);
3636 if (rc == -1) return errno.fromInt(errno.fromLibC());
3637 std.debug.assert(rc == 0);
3638}
3639pub fn pipe2(flag: c_int) ![2]c_int {
3640 var fildes: [2]c_int = @splat(-1);
3641 const rc = libc.pipe2(&fildes, flag);
3642 if (rc == -1) return errno.fromInt(errno.fromLibC());
3643 std.debug.assert(rc == 0);
3644 return fildes;
3645}
3646pub fn kill(pid: pid_t, sig: c_int) !void {
3647 const rc = libc.kill(pid, sig);
3648 if (rc == -1) return errno.fromInt(errno.fromLibC());
3649 std.debug.assert(rc == 0);
3650}
3651pub fn fork() !pid_t {
3652 const rc = libc.fork();
3653 if (rc == -1) return errno.fromInt(errno.fromLibC());
3654 std.debug.assert(rc >= 0);
3655 return rc;
3656}
3657pub fn fchdir(fildes: c_int) !void {
3658 const rc = libc.fchdir(fildes);
3659 if (rc == -1) return errno.fromInt(errno.fromLibC());
3660 std.debug.assert(rc == 0);
3661}
3662pub fn execvp(file: [*:0]const u8, argv: [*:null]const ?[*:0]const u8) !noreturn {
3663 const rc = libc.execvp(file, argv);
3664 std.debug.assert(rc == -1);
3665 return errno.fromInt(errno.fromLibC());
3666}
3667pub fn dup2(fildes: c_int, fildes2: c_int) !void {
3668 const rc = libc.dup2(fildes, fildes2);
3669 if (rc == -1) return errno.fromInt(errno.fromLibC());
3670 std.debug.assert(rc >= 0);
3671}
3672pub fn poll(fds: []struct_pollfd, timeout_ms: c_int) !c_int {
3673 const rc = libc.poll(fds.ptr, fds.len, timeout_ms);
3674 if (rc == -1) return errno.fromInt(errno.fromLibC());
3675 std.debug.assert(rc >= 0);
3676 return rc;
3677}
3678pub fn waitpid(pid: pid_t, options: c_int) !struct { pid_t, c_int } {
3679 var status: c_int = 0;
3680 const rc = libc.waitpid(pid, &status, options);
3681 if (rc == -1) return errno.fromInt(errno.fromLibC());
3682 std.debug.assert(rc >= 0);
3683 return .{ rc, status };
3684}
3685pub fn unlinkat(fd: c_int, name: [*:0]const u8, flag: c_int) !void {
3686 const rc = libc.unlinkat(fd, name, flag);
3687 if (rc == -1) return errno.fromInt(errno.fromLibC());
3688 std.debug.assert(rc == 0);
3689}
3690pub fn lseek(fd: c_int, offset: off_t, whence: c_int) !void {
3691 const rc = libc.lseek(fd, offset, whence);
3692 if (rc == -1) return errno.fromInt(errno.fromLibC());
3693 std.debug.assert(rc >= 0);
3694}
3695pub fn getcwd(buf: []u8) ![*:0]u8 {
3696 const rc = libc.getcwd(buf.ptr, buf.len);
3697 if (rc == null) return errno.fromInt(errno.fromLibC());
3698 return rc.?;
3699}
3700pub fn fchmod(fd: c_int, mode: mode_t) !void {
3701 const rc = libc.fchmod(fd, mode);
3702 if (rc == -1) return errno.fromInt(errno.fromLibC());
3703 std.debug.assert(rc == 0);
3704}
3705pub fn copy_file_range(fd_int: c_int, off_in: ?*off_t, fd_out: c_int, off_out: ?*off_t, size: usize, flags: c_uint) errno.Error!usize {
3706 const rc = libc.copy_file_range(fd_int, off_in, fd_out, off_out, size, flags);
3707 if (rc == -1) return errno.fromInt(errno.fromLibC());
3708 std.debug.assert(rc >= 0);
3709 return @intCast(rc);
3710}
3711pub fn dup(fildes: c_int) !c_int {
3712 const rc = libc.dup(fildes);
3713 if (rc == -1) return errno.fromInt(errno.fromLibC());
3714 std.debug.assert(rc >= 0);
3715 return rc;
3716}