authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-05-24 19:36:09-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-05-26 18:32:44-04:00
log3d61e4228298dcb973c13d8d6eba0bff36acf1ca
treed20ca827bdbcfef862a3048df288e65c3971aab5
parent17b0166e004e81d9c433576f4c642e743fc527b7
signaturelock-open Commit is signed but in an unrecognized format.

rename "posix" to "bits"


30 files changed, 5384 insertions(+), 5381 deletions(-)

CMakeLists.txt+30-33
...@@ -474,10 +474,7 @@ set(ZIG_STD_FILES...@@ -474,10 +474,7 @@ set(ZIG_STD_FILES
474 "c/linux.zig"474 "c/linux.zig"
475 "c/netbsd.zig"475 "c/netbsd.zig"
476 "c/windows.zig"476 "c/windows.zig"
477 "c/posix.zig"477 "child_process.zig"
478 "c/posix/darwin.zig"
479 "c/posix/freebsd.zig"
480 "c/posix/windows.zig"
481 "coff.zig"478 "coff.zig"
482 "crypto.zig"479 "crypto.zig"
483 "crypto/blake2.zig"480 "crypto/blake2.zig"
...@@ -491,8 +488,8 @@ set(ZIG_STD_FILES...@@ -491,8 +488,8 @@ set(ZIG_STD_FILES
491 "crypto/x25519.zig"488 "crypto/x25519.zig"
492 "cstr.zig"489 "cstr.zig"
493 "debug.zig"490 "debug.zig"
494 "debug/leb128.zig"
495 "debug/failing_allocator.zig"491 "debug/failing_allocator.zig"
492 "debug/leb128.zig"
496 "dwarf.zig"493 "dwarf.zig"
497 "dynamic_library.zig"494 "dynamic_library.zig"
498 "elf.zig"495 "elf.zig"
...@@ -513,6 +510,10 @@ set(ZIG_STD_FILES...@@ -513,6 +510,10 @@ set(ZIG_STD_FILES
513 "fmt/errol/enum3.zig"510 "fmt/errol/enum3.zig"
514 "fmt/errol/lookup.zig"511 "fmt/errol/lookup.zig"
515 "fmt/parse_float.zig"512 "fmt/parse_float.zig"
513 "fs.zig"
514 "fs/file.zig"
515 "fs/get_app_data_dir.zig"
516 "fs/path.zig"
516 "hash.zig"517 "hash.zig"
517 "hash/adler.zig"518 "hash/adler.zig"
518 "hash/crc.zig"519 "hash/crc.zig"
...@@ -521,8 +522,8 @@ set(ZIG_STD_FILES...@@ -521,8 +522,8 @@ set(ZIG_STD_FILES
521 "hash_map.zig"522 "hash_map.zig"
522 "heap.zig"523 "heap.zig"
523 "io.zig"524 "io.zig"
524 "io/seekable_stream.zig"
525 "io/c_out_stream.zig"525 "io/c_out_stream.zig"
526 "io/seekable_stream.zig"
526 "json.zig"527 "json.zig"
527 "lazy_init.zig"528 "lazy_init.zig"
528 "linked_list.zig"529 "linked_list.zig"
...@@ -604,46 +605,40 @@ set(ZIG_STD_FILES...@@ -604,46 +605,40 @@ set(ZIG_STD_FILES
604 "mutex.zig"605 "mutex.zig"
605 "net.zig"606 "net.zig"
606 "os.zig"607 "os.zig"
607 "os/child_process.zig"608 "os/bits.zig"
609 "os/bits/darwin.zig"
610 "os/bits/freebsd.zig"
611 "os/bits/linux.zig"
612 "os/bits/linux/arm64.zig"
613 "os/bits/linux/errno.zig"
614 "os/bits/linux/x86_64.zig"
615 "os/bits/netbsd.zig"
616 "os/bits/wasi.zig"
617 "os/bits/windows.zig"
608 "os/darwin.zig"618 "os/darwin.zig"
609 "os/darwin/errno.zig"
610 "os/epoch.zig"619 "os/epoch.zig"
611 "os/file.zig"
612 "os/freebsd.zig"620 "os/freebsd.zig"
613 "os/freebsd/errno.zig"
614 "os/get_app_data_dir.zig"
615 "os/get_user_id.zig"
616 "os/linux.zig"621 "os/linux.zig"
617 "os/linux/arm64.zig"622 "os/linux/arm64.zig"
618 "os/linux/errno.zig"
619 "os/linux/posix.zig"
620 "os/linux/posix/arm64.zig"
621 "os/linux/posix/x86_64.zig"
622 "os/linux/sys.zig"623 "os/linux/sys.zig"
623 "os/linux/tls.zig"624 "os/linux/tls.zig"
624 "os/linux/vdso.zig"625 "os/linux/vdso.zig"
625 "os/linux/x86_64.zig"626 "os/linux/x86_64.zig"
626 "os/netbsd.zig"627 "os/netbsd.zig"
627 "os/netbsd/errno.zig"
628 "os/path.zig"
629 "os/posix.zig"
630 "os/time.zig"
631 "os/uefi.zig"628 "os/uefi.zig"
632 "os/wasi.zig"629 "os/wasi.zig"
633 "os/wasi/posix.zig"
634 "os/windows.zig"630 "os/windows.zig"
635 "os/windows/advapi32.zig"631 "os/windows/advapi32.zig"
636 "os/windows/errno.zig"
637 "os/windows/error.zig"632 "os/windows/error.zig"
638 "os/windows/kernel32.zig"633 "os/windows/kernel32.zig"
639 "os/windows/ntdll.zig"634 "os/windows/ntdll.zig"
640 "os/windows/ole32.zig"635 "os/windows/ole32.zig"
641 "os/windows/shell32.zig"636 "os/windows/shell32.zig"
642 "os/windows/util.zig"
643 "os/zen.zig"637 "os/zen.zig"
644 "packed_int_array.zig"638 "packed_int_array.zig"
645 "pdb.zig"639 "pdb.zig"
646 "priority_queue.zig"640 "priority_queue.zig"
641 "process.zig"
647 "rand.zig"642 "rand.zig"
648 "rand/ziggurat.zig"643 "rand/ziggurat.zig"
649 "rb.zig"644 "rb.zig"
...@@ -655,17 +650,18 @@ set(ZIG_STD_FILES...@@ -655,17 +650,18 @@ set(ZIG_STD_FILES
655 "special/build_runner.zig"650 "special/build_runner.zig"
656 "special/c.zig"651 "special/c.zig"
657 "special/compiler_rt.zig"652 "special/compiler_rt.zig"
658 "special/compiler_rt/stack_probe.zig"
659 "special/compiler_rt/arm/aeabi_fcmp.zig"
660 "special/compiler_rt/arm/aeabi_dcmp.zig"
661 "special/compiler_rt/addXf3.zig"653 "special/compiler_rt/addXf3.zig"
654 "special/compiler_rt/arm/aeabi_dcmp.zig"
655 "special/compiler_rt/arm/aeabi_fcmp.zig"
656 "special/compiler_rt/ashlti3.zig"
657 "special/compiler_rt/ashrti3.zig"
662 "special/compiler_rt/aulldiv.zig"658 "special/compiler_rt/aulldiv.zig"
663 "special/compiler_rt/aullrem.zig"659 "special/compiler_rt/aullrem.zig"
664 "special/compiler_rt/comparetf2.zig"
665 "special/compiler_rt/comparedf2.zig"660 "special/compiler_rt/comparedf2.zig"
666 "special/compiler_rt/comparesf2.zig"661 "special/compiler_rt/comparesf2.zig"
667 "special/compiler_rt/divsf3.zig"662 "special/compiler_rt/comparetf2.zig"
668 "special/compiler_rt/divdf3.zig"663 "special/compiler_rt/divdf3.zig"
664 "special/compiler_rt/divsf3.zig"
669 "special/compiler_rt/divti3.zig"665 "special/compiler_rt/divti3.zig"
670 "special/compiler_rt/extendXfYf2.zig"666 "special/compiler_rt/extendXfYf2.zig"
671 "special/compiler_rt/fixdfdi.zig"667 "special/compiler_rt/fixdfdi.zig"
...@@ -690,26 +686,25 @@ set(ZIG_STD_FILES...@@ -690,26 +686,25 @@ set(ZIG_STD_FILES
690 "special/compiler_rt/fixunstfti.zig"686 "special/compiler_rt/fixunstfti.zig"
691 "special/compiler_rt/floatdidf.zig"687 "special/compiler_rt/floatdidf.zig"
692 "special/compiler_rt/floatsiXf.zig"688 "special/compiler_rt/floatsiXf.zig"
693 "special/compiler_rt/floatunsidf.zig"
694 "special/compiler_rt/floattidf.zig"689 "special/compiler_rt/floattidf.zig"
695 "special/compiler_rt/floattisf.zig"690 "special/compiler_rt/floattisf.zig"
696 "special/compiler_rt/floattitf.zig"691 "special/compiler_rt/floattitf.zig"
697 "special/compiler_rt/floatundidf.zig"692 "special/compiler_rt/floatundidf.zig"
698 "special/compiler_rt/floatunditf.zig"693 "special/compiler_rt/floatunditf.zig"
694 "special/compiler_rt/floatunsidf.zig"
699 "special/compiler_rt/floatunsitf.zig"695 "special/compiler_rt/floatunsitf.zig"
700 "special/compiler_rt/floatuntidf.zig"696 "special/compiler_rt/floatuntidf.zig"
701 "special/compiler_rt/floatuntisf.zig"697 "special/compiler_rt/floatuntisf.zig"
702 "special/compiler_rt/floatuntitf.zig"698 "special/compiler_rt/floatuntitf.zig"
699 "special/compiler_rt/lshrti3.zig"
703 "special/compiler_rt/modti3.zig"700 "special/compiler_rt/modti3.zig"
704 "special/compiler_rt/mulXf3.zig"701 "special/compiler_rt/mulXf3.zig"
705 "special/compiler_rt/muloti4.zig"
706 "special/compiler_rt/mulodi4.zig"702 "special/compiler_rt/mulodi4.zig"
703 "special/compiler_rt/muloti4.zig"
707 "special/compiler_rt/multi3.zig"704 "special/compiler_rt/multi3.zig"
708 "special/compiler_rt/ashlti3.zig"
709 "special/compiler_rt/ashrti3.zig"
710 "special/compiler_rt/lshrti3.zig"
711 "special/compiler_rt/negXf2.zig"705 "special/compiler_rt/negXf2.zig"
712 "special/compiler_rt/popcountdi2.zig"706 "special/compiler_rt/popcountdi2.zig"
707 "special/compiler_rt/stack_probe.zig"
713 "special/compiler_rt/truncXfYf2.zig"708 "special/compiler_rt/truncXfYf2.zig"
714 "special/compiler_rt/udivmod.zig"709 "special/compiler_rt/udivmod.zig"
715 "special/compiler_rt/udivmoddi4.zig"710 "special/compiler_rt/udivmoddi4.zig"
...@@ -726,6 +721,8 @@ set(ZIG_STD_FILES...@@ -726,6 +721,8 @@ set(ZIG_STD_FILES
726 "statically_initialized_mutex.zig"721 "statically_initialized_mutex.zig"
727 "std.zig"722 "std.zig"
728 "testing.zig"723 "testing.zig"
724 "thread.zig"
725 "time.zig"
729 "unicode.zig"726 "unicode.zig"
730 "valgrind.zig"727 "valgrind.zig"
731 "valgrind/callgrind.zig"728 "valgrind/callgrind.zig"
std/c.zig+2-3
...@@ -1,10 +1,9 @@...@@ -1,10 +1,9 @@
1const builtin = @import("builtin");1const builtin = @import("builtin");
22
3pub const posix = @import("c/posix.zig");3pub use @import("os/bits.zig");
4pub use posix;
54
6pub use switch (builtin.os) {5pub use switch (builtin.os) {
7 .linux => @import("os/linux/posix.zig"),6 .linux => @import("c/linux.zig"),
8 .windows => @import("c/windows.zig"),7 .windows => @import("c/windows.zig"),
9 .macosx, .ios, .tvos, .watchos => @import("c/darwin.zig"),8 .macosx, .ios, .tvos, .watchos => @import("c/darwin.zig"),
10 .freebsd => @import("c/freebsd.zig"),9 .freebsd => @import("c/freebsd.zig"),
std/c/linux.zig+3-8
...@@ -1,17 +1,12 @@...@@ -1,17 +1,12 @@
1const linux = @import("../os/linux.zig");1const std = @import("../std.zig");
2pub use @import("../os/linux/errno.zig");2use std.c;
33
4pub extern "c" fn getrandom(buf_ptr: [*]u8, buf_len: usize, flags: c_uint) c_int;4pub extern "c" fn getrandom(buf_ptr: [*]u8, buf_len: usize, flags: c_uint) c_int;
5extern "c" fn __errno_location() *c_int;5extern "c" fn __errno_location() *c_int;
6pub const _errno = __errno_location;6pub const _errno = __errno_location;
77
8pub const pthread_attr_t = extern struct {
9 __size: [56]u8,
10 __align: c_long,
11};
12
13/// See std.elf for constants for this8/// See std.elf for constants for this
14pub extern fn getauxval(__type: c_ulong) c_ulong;9pub extern fn getauxval(__type: c_ulong) c_ulong;
1510
16pub const dl_iterate_phdr_callback = extern fn (info: *linux.dl_phdr_info, size: usize, data: ?*c_void) c_int;11pub const dl_iterate_phdr_callback = extern fn (info: *dl_phdr_info, size: usize, data: ?*c_void) c_int;
17pub extern fn dl_iterate_phdr(callback: dl_iterate_phdr_callback, data: ?*c_void) c_int;12pub extern fn dl_iterate_phdr(callback: dl_iterate_phdr_callback, data: ?*c_void) c_int;
std/c/posix.zig deleted-26
...@@ -1,26 +0,0 @@
1// Declarations that are intended to be imported into the POSIX namespace.
2
3const builtin = @import("builtin");
4
5pub use switch (builtin.os) {
6 .windows => @import("posix/windows.zig"),
7 .macosx, .ios, .tvos, .watchos => @import("posix/darwin.zig"),
8 .freebsd => @import("posix/freebsd.zig"),
9 .netbsd => @import("posix/netbsd.zig"),
10 else => struct {},
11};
12
13pub const fd_t = c_int;
14pub const pid_t = c_int;
15pub const pthread_t = *@OpaqueType();
16pub const FILE = @OpaqueType();
17
18pub const iovec = extern struct {
19 iov_base: [*]u8,
20 iov_len: usize,
21};
22
23pub const iovec_const = extern struct {
24 iov_base: [*]const u8,
25 iov_len: usize,
26};
std/c/posix/darwin.zig deleted-1099
...@@ -1,1099 +0,0 @@
1const std = @import("../std.zig");
2const assert = std.debug.assert;
3
4pub fn sigaction(sig: u5, noalias act: *const Sigaction, noalias oact: ?*Sigaction) usize {
5 assert(sig != SIGKILL);
6 assert(sig != SIGSTOP);
7 var cact = c.Sigaction{
8 .handler = @ptrCast(extern fn (c_int) void, act.handler),
9 .sa_flags = @bitCast(c_int, act.flags),
10 .sa_mask = act.mask,
11 };
12 var coact: c.Sigaction = undefined;
13 const result = errnoWrap(c.sigaction(sig, &cact, &coact));
14 if (result != 0) {
15 return result;
16 }
17 if (oact) |old| {
18 old.* = Sigaction{
19 .handler = @ptrCast(extern fn (i32) void, coact.handler),
20 .flags = @bitCast(u32, coact.sa_flags),
21 .mask = coact.sa_mask,
22 };
23 }
24 return result;
25}
26
27pub const in_port_t = u16;
28pub const sa_family_t = u8;
29pub const socklen_t = u32;
30pub const sockaddr = extern union {
31 in: sockaddr_in,
32 in6: sockaddr_in6,
33};
34pub const sockaddr_in = extern struct {
35 len: u8,
36 family: sa_family_t,
37 port: in_port_t,
38 addr: u32,
39 zero: [8]u8,
40};
41pub const sockaddr_in6 = extern struct {
42 len: u8,
43 family: sa_family_t,
44 port: in_port_t,
45 flowinfo: u32,
46 addr: [16]u8,
47 scope_id: u32,
48};
49
50pub const timeval = extern struct {
51 tv_sec: c_long,
52 tv_usec: i32,
53};
54
55pub const timezone = extern struct {
56 tz_minuteswest: i32,
57 tz_dsttime: i32,
58};
59
60pub const mach_timebase_info_data = extern struct {
61 numer: u32,
62 denom: u32,
63};
64
65/// Renamed to Stat to not conflict with the stat function.
66pub const Stat = extern struct {
67 dev: i32,
68 mode: u16,
69 nlink: u16,
70 ino: u64,
71 uid: u32,
72 gid: u32,
73 rdev: i32,
74 atime: usize,
75 atimensec: usize,
76 mtime: usize,
77 mtimensec: usize,
78 ctime: usize,
79 ctimensec: usize,
80 birthtime: usize,
81 birthtimensec: usize,
82 size: i64,
83 blocks: i64,
84 blksize: i32,
85 flags: u32,
86 gen: u32,
87 lspare: i32,
88 qspare: [2]i64,
89};
90
91pub const timespec = extern struct {
92 tv_sec: isize,
93 tv_nsec: isize,
94};
95
96pub const sigset_t = u32;
97pub const empty_sigset = sigset_t(0);
98
99/// Renamed from `sigaction` to `Sigaction` to avoid conflict with function name.
100pub const Sigaction = extern struct {
101 handler: extern fn (c_int) void,
102 sa_mask: sigset_t,
103 sa_flags: c_int,
104};
105
106pub const dirent = extern struct {
107 d_ino: usize,
108 d_seekoff: usize,
109 d_reclen: u16,
110 d_namlen: u16,
111 d_type: u8,
112 d_name: u8, // field address is address of first byte of name
113};
114
115pub const pthread_attr_t = extern struct {
116 __sig: c_long,
117 __opaque: [56]u8,
118};
119
120/// Renamed from `kevent` to `Kevent` to avoid conflict with function name.
121pub const Kevent = extern struct {
122 ident: usize,
123 filter: i16,
124 flags: u16,
125 fflags: u32,
126 data: isize,
127 udata: usize,
128};
129
130// sys/types.h on macos uses #pragma pack(4) so these checks are
131// to make sure the struct is laid out the same. These values were
132// produced from C code using the offsetof macro.
133comptime {
134 assert(@byteOffsetOf(Kevent, "ident") == 0);
135 assert(@byteOffsetOf(Kevent, "filter") == 8);
136 assert(@byteOffsetOf(Kevent, "flags") == 10);
137 assert(@byteOffsetOf(Kevent, "fflags") == 12);
138 assert(@byteOffsetOf(Kevent, "data") == 16);
139 assert(@byteOffsetOf(Kevent, "udata") == 24);
140}
141
142pub const kevent64_s = extern struct {
143 ident: u64,
144 filter: i16,
145 flags: u16,
146 fflags: u32,
147 data: i64,
148 udata: u64,
149 ext: [2]u64,
150};
151
152// sys/types.h on macos uses #pragma pack() so these checks are
153// to make sure the struct is laid out the same. These values were
154// produced from C code using the offsetof macro.
155comptime {
156 assert(@byteOffsetOf(kevent64_s, "ident") == 0);
157 assert(@byteOffsetOf(kevent64_s, "filter") == 8);
158 assert(@byteOffsetOf(kevent64_s, "flags") == 10);
159 assert(@byteOffsetOf(kevent64_s, "fflags") == 12);
160 assert(@byteOffsetOf(kevent64_s, "data") == 16);
161 assert(@byteOffsetOf(kevent64_s, "udata") == 24);
162 assert(@byteOffsetOf(kevent64_s, "ext") == 32);
163}
164
165pub const mach_port_t = c_uint;
166pub const clock_serv_t = mach_port_t;
167pub const clock_res_t = c_int;
168pub const mach_port_name_t = natural_t;
169pub const natural_t = c_uint;
170pub const mach_timespec_t = extern struct {
171 tv_sec: c_uint,
172 tv_nsec: clock_res_t,
173};
174pub const kern_return_t = c_int;
175pub const host_t = mach_port_t;
176pub const CALENDAR_CLOCK = 1;
177
178pub const PATH_MAX = 1024;
179
180pub const STDIN_FILENO = 0;
181pub const STDOUT_FILENO = 1;
182pub const STDERR_FILENO = 2;
183
184/// [MC2] no permissions
185pub const PROT_NONE = 0x00;
186
187/// [MC2] pages can be read
188pub const PROT_READ = 0x01;
189
190/// [MC2] pages can be written
191pub const PROT_WRITE = 0x02;
192
193/// [MC2] pages can be executed
194pub const PROT_EXEC = 0x04;
195
196/// allocated from memory, swap space
197pub const MAP_ANONYMOUS = 0x1000;
198
199/// map from file (default)
200pub const MAP_FILE = 0x0000;
201
202/// interpret addr exactly
203pub const MAP_FIXED = 0x0010;
204
205/// region may contain semaphores
206pub const MAP_HASSEMAPHORE = 0x0200;
207
208/// changes are private
209pub const MAP_PRIVATE = 0x0002;
210
211/// share changes
212pub const MAP_SHARED = 0x0001;
213
214/// don't cache pages for this mapping
215pub const MAP_NOCACHE = 0x0400;
216
217/// don't reserve needed swap area
218pub const MAP_NORESERVE = 0x0040;
219pub const MAP_FAILED = maxInt(usize);
220
221/// [XSI] no hang in wait/no child to reap
222pub const WNOHANG = 0x00000001;
223
224/// [XSI] notify on stop, untraced child
225pub const WUNTRACED = 0x00000002;
226
227/// take signal on signal stack
228pub const SA_ONSTACK = 0x0001;
229
230/// restart system on signal return
231pub const SA_RESTART = 0x0002;
232
233/// reset to SIG_DFL when taking signal
234pub const SA_RESETHAND = 0x0004;
235
236/// do not generate SIGCHLD on child stop
237pub const SA_NOCLDSTOP = 0x0008;
238
239/// don't mask the signal we're delivering
240pub const SA_NODEFER = 0x0010;
241
242/// don't keep zombies around
243pub const SA_NOCLDWAIT = 0x0020;
244
245/// signal handler with SA_SIGINFO args
246pub const SA_SIGINFO = 0x0040;
247
248/// do not bounce off kernel's sigtramp
249pub const SA_USERTRAMP = 0x0100;
250
251/// signal handler with SA_SIGINFO args with 64bit regs information
252pub const SA_64REGSET = 0x0200;
253
254pub const O_LARGEFILE = 0x0000;
255pub const O_PATH = 0x0000;
256
257pub const F_OK = 0;
258pub const X_OK = 1;
259pub const W_OK = 2;
260pub const R_OK = 4;
261
262/// open for reading only
263pub const O_RDONLY = 0x0000;
264
265/// open for writing only
266pub const O_WRONLY = 0x0001;
267
268/// open for reading and writing
269pub const O_RDWR = 0x0002;
270
271/// do not block on open or for data to become available
272pub const O_NONBLOCK = 0x0004;
273
274/// append on each write
275pub const O_APPEND = 0x0008;
276
277/// create file if it does not exist
278pub const O_CREAT = 0x0200;
279
280/// truncate size to 0
281pub const O_TRUNC = 0x0400;
282
283/// error if O_CREAT and the file exists
284pub const O_EXCL = 0x0800;
285
286/// atomically obtain a shared lock
287pub const O_SHLOCK = 0x0010;
288
289/// atomically obtain an exclusive lock
290pub const O_EXLOCK = 0x0020;
291
292/// do not follow symlinks
293pub const O_NOFOLLOW = 0x0100;
294
295/// allow open of symlinks
296pub const O_SYMLINK = 0x200000;
297
298/// descriptor requested for event notifications only
299pub const O_EVTONLY = 0x8000;
300
301/// mark as close-on-exec
302pub const O_CLOEXEC = 0x1000000;
303
304pub const O_ACCMODE = 3;
305pub const O_ALERT = 536870912;
306pub const O_ASYNC = 64;
307pub const O_DIRECTORY = 1048576;
308pub const O_DP_GETRAWENCRYPTED = 1;
309pub const O_DP_GETRAWUNENCRYPTED = 2;
310pub const O_DSYNC = 4194304;
311pub const O_FSYNC = O_SYNC;
312pub const O_NOCTTY = 131072;
313pub const O_POPUP = 2147483648;
314pub const O_SYNC = 128;
315
316pub const SEEK_SET = 0x0;
317pub const SEEK_CUR = 0x1;
318pub const SEEK_END = 0x2;
319
320pub const DT_UNKNOWN = 0;
321pub const DT_FIFO = 1;
322pub const DT_CHR = 2;
323pub const DT_DIR = 4;
324pub const DT_BLK = 6;
325pub const DT_REG = 8;
326pub const DT_LNK = 10;
327pub const DT_SOCK = 12;
328pub const DT_WHT = 14;
329
330/// block specified signal set
331pub const SIG_BLOCK = 1;
332
333/// unblock specified signal set
334pub const SIG_UNBLOCK = 2;
335
336/// set specified signal set
337pub const SIG_SETMASK = 3;
338
339/// hangup
340pub const SIGHUP = 1;
341
342/// interrupt
343pub const SIGINT = 2;
344
345/// quit
346pub const SIGQUIT = 3;
347
348/// illegal instruction (not reset when caught)
349pub const SIGILL = 4;
350
351/// trace trap (not reset when caught)
352pub const SIGTRAP = 5;
353
354/// abort()
355pub const SIGABRT = 6;
356
357/// pollable event ([XSR] generated, not supported)
358pub const SIGPOLL = 7;
359
360/// compatibility
361pub const SIGIOT = SIGABRT;
362
363/// EMT instruction
364pub const SIGEMT = 7;
365
366/// floating point exception
367pub const SIGFPE = 8;
368
369/// kill (cannot be caught or ignored)
370pub const SIGKILL = 9;
371
372/// bus error
373pub const SIGBUS = 10;
374
375/// segmentation violation
376pub const SIGSEGV = 11;
377
378/// bad argument to system call
379pub const SIGSYS = 12;
380
381/// write on a pipe with no one to read it
382pub const SIGPIPE = 13;
383
384/// alarm clock
385pub const SIGALRM = 14;
386
387/// software termination signal from kill
388pub const SIGTERM = 15;
389
390/// urgent condition on IO channel
391pub const SIGURG = 16;
392
393/// sendable stop signal not from tty
394pub const SIGSTOP = 17;
395
396/// stop signal from tty
397pub const SIGTSTP = 18;
398
399/// continue a stopped process
400pub const SIGCONT = 19;
401
402/// to parent on child stop or exit
403pub const SIGCHLD = 20;
404
405/// to readers pgrp upon background tty read
406pub const SIGTTIN = 21;
407
408/// like TTIN for output if (tp->t_local&LTOSTOP)
409pub const SIGTTOU = 22;
410
411/// input/output possible signal
412pub const SIGIO = 23;
413
414/// exceeded CPU time limit
415pub const SIGXCPU = 24;
416
417/// exceeded file size limit
418pub const SIGXFSZ = 25;
419
420/// virtual time alarm
421pub const SIGVTALRM = 26;
422
423/// profiling time alarm
424pub const SIGPROF = 27;
425
426/// window size changes
427pub const SIGWINCH = 28;
428
429/// information request
430pub const SIGINFO = 29;
431
432/// user defined signal 1
433pub const SIGUSR1 = 30;
434
435/// user defined signal 2
436pub const SIGUSR2 = 31;
437
438/// no flag value
439pub const KEVENT_FLAG_NONE = 0x000;
440
441/// immediate timeout
442pub const KEVENT_FLAG_IMMEDIATE = 0x001;
443
444/// output events only include change
445pub const KEVENT_FLAG_ERROR_EVENTS = 0x002;
446
447/// add event to kq (implies enable)
448pub const EV_ADD = 0x0001;
449
450/// delete event from kq
451pub const EV_DELETE = 0x0002;
452
453/// enable event
454pub const EV_ENABLE = 0x0004;
455
456/// disable event (not reported)
457pub const EV_DISABLE = 0x0008;
458
459/// only report one occurrence
460pub const EV_ONESHOT = 0x0010;
461
462/// clear event state after reporting
463pub const EV_CLEAR = 0x0020;
464
465/// force immediate event output
466/// ... with or without EV_ERROR
467/// ... use KEVENT_FLAG_ERROR_EVENTS
468/// on syscalls supporting flags
469pub const EV_RECEIPT = 0x0040;
470
471/// disable event after reporting
472pub const EV_DISPATCH = 0x0080;
473
474/// unique kevent per udata value
475pub const EV_UDATA_SPECIFIC = 0x0100;
476
477/// ... in combination with EV_DELETE
478/// will defer delete until udata-specific
479/// event enabled. EINPROGRESS will be
480/// returned to indicate the deferral
481pub const EV_DISPATCH2 = EV_DISPATCH | EV_UDATA_SPECIFIC;
482
483/// report that source has vanished
484/// ... only valid with EV_DISPATCH2
485pub const EV_VANISHED = 0x0200;
486
487/// reserved by system
488pub const EV_SYSFLAGS = 0xF000;
489
490/// filter-specific flag
491pub const EV_FLAG0 = 0x1000;
492
493/// filter-specific flag
494pub const EV_FLAG1 = 0x2000;
495
496/// EOF detected
497pub const EV_EOF = 0x8000;
498
499/// error, data contains errno
500pub const EV_ERROR = 0x4000;
501
502pub const EV_POLL = EV_FLAG0;
503pub const EV_OOBAND = EV_FLAG1;
504
505pub const EVFILT_READ = -1;
506pub const EVFILT_WRITE = -2;
507
508/// attached to aio requests
509pub const EVFILT_AIO = -3;
510
511/// attached to vnodes
512pub const EVFILT_VNODE = -4;
513
514/// attached to struct proc
515pub const EVFILT_PROC = -5;
516
517/// attached to struct proc
518pub const EVFILT_SIGNAL = -6;
519
520/// timers
521pub const EVFILT_TIMER = -7;
522
523/// Mach portsets
524pub const EVFILT_MACHPORT = -8;
525
526/// Filesystem events
527pub const EVFILT_FS = -9;
528
529/// User events
530pub const EVFILT_USER = -10;
531
532/// Virtual memory events
533pub const EVFILT_VM = -12;
534
535/// Exception events
536pub const EVFILT_EXCEPT = -15;
537
538pub const EVFILT_SYSCOUNT = 17;
539
540/// On input, NOTE_TRIGGER causes the event to be triggered for output.
541pub const NOTE_TRIGGER = 0x01000000;
542
543/// ignore input fflags
544pub const NOTE_FFNOP = 0x00000000;
545
546/// and fflags
547pub const NOTE_FFAND = 0x40000000;
548
549/// or fflags
550pub const NOTE_FFOR = 0x80000000;
551
552/// copy fflags
553pub const NOTE_FFCOPY = 0xc0000000;
554
555/// mask for operations
556pub const NOTE_FFCTRLMASK = 0xc0000000;
557pub const NOTE_FFLAGSMASK = 0x00ffffff;
558
559/// low water mark
560pub const NOTE_LOWAT = 0x00000001;
561
562/// OOB data
563pub const NOTE_OOB = 0x00000002;
564
565/// vnode was removed
566pub const NOTE_DELETE = 0x00000001;
567
568/// data contents changed
569pub const NOTE_WRITE = 0x00000002;
570
571/// size increased
572pub const NOTE_EXTEND = 0x00000004;
573
574/// attributes changed
575pub const NOTE_ATTRIB = 0x00000008;
576
577/// link count changed
578pub const NOTE_LINK = 0x00000010;
579
580/// vnode was renamed
581pub const NOTE_RENAME = 0x00000020;
582
583/// vnode access was revoked
584pub const NOTE_REVOKE = 0x00000040;
585
586/// No specific vnode event: to test for EVFILT_READ activation
587pub const NOTE_NONE = 0x00000080;
588
589/// vnode was unlocked by flock(2)
590pub const NOTE_FUNLOCK = 0x00000100;
591
592/// process exited
593pub const NOTE_EXIT = 0x80000000;
594
595/// process forked
596pub const NOTE_FORK = 0x40000000;
597
598/// process exec'd
599pub const NOTE_EXEC = 0x20000000;
600
601/// shared with EVFILT_SIGNAL
602pub const NOTE_SIGNAL = 0x08000000;
603
604/// exit status to be returned, valid for child process only
605pub const NOTE_EXITSTATUS = 0x04000000;
606
607/// provide details on reasons for exit
608pub const NOTE_EXIT_DETAIL = 0x02000000;
609
610/// mask for signal & exit status
611pub const NOTE_PDATAMASK = 0x000fffff;
612pub const NOTE_PCTRLMASK = (~NOTE_PDATAMASK);
613
614pub const NOTE_EXIT_DETAIL_MASK = 0x00070000;
615pub const NOTE_EXIT_DECRYPTFAIL = 0x00010000;
616pub const NOTE_EXIT_MEMORY = 0x00020000;
617pub const NOTE_EXIT_CSERROR = 0x00040000;
618
619/// will react on memory pressure
620pub const NOTE_VM_PRESSURE = 0x80000000;
621
622/// will quit on memory pressure, possibly after cleaning up dirty state
623pub const NOTE_VM_PRESSURE_TERMINATE = 0x40000000;
624
625/// will quit immediately on memory pressure
626pub const NOTE_VM_PRESSURE_SUDDEN_TERMINATE = 0x20000000;
627
628/// there was an error
629pub const NOTE_VM_ERROR = 0x10000000;
630
631/// data is seconds
632pub const NOTE_SECONDS = 0x00000001;
633
634/// data is microseconds
635pub const NOTE_USECONDS = 0x00000002;
636
637/// data is nanoseconds
638pub const NOTE_NSECONDS = 0x00000004;
639
640/// absolute timeout
641pub const NOTE_ABSOLUTE = 0x00000008;
642
643/// ext[1] holds leeway for power aware timers
644pub const NOTE_LEEWAY = 0x00000010;
645
646/// system does minimal timer coalescing
647pub const NOTE_CRITICAL = 0x00000020;
648
649/// system does maximum timer coalescing
650pub const NOTE_BACKGROUND = 0x00000040;
651pub const NOTE_MACH_CONTINUOUS_TIME = 0x00000080;
652
653/// data is mach absolute time units
654pub const NOTE_MACHTIME = 0x00000100;
655
656pub const AF_UNSPEC = 0;
657pub const AF_LOCAL = 1;
658pub const AF_UNIX = AF_LOCAL;
659pub const AF_INET = 2;
660pub const AF_SYS_CONTROL = 2;
661pub const AF_IMPLINK = 3;
662pub const AF_PUP = 4;
663pub const AF_CHAOS = 5;
664pub const AF_NS = 6;
665pub const AF_ISO = 7;
666pub const AF_OSI = AF_ISO;
667pub const AF_ECMA = 8;
668pub const AF_DATAKIT = 9;
669pub const AF_CCITT = 10;
670pub const AF_SNA = 11;
671pub const AF_DECnet = 12;
672pub const AF_DLI = 13;
673pub const AF_LAT = 14;
674pub const AF_HYLINK = 15;
675pub const AF_APPLETALK = 16;
676pub const AF_ROUTE = 17;
677pub const AF_LINK = 18;
678pub const AF_XTP = 19;
679pub const AF_COIP = 20;
680pub const AF_CNT = 21;
681pub const AF_RTIP = 22;
682pub const AF_IPX = 23;
683pub const AF_SIP = 24;
684pub const AF_PIP = 25;
685pub const AF_ISDN = 28;
686pub const AF_E164 = AF_ISDN;
687pub const AF_KEY = 29;
688pub const AF_INET6 = 30;
689pub const AF_NATM = 31;
690pub const AF_SYSTEM = 32;
691pub const AF_NETBIOS = 33;
692pub const AF_PPP = 34;
693pub const AF_MAX = 40;
694
695pub const PF_UNSPEC = AF_UNSPEC;
696pub const PF_LOCAL = AF_LOCAL;
697pub const PF_UNIX = PF_LOCAL;
698pub const PF_INET = AF_INET;
699pub const PF_IMPLINK = AF_IMPLINK;
700pub const PF_PUP = AF_PUP;
701pub const PF_CHAOS = AF_CHAOS;
702pub const PF_NS = AF_NS;
703pub const PF_ISO = AF_ISO;
704pub const PF_OSI = AF_ISO;
705pub const PF_ECMA = AF_ECMA;
706pub const PF_DATAKIT = AF_DATAKIT;
707pub const PF_CCITT = AF_CCITT;
708pub const PF_SNA = AF_SNA;
709pub const PF_DECnet = AF_DECnet;
710pub const PF_DLI = AF_DLI;
711pub const PF_LAT = AF_LAT;
712pub const PF_HYLINK = AF_HYLINK;
713pub const PF_APPLETALK = AF_APPLETALK;
714pub const PF_ROUTE = AF_ROUTE;
715pub const PF_LINK = AF_LINK;
716pub const PF_XTP = AF_XTP;
717pub const PF_COIP = AF_COIP;
718pub const PF_CNT = AF_CNT;
719pub const PF_SIP = AF_SIP;
720pub const PF_IPX = AF_IPX;
721pub const PF_RTIP = AF_RTIP;
722pub const PF_PIP = AF_PIP;
723pub const PF_ISDN = AF_ISDN;
724pub const PF_KEY = AF_KEY;
725pub const PF_INET6 = AF_INET6;
726pub const PF_NATM = AF_NATM;
727pub const PF_SYSTEM = AF_SYSTEM;
728pub const PF_NETBIOS = AF_NETBIOS;
729pub const PF_PPP = AF_PPP;
730pub const PF_MAX = AF_MAX;
731
732pub const SYSPROTO_EVENT = 1;
733pub const SYSPROTO_CONTROL = 2;
734
735pub const SOCK_STREAM = 1;
736pub const SOCK_DGRAM = 2;
737pub const SOCK_RAW = 3;
738pub const SOCK_RDM = 4;
739pub const SOCK_SEQPACKET = 5;
740pub const SOCK_MAXADDRLEN = 255;
741
742pub const IPPROTO_ICMP = 1;
743pub const IPPROTO_ICMPV6 = 58;
744pub const IPPROTO_TCP = 6;
745pub const IPPROTO_UDP = 17;
746pub const IPPROTO_IP = 0;
747pub const IPPROTO_IPV6 = 41;
748
749fn wstatus(x: i32) i32 {
750 return x & 0o177;
751}
752const wstopped = 0o177;
753pub fn WEXITSTATUS(x: i32) i32 {
754 return x >> 8;
755}
756pub fn WTERMSIG(x: i32) i32 {
757 return wstatus(x);
758}
759pub fn WSTOPSIG(x: i32) i32 {
760 return x >> 8;
761}
762pub fn WIFEXITED(x: i32) bool {
763 return wstatus(x) == 0;
764}
765pub fn WIFSTOPPED(x: i32) bool {
766 return wstatus(x) == wstopped and WSTOPSIG(x) != 0x13;
767}
768pub fn WIFSIGNALED(x: i32) bool {
769 return wstatus(x) != wstopped and wstatus(x) != 0;
770}
771
772/// Operation not permitted
773pub const EPERM = 1;
774
775/// No such file or directory
776pub const ENOENT = 2;
777
778/// No such process
779pub const ESRCH = 3;
780
781/// Interrupted system call
782pub const EINTR = 4;
783
784/// Input/output error
785pub const EIO = 5;
786
787/// Device not configured
788pub const ENXIO = 6;
789
790/// Argument list too long
791pub const E2BIG = 7;
792
793/// Exec format error
794pub const ENOEXEC = 8;
795
796/// Bad file descriptor
797pub const EBADF = 9;
798
799/// No child processes
800pub const ECHILD = 10;
801
802/// Resource deadlock avoided
803pub const EDEADLK = 11;
804
805/// Cannot allocate memory
806pub const ENOMEM = 12;
807
808/// Permission denied
809pub const EACCES = 13;
810
811/// Bad address
812pub const EFAULT = 14;
813
814/// Block device required
815pub const ENOTBLK = 15;
816
817/// Device / Resource busy
818pub const EBUSY = 16;
819
820/// File exists
821pub const EEXIST = 17;
822
823/// Cross-device link
824pub const EXDEV = 18;
825
826/// Operation not supported by device
827pub const ENODEV = 19;
828
829/// Not a directory
830pub const ENOTDIR = 20;
831
832/// Is a directory
833pub const EISDIR = 21;
834
835/// Invalid argument
836pub const EINVAL = 22;
837
838/// Too many open files in system
839pub const ENFILE = 23;
840
841/// Too many open files
842pub const EMFILE = 24;
843
844/// Inappropriate ioctl for device
845pub const ENOTTY = 25;
846
847/// Text file busy
848pub const ETXTBSY = 26;
849
850/// File too large
851pub const EFBIG = 27;
852
853/// No space left on device
854pub const ENOSPC = 28;
855
856/// Illegal seek
857pub const ESPIPE = 29;
858
859/// Read-only file system
860pub const EROFS = 30;
861
862/// Too many links
863pub const EMLINK = 31;
864/// Broken pipe
865
866// math software
867pub const EPIPE = 32;
868
869/// Numerical argument out of domain
870pub const EDOM = 33;
871/// Result too large
872
873// non-blocking and interrupt i/o
874pub const ERANGE = 34;
875
876/// Resource temporarily unavailable
877pub const EAGAIN = 35;
878
879/// Operation would block
880pub const EWOULDBLOCK = EAGAIN;
881
882/// Operation now in progress
883pub const EINPROGRESS = 36;
884/// Operation already in progress
885
886// ipc/network software -- argument errors
887pub const EALREADY = 37;
888
889/// Socket operation on non-socket
890pub const ENOTSOCK = 38;
891
892/// Destination address required
893pub const EDESTADDRREQ = 39;
894
895/// Message too long
896pub const EMSGSIZE = 40;
897
898/// Protocol wrong type for socket
899pub const EPROTOTYPE = 41;
900
901/// Protocol not available
902pub const ENOPROTOOPT = 42;
903
904/// Protocol not supported
905pub const EPROTONOSUPPORT = 43;
906
907/// Socket type not supported
908pub const ESOCKTNOSUPPORT = 44;
909
910/// Operation not supported
911pub const ENOTSUP = 45;
912
913/// Protocol family not supported
914pub const EPFNOSUPPORT = 46;
915
916/// Address family not supported by protocol family
917pub const EAFNOSUPPORT = 47;
918
919/// Address already in use
920pub const EADDRINUSE = 48;
921/// Can't assign requested address
922
923// ipc/network software -- operational errors
924pub const EADDRNOTAVAIL = 49;
925
926/// Network is down
927pub const ENETDOWN = 50;
928
929/// Network is unreachable
930pub const ENETUNREACH = 51;
931
932/// Network dropped connection on reset
933pub const ENETRESET = 52;
934
935/// Software caused connection abort
936pub const ECONNABORTED = 53;
937
938/// Connection reset by peer
939pub const ECONNRESET = 54;
940
941/// No buffer space available
942pub const ENOBUFS = 55;
943
944/// Socket is already connected
945pub const EISCONN = 56;
946
947/// Socket is not connected
948pub const ENOTCONN = 57;
949
950/// Can't send after socket shutdown
951pub const ESHUTDOWN = 58;
952
953/// Too many references: can't splice
954pub const ETOOMANYREFS = 59;
955
956/// Operation timed out
957pub const ETIMEDOUT = 60;
958
959/// Connection refused
960pub const ECONNREFUSED = 61;
961
962/// Too many levels of symbolic links
963pub const ELOOP = 62;
964
965/// File name too long
966pub const ENAMETOOLONG = 63;
967
968/// Host is down
969pub const EHOSTDOWN = 64;
970
971/// No route to host
972pub const EHOSTUNREACH = 65;
973/// Directory not empty
974
975// quotas & mush
976pub const ENOTEMPTY = 66;
977
978/// Too many processes
979pub const EPROCLIM = 67;
980
981/// Too many users
982pub const EUSERS = 68;
983/// Disc quota exceeded
984
985// Network File System
986pub const EDQUOT = 69;
987
988/// Stale NFS file handle
989pub const ESTALE = 70;
990
991/// Too many levels of remote in path
992pub const EREMOTE = 71;
993
994/// RPC struct is bad
995pub const EBADRPC = 72;
996
997/// RPC version wrong
998pub const ERPCMISMATCH = 73;
999
1000/// RPC prog. not avail
1001pub const EPROGUNAVAIL = 74;
1002
1003/// Program version wrong
1004pub const EPROGMISMATCH = 75;
1005
1006/// Bad procedure for program
1007pub const EPROCUNAVAIL = 76;
1008
1009/// No locks available
1010pub const ENOLCK = 77;
1011
1012/// Function not implemented
1013pub const ENOSYS = 78;
1014
1015/// Inappropriate file type or format
1016pub const EFTYPE = 79;
1017
1018/// Authentication error
1019pub const EAUTH = 80;
1020/// Need authenticator
1021
1022// Intelligent device errors
1023pub const ENEEDAUTH = 81;
1024
1025/// Device power is off
1026pub const EPWROFF = 82;
1027
1028/// Device error, e.g. paper out
1029pub const EDEVERR = 83;
1030/// Value too large to be stored in data type
1031
1032// Program loading errors
1033pub const EOVERFLOW = 84;
1034
1035/// Bad executable
1036pub const EBADEXEC = 85;
1037
1038/// Bad CPU type in executable
1039pub const EBADARCH = 86;
1040
1041/// Shared library version mismatch
1042pub const ESHLIBVERS = 87;
1043
1044/// Malformed Macho file
1045pub const EBADMACHO = 88;
1046
1047/// Operation canceled
1048pub const ECANCELED = 89;
1049
1050/// Identifier removed
1051pub const EIDRM = 90;
1052
1053/// No message of desired type
1054pub const ENOMSG = 91;
1055
1056/// Illegal byte sequence
1057pub const EILSEQ = 92;
1058
1059/// Attribute not found
1060pub const ENOATTR = 93;
1061
1062/// Bad message
1063pub const EBADMSG = 94;
1064
1065/// Reserved
1066pub const EMULTIHOP = 95;
1067
1068/// No message available on STREAM
1069pub const ENODATA = 96;
1070
1071/// Reserved
1072pub const ENOLINK = 97;
1073
1074/// No STREAM resources
1075pub const ENOSR = 98;
1076
1077/// Not a STREAM
1078pub const ENOSTR = 99;
1079
1080/// Protocol error
1081pub const EPROTO = 100;
1082
1083/// STREAM ioctl timeout
1084pub const ETIME = 101;
1085
1086/// No such policy registered
1087pub const ENOPOLICY = 103;
1088
1089/// State not recoverable
1090pub const ENOTRECOVERABLE = 104;
1091
1092/// Previous owner died
1093pub const EOWNERDEAD = 105;
1094
1095/// Interface output queue is full
1096pub const EQFULL = 106;
1097
1098/// Must be equal largest errno
1099pub const ELAST = 106;
std/c/posix/freebsd.zig deleted-839
...@@ -1,839 +0,0 @@
1const std = @import("../std.zig");
2
3/// Renamed from `kevent` to `Kevent` to avoid conflict with function name.
4pub const Kevent = extern struct {
5 ident: usize,
6 filter: i16,
7 flags: u16,
8 fflags: u32,
9 data: i64,
10 udata: usize,
11 // TODO ext
12};
13
14pub const pthread_attr_t = extern struct {
15 __size: [56]u8,
16 __align: c_long,
17};
18
19pub const msghdr = extern struct {
20 /// optional address
21 msg_name: ?*sockaddr,
22
23 /// size of address
24 msg_namelen: socklen_t,
25
26 /// scatter/gather array
27 msg_iov: [*]iovec,
28
29 /// # elements in msg_iov
30 msg_iovlen: i32,
31
32 /// ancillary data
33 msg_control: ?*c_void,
34
35 /// ancillary data buffer len
36 msg_controllen: socklen_t,
37
38 /// flags on received message
39 msg_flags: i32,
40};
41
42pub const msghdr_const = extern struct {
43 /// optional address
44 msg_name: ?*const sockaddr,
45
46 /// size of address
47 msg_namelen: socklen_t,
48
49 /// scatter/gather array
50 msg_iov: [*]iovec_const,
51
52 /// # elements in msg_iov
53 msg_iovlen: i32,
54
55 /// ancillary data
56 msg_control: ?*c_void,
57
58 /// ancillary data buffer len
59 msg_controllen: socklen_t,
60
61 /// flags on received message
62 msg_flags: i32,
63};
64
65pub const Stat = extern struct {
66 dev: u64,
67 ino: u64,
68 nlink: usize,
69
70 mode: u16,
71 __pad0: u16,
72 uid: u32,
73 gid: u32,
74 __pad1: u32,
75 rdev: u64,
76
77 atim: timespec,
78 mtim: timespec,
79 ctim: timespec,
80 birthtim: timespec,
81
82 size: i64,
83 blocks: i64,
84 blksize: isize,
85 flags: u32,
86 gen: u64,
87 __spare: [10]u64,
88};
89
90pub const timespec = extern struct {
91 tv_sec: isize,
92 tv_nsec: isize,
93};
94
95pub const dirent = extern struct {
96 d_fileno: usize,
97 d_off: i64,
98 d_reclen: u16,
99 d_type: u8,
100 d_pad0: u8,
101 d_namlen: u16,
102 d_pad1: u16,
103 d_name: [256]u8,
104};
105
106pub const in_port_t = u16;
107pub const sa_family_t = u16;
108
109pub const sockaddr = extern union {
110 in: sockaddr_in,
111 in6: sockaddr_in6,
112};
113
114pub const sockaddr_in = extern struct {
115 len: u8,
116 family: sa_family_t,
117 port: in_port_t,
118 addr: [16]u8,
119 zero: [8]u8,
120};
121
122pub const sockaddr_in6 = extern struct {
123 len: u8,
124 family: sa_family_t,
125 port: in_port_t,
126 flowinfo: u32,
127 addr: [16]u8,
128 scope_id: u32,
129};
130
131pub const CTL_KERN = 1;
132pub const CTL_DEBUG = 5;
133
134pub const KERN_PROC = 14; // struct: process entries
135pub const KERN_PROC_PATHNAME = 12; // path to executable
136
137pub const PATH_MAX = 1024;
138
139pub const STDIN_FILENO = 0;
140pub const STDOUT_FILENO = 1;
141pub const STDERR_FILENO = 2;
142
143pub const PROT_NONE = 0;
144pub const PROT_READ = 1;
145pub const PROT_WRITE = 2;
146pub const PROT_EXEC = 4;
147
148pub const CLOCK_REALTIME = 0;
149pub const CLOCK_VIRTUAL = 1;
150pub const CLOCK_PROF = 2;
151pub const CLOCK_MONOTONIC = 4;
152pub const CLOCK_UPTIME = 5;
153pub const CLOCK_UPTIME_PRECISE = 7;
154pub const CLOCK_UPTIME_FAST = 8;
155pub const CLOCK_REALTIME_PRECISE = 9;
156pub const CLOCK_REALTIME_FAST = 10;
157pub const CLOCK_MONOTONIC_PRECISE = 11;
158pub const CLOCK_MONOTONIC_FAST = 12;
159pub const CLOCK_SECOND = 13;
160pub const CLOCK_THREAD_CPUTIME_ID = 14;
161pub const CLOCK_PROCESS_CPUTIME_ID = 15;
162
163pub const MAP_FAILED = maxInt(usize);
164pub const MAP_SHARED = 0x0001;
165pub const MAP_PRIVATE = 0x0002;
166pub const MAP_FIXED = 0x0010;
167pub const MAP_STACK = 0x0400;
168pub const MAP_NOSYNC = 0x0800;
169pub const MAP_ANON = 0x1000;
170pub const MAP_ANONYMOUS = MAP_ANON;
171pub const MAP_FILE = 0;
172pub const MAP_NORESERVE = 0;
173
174pub const MAP_GUARD = 0x00002000;
175pub const MAP_EXCL = 0x00004000;
176pub const MAP_NOCORE = 0x00020000;
177pub const MAP_PREFAULT_READ = 0x00040000;
178pub const MAP_32BIT = 0x00080000;
179
180pub const WNOHANG = 1;
181pub const WUNTRACED = 2;
182pub const WSTOPPED = WUNTRACED;
183pub const WCONTINUED = 4;
184pub const WNOWAIT = 8;
185pub const WEXITED = 16;
186pub const WTRAPPED = 32;
187
188pub const SA_ONSTACK = 0x0001;
189pub const SA_RESTART = 0x0002;
190pub const SA_RESETHAND = 0x0004;
191pub const SA_NOCLDSTOP = 0x0008;
192pub const SA_NODEFER = 0x0010;
193pub const SA_NOCLDWAIT = 0x0020;
194pub const SA_SIGINFO = 0x0040;
195
196pub const SIGHUP = 1;
197pub const SIGINT = 2;
198pub const SIGQUIT = 3;
199pub const SIGILL = 4;
200pub const SIGTRAP = 5;
201pub const SIGABRT = 6;
202pub const SIGIOT = SIGABRT;
203pub const SIGEMT = 7;
204pub const SIGFPE = 8;
205pub const SIGKILL = 9;
206pub const SIGBUS = 10;
207pub const SIGSEGV = 11;
208pub const SIGSYS = 12;
209pub const SIGPIPE = 13;
210pub const SIGALRM = 14;
211pub const SIGTERM = 15;
212pub const SIGURG = 16;
213pub const SIGSTOP = 17;
214pub const SIGTSTP = 18;
215pub const SIGCONT = 19;
216pub const SIGCHLD = 20;
217pub const SIGTTIN = 21;
218pub const SIGTTOU = 22;
219pub const SIGIO = 23;
220pub const SIGXCPU = 24;
221pub const SIGXFSZ = 25;
222pub const SIGVTALRM = 26;
223pub const SIGPROF = 27;
224pub const SIGWINCH = 28;
225pub const SIGINFO = 29;
226pub const SIGUSR1 = 30;
227pub const SIGUSR2 = 31;
228pub const SIGTHR = 32;
229pub const SIGLWP = SIGTHR;
230pub const SIGLIBRT = 33;
231
232pub const SIGRTMIN = 65;
233pub const SIGRTMAX = 126;
234
235// access function
236pub const F_OK = 0; // test for existence of file
237pub const X_OK = 1; // test for execute or search permission
238pub const W_OK = 2; // test for write permission
239pub const R_OK = 4; // test for read permission
240
241pub const O_RDONLY = 0x0000;
242pub const O_WRONLY = 0x0001;
243pub const O_RDWR = 0x0002;
244pub const O_ACCMODE = 0x0003;
245
246pub const O_CREAT = 0x0200;
247pub const O_EXCL = 0x0800;
248pub const O_NOCTTY = 0x8000;
249pub const O_TRUNC = 0x0400;
250pub const O_APPEND = 0x0008;
251pub const O_NONBLOCK = 0x0004;
252pub const O_DSYNC = 0o10000;
253pub const O_SYNC = 0x0080;
254pub const O_RSYNC = 0o4010000;
255pub const O_DIRECTORY = 0o200000;
256pub const O_NOFOLLOW = 0x0100;
257pub const O_CLOEXEC = 0x00100000;
258
259pub const O_ASYNC = 0x0040;
260pub const O_DIRECT = 0x00010000;
261pub const O_LARGEFILE = 0;
262pub const O_NOATIME = 0o1000000;
263pub const O_PATH = 0o10000000;
264pub const O_TMPFILE = 0o20200000;
265pub const O_NDELAY = O_NONBLOCK;
266
267pub const F_DUPFD = 0;
268pub const F_GETFD = 1;
269pub const F_SETFD = 2;
270pub const F_GETFL = 3;
271pub const F_SETFL = 4;
272
273pub const F_SETOWN = 8;
274pub const F_GETOWN = 9;
275pub const F_SETSIG = 10;
276pub const F_GETSIG = 11;
277
278pub const F_GETLK = 5;
279pub const F_SETLK = 6;
280pub const F_SETLKW = 7;
281
282pub const F_SETOWN_EX = 15;
283pub const F_GETOWN_EX = 16;
284
285pub const F_GETOWNER_UIDS = 17;
286
287pub const SEEK_SET = 0;
288pub const SEEK_CUR = 1;
289pub const SEEK_END = 2;
290
291pub const SIG_BLOCK = 1;
292pub const SIG_UNBLOCK = 2;
293pub const SIG_SETMASK = 3;
294
295pub const SOCK_STREAM = 1;
296pub const SOCK_DGRAM = 2;
297pub const SOCK_RAW = 3;
298pub const SOCK_RDM = 4;
299pub const SOCK_SEQPACKET = 5;
300
301pub const SOCK_CLOEXEC = 0x10000000;
302pub const SOCK_NONBLOCK = 0x20000000;
303
304pub const PROTO_ip = 0o000;
305pub const PROTO_icmp = 0o001;
306pub const PROTO_igmp = 0o002;
307pub const PROTO_ggp = 0o003;
308pub const PROTO_ipencap = 0o004;
309pub const PROTO_st = 0o005;
310pub const PROTO_tcp = 0o006;
311pub const PROTO_egp = 0o010;
312pub const PROTO_pup = 0o014;
313pub const PROTO_udp = 0o021;
314pub const PROTO_hmp = 0o024;
315pub const PROTO_xns_idp = 0o026;
316pub const PROTO_rdp = 0o033;
317pub const PROTO_iso_tp4 = 0o035;
318pub const PROTO_xtp = 0o044;
319pub const PROTO_ddp = 0o045;
320pub const PROTO_idpr_cmtp = 0o046;
321pub const PROTO_ipv6 = 0o051;
322pub const PROTO_ipv6_route = 0o053;
323pub const PROTO_ipv6_frag = 0o054;
324pub const PROTO_idrp = 0o055;
325pub const PROTO_rsvp = 0o056;
326pub const PROTO_gre = 0o057;
327pub const PROTO_esp = 0o062;
328pub const PROTO_ah = 0o063;
329pub const PROTO_skip = 0o071;
330pub const PROTO_ipv6_icmp = 0o072;
331pub const PROTO_ipv6_nonxt = 0o073;
332pub const PROTO_ipv6_opts = 0o074;
333pub const PROTO_rspf = 0o111;
334pub const PROTO_vmtp = 0o121;
335pub const PROTO_ospf = 0o131;
336pub const PROTO_ipip = 0o136;
337pub const PROTO_encap = 0o142;
338pub const PROTO_pim = 0o147;
339pub const PROTO_raw = 0o377;
340
341pub const PF_UNSPEC = 0;
342pub const PF_LOCAL = 1;
343pub const PF_UNIX = PF_LOCAL;
344pub const PF_FILE = PF_LOCAL;
345pub const PF_INET = 2;
346pub const PF_AX25 = 3;
347pub const PF_IPX = 4;
348pub const PF_APPLETALK = 5;
349pub const PF_NETROM = 6;
350pub const PF_BRIDGE = 7;
351pub const PF_ATMPVC = 8;
352pub const PF_X25 = 9;
353pub const PF_INET6 = 10;
354pub const PF_ROSE = 11;
355pub const PF_DECnet = 12;
356pub const PF_NETBEUI = 13;
357pub const PF_SECURITY = 14;
358pub const PF_KEY = 15;
359pub const PF_NETLINK = 16;
360pub const PF_ROUTE = PF_NETLINK;
361pub const PF_PACKET = 17;
362pub const PF_ASH = 18;
363pub const PF_ECONET = 19;
364pub const PF_ATMSVC = 20;
365pub const PF_RDS = 21;
366pub const PF_SNA = 22;
367pub const PF_IRDA = 23;
368pub const PF_PPPOX = 24;
369pub const PF_WANPIPE = 25;
370pub const PF_LLC = 26;
371pub const PF_IB = 27;
372pub const PF_MPLS = 28;
373pub const PF_CAN = 29;
374pub const PF_TIPC = 30;
375pub const PF_BLUETOOTH = 31;
376pub const PF_IUCV = 32;
377pub const PF_RXRPC = 33;
378pub const PF_ISDN = 34;
379pub const PF_PHONET = 35;
380pub const PF_IEEE802154 = 36;
381pub const PF_CAIF = 37;
382pub const PF_ALG = 38;
383pub const PF_NFC = 39;
384pub const PF_VSOCK = 40;
385pub const PF_MAX = 41;
386
387pub const AF_UNSPEC = PF_UNSPEC;
388pub const AF_LOCAL = PF_LOCAL;
389pub const AF_UNIX = AF_LOCAL;
390pub const AF_FILE = AF_LOCAL;
391pub const AF_INET = PF_INET;
392pub const AF_AX25 = PF_AX25;
393pub const AF_IPX = PF_IPX;
394pub const AF_APPLETALK = PF_APPLETALK;
395pub const AF_NETROM = PF_NETROM;
396pub const AF_BRIDGE = PF_BRIDGE;
397pub const AF_ATMPVC = PF_ATMPVC;
398pub const AF_X25 = PF_X25;
399pub const AF_INET6 = PF_INET6;
400pub const AF_ROSE = PF_ROSE;
401pub const AF_DECnet = PF_DECnet;
402pub const AF_NETBEUI = PF_NETBEUI;
403pub const AF_SECURITY = PF_SECURITY;
404pub const AF_KEY = PF_KEY;
405pub const AF_NETLINK = PF_NETLINK;
406pub const AF_ROUTE = PF_ROUTE;
407pub const AF_PACKET = PF_PACKET;
408pub const AF_ASH = PF_ASH;
409pub const AF_ECONET = PF_ECONET;
410pub const AF_ATMSVC = PF_ATMSVC;
411pub const AF_RDS = PF_RDS;
412pub const AF_SNA = PF_SNA;
413pub const AF_IRDA = PF_IRDA;
414pub const AF_PPPOX = PF_PPPOX;
415pub const AF_WANPIPE = PF_WANPIPE;
416pub const AF_LLC = PF_LLC;
417pub const AF_IB = PF_IB;
418pub const AF_MPLS = PF_MPLS;
419pub const AF_CAN = PF_CAN;
420pub const AF_TIPC = PF_TIPC;
421pub const AF_BLUETOOTH = PF_BLUETOOTH;
422pub const AF_IUCV = PF_IUCV;
423pub const AF_RXRPC = PF_RXRPC;
424pub const AF_ISDN = PF_ISDN;
425pub const AF_PHONET = PF_PHONET;
426pub const AF_IEEE802154 = PF_IEEE802154;
427pub const AF_CAIF = PF_CAIF;
428pub const AF_ALG = PF_ALG;
429pub const AF_NFC = PF_NFC;
430pub const AF_VSOCK = PF_VSOCK;
431pub const AF_MAX = PF_MAX;
432
433pub const DT_UNKNOWN = 0;
434pub const DT_FIFO = 1;
435pub const DT_CHR = 2;
436pub const DT_DIR = 4;
437pub const DT_BLK = 6;
438pub const DT_REG = 8;
439pub const DT_LNK = 10;
440pub const DT_SOCK = 12;
441pub const DT_WHT = 14;
442
443/// add event to kq (implies enable)
444pub const EV_ADD = 0x0001;
445
446/// delete event from kq
447pub const EV_DELETE = 0x0002;
448
449/// enable event
450pub const EV_ENABLE = 0x0004;
451
452/// disable event (not reported)
453pub const EV_DISABLE = 0x0008;
454
455/// only report one occurrence
456pub const EV_ONESHOT = 0x0010;
457
458/// clear event state after reporting
459pub const EV_CLEAR = 0x0020;
460
461/// force immediate event output
462/// ... with or without EV_ERROR
463/// ... use KEVENT_FLAG_ERROR_EVENTS
464/// on syscalls supporting flags
465pub const EV_RECEIPT = 0x0040;
466
467/// disable event after reporting
468pub const EV_DISPATCH = 0x0080;
469
470pub const EVFILT_READ = -1;
471pub const EVFILT_WRITE = -2;
472
473/// attached to aio requests
474pub const EVFILT_AIO = -3;
475
476/// attached to vnodes
477pub const EVFILT_VNODE = -4;
478
479/// attached to struct proc
480pub const EVFILT_PROC = -5;
481
482/// attached to struct proc
483pub const EVFILT_SIGNAL = -6;
484
485/// timers
486pub const EVFILT_TIMER = -7;
487
488/// Process descriptors
489pub const EVFILT_PROCDESC = -8;
490
491/// Filesystem events
492pub const EVFILT_FS = -9;
493
494pub const EVFILT_LIO = -10;
495
496/// User events
497pub const EVFILT_USER = -11;
498
499/// Sendfile events
500pub const EVFILT_SENDFILE = -12;
501
502pub const EVFILT_EMPTY = -13;
503
504/// On input, NOTE_TRIGGER causes the event to be triggered for output.
505pub const NOTE_TRIGGER = 0x01000000;
506
507/// ignore input fflags
508pub const NOTE_FFNOP = 0x00000000;
509
510/// and fflags
511pub const NOTE_FFAND = 0x40000000;
512
513/// or fflags
514pub const NOTE_FFOR = 0x80000000;
515
516/// copy fflags
517pub const NOTE_FFCOPY = 0xc0000000;
518
519/// mask for operations
520pub const NOTE_FFCTRLMASK = 0xc0000000;
521pub const NOTE_FFLAGSMASK = 0x00ffffff;
522
523/// low water mark
524pub const NOTE_LOWAT = 0x00000001;
525
526/// behave like poll()
527pub const NOTE_FILE_POLL = 0x00000002;
528
529/// vnode was removed
530pub const NOTE_DELETE = 0x00000001;
531
532/// data contents changed
533pub const NOTE_WRITE = 0x00000002;
534
535/// size increased
536pub const NOTE_EXTEND = 0x00000004;
537
538/// attributes changed
539pub const NOTE_ATTRIB = 0x00000008;
540
541/// link count changed
542pub const NOTE_LINK = 0x00000010;
543
544/// vnode was renamed
545pub const NOTE_RENAME = 0x00000020;
546
547/// vnode access was revoked
548pub const NOTE_REVOKE = 0x00000040;
549
550/// vnode was opened
551pub const NOTE_OPEN = 0x00000080;
552
553/// file closed, fd did not allow write
554pub const NOTE_CLOSE = 0x00000100;
555
556/// file closed, fd did allow write
557pub const NOTE_CLOSE_WRITE = 0x00000200;
558
559/// file was read
560pub const NOTE_READ = 0x00000400;
561
562/// process exited
563pub const NOTE_EXIT = 0x80000000;
564
565/// process forked
566pub const NOTE_FORK = 0x40000000;
567
568/// process exec'd
569pub const NOTE_EXEC = 0x20000000;
570
571/// mask for signal & exit status
572pub const NOTE_PDATAMASK = 0x000fffff;
573pub const NOTE_PCTRLMASK = (~NOTE_PDATAMASK);
574
575/// data is seconds
576pub const NOTE_SECONDS = 0x00000001;
577
578/// data is milliseconds
579pub const NOTE_MSECONDS = 0x00000002;
580
581/// data is microseconds
582pub const NOTE_USECONDS = 0x00000004;
583
584/// data is nanoseconds
585pub const NOTE_NSECONDS = 0x00000008;
586
587/// timeout is absolute
588pub const NOTE_ABSTIME = 0x00000010;
589
590pub const TCGETS = 0x5401;
591pub const TCSETS = 0x5402;
592pub const TCSETSW = 0x5403;
593pub const TCSETSF = 0x5404;
594pub const TCGETA = 0x5405;
595pub const TCSETA = 0x5406;
596pub const TCSETAW = 0x5407;
597pub const TCSETAF = 0x5408;
598pub const TCSBRK = 0x5409;
599pub const TCXONC = 0x540A;
600pub const TCFLSH = 0x540B;
601pub const TIOCEXCL = 0x540C;
602pub const TIOCNXCL = 0x540D;
603pub const TIOCSCTTY = 0x540E;
604pub const TIOCGPGRP = 0x540F;
605pub const TIOCSPGRP = 0x5410;
606pub const TIOCOUTQ = 0x5411;
607pub const TIOCSTI = 0x5412;
608pub const TIOCGWINSZ = 0x5413;
609pub const TIOCSWINSZ = 0x5414;
610pub const TIOCMGET = 0x5415;
611pub const TIOCMBIS = 0x5416;
612pub const TIOCMBIC = 0x5417;
613pub const TIOCMSET = 0x5418;
614pub const TIOCGSOFTCAR = 0x5419;
615pub const TIOCSSOFTCAR = 0x541A;
616pub const FIONREAD = 0x541B;
617pub const TIOCINQ = FIONREAD;
618pub const TIOCLINUX = 0x541C;
619pub const TIOCCONS = 0x541D;
620pub const TIOCGSERIAL = 0x541E;
621pub const TIOCSSERIAL = 0x541F;
622pub const TIOCPKT = 0x5420;
623pub const FIONBIO = 0x5421;
624pub const TIOCNOTTY = 0x5422;
625pub const TIOCSETD = 0x5423;
626pub const TIOCGETD = 0x5424;
627pub const TCSBRKP = 0x5425;
628pub const TIOCSBRK = 0x5427;
629pub const TIOCCBRK = 0x5428;
630pub const TIOCGSID = 0x5429;
631pub const TIOCGRS485 = 0x542E;
632pub const TIOCSRS485 = 0x542F;
633pub const TIOCGPTN = 0x80045430;
634pub const TIOCSPTLCK = 0x40045431;
635pub const TIOCGDEV = 0x80045432;
636pub const TCGETX = 0x5432;
637pub const TCSETX = 0x5433;
638pub const TCSETXF = 0x5434;
639pub const TCSETXW = 0x5435;
640pub const TIOCSIG = 0x40045436;
641pub const TIOCVHANGUP = 0x5437;
642pub const TIOCGPKT = 0x80045438;
643pub const TIOCGPTLCK = 0x80045439;
644pub const TIOCGEXCL = 0x80045440;
645
646fn unsigned(s: i32) u32 {
647 return @bitCast(u32, s);
648}
649fn signed(s: u32) i32 {
650 return @bitCast(i32, s);
651}
652pub fn WEXITSTATUS(s: i32) i32 {
653 return signed((unsigned(s) & 0xff00) >> 8);
654}
655pub fn WTERMSIG(s: i32) i32 {
656 return signed(unsigned(s) & 0x7f);
657}
658pub fn WSTOPSIG(s: i32) i32 {
659 return WEXITSTATUS(s);
660}
661pub fn WIFEXITED(s: i32) bool {
662 return WTERMSIG(s) == 0;
663}
664pub fn WIFSTOPPED(s: i32) bool {
665 return @intCast(u16, (((unsigned(s) & 0xffff) *% 0x10001) >> 8)) > 0x7f00;
666}
667pub fn WIFSIGNALED(s: i32) bool {
668 return (unsigned(s) & 0xffff) -% 1 < 0xff;
669}
670
671pub const winsize = extern struct {
672 ws_row: u16,
673 ws_col: u16,
674 ws_xpixel: u16,
675 ws_ypixel: u16,
676};
677
678const NSIG = 32;
679
680pub const SIG_ERR = @intToPtr(extern fn (i32) void, maxInt(usize));
681pub const SIG_DFL = @intToPtr(extern fn (i32) void, 0);
682pub const SIG_IGN = @intToPtr(extern fn (i32) void, 1);
683
684/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.
685pub const Sigaction = extern struct {
686 /// signal handler
687 __sigaction_u: extern union {
688 __sa_handler: extern fn (i32) void,
689 __sa_sigaction: extern fn (i32, *__siginfo, usize) void,
690 },
691
692 /// see signal options
693 sa_flags: u32,
694
695 /// signal mask to apply
696 sa_mask: sigset_t,
697};
698
699pub const _SIG_WORDS = 4;
700pub const _SIG_MAXSIG = 128;
701
702pub inline fn _SIG_IDX(sig: usize) usize {
703 return sig - 1;
704}
705pub inline fn _SIG_WORD(sig: usize) usize {
706 return_SIG_IDX(sig) >> 5;
707}
708pub inline fn _SIG_BIT(sig: usize) usize {
709 return 1 << (_SIG_IDX(sig) & 31);
710}
711pub inline fn _SIG_VALID(sig: usize) usize {
712 return sig <= _SIG_MAXSIG and sig > 0;
713}
714
715pub const sigset_t = extern struct {
716 __bits: [_SIG_WORDS]u32,
717};
718
719pub const EPERM = 1; // Operation not permitted
720pub const ENOENT = 2; // No such file or directory
721pub const ESRCH = 3; // No such process
722pub const EINTR = 4; // Interrupted system call
723pub const EIO = 5; // Input/output error
724pub const ENXIO = 6; // Device not configured
725pub const E2BIG = 7; // Argument list too long
726pub const ENOEXEC = 8; // Exec format error
727pub const EBADF = 9; // Bad file descriptor
728pub const ECHILD = 10; // No child processes
729pub const EDEADLK = 11; // Resource deadlock avoided
730// 11 was EAGAIN
731pub const ENOMEM = 12; // Cannot allocate memory
732pub const EACCES = 13; // Permission denied
733pub const EFAULT = 14; // Bad address
734pub const ENOTBLK = 15; // Block device required
735pub const EBUSY = 16; // Device busy
736pub const EEXIST = 17; // File exists
737pub const EXDEV = 18; // Cross-device link
738pub const ENODEV = 19; // Operation not supported by device
739pub const ENOTDIR = 20; // Not a directory
740pub const EISDIR = 21; // Is a directory
741pub const EINVAL = 22; // Invalid argument
742pub const ENFILE = 23; // Too many open files in system
743pub const EMFILE = 24; // Too many open files
744pub const ENOTTY = 25; // Inappropriate ioctl for device
745pub const ETXTBSY = 26; // Text file busy
746pub const EFBIG = 27; // File too large
747pub const ENOSPC = 28; // No space left on device
748pub const ESPIPE = 29; // Illegal seek
749pub const EROFS = 30; // Read-only filesystem
750pub const EMLINK = 31; // Too many links
751pub const EPIPE = 32; // Broken pipe
752
753// math software
754pub const EDOM = 33; // Numerical argument out of domain
755pub const ERANGE = 34; // Result too large
756
757// non-blocking and interrupt i/o
758pub const EAGAIN = 35; // Resource temporarily unavailable
759pub const EWOULDBLOCK = EAGAIN; // Operation would block
760pub const EINPROGRESS = 36; // Operation now in progress
761pub const EALREADY = 37; // Operation already in progress
762
763// ipc/network software -- argument errors
764pub const ENOTSOCK = 38; // Socket operation on non-socket
765pub const EDESTADDRREQ = 39; // Destination address required
766pub const EMSGSIZE = 40; // Message too long
767pub const EPROTOTYPE = 41; // Protocol wrong type for socket
768pub const ENOPROTOOPT = 42; // Protocol not available
769pub const EPROTONOSUPPORT = 43; // Protocol not supported
770pub const ESOCKTNOSUPPORT = 44; // Socket type not supported
771pub const EOPNOTSUPP = 45; // Operation not supported
772pub const ENOTSUP = EOPNOTSUPP; // Operation not supported
773pub const EPFNOSUPPORT = 46; // Protocol family not supported
774pub const EAFNOSUPPORT = 47; // Address family not supported by protocol family
775pub const EADDRINUSE = 48; // Address already in use
776pub const EADDRNOTAVAIL = 49; // Can't assign requested address
777
778// ipc/network software -- operational errors
779pub const ENETDOWN = 50; // Network is down
780pub const ENETUNREACH = 51; // Network is unreachable
781pub const ENETRESET = 52; // Network dropped connection on reset
782pub const ECONNABORTED = 53; // Software caused connection abort
783pub const ECONNRESET = 54; // Connection reset by peer
784pub const ENOBUFS = 55; // No buffer space available
785pub const EISCONN = 56; // Socket is already connected
786pub const ENOTCONN = 57; // Socket is not connected
787pub const ESHUTDOWN = 58; // Can't send after socket shutdown
788pub const ETOOMANYREFS = 59; // Too many references: can't splice
789pub const ETIMEDOUT = 60; // Operation timed out
790pub const ECONNREFUSED = 61; // Connection refused
791
792pub const ELOOP = 62; // Too many levels of symbolic links
793pub const ENAMETOOLONG = 63; // File name too long
794
795// should be rearranged
796pub const EHOSTDOWN = 64; // Host is down
797pub const EHOSTUNREACH = 65; // No route to host
798pub const ENOTEMPTY = 66; // Directory not empty
799
800// quotas & mush
801pub const EPROCLIM = 67; // Too many processes
802pub const EUSERS = 68; // Too many users
803pub const EDQUOT = 69; // Disc quota exceeded
804
805// Network File System
806pub const ESTALE = 70; // Stale NFS file handle
807pub const EREMOTE = 71; // Too many levels of remote in path
808pub const EBADRPC = 72; // RPC struct is bad
809pub const ERPCMISMATCH = 73; // RPC version wrong
810pub const EPROGUNAVAIL = 74; // RPC prog. not avail
811pub const EPROGMISMATCH = 75; // Program version wrong
812pub const EPROCUNAVAIL = 76; // Bad procedure for program
813
814pub const ENOLCK = 77; // No locks available
815pub const ENOSYS = 78; // Function not implemented
816
817pub const EFTYPE = 79; // Inappropriate file type or format
818pub const EAUTH = 80; // Authentication error
819pub const ENEEDAUTH = 81; // Need authenticator
820pub const EIDRM = 82; // Identifier removed
821pub const ENOMSG = 83; // No message of desired type
822pub const EOVERFLOW = 84; // Value too large to be stored in data type
823pub const ECANCELED = 85; // Operation canceled
824pub const EILSEQ = 86; // Illegal byte sequence
825pub const ENOATTR = 87; // Attribute not found
826
827pub const EDOOFUS = 88; // Programming error
828
829pub const EBADMSG = 89; // Bad message
830pub const EMULTIHOP = 90; // Multihop attempted
831pub const ENOLINK = 91; // Link has been severed
832pub const EPROTO = 92; // Protocol error
833
834pub const ENOTCAPABLE = 93; // Capabilities insufficient
835pub const ECAPMODE = 94; // Not permitted in capability mode
836pub const ENOTRECOVERABLE = 95; // State not recoverable
837pub const EOWNERDEAD = 96; // Previous owner died
838
839pub const ELAST = 96; // Must be equal largest errno
std/c/posix/netbsd.zig deleted-728
...@@ -1,728 +0,0 @@
1const std = @import("../../std.zig");
2const maxInt = std.math.maxInt;
3
4/// Renamed from `kevent` to `Kevent` to avoid conflict with function name.
5pub const Kevent = extern struct {
6 ident: usize,
7 filter: i32,
8 flags: u32,
9 fflags: u32,
10 data: i64,
11 udata: usize,
12};
13
14pub const pthread_attr_t = extern struct {
15 pta_magic: u32,
16 pta_flags: c_int,
17 pta_private: *c_void,
18};
19
20pub const msghdr = extern struct {
21 /// optional address
22 msg_name: ?*sockaddr,
23
24 /// size of address
25 msg_namelen: socklen_t,
26
27 /// scatter/gather array
28 msg_iov: [*]iovec,
29
30 /// # elements in msg_iov
31 msg_iovlen: i32,
32
33 /// ancillary data
34 msg_control: ?*c_void,
35
36 /// ancillary data buffer len
37 msg_controllen: socklen_t,
38
39 /// flags on received message
40 msg_flags: i32,
41};
42
43pub const msghdr_const = extern struct {
44 /// optional address
45 msg_name: ?*const sockaddr,
46
47 /// size of address
48 msg_namelen: socklen_t,
49
50 /// scatter/gather array
51 msg_iov: [*]iovec_const,
52
53 /// # elements in msg_iov
54 msg_iovlen: i32,
55
56 /// ancillary data
57 msg_control: ?*c_void,
58
59 /// ancillary data buffer len
60 msg_controllen: socklen_t,
61
62 /// flags on received message
63 msg_flags: i32,
64};
65
66pub const Stat = extern struct {
67 dev: u64,
68 mode: u32,
69 ino: u64,
70 nlink: usize,
71
72 uid: u32,
73 gid: u32,
74 rdev: u64,
75
76 atim: timespec,
77 mtim: timespec,
78 ctim: timespec,
79 birthtim: timespec,
80
81 size: i64,
82 blocks: i64,
83 blksize: isize,
84 flags: u32,
85 gen: u32,
86 __spare: [2]u32,
87};
88
89pub const timespec = extern struct {
90 tv_sec: i64,
91 tv_nsec: isize,
92};
93
94pub const dirent = extern struct {
95 d_fileno: u64,
96 d_reclen: u16,
97 d_namlen: u16,
98 d_type: u8,
99 d_off: i64,
100 d_name: [512]u8,
101};
102
103pub const in_port_t = u16;
104pub const sa_family_t = u8;
105
106pub const sockaddr = extern union {
107 in: sockaddr_in,
108 in6: sockaddr_in6,
109};
110
111pub const sockaddr_in = extern struct {
112 len: u8,
113 family: sa_family_t,
114 port: in_port_t,
115 addr: u32,
116 zero: [8]u8,
117};
118
119pub const sockaddr_in6 = extern struct {
120 len: u8,
121 family: sa_family_t,
122 port: in_port_t,
123 flowinfo: u32,
124 addr: [16]u8,
125 scope_id: u32,
126};
127
128pub const CTL_KERN = 1;
129pub const CTL_DEBUG = 5;
130
131pub const KERN_PROC_ARGS = 48; // struct: process argv/env
132pub const KERN_PROC_PATHNAME = 5; // path to executable
133
134pub const PATH_MAX = 1024;
135
136pub const STDIN_FILENO = 0;
137pub const STDOUT_FILENO = 1;
138pub const STDERR_FILENO = 2;
139
140pub const PROT_NONE = 0;
141pub const PROT_READ = 1;
142pub const PROT_WRITE = 2;
143pub const PROT_EXEC = 4;
144
145pub const CLOCK_REALTIME = 0;
146pub const CLOCK_VIRTUAL = 1;
147pub const CLOCK_PROF = 2;
148pub const CLOCK_MONOTONIC = 3;
149pub const CLOCK_THREAD_CPUTIME_ID = 0x20000000;
150pub const CLOCK_PROCESS_CPUTIME_ID = 0x40000000;
151
152pub const MAP_FAILED = maxInt(usize);
153pub const MAP_SHARED = 0x0001;
154pub const MAP_PRIVATE = 0x0002;
155pub const MAP_REMAPDUP = 0x0004;
156pub const MAP_FIXED = 0x0010;
157pub const MAP_RENAME = 0x0020;
158pub const MAP_NORESERVE = 0x0040;
159pub const MAP_INHERIT = 0x0080;
160pub const MAP_HASSEMAPHORE = 0x0200;
161pub const MAP_TRYFIXED = 0x0400;
162pub const MAP_WIRED = 0x0800;
163
164pub const MAP_FILE = 0x0000;
165pub const MAP_NOSYNC = 0x0800;
166pub const MAP_ANON = 0x1000;
167pub const MAP_ANONYMOUS = MAP_ANON;
168pub const MAP_STACK = 0x2000;
169
170pub const WNOHANG = 0x00000001;
171pub const WUNTRACED = 0x00000002;
172pub const WSTOPPED = WUNTRACED;
173pub const WCONTINUED = 0x00000010;
174pub const WNOWAIT = 0x00010000;
175pub const WEXITED = 0x00000020;
176pub const WTRAPPED = 0x00000040;
177
178pub const SA_ONSTACK = 0x0001;
179pub const SA_RESTART = 0x0002;
180pub const SA_RESETHAND = 0x0004;
181pub const SA_NOCLDSTOP = 0x0008;
182pub const SA_NODEFER = 0x0010;
183pub const SA_NOCLDWAIT = 0x0020;
184pub const SA_SIGINFO = 0x0040;
185
186pub const SIGHUP = 1;
187pub const SIGINT = 2;
188pub const SIGQUIT = 3;
189pub const SIGILL = 4;
190pub const SIGTRAP = 5;
191pub const SIGABRT = 6;
192pub const SIGIOT = SIGABRT;
193pub const SIGEMT = 7;
194pub const SIGFPE = 8;
195pub const SIGKILL = 9;
196pub const SIGBUS = 10;
197pub const SIGSEGV = 11;
198pub const SIGSYS = 12;
199pub const SIGPIPE = 13;
200pub const SIGALRM = 14;
201pub const SIGTERM = 15;
202pub const SIGURG = 16;
203pub const SIGSTOP = 17;
204pub const SIGTSTP = 18;
205pub const SIGCONT = 19;
206pub const SIGCHLD = 20;
207pub const SIGTTIN = 21;
208pub const SIGTTOU = 22;
209pub const SIGIO = 23;
210pub const SIGXCPU = 24;
211pub const SIGXFSZ = 25;
212pub const SIGVTALRM = 26;
213pub const SIGPROF = 27;
214pub const SIGWINCH = 28;
215pub const SIGINFO = 29;
216pub const SIGUSR1 = 30;
217pub const SIGUSR2 = 31;
218pub const SIGPWR = 32;
219
220pub const SIGRTMIN = 33;
221pub const SIGRTMAX = 63;
222
223// access function
224pub const F_OK = 0; // test for existence of file
225pub const X_OK = 1; // test for execute or search permission
226pub const W_OK = 2; // test for write permission
227pub const R_OK = 4; // test for read permission
228
229pub const O_RDONLY = 0x0000;
230pub const O_WRONLY = 0x0001;
231pub const O_RDWR = 0x0002;
232pub const O_ACCMODE = 0x0003;
233
234pub const O_CREAT = 0x0200;
235pub const O_EXCL = 0x0800;
236pub const O_NOCTTY = 0x8000;
237pub const O_TRUNC = 0x0400;
238pub const O_APPEND = 0x0008;
239pub const O_NONBLOCK = 0x0004;
240pub const O_DSYNC = 0x00010000;
241pub const O_SYNC = 0x0080;
242pub const O_RSYNC = 0x00020000;
243pub const O_DIRECTORY = 0x00080000;
244pub const O_NOFOLLOW = 0x00000100;
245pub const O_CLOEXEC = 0x00400000;
246
247pub const O_ASYNC = 0x0040;
248pub const O_DIRECT = 0x00080000;
249pub const O_LARGEFILE = 0;
250pub const O_NOATIME = 0;
251pub const O_PATH = 0;
252pub const O_TMPFILE = 0;
253pub const O_NDELAY = O_NONBLOCK;
254
255pub const F_DUPFD = 0;
256pub const F_GETFD = 1;
257pub const F_SETFD = 2;
258pub const F_GETFL = 3;
259pub const F_SETFL = 4;
260
261pub const F_GETOWN = 5;
262pub const F_SETOWN = 6;
263
264pub const F_GETLK = 7;
265pub const F_SETLK = 8;
266pub const F_SETLKW = 9;
267
268pub const SEEK_SET = 0;
269pub const SEEK_CUR = 1;
270pub const SEEK_END = 2;
271
272pub const SIG_BLOCK = 1;
273pub const SIG_UNBLOCK = 2;
274pub const SIG_SETMASK = 3;
275
276pub const SOCK_STREAM = 1;
277pub const SOCK_DGRAM = 2;
278pub const SOCK_RAW = 3;
279pub const SOCK_RDM = 4;
280pub const SOCK_SEQPACKET = 5;
281
282pub const SOCK_CLOEXEC = 0x10000000;
283pub const SOCK_NONBLOCK = 0x20000000;
284
285pub const PROTO_ip = 0;
286pub const PROTO_icmp = 1;
287pub const PROTO_igmp = 2;
288pub const PROTO_ggp = 3;
289pub const PROTO_ipencap = 4;
290pub const PROTO_tcp = 6;
291pub const PROTO_egp = 8;
292pub const PROTO_pup = 12;
293pub const PROTO_udp = 17;
294pub const PROTO_xns_idp = 22;
295pub const PROTO_iso_tp4 = 29;
296pub const PROTO_ipv6 = 41;
297pub const PROTO_ipv6_route = 43;
298pub const PROTO_ipv6_frag = 44;
299pub const PROTO_rsvp = 46;
300pub const PROTO_gre = 47;
301pub const PROTO_esp = 50;
302pub const PROTO_ah = 51;
303pub const PROTO_ipv6_icmp = 58;
304pub const PROTO_ipv6_nonxt = 59;
305pub const PROTO_ipv6_opts = 60;
306pub const PROTO_encap = 98;
307pub const PROTO_pim = 103;
308pub const PROTO_raw = 255;
309
310pub const PF_UNSPEC = 0;
311pub const PF_LOCAL = 1;
312pub const PF_UNIX = PF_LOCAL;
313pub const PF_FILE = PF_LOCAL;
314pub const PF_INET = 2;
315pub const PF_APPLETALK = 16;
316pub const PF_INET6 = 24;
317pub const PF_DECnet = 12;
318pub const PF_KEY = 29;
319pub const PF_ROUTE = 34;
320pub const PF_SNA = 11;
321pub const PF_MPLS = 33;
322pub const PF_CAN = 35;
323pub const PF_BLUETOOTH = 31;
324pub const PF_ISDN = 26;
325pub const PF_MAX = 37;
326
327pub const AF_UNSPEC = PF_UNSPEC;
328pub const AF_LOCAL = PF_LOCAL;
329pub const AF_UNIX = AF_LOCAL;
330pub const AF_FILE = AF_LOCAL;
331pub const AF_INET = PF_INET;
332pub const AF_APPLETALK = PF_APPLETALK;
333pub const AF_INET6 = PF_INET6;
334pub const AF_KEY = PF_KEY;
335pub const AF_ROUTE = PF_ROUTE;
336pub const AF_SNA = PF_SNA;
337pub const AF_MPLS = PF_MPLS;
338pub const AF_CAN = PF_CAN;
339pub const AF_BLUETOOTH = PF_BLUETOOTH;
340pub const AF_ISDN = PF_ISDN;
341pub const AF_MAX = PF_MAX;
342
343pub const DT_UNKNOWN = 0;
344pub const DT_FIFO = 1;
345pub const DT_CHR = 2;
346pub const DT_DIR = 4;
347pub const DT_BLK = 6;
348pub const DT_REG = 8;
349pub const DT_LNK = 10;
350pub const DT_SOCK = 12;
351pub const DT_WHT = 14;
352
353/// add event to kq (implies enable)
354pub const EV_ADD = 0x0001;
355
356/// delete event from kq
357pub const EV_DELETE = 0x0002;
358
359/// enable event
360pub const EV_ENABLE = 0x0004;
361
362/// disable event (not reported)
363pub const EV_DISABLE = 0x0008;
364
365/// only report one occurrence
366pub const EV_ONESHOT = 0x0010;
367
368/// clear event state after reporting
369pub const EV_CLEAR = 0x0020;
370
371/// force immediate event output
372/// ... with or without EV_ERROR
373/// ... use KEVENT_FLAG_ERROR_EVENTS
374/// on syscalls supporting flags
375pub const EV_RECEIPT = 0x0040;
376
377/// disable event after reporting
378pub const EV_DISPATCH = 0x0080;
379
380pub const EVFILT_READ = 0;
381pub const EVFILT_WRITE = 1;
382
383/// attached to aio requests
384pub const EVFILT_AIO = 2;
385
386/// attached to vnodes
387pub const EVFILT_VNODE = 3;
388
389/// attached to struct proc
390pub const EVFILT_PROC = 4;
391
392/// attached to struct proc
393pub const EVFILT_SIGNAL = 5;
394
395/// timers
396pub const EVFILT_TIMER = 6;
397
398/// Filesystem events
399pub const EVFILT_FS = 7;
400
401/// On input, NOTE_TRIGGER causes the event to be triggered for output.
402pub const NOTE_TRIGGER = 0x08000000;
403
404/// low water mark
405pub const NOTE_LOWAT = 0x00000001;
406
407/// vnode was removed
408pub const NOTE_DELETE = 0x00000001;
409
410/// data contents changed
411pub const NOTE_WRITE = 0x00000002;
412
413/// size increased
414pub const NOTE_EXTEND = 0x00000004;
415
416/// attributes changed
417pub const NOTE_ATTRIB = 0x00000008;
418
419/// link count changed
420pub const NOTE_LINK = 0x00000010;
421
422/// vnode was renamed
423pub const NOTE_RENAME = 0x00000020;
424
425/// vnode access was revoked
426pub const NOTE_REVOKE = 0x00000040;
427
428/// process exited
429pub const NOTE_EXIT = 0x80000000;
430
431/// process forked
432pub const NOTE_FORK = 0x40000000;
433
434/// process exec'd
435pub const NOTE_EXEC = 0x20000000;
436
437/// mask for signal & exit status
438pub const NOTE_PDATAMASK = 0x000fffff;
439pub const NOTE_PCTRLMASK = 0xf0000000;
440
441pub const TIOCCBRK = 0x2000747a;
442pub const TIOCCDTR = 0x20007478;
443pub const TIOCCONS = 0x80047462;
444pub const TIOCDCDTIMESTAMP = 0x40107458;
445pub const TIOCDRAIN = 0x2000745e;
446pub const TIOCEXCL = 0x2000740d;
447pub const TIOCEXT = 0x80047460;
448pub const TIOCFLAG_CDTRCTS = 0x10;
449pub const TIOCFLAG_CLOCAL = 0x2;
450pub const TIOCFLAG_CRTSCTS = 0x4;
451pub const TIOCFLAG_MDMBUF = 0x8;
452pub const TIOCFLAG_SOFTCAR = 0x1;
453pub const TIOCFLUSH = 0x80047410;
454pub const TIOCGETA = 0x402c7413;
455pub const TIOCGETD = 0x4004741a;
456pub const TIOCGFLAGS = 0x4004745d;
457pub const TIOCGLINED = 0x40207442;
458pub const TIOCGPGRP = 0x40047477;
459pub const TIOCGQSIZE = 0x40047481;
460pub const TIOCGRANTPT = 0x20007447;
461pub const TIOCGSID = 0x40047463;
462pub const TIOCGSIZE = 0x40087468;
463pub const TIOCGWINSZ = 0x40087468;
464pub const TIOCMBIC = 0x8004746b;
465pub const TIOCMBIS = 0x8004746c;
466pub const TIOCMGET = 0x4004746a;
467pub const TIOCMSET = 0x8004746d;
468pub const TIOCM_CAR = 0x40;
469pub const TIOCM_CD = 0x40;
470pub const TIOCM_CTS = 0x20;
471pub const TIOCM_DSR = 0x100;
472pub const TIOCM_DTR = 0x2;
473pub const TIOCM_LE = 0x1;
474pub const TIOCM_RI = 0x80;
475pub const TIOCM_RNG = 0x80;
476pub const TIOCM_RTS = 0x4;
477pub const TIOCM_SR = 0x10;
478pub const TIOCM_ST = 0x8;
479pub const TIOCNOTTY = 0x20007471;
480pub const TIOCNXCL = 0x2000740e;
481pub const TIOCOUTQ = 0x40047473;
482pub const TIOCPKT = 0x80047470;
483pub const TIOCPKT_DATA = 0x0;
484pub const TIOCPKT_DOSTOP = 0x20;
485pub const TIOCPKT_FLUSHREAD = 0x1;
486pub const TIOCPKT_FLUSHWRITE = 0x2;
487pub const TIOCPKT_IOCTL = 0x40;
488pub const TIOCPKT_NOSTOP = 0x10;
489pub const TIOCPKT_START = 0x8;
490pub const TIOCPKT_STOP = 0x4;
491pub const TIOCPTMGET = 0x40287446;
492pub const TIOCPTSNAME = 0x40287448;
493pub const TIOCRCVFRAME = 0x80087445;
494pub const TIOCREMOTE = 0x80047469;
495pub const TIOCSBRK = 0x2000747b;
496pub const TIOCSCTTY = 0x20007461;
497pub const TIOCSDTR = 0x20007479;
498pub const TIOCSETA = 0x802c7414;
499pub const TIOCSETAF = 0x802c7416;
500pub const TIOCSETAW = 0x802c7415;
501pub const TIOCSETD = 0x8004741b;
502pub const TIOCSFLAGS = 0x8004745c;
503pub const TIOCSIG = 0x2000745f;
504pub const TIOCSLINED = 0x80207443;
505pub const TIOCSPGRP = 0x80047476;
506pub const TIOCSQSIZE = 0x80047480;
507pub const TIOCSSIZE = 0x80087467;
508pub const TIOCSTART = 0x2000746e;
509pub const TIOCSTAT = 0x80047465;
510pub const TIOCSTI = 0x80017472;
511pub const TIOCSTOP = 0x2000746f;
512pub const TIOCSWINSZ = 0x80087467;
513pub const TIOCUCNTL = 0x80047466;
514pub const TIOCXMTFRAME = 0x80087444;
515
516fn unsigned(s: i32) u32 {
517 return @bitCast(u32, s);
518}
519fn signed(s: u32) i32 {
520 return @bitCast(i32, s);
521}
522pub fn WEXITSTATUS(s: i32) i32 {
523 return signed((unsigned(s) >> 8) & 0xff);
524}
525pub fn WTERMSIG(s: i32) i32 {
526 return signed(unsigned(s) & 0x7f);
527}
528pub fn WSTOPSIG(s: i32) i32 {
529 return WEXITSTATUS(s);
530}
531pub fn WIFEXITED(s: i32) bool {
532 return WTERMSIG(s) == 0;
533}
534
535pub fn WIFCONTINUED(s: i32) bool {
536 return ((s & 0x7f) == 0xffff);
537}
538
539pub fn WIFSTOPPED(s: i32) bool {
540 return ((s & 0x7f != 0x7f) and !WIFCONTINUED(s));
541}
542
543pub fn WIFSIGNALED(s: i32) bool {
544 return !WIFSTOPPED(s) and !WIFCONTINUED(s) and !WIFEXITED(s);
545}
546
547pub const winsize = extern struct {
548 ws_row: u16,
549 ws_col: u16,
550 ws_xpixel: u16,
551 ws_ypixel: u16,
552};
553
554const NSIG = 32;
555
556pub const SIG_ERR = @intToPtr(extern fn (i32) void, maxInt(usize));
557pub const SIG_DFL = @intToPtr(extern fn (i32) void, 0);
558pub const SIG_IGN = @intToPtr(extern fn (i32) void, 1);
559
560/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.
561pub const Sigaction = extern struct {
562 /// signal handler
563 __sigaction_u: extern union {
564 __sa_handler: extern fn (i32) void,
565 __sa_sigaction: extern fn (i32, *__siginfo, usize) void,
566 },
567
568 /// see signal options
569 sa_flags: u32,
570
571 /// signal mask to apply
572 sa_mask: sigset_t,
573};
574
575pub const _SIG_WORDS = 4;
576pub const _SIG_MAXSIG = 128;
577
578pub inline fn _SIG_IDX(sig: usize) usize {
579 return sig - 1;
580}
581pub inline fn _SIG_WORD(sig: usize) usize {
582 return_SIG_IDX(sig) >> 5;
583}
584pub inline fn _SIG_BIT(sig: usize) usize {
585 return 1 << (_SIG_IDX(sig) & 31);
586}
587pub inline fn _SIG_VALID(sig: usize) usize {
588 return sig <= _SIG_MAXSIG and sig > 0;
589}
590
591pub const sigset_t = extern struct {
592 __bits: [_SIG_WORDS]u32,
593};
594
595pub const EPERM = 1; // Operation not permitted
596pub const ENOENT = 2; // No such file or directory
597pub const ESRCH = 3; // No such process
598pub const EINTR = 4; // Interrupted system call
599pub const EIO = 5; // Input/output error
600pub const ENXIO = 6; // Device not configured
601pub const E2BIG = 7; // Argument list too long
602pub const ENOEXEC = 8; // Exec format error
603pub const EBADF = 9; // Bad file descriptor
604pub const ECHILD = 10; // No child processes
605pub const EDEADLK = 11; // Resource deadlock avoided
606// 11 was EAGAIN
607pub const ENOMEM = 12; // Cannot allocate memory
608pub const EACCES = 13; // Permission denied
609pub const EFAULT = 14; // Bad address
610pub const ENOTBLK = 15; // Block device required
611pub const EBUSY = 16; // Device busy
612pub const EEXIST = 17; // File exists
613pub const EXDEV = 18; // Cross-device link
614pub const ENODEV = 19; // Operation not supported by device
615pub const ENOTDIR = 20; // Not a directory
616pub const EISDIR = 21; // Is a directory
617pub const EINVAL = 22; // Invalid argument
618pub const ENFILE = 23; // Too many open files in system
619pub const EMFILE = 24; // Too many open files
620pub const ENOTTY = 25; // Inappropriate ioctl for device
621pub const ETXTBSY = 26; // Text file busy
622pub const EFBIG = 27; // File too large
623pub const ENOSPC = 28; // No space left on device
624pub const ESPIPE = 29; // Illegal seek
625pub const EROFS = 30; // Read-only file system
626pub const EMLINK = 31; // Too many links
627pub const EPIPE = 32; // Broken pipe
628
629// math software
630pub const EDOM = 33; // Numerical argument out of domain
631pub const ERANGE = 34; // Result too large or too small
632
633// non-blocking and interrupt i/o
634pub const EAGAIN = 35; // Resource temporarily unavailable
635pub const EWOULDBLOCK = EAGAIN; // Operation would block
636pub const EINPROGRESS = 36; // Operation now in progress
637pub const EALREADY = 37; // Operation already in progress
638
639// ipc/network software -- argument errors
640pub const ENOTSOCK = 38; // Socket operation on non-socket
641pub const EDESTADDRREQ = 39; // Destination address required
642pub const EMSGSIZE = 40; // Message too long
643pub const EPROTOTYPE = 41; // Protocol wrong type for socket
644pub const ENOPROTOOPT = 42; // Protocol option not available
645pub const EPROTONOSUPPORT = 43; // Protocol not supported
646pub const ESOCKTNOSUPPORT = 44; // Socket type not supported
647pub const EOPNOTSUPP = 45; // Operation not supported
648pub const EPFNOSUPPORT = 46; // Protocol family not supported
649pub const EAFNOSUPPORT = 47; // Address family not supported by protocol family
650pub const EADDRINUSE = 48; // Address already in use
651pub const EADDRNOTAVAIL = 49; // Can't assign requested address
652
653// ipc/network software -- operational errors
654pub const ENETDOWN = 50; // Network is down
655pub const ENETUNREACH = 51; // Network is unreachable
656pub const ENETRESET = 52; // Network dropped connection on reset
657pub const ECONNABORTED = 53; // Software caused connection abort
658pub const ECONNRESET = 54; // Connection reset by peer
659pub const ENOBUFS = 55; // No buffer space available
660pub const EISCONN = 56; // Socket is already connected
661pub const ENOTCONN = 57; // Socket is not connected
662pub const ESHUTDOWN = 58; // Can't send after socket shutdown
663pub const ETOOMANYREFS = 59; // Too many references: can't splice
664pub const ETIMEDOUT = 60; // Operation timed out
665pub const ECONNREFUSED = 61; // Connection refused
666
667pub const ELOOP = 62; // Too many levels of symbolic links
668pub const ENAMETOOLONG = 63; // File name too long
669
670// should be rearranged
671pub const EHOSTDOWN = 64; // Host is down
672pub const EHOSTUNREACH = 65; // No route to host
673pub const ENOTEMPTY = 66; // Directory not empty
674
675// quotas & mush
676pub const EPROCLIM = 67; // Too many processes
677pub const EUSERS = 68; // Too many users
678pub const EDQUOT = 69; // Disc quota exceeded
679
680// Network File System
681pub const ESTALE = 70; // Stale NFS file handle
682pub const EREMOTE = 71; // Too many levels of remote in path
683pub const EBADRPC = 72; // RPC struct is bad
684pub const ERPCMISMATCH = 73; // RPC version wrong
685pub const EPROGUNAVAIL = 74; // RPC prog. not avail
686pub const EPROGMISMATCH = 75; // Program version wrong
687pub const EPROCUNAVAIL = 76; // Bad procedure for program
688
689pub const ENOLCK = 77; // No locks available
690pub const ENOSYS = 78; // Function not implemented
691
692pub const EFTYPE = 79; // Inappropriate file type or format
693pub const EAUTH = 80; // Authentication error
694pub const ENEEDAUTH = 81; // Need authenticator
695
696// SystemV IPC
697pub const EIDRM = 82; // Identifier removed
698pub const ENOMSG = 83; // No message of desired type
699pub const EOVERFLOW = 84; // Value too large to be stored in data type
700
701// Wide/multibyte-character handling, ISO/IEC 9899/AMD1:1995
702pub const EILSEQ = 85; // Illegal byte sequence
703
704// From IEEE Std 1003.1-2001
705// Base, Realtime, Threads or Thread Priority Scheduling option errors
706pub const ENOTSUP = 86; // Not supported
707
708// Realtime option errors
709pub const ECANCELED = 87; // Operation canceled
710
711// Realtime, XSI STREAMS option errors
712pub const EBADMSG = 88; // Bad or Corrupt message
713
714// XSI STREAMS option errors
715pub const ENODATA = 89; // No message available
716pub const ENOSR = 90; // No STREAM resources
717pub const ENOSTR = 91; // Not a STREAM
718pub const ETIME = 92; // STREAM ioctl timeout
719
720// File system extended attribute errors
721pub const ENOATTR = 93; // Attribute not found
722
723// Realtime, XSI STREAMS option errors
724pub const EMULTIHOP = 94; // Multihop attempted
725pub const ENOLINK = 95; // Link has been severed
726pub const EPROTO = 96; // Protocol error
727
728pub const ELAST = 96; // Must equal largest errno
std/c/posix/windows.zig deleted-86
...@@ -1,86 +0,0 @@
1pub const EPERM = 1;
2pub const ENOENT = 2;
3pub const ESRCH = 3;
4pub const EINTR = 4;
5pub const EIO = 5;
6pub const ENXIO = 6;
7pub const E2BIG = 7;
8pub const ENOEXEC = 8;
9pub const EBADF = 9;
10pub const ECHILD = 10;
11pub const EAGAIN = 11;
12pub const ENOMEM = 12;
13pub const EACCES = 13;
14pub const EFAULT = 14;
15pub const EBUSY = 16;
16pub const EEXIST = 17;
17pub const EXDEV = 18;
18pub const ENODEV = 19;
19pub const ENOTDIR = 20;
20pub const EISDIR = 21;
21pub const ENFILE = 23;
22pub const EMFILE = 24;
23pub const ENOTTY = 25;
24pub const EFBIG = 27;
25pub const ENOSPC = 28;
26pub const ESPIPE = 29;
27pub const EROFS = 30;
28pub const EMLINK = 31;
29pub const EPIPE = 32;
30pub const EDOM = 33;
31pub const EDEADLK = 36;
32pub const ENAMETOOLONG = 38;
33pub const ENOLCK = 39;
34pub const ENOSYS = 40;
35pub const ENOTEMPTY = 41;
36
37pub const EINVAL = 22;
38pub const ERANGE = 34;
39pub const EILSEQ = 42;
40pub const STRUNCATE = 80;
41
42// Support EDEADLOCK for compatibility with older Microsoft C versions
43pub const EDEADLOCK = EDEADLK;
44
45// POSIX Supplement
46pub const EADDRINUSE = 100;
47pub const EADDRNOTAVAIL = 101;
48pub const EAFNOSUPPORT = 102;
49pub const EALREADY = 103;
50pub const EBADMSG = 104;
51pub const ECANCELED = 105;
52pub const ECONNABORTED = 106;
53pub const ECONNREFUSED = 107;
54pub const ECONNRESET = 108;
55pub const EDESTADDRREQ = 109;
56pub const EHOSTUNREACH = 110;
57pub const EIDRM = 111;
58pub const EINPROGRESS = 112;
59pub const EISCONN = 113;
60pub const ELOOP = 114;
61pub const EMSGSIZE = 115;
62pub const ENETDOWN = 116;
63pub const ENETRESET = 117;
64pub const ENETUNREACH = 118;
65pub const ENOBUFS = 119;
66pub const ENODATA = 120;
67pub const ENOLINK = 121;
68pub const ENOMSG = 122;
69pub const ENOPROTOOPT = 123;
70pub const ENOSR = 124;
71pub const ENOSTR = 125;
72pub const ENOTCONN = 126;
73pub const ENOTRECOVERABLE = 127;
74pub const ENOTSOCK = 128;
75pub const ENOTSUP = 129;
76pub const EOPNOTSUPP = 130;
77pub const EOTHER = 131;
78pub const EOVERFLOW = 132;
79pub const EOWNERDEAD = 133;
80pub const EPROTO = 134;
81pub const EPROTONOSUPPORT = 135;
82pub const EPROTOTYPE = 136;
83pub const ETIME = 137;
84pub const ETIMEDOUT = 138;
85pub const ETXTBSY = 139;
86pub const EWOULDBLOCK = 140;
std/os.zig+3-1
...@@ -19,7 +19,7 @@ const builtin = @import("builtin");...@@ -19,7 +19,7 @@ const builtin = @import("builtin");
19const MAX_PATH_BYTES = std.fs.MAX_PATH_BYTES;19const MAX_PATH_BYTES = std.fs.MAX_PATH_BYTES;
2020
21comptime {21comptime {
22 assert(@import("std") == std); // You have to run the std lib tests with --override-std-dir22 assert(@import("std") == std); // std lib tests require --override-std-dir
23}23}
2424
25pub const darwin = @import("os/darwin.zig");25pub const darwin = @import("os/darwin.zig");
...@@ -43,6 +43,8 @@ pub const system = if (builtin.link_libc) std.c else switch (builtin.os) {...@@ -43,6 +43,8 @@ pub const system = if (builtin.link_libc) std.c else switch (builtin.os) {
43 else => struct {},43 else => struct {},
44};44};
4545
46pub use @import("os/bits.zig");
47
46/// See also `getenv`.48/// See also `getenv`.
47pub var environ: [][*]u8 = undefined;49pub var environ: [][*]u8 = undefined;
4850
std/os/bits.zig created+27
...@@ -0,0 +1,27 @@
1// Platform-dependent types and values that are used along with OS-specific APIs.
2// These are imported into `std.c`, `std.os`, and `std.os.linux`.
3
4const builtin = @import("builtin");
5
6pub use switch (builtin.os) {
7 .macosx, .ios, .tvos, .watchos => @import("bits/darwin.zig"),
8 .freebsd => @import("bits/freebsd.zig"),
9 .linux => @import("bits/linux.zig"),
10 .netbsd => @import("bits/netbsd.zig"),
11 .wasi => @import("bits/wasi.zig"),
12 .windows => @import("bits/windows.zig"),
13 else => struct {},
14};
15
16pub const pthread_t = *@OpaqueType();
17pub const FILE = @OpaqueType();
18
19pub const iovec = extern struct {
20 iov_base: [*]u8,
21 iov_len: usize,
22};
23
24pub const iovec_const = extern struct {
25 iov_base: [*]const u8,
26 iov_len: usize,
27};
std/os/bits/darwin.zig created+1102
...@@ -0,0 +1,1102 @@
1const std = @import("../../std.zig");
2const assert = std.debug.assert;
3
4pub const fd_t = c_int;
5pub const pid_t = c_int;
6
7pub fn sigaction(sig: u5, noalias act: *const Sigaction, noalias oact: ?*Sigaction) usize {
8 assert(sig != SIGKILL);
9 assert(sig != SIGSTOP);
10 var cact = c.Sigaction{
11 .handler = @ptrCast(extern fn (c_int) void, act.handler),
12 .sa_flags = @bitCast(c_int, act.flags),
13 .sa_mask = act.mask,
14 };
15 var coact: c.Sigaction = undefined;
16 const result = errnoWrap(c.sigaction(sig, &cact, &coact));
17 if (result != 0) {
18 return result;
19 }
20 if (oact) |old| {
21 old.* = Sigaction{
22 .handler = @ptrCast(extern fn (i32) void, coact.handler),
23 .flags = @bitCast(u32, coact.sa_flags),
24 .mask = coact.sa_mask,
25 };
26 }
27 return result;
28}
29
30pub const in_port_t = u16;
31pub const sa_family_t = u8;
32pub const socklen_t = u32;
33pub const sockaddr = extern union {
34 in: sockaddr_in,
35 in6: sockaddr_in6,
36};
37pub const sockaddr_in = extern struct {
38 len: u8,
39 family: sa_family_t,
40 port: in_port_t,
41 addr: u32,
42 zero: [8]u8,
43};
44pub const sockaddr_in6 = extern struct {
45 len: u8,
46 family: sa_family_t,
47 port: in_port_t,
48 flowinfo: u32,
49 addr: [16]u8,
50 scope_id: u32,
51};
52
53pub const timeval = extern struct {
54 tv_sec: c_long,
55 tv_usec: i32,
56};
57
58pub const timezone = extern struct {
59 tz_minuteswest: i32,
60 tz_dsttime: i32,
61};
62
63pub const mach_timebase_info_data = extern struct {
64 numer: u32,
65 denom: u32,
66};
67
68/// Renamed to Stat to not conflict with the stat function.
69pub const Stat = extern struct {
70 dev: i32,
71 mode: u16,
72 nlink: u16,
73 ino: u64,
74 uid: u32,
75 gid: u32,
76 rdev: i32,
77 atime: usize,
78 atimensec: usize,
79 mtime: usize,
80 mtimensec: usize,
81 ctime: usize,
82 ctimensec: usize,
83 birthtime: usize,
84 birthtimensec: usize,
85 size: i64,
86 blocks: i64,
87 blksize: i32,
88 flags: u32,
89 gen: u32,
90 lspare: i32,
91 qspare: [2]i64,
92};
93
94pub const timespec = extern struct {
95 tv_sec: isize,
96 tv_nsec: isize,
97};
98
99pub const sigset_t = u32;
100pub const empty_sigset = sigset_t(0);
101
102/// Renamed from `sigaction` to `Sigaction` to avoid conflict with function name.
103pub const Sigaction = extern struct {
104 handler: extern fn (c_int) void,
105 sa_mask: sigset_t,
106 sa_flags: c_int,
107};
108
109pub const dirent = extern struct {
110 d_ino: usize,
111 d_seekoff: usize,
112 d_reclen: u16,
113 d_namlen: u16,
114 d_type: u8,
115 d_name: u8, // field address is address of first byte of name
116};
117
118pub const pthread_attr_t = extern struct {
119 __sig: c_long,
120 __opaque: [56]u8,
121};
122
123/// Renamed from `kevent` to `Kevent` to avoid conflict with function name.
124pub const Kevent = extern struct {
125 ident: usize,
126 filter: i16,
127 flags: u16,
128 fflags: u32,
129 data: isize,
130 udata: usize,
131};
132
133// sys/types.h on macos uses #pragma pack(4) so these checks are
134// to make sure the struct is laid out the same. These values were
135// produced from C code using the offsetof macro.
136comptime {
137 assert(@byteOffsetOf(Kevent, "ident") == 0);
138 assert(@byteOffsetOf(Kevent, "filter") == 8);
139 assert(@byteOffsetOf(Kevent, "flags") == 10);
140 assert(@byteOffsetOf(Kevent, "fflags") == 12);
141 assert(@byteOffsetOf(Kevent, "data") == 16);
142 assert(@byteOffsetOf(Kevent, "udata") == 24);
143}
144
145pub const kevent64_s = extern struct {
146 ident: u64,
147 filter: i16,
148 flags: u16,
149 fflags: u32,
150 data: i64,
151 udata: u64,
152 ext: [2]u64,
153};
154
155// sys/types.h on macos uses #pragma pack() so these checks are
156// to make sure the struct is laid out the same. These values were
157// produced from C code using the offsetof macro.
158comptime {
159 assert(@byteOffsetOf(kevent64_s, "ident") == 0);
160 assert(@byteOffsetOf(kevent64_s, "filter") == 8);
161 assert(@byteOffsetOf(kevent64_s, "flags") == 10);
162 assert(@byteOffsetOf(kevent64_s, "fflags") == 12);
163 assert(@byteOffsetOf(kevent64_s, "data") == 16);
164 assert(@byteOffsetOf(kevent64_s, "udata") == 24);
165 assert(@byteOffsetOf(kevent64_s, "ext") == 32);
166}
167
168pub const mach_port_t = c_uint;
169pub const clock_serv_t = mach_port_t;
170pub const clock_res_t = c_int;
171pub const mach_port_name_t = natural_t;
172pub const natural_t = c_uint;
173pub const mach_timespec_t = extern struct {
174 tv_sec: c_uint,
175 tv_nsec: clock_res_t,
176};
177pub const kern_return_t = c_int;
178pub const host_t = mach_port_t;
179pub const CALENDAR_CLOCK = 1;
180
181pub const PATH_MAX = 1024;
182
183pub const STDIN_FILENO = 0;
184pub const STDOUT_FILENO = 1;
185pub const STDERR_FILENO = 2;
186
187/// [MC2] no permissions
188pub const PROT_NONE = 0x00;
189
190/// [MC2] pages can be read
191pub const PROT_READ = 0x01;
192
193/// [MC2] pages can be written
194pub const PROT_WRITE = 0x02;
195
196/// [MC2] pages can be executed
197pub const PROT_EXEC = 0x04;
198
199/// allocated from memory, swap space
200pub const MAP_ANONYMOUS = 0x1000;
201
202/// map from file (default)
203pub const MAP_FILE = 0x0000;
204
205/// interpret addr exactly
206pub const MAP_FIXED = 0x0010;
207
208/// region may contain semaphores
209pub const MAP_HASSEMAPHORE = 0x0200;
210
211/// changes are private
212pub const MAP_PRIVATE = 0x0002;
213
214/// share changes
215pub const MAP_SHARED = 0x0001;
216
217/// don't cache pages for this mapping
218pub const MAP_NOCACHE = 0x0400;
219
220/// don't reserve needed swap area
221pub const MAP_NORESERVE = 0x0040;
222pub const MAP_FAILED = maxInt(usize);
223
224/// [XSI] no hang in wait/no child to reap
225pub const WNOHANG = 0x00000001;
226
227/// [XSI] notify on stop, untraced child
228pub const WUNTRACED = 0x00000002;
229
230/// take signal on signal stack
231pub const SA_ONSTACK = 0x0001;
232
233/// restart system on signal return
234pub const SA_RESTART = 0x0002;
235
236/// reset to SIG_DFL when taking signal
237pub const SA_RESETHAND = 0x0004;
238
239/// do not generate SIGCHLD on child stop
240pub const SA_NOCLDSTOP = 0x0008;
241
242/// don't mask the signal we're delivering
243pub const SA_NODEFER = 0x0010;
244
245/// don't keep zombies around
246pub const SA_NOCLDWAIT = 0x0020;
247
248/// signal handler with SA_SIGINFO args
249pub const SA_SIGINFO = 0x0040;
250
251/// do not bounce off kernel's sigtramp
252pub const SA_USERTRAMP = 0x0100;
253
254/// signal handler with SA_SIGINFO args with 64bit regs information
255pub const SA_64REGSET = 0x0200;
256
257pub const O_LARGEFILE = 0x0000;
258pub const O_PATH = 0x0000;
259
260pub const F_OK = 0;
261pub const X_OK = 1;
262pub const W_OK = 2;
263pub const R_OK = 4;
264
265/// open for reading only
266pub const O_RDONLY = 0x0000;
267
268/// open for writing only
269pub const O_WRONLY = 0x0001;
270
271/// open for reading and writing
272pub const O_RDWR = 0x0002;
273
274/// do not block on open or for data to become available
275pub const O_NONBLOCK = 0x0004;
276
277/// append on each write
278pub const O_APPEND = 0x0008;
279
280/// create file if it does not exist
281pub const O_CREAT = 0x0200;
282
283/// truncate size to 0
284pub const O_TRUNC = 0x0400;
285
286/// error if O_CREAT and the file exists
287pub const O_EXCL = 0x0800;
288
289/// atomically obtain a shared lock
290pub const O_SHLOCK = 0x0010;
291
292/// atomically obtain an exclusive lock
293pub const O_EXLOCK = 0x0020;
294
295/// do not follow symlinks
296pub const O_NOFOLLOW = 0x0100;
297
298/// allow open of symlinks
299pub const O_SYMLINK = 0x200000;
300
301/// descriptor requested for event notifications only
302pub const O_EVTONLY = 0x8000;
303
304/// mark as close-on-exec
305pub const O_CLOEXEC = 0x1000000;
306
307pub const O_ACCMODE = 3;
308pub const O_ALERT = 536870912;
309pub const O_ASYNC = 64;
310pub const O_DIRECTORY = 1048576;
311pub const O_DP_GETRAWENCRYPTED = 1;
312pub const O_DP_GETRAWUNENCRYPTED = 2;
313pub const O_DSYNC = 4194304;
314pub const O_FSYNC = O_SYNC;
315pub const O_NOCTTY = 131072;
316pub const O_POPUP = 2147483648;
317pub const O_SYNC = 128;
318
319pub const SEEK_SET = 0x0;
320pub const SEEK_CUR = 0x1;
321pub const SEEK_END = 0x2;
322
323pub const DT_UNKNOWN = 0;
324pub const DT_FIFO = 1;
325pub const DT_CHR = 2;
326pub const DT_DIR = 4;
327pub const DT_BLK = 6;
328pub const DT_REG = 8;
329pub const DT_LNK = 10;
330pub const DT_SOCK = 12;
331pub const DT_WHT = 14;
332
333/// block specified signal set
334pub const SIG_BLOCK = 1;
335
336/// unblock specified signal set
337pub const SIG_UNBLOCK = 2;
338
339/// set specified signal set
340pub const SIG_SETMASK = 3;
341
342/// hangup
343pub const SIGHUP = 1;
344
345/// interrupt
346pub const SIGINT = 2;
347
348/// quit
349pub const SIGQUIT = 3;
350
351/// illegal instruction (not reset when caught)
352pub const SIGILL = 4;
353
354/// trace trap (not reset when caught)
355pub const SIGTRAP = 5;
356
357/// abort()
358pub const SIGABRT = 6;
359
360/// pollable event ([XSR] generated, not supported)
361pub const SIGPOLL = 7;
362
363/// compatibility
364pub const SIGIOT = SIGABRT;
365
366/// EMT instruction
367pub const SIGEMT = 7;
368
369/// floating point exception
370pub const SIGFPE = 8;
371
372/// kill (cannot be caught or ignored)
373pub const SIGKILL = 9;
374
375/// bus error
376pub const SIGBUS = 10;
377
378/// segmentation violation
379pub const SIGSEGV = 11;
380
381/// bad argument to system call
382pub const SIGSYS = 12;
383
384/// write on a pipe with no one to read it
385pub const SIGPIPE = 13;
386
387/// alarm clock
388pub const SIGALRM = 14;
389
390/// software termination signal from kill
391pub const SIGTERM = 15;
392
393/// urgent condition on IO channel
394pub const SIGURG = 16;
395
396/// sendable stop signal not from tty
397pub const SIGSTOP = 17;
398
399/// stop signal from tty
400pub const SIGTSTP = 18;
401
402/// continue a stopped process
403pub const SIGCONT = 19;
404
405/// to parent on child stop or exit
406pub const SIGCHLD = 20;
407
408/// to readers pgrp upon background tty read
409pub const SIGTTIN = 21;
410
411/// like TTIN for output if (tp->t_local&LTOSTOP)
412pub const SIGTTOU = 22;
413
414/// input/output possible signal
415pub const SIGIO = 23;
416
417/// exceeded CPU time limit
418pub const SIGXCPU = 24;
419
420/// exceeded file size limit
421pub const SIGXFSZ = 25;
422
423/// virtual time alarm
424pub const SIGVTALRM = 26;
425
426/// profiling time alarm
427pub const SIGPROF = 27;
428
429/// window size changes
430pub const SIGWINCH = 28;
431
432/// information request
433pub const SIGINFO = 29;
434
435/// user defined signal 1
436pub const SIGUSR1 = 30;
437
438/// user defined signal 2
439pub const SIGUSR2 = 31;
440
441/// no flag value
442pub const KEVENT_FLAG_NONE = 0x000;
443
444/// immediate timeout
445pub const KEVENT_FLAG_IMMEDIATE = 0x001;
446
447/// output events only include change
448pub const KEVENT_FLAG_ERROR_EVENTS = 0x002;
449
450/// add event to kq (implies enable)
451pub const EV_ADD = 0x0001;
452
453/// delete event from kq
454pub const EV_DELETE = 0x0002;
455
456/// enable event
457pub const EV_ENABLE = 0x0004;
458
459/// disable event (not reported)
460pub const EV_DISABLE = 0x0008;
461
462/// only report one occurrence
463pub const EV_ONESHOT = 0x0010;
464
465/// clear event state after reporting
466pub const EV_CLEAR = 0x0020;
467
468/// force immediate event output
469/// ... with or without EV_ERROR
470/// ... use KEVENT_FLAG_ERROR_EVENTS
471/// on syscalls supporting flags
472pub const EV_RECEIPT = 0x0040;
473
474/// disable event after reporting
475pub const EV_DISPATCH = 0x0080;
476
477/// unique kevent per udata value
478pub const EV_UDATA_SPECIFIC = 0x0100;
479
480/// ... in combination with EV_DELETE
481/// will defer delete until udata-specific
482/// event enabled. EINPROGRESS will be
483/// returned to indicate the deferral
484pub const EV_DISPATCH2 = EV_DISPATCH | EV_UDATA_SPECIFIC;
485
486/// report that source has vanished
487/// ... only valid with EV_DISPATCH2
488pub const EV_VANISHED = 0x0200;
489
490/// reserved by system
491pub const EV_SYSFLAGS = 0xF000;
492
493/// filter-specific flag
494pub const EV_FLAG0 = 0x1000;
495
496/// filter-specific flag
497pub const EV_FLAG1 = 0x2000;
498
499/// EOF detected
500pub const EV_EOF = 0x8000;
501
502/// error, data contains errno
503pub const EV_ERROR = 0x4000;
504
505pub const EV_POLL = EV_FLAG0;
506pub const EV_OOBAND = EV_FLAG1;
507
508pub const EVFILT_READ = -1;
509pub const EVFILT_WRITE = -2;
510
511/// attached to aio requests
512pub const EVFILT_AIO = -3;
513
514/// attached to vnodes
515pub const EVFILT_VNODE = -4;
516
517/// attached to struct proc
518pub const EVFILT_PROC = -5;
519
520/// attached to struct proc
521pub const EVFILT_SIGNAL = -6;
522
523/// timers
524pub const EVFILT_TIMER = -7;
525
526/// Mach portsets
527pub const EVFILT_MACHPORT = -8;
528
529/// Filesystem events
530pub const EVFILT_FS = -9;
531
532/// User events
533pub const EVFILT_USER = -10;
534
535/// Virtual memory events
536pub const EVFILT_VM = -12;
537
538/// Exception events
539pub const EVFILT_EXCEPT = -15;
540
541pub const EVFILT_SYSCOUNT = 17;
542
543/// On input, NOTE_TRIGGER causes the event to be triggered for output.
544pub const NOTE_TRIGGER = 0x01000000;
545
546/// ignore input fflags
547pub const NOTE_FFNOP = 0x00000000;
548
549/// and fflags
550pub const NOTE_FFAND = 0x40000000;
551
552/// or fflags
553pub const NOTE_FFOR = 0x80000000;
554
555/// copy fflags
556pub const NOTE_FFCOPY = 0xc0000000;
557
558/// mask for operations
559pub const NOTE_FFCTRLMASK = 0xc0000000;
560pub const NOTE_FFLAGSMASK = 0x00ffffff;
561
562/// low water mark
563pub const NOTE_LOWAT = 0x00000001;
564
565/// OOB data
566pub const NOTE_OOB = 0x00000002;
567
568/// vnode was removed
569pub const NOTE_DELETE = 0x00000001;
570
571/// data contents changed
572pub const NOTE_WRITE = 0x00000002;
573
574/// size increased
575pub const NOTE_EXTEND = 0x00000004;
576
577/// attributes changed
578pub const NOTE_ATTRIB = 0x00000008;
579
580/// link count changed
581pub const NOTE_LINK = 0x00000010;
582
583/// vnode was renamed
584pub const NOTE_RENAME = 0x00000020;
585
586/// vnode access was revoked
587pub const NOTE_REVOKE = 0x00000040;
588
589/// No specific vnode event: to test for EVFILT_READ activation
590pub const NOTE_NONE = 0x00000080;
591
592/// vnode was unlocked by flock(2)
593pub const NOTE_FUNLOCK = 0x00000100;
594
595/// process exited
596pub const NOTE_EXIT = 0x80000000;
597
598/// process forked
599pub const NOTE_FORK = 0x40000000;
600
601/// process exec'd
602pub const NOTE_EXEC = 0x20000000;
603
604/// shared with EVFILT_SIGNAL
605pub const NOTE_SIGNAL = 0x08000000;
606
607/// exit status to be returned, valid for child process only
608pub const NOTE_EXITSTATUS = 0x04000000;
609
610/// provide details on reasons for exit
611pub const NOTE_EXIT_DETAIL = 0x02000000;
612
613/// mask for signal & exit status
614pub const NOTE_PDATAMASK = 0x000fffff;
615pub const NOTE_PCTRLMASK = (~NOTE_PDATAMASK);
616
617pub const NOTE_EXIT_DETAIL_MASK = 0x00070000;
618pub const NOTE_EXIT_DECRYPTFAIL = 0x00010000;
619pub const NOTE_EXIT_MEMORY = 0x00020000;
620pub const NOTE_EXIT_CSERROR = 0x00040000;
621
622/// will react on memory pressure
623pub const NOTE_VM_PRESSURE = 0x80000000;
624
625/// will quit on memory pressure, possibly after cleaning up dirty state
626pub const NOTE_VM_PRESSURE_TERMINATE = 0x40000000;
627
628/// will quit immediately on memory pressure
629pub const NOTE_VM_PRESSURE_SUDDEN_TERMINATE = 0x20000000;
630
631/// there was an error
632pub const NOTE_VM_ERROR = 0x10000000;
633
634/// data is seconds
635pub const NOTE_SECONDS = 0x00000001;
636
637/// data is microseconds
638pub const NOTE_USECONDS = 0x00000002;
639
640/// data is nanoseconds
641pub const NOTE_NSECONDS = 0x00000004;
642
643/// absolute timeout
644pub const NOTE_ABSOLUTE = 0x00000008;
645
646/// ext[1] holds leeway for power aware timers
647pub const NOTE_LEEWAY = 0x00000010;
648
649/// system does minimal timer coalescing
650pub const NOTE_CRITICAL = 0x00000020;
651
652/// system does maximum timer coalescing
653pub const NOTE_BACKGROUND = 0x00000040;
654pub const NOTE_MACH_CONTINUOUS_TIME = 0x00000080;
655
656/// data is mach absolute time units
657pub const NOTE_MACHTIME = 0x00000100;
658
659pub const AF_UNSPEC = 0;
660pub const AF_LOCAL = 1;
661pub const AF_UNIX = AF_LOCAL;
662pub const AF_INET = 2;
663pub const AF_SYS_CONTROL = 2;
664pub const AF_IMPLINK = 3;
665pub const AF_PUP = 4;
666pub const AF_CHAOS = 5;
667pub const AF_NS = 6;
668pub const AF_ISO = 7;
669pub const AF_OSI = AF_ISO;
670pub const AF_ECMA = 8;
671pub const AF_DATAKIT = 9;
672pub const AF_CCITT = 10;
673pub const AF_SNA = 11;
674pub const AF_DECnet = 12;
675pub const AF_DLI = 13;
676pub const AF_LAT = 14;
677pub const AF_HYLINK = 15;
678pub const AF_APPLETALK = 16;
679pub const AF_ROUTE = 17;
680pub const AF_LINK = 18;
681pub const AF_XTP = 19;
682pub const AF_COIP = 20;
683pub const AF_CNT = 21;
684pub const AF_RTIP = 22;
685pub const AF_IPX = 23;
686pub const AF_SIP = 24;
687pub const AF_PIP = 25;
688pub const AF_ISDN = 28;
689pub const AF_E164 = AF_ISDN;
690pub const AF_KEY = 29;
691pub const AF_INET6 = 30;
692pub const AF_NATM = 31;
693pub const AF_SYSTEM = 32;
694pub const AF_NETBIOS = 33;
695pub const AF_PPP = 34;
696pub const AF_MAX = 40;
697
698pub const PF_UNSPEC = AF_UNSPEC;
699pub const PF_LOCAL = AF_LOCAL;
700pub const PF_UNIX = PF_LOCAL;
701pub const PF_INET = AF_INET;
702pub const PF_IMPLINK = AF_IMPLINK;
703pub const PF_PUP = AF_PUP;
704pub const PF_CHAOS = AF_CHAOS;
705pub const PF_NS = AF_NS;
706pub const PF_ISO = AF_ISO;
707pub const PF_OSI = AF_ISO;
708pub const PF_ECMA = AF_ECMA;
709pub const PF_DATAKIT = AF_DATAKIT;
710pub const PF_CCITT = AF_CCITT;
711pub const PF_SNA = AF_SNA;
712pub const PF_DECnet = AF_DECnet;
713pub const PF_DLI = AF_DLI;
714pub const PF_LAT = AF_LAT;
715pub const PF_HYLINK = AF_HYLINK;
716pub const PF_APPLETALK = AF_APPLETALK;
717pub const PF_ROUTE = AF_ROUTE;
718pub const PF_LINK = AF_LINK;
719pub const PF_XTP = AF_XTP;
720pub const PF_COIP = AF_COIP;
721pub const PF_CNT = AF_CNT;
722pub const PF_SIP = AF_SIP;
723pub const PF_IPX = AF_IPX;
724pub const PF_RTIP = AF_RTIP;
725pub const PF_PIP = AF_PIP;
726pub const PF_ISDN = AF_ISDN;
727pub const PF_KEY = AF_KEY;
728pub const PF_INET6 = AF_INET6;
729pub const PF_NATM = AF_NATM;
730pub const PF_SYSTEM = AF_SYSTEM;
731pub const PF_NETBIOS = AF_NETBIOS;
732pub const PF_PPP = AF_PPP;
733pub const PF_MAX = AF_MAX;
734
735pub const SYSPROTO_EVENT = 1;
736pub const SYSPROTO_CONTROL = 2;
737
738pub const SOCK_STREAM = 1;
739pub const SOCK_DGRAM = 2;
740pub const SOCK_RAW = 3;
741pub const SOCK_RDM = 4;
742pub const SOCK_SEQPACKET = 5;
743pub const SOCK_MAXADDRLEN = 255;
744
745pub const IPPROTO_ICMP = 1;
746pub const IPPROTO_ICMPV6 = 58;
747pub const IPPROTO_TCP = 6;
748pub const IPPROTO_UDP = 17;
749pub const IPPROTO_IP = 0;
750pub const IPPROTO_IPV6 = 41;
751
752fn wstatus(x: i32) i32 {
753 return x & 0o177;
754}
755const wstopped = 0o177;
756pub fn WEXITSTATUS(x: i32) i32 {
757 return x >> 8;
758}
759pub fn WTERMSIG(x: i32) i32 {
760 return wstatus(x);
761}
762pub fn WSTOPSIG(x: i32) i32 {
763 return x >> 8;
764}
765pub fn WIFEXITED(x: i32) bool {
766 return wstatus(x) == 0;
767}
768pub fn WIFSTOPPED(x: i32) bool {
769 return wstatus(x) == wstopped and WSTOPSIG(x) != 0x13;
770}
771pub fn WIFSIGNALED(x: i32) bool {
772 return wstatus(x) != wstopped and wstatus(x) != 0;
773}
774
775/// Operation not permitted
776pub const EPERM = 1;
777
778/// No such file or directory
779pub const ENOENT = 2;
780
781/// No such process
782pub const ESRCH = 3;
783
784/// Interrupted system call
785pub const EINTR = 4;
786
787/// Input/output error
788pub const EIO = 5;
789
790/// Device not configured
791pub const ENXIO = 6;
792
793/// Argument list too long
794pub const E2BIG = 7;
795
796/// Exec format error
797pub const ENOEXEC = 8;
798
799/// Bad file descriptor
800pub const EBADF = 9;
801
802/// No child processes
803pub const ECHILD = 10;
804
805/// Resource deadlock avoided
806pub const EDEADLK = 11;
807
808/// Cannot allocate memory
809pub const ENOMEM = 12;
810
811/// Permission denied
812pub const EACCES = 13;
813
814/// Bad address
815pub const EFAULT = 14;
816
817/// Block device required
818pub const ENOTBLK = 15;
819
820/// Device / Resource busy
821pub const EBUSY = 16;
822
823/// File exists
824pub const EEXIST = 17;
825
826/// Cross-device link
827pub const EXDEV = 18;
828
829/// Operation not supported by device
830pub const ENODEV = 19;
831
832/// Not a directory
833pub const ENOTDIR = 20;
834
835/// Is a directory
836pub const EISDIR = 21;
837
838/// Invalid argument
839pub const EINVAL = 22;
840
841/// Too many open files in system
842pub const ENFILE = 23;
843
844/// Too many open files
845pub const EMFILE = 24;
846
847/// Inappropriate ioctl for device
848pub const ENOTTY = 25;
849
850/// Text file busy
851pub const ETXTBSY = 26;
852
853/// File too large
854pub const EFBIG = 27;
855
856/// No space left on device
857pub const ENOSPC = 28;
858
859/// Illegal seek
860pub const ESPIPE = 29;
861
862/// Read-only file system
863pub const EROFS = 30;
864
865/// Too many links
866pub const EMLINK = 31;
867/// Broken pipe
868
869// math software
870pub const EPIPE = 32;
871
872/// Numerical argument out of domain
873pub const EDOM = 33;
874/// Result too large
875
876// non-blocking and interrupt i/o
877pub const ERANGE = 34;
878
879/// Resource temporarily unavailable
880pub const EAGAIN = 35;
881
882/// Operation would block
883pub const EWOULDBLOCK = EAGAIN;
884
885/// Operation now in progress
886pub const EINPROGRESS = 36;
887/// Operation already in progress
888
889// ipc/network software -- argument errors
890pub const EALREADY = 37;
891
892/// Socket operation on non-socket
893pub const ENOTSOCK = 38;
894
895/// Destination address required
896pub const EDESTADDRREQ = 39;
897
898/// Message too long
899pub const EMSGSIZE = 40;
900
901/// Protocol wrong type for socket
902pub const EPROTOTYPE = 41;
903
904/// Protocol not available
905pub const ENOPROTOOPT = 42;
906
907/// Protocol not supported
908pub const EPROTONOSUPPORT = 43;
909
910/// Socket type not supported
911pub const ESOCKTNOSUPPORT = 44;
912
913/// Operation not supported
914pub const ENOTSUP = 45;
915
916/// Protocol family not supported
917pub const EPFNOSUPPORT = 46;
918
919/// Address family not supported by protocol family
920pub const EAFNOSUPPORT = 47;
921
922/// Address already in use
923pub const EADDRINUSE = 48;
924/// Can't assign requested address
925
926// ipc/network software -- operational errors
927pub const EADDRNOTAVAIL = 49;
928
929/// Network is down
930pub const ENETDOWN = 50;
931
932/// Network is unreachable
933pub const ENETUNREACH = 51;
934
935/// Network dropped connection on reset
936pub const ENETRESET = 52;
937
938/// Software caused connection abort
939pub const ECONNABORTED = 53;
940
941/// Connection reset by peer
942pub const ECONNRESET = 54;
943
944/// No buffer space available
945pub const ENOBUFS = 55;
946
947/// Socket is already connected
948pub const EISCONN = 56;
949
950/// Socket is not connected
951pub const ENOTCONN = 57;
952
953/// Can't send after socket shutdown
954pub const ESHUTDOWN = 58;
955
956/// Too many references: can't splice
957pub const ETOOMANYREFS = 59;
958
959/// Operation timed out
960pub const ETIMEDOUT = 60;
961
962/// Connection refused
963pub const ECONNREFUSED = 61;
964
965/// Too many levels of symbolic links
966pub const ELOOP = 62;
967
968/// File name too long
969pub const ENAMETOOLONG = 63;
970
971/// Host is down
972pub const EHOSTDOWN = 64;
973
974/// No route to host
975pub const EHOSTUNREACH = 65;
976/// Directory not empty
977
978// quotas & mush
979pub const ENOTEMPTY = 66;
980
981/// Too many processes
982pub const EPROCLIM = 67;
983
984/// Too many users
985pub const EUSERS = 68;
986/// Disc quota exceeded
987
988// Network File System
989pub const EDQUOT = 69;
990
991/// Stale NFS file handle
992pub const ESTALE = 70;
993
994/// Too many levels of remote in path
995pub const EREMOTE = 71;
996
997/// RPC struct is bad
998pub const EBADRPC = 72;
999
1000/// RPC version wrong
1001pub const ERPCMISMATCH = 73;
1002
1003/// RPC prog. not avail
1004pub const EPROGUNAVAIL = 74;
1005
1006/// Program version wrong
1007pub const EPROGMISMATCH = 75;
1008
1009/// Bad procedure for program
1010pub const EPROCUNAVAIL = 76;
1011
1012/// No locks available
1013pub const ENOLCK = 77;
1014
1015/// Function not implemented
1016pub const ENOSYS = 78;
1017
1018/// Inappropriate file type or format
1019pub const EFTYPE = 79;
1020
1021/// Authentication error
1022pub const EAUTH = 80;
1023/// Need authenticator
1024
1025// Intelligent device errors
1026pub const ENEEDAUTH = 81;
1027
1028/// Device power is off
1029pub const EPWROFF = 82;
1030
1031/// Device error, e.g. paper out
1032pub const EDEVERR = 83;
1033/// Value too large to be stored in data type
1034
1035// Program loading errors
1036pub const EOVERFLOW = 84;
1037
1038/// Bad executable
1039pub const EBADEXEC = 85;
1040
1041/// Bad CPU type in executable
1042pub const EBADARCH = 86;
1043
1044/// Shared library version mismatch
1045pub const ESHLIBVERS = 87;
1046
1047/// Malformed Macho file
1048pub const EBADMACHO = 88;
1049
1050/// Operation canceled
1051pub const ECANCELED = 89;
1052
1053/// Identifier removed
1054pub const EIDRM = 90;
1055
1056/// No message of desired type
1057pub const ENOMSG = 91;
1058
1059/// Illegal byte sequence
1060pub const EILSEQ = 92;
1061
1062/// Attribute not found
1063pub const ENOATTR = 93;
1064
1065/// Bad message
1066pub const EBADMSG = 94;
1067
1068/// Reserved
1069pub const EMULTIHOP = 95;
1070
1071/// No message available on STREAM
1072pub const ENODATA = 96;
1073
1074/// Reserved
1075pub const ENOLINK = 97;
1076
1077/// No STREAM resources
1078pub const ENOSR = 98;
1079
1080/// Not a STREAM
1081pub const ENOSTR = 99;
1082
1083/// Protocol error
1084pub const EPROTO = 100;
1085
1086/// STREAM ioctl timeout
1087pub const ETIME = 101;
1088
1089/// No such policy registered
1090pub const ENOPOLICY = 103;
1091
1092/// State not recoverable
1093pub const ENOTRECOVERABLE = 104;
1094
1095/// Previous owner died
1096pub const EOWNERDEAD = 105;
1097
1098/// Interface output queue is full
1099pub const EQFULL = 106;
1100
1101/// Must be equal largest errno
1102pub const ELAST = 106;
std/os/bits/freebsd.zig created+840
...@@ -0,0 +1,840 @@
1pub const fd_t = c_int;
2pub const pid_t = c_int;
3
4/// Renamed from `kevent` to `Kevent` to avoid conflict with function name.
5pub const Kevent = extern struct {
6 ident: usize,
7 filter: i16,
8 flags: u16,
9 fflags: u32,
10 data: i64,
11 udata: usize,
12 // TODO ext
13};
14
15pub const pthread_attr_t = extern struct {
16 __size: [56]u8,
17 __align: c_long,
18};
19
20pub const msghdr = extern struct {
21 /// optional address
22 msg_name: ?*sockaddr,
23
24 /// size of address
25 msg_namelen: socklen_t,
26
27 /// scatter/gather array
28 msg_iov: [*]iovec,
29
30 /// # elements in msg_iov
31 msg_iovlen: i32,
32
33 /// ancillary data
34 msg_control: ?*c_void,
35
36 /// ancillary data buffer len
37 msg_controllen: socklen_t,
38
39 /// flags on received message
40 msg_flags: i32,
41};
42
43pub const msghdr_const = extern struct {
44 /// optional address
45 msg_name: ?*const sockaddr,
46
47 /// size of address
48 msg_namelen: socklen_t,
49
50 /// scatter/gather array
51 msg_iov: [*]iovec_const,
52
53 /// # elements in msg_iov
54 msg_iovlen: i32,
55
56 /// ancillary data
57 msg_control: ?*c_void,
58
59 /// ancillary data buffer len
60 msg_controllen: socklen_t,
61
62 /// flags on received message
63 msg_flags: i32,
64};
65
66pub const Stat = extern struct {
67 dev: u64,
68 ino: u64,
69 nlink: usize,
70
71 mode: u16,
72 __pad0: u16,
73 uid: u32,
74 gid: u32,
75 __pad1: u32,
76 rdev: u64,
77
78 atim: timespec,
79 mtim: timespec,
80 ctim: timespec,
81 birthtim: timespec,
82
83 size: i64,
84 blocks: i64,
85 blksize: isize,
86 flags: u32,
87 gen: u64,
88 __spare: [10]u64,
89};
90
91pub const timespec = extern struct {
92 tv_sec: isize,
93 tv_nsec: isize,
94};
95
96pub const dirent = extern struct {
97 d_fileno: usize,
98 d_off: i64,
99 d_reclen: u16,
100 d_type: u8,
101 d_pad0: u8,
102 d_namlen: u16,
103 d_pad1: u16,
104 d_name: [256]u8,
105};
106
107pub const in_port_t = u16;
108pub const sa_family_t = u16;
109
110pub const sockaddr = extern union {
111 in: sockaddr_in,
112 in6: sockaddr_in6,
113};
114
115pub const sockaddr_in = extern struct {
116 len: u8,
117 family: sa_family_t,
118 port: in_port_t,
119 addr: [16]u8,
120 zero: [8]u8,
121};
122
123pub const sockaddr_in6 = extern struct {
124 len: u8,
125 family: sa_family_t,
126 port: in_port_t,
127 flowinfo: u32,
128 addr: [16]u8,
129 scope_id: u32,
130};
131
132pub const CTL_KERN = 1;
133pub const CTL_DEBUG = 5;
134
135pub const KERN_PROC = 14; // struct: process entries
136pub const KERN_PROC_PATHNAME = 12; // path to executable
137
138pub const PATH_MAX = 1024;
139
140pub const STDIN_FILENO = 0;
141pub const STDOUT_FILENO = 1;
142pub const STDERR_FILENO = 2;
143
144pub const PROT_NONE = 0;
145pub const PROT_READ = 1;
146pub const PROT_WRITE = 2;
147pub const PROT_EXEC = 4;
148
149pub const CLOCK_REALTIME = 0;
150pub const CLOCK_VIRTUAL = 1;
151pub const CLOCK_PROF = 2;
152pub const CLOCK_MONOTONIC = 4;
153pub const CLOCK_UPTIME = 5;
154pub const CLOCK_UPTIME_PRECISE = 7;
155pub const CLOCK_UPTIME_FAST = 8;
156pub const CLOCK_REALTIME_PRECISE = 9;
157pub const CLOCK_REALTIME_FAST = 10;
158pub const CLOCK_MONOTONIC_PRECISE = 11;
159pub const CLOCK_MONOTONIC_FAST = 12;
160pub const CLOCK_SECOND = 13;
161pub const CLOCK_THREAD_CPUTIME_ID = 14;
162pub const CLOCK_PROCESS_CPUTIME_ID = 15;
163
164pub const MAP_FAILED = maxInt(usize);
165pub const MAP_SHARED = 0x0001;
166pub const MAP_PRIVATE = 0x0002;
167pub const MAP_FIXED = 0x0010;
168pub const MAP_STACK = 0x0400;
169pub const MAP_NOSYNC = 0x0800;
170pub const MAP_ANON = 0x1000;
171pub const MAP_ANONYMOUS = MAP_ANON;
172pub const MAP_FILE = 0;
173pub const MAP_NORESERVE = 0;
174
175pub const MAP_GUARD = 0x00002000;
176pub const MAP_EXCL = 0x00004000;
177pub const MAP_NOCORE = 0x00020000;
178pub const MAP_PREFAULT_READ = 0x00040000;
179pub const MAP_32BIT = 0x00080000;
180
181pub const WNOHANG = 1;
182pub const WUNTRACED = 2;
183pub const WSTOPPED = WUNTRACED;
184pub const WCONTINUED = 4;
185pub const WNOWAIT = 8;
186pub const WEXITED = 16;
187pub const WTRAPPED = 32;
188
189pub const SA_ONSTACK = 0x0001;
190pub const SA_RESTART = 0x0002;
191pub const SA_RESETHAND = 0x0004;
192pub const SA_NOCLDSTOP = 0x0008;
193pub const SA_NODEFER = 0x0010;
194pub const SA_NOCLDWAIT = 0x0020;
195pub const SA_SIGINFO = 0x0040;
196
197pub const SIGHUP = 1;
198pub const SIGINT = 2;
199pub const SIGQUIT = 3;
200pub const SIGILL = 4;
201pub const SIGTRAP = 5;
202pub const SIGABRT = 6;
203pub const SIGIOT = SIGABRT;
204pub const SIGEMT = 7;
205pub const SIGFPE = 8;
206pub const SIGKILL = 9;
207pub const SIGBUS = 10;
208pub const SIGSEGV = 11;
209pub const SIGSYS = 12;
210pub const SIGPIPE = 13;
211pub const SIGALRM = 14;
212pub const SIGTERM = 15;
213pub const SIGURG = 16;
214pub const SIGSTOP = 17;
215pub const SIGTSTP = 18;
216pub const SIGCONT = 19;
217pub const SIGCHLD = 20;
218pub const SIGTTIN = 21;
219pub const SIGTTOU = 22;
220pub const SIGIO = 23;
221pub const SIGXCPU = 24;
222pub const SIGXFSZ = 25;
223pub const SIGVTALRM = 26;
224pub const SIGPROF = 27;
225pub const SIGWINCH = 28;
226pub const SIGINFO = 29;
227pub const SIGUSR1 = 30;
228pub const SIGUSR2 = 31;
229pub const SIGTHR = 32;
230pub const SIGLWP = SIGTHR;
231pub const SIGLIBRT = 33;
232
233pub const SIGRTMIN = 65;
234pub const SIGRTMAX = 126;
235
236// access function
237pub const F_OK = 0; // test for existence of file
238pub const X_OK = 1; // test for execute or search permission
239pub const W_OK = 2; // test for write permission
240pub const R_OK = 4; // test for read permission
241
242pub const O_RDONLY = 0x0000;
243pub const O_WRONLY = 0x0001;
244pub const O_RDWR = 0x0002;
245pub const O_ACCMODE = 0x0003;
246
247pub const O_CREAT = 0x0200;
248pub const O_EXCL = 0x0800;
249pub const O_NOCTTY = 0x8000;
250pub const O_TRUNC = 0x0400;
251pub const O_APPEND = 0x0008;
252pub const O_NONBLOCK = 0x0004;
253pub const O_DSYNC = 0o10000;
254pub const O_SYNC = 0x0080;
255pub const O_RSYNC = 0o4010000;
256pub const O_DIRECTORY = 0o200000;
257pub const O_NOFOLLOW = 0x0100;
258pub const O_CLOEXEC = 0x00100000;
259
260pub const O_ASYNC = 0x0040;
261pub const O_DIRECT = 0x00010000;
262pub const O_LARGEFILE = 0;
263pub const O_NOATIME = 0o1000000;
264pub const O_PATH = 0o10000000;
265pub const O_TMPFILE = 0o20200000;
266pub const O_NDELAY = O_NONBLOCK;
267
268pub const F_DUPFD = 0;
269pub const F_GETFD = 1;
270pub const F_SETFD = 2;
271pub const F_GETFL = 3;
272pub const F_SETFL = 4;
273
274pub const F_SETOWN = 8;
275pub const F_GETOWN = 9;
276pub const F_SETSIG = 10;
277pub const F_GETSIG = 11;
278
279pub const F_GETLK = 5;
280pub const F_SETLK = 6;
281pub const F_SETLKW = 7;
282
283pub const F_SETOWN_EX = 15;
284pub const F_GETOWN_EX = 16;
285
286pub const F_GETOWNER_UIDS = 17;
287
288pub const SEEK_SET = 0;
289pub const SEEK_CUR = 1;
290pub const SEEK_END = 2;
291
292pub const SIG_BLOCK = 1;
293pub const SIG_UNBLOCK = 2;
294pub const SIG_SETMASK = 3;
295
296pub const SOCK_STREAM = 1;
297pub const SOCK_DGRAM = 2;
298pub const SOCK_RAW = 3;
299pub const SOCK_RDM = 4;
300pub const SOCK_SEQPACKET = 5;
301
302pub const SOCK_CLOEXEC = 0x10000000;
303pub const SOCK_NONBLOCK = 0x20000000;
304
305pub const PROTO_ip = 0o000;
306pub const PROTO_icmp = 0o001;
307pub const PROTO_igmp = 0o002;
308pub const PROTO_ggp = 0o003;
309pub const PROTO_ipencap = 0o004;
310pub const PROTO_st = 0o005;
311pub const PROTO_tcp = 0o006;
312pub const PROTO_egp = 0o010;
313pub const PROTO_pup = 0o014;
314pub const PROTO_udp = 0o021;
315pub const PROTO_hmp = 0o024;
316pub const PROTO_xns_idp = 0o026;
317pub const PROTO_rdp = 0o033;
318pub const PROTO_iso_tp4 = 0o035;
319pub const PROTO_xtp = 0o044;
320pub const PROTO_ddp = 0o045;
321pub const PROTO_idpr_cmtp = 0o046;
322pub const PROTO_ipv6 = 0o051;
323pub const PROTO_ipv6_route = 0o053;
324pub const PROTO_ipv6_frag = 0o054;
325pub const PROTO_idrp = 0o055;
326pub const PROTO_rsvp = 0o056;
327pub const PROTO_gre = 0o057;
328pub const PROTO_esp = 0o062;
329pub const PROTO_ah = 0o063;
330pub const PROTO_skip = 0o071;
331pub const PROTO_ipv6_icmp = 0o072;
332pub const PROTO_ipv6_nonxt = 0o073;
333pub const PROTO_ipv6_opts = 0o074;
334pub const PROTO_rspf = 0o111;
335pub const PROTO_vmtp = 0o121;
336pub const PROTO_ospf = 0o131;
337pub const PROTO_ipip = 0o136;
338pub const PROTO_encap = 0o142;
339pub const PROTO_pim = 0o147;
340pub const PROTO_raw = 0o377;
341
342pub const PF_UNSPEC = 0;
343pub const PF_LOCAL = 1;
344pub const PF_UNIX = PF_LOCAL;
345pub const PF_FILE = PF_LOCAL;
346pub const PF_INET = 2;
347pub const PF_AX25 = 3;
348pub const PF_IPX = 4;
349pub const PF_APPLETALK = 5;
350pub const PF_NETROM = 6;
351pub const PF_BRIDGE = 7;
352pub const PF_ATMPVC = 8;
353pub const PF_X25 = 9;
354pub const PF_INET6 = 10;
355pub const PF_ROSE = 11;
356pub const PF_DECnet = 12;
357pub const PF_NETBEUI = 13;
358pub const PF_SECURITY = 14;
359pub const PF_KEY = 15;
360pub const PF_NETLINK = 16;
361pub const PF_ROUTE = PF_NETLINK;
362pub const PF_PACKET = 17;
363pub const PF_ASH = 18;
364pub const PF_ECONET = 19;
365pub const PF_ATMSVC = 20;
366pub const PF_RDS = 21;
367pub const PF_SNA = 22;
368pub const PF_IRDA = 23;
369pub const PF_PPPOX = 24;
370pub const PF_WANPIPE = 25;
371pub const PF_LLC = 26;
372pub const PF_IB = 27;
373pub const PF_MPLS = 28;
374pub const PF_CAN = 29;
375pub const PF_TIPC = 30;
376pub const PF_BLUETOOTH = 31;
377pub const PF_IUCV = 32;
378pub const PF_RXRPC = 33;
379pub const PF_ISDN = 34;
380pub const PF_PHONET = 35;
381pub const PF_IEEE802154 = 36;
382pub const PF_CAIF = 37;
383pub const PF_ALG = 38;
384pub const PF_NFC = 39;
385pub const PF_VSOCK = 40;
386pub const PF_MAX = 41;
387
388pub const AF_UNSPEC = PF_UNSPEC;
389pub const AF_LOCAL = PF_LOCAL;
390pub const AF_UNIX = AF_LOCAL;
391pub const AF_FILE = AF_LOCAL;
392pub const AF_INET = PF_INET;
393pub const AF_AX25 = PF_AX25;
394pub const AF_IPX = PF_IPX;
395pub const AF_APPLETALK = PF_APPLETALK;
396pub const AF_NETROM = PF_NETROM;
397pub const AF_BRIDGE = PF_BRIDGE;
398pub const AF_ATMPVC = PF_ATMPVC;
399pub const AF_X25 = PF_X25;
400pub const AF_INET6 = PF_INET6;
401pub const AF_ROSE = PF_ROSE;
402pub const AF_DECnet = PF_DECnet;
403pub const AF_NETBEUI = PF_NETBEUI;
404pub const AF_SECURITY = PF_SECURITY;
405pub const AF_KEY = PF_KEY;
406pub const AF_NETLINK = PF_NETLINK;
407pub const AF_ROUTE = PF_ROUTE;
408pub const AF_PACKET = PF_PACKET;
409pub const AF_ASH = PF_ASH;
410pub const AF_ECONET = PF_ECONET;
411pub const AF_ATMSVC = PF_ATMSVC;
412pub const AF_RDS = PF_RDS;
413pub const AF_SNA = PF_SNA;
414pub const AF_IRDA = PF_IRDA;
415pub const AF_PPPOX = PF_PPPOX;
416pub const AF_WANPIPE = PF_WANPIPE;
417pub const AF_LLC = PF_LLC;
418pub const AF_IB = PF_IB;
419pub const AF_MPLS = PF_MPLS;
420pub const AF_CAN = PF_CAN;
421pub const AF_TIPC = PF_TIPC;
422pub const AF_BLUETOOTH = PF_BLUETOOTH;
423pub const AF_IUCV = PF_IUCV;
424pub const AF_RXRPC = PF_RXRPC;
425pub const AF_ISDN = PF_ISDN;
426pub const AF_PHONET = PF_PHONET;
427pub const AF_IEEE802154 = PF_IEEE802154;
428pub const AF_CAIF = PF_CAIF;
429pub const AF_ALG = PF_ALG;
430pub const AF_NFC = PF_NFC;
431pub const AF_VSOCK = PF_VSOCK;
432pub const AF_MAX = PF_MAX;
433
434pub const DT_UNKNOWN = 0;
435pub const DT_FIFO = 1;
436pub const DT_CHR = 2;
437pub const DT_DIR = 4;
438pub const DT_BLK = 6;
439pub const DT_REG = 8;
440pub const DT_LNK = 10;
441pub const DT_SOCK = 12;
442pub const DT_WHT = 14;
443
444/// add event to kq (implies enable)
445pub const EV_ADD = 0x0001;
446
447/// delete event from kq
448pub const EV_DELETE = 0x0002;
449
450/// enable event
451pub const EV_ENABLE = 0x0004;
452
453/// disable event (not reported)
454pub const EV_DISABLE = 0x0008;
455
456/// only report one occurrence
457pub const EV_ONESHOT = 0x0010;
458
459/// clear event state after reporting
460pub const EV_CLEAR = 0x0020;
461
462/// force immediate event output
463/// ... with or without EV_ERROR
464/// ... use KEVENT_FLAG_ERROR_EVENTS
465/// on syscalls supporting flags
466pub const EV_RECEIPT = 0x0040;
467
468/// disable event after reporting
469pub const EV_DISPATCH = 0x0080;
470
471pub const EVFILT_READ = -1;
472pub const EVFILT_WRITE = -2;
473
474/// attached to aio requests
475pub const EVFILT_AIO = -3;
476
477/// attached to vnodes
478pub const EVFILT_VNODE = -4;
479
480/// attached to struct proc
481pub const EVFILT_PROC = -5;
482
483/// attached to struct proc
484pub const EVFILT_SIGNAL = -6;
485
486/// timers
487pub const EVFILT_TIMER = -7;
488
489/// Process descriptors
490pub const EVFILT_PROCDESC = -8;
491
492/// Filesystem events
493pub const EVFILT_FS = -9;
494
495pub const EVFILT_LIO = -10;
496
497/// User events
498pub const EVFILT_USER = -11;
499
500/// Sendfile events
501pub const EVFILT_SENDFILE = -12;
502
503pub const EVFILT_EMPTY = -13;
504
505/// On input, NOTE_TRIGGER causes the event to be triggered for output.
506pub const NOTE_TRIGGER = 0x01000000;
507
508/// ignore input fflags
509pub const NOTE_FFNOP = 0x00000000;
510
511/// and fflags
512pub const NOTE_FFAND = 0x40000000;
513
514/// or fflags
515pub const NOTE_FFOR = 0x80000000;
516
517/// copy fflags
518pub const NOTE_FFCOPY = 0xc0000000;
519
520/// mask for operations
521pub const NOTE_FFCTRLMASK = 0xc0000000;
522pub const NOTE_FFLAGSMASK = 0x00ffffff;
523
524/// low water mark
525pub const NOTE_LOWAT = 0x00000001;
526
527/// behave like poll()
528pub const NOTE_FILE_POLL = 0x00000002;
529
530/// vnode was removed
531pub const NOTE_DELETE = 0x00000001;
532
533/// data contents changed
534pub const NOTE_WRITE = 0x00000002;
535
536/// size increased
537pub const NOTE_EXTEND = 0x00000004;
538
539/// attributes changed
540pub const NOTE_ATTRIB = 0x00000008;
541
542/// link count changed
543pub const NOTE_LINK = 0x00000010;
544
545/// vnode was renamed
546pub const NOTE_RENAME = 0x00000020;
547
548/// vnode access was revoked
549pub const NOTE_REVOKE = 0x00000040;
550
551/// vnode was opened
552pub const NOTE_OPEN = 0x00000080;
553
554/// file closed, fd did not allow write
555pub const NOTE_CLOSE = 0x00000100;
556
557/// file closed, fd did allow write
558pub const NOTE_CLOSE_WRITE = 0x00000200;
559
560/// file was read
561pub const NOTE_READ = 0x00000400;
562
563/// process exited
564pub const NOTE_EXIT = 0x80000000;
565
566/// process forked
567pub const NOTE_FORK = 0x40000000;
568
569/// process exec'd
570pub const NOTE_EXEC = 0x20000000;
571
572/// mask for signal & exit status
573pub const NOTE_PDATAMASK = 0x000fffff;
574pub const NOTE_PCTRLMASK = (~NOTE_PDATAMASK);
575
576/// data is seconds
577pub const NOTE_SECONDS = 0x00000001;
578
579/// data is milliseconds
580pub const NOTE_MSECONDS = 0x00000002;
581
582/// data is microseconds
583pub const NOTE_USECONDS = 0x00000004;
584
585/// data is nanoseconds
586pub const NOTE_NSECONDS = 0x00000008;
587
588/// timeout is absolute
589pub const NOTE_ABSTIME = 0x00000010;
590
591pub const TCGETS = 0x5401;
592pub const TCSETS = 0x5402;
593pub const TCSETSW = 0x5403;
594pub const TCSETSF = 0x5404;
595pub const TCGETA = 0x5405;
596pub const TCSETA = 0x5406;
597pub const TCSETAW = 0x5407;
598pub const TCSETAF = 0x5408;
599pub const TCSBRK = 0x5409;
600pub const TCXONC = 0x540A;
601pub const TCFLSH = 0x540B;
602pub const TIOCEXCL = 0x540C;
603pub const TIOCNXCL = 0x540D;
604pub const TIOCSCTTY = 0x540E;
605pub const TIOCGPGRP = 0x540F;
606pub const TIOCSPGRP = 0x5410;
607pub const TIOCOUTQ = 0x5411;
608pub const TIOCSTI = 0x5412;
609pub const TIOCGWINSZ = 0x5413;
610pub const TIOCSWINSZ = 0x5414;
611pub const TIOCMGET = 0x5415;
612pub const TIOCMBIS = 0x5416;
613pub const TIOCMBIC = 0x5417;
614pub const TIOCMSET = 0x5418;
615pub const TIOCGSOFTCAR = 0x5419;
616pub const TIOCSSOFTCAR = 0x541A;
617pub const FIONREAD = 0x541B;
618pub const TIOCINQ = FIONREAD;
619pub const TIOCLINUX = 0x541C;
620pub const TIOCCONS = 0x541D;
621pub const TIOCGSERIAL = 0x541E;
622pub const TIOCSSERIAL = 0x541F;
623pub const TIOCPKT = 0x5420;
624pub const FIONBIO = 0x5421;
625pub const TIOCNOTTY = 0x5422;
626pub const TIOCSETD = 0x5423;
627pub const TIOCGETD = 0x5424;
628pub const TCSBRKP = 0x5425;
629pub const TIOCSBRK = 0x5427;
630pub const TIOCCBRK = 0x5428;
631pub const TIOCGSID = 0x5429;
632pub const TIOCGRS485 = 0x542E;
633pub const TIOCSRS485 = 0x542F;
634pub const TIOCGPTN = 0x80045430;
635pub const TIOCSPTLCK = 0x40045431;
636pub const TIOCGDEV = 0x80045432;
637pub const TCGETX = 0x5432;
638pub const TCSETX = 0x5433;
639pub const TCSETXF = 0x5434;
640pub const TCSETXW = 0x5435;
641pub const TIOCSIG = 0x40045436;
642pub const TIOCVHANGUP = 0x5437;
643pub const TIOCGPKT = 0x80045438;
644pub const TIOCGPTLCK = 0x80045439;
645pub const TIOCGEXCL = 0x80045440;
646
647fn unsigned(s: i32) u32 {
648 return @bitCast(u32, s);
649}
650fn signed(s: u32) i32 {
651 return @bitCast(i32, s);
652}
653pub fn WEXITSTATUS(s: i32) i32 {
654 return signed((unsigned(s) & 0xff00) >> 8);
655}
656pub fn WTERMSIG(s: i32) i32 {
657 return signed(unsigned(s) & 0x7f);
658}
659pub fn WSTOPSIG(s: i32) i32 {
660 return WEXITSTATUS(s);
661}
662pub fn WIFEXITED(s: i32) bool {
663 return WTERMSIG(s) == 0;
664}
665pub fn WIFSTOPPED(s: i32) bool {
666 return @intCast(u16, (((unsigned(s) & 0xffff) *% 0x10001) >> 8)) > 0x7f00;
667}
668pub fn WIFSIGNALED(s: i32) bool {
669 return (unsigned(s) & 0xffff) -% 1 < 0xff;
670}
671
672pub const winsize = extern struct {
673 ws_row: u16,
674 ws_col: u16,
675 ws_xpixel: u16,
676 ws_ypixel: u16,
677};
678
679const NSIG = 32;
680
681pub const SIG_ERR = @intToPtr(extern fn (i32) void, maxInt(usize));
682pub const SIG_DFL = @intToPtr(extern fn (i32) void, 0);
683pub const SIG_IGN = @intToPtr(extern fn (i32) void, 1);
684
685/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.
686pub const Sigaction = extern struct {
687 /// signal handler
688 __sigaction_u: extern union {
689 __sa_handler: extern fn (i32) void,
690 __sa_sigaction: extern fn (i32, *__siginfo, usize) void,
691 },
692
693 /// see signal options
694 sa_flags: u32,
695
696 /// signal mask to apply
697 sa_mask: sigset_t,
698};
699
700pub const _SIG_WORDS = 4;
701pub const _SIG_MAXSIG = 128;
702
703pub inline fn _SIG_IDX(sig: usize) usize {
704 return sig - 1;
705}
706pub inline fn _SIG_WORD(sig: usize) usize {
707 return_SIG_IDX(sig) >> 5;
708}
709pub inline fn _SIG_BIT(sig: usize) usize {
710 return 1 << (_SIG_IDX(sig) & 31);
711}
712pub inline fn _SIG_VALID(sig: usize) usize {
713 return sig <= _SIG_MAXSIG and sig > 0;
714}
715
716pub const sigset_t = extern struct {
717 __bits: [_SIG_WORDS]u32,
718};
719
720pub const EPERM = 1; // Operation not permitted
721pub const ENOENT = 2; // No such file or directory
722pub const ESRCH = 3; // No such process
723pub const EINTR = 4; // Interrupted system call
724pub const EIO = 5; // Input/output error
725pub const ENXIO = 6; // Device not configured
726pub const E2BIG = 7; // Argument list too long
727pub const ENOEXEC = 8; // Exec format error
728pub const EBADF = 9; // Bad file descriptor
729pub const ECHILD = 10; // No child processes
730pub const EDEADLK = 11; // Resource deadlock avoided
731// 11 was EAGAIN
732pub const ENOMEM = 12; // Cannot allocate memory
733pub const EACCES = 13; // Permission denied
734pub const EFAULT = 14; // Bad address
735pub const ENOTBLK = 15; // Block device required
736pub const EBUSY = 16; // Device busy
737pub const EEXIST = 17; // File exists
738pub const EXDEV = 18; // Cross-device link
739pub const ENODEV = 19; // Operation not supported by device
740pub const ENOTDIR = 20; // Not a directory
741pub const EISDIR = 21; // Is a directory
742pub const EINVAL = 22; // Invalid argument
743pub const ENFILE = 23; // Too many open files in system
744pub const EMFILE = 24; // Too many open files
745pub const ENOTTY = 25; // Inappropriate ioctl for device
746pub const ETXTBSY = 26; // Text file busy
747pub const EFBIG = 27; // File too large
748pub const ENOSPC = 28; // No space left on device
749pub const ESPIPE = 29; // Illegal seek
750pub const EROFS = 30; // Read-only filesystem
751pub const EMLINK = 31; // Too many links
752pub const EPIPE = 32; // Broken pipe
753
754// math software
755pub const EDOM = 33; // Numerical argument out of domain
756pub const ERANGE = 34; // Result too large
757
758// non-blocking and interrupt i/o
759pub const EAGAIN = 35; // Resource temporarily unavailable
760pub const EWOULDBLOCK = EAGAIN; // Operation would block
761pub const EINPROGRESS = 36; // Operation now in progress
762pub const EALREADY = 37; // Operation already in progress
763
764// ipc/network software -- argument errors
765pub const ENOTSOCK = 38; // Socket operation on non-socket
766pub const EDESTADDRREQ = 39; // Destination address required
767pub const EMSGSIZE = 40; // Message too long
768pub const EPROTOTYPE = 41; // Protocol wrong type for socket
769pub const ENOPROTOOPT = 42; // Protocol not available
770pub const EPROTONOSUPPORT = 43; // Protocol not supported
771pub const ESOCKTNOSUPPORT = 44; // Socket type not supported
772pub const EOPNOTSUPP = 45; // Operation not supported
773pub const ENOTSUP = EOPNOTSUPP; // Operation not supported
774pub const EPFNOSUPPORT = 46; // Protocol family not supported
775pub const EAFNOSUPPORT = 47; // Address family not supported by protocol family
776pub const EADDRINUSE = 48; // Address already in use
777pub const EADDRNOTAVAIL = 49; // Can't assign requested address
778
779// ipc/network software -- operational errors
780pub const ENETDOWN = 50; // Network is down
781pub const ENETUNREACH = 51; // Network is unreachable
782pub const ENETRESET = 52; // Network dropped connection on reset
783pub const ECONNABORTED = 53; // Software caused connection abort
784pub const ECONNRESET = 54; // Connection reset by peer
785pub const ENOBUFS = 55; // No buffer space available
786pub const EISCONN = 56; // Socket is already connected
787pub const ENOTCONN = 57; // Socket is not connected
788pub const ESHUTDOWN = 58; // Can't send after socket shutdown
789pub const ETOOMANYREFS = 59; // Too many references: can't splice
790pub const ETIMEDOUT = 60; // Operation timed out
791pub const ECONNREFUSED = 61; // Connection refused
792
793pub const ELOOP = 62; // Too many levels of symbolic links
794pub const ENAMETOOLONG = 63; // File name too long
795
796// should be rearranged
797pub const EHOSTDOWN = 64; // Host is down
798pub const EHOSTUNREACH = 65; // No route to host
799pub const ENOTEMPTY = 66; // Directory not empty
800
801// quotas & mush
802pub const EPROCLIM = 67; // Too many processes
803pub const EUSERS = 68; // Too many users
804pub const EDQUOT = 69; // Disc quota exceeded
805
806// Network File System
807pub const ESTALE = 70; // Stale NFS file handle
808pub const EREMOTE = 71; // Too many levels of remote in path
809pub const EBADRPC = 72; // RPC struct is bad
810pub const ERPCMISMATCH = 73; // RPC version wrong
811pub const EPROGUNAVAIL = 74; // RPC prog. not avail
812pub const EPROGMISMATCH = 75; // Program version wrong
813pub const EPROCUNAVAIL = 76; // Bad procedure for program
814
815pub const ENOLCK = 77; // No locks available
816pub const ENOSYS = 78; // Function not implemented
817
818pub const EFTYPE = 79; // Inappropriate file type or format
819pub const EAUTH = 80; // Authentication error
820pub const ENEEDAUTH = 81; // Need authenticator
821pub const EIDRM = 82; // Identifier removed
822pub const ENOMSG = 83; // No message of desired type
823pub const EOVERFLOW = 84; // Value too large to be stored in data type
824pub const ECANCELED = 85; // Operation canceled
825pub const EILSEQ = 86; // Illegal byte sequence
826pub const ENOATTR = 87; // Attribute not found
827
828pub const EDOOFUS = 88; // Programming error
829
830pub const EBADMSG = 89; // Bad message
831pub const EMULTIHOP = 90; // Multihop attempted
832pub const ENOLINK = 91; // Link has been severed
833pub const EPROTO = 92; // Protocol error
834
835pub const ENOTCAPABLE = 93; // Capabilities insufficient
836pub const ECAPMODE = 94; // Not permitted in capability mode
837pub const ENOTRECOVERABLE = 95; // State not recoverable
838pub const EOWNERDEAD = 96; // Previous owner died
839
840pub const ELAST = 96; // Must be equal largest errno
std/os/bits/linux.zig created+919
...@@ -0,0 +1,919 @@
1pub use @import("errno.zig");
2pub use switch (builtin.arch) {
3 .x86_64 => @import("linux/x86_64.zig"),
4 .aarch64 => @import("linux/arm64.zig"),
5 else => struct {},
6};
7
8pub const pid_t = i32;
9pub const fd_t = i32;
10
11pub const PATH_MAX = 4096;
12pub const IOV_MAX = 1024;
13
14pub const STDIN_FILENO = 0;
15pub const STDOUT_FILENO = 1;
16pub const STDERR_FILENO = 2;
17
18pub const FUTEX_WAIT = 0;
19pub const FUTEX_WAKE = 1;
20pub const FUTEX_FD = 2;
21pub const FUTEX_REQUEUE = 3;
22pub const FUTEX_CMP_REQUEUE = 4;
23pub const FUTEX_WAKE_OP = 5;
24pub const FUTEX_LOCK_PI = 6;
25pub const FUTEX_UNLOCK_PI = 7;
26pub const FUTEX_TRYLOCK_PI = 8;
27pub const FUTEX_WAIT_BITSET = 9;
28
29pub const FUTEX_PRIVATE_FLAG = 128;
30
31pub const FUTEX_CLOCK_REALTIME = 256;
32
33pub const PROT_NONE = 0;
34pub const PROT_READ = 1;
35pub const PROT_WRITE = 2;
36pub const PROT_EXEC = 4;
37pub const PROT_GROWSDOWN = 0x01000000;
38pub const PROT_GROWSUP = 0x02000000;
39
40pub const MAP_FAILED = maxInt(usize);
41pub const MAP_SHARED = 0x01;
42pub const MAP_PRIVATE = 0x02;
43pub const MAP_TYPE = 0x0f;
44pub const MAP_FIXED = 0x10;
45pub const MAP_ANONYMOUS = 0x20;
46pub const MAP_NORESERVE = 0x4000;
47pub const MAP_GROWSDOWN = 0x0100;
48pub const MAP_DENYWRITE = 0x0800;
49pub const MAP_EXECUTABLE = 0x1000;
50pub const MAP_LOCKED = 0x2000;
51pub const MAP_POPULATE = 0x8000;
52pub const MAP_NONBLOCK = 0x10000;
53pub const MAP_STACK = 0x20000;
54pub const MAP_HUGETLB = 0x40000;
55pub const MAP_FILE = 0;
56
57pub const F_OK = 0;
58pub const X_OK = 1;
59pub const W_OK = 2;
60pub const R_OK = 4;
61
62pub const WNOHANG = 1;
63pub const WUNTRACED = 2;
64pub const WSTOPPED = 2;
65pub const WEXITED = 4;
66pub const WCONTINUED = 8;
67pub const WNOWAIT = 0x1000000;
68
69pub const SA_NOCLDSTOP = 1;
70pub const SA_NOCLDWAIT = 2;
71pub const SA_SIGINFO = 4;
72pub const SA_ONSTACK = 0x08000000;
73pub const SA_RESTART = 0x10000000;
74pub const SA_NODEFER = 0x40000000;
75pub const SA_RESETHAND = 0x80000000;
76pub const SA_RESTORER = 0x04000000;
77
78pub const SIGHUP = 1;
79pub const SIGINT = 2;
80pub const SIGQUIT = 3;
81pub const SIGILL = 4;
82pub const SIGTRAP = 5;
83pub const SIGABRT = 6;
84pub const SIGIOT = SIGABRT;
85pub const SIGBUS = 7;
86pub const SIGFPE = 8;
87pub const SIGKILL = 9;
88pub const SIGUSR1 = 10;
89pub const SIGSEGV = 11;
90pub const SIGUSR2 = 12;
91pub const SIGPIPE = 13;
92pub const SIGALRM = 14;
93pub const SIGTERM = 15;
94pub const SIGSTKFLT = 16;
95pub const SIGCHLD = 17;
96pub const SIGCONT = 18;
97pub const SIGSTOP = 19;
98pub const SIGTSTP = 20;
99pub const SIGTTIN = 21;
100pub const SIGTTOU = 22;
101pub const SIGURG = 23;
102pub const SIGXCPU = 24;
103pub const SIGXFSZ = 25;
104pub const SIGVTALRM = 26;
105pub const SIGPROF = 27;
106pub const SIGWINCH = 28;
107pub const SIGIO = 29;
108pub const SIGPOLL = 29;
109pub const SIGPWR = 30;
110pub const SIGSYS = 31;
111pub const SIGUNUSED = SIGSYS;
112
113pub const O_RDONLY = 0o0;
114pub const O_WRONLY = 0o1;
115pub const O_RDWR = 0o2;
116
117pub const SEEK_SET = 0;
118pub const SEEK_CUR = 1;
119pub const SEEK_END = 2;
120
121pub const SIG_BLOCK = 0;
122pub const SIG_UNBLOCK = 1;
123pub const SIG_SETMASK = 2;
124
125pub const PROTO_ip = 0o000;
126pub const PROTO_icmp = 0o001;
127pub const PROTO_igmp = 0o002;
128pub const PROTO_ggp = 0o003;
129pub const PROTO_ipencap = 0o004;
130pub const PROTO_st = 0o005;
131pub const PROTO_tcp = 0o006;
132pub const PROTO_egp = 0o010;
133pub const PROTO_pup = 0o014;
134pub const PROTO_udp = 0o021;
135pub const PROTO_hmp = 0o024;
136pub const PROTO_xns_idp = 0o026;
137pub const PROTO_rdp = 0o033;
138pub const PROTO_iso_tp4 = 0o035;
139pub const PROTO_xtp = 0o044;
140pub const PROTO_ddp = 0o045;
141pub const PROTO_idpr_cmtp = 0o046;
142pub const PROTO_ipv6 = 0o051;
143pub const PROTO_ipv6_route = 0o053;
144pub const PROTO_ipv6_frag = 0o054;
145pub const PROTO_idrp = 0o055;
146pub const PROTO_rsvp = 0o056;
147pub const PROTO_gre = 0o057;
148pub const PROTO_esp = 0o062;
149pub const PROTO_ah = 0o063;
150pub const PROTO_skip = 0o071;
151pub const PROTO_ipv6_icmp = 0o072;
152pub const PROTO_ipv6_nonxt = 0o073;
153pub const PROTO_ipv6_opts = 0o074;
154pub const PROTO_rspf = 0o111;
155pub const PROTO_vmtp = 0o121;
156pub const PROTO_ospf = 0o131;
157pub const PROTO_ipip = 0o136;
158pub const PROTO_encap = 0o142;
159pub const PROTO_pim = 0o147;
160pub const PROTO_raw = 0o377;
161
162pub const SHUT_RD = 0;
163pub const SHUT_WR = 1;
164pub const SHUT_RDWR = 2;
165
166pub const SOCK_STREAM = 1;
167pub const SOCK_DGRAM = 2;
168pub const SOCK_RAW = 3;
169pub const SOCK_RDM = 4;
170pub const SOCK_SEQPACKET = 5;
171pub const SOCK_DCCP = 6;
172pub const SOCK_PACKET = 10;
173pub const SOCK_CLOEXEC = 0o2000000;
174pub const SOCK_NONBLOCK = 0o4000;
175
176pub const PF_UNSPEC = 0;
177pub const PF_LOCAL = 1;
178pub const PF_UNIX = PF_LOCAL;
179pub const PF_FILE = PF_LOCAL;
180pub const PF_INET = 2;
181pub const PF_AX25 = 3;
182pub const PF_IPX = 4;
183pub const PF_APPLETALK = 5;
184pub const PF_NETROM = 6;
185pub const PF_BRIDGE = 7;
186pub const PF_ATMPVC = 8;
187pub const PF_X25 = 9;
188pub const PF_INET6 = 10;
189pub const PF_ROSE = 11;
190pub const PF_DECnet = 12;
191pub const PF_NETBEUI = 13;
192pub const PF_SECURITY = 14;
193pub const PF_KEY = 15;
194pub const PF_NETLINK = 16;
195pub const PF_ROUTE = PF_NETLINK;
196pub const PF_PACKET = 17;
197pub const PF_ASH = 18;
198pub const PF_ECONET = 19;
199pub const PF_ATMSVC = 20;
200pub const PF_RDS = 21;
201pub const PF_SNA = 22;
202pub const PF_IRDA = 23;
203pub const PF_PPPOX = 24;
204pub const PF_WANPIPE = 25;
205pub const PF_LLC = 26;
206pub const PF_IB = 27;
207pub const PF_MPLS = 28;
208pub const PF_CAN = 29;
209pub const PF_TIPC = 30;
210pub const PF_BLUETOOTH = 31;
211pub const PF_IUCV = 32;
212pub const PF_RXRPC = 33;
213pub const PF_ISDN = 34;
214pub const PF_PHONET = 35;
215pub const PF_IEEE802154 = 36;
216pub const PF_CAIF = 37;
217pub const PF_ALG = 38;
218pub const PF_NFC = 39;
219pub const PF_VSOCK = 40;
220pub const PF_KCM = 41;
221pub const PF_QIPCRTR = 42;
222pub const PF_SMC = 43;
223pub const PF_MAX = 44;
224
225pub const AF_UNSPEC = PF_UNSPEC;
226pub const AF_LOCAL = PF_LOCAL;
227pub const AF_UNIX = AF_LOCAL;
228pub const AF_FILE = AF_LOCAL;
229pub const AF_INET = PF_INET;
230pub const AF_AX25 = PF_AX25;
231pub const AF_IPX = PF_IPX;
232pub const AF_APPLETALK = PF_APPLETALK;
233pub const AF_NETROM = PF_NETROM;
234pub const AF_BRIDGE = PF_BRIDGE;
235pub const AF_ATMPVC = PF_ATMPVC;
236pub const AF_X25 = PF_X25;
237pub const AF_INET6 = PF_INET6;
238pub const AF_ROSE = PF_ROSE;
239pub const AF_DECnet = PF_DECnet;
240pub const AF_NETBEUI = PF_NETBEUI;
241pub const AF_SECURITY = PF_SECURITY;
242pub const AF_KEY = PF_KEY;
243pub const AF_NETLINK = PF_NETLINK;
244pub const AF_ROUTE = PF_ROUTE;
245pub const AF_PACKET = PF_PACKET;
246pub const AF_ASH = PF_ASH;
247pub const AF_ECONET = PF_ECONET;
248pub const AF_ATMSVC = PF_ATMSVC;
249pub const AF_RDS = PF_RDS;
250pub const AF_SNA = PF_SNA;
251pub const AF_IRDA = PF_IRDA;
252pub const AF_PPPOX = PF_PPPOX;
253pub const AF_WANPIPE = PF_WANPIPE;
254pub const AF_LLC = PF_LLC;
255pub const AF_IB = PF_IB;
256pub const AF_MPLS = PF_MPLS;
257pub const AF_CAN = PF_CAN;
258pub const AF_TIPC = PF_TIPC;
259pub const AF_BLUETOOTH = PF_BLUETOOTH;
260pub const AF_IUCV = PF_IUCV;
261pub const AF_RXRPC = PF_RXRPC;
262pub const AF_ISDN = PF_ISDN;
263pub const AF_PHONET = PF_PHONET;
264pub const AF_IEEE802154 = PF_IEEE802154;
265pub const AF_CAIF = PF_CAIF;
266pub const AF_ALG = PF_ALG;
267pub const AF_NFC = PF_NFC;
268pub const AF_VSOCK = PF_VSOCK;
269pub const AF_KCM = PF_KCM;
270pub const AF_QIPCRTR = PF_QIPCRTR;
271pub const AF_SMC = PF_SMC;
272pub const AF_MAX = PF_MAX;
273
274pub const SO_DEBUG = 1;
275pub const SO_REUSEADDR = 2;
276pub const SO_TYPE = 3;
277pub const SO_ERROR = 4;
278pub const SO_DONTROUTE = 5;
279pub const SO_BROADCAST = 6;
280pub const SO_SNDBUF = 7;
281pub const SO_RCVBUF = 8;
282pub const SO_KEEPALIVE = 9;
283pub const SO_OOBINLINE = 10;
284pub const SO_NO_CHECK = 11;
285pub const SO_PRIORITY = 12;
286pub const SO_LINGER = 13;
287pub const SO_BSDCOMPAT = 14;
288pub const SO_REUSEPORT = 15;
289pub const SO_PASSCRED = 16;
290pub const SO_PEERCRED = 17;
291pub const SO_RCVLOWAT = 18;
292pub const SO_SNDLOWAT = 19;
293pub const SO_RCVTIMEO = 20;
294pub const SO_SNDTIMEO = 21;
295pub const SO_ACCEPTCONN = 30;
296pub const SO_SNDBUFFORCE = 32;
297pub const SO_RCVBUFFORCE = 33;
298pub const SO_PROTOCOL = 38;
299pub const SO_DOMAIN = 39;
300
301pub const SO_SECURITY_AUTHENTICATION = 22;
302pub const SO_SECURITY_ENCRYPTION_TRANSPORT = 23;
303pub const SO_SECURITY_ENCRYPTION_NETWORK = 24;
304
305pub const SO_BINDTODEVICE = 25;
306
307pub const SO_ATTACH_FILTER = 26;
308pub const SO_DETACH_FILTER = 27;
309pub const SO_GET_FILTER = SO_ATTACH_FILTER;
310
311pub const SO_PEERNAME = 28;
312pub const SO_TIMESTAMP = 29;
313pub const SCM_TIMESTAMP = SO_TIMESTAMP;
314
315pub const SO_PEERSEC = 31;
316pub const SO_PASSSEC = 34;
317pub const SO_TIMESTAMPNS = 35;
318pub const SCM_TIMESTAMPNS = SO_TIMESTAMPNS;
319pub const SO_MARK = 36;
320pub const SO_TIMESTAMPING = 37;
321pub const SCM_TIMESTAMPING = SO_TIMESTAMPING;
322pub const SO_RXQ_OVFL = 40;
323pub const SO_WIFI_STATUS = 41;
324pub const SCM_WIFI_STATUS = SO_WIFI_STATUS;
325pub const SO_PEEK_OFF = 42;
326pub const SO_NOFCS = 43;
327pub const SO_LOCK_FILTER = 44;
328pub const SO_SELECT_ERR_QUEUE = 45;
329pub const SO_BUSY_POLL = 46;
330pub const SO_MAX_PACING_RATE = 47;
331pub const SO_BPF_EXTENSIONS = 48;
332pub const SO_INCOMING_CPU = 49;
333pub const SO_ATTACH_BPF = 50;
334pub const SO_DETACH_BPF = SO_DETACH_FILTER;
335pub const SO_ATTACH_REUSEPORT_CBPF = 51;
336pub const SO_ATTACH_REUSEPORT_EBPF = 52;
337pub const SO_CNX_ADVICE = 53;
338pub const SCM_TIMESTAMPING_OPT_STATS = 54;
339pub const SO_MEMINFO = 55;
340pub const SO_INCOMING_NAPI_ID = 56;
341pub const SO_COOKIE = 57;
342pub const SCM_TIMESTAMPING_PKTINFO = 58;
343pub const SO_PEERGROUPS = 59;
344pub const SO_ZEROCOPY = 60;
345
346pub const SOL_SOCKET = 1;
347
348pub const SOL_IP = 0;
349pub const SOL_IPV6 = 41;
350pub const SOL_ICMPV6 = 58;
351
352pub const SOL_RAW = 255;
353pub const SOL_DECNET = 261;
354pub const SOL_X25 = 262;
355pub const SOL_PACKET = 263;
356pub const SOL_ATM = 264;
357pub const SOL_AAL = 265;
358pub const SOL_IRDA = 266;
359pub const SOL_NETBEUI = 267;
360pub const SOL_LLC = 268;
361pub const SOL_DCCP = 269;
362pub const SOL_NETLINK = 270;
363pub const SOL_TIPC = 271;
364pub const SOL_RXRPC = 272;
365pub const SOL_PPPOL2TP = 273;
366pub const SOL_BLUETOOTH = 274;
367pub const SOL_PNPIPE = 275;
368pub const SOL_RDS = 276;
369pub const SOL_IUCV = 277;
370pub const SOL_CAIF = 278;
371pub const SOL_ALG = 279;
372pub const SOL_NFC = 280;
373pub const SOL_KCM = 281;
374pub const SOL_TLS = 282;
375
376pub const SOMAXCONN = 128;
377
378pub const MSG_OOB = 0x0001;
379pub const MSG_PEEK = 0x0002;
380pub const MSG_DONTROUTE = 0x0004;
381pub const MSG_CTRUNC = 0x0008;
382pub const MSG_PROXY = 0x0010;
383pub const MSG_TRUNC = 0x0020;
384pub const MSG_DONTWAIT = 0x0040;
385pub const MSG_EOR = 0x0080;
386pub const MSG_WAITALL = 0x0100;
387pub const MSG_FIN = 0x0200;
388pub const MSG_SYN = 0x0400;
389pub const MSG_CONFIRM = 0x0800;
390pub const MSG_RST = 0x1000;
391pub const MSG_ERRQUEUE = 0x2000;
392pub const MSG_NOSIGNAL = 0x4000;
393pub const MSG_MORE = 0x8000;
394pub const MSG_WAITFORONE = 0x10000;
395pub const MSG_BATCH = 0x40000;
396pub const MSG_ZEROCOPY = 0x4000000;
397pub const MSG_FASTOPEN = 0x20000000;
398pub const MSG_CMSG_CLOEXEC = 0x40000000;
399
400pub const DT_UNKNOWN = 0;
401pub const DT_FIFO = 1;
402pub const DT_CHR = 2;
403pub const DT_DIR = 4;
404pub const DT_BLK = 6;
405pub const DT_REG = 8;
406pub const DT_LNK = 10;
407pub const DT_SOCK = 12;
408pub const DT_WHT = 14;
409
410pub const TCGETS = 0x5401;
411pub const TCSETS = 0x5402;
412pub const TCSETSW = 0x5403;
413pub const TCSETSF = 0x5404;
414pub const TCGETA = 0x5405;
415pub const TCSETA = 0x5406;
416pub const TCSETAW = 0x5407;
417pub const TCSETAF = 0x5408;
418pub const TCSBRK = 0x5409;
419pub const TCXONC = 0x540A;
420pub const TCFLSH = 0x540B;
421pub const TIOCEXCL = 0x540C;
422pub const TIOCNXCL = 0x540D;
423pub const TIOCSCTTY = 0x540E;
424pub const TIOCGPGRP = 0x540F;
425pub const TIOCSPGRP = 0x5410;
426pub const TIOCOUTQ = 0x5411;
427pub const TIOCSTI = 0x5412;
428pub const TIOCGWINSZ = 0x5413;
429pub const TIOCSWINSZ = 0x5414;
430pub const TIOCMGET = 0x5415;
431pub const TIOCMBIS = 0x5416;
432pub const TIOCMBIC = 0x5417;
433pub const TIOCMSET = 0x5418;
434pub const TIOCGSOFTCAR = 0x5419;
435pub const TIOCSSOFTCAR = 0x541A;
436pub const FIONREAD = 0x541B;
437pub const TIOCINQ = FIONREAD;
438pub const TIOCLINUX = 0x541C;
439pub const TIOCCONS = 0x541D;
440pub const TIOCGSERIAL = 0x541E;
441pub const TIOCSSERIAL = 0x541F;
442pub const TIOCPKT = 0x5420;
443pub const FIONBIO = 0x5421;
444pub const TIOCNOTTY = 0x5422;
445pub const TIOCSETD = 0x5423;
446pub const TIOCGETD = 0x5424;
447pub const TCSBRKP = 0x5425;
448pub const TIOCSBRK = 0x5427;
449pub const TIOCCBRK = 0x5428;
450pub const TIOCGSID = 0x5429;
451pub const TIOCGRS485 = 0x542E;
452pub const TIOCSRS485 = 0x542F;
453pub const TIOCGPTN = 0x80045430;
454pub const TIOCSPTLCK = 0x40045431;
455pub const TIOCGDEV = 0x80045432;
456pub const TCGETX = 0x5432;
457pub const TCSETX = 0x5433;
458pub const TCSETXF = 0x5434;
459pub const TCSETXW = 0x5435;
460pub const TIOCSIG = 0x40045436;
461pub const TIOCVHANGUP = 0x5437;
462pub const TIOCGPKT = 0x80045438;
463pub const TIOCGPTLCK = 0x80045439;
464pub const TIOCGEXCL = 0x80045440;
465
466pub const EPOLL_CLOEXEC = O_CLOEXEC;
467
468pub const EPOLL_CTL_ADD = 1;
469pub const EPOLL_CTL_DEL = 2;
470pub const EPOLL_CTL_MOD = 3;
471
472pub const EPOLLIN = 0x001;
473pub const EPOLLPRI = 0x002;
474pub const EPOLLOUT = 0x004;
475pub const EPOLLRDNORM = 0x040;
476pub const EPOLLRDBAND = 0x080;
477pub const EPOLLWRNORM = 0x100;
478pub const EPOLLWRBAND = 0x200;
479pub const EPOLLMSG = 0x400;
480pub const EPOLLERR = 0x008;
481pub const EPOLLHUP = 0x010;
482pub const EPOLLRDHUP = 0x2000;
483pub const EPOLLEXCLUSIVE = (u32(1) << 28);
484pub const EPOLLWAKEUP = (u32(1) << 29);
485pub const EPOLLONESHOT = (u32(1) << 30);
486pub const EPOLLET = (u32(1) << 31);
487
488pub const CLOCK_REALTIME = 0;
489pub const CLOCK_MONOTONIC = 1;
490pub const CLOCK_PROCESS_CPUTIME_ID = 2;
491pub const CLOCK_THREAD_CPUTIME_ID = 3;
492pub const CLOCK_MONOTONIC_RAW = 4;
493pub const CLOCK_REALTIME_COARSE = 5;
494pub const CLOCK_MONOTONIC_COARSE = 6;
495pub const CLOCK_BOOTTIME = 7;
496pub const CLOCK_REALTIME_ALARM = 8;
497pub const CLOCK_BOOTTIME_ALARM = 9;
498pub const CLOCK_SGI_CYCLE = 10;
499pub const CLOCK_TAI = 11;
500
501pub const CSIGNAL = 0x000000ff;
502pub const CLONE_VM = 0x00000100;
503pub const CLONE_FS = 0x00000200;
504pub const CLONE_FILES = 0x00000400;
505pub const CLONE_SIGHAND = 0x00000800;
506pub const CLONE_PTRACE = 0x00002000;
507pub const CLONE_VFORK = 0x00004000;
508pub const CLONE_PARENT = 0x00008000;
509pub const CLONE_THREAD = 0x00010000;
510pub const CLONE_NEWNS = 0x00020000;
511pub const CLONE_SYSVSEM = 0x00040000;
512pub const CLONE_SETTLS = 0x00080000;
513pub const CLONE_PARENT_SETTID = 0x00100000;
514pub const CLONE_CHILD_CLEARTID = 0x00200000;
515pub const CLONE_DETACHED = 0x00400000;
516pub const CLONE_UNTRACED = 0x00800000;
517pub const CLONE_CHILD_SETTID = 0x01000000;
518pub const CLONE_NEWCGROUP = 0x02000000;
519pub const CLONE_NEWUTS = 0x04000000;
520pub const CLONE_NEWIPC = 0x08000000;
521pub const CLONE_NEWUSER = 0x10000000;
522pub const CLONE_NEWPID = 0x20000000;
523pub const CLONE_NEWNET = 0x40000000;
524pub const CLONE_IO = 0x80000000;
525
526pub const EFD_SEMAPHORE = 1;
527pub const EFD_CLOEXEC = O_CLOEXEC;
528pub const EFD_NONBLOCK = O_NONBLOCK;
529
530pub const MS_RDONLY = 1;
531pub const MS_NOSUID = 2;
532pub const MS_NODEV = 4;
533pub const MS_NOEXEC = 8;
534pub const MS_SYNCHRONOUS = 16;
535pub const MS_REMOUNT = 32;
536pub const MS_MANDLOCK = 64;
537pub const MS_DIRSYNC = 128;
538pub const MS_NOATIME = 1024;
539pub const MS_NODIRATIME = 2048;
540pub const MS_BIND = 4096;
541pub const MS_MOVE = 8192;
542pub const MS_REC = 16384;
543pub const MS_SILENT = 32768;
544pub const MS_POSIXACL = (1 << 16);
545pub const MS_UNBINDABLE = (1 << 17);
546pub const MS_PRIVATE = (1 << 18);
547pub const MS_SLAVE = (1 << 19);
548pub const MS_SHARED = (1 << 20);
549pub const MS_RELATIME = (1 << 21);
550pub const MS_KERNMOUNT = (1 << 22);
551pub const MS_I_VERSION = (1 << 23);
552pub const MS_STRICTATIME = (1 << 24);
553pub const MS_LAZYTIME = (1 << 25);
554pub const MS_NOREMOTELOCK = (1 << 27);
555pub const MS_NOSEC = (1 << 28);
556pub const MS_BORN = (1 << 29);
557pub const MS_ACTIVE = (1 << 30);
558pub const MS_NOUSER = (1 << 31);
559
560pub const MS_RMT_MASK = (MS_RDONLY | MS_SYNCHRONOUS | MS_MANDLOCK | MS_I_VERSION | MS_LAZYTIME);
561
562pub const MS_MGC_VAL = 0xc0ed0000;
563pub const MS_MGC_MSK = 0xffff0000;
564
565pub const MNT_FORCE = 1;
566pub const MNT_DETACH = 2;
567pub const MNT_EXPIRE = 4;
568pub const UMOUNT_NOFOLLOW = 8;
569
570pub const IN_CLOEXEC = O_CLOEXEC;
571pub const IN_NONBLOCK = O_NONBLOCK;
572
573pub const IN_ACCESS = 0x00000001;
574pub const IN_MODIFY = 0x00000002;
575pub const IN_ATTRIB = 0x00000004;
576pub const IN_CLOSE_WRITE = 0x00000008;
577pub const IN_CLOSE_NOWRITE = 0x00000010;
578pub const IN_CLOSE = IN_CLOSE_WRITE | IN_CLOSE_NOWRITE;
579pub const IN_OPEN = 0x00000020;
580pub const IN_MOVED_FROM = 0x00000040;
581pub const IN_MOVED_TO = 0x00000080;
582pub const IN_MOVE = IN_MOVED_FROM | IN_MOVED_TO;
583pub const IN_CREATE = 0x00000100;
584pub const IN_DELETE = 0x00000200;
585pub const IN_DELETE_SELF = 0x00000400;
586pub const IN_MOVE_SELF = 0x00000800;
587pub const IN_ALL_EVENTS = 0x00000fff;
588
589pub const IN_UNMOUNT = 0x00002000;
590pub const IN_Q_OVERFLOW = 0x00004000;
591pub const IN_IGNORED = 0x00008000;
592
593pub const IN_ONLYDIR = 0x01000000;
594pub const IN_DONT_FOLLOW = 0x02000000;
595pub const IN_EXCL_UNLINK = 0x04000000;
596pub const IN_MASK_ADD = 0x20000000;
597
598pub const IN_ISDIR = 0x40000000;
599pub const IN_ONESHOT = 0x80000000;
600
601pub const S_IFMT = 0o170000;
602
603pub const S_IFDIR = 0o040000;
604pub const S_IFCHR = 0o020000;
605pub const S_IFBLK = 0o060000;
606pub const S_IFREG = 0o100000;
607pub const S_IFIFO = 0o010000;
608pub const S_IFLNK = 0o120000;
609pub const S_IFSOCK = 0o140000;
610
611pub const S_ISUID = 0o4000;
612pub const S_ISGID = 0o2000;
613pub const S_ISVTX = 0o1000;
614pub const S_IRUSR = 0o400;
615pub const S_IWUSR = 0o200;
616pub const S_IXUSR = 0o100;
617pub const S_IRWXU = 0o700;
618pub const S_IRGRP = 0o040;
619pub const S_IWGRP = 0o020;
620pub const S_IXGRP = 0o010;
621pub const S_IRWXG = 0o070;
622pub const S_IROTH = 0o004;
623pub const S_IWOTH = 0o002;
624pub const S_IXOTH = 0o001;
625pub const S_IRWXO = 0o007;
626
627pub fn S_ISREG(m: u32) bool {
628 return m & S_IFMT == S_IFREG;
629}
630
631pub fn S_ISDIR(m: u32) bool {
632 return m & S_IFMT == S_IFDIR;
633}
634
635pub fn S_ISCHR(m: u32) bool {
636 return m & S_IFMT == S_IFCHR;
637}
638
639pub fn S_ISBLK(m: u32) bool {
640 return m & S_IFMT == S_IFBLK;
641}
642
643pub fn S_ISFIFO(m: u32) bool {
644 return m & S_IFMT == S_IFIFO;
645}
646
647pub fn S_ISLNK(m: u32) bool {
648 return m & S_IFMT == S_IFLNK;
649}
650
651pub fn S_ISSOCK(m: u32) bool {
652 return m & S_IFMT == S_IFSOCK;
653}
654
655pub const TFD_NONBLOCK = O_NONBLOCK;
656pub const TFD_CLOEXEC = O_CLOEXEC;
657
658pub const TFD_TIMER_ABSTIME = 1;
659pub const TFD_TIMER_CANCEL_ON_SET = (1 << 1);
660
661fn unsigned(s: i32) u32 {
662 return @bitCast(u32, s);
663}
664fn signed(s: u32) i32 {
665 return @bitCast(i32, s);
666}
667pub fn WEXITSTATUS(s: i32) i32 {
668 return signed((unsigned(s) & 0xff00) >> 8);
669}
670pub fn WTERMSIG(s: i32) i32 {
671 return signed(unsigned(s) & 0x7f);
672}
673pub fn WSTOPSIG(s: i32) i32 {
674 return WEXITSTATUS(s);
675}
676pub fn WIFEXITED(s: i32) bool {
677 return WTERMSIG(s) == 0;
678}
679pub fn WIFSTOPPED(s: i32) bool {
680 return @intCast(u16, ((unsigned(s) & 0xffff) *% 0x10001) >> 8) > 0x7f00;
681}
682pub fn WIFSIGNALED(s: i32) bool {
683 return (unsigned(s) & 0xffff) -% 1 < 0xff;
684}
685
686pub const winsize = extern struct {
687 ws_row: u16,
688 ws_col: u16,
689 ws_xpixel: u16,
690 ws_ypixel: u16,
691};
692
693const NSIG = 65;
694const sigset_t = [128 / @sizeOf(usize)]usize;
695const all_mask = []u32{ 0xffffffff, 0xffffffff };
696const app_mask = []u32{ 0xfffffffc, 0x7fffffff };
697
698const k_sigaction = extern struct {
699 handler: extern fn (i32) void,
700 flags: usize,
701 restorer: extern fn () void,
702 mask: [2]u32,
703};
704
705/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.
706pub const Sigaction = struct {
707 handler: extern fn (i32) void,
708 mask: sigset_t,
709 flags: u32,
710};
711
712pub const SIG_ERR = @intToPtr(extern fn (i32) void, maxInt(usize));
713pub const SIG_DFL = @intToPtr(extern fn (i32) void, 0);
714pub const SIG_IGN = @intToPtr(extern fn (i32) void, 1);
715pub const empty_sigset = []usize{0} ** sigset_t.len;
716
717pub const in_port_t = u16;
718pub const sa_family_t = u16;
719pub const socklen_t = u32;
720
721/// This intentionally only has ip4 and ip6
722pub const sockaddr = extern union {
723 in: sockaddr_in,
724 in6: sockaddr_in6,
725};
726
727pub const sockaddr_in = extern struct {
728 family: sa_family_t,
729 port: in_port_t,
730 addr: u32,
731 zero: [8]u8,
732};
733
734pub const sockaddr_in6 = extern struct {
735 family: sa_family_t,
736 port: in_port_t,
737 flowinfo: u32,
738 addr: [16]u8,
739 scope_id: u32,
740};
741
742pub const sockaddr_un = extern struct {
743 family: sa_family_t,
744 path: [108]u8,
745};
746
747pub const iovec = extern struct {
748 iov_base: [*]u8,
749 iov_len: usize,
750};
751
752pub const iovec_const = extern struct {
753 iov_base: [*]const u8,
754 iov_len: usize,
755};
756
757pub const mmsghdr = extern struct {
758 msg_hdr: msghdr,
759 msg_len: u32,
760};
761
762pub const mmsghdr_const = extern struct {
763 msg_hdr: msghdr_const,
764 msg_len: u32,
765};
766
767pub const epoll_data = extern union {
768 ptr: usize,
769 fd: i32,
770 @"u32": u32,
771 @"u64": u64,
772};
773
774// On x86_64 the structure is packed so that it matches the definition of its
775// 32bit counterpart
776pub const epoll_event = if (builtin.arch != .x86_64)
777 extern struct {
778 events: u32,
779 data: epoll_data,
780 }
781else
782 packed struct {
783 events: u32,
784 data: epoll_data,
785 };
786
787pub const _LINUX_CAPABILITY_VERSION_1 = 0x19980330;
788pub const _LINUX_CAPABILITY_U32S_1 = 1;
789
790pub const _LINUX_CAPABILITY_VERSION_2 = 0x20071026;
791pub const _LINUX_CAPABILITY_U32S_2 = 2;
792
793pub const _LINUX_CAPABILITY_VERSION_3 = 0x20080522;
794pub const _LINUX_CAPABILITY_U32S_3 = 2;
795
796pub const VFS_CAP_REVISION_MASK = 0xFF000000;
797pub const VFS_CAP_REVISION_SHIFT = 24;
798pub const VFS_CAP_FLAGS_MASK = ~VFS_CAP_REVISION_MASK;
799pub const VFS_CAP_FLAGS_EFFECTIVE = 0x000001;
800
801pub const VFS_CAP_REVISION_1 = 0x01000000;
802pub const VFS_CAP_U32_1 = 1;
803pub const XATTR_CAPS_SZ_1 = @sizeOf(u32) * (1 + 2 * VFS_CAP_U32_1);
804
805pub const VFS_CAP_REVISION_2 = 0x02000000;
806pub const VFS_CAP_U32_2 = 2;
807pub const XATTR_CAPS_SZ_2 = @sizeOf(u32) * (1 + 2 * VFS_CAP_U32_2);
808
809pub const XATTR_CAPS_SZ = XATTR_CAPS_SZ_2;
810pub const VFS_CAP_U32 = VFS_CAP_U32_2;
811pub const VFS_CAP_REVISION = VFS_CAP_REVISION_2;
812
813pub const vfs_cap_data = extern struct {
814 //all of these are mandated as little endian
815 //when on disk.
816 const Data = struct {
817 permitted: u32,
818 inheritable: u32,
819 };
820
821 magic_etc: u32,
822 data: [VFS_CAP_U32]Data,
823};
824
825pub const CAP_CHOWN = 0;
826pub const CAP_DAC_OVERRIDE = 1;
827pub const CAP_DAC_READ_SEARCH = 2;
828pub const CAP_FOWNER = 3;
829pub const CAP_FSETID = 4;
830pub const CAP_KILL = 5;
831pub const CAP_SETGID = 6;
832pub const CAP_SETUID = 7;
833pub const CAP_SETPCAP = 8;
834pub const CAP_LINUX_IMMUTABLE = 9;
835pub const CAP_NET_BIND_SERVICE = 10;
836pub const CAP_NET_BROADCAST = 11;
837pub const CAP_NET_ADMIN = 12;
838pub const CAP_NET_RAW = 13;
839pub const CAP_IPC_LOCK = 14;
840pub const CAP_IPC_OWNER = 15;
841pub const CAP_SYS_MODULE = 16;
842pub const CAP_SYS_RAWIO = 17;
843pub const CAP_SYS_CHROOT = 18;
844pub const CAP_SYS_PTRACE = 19;
845pub const CAP_SYS_PACCT = 20;
846pub const CAP_SYS_ADMIN = 21;
847pub const CAP_SYS_BOOT = 22;
848pub const CAP_SYS_NICE = 23;
849pub const CAP_SYS_RESOURCE = 24;
850pub const CAP_SYS_TIME = 25;
851pub const CAP_SYS_TTY_CONFIG = 26;
852pub const CAP_MKNOD = 27;
853pub const CAP_LEASE = 28;
854pub const CAP_AUDIT_WRITE = 29;
855pub const CAP_AUDIT_CONTROL = 30;
856pub const CAP_SETFCAP = 31;
857pub const CAP_MAC_OVERRIDE = 32;
858pub const CAP_MAC_ADMIN = 33;
859pub const CAP_SYSLOG = 34;
860pub const CAP_WAKE_ALARM = 35;
861pub const CAP_BLOCK_SUSPEND = 36;
862pub const CAP_AUDIT_READ = 37;
863pub const CAP_LAST_CAP = CAP_AUDIT_READ;
864
865pub fn cap_valid(u8: x) bool {
866 return x >= 0 and x <= CAP_LAST_CAP;
867}
868
869pub fn CAP_TO_MASK(cap: u8) u32 {
870 return u32(1) << u5(cap & 31);
871}
872
873pub fn CAP_TO_INDEX(cap: u8) u8 {
874 return cap >> 5;
875}
876
877pub const cap_t = extern struct {
878 hdrp: *cap_user_header_t,
879 datap: *cap_user_data_t,
880};
881
882pub const cap_user_header_t = extern struct {
883 version: u32,
884 pid: usize,
885};
886
887pub const cap_user_data_t = extern struct {
888 effective: u32,
889 permitted: u32,
890 inheritable: u32,
891};
892
893pub const inotify_event = extern struct {
894 wd: i32,
895 mask: u32,
896 cookie: u32,
897 len: u32,
898 //name: [?]u8,
899};
900
901pub const dirent64 = extern struct {
902 d_ino: u64,
903 d_off: u64,
904 d_reclen: u16,
905 d_type: u8,
906 d_name: u8, // field address is the address of first byte of name https://github.com/ziglang/zig/issues/173
907};
908
909pub const dl_phdr_info = extern struct {
910 dlpi_addr: usize,
911 dlpi_name: ?[*]const u8,
912 dlpi_phdr: [*]elf.Phdr,
913 dlpi_phnum: u16,
914};
915
916pub const pthread_attr_t = extern struct {
917 __size: [56]u8,
918 __align: c_long,
919};
std/os/bits/linux/arm64.zig created+405
...@@ -0,0 +1,405 @@
1// arm64-specific declarations that are intended to be imported into the POSIX namespace.
2// This does include Linux-only APIs.
3
4const std = @import("../../std.zig");
5const linux = std.os.linux;
6const socklen_t = linux.socklen_t;
7const iovec = linux.iovec;
8const iovec_const = linux.iovec_const;
9
10pub const SYS_io_setup = 0;
11pub const SYS_io_destroy = 1;
12pub const SYS_io_submit = 2;
13pub const SYS_io_cancel = 3;
14pub const SYS_io_getevents = 4;
15pub const SYS_setxattr = 5;
16pub const SYS_lsetxattr = 6;
17pub const SYS_fsetxattr = 7;
18pub const SYS_getxattr = 8;
19pub const SYS_lgetxattr = 9;
20pub const SYS_fgetxattr = 10;
21pub const SYS_listxattr = 11;
22pub const SYS_llistxattr = 12;
23pub const SYS_flistxattr = 13;
24pub const SYS_removexattr = 14;
25pub const SYS_lremovexattr = 15;
26pub const SYS_fremovexattr = 16;
27pub const SYS_getcwd = 17;
28pub const SYS_lookup_dcookie = 18;
29pub const SYS_eventfd2 = 19;
30pub const SYS_epoll_create1 = 20;
31pub const SYS_epoll_ctl = 21;
32pub const SYS_epoll_pwait = 22;
33pub const SYS_dup = 23;
34pub const SYS_dup3 = 24;
35pub const SYS_fcntl = 25;
36pub const SYS_inotify_init1 = 26;
37pub const SYS_inotify_add_watch = 27;
38pub const SYS_inotify_rm_watch = 28;
39pub const SYS_ioctl = 29;
40pub const SYS_ioprio_set = 30;
41pub const SYS_ioprio_get = 31;
42pub const SYS_flock = 32;
43pub const SYS_mknodat = 33;
44pub const SYS_mkdirat = 34;
45pub const SYS_unlinkat = 35;
46pub const SYS_symlinkat = 36;
47pub const SYS_linkat = 37;
48pub const SYS_renameat = 38;
49pub const SYS_umount2 = 39;
50pub const SYS_mount = 40;
51pub const SYS_pivot_root = 41;
52pub const SYS_nfsservctl = 42;
53pub const SYS_statfs = 43;
54pub const SYS_fstatfs = 44;
55pub const SYS_truncate = 45;
56pub const SYS_ftruncate = 46;
57pub const SYS_fallocate = 47;
58pub const SYS_faccessat = 48;
59pub const SYS_chdir = 49;
60pub const SYS_fchdir = 50;
61pub const SYS_chroot = 51;
62pub const SYS_fchmod = 52;
63pub const SYS_fchmodat = 53;
64pub const SYS_fchownat = 54;
65pub const SYS_fchown = 55;
66pub const SYS_openat = 56;
67pub const SYS_close = 57;
68pub const SYS_vhangup = 58;
69pub const SYS_pipe2 = 59;
70pub const SYS_quotactl = 60;
71pub const SYS_getdents64 = 61;
72pub const SYS_lseek = 62;
73pub const SYS_read = 63;
74pub const SYS_write = 64;
75pub const SYS_readv = 65;
76pub const SYS_writev = 66;
77pub const SYS_pread64 = 67;
78pub const SYS_pwrite64 = 68;
79pub const SYS_preadv = 69;
80pub const SYS_pwritev = 70;
81pub const SYS_pselect6 = 72;
82pub const SYS_ppoll = 73;
83pub const SYS_signalfd4 = 74;
84pub const SYS_vmsplice = 75;
85pub const SYS_splice = 76;
86pub const SYS_tee = 77;
87pub const SYS_readlinkat = 78;
88pub const SYS_fstatat = 79;
89pub const SYS_fstat = 80;
90pub const SYS_sync = 81;
91pub const SYS_fsync = 82;
92pub const SYS_fdatasync = 83;
93pub const SYS_sync_file_range2 = 84;
94pub const SYS_sync_file_range = 84;
95pub const SYS_timerfd_create = 85;
96pub const SYS_timerfd_settime = 86;
97pub const SYS_timerfd_gettime = 87;
98pub const SYS_utimensat = 88;
99pub const SYS_acct = 89;
100pub const SYS_capget = 90;
101pub const SYS_capset = 91;
102pub const SYS_personality = 92;
103pub const SYS_exit = 93;
104pub const SYS_exit_group = 94;
105pub const SYS_waitid = 95;
106pub const SYS_set_tid_address = 96;
107pub const SYS_unshare = 97;
108pub const SYS_futex = 98;
109pub const SYS_set_robust_list = 99;
110pub const SYS_get_robust_list = 100;
111pub const SYS_nanosleep = 101;
112pub const SYS_getitimer = 102;
113pub const SYS_setitimer = 103;
114pub const SYS_kexec_load = 104;
115pub const SYS_init_module = 105;
116pub const SYS_delete_module = 106;
117pub const SYS_timer_create = 107;
118pub const SYS_timer_gettime = 108;
119pub const SYS_timer_getoverrun = 109;
120pub const SYS_timer_settime = 110;
121pub const SYS_timer_delete = 111;
122pub const SYS_clock_settime = 112;
123pub const SYS_clock_gettime = 113;
124pub const SYS_clock_getres = 114;
125pub const SYS_clock_nanosleep = 115;
126pub const SYS_syslog = 116;
127pub const SYS_ptrace = 117;
128pub const SYS_sched_setparam = 118;
129pub const SYS_sched_setscheduler = 119;
130pub const SYS_sched_getscheduler = 120;
131pub const SYS_sched_getparam = 121;
132pub const SYS_sched_setaffinity = 122;
133pub const SYS_sched_getaffinity = 123;
134pub const SYS_sched_yield = 124;
135pub const SYS_sched_get_priority_max = 125;
136pub const SYS_sched_get_priority_min = 126;
137pub const SYS_sched_rr_get_interval = 127;
138pub const SYS_restart_syscall = 128;
139pub const SYS_kill = 129;
140pub const SYS_tkill = 130;
141pub const SYS_tgkill = 131;
142pub const SYS_sigaltstack = 132;
143pub const SYS_rt_sigsuspend = 133;
144pub const SYS_rt_sigaction = 134;
145pub const SYS_rt_sigprocmask = 135;
146pub const SYS_rt_sigpending = 136;
147pub const SYS_rt_sigtimedwait = 137;
148pub const SYS_rt_sigqueueinfo = 138;
149pub const SYS_rt_sigreturn = 139;
150pub const SYS_setpriority = 140;
151pub const SYS_getpriority = 141;
152pub const SYS_reboot = 142;
153pub const SYS_setregid = 143;
154pub const SYS_setgid = 144;
155pub const SYS_setreuid = 145;
156pub const SYS_setuid = 146;
157pub const SYS_setresuid = 147;
158pub const SYS_getresuid = 148;
159pub const SYS_setresgid = 149;
160pub const SYS_getresgid = 150;
161pub const SYS_setfsuid = 151;
162pub const SYS_setfsgid = 152;
163pub const SYS_times = 153;
164pub const SYS_setpgid = 154;
165pub const SYS_getpgid = 155;
166pub const SYS_getsid = 156;
167pub const SYS_setsid = 157;
168pub const SYS_getgroups = 158;
169pub const SYS_setgroups = 159;
170pub const SYS_uname = 160;
171pub const SYS_sethostname = 161;
172pub const SYS_setdomainname = 162;
173pub const SYS_getrlimit = 163;
174pub const SYS_setrlimit = 164;
175pub const SYS_getrusage = 165;
176pub const SYS_umask = 166;
177pub const SYS_prctl = 167;
178pub const SYS_getcpu = 168;
179pub const SYS_gettimeofday = 169;
180pub const SYS_settimeofday = 170;
181pub const SYS_adjtimex = 171;
182pub const SYS_getpid = 172;
183pub const SYS_getppid = 173;
184pub const SYS_getuid = 174;
185pub const SYS_geteuid = 175;
186pub const SYS_getgid = 176;
187pub const SYS_getegid = 177;
188pub const SYS_gettid = 178;
189pub const SYS_sysinfo = 179;
190pub const SYS_mq_open = 180;
191pub const SYS_mq_unlink = 181;
192pub const SYS_mq_timedsend = 182;
193pub const SYS_mq_timedreceive = 183;
194pub const SYS_mq_notify = 184;
195pub const SYS_mq_getsetattr = 185;
196pub const SYS_msgget = 186;
197pub const SYS_msgctl = 187;
198pub const SYS_msgrcv = 188;
199pub const SYS_msgsnd = 189;
200pub const SYS_semget = 190;
201pub const SYS_semctl = 191;
202pub const SYS_semtimedop = 192;
203pub const SYS_semop = 193;
204pub const SYS_shmget = 194;
205pub const SYS_shmctl = 195;
206pub const SYS_shmat = 196;
207pub const SYS_shmdt = 197;
208pub const SYS_socket = 198;
209pub const SYS_socketpair = 199;
210pub const SYS_bind = 200;
211pub const SYS_listen = 201;
212pub const SYS_accept = 202;
213pub const SYS_connect = 203;
214pub const SYS_getsockname = 204;
215pub const SYS_getpeername = 205;
216pub const SYS_sendto = 206;
217pub const SYS_recvfrom = 207;
218pub const SYS_setsockopt = 208;
219pub const SYS_getsockopt = 209;
220pub const SYS_shutdown = 210;
221pub const SYS_sendmsg = 211;
222pub const SYS_recvmsg = 212;
223pub const SYS_readahead = 213;
224pub const SYS_brk = 214;
225pub const SYS_munmap = 215;
226pub const SYS_mremap = 216;
227pub const SYS_add_key = 217;
228pub const SYS_request_key = 218;
229pub const SYS_keyctl = 219;
230pub const SYS_clone = 220;
231pub const SYS_execve = 221;
232pub const SYS_mmap = 222;
233pub const SYS_fadvise64 = 223;
234pub const SYS_swapon = 224;
235pub const SYS_swapoff = 225;
236pub const SYS_mprotect = 226;
237pub const SYS_msync = 227;
238pub const SYS_mlock = 228;
239pub const SYS_munlock = 229;
240pub const SYS_mlockall = 230;
241pub const SYS_munlockall = 231;
242pub const SYS_mincore = 232;
243pub const SYS_madvise = 233;
244pub const SYS_remap_file_pages = 234;
245pub const SYS_mbind = 235;
246pub const SYS_get_mempolicy = 236;
247pub const SYS_set_mempolicy = 237;
248pub const SYS_migrate_pages = 238;
249pub const SYS_move_pages = 239;
250pub const SYS_rt_tgsigqueueinfo = 240;
251pub const SYS_perf_event_open = 241;
252pub const SYS_accept4 = 242;
253pub const SYS_recvmmsg = 243;
254pub const SYS_arch_specific_syscall = 244;
255pub const SYS_wait4 = 260;
256pub const SYS_prlimit64 = 261;
257pub const SYS_fanotify_init = 262;
258pub const SYS_fanotify_mark = 263;
259pub const SYS_clock_adjtime = 266;
260pub const SYS_syncfs = 267;
261pub const SYS_setns = 268;
262pub const SYS_sendmmsg = 269;
263pub const SYS_process_vm_readv = 270;
264pub const SYS_process_vm_writev = 271;
265pub const SYS_kcmp = 272;
266pub const SYS_finit_module = 273;
267pub const SYS_sched_setattr = 274;
268pub const SYS_sched_getattr = 275;
269pub const SYS_renameat2 = 276;
270pub const SYS_seccomp = 277;
271pub const SYS_getrandom = 278;
272pub const SYS_memfd_create = 279;
273pub const SYS_bpf = 280;
274pub const SYS_execveat = 281;
275pub const SYS_userfaultfd = 282;
276pub const SYS_membarrier = 283;
277pub const SYS_mlock2 = 284;
278pub const SYS_copy_file_range = 285;
279pub const SYS_preadv2 = 286;
280pub const SYS_pwritev2 = 287;
281pub const SYS_pkey_mprotect = 288;
282pub const SYS_pkey_alloc = 289;
283pub const SYS_pkey_free = 290;
284pub const SYS_statx = 291;
285pub const SYS_io_pgetevents = 292;
286pub const SYS_rseq = 293;
287pub const SYS_kexec_file_load = 294;
288pub const SYS_pidfd_send_signal = 424;
289pub const SYS_io_uring_setup = 425;
290pub const SYS_io_uring_enter = 426;
291pub const SYS_io_uring_register = 427;
292
293pub const O_CREAT = 0o100;
294pub const O_EXCL = 0o200;
295pub const O_NOCTTY = 0o400;
296pub const O_TRUNC = 0o1000;
297pub const O_APPEND = 0o2000;
298pub const O_NONBLOCK = 0o4000;
299pub const O_DSYNC = 0o10000;
300pub const O_SYNC = 0o4010000;
301pub const O_RSYNC = 0o4010000;
302pub const O_DIRECTORY = 0o200000;
303pub const O_NOFOLLOW = 0o400000;
304pub const O_CLOEXEC = 0o2000000;
305
306pub const O_ASYNC = 0o20000;
307pub const O_DIRECT = 0o40000;
308pub const O_LARGEFILE = 0;
309pub const O_NOATIME = 0o1000000;
310pub const O_PATH = 0o10000000;
311pub const O_TMPFILE = 0o20200000;
312pub const O_NDELAY = O_NONBLOCK;
313
314pub const F_DUPFD = 0;
315pub const F_GETFD = 1;
316pub const F_SETFD = 2;
317pub const F_GETFL = 3;
318pub const F_SETFL = 4;
319
320pub const F_SETOWN = 8;
321pub const F_GETOWN = 9;
322pub const F_SETSIG = 10;
323pub const F_GETSIG = 11;
324
325pub const F_GETLK = 5;
326pub const F_SETLK = 6;
327pub const F_SETLKW = 7;
328
329pub const F_SETOWN_EX = 15;
330pub const F_GETOWN_EX = 16;
331
332pub const F_GETOWNER_UIDS = 17;
333
334pub const AT_FDCWD = -100;
335pub const AT_SYMLINK_NOFOLLOW = 0x100;
336pub const AT_REMOVEDIR = 0x200;
337pub const AT_SYMLINK_FOLLOW = 0x400;
338pub const AT_NO_AUTOMOUNT = 0x800;
339pub const AT_EMPTY_PATH = 0x1000;
340
341pub const VDSO_USEFUL = true;
342pub const VDSO_CGT_SYM = "__kernel_clock_gettime";
343pub const VDSO_CGT_VER = "LINUX_2.6.39";
344
345pub const msghdr = extern struct {
346 msg_name: ?*sockaddr,
347 msg_namelen: socklen_t,
348 msg_iov: [*]iovec,
349 msg_iovlen: i32,
350 __pad1: i32,
351 msg_control: ?*c_void,
352 msg_controllen: socklen_t,
353 __pad2: socklen_t,
354 msg_flags: i32,
355};
356
357pub const msghdr_const = extern struct {
358 msg_name: ?*const sockaddr,
359 msg_namelen: socklen_t,
360 msg_iov: [*]iovec_const,
361 msg_iovlen: i32,
362 __pad1: i32,
363 msg_control: ?*c_void,
364 msg_controllen: socklen_t,
365 __pad2: socklen_t,
366 msg_flags: i32,
367};
368
369/// Renamed to Stat to not conflict with the stat function.
370pub const Stat = extern struct {
371 dev: u64,
372 ino: u64,
373 nlink: usize,
374
375 mode: u32,
376 uid: u32,
377 gid: u32,
378 __pad0: u32,
379 rdev: u64,
380 size: i64,
381 blksize: isize,
382 blocks: i64,
383
384 atim: timespec,
385 mtim: timespec,
386 ctim: timespec,
387 __unused: [3]isize,
388};
389
390pub const timespec = extern struct {
391 tv_sec: isize,
392 tv_nsec: isize,
393};
394
395pub const timeval = extern struct {
396 tv_sec: isize,
397 tv_usec: isize,
398};
399
400pub const timezone = extern struct {
401 tz_minuteswest: i32,
402 tz_dsttime: i32,
403};
404
405pub const Elf_Symndx = u32;
std/os/bits/linux/errno.zig created+427
...@@ -0,0 +1,427 @@
1/// Operation not permitted
2pub const EPERM = 1;
3
4/// No such file or directory
5pub const ENOENT = 2;
6
7/// No such process
8pub const ESRCH = 3;
9
10/// Interrupted system call
11pub const EINTR = 4;
12
13/// I/O error
14pub const EIO = 5;
15
16/// No such device or address
17pub const ENXIO = 6;
18
19/// Arg list too long
20pub const E2BIG = 7;
21
22/// Exec format error
23pub const ENOEXEC = 8;
24
25/// Bad file number
26pub const EBADF = 9;
27
28/// No child processes
29pub const ECHILD = 10;
30
31/// Try again
32pub const EAGAIN = 11;
33
34/// Out of memory
35pub const ENOMEM = 12;
36
37/// Permission denied
38pub const EACCES = 13;
39
40/// Bad address
41pub const EFAULT = 14;
42
43/// Block device required
44pub const ENOTBLK = 15;
45
46/// Device or resource busy
47pub const EBUSY = 16;
48
49/// File exists
50pub const EEXIST = 17;
51
52/// Cross-device link
53pub const EXDEV = 18;
54
55/// No such device
56pub const ENODEV = 19;
57
58/// Not a directory
59pub const ENOTDIR = 20;
60
61/// Is a directory
62pub const EISDIR = 21;
63
64/// Invalid argument
65pub const EINVAL = 22;
66
67/// File table overflow
68pub const ENFILE = 23;
69
70/// Too many open files
71pub const EMFILE = 24;
72
73/// Not a typewriter
74pub const ENOTTY = 25;
75
76/// Text file busy
77pub const ETXTBSY = 26;
78
79/// File too large
80pub const EFBIG = 27;
81
82/// No space left on device
83pub const ENOSPC = 28;
84
85/// Illegal seek
86pub const ESPIPE = 29;
87
88/// Read-only file system
89pub const EROFS = 30;
90
91/// Too many links
92pub const EMLINK = 31;
93
94/// Broken pipe
95pub const EPIPE = 32;
96
97/// Math argument out of domain of func
98pub const EDOM = 33;
99
100/// Math result not representable
101pub const ERANGE = 34;
102
103/// Resource deadlock would occur
104pub const EDEADLK = 35;
105
106/// File name too long
107pub const ENAMETOOLONG = 36;
108
109/// No record locks available
110pub const ENOLCK = 37;
111
112/// Function not implemented
113pub const ENOSYS = 38;
114
115/// Directory not empty
116pub const ENOTEMPTY = 39;
117
118/// Too many symbolic links encountered
119pub const ELOOP = 40;
120
121/// Operation would block
122pub const EWOULDBLOCK = EAGAIN;
123
124/// No message of desired type
125pub const ENOMSG = 42;
126
127/// Identifier removed
128pub const EIDRM = 43;
129
130/// Channel number out of range
131pub const ECHRNG = 44;
132
133/// Level 2 not synchronized
134pub const EL2NSYNC = 45;
135
136/// Level 3 halted
137pub const EL3HLT = 46;
138
139/// Level 3 reset
140pub const EL3RST = 47;
141
142/// Link number out of range
143pub const ELNRNG = 48;
144
145/// Protocol driver not attached
146pub const EUNATCH = 49;
147
148/// No CSI structure available
149pub const ENOCSI = 50;
150
151/// Level 2 halted
152pub const EL2HLT = 51;
153
154/// Invalid exchange
155pub const EBADE = 52;
156
157/// Invalid request descriptor
158pub const EBADR = 53;
159
160/// Exchange full
161pub const EXFULL = 54;
162
163/// No anode
164pub const ENOANO = 55;
165
166/// Invalid request code
167pub const EBADRQC = 56;
168
169/// Invalid slot
170pub const EBADSLT = 57;
171
172/// Bad font file format
173pub const EBFONT = 59;
174
175/// Device not a stream
176pub const ENOSTR = 60;
177
178/// No data available
179pub const ENODATA = 61;
180
181/// Timer expired
182pub const ETIME = 62;
183
184/// Out of streams resources
185pub const ENOSR = 63;
186
187/// Machine is not on the network
188pub const ENONET = 64;
189
190/// Package not installed
191pub const ENOPKG = 65;
192
193/// Object is remote
194pub const EREMOTE = 66;
195
196/// Link has been severed
197pub const ENOLINK = 67;
198
199/// Advertise error
200pub const EADV = 68;
201
202/// Srmount error
203pub const ESRMNT = 69;
204
205/// Communication error on send
206pub const ECOMM = 70;
207
208/// Protocol error
209pub const EPROTO = 71;
210
211/// Multihop attempted
212pub const EMULTIHOP = 72;
213
214/// RFS specific error
215pub const EDOTDOT = 73;
216
217/// Not a data message
218pub const EBADMSG = 74;
219
220/// Value too large for defined data type
221pub const EOVERFLOW = 75;
222
223/// Name not unique on network
224pub const ENOTUNIQ = 76;
225
226/// File descriptor in bad state
227pub const EBADFD = 77;
228
229/// Remote address changed
230pub const EREMCHG = 78;
231
232/// Can not access a needed shared library
233pub const ELIBACC = 79;
234
235/// Accessing a corrupted shared library
236pub const ELIBBAD = 80;
237
238/// .lib section in a.out corrupted
239pub const ELIBSCN = 81;
240
241/// Attempting to link in too many shared libraries
242pub const ELIBMAX = 82;
243
244/// Cannot exec a shared library directly
245pub const ELIBEXEC = 83;
246
247/// Illegal byte sequence
248pub const EILSEQ = 84;
249
250/// Interrupted system call should be restarted
251pub const ERESTART = 85;
252
253/// Streams pipe error
254pub const ESTRPIPE = 86;
255
256/// Too many users
257pub const EUSERS = 87;
258
259/// Socket operation on non-socket
260pub const ENOTSOCK = 88;
261
262/// Destination address required
263pub const EDESTADDRREQ = 89;
264
265/// Message too long
266pub const EMSGSIZE = 90;
267
268/// Protocol wrong type for socket
269pub const EPROTOTYPE = 91;
270
271/// Protocol not available
272pub const ENOPROTOOPT = 92;
273
274/// Protocol not supported
275pub const EPROTONOSUPPORT = 93;
276
277/// Socket type not supported
278pub const ESOCKTNOSUPPORT = 94;
279
280/// Operation not supported on transport endpoint
281pub const EOPNOTSUPP = 95;
282
283/// Protocol family not supported
284pub const EPFNOSUPPORT = 96;
285
286/// Address family not supported by protocol
287pub const EAFNOSUPPORT = 97;
288
289/// Address already in use
290pub const EADDRINUSE = 98;
291
292/// Cannot assign requested address
293pub const EADDRNOTAVAIL = 99;
294
295/// Network is down
296pub const ENETDOWN = 100;
297
298/// Network is unreachable
299pub const ENETUNREACH = 101;
300
301/// Network dropped connection because of reset
302pub const ENETRESET = 102;
303
304/// Software caused connection abort
305pub const ECONNABORTED = 103;
306
307/// Connection reset by peer
308pub const ECONNRESET = 104;
309
310/// No buffer space available
311pub const ENOBUFS = 105;
312
313/// Transport endpoint is already connected
314pub const EISCONN = 106;
315
316/// Transport endpoint is not connected
317pub const ENOTCONN = 107;
318
319/// Cannot send after transport endpoint shutdown
320pub const ESHUTDOWN = 108;
321
322/// Too many references: cannot splice
323pub const ETOOMANYREFS = 109;
324
325/// Connection timed out
326pub const ETIMEDOUT = 110;
327
328/// Connection refused
329pub const ECONNREFUSED = 111;
330
331/// Host is down
332pub const EHOSTDOWN = 112;
333
334/// No route to host
335pub const EHOSTUNREACH = 113;
336
337/// Operation already in progress
338pub const EALREADY = 114;
339
340/// Operation now in progress
341pub const EINPROGRESS = 115;
342
343/// Stale NFS file handle
344pub const ESTALE = 116;
345
346/// Structure needs cleaning
347pub const EUCLEAN = 117;
348
349/// Not a XENIX named type file
350pub const ENOTNAM = 118;
351
352/// No XENIX semaphores available
353pub const ENAVAIL = 119;
354
355/// Is a named type file
356pub const EISNAM = 120;
357
358/// Remote I/O error
359pub const EREMOTEIO = 121;
360
361/// Quota exceeded
362pub const EDQUOT = 122;
363
364/// No medium found
365pub const ENOMEDIUM = 123;
366
367/// Wrong medium type
368pub const EMEDIUMTYPE = 124;
369
370// nameserver query return codes
371
372/// DNS server returned answer with no data
373pub const ENSROK = 0;
374
375/// DNS server returned answer with no data
376pub const ENSRNODATA = 160;
377
378/// DNS server claims query was misformatted
379pub const ENSRFORMERR = 161;
380
381/// DNS server returned general failure
382pub const ENSRSERVFAIL = 162;
383
384/// Domain name not found
385pub const ENSRNOTFOUND = 163;
386
387/// DNS server does not implement requested operation
388pub const ENSRNOTIMP = 164;
389
390/// DNS server refused query
391pub const ENSRREFUSED = 165;
392
393/// Misformatted DNS query
394pub const ENSRBADQUERY = 166;
395
396/// Misformatted domain name
397pub const ENSRBADNAME = 167;
398
399/// Unsupported address family
400pub const ENSRBADFAMILY = 168;
401
402/// Misformatted DNS reply
403pub const ENSRBADRESP = 169;
404
405/// Could not contact DNS servers
406pub const ENSRCONNREFUSED = 170;
407
408/// Timeout while contacting DNS servers
409pub const ENSRTIMEOUT = 171;
410
411/// End of file
412pub const ENSROF = 172;
413
414/// Error reading file
415pub const ENSRFILE = 173;
416
417/// Out of memory
418pub const ENSRNOMEM = 174;
419
420/// Application terminated lookup
421pub const ENSRDESTRUCTION = 175;
422
423/// Domain name is too long
424pub const ENSRQUERYDOMAINTOOLONG = 176;
425
426/// Domain name is too long
427pub const ENSRCNAMELOOP = 177;
std/os/bits/linux/x86_64.zig created+470
...@@ -0,0 +1,470 @@
1// x86-64-specific declarations that are intended to be imported into the POSIX namespace.
2const std = @import("../../../std.zig");
3
4const linux = std.os.linux;
5const sockaddr = linux.sockaddr;
6const socklen_t = linux.socklen_t;
7const iovec = linux.iovec;
8const iovec_const = linux.iovec_const;
9
10pub const SYS_read = 0;
11pub const SYS_write = 1;
12pub const SYS_open = 2;
13pub const SYS_close = 3;
14pub const SYS_stat = 4;
15pub const SYS_fstat = 5;
16pub const SYS_lstat = 6;
17pub const SYS_poll = 7;
18pub const SYS_lseek = 8;
19pub const SYS_mmap = 9;
20pub const SYS_mprotect = 10;
21pub const SYS_munmap = 11;
22pub const SYS_brk = 12;
23pub const SYS_rt_sigaction = 13;
24pub const SYS_rt_sigprocmask = 14;
25pub const SYS_rt_sigreturn = 15;
26pub const SYS_ioctl = 16;
27pub const SYS_pread = 17;
28pub const SYS_pwrite = 18;
29pub const SYS_readv = 19;
30pub const SYS_writev = 20;
31pub const SYS_access = 21;
32pub const SYS_pipe = 22;
33pub const SYS_select = 23;
34pub const SYS_sched_yield = 24;
35pub const SYS_mremap = 25;
36pub const SYS_msync = 26;
37pub const SYS_mincore = 27;
38pub const SYS_madvise = 28;
39pub const SYS_shmget = 29;
40pub const SYS_shmat = 30;
41pub const SYS_shmctl = 31;
42pub const SYS_dup = 32;
43pub const SYS_dup2 = 33;
44pub const SYS_pause = 34;
45pub const SYS_nanosleep = 35;
46pub const SYS_getitimer = 36;
47pub const SYS_alarm = 37;
48pub const SYS_setitimer = 38;
49pub const SYS_getpid = 39;
50pub const SYS_sendfile = 40;
51pub const SYS_socket = 41;
52pub const SYS_connect = 42;
53pub const SYS_accept = 43;
54pub const SYS_sendto = 44;
55pub const SYS_recvfrom = 45;
56pub const SYS_sendmsg = 46;
57pub const SYS_recvmsg = 47;
58pub const SYS_shutdown = 48;
59pub const SYS_bind = 49;
60pub const SYS_listen = 50;
61pub const SYS_getsockname = 51;
62pub const SYS_getpeername = 52;
63pub const SYS_socketpair = 53;
64pub const SYS_setsockopt = 54;
65pub const SYS_getsockopt = 55;
66pub const SYS_clone = 56;
67pub const SYS_fork = 57;
68pub const SYS_vfork = 58;
69pub const SYS_execve = 59;
70pub const SYS_exit = 60;
71pub const SYS_wait4 = 61;
72pub const SYS_kill = 62;
73pub const SYS_uname = 63;
74pub const SYS_semget = 64;
75pub const SYS_semop = 65;
76pub const SYS_semctl = 66;
77pub const SYS_shmdt = 67;
78pub const SYS_msgget = 68;
79pub const SYS_msgsnd = 69;
80pub const SYS_msgrcv = 70;
81pub const SYS_msgctl = 71;
82pub const SYS_fcntl = 72;
83pub const SYS_flock = 73;
84pub const SYS_fsync = 74;
85pub const SYS_fdatasync = 75;
86pub const SYS_truncate = 76;
87pub const SYS_ftruncate = 77;
88pub const SYS_getdents = 78;
89pub const SYS_getcwd = 79;
90pub const SYS_chdir = 80;
91pub const SYS_fchdir = 81;
92pub const SYS_rename = 82;
93pub const SYS_mkdir = 83;
94pub const SYS_rmdir = 84;
95pub const SYS_creat = 85;
96pub const SYS_link = 86;
97pub const SYS_unlink = 87;
98pub const SYS_symlink = 88;
99pub const SYS_readlink = 89;
100pub const SYS_chmod = 90;
101pub const SYS_fchmod = 91;
102pub const SYS_chown = 92;
103pub const SYS_fchown = 93;
104pub const SYS_lchown = 94;
105pub const SYS_umask = 95;
106pub const SYS_gettimeofday = 96;
107pub const SYS_getrlimit = 97;
108pub const SYS_getrusage = 98;
109pub const SYS_sysinfo = 99;
110pub const SYS_times = 100;
111pub const SYS_ptrace = 101;
112pub const SYS_getuid = 102;
113pub const SYS_syslog = 103;
114pub const SYS_getgid = 104;
115pub const SYS_setuid = 105;
116pub const SYS_setgid = 106;
117pub const SYS_geteuid = 107;
118pub const SYS_getegid = 108;
119pub const SYS_setpgid = 109;
120pub const SYS_getppid = 110;
121pub const SYS_getpgrp = 111;
122pub const SYS_setsid = 112;
123pub const SYS_setreuid = 113;
124pub const SYS_setregid = 114;
125pub const SYS_getgroups = 115;
126pub const SYS_setgroups = 116;
127pub const SYS_setresuid = 117;
128pub const SYS_getresuid = 118;
129pub const SYS_setresgid = 119;
130pub const SYS_getresgid = 120;
131pub const SYS_getpgid = 121;
132pub const SYS_setfsuid = 122;
133pub const SYS_setfsgid = 123;
134pub const SYS_getsid = 124;
135pub const SYS_capget = 125;
136pub const SYS_capset = 126;
137pub const SYS_rt_sigpending = 127;
138pub const SYS_rt_sigtimedwait = 128;
139pub const SYS_rt_sigqueueinfo = 129;
140pub const SYS_rt_sigsuspend = 130;
141pub const SYS_sigaltstack = 131;
142pub const SYS_utime = 132;
143pub const SYS_mknod = 133;
144pub const SYS_uselib = 134;
145pub const SYS_personality = 135;
146pub const SYS_ustat = 136;
147pub const SYS_statfs = 137;
148pub const SYS_fstatfs = 138;
149pub const SYS_sysfs = 139;
150pub const SYS_getpriority = 140;
151pub const SYS_setpriority = 141;
152pub const SYS_sched_setparam = 142;
153pub const SYS_sched_getparam = 143;
154pub const SYS_sched_setscheduler = 144;
155pub const SYS_sched_getscheduler = 145;
156pub const SYS_sched_get_priority_max = 146;
157pub const SYS_sched_get_priority_min = 147;
158pub const SYS_sched_rr_get_interval = 148;
159pub const SYS_mlock = 149;
160pub const SYS_munlock = 150;
161pub const SYS_mlockall = 151;
162pub const SYS_munlockall = 152;
163pub const SYS_vhangup = 153;
164pub const SYS_modify_ldt = 154;
165pub const SYS_pivot_root = 155;
166pub const SYS__sysctl = 156;
167pub const SYS_prctl = 157;
168pub const SYS_arch_prctl = 158;
169pub const SYS_adjtimex = 159;
170pub const SYS_setrlimit = 160;
171pub const SYS_chroot = 161;
172pub const SYS_sync = 162;
173pub const SYS_acct = 163;
174pub const SYS_settimeofday = 164;
175pub const SYS_mount = 165;
176pub const SYS_umount2 = 166;
177pub const SYS_swapon = 167;
178pub const SYS_swapoff = 168;
179pub const SYS_reboot = 169;
180pub const SYS_sethostname = 170;
181pub const SYS_setdomainname = 171;
182pub const SYS_iopl = 172;
183pub const SYS_ioperm = 173;
184pub const SYS_create_module = 174;
185pub const SYS_init_module = 175;
186pub const SYS_delete_module = 176;
187pub const SYS_get_kernel_syms = 177;
188pub const SYS_query_module = 178;
189pub const SYS_quotactl = 179;
190pub const SYS_nfsservctl = 180;
191pub const SYS_getpmsg = 181;
192pub const SYS_putpmsg = 182;
193pub const SYS_afs_syscall = 183;
194pub const SYS_tuxcall = 184;
195pub const SYS_security = 185;
196pub const SYS_gettid = 186;
197pub const SYS_readahead = 187;
198pub const SYS_setxattr = 188;
199pub const SYS_lsetxattr = 189;
200pub const SYS_fsetxattr = 190;
201pub const SYS_getxattr = 191;
202pub const SYS_lgetxattr = 192;
203pub const SYS_fgetxattr = 193;
204pub const SYS_listxattr = 194;
205pub const SYS_llistxattr = 195;
206pub const SYS_flistxattr = 196;
207pub const SYS_removexattr = 197;
208pub const SYS_lremovexattr = 198;
209pub const SYS_fremovexattr = 199;
210pub const SYS_tkill = 200;
211pub const SYS_time = 201;
212pub const SYS_futex = 202;
213pub const SYS_sched_setaffinity = 203;
214pub const SYS_sched_getaffinity = 204;
215pub const SYS_set_thread_area = 205;
216pub const SYS_io_setup = 206;
217pub const SYS_io_destroy = 207;
218pub const SYS_io_getevents = 208;
219pub const SYS_io_submit = 209;
220pub const SYS_io_cancel = 210;
221pub const SYS_get_thread_area = 211;
222pub const SYS_lookup_dcookie = 212;
223pub const SYS_epoll_create = 213;
224pub const SYS_epoll_ctl_old = 214;
225pub const SYS_epoll_wait_old = 215;
226pub const SYS_remap_file_pages = 216;
227pub const SYS_getdents64 = 217;
228pub const SYS_set_tid_address = 218;
229pub const SYS_restart_syscall = 219;
230pub const SYS_semtimedop = 220;
231pub const SYS_fadvise64 = 221;
232pub const SYS_timer_create = 222;
233pub const SYS_timer_settime = 223;
234pub const SYS_timer_gettime = 224;
235pub const SYS_timer_getoverrun = 225;
236pub const SYS_timer_delete = 226;
237pub const SYS_clock_settime = 227;
238pub const SYS_clock_gettime = 228;
239pub const SYS_clock_getres = 229;
240pub const SYS_clock_nanosleep = 230;
241pub const SYS_exit_group = 231;
242pub const SYS_epoll_wait = 232;
243pub const SYS_epoll_ctl = 233;
244pub const SYS_tgkill = 234;
245pub const SYS_utimes = 235;
246pub const SYS_vserver = 236;
247pub const SYS_mbind = 237;
248pub const SYS_set_mempolicy = 238;
249pub const SYS_get_mempolicy = 239;
250pub const SYS_mq_open = 240;
251pub const SYS_mq_unlink = 241;
252pub const SYS_mq_timedsend = 242;
253pub const SYS_mq_timedreceive = 243;
254pub const SYS_mq_notify = 244;
255pub const SYS_mq_getsetattr = 245;
256pub const SYS_kexec_load = 246;
257pub const SYS_waitid = 247;
258pub const SYS_add_key = 248;
259pub const SYS_request_key = 249;
260pub const SYS_keyctl = 250;
261pub const SYS_ioprio_set = 251;
262pub const SYS_ioprio_get = 252;
263pub const SYS_inotify_init = 253;
264pub const SYS_inotify_add_watch = 254;
265pub const SYS_inotify_rm_watch = 255;
266pub const SYS_migrate_pages = 256;
267pub const SYS_openat = 257;
268pub const SYS_mkdirat = 258;
269pub const SYS_mknodat = 259;
270pub const SYS_fchownat = 260;
271pub const SYS_futimesat = 261;
272pub const SYS_newfstatat = 262;
273pub const SYS_fstatat = 262;
274pub const SYS_unlinkat = 263;
275pub const SYS_renameat = 264;
276pub const SYS_linkat = 265;
277pub const SYS_symlinkat = 266;
278pub const SYS_readlinkat = 267;
279pub const SYS_fchmodat = 268;
280pub const SYS_faccessat = 269;
281pub const SYS_pselect6 = 270;
282pub const SYS_ppoll = 271;
283pub const SYS_unshare = 272;
284pub const SYS_set_robust_list = 273;
285pub const SYS_get_robust_list = 274;
286pub const SYS_splice = 275;
287pub const SYS_tee = 276;
288pub const SYS_sync_file_range = 277;
289pub const SYS_vmsplice = 278;
290pub const SYS_move_pages = 279;
291pub const SYS_utimensat = 280;
292pub const SYS_epoll_pwait = 281;
293pub const SYS_signalfd = 282;
294pub const SYS_timerfd_create = 283;
295pub const SYS_eventfd = 284;
296pub const SYS_fallocate = 285;
297pub const SYS_timerfd_settime = 286;
298pub const SYS_timerfd_gettime = 287;
299pub const SYS_accept4 = 288;
300pub const SYS_signalfd4 = 289;
301pub const SYS_eventfd2 = 290;
302pub const SYS_epoll_create1 = 291;
303pub const SYS_dup3 = 292;
304pub const SYS_pipe2 = 293;
305pub const SYS_inotify_init1 = 294;
306pub const SYS_preadv = 295;
307pub const SYS_pwritev = 296;
308pub const SYS_rt_tgsigqueueinfo = 297;
309pub const SYS_perf_event_open = 298;
310pub const SYS_recvmmsg = 299;
311pub const SYS_fanotify_init = 300;
312pub const SYS_fanotify_mark = 301;
313pub const SYS_prlimit64 = 302;
314pub const SYS_name_to_handle_at = 303;
315pub const SYS_open_by_handle_at = 304;
316pub const SYS_clock_adjtime = 305;
317pub const SYS_syncfs = 306;
318pub const SYS_sendmmsg = 307;
319pub const SYS_setns = 308;
320pub const SYS_getcpu = 309;
321pub const SYS_process_vm_readv = 310;
322pub const SYS_process_vm_writev = 311;
323pub const SYS_kcmp = 312;
324pub const SYS_finit_module = 313;
325pub const SYS_sched_setattr = 314;
326pub const SYS_sched_getattr = 315;
327pub const SYS_renameat2 = 316;
328pub const SYS_seccomp = 317;
329pub const SYS_getrandom = 318;
330pub const SYS_memfd_create = 319;
331pub const SYS_kexec_file_load = 320;
332pub const SYS_bpf = 321;
333pub const SYS_execveat = 322;
334pub const SYS_userfaultfd = 323;
335pub const SYS_membarrier = 324;
336pub const SYS_mlock2 = 325;
337pub const SYS_copy_file_range = 326;
338pub const SYS_preadv2 = 327;
339pub const SYS_pwritev2 = 328;
340pub const SYS_pkey_mprotect = 329;
341pub const SYS_pkey_alloc = 330;
342pub const SYS_pkey_free = 331;
343pub const SYS_statx = 332;
344pub const SYS_io_pgetevents = 333;
345pub const SYS_rseq = 334;
346pub const SYS_pidfd_send_signal = 424;
347pub const SYS_io_uring_setup = 425;
348pub const SYS_io_uring_enter = 426;
349pub const SYS_io_uring_register = 427;
350
351pub const O_CREAT = 0o100;
352pub const O_EXCL = 0o200;
353pub const O_NOCTTY = 0o400;
354pub const O_TRUNC = 0o1000;
355pub const O_APPEND = 0o2000;
356pub const O_NONBLOCK = 0o4000;
357pub const O_DSYNC = 0o10000;
358pub const O_SYNC = 0o4010000;
359pub const O_RSYNC = 0o4010000;
360pub const O_DIRECTORY = 0o200000;
361pub const O_NOFOLLOW = 0o400000;
362pub const O_CLOEXEC = 0o2000000;
363
364pub const O_ASYNC = 0o20000;
365pub const O_DIRECT = 0o40000;
366pub const O_LARGEFILE = 0;
367pub const O_NOATIME = 0o1000000;
368pub const O_PATH = 0o10000000;
369pub const O_TMPFILE = 0o20200000;
370pub const O_NDELAY = O_NONBLOCK;
371
372pub const F_DUPFD = 0;
373pub const F_GETFD = 1;
374pub const F_SETFD = 2;
375pub const F_GETFL = 3;
376pub const F_SETFL = 4;
377
378pub const F_SETOWN = 8;
379pub const F_GETOWN = 9;
380pub const F_SETSIG = 10;
381pub const F_GETSIG = 11;
382
383pub const F_GETLK = 5;
384pub const F_SETLK = 6;
385pub const F_SETLKW = 7;
386
387pub const F_SETOWN_EX = 15;
388pub const F_GETOWN_EX = 16;
389
390pub const F_GETOWNER_UIDS = 17;
391
392pub const AT_FDCWD = -100;
393pub const AT_SYMLINK_NOFOLLOW = 0x100;
394pub const AT_REMOVEDIR = 0x200;
395pub const AT_SYMLINK_FOLLOW = 0x400;
396pub const AT_NO_AUTOMOUNT = 0x800;
397pub const AT_EMPTY_PATH = 0x1000;
398
399pub const VDSO_USEFUL = true;
400pub const VDSO_CGT_SYM = "__vdso_clock_gettime";
401pub const VDSO_CGT_VER = "LINUX_2.6";
402pub const VDSO_GETCPU_SYM = "__vdso_getcpu";
403pub const VDSO_GETCPU_VER = "LINUX_2.6";
404
405pub const ARCH_SET_GS = 0x1001;
406pub const ARCH_SET_FS = 0x1002;
407pub const ARCH_GET_FS = 0x1003;
408pub const ARCH_GET_GS = 0x1004;
409
410pub const msghdr = extern struct {
411 msg_name: ?*sockaddr,
412 msg_namelen: socklen_t,
413 msg_iov: [*]iovec,
414 msg_iovlen: i32,
415 __pad1: i32,
416 msg_control: ?*c_void,
417 msg_controllen: socklen_t,
418 __pad2: socklen_t,
419 msg_flags: i32,
420};
421
422pub const msghdr_const = extern struct {
423 msg_name: ?*const sockaddr,
424 msg_namelen: socklen_t,
425 msg_iov: [*]iovec_const,
426 msg_iovlen: i32,
427 __pad1: i32,
428 msg_control: ?*c_void,
429 msg_controllen: socklen_t,
430 __pad2: socklen_t,
431 msg_flags: i32,
432};
433
434/// Renamed to Stat to not conflict with the stat function.
435pub const Stat = extern struct {
436 dev: u64,
437 ino: u64,
438 nlink: usize,
439
440 mode: u32,
441 uid: u32,
442 gid: u32,
443 __pad0: u32,
444 rdev: u64,
445 size: i64,
446 blksize: isize,
447 blocks: i64,
448
449 atim: timespec,
450 mtim: timespec,
451 ctim: timespec,
452 __unused: [3]isize,
453};
454
455pub const timespec = extern struct {
456 tv_sec: isize,
457 tv_nsec: isize,
458};
459
460pub const timeval = extern struct {
461 tv_sec: isize,
462 tv_usec: isize,
463};
464
465pub const timezone = extern struct {
466 tz_minuteswest: i32,
467 tz_dsttime: i32,
468};
469
470pub const Elf_Symndx = u32;
std/os/bits/netbsd.zig created+731
...@@ -0,0 +1,731 @@
1const std = @import("../../std.zig");
2const maxInt = std.math.maxInt;
3
4pub const fd_t = c_int;
5pub const pid_t = c_int;
6
7/// Renamed from `kevent` to `Kevent` to avoid conflict with function name.
8pub const Kevent = extern struct {
9 ident: usize,
10 filter: i32,
11 flags: u32,
12 fflags: u32,
13 data: i64,
14 udata: usize,
15};
16
17pub const pthread_attr_t = extern struct {
18 pta_magic: u32,
19 pta_flags: c_int,
20 pta_private: *c_void,
21};
22
23pub const msghdr = extern struct {
24 /// optional address
25 msg_name: ?*sockaddr,
26
27 /// size of address
28 msg_namelen: socklen_t,
29
30 /// scatter/gather array
31 msg_iov: [*]iovec,
32
33 /// # elements in msg_iov
34 msg_iovlen: i32,
35
36 /// ancillary data
37 msg_control: ?*c_void,
38
39 /// ancillary data buffer len
40 msg_controllen: socklen_t,
41
42 /// flags on received message
43 msg_flags: i32,
44};
45
46pub const msghdr_const = extern struct {
47 /// optional address
48 msg_name: ?*const sockaddr,
49
50 /// size of address
51 msg_namelen: socklen_t,
52
53 /// scatter/gather array
54 msg_iov: [*]iovec_const,
55
56 /// # elements in msg_iov
57 msg_iovlen: i32,
58
59 /// ancillary data
60 msg_control: ?*c_void,
61
62 /// ancillary data buffer len
63 msg_controllen: socklen_t,
64
65 /// flags on received message
66 msg_flags: i32,
67};
68
69pub const Stat = extern struct {
70 dev: u64,
71 mode: u32,
72 ino: u64,
73 nlink: usize,
74
75 uid: u32,
76 gid: u32,
77 rdev: u64,
78
79 atim: timespec,
80 mtim: timespec,
81 ctim: timespec,
82 birthtim: timespec,
83
84 size: i64,
85 blocks: i64,
86 blksize: isize,
87 flags: u32,
88 gen: u32,
89 __spare: [2]u32,
90};
91
92pub const timespec = extern struct {
93 tv_sec: i64,
94 tv_nsec: isize,
95};
96
97pub const dirent = extern struct {
98 d_fileno: u64,
99 d_reclen: u16,
100 d_namlen: u16,
101 d_type: u8,
102 d_off: i64,
103 d_name: [512]u8,
104};
105
106pub const in_port_t = u16;
107pub const sa_family_t = u8;
108
109pub const sockaddr = extern union {
110 in: sockaddr_in,
111 in6: sockaddr_in6,
112};
113
114pub const sockaddr_in = extern struct {
115 len: u8,
116 family: sa_family_t,
117 port: in_port_t,
118 addr: u32,
119 zero: [8]u8,
120};
121
122pub const sockaddr_in6 = extern struct {
123 len: u8,
124 family: sa_family_t,
125 port: in_port_t,
126 flowinfo: u32,
127 addr: [16]u8,
128 scope_id: u32,
129};
130
131pub const CTL_KERN = 1;
132pub const CTL_DEBUG = 5;
133
134pub const KERN_PROC_ARGS = 48; // struct: process argv/env
135pub const KERN_PROC_PATHNAME = 5; // path to executable
136
137pub const PATH_MAX = 1024;
138
139pub const STDIN_FILENO = 0;
140pub const STDOUT_FILENO = 1;
141pub const STDERR_FILENO = 2;
142
143pub const PROT_NONE = 0;
144pub const PROT_READ = 1;
145pub const PROT_WRITE = 2;
146pub const PROT_EXEC = 4;
147
148pub const CLOCK_REALTIME = 0;
149pub const CLOCK_VIRTUAL = 1;
150pub const CLOCK_PROF = 2;
151pub const CLOCK_MONOTONIC = 3;
152pub const CLOCK_THREAD_CPUTIME_ID = 0x20000000;
153pub const CLOCK_PROCESS_CPUTIME_ID = 0x40000000;
154
155pub const MAP_FAILED = maxInt(usize);
156pub const MAP_SHARED = 0x0001;
157pub const MAP_PRIVATE = 0x0002;
158pub const MAP_REMAPDUP = 0x0004;
159pub const MAP_FIXED = 0x0010;
160pub const MAP_RENAME = 0x0020;
161pub const MAP_NORESERVE = 0x0040;
162pub const MAP_INHERIT = 0x0080;
163pub const MAP_HASSEMAPHORE = 0x0200;
164pub const MAP_TRYFIXED = 0x0400;
165pub const MAP_WIRED = 0x0800;
166
167pub const MAP_FILE = 0x0000;
168pub const MAP_NOSYNC = 0x0800;
169pub const MAP_ANON = 0x1000;
170pub const MAP_ANONYMOUS = MAP_ANON;
171pub const MAP_STACK = 0x2000;
172
173pub const WNOHANG = 0x00000001;
174pub const WUNTRACED = 0x00000002;
175pub const WSTOPPED = WUNTRACED;
176pub const WCONTINUED = 0x00000010;
177pub const WNOWAIT = 0x00010000;
178pub const WEXITED = 0x00000020;
179pub const WTRAPPED = 0x00000040;
180
181pub const SA_ONSTACK = 0x0001;
182pub const SA_RESTART = 0x0002;
183pub const SA_RESETHAND = 0x0004;
184pub const SA_NOCLDSTOP = 0x0008;
185pub const SA_NODEFER = 0x0010;
186pub const SA_NOCLDWAIT = 0x0020;
187pub const SA_SIGINFO = 0x0040;
188
189pub const SIGHUP = 1;
190pub const SIGINT = 2;
191pub const SIGQUIT = 3;
192pub const SIGILL = 4;
193pub const SIGTRAP = 5;
194pub const SIGABRT = 6;
195pub const SIGIOT = SIGABRT;
196pub const SIGEMT = 7;
197pub const SIGFPE = 8;
198pub const SIGKILL = 9;
199pub const SIGBUS = 10;
200pub const SIGSEGV = 11;
201pub const SIGSYS = 12;
202pub const SIGPIPE = 13;
203pub const SIGALRM = 14;
204pub const SIGTERM = 15;
205pub const SIGURG = 16;
206pub const SIGSTOP = 17;
207pub const SIGTSTP = 18;
208pub const SIGCONT = 19;
209pub const SIGCHLD = 20;
210pub const SIGTTIN = 21;
211pub const SIGTTOU = 22;
212pub const SIGIO = 23;
213pub const SIGXCPU = 24;
214pub const SIGXFSZ = 25;
215pub const SIGVTALRM = 26;
216pub const SIGPROF = 27;
217pub const SIGWINCH = 28;
218pub const SIGINFO = 29;
219pub const SIGUSR1 = 30;
220pub const SIGUSR2 = 31;
221pub const SIGPWR = 32;
222
223pub const SIGRTMIN = 33;
224pub const SIGRTMAX = 63;
225
226// access function
227pub const F_OK = 0; // test for existence of file
228pub const X_OK = 1; // test for execute or search permission
229pub const W_OK = 2; // test for write permission
230pub const R_OK = 4; // test for read permission
231
232pub const O_RDONLY = 0x0000;
233pub const O_WRONLY = 0x0001;
234pub const O_RDWR = 0x0002;
235pub const O_ACCMODE = 0x0003;
236
237pub const O_CREAT = 0x0200;
238pub const O_EXCL = 0x0800;
239pub const O_NOCTTY = 0x8000;
240pub const O_TRUNC = 0x0400;
241pub const O_APPEND = 0x0008;
242pub const O_NONBLOCK = 0x0004;
243pub const O_DSYNC = 0x00010000;
244pub const O_SYNC = 0x0080;
245pub const O_RSYNC = 0x00020000;
246pub const O_DIRECTORY = 0x00080000;
247pub const O_NOFOLLOW = 0x00000100;
248pub const O_CLOEXEC = 0x00400000;
249
250pub const O_ASYNC = 0x0040;
251pub const O_DIRECT = 0x00080000;
252pub const O_LARGEFILE = 0;
253pub const O_NOATIME = 0;
254pub const O_PATH = 0;
255pub const O_TMPFILE = 0;
256pub const O_NDELAY = O_NONBLOCK;
257
258pub const F_DUPFD = 0;
259pub const F_GETFD = 1;
260pub const F_SETFD = 2;
261pub const F_GETFL = 3;
262pub const F_SETFL = 4;
263
264pub const F_GETOWN = 5;
265pub const F_SETOWN = 6;
266
267pub const F_GETLK = 7;
268pub const F_SETLK = 8;
269pub const F_SETLKW = 9;
270
271pub const SEEK_SET = 0;
272pub const SEEK_CUR = 1;
273pub const SEEK_END = 2;
274
275pub const SIG_BLOCK = 1;
276pub const SIG_UNBLOCK = 2;
277pub const SIG_SETMASK = 3;
278
279pub const SOCK_STREAM = 1;
280pub const SOCK_DGRAM = 2;
281pub const SOCK_RAW = 3;
282pub const SOCK_RDM = 4;
283pub const SOCK_SEQPACKET = 5;
284
285pub const SOCK_CLOEXEC = 0x10000000;
286pub const SOCK_NONBLOCK = 0x20000000;
287
288pub const PROTO_ip = 0;
289pub const PROTO_icmp = 1;
290pub const PROTO_igmp = 2;
291pub const PROTO_ggp = 3;
292pub const PROTO_ipencap = 4;
293pub const PROTO_tcp = 6;
294pub const PROTO_egp = 8;
295pub const PROTO_pup = 12;
296pub const PROTO_udp = 17;
297pub const PROTO_xns_idp = 22;
298pub const PROTO_iso_tp4 = 29;
299pub const PROTO_ipv6 = 41;
300pub const PROTO_ipv6_route = 43;
301pub const PROTO_ipv6_frag = 44;
302pub const PROTO_rsvp = 46;
303pub const PROTO_gre = 47;
304pub const PROTO_esp = 50;
305pub const PROTO_ah = 51;
306pub const PROTO_ipv6_icmp = 58;
307pub const PROTO_ipv6_nonxt = 59;
308pub const PROTO_ipv6_opts = 60;
309pub const PROTO_encap = 98;
310pub const PROTO_pim = 103;
311pub const PROTO_raw = 255;
312
313pub const PF_UNSPEC = 0;
314pub const PF_LOCAL = 1;
315pub const PF_UNIX = PF_LOCAL;
316pub const PF_FILE = PF_LOCAL;
317pub const PF_INET = 2;
318pub const PF_APPLETALK = 16;
319pub const PF_INET6 = 24;
320pub const PF_DECnet = 12;
321pub const PF_KEY = 29;
322pub const PF_ROUTE = 34;
323pub const PF_SNA = 11;
324pub const PF_MPLS = 33;
325pub const PF_CAN = 35;
326pub const PF_BLUETOOTH = 31;
327pub const PF_ISDN = 26;
328pub const PF_MAX = 37;
329
330pub const AF_UNSPEC = PF_UNSPEC;
331pub const AF_LOCAL = PF_LOCAL;
332pub const AF_UNIX = AF_LOCAL;
333pub const AF_FILE = AF_LOCAL;
334pub const AF_INET = PF_INET;
335pub const AF_APPLETALK = PF_APPLETALK;
336pub const AF_INET6 = PF_INET6;
337pub const AF_KEY = PF_KEY;
338pub const AF_ROUTE = PF_ROUTE;
339pub const AF_SNA = PF_SNA;
340pub const AF_MPLS = PF_MPLS;
341pub const AF_CAN = PF_CAN;
342pub const AF_BLUETOOTH = PF_BLUETOOTH;
343pub const AF_ISDN = PF_ISDN;
344pub const AF_MAX = PF_MAX;
345
346pub const DT_UNKNOWN = 0;
347pub const DT_FIFO = 1;
348pub const DT_CHR = 2;
349pub const DT_DIR = 4;
350pub const DT_BLK = 6;
351pub const DT_REG = 8;
352pub const DT_LNK = 10;
353pub const DT_SOCK = 12;
354pub const DT_WHT = 14;
355
356/// add event to kq (implies enable)
357pub const EV_ADD = 0x0001;
358
359/// delete event from kq
360pub const EV_DELETE = 0x0002;
361
362/// enable event
363pub const EV_ENABLE = 0x0004;
364
365/// disable event (not reported)
366pub const EV_DISABLE = 0x0008;
367
368/// only report one occurrence
369pub const EV_ONESHOT = 0x0010;
370
371/// clear event state after reporting
372pub const EV_CLEAR = 0x0020;
373
374/// force immediate event output
375/// ... with or without EV_ERROR
376/// ... use KEVENT_FLAG_ERROR_EVENTS
377/// on syscalls supporting flags
378pub const EV_RECEIPT = 0x0040;
379
380/// disable event after reporting
381pub const EV_DISPATCH = 0x0080;
382
383pub const EVFILT_READ = 0;
384pub const EVFILT_WRITE = 1;
385
386/// attached to aio requests
387pub const EVFILT_AIO = 2;
388
389/// attached to vnodes
390pub const EVFILT_VNODE = 3;
391
392/// attached to struct proc
393pub const EVFILT_PROC = 4;
394
395/// attached to struct proc
396pub const EVFILT_SIGNAL = 5;
397
398/// timers
399pub const EVFILT_TIMER = 6;
400
401/// Filesystem events
402pub const EVFILT_FS = 7;
403
404/// On input, NOTE_TRIGGER causes the event to be triggered for output.
405pub const NOTE_TRIGGER = 0x08000000;
406
407/// low water mark
408pub const NOTE_LOWAT = 0x00000001;
409
410/// vnode was removed
411pub const NOTE_DELETE = 0x00000001;
412
413/// data contents changed
414pub const NOTE_WRITE = 0x00000002;
415
416/// size increased
417pub const NOTE_EXTEND = 0x00000004;
418
419/// attributes changed
420pub const NOTE_ATTRIB = 0x00000008;
421
422/// link count changed
423pub const NOTE_LINK = 0x00000010;
424
425/// vnode was renamed
426pub const NOTE_RENAME = 0x00000020;
427
428/// vnode access was revoked
429pub const NOTE_REVOKE = 0x00000040;
430
431/// process exited
432pub const NOTE_EXIT = 0x80000000;
433
434/// process forked
435pub const NOTE_FORK = 0x40000000;
436
437/// process exec'd
438pub const NOTE_EXEC = 0x20000000;
439
440/// mask for signal & exit status
441pub const NOTE_PDATAMASK = 0x000fffff;
442pub const NOTE_PCTRLMASK = 0xf0000000;
443
444pub const TIOCCBRK = 0x2000747a;
445pub const TIOCCDTR = 0x20007478;
446pub const TIOCCONS = 0x80047462;
447pub const TIOCDCDTIMESTAMP = 0x40107458;
448pub const TIOCDRAIN = 0x2000745e;
449pub const TIOCEXCL = 0x2000740d;
450pub const TIOCEXT = 0x80047460;
451pub const TIOCFLAG_CDTRCTS = 0x10;
452pub const TIOCFLAG_CLOCAL = 0x2;
453pub const TIOCFLAG_CRTSCTS = 0x4;
454pub const TIOCFLAG_MDMBUF = 0x8;
455pub const TIOCFLAG_SOFTCAR = 0x1;
456pub const TIOCFLUSH = 0x80047410;
457pub const TIOCGETA = 0x402c7413;
458pub const TIOCGETD = 0x4004741a;
459pub const TIOCGFLAGS = 0x4004745d;
460pub const TIOCGLINED = 0x40207442;
461pub const TIOCGPGRP = 0x40047477;
462pub const TIOCGQSIZE = 0x40047481;
463pub const TIOCGRANTPT = 0x20007447;
464pub const TIOCGSID = 0x40047463;
465pub const TIOCGSIZE = 0x40087468;
466pub const TIOCGWINSZ = 0x40087468;
467pub const TIOCMBIC = 0x8004746b;
468pub const TIOCMBIS = 0x8004746c;
469pub const TIOCMGET = 0x4004746a;
470pub const TIOCMSET = 0x8004746d;
471pub const TIOCM_CAR = 0x40;
472pub const TIOCM_CD = 0x40;
473pub const TIOCM_CTS = 0x20;
474pub const TIOCM_DSR = 0x100;
475pub const TIOCM_DTR = 0x2;
476pub const TIOCM_LE = 0x1;
477pub const TIOCM_RI = 0x80;
478pub const TIOCM_RNG = 0x80;
479pub const TIOCM_RTS = 0x4;
480pub const TIOCM_SR = 0x10;
481pub const TIOCM_ST = 0x8;
482pub const TIOCNOTTY = 0x20007471;
483pub const TIOCNXCL = 0x2000740e;
484pub const TIOCOUTQ = 0x40047473;
485pub const TIOCPKT = 0x80047470;
486pub const TIOCPKT_DATA = 0x0;
487pub const TIOCPKT_DOSTOP = 0x20;
488pub const TIOCPKT_FLUSHREAD = 0x1;
489pub const TIOCPKT_FLUSHWRITE = 0x2;
490pub const TIOCPKT_IOCTL = 0x40;
491pub const TIOCPKT_NOSTOP = 0x10;
492pub const TIOCPKT_START = 0x8;
493pub const TIOCPKT_STOP = 0x4;
494pub const TIOCPTMGET = 0x40287446;
495pub const TIOCPTSNAME = 0x40287448;
496pub const TIOCRCVFRAME = 0x80087445;
497pub const TIOCREMOTE = 0x80047469;
498pub const TIOCSBRK = 0x2000747b;
499pub const TIOCSCTTY = 0x20007461;
500pub const TIOCSDTR = 0x20007479;
501pub const TIOCSETA = 0x802c7414;
502pub const TIOCSETAF = 0x802c7416;
503pub const TIOCSETAW = 0x802c7415;
504pub const TIOCSETD = 0x8004741b;
505pub const TIOCSFLAGS = 0x8004745c;
506pub const TIOCSIG = 0x2000745f;
507pub const TIOCSLINED = 0x80207443;
508pub const TIOCSPGRP = 0x80047476;
509pub const TIOCSQSIZE = 0x80047480;
510pub const TIOCSSIZE = 0x80087467;
511pub const TIOCSTART = 0x2000746e;
512pub const TIOCSTAT = 0x80047465;
513pub const TIOCSTI = 0x80017472;
514pub const TIOCSTOP = 0x2000746f;
515pub const TIOCSWINSZ = 0x80087467;
516pub const TIOCUCNTL = 0x80047466;
517pub const TIOCXMTFRAME = 0x80087444;
518
519fn unsigned(s: i32) u32 {
520 return @bitCast(u32, s);
521}
522fn signed(s: u32) i32 {
523 return @bitCast(i32, s);
524}
525pub fn WEXITSTATUS(s: i32) i32 {
526 return signed((unsigned(s) >> 8) & 0xff);
527}
528pub fn WTERMSIG(s: i32) i32 {
529 return signed(unsigned(s) & 0x7f);
530}
531pub fn WSTOPSIG(s: i32) i32 {
532 return WEXITSTATUS(s);
533}
534pub fn WIFEXITED(s: i32) bool {
535 return WTERMSIG(s) == 0;
536}
537
538pub fn WIFCONTINUED(s: i32) bool {
539 return ((s & 0x7f) == 0xffff);
540}
541
542pub fn WIFSTOPPED(s: i32) bool {
543 return ((s & 0x7f != 0x7f) and !WIFCONTINUED(s));
544}
545
546pub fn WIFSIGNALED(s: i32) bool {
547 return !WIFSTOPPED(s) and !WIFCONTINUED(s) and !WIFEXITED(s);
548}
549
550pub const winsize = extern struct {
551 ws_row: u16,
552 ws_col: u16,
553 ws_xpixel: u16,
554 ws_ypixel: u16,
555};
556
557const NSIG = 32;
558
559pub const SIG_ERR = @intToPtr(extern fn (i32) void, maxInt(usize));
560pub const SIG_DFL = @intToPtr(extern fn (i32) void, 0);
561pub const SIG_IGN = @intToPtr(extern fn (i32) void, 1);
562
563/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.
564pub const Sigaction = extern struct {
565 /// signal handler
566 __sigaction_u: extern union {
567 __sa_handler: extern fn (i32) void,
568 __sa_sigaction: extern fn (i32, *__siginfo, usize) void,
569 },
570
571 /// see signal options
572 sa_flags: u32,
573
574 /// signal mask to apply
575 sa_mask: sigset_t,
576};
577
578pub const _SIG_WORDS = 4;
579pub const _SIG_MAXSIG = 128;
580
581pub inline fn _SIG_IDX(sig: usize) usize {
582 return sig - 1;
583}
584pub inline fn _SIG_WORD(sig: usize) usize {
585 return_SIG_IDX(sig) >> 5;
586}
587pub inline fn _SIG_BIT(sig: usize) usize {
588 return 1 << (_SIG_IDX(sig) & 31);
589}
590pub inline fn _SIG_VALID(sig: usize) usize {
591 return sig <= _SIG_MAXSIG and sig > 0;
592}
593
594pub const sigset_t = extern struct {
595 __bits: [_SIG_WORDS]u32,
596};
597
598pub const EPERM = 1; // Operation not permitted
599pub const ENOENT = 2; // No such file or directory
600pub const ESRCH = 3; // No such process
601pub const EINTR = 4; // Interrupted system call
602pub const EIO = 5; // Input/output error
603pub const ENXIO = 6; // Device not configured
604pub const E2BIG = 7; // Argument list too long
605pub const ENOEXEC = 8; // Exec format error
606pub const EBADF = 9; // Bad file descriptor
607pub const ECHILD = 10; // No child processes
608pub const EDEADLK = 11; // Resource deadlock avoided
609// 11 was EAGAIN
610pub const ENOMEM = 12; // Cannot allocate memory
611pub const EACCES = 13; // Permission denied
612pub const EFAULT = 14; // Bad address
613pub const ENOTBLK = 15; // Block device required
614pub const EBUSY = 16; // Device busy
615pub const EEXIST = 17; // File exists
616pub const EXDEV = 18; // Cross-device link
617pub const ENODEV = 19; // Operation not supported by device
618pub const ENOTDIR = 20; // Not a directory
619pub const EISDIR = 21; // Is a directory
620pub const EINVAL = 22; // Invalid argument
621pub const ENFILE = 23; // Too many open files in system
622pub const EMFILE = 24; // Too many open files
623pub const ENOTTY = 25; // Inappropriate ioctl for device
624pub const ETXTBSY = 26; // Text file busy
625pub const EFBIG = 27; // File too large
626pub const ENOSPC = 28; // No space left on device
627pub const ESPIPE = 29; // Illegal seek
628pub const EROFS = 30; // Read-only file system
629pub const EMLINK = 31; // Too many links
630pub const EPIPE = 32; // Broken pipe
631
632// math software
633pub const EDOM = 33; // Numerical argument out of domain
634pub const ERANGE = 34; // Result too large or too small
635
636// non-blocking and interrupt i/o
637pub const EAGAIN = 35; // Resource temporarily unavailable
638pub const EWOULDBLOCK = EAGAIN; // Operation would block
639pub const EINPROGRESS = 36; // Operation now in progress
640pub const EALREADY = 37; // Operation already in progress
641
642// ipc/network software -- argument errors
643pub const ENOTSOCK = 38; // Socket operation on non-socket
644pub const EDESTADDRREQ = 39; // Destination address required
645pub const EMSGSIZE = 40; // Message too long
646pub const EPROTOTYPE = 41; // Protocol wrong type for socket
647pub const ENOPROTOOPT = 42; // Protocol option not available
648pub const EPROTONOSUPPORT = 43; // Protocol not supported
649pub const ESOCKTNOSUPPORT = 44; // Socket type not supported
650pub const EOPNOTSUPP = 45; // Operation not supported
651pub const EPFNOSUPPORT = 46; // Protocol family not supported
652pub const EAFNOSUPPORT = 47; // Address family not supported by protocol family
653pub const EADDRINUSE = 48; // Address already in use
654pub const EADDRNOTAVAIL = 49; // Can't assign requested address
655
656// ipc/network software -- operational errors
657pub const ENETDOWN = 50; // Network is down
658pub const ENETUNREACH = 51; // Network is unreachable
659pub const ENETRESET = 52; // Network dropped connection on reset
660pub const ECONNABORTED = 53; // Software caused connection abort
661pub const ECONNRESET = 54; // Connection reset by peer
662pub const ENOBUFS = 55; // No buffer space available
663pub const EISCONN = 56; // Socket is already connected
664pub const ENOTCONN = 57; // Socket is not connected
665pub const ESHUTDOWN = 58; // Can't send after socket shutdown
666pub const ETOOMANYREFS = 59; // Too many references: can't splice
667pub const ETIMEDOUT = 60; // Operation timed out
668pub const ECONNREFUSED = 61; // Connection refused
669
670pub const ELOOP = 62; // Too many levels of symbolic links
671pub const ENAMETOOLONG = 63; // File name too long
672
673// should be rearranged
674pub const EHOSTDOWN = 64; // Host is down
675pub const EHOSTUNREACH = 65; // No route to host
676pub const ENOTEMPTY = 66; // Directory not empty
677
678// quotas & mush
679pub const EPROCLIM = 67; // Too many processes
680pub const EUSERS = 68; // Too many users
681pub const EDQUOT = 69; // Disc quota exceeded
682
683// Network File System
684pub const ESTALE = 70; // Stale NFS file handle
685pub const EREMOTE = 71; // Too many levels of remote in path
686pub const EBADRPC = 72; // RPC struct is bad
687pub const ERPCMISMATCH = 73; // RPC version wrong
688pub const EPROGUNAVAIL = 74; // RPC prog. not avail
689pub const EPROGMISMATCH = 75; // Program version wrong
690pub const EPROCUNAVAIL = 76; // Bad procedure for program
691
692pub const ENOLCK = 77; // No locks available
693pub const ENOSYS = 78; // Function not implemented
694
695pub const EFTYPE = 79; // Inappropriate file type or format
696pub const EAUTH = 80; // Authentication error
697pub const ENEEDAUTH = 81; // Need authenticator
698
699// SystemV IPC
700pub const EIDRM = 82; // Identifier removed
701pub const ENOMSG = 83; // No message of desired type
702pub const EOVERFLOW = 84; // Value too large to be stored in data type
703
704// Wide/multibyte-character handling, ISO/IEC 9899/AMD1:1995
705pub const EILSEQ = 85; // Illegal byte sequence
706
707// From IEEE Std 1003.1-2001
708// Base, Realtime, Threads or Thread Priority Scheduling option errors
709pub const ENOTSUP = 86; // Not supported
710
711// Realtime option errors
712pub const ECANCELED = 87; // Operation canceled
713
714// Realtime, XSI STREAMS option errors
715pub const EBADMSG = 88; // Bad or Corrupt message
716
717// XSI STREAMS option errors
718pub const ENODATA = 89; // No message available
719pub const ENOSR = 90; // No STREAM resources
720pub const ENOSTR = 91; // Not a STREAM
721pub const ETIME = 92; // STREAM ioctl timeout
722
723// File system extended attribute errors
724pub const ENOATTR = 93; // Attribute not found
725
726// Realtime, XSI STREAMS option errors
727pub const EMULTIHOP = 94; // Multihop attempted
728pub const ENOLINK = 95; // Link has been severed
729pub const EPROTO = 96; // Protocol error
730
731pub const ELAST = 96; // Must equal largest errno
std/os/bits/wasi.zig created+320
...@@ -0,0 +1,320 @@
1// Declarations that are intended to be imported into the POSIX namespace.
2// This includes WASI-only APIs.
3
4pub const STDIN_FILENO = 0;
5pub const STDOUT_FILENO = 1;
6pub const STDERR_FILENO = 2;
7
8pub const advice_t = u8;
9pub const ADVICE_NORMAL: advice_t = 0;
10pub const ADVICE_SEQUENTIAL: advice_t = 1;
11pub const ADVICE_RANDOM: advice_t = 2;
12pub const ADVICE_WILLNEED: advice_t = 3;
13pub const ADVICE_DONTNEED: advice_t = 4;
14pub const ADVICE_NOREUSE: advice_t = 5;
15
16pub const ciovec_t = extern struct {
17 buf: [*]const u8,
18 buf_len: usize,
19};
20
21pub const clockid_t = u32;
22pub const CLOCK_REALTIME: clockid_t = 0;
23pub const CLOCK_MONOTONIC: clockid_t = 1;
24pub const CLOCK_PROCESS_CPUTIME_ID: clockid_t = 2;
25pub const CLOCK_THREAD_CPUTIME_ID: clockid_t = 3;
26
27pub const device_t = u64;
28
29pub const dircookie_t = u64;
30pub const DIRCOOKIE_START: dircookie_t = 0;
31
32pub const dirent_t = extern struct {
33 d_next: dircookie_t,
34 d_ino: inode_t,
35 d_namlen: u32,
36 d_type: filetype_t,
37};
38
39pub const errno_t = u16;
40pub const ESUCCESS: errno_t = 0;
41pub const E2BIG: errno_t = 1;
42pub const EACCES: errno_t = 2;
43pub const EADDRINUSE: errno_t = 3;
44pub const EADDRNOTAVAIL: errno_t = 4;
45pub const EAFNOSUPPORT: errno_t = 5;
46pub const EAGAIN: errno_t = 6;
47pub const EALREADY: errno_t = 7;
48pub const EBADF: errno_t = 8;
49pub const EBADMSG: errno_t = 9;
50pub const EBUSY: errno_t = 10;
51pub const ECANCELED: errno_t = 11;
52pub const ECHILD: errno_t = 12;
53pub const ECONNABORTED: errno_t = 13;
54pub const ECONNREFUSED: errno_t = 14;
55pub const ECONNRESET: errno_t = 15;
56pub const EDEADLK: errno_t = 16;
57pub const EDESTADDRREQ: errno_t = 17;
58pub const EDOM: errno_t = 18;
59pub const EDQUOT: errno_t = 19;
60pub const EEXIST: errno_t = 20;
61pub const EFAULT: errno_t = 21;
62pub const EFBIG: errno_t = 22;
63pub const EHOSTUNREACH: errno_t = 23;
64pub const EIDRM: errno_t = 24;
65pub const EILSEQ: errno_t = 25;
66pub const EINPROGRESS: errno_t = 26;
67pub const EINTR: errno_t = 27;
68pub const EINVAL: errno_t = 28;
69pub const EIO: errno_t = 29;
70pub const EISCONN: errno_t = 30;
71pub const EISDIR: errno_t = 31;
72pub const ELOOP: errno_t = 32;
73pub const EMFILE: errno_t = 33;
74pub const EMLINK: errno_t = 34;
75pub const EMSGSIZE: errno_t = 35;
76pub const EMULTIHOP: errno_t = 36;
77pub const ENAMETOOLONG: errno_t = 37;
78pub const ENETDOWN: errno_t = 38;
79pub const ENETRESET: errno_t = 39;
80pub const ENETUNREACH: errno_t = 40;
81pub const ENFILE: errno_t = 41;
82pub const ENOBUFS: errno_t = 42;
83pub const ENODEV: errno_t = 43;
84pub const ENOENT: errno_t = 44;
85pub const ENOEXEC: errno_t = 45;
86pub const ENOLCK: errno_t = 46;
87pub const ENOLINK: errno_t = 47;
88pub const ENOMEM: errno_t = 48;
89pub const ENOMSG: errno_t = 49;
90pub const ENOPROTOOPT: errno_t = 50;
91pub const ENOSPC: errno_t = 51;
92pub const ENOSYS: errno_t = 52;
93pub const ENOTCONN: errno_t = 53;
94pub const ENOTDIR: errno_t = 54;
95pub const ENOTEMPTY: errno_t = 55;
96pub const ENOTRECOVERABLE: errno_t = 56;
97pub const ENOTSOCK: errno_t = 57;
98pub const ENOTSUP: errno_t = 58;
99pub const ENOTTY: errno_t = 59;
100pub const ENXIO: errno_t = 60;
101pub const EOVERFLOW: errno_t = 61;
102pub const EOWNERDEAD: errno_t = 62;
103pub const EPERM: errno_t = 63;
104pub const EPIPE: errno_t = 64;
105pub const EPROTO: errno_t = 65;
106pub const EPROTONOSUPPORT: errno_t = 66;
107pub const EPROTOTYPE: errno_t = 67;
108pub const ERANGE: errno_t = 68;
109pub const EROFS: errno_t = 69;
110pub const ESPIPE: errno_t = 70;
111pub const ESRCH: errno_t = 71;
112pub const ESTALE: errno_t = 72;
113pub const ETIMEDOUT: errno_t = 73;
114pub const ETXTBSY: errno_t = 74;
115pub const EXDEV: errno_t = 75;
116pub const ENOTCAPABLE: errno_t = 76;
117
118pub const event_t = extern struct {
119 userdata: userdata_t,
120 @"error": errno_t,
121 @"type": eventtype_t,
122 u: extern union {
123 fd_readwrite: extern struct {
124 nbytes: filesize_t,
125 flags: eventrwflags_t,
126 },
127 },
128};
129
130pub const eventrwflags_t = u16;
131pub const EVENT_FD_READWRITE_HANGUP: eventrwflags_t = 0x0001;
132
133pub const eventtype_t = u8;
134pub const EVENTTYPE_CLOCK: eventtype_t = 0;
135pub const EVENTTYPE_FD_READ: eventtype_t = 1;
136pub const EVENTTYPE_FD_WRITE: eventtype_t = 2;
137
138pub const exitcode_t = u32;
139
140pub const fd_t = u32;
141
142pub const fdflags_t = u16;
143pub const FDFLAG_APPEND: fdflags_t = 0x0001;
144pub const FDFLAG_DSYNC: fdflags_t = 0x0002;
145pub const FDFLAG_NONBLOCK: fdflags_t = 0x0004;
146pub const FDFLAG_RSYNC: fdflags_t = 0x0008;
147pub const FDFLAG_SYNC: fdflags_t = 0x0010;
148
149const fdstat_t = extern struct {
150 fs_filetype: filetype_t,
151 fs_flags: fdflags_t,
152 fs_rights_base: rights_t,
153 fs_rights_inheriting: rights_t,
154};
155
156pub const filedelta_t = i64;
157
158pub const filesize_t = u64;
159
160pub const filestat_t = extern struct {
161 st_dev: device_t,
162 st_ino: inode_t,
163 st_filetype: filetype_t,
164 st_nlink: linkcount_t,
165 st_size: filesize_t,
166 st_atim: timestamp_t,
167 st_mtim: timestamp_t,
168 st_ctim: timestamp_t,
169};
170
171pub const filetype_t = u8;
172pub const FILETYPE_UNKNOWN: filetype_t = 0;
173pub const FILETYPE_BLOCK_DEVICE: filetype_t = 1;
174pub const FILETYPE_CHARACTER_DEVICE: filetype_t = 2;
175pub const FILETYPE_DIRECTORY: filetype_t = 3;
176pub const FILETYPE_REGULAR_FILE: filetype_t = 4;
177pub const FILETYPE_SOCKET_DGRAM: filetype_t = 5;
178pub const FILETYPE_SOCKET_STREAM: filetype_t = 6;
179pub const FILETYPE_SYMBOLIC_LINK: filetype_t = 7;
180
181pub const fstflags_t = u16;
182pub const FILESTAT_SET_ATIM: fstflags_t = 0x0001;
183pub const FILESTAT_SET_ATIM_NOW: fstflags_t = 0x0002;
184pub const FILESTAT_SET_MTIM: fstflags_t = 0x0004;
185pub const FILESTAT_SET_MTIM_NOW: fstflags_t = 0x0008;
186
187pub const inode_t = u64;
188
189pub const iovec_t = extern struct {
190 buf: [*]u8,
191 buf_len: usize,
192};
193
194pub const linkcount_t = u32;
195
196pub const lookupflags_t = u32;
197pub const LOOKUP_SYMLINK_FOLLOW: lookupflags_t = 0x00000001;
198
199pub const oflags_t = u16;
200pub const O_CREAT: oflags_t = 0x0001;
201pub const O_DIRECTORY: oflags_t = 0x0002;
202pub const O_EXCL: oflags_t = 0x0004;
203pub const O_TRUNC: oflags_t = 0x0008;
204
205pub const preopentype_t = u8;
206pub const PREOPENTYPE_DIR: preopentype_t = 0;
207
208pub const prestat_t = extern struct {
209 pr_type: preopentype_t,
210 u: extern union {
211 dir: extern struct {
212 pr_name_len: usize,
213 },
214 },
215};
216
217pub const riflags_t = u16;
218pub const SOCK_RECV_PEEK: riflags_t = 0x0001;
219pub const SOCK_RECV_WAITALL: riflags_t = 0x0002;
220
221pub const rights_t = u64;
222pub const RIGHT_FD_DATASYNC: rights_t = 0x0000000000000001;
223pub const RIGHT_FD_READ: rights_t = 0x0000000000000002;
224pub const RIGHT_FD_SEEK: rights_t = 0x0000000000000004;
225pub const RIGHT_FD_FDSTAT_SET_FLAGS: rights_t = 0x0000000000000008;
226pub const RIGHT_FD_SYNC: rights_t = 0x0000000000000010;
227pub const RIGHT_FD_TELL: rights_t = 0x0000000000000020;
228pub const RIGHT_FD_WRITE: rights_t = 0x0000000000000040;
229pub const RIGHT_FD_ADVISE: rights_t = 0x0000000000000080;
230pub const RIGHT_FD_ALLOCATE: rights_t = 0x0000000000000100;
231pub const RIGHT_PATH_CREATE_DIRECTORY: rights_t = 0x0000000000000200;
232pub const RIGHT_PATH_CREATE_FILE: rights_t = 0x0000000000000400;
233pub const RIGHT_PATH_LINK_SOURCE: rights_t = 0x0000000000000800;
234pub const RIGHT_PATH_LINK_TARGET: rights_t = 0x0000000000001000;
235pub const RIGHT_PATH_OPEN: rights_t = 0x0000000000002000;
236pub const RIGHT_FD_READDIR: rights_t = 0x0000000000004000;
237pub const RIGHT_PATH_READLINK: rights_t = 0x0000000000008000;
238pub const RIGHT_PATH_RENAME_SOURCE: rights_t = 0x0000000000010000;
239pub const RIGHT_PATH_RENAME_TARGET: rights_t = 0x0000000000020000;
240pub const RIGHT_PATH_FILESTAT_GET: rights_t = 0x0000000000040000;
241pub const RIGHT_PATH_FILESTAT_SET_SIZE: rights_t = 0x0000000000080000;
242pub const RIGHT_PATH_FILESTAT_SET_TIMES: rights_t = 0x0000000000100000;
243pub const RIGHT_FD_FILESTAT_GET: rights_t = 0x0000000000200000;
244pub const RIGHT_FD_FILESTAT_SET_SIZE: rights_t = 0x0000000000400000;
245pub const RIGHT_FD_FILESTAT_SET_TIMES: rights_t = 0x0000000000800000;
246pub const RIGHT_PATH_SYMLINK: rights_t = 0x0000000001000000;
247pub const RIGHT_PATH_REMOVE_DIRECTORY: rights_t = 0x0000000002000000;
248pub const RIGHT_PATH_UNLINK_FILE: rights_t = 0x0000000004000000;
249pub const RIGHT_POLL_FD_READWRITE: rights_t = 0x0000000008000000;
250pub const RIGHT_SOCK_SHUTDOWN: rights_t = 0x0000000010000000;
251
252pub const roflags_t = u16;
253pub const SOCK_RECV_DATA_TRUNCATED: roflags_t = 0x0001;
254
255pub const sdflags_t = u8;
256pub const SHUT_RD: sdflags_t = 0x01;
257pub const SHUT_WR: sdflags_t = 0x02;
258
259pub const siflags_t = u16;
260
261pub const signal_t = u8;
262pub const SIGHUP: signal_t = 1;
263pub const SIGINT: signal_t = 2;
264pub const SIGQUIT: signal_t = 3;
265pub const SIGILL: signal_t = 4;
266pub const SIGTRAP: signal_t = 5;
267pub const SIGABRT: signal_t = 6;
268pub const SIGBUS: signal_t = 7;
269pub const SIGFPE: signal_t = 8;
270pub const SIGKILL: signal_t = 9;
271pub const SIGUSR1: signal_t = 10;
272pub const SIGSEGV: signal_t = 11;
273pub const SIGUSR2: signal_t = 12;
274pub const SIGPIPE: signal_t = 13;
275pub const SIGALRM: signal_t = 14;
276pub const SIGTERM: signal_t = 15;
277pub const SIGCHLD: signal_t = 16;
278pub const SIGCONT: signal_t = 17;
279pub const SIGSTOP: signal_t = 18;
280pub const SIGTSTP: signal_t = 19;
281pub const SIGTTIN: signal_t = 20;
282pub const SIGTTOU: signal_t = 21;
283pub const SIGURG: signal_t = 22;
284pub const SIGXCPU: signal_t = 23;
285pub const SIGXFSZ: signal_t = 24;
286pub const SIGVTALRM: signal_t = 25;
287pub const SIGPROF: signal_t = 26;
288pub const SIGWINCH: signal_t = 27;
289pub const SIGPOLL: signal_t = 28;
290pub const SIGPWR: signal_t = 29;
291pub const SIGSYS: signal_t = 30;
292
293pub const subclockflags_t = u16;
294pub const SUBSCRIPTION_CLOCK_ABSTIME: subclockflags_t = 0x0001;
295
296pub const subscription_t = extern struct {
297 userdata: userdata_t,
298 @"type": eventtype_t,
299 u: extern union {
300 clock: extern struct {
301 identifier: userdata_t,
302 clock_id: clockid_t,
303 timeout: timestamp_t,
304 precision: timestamp_t,
305 flags: subclockflags_t,
306 },
307 fd_readwrite: extern struct {
308 fd: fd_t,
309 },
310 },
311};
312
313pub const timestamp_t = u64;
314
315pub const userdata_t = u64;
316
317pub const whence_t = u8;
318pub const WHENCE_CUR: whence_t = 0;
319pub const WHENCE_END: whence_t = 1;
320pub const WHENCE_SET: whence_t = 2;
std/os/bits/windows.zig created+91
...@@ -0,0 +1,91 @@
1use @import("../windows.zig");
2
3pub const fd_t = HANDLE;
4pub const pid_t = HANDLE;
5
6pub const EPERM = 1;
7pub const ENOENT = 2;
8pub const ESRCH = 3;
9pub const EINTR = 4;
10pub const EIO = 5;
11pub const ENXIO = 6;
12pub const E2BIG = 7;
13pub const ENOEXEC = 8;
14pub const EBADF = 9;
15pub const ECHILD = 10;
16pub const EAGAIN = 11;
17pub const ENOMEM = 12;
18pub const EACCES = 13;
19pub const EFAULT = 14;
20pub const EBUSY = 16;
21pub const EEXIST = 17;
22pub const EXDEV = 18;
23pub const ENODEV = 19;
24pub const ENOTDIR = 20;
25pub const EISDIR = 21;
26pub const ENFILE = 23;
27pub const EMFILE = 24;
28pub const ENOTTY = 25;
29pub const EFBIG = 27;
30pub const ENOSPC = 28;
31pub const ESPIPE = 29;
32pub const EROFS = 30;
33pub const EMLINK = 31;
34pub const EPIPE = 32;
35pub const EDOM = 33;
36pub const EDEADLK = 36;
37pub const ENAMETOOLONG = 38;
38pub const ENOLCK = 39;
39pub const ENOSYS = 40;
40pub const ENOTEMPTY = 41;
41
42pub const EINVAL = 22;
43pub const ERANGE = 34;
44pub const EILSEQ = 42;
45pub const STRUNCATE = 80;
46
47// Support EDEADLOCK for compatibility with older Microsoft C versions
48pub const EDEADLOCK = EDEADLK;
49
50// POSIX Supplement
51pub const EADDRINUSE = 100;
52pub const EADDRNOTAVAIL = 101;
53pub const EAFNOSUPPORT = 102;
54pub const EALREADY = 103;
55pub const EBADMSG = 104;
56pub const ECANCELED = 105;
57pub const ECONNABORTED = 106;
58pub const ECONNREFUSED = 107;
59pub const ECONNRESET = 108;
60pub const EDESTADDRREQ = 109;
61pub const EHOSTUNREACH = 110;
62pub const EIDRM = 111;
63pub const EINPROGRESS = 112;
64pub const EISCONN = 113;
65pub const ELOOP = 114;
66pub const EMSGSIZE = 115;
67pub const ENETDOWN = 116;
68pub const ENETRESET = 117;
69pub const ENETUNREACH = 118;
70pub const ENOBUFS = 119;
71pub const ENODATA = 120;
72pub const ENOLINK = 121;
73pub const ENOMSG = 122;
74pub const ENOPROTOOPT = 123;
75pub const ENOSR = 124;
76pub const ENOSTR = 125;
77pub const ENOTCONN = 126;
78pub const ENOTRECOVERABLE = 127;
79pub const ENOTSOCK = 128;
80pub const ENOTSUP = 129;
81pub const EOPNOTSUPP = 130;
82pub const EOTHER = 131;
83pub const EOVERFLOW = 132;
84pub const EOWNERDEAD = 133;
85pub const EPROTO = 134;
86pub const EPROTONOSUPPORT = 135;
87pub const EPROTOTYPE = 136;
88pub const ETIME = 137;
89pub const ETIMEDOUT = 138;
90pub const ETXTBSY = 139;
91pub const EWOULDBLOCK = 140;
std/os/linux.zig+1-1
...@@ -4,7 +4,7 @@ pub const is_the_target = builtin.os == .linux;...@@ -4,7 +4,7 @@ pub const is_the_target = builtin.os == .linux;
4pub const sys = @import("linux/sys.zig");4pub const sys = @import("linux/sys.zig");
5pub use if (builtin.link_libc) std.c else sys;5pub use if (builtin.link_libc) std.c else sys;
66
7test "import" {7test "" {
8 if (is_the_target) {8 if (is_the_target) {
9 _ = @import("linux/test.zig");9 _ = @import("linux/test.zig");
10 }10 }
std/os/linux/errno.zig deleted-427
...@@ -1,427 +0,0 @@
1/// Operation not permitted
2pub const EPERM = 1;
3
4/// No such file or directory
5pub const ENOENT = 2;
6
7/// No such process
8pub const ESRCH = 3;
9
10/// Interrupted system call
11pub const EINTR = 4;
12
13/// I/O error
14pub const EIO = 5;
15
16/// No such device or address
17pub const ENXIO = 6;
18
19/// Arg list too long
20pub const E2BIG = 7;
21
22/// Exec format error
23pub const ENOEXEC = 8;
24
25/// Bad file number
26pub const EBADF = 9;
27
28/// No child processes
29pub const ECHILD = 10;
30
31/// Try again
32pub const EAGAIN = 11;
33
34/// Out of memory
35pub const ENOMEM = 12;
36
37/// Permission denied
38pub const EACCES = 13;
39
40/// Bad address
41pub const EFAULT = 14;
42
43/// Block device required
44pub const ENOTBLK = 15;
45
46/// Device or resource busy
47pub const EBUSY = 16;
48
49/// File exists
50pub const EEXIST = 17;
51
52/// Cross-device link
53pub const EXDEV = 18;
54
55/// No such device
56pub const ENODEV = 19;
57
58/// Not a directory
59pub const ENOTDIR = 20;
60
61/// Is a directory
62pub const EISDIR = 21;
63
64/// Invalid argument
65pub const EINVAL = 22;
66
67/// File table overflow
68pub const ENFILE = 23;
69
70/// Too many open files
71pub const EMFILE = 24;
72
73/// Not a typewriter
74pub const ENOTTY = 25;
75
76/// Text file busy
77pub const ETXTBSY = 26;
78
79/// File too large
80pub const EFBIG = 27;
81
82/// No space left on device
83pub const ENOSPC = 28;
84
85/// Illegal seek
86pub const ESPIPE = 29;
87
88/// Read-only file system
89pub const EROFS = 30;
90
91/// Too many links
92pub const EMLINK = 31;
93
94/// Broken pipe
95pub const EPIPE = 32;
96
97/// Math argument out of domain of func
98pub const EDOM = 33;
99
100/// Math result not representable
101pub const ERANGE = 34;
102
103/// Resource deadlock would occur
104pub const EDEADLK = 35;
105
106/// File name too long
107pub const ENAMETOOLONG = 36;
108
109/// No record locks available
110pub const ENOLCK = 37;
111
112/// Function not implemented
113pub const ENOSYS = 38;
114
115/// Directory not empty
116pub const ENOTEMPTY = 39;
117
118/// Too many symbolic links encountered
119pub const ELOOP = 40;
120
121/// Operation would block
122pub const EWOULDBLOCK = EAGAIN;
123
124/// No message of desired type
125pub const ENOMSG = 42;
126
127/// Identifier removed
128pub const EIDRM = 43;
129
130/// Channel number out of range
131pub const ECHRNG = 44;
132
133/// Level 2 not synchronized
134pub const EL2NSYNC = 45;
135
136/// Level 3 halted
137pub const EL3HLT = 46;
138
139/// Level 3 reset
140pub const EL3RST = 47;
141
142/// Link number out of range
143pub const ELNRNG = 48;
144
145/// Protocol driver not attached
146pub const EUNATCH = 49;
147
148/// No CSI structure available
149pub const ENOCSI = 50;
150
151/// Level 2 halted
152pub const EL2HLT = 51;
153
154/// Invalid exchange
155pub const EBADE = 52;
156
157/// Invalid request descriptor
158pub const EBADR = 53;
159
160/// Exchange full
161pub const EXFULL = 54;
162
163/// No anode
164pub const ENOANO = 55;
165
166/// Invalid request code
167pub const EBADRQC = 56;
168
169/// Invalid slot
170pub const EBADSLT = 57;
171
172/// Bad font file format
173pub const EBFONT = 59;
174
175/// Device not a stream
176pub const ENOSTR = 60;
177
178/// No data available
179pub const ENODATA = 61;
180
181/// Timer expired
182pub const ETIME = 62;
183
184/// Out of streams resources
185pub const ENOSR = 63;
186
187/// Machine is not on the network
188pub const ENONET = 64;
189
190/// Package not installed
191pub const ENOPKG = 65;
192
193/// Object is remote
194pub const EREMOTE = 66;
195
196/// Link has been severed
197pub const ENOLINK = 67;
198
199/// Advertise error
200pub const EADV = 68;
201
202/// Srmount error
203pub const ESRMNT = 69;
204
205/// Communication error on send
206pub const ECOMM = 70;
207
208/// Protocol error
209pub const EPROTO = 71;
210
211/// Multihop attempted
212pub const EMULTIHOP = 72;
213
214/// RFS specific error
215pub const EDOTDOT = 73;
216
217/// Not a data message
218pub const EBADMSG = 74;
219
220/// Value too large for defined data type
221pub const EOVERFLOW = 75;
222
223/// Name not unique on network
224pub const ENOTUNIQ = 76;
225
226/// File descriptor in bad state
227pub const EBADFD = 77;
228
229/// Remote address changed
230pub const EREMCHG = 78;
231
232/// Can not access a needed shared library
233pub const ELIBACC = 79;
234
235/// Accessing a corrupted shared library
236pub const ELIBBAD = 80;
237
238/// .lib section in a.out corrupted
239pub const ELIBSCN = 81;
240
241/// Attempting to link in too many shared libraries
242pub const ELIBMAX = 82;
243
244/// Cannot exec a shared library directly
245pub const ELIBEXEC = 83;
246
247/// Illegal byte sequence
248pub const EILSEQ = 84;
249
250/// Interrupted system call should be restarted
251pub const ERESTART = 85;
252
253/// Streams pipe error
254pub const ESTRPIPE = 86;
255
256/// Too many users
257pub const EUSERS = 87;
258
259/// Socket operation on non-socket
260pub const ENOTSOCK = 88;
261
262/// Destination address required
263pub const EDESTADDRREQ = 89;
264
265/// Message too long
266pub const EMSGSIZE = 90;
267
268/// Protocol wrong type for socket
269pub const EPROTOTYPE = 91;
270
271/// Protocol not available
272pub const ENOPROTOOPT = 92;
273
274/// Protocol not supported
275pub const EPROTONOSUPPORT = 93;
276
277/// Socket type not supported
278pub const ESOCKTNOSUPPORT = 94;
279
280/// Operation not supported on transport endpoint
281pub const EOPNOTSUPP = 95;
282
283/// Protocol family not supported
284pub const EPFNOSUPPORT = 96;
285
286/// Address family not supported by protocol
287pub const EAFNOSUPPORT = 97;
288
289/// Address already in use
290pub const EADDRINUSE = 98;
291
292/// Cannot assign requested address
293pub const EADDRNOTAVAIL = 99;
294
295/// Network is down
296pub const ENETDOWN = 100;
297
298/// Network is unreachable
299pub const ENETUNREACH = 101;
300
301/// Network dropped connection because of reset
302pub const ENETRESET = 102;
303
304/// Software caused connection abort
305pub const ECONNABORTED = 103;
306
307/// Connection reset by peer
308pub const ECONNRESET = 104;
309
310/// No buffer space available
311pub const ENOBUFS = 105;
312
313/// Transport endpoint is already connected
314pub const EISCONN = 106;
315
316/// Transport endpoint is not connected
317pub const ENOTCONN = 107;
318
319/// Cannot send after transport endpoint shutdown
320pub const ESHUTDOWN = 108;
321
322/// Too many references: cannot splice
323pub const ETOOMANYREFS = 109;
324
325/// Connection timed out
326pub const ETIMEDOUT = 110;
327
328/// Connection refused
329pub const ECONNREFUSED = 111;
330
331/// Host is down
332pub const EHOSTDOWN = 112;
333
334/// No route to host
335pub const EHOSTUNREACH = 113;
336
337/// Operation already in progress
338pub const EALREADY = 114;
339
340/// Operation now in progress
341pub const EINPROGRESS = 115;
342
343/// Stale NFS file handle
344pub const ESTALE = 116;
345
346/// Structure needs cleaning
347pub const EUCLEAN = 117;
348
349/// Not a XENIX named type file
350pub const ENOTNAM = 118;
351
352/// No XENIX semaphores available
353pub const ENAVAIL = 119;
354
355/// Is a named type file
356pub const EISNAM = 120;
357
358/// Remote I/O error
359pub const EREMOTEIO = 121;
360
361/// Quota exceeded
362pub const EDQUOT = 122;
363
364/// No medium found
365pub const ENOMEDIUM = 123;
366
367/// Wrong medium type
368pub const EMEDIUMTYPE = 124;
369
370// nameserver query return codes
371
372/// DNS server returned answer with no data
373pub const ENSROK = 0;
374
375/// DNS server returned answer with no data
376pub const ENSRNODATA = 160;
377
378/// DNS server claims query was misformatted
379pub const ENSRFORMERR = 161;
380
381/// DNS server returned general failure
382pub const ENSRSERVFAIL = 162;
383
384/// Domain name not found
385pub const ENSRNOTFOUND = 163;
386
387/// DNS server does not implement requested operation
388pub const ENSRNOTIMP = 164;
389
390/// DNS server refused query
391pub const ENSRREFUSED = 165;
392
393/// Misformatted DNS query
394pub const ENSRBADQUERY = 166;
395
396/// Misformatted domain name
397pub const ENSRBADNAME = 167;
398
399/// Unsupported address family
400pub const ENSRBADFAMILY = 168;
401
402/// Misformatted DNS reply
403pub const ENSRBADRESP = 169;
404
405/// Could not contact DNS servers
406pub const ENSRCONNREFUSED = 170;
407
408/// Timeout while contacting DNS servers
409pub const ENSRTIMEOUT = 171;
410
411/// End of file
412pub const ENSROF = 172;
413
414/// Error reading file
415pub const ENSRFILE = 173;
416
417/// Out of memory
418pub const ENSRNOMEM = 174;
419
420/// Application terminated lookup
421pub const ENSRDESTRUCTION = 175;
422
423/// Domain name is too long
424pub const ENSRQUERYDOMAINTOOLONG = 176;
425
426/// Domain name is too long
427pub const ENSRCNAMELOOP = 177;
std/os/linux/posix.zig deleted-917
...@@ -1,917 +0,0 @@
1// Declarations that are intended to be imported into the POSIX namespace.
2// This includes Linux-only APIs.
3
4pub use @import("errno.zig");
5pub use switch (builtin.arch) {
6 .x86_64 => @import("posix/x86_64.zig"),
7 .aarch64 => @import("posix/arm64.zig"),
8 else => struct {},
9};
10
11pub const pid_t = i32;
12pub const fd_t = i32;
13
14pub const PATH_MAX = 4096;
15pub const IOV_MAX = 1024;
16
17pub const STDIN_FILENO = 0;
18pub const STDOUT_FILENO = 1;
19pub const STDERR_FILENO = 2;
20
21pub const FUTEX_WAIT = 0;
22pub const FUTEX_WAKE = 1;
23pub const FUTEX_FD = 2;
24pub const FUTEX_REQUEUE = 3;
25pub const FUTEX_CMP_REQUEUE = 4;
26pub const FUTEX_WAKE_OP = 5;
27pub const FUTEX_LOCK_PI = 6;
28pub const FUTEX_UNLOCK_PI = 7;
29pub const FUTEX_TRYLOCK_PI = 8;
30pub const FUTEX_WAIT_BITSET = 9;
31
32pub const FUTEX_PRIVATE_FLAG = 128;
33
34pub const FUTEX_CLOCK_REALTIME = 256;
35
36pub const PROT_NONE = 0;
37pub const PROT_READ = 1;
38pub const PROT_WRITE = 2;
39pub const PROT_EXEC = 4;
40pub const PROT_GROWSDOWN = 0x01000000;
41pub const PROT_GROWSUP = 0x02000000;
42
43pub const MAP_FAILED = maxInt(usize);
44pub const MAP_SHARED = 0x01;
45pub const MAP_PRIVATE = 0x02;
46pub const MAP_TYPE = 0x0f;
47pub const MAP_FIXED = 0x10;
48pub const MAP_ANONYMOUS = 0x20;
49pub const MAP_NORESERVE = 0x4000;
50pub const MAP_GROWSDOWN = 0x0100;
51pub const MAP_DENYWRITE = 0x0800;
52pub const MAP_EXECUTABLE = 0x1000;
53pub const MAP_LOCKED = 0x2000;
54pub const MAP_POPULATE = 0x8000;
55pub const MAP_NONBLOCK = 0x10000;
56pub const MAP_STACK = 0x20000;
57pub const MAP_HUGETLB = 0x40000;
58pub const MAP_FILE = 0;
59
60pub const F_OK = 0;
61pub const X_OK = 1;
62pub const W_OK = 2;
63pub const R_OK = 4;
64
65pub const WNOHANG = 1;
66pub const WUNTRACED = 2;
67pub const WSTOPPED = 2;
68pub const WEXITED = 4;
69pub const WCONTINUED = 8;
70pub const WNOWAIT = 0x1000000;
71
72pub const SA_NOCLDSTOP = 1;
73pub const SA_NOCLDWAIT = 2;
74pub const SA_SIGINFO = 4;
75pub const SA_ONSTACK = 0x08000000;
76pub const SA_RESTART = 0x10000000;
77pub const SA_NODEFER = 0x40000000;
78pub const SA_RESETHAND = 0x80000000;
79pub const SA_RESTORER = 0x04000000;
80
81pub const SIGHUP = 1;
82pub const SIGINT = 2;
83pub const SIGQUIT = 3;
84pub const SIGILL = 4;
85pub const SIGTRAP = 5;
86pub const SIGABRT = 6;
87pub const SIGIOT = SIGABRT;
88pub const SIGBUS = 7;
89pub const SIGFPE = 8;
90pub const SIGKILL = 9;
91pub const SIGUSR1 = 10;
92pub const SIGSEGV = 11;
93pub const SIGUSR2 = 12;
94pub const SIGPIPE = 13;
95pub const SIGALRM = 14;
96pub const SIGTERM = 15;
97pub const SIGSTKFLT = 16;
98pub const SIGCHLD = 17;
99pub const SIGCONT = 18;
100pub const SIGSTOP = 19;
101pub const SIGTSTP = 20;
102pub const SIGTTIN = 21;
103pub const SIGTTOU = 22;
104pub const SIGURG = 23;
105pub const SIGXCPU = 24;
106pub const SIGXFSZ = 25;
107pub const SIGVTALRM = 26;
108pub const SIGPROF = 27;
109pub const SIGWINCH = 28;
110pub const SIGIO = 29;
111pub const SIGPOLL = 29;
112pub const SIGPWR = 30;
113pub const SIGSYS = 31;
114pub const SIGUNUSED = SIGSYS;
115
116pub const O_RDONLY = 0o0;
117pub const O_WRONLY = 0o1;
118pub const O_RDWR = 0o2;
119
120pub const SEEK_SET = 0;
121pub const SEEK_CUR = 1;
122pub const SEEK_END = 2;
123
124pub const SIG_BLOCK = 0;
125pub const SIG_UNBLOCK = 1;
126pub const SIG_SETMASK = 2;
127
128pub const PROTO_ip = 0o000;
129pub const PROTO_icmp = 0o001;
130pub const PROTO_igmp = 0o002;
131pub const PROTO_ggp = 0o003;
132pub const PROTO_ipencap = 0o004;
133pub const PROTO_st = 0o005;
134pub const PROTO_tcp = 0o006;
135pub const PROTO_egp = 0o010;
136pub const PROTO_pup = 0o014;
137pub const PROTO_udp = 0o021;
138pub const PROTO_hmp = 0o024;
139pub const PROTO_xns_idp = 0o026;
140pub const PROTO_rdp = 0o033;
141pub const PROTO_iso_tp4 = 0o035;
142pub const PROTO_xtp = 0o044;
143pub const PROTO_ddp = 0o045;
144pub const PROTO_idpr_cmtp = 0o046;
145pub const PROTO_ipv6 = 0o051;
146pub const PROTO_ipv6_route = 0o053;
147pub const PROTO_ipv6_frag = 0o054;
148pub const PROTO_idrp = 0o055;
149pub const PROTO_rsvp = 0o056;
150pub const PROTO_gre = 0o057;
151pub const PROTO_esp = 0o062;
152pub const PROTO_ah = 0o063;
153pub const PROTO_skip = 0o071;
154pub const PROTO_ipv6_icmp = 0o072;
155pub const PROTO_ipv6_nonxt = 0o073;
156pub const PROTO_ipv6_opts = 0o074;
157pub const PROTO_rspf = 0o111;
158pub const PROTO_vmtp = 0o121;
159pub const PROTO_ospf = 0o131;
160pub const PROTO_ipip = 0o136;
161pub const PROTO_encap = 0o142;
162pub const PROTO_pim = 0o147;
163pub const PROTO_raw = 0o377;
164
165pub const SHUT_RD = 0;
166pub const SHUT_WR = 1;
167pub const SHUT_RDWR = 2;
168
169pub const SOCK_STREAM = 1;
170pub const SOCK_DGRAM = 2;
171pub const SOCK_RAW = 3;
172pub const SOCK_RDM = 4;
173pub const SOCK_SEQPACKET = 5;
174pub const SOCK_DCCP = 6;
175pub const SOCK_PACKET = 10;
176pub const SOCK_CLOEXEC = 0o2000000;
177pub const SOCK_NONBLOCK = 0o4000;
178
179pub const PF_UNSPEC = 0;
180pub const PF_LOCAL = 1;
181pub const PF_UNIX = PF_LOCAL;
182pub const PF_FILE = PF_LOCAL;
183pub const PF_INET = 2;
184pub const PF_AX25 = 3;
185pub const PF_IPX = 4;
186pub const PF_APPLETALK = 5;
187pub const PF_NETROM = 6;
188pub const PF_BRIDGE = 7;
189pub const PF_ATMPVC = 8;
190pub const PF_X25 = 9;
191pub const PF_INET6 = 10;
192pub const PF_ROSE = 11;
193pub const PF_DECnet = 12;
194pub const PF_NETBEUI = 13;
195pub const PF_SECURITY = 14;
196pub const PF_KEY = 15;
197pub const PF_NETLINK = 16;
198pub const PF_ROUTE = PF_NETLINK;
199pub const PF_PACKET = 17;
200pub const PF_ASH = 18;
201pub const PF_ECONET = 19;
202pub const PF_ATMSVC = 20;
203pub const PF_RDS = 21;
204pub const PF_SNA = 22;
205pub const PF_IRDA = 23;
206pub const PF_PPPOX = 24;
207pub const PF_WANPIPE = 25;
208pub const PF_LLC = 26;
209pub const PF_IB = 27;
210pub const PF_MPLS = 28;
211pub const PF_CAN = 29;
212pub const PF_TIPC = 30;
213pub const PF_BLUETOOTH = 31;
214pub const PF_IUCV = 32;
215pub const PF_RXRPC = 33;
216pub const PF_ISDN = 34;
217pub const PF_PHONET = 35;
218pub const PF_IEEE802154 = 36;
219pub const PF_CAIF = 37;
220pub const PF_ALG = 38;
221pub const PF_NFC = 39;
222pub const PF_VSOCK = 40;
223pub const PF_KCM = 41;
224pub const PF_QIPCRTR = 42;
225pub const PF_SMC = 43;
226pub const PF_MAX = 44;
227
228pub const AF_UNSPEC = PF_UNSPEC;
229pub const AF_LOCAL = PF_LOCAL;
230pub const AF_UNIX = AF_LOCAL;
231pub const AF_FILE = AF_LOCAL;
232pub const AF_INET = PF_INET;
233pub const AF_AX25 = PF_AX25;
234pub const AF_IPX = PF_IPX;
235pub const AF_APPLETALK = PF_APPLETALK;
236pub const AF_NETROM = PF_NETROM;
237pub const AF_BRIDGE = PF_BRIDGE;
238pub const AF_ATMPVC = PF_ATMPVC;
239pub const AF_X25 = PF_X25;
240pub const AF_INET6 = PF_INET6;
241pub const AF_ROSE = PF_ROSE;
242pub const AF_DECnet = PF_DECnet;
243pub const AF_NETBEUI = PF_NETBEUI;
244pub const AF_SECURITY = PF_SECURITY;
245pub const AF_KEY = PF_KEY;
246pub const AF_NETLINK = PF_NETLINK;
247pub const AF_ROUTE = PF_ROUTE;
248pub const AF_PACKET = PF_PACKET;
249pub const AF_ASH = PF_ASH;
250pub const AF_ECONET = PF_ECONET;
251pub const AF_ATMSVC = PF_ATMSVC;
252pub const AF_RDS = PF_RDS;
253pub const AF_SNA = PF_SNA;
254pub const AF_IRDA = PF_IRDA;
255pub const AF_PPPOX = PF_PPPOX;
256pub const AF_WANPIPE = PF_WANPIPE;
257pub const AF_LLC = PF_LLC;
258pub const AF_IB = PF_IB;
259pub const AF_MPLS = PF_MPLS;
260pub const AF_CAN = PF_CAN;
261pub const AF_TIPC = PF_TIPC;
262pub const AF_BLUETOOTH = PF_BLUETOOTH;
263pub const AF_IUCV = PF_IUCV;
264pub const AF_RXRPC = PF_RXRPC;
265pub const AF_ISDN = PF_ISDN;
266pub const AF_PHONET = PF_PHONET;
267pub const AF_IEEE802154 = PF_IEEE802154;
268pub const AF_CAIF = PF_CAIF;
269pub const AF_ALG = PF_ALG;
270pub const AF_NFC = PF_NFC;
271pub const AF_VSOCK = PF_VSOCK;
272pub const AF_KCM = PF_KCM;
273pub const AF_QIPCRTR = PF_QIPCRTR;
274pub const AF_SMC = PF_SMC;
275pub const AF_MAX = PF_MAX;
276
277pub const SO_DEBUG = 1;
278pub const SO_REUSEADDR = 2;
279pub const SO_TYPE = 3;
280pub const SO_ERROR = 4;
281pub const SO_DONTROUTE = 5;
282pub const SO_BROADCAST = 6;
283pub const SO_SNDBUF = 7;
284pub const SO_RCVBUF = 8;
285pub const SO_KEEPALIVE = 9;
286pub const SO_OOBINLINE = 10;
287pub const SO_NO_CHECK = 11;
288pub const SO_PRIORITY = 12;
289pub const SO_LINGER = 13;
290pub const SO_BSDCOMPAT = 14;
291pub const SO_REUSEPORT = 15;
292pub const SO_PASSCRED = 16;
293pub const SO_PEERCRED = 17;
294pub const SO_RCVLOWAT = 18;
295pub const SO_SNDLOWAT = 19;
296pub const SO_RCVTIMEO = 20;
297pub const SO_SNDTIMEO = 21;
298pub const SO_ACCEPTCONN = 30;
299pub const SO_SNDBUFFORCE = 32;
300pub const SO_RCVBUFFORCE = 33;
301pub const SO_PROTOCOL = 38;
302pub const SO_DOMAIN = 39;
303
304pub const SO_SECURITY_AUTHENTICATION = 22;
305pub const SO_SECURITY_ENCRYPTION_TRANSPORT = 23;
306pub const SO_SECURITY_ENCRYPTION_NETWORK = 24;
307
308pub const SO_BINDTODEVICE = 25;
309
310pub const SO_ATTACH_FILTER = 26;
311pub const SO_DETACH_FILTER = 27;
312pub const SO_GET_FILTER = SO_ATTACH_FILTER;
313
314pub const SO_PEERNAME = 28;
315pub const SO_TIMESTAMP = 29;
316pub const SCM_TIMESTAMP = SO_TIMESTAMP;
317
318pub const SO_PEERSEC = 31;
319pub const SO_PASSSEC = 34;
320pub const SO_TIMESTAMPNS = 35;
321pub const SCM_TIMESTAMPNS = SO_TIMESTAMPNS;
322pub const SO_MARK = 36;
323pub const SO_TIMESTAMPING = 37;
324pub const SCM_TIMESTAMPING = SO_TIMESTAMPING;
325pub const SO_RXQ_OVFL = 40;
326pub const SO_WIFI_STATUS = 41;
327pub const SCM_WIFI_STATUS = SO_WIFI_STATUS;
328pub const SO_PEEK_OFF = 42;
329pub const SO_NOFCS = 43;
330pub const SO_LOCK_FILTER = 44;
331pub const SO_SELECT_ERR_QUEUE = 45;
332pub const SO_BUSY_POLL = 46;
333pub const SO_MAX_PACING_RATE = 47;
334pub const SO_BPF_EXTENSIONS = 48;
335pub const SO_INCOMING_CPU = 49;
336pub const SO_ATTACH_BPF = 50;
337pub const SO_DETACH_BPF = SO_DETACH_FILTER;
338pub const SO_ATTACH_REUSEPORT_CBPF = 51;
339pub const SO_ATTACH_REUSEPORT_EBPF = 52;
340pub const SO_CNX_ADVICE = 53;
341pub const SCM_TIMESTAMPING_OPT_STATS = 54;
342pub const SO_MEMINFO = 55;
343pub const SO_INCOMING_NAPI_ID = 56;
344pub const SO_COOKIE = 57;
345pub const SCM_TIMESTAMPING_PKTINFO = 58;
346pub const SO_PEERGROUPS = 59;
347pub const SO_ZEROCOPY = 60;
348
349pub const SOL_SOCKET = 1;
350
351pub const SOL_IP = 0;
352pub const SOL_IPV6 = 41;
353pub const SOL_ICMPV6 = 58;
354
355pub const SOL_RAW = 255;
356pub const SOL_DECNET = 261;
357pub const SOL_X25 = 262;
358pub const SOL_PACKET = 263;
359pub const SOL_ATM = 264;
360pub const SOL_AAL = 265;
361pub const SOL_IRDA = 266;
362pub const SOL_NETBEUI = 267;
363pub const SOL_LLC = 268;
364pub const SOL_DCCP = 269;
365pub const SOL_NETLINK = 270;
366pub const SOL_TIPC = 271;
367pub const SOL_RXRPC = 272;
368pub const SOL_PPPOL2TP = 273;
369pub const SOL_BLUETOOTH = 274;
370pub const SOL_PNPIPE = 275;
371pub const SOL_RDS = 276;
372pub const SOL_IUCV = 277;
373pub const SOL_CAIF = 278;
374pub const SOL_ALG = 279;
375pub const SOL_NFC = 280;
376pub const SOL_KCM = 281;
377pub const SOL_TLS = 282;
378
379pub const SOMAXCONN = 128;
380
381pub const MSG_OOB = 0x0001;
382pub const MSG_PEEK = 0x0002;
383pub const MSG_DONTROUTE = 0x0004;
384pub const MSG_CTRUNC = 0x0008;
385pub const MSG_PROXY = 0x0010;
386pub const MSG_TRUNC = 0x0020;
387pub const MSG_DONTWAIT = 0x0040;
388pub const MSG_EOR = 0x0080;
389pub const MSG_WAITALL = 0x0100;
390pub const MSG_FIN = 0x0200;
391pub const MSG_SYN = 0x0400;
392pub const MSG_CONFIRM = 0x0800;
393pub const MSG_RST = 0x1000;
394pub const MSG_ERRQUEUE = 0x2000;
395pub const MSG_NOSIGNAL = 0x4000;
396pub const MSG_MORE = 0x8000;
397pub const MSG_WAITFORONE = 0x10000;
398pub const MSG_BATCH = 0x40000;
399pub const MSG_ZEROCOPY = 0x4000000;
400pub const MSG_FASTOPEN = 0x20000000;
401pub const MSG_CMSG_CLOEXEC = 0x40000000;
402
403pub const DT_UNKNOWN = 0;
404pub const DT_FIFO = 1;
405pub const DT_CHR = 2;
406pub const DT_DIR = 4;
407pub const DT_BLK = 6;
408pub const DT_REG = 8;
409pub const DT_LNK = 10;
410pub const DT_SOCK = 12;
411pub const DT_WHT = 14;
412
413pub const TCGETS = 0x5401;
414pub const TCSETS = 0x5402;
415pub const TCSETSW = 0x5403;
416pub const TCSETSF = 0x5404;
417pub const TCGETA = 0x5405;
418pub const TCSETA = 0x5406;
419pub const TCSETAW = 0x5407;
420pub const TCSETAF = 0x5408;
421pub const TCSBRK = 0x5409;
422pub const TCXONC = 0x540A;
423pub const TCFLSH = 0x540B;
424pub const TIOCEXCL = 0x540C;
425pub const TIOCNXCL = 0x540D;
426pub const TIOCSCTTY = 0x540E;
427pub const TIOCGPGRP = 0x540F;
428pub const TIOCSPGRP = 0x5410;
429pub const TIOCOUTQ = 0x5411;
430pub const TIOCSTI = 0x5412;
431pub const TIOCGWINSZ = 0x5413;
432pub const TIOCSWINSZ = 0x5414;
433pub const TIOCMGET = 0x5415;
434pub const TIOCMBIS = 0x5416;
435pub const TIOCMBIC = 0x5417;
436pub const TIOCMSET = 0x5418;
437pub const TIOCGSOFTCAR = 0x5419;
438pub const TIOCSSOFTCAR = 0x541A;
439pub const FIONREAD = 0x541B;
440pub const TIOCINQ = FIONREAD;
441pub const TIOCLINUX = 0x541C;
442pub const TIOCCONS = 0x541D;
443pub const TIOCGSERIAL = 0x541E;
444pub const TIOCSSERIAL = 0x541F;
445pub const TIOCPKT = 0x5420;
446pub const FIONBIO = 0x5421;
447pub const TIOCNOTTY = 0x5422;
448pub const TIOCSETD = 0x5423;
449pub const TIOCGETD = 0x5424;
450pub const TCSBRKP = 0x5425;
451pub const TIOCSBRK = 0x5427;
452pub const TIOCCBRK = 0x5428;
453pub const TIOCGSID = 0x5429;
454pub const TIOCGRS485 = 0x542E;
455pub const TIOCSRS485 = 0x542F;
456pub const TIOCGPTN = 0x80045430;
457pub const TIOCSPTLCK = 0x40045431;
458pub const TIOCGDEV = 0x80045432;
459pub const TCGETX = 0x5432;
460pub const TCSETX = 0x5433;
461pub const TCSETXF = 0x5434;
462pub const TCSETXW = 0x5435;
463pub const TIOCSIG = 0x40045436;
464pub const TIOCVHANGUP = 0x5437;
465pub const TIOCGPKT = 0x80045438;
466pub const TIOCGPTLCK = 0x80045439;
467pub const TIOCGEXCL = 0x80045440;
468
469pub const EPOLL_CLOEXEC = O_CLOEXEC;
470
471pub const EPOLL_CTL_ADD = 1;
472pub const EPOLL_CTL_DEL = 2;
473pub const EPOLL_CTL_MOD = 3;
474
475pub const EPOLLIN = 0x001;
476pub const EPOLLPRI = 0x002;
477pub const EPOLLOUT = 0x004;
478pub const EPOLLRDNORM = 0x040;
479pub const EPOLLRDBAND = 0x080;
480pub const EPOLLWRNORM = 0x100;
481pub const EPOLLWRBAND = 0x200;
482pub const EPOLLMSG = 0x400;
483pub const EPOLLERR = 0x008;
484pub const EPOLLHUP = 0x010;
485pub const EPOLLRDHUP = 0x2000;
486pub const EPOLLEXCLUSIVE = (u32(1) << 28);
487pub const EPOLLWAKEUP = (u32(1) << 29);
488pub const EPOLLONESHOT = (u32(1) << 30);
489pub const EPOLLET = (u32(1) << 31);
490
491pub const CLOCK_REALTIME = 0;
492pub const CLOCK_MONOTONIC = 1;
493pub const CLOCK_PROCESS_CPUTIME_ID = 2;
494pub const CLOCK_THREAD_CPUTIME_ID = 3;
495pub const CLOCK_MONOTONIC_RAW = 4;
496pub const CLOCK_REALTIME_COARSE = 5;
497pub const CLOCK_MONOTONIC_COARSE = 6;
498pub const CLOCK_BOOTTIME = 7;
499pub const CLOCK_REALTIME_ALARM = 8;
500pub const CLOCK_BOOTTIME_ALARM = 9;
501pub const CLOCK_SGI_CYCLE = 10;
502pub const CLOCK_TAI = 11;
503
504pub const CSIGNAL = 0x000000ff;
505pub const CLONE_VM = 0x00000100;
506pub const CLONE_FS = 0x00000200;
507pub const CLONE_FILES = 0x00000400;
508pub const CLONE_SIGHAND = 0x00000800;
509pub const CLONE_PTRACE = 0x00002000;
510pub const CLONE_VFORK = 0x00004000;
511pub const CLONE_PARENT = 0x00008000;
512pub const CLONE_THREAD = 0x00010000;
513pub const CLONE_NEWNS = 0x00020000;
514pub const CLONE_SYSVSEM = 0x00040000;
515pub const CLONE_SETTLS = 0x00080000;
516pub const CLONE_PARENT_SETTID = 0x00100000;
517pub const CLONE_CHILD_CLEARTID = 0x00200000;
518pub const CLONE_DETACHED = 0x00400000;
519pub const CLONE_UNTRACED = 0x00800000;
520pub const CLONE_CHILD_SETTID = 0x01000000;
521pub const CLONE_NEWCGROUP = 0x02000000;
522pub const CLONE_NEWUTS = 0x04000000;
523pub const CLONE_NEWIPC = 0x08000000;
524pub const CLONE_NEWUSER = 0x10000000;
525pub const CLONE_NEWPID = 0x20000000;
526pub const CLONE_NEWNET = 0x40000000;
527pub const CLONE_IO = 0x80000000;
528
529pub const EFD_SEMAPHORE = 1;
530pub const EFD_CLOEXEC = O_CLOEXEC;
531pub const EFD_NONBLOCK = O_NONBLOCK;
532
533pub const MS_RDONLY = 1;
534pub const MS_NOSUID = 2;
535pub const MS_NODEV = 4;
536pub const MS_NOEXEC = 8;
537pub const MS_SYNCHRONOUS = 16;
538pub const MS_REMOUNT = 32;
539pub const MS_MANDLOCK = 64;
540pub const MS_DIRSYNC = 128;
541pub const MS_NOATIME = 1024;
542pub const MS_NODIRATIME = 2048;
543pub const MS_BIND = 4096;
544pub const MS_MOVE = 8192;
545pub const MS_REC = 16384;
546pub const MS_SILENT = 32768;
547pub const MS_POSIXACL = (1 << 16);
548pub const MS_UNBINDABLE = (1 << 17);
549pub const MS_PRIVATE = (1 << 18);
550pub const MS_SLAVE = (1 << 19);
551pub const MS_SHARED = (1 << 20);
552pub const MS_RELATIME = (1 << 21);
553pub const MS_KERNMOUNT = (1 << 22);
554pub const MS_I_VERSION = (1 << 23);
555pub const MS_STRICTATIME = (1 << 24);
556pub const MS_LAZYTIME = (1 << 25);
557pub const MS_NOREMOTELOCK = (1 << 27);
558pub const MS_NOSEC = (1 << 28);
559pub const MS_BORN = (1 << 29);
560pub const MS_ACTIVE = (1 << 30);
561pub const MS_NOUSER = (1 << 31);
562
563pub const MS_RMT_MASK = (MS_RDONLY | MS_SYNCHRONOUS | MS_MANDLOCK | MS_I_VERSION | MS_LAZYTIME);
564
565pub const MS_MGC_VAL = 0xc0ed0000;
566pub const MS_MGC_MSK = 0xffff0000;
567
568pub const MNT_FORCE = 1;
569pub const MNT_DETACH = 2;
570pub const MNT_EXPIRE = 4;
571pub const UMOUNT_NOFOLLOW = 8;
572
573pub const IN_CLOEXEC = O_CLOEXEC;
574pub const IN_NONBLOCK = O_NONBLOCK;
575
576pub const IN_ACCESS = 0x00000001;
577pub const IN_MODIFY = 0x00000002;
578pub const IN_ATTRIB = 0x00000004;
579pub const IN_CLOSE_WRITE = 0x00000008;
580pub const IN_CLOSE_NOWRITE = 0x00000010;
581pub const IN_CLOSE = IN_CLOSE_WRITE | IN_CLOSE_NOWRITE;
582pub const IN_OPEN = 0x00000020;
583pub const IN_MOVED_FROM = 0x00000040;
584pub const IN_MOVED_TO = 0x00000080;
585pub const IN_MOVE = IN_MOVED_FROM | IN_MOVED_TO;
586pub const IN_CREATE = 0x00000100;
587pub const IN_DELETE = 0x00000200;
588pub const IN_DELETE_SELF = 0x00000400;
589pub const IN_MOVE_SELF = 0x00000800;
590pub const IN_ALL_EVENTS = 0x00000fff;
591
592pub const IN_UNMOUNT = 0x00002000;
593pub const IN_Q_OVERFLOW = 0x00004000;
594pub const IN_IGNORED = 0x00008000;
595
596pub const IN_ONLYDIR = 0x01000000;
597pub const IN_DONT_FOLLOW = 0x02000000;
598pub const IN_EXCL_UNLINK = 0x04000000;
599pub const IN_MASK_ADD = 0x20000000;
600
601pub const IN_ISDIR = 0x40000000;
602pub const IN_ONESHOT = 0x80000000;
603
604pub const S_IFMT = 0o170000;
605
606pub const S_IFDIR = 0o040000;
607pub const S_IFCHR = 0o020000;
608pub const S_IFBLK = 0o060000;
609pub const S_IFREG = 0o100000;
610pub const S_IFIFO = 0o010000;
611pub const S_IFLNK = 0o120000;
612pub const S_IFSOCK = 0o140000;
613
614pub const S_ISUID = 0o4000;
615pub const S_ISGID = 0o2000;
616pub const S_ISVTX = 0o1000;
617pub const S_IRUSR = 0o400;
618pub const S_IWUSR = 0o200;
619pub const S_IXUSR = 0o100;
620pub const S_IRWXU = 0o700;
621pub const S_IRGRP = 0o040;
622pub const S_IWGRP = 0o020;
623pub const S_IXGRP = 0o010;
624pub const S_IRWXG = 0o070;
625pub const S_IROTH = 0o004;
626pub const S_IWOTH = 0o002;
627pub const S_IXOTH = 0o001;
628pub const S_IRWXO = 0o007;
629
630pub fn S_ISREG(m: u32) bool {
631 return m & S_IFMT == S_IFREG;
632}
633
634pub fn S_ISDIR(m: u32) bool {
635 return m & S_IFMT == S_IFDIR;
636}
637
638pub fn S_ISCHR(m: u32) bool {
639 return m & S_IFMT == S_IFCHR;
640}
641
642pub fn S_ISBLK(m: u32) bool {
643 return m & S_IFMT == S_IFBLK;
644}
645
646pub fn S_ISFIFO(m: u32) bool {
647 return m & S_IFMT == S_IFIFO;
648}
649
650pub fn S_ISLNK(m: u32) bool {
651 return m & S_IFMT == S_IFLNK;
652}
653
654pub fn S_ISSOCK(m: u32) bool {
655 return m & S_IFMT == S_IFSOCK;
656}
657
658pub const TFD_NONBLOCK = O_NONBLOCK;
659pub const TFD_CLOEXEC = O_CLOEXEC;
660
661pub const TFD_TIMER_ABSTIME = 1;
662pub const TFD_TIMER_CANCEL_ON_SET = (1 << 1);
663
664fn unsigned(s: i32) u32 {
665 return @bitCast(u32, s);
666}
667fn signed(s: u32) i32 {
668 return @bitCast(i32, s);
669}
670pub fn WEXITSTATUS(s: i32) i32 {
671 return signed((unsigned(s) & 0xff00) >> 8);
672}
673pub fn WTERMSIG(s: i32) i32 {
674 return signed(unsigned(s) & 0x7f);
675}
676pub fn WSTOPSIG(s: i32) i32 {
677 return WEXITSTATUS(s);
678}
679pub fn WIFEXITED(s: i32) bool {
680 return WTERMSIG(s) == 0;
681}
682pub fn WIFSTOPPED(s: i32) bool {
683 return @intCast(u16, ((unsigned(s) & 0xffff) *% 0x10001) >> 8) > 0x7f00;
684}
685pub fn WIFSIGNALED(s: i32) bool {
686 return (unsigned(s) & 0xffff) -% 1 < 0xff;
687}
688
689pub const winsize = extern struct {
690 ws_row: u16,
691 ws_col: u16,
692 ws_xpixel: u16,
693 ws_ypixel: u16,
694};
695
696const NSIG = 65;
697const sigset_t = [128 / @sizeOf(usize)]usize;
698const all_mask = []u32{ 0xffffffff, 0xffffffff };
699const app_mask = []u32{ 0xfffffffc, 0x7fffffff };
700
701const k_sigaction = extern struct {
702 handler: extern fn (i32) void,
703 flags: usize,
704 restorer: extern fn () void,
705 mask: [2]u32,
706};
707
708/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.
709pub const Sigaction = struct {
710 handler: extern fn (i32) void,
711 mask: sigset_t,
712 flags: u32,
713};
714
715pub const SIG_ERR = @intToPtr(extern fn (i32) void, maxInt(usize));
716pub const SIG_DFL = @intToPtr(extern fn (i32) void, 0);
717pub const SIG_IGN = @intToPtr(extern fn (i32) void, 1);
718pub const empty_sigset = []usize{0} ** sigset_t.len;
719
720pub const in_port_t = u16;
721pub const sa_family_t = u16;
722pub const socklen_t = u32;
723
724/// This intentionally only has ip4 and ip6
725pub const sockaddr = extern union {
726 in: sockaddr_in,
727 in6: sockaddr_in6,
728};
729
730pub const sockaddr_in = extern struct {
731 family: sa_family_t,
732 port: in_port_t,
733 addr: u32,
734 zero: [8]u8,
735};
736
737pub const sockaddr_in6 = extern struct {
738 family: sa_family_t,
739 port: in_port_t,
740 flowinfo: u32,
741 addr: [16]u8,
742 scope_id: u32,
743};
744
745pub const sockaddr_un = extern struct {
746 family: sa_family_t,
747 path: [108]u8,
748};
749
750pub const iovec = extern struct {
751 iov_base: [*]u8,
752 iov_len: usize,
753};
754
755pub const iovec_const = extern struct {
756 iov_base: [*]const u8,
757 iov_len: usize,
758};
759
760pub const mmsghdr = extern struct {
761 msg_hdr: msghdr,
762 msg_len: u32,
763};
764
765pub const mmsghdr_const = extern struct {
766 msg_hdr: msghdr_const,
767 msg_len: u32,
768};
769
770pub const epoll_data = extern union {
771 ptr: usize,
772 fd: i32,
773 @"u32": u32,
774 @"u64": u64,
775};
776
777// On x86_64 the structure is packed so that it matches the definition of its
778// 32bit counterpart
779pub const epoll_event = if (builtin.arch != .x86_64)
780 extern struct {
781 events: u32,
782 data: epoll_data,
783 }
784else
785 packed struct {
786 events: u32,
787 data: epoll_data,
788 };
789
790pub const _LINUX_CAPABILITY_VERSION_1 = 0x19980330;
791pub const _LINUX_CAPABILITY_U32S_1 = 1;
792
793pub const _LINUX_CAPABILITY_VERSION_2 = 0x20071026;
794pub const _LINUX_CAPABILITY_U32S_2 = 2;
795
796pub const _LINUX_CAPABILITY_VERSION_3 = 0x20080522;
797pub const _LINUX_CAPABILITY_U32S_3 = 2;
798
799pub const VFS_CAP_REVISION_MASK = 0xFF000000;
800pub const VFS_CAP_REVISION_SHIFT = 24;
801pub const VFS_CAP_FLAGS_MASK = ~VFS_CAP_REVISION_MASK;
802pub const VFS_CAP_FLAGS_EFFECTIVE = 0x000001;
803
804pub const VFS_CAP_REVISION_1 = 0x01000000;
805pub const VFS_CAP_U32_1 = 1;
806pub const XATTR_CAPS_SZ_1 = @sizeOf(u32) * (1 + 2 * VFS_CAP_U32_1);
807
808pub const VFS_CAP_REVISION_2 = 0x02000000;
809pub const VFS_CAP_U32_2 = 2;
810pub const XATTR_CAPS_SZ_2 = @sizeOf(u32) * (1 + 2 * VFS_CAP_U32_2);
811
812pub const XATTR_CAPS_SZ = XATTR_CAPS_SZ_2;
813pub const VFS_CAP_U32 = VFS_CAP_U32_2;
814pub const VFS_CAP_REVISION = VFS_CAP_REVISION_2;
815
816pub const vfs_cap_data = extern struct {
817 //all of these are mandated as little endian
818 //when on disk.
819 const Data = struct {
820 permitted: u32,
821 inheritable: u32,
822 };
823
824 magic_etc: u32,
825 data: [VFS_CAP_U32]Data,
826};
827
828pub const CAP_CHOWN = 0;
829pub const CAP_DAC_OVERRIDE = 1;
830pub const CAP_DAC_READ_SEARCH = 2;
831pub const CAP_FOWNER = 3;
832pub const CAP_FSETID = 4;
833pub const CAP_KILL = 5;
834pub const CAP_SETGID = 6;
835pub const CAP_SETUID = 7;
836pub const CAP_SETPCAP = 8;
837pub const CAP_LINUX_IMMUTABLE = 9;
838pub const CAP_NET_BIND_SERVICE = 10;
839pub const CAP_NET_BROADCAST = 11;
840pub const CAP_NET_ADMIN = 12;
841pub const CAP_NET_RAW = 13;
842pub const CAP_IPC_LOCK = 14;
843pub const CAP_IPC_OWNER = 15;
844pub const CAP_SYS_MODULE = 16;
845pub const CAP_SYS_RAWIO = 17;
846pub const CAP_SYS_CHROOT = 18;
847pub const CAP_SYS_PTRACE = 19;
848pub const CAP_SYS_PACCT = 20;
849pub const CAP_SYS_ADMIN = 21;
850pub const CAP_SYS_BOOT = 22;
851pub const CAP_SYS_NICE = 23;
852pub const CAP_SYS_RESOURCE = 24;
853pub const CAP_SYS_TIME = 25;
854pub const CAP_SYS_TTY_CONFIG = 26;
855pub const CAP_MKNOD = 27;
856pub const CAP_LEASE = 28;
857pub const CAP_AUDIT_WRITE = 29;
858pub const CAP_AUDIT_CONTROL = 30;
859pub const CAP_SETFCAP = 31;
860pub const CAP_MAC_OVERRIDE = 32;
861pub const CAP_MAC_ADMIN = 33;
862pub const CAP_SYSLOG = 34;
863pub const CAP_WAKE_ALARM = 35;
864pub const CAP_BLOCK_SUSPEND = 36;
865pub const CAP_AUDIT_READ = 37;
866pub const CAP_LAST_CAP = CAP_AUDIT_READ;
867
868pub fn cap_valid(u8: x) bool {
869 return x >= 0 and x <= CAP_LAST_CAP;
870}
871
872pub fn CAP_TO_MASK(cap: u8) u32 {
873 return u32(1) << u5(cap & 31);
874}
875
876pub fn CAP_TO_INDEX(cap: u8) u8 {
877 return cap >> 5;
878}
879
880pub const cap_t = extern struct {
881 hdrp: *cap_user_header_t,
882 datap: *cap_user_data_t,
883};
884
885pub const cap_user_header_t = extern struct {
886 version: u32,
887 pid: usize,
888};
889
890pub const cap_user_data_t = extern struct {
891 effective: u32,
892 permitted: u32,
893 inheritable: u32,
894};
895
896pub const inotify_event = extern struct {
897 wd: i32,
898 mask: u32,
899 cookie: u32,
900 len: u32,
901 //name: [?]u8,
902};
903
904pub const dirent64 = extern struct {
905 d_ino: u64,
906 d_off: u64,
907 d_reclen: u16,
908 d_type: u8,
909 d_name: u8, // field address is the address of first byte of name https://github.com/ziglang/zig/issues/173
910};
911
912pub const dl_phdr_info = extern struct {
913 dlpi_addr: usize,
914 dlpi_name: ?[*]const u8,
915 dlpi_phdr: [*]elf.Phdr,
916 dlpi_phnum: u16,
917};
std/os/linux/posix/arm64.zig deleted-405
...@@ -1,405 +0,0 @@
1// arm64-specific declarations that are intended to be imported into the POSIX namespace.
2// This does include Linux-only APIs.
3
4const std = @import("../../std.zig");
5const linux = std.os.linux;
6const socklen_t = linux.socklen_t;
7const iovec = linux.iovec;
8const iovec_const = linux.iovec_const;
9
10pub const SYS_io_setup = 0;
11pub const SYS_io_destroy = 1;
12pub const SYS_io_submit = 2;
13pub const SYS_io_cancel = 3;
14pub const SYS_io_getevents = 4;
15pub const SYS_setxattr = 5;
16pub const SYS_lsetxattr = 6;
17pub const SYS_fsetxattr = 7;
18pub const SYS_getxattr = 8;
19pub const SYS_lgetxattr = 9;
20pub const SYS_fgetxattr = 10;
21pub const SYS_listxattr = 11;
22pub const SYS_llistxattr = 12;
23pub const SYS_flistxattr = 13;
24pub const SYS_removexattr = 14;
25pub const SYS_lremovexattr = 15;
26pub const SYS_fremovexattr = 16;
27pub const SYS_getcwd = 17;
28pub const SYS_lookup_dcookie = 18;
29pub const SYS_eventfd2 = 19;
30pub const SYS_epoll_create1 = 20;
31pub const SYS_epoll_ctl = 21;
32pub const SYS_epoll_pwait = 22;
33pub const SYS_dup = 23;
34pub const SYS_dup3 = 24;
35pub const SYS_fcntl = 25;
36pub const SYS_inotify_init1 = 26;
37pub const SYS_inotify_add_watch = 27;
38pub const SYS_inotify_rm_watch = 28;
39pub const SYS_ioctl = 29;
40pub const SYS_ioprio_set = 30;
41pub const SYS_ioprio_get = 31;
42pub const SYS_flock = 32;
43pub const SYS_mknodat = 33;
44pub const SYS_mkdirat = 34;
45pub const SYS_unlinkat = 35;
46pub const SYS_symlinkat = 36;
47pub const SYS_linkat = 37;
48pub const SYS_renameat = 38;
49pub const SYS_umount2 = 39;
50pub const SYS_mount = 40;
51pub const SYS_pivot_root = 41;
52pub const SYS_nfsservctl = 42;
53pub const SYS_statfs = 43;
54pub const SYS_fstatfs = 44;
55pub const SYS_truncate = 45;
56pub const SYS_ftruncate = 46;
57pub const SYS_fallocate = 47;
58pub const SYS_faccessat = 48;
59pub const SYS_chdir = 49;
60pub const SYS_fchdir = 50;
61pub const SYS_chroot = 51;
62pub const SYS_fchmod = 52;
63pub const SYS_fchmodat = 53;
64pub const SYS_fchownat = 54;
65pub const SYS_fchown = 55;
66pub const SYS_openat = 56;
67pub const SYS_close = 57;
68pub const SYS_vhangup = 58;
69pub const SYS_pipe2 = 59;
70pub const SYS_quotactl = 60;
71pub const SYS_getdents64 = 61;
72pub const SYS_lseek = 62;
73pub const SYS_read = 63;
74pub const SYS_write = 64;
75pub const SYS_readv = 65;
76pub const SYS_writev = 66;
77pub const SYS_pread64 = 67;
78pub const SYS_pwrite64 = 68;
79pub const SYS_preadv = 69;
80pub const SYS_pwritev = 70;
81pub const SYS_pselect6 = 72;
82pub const SYS_ppoll = 73;
83pub const SYS_signalfd4 = 74;
84pub const SYS_vmsplice = 75;
85pub const SYS_splice = 76;
86pub const SYS_tee = 77;
87pub const SYS_readlinkat = 78;
88pub const SYS_fstatat = 79;
89pub const SYS_fstat = 80;
90pub const SYS_sync = 81;
91pub const SYS_fsync = 82;
92pub const SYS_fdatasync = 83;
93pub const SYS_sync_file_range2 = 84;
94pub const SYS_sync_file_range = 84;
95pub const SYS_timerfd_create = 85;
96pub const SYS_timerfd_settime = 86;
97pub const SYS_timerfd_gettime = 87;
98pub const SYS_utimensat = 88;
99pub const SYS_acct = 89;
100pub const SYS_capget = 90;
101pub const SYS_capset = 91;
102pub const SYS_personality = 92;
103pub const SYS_exit = 93;
104pub const SYS_exit_group = 94;
105pub const SYS_waitid = 95;
106pub const SYS_set_tid_address = 96;
107pub const SYS_unshare = 97;
108pub const SYS_futex = 98;
109pub const SYS_set_robust_list = 99;
110pub const SYS_get_robust_list = 100;
111pub const SYS_nanosleep = 101;
112pub const SYS_getitimer = 102;
113pub const SYS_setitimer = 103;
114pub const SYS_kexec_load = 104;
115pub const SYS_init_module = 105;
116pub const SYS_delete_module = 106;
117pub const SYS_timer_create = 107;
118pub const SYS_timer_gettime = 108;
119pub const SYS_timer_getoverrun = 109;
120pub const SYS_timer_settime = 110;
121pub const SYS_timer_delete = 111;
122pub const SYS_clock_settime = 112;
123pub const SYS_clock_gettime = 113;
124pub const SYS_clock_getres = 114;
125pub const SYS_clock_nanosleep = 115;
126pub const SYS_syslog = 116;
127pub const SYS_ptrace = 117;
128pub const SYS_sched_setparam = 118;
129pub const SYS_sched_setscheduler = 119;
130pub const SYS_sched_getscheduler = 120;
131pub const SYS_sched_getparam = 121;
132pub const SYS_sched_setaffinity = 122;
133pub const SYS_sched_getaffinity = 123;
134pub const SYS_sched_yield = 124;
135pub const SYS_sched_get_priority_max = 125;
136pub const SYS_sched_get_priority_min = 126;
137pub const SYS_sched_rr_get_interval = 127;
138pub const SYS_restart_syscall = 128;
139pub const SYS_kill = 129;
140pub const SYS_tkill = 130;
141pub const SYS_tgkill = 131;
142pub const SYS_sigaltstack = 132;
143pub const SYS_rt_sigsuspend = 133;
144pub const SYS_rt_sigaction = 134;
145pub const SYS_rt_sigprocmask = 135;
146pub const SYS_rt_sigpending = 136;
147pub const SYS_rt_sigtimedwait = 137;
148pub const SYS_rt_sigqueueinfo = 138;
149pub const SYS_rt_sigreturn = 139;
150pub const SYS_setpriority = 140;
151pub const SYS_getpriority = 141;
152pub const SYS_reboot = 142;
153pub const SYS_setregid = 143;
154pub const SYS_setgid = 144;
155pub const SYS_setreuid = 145;
156pub const SYS_setuid = 146;
157pub const SYS_setresuid = 147;
158pub const SYS_getresuid = 148;
159pub const SYS_setresgid = 149;
160pub const SYS_getresgid = 150;
161pub const SYS_setfsuid = 151;
162pub const SYS_setfsgid = 152;
163pub const SYS_times = 153;
164pub const SYS_setpgid = 154;
165pub const SYS_getpgid = 155;
166pub const SYS_getsid = 156;
167pub const SYS_setsid = 157;
168pub const SYS_getgroups = 158;
169pub const SYS_setgroups = 159;
170pub const SYS_uname = 160;
171pub const SYS_sethostname = 161;
172pub const SYS_setdomainname = 162;
173pub const SYS_getrlimit = 163;
174pub const SYS_setrlimit = 164;
175pub const SYS_getrusage = 165;
176pub const SYS_umask = 166;
177pub const SYS_prctl = 167;
178pub const SYS_getcpu = 168;
179pub const SYS_gettimeofday = 169;
180pub const SYS_settimeofday = 170;
181pub const SYS_adjtimex = 171;
182pub const SYS_getpid = 172;
183pub const SYS_getppid = 173;
184pub const SYS_getuid = 174;
185pub const SYS_geteuid = 175;
186pub const SYS_getgid = 176;
187pub const SYS_getegid = 177;
188pub const SYS_gettid = 178;
189pub const SYS_sysinfo = 179;
190pub const SYS_mq_open = 180;
191pub const SYS_mq_unlink = 181;
192pub const SYS_mq_timedsend = 182;
193pub const SYS_mq_timedreceive = 183;
194pub const SYS_mq_notify = 184;
195pub const SYS_mq_getsetattr = 185;
196pub const SYS_msgget = 186;
197pub const SYS_msgctl = 187;
198pub const SYS_msgrcv = 188;
199pub const SYS_msgsnd = 189;
200pub const SYS_semget = 190;
201pub const SYS_semctl = 191;
202pub const SYS_semtimedop = 192;
203pub const SYS_semop = 193;
204pub const SYS_shmget = 194;
205pub const SYS_shmctl = 195;
206pub const SYS_shmat = 196;
207pub const SYS_shmdt = 197;
208pub const SYS_socket = 198;
209pub const SYS_socketpair = 199;
210pub const SYS_bind = 200;
211pub const SYS_listen = 201;
212pub const SYS_accept = 202;
213pub const SYS_connect = 203;
214pub const SYS_getsockname = 204;
215pub const SYS_getpeername = 205;
216pub const SYS_sendto = 206;
217pub const SYS_recvfrom = 207;
218pub const SYS_setsockopt = 208;
219pub const SYS_getsockopt = 209;
220pub const SYS_shutdown = 210;
221pub const SYS_sendmsg = 211;
222pub const SYS_recvmsg = 212;
223pub const SYS_readahead = 213;
224pub const SYS_brk = 214;
225pub const SYS_munmap = 215;
226pub const SYS_mremap = 216;
227pub const SYS_add_key = 217;
228pub const SYS_request_key = 218;
229pub const SYS_keyctl = 219;
230pub const SYS_clone = 220;
231pub const SYS_execve = 221;
232pub const SYS_mmap = 222;
233pub const SYS_fadvise64 = 223;
234pub const SYS_swapon = 224;
235pub const SYS_swapoff = 225;
236pub const SYS_mprotect = 226;
237pub const SYS_msync = 227;
238pub const SYS_mlock = 228;
239pub const SYS_munlock = 229;
240pub const SYS_mlockall = 230;
241pub const SYS_munlockall = 231;
242pub const SYS_mincore = 232;
243pub const SYS_madvise = 233;
244pub const SYS_remap_file_pages = 234;
245pub const SYS_mbind = 235;
246pub const SYS_get_mempolicy = 236;
247pub const SYS_set_mempolicy = 237;
248pub const SYS_migrate_pages = 238;
249pub const SYS_move_pages = 239;
250pub const SYS_rt_tgsigqueueinfo = 240;
251pub const SYS_perf_event_open = 241;
252pub const SYS_accept4 = 242;
253pub const SYS_recvmmsg = 243;
254pub const SYS_arch_specific_syscall = 244;
255pub const SYS_wait4 = 260;
256pub const SYS_prlimit64 = 261;
257pub const SYS_fanotify_init = 262;
258pub const SYS_fanotify_mark = 263;
259pub const SYS_clock_adjtime = 266;
260pub const SYS_syncfs = 267;
261pub const SYS_setns = 268;
262pub const SYS_sendmmsg = 269;
263pub const SYS_process_vm_readv = 270;
264pub const SYS_process_vm_writev = 271;
265pub const SYS_kcmp = 272;
266pub const SYS_finit_module = 273;
267pub const SYS_sched_setattr = 274;
268pub const SYS_sched_getattr = 275;
269pub const SYS_renameat2 = 276;
270pub const SYS_seccomp = 277;
271pub const SYS_getrandom = 278;
272pub const SYS_memfd_create = 279;
273pub const SYS_bpf = 280;
274pub const SYS_execveat = 281;
275pub const SYS_userfaultfd = 282;
276pub const SYS_membarrier = 283;
277pub const SYS_mlock2 = 284;
278pub const SYS_copy_file_range = 285;
279pub const SYS_preadv2 = 286;
280pub const SYS_pwritev2 = 287;
281pub const SYS_pkey_mprotect = 288;
282pub const SYS_pkey_alloc = 289;
283pub const SYS_pkey_free = 290;
284pub const SYS_statx = 291;
285pub const SYS_io_pgetevents = 292;
286pub const SYS_rseq = 293;
287pub const SYS_kexec_file_load = 294;
288pub const SYS_pidfd_send_signal = 424;
289pub const SYS_io_uring_setup = 425;
290pub const SYS_io_uring_enter = 426;
291pub const SYS_io_uring_register = 427;
292
293pub const O_CREAT = 0o100;
294pub const O_EXCL = 0o200;
295pub const O_NOCTTY = 0o400;
296pub const O_TRUNC = 0o1000;
297pub const O_APPEND = 0o2000;
298pub const O_NONBLOCK = 0o4000;
299pub const O_DSYNC = 0o10000;
300pub const O_SYNC = 0o4010000;
301pub const O_RSYNC = 0o4010000;
302pub const O_DIRECTORY = 0o200000;
303pub const O_NOFOLLOW = 0o400000;
304pub const O_CLOEXEC = 0o2000000;
305
306pub const O_ASYNC = 0o20000;
307pub const O_DIRECT = 0o40000;
308pub const O_LARGEFILE = 0;
309pub const O_NOATIME = 0o1000000;
310pub const O_PATH = 0o10000000;
311pub const O_TMPFILE = 0o20200000;
312pub const O_NDELAY = O_NONBLOCK;
313
314pub const F_DUPFD = 0;
315pub const F_GETFD = 1;
316pub const F_SETFD = 2;
317pub const F_GETFL = 3;
318pub const F_SETFL = 4;
319
320pub const F_SETOWN = 8;
321pub const F_GETOWN = 9;
322pub const F_SETSIG = 10;
323pub const F_GETSIG = 11;
324
325pub const F_GETLK = 5;
326pub const F_SETLK = 6;
327pub const F_SETLKW = 7;
328
329pub const F_SETOWN_EX = 15;
330pub const F_GETOWN_EX = 16;
331
332pub const F_GETOWNER_UIDS = 17;
333
334pub const AT_FDCWD = -100;
335pub const AT_SYMLINK_NOFOLLOW = 0x100;
336pub const AT_REMOVEDIR = 0x200;
337pub const AT_SYMLINK_FOLLOW = 0x400;
338pub const AT_NO_AUTOMOUNT = 0x800;
339pub const AT_EMPTY_PATH = 0x1000;
340
341pub const VDSO_USEFUL = true;
342pub const VDSO_CGT_SYM = "__kernel_clock_gettime";
343pub const VDSO_CGT_VER = "LINUX_2.6.39";
344
345pub const msghdr = extern struct {
346 msg_name: ?*sockaddr,
347 msg_namelen: socklen_t,
348 msg_iov: [*]iovec,
349 msg_iovlen: i32,
350 __pad1: i32,
351 msg_control: ?*c_void,
352 msg_controllen: socklen_t,
353 __pad2: socklen_t,
354 msg_flags: i32,
355};
356
357pub const msghdr_const = extern struct {
358 msg_name: ?*const sockaddr,
359 msg_namelen: socklen_t,
360 msg_iov: [*]iovec_const,
361 msg_iovlen: i32,
362 __pad1: i32,
363 msg_control: ?*c_void,
364 msg_controllen: socklen_t,
365 __pad2: socklen_t,
366 msg_flags: i32,
367};
368
369/// Renamed to Stat to not conflict with the stat function.
370pub const Stat = extern struct {
371 dev: u64,
372 ino: u64,
373 nlink: usize,
374
375 mode: u32,
376 uid: u32,
377 gid: u32,
378 __pad0: u32,
379 rdev: u64,
380 size: i64,
381 blksize: isize,
382 blocks: i64,
383
384 atim: timespec,
385 mtim: timespec,
386 ctim: timespec,
387 __unused: [3]isize,
388};
389
390pub const timespec = extern struct {
391 tv_sec: isize,
392 tv_nsec: isize,
393};
394
395pub const timeval = extern struct {
396 tv_sec: isize,
397 tv_usec: isize,
398};
399
400pub const timezone = extern struct {
401 tz_minuteswest: i32,
402 tz_dsttime: i32,
403};
404
405pub const Elf_Symndx = u32;
std/os/linux/posix/x86_64.zig deleted-470
...@@ -1,470 +0,0 @@
1// x86-64-specific declarations that are intended to be imported into the POSIX namespace.
2const std = @import("../../../std.zig");
3
4const linux = std.os.linux;
5const sockaddr = linux.sockaddr;
6const socklen_t = linux.socklen_t;
7const iovec = linux.iovec;
8const iovec_const = linux.iovec_const;
9
10pub const SYS_read = 0;
11pub const SYS_write = 1;
12pub const SYS_open = 2;
13pub const SYS_close = 3;
14pub const SYS_stat = 4;
15pub const SYS_fstat = 5;
16pub const SYS_lstat = 6;
17pub const SYS_poll = 7;
18pub const SYS_lseek = 8;
19pub const SYS_mmap = 9;
20pub const SYS_mprotect = 10;
21pub const SYS_munmap = 11;
22pub const SYS_brk = 12;
23pub const SYS_rt_sigaction = 13;
24pub const SYS_rt_sigprocmask = 14;
25pub const SYS_rt_sigreturn = 15;
26pub const SYS_ioctl = 16;
27pub const SYS_pread = 17;
28pub const SYS_pwrite = 18;
29pub const SYS_readv = 19;
30pub const SYS_writev = 20;
31pub const SYS_access = 21;
32pub const SYS_pipe = 22;
33pub const SYS_select = 23;
34pub const SYS_sched_yield = 24;
35pub const SYS_mremap = 25;
36pub const SYS_msync = 26;
37pub const SYS_mincore = 27;
38pub const SYS_madvise = 28;
39pub const SYS_shmget = 29;
40pub const SYS_shmat = 30;
41pub const SYS_shmctl = 31;
42pub const SYS_dup = 32;
43pub const SYS_dup2 = 33;
44pub const SYS_pause = 34;
45pub const SYS_nanosleep = 35;
46pub const SYS_getitimer = 36;
47pub const SYS_alarm = 37;
48pub const SYS_setitimer = 38;
49pub const SYS_getpid = 39;
50pub const SYS_sendfile = 40;
51pub const SYS_socket = 41;
52pub const SYS_connect = 42;
53pub const SYS_accept = 43;
54pub const SYS_sendto = 44;
55pub const SYS_recvfrom = 45;
56pub const SYS_sendmsg = 46;
57pub const SYS_recvmsg = 47;
58pub const SYS_shutdown = 48;
59pub const SYS_bind = 49;
60pub const SYS_listen = 50;
61pub const SYS_getsockname = 51;
62pub const SYS_getpeername = 52;
63pub const SYS_socketpair = 53;
64pub const SYS_setsockopt = 54;
65pub const SYS_getsockopt = 55;
66pub const SYS_clone = 56;
67pub const SYS_fork = 57;
68pub const SYS_vfork = 58;
69pub const SYS_execve = 59;
70pub const SYS_exit = 60;
71pub const SYS_wait4 = 61;
72pub const SYS_kill = 62;
73pub const SYS_uname = 63;
74pub const SYS_semget = 64;
75pub const SYS_semop = 65;
76pub const SYS_semctl = 66;
77pub const SYS_shmdt = 67;
78pub const SYS_msgget = 68;
79pub const SYS_msgsnd = 69;
80pub const SYS_msgrcv = 70;
81pub const SYS_msgctl = 71;
82pub const SYS_fcntl = 72;
83pub const SYS_flock = 73;
84pub const SYS_fsync = 74;
85pub const SYS_fdatasync = 75;
86pub const SYS_truncate = 76;
87pub const SYS_ftruncate = 77;
88pub const SYS_getdents = 78;
89pub const SYS_getcwd = 79;
90pub const SYS_chdir = 80;
91pub const SYS_fchdir = 81;
92pub const SYS_rename = 82;
93pub const SYS_mkdir = 83;
94pub const SYS_rmdir = 84;
95pub const SYS_creat = 85;
96pub const SYS_link = 86;
97pub const SYS_unlink = 87;
98pub const SYS_symlink = 88;
99pub const SYS_readlink = 89;
100pub const SYS_chmod = 90;
101pub const SYS_fchmod = 91;
102pub const SYS_chown = 92;
103pub const SYS_fchown = 93;
104pub const SYS_lchown = 94;
105pub const SYS_umask = 95;
106pub const SYS_gettimeofday = 96;
107pub const SYS_getrlimit = 97;
108pub const SYS_getrusage = 98;
109pub const SYS_sysinfo = 99;
110pub const SYS_times = 100;
111pub const SYS_ptrace = 101;
112pub const SYS_getuid = 102;
113pub const SYS_syslog = 103;
114pub const SYS_getgid = 104;
115pub const SYS_setuid = 105;
116pub const SYS_setgid = 106;
117pub const SYS_geteuid = 107;
118pub const SYS_getegid = 108;
119pub const SYS_setpgid = 109;
120pub const SYS_getppid = 110;
121pub const SYS_getpgrp = 111;
122pub const SYS_setsid = 112;
123pub const SYS_setreuid = 113;
124pub const SYS_setregid = 114;
125pub const SYS_getgroups = 115;
126pub const SYS_setgroups = 116;
127pub const SYS_setresuid = 117;
128pub const SYS_getresuid = 118;
129pub const SYS_setresgid = 119;
130pub const SYS_getresgid = 120;
131pub const SYS_getpgid = 121;
132pub const SYS_setfsuid = 122;
133pub const SYS_setfsgid = 123;
134pub const SYS_getsid = 124;
135pub const SYS_capget = 125;
136pub const SYS_capset = 126;
137pub const SYS_rt_sigpending = 127;
138pub const SYS_rt_sigtimedwait = 128;
139pub const SYS_rt_sigqueueinfo = 129;
140pub const SYS_rt_sigsuspend = 130;
141pub const SYS_sigaltstack = 131;
142pub const SYS_utime = 132;
143pub const SYS_mknod = 133;
144pub const SYS_uselib = 134;
145pub const SYS_personality = 135;
146pub const SYS_ustat = 136;
147pub const SYS_statfs = 137;
148pub const SYS_fstatfs = 138;
149pub const SYS_sysfs = 139;
150pub const SYS_getpriority = 140;
151pub const SYS_setpriority = 141;
152pub const SYS_sched_setparam = 142;
153pub const SYS_sched_getparam = 143;
154pub const SYS_sched_setscheduler = 144;
155pub const SYS_sched_getscheduler = 145;
156pub const SYS_sched_get_priority_max = 146;
157pub const SYS_sched_get_priority_min = 147;
158pub const SYS_sched_rr_get_interval = 148;
159pub const SYS_mlock = 149;
160pub const SYS_munlock = 150;
161pub const SYS_mlockall = 151;
162pub const SYS_munlockall = 152;
163pub const SYS_vhangup = 153;
164pub const SYS_modify_ldt = 154;
165pub const SYS_pivot_root = 155;
166pub const SYS__sysctl = 156;
167pub const SYS_prctl = 157;
168pub const SYS_arch_prctl = 158;
169pub const SYS_adjtimex = 159;
170pub const SYS_setrlimit = 160;
171pub const SYS_chroot = 161;
172pub const SYS_sync = 162;
173pub const SYS_acct = 163;
174pub const SYS_settimeofday = 164;
175pub const SYS_mount = 165;
176pub const SYS_umount2 = 166;
177pub const SYS_swapon = 167;
178pub const SYS_swapoff = 168;
179pub const SYS_reboot = 169;
180pub const SYS_sethostname = 170;
181pub const SYS_setdomainname = 171;
182pub const SYS_iopl = 172;
183pub const SYS_ioperm = 173;
184pub const SYS_create_module = 174;
185pub const SYS_init_module = 175;
186pub const SYS_delete_module = 176;
187pub const SYS_get_kernel_syms = 177;
188pub const SYS_query_module = 178;
189pub const SYS_quotactl = 179;
190pub const SYS_nfsservctl = 180;
191pub const SYS_getpmsg = 181;
192pub const SYS_putpmsg = 182;
193pub const SYS_afs_syscall = 183;
194pub const SYS_tuxcall = 184;
195pub const SYS_security = 185;
196pub const SYS_gettid = 186;
197pub const SYS_readahead = 187;
198pub const SYS_setxattr = 188;
199pub const SYS_lsetxattr = 189;
200pub const SYS_fsetxattr = 190;
201pub const SYS_getxattr = 191;
202pub const SYS_lgetxattr = 192;
203pub const SYS_fgetxattr = 193;
204pub const SYS_listxattr = 194;
205pub const SYS_llistxattr = 195;
206pub const SYS_flistxattr = 196;
207pub const SYS_removexattr = 197;
208pub const SYS_lremovexattr = 198;
209pub const SYS_fremovexattr = 199;
210pub const SYS_tkill = 200;
211pub const SYS_time = 201;
212pub const SYS_futex = 202;
213pub const SYS_sched_setaffinity = 203;
214pub const SYS_sched_getaffinity = 204;
215pub const SYS_set_thread_area = 205;
216pub const SYS_io_setup = 206;
217pub const SYS_io_destroy = 207;
218pub const SYS_io_getevents = 208;
219pub const SYS_io_submit = 209;
220pub const SYS_io_cancel = 210;
221pub const SYS_get_thread_area = 211;
222pub const SYS_lookup_dcookie = 212;
223pub const SYS_epoll_create = 213;
224pub const SYS_epoll_ctl_old = 214;
225pub const SYS_epoll_wait_old = 215;
226pub const SYS_remap_file_pages = 216;
227pub const SYS_getdents64 = 217;
228pub const SYS_set_tid_address = 218;
229pub const SYS_restart_syscall = 219;
230pub const SYS_semtimedop = 220;
231pub const SYS_fadvise64 = 221;
232pub const SYS_timer_create = 222;
233pub const SYS_timer_settime = 223;
234pub const SYS_timer_gettime = 224;
235pub const SYS_timer_getoverrun = 225;
236pub const SYS_timer_delete = 226;
237pub const SYS_clock_settime = 227;
238pub const SYS_clock_gettime = 228;
239pub const SYS_clock_getres = 229;
240pub const SYS_clock_nanosleep = 230;
241pub const SYS_exit_group = 231;
242pub const SYS_epoll_wait = 232;
243pub const SYS_epoll_ctl = 233;
244pub const SYS_tgkill = 234;
245pub const SYS_utimes = 235;
246pub const SYS_vserver = 236;
247pub const SYS_mbind = 237;
248pub const SYS_set_mempolicy = 238;
249pub const SYS_get_mempolicy = 239;
250pub const SYS_mq_open = 240;
251pub const SYS_mq_unlink = 241;
252pub const SYS_mq_timedsend = 242;
253pub const SYS_mq_timedreceive = 243;
254pub const SYS_mq_notify = 244;
255pub const SYS_mq_getsetattr = 245;
256pub const SYS_kexec_load = 246;
257pub const SYS_waitid = 247;
258pub const SYS_add_key = 248;
259pub const SYS_request_key = 249;
260pub const SYS_keyctl = 250;
261pub const SYS_ioprio_set = 251;
262pub const SYS_ioprio_get = 252;
263pub const SYS_inotify_init = 253;
264pub const SYS_inotify_add_watch = 254;
265pub const SYS_inotify_rm_watch = 255;
266pub const SYS_migrate_pages = 256;
267pub const SYS_openat = 257;
268pub const SYS_mkdirat = 258;
269pub const SYS_mknodat = 259;
270pub const SYS_fchownat = 260;
271pub const SYS_futimesat = 261;
272pub const SYS_newfstatat = 262;
273pub const SYS_fstatat = 262;
274pub const SYS_unlinkat = 263;
275pub const SYS_renameat = 264;
276pub const SYS_linkat = 265;
277pub const SYS_symlinkat = 266;
278pub const SYS_readlinkat = 267;
279pub const SYS_fchmodat = 268;
280pub const SYS_faccessat = 269;
281pub const SYS_pselect6 = 270;
282pub const SYS_ppoll = 271;
283pub const SYS_unshare = 272;
284pub const SYS_set_robust_list = 273;
285pub const SYS_get_robust_list = 274;
286pub const SYS_splice = 275;
287pub const SYS_tee = 276;
288pub const SYS_sync_file_range = 277;
289pub const SYS_vmsplice = 278;
290pub const SYS_move_pages = 279;
291pub const SYS_utimensat = 280;
292pub const SYS_epoll_pwait = 281;
293pub const SYS_signalfd = 282;
294pub const SYS_timerfd_create = 283;
295pub const SYS_eventfd = 284;
296pub const SYS_fallocate = 285;
297pub const SYS_timerfd_settime = 286;
298pub const SYS_timerfd_gettime = 287;
299pub const SYS_accept4 = 288;
300pub const SYS_signalfd4 = 289;
301pub const SYS_eventfd2 = 290;
302pub const SYS_epoll_create1 = 291;
303pub const SYS_dup3 = 292;
304pub const SYS_pipe2 = 293;
305pub const SYS_inotify_init1 = 294;
306pub const SYS_preadv = 295;
307pub const SYS_pwritev = 296;
308pub const SYS_rt_tgsigqueueinfo = 297;
309pub const SYS_perf_event_open = 298;
310pub const SYS_recvmmsg = 299;
311pub const SYS_fanotify_init = 300;
312pub const SYS_fanotify_mark = 301;
313pub const SYS_prlimit64 = 302;
314pub const SYS_name_to_handle_at = 303;
315pub const SYS_open_by_handle_at = 304;
316pub const SYS_clock_adjtime = 305;
317pub const SYS_syncfs = 306;
318pub const SYS_sendmmsg = 307;
319pub const SYS_setns = 308;
320pub const SYS_getcpu = 309;
321pub const SYS_process_vm_readv = 310;
322pub const SYS_process_vm_writev = 311;
323pub const SYS_kcmp = 312;
324pub const SYS_finit_module = 313;
325pub const SYS_sched_setattr = 314;
326pub const SYS_sched_getattr = 315;
327pub const SYS_renameat2 = 316;
328pub const SYS_seccomp = 317;
329pub const SYS_getrandom = 318;
330pub const SYS_memfd_create = 319;
331pub const SYS_kexec_file_load = 320;
332pub const SYS_bpf = 321;
333pub const SYS_execveat = 322;
334pub const SYS_userfaultfd = 323;
335pub const SYS_membarrier = 324;
336pub const SYS_mlock2 = 325;
337pub const SYS_copy_file_range = 326;
338pub const SYS_preadv2 = 327;
339pub const SYS_pwritev2 = 328;
340pub const SYS_pkey_mprotect = 329;
341pub const SYS_pkey_alloc = 330;
342pub const SYS_pkey_free = 331;
343pub const SYS_statx = 332;
344pub const SYS_io_pgetevents = 333;
345pub const SYS_rseq = 334;
346pub const SYS_pidfd_send_signal = 424;
347pub const SYS_io_uring_setup = 425;
348pub const SYS_io_uring_enter = 426;
349pub const SYS_io_uring_register = 427;
350
351pub const O_CREAT = 0o100;
352pub const O_EXCL = 0o200;
353pub const O_NOCTTY = 0o400;
354pub const O_TRUNC = 0o1000;
355pub const O_APPEND = 0o2000;
356pub const O_NONBLOCK = 0o4000;
357pub const O_DSYNC = 0o10000;
358pub const O_SYNC = 0o4010000;
359pub const O_RSYNC = 0o4010000;
360pub const O_DIRECTORY = 0o200000;
361pub const O_NOFOLLOW = 0o400000;
362pub const O_CLOEXEC = 0o2000000;
363
364pub const O_ASYNC = 0o20000;
365pub const O_DIRECT = 0o40000;
366pub const O_LARGEFILE = 0;
367pub const O_NOATIME = 0o1000000;
368pub const O_PATH = 0o10000000;
369pub const O_TMPFILE = 0o20200000;
370pub const O_NDELAY = O_NONBLOCK;
371
372pub const F_DUPFD = 0;
373pub const F_GETFD = 1;
374pub const F_SETFD = 2;
375pub const F_GETFL = 3;
376pub const F_SETFL = 4;
377
378pub const F_SETOWN = 8;
379pub const F_GETOWN = 9;
380pub const F_SETSIG = 10;
381pub const F_GETSIG = 11;
382
383pub const F_GETLK = 5;
384pub const F_SETLK = 6;
385pub const F_SETLKW = 7;
386
387pub const F_SETOWN_EX = 15;
388pub const F_GETOWN_EX = 16;
389
390pub const F_GETOWNER_UIDS = 17;
391
392pub const AT_FDCWD = -100;
393pub const AT_SYMLINK_NOFOLLOW = 0x100;
394pub const AT_REMOVEDIR = 0x200;
395pub const AT_SYMLINK_FOLLOW = 0x400;
396pub const AT_NO_AUTOMOUNT = 0x800;
397pub const AT_EMPTY_PATH = 0x1000;
398
399pub const VDSO_USEFUL = true;
400pub const VDSO_CGT_SYM = "__vdso_clock_gettime";
401pub const VDSO_CGT_VER = "LINUX_2.6";
402pub const VDSO_GETCPU_SYM = "__vdso_getcpu";
403pub const VDSO_GETCPU_VER = "LINUX_2.6";
404
405pub const ARCH_SET_GS = 0x1001;
406pub const ARCH_SET_FS = 0x1002;
407pub const ARCH_GET_FS = 0x1003;
408pub const ARCH_GET_GS = 0x1004;
409
410pub const msghdr = extern struct {
411 msg_name: ?*sockaddr,
412 msg_namelen: socklen_t,
413 msg_iov: [*]iovec,
414 msg_iovlen: i32,
415 __pad1: i32,
416 msg_control: ?*c_void,
417 msg_controllen: socklen_t,
418 __pad2: socklen_t,
419 msg_flags: i32,
420};
421
422pub const msghdr_const = extern struct {
423 msg_name: ?*const sockaddr,
424 msg_namelen: socklen_t,
425 msg_iov: [*]iovec_const,
426 msg_iovlen: i32,
427 __pad1: i32,
428 msg_control: ?*c_void,
429 msg_controllen: socklen_t,
430 __pad2: socklen_t,
431 msg_flags: i32,
432};
433
434/// Renamed to Stat to not conflict with the stat function.
435pub const Stat = extern struct {
436 dev: u64,
437 ino: u64,
438 nlink: usize,
439
440 mode: u32,
441 uid: u32,
442 gid: u32,
443 __pad0: u32,
444 rdev: u64,
445 size: i64,
446 blksize: isize,
447 blocks: i64,
448
449 atim: timespec,
450 mtim: timespec,
451 ctim: timespec,
452 __unused: [3]isize,
453};
454
455pub const timespec = extern struct {
456 tv_sec: isize,
457 tv_nsec: isize,
458};
459
460pub const timeval = extern struct {
461 tv_sec: isize,
462 tv_usec: isize,
463};
464
465pub const timezone = extern struct {
466 tz_minuteswest: i32,
467 tz_dsttime: i32,
468};
469
470pub const Elf_Symndx = u32;
std/os/linux/sys.zig+1-2
...@@ -17,8 +17,7 @@ pub use switch (builtin.arch) {...@@ -17,8 +17,7 @@ pub use switch (builtin.arch) {
17 .aarch64 => @import("arm64.zig"),17 .aarch64 => @import("arm64.zig"),
18 else => struct {},18 else => struct {},
19};19};
20pub const posix = @import("posix.zig");20pub use @import("../bits.zig");
21pub use posix;
2221
23/// See `std.os.posix.getauxval`.22/// See `std.os.posix.getauxval`.
24pub var elf_aux_maybe: ?[*]std.elf.Auxv = null;23pub var elf_aux_maybe: ?[*]std.elf.Auxv = null;
std/os/wasi.zig+3-3
...@@ -1,11 +1,11 @@...@@ -1,11 +1,11 @@
1// Based on https://github.com/CraneStation/wasi-sysroot/blob/wasi/libc-bottom-half/headers/public/wasi/core.h1// Based on https://github.com/CraneStation/wasi-sysroot/blob/wasi/libc-bottom-half/headers/public/wasi/core.h
2// and https://github.com/WebAssembly/WASI/blob/master/design/WASI-core.md2// and https://github.com/WebAssembly/WASI/blob/master/design/WASI-core.md
3const builtin = @import("builtin");
3const std = @import("std");4const std = @import("std");
4const assert = std.debug.assert;5const assert = std.debug.assert;
56
6pub const is_the_target = @import("builtin").os == .wasi;7pub const is_the_target = builtin.os == .wasi;
7pub const posix = @import("wasi/posix.zig");8pub use @import("bits/wasi.zig");
8pub use posix;
99
10comptime {10comptime {
11 assert(@alignOf(i8) == 1);11 assert(@alignOf(i8) == 1);
std/os/wasi/posix.zig deleted-320
...@@ -1,320 +0,0 @@
1// Declarations that are intended to be imported into the POSIX namespace.
2// This includes WASI-only APIs.
3
4pub const STDIN_FILENO = 0;
5pub const STDOUT_FILENO = 1;
6pub const STDERR_FILENO = 2;
7
8pub const advice_t = u8;
9pub const ADVICE_NORMAL: advice_t = 0;
10pub const ADVICE_SEQUENTIAL: advice_t = 1;
11pub const ADVICE_RANDOM: advice_t = 2;
12pub const ADVICE_WILLNEED: advice_t = 3;
13pub const ADVICE_DONTNEED: advice_t = 4;
14pub const ADVICE_NOREUSE: advice_t = 5;
15
16pub const ciovec_t = extern struct {
17 buf: [*]const u8,
18 buf_len: usize,
19};
20
21pub const clockid_t = u32;
22pub const CLOCK_REALTIME: clockid_t = 0;
23pub const CLOCK_MONOTONIC: clockid_t = 1;
24pub const CLOCK_PROCESS_CPUTIME_ID: clockid_t = 2;
25pub const CLOCK_THREAD_CPUTIME_ID: clockid_t = 3;
26
27pub const device_t = u64;
28
29pub const dircookie_t = u64;
30pub const DIRCOOKIE_START: dircookie_t = 0;
31
32pub const dirent_t = extern struct {
33 d_next: dircookie_t,
34 d_ino: inode_t,
35 d_namlen: u32,
36 d_type: filetype_t,
37};
38
39pub const errno_t = u16;
40pub const ESUCCESS: errno_t = 0;
41pub const E2BIG: errno_t = 1;
42pub const EACCES: errno_t = 2;
43pub const EADDRINUSE: errno_t = 3;
44pub const EADDRNOTAVAIL: errno_t = 4;
45pub const EAFNOSUPPORT: errno_t = 5;
46pub const EAGAIN: errno_t = 6;
47pub const EALREADY: errno_t = 7;
48pub const EBADF: errno_t = 8;
49pub const EBADMSG: errno_t = 9;
50pub const EBUSY: errno_t = 10;
51pub const ECANCELED: errno_t = 11;
52pub const ECHILD: errno_t = 12;
53pub const ECONNABORTED: errno_t = 13;
54pub const ECONNREFUSED: errno_t = 14;
55pub const ECONNRESET: errno_t = 15;
56pub const EDEADLK: errno_t = 16;
57pub const EDESTADDRREQ: errno_t = 17;
58pub const EDOM: errno_t = 18;
59pub const EDQUOT: errno_t = 19;
60pub const EEXIST: errno_t = 20;
61pub const EFAULT: errno_t = 21;
62pub const EFBIG: errno_t = 22;
63pub const EHOSTUNREACH: errno_t = 23;
64pub const EIDRM: errno_t = 24;
65pub const EILSEQ: errno_t = 25;
66pub const EINPROGRESS: errno_t = 26;
67pub const EINTR: errno_t = 27;
68pub const EINVAL: errno_t = 28;
69pub const EIO: errno_t = 29;
70pub const EISCONN: errno_t = 30;
71pub const EISDIR: errno_t = 31;
72pub const ELOOP: errno_t = 32;
73pub const EMFILE: errno_t = 33;
74pub const EMLINK: errno_t = 34;
75pub const EMSGSIZE: errno_t = 35;
76pub const EMULTIHOP: errno_t = 36;
77pub const ENAMETOOLONG: errno_t = 37;
78pub const ENETDOWN: errno_t = 38;
79pub const ENETRESET: errno_t = 39;
80pub const ENETUNREACH: errno_t = 40;
81pub const ENFILE: errno_t = 41;
82pub const ENOBUFS: errno_t = 42;
83pub const ENODEV: errno_t = 43;
84pub const ENOENT: errno_t = 44;
85pub const ENOEXEC: errno_t = 45;
86pub const ENOLCK: errno_t = 46;
87pub const ENOLINK: errno_t = 47;
88pub const ENOMEM: errno_t = 48;
89pub const ENOMSG: errno_t = 49;
90pub const ENOPROTOOPT: errno_t = 50;
91pub const ENOSPC: errno_t = 51;
92pub const ENOSYS: errno_t = 52;
93pub const ENOTCONN: errno_t = 53;
94pub const ENOTDIR: errno_t = 54;
95pub const ENOTEMPTY: errno_t = 55;
96pub const ENOTRECOVERABLE: errno_t = 56;
97pub const ENOTSOCK: errno_t = 57;
98pub const ENOTSUP: errno_t = 58;
99pub const ENOTTY: errno_t = 59;
100pub const ENXIO: errno_t = 60;
101pub const EOVERFLOW: errno_t = 61;
102pub const EOWNERDEAD: errno_t = 62;
103pub const EPERM: errno_t = 63;
104pub const EPIPE: errno_t = 64;
105pub const EPROTO: errno_t = 65;
106pub const EPROTONOSUPPORT: errno_t = 66;
107pub const EPROTOTYPE: errno_t = 67;
108pub const ERANGE: errno_t = 68;
109pub const EROFS: errno_t = 69;
110pub const ESPIPE: errno_t = 70;
111pub const ESRCH: errno_t = 71;
112pub const ESTALE: errno_t = 72;
113pub const ETIMEDOUT: errno_t = 73;
114pub const ETXTBSY: errno_t = 74;
115pub const EXDEV: errno_t = 75;
116pub const ENOTCAPABLE: errno_t = 76;
117
118pub const event_t = extern struct {
119 userdata: userdata_t,
120 @"error": errno_t,
121 @"type": eventtype_t,
122 u: extern union {
123 fd_readwrite: extern struct {
124 nbytes: filesize_t,
125 flags: eventrwflags_t,
126 },
127 },
128};
129
130pub const eventrwflags_t = u16;
131pub const EVENT_FD_READWRITE_HANGUP: eventrwflags_t = 0x0001;
132
133pub const eventtype_t = u8;
134pub const EVENTTYPE_CLOCK: eventtype_t = 0;
135pub const EVENTTYPE_FD_READ: eventtype_t = 1;
136pub const EVENTTYPE_FD_WRITE: eventtype_t = 2;
137
138pub const exitcode_t = u32;
139
140pub const fd_t = u32;
141
142pub const fdflags_t = u16;
143pub const FDFLAG_APPEND: fdflags_t = 0x0001;
144pub const FDFLAG_DSYNC: fdflags_t = 0x0002;
145pub const FDFLAG_NONBLOCK: fdflags_t = 0x0004;
146pub const FDFLAG_RSYNC: fdflags_t = 0x0008;
147pub const FDFLAG_SYNC: fdflags_t = 0x0010;
148
149const fdstat_t = extern struct {
150 fs_filetype: filetype_t,
151 fs_flags: fdflags_t,
152 fs_rights_base: rights_t,
153 fs_rights_inheriting: rights_t,
154};
155
156pub const filedelta_t = i64;
157
158pub const filesize_t = u64;
159
160pub const filestat_t = extern struct {
161 st_dev: device_t,
162 st_ino: inode_t,
163 st_filetype: filetype_t,
164 st_nlink: linkcount_t,
165 st_size: filesize_t,
166 st_atim: timestamp_t,
167 st_mtim: timestamp_t,
168 st_ctim: timestamp_t,
169};
170
171pub const filetype_t = u8;
172pub const FILETYPE_UNKNOWN: filetype_t = 0;
173pub const FILETYPE_BLOCK_DEVICE: filetype_t = 1;
174pub const FILETYPE_CHARACTER_DEVICE: filetype_t = 2;
175pub const FILETYPE_DIRECTORY: filetype_t = 3;
176pub const FILETYPE_REGULAR_FILE: filetype_t = 4;
177pub const FILETYPE_SOCKET_DGRAM: filetype_t = 5;
178pub const FILETYPE_SOCKET_STREAM: filetype_t = 6;
179pub const FILETYPE_SYMBOLIC_LINK: filetype_t = 7;
180
181pub const fstflags_t = u16;
182pub const FILESTAT_SET_ATIM: fstflags_t = 0x0001;
183pub const FILESTAT_SET_ATIM_NOW: fstflags_t = 0x0002;
184pub const FILESTAT_SET_MTIM: fstflags_t = 0x0004;
185pub const FILESTAT_SET_MTIM_NOW: fstflags_t = 0x0008;
186
187pub const inode_t = u64;
188
189pub const iovec_t = extern struct {
190 buf: [*]u8,
191 buf_len: usize,
192};
193
194pub const linkcount_t = u32;
195
196pub const lookupflags_t = u32;
197pub const LOOKUP_SYMLINK_FOLLOW: lookupflags_t = 0x00000001;
198
199pub const oflags_t = u16;
200pub const O_CREAT: oflags_t = 0x0001;
201pub const O_DIRECTORY: oflags_t = 0x0002;
202pub const O_EXCL: oflags_t = 0x0004;
203pub const O_TRUNC: oflags_t = 0x0008;
204
205pub const preopentype_t = u8;
206pub const PREOPENTYPE_DIR: preopentype_t = 0;
207
208pub const prestat_t = extern struct {
209 pr_type: preopentype_t,
210 u: extern union {
211 dir: extern struct {
212 pr_name_len: usize,
213 },
214 },
215};
216
217pub const riflags_t = u16;
218pub const SOCK_RECV_PEEK: riflags_t = 0x0001;
219pub const SOCK_RECV_WAITALL: riflags_t = 0x0002;
220
221pub const rights_t = u64;
222pub const RIGHT_FD_DATASYNC: rights_t = 0x0000000000000001;
223pub const RIGHT_FD_READ: rights_t = 0x0000000000000002;
224pub const RIGHT_FD_SEEK: rights_t = 0x0000000000000004;
225pub const RIGHT_FD_FDSTAT_SET_FLAGS: rights_t = 0x0000000000000008;
226pub const RIGHT_FD_SYNC: rights_t = 0x0000000000000010;
227pub const RIGHT_FD_TELL: rights_t = 0x0000000000000020;
228pub const RIGHT_FD_WRITE: rights_t = 0x0000000000000040;
229pub const RIGHT_FD_ADVISE: rights_t = 0x0000000000000080;
230pub const RIGHT_FD_ALLOCATE: rights_t = 0x0000000000000100;
231pub const RIGHT_PATH_CREATE_DIRECTORY: rights_t = 0x0000000000000200;
232pub const RIGHT_PATH_CREATE_FILE: rights_t = 0x0000000000000400;
233pub const RIGHT_PATH_LINK_SOURCE: rights_t = 0x0000000000000800;
234pub const RIGHT_PATH_LINK_TARGET: rights_t = 0x0000000000001000;
235pub const RIGHT_PATH_OPEN: rights_t = 0x0000000000002000;
236pub const RIGHT_FD_READDIR: rights_t = 0x0000000000004000;
237pub const RIGHT_PATH_READLINK: rights_t = 0x0000000000008000;
238pub const RIGHT_PATH_RENAME_SOURCE: rights_t = 0x0000000000010000;
239pub const RIGHT_PATH_RENAME_TARGET: rights_t = 0x0000000000020000;
240pub const RIGHT_PATH_FILESTAT_GET: rights_t = 0x0000000000040000;
241pub const RIGHT_PATH_FILESTAT_SET_SIZE: rights_t = 0x0000000000080000;
242pub const RIGHT_PATH_FILESTAT_SET_TIMES: rights_t = 0x0000000000100000;
243pub const RIGHT_FD_FILESTAT_GET: rights_t = 0x0000000000200000;
244pub const RIGHT_FD_FILESTAT_SET_SIZE: rights_t = 0x0000000000400000;
245pub const RIGHT_FD_FILESTAT_SET_TIMES: rights_t = 0x0000000000800000;
246pub const RIGHT_PATH_SYMLINK: rights_t = 0x0000000001000000;
247pub const RIGHT_PATH_REMOVE_DIRECTORY: rights_t = 0x0000000002000000;
248pub const RIGHT_PATH_UNLINK_FILE: rights_t = 0x0000000004000000;
249pub const RIGHT_POLL_FD_READWRITE: rights_t = 0x0000000008000000;
250pub const RIGHT_SOCK_SHUTDOWN: rights_t = 0x0000000010000000;
251
252pub const roflags_t = u16;
253pub const SOCK_RECV_DATA_TRUNCATED: roflags_t = 0x0001;
254
255pub const sdflags_t = u8;
256pub const SHUT_RD: sdflags_t = 0x01;
257pub const SHUT_WR: sdflags_t = 0x02;
258
259pub const siflags_t = u16;
260
261pub const signal_t = u8;
262pub const SIGHUP: signal_t = 1;
263pub const SIGINT: signal_t = 2;
264pub const SIGQUIT: signal_t = 3;
265pub const SIGILL: signal_t = 4;
266pub const SIGTRAP: signal_t = 5;
267pub const SIGABRT: signal_t = 6;
268pub const SIGBUS: signal_t = 7;
269pub const SIGFPE: signal_t = 8;
270pub const SIGKILL: signal_t = 9;
271pub const SIGUSR1: signal_t = 10;
272pub const SIGSEGV: signal_t = 11;
273pub const SIGUSR2: signal_t = 12;
274pub const SIGPIPE: signal_t = 13;
275pub const SIGALRM: signal_t = 14;
276pub const SIGTERM: signal_t = 15;
277pub const SIGCHLD: signal_t = 16;
278pub const SIGCONT: signal_t = 17;
279pub const SIGSTOP: signal_t = 18;
280pub const SIGTSTP: signal_t = 19;
281pub const SIGTTIN: signal_t = 20;
282pub const SIGTTOU: signal_t = 21;
283pub const SIGURG: signal_t = 22;
284pub const SIGXCPU: signal_t = 23;
285pub const SIGXFSZ: signal_t = 24;
286pub const SIGVTALRM: signal_t = 25;
287pub const SIGPROF: signal_t = 26;
288pub const SIGWINCH: signal_t = 27;
289pub const SIGPOLL: signal_t = 28;
290pub const SIGPWR: signal_t = 29;
291pub const SIGSYS: signal_t = 30;
292
293pub const subclockflags_t = u16;
294pub const SUBSCRIPTION_CLOCK_ABSTIME: subclockflags_t = 0x0001;
295
296pub const subscription_t = extern struct {
297 userdata: userdata_t,
298 @"type": eventtype_t,
299 u: extern union {
300 clock: extern struct {
301 identifier: userdata_t,
302 clock_id: clockid_t,
303 timeout: timestamp_t,
304 precision: timestamp_t,
305 flags: subclockflags_t,
306 },
307 fd_readwrite: extern struct {
308 fd: fd_t,
309 },
310 },
311};
312
313pub const timestamp_t = u64;
314
315pub const userdata_t = u64;
316
317pub const whence_t = u8;
318pub const WHENCE_CUR: whence_t = 0;
319pub const WHENCE_END: whence_t = 1;
320pub const WHENCE_SET: whence_t = 2;
std/os/windows.zig+8-6
...@@ -1,12 +1,14 @@...@@ -1,12 +1,14 @@
1// This file contains the types and constants of the Windows API,1// This file contains thin wrappers around Windows-specific APIs, with these
2// as well as the Windows-equivalent of "Zig-flavored POSIX" API layer.2// specific goals in mind:
3// * Convert "errno"-style error codes into Zig errors.
4// * When null-terminated or UTF16LE byte buffers are required, provide APIs which accept
5// slices as well as APIs which accept null-terminated UTF16LE byte buffers.
6
3const std = @import("../std.zig");7const std = @import("../std.zig");
4const assert = std.debug.assert;8const assert = std.debug.assert;
5const maxInt = std.math.maxInt;9const maxInt = std.math.maxInt;
610
7pub const is_the_target = builtin.os == .windows;11pub const is_the_target = builtin.os == .windows;
8pub const posix = if (builtin.link_libc) struct {} else @import("windows/posix.zig");
9pub use posix;
1012
11pub const advapi32 = @import("windows/advapi32.zig");13pub const advapi32 = @import("windows/advapi32.zig");
12pub const kernel32 = @import("windows/kernel32.zig");14pub const kernel32 = @import("windows/kernel32.zig");
...@@ -565,7 +567,7 @@ pub fn CreateFile(...@@ -565,7 +567,7 @@ pub fn CreateFile(
565 share_mode: DWORD,567 share_mode: DWORD,
566 creation_disposition: DWORD,568 creation_disposition: DWORD,
567 flags_and_attrs: DWORD,569 flags_and_attrs: DWORD,
568) CreateFileError!fd_t {570) CreateFileError!HANDLE {
569 const file_path_w = try sliceToPrefixedFileW(file_path);571 const file_path_w = try sliceToPrefixedFileW(file_path);
570 return CreateFileW(&file_path_w, desired_access, share_mode, creation_disposition, flags_and_attrs);572 return CreateFileW(&file_path_w, desired_access, share_mode, creation_disposition, flags_and_attrs);
571}573}
...@@ -934,7 +936,7 @@ pub const GetStdHandleError = error{...@@ -934,7 +936,7 @@ pub const GetStdHandleError = error{
934 Unexpected,936 Unexpected,
935};937};
936938
937pub fn GetStdHandle(handle_id: DWORD) GetStdHandleError!fd_t {939pub fn GetStdHandle(handle_id: DWORD) GetStdHandleError!HANDLE {
938 const handle = kernel32.GetStdHandle(handle_id) orelse return error.NoStandardHandleAttached;940 const handle = kernel32.GetStdHandle(handle_id) orelse return error.NoStandardHandleAttached;
939 if (handle == INVALID_HANDLE_VALUE) {941 if (handle == INVALID_HANDLE_VALUE) {
940 switch (kernel32.GetLastError()) {942 switch (kernel32.GetLastError()) {
std/os/windows/posix.zig deleted-6
...@@ -1,6 +0,0 @@
1// Declarations that are intended to be imported into the POSIX namespace,
2// when not linking libc.
3const std = @import("../../std.zig");
4const builtin = @import("builtin");
5
6pub const fd_t = std.os.windows.HANDLE;
std/os/zen.zig+1-1
...@@ -80,7 +80,7 @@ pub const STDOUT_FILENO = 1;...@@ -80,7 +80,7 @@ pub const STDOUT_FILENO = 1;
80pub const STDERR_FILENO = 2;80pub const STDERR_FILENO = 2;
8181
82// FIXME: let's borrow Linux's error numbers for now.82// FIXME: let's borrow Linux's error numbers for now.
83use @import("linux/errno.zig");83use @import("../bits/linux/errno.zig");
84// Get the errno from a syscall return value, or 0 for no error.84// Get the errno from a syscall return value, or 0 for no error.
85pub fn getErrno(r: usize) usize {85pub fn getErrno(r: usize) usize {
86 const signed_r = @bitCast(isize, r);86 const signed_r = @bitCast(isize, r);