authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-08-25 00:00:39-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-09-01 17:54:06-07:00
log7f03cfe161a2f7b5abbd00ab1ea29ddd6190d435
tree5e3a36e5d74e2d07706b817953e74f13a67c272d
parentc09ba8796c64a0bd3a39d6545b852c1b2e91f473

std.os: more reorganization efforts

* std lib tests are passing on x86_64-linux with and without -lc * stage2 is building from source on x86_64-linux * down to 38 remaining uses of `usingnamespace`

43 files changed, 3147 insertions(+), 3281 deletions(-)

lib/std/Thread.zig+8-8
...@@ -877,8 +877,8 @@ const LinuxThreadImpl = struct {...@@ -877,8 +877,8 @@ const LinuxThreadImpl = struct {
877 const mapped = os.mmap(877 const mapped = os.mmap(
878 null,878 null,
879 map_bytes,879 map_bytes,
880 os.PROT_NONE,880 os.PROT.NONE,
881 os.MAP_PRIVATE | os.MAP_ANONYMOUS,881 os.MAP.PRIVATE | os.MAP.ANONYMOUS,
882 -1,882 -1,
883 0,883 0,
884 ) catch |err| switch (err) {884 ) catch |err| switch (err) {
...@@ -893,7 +893,7 @@ const LinuxThreadImpl = struct {...@@ -893,7 +893,7 @@ const LinuxThreadImpl = struct {
893 // map everything but the guard page as read/write893 // map everything but the guard page as read/write
894 os.mprotect(894 os.mprotect(
895 mapped[guard_offset..],895 mapped[guard_offset..],
896 os.PROT_READ | os.PROT_WRITE,896 os.PROT.READ | os.PROT.WRITE,
897 ) catch |err| switch (err) {897 ) catch |err| switch (err) {
898 error.AccessDenied => unreachable,898 error.AccessDenied => unreachable,
899 else => |e| return e,899 else => |e| return e,
...@@ -923,10 +923,10 @@ const LinuxThreadImpl = struct {...@@ -923,10 +923,10 @@ const LinuxThreadImpl = struct {
923 .thread = .{ .mapped = mapped },923 .thread = .{ .mapped = mapped },
924 };924 };
925925
926 const flags: u32 = os.CLONE_THREAD | os.CLONE_DETACHED |926 const flags: u32 = linux.CLONE.THREAD | linux.CLONE.DETACHED |
927 os.CLONE_VM | os.CLONE_FS | os.CLONE_FILES |927 linux.CLONE.VM | linux.CLONE.FS | linux.CLONE.FILES |
928 os.CLONE_PARENT_SETTID | os.CLONE_CHILD_CLEARTID |928 linux.CLONE.PARENT_SETTID | linux.CLONE.CHILD_CLEARTID |
929 os.CLONE_SIGHAND | os.CLONE_SYSVSEM | os.CLONE_SETTLS;929 linux.CLONE.SIGHAND | linux.CLONE.SYSVSEM | linux.CLONE.SETTLS;
930930
931 switch (linux.getErrno(linux.clone(931 switch (linux.getErrno(linux.clone(
932 Instance.entryFn,932 Instance.entryFn,
...@@ -978,7 +978,7 @@ const LinuxThreadImpl = struct {...@@ -978,7 +978,7 @@ const LinuxThreadImpl = struct {
978978
979 switch (linux.getErrno(linux.futex_wait(979 switch (linux.getErrno(linux.futex_wait(
980 &self.thread.child_tid.value,980 &self.thread.child_tid.value,
981 linux.FUTEX_WAIT,981 linux.FUTEX.WAIT,
982 tid,982 tid,
983 null,983 null,
984 ))) {984 ))) {
lib/std/Thread/Futex.zig+3-3
...@@ -142,7 +142,7 @@ const LinuxFutex = struct {...@@ -142,7 +142,7 @@ const LinuxFutex = struct {
142142
143 switch (linux.getErrno(linux.futex_wait(143 switch (linux.getErrno(linux.futex_wait(
144 @ptrCast(*const i32, ptr),144 @ptrCast(*const i32, ptr),
145 linux.FUTEX_PRIVATE_FLAG | linux.FUTEX_WAIT,145 linux.FUTEX.PRIVATE_FLAG | linux.FUTEX.WAIT,
146 @bitCast(i32, expect),146 @bitCast(i32, expect),
147 ts_ptr,147 ts_ptr,
148 ))) {148 ))) {
...@@ -159,7 +159,7 @@ const LinuxFutex = struct {...@@ -159,7 +159,7 @@ const LinuxFutex = struct {
159 fn wake(ptr: *const Atomic(u32), num_waiters: u32) void {159 fn wake(ptr: *const Atomic(u32), num_waiters: u32) void {
160 switch (linux.getErrno(linux.futex_wake(160 switch (linux.getErrno(linux.futex_wake(
161 @ptrCast(*const i32, ptr),161 @ptrCast(*const i32, ptr),
162 linux.FUTEX_PRIVATE_FLAG | linux.FUTEX_WAKE,162 linux.FUTEX.PRIVATE_FLAG | linux.FUTEX.WAKE,
163 std.math.cast(i32, num_waiters) catch std.math.maxInt(i32),163 std.math.cast(i32, num_waiters) catch std.math.maxInt(i32),
164 ))) {164 ))) {
165 .SUCCESS => {}, // successful wake up165 .SUCCESS => {}, // successful wake up
...@@ -352,7 +352,7 @@ const PosixFutex = struct {...@@ -352,7 +352,7 @@ const PosixFutex = struct {
352 var ts_ptr: ?*const std.os.timespec = null;352 var ts_ptr: ?*const std.os.timespec = null;
353 if (timeout) |timeout_ns| {353 if (timeout) |timeout_ns| {
354 ts_ptr = &ts;354 ts_ptr = &ts;
355 std.os.clock_gettime(std.os.CLOCK_REALTIME, &ts) catch unreachable;355 std.os.clock_gettime(std.os.CLOCK.REALTIME, &ts) catch unreachable;
356 ts.tv_sec += @intCast(@TypeOf(ts.tv_sec), timeout_ns / std.time.ns_per_s);356 ts.tv_sec += @intCast(@TypeOf(ts.tv_sec), timeout_ns / std.time.ns_per_s);
357 ts.tv_nsec += @intCast(@TypeOf(ts.tv_nsec), timeout_ns % std.time.ns_per_s);357 ts.tv_nsec += @intCast(@TypeOf(ts.tv_nsec), timeout_ns % std.time.ns_per_s);
358 if (ts.tv_nsec >= std.time.ns_per_s) {358 if (ts.tv_nsec >= std.time.ns_per_s) {
lib/std/Thread/ResetEvent.zig+1-1
...@@ -152,7 +152,7 @@ pub const PosixEvent = struct {...@@ -152,7 +152,7 @@ pub const PosixEvent = struct {
152 pub fn timedWait(ev: *PosixEvent, timeout_ns: u64) TimedWaitResult {152 pub fn timedWait(ev: *PosixEvent, timeout_ns: u64) TimedWaitResult {
153 var ts: os.timespec = undefined;153 var ts: os.timespec = undefined;
154 var timeout_abs = timeout_ns;154 var timeout_abs = timeout_ns;
155 os.clock_gettime(os.CLOCK_REALTIME, &ts) catch return .timed_out;155 os.clock_gettime(os.CLOCK.REALTIME, &ts) catch return .timed_out;
156 timeout_abs += @intCast(u64, ts.tv_sec) * time.ns_per_s;156 timeout_abs += @intCast(u64, ts.tv_sec) * time.ns_per_s;
157 timeout_abs += @intCast(u64, ts.tv_nsec);157 timeout_abs += @intCast(u64, ts.tv_nsec);
158 ts.tv_sec = @intCast(@TypeOf(ts.tv_sec), @divFloor(timeout_abs, time.ns_per_s));158 ts.tv_sec = @intCast(@TypeOf(ts.tv_sec), @divFloor(timeout_abs, time.ns_per_s));
lib/std/c.zig+52-15
...@@ -1,6 +1,8 @@...@@ -1,6 +1,8 @@
1const std = @import("std");1const std = @import("std");
2const builtin = std.builtin;2const builtin = std.builtin;
3const page_size = std.mem.page_size;3const page_size = std.mem.page_size;
4const iovec = std.os.iovec;
5const iovec_const = std.os.iovec_const;
46
5pub const tokenizer = @import("c/tokenizer.zig");7pub const tokenizer = @import("c/tokenizer.zig");
6pub const Token = tokenizer.Token;8pub const Token = tokenizer.Token;
...@@ -28,14 +30,9 @@ const system = switch (builtin.os.tag) {...@@ -28,14 +30,9 @@ const system = switch (builtin.os.tag) {
28 .wasi => @import("c/wasi.zig"),30 .wasi => @import("c/wasi.zig"),
29 else => struct {},31 else => struct {},
30};32};
31pub const E = system.E;33
32pub const _errno = system._errno;34pub const _errno = system._errno;
33pub const MAP_FAILED = system.MAP_FAILED;35pub const copy_file_range = system.copy_file_range;
34pub const AI = system.AI;
35pub const NI = system.NI;
36pub const EAI = system.EAI;
37pub const timespec = system.timespec;
38pub const Sigaction = system.Sigaction;
39pub const fallocate64 = system.fallocate64;36pub const fallocate64 = system.fallocate64;
40pub const fopen64 = system.fopen64;37pub const fopen64 = system.fopen64;
41pub const fstat64 = system.fstat64;38pub const fstat64 = system.fstat64;
...@@ -53,21 +50,53 @@ pub const pwritev64 = system.pwritev64;...@@ -53,21 +50,53 @@ pub const pwritev64 = system.pwritev64;
53pub const sendfile64 = system.sendfile64;50pub const sendfile64 = system.sendfile64;
54pub const setrlimit64 = system.setrlimit64;51pub const setrlimit64 = system.setrlimit64;
5552
53pub const AF = system.AF;
54pub const AI = system.AI;
56pub const AT = system.AT;55pub const AT = system.AT;
57pub const CLOCK = system.CLOCK;56pub const CLOCK = system.CLOCK;
57pub const CPU_COUNT = system.CPU_COUNT;
58pub const E = system.E;
59pub const EAI = system.EAI;
60pub const F = system.F;
61pub const FD_CLOEXEC = system.FD_CLOEXEC;
62pub const F_OK = system.F_OK;
63pub const HOST_NAME_MAX = system.HOST_NAME_MAX;
64pub const IFNAMESIZE = system.IFNAMESIZE;
58pub const IOV_MAX = system.IOV_MAX;65pub const IOV_MAX = system.IOV_MAX;
66pub const IPPROTO = system.IPPROTO;
67pub const LOCK = system.LOCK;
68pub const MADV = system.MADV;
69pub const MAP = system.MAP;
59pub const NAME_MAX = system.NAME_MAX;70pub const NAME_MAX = system.NAME_MAX;
71pub const NI = system.NI;
72pub const O = system.O;
60pub const PATH_MAX = system.PATH_MAX;73pub const PATH_MAX = system.PATH_MAX;
74pub const POLL = system.POLL;
61pub const PROT = system.PROT;75pub const PROT = system.PROT;
76pub const REG = system.REG;
77pub const RLIM = system.RLIM;
62pub const RTLD = system.RTLD;78pub const RTLD = system.RTLD;
79pub const R_OK = system.R_OK;
63pub const S = system.S;80pub const S = system.S;
64pub const SA = system.SA;81pub const SA = system.SA;
82pub const SEEK = system.SEEK;
83pub const SHUT = system.SHUT;
65pub const SIG = system.SIG;84pub const SIG = system.SIG;
85pub const SIOCGIFINDEX = system.SIOCGIFINDEX;
86pub const SO = system.SO;
87pub const SOCK = system.SOCK;
88pub const SOL = system.SOL;
66pub const STDERR_FILENO = system.STDIN_FILENO;89pub const STDERR_FILENO = system.STDIN_FILENO;
67pub const STDIN_FILENO = system.STDIN_FILENO;90pub const STDIN_FILENO = system.STDIN_FILENO;
68pub const STDOUT_FILENO = system.STDIN_FILENO;91pub const STDOUT_FILENO = system.STDIN_FILENO;
92pub const Sigaction = system.Sigaction;
69pub const Stat = system.Stat;93pub const Stat = system.Stat;
70pub const copy_file_range = system.copy_file_range;94pub const W = system.W;
95pub const W_OK = system.W_OK;
96pub const X_OK = system.X_OK;
97pub const addrinfo = system.addrinfo;
98pub const cpu_set_t = system.cpu_set_t;
99pub const dl_iterate_phdr = system.dl_iterate_phdr;
71pub const dl_iterate_phdr_callback = system.dl_iterate_phdr_callback;100pub const dl_iterate_phdr_callback = system.dl_iterate_phdr_callback;
72pub const dl_phdr_info = system.dl_phdr_info;101pub const dl_phdr_info = system.dl_phdr_info;
73pub const empty_sigset = system.empty_sigset;102pub const empty_sigset = system.empty_sigset;
...@@ -81,12 +110,19 @@ pub const fd_t = system.fd_t;...@@ -81,12 +110,19 @@ pub const fd_t = system.fd_t;
81pub const getauxval = system.getauxval;110pub const getauxval = system.getauxval;
82pub const getdents = system.getdents;111pub const getdents = system.getdents;
83pub const getrandom = system.getrandom;112pub const getrandom = system.getrandom;
113pub const gid_t = system.gid_t;
114pub const ifreq = system.ifreq;
115pub const ino_t = system.ino_t;
84pub const inotify_add_watch = system.inotify_add_watch;116pub const inotify_add_watch = system.inotify_add_watch;
85pub const inotify_init1 = system.inotify_init1;117pub const inotify_init1 = system.inotify_init1;
86pub const inotify_rm_watch = system.inotify_rm_watch;118pub const inotify_rm_watch = system.inotify_rm_watch;
87pub const madvise = system.madvise;119pub const madvise = system.madvise;
88pub const malloc_usable_size = system.malloc_usable_size;120pub const malloc_usable_size = system.malloc_usable_size;
89pub const memfd_create = system.memfd_create;121pub const memfd_create = system.memfd_create;
122pub const mode_t = system.mode_t;
123pub const nfds_t = system.nfds_t;
124pub const off_t = system.off_t;
125pub const pid_t = system.pid_t;
90pub const pipe2 = system.pipe2;126pub const pipe2 = system.pipe2;
91pub const pollfd = system.pollfd;127pub const pollfd = system.pollfd;
92pub const posix_memalign = system.posix_memalign;128pub const posix_memalign = system.posix_memalign;
...@@ -97,6 +133,7 @@ pub const pthread_getname_np = system.pthread_getname_np;...@@ -97,6 +133,7 @@ pub const pthread_getname_np = system.pthread_getname_np;
97pub const pthread_mutex_t = system.pthread_mutex_t;133pub const pthread_mutex_t = system.pthread_mutex_t;
98pub const pthread_rwlock_t = system.pthread_rwlock_t;134pub const pthread_rwlock_t = system.pthread_rwlock_t;
99pub const pthread_setname_np = system.pthread_setname_np;135pub const pthread_setname_np = system.pthread_setname_np;
136pub const rlim_t = system.rlim_t;
100pub const rlimit = system.rlimit;137pub const rlimit = system.rlimit;
101pub const rlimit_resource = system.rlimit_resource;138pub const rlimit_resource = system.rlimit_resource;
102pub const sched_getaffinity = system.sched_getaffinity;139pub const sched_getaffinity = system.sched_getaffinity;
...@@ -106,14 +143,14 @@ pub const sigaltstack = system.sigaltstack;...@@ -106,14 +143,14 @@ pub const sigaltstack = system.sigaltstack;
106pub const siginfo_t = system.siginfo_t;143pub const siginfo_t = system.siginfo_t;
107pub const signalfd = system.signalfd;144pub const signalfd = system.signalfd;
108pub const sigset_t = system.sigset_t;145pub const sigset_t = system.sigset_t;
109pub const MAP = system.MAP;146pub const sockaddr = system.sockaddr;
110pub const LOCK = system.LOCK;147pub const socklen_t = system.socklen_t;
111pub const REG = system.REG;148pub const stack_t = system.stack_t;
112pub const dl_iterate_phdr = system.dl_iterate_phdr;149pub const timespec = system.timespec;
113pub const ino_t = system.ino_t;150pub const timeval = system.timeval;
114pub const mode_t = system.mode_t;
115pub const ucontext_t = system.ucontext_t;151pub const ucontext_t = system.ucontext_t;
116pub const O = system.O;152pub const uid_t = system.uid_t;
153pub const utsname = system.utsname;
117154
118pub const alarm = if (@hasDecl(system, "alarm")) system.alarm else generic.alarm;155pub const alarm = if (@hasDecl(system, "alarm")) system.alarm else generic.alarm;
119pub const clock_getres = if (@hasDecl(system, "clock_getres")) system.clock_getres else generic.clock_getres;156pub const clock_getres = if (@hasDecl(system, "clock_getres")) system.clock_getres else generic.clock_getres;
lib/std/c/darwin.zig+247-231
...@@ -109,17 +109,16 @@ pub fn sigaddset(set: *sigset_t, signo: u5) void {...@@ -109,17 +109,16 @@ pub fn sigaddset(set: *sigset_t, signo: u5) void {
109109
110pub extern "c" fn sigaltstack(ss: ?*stack_t, old_ss: ?*stack_t) c_int;110pub extern "c" fn sigaltstack(ss: ?*stack_t, old_ss: ?*stack_t) c_int;
111111
112/// get address to use bind()112pub const AI = struct {
113pub const AI_PASSIVE = 0x00000001;113 /// get address to use bind()
114114 pub const PASSIVE = 0x00000001;
115/// fill ai_canonname115 /// fill ai_canonname
116pub const AI_CANONNAME = 0x00000002;116 pub const CANONNAME = 0x00000002;
117117 /// prevent host name resolution
118/// prevent host name resolution118 pub const NUMERICHOST = 0x00000004;
119pub const AI_NUMERICHOST = 0x00000004;119 /// prevent service name resolution
120120 pub const NUMERICSERV = 0x00001000;
121/// prevent service name resolution121};
122pub const AI_NUMERICSERV = 0x00001000;
123122
124pub const EAI = enum(c_int) {123pub const EAI = enum(c_int) {
125 /// address family for hostname not supported124 /// address family for hostname not supported
...@@ -292,31 +291,31 @@ pub const sockaddr = extern struct {...@@ -292,31 +291,31 @@ pub const sockaddr = extern struct {
292 len: u8,291 len: u8,
293 family: sa_family_t,292 family: sa_family_t,
294 data: [14]u8,293 data: [14]u8,
295};
296pub const sockaddr_storage = std.x.os.Socket.Address.Native.Storage;
297pub const sockaddr_in = extern struct {
298 len: u8 = @sizeOf(sockaddr_in),
299 family: sa_family_t = AF_INET,
300 port: in_port_t,
301 addr: u32,
302 zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },
303};
304pub const sockaddr_in6 = extern struct {
305 len: u8 = @sizeOf(sockaddr_in6),
306 family: sa_family_t = AF_INET6,
307 port: in_port_t,
308 flowinfo: u32,
309 addr: [16]u8,
310 scope_id: u32,
311};
312294
313/// UNIX domain socket295 pub const storage = std.x.os.Socket.Address.Native.Storage;
314pub const sockaddr_un = extern struct {296 pub const in = extern struct {
315 len: u8 = @sizeOf(sockaddr_un),297 len: u8 = @sizeOf(in),
316 family: sa_family_t = AF_UNIX,298 family: sa_family_t = AF.INET,
317 path: [104]u8,299 port: in_port_t,
300 addr: u32,
301 zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },
302 };
303 pub const in6 = extern struct {
304 len: u8 = @sizeOf(in6),
305 family: sa_family_t = AF.INET6,
306 port: in_port_t,
307 flowinfo: u32,
308 addr: [16]u8,
309 scope_id: u32,
310 };
311
312 /// UNIX domain socket
313 pub const un = extern struct {
314 len: u8 = @sizeOf(un),
315 family: sa_family_t = AF.UNIX,
316 path: [104]u8,
317 };
318};318};
319
320pub const timeval = extern struct {319pub const timeval = extern struct {
321 tv_sec: c_long,320 tv_sec: c_long,
322 tv_usec: i32,321 tv_usec: i32,
...@@ -521,30 +520,25 @@ pub const PROT_WRITE = 0x02;...@@ -521,30 +520,25 @@ pub const PROT_WRITE = 0x02;
521/// [MC2] pages can be executed520/// [MC2] pages can be executed
522pub const PROT_EXEC = 0x04;521pub const PROT_EXEC = 0x04;
523522
524/// allocated from memory, swap space523pub const MAP = struct {
525pub const MAP_ANONYMOUS = 0x1000;524 /// allocated from memory, swap space
526525 pub const ANONYMOUS = 0x1000;
527/// map from file (default)526 /// map from file (default)
528pub const MAP_FILE = 0x0000;527 pub const FILE = 0x0000;
529528 /// interpret addr exactly
530/// interpret addr exactly529 pub const FIXED = 0x0010;
531pub const MAP_FIXED = 0x0010;530 /// region may contain semaphores
532531 pub const HASSEMAPHORE = 0x0200;
533/// region may contain semaphores532 /// changes are private
534pub const MAP_HASSEMAPHORE = 0x0200;533 pub const PRIVATE = 0x0002;
535534 /// share changes
536/// changes are private535 pub const SHARED = 0x0001;
537pub const MAP_PRIVATE = 0x0002;536 /// don't cache pages for this mapping
538537 pub const NOCACHE = 0x0400;
539/// share changes538 /// don't reserve needed swap area
540pub const MAP_SHARED = 0x0001;539 pub const NORESERVE = 0x0040;
541540 pub const FAILED = @intToPtr(*c_void, maxInt(usize));
542/// don't cache pages for this mapping541};
543pub const MAP_NOCACHE = 0x0400;
544
545/// don't reserve needed swap area
546pub const MAP_NORESERVE = 0x0040;
547pub const MAP_FAILED = @intToPtr(*c_void, maxInt(usize));
548542
549/// [XSI] no hang in wait/no child to reap543/// [XSI] no hang in wait/no child to reap
550pub const WNOHANG = 0x00000001;544pub const WNOHANG = 0x00000001;
...@@ -980,136 +974,148 @@ pub const NOTE_MACH_CONTINUOUS_TIME = 0x00000080;...@@ -980,136 +974,148 @@ pub const NOTE_MACH_CONTINUOUS_TIME = 0x00000080;
980/// data is mach absolute time units974/// data is mach absolute time units
981pub const NOTE_MACHTIME = 0x00000100;975pub const NOTE_MACHTIME = 0x00000100;
982976
983pub const AF_UNSPEC = 0;977pub const AF = struct {
984pub const AF_LOCAL = 1;978 pub const UNSPEC = 0;
985pub const AF_UNIX = AF_LOCAL;979 pub const LOCAL = 1;
986pub const AF_INET = 2;980 pub const UNIX = LOCAL;
987pub const AF_SYS_CONTROL = 2;981 pub const INET = 2;
988pub const AF_IMPLINK = 3;982 pub const SYS_CONTROL = 2;
989pub const AF_PUP = 4;983 pub const IMPLINK = 3;
990pub const AF_CHAOS = 5;984 pub const PUP = 4;
991pub const AF_NS = 6;985 pub const CHAOS = 5;
992pub const AF_ISO = 7;986 pub const NS = 6;
993pub const AF_OSI = AF_ISO;987 pub const ISO = 7;
994pub const AF_ECMA = 8;988 pub const OSI = ISO;
995pub const AF_DATAKIT = 9;989 pub const ECMA = 8;
996pub const AF_CCITT = 10;990 pub const DATAKIT = 9;
997pub const AF_SNA = 11;991 pub const CCITT = 10;
998pub const AF_DECnet = 12;992 pub const SNA = 11;
999pub const AF_DLI = 13;993 pub const DECnet = 12;
1000pub const AF_LAT = 14;994 pub const DLI = 13;
1001pub const AF_HYLINK = 15;995 pub const LAT = 14;
1002pub const AF_APPLETALK = 16;996 pub const HYLINK = 15;
1003pub const AF_ROUTE = 17;997 pub const APPLETALK = 16;
1004pub const AF_LINK = 18;998 pub const ROUTE = 17;
1005pub const AF_XTP = 19;999 pub const LINK = 18;
1006pub const AF_COIP = 20;1000 pub const XTP = 19;
1007pub const AF_CNT = 21;1001 pub const COIP = 20;
1008pub const AF_RTIP = 22;1002 pub const CNT = 21;
1009pub const AF_IPX = 23;1003 pub const RTIP = 22;
1010pub const AF_SIP = 24;1004 pub const IPX = 23;
1011pub const AF_PIP = 25;1005 pub const SIP = 24;
1012pub const AF_ISDN = 28;1006 pub const PIP = 25;
1013pub const AF_E164 = AF_ISDN;1007 pub const ISDN = 28;
1014pub const AF_KEY = 29;1008 pub const E164 = ISDN;
1015pub const AF_INET6 = 30;1009 pub const KEY = 29;
1016pub const AF_NATM = 31;1010 pub const INET6 = 30;
1017pub const AF_SYSTEM = 32;1011 pub const NATM = 31;
1018pub const AF_NETBIOS = 33;1012 pub const SYSTEM = 32;
1019pub const AF_PPP = 34;1013 pub const NETBIOS = 33;
1020pub const AF_MAX = 40;1014 pub const PPP = 34;
10211015 pub const MAX = 40;
1022pub const PF_UNSPEC = AF_UNSPEC;1016};
1023pub const PF_LOCAL = AF_LOCAL;1017
1024pub const PF_UNIX = PF_LOCAL;1018pub const PF = struct {
1025pub const PF_INET = AF_INET;1019 pub const UNSPEC = AF.UNSPEC;
1026pub const PF_IMPLINK = AF_IMPLINK;1020 pub const LOCAL = AF.LOCAL;
1027pub const PF_PUP = AF_PUP;1021 pub const UNIX = PF.LOCAL;
1028pub const PF_CHAOS = AF_CHAOS;1022 pub const INET = AF.INET;
1029pub const PF_NS = AF_NS;1023 pub const IMPLINK = AF.IMPLINK;
1030pub const PF_ISO = AF_ISO;1024 pub const PUP = AF.PUP;
1031pub const PF_OSI = AF_ISO;1025 pub const CHAOS = AF.CHAOS;
1032pub const PF_ECMA = AF_ECMA;1026 pub const NS = AF.NS;
1033pub const PF_DATAKIT = AF_DATAKIT;1027 pub const ISO = AF.ISO;
1034pub const PF_CCITT = AF_CCITT;1028 pub const OSI = AF.ISO;
1035pub const PF_SNA = AF_SNA;1029 pub const ECMA = AF.ECMA;
1036pub const PF_DECnet = AF_DECnet;1030 pub const DATAKIT = AF.DATAKIT;
1037pub const PF_DLI = AF_DLI;1031 pub const CCITT = AF.CCITT;
1038pub const PF_LAT = AF_LAT;1032 pub const SNA = AF.SNA;
1039pub const PF_HYLINK = AF_HYLINK;1033 pub const DECnet = AF.DECnet;
1040pub const PF_APPLETALK = AF_APPLETALK;1034 pub const DLI = AF.DLI;
1041pub const PF_ROUTE = AF_ROUTE;1035 pub const LAT = AF.LAT;
1042pub const PF_LINK = AF_LINK;1036 pub const HYLINK = AF.HYLINK;
1043pub const PF_XTP = AF_XTP;1037 pub const APPLETALK = AF.APPLETALK;
1044pub const PF_COIP = AF_COIP;1038 pub const ROUTE = AF.ROUTE;
1045pub const PF_CNT = AF_CNT;1039 pub const LINK = AF.LINK;
1046pub const PF_SIP = AF_SIP;1040 pub const XTP = AF.XTP;
1047pub const PF_IPX = AF_IPX;1041 pub const COIP = AF.COIP;
1048pub const PF_RTIP = AF_RTIP;1042 pub const CNT = AF.CNT;
1049pub const PF_PIP = AF_PIP;1043 pub const SIP = AF.SIP;
1050pub const PF_ISDN = AF_ISDN;1044 pub const IPX = AF.IPX;
1051pub const PF_KEY = AF_KEY;1045 pub const RTIP = AF.RTIP;
1052pub const PF_INET6 = AF_INET6;1046 pub const PIP = AF.PIP;
1053pub const PF_NATM = AF_NATM;1047 pub const ISDN = AF.ISDN;
1054pub const PF_SYSTEM = AF_SYSTEM;1048 pub const KEY = AF.KEY;
1055pub const PF_NETBIOS = AF_NETBIOS;1049 pub const INET6 = AF.INET6;
1056pub const PF_PPP = AF_PPP;1050 pub const NATM = AF.NATM;
1057pub const PF_MAX = AF_MAX;1051 pub const SYSTEM = AF.SYSTEM;
1052 pub const NETBIOS = AF.NETBIOS;
1053 pub const PPP = AF.PPP;
1054 pub const MAX = AF.MAX;
1055};
10581056
1059pub const SYSPROTO_EVENT = 1;1057pub const SYSPROTO_EVENT = 1;
1060pub const SYSPROTO_CONTROL = 2;1058pub const SYSPROTO_CONTROL = 2;
10611059
1062pub const SOCK_STREAM = 1;1060pub const SOCK = struct {
1063pub const SOCK_DGRAM = 2;1061 pub const STREAM = 1;
1064pub const SOCK_RAW = 3;1062 pub const DGRAM = 2;
1065pub const SOCK_RDM = 4;1063 pub const RAW = 3;
1066pub const SOCK_SEQPACKET = 5;1064 pub const RDM = 4;
1067pub const SOCK_MAXADDRLEN = 255;1065 pub const SEQPACKET = 5;
10681066 pub const MAXADDRLEN = 255;
1069/// Not actually supported by Darwin, but Zig supplies a shim.1067
1070/// This numerical value is not ABI-stable. It need only not conflict1068 /// Not actually supported by Darwin, but Zig supplies a shim.
1071/// with any other "SOCK_" bits.1069 /// This numerical value is not ABI-stable. It need only not conflict
1072pub const SOCK_CLOEXEC = 1 << 15;1070 /// with any other `SOCK` bits.
1073/// Not actually supported by Darwin, but Zig supplies a shim.1071 pub const CLOEXEC = 1 << 15;
1074/// This numerical value is not ABI-stable. It need only not conflict1072 /// Not actually supported by Darwin, but Zig supplies a shim.
1075/// with any other "SOCK_" bits.1073 /// This numerical value is not ABI-stable. It need only not conflict
1076pub const SOCK_NONBLOCK = 1 << 16;1074 /// with any other `SOCK` bits.
10771075 pub const NONBLOCK = 1 << 16;
1078pub const IPPROTO_ICMP = 1;1076};
1079pub const IPPROTO_ICMPV6 = 58;1077
1080pub const IPPROTO_TCP = 6;1078pub const IPPROTO = struct {
1081pub const IPPROTO_UDP = 17;1079 pub const ICMP = 1;
1082pub const IPPROTO_IP = 0;1080 pub const ICMPV6 = 58;
1083pub const IPPROTO_IPV6 = 41;1081 pub const TCP = 6;
10841082 pub const UDP = 17;
1085pub const SOL_SOCKET = 0xffff;1083 pub const IP = 0;
10861084 pub const IPV6 = 41;
1087pub const SO_DEBUG = 0x0001;1085};
1088pub const SO_ACCEPTCONN = 0x0002;1086
1089pub const SO_REUSEADDR = 0x0004;1087pub const SOL = struct {
1090pub const SO_KEEPALIVE = 0x0008;1088 pub const SOCKET = 0xffff;
1091pub const SO_DONTROUTE = 0x0010;1089};
1092pub const SO_BROADCAST = 0x0020;1090
1093pub const SO_USELOOPBACK = 0x0040;1091pub const SO = struct {
1094pub const SO_LINGER = 0x1080;1092 pub const DEBUG = 0x0001;
1095pub const SO_OOBINLINE = 0x0100;1093 pub const ACCEPTCONN = 0x0002;
1096pub const SO_REUSEPORT = 0x0200;1094 pub const REUSEADDR = 0x0004;
1097pub const SO_ACCEPTFILTER = 0x1000;1095 pub const KEEPALIVE = 0x0008;
1098pub const SO_SNDBUF = 0x1001;1096 pub const DONTROUTE = 0x0010;
1099pub const SO_RCVBUF = 0x1002;1097 pub const BROADCAST = 0x0020;
1100pub const SO_SNDLOWAT = 0x1003;1098 pub const USELOOPBACK = 0x0040;
1101pub const SO_RCVLOWAT = 0x1004;1099 pub const LINGER = 0x1080;
1102pub const SO_SNDTIMEO = 0x1005;1100 pub const OOBINLINE = 0x0100;
1103pub const SO_RCVTIMEO = 0x1006;1101 pub const REUSEPORT = 0x0200;
1104pub const SO_ERROR = 0x1007;1102 pub const ACCEPTFILTER = 0x1000;
1105pub const SO_TYPE = 0x1008;1103 pub const SNDBUF = 0x1001;
11061104 pub const RCVBUF = 0x1002;
1107pub const SO_NREAD = 0x1020;1105 pub const SNDLOWAT = 0x1003;
1108pub const SO_NKE = 0x1021;1106 pub const RCVLOWAT = 0x1004;
1109pub const SO_NOSIGPIPE = 0x1022;1107 pub const SNDTIMEO = 0x1005;
1110pub const SO_NOADDRERR = 0x1023;1108 pub const RCVTIMEO = 0x1006;
1111pub const SO_NWRITE = 0x1024;1109 pub const ERROR = 0x1007;
1112pub const SO_REUSESHAREUID = 0x1025;1110 pub const TYPE = 0x1008;
1111
1112 pub const NREAD = 0x1020;
1113 pub const NKE = 0x1021;
1114 pub const NOSIGPIPE = 0x1022;
1115 pub const NOADDRERR = 0x1023;
1116 pub const NWRITE = 0x1024;
1117 pub const REUSESHAREUID = 0x1025;
1118};
11131119
1114fn wstatus(x: u32) u32 {1120fn wstatus(x: u32) u32 {
1115 return x & 0o177;1121 return x & 0o177;
...@@ -1569,18 +1575,20 @@ pub const addrinfo = extern struct {...@@ -1569,18 +1575,20 @@ pub const addrinfo = extern struct {
1569 next: ?*addrinfo,1575 next: ?*addrinfo,
1570};1576};
15711577
1572pub const RTLD_LAZY = 0x1;1578pub const RTLD = struct {
1573pub const RTLD_NOW = 0x2;1579 pub const LAZY = 0x1;
1574pub const RTLD_LOCAL = 0x4;1580 pub const NOW = 0x2;
1575pub const RTLD_GLOBAL = 0x8;1581 pub const LOCAL = 0x4;
1576pub const RTLD_NOLOAD = 0x10;1582 pub const GLOBAL = 0x8;
1577pub const RTLD_NODELETE = 0x80;1583 pub const NOLOAD = 0x10;
1578pub const RTLD_FIRST = 0x100;1584 pub const NODELETE = 0x80;
15791585 pub const FIRST = 0x100;
1580pub const RTLD_NEXT = @intToPtr(*c_void, @bitCast(usize, @as(isize, -1)));1586
1581pub const RTLD_DEFAULT = @intToPtr(*c_void, @bitCast(usize, @as(isize, -2)));1587 pub const NEXT = @intToPtr(*c_void, @bitCast(usize, @as(isize, -1)));
1582pub const RTLD_SELF = @intToPtr(*c_void, @bitCast(usize, @as(isize, -3)));1588 pub const DEFAULT = @intToPtr(*c_void, @bitCast(usize, @as(isize, -2)));
1583pub const RTLD_MAIN_ONLY = @intToPtr(*c_void, @bitCast(usize, @as(isize, -5)));1589 pub const SELF = @intToPtr(*c_void, @bitCast(usize, @as(isize, -3)));
1590 pub const MAIN_ONLY = @intToPtr(*c_void, @bitCast(usize, @as(isize, -5)));
1591};
15841592
1585/// duplicate file descriptor1593/// duplicate file descriptor
1586pub const F_DUPFD = 0;1594pub const F_DUPFD = 0;
...@@ -1740,10 +1748,12 @@ pub const F_UNLCK = 2;...@@ -1740,10 +1748,12 @@ pub const F_UNLCK = 2;
1740/// exclusive or write lock1748/// exclusive or write lock
1741pub const F_WRLCK = 3;1749pub const F_WRLCK = 3;
17421750
1743pub const LOCK_SH = 1;1751pub const LOCK = struct {
1744pub const LOCK_EX = 2;1752 pub const SH = 1;
1745pub const LOCK_UN = 8;1753 pub const EX = 2;
1746pub const LOCK_NB = 4;1754 pub const UN = 8;
1755 pub const NB = 4;
1756};
17471757
1748pub const nfds_t = u32;1758pub const nfds_t = u32;
1749pub const pollfd = extern struct {1759pub const pollfd = extern struct {
...@@ -1752,33 +1762,37 @@ pub const pollfd = extern struct {...@@ -1752,33 +1762,37 @@ pub const pollfd = extern struct {
1752 revents: i16,1762 revents: i16,
1753};1763};
17541764
1755pub const POLLIN = 0x001;1765pub const POLL = struct {
1756pub const POLLPRI = 0x002;1766 pub const IN = 0x001;
1757pub const POLLOUT = 0x004;1767 pub const PRI = 0x002;
1758pub const POLLRDNORM = 0x040;1768 pub const OUT = 0x004;
1759pub const POLLWRNORM = POLLOUT;1769 pub const RDNORM = 0x040;
1760pub const POLLRDBAND = 0x080;1770 pub const WRNORM = OUT;
1761pub const POLLWRBAND = 0x100;1771 pub const RDBAND = 0x080;
17621772 pub const WRBAND = 0x100;
1763pub const POLLEXTEND = 0x0200;1773
1764pub const POLLATTRIB = 0x0400;1774 pub const EXTEND = 0x0200;
1765pub const POLLNLINK = 0x0800;1775 pub const ATTRIB = 0x0400;
1766pub const POLLWRITE = 0x1000;1776 pub const NLINK = 0x0800;
17671777 pub const WRITE = 0x1000;
1768pub const POLLERR = 0x008;1778
1769pub const POLLHUP = 0x010;1779 pub const ERR = 0x008;
1770pub const POLLNVAL = 0x020;1780 pub const HUP = 0x010;
17711781 pub const NVAL = 0x020;
1772pub const POLLSTANDARD = POLLIN | POLLPRI | POLLOUT | POLLRDNORM | POLLRDBAND | POLLWRBAND | POLLERR | POLLHUP | POLLNVAL;1782
17731783 pub const STANDARD = IN | PRI | OUT | RDNORM | RDBAND | WRBAND | ERR | HUP | NVAL;
1774pub const CLOCK_REALTIME = 0;1784};
1775pub const CLOCK_MONOTONIC = 6;1785
1776pub const CLOCK_MONOTONIC_RAW = 4;1786pub const CLOCK = struct {
1777pub const CLOCK_MONOTONIC_RAW_APPROX = 5;1787 pub const REALTIME = 0;
1778pub const CLOCK_UPTIME_RAW = 8;1788 pub const MONOTONIC = 6;
1779pub const CLOCK_UPTIME_RAW_APPROX = 9;1789 pub const MONOTONIC_RAW = 4;
1780pub const CLOCK_PROCESS_CPUTIME_ID = 12;1790 pub const MONOTONIC_RAW_APPROX = 5;
1781pub const CLOCK_THREAD_CPUTIME_ID = 16;1791 pub const UPTIME_RAW = 8;
1792 pub const UPTIME_RAW_APPROX = 9;
1793 pub const PROCESS_CPUTIME_ID = 12;
1794 pub const THREAD_CPUTIME_ID = 16;
1795};
17821796
1783/// Max open files per process1797/// Max open files per process
1784/// https://opensource.apple.com/source/xnu/xnu-4903.221.2/bsd/sys/syslimits.h.auto.html1798/// https://opensource.apple.com/source/xnu/xnu-4903.221.2/bsd/sys/syslimits.h.auto.html
...@@ -1822,11 +1836,13 @@ pub const rlimit_resource = enum(c_int) {...@@ -1822,11 +1836,13 @@ pub const rlimit_resource = enum(c_int) {
18221836
1823pub const rlim_t = u64;1837pub const rlim_t = u64;
18241838
1825/// No limit1839pub const RLIM = struct {
1826pub const RLIM_INFINITY: rlim_t = (1 << 63) - 1;1840 /// No limit
1841 pub const INFINITY: rlim_t = (1 << 63) - 1;
18271842
1828pub const RLIM_SAVED_MAX = RLIM_INFINITY;1843 pub const SAVED_MAX = INFINITY;
1829pub const RLIM_SAVED_CUR = RLIM_INFINITY;1844 pub const SAVED_CUR = INFINITY;
1845};
18301846
1831pub const rlimit = extern struct {1847pub const rlimit = extern struct {
1832 /// Soft limit1848 /// Soft limit
lib/std/c/dragonfly.zig+357-329
...@@ -161,25 +161,27 @@ pub const PROT_READ = 1;...@@ -161,25 +161,27 @@ pub const PROT_READ = 1;
161pub const PROT_WRITE = 2;161pub const PROT_WRITE = 2;
162pub const PROT_EXEC = 4;162pub const PROT_EXEC = 4;
163163
164pub const MAP_FILE = 0;164pub const MAP = struct {
165pub const MAP_FAILED = @intToPtr(*c_void, maxInt(usize));165 pub const FILE = 0;
166pub const MAP_ANONYMOUS = MAP_ANON;166 pub const FAILED = @intToPtr(*c_void, maxInt(usize));
167pub const MAP_COPY = MAP_PRIVATE;167 pub const ANONYMOUS = ANON;
168pub const MAP_SHARED = 1;168 pub const COPY = PRIVATE;
169pub const MAP_PRIVATE = 2;169 pub const SHARED = 1;
170pub const MAP_FIXED = 16;170 pub const PRIVATE = 2;
171pub const MAP_RENAME = 32;171 pub const FIXED = 16;
172pub const MAP_NORESERVE = 64;172 pub const RENAME = 32;
173pub const MAP_INHERIT = 128;173 pub const NORESERVE = 64;
174pub const MAP_NOEXTEND = 256;174 pub const INHERIT = 128;
175pub const MAP_HASSEMAPHORE = 512;175 pub const NOEXTEND = 256;
176pub const MAP_STACK = 1024;176 pub const HASSEMAPHORE = 512;
177pub const MAP_NOSYNC = 2048;177 pub const STACK = 1024;
178pub const MAP_ANON = 4096;178 pub const NOSYNC = 2048;
179pub const MAP_VPAGETABLE = 8192;179 pub const ANON = 4096;
180pub const MAP_TRYFIXED = 65536;180 pub const VPAGETABLE = 8192;
181pub const MAP_NOCORE = 131072;181 pub const TRYFIXED = 65536;
182pub const MAP_SIZEALIGN = 262144;182 pub const NOCORE = 131072;
183 pub const SIZEALIGN = 262144;
184};
183185
184pub const WNOHANG = 0x0001;186pub const WNOHANG = 0x0001;
185pub const WUNTRACED = 0x0002;187pub const WUNTRACED = 0x0002;
...@@ -407,28 +409,47 @@ pub const DT_SOCK = 12;...@@ -407,28 +409,47 @@ pub const DT_SOCK = 12;
407pub const DT_WHT = 14;409pub const DT_WHT = 14;
408pub const DT_DBF = 15;410pub const DT_DBF = 15;
409411
410pub const CLOCK_REALTIME = 0;412pub const CLOCK = struct {
411pub const CLOCK_VIRTUAL = 1;413 pub const REALTIME = 0;
412pub const CLOCK_PROF = 2;414 pub const VIRTUAL = 1;
413pub const CLOCK_MONOTONIC = 4;415 pub const PROF = 2;
414pub const CLOCK_UPTIME = 5;416 pub const MONOTONIC = 4;
415pub const CLOCK_UPTIME_PRECISE = 7;417 pub const UPTIME = 5;
416pub const CLOCK_UPTIME_FAST = 8;418 pub const UPTIME_PRECISE = 7;
417pub const CLOCK_REALTIME_PRECISE = 9;419 pub const UPTIME_FAST = 8;
418pub const CLOCK_REALTIME_FAST = 10;420 pub const REALTIME_PRECISE = 9;
419pub const CLOCK_MONOTONIC_PRECISE = 11;421 pub const REALTIME_FAST = 10;
420pub const CLOCK_MONOTONIC_FAST = 12;422 pub const MONOTONIC_PRECISE = 11;
421pub const CLOCK_SECOND = 13;423 pub const MONOTONIC_FAST = 12;
422pub const CLOCK_THREAD_CPUTIME_ID = 14;424 pub const SECOND = 13;
423pub const CLOCK_PROCESS_CPUTIME_ID = 15;425 pub const THREAD_CPUTIME_ID = 14;
426 pub const PROCESS_CPUTIME_ID = 15;
427};
424428
425pub const sockaddr = extern struct {429pub const sockaddr = extern struct {
426 len: u8,430 len: u8,
427 family: u8,431 family: u8,
428 data: [14]u8,432 data: [14]u8,
429};
430433
431pub const sockaddr_storage = std.x.os.Socket.Address.Native.Storage;434 pub const storage = std.x.os.Socket.Address.Native.Storage;
435
436 pub const in = extern struct {
437 len: u8 = @sizeOf(in),
438 family: sa_family_t = AF.INET,
439 port: in_port_t,
440 addr: u32,
441 zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },
442 };
443
444 pub const in6 = extern struct {
445 len: u8 = @sizeOf(in6),
446 family: sa_family_t = AF.INET6,
447 port: in_port_t,
448 flowinfo: u32,
449 addr: [16]u8,
450 scope_id: u32,
451 };
452};
432453
433pub const Kevent = extern struct {454pub const Kevent = extern struct {
434 ident: usize,455 ident: usize,
...@@ -616,135 +637,128 @@ pub const Sigaction = extern struct {...@@ -616,135 +637,128 @@ pub const Sigaction = extern struct {
616637
617pub const sig_t = [*c]fn (c_int) callconv(.C) void;638pub const sig_t = [*c]fn (c_int) callconv(.C) void;
618639
619pub const SOCK_STREAM = 1;640pub const SOCK = struct {
620pub const SOCK_DGRAM = 2;641 pub const STREAM = 1;
621pub const SOCK_RAW = 3;642 pub const DGRAM = 2;
622pub const SOCK_RDM = 4;643 pub const RAW = 3;
623pub const SOCK_SEQPACKET = 5;644 pub const RDM = 4;
624pub const SOCK_MAXADDRLEN = 255;645 pub const SEQPACKET = 5;
625pub const SOCK_CLOEXEC = 0x10000000;646 pub const MAXADDRLEN = 255;
626pub const SOCK_NONBLOCK = 0x20000000;647 pub const CLOEXEC = 0x10000000;
627648 pub const NONBLOCK = 0x20000000;
628pub const SO_DEBUG = 0x0001;649};
629pub const SO_ACCEPTCONN = 0x0002;
630pub const SO_REUSEADDR = 0x0004;
631pub const SO_KEEPALIVE = 0x0008;
632pub const SO_DONTROUTE = 0x0010;
633pub const SO_BROADCAST = 0x0020;
634pub const SO_USELOOPBACK = 0x0040;
635pub const SO_LINGER = 0x0080;
636pub const SO_OOBINLINE = 0x0100;
637pub const SO_REUSEPORT = 0x0200;
638pub const SO_TIMESTAMP = 0x0400;
639pub const SO_NOSIGPIPE = 0x0800;
640pub const SO_ACCEPTFILTER = 0x1000;
641pub const SO_RERROR = 0x2000;
642pub const SO_PASSCRED = 0x4000;
643
644pub const SO_SNDBUF = 0x1001;
645pub const SO_RCVBUF = 0x1002;
646pub const SO_SNDLOWAT = 0x1003;
647pub const SO_RCVLOWAT = 0x1004;
648pub const SO_SNDTIMEO = 0x1005;
649pub const SO_RCVTIMEO = 0x1006;
650pub const SO_ERROR = 0x1007;
651pub const SO_TYPE = 0x1008;
652pub const SO_SNDSPACE = 0x100a;
653pub const SO_CPUHINT = 0x1030;
654
655pub const SOL_SOCKET = 0xffff;
656
657pub const PF_INET6 = AF_INET6;
658pub const PF_IMPLINK = AF_IMPLINK;
659pub const PF_ROUTE = AF_ROUTE;
660pub const PF_ISO = AF_ISO;
661pub const PF_PIP = pseudo_AF_PIP;
662pub const PF_CHAOS = AF_CHAOS;
663pub const PF_DATAKIT = AF_DATAKIT;
664pub const PF_INET = AF_INET;
665pub const PF_APPLETALK = AF_APPLETALK;
666pub const PF_SIP = AF_SIP;
667pub const PF_OSI = AF_ISO;
668pub const PF_CNT = AF_CNT;
669pub const PF_LINK = AF_LINK;
670pub const PF_HYLINK = AF_HYLINK;
671pub const PF_MAX = AF_MAX;
672pub const PF_KEY = pseudo_AF_KEY;
673pub const PF_PUP = AF_PUP;
674pub const PF_COIP = AF_COIP;
675pub const PF_SNA = AF_SNA;
676pub const PF_LOCAL = AF_LOCAL;
677pub const PF_NETBIOS = AF_NETBIOS;
678pub const PF_NATM = AF_NATM;
679pub const PF_BLUETOOTH = AF_BLUETOOTH;
680pub const PF_UNSPEC = AF_UNSPEC;
681pub const PF_NETGRAPH = AF_NETGRAPH;
682pub const PF_ECMA = AF_ECMA;
683pub const PF_IPX = AF_IPX;
684pub const PF_DLI = AF_DLI;
685pub const PF_ATM = AF_ATM;
686pub const PF_CCITT = AF_CCITT;
687pub const PF_ISDN = AF_ISDN;
688pub const PF_RTIP = pseudo_AF_RTIP;
689pub const PF_LAT = AF_LAT;
690pub const PF_UNIX = PF_LOCAL;
691pub const PF_XTP = pseudo_AF_XTP;
692pub const PF_DECnet = AF_DECnet;
693
694pub const AF_UNSPEC = 0;
695pub const AF_OSI = AF_ISO;
696pub const AF_UNIX = AF_LOCAL;
697pub const AF_LOCAL = 1;
698pub const AF_INET = 2;
699pub const AF_IMPLINK = 3;
700pub const AF_PUP = 4;
701pub const AF_CHAOS = 5;
702pub const AF_NETBIOS = 6;
703pub const AF_ISO = 7;
704pub const AF_ECMA = 8;
705pub const AF_DATAKIT = 9;
706pub const AF_CCITT = 10;
707pub const AF_SNA = 11;
708pub const AF_DLI = 13;
709pub const AF_LAT = 14;
710pub const AF_HYLINK = 15;
711pub const AF_APPLETALK = 16;
712pub const AF_ROUTE = 17;
713pub const AF_LINK = 18;
714pub const AF_COIP = 20;
715pub const AF_CNT = 21;
716pub const AF_IPX = 23;
717pub const AF_SIP = 24;
718pub const AF_ISDN = 26;
719pub const AF_INET6 = 28;
720pub const AF_NATM = 29;
721pub const AF_ATM = 30;
722pub const AF_NETGRAPH = 32;
723pub const AF_BLUETOOTH = 33;
724pub const AF_MPLS = 34;
725pub const AF_MAX = 36;
726650
727pub const in_port_t = u16;651pub const SO = struct {
728pub const sa_family_t = u8;652 pub const DEBUG = 0x0001;
729pub const socklen_t = u32;653 pub const ACCEPTCONN = 0x0002;
654 pub const REUSEADDR = 0x0004;
655 pub const KEEPALIVE = 0x0008;
656 pub const DONTROUTE = 0x0010;
657 pub const BROADCAST = 0x0020;
658 pub const USELOOPBACK = 0x0040;
659 pub const LINGER = 0x0080;
660 pub const OOBINLINE = 0x0100;
661 pub const REUSEPORT = 0x0200;
662 pub const TIMESTAMP = 0x0400;
663 pub const NOSIGPIPE = 0x0800;
664 pub const ACCEPTFILTER = 0x1000;
665 pub const RERROR = 0x2000;
666 pub const PASSCRED = 0x4000;
667
668 pub const SNDBUF = 0x1001;
669 pub const RCVBUF = 0x1002;
670 pub const SNDLOWAT = 0x1003;
671 pub const RCVLOWAT = 0x1004;
672 pub const SNDTIMEO = 0x1005;
673 pub const RCVTIMEO = 0x1006;
674 pub const ERROR = 0x1007;
675 pub const TYPE = 0x1008;
676 pub const SNDSPACE = 0x100a;
677 pub const CPUHINT = 0x1030;
678};
730679
731pub const sockaddr_in = extern struct {680pub const SOL = struct {
732 len: u8 = @sizeOf(sockaddr_in),681 pub const SOCKET = 0xffff;
733 family: sa_family_t = AF_INET,
734 port: in_port_t,
735 addr: u32,
736 zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },
737};682};
738683
739pub const sockaddr_in6 = extern struct {684pub const PF = struct {
740 len: u8 = @sizeOf(sockaddr_in6),685 pub const INET6 = AF.INET6;
741 family: sa_family_t = AF_INET6,686 pub const IMPLINK = AF.IMPLINK;
742 port: in_port_t,687 pub const ROUTE = AF.ROUTE;
743 flowinfo: u32,688 pub const ISO = AF.ISO;
744 addr: [16]u8,689 pub const PIP = AF.pseudo_PIP;
745 scope_id: u32,690 pub const CHAOS = AF.CHAOS;
691 pub const DATAKIT = AF.DATAKIT;
692 pub const INET = AF.INET;
693 pub const APPLETALK = AF.APPLETALK;
694 pub const SIP = AF.SIP;
695 pub const OSI = AF.ISO;
696 pub const CNT = AF.CNT;
697 pub const LINK = AF.LINK;
698 pub const HYLINK = AF.HYLINK;
699 pub const MAX = AF.MAX;
700 pub const KEY = AF.pseudo_KEY;
701 pub const PUP = AF.PUP;
702 pub const COIP = AF.COIP;
703 pub const SNA = AF.SNA;
704 pub const LOCAL = AF.LOCAL;
705 pub const NETBIOS = AF.NETBIOS;
706 pub const NATM = AF.NATM;
707 pub const BLUETOOTH = AF.BLUETOOTH;
708 pub const UNSPEC = AF.UNSPEC;
709 pub const NETGRAPH = AF.NETGRAPH;
710 pub const ECMA = AF.ECMA;
711 pub const IPX = AF.IPX;
712 pub const DLI = AF.DLI;
713 pub const ATM = AF.ATM;
714 pub const CCITT = AF.CCITT;
715 pub const ISDN = AF.ISDN;
716 pub const RTIP = AF.pseudo_RTIP;
717 pub const LAT = AF.LAT;
718 pub const UNIX = PF_LOCAL;
719 pub const XTP = AF.pseudo_XTP;
720 pub const DECnet = AF.DECnet;
746};721};
747722
723pub const AF = struct {
724 pub const UNSPEC = 0;
725 pub const OSI = ISO;
726 pub const UNIX = LOCAL;
727 pub const LOCAL = 1;
728 pub const INET = 2;
729 pub const IMPLINK = 3;
730 pub const PUP = 4;
731 pub const CHAOS = 5;
732 pub const NETBIOS = 6;
733 pub const ISO = 7;
734 pub const ECMA = 8;
735 pub const DATAKIT = 9;
736 pub const CCITT = 10;
737 pub const SNA = 11;
738 pub const DLI = 13;
739 pub const LAT = 14;
740 pub const HYLINK = 15;
741 pub const APPLETALK = 16;
742 pub const ROUTE = 17;
743 pub const LINK = 18;
744 pub const COIP = 20;
745 pub const CNT = 21;
746 pub const IPX = 23;
747 pub const SIP = 24;
748 pub const ISDN = 26;
749 pub const INET6 = 28;
750 pub const NATM = 29;
751 pub const ATM = 30;
752 pub const NETGRAPH = 32;
753 pub const BLUETOOTH = 33;
754 pub const MPLS = 34;
755 pub const MAX = 36;
756};
757
758pub const in_port_t = u16;
759pub const sa_family_t = u8;
760pub const socklen_t = u32;
761
748pub const EAI = enum(c_int) {762pub const EAI = enum(c_int) {
749 ADDRFAMILY = 1,763 ADDRFAMILY = 1,
750 AGAIN = 2,764 AGAIN = 2,
...@@ -763,30 +777,34 @@ pub const EAI = enum(c_int) {...@@ -763,30 +777,34 @@ pub const EAI = enum(c_int) {
763 _,777 _,
764};778};
765779
766pub const AI_PASSIVE = 0x00000001;780pub const AI = struct {
767pub const AI_CANONNAME = 0x00000002;781 pub const PASSIVE = 0x00000001;
768pub const AI_NUMERICHOST = 0x00000004;782 pub const CANONNAME = 0x00000002;
769pub const AI_NUMERICSERV = 0x00000008;783 pub const NUMERICHOST = 0x00000004;
770pub const AI_MASK = AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST | AI_NUMERICSERV | AI_ADDRCONFIG;784 pub const NUMERICSERV = 0x00000008;
771pub const AI_ALL = 0x00000100;785 pub const MASK = PASSIVE | CANONNAME | NUMERICHOST | NUMERICSERV | ADDRCONFIG;
772pub const AI_V4MAPPED_CFG = 0x00000200;786 pub const ALL = 0x00000100;
773pub const AI_ADDRCONFIG = 0x00000400;787 pub const V4MAPPED_CFG = 0x00000200;
774pub const AI_V4MAPPED = 0x00000800;788 pub const ADDRCONFIG = 0x00000400;
775pub const AI_DEFAULT = AI_V4MAPPED_CFG | AI_ADDRCONFIG;789 pub const V4MAPPED = 0x00000800;
776790 pub const DEFAULT = V4MAPPED_CFG | ADDRCONFIG;
777pub const RTLD_LAZY = 1;791};
778pub const RTLD_NOW = 2;792
779pub const RTLD_MODEMASK = 0x3;793pub const RTLD = struct {
780pub const RTLD_GLOBAL = 0x100;794 pub const LAZY = 1;
781pub const RTLD_LOCAL = 0;795 pub const NOW = 2;
782pub const RTLD_TRACE = 0x200;796 pub const MODEMASK = 0x3;
783pub const RTLD_NODELETE = 0x01000;797 pub const GLOBAL = 0x100;
784pub const RTLD_NOLOAD = 0x02000;798 pub const LOCAL = 0;
785799 pub const TRACE = 0x200;
786pub const RTLD_NEXT = @intToPtr(*c_void, @bitCast(usize, @as(isize, -1)));800 pub const NODELETE = 0x01000;
787pub const RTLD_DEFAULT = @intToPtr(*c_void, @bitCast(usize, @as(isize, -2)));801 pub const NOLOAD = 0x02000;
788pub const RTLD_SELF = @intToPtr(*c_void, @bitCast(usize, @as(isize, -3)));802
789pub const RTLD_ALL = @intToPtr(*c_void, @bitCast(usize, @as(isize, -4)));803 pub const NEXT = @intToPtr(*c_void, @bitCast(usize, @as(isize, -1)));
804 pub const DEFAULT = @intToPtr(*c_void, @bitCast(usize, @as(isize, -2)));
805 pub const SELF = @intToPtr(*c_void, @bitCast(usize, @as(isize, -3)));
806 pub const ALL = @intToPtr(*c_void, @bitCast(usize, @as(isize, -4)));
807};
790808
791pub const dl_phdr_info = extern struct {809pub const dl_phdr_info = extern struct {
792 dlpi_addr: usize,810 dlpi_addr: usize,
...@@ -833,20 +851,22 @@ pub const POSIX_MADV_DONTNEED = 4;...@@ -833,20 +851,22 @@ pub const POSIX_MADV_DONTNEED = 4;
833pub const POSIX_MADV_NORMAL = 0;851pub const POSIX_MADV_NORMAL = 0;
834pub const POSIX_MADV_WILLNEED = 3;852pub const POSIX_MADV_WILLNEED = 3;
835853
836pub const MADV_SEQUENTIAL = 2;854pub const MADV = struct {
837pub const MADV_CONTROL_END = MADV_SETMAP;855 pub const SEQUENTIAL = 2;
838pub const MADV_DONTNEED = 4;856 pub const CONTROL_END = SETMAP;
839pub const MADV_RANDOM = 1;857 pub const DONTNEED = 4;
840pub const MADV_WILLNEED = 3;858 pub const RANDOM = 1;
841pub const MADV_NORMAL = 0;859 pub const WILLNEED = 3;
842pub const MADV_CONTROL_START = MADV_INVAL;860 pub const NORMAL = 0;
843pub const MADV_FREE = 5;861 pub const CONTROL_START = INVAL;
844pub const MADV_NOSYNC = 6;862 pub const FREE = 5;
845pub const MADV_AUTOSYNC = 7;863 pub const NOSYNC = 6;
846pub const MADV_NOCORE = 8;864 pub const AUTOSYNC = 7;
847pub const MADV_CORE = 9;865 pub const NOCORE = 8;
848pub const MADV_INVAL = 10;866 pub const CORE = 9;
849pub const MADV_SETMAP = 11;867 pub const INVAL = 10;
868 pub const SETMAP = 11;
869};
850870
851pub const F_DUPFD = 0;871pub const F_DUPFD = 0;
852pub const F_GETFD = 1;872pub const F_GETFD = 1;
...@@ -865,10 +885,12 @@ pub const F_DUP2FD = 10;...@@ -865,10 +885,12 @@ pub const F_DUP2FD = 10;
865pub const F_DUPFD_CLOEXEC = 17;885pub const F_DUPFD_CLOEXEC = 17;
866pub const F_DUP2FD_CLOEXEC = 18;886pub const F_DUP2FD_CLOEXEC = 18;
867887
868pub const LOCK_SH = 1;888pub const LOCK = struct {
869pub const LOCK_EX = 2;889 pub const SH = 1;
870pub const LOCK_UN = 8;890 pub const EX = 2;
871pub const LOCK_NB = 4;891 pub const UN = 8;
892 pub const NB = 4;
893};
872894
873pub const Flock = extern struct {895pub const Flock = extern struct {
874 l_start: off_t,896 l_start: off_t,
...@@ -889,118 +911,120 @@ pub const addrinfo = extern struct {...@@ -889,118 +911,120 @@ pub const addrinfo = extern struct {
889 next: ?*addrinfo,911 next: ?*addrinfo,
890};912};
891913
892pub const IPPROTO_IP = 0;914pub const IPPROTO = struct {
893pub const IPPROTO_ICMP = 1;915 pub const IP = 0;
894pub const IPPROTO_TCP = 6;916 pub const ICMP = 1;
895pub const IPPROTO_UDP = 17;917 pub const TCP = 6;
896pub const IPPROTO_IPV6 = 41;918 pub const UDP = 17;
897pub const IPPROTO_RAW = 255;919 pub const IPV6 = 41;
898pub const IPPROTO_HOPOPTS = 0;920 pub const RAW = 255;
899pub const IPPROTO_IGMP = 2;921 pub const HOPOPTS = 0;
900pub const IPPROTO_GGP = 3;922 pub const IGMP = 2;
901pub const IPPROTO_IPV4 = 4;923 pub const GGP = 3;
902pub const IPPROTO_IPIP = IPPROTO_IPV4;924 pub const IPV4 = 4;
903pub const IPPROTO_ST = 7;925 pub const IPIP = IPV4;
904pub const IPPROTO_EGP = 8;926 pub const ST = 7;
905pub const IPPROTO_PIGP = 9;927 pub const EGP = 8;
906pub const IPPROTO_RCCMON = 10;928 pub const PIGP = 9;
907pub const IPPROTO_NVPII = 11;929 pub const RCCMON = 10;
908pub const IPPROTO_PUP = 12;930 pub const NVPII = 11;
909pub const IPPROTO_ARGUS = 13;931 pub const PUP = 12;
910pub const IPPROTO_EMCON = 14;932 pub const ARGUS = 13;
911pub const IPPROTO_XNET = 15;933 pub const EMCON = 14;
912pub const IPPROTO_CHAOS = 16;934 pub const XNET = 15;
913pub const IPPROTO_MUX = 18;935 pub const CHAOS = 16;
914pub const IPPROTO_MEAS = 19;936 pub const MUX = 18;
915pub const IPPROTO_HMP = 20;937 pub const MEAS = 19;
916pub const IPPROTO_PRM = 21;938 pub const HMP = 20;
917pub const IPPROTO_IDP = 22;939 pub const PRM = 21;
918pub const IPPROTO_TRUNK1 = 23;940 pub const IDP = 22;
919pub const IPPROTO_TRUNK2 = 24;941 pub const TRUNK1 = 23;
920pub const IPPROTO_LEAF1 = 25;942 pub const TRUNK2 = 24;
921pub const IPPROTO_LEAF2 = 26;943 pub const LEAF1 = 25;
922pub const IPPROTO_RDP = 27;944 pub const LEAF2 = 26;
923pub const IPPROTO_IRTP = 28;945 pub const RDP = 27;
924pub const IPPROTO_TP = 29;946 pub const IRTP = 28;
925pub const IPPROTO_BLT = 30;947 pub const TP = 29;
926pub const IPPROTO_NSP = 31;948 pub const BLT = 30;
927pub const IPPROTO_INP = 32;949 pub const NSP = 31;
928pub const IPPROTO_SEP = 33;950 pub const INP = 32;
929pub const IPPROTO_3PC = 34;951 pub const SEP = 33;
930pub const IPPROTO_IDPR = 35;952 pub const @"3PC" = 34;
931pub const IPPROTO_XTP = 36;953 pub const IDPR = 35;
932pub const IPPROTO_DDP = 37;954 pub const XTP = 36;
933pub const IPPROTO_CMTP = 38;955 pub const DDP = 37;
934pub const IPPROTO_TPXX = 39;956 pub const CMTP = 38;
935pub const IPPROTO_IL = 40;957 pub const TPXX = 39;
936pub const IPPROTO_SDRP = 42;958 pub const IL = 40;
937pub const IPPROTO_ROUTING = 43;959 pub const SDRP = 42;
938pub const IPPROTO_FRAGMENT = 44;960 pub const ROUTING = 43;
939pub const IPPROTO_IDRP = 45;961 pub const FRAGMENT = 44;
940pub const IPPROTO_RSVP = 46;962 pub const IDRP = 45;
941pub const IPPROTO_GRE = 47;963 pub const RSVP = 46;
942pub const IPPROTO_MHRP = 48;964 pub const GRE = 47;
943pub const IPPROTO_BHA = 49;965 pub const MHRP = 48;
944pub const IPPROTO_ESP = 50;966 pub const BHA = 49;
945pub const IPPROTO_AH = 51;967 pub const ESP = 50;
946pub const IPPROTO_INLSP = 52;968 pub const AH = 51;
947pub const IPPROTO_SWIPE = 53;969 pub const INLSP = 52;
948pub const IPPROTO_NHRP = 54;970 pub const SWIPE = 53;
949pub const IPPROTO_MOBILE = 55;971 pub const NHRP = 54;
950pub const IPPROTO_TLSP = 56;972 pub const MOBILE = 55;
951pub const IPPROTO_SKIP = 57;973 pub const TLSP = 56;
952pub const IPPROTO_ICMPV6 = 58;974 pub const SKIP = 57;
953pub const IPPROTO_NONE = 59;975 pub const ICMPV6 = 58;
954pub const IPPROTO_DSTOPTS = 60;976 pub const NONE = 59;
955pub const IPPROTO_AHIP = 61;977 pub const DSTOPTS = 60;
956pub const IPPROTO_CFTP = 62;978 pub const AHIP = 61;
957pub const IPPROTO_HELLO = 63;979 pub const CFTP = 62;
958pub const IPPROTO_SATEXPAK = 64;980 pub const HELLO = 63;
959pub const IPPROTO_KRYPTOLAN = 65;981 pub const SATEXPAK = 64;
960pub const IPPROTO_RVD = 66;982 pub const KRYPTOLAN = 65;
961pub const IPPROTO_IPPC = 67;983 pub const RVD = 66;
962pub const IPPROTO_ADFS = 68;984 pub const IPPC = 67;
963pub const IPPROTO_SATMON = 69;985 pub const ADFS = 68;
964pub const IPPROTO_VISA = 70;986 pub const SATMON = 69;
965pub const IPPROTO_IPCV = 71;987 pub const VISA = 70;
966pub const IPPROTO_CPNX = 72;988 pub const IPCV = 71;
967pub const IPPROTO_CPHB = 73;989 pub const CPNX = 72;
968pub const IPPROTO_WSN = 74;990 pub const CPHB = 73;
969pub const IPPROTO_PVP = 75;991 pub const WSN = 74;
970pub const IPPROTO_BRSATMON = 76;992 pub const PVP = 75;
971pub const IPPROTO_ND = 77;993 pub const BRSATMON = 76;
972pub const IPPROTO_WBMON = 78;994 pub const ND = 77;
973pub const IPPROTO_WBEXPAK = 79;995 pub const WBMON = 78;
974pub const IPPROTO_EON = 80;996 pub const WBEXPAK = 79;
975pub const IPPROTO_VMTP = 81;997 pub const EON = 80;
976pub const IPPROTO_SVMTP = 82;998 pub const VMTP = 81;
977pub const IPPROTO_VINES = 83;999 pub const SVMTP = 82;
978pub const IPPROTO_TTP = 84;1000 pub const VINES = 83;
979pub const IPPROTO_IGP = 85;1001 pub const TTP = 84;
980pub const IPPROTO_DGP = 86;1002 pub const IGP = 85;
981pub const IPPROTO_TCF = 87;1003 pub const DGP = 86;
982pub const IPPROTO_IGRP = 88;1004 pub const TCF = 87;
983pub const IPPROTO_OSPFIGP = 89;1005 pub const IGRP = 88;
984pub const IPPROTO_SRPC = 90;1006 pub const OSPFIGP = 89;
985pub const IPPROTO_LARP = 91;1007 pub const SRPC = 90;
986pub const IPPROTO_MTP = 92;1008 pub const LARP = 91;
987pub const IPPROTO_AX25 = 93;1009 pub const MTP = 92;
988pub const IPPROTO_IPEIP = 94;1010 pub const AX25 = 93;
989pub const IPPROTO_MICP = 95;1011 pub const IPEIP = 94;
990pub const IPPROTO_SCCSP = 96;1012 pub const MICP = 95;
991pub const IPPROTO_ETHERIP = 97;1013 pub const SCCSP = 96;
992pub const IPPROTO_ENCAP = 98;1014 pub const ETHERIP = 97;
993pub const IPPROTO_APES = 99;1015 pub const ENCAP = 98;
994pub const IPPROTO_GMTP = 100;1016 pub const APES = 99;
995pub const IPPROTO_IPCOMP = 108;1017 pub const GMTP = 100;
996pub const IPPROTO_PIM = 103;1018 pub const IPCOMP = 108;
997pub const IPPROTO_CARP = 112;1019 pub const PIM = 103;
998pub const IPPROTO_PGM = 113;1020 pub const CARP = 112;
999pub const IPPROTO_PFSYNC = 240;1021 pub const PGM = 113;
1000pub const IPPROTO_DIVERT = 254;1022 pub const PFSYNC = 240;
1001pub const IPPROTO_MAX = 256;1023 pub const DIVERT = 254;
1002pub const IPPROTO_DONE = 257;1024 pub const MAX = 256;
1003pub const IPPROTO_UNKNOWN = 258;1025 pub const DONE = 257;
1026 pub const UNKNOWN = 258;
1027};
10041028
1005pub const rlimit_resource = enum(c_int) {1029pub const rlimit_resource = enum(c_int) {
1006 CPU = 0,1030 CPU = 0,
...@@ -1022,11 +1046,13 @@ pub const rlimit_resource = enum(c_int) {...@@ -1022,11 +1046,13 @@ pub const rlimit_resource = enum(c_int) {
10221046
1023pub const rlim_t = i64;1047pub const rlim_t = i64;
10241048
1025/// No limit1049pub const RLIM = struct {
1026pub const RLIM_INFINITY: rlim_t = (1 << 63) - 1;1050 /// No limit
1051 pub const INFINITY: rlim_t = (1 << 63) - 1;
10271052
1028pub const RLIM_SAVED_MAX = RLIM_INFINITY;1053 pub const SAVED_MAX = INFINITY;
1029pub const RLIM_SAVED_CUR = RLIM_INFINITY;1054 pub const SAVED_CUR = INFINITY;
1055};
10301056
1031pub const rlimit = extern struct {1057pub const rlimit = extern struct {
1032 /// Soft limit1058 /// Soft limit
...@@ -1047,16 +1073,18 @@ pub const pollfd = extern struct {...@@ -1047,16 +1073,18 @@ pub const pollfd = extern struct {
1047 revents: i16,1073 revents: i16,
1048};1074};
10491075
1050/// Requestable events.1076pub const POLL = struct {
1051pub const POLLIN = 0x0001;1077 /// Requestable events.
1052pub const POLLPRI = 0x0002;1078 pub const IN = 0x0001;
1053pub const POLLOUT = 0x0004;1079 pub const PRI = 0x0002;
1054pub const POLLRDNORM = 0x0040;1080 pub const OUT = 0x0004;
1055pub const POLLWRNORM = POLLOUT;1081 pub const RDNORM = 0x0040;
1056pub const POLLRDBAND = 0x0080;1082 pub const WRNORM = OUT;
1057pub const POLLWRBAND = 0x0100;1083 pub const RDBAND = 0x0080;
10581084 pub const WRBAND = 0x0100;
1059/// These events are set if they occur regardless of whether they were requested.1085
1060pub const POLLERR = 0x0008;1086 /// These events are set if they occur regardless of whether they were requested.
1061pub const POLLHUP = 0x0010;1087 pub const ERR = 0x0008;
1062pub const POLLNVAL = 0x0020;1088 pub const HUP = 0x0010;
1089 pub const NVAL = 0x0020;
1090};
lib/std/c/freebsd.zig+516-625
...@@ -107,35 +107,28 @@ pub const EAI = enum(c_int) {...@@ -107,35 +107,28 @@ pub const EAI = enum(c_int) {
107107
108pub const EAI_MAX = 15;108pub const EAI_MAX = 15;
109109
110/// get address to use bind()110pub const AI = struct {
111pub const AI_PASSIVE = 0x00000001;111 /// get address to use bind()
112112 pub const PASSIVE = 0x00000001;
113/// fill ai_canonname113 /// fill ai_canonname
114pub const AI_CANONNAME = 0x00000002;114 pub const CANONNAME = 0x00000002;
115115 /// prevent host name resolution
116/// prevent host name resolution116 pub const NUMERICHOST = 0x00000004;
117pub const AI_NUMERICHOST = 0x00000004;117 /// prevent service name resolution
118118 pub const NUMERICSERV = 0x00000008;
119/// prevent service name resolution119 /// valid flags for addrinfo (not a standard def, apps should not use it)
120pub const AI_NUMERICSERV = 0x00000008;120 pub const MASK = (PASSIVE | CANONNAME | NUMERICHOST | NUMERICSERV | ADDRCONFIG | ALL | V4MAPPED);
121121 /// IPv6 and IPv4-mapped (with V4MAPPED)
122/// valid flags for addrinfo (not a standard def, apps should not use it)122 pub const ALL = 0x00000100;
123pub const AI_MASK = (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST | AI_NUMERICSERV | AI_ADDRCONFIG | AI_ALL | AI_V4MAPPED);123 /// accept IPv4-mapped if kernel supports
124124 pub const V4MAPPED_CFG = 0x00000200;
125/// IPv6 and IPv4-mapped (with AI_V4MAPPED)125 /// only if any address is assigned
126pub const AI_ALL = 0x00000100;126 pub const ADDRCONFIG = 0x00000400;
127127 /// accept IPv4-mapped IPv6 address
128/// accept IPv4-mapped if kernel supports128 pub const V4MAPPED = 0x00000800;
129pub const AI_V4MAPPED_CFG = 0x00000200;129 /// special recommended flags for getipnodebyname
130130 pub const DEFAULT = (V4MAPPED_CFG | ADDRCONFIG);
131/// only if any address is assigned131};
132pub const AI_ADDRCONFIG = 0x00000400;
133
134/// accept IPv4-mapped IPv6 address
135pub const AI_V4MAPPED = 0x00000800;
136
137/// special recommended flags for getipnodebyname
138pub const AI_DEFAULT = (AI_V4MAPPED_CFG | AI_ADDRCONFIG);
139132
140pub const blksize_t = i32;133pub const blksize_t = i32;
141pub const blkcnt_t = i64;134pub const blkcnt_t = i64;
...@@ -172,29 +165,23 @@ pub const Kevent = extern struct {...@@ -172,29 +165,23 @@ pub const Kevent = extern struct {
172// Modes and flags for dlopen()165// Modes and flags for dlopen()
173// include/dlfcn.h166// include/dlfcn.h
174167
175/// Bind function calls lazily.168pub const RTLD = struct {
176pub const RTLD_LAZY = 1;169 /// Bind function calls lazily.
177170 pub const LAZY = 1;
178/// Bind function calls immediately.171 /// Bind function calls immediately.
179pub const RTLD_NOW = 2;172 pub const NOW = 2;
180173 pub const MODEMASK = 0x3;
181pub const RTLD_MODEMASK = 0x3;174 /// Make symbols globally available.
182175 pub const GLOBAL = 0x100;
183/// Make symbols globally available.176 /// Opposite of GLOBAL, and the default.
184pub const RTLD_GLOBAL = 0x100;177 pub const LOCAL = 0;
185178 /// Trace loaded objects and exit.
186/// Opposite of RTLD_GLOBAL, and the default.179 pub const TRACE = 0x200;
187pub const RTLD_LOCAL = 0;180 /// Do not remove members.
188181 pub const NODELETE = 0x01000;
189/// Trace loaded objects and exit.182 /// Do not load if not already loaded.
190pub const RTLD_TRACE = 0x200;183 pub const NOLOAD = 0x02000;
191184};
192/// Do not remove members.
193pub const RTLD_NODELETE = 0x01000;
194
195/// Do not load if not already loaded.
196pub const RTLD_NOLOAD = 0x02000;
197
198pub const dl_phdr_info = extern struct {185pub const dl_phdr_info = extern struct {
199 dlpi_addr: usize,186 dlpi_addr: usize,
200 dlpi_name: ?[*:0]const u8,187 dlpi_name: ?[*:0]const u8,
...@@ -328,37 +315,35 @@ pub const sa_family_t = u8;...@@ -328,37 +315,35 @@ pub const sa_family_t = u8;
328pub const sockaddr = extern struct {315pub const sockaddr = extern struct {
329 /// total length316 /// total length
330 len: u8,317 len: u8,
331
332 /// address family318 /// address family
333 family: sa_family_t,319 family: sa_family_t,
334
335 /// actually longer; address value320 /// actually longer; address value
336 data: [14]u8,321 data: [14]u8,
337};
338
339pub const sockaddr_storage = std.x.os.Socket.Address.Native.Storage;
340
341pub const sockaddr_in = extern struct {
342 len: u8 = @sizeOf(sockaddr_in),
343 family: sa_family_t = AF_INET,
344 port: in_port_t,
345 addr: u32,
346 zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },
347};
348322
349pub const sockaddr_in6 = extern struct {323 pub const storage = std.x.os.Socket.Address.Native.Storage;
350 len: u8 = @sizeOf(sockaddr_in6),324
351 family: sa_family_t = AF_INET6,325 pub const in = extern struct {
352 port: in_port_t,326 len: u8 = @sizeOf(in),
353 flowinfo: u32,327 family: sa_family_t = AF.INET,
354 addr: [16]u8,328 port: in_port_t,
355 scope_id: u32,329 addr: u32,
356};330 zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },
357331 };
358pub const sockaddr_un = extern struct {332
359 len: u8 = @sizeOf(sockaddr_un),333 pub const in6 = extern struct {
360 family: sa_family_t = AF_UNIX,334 len: u8 = @sizeOf(in6),
361 path: [104]u8,335 family: sa_family_t = AF.INET6,
336 port: in_port_t,
337 flowinfo: u32,
338 addr: [16]u8,
339 scope_id: u32,
340 };
341
342 pub const un = extern struct {
343 len: u8 = @sizeOf(un),
344 family: sa_family_t = AF.UNIX,
345 path: [104]u8,
346 };
362};347};
363348
364pub const CTL_KERN = 1;349pub const CTL_KERN = 1;
...@@ -380,36 +365,40 @@ pub const PROT_READ = 1;...@@ -380,36 +365,40 @@ pub const PROT_READ = 1;
380pub const PROT_WRITE = 2;365pub const PROT_WRITE = 2;
381pub const PROT_EXEC = 4;366pub const PROT_EXEC = 4;
382367
383pub const CLOCK_REALTIME = 0;368pub const CLOCK = struct {
384pub const CLOCK_VIRTUAL = 1;369 pub const REALTIME = 0;
385pub const CLOCK_PROF = 2;370 pub const VIRTUAL = 1;
386pub const CLOCK_MONOTONIC = 4;371 pub const PROF = 2;
387pub const CLOCK_UPTIME = 5;372 pub const MONOTONIC = 4;
388pub const CLOCK_UPTIME_PRECISE = 7;373 pub const UPTIME = 5;
389pub const CLOCK_UPTIME_FAST = 8;374 pub const UPTIME_PRECISE = 7;
390pub const CLOCK_REALTIME_PRECISE = 9;375 pub const UPTIME_FAST = 8;
391pub const CLOCK_REALTIME_FAST = 10;376 pub const REALTIME_PRECISE = 9;
392pub const CLOCK_MONOTONIC_PRECISE = 11;377 pub const REALTIME_FAST = 10;
393pub const CLOCK_MONOTONIC_FAST = 12;378 pub const MONOTONIC_PRECISE = 11;
394pub const CLOCK_SECOND = 13;379 pub const MONOTONIC_FAST = 12;
395pub const CLOCK_THREAD_CPUTIME_ID = 14;380 pub const SECOND = 13;
396pub const CLOCK_PROCESS_CPUTIME_ID = 15;381 pub const THREAD_CPUTIME_ID = 14;
397382 pub const PROCESS_CPUTIME_ID = 15;
398pub const MAP_FAILED = @intToPtr(*c_void, maxInt(usize));383};
399pub const MAP_SHARED = 0x0001;384
400pub const MAP_PRIVATE = 0x0002;385pub const MAP = struct {
401pub const MAP_FIXED = 0x0010;386 pub const FAILED = @intToPtr(*c_void, maxInt(usize));
402pub const MAP_STACK = 0x0400;387 pub const SHARED = 0x0001;
403pub const MAP_NOSYNC = 0x0800;388 pub const PRIVATE = 0x0002;
404pub const MAP_ANON = 0x1000;389 pub const FIXED = 0x0010;
405pub const MAP_ANONYMOUS = MAP_ANON;390 pub const STACK = 0x0400;
406pub const MAP_FILE = 0;391 pub const NOSYNC = 0x0800;
407392 pub const ANON = 0x1000;
408pub const MAP_GUARD = 0x00002000;393 pub const ANONYMOUS = ANON;
409pub const MAP_EXCL = 0x00004000;394 pub const FILE = 0;
410pub const MAP_NOCORE = 0x00020000;395
411pub const MAP_PREFAULT_READ = 0x00040000;396 pub const GUARD = 0x00002000;
412pub const MAP_32BIT = 0x00080000;397 pub const EXCL = 0x00004000;
398 pub const NOCORE = 0x00020000;
399 pub const PREFAULT_READ = 0x00040000;
400 pub const @"32BIT" = 0x00080000;
401};
413402
414pub const WNOHANG = 1;403pub const WNOHANG = 1;
415pub const WUNTRACED = 2;404pub const WUNTRACED = 2;
...@@ -517,10 +506,12 @@ pub const F_RDLCK = 1;...@@ -517,10 +506,12 @@ pub const F_RDLCK = 1;
517pub const F_WRLCK = 3;506pub const F_WRLCK = 3;
518pub const F_UNLCK = 2;507pub const F_UNLCK = 2;
519508
520pub const LOCK_SH = 1;509pub const LOCK = struct {
521pub const LOCK_EX = 2;510 pub const SH = 1;
522pub const LOCK_UN = 8;511 pub const EX = 2;
523pub const LOCK_NB = 4;512 pub const UN = 8;
513 pub const NB = 4;
514};
524515
525pub const F_SETOWN_EX = 15;516pub const F_SETOWN_EX = 15;
526pub const F_GETOWN_EX = 16;517pub const F_GETOWN_EX = 16;
...@@ -537,143 +528,153 @@ pub const SIG_BLOCK = 1;...@@ -537,143 +528,153 @@ pub const SIG_BLOCK = 1;
537pub const SIG_UNBLOCK = 2;528pub const SIG_UNBLOCK = 2;
538pub const SIG_SETMASK = 3;529pub const SIG_SETMASK = 3;
539530
540pub const SOCK_STREAM = 1;531pub const SOCK = struct {
541pub const SOCK_DGRAM = 2;532 pub const STREAM = 1;
542pub const SOCK_RAW = 3;533 pub const DGRAM = 2;
543pub const SOCK_RDM = 4;534 pub const RAW = 3;
544pub const SOCK_SEQPACKET = 5;535 pub const RDM = 4;
545536 pub const SEQPACKET = 5;
546pub const SOCK_CLOEXEC = 0x10000000;537
547pub const SOCK_NONBLOCK = 0x20000000;538 pub const CLOEXEC = 0x10000000;
548539 pub const NONBLOCK = 0x20000000;
549pub const SO_DEBUG = 0x00000001;540};
550pub const SO_ACCEPTCONN = 0x00000002;541
551pub const SO_REUSEADDR = 0x00000004;542pub const SO = struct {
552pub const SO_KEEPALIVE = 0x00000008;543 pub const DEBUG = 0x00000001;
553pub const SO_DONTROUTE = 0x00000010;544 pub const ACCEPTCONN = 0x00000002;
554pub const SO_BROADCAST = 0x00000020;545 pub const REUSEADDR = 0x00000004;
555pub const SO_USELOOPBACK = 0x00000040;546 pub const KEEPALIVE = 0x00000008;
556pub const SO_LINGER = 0x00000080;547 pub const DONTROUTE = 0x00000010;
557pub const SO_OOBINLINE = 0x00000100;548 pub const BROADCAST = 0x00000020;
558pub const SO_REUSEPORT = 0x00000200;549 pub const USELOOPBACK = 0x00000040;
559pub const SO_TIMESTAMP = 0x00000400;550 pub const LINGER = 0x00000080;
560pub const SO_NOSIGPIPE = 0x00000800;551 pub const OOBINLINE = 0x00000100;
561pub const SO_ACCEPTFILTER = 0x00001000;552 pub const REUSEPORT = 0x00000200;
562pub const SO_BINTIME = 0x00002000;553 pub const TIMESTAMP = 0x00000400;
563pub const SO_NO_OFFLOAD = 0x00004000;554 pub const NOSIGPIPE = 0x00000800;
564pub const SO_NO_DDP = 0x00008000;555 pub const ACCEPTFILTER = 0x00001000;
565pub const SO_REUSEPORT_LB = 0x00010000;556 pub const BINTIME = 0x00002000;
566557 pub const NO_OFFLOAD = 0x00004000;
567pub const SO_SNDBUF = 0x1001;558 pub const NO_DDP = 0x00008000;
568pub const SO_RCVBUF = 0x1002;559 pub const REUSEPORT_LB = 0x00010000;
569pub const SO_SNDLOWAT = 0x1003;560
570pub const SO_RCVLOWAT = 0x1004;561 pub const SNDBUF = 0x1001;
571pub const SO_SNDTIMEO = 0x1005;562 pub const RCVBUF = 0x1002;
572pub const SO_RCVTIMEO = 0x1006;563 pub const SNDLOWAT = 0x1003;
573pub const SO_ERROR = 0x1007;564 pub const RCVLOWAT = 0x1004;
574pub const SO_TYPE = 0x1008;565 pub const SNDTIMEO = 0x1005;
575pub const SO_LABEL = 0x1009;566 pub const RCVTIMEO = 0x1006;
576pub const SO_PEERLABEL = 0x1010;567 pub const ERROR = 0x1007;
577pub const SO_LISTENQLIMIT = 0x1011;568 pub const TYPE = 0x1008;
578pub const SO_LISTENQLEN = 0x1012;569 pub const LABEL = 0x1009;
579pub const SO_LISTENINCQLEN = 0x1013;570 pub const PEERLABEL = 0x1010;
580pub const SO_SETFIB = 0x1014;571 pub const LISTENQLIMIT = 0x1011;
581pub const SO_USER_COOKIE = 0x1015;572 pub const LISTENQLEN = 0x1012;
582pub const SO_PROTOCOL = 0x1016;573 pub const LISTENINCQLEN = 0x1013;
583pub const SO_PROTOTYPE = SO_PROTOCOL;574 pub const SETFIB = 0x1014;
584pub const SO_TS_CLOCK = 0x1017;575 pub const USER_COOKIE = 0x1015;
585pub const SO_MAX_PACING_RATE = 0x1018;576 pub const PROTOCOL = 0x1016;
586pub const SO_DOMAIN = 0x1019;577 pub const PROTOTYPE = PROTOCOL;
587578 pub const TS_CLOCK = 0x1017;
588pub const SOL_SOCKET = 0xffff;579 pub const MAX_PACING_RATE = 0x1018;
589580 pub const DOMAIN = 0x1019;
590pub const PF_UNSPEC = AF_UNSPEC;581};
591pub const PF_LOCAL = AF_LOCAL;582
592pub const PF_UNIX = PF_LOCAL;583pub const SOL = struct {
593pub const PF_INET = AF_INET;584 pub const SOCKET = 0xffff;
594pub const PF_IMPLINK = AF_IMPLINK;585};
595pub const PF_PUP = AF_PUP;586
596pub const PF_CHAOS = AF_CHAOS;587pub const PF = struct {
597pub const PF_NETBIOS = AF_NETBIOS;588 pub const UNSPEC = AF.UNSPEC;
598pub const PF_ISO = AF_ISO;589 pub const LOCAL = AF.LOCAL;
599pub const PF_OSI = AF_ISO;590 pub const UNIX = PF.LOCAL;
600pub const PF_ECMA = AF_ECMA;591 pub const INET = AF.INET;
601pub const PF_DATAKIT = AF_DATAKIT;592 pub const IMPLINK = AF.IMPLINK;
602pub const PF_CCITT = AF_CCITT;593 pub const PUP = AF.PUP;
603pub const PF_DECnet = AF_DECnet;594 pub const CHAOS = AF.CHAOS;
604pub const PF_DLI = AF_DLI;595 pub const NETBIOS = AF.NETBIOS;
605pub const PF_LAT = AF_LAT;596 pub const ISO = AF.ISO;
606pub const PF_HYLINK = AF_HYLINK;597 pub const OSI = AF.ISO;
607pub const PF_APPLETALK = AF_APPLETALK;598 pub const ECMA = AF.ECMA;
608pub const PF_ROUTE = AF_ROUTE;599 pub const DATAKIT = AF.DATAKIT;
609pub const PF_LINK = AF_LINK;600 pub const CCITT = AF.CCITT;
610pub const PF_XTP = pseudo_AF_XTP;601 pub const DECnet = AF.DECnet;
611pub const PF_COIP = AF_COIP;602 pub const DLI = AF.DLI;
612pub const PF_CNT = AF_CNT;603 pub const LAT = AF.LAT;
613pub const PF_SIP = AF_SIP;604 pub const HYLINK = AF.HYLINK;
614pub const PF_IPX = AF_IPX;605 pub const APPLETALK = AF.APPLETALK;
615pub const PF_RTIP = pseudo_AF_RTIP;606 pub const ROUTE = AF.ROUTE;
616pub const PF_PIP = psuedo_AF_PIP;607 pub const LINK = AF.LINK;
617pub const PF_ISDN = AF_ISDN;608 pub const XTP = AF.pseudo_XTP;
618pub const PF_KEY = pseudo_AF_KEY;609 pub const COIP = AF.COIP;
619pub const PF_INET6 = pseudo_AF_INET6;610 pub const CNT = AF.CNT;
620pub const PF_NATM = AF_NATM;611 pub const SIP = AF.SIP;
621pub const PF_ATM = AF_ATM;612 pub const IPX = AF.IPX;
622pub const PF_NETGRAPH = AF_NETGRAPH;613 pub const RTIP = AF.pseudo_RTIP;
623pub const PF_SLOW = AF_SLOW;614 pub const PIP = AF.pseudo_PIP;
624pub const PF_SCLUSTER = AF_SCLUSTER;615 pub const ISDN = AF.ISDN;
625pub const PF_ARP = AF_ARP;616 pub const KEY = AF.pseudo_KEY;
626pub const PF_BLUETOOTH = AF_BLUETOOTH;617 pub const INET6 = AF.pseudo_INET6;
627pub const PF_IEEE80211 = AF_IEEE80211;618 pub const NATM = AF.NATM;
628pub const PF_INET_SDP = AF_INET_SDP;619 pub const ATM = AF.ATM;
629pub const PF_INET6_SDP = AF_INET6_SDP;620 pub const NETGRAPH = AF.NETGRAPH;
630pub const PF_MAX = AF_MAX;621 pub const SLOW = AF.SLOW;
631622 pub const SCLUSTER = AF.SCLUSTER;
632pub const AF_UNSPEC = 0;623 pub const ARP = AF.ARP;
633pub const AF_UNIX = 1;624 pub const BLUETOOTH = AF.BLUETOOTH;
634pub const AF_LOCAL = AF_UNIX;625 pub const IEEE80211 = AF.IEEE80211;
635pub const AF_FILE = AF_LOCAL;626 pub const INET_SDP = AF.INET_SDP;
636pub const AF_INET = 2;627 pub const INET6_SDP = AF.INET6_SDP;
637pub const AF_IMPLINK = 3;628 pub const MAX = AF.MAX;
638pub const AF_PUP = 4;629};
639pub const AF_CHAOS = 5;630
640pub const AF_NETBIOS = 6;631pub const AF = struct {
641pub const AF_ISO = 7;632 pub const UNSPEC = 0;
642pub const AF_OSI = AF_ISO;633 pub const UNIX = 1;
643pub const AF_ECMA = 8;634 pub const LOCAL = UNIX;
644pub const AF_DATAKIT = 9;635 pub const FILE = LOCAL;
645pub const AF_CCITT = 10;636 pub const INET = 2;
646pub const AF_SNA = 11;637 pub const IMPLINK = 3;
647pub const AF_DECnet = 12;638 pub const PUP = 4;
648pub const AF_DLI = 13;639 pub const CHAOS = 5;
649pub const AF_LAT = 14;640 pub const NETBIOS = 6;
650pub const AF_HYLINK = 15;641 pub const ISO = 7;
651pub const AF_APPLETALK = 16;642 pub const OSI = ISO;
652pub const AF_ROUTE = 17;643 pub const ECMA = 8;
653pub const AF_LINK = 18;644 pub const DATAKIT = 9;
654pub const pseudo_AF_XTP = 19;645 pub const CCITT = 10;
655pub const AF_COIP = 20;646 pub const SNA = 11;
656pub const AF_CNT = 21;647 pub const DECnet = 12;
657pub const pseudo_AF_RTIP = 22;648 pub const DLI = 13;
658pub const AF_IPX = 23;649 pub const LAT = 14;
659pub const AF_SIP = 24;650 pub const HYLINK = 15;
660pub const pseudo_AF_PIP = 25;651 pub const APPLETALK = 16;
661pub const AF_ISDN = 26;652 pub const ROUTE = 17;
662pub const AF_E164 = AF_ISDN;653 pub const LINK = 18;
663pub const pseudo_AF_KEY = 27;654 pub const pseudo_XTP = 19;
664pub const AF_INET6 = 28;655 pub const COIP = 20;
665pub const AF_NATM = 29;656 pub const CNT = 21;
666pub const AF_ATM = 30;657 pub const pseudo_RTIP = 22;
667pub const pseudo_AF_HDRCMPLT = 31;658 pub const IPX = 23;
668pub const AF_NETGRAPH = 32;659 pub const SIP = 24;
669pub const AF_SLOW = 33;660 pub const pseudo_PIP = 25;
670pub const AF_SCLUSTER = 34;661 pub const ISDN = 26;
671pub const AF_ARP = 35;662 pub const E164 = ISDN;
672pub const AF_BLUETOOTH = 36;663 pub const pseudo_KEY = 27;
673pub const AF_IEEE80211 = 37;664 pub const INET6 = 28;
674pub const AF_INET_SDP = 40;665 pub const NATM = 29;
675pub const AF_INET6_SDP = 42;666 pub const ATM = 30;
676pub const AF_MAX = 42;667 pub const pseudo_HDRCMPLT = 31;
668 pub const NETGRAPH = 32;
669 pub const SLOW = 33;
670 pub const SCLUSTER = 34;
671 pub const ARP = 35;
672 pub const BLUETOOTH = 36;
673 pub const IEEE80211 = 37;
674 pub const INET_SDP = 40;
675 pub const INET6_SDP = 42;
676 pub const MAX = 42;
677};
677678
678pub const DT_UNKNOWN = 0;679pub const DT_UNKNOWN = 0;
679pub const DT_FIFO = 1;680pub const DT_FIFO = 1;
...@@ -1252,353 +1253,240 @@ pub const addrinfo = extern struct {...@@ -1252,353 +1253,240 @@ pub const addrinfo = extern struct {
1252/// Fail if not under dirfd1253/// Fail if not under dirfd
1253pub const AT_BENEATH = 0x1000;1254pub const AT_BENEATH = 0x1000;
12541255
1255/// dummy for IP1256pub const IPPROTO = struct {
1256pub const IPPROTO_IP = 0;1257 /// dummy for IP
12571258 pub const IP = 0;
1258/// control message protocol1259 /// control message protocol
1259pub const IPPROTO_ICMP = 1;1260 pub const ICMP = 1;
12601261 /// tcp
1261/// tcp1262 pub const TCP = 6;
1262pub const IPPROTO_TCP = 6;1263 /// user datagram protocol
12631264 pub const UDP = 17;
1264/// user datagram protocol1265 /// IP6 header
1265pub const IPPROTO_UDP = 17;1266 pub const IPV6 = 41;
12661267 /// raw IP packet
1267/// IP6 header1268 pub const RAW = 255;
1268pub const IPPROTO_IPV6 = 41;1269 /// IP6 hop-by-hop options
12691270 pub const HOPOPTS = 0;
1270/// raw IP packet1271 /// group mgmt protocol
1271pub const IPPROTO_RAW = 255;1272 pub const IGMP = 2;
12721273 /// gateway^2 (deprecated)
1273/// IP6 hop-by-hop options1274 pub const GGP = 3;
1274pub const IPPROTO_HOPOPTS = 0;1275 /// IPv4 encapsulation
12751276 pub const IPV4 = 4;
1276/// group mgmt protocol1277 /// for compatibility
1277pub const IPPROTO_IGMP = 2;1278 pub const IPIP = IPV4;
12781279 /// Stream protocol II
1279/// gateway^2 (deprecated)1280 pub const ST = 7;
1280pub const IPPROTO_GGP = 3;1281 /// exterior gateway protocol
12811282 pub const EGP = 8;
1282/// IPv4 encapsulation1283 /// private interior gateway
1283pub const IPPROTO_IPV4 = 4;1284 pub const PIGP = 9;
12841285 /// BBN RCC Monitoring
1285/// for compatibility1286 pub const RCCMON = 10;
1286pub const IPPROTO_IPIP = IPPROTO_IPV4;1287 /// network voice protocol
12871288 pub const NVPII = 11;
1288/// Stream protocol II1289 /// pup
1289pub const IPPROTO_ST = 7;1290 pub const PUP = 12;
12901291 /// Argus
1291/// exterior gateway protocol1292 pub const ARGUS = 13;
1292pub const IPPROTO_EGP = 8;1293 /// EMCON
12931294 pub const EMCON = 14;
1294/// private interior gateway1295 /// Cross Net Debugger
1295pub const IPPROTO_PIGP = 9;1296 pub const XNET = 15;
12961297 /// Chaos
1297/// BBN RCC Monitoring1298 pub const CHAOS = 16;
1298pub const IPPROTO_RCCMON = 10;1299 /// Multiplexing
12991300 pub const MUX = 18;
1300/// network voice protocol1301 /// DCN Measurement Subsystems
1301pub const IPPROTO_NVPII = 11;1302 pub const MEAS = 19;
13021303 /// Host Monitoring
1303/// pup1304 pub const HMP = 20;
1304pub const IPPROTO_PUP = 12;1305 /// Packet Radio Measurement
13051306 pub const PRM = 21;
1306/// Argus1307 /// xns idp
1307pub const IPPROTO_ARGUS = 13;1308 pub const IDP = 22;
13081309 /// Trunk-1
1309/// EMCON1310 pub const TRUNK1 = 23;
1310pub const IPPROTO_EMCON = 14;1311 /// Trunk-2
13111312 pub const TRUNK2 = 24;
1312/// Cross Net Debugger1313 /// Leaf-1
1313pub const IPPROTO_XNET = 15;1314 pub const LEAF1 = 25;
13141315 /// Leaf-2
1315/// Chaos1316 pub const LEAF2 = 26;
1316pub const IPPROTO_CHAOS = 16;1317 /// Reliable Data
13171318 pub const RDP = 27;
1318/// Multiplexing1319 /// Reliable Transaction
1319pub const IPPROTO_MUX = 18;1320 pub const IRTP = 28;
13201321 /// tp-4 w/ class negotiation
1321/// DCN Measurement Subsystems1322 pub const TP = 29;
1322pub const IPPROTO_MEAS = 19;1323 /// Bulk Data Transfer
13231324 pub const BLT = 30;
1324/// Host Monitoring1325 /// Network Services
1325pub const IPPROTO_HMP = 20;1326 pub const NSP = 31;
13261327 /// Merit Internodal
1327/// Packet Radio Measurement1328 pub const INP = 32;
1328pub const IPPROTO_PRM = 21;1329 /// Datagram Congestion Control Protocol
13291330 pub const DCCP = 33;
1330/// xns idp1331 /// Third Party Connect
1331pub const IPPROTO_IDP = 22;1332 pub const @"3PC" = 34;
13321333 /// InterDomain Policy Routing
1333/// Trunk-11334 pub const IDPR = 35;
1334pub const IPPROTO_TRUNK1 = 23;1335 /// XTP
13351336 pub const XTP = 36;
1336/// Trunk-21337 /// Datagram Delivery
1337pub const IPPROTO_TRUNK2 = 24;1338 pub const DDP = 37;
13381339 /// Control Message Transport
1339/// Leaf-11340 pub const CMTP = 38;
1340pub const IPPROTO_LEAF1 = 25;1341 /// TP++ Transport
13411342 pub const TPXX = 39;
1342/// Leaf-21343 /// IL transport protocol
1343pub const IPPROTO_LEAF2 = 26;1344 pub const IL = 40;
13441345 /// Source Demand Routing
1345/// Reliable Data1346 pub const SDRP = 42;
1346pub const IPPROTO_RDP = 27;1347 /// IP6 routing header
13471348 pub const ROUTING = 43;
1348/// Reliable Transaction1349 /// IP6 fragmentation header
1349pub const IPPROTO_IRTP = 28;1350 pub const FRAGMENT = 44;
13501351 /// InterDomain Routing
1351/// tp-4 w/ class negotiation1352 pub const IDRP = 45;
1352pub const IPPROTO_TP = 29;1353 /// resource reservation
13531354 pub const RSVP = 46;
1354/// Bulk Data Transfer1355 /// General Routing Encap.
1355pub const IPPROTO_BLT = 30;1356 pub const GRE = 47;
13561357 /// Mobile Host Routing
1357/// Network Services1358 pub const MHRP = 48;
1358pub const IPPROTO_NSP = 31;1359 /// BHA
13591360 pub const BHA = 49;
1360/// Merit Internodal1361 /// IP6 Encap Sec. Payload
1361pub const IPPROTO_INP = 32;1362 pub const ESP = 50;
13621363 /// IP6 Auth Header
1363/// Datagram Congestion Control Protocol1364 pub const AH = 51;
1364pub const IPPROTO_DCCP = 33;1365 /// Integ. Net Layer Security
13651366 pub const INLSP = 52;
1366/// Third Party Connect1367 /// IP with encryption
1367pub const IPPROTO_3PC = 34;1368 pub const SWIPE = 53;
13681369 /// Next Hop Resolution
1369/// InterDomain Policy Routing1370 pub const NHRP = 54;
1370pub const IPPROTO_IDPR = 35;1371 /// IP Mobility
13711372 pub const MOBILE = 55;
1372/// XTP1373 /// Transport Layer Security
1373pub const IPPROTO_XTP = 36;1374 pub const TLSP = 56;
13741375 /// SKIP
1375/// Datagram Delivery1376 pub const SKIP = 57;
1376pub const IPPROTO_DDP = 37;1377 /// ICMP6
13771378 pub const ICMPV6 = 58;
1378/// Control Message Transport1379 /// IP6 no next header
1379pub const IPPROTO_CMTP = 38;1380 pub const NONE = 59;
13801381 /// IP6 destination option
1381/// TP++ Transport1382 pub const DSTOPTS = 60;
1382pub const IPPROTO_TPXX = 39;1383 /// any host internal protocol
13831384 pub const AHIP = 61;
1384/// IL transport protocol1385 /// CFTP
1385pub const IPPROTO_IL = 40;1386 pub const CFTP = 62;
13861387 /// "hello" routing protocol
1387/// Source Demand Routing1388 pub const HELLO = 63;
1388pub const IPPROTO_SDRP = 42;1389 /// SATNET/Backroom EXPAK
13891390 pub const SATEXPAK = 64;
1390/// IP6 routing header1391 /// Kryptolan
1391pub const IPPROTO_ROUTING = 43;1392 pub const KRYPTOLAN = 65;
13921393 /// Remote Virtual Disk
1393/// IP6 fragmentation header1394 pub const RVD = 66;
1394pub const IPPROTO_FRAGMENT = 44;1395 /// Pluribus Packet Core
13951396 pub const IPPC = 67;
1396/// InterDomain Routing1397 /// Any distributed FS
1397pub const IPPROTO_IDRP = 45;1398 pub const ADFS = 68;
13981399 /// Satnet Monitoring
1399/// resource reservation1400 pub const SATMON = 69;
1400pub const IPPROTO_RSVP = 46;1401 /// VISA Protocol
14011402 pub const VISA = 70;
1402/// General Routing Encap.1403 /// Packet Core Utility
1403pub const IPPROTO_GRE = 47;1404 pub const IPCV = 71;
14041405 /// Comp. Prot. Net. Executive
1405/// Mobile Host Routing1406 pub const CPNX = 72;
1406pub const IPPROTO_MHRP = 48;1407 /// Comp. Prot. HeartBeat
14071408 pub const CPHB = 73;
1408/// BHA1409 /// Wang Span Network
1409pub const IPPROTO_BHA = 49;1410 pub const WSN = 74;
14101411 /// Packet Video Protocol
1411/// IP6 Encap Sec. Payload1412 pub const PVP = 75;
1412pub const IPPROTO_ESP = 50;1413 /// BackRoom SATNET Monitoring
14131414 pub const BRSATMON = 76;
1414/// IP6 Auth Header1415 /// Sun net disk proto (temp.)
1415pub const IPPROTO_AH = 51;1416 pub const ND = 77;
14161417 /// WIDEBAND Monitoring
1417/// Integ. Net Layer Security1418 pub const WBMON = 78;
1418pub const IPPROTO_INLSP = 52;1419 /// WIDEBAND EXPAK
14191420 pub const WBEXPAK = 79;
1420/// IP with encryption1421 /// ISO cnlp
1421pub const IPPROTO_SWIPE = 53;1422 pub const EON = 80;
14221423 /// VMTP
1423/// Next Hop Resolution1424 pub const VMTP = 81;
1424pub const IPPROTO_NHRP = 54;1425 /// Secure VMTP
14251426 pub const SVMTP = 82;
1426/// IP Mobility1427 /// Banyon VINES
1427pub const IPPROTO_MOBILE = 55;1428 pub const VINES = 83;
14281429 /// TTP
1429/// Transport Layer Security1430 pub const TTP = 84;
1430pub const IPPROTO_TLSP = 56;1431 /// NSFNET-IGP
14311432 pub const IGP = 85;
1432/// SKIP1433 /// dissimilar gateway prot.
1433pub const IPPROTO_SKIP = 57;1434 pub const DGP = 86;
14341435 /// TCF
1435/// ICMP61436 pub const TCF = 87;
1436pub const IPPROTO_ICMPV6 = 58;1437 /// Cisco/GXS IGRP
14371438 pub const IGRP = 88;
1438/// IP6 no next header1439 /// OSPFIGP
1439pub const IPPROTO_NONE = 59;1440 pub const OSPFIGP = 89;
14401441 /// Strite RPC protocol
1441/// IP6 destination option1442 pub const SRPC = 90;
1442pub const IPPROTO_DSTOPTS = 60;1443 /// Locus Address Resoloution
14431444 pub const LARP = 91;
1444/// any host internal protocol1445 /// Multicast Transport
1445pub const IPPROTO_AHIP = 61;1446 pub const MTP = 92;
14461447 /// AX.25 Frames
1447/// CFTP1448 pub const AX25 = 93;
1448pub const IPPROTO_CFTP = 62;1449 /// IP encapsulated in IP
14491450 pub const IPEIP = 94;
1450/// "hello" routing protocol1451 /// Mobile Int.ing control
1451pub const IPPROTO_HELLO = 63;1452 pub const MICP = 95;
14521453 /// Semaphore Comm. security
1453/// SATNET/Backroom EXPAK1454 pub const SCCSP = 96;
1454pub const IPPROTO_SATEXPAK = 64;1455 /// Ethernet IP encapsulation
14551456 pub const ETHERIP = 97;
1456/// Kryptolan1457 /// encapsulation header
1457pub const IPPROTO_KRYPTOLAN = 65;1458 pub const ENCAP = 98;
14581459 /// any private encr. scheme
1459/// Remote Virtual Disk1460 pub const APES = 99;
1460pub const IPPROTO_RVD = 66;1461 /// GMTP
14611462 pub const GMTP = 100;
1462/// Pluribus Packet Core1463 /// payload compression (IPComp)
1463pub const IPPROTO_IPPC = 67;1464 pub const IPCOMP = 108;
14641465 /// SCTP
1465/// Any distributed FS1466 pub const SCTP = 132;
1466pub const IPPROTO_ADFS = 68;1467 /// IPv6 Mobility Header
14671468 pub const MH = 135;
1468/// Satnet Monitoring1469 /// UDP-Lite
1469pub const IPPROTO_SATMON = 69;1470 pub const UDPLITE = 136;
14701471 /// IP6 Host Identity Protocol
1471/// VISA Protocol1472 pub const HIP = 139;
1472pub const IPPROTO_VISA = 70;1473 /// IP6 Shim6 Protocol
14731474 pub const SHIM6 = 140;
1474/// Packet Core Utility1475 /// Protocol Independent Mcast
1475pub const IPPROTO_IPCV = 71;1476 pub const PIM = 103;
14761477 /// CARP
1477/// Comp. Prot. Net. Executive1478 pub const CARP = 112;
1478pub const IPPROTO_CPNX = 72;1479 /// PGM
14791480 pub const PGM = 113;
1480/// Comp. Prot. HeartBeat1481 /// MPLS-in-IP
1481pub const IPPROTO_CPHB = 73;1482 pub const MPLS = 137;
14821483 /// PFSYNC
1483/// Wang Span Network1484 pub const PFSYNC = 240;
1484pub const IPPROTO_WSN = 74;1485 /// Reserved
14851486 pub const RESERVED_253 = 253;
1486/// Packet Video Protocol1487 /// Reserved
1487pub const IPPROTO_PVP = 75;1488 pub const RESERVED_254 = 254;
14881489};
1489/// BackRoom SATNET Monitoring
1490pub const IPPROTO_BRSATMON = 76;
1491
1492/// Sun net disk proto (temp.)
1493pub const IPPROTO_ND = 77;
1494
1495/// WIDEBAND Monitoring
1496pub const IPPROTO_WBMON = 78;
1497
1498/// WIDEBAND EXPAK
1499pub const IPPROTO_WBEXPAK = 79;
1500
1501/// ISO cnlp
1502pub const IPPROTO_EON = 80;
1503
1504/// VMTP
1505pub const IPPROTO_VMTP = 81;
1506
1507/// Secure VMTP
1508pub const IPPROTO_SVMTP = 82;
1509
1510/// Banyon VINES
1511pub const IPPROTO_VINES = 83;
1512
1513/// TTP
1514pub const IPPROTO_TTP = 84;
1515
1516/// NSFNET-IGP
1517pub const IPPROTO_IGP = 85;
1518
1519/// dissimilar gateway prot.
1520pub const IPPROTO_DGP = 86;
1521
1522/// TCF
1523pub const IPPROTO_TCF = 87;
1524
1525/// Cisco/GXS IGRP
1526pub const IPPROTO_IGRP = 88;
1527
1528/// OSPFIGP
1529pub const IPPROTO_OSPFIGP = 89;
1530
1531/// Strite RPC protocol
1532pub const IPPROTO_SRPC = 90;
1533
1534/// Locus Address Resoloution
1535pub const IPPROTO_LARP = 91;
1536
1537/// Multicast Transport
1538pub const IPPROTO_MTP = 92;
1539
1540/// AX.25 Frames
1541pub const IPPROTO_AX25 = 93;
1542
1543/// IP encapsulated in IP
1544pub const IPPROTO_IPEIP = 94;
1545
1546/// Mobile Int.ing control
1547pub const IPPROTO_MICP = 95;
1548
1549/// Semaphore Comm. security
1550pub const IPPROTO_SCCSP = 96;
1551
1552/// Ethernet IP encapsulation
1553pub const IPPROTO_ETHERIP = 97;
1554
1555/// encapsulation header
1556pub const IPPROTO_ENCAP = 98;
1557
1558/// any private encr. scheme
1559pub const IPPROTO_APES = 99;
1560
1561/// GMTP
1562pub const IPPROTO_GMTP = 100;
1563
1564/// payload compression (IPComp)
1565pub const IPPROTO_IPCOMP = 108;
1566
1567/// SCTP
1568pub const IPPROTO_SCTP = 132;
1569
1570/// IPv6 Mobility Header
1571pub const IPPROTO_MH = 135;
1572
1573/// UDP-Lite
1574pub const IPPROTO_UDPLITE = 136;
1575
1576/// IP6 Host Identity Protocol
1577pub const IPPROTO_HIP = 139;
1578
1579/// IP6 Shim6 Protocol
1580pub const IPPROTO_SHIM6 = 140;
1581
1582/// Protocol Independent Mcast
1583pub const IPPROTO_PIM = 103;
1584
1585/// CARP
1586pub const IPPROTO_CARP = 112;
1587
1588/// PGM
1589pub const IPPROTO_PGM = 113;
1590
1591/// MPLS-in-IP
1592pub const IPPROTO_MPLS = 137;
1593
1594/// PFSYNC
1595pub const IPPROTO_PFSYNC = 240;
1596
1597/// Reserved
1598pub const IPPROTO_RESERVED_253 = 253;
1599
1600/// Reserved
1601pub const IPPROTO_RESERVED_254 = 254;
16021490
1603pub const rlimit_resource = enum(c_int) {1491pub const rlimit_resource = enum(c_int) {
1604 CPU = 0,1492 CPU = 0,
...@@ -1623,11 +1511,13 @@ pub const rlimit_resource = enum(c_int) {...@@ -1623,11 +1511,13 @@ pub const rlimit_resource = enum(c_int) {
16231511
1624pub const rlim_t = i64;1512pub const rlim_t = i64;
16251513
1626/// No limit1514pub const RLIM = struct {
1627pub const RLIM_INFINITY: rlim_t = (1 << 63) - 1;1515 /// No limit
1516 pub const INFINITY: rlim_t = (1 << 63) - 1;
16281517
1629pub const RLIM_SAVED_MAX = RLIM_INFINITY;1518 pub const SAVED_MAX = INFINITY;
1630pub const RLIM_SAVED_CUR = RLIM_INFINITY;1519 pub const SAVED_CUR = INFINITY;
1520};
16311521
1632pub const rlimit = extern struct {1522pub const rlimit = extern struct {
1633 /// Soft limit1523 /// Soft limit
...@@ -1648,28 +1538,29 @@ pub const pollfd = extern struct {...@@ -1648,28 +1538,29 @@ pub const pollfd = extern struct {
1648 revents: i16,1538 revents: i16,
1649};1539};
16501540
1651/// any readable data available.1541pub const POLL = struct {
1652pub const POLLIN = 0x0001;1542 /// any readable data available.
1653/// OOB/Urgent readable data.1543 pub const IN = 0x0001;
1654pub const POLLPRI = 0x0002;1544 /// OOB/Urgent readable data.
1655/// file descriptor is writeable.1545 pub const PRI = 0x0002;
1656pub const POLLOUT = 0x0004;1546 /// file descriptor is writeable.
1657/// non-OOB/URG data available.1547 pub const OUT = 0x0004;
1658pub const POLLRDNORM = 0x0040;1548 /// non-OOB/URG data available.
1659/// no write type differentiation.1549 pub const RDNORM = 0x0040;
1660pub const POLLWRNORM = POLLOUT;1550 /// no write type differentiation.
1661/// OOB/Urgent readable data.1551 pub const WRNORM = OUT;
1662pub const POLLRDBAND = 0x0080;1552 /// OOB/Urgent readable data.
1663/// OOB/Urgent data can be written.1553 pub const RDBAND = 0x0080;
1664pub const POLLWRBAND = 0x0100;1554 /// OOB/Urgent data can be written.
1665/// like POLLIN, except ignore EOF.1555 pub const WRBAND = 0x0100;
1666pub const POLLINIGNEOF = 0x2000;1556 /// like IN, except ignore EOF.
1667/// some poll error occurred.1557 pub const INIGNEOF = 0x2000;
1668pub const POLLERR = 0x0008;1558 /// some poll error occurred.
1669/// file descriptor was "hung up".1559 pub const ERR = 0x0008;
1670pub const POLLHUP = 0x0010;1560 /// file descriptor was "hung up".
1671/// requested events "invalid".1561 pub const HUP = 0x0010;
1672pub const POLLNVAL = 0x0020;1562 /// requested events "invalid".
16731563 pub const NVAL = 0x0020;
1674pub const POLLSTANDARD = POLLIN | POLLPRI | POLLOUT | POLLRDNORM | POLLRDBAND |1564
1675 POLLWRBAND | POLLERR | POLLHUP | POLLNVAL;1565 pub const STANDARD = IN | PRI | OUT | RDNORM | RDBAND | WRBAND | ERR | HUP | NVAL;
1566};
lib/std/c/haiku.zig+463-564
...@@ -133,33 +133,30 @@ pub const Kevent = extern struct {...@@ -133,33 +133,30 @@ pub const Kevent = extern struct {
133// Modes and flags for dlopen()133// Modes and flags for dlopen()
134// include/dlfcn.h134// include/dlfcn.h
135135
136pub const POLLIN = 0x0001;136pub const POLL = struct {
137pub const POLLERR = 0x0004;137 pub const IN = 0x0001;
138pub const POLLNVAL = 0x1000;138 pub const ERR = 0x0004;
139pub const POLLHUP = 0x0080;139 pub const NVAL = 0x1000;
140140 pub const HUP = 0x0080;
141/// Bind function calls lazily.141};
142pub const RTLD_LAZY = 1;
143
144/// Bind function calls immediately.
145pub const RTLD_NOW = 2;
146
147pub const RTLD_MODEMASK = 0x3;
148
149/// Make symbols globally available.
150pub const RTLD_GLOBAL = 0x100;
151
152/// Opposite of RTLD_GLOBAL, and the default.
153pub const RTLD_LOCAL = 0;
154
155/// Trace loaded objects and exit.
156pub const RTLD_TRACE = 0x200;
157
158/// Do not remove members.
159pub const RTLD_NODELETE = 0x01000;
160142
161/// Do not load if not already loaded.143pub const RTLD = struct {
162pub const RTLD_NOLOAD = 0x02000;144 /// Bind function calls lazily.
145 pub const LAZY = 1;
146 /// Bind function calls immediately.
147 pub const NOW = 2;
148 pub const MODEMASK = 0x3;
149 /// Make symbols globally available.
150 pub const GLOBAL = 0x100;
151 /// Opposite of GLOBAL, and the default.
152 pub const LOCAL = 0;
153 /// Trace loaded objects and exit.
154 pub const TRACE = 0x200;
155 /// Do not remove members.
156 pub const NODELETE = 0x01000;
157 /// Do not load if not already loaded.
158 pub const NOLOAD = 0x02000;
159};
163160
164pub const dl_phdr_info = extern struct {161pub const dl_phdr_info = extern struct {
165 dlpi_addr: usize,162 dlpi_addr: usize,
...@@ -336,37 +333,35 @@ pub const sa_family_t = u8;...@@ -336,37 +333,35 @@ pub const sa_family_t = u8;
336pub const sockaddr = extern struct {333pub const sockaddr = extern struct {
337 /// total length334 /// total length
338 len: u8,335 len: u8,
339
340 /// address family336 /// address family
341 family: sa_family_t,337 family: sa_family_t,
342
343 /// actually longer; address value338 /// actually longer; address value
344 data: [14]u8,339 data: [14]u8,
345};
346
347pub const sockaddr_storage = std.x.os.Socket.Address.Native.Storage;
348
349pub const sockaddr_in = extern struct {
350 len: u8 = @sizeOf(sockaddr_in),
351 family: sa_family_t = AF_INET,
352 port: in_port_t,
353 addr: u32,
354 zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },
355};
356340
357pub const sockaddr_in6 = extern struct {341 pub const storage = std.x.os.Socket.Address.Native.Storage;
358 len: u8 = @sizeOf(sockaddr_in6),342
359 family: sa_family_t = AF_INET6,343 pub const in = extern struct {
360 port: in_port_t,344 len: u8 = @sizeOf(in),
361 flowinfo: u32,345 family: sa_family_t = AF.INET,
362 addr: [16]u8,346 port: in_port_t,
363 scope_id: u32,347 addr: u32,
364};348 zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },
365349 };
366pub const sockaddr_un = extern struct {350
367 len: u8 = @sizeOf(sockaddr_un),351 pub const in6 = extern struct {
368 family: sa_family_t = AF_UNIX,352 len: u8 = @sizeOf(in6),
369 path: [104]u8,353 family: sa_family_t = AF.INET6,
354 port: in_port_t,
355 flowinfo: u32,
356 addr: [16]u8,
357 scope_id: u32,
358 };
359
360 pub const un = extern struct {
361 len: u8 = @sizeOf(un),
362 family: sa_family_t = AF.UNIX,
363 path: [104]u8,
364 };
370};365};
371366
372pub const CTL_KERN = 1;367pub const CTL_KERN = 1;
...@@ -386,27 +381,30 @@ pub const PROT_READ = 1;...@@ -386,27 +381,30 @@ pub const PROT_READ = 1;
386pub const PROT_WRITE = 2;381pub const PROT_WRITE = 2;
387pub const PROT_EXEC = 4;382pub const PROT_EXEC = 4;
388383
389pub const CLOCK_MONOTONIC = 0;384pub const CLOCK = struct {
390pub const CLOCK_REALTIME = -1;385 pub const MONOTONIC = 0;
391pub const CLOCK_PROCESS_CPUTIME_ID = -2;386 pub const REALTIME = -1;
392pub const CLOCK_THREAD_CPUTIME_ID = -3;387 pub const PROCESS_CPUTIME_ID = -2;
393388 pub const THREAD_CPUTIME_ID = -3;
394pub const MAP_FAILED = @intToPtr(*c_void, maxInt(usize));389};
395pub const MAP_SHARED = 0x0001;
396pub const MAP_PRIVATE = 0x0002;
397pub const MAP_FIXED = 0x0010;
398pub const MAP_STACK = 0x0400;
399pub const MAP_NOSYNC = 0x0800;
400pub const MAP_ANON = 0x1000;
401pub const MAP_ANONYMOUS = MAP_ANON;
402pub const MAP_FILE = 0;
403
404pub const MAP_GUARD = 0x00002000;
405pub const MAP_EXCL = 0x00004000;
406pub const MAP_NOCORE = 0x00020000;
407pub const MAP_PREFAULT_READ = 0x00040000;
408pub const MAP_32BIT = 0x00080000;
409390
391pub const MAP = struct {
392 pub const FAILED = @intToPtr(*c_void, maxInt(usize));
393 pub const SHARED = 0x0001;
394 pub const PRIVATE = 0x0002;
395 pub const FIXED = 0x0010;
396 pub const STACK = 0x0400;
397 pub const NOSYNC = 0x0800;
398 pub const ANON = 0x1000;
399 pub const ANONYMOUS = ANON;
400 pub const FILE = 0;
401
402 pub const GUARD = 0x00002000;
403 pub const EXCL = 0x00004000;
404 pub const NOCORE = 0x00020000;
405 pub const PREFAULT_READ = 0x00040000;
406 pub const @"32BIT" = 0x00080000;
407};
410pub const WNOHANG = 0x1;408pub const WNOHANG = 0x1;
411pub const WUNTRACED = 0x2;409pub const WUNTRACED = 0x2;
412pub const WSTOPPED = 0x10;410pub const WSTOPPED = 0x10;
...@@ -514,10 +512,12 @@ pub const F_RDLCK = 1;...@@ -514,10 +512,12 @@ pub const F_RDLCK = 1;
514pub const F_WRLCK = 3;512pub const F_WRLCK = 3;
515pub const F_UNLCK = 2;513pub const F_UNLCK = 2;
516514
517pub const LOCK_SH = 1;515pub const LOCK = struct {
518pub const LOCK_EX = 2;516 pub const SH = 1;
519pub const LOCK_UN = 8;517 pub const EX = 2;
520pub const LOCK_NB = 4;518 pub const UN = 8;
519 pub const NB = 4;
520};
521521
522pub const F_SETOWN_EX = 15;522pub const F_SETOWN_EX = 15;
523pub const F_GETOWN_EX = 16;523pub const F_GETOWN_EX = 16;
...@@ -534,143 +534,153 @@ pub const SIG_BLOCK = 1;...@@ -534,143 +534,153 @@ pub const SIG_BLOCK = 1;
534pub const SIG_UNBLOCK = 2;534pub const SIG_UNBLOCK = 2;
535pub const SIG_SETMASK = 3;535pub const SIG_SETMASK = 3;
536536
537pub const SOCK_STREAM = 1;537pub const SOCK = struct {
538pub const SOCK_DGRAM = 2;538 pub const STREAM = 1;
539pub const SOCK_RAW = 3;539 pub const DGRAM = 2;
540pub const SOCK_RDM = 4;540 pub const RAW = 3;
541pub const SOCK_SEQPACKET = 5;541 pub const RDM = 4;
542542 pub const SEQPACKET = 5;
543pub const SOCK_CLOEXEC = 0x10000000;543
544pub const SOCK_NONBLOCK = 0x20000000;544 pub const CLOEXEC = 0x10000000;
545545 pub const NONBLOCK = 0x20000000;
546pub const SO_DEBUG = 0x00000001;546};
547pub const SO_ACCEPTCONN = 0x00000002;547
548pub const SO_REUSEADDR = 0x00000004;548pub const SO = struct {
549pub const SO_KEEPALIVE = 0x00000008;549 pub const DEBUG = 0x00000001;
550pub const SO_DONTROUTE = 0x00000010;550 pub const ACCEPTCONN = 0x00000002;
551pub const SO_BROADCAST = 0x00000020;551 pub const REUSEADDR = 0x00000004;
552pub const SO_USELOOPBACK = 0x00000040;552 pub const KEEPALIVE = 0x00000008;
553pub const SO_LINGER = 0x00000080;553 pub const DONTROUTE = 0x00000010;
554pub const SO_OOBINLINE = 0x00000100;554 pub const BROADCAST = 0x00000020;
555pub const SO_REUSEPORT = 0x00000200;555 pub const USELOOPBACK = 0x00000040;
556pub const SO_TIMESTAMP = 0x00000400;556 pub const LINGER = 0x00000080;
557pub const SO_NOSIGPIPE = 0x00000800;557 pub const OOBINLINE = 0x00000100;
558pub const SO_ACCEPTFILTER = 0x00001000;558 pub const REUSEPORT = 0x00000200;
559pub const SO_BINTIME = 0x00002000;559 pub const TIMESTAMP = 0x00000400;
560pub const SO_NO_OFFLOAD = 0x00004000;560 pub const NOSIGPIPE = 0x00000800;
561pub const SO_NO_DDP = 0x00008000;561 pub const ACCEPTFILTER = 0x00001000;
562pub const SO_REUSEPORT_LB = 0x00010000;562 pub const BINTIME = 0x00002000;
563563 pub const NO_OFFLOAD = 0x00004000;
564pub const SO_SNDBUF = 0x1001;564 pub const NO_DDP = 0x00008000;
565pub const SO_RCVBUF = 0x1002;565 pub const REUSEPORT_LB = 0x00010000;
566pub const SO_SNDLOWAT = 0x1003;566
567pub const SO_RCVLOWAT = 0x1004;567 pub const SNDBUF = 0x1001;
568pub const SO_SNDTIMEO = 0x1005;568 pub const RCVBUF = 0x1002;
569pub const SO_RCVTIMEO = 0x1006;569 pub const SNDLOWAT = 0x1003;
570pub const SO_ERROR = 0x1007;570 pub const RCVLOWAT = 0x1004;
571pub const SO_TYPE = 0x1008;571 pub const SNDTIMEO = 0x1005;
572pub const SO_LABEL = 0x1009;572 pub const RCVTIMEO = 0x1006;
573pub const SO_PEERLABEL = 0x1010;573 pub const ERROR = 0x1007;
574pub const SO_LISTENQLIMIT = 0x1011;574 pub const TYPE = 0x1008;
575pub const SO_LISTENQLEN = 0x1012;575 pub const LABEL = 0x1009;
576pub const SO_LISTENINCQLEN = 0x1013;576 pub const PEERLABEL = 0x1010;
577pub const SO_SETFIB = 0x1014;577 pub const LISTENQLIMIT = 0x1011;
578pub const SO_USER_COOKIE = 0x1015;578 pub const LISTENQLEN = 0x1012;
579pub const SO_PROTOCOL = 0x1016;579 pub const LISTENINCQLEN = 0x1013;
580pub const SO_PROTOTYPE = SO_PROTOCOL;580 pub const SETFIB = 0x1014;
581pub const SO_TS_CLOCK = 0x1017;581 pub const USER_COOKIE = 0x1015;
582pub const SO_MAX_PACING_RATE = 0x1018;582 pub const PROTOCOL = 0x1016;
583pub const SO_DOMAIN = 0x1019;583 pub const PROTOTYPE = PROTOCOL;
584584 pub const TS_CLOCK = 0x1017;
585pub const SOL_SOCKET = 0xffff;585 pub const MAX_PACING_RATE = 0x1018;
586586 pub const DOMAIN = 0x1019;
587pub const PF_UNSPEC = AF_UNSPEC;587};
588pub const PF_LOCAL = AF_LOCAL;588
589pub const PF_UNIX = PF_LOCAL;589pub const SOL = struct {
590pub const PF_INET = AF_INET;590 pub const SOCKET = 0xffff;
591pub const PF_IMPLINK = AF_IMPLINK;591};
592pub const PF_PUP = AF_PUP;592
593pub const PF_CHAOS = AF_CHAOS;593pub const PF = struct {
594pub const PF_NETBIOS = AF_NETBIOS;594 pub const UNSPEC = AF.UNSPEC;
595pub const PF_ISO = AF_ISO;595 pub const LOCAL = AF.LOCAL;
596pub const PF_OSI = AF_ISO;596 pub const UNIX = PF.LOCAL;
597pub const PF_ECMA = AF_ECMA;597 pub const INET = AF.INET;
598pub const PF_DATAKIT = AF_DATAKIT;598 pub const IMPLINK = AF.IMPLINK;
599pub const PF_CCITT = AF_CCITT;599 pub const PUP = AF.PUP;
600pub const PF_DECnet = AF_DECnet;600 pub const CHAOS = AF.CHAOS;
601pub const PF_DLI = AF_DLI;601 pub const NETBIOS = AF.NETBIOS;
602pub const PF_LAT = AF_LAT;602 pub const ISO = AF.ISO;
603pub const PF_HYLINK = AF_HYLINK;603 pub const OSI = AF.ISO;
604pub const PF_APPLETALK = AF_APPLETALK;604 pub const ECMA = AF.ECMA;
605pub const PF_ROUTE = AF_ROUTE;605 pub const DATAKIT = AF.DATAKIT;
606pub const PF_LINK = AF_LINK;606 pub const CCITT = AF.CCITT;
607pub const PF_XTP = pseudo_AF_XTP;607 pub const DECnet = AF.DECnet;
608pub const PF_COIP = AF_COIP;608 pub const DLI = AF.DLI;
609pub const PF_CNT = AF_CNT;609 pub const LAT = AF.LAT;
610pub const PF_SIP = AF_SIP;610 pub const HYLINK = AF.HYLINK;
611pub const PF_IPX = AF_IPX;611 pub const APPLETALK = AF.APPLETALK;
612pub const PF_RTIP = pseudo_AF_RTIP;612 pub const ROUTE = AF.ROUTE;
613pub const PF_PIP = psuedo_AF_PIP;613 pub const LINK = AF.LINK;
614pub const PF_ISDN = AF_ISDN;614 pub const XTP = AF.pseudo_XTP;
615pub const PF_KEY = pseudo_AF_KEY;615 pub const COIP = AF.COIP;
616pub const PF_INET6 = pseudo_AF_INET6;616 pub const CNT = AF.CNT;
617pub const PF_NATM = AF_NATM;617 pub const SIP = AF.SIP;
618pub const PF_ATM = AF_ATM;618 pub const IPX = AF.IPX;
619pub const PF_NETGRAPH = AF_NETGRAPH;619 pub const RTIP = AF.pseudo_RTIP;
620pub const PF_SLOW = AF_SLOW;620 pub const PIP = psuedo_AF.PIP;
621pub const PF_SCLUSTER = AF_SCLUSTER;621 pub const ISDN = AF.ISDN;
622pub const PF_ARP = AF_ARP;622 pub const KEY = AF.pseudo_KEY;
623pub const PF_BLUETOOTH = AF_BLUETOOTH;623 pub const INET6 = AF.pseudo_INET6;
624pub const PF_IEEE80211 = AF_IEEE80211;624 pub const NATM = AF.NATM;
625pub const PF_INET_SDP = AF_INET_SDP;625 pub const ATM = AF.ATM;
626pub const PF_INET6_SDP = AF_INET6_SDP;626 pub const NETGRAPH = AF.NETGRAPH;
627pub const PF_MAX = AF_MAX;627 pub const SLOW = AF.SLOW;
628628 pub const SCLUSTER = AF.SCLUSTER;
629pub const AF_UNSPEC = 0;629 pub const ARP = AF.ARP;
630pub const AF_UNIX = 1;630 pub const BLUETOOTH = AF.BLUETOOTH;
631pub const AF_LOCAL = AF_UNIX;631 pub const IEEE80211 = AF.IEEE80211;
632pub const AF_FILE = AF_LOCAL;632 pub const INET_SDP = AF.INET_SDP;
633pub const AF_INET = 2;633 pub const INET6_SDP = AF.INET6_SDP;
634pub const AF_IMPLINK = 3;634 pub const MAX = AF.MAX;
635pub const AF_PUP = 4;635};
636pub const AF_CHAOS = 5;636
637pub const AF_NETBIOS = 6;637pub const AF = struct {
638pub const AF_ISO = 7;638 pub const UNSPEC = 0;
639pub const AF_OSI = AF_ISO;639 pub const UNIX = 1;
640pub const AF_ECMA = 8;640 pub const LOCAL = UNIX;
641pub const AF_DATAKIT = 9;641 pub const FILE = LOCAL;
642pub const AF_CCITT = 10;642 pub const INET = 2;
643pub const AF_SNA = 11;643 pub const IMPLINK = 3;
644pub const AF_DECnet = 12;644 pub const PUP = 4;
645pub const AF_DLI = 13;645 pub const CHAOS = 5;
646pub const AF_LAT = 14;646 pub const NETBIOS = 6;
647pub const AF_HYLINK = 15;647 pub const ISO = 7;
648pub const AF_APPLETALK = 16;648 pub const OSI = ISO;
649pub const AF_ROUTE = 17;649 pub const ECMA = 8;
650pub const AF_LINK = 18;650 pub const DATAKIT = 9;
651pub const pseudo_AF_XTP = 19;651 pub const CCITT = 10;
652pub const AF_COIP = 20;652 pub const SNA = 11;
653pub const AF_CNT = 21;653 pub const DECnet = 12;
654pub const pseudo_AF_RTIP = 22;654 pub const DLI = 13;
655pub const AF_IPX = 23;655 pub const LAT = 14;
656pub const AF_SIP = 24;656 pub const HYLINK = 15;
657pub const pseudo_AF_PIP = 25;657 pub const APPLETALK = 16;
658pub const AF_ISDN = 26;658 pub const ROUTE = 17;
659pub const AF_E164 = AF_ISDN;659 pub const LINK = 18;
660pub const pseudo_AF_KEY = 27;660 pub const pseudo_XTP = 19;
661pub const AF_INET6 = 28;661 pub const COIP = 20;
662pub const AF_NATM = 29;662 pub const CNT = 21;
663pub const AF_ATM = 30;663 pub const pseudo_RTIP = 22;
664pub const pseudo_AF_HDRCMPLT = 31;664 pub const IPX = 23;
665pub const AF_NETGRAPH = 32;665 pub const SIP = 24;
666pub const AF_SLOW = 33;666 pub const pseudo_PIP = 25;
667pub const AF_SCLUSTER = 34;667 pub const ISDN = 26;
668pub const AF_ARP = 35;668 pub const E164 = ISDN;
669pub const AF_BLUETOOTH = 36;669 pub const pseudo_KEY = 27;
670pub const AF_IEEE80211 = 37;670 pub const INET6 = 28;
671pub const AF_INET_SDP = 40;671 pub const NATM = 29;
672pub const AF_INET6_SDP = 42;672 pub const ATM = 30;
673pub const AF_MAX = 42;673 pub const pseudo_HDRCMPLT = 31;
674 pub const NETGRAPH = 32;
675 pub const SLOW = 33;
676 pub const SCLUSTER = 34;
677 pub const ARP = 35;
678 pub const BLUETOOTH = 36;
679 pub const IEEE80211 = 37;
680 pub const INET_SDP = 40;
681 pub const INET6_SDP = 42;
682 pub const MAX = 42;
683};
674684
675pub const DT_UNKNOWN = 0;685pub const DT_UNKNOWN = 0;
676pub const DT_FIFO = 1;686pub const DT_FIFO = 1;
...@@ -1070,353 +1080,240 @@ pub const addrinfo = extern struct {...@@ -1070,353 +1080,240 @@ pub const addrinfo = extern struct {
1070/// Fail if not under dirfd1080/// Fail if not under dirfd
1071pub const AT_BENEATH = 0x1000;1081pub const AT_BENEATH = 0x1000;
10721082
1073/// dummy for IP1083pub const IPPROTO = struct {
1074pub const IPPROTO_IP = 0;1084 /// dummy for IP
10751085 pub const IP = 0;
1076/// control message protocol1086 /// control message protocol
1077pub const IPPROTO_ICMP = 1;1087 pub const ICMP = 1;
10781088 /// tcp
1079/// tcp1089 pub const TCP = 6;
1080pub const IPPROTO_TCP = 6;1090 /// user datagram protocol
10811091 pub const UDP = 17;
1082/// user datagram protocol1092 /// IP6 header
1083pub const IPPROTO_UDP = 17;1093 pub const IPV6 = 41;
10841094 /// raw IP packet
1085/// IP6 header1095 pub const RAW = 255;
1086pub const IPPROTO_IPV6 = 41;1096 /// IP6 hop-by-hop options
10871097 pub const HOPOPTS = 0;
1088/// raw IP packet1098 /// group mgmt protocol
1089pub const IPPROTO_RAW = 255;1099 pub const IGMP = 2;
10901100 /// gateway^2 (deprecated)
1091/// IP6 hop-by-hop options1101 pub const GGP = 3;
1092pub const IPPROTO_HOPOPTS = 0;1102 /// IPv4 encapsulation
10931103 pub const IPV4 = 4;
1094/// group mgmt protocol1104 /// for compatibility
1095pub const IPPROTO_IGMP = 2;1105 pub const IPIP = IPV4;
10961106 /// Stream protocol II
1097/// gateway^2 (deprecated)1107 pub const ST = 7;
1098pub const IPPROTO_GGP = 3;1108 /// exterior gateway protocol
10991109 pub const EGP = 8;
1100/// IPv4 encapsulation1110 /// private interior gateway
1101pub const IPPROTO_IPV4 = 4;1111 pub const PIGP = 9;
11021112 /// BBN RCC Monitoring
1103/// for compatibility1113 pub const RCCMON = 10;
1104pub const IPPROTO_IPIP = IPPROTO_IPV4;1114 /// network voice protocol
11051115 pub const NVPII = 11;
1106/// Stream protocol II1116 /// pup
1107pub const IPPROTO_ST = 7;1117 pub const PUP = 12;
11081118 /// Argus
1109/// exterior gateway protocol1119 pub const ARGUS = 13;
1110pub const IPPROTO_EGP = 8;1120 /// EMCON
11111121 pub const EMCON = 14;
1112/// private interior gateway1122 /// Cross Net Debugger
1113pub const IPPROTO_PIGP = 9;1123 pub const XNET = 15;
11141124 /// Chaos
1115/// BBN RCC Monitoring1125 pub const CHAOS = 16;
1116pub const IPPROTO_RCCMON = 10;1126 /// Multiplexing
11171127 pub const MUX = 18;
1118/// network voice protocol1128 /// DCN Measurement Subsystems
1119pub const IPPROTO_NVPII = 11;1129 pub const MEAS = 19;
11201130 /// Host Monitoring
1121/// pup1131 pub const HMP = 20;
1122pub const IPPROTO_PUP = 12;1132 /// Packet Radio Measurement
11231133 pub const PRM = 21;
1124/// Argus1134 /// xns idp
1125pub const IPPROTO_ARGUS = 13;1135 pub const IDP = 22;
11261136 /// Trunk-1
1127/// EMCON1137 pub const TRUNK1 = 23;
1128pub const IPPROTO_EMCON = 14;1138 /// Trunk-2
11291139 pub const TRUNK2 = 24;
1130/// Cross Net Debugger1140 /// Leaf-1
1131pub const IPPROTO_XNET = 15;1141 pub const LEAF1 = 25;
11321142 /// Leaf-2
1133/// Chaos1143 pub const LEAF2 = 26;
1134pub const IPPROTO_CHAOS = 16;1144 /// Reliable Data
11351145 pub const RDP = 27;
1136/// Multiplexing1146 /// Reliable Transaction
1137pub const IPPROTO_MUX = 18;1147 pub const IRTP = 28;
11381148 /// tp-4 w/ class negotiation
1139/// DCN Measurement Subsystems1149 pub const TP = 29;
1140pub const IPPROTO_MEAS = 19;1150 /// Bulk Data Transfer
11411151 pub const BLT = 30;
1142/// Host Monitoring1152 /// Network Services
1143pub const IPPROTO_HMP = 20;1153 pub const NSP = 31;
11441154 /// Merit Internodal
1145/// Packet Radio Measurement1155 pub const INP = 32;
1146pub const IPPROTO_PRM = 21;1156 /// Datagram Congestion Control Protocol
11471157 pub const DCCP = 33;
1148/// xns idp1158 /// Third Party Connect
1149pub const IPPROTO_IDP = 22;1159 pub const @"3PC" = 34;
11501160 /// InterDomain Policy Routing
1151/// Trunk-11161 pub const IDPR = 35;
1152pub const IPPROTO_TRUNK1 = 23;1162 /// XTP
11531163 pub const XTP = 36;
1154/// Trunk-21164 /// Datagram Delivery
1155pub const IPPROTO_TRUNK2 = 24;1165 pub const DDP = 37;
11561166 /// Control Message Transport
1157/// Leaf-11167 pub const CMTP = 38;
1158pub const IPPROTO_LEAF1 = 25;1168 /// TP++ Transport
11591169 pub const TPXX = 39;
1160/// Leaf-21170 /// IL transport protocol
1161pub const IPPROTO_LEAF2 = 26;1171 pub const IL = 40;
11621172 /// Source Demand Routing
1163/// Reliable Data1173 pub const SDRP = 42;
1164pub const IPPROTO_RDP = 27;1174 /// IP6 routing header
11651175 pub const ROUTING = 43;
1166/// Reliable Transaction1176 /// IP6 fragmentation header
1167pub const IPPROTO_IRTP = 28;1177 pub const FRAGMENT = 44;
11681178 /// InterDomain Routing
1169/// tp-4 w/ class negotiation1179 pub const IDRP = 45;
1170pub const IPPROTO_TP = 29;1180 /// resource reservation
11711181 pub const RSVP = 46;
1172/// Bulk Data Transfer1182 /// General Routing Encap.
1173pub const IPPROTO_BLT = 30;1183 pub const GRE = 47;
11741184 /// Mobile Host Routing
1175/// Network Services1185 pub const MHRP = 48;
1176pub const IPPROTO_NSP = 31;1186 /// BHA
11771187 pub const BHA = 49;
1178/// Merit Internodal1188 /// IP6 Encap Sec. Payload
1179pub const IPPROTO_INP = 32;1189 pub const ESP = 50;
11801190 /// IP6 Auth Header
1181/// Datagram Congestion Control Protocol1191 pub const AH = 51;
1182pub const IPPROTO_DCCP = 33;1192 /// Integ. Net Layer Security
11831193 pub const INLSP = 52;
1184/// Third Party Connect1194 /// IP with encryption
1185pub const IPPROTO_3PC = 34;1195 pub const SWIPE = 53;
11861196 /// Next Hop Resolution
1187/// InterDomain Policy Routing1197 pub const NHRP = 54;
1188pub const IPPROTO_IDPR = 35;1198 /// IP Mobility
11891199 pub const MOBILE = 55;
1190/// XTP1200 /// Transport Layer Security
1191pub const IPPROTO_XTP = 36;1201 pub const TLSP = 56;
11921202 /// SKIP
1193/// Datagram Delivery1203 pub const SKIP = 57;
1194pub const IPPROTO_DDP = 37;1204 /// ICMP6
11951205 pub const ICMPV6 = 58;
1196/// Control Message Transport1206 /// IP6 no next header
1197pub const IPPROTO_CMTP = 38;1207 pub const NONE = 59;
11981208 /// IP6 destination option
1199/// TP++ Transport1209 pub const DSTOPTS = 60;
1200pub const IPPROTO_TPXX = 39;1210 /// any host internal protocol
12011211 pub const AHIP = 61;
1202/// IL transport protocol1212 /// CFTP
1203pub const IPPROTO_IL = 40;1213 pub const CFTP = 62;
12041214 /// "hello" routing protocol
1205/// Source Demand Routing1215 pub const HELLO = 63;
1206pub const IPPROTO_SDRP = 42;1216 /// SATNET/Backroom EXPAK
12071217 pub const SATEXPAK = 64;
1208/// IP6 routing header1218 /// Kryptolan
1209pub const IPPROTO_ROUTING = 43;1219 pub const KRYPTOLAN = 65;
12101220 /// Remote Virtual Disk
1211/// IP6 fragmentation header1221 pub const RVD = 66;
1212pub const IPPROTO_FRAGMENT = 44;1222 /// Pluribus Packet Core
12131223 pub const IPPC = 67;
1214/// InterDomain Routing1224 /// Any distributed FS
1215pub const IPPROTO_IDRP = 45;1225 pub const ADFS = 68;
12161226 /// Satnet Monitoring
1217/// resource reservation1227 pub const SATMON = 69;
1218pub const IPPROTO_RSVP = 46;1228 /// VISA Protocol
12191229 pub const VISA = 70;
1220/// General Routing Encap.1230 /// Packet Core Utility
1221pub const IPPROTO_GRE = 47;1231 pub const IPCV = 71;
12221232 /// Comp. Prot. Net. Executive
1223/// Mobile Host Routing1233 pub const CPNX = 72;
1224pub const IPPROTO_MHRP = 48;1234 /// Comp. Prot. HeartBeat
12251235 pub const CPHB = 73;
1226/// BHA1236 /// Wang Span Network
1227pub const IPPROTO_BHA = 49;1237 pub const WSN = 74;
12281238 /// Packet Video Protocol
1229/// IP6 Encap Sec. Payload1239 pub const PVP = 75;
1230pub const IPPROTO_ESP = 50;1240 /// BackRoom SATNET Monitoring
12311241 pub const BRSATMON = 76;
1232/// IP6 Auth Header1242 /// Sun net disk proto (temp.)
1233pub const IPPROTO_AH = 51;1243 pub const ND = 77;
12341244 /// WIDEBAND Monitoring
1235/// Integ. Net Layer Security1245 pub const WBMON = 78;
1236pub const IPPROTO_INLSP = 52;1246 /// WIDEBAND EXPAK
12371247 pub const WBEXPAK = 79;
1238/// IP with encryption1248 /// ISO cnlp
1239pub const IPPROTO_SWIPE = 53;1249 pub const EON = 80;
12401250 /// VMTP
1241/// Next Hop Resolution1251 pub const VMTP = 81;
1242pub const IPPROTO_NHRP = 54;1252 /// Secure VMTP
12431253 pub const SVMTP = 82;
1244/// IP Mobility1254 /// Banyon VINES
1245pub const IPPROTO_MOBILE = 55;1255 pub const VINES = 83;
12461256 /// TTP
1247/// Transport Layer Security1257 pub const TTP = 84;
1248pub const IPPROTO_TLSP = 56;1258 /// NSFNET-IGP
12491259 pub const IGP = 85;
1250/// SKIP1260 /// dissimilar gateway prot.
1251pub const IPPROTO_SKIP = 57;1261 pub const DGP = 86;
12521262 /// TCF
1253/// ICMP61263 pub const TCF = 87;
1254pub const IPPROTO_ICMPV6 = 58;1264 /// Cisco/GXS IGRP
12551265 pub const IGRP = 88;
1256/// IP6 no next header1266 /// OSPFIGP
1257pub const IPPROTO_NONE = 59;1267 pub const OSPFIGP = 89;
12581268 /// Strite RPC protocol
1259/// IP6 destination option1269 pub const SRPC = 90;
1260pub const IPPROTO_DSTOPTS = 60;1270 /// Locus Address Resoloution
12611271 pub const LARP = 91;
1262/// any host internal protocol1272 /// Multicast Transport
1263pub const IPPROTO_AHIP = 61;1273 pub const MTP = 92;
12641274 /// AX.25 Frames
1265/// CFTP1275 pub const AX25 = 93;
1266pub const IPPROTO_CFTP = 62;1276 /// IP encapsulated in IP
12671277 pub const IPEIP = 94;
1268/// "hello" routing protocol1278 /// Mobile Int.ing control
1269pub const IPPROTO_HELLO = 63;1279 pub const MICP = 95;
12701280 /// Semaphore Comm. security
1271/// SATNET/Backroom EXPAK1281 pub const SCCSP = 96;
1272pub const IPPROTO_SATEXPAK = 64;1282 /// Ethernet IP encapsulation
12731283 pub const ETHERIP = 97;
1274/// Kryptolan1284 /// encapsulation header
1275pub const IPPROTO_KRYPTOLAN = 65;1285 pub const ENCAP = 98;
12761286 /// any private encr. scheme
1277/// Remote Virtual Disk1287 pub const APES = 99;
1278pub const IPPROTO_RVD = 66;1288 /// GMTP
12791289 pub const GMTP = 100;
1280/// Pluribus Packet Core1290 /// payload compression (IPComp)
1281pub const IPPROTO_IPPC = 67;1291 pub const IPCOMP = 108;
12821292 /// SCTP
1283/// Any distributed FS1293 pub const SCTP = 132;
1284pub const IPPROTO_ADFS = 68;1294 /// IPv6 Mobility Header
12851295 pub const MH = 135;
1286/// Satnet Monitoring1296 /// UDP-Lite
1287pub const IPPROTO_SATMON = 69;1297 pub const UDPLITE = 136;
12881298 /// IP6 Host Identity Protocol
1289/// VISA Protocol1299 pub const HIP = 139;
1290pub const IPPROTO_VISA = 70;1300 /// IP6 Shim6 Protocol
12911301 pub const SHIM6 = 140;
1292/// Packet Core Utility1302 /// Protocol Independent Mcast
1293pub const IPPROTO_IPCV = 71;1303 pub const PIM = 103;
12941304 /// CARP
1295/// Comp. Prot. Net. Executive1305 pub const CARP = 112;
1296pub const IPPROTO_CPNX = 72;1306 /// PGM
12971307 pub const PGM = 113;
1298/// Comp. Prot. HeartBeat1308 /// MPLS-in-IP
1299pub const IPPROTO_CPHB = 73;1309 pub const MPLS = 137;
13001310 /// PFSYNC
1301/// Wang Span Network1311 pub const PFSYNC = 240;
1302pub const IPPROTO_WSN = 74;1312 /// Reserved
13031313 pub const RESERVED_253 = 253;
1304/// Packet Video Protocol1314 /// Reserved
1305pub const IPPROTO_PVP = 75;1315 pub const RESERVED_254 = 254;
13061316};
1307/// BackRoom SATNET Monitoring
1308pub const IPPROTO_BRSATMON = 76;
1309
1310/// Sun net disk proto (temp.)
1311pub const IPPROTO_ND = 77;
1312
1313/// WIDEBAND Monitoring
1314pub const IPPROTO_WBMON = 78;
1315
1316/// WIDEBAND EXPAK
1317pub const IPPROTO_WBEXPAK = 79;
1318
1319/// ISO cnlp
1320pub const IPPROTO_EON = 80;
1321
1322/// VMTP
1323pub const IPPROTO_VMTP = 81;
1324
1325/// Secure VMTP
1326pub const IPPROTO_SVMTP = 82;
1327
1328/// Banyon VINES
1329pub const IPPROTO_VINES = 83;
1330
1331/// TTP
1332pub const IPPROTO_TTP = 84;
1333
1334/// NSFNET-IGP
1335pub const IPPROTO_IGP = 85;
1336
1337/// dissimilar gateway prot.
1338pub const IPPROTO_DGP = 86;
1339
1340/// TCF
1341pub const IPPROTO_TCF = 87;
1342
1343/// Cisco/GXS IGRP
1344pub const IPPROTO_IGRP = 88;
1345
1346/// OSPFIGP
1347pub const IPPROTO_OSPFIGP = 89;
1348
1349/// Strite RPC protocol
1350pub const IPPROTO_SRPC = 90;
1351
1352/// Locus Address Resoloution
1353pub const IPPROTO_LARP = 91;
1354
1355/// Multicast Transport
1356pub const IPPROTO_MTP = 92;
1357
1358/// AX.25 Frames
1359pub const IPPROTO_AX25 = 93;
1360
1361/// IP encapsulated in IP
1362pub const IPPROTO_IPEIP = 94;
1363
1364/// Mobile Int.ing control
1365pub const IPPROTO_MICP = 95;
1366
1367/// Semaphore Comm. security
1368pub const IPPROTO_SCCSP = 96;
1369
1370/// Ethernet IP encapsulation
1371pub const IPPROTO_ETHERIP = 97;
1372
1373/// encapsulation header
1374pub const IPPROTO_ENCAP = 98;
1375
1376/// any private encr. scheme
1377pub const IPPROTO_APES = 99;
1378
1379/// GMTP
1380pub const IPPROTO_GMTP = 100;
1381
1382/// payload compression (IPComp)
1383pub const IPPROTO_IPCOMP = 108;
1384
1385/// SCTP
1386pub const IPPROTO_SCTP = 132;
1387
1388/// IPv6 Mobility Header
1389pub const IPPROTO_MH = 135;
1390
1391/// UDP-Lite
1392pub const IPPROTO_UDPLITE = 136;
1393
1394/// IP6 Host Identity Protocol
1395pub const IPPROTO_HIP = 139;
1396
1397/// IP6 Shim6 Protocol
1398pub const IPPROTO_SHIM6 = 140;
1399
1400/// Protocol Independent Mcast
1401pub const IPPROTO_PIM = 103;
1402
1403/// CARP
1404pub const IPPROTO_CARP = 112;
1405
1406/// PGM
1407pub const IPPROTO_PGM = 113;
1408
1409/// MPLS-in-IP
1410pub const IPPROTO_MPLS = 137;
1411
1412/// PFSYNC
1413pub const IPPROTO_PFSYNC = 240;
1414
1415/// Reserved
1416pub const IPPROTO_RESERVED_253 = 253;
1417
1418/// Reserved
1419pub const IPPROTO_RESERVED_254 = 254;
14201317
1421pub const rlimit_resource = enum(c_int) {1318pub const rlimit_resource = enum(c_int) {
1422 CPU = 0,1319 CPU = 0,
...@@ -1441,11 +1338,13 @@ pub const rlimit_resource = enum(c_int) {...@@ -1441,11 +1338,13 @@ pub const rlimit_resource = enum(c_int) {
14411338
1442pub const rlim_t = i64;1339pub const rlim_t = i64;
14431340
1444/// No limit1341pub const RLIM = struct {
1445pub const RLIM_INFINITY: rlim_t = (1 << 63) - 1;1342 /// No limit
1343 pub const INFINITY: rlim_t = (1 << 63) - 1;
14461344
1447pub const RLIM_SAVED_MAX = RLIM_INFINITY;1345 pub const SAVED_MAX = INFINITY;
1448pub const RLIM_SAVED_CUR = RLIM_INFINITY;1346 pub const SAVED_CUR = INFINITY;
1347};
14491348
1450pub const rlimit = extern struct {1349pub const rlimit = extern struct {
1451 /// Soft limit1350 /// Soft limit
lib/std/c/linux.zig+58-28
...@@ -4,61 +4,93 @@ const maxInt = std.math.maxInt;...@@ -4,61 +4,93 @@ const maxInt = std.math.maxInt;
4const native_abi = builtin.abi;4const native_abi = builtin.abi;
5const native_arch = builtin.cpu.arch;5const native_arch = builtin.cpu.arch;
6const linux = std.os.linux;6const linux = std.os.linux;
7const iovec = std.os.iovec;
8const iovec_const = std.os.iovec_const;
79
8pub const E = linux.E;10pub const AF = linux.AF;
9pub const Sigaction = linux.Sigaction;11pub const ARCH = linux.ARCH;
10pub const dl_phdr_info = linux.dl_phdr_info;
11pub const fd_t = linux.fd_t;
12pub const rlimit = linux.rlimit;
13pub const rlimit_resource = linux.rlimit_resource;
14pub const timespec = linux.timespec;
15pub const NAME_MAX = linux.NAME_MAX;
16pub const PATH_MAX = linux.PATH_MAX;
17pub const IOV_MAX = linux.IOV_MAX;
18pub const STDIN_FILENO = linux.STDIN_FILENO;
19pub const STDOUT_FILENO = linux.STDIN_FILENO;
20pub const STDERR_FILENO = linux.STDIN_FILENO;
21pub const AT = linux.AT;12pub const AT = linux.AT;
22pub const PROT = linux.PROT;
23pub const CLOCK = linux.CLOCK;13pub const CLOCK = linux.CLOCK;
24pub const SIG = linux.SIG;14pub const CPU_COUNT = linux.CPU_COUNT;
25pub const empty_sigset = linux.empty_sigset;15pub const E = linux.E;
26pub const S = linux.S;
27pub const siginfo_t = linux.siginfo_t;
28pub const SA = linux.SA;
29pub const pollfd = linux.pollfd;
30pub const sigset_t = linux.sigset_t;
31pub const ARCH = linux.ARCH;
32pub const Elf_Symndx = linux.Elf_Symndx;16pub const Elf_Symndx = linux.Elf_Symndx;
33pub const F = linux.F;17pub const F = linux.F;
18pub const FD_CLOEXEC = linux.FD_CLOEXEC;
19pub const F_OK = linux.F_OK;
34pub const Flock = linux.Flock;20pub const Flock = linux.Flock;
21pub const HOST_NAME_MAX = linux.HOST_NAME_MAX;
22pub const IFNAMESIZE = linux.IFNAMESIZE;
23pub const IOV_MAX = linux.IOV_MAX;
24pub const IPPROTO = linux.IPPROTO;
35pub const LOCK = linux.LOCK;25pub const LOCK = linux.LOCK;
26pub const MADV = linux.MADV;
36pub const MAP = linux.MAP;27pub const MAP = linux.MAP;
37pub const MMAP2_UNIT = linux.MMAP2_UNIT;28pub const MMAP2_UNIT = linux.MMAP2_UNIT;
29pub const NAME_MAX = linux.NAME_MAX;
38pub const O = linux.O;30pub const O = linux.O;
31pub const PATH_MAX = linux.PATH_MAX;
32pub const POLL = linux.POLL;
33pub const PROT = linux.PROT;
39pub const REG = linux.REG;34pub const REG = linux.REG;
35pub const RLIM = linux.RLIM;
36pub const R_OK = linux.R_OK;
37pub const S = linux.S;
38pub const SA = linux.SA;
40pub const SC = linux.SC;39pub const SC = linux.SC;
40pub const SEEK = linux.SEEK;
41pub const SHUT = linux.SHUT;
42pub const SIG = linux.SIG;
43pub const SIOCGIFINDEX = linux.SIOCGIFINDEX;
44pub const SO = linux.SO;
45pub const SOCK = linux.SOCK;
46pub const SOL = linux.SOL;
47pub const STDERR_FILENO = linux.STDIN_FILENO;
48pub const STDIN_FILENO = linux.STDIN_FILENO;
49pub const STDOUT_FILENO = linux.STDIN_FILENO;
41pub const SYS = linux.SYS;50pub const SYS = linux.SYS;
51pub const Sigaction = linux.Sigaction;
42pub const VDSO = linux.VDSO;52pub const VDSO = linux.VDSO;
53pub const W = linux.W;
54pub const W_OK = linux.W_OK;
55pub const X_OK = linux.X_OK;
56pub const addrinfo = linux.addrinfo;
43pub const blkcnt_t = linux.blkcnt_t;57pub const blkcnt_t = linux.blkcnt_t;
44pub const blksize_t = linux.blksize_t;58pub const blksize_t = linux.blksize_t;
59pub const clock_t = linux.clock_t;
60pub const cpu_set_t = linux.cpu_set_t;
45pub const dev_t = linux.dev_t;61pub const dev_t = linux.dev_t;
62pub const dl_phdr_info = linux.dl_phdr_info;
63pub const empty_sigset = linux.empty_sigset;
64pub const epoll_event = linux.epoll_event;
65pub const fd_t = linux.fd_t;
66pub const gid_t = linux.gid_t;
67pub const ifreq = linux.ifreq;
46pub const ino_t = linux.ino_t;68pub const ino_t = linux.ino_t;
47pub const mcontext_t = linux.mcontext_t;69pub const mcontext_t = linux.mcontext_t;
48pub const mode_t = linux.mode_t;70pub const mode_t = linux.mode_t;
49pub const msghdr = linux.msghdr;71pub const msghdr = linux.msghdr;
50pub const msghdr_const = linux.msghdr_const;72pub const msghdr_const = linux.msghdr_const;
73pub const nfds_t = linux.nfds_t;
51pub const nlink_t = linux.nlink_t;74pub const nlink_t = linux.nlink_t;
52pub const off_t = linux.off_t;75pub const off_t = linux.off_t;
76pub const pid_t = linux.pid_t;
77pub const pollfd = linux.pollfd;
78pub const rlim_t = linux.rlim_t;
79pub const rlimit = linux.rlimit;
80pub const rlimit_resource = linux.rlimit_resource;
81pub const siginfo_t = linux.siginfo_t;
82pub const sigset_t = linux.sigset_t;
83pub const sockaddr = linux.sockaddr;
84pub const socklen_t = linux.socklen_t;
85pub const stack_t = linux.stack_t;
53pub const time_t = linux.time_t;86pub const time_t = linux.time_t;
87pub const timespec = linux.timespec;
54pub const timeval = linux.timeval;88pub const timeval = linux.timeval;
55pub const timezone = linux.timezone;89pub const timezone = linux.timezone;
56pub const ucontext_t = linux.ucontext_t;90pub const ucontext_t = linux.ucontext_t;
57pub const user_desc = linux.user_desc;
58pub const pid_t = linux.pid_t;
59pub const uid_t = linux.uid_t;91pub const uid_t = linux.uid_t;
60pub const gid_t = linux.gid_t;92pub const user_desc = linux.user_desc;
61pub const clock_t = linux.clock_t;93pub const utsname = linux.utsname;
6294
63pub const _errno = switch (native_abi) {95pub const _errno = switch (native_abi) {
64 .android => struct {96 .android => struct {
...@@ -140,8 +172,6 @@ pub const Stat = switch (native_arch) {...@@ -140,8 +172,6 @@ pub const Stat = switch (native_arch) {
140 else => std.os.linux.Stat, // libc stat is the same as kernel stat.172 else => std.os.linux.Stat, // libc stat is the same as kernel stat.
141};173};
142174
143pub const MAP_FAILED = @intToPtr(*c_void, maxInt(usize));
144
145pub const AI = struct {175pub const AI = struct {
146 pub const PASSIVE = 0x01;176 pub const PASSIVE = 0x01;
147 pub const CANONNAME = 0x02;177 pub const CANONNAME = 0x02;
lib/std/c/netbsd.zig+306-324
...@@ -135,16 +135,18 @@ pub const Kevent = extern struct {...@@ -135,16 +135,18 @@ pub const Kevent = extern struct {
135 udata: usize,135 udata: usize,
136};136};
137137
138pub const RTLD_LAZY = 1;138pub const RTLD = struct {
139pub const RTLD_NOW = 2;139 pub const LAZY = 1;
140pub const RTLD_GLOBAL = 0x100;140 pub const NOW = 2;
141pub const RTLD_LOCAL = 0x200;141 pub const GLOBAL = 0x100;
142pub const RTLD_NODELETE = 0x01000;142 pub const LOCAL = 0x200;
143pub const RTLD_NOLOAD = 0x02000;143 pub const NODELETE = 0x01000;
144144 pub const NOLOAD = 0x02000;
145pub const RTLD_NEXT = @intToPtr(*c_void, @bitCast(usize, @as(isize, -1)));145
146pub const RTLD_DEFAULT = @intToPtr(*c_void, @bitCast(usize, @as(isize, -2)));146 pub const NEXT = @intToPtr(*c_void, @bitCast(usize, @as(isize, -1)));
147pub const RTLD_SELF = @intToPtr(*c_void, @bitCast(usize, @as(isize, -3)));147 pub const DEFAULT = @intToPtr(*c_void, @bitCast(usize, @as(isize, -2)));
148 pub const SELF = @intToPtr(*c_void, @bitCast(usize, @as(isize, -3)));
149};
148150
149pub const dl_phdr_info = extern struct {151pub const dl_phdr_info = extern struct {
150 dlpi_addr: usize,152 dlpi_addr: usize,
...@@ -325,120 +327,130 @@ pub const dirent = extern struct {...@@ -325,120 +327,130 @@ pub const dirent = extern struct {
325 }327 }
326};328};
327329
328pub const SOCK_STREAM = 1;330pub const SOCK = struct {
329pub const SOCK_DGRAM = 2;331 pub const STREAM = 1;
330pub const SOCK_RAW = 3;332 pub const DGRAM = 2;
331pub const SOCK_RDM = 4;333 pub const RAW = 3;
332pub const SOCK_SEQPACKET = 5;334 pub const RDM = 4;
333pub const SOCK_CONN_DGRAM = 6;335 pub const SEQPACKET = 5;
334pub const SOCK_DCCP = SOCK_CONN_DGRAM;336 pub const CONN_DGRAM = 6;
335337 pub const DCCP = CONN_DGRAM;
336pub const SOCK_CLOEXEC = 0x10000000;338
337pub const SOCK_NONBLOCK = 0x20000000;339 pub const CLOEXEC = 0x10000000;
338pub const SOCK_NOSIGPIPE = 0x40000000;340 pub const NONBLOCK = 0x20000000;
339pub const SOCK_FLAGS_MASK = 0xf0000000;341 pub const NOSIGPIPE = 0x40000000;
340342 pub const FLAGS_MASK = 0xf0000000;
341pub const SO_DEBUG = 0x0001;343};
342pub const SO_ACCEPTCONN = 0x0002;344
343pub const SO_REUSEADDR = 0x0004;345pub const SO = struct {
344pub const SO_KEEPALIVE = 0x0008;346 pub const DEBUG = 0x0001;
345pub const SO_DONTROUTE = 0x0010;347 pub const ACCEPTCONN = 0x0002;
346pub const SO_BROADCAST = 0x0020;348 pub const REUSEADDR = 0x0004;
347pub const SO_USELOOPBACK = 0x0040;349 pub const KEEPALIVE = 0x0008;
348pub const SO_LINGER = 0x0080;350 pub const DONTROUTE = 0x0010;
349pub const SO_OOBINLINE = 0x0100;351 pub const BROADCAST = 0x0020;
350pub const SO_REUSEPORT = 0x0200;352 pub const USELOOPBACK = 0x0040;
351pub const SO_NOSIGPIPE = 0x0800;353 pub const LINGER = 0x0080;
352pub const SO_ACCEPTFILTER = 0x1000;354 pub const OOBINLINE = 0x0100;
353pub const SO_TIMESTAMP = 0x2000;355 pub const REUSEPORT = 0x0200;
354pub const SO_RERROR = 0x4000;356 pub const NOSIGPIPE = 0x0800;
355357 pub const ACCEPTFILTER = 0x1000;
356pub const SO_SNDBUF = 0x1001;358 pub const TIMESTAMP = 0x2000;
357pub const SO_RCVBUF = 0x1002;359 pub const RERROR = 0x4000;
358pub const SO_SNDLOWAT = 0x1003;360
359pub const SO_RCVLOWAT = 0x1004;361 pub const SNDBUF = 0x1001;
360pub const SO_ERROR = 0x1007;362 pub const RCVBUF = 0x1002;
361pub const SO_TYPE = 0x1008;363 pub const SNDLOWAT = 0x1003;
362pub const SO_OVERFLOWED = 0x1009;364 pub const RCVLOWAT = 0x1004;
363365 pub const ERROR = 0x1007;
364pub const SO_NOHEADER = 0x100a;366 pub const TYPE = 0x1008;
365pub const SO_SNDTIMEO = 0x100b;367 pub const OVERFLOWED = 0x1009;
366pub const SO_RCVTIMEO = 0x100c;368
367369 pub const NOHEADER = 0x100a;
368pub const SOL_SOCKET = 0xffff;370 pub const SNDTIMEO = 0x100b;
369371 pub const RCVTIMEO = 0x100c;
370pub const PF_UNSPEC = AF_UNSPEC;372};
371pub const PF_LOCAL = AF_LOCAL;373
372pub const PF_UNIX = PF_LOCAL;374pub const SOL = struct {
373pub const PF_INET = AF_INET;375 pub const SOCKET = 0xffff;
374pub const PF_IMPLINK = AF_IMPLINK;376};
375pub const PF_PUP = AF_PUP;377
376pub const PF_CHAOS = AF_CHAOS;378pub const PF = struct {
377pub const PF_NS = AF_NS;379 pub const UNSPEC = AF.UNSPEC;
378pub const PF_ISO = AF_ISO;380 pub const LOCAL = AF.LOCAL;
379pub const PF_OSI = AF_ISO;381 pub const UNIX = PF.LOCAL;
380pub const PF_ECMA = AF_ECMA;382 pub const INET = AF.INET;
381pub const PF_DATAKIT = AF_DATAKIT;383 pub const IMPLINK = AF.IMPLINK;
382pub const PF_CCITT = AF_CCITT;384 pub const PUP = AF.PUP;
383pub const PF_SNA = AF_SNA;385 pub const CHAOS = AF.CHAOS;
384pub const PF_DECnet = AF_DECnet;386 pub const NS = AF.NS;
385pub const PF_DLI = AF_DLI;387 pub const ISO = AF.ISO;
386pub const PF_LAT = AF_LAT;388 pub const OSI = AF.ISO;
387pub const PF_HYLINK = AF_HYLINK;389 pub const ECMA = AF.ECMA;
388pub const PF_APPLETALK = AF_APPLETALK;390 pub const DATAKIT = AF.DATAKIT;
389pub const PF_OROUTE = AF_OROUTE;391 pub const CCITT = AF.CCITT;
390pub const PF_LINK = AF_LINK;392 pub const SNA = AF.SNA;
391pub const PF_COIP = AF_COIP;393 pub const DECnet = AF.DECnet;
392pub const PF_CNT = AF_CNT;394 pub const DLI = AF.DLI;
393pub const PF_INET6 = AF_INET6;395 pub const LAT = AF.LAT;
394pub const PF_IPX = AF_IPX;396 pub const HYLINK = AF.HYLINK;
395pub const PF_ISDN = AF_ISDN;397 pub const APPLETALK = AF.APPLETALK;
396pub const PF_E164 = AF_E164;398 pub const OROUTE = AF.OROUTE;
397pub const PF_NATM = AF_NATM;399 pub const LINK = AF.LINK;
398pub const PF_ARP = AF_ARP;400 pub const COIP = AF.COIP;
399pub const PF_BLUETOOTH = AF_BLUETOOTH;401 pub const CNT = AF.CNT;
400pub const PF_MPLS = AF_MPLS;402 pub const INET6 = AF.INET6;
401pub const PF_ROUTE = AF_ROUTE;403 pub const IPX = AF.IPX;
402pub const PF_CAN = AF_CAN;404 pub const ISDN = AF.ISDN;
403pub const PF_ETHER = AF_ETHER;405 pub const E164 = AF.E164;
404pub const PF_MAX = AF_MAX;406 pub const NATM = AF.NATM;
405407 pub const ARP = AF.ARP;
406pub const AF_UNSPEC = 0;408 pub const BLUETOOTH = AF.BLUETOOTH;
407pub const AF_LOCAL = 1;409 pub const MPLS = AF.MPLS;
408pub const AF_UNIX = AF_LOCAL;410 pub const ROUTE = AF.ROUTE;
409pub const AF_INET = 2;411 pub const CAN = AF.CAN;
410pub const AF_IMPLINK = 3;412 pub const ETHER = AF.ETHER;
411pub const AF_PUP = 4;413 pub const MAX = AF.MAX;
412pub const AF_CHAOS = 5;414};
413pub const AF_NS = 6;415
414pub const AF_ISO = 7;416pub const AF = struct {
415pub const AF_OSI = AF_ISO;417 pub const UNSPEC = 0;
416pub const AF_ECMA = 8;418 pub const LOCAL = 1;
417pub const AF_DATAKIT = 9;419 pub const UNIX = LOCAL;
418pub const AF_CCITT = 10;420 pub const INET = 2;
419pub const AF_SNA = 11;421 pub const IMPLINK = 3;
420pub const AF_DECnet = 12;422 pub const PUP = 4;
421pub const AF_DLI = 13;423 pub const CHAOS = 5;
422pub const AF_LAT = 14;424 pub const NS = 6;
423pub const AF_HYLINK = 15;425 pub const ISO = 7;
424pub const AF_APPLETALK = 16;426 pub const OSI = ISO;
425pub const AF_OROUTE = 17;427 pub const ECMA = 8;
426pub const AF_LINK = 18;428 pub const DATAKIT = 9;
427pub const AF_COIP = 20;429 pub const CCITT = 10;
428pub const AF_CNT = 21;430 pub const SNA = 11;
429pub const AF_IPX = 23;431 pub const DECnet = 12;
430pub const AF_INET6 = 24;432 pub const DLI = 13;
431pub const AF_ISDN = 26;433 pub const LAT = 14;
432pub const AF_E164 = AF_ISDN;434 pub const HYLINK = 15;
433pub const AF_NATM = 27;435 pub const APPLETALK = 16;
434pub const AF_ARP = 28;436 pub const OROUTE = 17;
435pub const AF_BLUETOOTH = 31;437 pub const LINK = 18;
436pub const AF_IEEE80211 = 32;438 pub const COIP = 20;
437pub const AF_MPLS = 33;439 pub const CNT = 21;
438pub const AF_ROUTE = 34;440 pub const IPX = 23;
439pub const AF_CAN = 35;441 pub const INET6 = 24;
440pub const AF_ETHER = 36;442 pub const ISDN = 26;
441pub const AF_MAX = 37;443 pub const E164 = ISDN;
444 pub const NATM = 27;
445 pub const ARP = 28;
446 pub const BLUETOOTH = 31;
447 pub const IEEE80211 = 32;
448 pub const MPLS = 33;
449 pub const ROUTE = 34;
450 pub const CAN = 35;
451 pub const ETHER = 36;
452 pub const MAX = 37;
453};
442454
443pub const in_port_t = u16;455pub const in_port_t = u16;
444pub const sa_family_t = u8;456pub const sa_family_t = u8;
...@@ -446,60 +458,55 @@ pub const sa_family_t = u8;...@@ -446,60 +458,55 @@ pub const sa_family_t = u8;
446pub const sockaddr = extern struct {458pub const sockaddr = extern struct {
447 /// total length459 /// total length
448 len: u8,460 len: u8,
449
450 /// address family461 /// address family
451 family: sa_family_t,462 family: sa_family_t,
452
453 /// actually longer; address value463 /// actually longer; address value
454 data: [14]u8,464 data: [14]u8,
455};
456
457pub const sockaddr_storage = std.x.os.Socket.Address.Native.Storage;
458465
459pub const sockaddr_in = extern struct {466 pub const storage = std.x.os.Socket.Address.Native.Storage;
460 len: u8 = @sizeOf(sockaddr_in),467
461 family: sa_family_t = AF_INET,468 pub const in = extern struct {
462 port: in_port_t,469 len: u8 = @sizeOf(in),
463 addr: u32,470 family: sa_family_t = AF.INET,
464 zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },471 port: in_port_t,
472 addr: u32,
473 zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },
474 };
475
476 pub const in6 = extern struct {
477 len: u8 = @sizeOf(in6),
478 family: sa_family_t = AF.INET6,
479 port: in_port_t,
480 flowinfo: u32,
481 addr: [16]u8,
482 scope_id: u32,
483 };
484
485 /// Definitions for UNIX IPC domain.
486 pub const un = extern struct {
487 /// total sockaddr length
488 len: u8 = @sizeOf(un),
489
490 family: sa_family_t = AF.LOCAL,
491
492 /// path name
493 path: [104]u8,
494 };
465};495};
466496
467pub const sockaddr_in6 = extern struct {497pub const AI = struct {
468 len: u8 = @sizeOf(sockaddr_in6),498 /// get address to use bind()
469 family: sa_family_t = AF_INET6,499 pub const PASSIVE = 0x00000001;
470 port: in_port_t,500 /// fill ai_canonname
471 flowinfo: u32,501 pub const CANONNAME = 0x00000002;
472 addr: [16]u8,502 /// prevent host name resolution
473 scope_id: u32,503 pub const NUMERICHOST = 0x00000004;
504 /// prevent service name resolution
505 pub const NUMERICSERV = 0x00000008;
506 /// only if any address is assigned
507 pub const ADDRCONFIG = 0x00000400;
474};508};
475509
476/// Definitions for UNIX IPC domain.
477pub const sockaddr_un = extern struct {
478 /// total sockaddr length
479 len: u8 = @sizeOf(sockaddr_un),
480
481 /// AF_LOCAL
482 family: sa_family_t = AF_LOCAL,
483
484 /// path name
485 path: [104]u8,
486};
487
488/// get address to use bind()
489pub const AI_PASSIVE = 0x00000001;
490
491/// fill ai_canonname
492pub const AI_CANONNAME = 0x00000002;
493
494/// prevent host name resolution
495pub const AI_NUMERICHOST = 0x00000004;
496
497/// prevent service name resolution
498pub const AI_NUMERICSERV = 0x00000008;
499
500/// only if any address is assigned
501pub const AI_ADDRCONFIG = 0x00000400;
502
503pub const CTL_KERN = 1;510pub const CTL_KERN = 1;
504pub const CTL_DEBUG = 5;511pub const CTL_DEBUG = 5;
505512
...@@ -519,31 +526,34 @@ pub const PROT_READ = 1;...@@ -519,31 +526,34 @@ pub const PROT_READ = 1;
519pub const PROT_WRITE = 2;526pub const PROT_WRITE = 2;
520pub const PROT_EXEC = 4;527pub const PROT_EXEC = 4;
521528
522pub const CLOCK_REALTIME = 0;529pub const CLOCK = struct {
523pub const CLOCK_VIRTUAL = 1;530 pub const REALTIME = 0;
524pub const CLOCK_PROF = 2;531 pub const VIRTUAL = 1;
525pub const CLOCK_MONOTONIC = 3;532 pub const PROF = 2;
526pub const CLOCK_THREAD_CPUTIME_ID = 0x20000000;533 pub const MONOTONIC = 3;
527pub const CLOCK_PROCESS_CPUTIME_ID = 0x40000000;534 pub const THREAD_CPUTIME_ID = 0x20000000;
528535 pub const PROCESS_CPUTIME_ID = 0x40000000;
529pub const MAP_FAILED = @intToPtr(*c_void, maxInt(usize));536};
530pub const MAP_SHARED = 0x0001;
531pub const MAP_PRIVATE = 0x0002;
532pub const MAP_REMAPDUP = 0x0004;
533pub const MAP_FIXED = 0x0010;
534pub const MAP_RENAME = 0x0020;
535pub const MAP_NORESERVE = 0x0040;
536pub const MAP_INHERIT = 0x0080;
537pub const MAP_HASSEMAPHORE = 0x0200;
538pub const MAP_TRYFIXED = 0x0400;
539pub const MAP_WIRED = 0x0800;
540
541pub const MAP_FILE = 0x0000;
542pub const MAP_NOSYNC = 0x0800;
543pub const MAP_ANON = 0x1000;
544pub const MAP_ANONYMOUS = MAP_ANON;
545pub const MAP_STACK = 0x2000;
546537
538pub const MAP = struct {
539 pub const FAILED = @intToPtr(*c_void, maxInt(usize));
540 pub const SHARED = 0x0001;
541 pub const PRIVATE = 0x0002;
542 pub const REMAPDUP = 0x0004;
543 pub const FIXED = 0x0010;
544 pub const RENAME = 0x0020;
545 pub const NORESERVE = 0x0040;
546 pub const INHERIT = 0x0080;
547 pub const HASSEMAPHORE = 0x0200;
548 pub const TRYFIXED = 0x0400;
549 pub const WIRED = 0x0800;
550
551 pub const FILE = 0x0000;
552 pub const NOSYNC = 0x0800;
553 pub const ANON = 0x1000;
554 pub const ANONYMOUS = ANON;
555 pub const STACK = 0x2000;
556};
547pub const WNOHANG = 0x00000001;557pub const WNOHANG = 0x00000001;
548pub const WUNTRACED = 0x00000002;558pub const WUNTRACED = 0x00000002;
549pub const WSTOPPED = WUNTRACED;559pub const WSTOPPED = WUNTRACED;
...@@ -686,10 +696,12 @@ pub const F_RDLCK = 1;...@@ -686,10 +696,12 @@ pub const F_RDLCK = 1;
686pub const F_WRLCK = 3;696pub const F_WRLCK = 3;
687pub const F_UNLCK = 2;697pub const F_UNLCK = 2;
688698
689pub const LOCK_SH = 1;699pub const LOCK = struct {
690pub const LOCK_EX = 2;700 pub const SH = 1;
691pub const LOCK_UN = 8;701 pub const EX = 2;
692pub const LOCK_NB = 4;702 pub const UN = 8;
703 pub const NB = 4;
704};
693705
694pub const FD_CLOEXEC = 1;706pub const FD_CLOEXEC = 1;
695707
...@@ -1262,116 +1274,82 @@ pub const AT_REMOVEDIR = 0x0800;...@@ -1262,116 +1274,82 @@ pub const AT_REMOVEDIR = 0x0800;
12621274
1263pub const HOST_NAME_MAX = 255;1275pub const HOST_NAME_MAX = 255;
12641276
1265/// dummy for IP1277pub const IPPROTO = struct {
1266pub const IPPROTO_IP = 0;1278 /// dummy for IP
12671279 pub const IP = 0;
1268/// IP6 hop-by-hop options1280 /// IP6 hop-by-hop options
1269pub const IPPROTO_HOPOPTS = 0;1281 pub const HOPOPTS = 0;
12701282 /// control message protocol
1271/// control message protocol1283 pub const ICMP = 1;
1272pub const IPPROTO_ICMP = 1;1284 /// group mgmt protocol
12731285 pub const IGMP = 2;
1274/// group mgmt protocol1286 /// gateway^2 (deprecated)
1275pub const IPPROTO_IGMP = 2;1287 pub const GGP = 3;
12761288 /// IP header
1277/// gateway^2 (deprecated)1289 pub const IPV4 = 4;
1278pub const IPPROTO_GGP = 3;1290 /// IP inside IP
12791291 pub const IPIP = 4;
1280/// IP header1292 /// tcp
1281pub const IPPROTO_IPV4 = 4;1293 pub const TCP = 6;
12821294 /// exterior gateway protocol
1283/// IP inside IP1295 pub const EGP = 8;
1284pub const IPPROTO_IPIP = 4;1296 /// pup
12851297 pub const PUP = 12;
1286/// tcp1298 /// user datagram protocol
1287pub const IPPROTO_TCP = 6;1299 pub const UDP = 17;
12881300 /// xns idp
1289/// exterior gateway protocol1301 pub const IDP = 22;
1290pub const IPPROTO_EGP = 8;1302 /// tp-4 w/ class negotiation
12911303 pub const TP = 29;
1292/// pup1304 /// DCCP
1293pub const IPPROTO_PUP = 12;1305 pub const DCCP = 33;
12941306 /// IP6 header
1295/// user datagram protocol1307 pub const IPV6 = 41;
1296pub const IPPROTO_UDP = 17;1308 /// IP6 routing header
12971309 pub const ROUTING = 43;
1298/// xns idp1310 /// IP6 fragmentation header
1299pub const IPPROTO_IDP = 22;1311 pub const FRAGMENT = 44;
13001312 /// resource reservation
1301/// tp-4 w/ class negotiation1313 pub const RSVP = 46;
1302pub const IPPROTO_TP = 29;1314 /// GRE encaps RFC 1701
13031315 pub const GRE = 47;
1304/// DCCP1316 /// encap. security payload
1305pub const IPPROTO_DCCP = 33;1317 pub const ESP = 50;
13061318 /// authentication header
1307/// IP6 header1319 pub const AH = 51;
1308pub const IPPROTO_IPV6 = 41;1320 /// IP Mobility RFC 2004
13091321 pub const MOBILE = 55;
1310/// IP6 routing header1322 /// IPv6 ICMP
1311pub const IPPROTO_ROUTING = 43;1323 pub const IPV6_ICMP = 58;
13121324 /// ICMP6
1313/// IP6 fragmentation header1325 pub const ICMPV6 = 58;
1314pub const IPPROTO_FRAGMENT = 44;1326 /// IP6 no next header
13151327 pub const NONE = 59;
1316/// resource reservation1328 /// IP6 destination option
1317pub const IPPROTO_RSVP = 46;1329 pub const DSTOPTS = 60;
13181330 /// ISO cnlp
1319/// GRE encaps RFC 17011331 pub const EON = 80;
1320pub const IPPROTO_GRE = 47;1332 /// Ethernet-in-IP
13211333 pub const ETHERIP = 97;
1322/// encap. security payload1334 /// encapsulation header
1323pub const IPPROTO_ESP = 50;1335 pub const ENCAP = 98;
13241336 /// Protocol indep. multicast
1325/// authentication header1337 pub const PIM = 103;
1326pub const IPPROTO_AH = 51;1338 /// IP Payload Comp. Protocol
13271339 pub const IPCOMP = 108;
1328/// IP Mobility RFC 20041340 /// VRRP RFC 2338
1329pub const IPPROTO_MOBILE = 55;1341 pub const VRRP = 112;
13301342 /// Common Address Resolution Protocol
1331/// IPv6 ICMP1343 pub const CARP = 112;
1332pub const IPPROTO_IPV6_ICMP = 58;1344 /// L2TPv3
13331345 pub const L2TP = 115;
1334/// ICMP61346 /// SCTP
1335pub const IPPROTO_ICMPV6 = 58;1347 pub const SCTP = 132;
13361348 /// PFSYNC
1337/// IP6 no next header1349 pub const PFSYNC = 240;
1338pub const IPPROTO_NONE = 59;1350 /// raw IP packet
13391351 pub const RAW = 255;
1340/// IP6 destination option1352};
1341pub const IPPROTO_DSTOPTS = 60;
1342
1343/// ISO cnlp
1344pub const IPPROTO_EON = 80;
1345
1346/// Ethernet-in-IP
1347pub const IPPROTO_ETHERIP = 97;
1348
1349/// encapsulation header
1350pub const IPPROTO_ENCAP = 98;
1351
1352/// Protocol indep. multicast
1353pub const IPPROTO_PIM = 103;
1354
1355/// IP Payload Comp. Protocol
1356pub const IPPROTO_IPCOMP = 108;
1357
1358/// VRRP RFC 2338
1359pub const IPPROTO_VRRP = 112;
1360
1361/// Common Address Resolution Protocol
1362pub const IPPROTO_CARP = 112;
1363
1364/// L2TPv3
1365pub const IPPROTO_L2TP = 115;
1366
1367/// SCTP
1368pub const IPPROTO_SCTP = 132;
1369
1370/// PFSYNC
1371pub const IPPROTO_PFSYNC = 240;
1372
1373/// raw IP packet
1374pub const IPPROTO_RAW = 255;
13751353
1376pub const rlimit_resource = enum(c_int) {1354pub const rlimit_resource = enum(c_int) {
1377 CPU = 0,1355 CPU = 0,
...@@ -1393,11 +1371,13 @@ pub const rlimit_resource = enum(c_int) {...@@ -1393,11 +1371,13 @@ pub const rlimit_resource = enum(c_int) {
13931371
1394pub const rlim_t = u64;1372pub const rlim_t = u64;
13951373
1396/// No limit1374pub const RLIM = struct {
1397pub const RLIM_INFINITY: rlim_t = (1 << 63) - 1;1375 /// No limit
1376 pub const INFINITY: rlim_t = (1 << 63) - 1;
13981377
1399pub const RLIM_SAVED_MAX = RLIM_INFINITY;1378 pub const SAVED_MAX = INFINITY;
1400pub const RLIM_SAVED_CUR = RLIM_INFINITY;1379 pub const SAVED_CUR = INFINITY;
1380};
14011381
1402pub const rlimit = extern struct {1382pub const rlimit = extern struct {
1403 /// Soft limit1383 /// Soft limit
...@@ -1418,16 +1398,18 @@ pub const pollfd = extern struct {...@@ -1418,16 +1398,18 @@ pub const pollfd = extern struct {
1418 revents: i16,1398 revents: i16,
1419};1399};
14201400
1421/// Testable events (may be specified in events field).1401pub const POLL = struct {
1422pub const POLLIN = 0x0001;1402 /// Testable events (may be specified in events field).
1423pub const POLLPRI = 0x0002;1403 pub const IN = 0x0001;
1424pub const POLLOUT = 0x0004;1404 pub const PRI = 0x0002;
1425pub const POLLRDNORM = 0x0040;1405 pub const OUT = 0x0004;
1426pub const POLLWRNORM = POLLOUT;1406 pub const RDNORM = 0x0040;
1427pub const POLLRDBAND = 0x0080;1407 pub const WRNORM = OUT;
1428pub const POLLWRBAND = 0x0100;1408 pub const RDBAND = 0x0080;
14291409 pub const WRBAND = 0x0100;
1430/// Non-testable events (may not be specified in events field).1410
1431pub const POLLERR = 0x0008;1411 /// Non-testable events (may not be specified in events field).
1432pub const POLLHUP = 0x0010;1412 pub const ERR = 0x0008;
1433pub const POLLNVAL = 0x0020;1413 pub const HUP = 0x0010;
1414 pub const NVAL = 0x0020;
1415};
lib/std/c/openbsd.zig+247-266
...@@ -71,20 +71,18 @@ pub const Kevent = extern struct {...@@ -71,20 +71,18 @@ pub const Kevent = extern struct {
71// Modes and flags for dlopen()71// Modes and flags for dlopen()
72// include/dlfcn.h72// include/dlfcn.h
7373
74/// Bind function calls lazily.74pub const RTLD = struct {
75pub const RTLD_LAZY = 1;75 /// Bind function calls lazily.
7676 pub const LAZY = 1;
77/// Bind function calls immediately.77 /// Bind function calls immediately.
78pub const RTLD_NOW = 2;78 pub const NOW = 2;
7979 /// Make symbols globally available.
80/// Make symbols globally available.80 pub const GLOBAL = 0x100;
81pub const RTLD_GLOBAL = 0x100;81 /// Opposite of GLOBAL, and the default.
8282 pub const LOCAL = 0x000;
83/// Opposite of RTLD_GLOBAL, and the default.83 /// Trace loaded objects and exit.
84pub const RTLD_LOCAL = 0x000;84 pub const TRACE = 0x200;
8585};
86/// Trace loaded objects and exit.
87pub const RTLD_TRACE = 0x200;
8886
89pub const dl_phdr_info = extern struct {87pub const dl_phdr_info = extern struct {
90 dlpi_addr: std.elf.Addr,88 dlpi_addr: std.elf.Addr,
...@@ -274,60 +272,55 @@ pub const sa_family_t = u8;...@@ -274,60 +272,55 @@ pub const sa_family_t = u8;
274pub const sockaddr = extern struct {272pub const sockaddr = extern struct {
275 /// total length273 /// total length
276 len: u8,274 len: u8,
277
278 /// address family275 /// address family
279 family: sa_family_t,276 family: sa_family_t,
280
281 /// actually longer; address value277 /// actually longer; address value
282 data: [14]u8,278 data: [14]u8,
283};
284
285pub const sockaddr_storage = std.x.os.Socket.Address.Native.Storage;
286279
287pub const sockaddr_in = extern struct {280 pub const storage = std.x.os.Socket.Address.Native.Storage;
288 len: u8 = @sizeOf(sockaddr_in),281
289 family: sa_family_t = AF_INET,282 pub const in = extern struct {
290 port: in_port_t,283 len: u8 = @sizeOf(in),
291 addr: u32,284 family: sa_family_t = AF.INET,
292 zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },285 port: in_port_t,
286 addr: u32,
287 zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },
288 };
289
290 pub const in6 = extern struct {
291 len: u8 = @sizeOf(in6),
292 family: sa_family_t = AF.INET6,
293 port: in_port_t,
294 flowinfo: u32,
295 addr: [16]u8,
296 scope_id: u32,
297 };
298
299 /// Definitions for UNIX IPC domain.
300 pub const un = extern struct {
301 /// total sockaddr length
302 len: u8 = @sizeOf(un),
303
304 family: sa_family_t = AF.LOCAL,
305
306 /// path name
307 path: [104]u8,
308 };
293};309};
294310
295pub const sockaddr_in6 = extern struct {311pub const AI = struct {
296 len: u8 = @sizeOf(sockaddr_in6),312 /// get address to use bind()
297 family: sa_family_t = AF_INET6,313 pub const PASSIVE = 1;
298 port: in_port_t,314 /// fill ai_canonname
299 flowinfo: u32,315 pub const CANONNAME = 2;
300 addr: [16]u8,316 /// prevent host name resolution
301 scope_id: u32,317 pub const NUMERICHOST = 4;
318 /// prevent service name resolution
319 pub const NUMERICSERV = 16;
320 /// only if any address is assigned
321 pub const ADDRCONFIG = 64;
302};322};
303323
304/// Definitions for UNIX IPC domain.
305pub const sockaddr_un = extern struct {
306 /// total sockaddr length
307 len: u8 = @sizeOf(sockaddr_un),
308
309 /// AF_LOCAL
310 family: sa_family_t = AF_LOCAL,
311
312 /// path name
313 path: [104]u8,
314};
315
316/// get address to use bind()
317pub const AI_PASSIVE = 1;
318
319/// fill ai_canonname
320pub const AI_CANONNAME = 2;
321
322/// prevent host name resolution
323pub const AI_NUMERICHOST = 4;
324
325/// prevent service name resolution
326pub const AI_NUMERICSERV = 16;
327
328/// only if any address is assigned
329pub const AI_ADDRCONFIG = 64;
330
331pub const PATH_MAX = 1024;324pub const PATH_MAX = 1024;
332pub const IOV_MAX = 1024;325pub const IOV_MAX = 1024;
333326
...@@ -340,27 +333,30 @@ pub const PROT_READ = 1;...@@ -340,27 +333,30 @@ pub const PROT_READ = 1;
340pub const PROT_WRITE = 2;333pub const PROT_WRITE = 2;
341pub const PROT_EXEC = 4;334pub const PROT_EXEC = 4;
342335
343pub const CLOCK_REALTIME = 0;336pub const CLOCK = struct {
344pub const CLOCK_PROCESS_CPUTIME_ID = 2;337 pub const REALTIME = 0;
345pub const CLOCK_MONOTONIC = 3;338 pub const PROCESS_CPUTIME_ID = 2;
346pub const CLOCK_THREAD_CPUTIME_ID = 4;339 pub const MONOTONIC = 3;
347340 pub const THREAD_CPUTIME_ID = 4;
348pub const MAP_FAILED = @intToPtr(*c_void, maxInt(usize));341};
349pub const MAP_SHARED = 0x0001;
350pub const MAP_PRIVATE = 0x0002;
351pub const MAP_FIXED = 0x0010;
352pub const MAP_RENAME = 0;
353pub const MAP_NORESERVE = 0;
354pub const MAP_INHERIT = 0;
355pub const MAP_HASSEMAPHORE = 0;
356pub const MAP_TRYFIXED = 0;
357
358pub const MAP_FILE = 0;
359pub const MAP_ANON = 0x1000;
360pub const MAP_ANONYMOUS = MAP_ANON;
361pub const MAP_STACK = 0x4000;
362pub const MAP_CONCEAL = 0x8000;
363342
343pub const MAP = struct {
344 pub const FAILED = @intToPtr(*c_void, maxInt(usize));
345 pub const SHARED = 0x0001;
346 pub const PRIVATE = 0x0002;
347 pub const FIXED = 0x0010;
348 pub const RENAME = 0;
349 pub const NORESERVE = 0;
350 pub const INHERIT = 0;
351 pub const HASSEMAPHORE = 0;
352 pub const TRYFIXED = 0;
353
354 pub const FILE = 0;
355 pub const ANON = 0x1000;
356 pub const ANONYMOUS = ANON;
357 pub const STACK = 0x4000;
358 pub const CONCEAL = 0x8000;
359};
364pub const WNOHANG = 1;360pub const WNOHANG = 1;
365pub const WUNTRACED = 2;361pub const WUNTRACED = 2;
366pub const WCONTINUED = 8;362pub const WCONTINUED = 8;
...@@ -487,10 +483,12 @@ pub const F_RDLCK = 1;...@@ -487,10 +483,12 @@ pub const F_RDLCK = 1;
487pub const F_UNLCK = 2;483pub const F_UNLCK = 2;
488pub const F_WRLCK = 3;484pub const F_WRLCK = 3;
489485
490pub const LOCK_SH = 0x01;486pub const LOCK = struct {
491pub const LOCK_EX = 0x02;487 pub const SH = 0x01;
492pub const LOCK_NB = 0x04;488 pub const EX = 0x02;
493pub const LOCK_UN = 0x08;489 pub const NB = 0x04;
490 pub const UN = 0x08;
491};
494492
495pub const FD_CLOEXEC = 1;493pub const FD_CLOEXEC = 1;
496494
...@@ -502,73 +500,83 @@ pub const SIG_BLOCK = 1;...@@ -502,73 +500,83 @@ pub const SIG_BLOCK = 1;
502pub const SIG_UNBLOCK = 2;500pub const SIG_UNBLOCK = 2;
503pub const SIG_SETMASK = 3;501pub const SIG_SETMASK = 3;
504502
505pub const SOCK_STREAM = 1;503pub const SOCK = struct {
506pub const SOCK_DGRAM = 2;504 pub const STREAM = 1;
507pub const SOCK_RAW = 3;505 pub const DGRAM = 2;
508pub const SOCK_RDM = 4;506 pub const RAW = 3;
509pub const SOCK_SEQPACKET = 5;507 pub const RDM = 4;
510508 pub const SEQPACKET = 5;
511pub const SOCK_CLOEXEC = 0x8000;509
512pub const SOCK_NONBLOCK = 0x4000;510 pub const CLOEXEC = 0x8000;
513511 pub const NONBLOCK = 0x4000;
514pub const SO_DEBUG = 0x0001;512};
515pub const SO_ACCEPTCONN = 0x0002;513
516pub const SO_REUSEADDR = 0x0004;514pub const SO = struct {
517pub const SO_KEEPALIVE = 0x0008;515 pub const DEBUG = 0x0001;
518pub const SO_DONTROUTE = 0x0010;516 pub const ACCEPTCONN = 0x0002;
519pub const SO_BROADCAST = 0x0020;517 pub const REUSEADDR = 0x0004;
520pub const SO_USELOOPBACK = 0x0040;518 pub const KEEPALIVE = 0x0008;
521pub const SO_LINGER = 0x0080;519 pub const DONTROUTE = 0x0010;
522pub const SO_OOBINLINE = 0x0100;520 pub const BROADCAST = 0x0020;
523pub const SO_REUSEPORT = 0x0200;521 pub const USELOOPBACK = 0x0040;
524pub const SO_TIMESTAMP = 0x0800;522 pub const LINGER = 0x0080;
525pub const SO_BINDANY = 0x1000;523 pub const OOBINLINE = 0x0100;
526pub const SO_ZEROIZE = 0x2000;524 pub const REUSEPORT = 0x0200;
527pub const SO_SNDBUF = 0x1001;525 pub const TIMESTAMP = 0x0800;
528pub const SO_RCVBUF = 0x1002;526 pub const BINDANY = 0x1000;
529pub const SO_SNDLOWAT = 0x1003;527 pub const ZEROIZE = 0x2000;
530pub const SO_RCVLOWAT = 0x1004;528 pub const SNDBUF = 0x1001;
531pub const SO_SNDTIMEO = 0x1005;529 pub const RCVBUF = 0x1002;
532pub const SO_RCVTIMEO = 0x1006;530 pub const SNDLOWAT = 0x1003;
533pub const SO_ERROR = 0x1007;531 pub const RCVLOWAT = 0x1004;
534pub const SO_TYPE = 0x1008;532 pub const SNDTIMEO = 0x1005;
535pub const SO_NETPROC = 0x1020;533 pub const RCVTIMEO = 0x1006;
536pub const SO_RTABLE = 0x1021;534 pub const ERROR = 0x1007;
537pub const SO_PEERCRED = 0x1022;535 pub const TYPE = 0x1008;
538pub const SO_SPLICE = 0x1023;536 pub const NETPROC = 0x1020;
539pub const SO_DOMAIN = 0x1024;537 pub const RTABLE = 0x1021;
540pub const SO_PROTOCOL = 0x1025;538 pub const PEERCRED = 0x1022;
541539 pub const SPLICE = 0x1023;
542pub const SOL_SOCKET = 0xffff;540 pub const DOMAIN = 0x1024;
543541 pub const PROTOCOL = 0x1025;
544pub const PF_UNSPEC = AF_UNSPEC;542};
545pub const PF_LOCAL = AF_LOCAL;543
546pub const PF_UNIX = AF_UNIX;544pub const SOL = struct {
547pub const PF_INET = AF_INET;545 pub const SOCKET = 0xffff;
548pub const PF_APPLETALK = AF_APPLETALK;546};
549pub const PF_INET6 = AF_INET6;547
550pub const PF_DECnet = AF_DECnet;548pub const PF = struct {
551pub const PF_KEY = AF_KEY;549 pub const UNSPEC = AF.UNSPEC;
552pub const PF_ROUTE = AF_ROUTE;550 pub const LOCAL = AF.LOCAL;
553pub const PF_SNA = AF_SNA;551 pub const UNIX = AF.UNIX;
554pub const PF_MPLS = AF_MPLS;552 pub const INET = AF.INET;
555pub const PF_BLUETOOTH = AF_BLUETOOTH;553 pub const APPLETALK = AF.APPLETALK;
556pub const PF_ISDN = AF_ISDN;554 pub const INET6 = AF.INET6;
557pub const PF_MAX = AF_MAX;555 pub const DECnet = AF.DECnet;
558556 pub const KEY = AF.KEY;
559pub const AF_UNSPEC = 0;557 pub const ROUTE = AF.ROUTE;
560pub const AF_UNIX = 1;558 pub const SNA = AF.SNA;
561pub const AF_LOCAL = AF_UNIX;559 pub const MPLS = AF.MPLS;
562pub const AF_INET = 2;560 pub const BLUETOOTH = AF.BLUETOOTH;
563pub const AF_APPLETALK = 16;561 pub const ISDN = AF.ISDN;
564pub const AF_INET6 = 24;562 pub const MAX = AF.MAX;
565pub const AF_KEY = 30;563};
566pub const AF_ROUTE = 17;564
567pub const AF_SNA = 11;565pub const AF = struct {
568pub const AF_MPLS = 33;566 pub const UNSPEC = 0;
569pub const AF_BLUETOOTH = 32;567 pub const UNIX = 1;
570pub const AF_ISDN = 26;568 pub const LOCAL = UNIX;
571pub const AF_MAX = 36;569 pub const INET = 2;
570 pub const APPLETALK = 16;
571 pub const INET6 = 24;
572 pub const KEY = 30;
573 pub const ROUTE = 17;
574 pub const SNA = 11;
575 pub const MPLS = 33;
576 pub const BLUETOOTH = 32;
577 pub const ISDN = 26;
578 pub const MAX = 36;
579};
572580
573pub const DT_UNKNOWN = 0;581pub const DT_UNKNOWN = 0;
574pub const DT_FIFO = 1;582pub const DT_FIFO = 1;
...@@ -1072,107 +1080,76 @@ pub const AT_REMOVEDIR = 0x08;...@@ -1072,107 +1080,76 @@ pub const AT_REMOVEDIR = 0x08;
10721080
1073pub const HOST_NAME_MAX = 255;1081pub const HOST_NAME_MAX = 255;
10741082
1075/// dummy for IP1083pub const IPPROTO = struct {
1076pub const IPPROTO_IP = 0;1084 /// dummy for IP
10771085 pub const IP = 0;
1078/// IP6 hop-by-hop options1086 /// IP6 hop-by-hop options
1079pub const IPPROTO_HOPOPTS = IPPROTO_IP;1087 pub const HOPOPTS = IP;
10801088 /// control message protocol
1081/// control message protocol1089 pub const ICMP = 1;
1082pub const IPPROTO_ICMP = 1;1090 /// group mgmt protocol
10831091 pub const IGMP = 2;
1084/// group mgmt protocol1092 /// gateway^2 (deprecated)
1085pub const IPPROTO_IGMP = 2;1093 pub const GGP = 3;
10861094 /// IP header
1087/// gateway^2 (deprecated)1095 pub const IPV4 = IPIP;
1088pub const IPPROTO_GGP = 3;1096 /// IP inside IP
10891097 pub const IPIP = 4;
1090/// IP header1098 /// tcp
1091pub const IPPROTO_IPV4 = IPPROTO_IPIP;1099 pub const TCP = 6;
10921100 /// exterior gateway protocol
1093/// IP inside IP1101 pub const EGP = 8;
1094pub const IPPROTO_IPIP = 4;1102 /// pup
10951103 pub const PUP = 12;
1096/// tcp1104 /// user datagram protocol
1097pub const IPPROTO_TCP = 6;1105 pub const UDP = 17;
10981106 /// xns idp
1099/// exterior gateway protocol1107 pub const IDP = 22;
1100pub const IPPROTO_EGP = 8;1108 /// tp-4 w/ class negotiation
11011109 pub const TP = 29;
1102/// pup1110 /// IP6 header
1103pub const IPPROTO_PUP = 12;1111 pub const IPV6 = 41;
11041112 /// IP6 routing header
1105/// user datagram protocol1113 pub const ROUTING = 43;
1106pub const IPPROTO_UDP = 17;1114 /// IP6 fragmentation header
11071115 pub const FRAGMENT = 44;
1108/// xns idp1116 /// resource reservation
1109pub const IPPROTO_IDP = 22;1117 pub const RSVP = 46;
11101118 /// GRE encaps RFC 1701
1111/// tp-4 w/ class negotiation1119 pub const GRE = 47;
1112pub const IPPROTO_TP = 29;1120 /// encap. security payload
11131121 pub const ESP = 50;
1114/// IP6 header1122 /// authentication header
1115pub const IPPROTO_IPV6 = 41;1123 pub const AH = 51;
11161124 /// IP Mobility RFC 2004
1117/// IP6 routing header1125 pub const MOBILE = 55;
1118pub const IPPROTO_ROUTING = 43;1126 /// IPv6 ICMP
11191127 pub const IPV6_ICMP = 58;
1120/// IP6 fragmentation header1128 /// ICMP6
1121pub const IPPROTO_FRAGMENT = 44;1129 pub const ICMPV6 = 58;
11221130 /// IP6 no next header
1123/// resource reservation1131 pub const NONE = 59;
1124pub const IPPROTO_RSVP = 46;1132 /// IP6 destination option
11251133 pub const DSTOPTS = 60;
1126/// GRE encaps RFC 17011134 /// ISO cnlp
1127pub const IPPROTO_GRE = 47;1135 pub const EON = 80;
11281136 /// Ethernet-in-IP
1129/// encap. security payload1137 pub const ETHERIP = 97;
1130pub const IPPROTO_ESP = 50;1138 /// encapsulation header
11311139 pub const ENCAP = 98;
1132/// authentication header1140 /// Protocol indep. multicast
1133pub const IPPROTO_AH = 51;1141 pub const PIM = 103;
11341142 /// IP Payload Comp. Protocol
1135/// IP Mobility RFC 20041143 pub const IPCOMP = 108;
1136pub const IPPROTO_MOBILE = 55;1144 /// VRRP RFC 2338
11371145 pub const VRRP = 112;
1138/// IPv6 ICMP1146 /// Common Address Resolution Protocol
1139pub const IPPROTO_IPV6_ICMP = 58;1147 pub const CARP = 112;
11401148 /// PFSYNC
1141/// ICMP61149 pub const PFSYNC = 240;
1142pub const IPPROTO_ICMPV6 = 58;1150 /// raw IP packet
11431151 pub const RAW = 255;
1144/// IP6 no next header1152};
1145pub const IPPROTO_NONE = 59;
1146
1147/// IP6 destination option
1148pub const IPPROTO_DSTOPTS = 60;
1149
1150/// ISO cnlp
1151pub const IPPROTO_EON = 80;
1152
1153/// Ethernet-in-IP
1154pub const IPPROTO_ETHERIP = 97;
1155
1156/// encapsulation header
1157pub const IPPROTO_ENCAP = 98;
1158
1159/// Protocol indep. multicast
1160pub const IPPROTO_PIM = 103;
1161
1162/// IP Payload Comp. Protocol
1163pub const IPPROTO_IPCOMP = 108;
1164
1165/// VRRP RFC 2338
1166pub const IPPROTO_VRRP = 112;
1167
1168/// Common Address Resolution Protocol
1169pub const IPPROTO_CARP = 112;
1170
1171/// PFSYNC
1172pub const IPPROTO_PFSYNC = 240;
1173
1174/// raw IP packet
1175pub const IPPROTO_RAW = 255;
11761153
1177pub const rlimit_resource = enum(c_int) {1154pub const rlimit_resource = enum(c_int) {
1178 CPU,1155 CPU,
...@@ -1190,11 +1167,13 @@ pub const rlimit_resource = enum(c_int) {...@@ -1190,11 +1167,13 @@ pub const rlimit_resource = enum(c_int) {
11901167
1191pub const rlim_t = u64;1168pub const rlim_t = u64;
11921169
1193/// No limit1170pub const RLIM = struct {
1194pub const RLIM_INFINITY: rlim_t = (1 << 63) - 1;1171 /// No limit
1172 pub const INFINITY: rlim_t = (1 << 63) - 1;
11951173
1196pub const RLIM_SAVED_MAX = RLIM_INFINITY;1174 pub const SAVED_MAX = INFINITY;
1197pub const RLIM_SAVED_CUR = RLIM_INFINITY;1175 pub const SAVED_CUR = INFINITY;
1176};
11981177
1199pub const rlimit = extern struct {1178pub const rlimit = extern struct {
1200 /// Soft limit1179 /// Soft limit
...@@ -1215,17 +1194,19 @@ pub const pollfd = extern struct {...@@ -1215,17 +1194,19 @@ pub const pollfd = extern struct {
1215 revents: c_short,1194 revents: c_short,
1216};1195};
12171196
1218pub const POLLIN = 0x0001;1197pub const POLL = struct {
1219pub const POLLPRI = 0x0002;1198 pub const IN = 0x0001;
1220pub const POLLOUT = 0x0004;1199 pub const PRI = 0x0002;
1221pub const POLLERR = 0x0008;1200 pub const OUT = 0x0004;
1222pub const POLLHUP = 0x0010;1201 pub const ERR = 0x0008;
1223pub const POLLNVAL = 0x0020;1202 pub const HUP = 0x0010;
1224pub const POLLRDNORM = 0x0040;1203 pub const NVAL = 0x0020;
1225pub const POLLNORM = POLLRDNORM;1204 pub const RDNORM = 0x0040;
1226pub const POLLWRNORM = POLLOUT;1205 pub const NORM = RDNORM;
1227pub const POLLRDBAND = 0x0080;1206 pub const WRNORM = OUT;
1228pub const POLLWRBAND = 0x0100;1207 pub const RDBAND = 0x0080;
1208 pub const WRBAND = 0x0100;
1209};
12291210
1230// sysctl mib1211// sysctl mib
1231pub const CTL_UNSPEC = 0;1212pub const CTL_UNSPEC = 0;
lib/std/c/windows.zig+6-105
...@@ -198,121 +198,22 @@ pub const sa_family_t = ws2_32.ADDRESS_FAMILY;...@@ -198,121 +198,22 @@ pub const sa_family_t = ws2_32.ADDRESS_FAMILY;
198pub const socklen_t = ws2_32.socklen_t;198pub const socklen_t = ws2_32.socklen_t;
199199
200pub const sockaddr = ws2_32.sockaddr;200pub const sockaddr = ws2_32.sockaddr;
201pub const sockaddr_in = ws2_32.sockaddr_in;
202pub const sockaddr_in6 = ws2_32.sockaddr_in6;
203pub const sockaddr_un = ws2_32.sockaddr_un;
204201
205pub const in6_addr = [16]u8;202pub const in6_addr = [16]u8;
206pub const in_addr = u32;203pub const in_addr = u32;
207204
208pub const addrinfo = ws2_32.addrinfo;205pub const addrinfo = ws2_32.addrinfo;
209206pub const AF = ws2_32.AF;
210pub const AF_UNSPEC = ws2_32.AF_UNSPEC;207pub const SOCK = ws2_32.SOCK;
211pub const AF_UNIX = ws2_32.AF_UNIX;208pub const IPPROTO = ws2_32.IPPROTOP;
212pub const AF_INET = ws2_32.AF_INET;
213pub const AF_IMPLINK = ws2_32.AF_IMPLINK;
214pub const AF_PUP = ws2_32.AF_PUP;
215pub const AF_CHAOS = ws2_32.AF_CHAOS;
216pub const AF_NS = ws2_32.AF_NS;
217pub const AF_IPX = ws2_32.AF_IPX;
218pub const AF_ISO = ws2_32.AF_ISO;
219pub const AF_OSI = ws2_32.AF_OSI;
220pub const AF_ECMA = ws2_32.AF_ECMA;
221pub const AF_DATAKIT = ws2_32.AF_DATAKIT;
222pub const AF_CCITT = ws2_32.AF_CCITT;
223pub const AF_SNA = ws2_32.AF_SNA;
224pub const AF_DECnet = ws2_32.AF_DECnet;
225pub const AF_DLI = ws2_32.AF_DLI;
226pub const AF_LAT = ws2_32.AF_LAT;
227pub const AF_HYLINK = ws2_32.AF_HYLINK;
228pub const AF_APPLETALK = ws2_32.AF_APPLETALK;
229pub const AF_NETBIOS = ws2_32.AF_NETBIOS;
230pub const AF_VOICEVIEW = ws2_32.AF_VOICEVIEW;
231pub const AF_FIREFOX = ws2_32.AF_FIREFOX;
232pub const AF_UNKNOWN1 = ws2_32.AF_UNKNOWN1;
233pub const AF_BAN = ws2_32.AF_BAN;
234pub const AF_ATM = ws2_32.AF_ATM;
235pub const AF_INET6 = ws2_32.AF_INET6;
236pub const AF_CLUSTER = ws2_32.AF_CLUSTER;
237pub const AF_12844 = ws2_32.AF_12844;
238pub const AF_IRDA = ws2_32.AF_IRDA;
239pub const AF_NETDES = ws2_32.AF_NETDES;
240pub const AF_TCNPROCESS = ws2_32.AF_TCNPROCESS;
241pub const AF_TCNMESSAGE = ws2_32.AF_TCNMESSAGE;
242pub const AF_ICLFXBM = ws2_32.AF_ICLFXBM;
243pub const AF_BTH = ws2_32.AF_BTH;
244pub const AF_MAX = ws2_32.AF_MAX;
245
246pub const SOCK_STREAM = ws2_32.SOCK_STREAM;
247pub const SOCK_DGRAM = ws2_32.SOCK_DGRAM;
248pub const SOCK_RAW = ws2_32.SOCK_RAW;
249pub const SOCK_RDM = ws2_32.SOCK_RDM;
250pub const SOCK_SEQPACKET = ws2_32.SOCK_SEQPACKET;
251
252/// WARNING: this flag is not supported by windows socket functions directly,
253/// it is only supported by std.os.socket. Be sure that this value does
254/// not share any bits with any of the SOCK_* values.
255pub const SOCK_CLOEXEC = 0x10000;
256/// WARNING: this flag is not supported by windows socket functions directly,
257/// it is only supported by std.os.socket. Be sure that this value does
258/// not share any bits with any of the SOCK_* values.
259pub const SOCK_NONBLOCK = 0x20000;
260
261pub const IPPROTO_ICMP = ws2_32.IPPROTO_ICMP;
262pub const IPPROTO_IGMP = ws2_32.IPPROTO_IGMP;
263pub const BTHPROTO_RFCOMM = ws2_32.BTHPROTO_RFCOMM;209pub const BTHPROTO_RFCOMM = ws2_32.BTHPROTO_RFCOMM;
264pub const IPPROTO_TCP = ws2_32.IPPROTO_TCP;
265pub const IPPROTO_UDP = ws2_32.IPPROTO_UDP;
266pub const IPPROTO_ICMPV6 = ws2_32.IPPROTO_ICMPV6;
267pub const IPPROTO_RM = ws2_32.IPPROTO_RM;
268210
269pub const nfds_t = c_ulong;211pub const nfds_t = c_ulong;
270pub const pollfd = ws2_32.pollfd;212pub const pollfd = ws2_32.pollfd;
271213pub const POLL = ws2_32.POLL;
272pub const POLLRDNORM = ws2_32.POLLRDNORM;214pub const SOL = ws2_32.SOL;
273pub const POLLRDBAND = ws2_32.POLLRDBAND;215pub const SO = ws2_32.SO;
274pub const POLLIN = ws2_32.POLLIN;
275pub const POLLPRI = ws2_32.POLLPRI;
276pub const POLLWRNORM = ws2_32.POLLWRNORM;
277pub const POLLOUT = ws2_32.POLLOUT;
278pub const POLLWRBAND = ws2_32.POLLWRBAND;
279pub const POLLERR = ws2_32.POLLERR;
280pub const POLLHUP = ws2_32.POLLHUP;
281pub const POLLNVAL = ws2_32.POLLNVAL;
282
283pub const SOL_SOCKET = ws2_32.SOL_SOCKET;
284
285pub const SO_DEBUG = ws2_32.SO_DEBUG;
286pub const SO_ACCEPTCONN = ws2_32.SO_ACCEPTCONN;
287pub const SO_REUSEADDR = ws2_32.SO_REUSEADDR;
288pub const SO_KEEPALIVE = ws2_32.SO_KEEPALIVE;
289pub const SO_DONTROUTE = ws2_32.SO_DONTROUTE;
290pub const SO_BROADCAST = ws2_32.SO_BROADCAST;
291pub const SO_USELOOPBACK = ws2_32.SO_USELOOPBACK;
292pub const SO_LINGER = ws2_32.SO_LINGER;
293pub const SO_OOBINLINE = ws2_32.SO_OOBINLINE;
294
295pub const SO_DONTLINGER = ws2_32.SO_DONTLINGER;
296pub const SO_EXCLUSIVEADDRUSE = ws2_32.SO_EXCLUSIVEADDRUSE;
297
298pub const SO_SNDBUF = ws2_32.SO_SNDBUF;
299pub const SO_RCVBUF = ws2_32.SO_RCVBUF;
300pub const SO_SNDLOWAT = ws2_32.SO_SNDLOWAT;
301pub const SO_RCVLOWAT = ws2_32.SO_RCVLOWAT;
302pub const SO_SNDTIMEO = ws2_32.SO_SNDTIMEO;
303pub const SO_RCVTIMEO = ws2_32.SO_RCVTIMEO;
304pub const SO_ERROR = ws2_32.SO_ERROR;
305pub const SO_TYPE = ws2_32.SO_TYPE;
306
307pub const SO_GROUP_ID = ws2_32.SO_GROUP_ID;
308pub const SO_GROUP_PRIORITY = ws2_32.SO_GROUP_PRIORITY;
309pub const SO_MAX_MSG_SIZE = ws2_32.SO_MAX_MSG_SIZE;
310pub const SO_PROTOCOL_INFOA = ws2_32.SO_PROTOCOL_INFOA;
311pub const SO_PROTOCOL_INFOW = ws2_32.SO_PROTOCOL_INFOW;
312
313pub const PVD_CONFIG = ws2_32.PVD_CONFIG;216pub const PVD_CONFIG = ws2_32.PVD_CONFIG;
314pub const SO_CONDITIONAL_ACCEPT = ws2_32.SO_CONDITIONAL_ACCEPT;
315
316pub const TCP_NODELAY = ws2_32.TCP_NODELAY;217pub const TCP_NODELAY = ws2_32.TCP_NODELAY;
317218
318pub const O_RDONLY = 0o0;219pub const O_RDONLY = 0o0;
lib/std/child_process.zig+19-18
...@@ -7,6 +7,7 @@ const os = std.os;...@@ -7,6 +7,7 @@ const os = std.os;
7const process = std.process;7const process = std.process;
8const File = std.fs.File;8const File = std.fs.File;
9const windows = os.windows;9const windows = os.windows;
10const linux = os.linux;
10const mem = std.mem;11const mem = std.mem;
11const math = std.math;12const math = std.math;
12const debug = std.debug;13const debug = std.debug;
...@@ -189,8 +190,8 @@ pub const ChildProcess = struct {...@@ -189,8 +190,8 @@ pub const ChildProcess = struct {
189 max_output_bytes: usize,190 max_output_bytes: usize,
190 ) !void {191 ) !void {
191 var poll_fds = [_]os.pollfd{192 var poll_fds = [_]os.pollfd{
192 .{ .fd = child.stdout.?.handle, .events = os.POLLIN, .revents = undefined },193 .{ .fd = child.stdout.?.handle, .events = os.POLL.IN, .revents = undefined },
193 .{ .fd = child.stderr.?.handle, .events = os.POLLIN, .revents = undefined },194 .{ .fd = child.stderr.?.handle, .events = os.POLL.IN, .revents = undefined },
194 };195 };
195196
196 var dead_fds: usize = 0;197 var dead_fds: usize = 0;
...@@ -199,7 +200,7 @@ pub const ChildProcess = struct {...@@ -199,7 +200,7 @@ pub const ChildProcess = struct {
199 // of space an ArrayList will allocate grows exponentially.200 // of space an ArrayList will allocate grows exponentially.
200 const bump_amt = 512;201 const bump_amt = 512;
201202
202 const err_mask = os.POLLERR | os.POLLNVAL | os.POLLHUP;203 const err_mask = os.POLL.ERR | os.POLL.NVAL | os.POLL.HUP;
203204
204 while (dead_fds < poll_fds.len) {205 while (dead_fds < poll_fds.len) {
205 const events = try os.poll(&poll_fds, std.math.maxInt(i32));206 const events = try os.poll(&poll_fds, std.math.maxInt(i32));
...@@ -209,9 +210,9 @@ pub const ChildProcess = struct {...@@ -209,9 +210,9 @@ pub const ChildProcess = struct {
209 var remove_stderr = false;210 var remove_stderr = false;
210 // Try reading whatever is available before checking the error211 // Try reading whatever is available before checking the error
211 // conditions.212 // conditions.
212 // It's still possible to read after a POLLHUP is received, always213 // It's still possible to read after a POLL.HUP is received, always
213 // check if there's some data waiting to be read first.214 // check if there's some data waiting to be read first.
214 if (poll_fds[0].revents & os.POLLIN != 0) {215 if (poll_fds[0].revents & os.POLL.IN != 0) {
215 // stdout is ready.216 // stdout is ready.
216 const new_capacity = std.math.min(stdout.items.len + bump_amt, max_output_bytes);217 const new_capacity = std.math.min(stdout.items.len + bump_amt, max_output_bytes);
217 try stdout.ensureCapacity(new_capacity);218 try stdout.ensureCapacity(new_capacity);
...@@ -226,7 +227,7 @@ pub const ChildProcess = struct {...@@ -226,7 +227,7 @@ pub const ChildProcess = struct {
226 remove_stdout = poll_fds[0].revents & err_mask != 0;227 remove_stdout = poll_fds[0].revents & err_mask != 0;
227 }228 }
228229
229 if (poll_fds[1].revents & os.POLLIN != 0) {230 if (poll_fds[1].revents & os.POLL.IN != 0) {
230 // stderr is ready.231 // stderr is ready.
231 const new_capacity = std.math.min(stderr.items.len + bump_amt, max_output_bytes);232 const new_capacity = std.math.min(stderr.items.len + bump_amt, max_output_bytes);
232 try stderr.ensureCapacity(new_capacity);233 try stderr.ensureCapacity(new_capacity);
...@@ -461,7 +462,7 @@ pub const ChildProcess = struct {...@@ -461,7 +462,7 @@ pub const ChildProcess = struct {
461 if (builtin.os.tag == .linux) {462 if (builtin.os.tag == .linux) {
462 var fd = [1]std.os.pollfd{std.os.pollfd{463 var fd = [1]std.os.pollfd{std.os.pollfd{
463 .fd = self.err_pipe[0],464 .fd = self.err_pipe[0],
464 .events = std.os.POLLIN,465 .events = std.os.POLL.IN,
465 .revents = undefined,466 .revents = undefined,
466 }};467 }};
467468
...@@ -471,7 +472,7 @@ pub const ChildProcess = struct {...@@ -471,7 +472,7 @@ pub const ChildProcess = struct {
471472
472 // According to eventfd(2) the descriptro is readable if the counter473 // According to eventfd(2) the descriptro is readable if the counter
473 // has a value greater than 0474 // has a value greater than 0
474 if ((fd[0].revents & std.os.POLLIN) != 0) {475 if ((fd[0].revents & std.os.POLL.IN) != 0) {
475 const err_int = try readIntFd(self.err_pipe[0]);476 const err_int = try readIntFd(self.err_pipe[0]);
476 return @errSetCast(SpawnError, @intToError(err_int));477 return @errSetCast(SpawnError, @intToError(err_int));
477 }478 }
...@@ -494,18 +495,18 @@ pub const ChildProcess = struct {...@@ -494,18 +495,18 @@ pub const ChildProcess = struct {
494 }495 }
495496
496 fn statusToTerm(status: u32) Term {497 fn statusToTerm(status: u32) Term {
497 return if (os.WIFEXITED(status))498 return if (os.W.IFEXITED(status))
498 Term{ .Exited = os.WEXITSTATUS(status) }499 Term{ .Exited = os.W.EXITSTATUS(status) }
499 else if (os.WIFSIGNALED(status))500 else if (os.W.IFSIGNALED(status))
500 Term{ .Signal = os.WTERMSIG(status) }501 Term{ .Signal = os.W.TERMSIG(status) }
501 else if (os.WIFSTOPPED(status))502 else if (os.W.IFSTOPPED(status))
502 Term{ .Stopped = os.WSTOPSIG(status) }503 Term{ .Stopped = os.W.STOPSIG(status) }
503 else504 else
504 Term{ .Unknown = status };505 Term{ .Unknown = status };
505 }506 }
506507
507 fn spawnPosix(self: *ChildProcess) SpawnError!void {508 fn spawnPosix(self: *ChildProcess) SpawnError!void {
508 const pipe_flags = if (io.is_async) os.O_NONBLOCK else 0;509 const pipe_flags = if (io.is_async) os.O.NONBLOCK else 0;
509 const stdin_pipe = if (self.stdin_behavior == StdIo.Pipe) try os.pipe2(pipe_flags) else undefined;510 const stdin_pipe = if (self.stdin_behavior == StdIo.Pipe) try os.pipe2(pipe_flags) else undefined;
510 errdefer if (self.stdin_behavior == StdIo.Pipe) {511 errdefer if (self.stdin_behavior == StdIo.Pipe) {
511 destroyPipe(stdin_pipe);512 destroyPipe(stdin_pipe);
...@@ -523,7 +524,7 @@ pub const ChildProcess = struct {...@@ -523,7 +524,7 @@ pub const ChildProcess = struct {
523524
524 const any_ignore = (self.stdin_behavior == StdIo.Ignore or self.stdout_behavior == StdIo.Ignore or self.stderr_behavior == StdIo.Ignore);525 const any_ignore = (self.stdin_behavior == StdIo.Ignore or self.stdout_behavior == StdIo.Ignore or self.stderr_behavior == StdIo.Ignore);
525 const dev_null_fd = if (any_ignore)526 const dev_null_fd = if (any_ignore)
526 os.openZ("/dev/null", os.O_RDWR, 0) catch |err| switch (err) {527 os.openZ("/dev/null", os.O.RDWR, 0) catch |err| switch (err) {
527 error.PathAlreadyExists => unreachable,528 error.PathAlreadyExists => unreachable,
528 error.NoSpaceLeft => unreachable,529 error.NoSpaceLeft => unreachable,
529 error.FileTooBig => unreachable,530 error.FileTooBig => unreachable,
...@@ -575,12 +576,12 @@ pub const ChildProcess = struct {...@@ -575,12 +576,12 @@ pub const ChildProcess = struct {
575 // and execve from the child process to the parent process.576 // and execve from the child process to the parent process.
576 const err_pipe = blk: {577 const err_pipe = blk: {
577 if (builtin.os.tag == .linux) {578 if (builtin.os.tag == .linux) {
578 const fd = try os.eventfd(0, os.EFD_CLOEXEC);579 const fd = try os.eventfd(0, linux.EFD.CLOEXEC);
579 // There's no distinction between the readable and the writeable580 // There's no distinction between the readable and the writeable
580 // end with eventfd581 // end with eventfd
581 break :blk [2]os.fd_t{ fd, fd };582 break :blk [2]os.fd_t{ fd, fd };
582 } else {583 } else {
583 break :blk try os.pipe2(os.O_CLOEXEC);584 break :blk try os.pipe2(os.O.CLOEXEC);
584 }585 }
585 };586 };
586 errdefer destroyPipe(err_pipe);587 errdefer destroyPipe(err_pipe);
lib/std/crypto/tlcsprng.zig+3-3
...@@ -74,8 +74,8 @@ fn tlsCsprngFill(_: *const std.rand.Random, buffer: []u8) void {...@@ -74,8 +74,8 @@ fn tlsCsprngFill(_: *const std.rand.Random, buffer: []u8) void {
74 wipe_mem = os.mmap(74 wipe_mem = os.mmap(
75 null,75 null,
76 @sizeOf(Context),76 @sizeOf(Context),
77 os.PROT_READ | os.PROT_WRITE,77 os.PROT.READ | os.PROT.WRITE,
78 os.MAP_PRIVATE | os.MAP_ANONYMOUS,78 os.MAP.PRIVATE | os.MAP.ANONYMOUS,
79 -1,79 -1,
80 0,80 0,
81 ) catch {81 ) catch {
...@@ -111,7 +111,7 @@ fn tlsCsprngFill(_: *const std.rand.Random, buffer: []u8) void {...@@ -111,7 +111,7 @@ fn tlsCsprngFill(_: *const std.rand.Random, buffer: []u8) void {
111 break :wof;111 break :wof;
112 } else |_| {}112 } else |_| {}
113113
114 if (os.madvise(wipe_mem.ptr, wipe_mem.len, os.MADV_WIPEONFORK)) |_| {114 if (os.madvise(wipe_mem.ptr, wipe_mem.len, os.MADV.WIPEONFORK)) |_| {
115 return initAndFill(buffer);115 return initAndFill(buffer);
116 } else |_| {}116 } else |_| {}
117 }117 }
lib/std/dynamic_library.zig+13-13
...@@ -115,7 +115,7 @@ pub const ElfDynLib = struct {...@@ -115,7 +115,7 @@ pub const ElfDynLib = struct {
115115
116 /// Trusts the file. Malicious file will be able to execute arbitrary code.116 /// Trusts the file. Malicious file will be able to execute arbitrary code.
117 pub fn open(path: []const u8) !ElfDynLib {117 pub fn open(path: []const u8) !ElfDynLib {
118 const fd = try os.open(path, 0, os.O_RDONLY | os.O_CLOEXEC);118 const fd = try os.open(path, 0, os.O.RDONLY | os.O.CLOEXEC);
119 defer os.close(fd);119 defer os.close(fd);
120120
121 const stat = try os.fstat(fd);121 const stat = try os.fstat(fd);
...@@ -126,8 +126,8 @@ pub const ElfDynLib = struct {...@@ -126,8 +126,8 @@ pub const ElfDynLib = struct {
126 const file_bytes = try os.mmap(126 const file_bytes = try os.mmap(
127 null,127 null,
128 mem.alignForward(size, mem.page_size),128 mem.alignForward(size, mem.page_size),
129 os.PROT_READ,129 os.PROT.READ,
130 os.MAP_PRIVATE,130 os.MAP.PRIVATE,
131 fd,131 fd,
132 0,132 0,
133 );133 );
...@@ -160,12 +160,12 @@ pub const ElfDynLib = struct {...@@ -160,12 +160,12 @@ pub const ElfDynLib = struct {
160 }160 }
161 const dynv = maybe_dynv orelse return error.MissingDynamicLinkingInformation;161 const dynv = maybe_dynv orelse return error.MissingDynamicLinkingInformation;
162162
163 // Reserve the entire range (with no permissions) so that we can do MAP_FIXED below.163 // Reserve the entire range (with no permissions) so that we can do MAP.FIXED below.
164 const all_loaded_mem = try os.mmap(164 const all_loaded_mem = try os.mmap(
165 null,165 null,
166 virt_addr_end,166 virt_addr_end,
167 os.PROT_NONE,167 os.PROT.NONE,
168 os.MAP_PRIVATE | os.MAP_ANONYMOUS,168 os.MAP.PRIVATE | os.MAP.ANONYMOUS,
169 -1,169 -1,
170 0,170 0,
171 );171 );
...@@ -197,7 +197,7 @@ pub const ElfDynLib = struct {...@@ -197,7 +197,7 @@ pub const ElfDynLib = struct {
197 ptr,197 ptr,
198 extended_memsz,198 extended_memsz,
199 prot,199 prot,
200 os.MAP_PRIVATE | os.MAP_FIXED,200 os.MAP.PRIVATE | os.MAP.FIXED,
201 fd,201 fd,
202 ph.p_offset - extra_bytes,202 ph.p_offset - extra_bytes,
203 );203 );
...@@ -206,7 +206,7 @@ pub const ElfDynLib = struct {...@@ -206,7 +206,7 @@ pub const ElfDynLib = struct {
206 ptr,206 ptr,
207 extended_memsz,207 extended_memsz,
208 prot,208 prot,
209 os.MAP_PRIVATE | os.MAP_FIXED | os.MAP_ANONYMOUS,209 os.MAP.PRIVATE | os.MAP.FIXED | os.MAP.ANONYMOUS,
210 -1,210 -1,
211 0,211 0,
212 );212 );
...@@ -294,10 +294,10 @@ pub const ElfDynLib = struct {...@@ -294,10 +294,10 @@ pub const ElfDynLib = struct {
294 }294 }
295295
296 fn elfToMmapProt(elf_prot: u64) u32 {296 fn elfToMmapProt(elf_prot: u64) u32 {
297 var result: u32 = os.PROT_NONE;297 var result: u32 = os.PROT.NONE;
298 if ((elf_prot & elf.PF_R) != 0) result |= os.PROT_READ;298 if ((elf_prot & elf.PF_R) != 0) result |= os.PROT.READ;
299 if ((elf_prot & elf.PF_W) != 0) result |= os.PROT_WRITE;299 if ((elf_prot & elf.PF_W) != 0) result |= os.PROT.WRITE;
300 if ((elf_prot & elf.PF_X) != 0) result |= os.PROT_EXEC;300 if ((elf_prot & elf.PF_X) != 0) result |= os.PROT.EXEC;
301 return result;301 return result;
302 }302 }
303};303};
...@@ -373,7 +373,7 @@ pub const DlDynlib = struct {...@@ -373,7 +373,7 @@ pub const DlDynlib = struct {
373373
374 pub fn openZ(path_c: [*:0]const u8) !DlDynlib {374 pub fn openZ(path_c: [*:0]const u8) !DlDynlib {
375 return DlDynlib{375 return DlDynlib{
376 .handle = system.dlopen(path_c, system.RTLD_LAZY) orelse {376 .handle = system.dlopen(path_c, system.RTLD.LAZY) orelse {
377 return error.FileNotFound;377 return error.FileNotFound;
378 },378 },
379 };379 };
lib/std/event/loop.zig+4-4
...@@ -457,8 +457,8 @@ pub const Loop = struct {...@@ -457,8 +457,8 @@ pub const Loop = struct {
457 // Fall back to a blocking poll(). Ideally this codepath is never hit, since457 // Fall back to a blocking poll(). Ideally this codepath is never hit, since
458 // epoll should be just fine. But this is better than incorrect behavior.458 // epoll should be just fine. But this is better than incorrect behavior.
459 var poll_flags: i16 = 0;459 var poll_flags: i16 = 0;
460 if ((flags & os.EPOLLIN) != 0) poll_flags |= os.POLLIN;460 if ((flags & os.EPOLLIN) != 0) poll_flags |= os.POLL.IN;
461 if ((flags & os.EPOLLOUT) != 0) poll_flags |= os.POLLOUT;461 if ((flags & os.EPOLLOUT) != 0) poll_flags |= os.POLL.OUT;
462 var pfd = [1]os.pollfd{os.pollfd{462 var pfd = [1]os.pollfd{os.pollfd{
463 .fd = fd,463 .fd = fd,
464 .events = poll_flags,464 .events = poll_flags,
...@@ -903,12 +903,12 @@ pub const Loop = struct {...@@ -903,12 +903,12 @@ pub const Loop = struct {
903 /// will return a value greater than was supplied to the call.903 /// will return a value greater than was supplied to the call.
904 addr_size: *os.socklen_t,904 addr_size: *os.socklen_t,
905 /// The following values can be bitwise ORed in flags to obtain different behavior:905 /// The following values can be bitwise ORed in flags to obtain different behavior:
906 /// * `SOCK_CLOEXEC` - Set the close-on-exec (`FD_CLOEXEC`) flag on the new file descriptor. See the906 /// * `SOCK.CLOEXEC` - Set the close-on-exec (`FD_CLOEXEC`) flag on the new file descriptor. See the
907 /// description of the `O_CLOEXEC` flag in `open` for reasons why this may be useful.907 /// description of the `O_CLOEXEC` flag in `open` for reasons why this may be useful.
908 flags: u32,908 flags: u32,
909 ) os.AcceptError!os.socket_t {909 ) os.AcceptError!os.socket_t {
910 while (true) {910 while (true) {
911 return os.accept(sockfd, addr, addr_size, flags | os.SOCK_NONBLOCK) catch |err| switch (err) {911 return os.accept(sockfd, addr, addr_size, flags | os.SOCK.NONBLOCK) catch |err| switch (err) {
912 error.WouldBlock => {912 error.WouldBlock => {
913 self.waitUntilFdReadable(sockfd);913 self.waitUntilFdReadable(sockfd);
914 continue;914 continue;
lib/std/fs.zig+23-22
...@@ -500,13 +500,14 @@ pub const Dir = struct {...@@ -500,13 +500,14 @@ pub const Dir = struct {
500 },500 },
501 .linux => struct {501 .linux => struct {
502 dir: Dir,502 dir: Dir,
503 // The if guard is solely there to prevent compile errors from missing `os.linux.dirent64`503 // The if guard is solely there to prevent compile errors from missing `linux.dirent64`
504 // definition when compiling for other OSes. It doesn't do anything when compiling for Linux.504 // definition when compiling for other OSes. It doesn't do anything when compiling for Linux.
505 buf: [8192]u8 align(if (builtin.os.tag != .linux) 1 else @alignOf(os.linux.dirent64)),505 buf: [8192]u8 align(if (builtin.os.tag != .linux) 1 else @alignOf(linux.dirent64)),
506 index: usize,506 index: usize,
507 end_index: usize,507 end_index: usize,
508508
509 const Self = @This();509 const Self = @This();
510 const linux = os.linux;
510511
511 pub const Error = IteratorError;512 pub const Error = IteratorError;
512513
...@@ -515,8 +516,8 @@ pub const Dir = struct {...@@ -515,8 +516,8 @@ pub const Dir = struct {
515 pub fn next(self: *Self) Error!?Entry {516 pub fn next(self: *Self) Error!?Entry {
516 start_over: while (true) {517 start_over: while (true) {
517 if (self.index >= self.end_index) {518 if (self.index >= self.end_index) {
518 const rc = os.linux.getdents64(self.dir.fd, &self.buf, self.buf.len);519 const rc = linux.getdents64(self.dir.fd, &self.buf, self.buf.len);
519 switch (os.linux.getErrno(rc)) {520 switch (linux.getErrno(rc)) {
520 .SUCCESS => {},521 .SUCCESS => {},
521 .BADF => unreachable, // Dir is invalid or was opened without iteration ability522 .BADF => unreachable, // Dir is invalid or was opened without iteration ability
522 .FAULT => unreachable,523 .FAULT => unreachable,
...@@ -528,7 +529,7 @@ pub const Dir = struct {...@@ -528,7 +529,7 @@ pub const Dir = struct {
528 self.index = 0;529 self.index = 0;
529 self.end_index = rc;530 self.end_index = rc;
530 }531 }
531 const linux_entry = @ptrCast(*align(1) os.dirent64, &self.buf[self.index]);532 const linux_entry = @ptrCast(*align(1) linux.dirent64, &self.buf[self.index]);
532 const next_index = self.index + linux_entry.reclen();533 const next_index = self.index + linux_entry.reclen();
533 self.index = next_index;534 self.index = next_index;
534535
...@@ -540,13 +541,13 @@ pub const Dir = struct {...@@ -540,13 +541,13 @@ pub const Dir = struct {
540 }541 }
541542
542 const entry_kind = switch (linux_entry.d_type) {543 const entry_kind = switch (linux_entry.d_type) {
543 os.DT_BLK => Entry.Kind.BlockDevice,544 linux.DT.BLK => Entry.Kind.BlockDevice,
544 os.DT_CHR => Entry.Kind.CharacterDevice,545 linux.DT.CHR => Entry.Kind.CharacterDevice,
545 os.DT_DIR => Entry.Kind.Directory,546 linux.DT.DIR => Entry.Kind.Directory,
546 os.DT_FIFO => Entry.Kind.NamedPipe,547 linux.DT.FIFO => Entry.Kind.NamedPipe,
547 os.DT_LNK => Entry.Kind.SymLink,548 linux.DT.LNK => Entry.Kind.SymLink,
548 os.DT_REG => Entry.Kind.File,549 linux.DT.REG => Entry.Kind.File,
549 os.DT_SOCK => Entry.Kind.UnixDomainSocket,550 linux.DT.SOCK => Entry.Kind.UnixDomainSocket,
550 else => Entry.Kind.Unknown,551 else => Entry.Kind.Unknown,
551 };552 };
552 return Entry{553 return Entry{
...@@ -1537,7 +1538,7 @@ pub const Dir = struct {...@@ -1537,7 +1538,7 @@ pub const Dir = struct {
1537 return self.deleteFileW(sub_path_w.span());1538 return self.deleteFileW(sub_path_w.span());
1538 } else if (builtin.os.tag == .wasi and !builtin.link_libc) {1539 } else if (builtin.os.tag == .wasi and !builtin.link_libc) {
1539 os.unlinkatWasi(self.fd, sub_path, 0) catch |err| switch (err) {1540 os.unlinkatWasi(self.fd, sub_path, 0) catch |err| switch (err) {
1540 error.DirNotEmpty => unreachable, // not passing AT_REMOVEDIR1541 error.DirNotEmpty => unreachable, // not passing AT.REMOVEDIR
1541 else => |e| return e,1542 else => |e| return e,
1542 };1543 };
1543 } else {1544 } else {
...@@ -1551,13 +1552,13 @@ pub const Dir = struct {...@@ -1551,13 +1552,13 @@ pub const Dir = struct {
1551 /// Same as `deleteFile` except the parameter is null-terminated.1552 /// Same as `deleteFile` except the parameter is null-terminated.
1552 pub fn deleteFileZ(self: Dir, sub_path_c: [*:0]const u8) DeleteFileError!void {1553 pub fn deleteFileZ(self: Dir, sub_path_c: [*:0]const u8) DeleteFileError!void {
1553 os.unlinkatZ(self.fd, sub_path_c, 0) catch |err| switch (err) {1554 os.unlinkatZ(self.fd, sub_path_c, 0) catch |err| switch (err) {
1554 error.DirNotEmpty => unreachable, // not passing AT_REMOVEDIR1555 error.DirNotEmpty => unreachable, // not passing AT.REMOVEDIR
1555 error.AccessDenied => |e| switch (builtin.os.tag) {1556 error.AccessDenied => |e| switch (builtin.os.tag) {
1556 // non-Linux POSIX systems return EPERM when trying to delete a directory, so1557 // non-Linux POSIX systems return EPERM when trying to delete a directory, so
1557 // we need to handle that case specifically and translate the error1558 // we need to handle that case specifically and translate the error
1558 .macos, .ios, .freebsd, .netbsd, .dragonfly, .openbsd => {1559 .macos, .ios, .freebsd, .netbsd, .dragonfly, .openbsd => {
1559 // Don't follow symlinks to match unlinkat (which acts on symlinks rather than follows them)1560 // Don't follow symlinks to match unlinkat (which acts on symlinks rather than follows them)
1560 const fstat = os.fstatatZ(self.fd, sub_path_c, os.AT_SYMLINK_NOFOLLOW) catch return e;1561 const fstat = os.fstatatZ(self.fd, sub_path_c, os.AT.SYMLINK_NOFOLLOW) catch return e;
1561 const is_dir = fstat.mode & os.S_IFMT == os.S_IFDIR;1562 const is_dir = fstat.mode & os.S_IFMT == os.S_IFDIR;
1562 return if (is_dir) error.IsDir else e;1563 return if (is_dir) error.IsDir else e;
1563 },1564 },
...@@ -1570,7 +1571,7 @@ pub const Dir = struct {...@@ -1570,7 +1571,7 @@ pub const Dir = struct {
1570 /// Same as `deleteFile` except the parameter is WTF-16 encoded.1571 /// Same as `deleteFile` except the parameter is WTF-16 encoded.
1571 pub fn deleteFileW(self: Dir, sub_path_w: []const u16) DeleteFileError!void {1572 pub fn deleteFileW(self: Dir, sub_path_w: []const u16) DeleteFileError!void {
1572 os.unlinkatW(self.fd, sub_path_w, 0) catch |err| switch (err) {1573 os.unlinkatW(self.fd, sub_path_w, 0) catch |err| switch (err) {
1573 error.DirNotEmpty => unreachable, // not passing AT_REMOVEDIR1574 error.DirNotEmpty => unreachable, // not passing AT.REMOVEDIR
1574 else => |e| return e,1575 else => |e| return e,
1575 };1576 };
1576 }1577 }
...@@ -1599,8 +1600,8 @@ pub const Dir = struct {...@@ -1599,8 +1600,8 @@ pub const Dir = struct {
1599 const sub_path_w = try os.windows.sliceToPrefixedFileW(sub_path);1600 const sub_path_w = try os.windows.sliceToPrefixedFileW(sub_path);
1600 return self.deleteDirW(sub_path_w.span());1601 return self.deleteDirW(sub_path_w.span());
1601 } else if (builtin.os.tag == .wasi and !builtin.link_libc) {1602 } else if (builtin.os.tag == .wasi and !builtin.link_libc) {
1602 os.unlinkat(self.fd, sub_path, os.AT_REMOVEDIR) catch |err| switch (err) {1603 os.unlinkat(self.fd, sub_path, os.AT.REMOVEDIR) catch |err| switch (err) {
1603 error.IsDir => unreachable, // not possible since we pass AT_REMOVEDIR1604 error.IsDir => unreachable, // not possible since we pass AT.REMOVEDIR
1604 else => |e| return e,1605 else => |e| return e,
1605 };1606 };
1606 } else {1607 } else {
...@@ -1611,8 +1612,8 @@ pub const Dir = struct {...@@ -1611,8 +1612,8 @@ pub const Dir = struct {
16111612
1612 /// Same as `deleteDir` except the parameter is null-terminated.1613 /// Same as `deleteDir` except the parameter is null-terminated.
1613 pub fn deleteDirZ(self: Dir, sub_path_c: [*:0]const u8) DeleteDirError!void {1614 pub fn deleteDirZ(self: Dir, sub_path_c: [*:0]const u8) DeleteDirError!void {
1614 os.unlinkatZ(self.fd, sub_path_c, os.AT_REMOVEDIR) catch |err| switch (err) {1615 os.unlinkatZ(self.fd, sub_path_c, os.AT.REMOVEDIR) catch |err| switch (err) {
1615 error.IsDir => unreachable, // not possible since we pass AT_REMOVEDIR1616 error.IsDir => unreachable, // not possible since we pass AT.REMOVEDIR
1616 else => |e| return e,1617 else => |e| return e,
1617 };1618 };
1618 }1619 }
...@@ -1620,8 +1621,8 @@ pub const Dir = struct {...@@ -1620,8 +1621,8 @@ pub const Dir = struct {
1620 /// Same as `deleteDir` except the parameter is UTF16LE, NT prefixed.1621 /// Same as `deleteDir` except the parameter is UTF16LE, NT prefixed.
1621 /// This function is Windows-only.1622 /// This function is Windows-only.
1622 pub fn deleteDirW(self: Dir, sub_path_w: []const u16) DeleteDirError!void {1623 pub fn deleteDirW(self: Dir, sub_path_w: []const u16) DeleteDirError!void {
1623 os.unlinkatW(self.fd, sub_path_w, os.AT_REMOVEDIR) catch |err| switch (err) {1624 os.unlinkatW(self.fd, sub_path_w, os.AT.REMOVEDIR) catch |err| switch (err) {
1624 error.IsDir => unreachable, // not possible since we pass AT_REMOVEDIR1625 error.IsDir => unreachable, // not possible since we pass AT.REMOVEDIR
1625 else => |e| return e,1626 else => |e| return e,
1626 };1627 };
1627 }1628 }
lib/std/fs/file.zig+8-8
...@@ -883,9 +883,9 @@ pub const File = struct {...@@ -883,9 +883,9 @@ pub const File = struct {
883 };883 };
884 } else {884 } else {
885 return os.flock(file.handle, switch (l) {885 return os.flock(file.handle, switch (l) {
886 .None => os.LOCK_UN,886 .None => os.LOCK.UN,
887 .Shared => os.LOCK_SH,887 .Shared => os.LOCK.SH,
888 .Exclusive => os.LOCK_EX,888 .Exclusive => os.LOCK.EX,
889 }) catch |err| switch (err) {889 }) catch |err| switch (err) {
890 error.WouldBlock => unreachable, // non-blocking=false890 error.WouldBlock => unreachable, // non-blocking=false
891 else => |e| return e,891 else => |e| return e,
...@@ -908,7 +908,7 @@ pub const File = struct {...@@ -908,7 +908,7 @@ pub const File = struct {
908 error.Unexpected => unreachable, // Resource deallocation must succeed.908 error.Unexpected => unreachable, // Resource deallocation must succeed.
909 };909 };
910 } else {910 } else {
911 return os.flock(file.handle, os.LOCK_UN) catch |err| switch (err) {911 return os.flock(file.handle, os.LOCK.UN) catch |err| switch (err) {
912 error.WouldBlock => unreachable, // unlocking can't block912 error.WouldBlock => unreachable, // unlocking can't block
913 error.SystemResources => unreachable, // We are deallocating resources.913 error.SystemResources => unreachable, // We are deallocating resources.
914 error.Unexpected => unreachable, // Resource deallocation must succeed.914 error.Unexpected => unreachable, // Resource deallocation must succeed.
...@@ -949,9 +949,9 @@ pub const File = struct {...@@ -949,9 +949,9 @@ pub const File = struct {
949 };949 };
950 } else {950 } else {
951 os.flock(file.handle, switch (l) {951 os.flock(file.handle, switch (l) {
952 .None => os.LOCK_UN,952 .None => os.LOCK.UN,
953 .Shared => os.LOCK_SH | os.LOCK_NB,953 .Shared => os.LOCK.SH | os.LOCK.NB,
954 .Exclusive => os.LOCK_EX | os.LOCK_NB,954 .Exclusive => os.LOCK.EX | os.LOCK.NB,
955 }) catch |err| switch (err) {955 }) catch |err| switch (err) {
956 error.WouldBlock => return false,956 error.WouldBlock => return false,
957 else => |e| return e,957 else => |e| return e,
...@@ -998,7 +998,7 @@ pub const File = struct {...@@ -998,7 +998,7 @@ pub const File = struct {
998 error.Unexpected => unreachable, // Resource deallocation must succeed.998 error.Unexpected => unreachable, // Resource deallocation must succeed.
999 };999 };
1000 } else {1000 } else {
1001 return os.flock(file.handle, os.LOCK_SH | os.LOCK_NB) catch |err| switch (err) {1001 return os.flock(file.handle, os.LOCK.SH | os.LOCK.NB) catch |err| switch (err) {
1002 error.WouldBlock => unreachable, // File was not locked in exclusive mode.1002 error.WouldBlock => unreachable, // File was not locked in exclusive mode.
1003 else => |e| return e,1003 else => |e| return e,
1004 };1004 };
lib/std/net.zig+97-97
...@@ -10,7 +10,7 @@ const native_endian = builtin.target.cpu.arch.endian();...@@ -10,7 +10,7 @@ const native_endian = builtin.target.cpu.arch.endian();
1010
11// Windows 10 added support for unix sockets in build 17063, redstone 4 is the11// Windows 10 added support for unix sockets in build 17063, redstone 4 is the
12// first release to support them.12// first release to support them.
13pub const has_unix_sockets = @hasDecl(os, "sockaddr_un") and13pub const has_unix_sockets = @hasDecl(os.sockaddr, "un") and
14 (builtin.target.os.tag != .windows or14 (builtin.target.os.tag != .windows or
15 std.Target.current.os.version_range.windows.isAtLeast(.win10_rs4) orelse false);15 std.Target.current.os.version_range.windows.isAtLeast(.win10_rs4) orelse false);
1616
...@@ -18,7 +18,7 @@ pub const Address = extern union {...@@ -18,7 +18,7 @@ pub const Address = extern union {
18 any: os.sockaddr,18 any: os.sockaddr,
19 in: Ip4Address,19 in: Ip4Address,
20 in6: Ip6Address,20 in6: Ip6Address,
21 un: if (has_unix_sockets) os.sockaddr_un else void,21 un: if (has_unix_sockets) os.sockaddr.un else void,
2222
23 /// Parse the given IP address string into an Address value.23 /// Parse the given IP address string into an Address value.
24 /// It is recommended to use `resolveIp` instead, to handle24 /// It is recommended to use `resolveIp` instead, to handle
...@@ -70,9 +70,9 @@ pub const Address = extern union {...@@ -70,9 +70,9 @@ pub const Address = extern union {
7070
71 pub fn parseExpectingFamily(name: []const u8, family: os.sa_family_t, port: u16) !Address {71 pub fn parseExpectingFamily(name: []const u8, family: os.sa_family_t, port: u16) !Address {
72 switch (family) {72 switch (family) {
73 os.AF_INET => return parseIp4(name, port),73 os.AF.INET => return parseIp4(name, port),
74 os.AF_INET6 => return parseIp6(name, port),74 os.AF.INET6 => return parseIp6(name, port),
75 os.AF_UNSPEC => return parseIp(name, port),75 os.AF.UNSPEC => return parseIp(name, port),
76 else => unreachable,76 else => unreachable,
77 }77 }
78 }78 }
...@@ -98,8 +98,8 @@ pub const Address = extern union {...@@ -98,8 +98,8 @@ pub const Address = extern union {
98 }98 }
9999
100 pub fn initUnix(path: []const u8) !Address {100 pub fn initUnix(path: []const u8) !Address {
101 var sock_addr = os.sockaddr_un{101 var sock_addr = os.sockaddr.un{
102 .family = os.AF_UNIX,102 .family = os.AF.UNIX,
103 .path = undefined,103 .path = undefined,
104 };104 };
105105
...@@ -116,8 +116,8 @@ pub const Address = extern union {...@@ -116,8 +116,8 @@ pub const Address = extern union {
116 /// Asserts that the address is ip4 or ip6.116 /// Asserts that the address is ip4 or ip6.
117 pub fn getPort(self: Address) u16 {117 pub fn getPort(self: Address) u16 {
118 return switch (self.any.family) {118 return switch (self.any.family) {
119 os.AF_INET => self.in.getPort(),119 os.AF.INET => self.in.getPort(),
120 os.AF_INET6 => self.in6.getPort(),120 os.AF.INET6 => self.in6.getPort(),
121 else => unreachable,121 else => unreachable,
122 };122 };
123 }123 }
...@@ -126,8 +126,8 @@ pub const Address = extern union {...@@ -126,8 +126,8 @@ pub const Address = extern union {
126 /// Asserts that the address is ip4 or ip6.126 /// Asserts that the address is ip4 or ip6.
127 pub fn setPort(self: *Address, port: u16) void {127 pub fn setPort(self: *Address, port: u16) void {
128 switch (self.any.family) {128 switch (self.any.family) {
129 os.AF_INET => self.in.setPort(port),129 os.AF.INET => self.in.setPort(port),
130 os.AF_INET6 => self.in6.setPort(port),130 os.AF.INET6 => self.in6.setPort(port),
131 else => unreachable,131 else => unreachable,
132 }132 }
133 }133 }
...@@ -137,8 +137,8 @@ pub const Address = extern union {...@@ -137,8 +137,8 @@ pub const Address = extern union {
137 /// on the address family.137 /// on the address family.
138 pub fn initPosix(addr: *align(4) const os.sockaddr) Address {138 pub fn initPosix(addr: *align(4) const os.sockaddr) Address {
139 switch (addr.family) {139 switch (addr.family) {
140 os.AF_INET => return Address{ .in = Ip4Address{ .sa = @ptrCast(*const os.sockaddr_in, addr).* } },140 os.AF.INET => return Address{ .in = Ip4Address{ .sa = @ptrCast(*const os.sockaddr.in, addr).* } },
141 os.AF_INET6 => return Address{ .in6 = Ip6Address{ .sa = @ptrCast(*const os.sockaddr_in6, addr).* } },141 os.AF.INET6 => return Address{ .in6 = Ip6Address{ .sa = @ptrCast(*const os.sockaddr.in6, addr).* } },
142 else => unreachable,142 else => unreachable,
143 }143 }
144 }144 }
...@@ -150,9 +150,9 @@ pub const Address = extern union {...@@ -150,9 +150,9 @@ pub const Address = extern union {
150 out_stream: anytype,150 out_stream: anytype,
151 ) !void {151 ) !void {
152 switch (self.any.family) {152 switch (self.any.family) {
153 os.AF_INET => try self.in.format(fmt, options, out_stream),153 os.AF.INET => try self.in.format(fmt, options, out_stream),
154 os.AF_INET6 => try self.in6.format(fmt, options, out_stream),154 os.AF.INET6 => try self.in6.format(fmt, options, out_stream),
155 os.AF_UNIX => {155 os.AF.UNIX => {
156 if (!has_unix_sockets) {156 if (!has_unix_sockets) {
157 unreachable;157 unreachable;
158 }158 }
...@@ -171,15 +171,15 @@ pub const Address = extern union {...@@ -171,15 +171,15 @@ pub const Address = extern union {
171171
172 pub fn getOsSockLen(self: Address) os.socklen_t {172 pub fn getOsSockLen(self: Address) os.socklen_t {
173 switch (self.any.family) {173 switch (self.any.family) {
174 os.AF_INET => return self.in.getOsSockLen(),174 os.AF.INET => return self.in.getOsSockLen(),
175 os.AF_INET6 => return self.in6.getOsSockLen(),175 os.AF.INET6 => return self.in6.getOsSockLen(),
176 os.AF_UNIX => {176 os.AF.UNIX => {
177 if (!has_unix_sockets) {177 if (!has_unix_sockets) {
178 unreachable;178 unreachable;
179 }179 }
180180
181 const path_len = std.mem.len(std.meta.assumeSentinel(&self.un.path, 0));181 const path_len = std.mem.len(std.meta.assumeSentinel(&self.un.path, 0));
182 return @intCast(os.socklen_t, @sizeOf(os.sockaddr_un) - self.un.path.len + path_len);182 return @intCast(os.socklen_t, @sizeOf(os.sockaddr.un) - self.un.path.len + path_len);
183 },183 },
184 else => unreachable,184 else => unreachable,
185 }185 }
...@@ -187,7 +187,7 @@ pub const Address = extern union {...@@ -187,7 +187,7 @@ pub const Address = extern union {
187};187};
188188
189pub const Ip4Address = extern struct {189pub const Ip4Address = extern struct {
190 sa: os.sockaddr_in,190 sa: os.sockaddr.in,
191191
192 pub fn parse(buf: []const u8, port: u16) !Ip4Address {192 pub fn parse(buf: []const u8, port: u16) !Ip4Address {
193 var result = Ip4Address{193 var result = Ip4Address{
...@@ -249,7 +249,7 @@ pub const Ip4Address = extern struct {...@@ -249,7 +249,7 @@ pub const Ip4Address = extern struct {
249249
250 pub fn init(addr: [4]u8, port: u16) Ip4Address {250 pub fn init(addr: [4]u8, port: u16) Ip4Address {
251 return Ip4Address{251 return Ip4Address{
252 .sa = os.sockaddr_in{252 .sa = os.sockaddr.in{
253 .port = mem.nativeToBig(u16, port),253 .port = mem.nativeToBig(u16, port),
254 .addr = @ptrCast(*align(1) const u32, &addr).*,254 .addr = @ptrCast(*align(1) const u32, &addr).*,
255 },255 },
...@@ -288,19 +288,19 @@ pub const Ip4Address = extern struct {...@@ -288,19 +288,19 @@ pub const Ip4Address = extern struct {
288288
289 pub fn getOsSockLen(self: Ip4Address) os.socklen_t {289 pub fn getOsSockLen(self: Ip4Address) os.socklen_t {
290 _ = self;290 _ = self;
291 return @sizeOf(os.sockaddr_in);291 return @sizeOf(os.sockaddr.in);
292 }292 }
293};293};
294294
295pub const Ip6Address = extern struct {295pub const Ip6Address = extern struct {
296 sa: os.sockaddr_in6,296 sa: os.sockaddr.in6,
297297
298 /// Parse a given IPv6 address string into an Address.298 /// Parse a given IPv6 address string into an Address.
299 /// Assumes the Scope ID of the address is fully numeric.299 /// Assumes the Scope ID of the address is fully numeric.
300 /// For non-numeric addresses, see `resolveIp6`.300 /// For non-numeric addresses, see `resolveIp6`.
301 pub fn parse(buf: []const u8, port: u16) !Ip6Address {301 pub fn parse(buf: []const u8, port: u16) !Ip6Address {
302 var result = Ip6Address{302 var result = Ip6Address{
303 .sa = os.sockaddr_in6{303 .sa = os.sockaddr.in6{
304 .scope_id = 0,304 .scope_id = 0,
305 .port = mem.nativeToBig(u16, port),305 .port = mem.nativeToBig(u16, port),
306 .flowinfo = 0,306 .flowinfo = 0,
...@@ -407,7 +407,7 @@ pub const Ip6Address = extern struct {...@@ -407,7 +407,7 @@ pub const Ip6Address = extern struct {
407 pub fn resolve(buf: []const u8, port: u16) !Ip6Address {407 pub fn resolve(buf: []const u8, port: u16) !Ip6Address {
408 // TODO: Unify the implementations of resolveIp6 and parseIp6.408 // TODO: Unify the implementations of resolveIp6 and parseIp6.
409 var result = Ip6Address{409 var result = Ip6Address{
410 .sa = os.sockaddr_in6{410 .sa = os.sockaddr.in6{
411 .scope_id = 0,411 .scope_id = 0,
412 .port = mem.nativeToBig(u16, port),412 .port = mem.nativeToBig(u16, port),
413 .flowinfo = 0,413 .flowinfo = 0,
...@@ -536,7 +536,7 @@ pub const Ip6Address = extern struct {...@@ -536,7 +536,7 @@ pub const Ip6Address = extern struct {
536536
537 pub fn init(addr: [16]u8, port: u16, flowinfo: u32, scope_id: u32) Ip6Address {537 pub fn init(addr: [16]u8, port: u16, flowinfo: u32, scope_id: u32) Ip6Address {
538 return Ip6Address{538 return Ip6Address{
539 .sa = os.sockaddr_in6{539 .sa = os.sockaddr.in6{
540 .addr = addr,540 .addr = addr,
541 .port = mem.nativeToBig(u16, port),541 .port = mem.nativeToBig(u16, port),
542 .flowinfo = flowinfo,542 .flowinfo = flowinfo,
...@@ -608,15 +608,15 @@ pub const Ip6Address = extern struct {...@@ -608,15 +608,15 @@ pub const Ip6Address = extern struct {
608608
609 pub fn getOsSockLen(self: Ip6Address) os.socklen_t {609 pub fn getOsSockLen(self: Ip6Address) os.socklen_t {
610 _ = self;610 _ = self;
611 return @sizeOf(os.sockaddr_in6);611 return @sizeOf(os.sockaddr.in6);
612 }612 }
613};613};
614614
615pub fn connectUnixSocket(path: []const u8) !Stream {615pub fn connectUnixSocket(path: []const u8) !Stream {
616 const opt_non_block = if (std.io.is_async) os.SOCK_NONBLOCK else 0;616 const opt_non_block = if (std.io.is_async) os.SOCK.NONBLOCK else 0;
617 const sockfd = try os.socket(617 const sockfd = try os.socket(
618 os.AF_UNIX,618 os.AF.UNIX,
619 os.SOCK_STREAM | os.SOCK_CLOEXEC | opt_non_block,619 os.SOCK.STREAM | os.SOCK.CLOEXEC | opt_non_block,
620 0,620 0,
621 );621 );
622 errdefer os.closeSocket(sockfd);622 errdefer os.closeSocket(sockfd);
...@@ -637,7 +637,7 @@ pub fn connectUnixSocket(path: []const u8) !Stream {...@@ -637,7 +637,7 @@ pub fn connectUnixSocket(path: []const u8) !Stream {
637637
638fn if_nametoindex(name: []const u8) !u32 {638fn if_nametoindex(name: []const u8) !u32 {
639 var ifr: os.ifreq = undefined;639 var ifr: os.ifreq = undefined;
640 var sockfd = try os.socket(os.AF_UNIX, os.SOCK_DGRAM | os.SOCK_CLOEXEC, 0);640 var sockfd = try os.socket(os.AF.UNIX, os.SOCK.DGRAM | os.SOCK.CLOEXEC, 0);
641 defer os.closeSocket(sockfd);641 defer os.closeSocket(sockfd);
642642
643 std.mem.copy(u8, &ifr.ifrn.name, name);643 std.mem.copy(u8, &ifr.ifrn.name, name);
...@@ -682,10 +682,10 @@ pub fn tcpConnectToHost(allocator: *mem.Allocator, name: []const u8, port: u16)...@@ -682,10 +682,10 @@ pub fn tcpConnectToHost(allocator: *mem.Allocator, name: []const u8, port: u16)
682}682}
683683
684pub fn tcpConnectToAddress(address: Address) !Stream {684pub fn tcpConnectToAddress(address: Address) !Stream {
685 const nonblock = if (std.io.is_async) os.SOCK_NONBLOCK else 0;685 const nonblock = if (std.io.is_async) os.SOCK.NONBLOCK else 0;
686 const sock_flags = os.SOCK_STREAM | nonblock |686 const sock_flags = os.SOCK.STREAM | nonblock |
687 (if (builtin.target.os.tag == .windows) 0 else os.SOCK_CLOEXEC);687 (if (builtin.target.os.tag == .windows) 0 else os.SOCK.CLOEXEC);
688 const sockfd = try os.socket(address.any.family, sock_flags, os.IPPROTO_TCP);688 const sockfd = try os.socket(address.any.family, sock_flags, os.IPPROTO.TCP);
689 errdefer os.closeSocket(sockfd);689 errdefer os.closeSocket(sockfd);
690690
691 if (std.io.is_async) {691 if (std.io.is_async) {
...@@ -724,10 +724,10 @@ pub fn getAddressList(allocator: *mem.Allocator, name: []const u8, port: u16) !*...@@ -724,10 +724,10 @@ pub fn getAddressList(allocator: *mem.Allocator, name: []const u8, port: u16) !*
724724
725 const sys = if (builtin.target.os.tag == .windows) os.windows.ws2_32 else os.system;725 const sys = if (builtin.target.os.tag == .windows) os.windows.ws2_32 else os.system;
726 const hints = os.addrinfo{726 const hints = os.addrinfo{
727 .flags = sys.AI_NUMERICSERV,727 .flags = sys.AI.NUMERICSERV,
728 .family = os.AF_UNSPEC,728 .family = os.AF.UNSPEC,
729 .socktype = os.SOCK_STREAM,729 .socktype = os.SOCK.STREAM,
730 .protocol = os.IPPROTO_TCP,730 .protocol = os.IPPROTO.TCP,
731 .canonname = null,731 .canonname = null,
732 .addr = null,732 .addr = null,
733 .addrlen = 0,733 .addrlen = 0,
...@@ -794,8 +794,8 @@ pub fn getAddressList(allocator: *mem.Allocator, name: []const u8, port: u16) !*...@@ -794,8 +794,8 @@ pub fn getAddressList(allocator: *mem.Allocator, name: []const u8, port: u16) !*
794 return result;794 return result;
795 }795 }
796 if (builtin.target.os.tag == .linux) {796 if (builtin.target.os.tag == .linux) {
797 const flags = std.c.AI_NUMERICSERV;797 const flags = std.c.AI.NUMERICSERV;
798 const family = os.AF_UNSPEC;798 const family = os.AF.UNSPEC;
799 var lookup_addrs = std.ArrayList(LookupAddr).init(allocator);799 var lookup_addrs = std.ArrayList(LookupAddr).init(allocator);
800 defer lookup_addrs.deinit();800 defer lookup_addrs.deinit();
801801
...@@ -846,7 +846,7 @@ fn linuxLookupName(...@@ -846,7 +846,7 @@ fn linuxLookupName(
846 try canon.appendSlice(name);846 try canon.appendSlice(name);
847 if (Address.parseExpectingFamily(name, family, port)) |addr| {847 if (Address.parseExpectingFamily(name, family, port)) |addr| {
848 try addrs.append(LookupAddr{ .addr = addr });848 try addrs.append(LookupAddr{ .addr = addr });
849 } else |name_err| if ((flags & std.c.AI_NUMERICHOST) != 0) {849 } else |name_err| if ((flags & std.c.AI.NUMERICHOST) != 0) {
850 return name_err;850 return name_err;
851 } else {851 } else {
852 try linuxLookupNameFromHosts(addrs, canon, name, family, port);852 try linuxLookupNameFromHosts(addrs, canon, name, family, port);
...@@ -876,9 +876,9 @@ fn linuxLookupName(...@@ -876,9 +876,9 @@ fn linuxLookupName(
876876
877 // No further processing is needed if there are fewer than 2877 // No further processing is needed if there are fewer than 2
878 // results or if there are only IPv4 results.878 // results or if there are only IPv4 results.
879 if (addrs.items.len == 1 or family == os.AF_INET) return;879 if (addrs.items.len == 1 or family == os.AF.INET) return;
880 const all_ip4 = for (addrs.items) |addr| {880 const all_ip4 = for (addrs.items) |addr| {
881 if (addr.addr.any.family != os.AF_INET) break false;881 if (addr.addr.any.family != os.AF.INET) break false;
882 } else true;882 } else true;
883 if (all_ip4) return;883 if (all_ip4) return;
884884
...@@ -891,19 +891,19 @@ fn linuxLookupName(...@@ -891,19 +891,19 @@ fn linuxLookupName(
891 // A more idiomatic "ziggy" implementation would be welcome.891 // A more idiomatic "ziggy" implementation would be welcome.
892 for (addrs.items) |*addr, i| {892 for (addrs.items) |*addr, i| {
893 var key: i32 = 0;893 var key: i32 = 0;
894 var sa6: os.sockaddr_in6 = undefined;894 var sa6: os.sockaddr.in6 = undefined;
895 @memset(@ptrCast([*]u8, &sa6), 0, @sizeOf(os.sockaddr_in6));895 @memset(@ptrCast([*]u8, &sa6), 0, @sizeOf(os.sockaddr.in6));
896 var da6 = os.sockaddr_in6{896 var da6 = os.sockaddr.in6{
897 .family = os.AF_INET6,897 .family = os.AF.INET6,
898 .scope_id = addr.addr.in6.sa.scope_id,898 .scope_id = addr.addr.in6.sa.scope_id,
899 .port = 65535,899 .port = 65535,
900 .flowinfo = 0,900 .flowinfo = 0,
901 .addr = [1]u8{0} ** 16,901 .addr = [1]u8{0} ** 16,
902 };902 };
903 var sa4: os.sockaddr_in = undefined;903 var sa4: os.sockaddr.in = undefined;
904 @memset(@ptrCast([*]u8, &sa4), 0, @sizeOf(os.sockaddr_in));904 @memset(@ptrCast([*]u8, &sa4), 0, @sizeOf(os.sockaddr.in));
905 var da4 = os.sockaddr_in{905 var da4 = os.sockaddr.in{
906 .family = os.AF_INET,906 .family = os.AF.INET,
907 .port = 65535,907 .port = 65535,
908 .addr = 0,908 .addr = 0,
909 .zero = [1]u8{0} ** 8,909 .zero = [1]u8{0} ** 8,
...@@ -912,21 +912,21 @@ fn linuxLookupName(...@@ -912,21 +912,21 @@ fn linuxLookupName(
912 var da: *align(4) os.sockaddr = undefined;912 var da: *align(4) os.sockaddr = undefined;
913 var salen: os.socklen_t = undefined;913 var salen: os.socklen_t = undefined;
914 var dalen: os.socklen_t = undefined;914 var dalen: os.socklen_t = undefined;
915 if (addr.addr.any.family == os.AF_INET6) {915 if (addr.addr.any.family == os.AF.INET6) {
916 mem.copy(u8, &da6.addr, &addr.addr.in6.sa.addr);916 mem.copy(u8, &da6.addr, &addr.addr.in6.sa.addr);
917 da = @ptrCast(*os.sockaddr, &da6);917 da = @ptrCast(*os.sockaddr, &da6);
918 dalen = @sizeOf(os.sockaddr_in6);918 dalen = @sizeOf(os.sockaddr.in6);
919 sa = @ptrCast(*os.sockaddr, &sa6);919 sa = @ptrCast(*os.sockaddr, &sa6);
920 salen = @sizeOf(os.sockaddr_in6);920 salen = @sizeOf(os.sockaddr.in6);
921 } else {921 } else {
922 mem.copy(u8, &sa6.addr, "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff");922 mem.copy(u8, &sa6.addr, "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff");
923 mem.copy(u8, &da6.addr, "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff");923 mem.copy(u8, &da6.addr, "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff");
924 mem.writeIntNative(u32, da6.addr[12..], addr.addr.in.sa.addr);924 mem.writeIntNative(u32, da6.addr[12..], addr.addr.in.sa.addr);
925 da4.addr = addr.addr.in.sa.addr;925 da4.addr = addr.addr.in.sa.addr;
926 da = @ptrCast(*os.sockaddr, &da4);926 da = @ptrCast(*os.sockaddr, &da4);
927 dalen = @sizeOf(os.sockaddr_in);927 dalen = @sizeOf(os.sockaddr.in);
928 sa = @ptrCast(*os.sockaddr, &sa4);928 sa = @ptrCast(*os.sockaddr, &sa4);
929 salen = @sizeOf(os.sockaddr_in);929 salen = @sizeOf(os.sockaddr.in);
930 }930 }
931 const dpolicy = policyOf(da6.addr);931 const dpolicy = policyOf(da6.addr);
932 const dscope: i32 = scopeOf(da6.addr);932 const dscope: i32 = scopeOf(da6.addr);
...@@ -934,13 +934,13 @@ fn linuxLookupName(...@@ -934,13 +934,13 @@ fn linuxLookupName(
934 const dprec: i32 = dpolicy.prec;934 const dprec: i32 = dpolicy.prec;
935 const MAXADDRS = 3;935 const MAXADDRS = 3;
936 var prefixlen: i32 = 0;936 var prefixlen: i32 = 0;
937 const sock_flags = os.SOCK_DGRAM | os.SOCK_CLOEXEC;937 const sock_flags = os.SOCK.DGRAM | os.SOCK.CLOEXEC;
938 if (os.socket(addr.addr.any.family, sock_flags, os.IPPROTO_UDP)) |fd| syscalls: {938 if (os.socket(addr.addr.any.family, sock_flags, os.IPPROTO.UDP)) |fd| syscalls: {
939 defer os.closeSocket(fd);939 defer os.closeSocket(fd);
940 os.connect(fd, da, dalen) catch break :syscalls;940 os.connect(fd, da, dalen) catch break :syscalls;
941 key |= DAS_USABLE;941 key |= DAS_USABLE;
942 os.getsockname(fd, sa, &salen) catch break :syscalls;942 os.getsockname(fd, sa, &salen) catch break :syscalls;
943 if (addr.addr.any.family == os.AF_INET) {943 if (addr.addr.any.family == os.AF.INET) {
944 // TODO sa6.addr[12..16] should return *[4]u8, making this cast unnecessary.944 // TODO sa6.addr[12..16] should return *[4]u8, making this cast unnecessary.
945 mem.writeIntNative(u32, @ptrCast(*[4]u8, &sa6.addr[12]), sa4.addr);945 mem.writeIntNative(u32, @ptrCast(*[4]u8, &sa6.addr[12]), sa4.addr);
946 }946 }
...@@ -1082,24 +1082,24 @@ fn linuxLookupNameFromNull(...@@ -1082,24 +1082,24 @@ fn linuxLookupNameFromNull(
1082 flags: u32,1082 flags: u32,
1083 port: u16,1083 port: u16,
1084) !void {1084) !void {
1085 if ((flags & std.c.AI_PASSIVE) != 0) {1085 if ((flags & std.c.AI.PASSIVE) != 0) {
1086 if (family != os.AF_INET6) {1086 if (family != os.AF.INET6) {
1087 (try addrs.addOne()).* = LookupAddr{1087 (try addrs.addOne()).* = LookupAddr{
1088 .addr = Address.initIp4([1]u8{0} ** 4, port),1088 .addr = Address.initIp4([1]u8{0} ** 4, port),
1089 };1089 };
1090 }1090 }
1091 if (family != os.AF_INET) {1091 if (family != os.AF.INET) {
1092 (try addrs.addOne()).* = LookupAddr{1092 (try addrs.addOne()).* = LookupAddr{
1093 .addr = Address.initIp6([1]u8{0} ** 16, port, 0, 0),1093 .addr = Address.initIp6([1]u8{0} ** 16, port, 0, 0),
1094 };1094 };
1095 }1095 }
1096 } else {1096 } else {
1097 if (family != os.AF_INET6) {1097 if (family != os.AF.INET6) {
1098 (try addrs.addOne()).* = LookupAddr{1098 (try addrs.addOne()).* = LookupAddr{
1099 .addr = Address.initIp4([4]u8{ 127, 0, 0, 1 }, port),1099 .addr = Address.initIp4([4]u8{ 127, 0, 0, 1 }, port),
1100 };1100 };
1101 }1101 }
1102 if (family != os.AF_INET) {1102 if (family != os.AF.INET) {
1103 (try addrs.addOne()).* = LookupAddr{1103 (try addrs.addOne()).* = LookupAddr{
1104 .addr = Address.initIp6(([1]u8{0} ** 15) ++ [1]u8{1}, port, 0, 0),1104 .addr = Address.initIp6(([1]u8{0} ** 15) ++ [1]u8{1}, port, 0, 0),
1105 };1105 };
...@@ -1252,8 +1252,8 @@ fn linuxLookupNameFromDns(...@@ -1252,8 +1252,8 @@ fn linuxLookupNameFromDns(
1252 rr: u8,1252 rr: u8,
1253 };1253 };
1254 const afrrs = [_]AfRr{1254 const afrrs = [_]AfRr{
1255 AfRr{ .af = os.AF_INET6, .rr = os.RR_A },1255 AfRr{ .af = os.AF.INET6, .rr = os.RR.A },
1256 AfRr{ .af = os.AF_INET, .rr = os.RR_AAAA },1256 AfRr{ .af = os.AF.INET, .rr = os.RR.AAAA },
1257 };1257 };
1258 var qbuf: [2][280]u8 = undefined;1258 var qbuf: [2][280]u8 = undefined;
1259 var abuf: [2][512]u8 = undefined;1259 var abuf: [2][512]u8 = undefined;
...@@ -1386,8 +1386,8 @@ fn resMSendRc(...@@ -1386,8 +1386,8 @@ fn resMSendRc(
1386 const timeout = 1000 * rc.timeout;1386 const timeout = 1000 * rc.timeout;
1387 const attempts = rc.attempts;1387 const attempts = rc.attempts;
13881388
1389 var sl: os.socklen_t = @sizeOf(os.sockaddr_in);1389 var sl: os.socklen_t = @sizeOf(os.sockaddr.in);
1390 var family: os.sa_family_t = os.AF_INET;1390 var family: os.sa_family_t = os.AF.INET;
13911391
1392 var ns_list = std.ArrayList(Address).init(rc.ns.allocator);1392 var ns_list = std.ArrayList(Address).init(rc.ns.allocator);
1393 defer ns_list.deinit();1393 defer ns_list.deinit();
...@@ -1398,9 +1398,9 @@ fn resMSendRc(...@@ -1398,9 +1398,9 @@ fn resMSendRc(
1398 for (rc.ns.items) |iplit, i| {1398 for (rc.ns.items) |iplit, i| {
1399 ns[i] = iplit.addr;1399 ns[i] = iplit.addr;
1400 assert(ns[i].getPort() == 53);1400 assert(ns[i].getPort() == 53);
1401 if (iplit.addr.any.family != os.AF_INET) {1401 if (iplit.addr.any.family != os.AF.INET) {
1402 sl = @sizeOf(os.sockaddr_in6);1402 sl = @sizeOf(os.sockaddr.in6);
1403 family = os.AF_INET6;1403 family = os.AF.INET6;
1404 }1404 }
1405 }1405 }
14061406
...@@ -1408,13 +1408,13 @@ fn resMSendRc(...@@ -1408,13 +1408,13 @@ fn resMSendRc(
1408 var sa: Address = undefined;1408 var sa: Address = undefined;
1409 @memset(@ptrCast([*]u8, &sa), 0, @sizeOf(Address));1409 @memset(@ptrCast([*]u8, &sa), 0, @sizeOf(Address));
1410 sa.any.family = family;1410 sa.any.family = family;
1411 const flags = os.SOCK_DGRAM | os.SOCK_CLOEXEC | os.SOCK_NONBLOCK;1411 const flags = os.SOCK.DGRAM | os.SOCK.CLOEXEC | os.SOCK.NONBLOCK;
1412 const fd = os.socket(family, flags, 0) catch |err| switch (err) {1412 const fd = os.socket(family, flags, 0) catch |err| switch (err) {
1413 error.AddressFamilyNotSupported => blk: {1413 error.AddressFamilyNotSupported => blk: {
1414 // Handle case where system lacks IPv6 support1414 // Handle case where system lacks IPv6 support
1415 if (family == os.AF_INET6) {1415 if (family == os.AF.INET6) {
1416 family = os.AF_INET;1416 family = os.AF.INET;
1417 break :blk try os.socket(os.AF_INET, flags, 0);1417 break :blk try os.socket(os.AF.INET, flags, 0);
1418 }1418 }
1419 return err;1419 return err;
1420 },1420 },
...@@ -1429,15 +1429,15 @@ fn resMSendRc(...@@ -1429,15 +1429,15 @@ fn resMSendRc(
14291429
1430 // Convert any IPv4 addresses in a mixed environment to v4-mapped1430 // Convert any IPv4 addresses in a mixed environment to v4-mapped
1431 // TODO1431 // TODO
1432 //if (family == AF_INET6) {1432 //if (family == AF.INET6) {
1433 // setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &(int){0}, sizeof 0);1433 // setsockopt(fd, IPPROTO.IPV6, IPV6_V6ONLY, &(int){0}, sizeof 0);
1434 // for (i=0; i<nns; i++) {1434 // for (i=0; i<nns; i++) {
1435 // if (ns[i].sin.sin_family != AF_INET) continue;1435 // if (ns[i].sin.sin_family != AF.INET) continue;
1436 // memcpy(ns[i].sin6.sin6_addr.s6_addr+12,1436 // memcpy(ns[i].sin6.sin6_addr.s6_addr+12,
1437 // &ns[i].sin.sin_addr, 4);1437 // &ns[i].sin.sin_addr, 4);
1438 // memcpy(ns[i].sin6.sin6_addr.s6_addr,1438 // memcpy(ns[i].sin6.sin6_addr.s6_addr,
1439 // "\0\0\0\0\0\0\0\0\0\0\xff\xff", 12);1439 // "\0\0\0\0\0\0\0\0\0\0\xff\xff", 12);
1440 // ns[i].sin6.sin6_family = AF_INET6;1440 // ns[i].sin6.sin6_family = AF.INET6;
1441 // ns[i].sin6.sin6_flowinfo = 0;1441 // ns[i].sin6.sin6_flowinfo = 0;
1442 // ns[i].sin6.sin6_scope_id = 0;1442 // ns[i].sin6.sin6_scope_id = 0;
1443 // }1443 // }
...@@ -1445,7 +1445,7 @@ fn resMSendRc(...@@ -1445,7 +1445,7 @@ fn resMSendRc(
14451445
1446 var pfd = [1]os.pollfd{os.pollfd{1446 var pfd = [1]os.pollfd{os.pollfd{
1447 .fd = fd,1447 .fd = fd,
1448 .events = os.POLLIN,1448 .events = os.POLL.IN,
1449 .revents = undefined,1449 .revents = undefined,
1450 }};1450 }};
1451 const retry_interval = timeout / attempts;1451 const retry_interval = timeout / attempts;
...@@ -1465,9 +1465,9 @@ fn resMSendRc(...@@ -1465,9 +1465,9 @@ fn resMSendRc(
1465 var j: usize = 0;1465 var j: usize = 0;
1466 while (j < ns.len) : (j += 1) {1466 while (j < ns.len) : (j += 1) {
1467 if (std.io.is_async) {1467 if (std.io.is_async) {
1468 _ = std.event.Loop.instance.?.sendto(fd, queries[i], os.MSG_NOSIGNAL, &ns[j].any, sl) catch undefined;1468 _ = std.event.Loop.instance.?.sendto(fd, queries[i], os.MSG.NOSIGNAL, &ns[j].any, sl) catch undefined;
1469 } else {1469 } else {
1470 _ = os.sendto(fd, queries[i], os.MSG_NOSIGNAL, &ns[j].any, sl) catch undefined;1470 _ = os.sendto(fd, queries[i], os.MSG.NOSIGNAL, &ns[j].any, sl) catch undefined;
1471 }1471 }
1472 }1472 }
1473 }1473 }
...@@ -1513,9 +1513,9 @@ fn resMSendRc(...@@ -1513,9 +1513,9 @@ fn resMSendRc(
1513 2 => if (servfail_retry != 0) {1513 2 => if (servfail_retry != 0) {
1514 servfail_retry -= 1;1514 servfail_retry -= 1;
1515 if (std.io.is_async) {1515 if (std.io.is_async) {
1516 _ = std.event.Loop.instance.?.sendto(fd, queries[i], os.MSG_NOSIGNAL, &ns[j].any, sl) catch undefined;1516 _ = std.event.Loop.instance.?.sendto(fd, queries[i], os.MSG.NOSIGNAL, &ns[j].any, sl) catch undefined;
1517 } else {1517 } else {
1518 _ = os.sendto(fd, queries[i], os.MSG_NOSIGNAL, &ns[j].any, sl) catch undefined;1518 _ = os.sendto(fd, queries[i], os.MSG.NOSIGNAL, &ns[j].any, sl) catch undefined;
1519 }1519 }
1520 },1520 },
1521 else => continue,1521 else => continue,
...@@ -1570,21 +1570,21 @@ fn dnsParse(...@@ -1570,21 +1570,21 @@ fn dnsParse(
15701570
1571fn dnsParseCallback(ctx: dpc_ctx, rr: u8, data: []const u8, packet: []const u8) !void {1571fn dnsParseCallback(ctx: dpc_ctx, rr: u8, data: []const u8, packet: []const u8) !void {
1572 switch (rr) {1572 switch (rr) {
1573 os.RR_A => {1573 os.RR.A => {
1574 if (data.len != 4) return error.InvalidDnsARecord;1574 if (data.len != 4) return error.InvalidDnsARecord;
1575 const new_addr = try ctx.addrs.addOne();1575 const new_addr = try ctx.addrs.addOne();
1576 new_addr.* = LookupAddr{1576 new_addr.* = LookupAddr{
1577 .addr = Address.initIp4(data[0..4].*, ctx.port),1577 .addr = Address.initIp4(data[0..4].*, ctx.port),
1578 };1578 };
1579 },1579 },
1580 os.RR_AAAA => {1580 os.RR.AAAA => {
1581 if (data.len != 16) return error.InvalidDnsAAAARecord;1581 if (data.len != 16) return error.InvalidDnsAAAARecord;
1582 const new_addr = try ctx.addrs.addOne();1582 const new_addr = try ctx.addrs.addOne();
1583 new_addr.* = LookupAddr{1583 new_addr.* = LookupAddr{
1584 .addr = Address.initIp6(data[0..16].*, ctx.port, 0, 0),1584 .addr = Address.initIp6(data[0..16].*, ctx.port, 0, 0),
1585 };1585 };
1586 },1586 },
1587 os.RR_CNAME => {1587 os.RR.CNAME => {
1588 var tmp: [256]u8 = undefined;1588 var tmp: [256]u8 = undefined;
1589 // Returns len of compressed name. strlen to get canon name.1589 // Returns len of compressed name. strlen to get canon name.
1590 _ = try os.dn_expand(packet, data, &tmp);1590 _ = try os.dn_expand(packet, data, &tmp);
...@@ -1700,7 +1700,7 @@ pub const StreamServer = struct {...@@ -1700,7 +1700,7 @@ pub const StreamServer = struct {
1700 /// seeing "Connection refused".1700 /// seeing "Connection refused".
1701 kernel_backlog: u31 = 128,1701 kernel_backlog: u31 = 128,
17021702
1703 /// Enable SO_REUSEADDR on the socket.1703 /// Enable SO.REUSEADDR on the socket.
1704 reuse_address: bool = false,1704 reuse_address: bool = false,
1705 };1705 };
17061706
...@@ -1722,9 +1722,9 @@ pub const StreamServer = struct {...@@ -1722,9 +1722,9 @@ pub const StreamServer = struct {
1722 }1722 }
17231723
1724 pub fn listen(self: *StreamServer, address: Address) !void {1724 pub fn listen(self: *StreamServer, address: Address) !void {
1725 const nonblock = if (std.io.is_async) os.SOCK_NONBLOCK else 0;1725 const nonblock = if (std.io.is_async) os.SOCK.NONBLOCK else 0;
1726 const sock_flags = os.SOCK_STREAM | os.SOCK_CLOEXEC | nonblock;1726 const sock_flags = os.SOCK.STREAM | os.SOCK.CLOEXEC | nonblock;
1727 const proto = if (address.any.family == os.AF_UNIX) @as(u32, 0) else os.IPPROTO_TCP;1727 const proto = if (address.any.family == os.AF.UNIX) @as(u32, 0) else os.IPPROTO.TCP;
17281728
1729 const sockfd = try os.socket(address.any.family, sock_flags, proto);1729 const sockfd = try os.socket(address.any.family, sock_flags, proto);
1730 self.sockfd = sockfd;1730 self.sockfd = sockfd;
...@@ -1736,8 +1736,8 @@ pub const StreamServer = struct {...@@ -1736,8 +1736,8 @@ pub const StreamServer = struct {
1736 if (self.reuse_address) {1736 if (self.reuse_address) {
1737 try os.setsockopt(1737 try os.setsockopt(
1738 sockfd,1738 sockfd,
1739 os.SOL_SOCKET,1739 os.SOL.SOCKET,
1740 os.SO_REUSEADDR,1740 os.SO.REUSEADDR,
1741 &mem.toBytes(@as(c_int, 1)),1741 &mem.toBytes(@as(c_int, 1)),
1742 );1742 );
1743 }1743 }
...@@ -1801,9 +1801,9 @@ pub const StreamServer = struct {...@@ -1801,9 +1801,9 @@ pub const StreamServer = struct {
1801 const accept_result = blk: {1801 const accept_result = blk: {
1802 if (std.io.is_async) {1802 if (std.io.is_async) {
1803 const loop = std.event.Loop.instance orelse return error.UnexpectedError;1803 const loop = std.event.Loop.instance orelse return error.UnexpectedError;
1804 break :blk loop.accept(self.sockfd.?, &accepted_addr.any, &adr_len, os.SOCK_CLOEXEC);1804 break :blk loop.accept(self.sockfd.?, &accepted_addr.any, &adr_len, os.SOCK.CLOEXEC);
1805 } else {1805 } else {
1806 break :blk os.accept(self.sockfd.?, &accepted_addr.any, &adr_len, os.SOCK_CLOEXEC);1806 break :blk os.accept(self.sockfd.?, &accepted_addr.any, &adr_len, os.SOCK.CLOEXEC);
1807 }1807 }
1808 };1808 };
18091809
lib/std/os.zig+96-62
...@@ -62,27 +62,48 @@ else switch (builtin.os.tag) {...@@ -62,27 +62,48 @@ else switch (builtin.os.tag) {
62 .uefi => uefi,62 .uefi => uefi,
63 else => struct {},63 else => struct {},
64};64};
65
66pub const AF = system.AF;
65pub const ARCH = system.ARCH;67pub const ARCH = system.ARCH;
66pub const AT = system.AT;68pub const AT = system.AT;
67pub const CLOCK = system.CLOCK;69pub const CLOCK = system.CLOCK;
70pub const CPU_COUNT = system.CPU_COUNT;
68pub const E = system.E;71pub const E = system.E;
69pub const Elf_Symndx = system.Elf_Symndx;72pub const Elf_Symndx = system.Elf_Symndx;
70pub const F = system.F;73pub const F = system.F;
74pub const FD_CLOEXEC = system.FD_CLOEXEC;
75pub const F_OK = system.F_OK;
71pub const Flock = system.Flock;76pub const Flock = system.Flock;
77pub const HOST_NAME_MAX = system.HOST_NAME_MAX;
78pub const IFNAMESIZE = system.IFNAMESIZE;
72pub const IOV_MAX = system.IOV_MAX;79pub const IOV_MAX = system.IOV_MAX;
80pub const IPPROTO = system.IPPROTO;
73pub const LOCK = system.LOCK;81pub const LOCK = system.LOCK;
82pub const MADV = system.MADV;
74pub const MAP = system.MAP;83pub const MAP = system.MAP;
75pub const MAX_ADDR_LEN = system.MAX_ADDR_LEN;84pub const MAX_ADDR_LEN = system.MAX_ADDR_LEN;
76pub const MMAP2_UNIT = system.MMAP2_UNIT;85pub const MMAP2_UNIT = system.MMAP2_UNIT;
86pub const MSG = system.MSG;
77pub const NAME_MAX = system.NAME_MAX;87pub const NAME_MAX = system.NAME_MAX;
78pub const O = system.O;88pub const O = system.O;
79pub const PATH_MAX = system.PATH_MAX;89pub const PATH_MAX = system.PATH_MAX;
90pub const POLL = system.POLL;
91pub const POSIX_FADV = system.POSIX_FADV;
80pub const PROT = system.PROT;92pub const PROT = system.PROT;
81pub const REG = system.REG;93pub const REG = system.REG;
94pub const RLIM = system.RLIM;
95pub const RR = system.RR;
96pub const R_OK = system.R_OK;
82pub const S = system.S;97pub const S = system.S;
83pub const SA = system.SA;98pub const SA = system.SA;
84pub const SC = system.SC;99pub const SC = system.SC;
100pub const SEEK = system.SEEK;
101pub const SHUT = system.SHUT;
85pub const SIG = system.SIG;102pub const SIG = system.SIG;
103pub const SIOCGIFINDEX = system.SIOCGIFINDEX;
104pub const SO = system.SO;
105pub const SOCK = system.SOCK;
106pub const SOL = system.SOL;
86pub const STDERR_FILENO = system.STDIN_FILENO;107pub const STDERR_FILENO = system.STDIN_FILENO;
87pub const STDIN_FILENO = system.STDIN_FILENO;108pub const STDIN_FILENO = system.STDIN_FILENO;
88pub const STDOUT_FILENO = system.STDIN_FILENO;109pub const STDOUT_FILENO = system.STDIN_FILENO;
...@@ -90,27 +111,39 @@ pub const SYS = system.SYS;...@@ -90,27 +111,39 @@ pub const SYS = system.SYS;
90pub const Sigaction = system.Sigaction;111pub const Sigaction = system.Sigaction;
91pub const Stat = system.Stat;112pub const Stat = system.Stat;
92pub const VDSO = system.VDSO;113pub const VDSO = system.VDSO;
114pub const W = system.W;
115pub const W_OK = system.W_OK;
116pub const X_OK = system.X_OK;
117pub const addrinfo = system.addrinfo;
93pub const blkcnt_t = system.blkcnt_t;118pub const blkcnt_t = system.blkcnt_t;
94pub const blksize_t = system.blksize_t;119pub const blksize_t = system.blksize_t;
95pub const clock_t = system.clock_t;120pub const clock_t = system.clock_t;
121pub const cpu_set_t = system.cpu_set_t;
96pub const dev_t = system.dev_t;122pub const dev_t = system.dev_t;
97pub const dl_phdr_info = system.dl_phdr_info;123pub const dl_phdr_info = system.dl_phdr_info;
98pub const empty_sigset = system.empty_sigset;124pub const empty_sigset = system.empty_sigset;
99pub const fd_t = system.fd_t;125pub const fd_t = system.fd_t;
100pub const gid_t = system.gid_t;126pub const gid_t = system.gid_t;
127pub const ifreq = system.ifreq;
101pub const ino_t = system.ino_t;128pub const ino_t = system.ino_t;
102pub const mcontext_t = system.mcontext_t;129pub const mcontext_t = system.mcontext_t;
103pub const mode_t = system.mode_t;130pub const mode_t = system.mode_t;
104pub const msghdr = system.msghdr;131pub const msghdr = system.msghdr;
105pub const msghdr_const = system.msghdr_const;132pub const msghdr_const = system.msghdr_const;
133pub const nfds_t = system.nfds_t;
106pub const nlink_t = system.nlink_t;134pub const nlink_t = system.nlink_t;
107pub const off_t = system.off_t;135pub const off_t = system.off_t;
108pub const pid_t = system.pid_t;136pub const pid_t = system.pid_t;
109pub const pollfd = system.pollfd;137pub const pollfd = system.pollfd;
138pub const rlim_t = system.rlim_t;
110pub const rlimit = system.rlimit;139pub const rlimit = system.rlimit;
111pub const rlimit_resource = system.rlimit_resource;140pub const rlimit_resource = system.rlimit_resource;
141pub const sa_family_t = system.sa_family_t;
112pub const siginfo_t = system.siginfo_t;142pub const siginfo_t = system.siginfo_t;
113pub const sigset_t = system.sigset_t;143pub const sigset_t = system.sigset_t;
144pub const sockaddr = system.sockaddr;
145pub const socklen_t = system.socklen_t;
146pub const stack_t = system.stack_t;
114pub const time_t = system.time_t;147pub const time_t = system.time_t;
115pub const timespec = system.timespec;148pub const timespec = system.timespec;
116pub const timeval = system.timeval;149pub const timeval = system.timeval;
...@@ -118,6 +151,7 @@ pub const timezone = system.timezone;...@@ -118,6 +151,7 @@ pub const timezone = system.timezone;
118pub const ucontext_t = system.ucontext_t;151pub const ucontext_t = system.ucontext_t;
119pub const uid_t = system.uid_t;152pub const uid_t = system.uid_t;
120pub const user_desc = system.user_desc;153pub const user_desc = system.user_desc;
154pub const utsname = system.utsname;
121155
122pub const iovec = extern struct {156pub const iovec = extern struct {
123 iov_base: [*]u8,157 iov_base: [*]u8,
...@@ -251,11 +285,11 @@ pub fn getrandom(buffer: []u8) GetRandomError!void {...@@ -251,11 +285,11 @@ pub fn getrandom(buffer: []u8) GetRandomError!void {
251}285}
252286
253fn getRandomBytesDevURandom(buf: []u8) !void {287fn getRandomBytesDevURandom(buf: []u8) !void {
254 const fd = try openZ("/dev/urandom", O_RDONLY | O_CLOEXEC, 0);288 const fd = try openZ("/dev/urandom", O.RDONLY | O.CLOEXEC, 0);
255 defer close(fd);289 defer close(fd);
256290
257 const st = try fstat(fd);291 const st = try fstat(fd);
258 if (!S_ISCHR(st.mode)) {292 if (!S.ISCHR(st.mode)) {
259 return error.NoDevice;293 return error.NoDevice;
260 }294 }
261295
...@@ -1113,18 +1147,18 @@ pub const OpenError = error{...@@ -1113,18 +1147,18 @@ pub const OpenError = error{
1113 /// for 64-bit targets, as well as when opening directories.1147 /// for 64-bit targets, as well as when opening directories.
1114 FileTooBig,1148 FileTooBig,
11151149
1116 /// The path refers to directory but the `O_DIRECTORY` flag was not provided.1150 /// The path refers to directory but the `O.DIRECTORY` flag was not provided.
1117 IsDir,1151 IsDir,
11181152
1119 /// A new path cannot be created because the device has no room for the new file.1153 /// A new path cannot be created because the device has no room for the new file.
1120 /// This error is only reachable when the `O_CREAT` flag is provided.1154 /// This error is only reachable when the `O.CREAT` flag is provided.
1121 NoSpaceLeft,1155 NoSpaceLeft,
11221156
1123 /// A component used as a directory in the path was not, in fact, a directory, or1157 /// A component used as a directory in the path was not, in fact, a directory, or
1124 /// `O_DIRECTORY` was specified and the path was not a directory.1158 /// `O.DIRECTORY` was specified and the path was not a directory.
1125 NotDir,1159 NotDir,
11261160
1127 /// The path already exists and the `O_CREAT` and `O_EXCL` flags were provided.1161 /// The path already exists and the `O.CREAT` and `O.EXCL` flags were provided.
1128 PathAlreadyExists,1162 PathAlreadyExists,
1129 DeviceBusy,1163 DeviceBusy,
11301164
...@@ -1196,20 +1230,20 @@ fn openOptionsFromFlags(flags: u32) windows.OpenFileOptions {...@@ -1196,20 +1230,20 @@ fn openOptionsFromFlags(flags: u32) windows.OpenFileOptions {
1196 const w = windows;1230 const w = windows;
11971231
1198 var access_mask: w.ULONG = w.READ_CONTROL | w.FILE_WRITE_ATTRIBUTES | w.SYNCHRONIZE;1232 var access_mask: w.ULONG = w.READ_CONTROL | w.FILE_WRITE_ATTRIBUTES | w.SYNCHRONIZE;
1199 if (flags & O_RDWR != 0) {1233 if (flags & O.RDWR != 0) {
1200 access_mask |= w.GENERIC_READ | w.GENERIC_WRITE;1234 access_mask |= w.GENERIC_READ | w.GENERIC_WRITE;
1201 } else if (flags & O_WRONLY != 0) {1235 } else if (flags & O.WRONLY != 0) {
1202 access_mask |= w.GENERIC_WRITE;1236 access_mask |= w.GENERIC_WRITE;
1203 } else {1237 } else {
1204 access_mask |= w.GENERIC_READ | w.GENERIC_WRITE;1238 access_mask |= w.GENERIC_READ | w.GENERIC_WRITE;
1205 }1239 }
12061240
1207 const open_dir: bool = flags & O_DIRECTORY != 0;1241 const open_dir: bool = flags & O.DIRECTORY != 0;
1208 const follow_symlinks: bool = flags & O_NOFOLLOW == 0;1242 const follow_symlinks: bool = flags & O.NOFOLLOW == 0;
12091243
1210 const creation: w.ULONG = blk: {1244 const creation: w.ULONG = blk: {
1211 if (flags & O_CREAT != 0) {1245 if (flags & O.CREAT != 0) {
1212 if (flags & O_EXCL != 0) {1246 if (flags & O.EXCL != 0) {
1213 break :blk w.FILE_CREATE;1247 break :blk w.FILE_CREATE;
1214 }1248 }
1215 }1249 }
...@@ -2812,10 +2846,10 @@ pub const SocketError = error{...@@ -2812,10 +2846,10 @@ pub const SocketError = error{
28122846
2813pub fn socket(domain: u32, socket_type: u32, protocol: u32) SocketError!socket_t {2847pub fn socket(domain: u32, socket_type: u32, protocol: u32) SocketError!socket_t {
2814 if (builtin.os.tag == .windows) {2848 if (builtin.os.tag == .windows) {
2815 // NOTE: windows translates the SOCK_NONBLOCK/SOCK_CLOEXEC flags into2849 // NOTE: windows translates the SOCK.NONBLOCK/SOCK.CLOEXEC flags into
2816 // windows-analagous operations2850 // windows-analagous operations
2817 const filtered_sock_type = socket_type & ~@as(u32, SOCK_NONBLOCK | SOCK_CLOEXEC);2851 const filtered_sock_type = socket_type & ~@as(u32, SOCK.NONBLOCK | SOCK.CLOEXEC);
2818 const flags: u32 = if ((socket_type & SOCK_CLOEXEC) != 0)2852 const flags: u32 = if ((socket_type & SOCK.CLOEXEC) != 0)
2819 windows.ws2_32.WSA_FLAG_NO_HANDLE_INHERIT2853 windows.ws2_32.WSA_FLAG_NO_HANDLE_INHERIT
2820 else2854 else
2821 0;2855 0;
...@@ -2828,7 +2862,7 @@ pub fn socket(domain: u32, socket_type: u32, protocol: u32) SocketError!socket_t...@@ -2828,7 +2862,7 @@ pub fn socket(domain: u32, socket_type: u32, protocol: u32) SocketError!socket_t
2828 flags,2862 flags,
2829 );2863 );
2830 errdefer windows.closesocket(rc) catch unreachable;2864 errdefer windows.closesocket(rc) catch unreachable;
2831 if ((socket_type & SOCK_NONBLOCK) != 0) {2865 if ((socket_type & SOCK.NONBLOCK) != 0) {
2832 var mode: c_ulong = 1; // nonblocking2866 var mode: c_ulong = 1; // nonblocking
2833 if (windows.ws2_32.SOCKET_ERROR == windows.ws2_32.ioctlsocket(rc, windows.ws2_32.FIONBIO, &mode)) {2867 if (windows.ws2_32.SOCKET_ERROR == windows.ws2_32.ioctlsocket(rc, windows.ws2_32.FIONBIO, &mode)) {
2834 switch (windows.ws2_32.WSAGetLastError()) {2868 switch (windows.ws2_32.WSAGetLastError()) {
...@@ -2842,7 +2876,7 @@ pub fn socket(domain: u32, socket_type: u32, protocol: u32) SocketError!socket_t...@@ -2842,7 +2876,7 @@ pub fn socket(domain: u32, socket_type: u32, protocol: u32) SocketError!socket_t
28422876
2843 const have_sock_flags = comptime !std.Target.current.isDarwin();2877 const have_sock_flags = comptime !std.Target.current.isDarwin();
2844 const filtered_sock_type = if (!have_sock_flags)2878 const filtered_sock_type = if (!have_sock_flags)
2845 socket_type & ~@as(u32, SOCK_NONBLOCK | SOCK_CLOEXEC)2879 socket_type & ~@as(u32, SOCK.NONBLOCK | SOCK.CLOEXEC)
2846 else2880 else
2847 socket_type;2881 socket_type;
2848 const rc = system.socket(domain, filtered_sock_type, protocol);2882 const rc = system.socket(domain, filtered_sock_type, protocol);
...@@ -2905,9 +2939,9 @@ pub fn shutdown(sock: socket_t, how: ShutdownHow) ShutdownError!void {...@@ -2905,9 +2939,9 @@ pub fn shutdown(sock: socket_t, how: ShutdownHow) ShutdownError!void {
2905 };2939 };
2906 } else {2940 } else {
2907 const rc = system.shutdown(sock, switch (how) {2941 const rc = system.shutdown(sock, switch (how) {
2908 .recv => SHUT_RD,2942 .recv => SHUT.RD,
2909 .send => SHUT_WR,2943 .send => SHUT.WR,
2910 .both => SHUT_RDWR,2944 .both => SHUT.RDWR,
2911 });2945 });
2912 switch (errno(rc)) {2946 switch (errno(rc)) {
2913 .SUCCESS => return,2947 .SUCCESS => return,
...@@ -3132,15 +3166,15 @@ pub fn accept(...@@ -3132,15 +3166,15 @@ pub fn accept(
3132 /// will return a value greater than was supplied to the call.3166 /// will return a value greater than was supplied to the call.
3133 addr_size: ?*socklen_t,3167 addr_size: ?*socklen_t,
3134 /// The following values can be bitwise ORed in flags to obtain different behavior:3168 /// The following values can be bitwise ORed in flags to obtain different behavior:
3135 /// * `SOCK_NONBLOCK` - Set the `O_NONBLOCK` file status flag on the open file description (see `open`)3169 /// * `SOCK.NONBLOCK` - Set the `O.NONBLOCK` file status flag on the open file description (see `open`)
3136 /// referred to by the new file descriptor. Using this flag saves extra calls to `fcntl` to achieve3170 /// referred to by the new file descriptor. Using this flag saves extra calls to `fcntl` to achieve
3137 /// the same result.3171 /// the same result.
3138 /// * `SOCK_CLOEXEC` - Set the close-on-exec (`FD_CLOEXEC`) flag on the new file descriptor. See the3172 /// * `SOCK.CLOEXEC` - Set the close-on-exec (`FD_CLOEXEC`) flag on the new file descriptor. See the
3139 /// description of the `O_CLOEXEC` flag in `open` for reasons why this may be useful.3173 /// description of the `O.CLOEXEC` flag in `open` for reasons why this may be useful.
3140 flags: u32,3174 flags: u32,
3141) AcceptError!socket_t {3175) AcceptError!socket_t {
3142 const have_accept4 = comptime !(std.Target.current.isDarwin() or builtin.os.tag == .windows);3176 const have_accept4 = comptime !(std.Target.current.isDarwin() or builtin.os.tag == .windows);
3143 assert(0 == (flags & ~@as(u32, SOCK_NONBLOCK | SOCK_CLOEXEC))); // Unsupported flag(s)3177 assert(0 == (flags & ~@as(u32, SOCK.NONBLOCK | SOCK.CLOEXEC))); // Unsupported flag(s)
31443178
3145 const accepted_sock = while (true) {3179 const accepted_sock = while (true) {
3146 const rc = if (have_accept4)3180 const rc = if (have_accept4)
...@@ -3250,7 +3284,7 @@ pub const EpollCtlError = error{...@@ -3250,7 +3284,7 @@ pub const EpollCtlError = error{
3250 FileDescriptorIncompatibleWithEpoll,3284 FileDescriptorIncompatibleWithEpoll,
3251} || UnexpectedError;3285} || UnexpectedError;
32523286
3253pub fn epoll_ctl(epfd: i32, op: u32, fd: i32, event: ?*epoll_event) EpollCtlError!void {3287pub fn epoll_ctl(epfd: i32, op: u32, fd: i32, event: ?*linux.epoll_event) EpollCtlError!void {
3254 const rc = system.epoll_ctl(epfd, op, fd, event);3288 const rc = system.epoll_ctl(epfd, op, fd, event);
3255 switch (errno(rc)) {3289 switch (errno(rc)) {
3256 .SUCCESS => return,3290 .SUCCESS => return,
...@@ -3270,7 +3304,7 @@ pub fn epoll_ctl(epfd: i32, op: u32, fd: i32, event: ?*epoll_event) EpollCtlErro...@@ -3270,7 +3304,7 @@ pub fn epoll_ctl(epfd: i32, op: u32, fd: i32, event: ?*epoll_event) EpollCtlErro
3270/// Waits for an I/O event on an epoll file descriptor.3304/// Waits for an I/O event on an epoll file descriptor.
3271/// Returns the number of file descriptors ready for the requested I/O,3305/// Returns the number of file descriptors ready for the requested I/O,
3272/// or zero if no file descriptor became ready during the requested timeout milliseconds.3306/// or zero if no file descriptor became ready during the requested timeout milliseconds.
3273pub fn epoll_wait(epfd: i32, events: []epoll_event, timeout: i32) usize {3307pub fn epoll_wait(epfd: i32, events: []linux.epoll_event, timeout: i32) usize {
3274 while (true) {3308 while (true) {
3275 // TODO get rid of the @intCast3309 // TODO get rid of the @intCast
3276 const rc = system.epoll_wait(epfd, events.ptr, @intCast(u32, events.len), timeout);3310 const rc = system.epoll_wait(epfd, events.ptr, @intCast(u32, events.len), timeout);
...@@ -3472,7 +3506,7 @@ pub fn connect(sock: socket_t, sock_addr: *const sockaddr, len: socklen_t) Conne...@@ -3472,7 +3506,7 @@ pub fn connect(sock: socket_t, sock_addr: *const sockaddr, len: socklen_t) Conne
3472 .NOTSOCK => unreachable, // The file descriptor sockfd does not refer to a socket.3506 .NOTSOCK => unreachable, // The file descriptor sockfd does not refer to a socket.
3473 .PROTOTYPE => unreachable, // The socket type does not support the requested communications protocol.3507 .PROTOTYPE => unreachable, // The socket type does not support the requested communications protocol.
3474 .TIMEDOUT => return error.ConnectionTimedOut,3508 .TIMEDOUT => return error.ConnectionTimedOut,
3475 .NOENT => return error.FileNotFound, // Returned when socket is AF_UNIX and the given path does not exist.3509 .NOENT => return error.FileNotFound, // Returned when socket is AF.UNIX and the given path does not exist.
3476 else => |err| return unexpectedErrno(err),3510 else => |err| return unexpectedErrno(err),
3477 }3511 }
3478 }3512 }
...@@ -3481,7 +3515,7 @@ pub fn connect(sock: socket_t, sock_addr: *const sockaddr, len: socklen_t) Conne...@@ -3481,7 +3515,7 @@ pub fn connect(sock: socket_t, sock_addr: *const sockaddr, len: socklen_t) Conne
3481pub fn getsockoptError(sockfd: fd_t) ConnectError!void {3515pub fn getsockoptError(sockfd: fd_t) ConnectError!void {
3482 var err_code: i32 = undefined;3516 var err_code: i32 = undefined;
3483 var size: u32 = @sizeOf(u32);3517 var size: u32 = @sizeOf(u32);
3484 const rc = system.getsockopt(sockfd, SOL_SOCKET, SO_ERROR, @ptrCast([*]u8, &err_code), &size);3518 const rc = system.getsockopt(sockfd, SOL.SOCKET, SO.ERROR, @ptrCast([*]u8, &err_code), &size);
3485 assert(size == 4);3519 assert(size == 4);
3486 switch (errno(rc)) {3520 switch (errno(rc)) {
3487 .SUCCESS => switch (@intToEnum(E, err_code)) {3521 .SUCCESS => switch (@intToEnum(E, err_code)) {
...@@ -3813,8 +3847,8 @@ pub const MMapError = error{...@@ -3813,8 +3847,8 @@ pub const MMapError = error{
3813 MemoryMappingNotSupported,3847 MemoryMappingNotSupported,
38143848
3815 /// A file descriptor refers to a non-regular file. Or a file mapping was requested,3849 /// A file descriptor refers to a non-regular file. Or a file mapping was requested,
3816 /// but the file descriptor is not open for reading. Or `MAP_SHARED` was requested3850 /// but the file descriptor is not open for reading. Or `MAP.SHARED` was requested
3817 /// and `PROT_WRITE` is set, but the file descriptor is not open in `O_RDWR` mode.3851 /// and `PROT_WRITE` is set, but the file descriptor is not open in `O.RDWR` mode.
3818 /// Or `PROT_WRITE` is set, but the file is append-only.3852 /// Or `PROT_WRITE` is set, but the file is append-only.
3819 AccessDenied,3853 AccessDenied,
38203854
...@@ -3846,7 +3880,7 @@ pub fn mmap(...@@ -3846,7 +3880,7 @@ pub fn mmap(
3846 const ioffset = @bitCast(i64, offset); // the OS treats this as unsigned3880 const ioffset = @bitCast(i64, offset); // the OS treats this as unsigned
3847 const rc = mmap_sym(ptr, length, prot, flags, fd, ioffset);3881 const rc = mmap_sym(ptr, length, prot, flags, fd, ioffset);
3848 const err = if (builtin.link_libc) blk: {3882 const err = if (builtin.link_libc) blk: {
3849 if (rc != std.c.MAP_FAILED) return @ptrCast([*]align(mem.page_size) u8, @alignCast(mem.page_size, rc))[0..length];3883 if (rc != std.c.MAP.FAILED) return @ptrCast([*]align(mem.page_size) u8, @alignCast(mem.page_size, rc))[0..length];
3850 break :blk @intToEnum(E, system._errno().*);3884 break :blk @intToEnum(E, system._errno().*);
3851 } else blk: {3885 } else blk: {
3852 const err = errno(rc);3886 const err = errno(rc);
...@@ -4069,9 +4103,9 @@ pub fn pipe2(flags: u32) PipeError![2]fd_t {...@@ -4069,9 +4103,9 @@ pub fn pipe2(flags: u32) PipeError![2]fd_t {
4069 if (flags == 0)4103 if (flags == 0)
4070 return fds;4104 return fds;
40714105
4072 // O_CLOEXEC is special, it's a file descriptor flag and must be set using4106 // O.CLOEXEC is special, it's a file descriptor flag and must be set using
4073 // F_SETFD.4107 // F_SETFD.
4074 if (flags & O_CLOEXEC != 0) {4108 if (flags & O.CLOEXEC != 0) {
4075 for (fds) |fd| {4109 for (fds) |fd| {
4076 switch (errno(system.fcntl(fd, F_SETFD, @as(u32, FD_CLOEXEC)))) {4110 switch (errno(system.fcntl(fd, F_SETFD, @as(u32, FD_CLOEXEC)))) {
4077 .SUCCESS => {},4111 .SUCCESS => {},
...@@ -4082,7 +4116,7 @@ pub fn pipe2(flags: u32) PipeError![2]fd_t {...@@ -4082,7 +4116,7 @@ pub fn pipe2(flags: u32) PipeError![2]fd_t {
4082 }4116 }
4083 }4117 }
40844118
4085 const new_flags = flags & ~@as(u32, O_CLOEXEC);4119 const new_flags = flags & ~@as(u32, O.CLOEXEC);
4086 // Set every other flag affecting the file status using F_SETFL.4120 // Set every other flag affecting the file status using F_SETFL.
4087 if (new_flags != 0) {4121 if (new_flags != 0) {
4088 for (fds) |fd| {4122 for (fds) |fd| {
...@@ -4176,7 +4210,7 @@ pub const SeekError = error{...@@ -4176,7 +4210,7 @@ pub const SeekError = error{
4176pub fn lseek_SET(fd: fd_t, offset: u64) SeekError!void {4210pub fn lseek_SET(fd: fd_t, offset: u64) SeekError!void {
4177 if (builtin.os.tag == .linux and !builtin.link_libc and @sizeOf(usize) == 4) {4211 if (builtin.os.tag == .linux and !builtin.link_libc and @sizeOf(usize) == 4) {
4178 var result: u64 = undefined;4212 var result: u64 = undefined;
4179 switch (errno(system.llseek(fd, offset, &result, SEEK_SET))) {4213 switch (errno(system.llseek(fd, offset, &result, SEEK.SET))) {
4180 .SUCCESS => return,4214 .SUCCESS => return,
4181 .BADF => unreachable, // always a race condition4215 .BADF => unreachable, // always a race condition
4182 .INVAL => return error.Unseekable,4216 .INVAL => return error.Unseekable,
...@@ -4209,7 +4243,7 @@ pub fn lseek_SET(fd: fd_t, offset: u64) SeekError!void {...@@ -4209,7 +4243,7 @@ pub fn lseek_SET(fd: fd_t, offset: u64) SeekError!void {
4209 system.lseek;4243 system.lseek;
42104244
4211 const ioffset = @bitCast(i64, offset); // the OS treats this as unsigned4245 const ioffset = @bitCast(i64, offset); // the OS treats this as unsigned
4212 switch (errno(lseek_sym(fd, ioffset, SEEK_SET))) {4246 switch (errno(lseek_sym(fd, ioffset, SEEK.SET))) {
4213 .SUCCESS => return,4247 .SUCCESS => return,
4214 .BADF => unreachable, // always a race condition4248 .BADF => unreachable, // always a race condition
4215 .INVAL => return error.Unseekable,4249 .INVAL => return error.Unseekable,
...@@ -4224,7 +4258,7 @@ pub fn lseek_SET(fd: fd_t, offset: u64) SeekError!void {...@@ -4224,7 +4258,7 @@ pub fn lseek_SET(fd: fd_t, offset: u64) SeekError!void {
4224pub fn lseek_CUR(fd: fd_t, offset: i64) SeekError!void {4258pub fn lseek_CUR(fd: fd_t, offset: i64) SeekError!void {
4225 if (builtin.os.tag == .linux and !builtin.link_libc and @sizeOf(usize) == 4) {4259 if (builtin.os.tag == .linux and !builtin.link_libc and @sizeOf(usize) == 4) {
4226 var result: u64 = undefined;4260 var result: u64 = undefined;
4227 switch (errno(system.llseek(fd, @bitCast(u64, offset), &result, SEEK_CUR))) {4261 switch (errno(system.llseek(fd, @bitCast(u64, offset), &result, SEEK.CUR))) {
4228 .SUCCESS => return,4262 .SUCCESS => return,
4229 .BADF => unreachable, // always a race condition4263 .BADF => unreachable, // always a race condition
4230 .INVAL => return error.Unseekable,4264 .INVAL => return error.Unseekable,
...@@ -4256,7 +4290,7 @@ pub fn lseek_CUR(fd: fd_t, offset: i64) SeekError!void {...@@ -4256,7 +4290,7 @@ pub fn lseek_CUR(fd: fd_t, offset: i64) SeekError!void {
4256 system.lseek;4290 system.lseek;
42574291
4258 const ioffset = @bitCast(i64, offset); // the OS treats this as unsigned4292 const ioffset = @bitCast(i64, offset); // the OS treats this as unsigned
4259 switch (errno(lseek_sym(fd, ioffset, SEEK_CUR))) {4293 switch (errno(lseek_sym(fd, ioffset, SEEK.CUR))) {
4260 .SUCCESS => return,4294 .SUCCESS => return,
4261 .BADF => unreachable, // always a race condition4295 .BADF => unreachable, // always a race condition
4262 .INVAL => return error.Unseekable,4296 .INVAL => return error.Unseekable,
...@@ -4271,7 +4305,7 @@ pub fn lseek_CUR(fd: fd_t, offset: i64) SeekError!void {...@@ -4271,7 +4305,7 @@ pub fn lseek_CUR(fd: fd_t, offset: i64) SeekError!void {
4271pub fn lseek_END(fd: fd_t, offset: i64) SeekError!void {4305pub fn lseek_END(fd: fd_t, offset: i64) SeekError!void {
4272 if (builtin.os.tag == .linux and !builtin.link_libc and @sizeOf(usize) == 4) {4306 if (builtin.os.tag == .linux and !builtin.link_libc and @sizeOf(usize) == 4) {
4273 var result: u64 = undefined;4307 var result: u64 = undefined;
4274 switch (errno(system.llseek(fd, @bitCast(u64, offset), &result, SEEK_END))) {4308 switch (errno(system.llseek(fd, @bitCast(u64, offset), &result, SEEK.END))) {
4275 .SUCCESS => return,4309 .SUCCESS => return,
4276 .BADF => unreachable, // always a race condition4310 .BADF => unreachable, // always a race condition
4277 .INVAL => return error.Unseekable,4311 .INVAL => return error.Unseekable,
...@@ -4303,7 +4337,7 @@ pub fn lseek_END(fd: fd_t, offset: i64) SeekError!void {...@@ -4303,7 +4337,7 @@ pub fn lseek_END(fd: fd_t, offset: i64) SeekError!void {
4303 system.lseek;4337 system.lseek;
43044338
4305 const ioffset = @bitCast(i64, offset); // the OS treats this as unsigned4339 const ioffset = @bitCast(i64, offset); // the OS treats this as unsigned
4306 switch (errno(lseek_sym(fd, ioffset, SEEK_END))) {4340 switch (errno(lseek_sym(fd, ioffset, SEEK.END))) {
4307 .SUCCESS => return,4341 .SUCCESS => return,
4308 .BADF => unreachable, // always a race condition4342 .BADF => unreachable, // always a race condition
4309 .INVAL => return error.Unseekable,4343 .INVAL => return error.Unseekable,
...@@ -4318,7 +4352,7 @@ pub fn lseek_END(fd: fd_t, offset: i64) SeekError!void {...@@ -4318,7 +4352,7 @@ pub fn lseek_END(fd: fd_t, offset: i64) SeekError!void {
4318pub fn lseek_CUR_get(fd: fd_t) SeekError!u64 {4352pub fn lseek_CUR_get(fd: fd_t) SeekError!u64 {
4319 if (builtin.os.tag == .linux and !builtin.link_libc and @sizeOf(usize) == 4) {4353 if (builtin.os.tag == .linux and !builtin.link_libc and @sizeOf(usize) == 4) {
4320 var result: u64 = undefined;4354 var result: u64 = undefined;
4321 switch (errno(system.llseek(fd, 0, &result, SEEK_CUR))) {4355 switch (errno(system.llseek(fd, 0, &result, SEEK.CUR))) {
4322 .SUCCESS => return result,4356 .SUCCESS => return result,
4323 .BADF => unreachable, // always a race condition4357 .BADF => unreachable, // always a race condition
4324 .INVAL => return error.Unseekable,4358 .INVAL => return error.Unseekable,
...@@ -4349,7 +4383,7 @@ pub fn lseek_CUR_get(fd: fd_t) SeekError!u64 {...@@ -4349,7 +4383,7 @@ pub fn lseek_CUR_get(fd: fd_t) SeekError!u64 {
4349 else4383 else
4350 system.lseek;4384 system.lseek;
43514385
4352 const rc = lseek_sym(fd, 0, SEEK_CUR);4386 const rc = lseek_sym(fd, 0, SEEK.CUR);
4353 switch (errno(rc)) {4387 switch (errno(rc)) {
4354 .SUCCESS => return @bitCast(u64, rc),4388 .SUCCESS => return @bitCast(u64, rc),
4355 .BADF => unreachable, // always a race condition4389 .BADF => unreachable, // always a race condition
...@@ -4387,7 +4421,7 @@ pub fn fcntl(fd: fd_t, cmd: i32, arg: usize) FcntlError!usize {...@@ -4387,7 +4421,7 @@ pub fn fcntl(fd: fd_t, cmd: i32, arg: usize) FcntlError!usize {
4387}4421}
43884422
4389fn setSockFlags(sock: socket_t, flags: u32) !void {4423fn setSockFlags(sock: socket_t, flags: u32) !void {
4390 if ((flags & SOCK_CLOEXEC) != 0) {4424 if ((flags & SOCK.CLOEXEC) != 0) {
4391 if (builtin.os.tag == .windows) {4425 if (builtin.os.tag == .windows) {
4392 // TODO: Find out if this is supported for sockets4426 // TODO: Find out if this is supported for sockets
4393 } else {4427 } else {
...@@ -4406,7 +4440,7 @@ fn setSockFlags(sock: socket_t, flags: u32) !void {...@@ -4406,7 +4440,7 @@ fn setSockFlags(sock: socket_t, flags: u32) !void {
4406 };4440 };
4407 }4441 }
4408 }4442 }
4409 if ((flags & SOCK_NONBLOCK) != 0) {4443 if ((flags & SOCK.NONBLOCK) != 0) {
4410 if (builtin.os.tag == .windows) {4444 if (builtin.os.tag == .windows) {
4411 var mode: c_ulong = 1;4445 var mode: c_ulong = 1;
4412 if (windows.ws2_32.ioctlsocket(sock, windows.ws2_32.FIONBIO, &mode) == windows.ws2_32.SOCKET_ERROR) {4446 if (windows.ws2_32.ioctlsocket(sock, windows.ws2_32.FIONBIO, &mode) == windows.ws2_32.SOCKET_ERROR) {
...@@ -4425,7 +4459,7 @@ fn setSockFlags(sock: socket_t, flags: u32) !void {...@@ -4425,7 +4459,7 @@ fn setSockFlags(sock: socket_t, flags: u32) !void {
4425 error.PermissionDenied => unreachable,4459 error.PermissionDenied => unreachable,
4426 else => |e| return e,4460 else => |e| return e,
4427 };4461 };
4428 fl_flags |= O_NONBLOCK;4462 fl_flags |= O.NONBLOCK;
4429 _ = fcntl(sock, F_SETFL, fl_flags) catch |err| switch (err) {4463 _ = fcntl(sock, F_SETFL, fl_flags) catch |err| switch (err) {
4430 error.FileBusy => unreachable,4464 error.FileBusy => unreachable,
4431 error.Locked => unreachable,4465 error.Locked => unreachable,
...@@ -4512,7 +4546,7 @@ pub fn realpathZ(pathname: [*:0]const u8, out_buffer: *[MAX_PATH_BYTES]u8) RealP...@@ -4512,7 +4546,7 @@ pub fn realpathZ(pathname: [*:0]const u8, out_buffer: *[MAX_PATH_BYTES]u8) RealP
4512 return realpathW(pathname_w.span(), out_buffer);4546 return realpathW(pathname_w.span(), out_buffer);
4513 }4547 }
4514 if (!builtin.link_libc) {4548 if (!builtin.link_libc) {
4515 const flags = if (builtin.os.tag == .linux) O_PATH | O_NONBLOCK | O_CLOEXEC else O_NONBLOCK | O_CLOEXEC;4549 const flags = if (builtin.os.tag == .linux) O.PATH | O.NONBLOCK | O.CLOEXEC else O.NONBLOCK | O.CLOEXEC;
4516 const fd = openZ(pathname, flags, 0) catch |err| switch (err) {4550 const fd = openZ(pathname, flags, 0) catch |err| switch (err) {
4517 error.FileLocksNotSupported => unreachable,4551 error.FileLocksNotSupported => unreachable,
4518 error.WouldBlock => unreachable,4552 error.WouldBlock => unreachable,
...@@ -5043,7 +5077,7 @@ pub const SendError = error{...@@ -5043,7 +5077,7 @@ pub const SendError = error{
5043 SystemResources,5077 SystemResources,
50445078
5045 /// The local end has been shut down on a connection oriented socket. In this case, the5079 /// The local end has been shut down on a connection oriented socket. In this case, the
5046 /// process will also receive a SIGPIPE unless MSG_NOSIGNAL is set.5080 /// process will also receive a SIGPIPE unless MSG.NOSIGNAL is set.
5047 BrokenPipe,5081 BrokenPipe,
50485082
5049 FileDescriptorNotASocket,5083 FileDescriptorNotASocket,
...@@ -5059,13 +5093,13 @@ pub const SendMsgError = SendError || error{...@@ -5059,13 +5093,13 @@ pub const SendMsgError = SendError || error{
5059 /// The passed address didn't have the correct address family in its sa_family field.5093 /// The passed address didn't have the correct address family in its sa_family field.
5060 AddressFamilyNotSupported,5094 AddressFamilyNotSupported,
50615095
5062 /// Returned when socket is AF_UNIX and the given path has a symlink loop.5096 /// Returned when socket is AF.UNIX and the given path has a symlink loop.
5063 SymLinkLoop,5097 SymLinkLoop,
50645098
5065 /// Returned when socket is AF_UNIX and the given path length exceeds `MAX_PATH_BYTES` bytes.5099 /// Returned when socket is AF.UNIX and the given path length exceeds `MAX_PATH_BYTES` bytes.
5066 NameTooLong,5100 NameTooLong,
50675101
5068 /// Returned when socket is AF_UNIX and the given path does not point to an existing file.5102 /// Returned when socket is AF.UNIX and the given path does not point to an existing file.
5069 FileNotFound,5103 FileNotFound,
5070 NotDir,5104 NotDir,
50715105
...@@ -5158,7 +5192,7 @@ pub const SendToError = SendMsgError;...@@ -5158,7 +5192,7 @@ pub const SendToError = SendMsgError;
5158///5192///
5159/// sendto(sockfd, buf, len, flags, NULL, 0);5193/// sendto(sockfd, buf, len, flags, NULL, 0);
5160///5194///
5161/// If sendto() is used on a connection-mode (`SOCK_STREAM`, `SOCK_SEQPACKET`) socket, the arguments5195/// If sendto() is used on a connection-mode (`SOCK.STREAM`, `SOCK.SEQPACKET`) socket, the arguments
5162/// `dest_addr` and `addrlen` are asserted to be `null` and `0` respectively, and asserted5196/// `dest_addr` and `addrlen` are asserted to be `null` and `0` respectively, and asserted
5163/// that the socket was actually connected.5197/// that the socket was actually connected.
5164/// Otherwise, the address of the target is given by `dest_addr` with `addrlen` specifying its size.5198/// Otherwise, the address of the target is given by `dest_addr` with `addrlen` specifying its size.
...@@ -5398,7 +5432,7 @@ pub fn sendfile(...@@ -5398,7 +5432,7 @@ pub fn sendfile(
5398 // * Descriptor is not valid or locked5432 // * Descriptor is not valid or locked
5399 // * an mmap(2)-like operation is not available for in_fd5433 // * an mmap(2)-like operation is not available for in_fd
5400 // * count is negative5434 // * count is negative
5401 // * out_fd has the O_APPEND flag set5435 // * out_fd has the O.APPEND flag set
5402 // Because of the "mmap(2)-like operation" possibility, we fall back to doing read/write5436 // Because of the "mmap(2)-like operation" possibility, we fall back to doing read/write
5403 // manually, the same as ENOSYS.5437 // manually, the same as ENOSYS.
5404 break :sf;5438 break :sf;
...@@ -5464,7 +5498,7 @@ pub fn sendfile(...@@ -5464,7 +5498,7 @@ pub fn sendfile(
5464 .INVAL, .OPNOTSUPP, .NOTSOCK, .NOSYS => {5498 .INVAL, .OPNOTSUPP, .NOTSOCK, .NOSYS => {
5465 // EINVAL could be any of the following situations:5499 // EINVAL could be any of the following situations:
5466 // * The fd argument is not a regular file.5500 // * The fd argument is not a regular file.
5467 // * The s argument is not a SOCK_STREAM type socket.5501 // * The s argument is not a SOCK.STREAM type socket.
5468 // * The offset argument is negative.5502 // * The offset argument is negative.
5469 // Because of some of these possibilities, we fall back to doing read/write5503 // Because of some of these possibilities, we fall back to doing read/write
5470 // manually, the same as ENOSYS.5504 // manually, the same as ENOSYS.
...@@ -5606,7 +5640,7 @@ pub const CopyFileRangeError = error{...@@ -5606,7 +5640,7 @@ pub const CopyFileRangeError = error{
5606 FileTooBig,5640 FileTooBig,
5607 InputOutput,5641 InputOutput,
5608 /// `fd_in` is not open for reading; or `fd_out` is not open for writing;5642 /// `fd_in` is not open for reading; or `fd_out` is not open for writing;
5609 /// or the `O_APPEND` flag is set for `fd_out`.5643 /// or the `O.APPEND` flag is set for `fd_out`.
5610 FilesOpenedWithWrongFlags,5644 FilesOpenedWithWrongFlags,
5611 IsDir,5645 IsDir,
5612 OutOfMemory,5646 OutOfMemory,
...@@ -6222,27 +6256,27 @@ pub fn setrlimit(resource: rlimit_resource, limits: rlimit) SetrlimitError!void...@@ -6222,27 +6256,27 @@ pub fn setrlimit(resource: rlimit_resource, limits: rlimit) SetrlimitError!void
6222}6256}
62236257
6224pub const MadviseError = error{6258pub const MadviseError = error{
6225 /// advice is MADV_REMOVE, but the specified address range is not a shared writable mapping.6259 /// advice is MADV.REMOVE, but the specified address range is not a shared writable mapping.
6226 AccessDenied,6260 AccessDenied,
6227 /// advice is MADV_HWPOISON, but the caller does not have the CAP_SYS_ADMIN capability.6261 /// advice is MADV.HWPOISON, but the caller does not have the CAP_SYS_ADMIN capability.
6228 PermissionDenied,6262 PermissionDenied,
6229 /// A kernel resource was temporarily unavailable.6263 /// A kernel resource was temporarily unavailable.
6230 SystemResources,6264 SystemResources,
6231 /// One of the following:6265 /// One of the following:
6232 /// * addr is not page-aligned or length is negative6266 /// * addr is not page-aligned or length is negative
6233 /// * advice is not valid6267 /// * advice is not valid
6234 /// * advice is MADV_DONTNEED or MADV_REMOVE and the specified address range6268 /// * advice is MADV.DONTNEED or MADV.REMOVE and the specified address range
6235 /// includes locked, Huge TLB pages, or VM_PFNMAP pages.6269 /// includes locked, Huge TLB pages, or VM_PFNMAP pages.
6236 /// * advice is MADV_MERGEABLE or MADV_UNMERGEABLE, but the kernel was not6270 /// * advice is MADV.MERGEABLE or MADV.UNMERGEABLE, but the kernel was not
6237 /// configured with CONFIG_KSM.6271 /// configured with CONFIG_KSM.
6238 /// * advice is MADV_FREE or MADV_WIPEONFORK but the specified address range6272 /// * advice is MADV.FREE or MADV.WIPEONFORK but the specified address range
6239 /// includes file, Huge TLB, MAP_SHARED, or VM_PFNMAP ranges.6273 /// includes file, Huge TLB, MAP.SHARED, or VM_PFNMAP ranges.
6240 InvalidSyscall,6274 InvalidSyscall,
6241 /// (for MADV_WILLNEED) Paging in this area would exceed the process's6275 /// (for MADV.WILLNEED) Paging in this area would exceed the process's
6242 /// maximum resident set size.6276 /// maximum resident set size.
6243 WouldExceedMaximumResidentSetSize,6277 WouldExceedMaximumResidentSetSize,
6244 /// One of the following:6278 /// One of the following:
6245 /// * (for MADV_WILLNEED) Not enough memory: paging in failed.6279 /// * (for MADV.WILLNEED) Not enough memory: paging in failed.
6246 /// * Addresses in the specified range are not currently mapped, or6280 /// * Addresses in the specified range are not currently mapped, or
6247 /// are outside the address space of the process.6281 /// are outside the address space of the process.
6248 OutOfMemory,6282 OutOfMemory,
lib/std/os/linux.zig+126-110
...@@ -17,6 +17,8 @@ const is_mips = native_arch.isMIPS();...@@ -17,6 +17,8 @@ const is_mips = native_arch.isMIPS();
17const is_ppc = native_arch.isPPC();17const is_ppc = native_arch.isPPC();
18const is_ppc64 = native_arch.isPPC64();18const is_ppc64 = native_arch.isPPC64();
19const is_sparc = native_arch.isSPARC();19const is_sparc = native_arch.isSPARC();
20const iovec = std.os.iovec;
21const iovec_const = std.os.iovec_const;
2022
21test {23test {
22 if (std.Target.current.os.tag == .linux) {24 if (std.Target.current.os.tag == .linux) {
...@@ -306,7 +308,7 @@ pub fn readlink(noalias path: [*:0]const u8, noalias buf_ptr: [*]u8, buf_len: us...@@ -306,7 +308,7 @@ pub fn readlink(noalias path: [*:0]const u8, noalias buf_ptr: [*]u8, buf_len: us
306 if (@hasField(SYS, "readlink")) {308 if (@hasField(SYS, "readlink")) {
307 return syscall3(.readlink, @ptrToInt(path), @ptrToInt(buf_ptr), buf_len);309 return syscall3(.readlink, @ptrToInt(path), @ptrToInt(buf_ptr), buf_len);
308 } else {310 } else {
309 return syscall4(.readlinkat, @bitCast(usize, @as(isize, AT_FDCWD)), @ptrToInt(path), @ptrToInt(buf_ptr), buf_len);311 return syscall4(.readlinkat, @bitCast(usize, @as(isize, AT.FDCWD)), @ptrToInt(path), @ptrToInt(buf_ptr), buf_len);
310 }312 }
311}313}
312314
...@@ -318,7 +320,7 @@ pub fn mkdir(path: [*:0]const u8, mode: u32) usize {...@@ -318,7 +320,7 @@ pub fn mkdir(path: [*:0]const u8, mode: u32) usize {
318 if (@hasField(SYS, "mkdir")) {320 if (@hasField(SYS, "mkdir")) {
319 return syscall2(.mkdir, @ptrToInt(path), mode);321 return syscall2(.mkdir, @ptrToInt(path), mode);
320 } else {322 } else {
321 return syscall3(.mkdirat, @bitCast(usize, @as(isize, AT_FDCWD)), @ptrToInt(path), mode);323 return syscall3(.mkdirat, @bitCast(usize, @as(isize, AT.FDCWD)), @ptrToInt(path), mode);
322 }324 }
323}325}
324326
...@@ -330,7 +332,7 @@ pub fn mknod(path: [*:0]const u8, mode: u32, dev: u32) usize {...@@ -330,7 +332,7 @@ pub fn mknod(path: [*:0]const u8, mode: u32, dev: u32) usize {
330 if (@hasField(SYS, "mknod")) {332 if (@hasField(SYS, "mknod")) {
331 return syscall3(.mknod, @ptrToInt(path), mode, dev);333 return syscall3(.mknod, @ptrToInt(path), mode, dev);
332 } else {334 } else {
333 return mknodat(AT_FDCWD, path, mode, dev);335 return mknodat(AT.FDCWD, path, mode, dev);
334 }336 }
335}337}
336338
...@@ -477,7 +479,7 @@ pub fn rmdir(path: [*:0]const u8) usize {...@@ -477,7 +479,7 @@ pub fn rmdir(path: [*:0]const u8) usize {
477 if (@hasField(SYS, "rmdir")) {479 if (@hasField(SYS, "rmdir")) {
478 return syscall1(.rmdir, @ptrToInt(path));480 return syscall1(.rmdir, @ptrToInt(path));
479 } else {481 } else {
480 return syscall3(.unlinkat, @bitCast(usize, @as(isize, AT_FDCWD)), @ptrToInt(path), AT_REMOVEDIR);482 return syscall3(.unlinkat, @bitCast(usize, @as(isize, AT.FDCWD)), @ptrToInt(path), AT.REMOVEDIR);
481 }483 }
482}484}
483485
...@@ -485,7 +487,7 @@ pub fn symlink(existing: [*:0]const u8, new: [*:0]const u8) usize {...@@ -485,7 +487,7 @@ pub fn symlink(existing: [*:0]const u8, new: [*:0]const u8) usize {
485 if (@hasField(SYS, "symlink")) {487 if (@hasField(SYS, "symlink")) {
486 return syscall2(.symlink, @ptrToInt(existing), @ptrToInt(new));488 return syscall2(.symlink, @ptrToInt(existing), @ptrToInt(new));
487 } else {489 } else {
488 return syscall3(.symlinkat, @ptrToInt(existing), @bitCast(usize, @as(isize, AT_FDCWD)), @ptrToInt(new));490 return syscall3(.symlinkat, @ptrToInt(existing), @bitCast(usize, @as(isize, AT.FDCWD)), @ptrToInt(new));
489 }491 }
490}492}
491493
...@@ -518,9 +520,12 @@ pub fn pread(fd: i32, buf: [*]u8, count: usize, offset: i64) usize {...@@ -518,9 +520,12 @@ pub fn pread(fd: i32, buf: [*]u8, count: usize, offset: i64) usize {
518 }520 }
519 } else {521 } else {
520 // Some architectures (eg. 64bit SPARC) pread is called pread64.522 // Some architectures (eg. 64bit SPARC) pread is called pread64.
521 const S = if (!@hasField(SYS, "pread") and @hasField(SYS, "pread64")) .pread64 else .pread;523 const syscall_number = if (!@hasField(SYS, "pread") and @hasField(SYS, "pread64"))
524 .pread64
525 else
526 .pread;
522 return syscall4(527 return syscall4(
523 S,528 syscall_number,
524 @bitCast(usize, @as(isize, fd)),529 @bitCast(usize, @as(isize, fd)),
525 @ptrToInt(buf),530 @ptrToInt(buf),
526 count,531 count,
...@@ -533,7 +538,7 @@ pub fn access(path: [*:0]const u8, mode: u32) usize {...@@ -533,7 +538,7 @@ pub fn access(path: [*:0]const u8, mode: u32) usize {
533 if (@hasField(SYS, "access")) {538 if (@hasField(SYS, "access")) {
534 return syscall2(.access, @ptrToInt(path), mode);539 return syscall2(.access, @ptrToInt(path), mode);
535 } else {540 } else {
536 return syscall4(.faccessat, @bitCast(usize, @as(isize, AT_FDCWD)), @ptrToInt(path), mode, 0);541 return syscall4(.faccessat, @bitCast(usize, @as(isize, AT.FDCWD)), @ptrToInt(path), mode, 0);
537 }542 }
538}543}
539544
...@@ -613,9 +618,12 @@ pub fn pwrite(fd: i32, buf: [*]const u8, count: usize, offset: i64) usize {...@@ -613,9 +618,12 @@ pub fn pwrite(fd: i32, buf: [*]const u8, count: usize, offset: i64) usize {
613 }618 }
614 } else {619 } else {
615 // Some architectures (eg. 64bit SPARC) pwrite is called pwrite64.620 // Some architectures (eg. 64bit SPARC) pwrite is called pwrite64.
616 const S = if (!@hasField(SYS, "pwrite") and @hasField(SYS, "pwrite64")) .pwrite64 else .pwrite;621 const syscall_number = if (!@hasField(SYS, "pwrite") and @hasField(SYS, "pwrite64"))
622 .pwrite64
623 else
624 .pwrite;
617 return syscall4(625 return syscall4(
618 S,626 syscall_number,
619 @bitCast(usize, @as(isize, fd)),627 @bitCast(usize, @as(isize, fd)),
620 @ptrToInt(buf),628 @ptrToInt(buf),
621 count,629 count,
...@@ -628,9 +636,9 @@ pub fn rename(old: [*:0]const u8, new: [*:0]const u8) usize {...@@ -628,9 +636,9 @@ pub fn rename(old: [*:0]const u8, new: [*:0]const u8) usize {
628 if (@hasField(SYS, "rename")) {636 if (@hasField(SYS, "rename")) {
629 return syscall2(.rename, @ptrToInt(old), @ptrToInt(new));637 return syscall2(.rename, @ptrToInt(old), @ptrToInt(new));
630 } else if (@hasField(SYS, "renameat")) {638 } else if (@hasField(SYS, "renameat")) {
631 return syscall4(.renameat, @bitCast(usize, @as(isize, AT_FDCWD)), @ptrToInt(old), @bitCast(usize, @as(isize, AT_FDCWD)), @ptrToInt(new));639 return syscall4(.renameat, @bitCast(usize, @as(isize, AT.FDCWD)), @ptrToInt(old), @bitCast(usize, @as(isize, AT.FDCWD)), @ptrToInt(new));
632 } else {640 } else {
633 return syscall5(.renameat2, @bitCast(usize, @as(isize, AT_FDCWD)), @ptrToInt(old), @bitCast(usize, @as(isize, AT_FDCWD)), @ptrToInt(new), 0);641 return syscall5(.renameat2, @bitCast(usize, @as(isize, AT.FDCWD)), @ptrToInt(old), @bitCast(usize, @as(isize, AT.FDCWD)), @ptrToInt(new), 0);
634 }642 }
635}643}
636644
...@@ -672,7 +680,7 @@ pub fn open(path: [*:0]const u8, flags: u32, perm: mode_t) usize {...@@ -672,7 +680,7 @@ pub fn open(path: [*:0]const u8, flags: u32, perm: mode_t) usize {
672 } else {680 } else {
673 return syscall4(681 return syscall4(
674 .openat,682 .openat,
675 @bitCast(usize, @as(isize, AT_FDCWD)),683 @bitCast(usize, @as(isize, AT.FDCWD)),
676 @ptrToInt(path),684 @ptrToInt(path),
677 flags,685 flags,
678 perm,686 perm,
...@@ -685,7 +693,7 @@ pub fn create(path: [*:0]const u8, perm: mode_t) usize {...@@ -685,7 +693,7 @@ pub fn create(path: [*:0]const u8, perm: mode_t) usize {
685}693}
686694
687pub fn openat(dirfd: i32, path: [*:0]const u8, flags: u32, mode: mode_t) usize {695pub fn openat(dirfd: i32, path: [*:0]const u8, flags: u32, mode: mode_t) usize {
688 // dirfd could be negative, for example AT_FDCWD is -100696 // dirfd could be negative, for example AT.FDCWD is -100
689 return syscall4(.openat, @bitCast(usize, @as(isize, dirfd)), @ptrToInt(path), flags, mode);697 return syscall4(.openat, @bitCast(usize, @as(isize, dirfd)), @ptrToInt(path), flags, mode);
690}698}
691699
...@@ -759,9 +767,9 @@ pub fn link(oldpath: [*:0]const u8, newpath: [*:0]const u8, flags: i32) usize {...@@ -759,9 +767,9 @@ pub fn link(oldpath: [*:0]const u8, newpath: [*:0]const u8, flags: i32) usize {
759 } else {767 } else {
760 return syscall5(768 return syscall5(
761 .linkat,769 .linkat,
762 @bitCast(usize, @as(isize, AT_FDCWD)),770 @bitCast(usize, @as(isize, AT.FDCWD)),
763 @ptrToInt(oldpath),771 @ptrToInt(oldpath),
764 @bitCast(usize, @as(isize, AT_FDCWD)),772 @bitCast(usize, @as(isize, AT.FDCWD)),
765 @ptrToInt(newpath),773 @ptrToInt(newpath),
766 @bitCast(usize, @as(isize, flags)),774 @bitCast(usize, @as(isize, flags)),
767 );775 );
...@@ -783,7 +791,7 @@ pub fn unlink(path: [*:0]const u8) usize {...@@ -783,7 +791,7 @@ pub fn unlink(path: [*:0]const u8) usize {
783 if (@hasField(SYS, "unlink")) {791 if (@hasField(SYS, "unlink")) {
784 return syscall1(.unlink, @ptrToInt(path));792 return syscall1(.unlink, @ptrToInt(path));
785 } else {793 } else {
786 return syscall3(.unlinkat, @bitCast(usize, @as(isize, AT_FDCWD)), @ptrToInt(path), 0);794 return syscall3(.unlinkat, @bitCast(usize, @as(isize, AT.FDCWD)), @ptrToInt(path), 0);
787 }795 }
788}796}
789797
...@@ -1131,7 +1139,7 @@ pub fn sendmmsg(fd: i32, msgvec: [*]mmsghdr_const, vlen: u32, flags: u32) usize...@@ -1131,7 +1139,7 @@ pub fn sendmmsg(fd: i32, msgvec: [*]mmsghdr_const, vlen: u32, flags: u32) usize
1131 }1139 }
1132 }1140 }
1133 }1141 }
1134 if (next_unsent < kvlen or next_unsent == 0) { // want to make sure at least one syscall occurs (e.g. to trigger MSG_EOR)1142 if (next_unsent < kvlen or next_unsent == 0) { // want to make sure at least one syscall occurs (e.g. to trigger MSG.EOR)
1135 const batch_size = kvlen - next_unsent;1143 const batch_size = kvlen - next_unsent;
1136 const r = syscall4(.sendmmsg, @bitCast(usize, @as(isize, fd)), @ptrToInt(&msgvec[next_unsent]), batch_size, flags);1144 const r = syscall4(.sendmmsg, @bitCast(usize, @as(isize, fd)), @ptrToInt(&msgvec[next_unsent]), batch_size, flags);
1137 if (getErrno(r) != 0) return r;1145 if (getErrno(r) != 0) return r;
...@@ -1759,10 +1767,10 @@ pub const W = struct {...@@ -1759,10 +1767,10 @@ pub const W = struct {
1759 return s & 0x7f;1767 return s & 0x7f;
1760 }1768 }
1761 pub fn STOPSIG(s: u32) u32 {1769 pub fn STOPSIG(s: u32) u32 {
1762 return WEXITSTATUS(s);1770 return EXITSTATUS(s);
1763 }1771 }
1764 pub fn IFEXITED(s: u32) bool {1772 pub fn IFEXITED(s: u32) bool {
1765 return WTERMSIG(s) == 0;1773 return TERMSIG(s) == 0;
1766 }1774 }
1767 pub fn IFSTOPPED(s: u32) bool {1775 pub fn IFSTOPPED(s: u32) bool {
1768 return @intCast(u16, ((s & 0xffff) *% 0x10001) >> 8) > 0x7f00;1776 return @intCast(u16, ((s & 0xffff) *% 0x10001) >> 8) > 0x7f00;
...@@ -2886,31 +2894,51 @@ pub const socklen_t = u32;...@@ -2886,31 +2894,51 @@ pub const socklen_t = u32;
2886pub const sockaddr = extern struct {2894pub const sockaddr = extern struct {
2887 family: sa_family_t,2895 family: sa_family_t,
2888 data: [14]u8,2896 data: [14]u8,
2889};
28902897
2891pub const sockaddr_storage = std.x.os.Socket.Address.Native.Storage;2898 pub const storage = std.x.os.Socket.Address.Native.Storage;
28922899
2893/// IPv4 socket address2900 /// IPv4 socket address
2894pub const sockaddr_in = extern struct {2901 pub const in = extern struct {
2895 family: sa_family_t = AF_INET,2902 family: sa_family_t = AF.INET,
2896 port: in_port_t,2903 port: in_port_t,
2897 addr: u32,2904 addr: u32,
2898 zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },2905 zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },
2899};2906 };
29002907
2901/// IPv6 socket address2908 /// IPv6 socket address
2902pub const sockaddr_in6 = extern struct {2909 pub const in6 = extern struct {
2903 family: sa_family_t = AF_INET6,2910 family: sa_family_t = AF.INET6,
2904 port: in_port_t,2911 port: in_port_t,
2905 flowinfo: u32,2912 flowinfo: u32,
2906 addr: [16]u8,2913 addr: [16]u8,
2907 scope_id: u32,2914 scope_id: u32,
2908};2915 };
2916
2917 /// UNIX domain socket address
2918 pub const un = extern struct {
2919 family: sa_family_t = AF.UNIX,
2920 path: [108]u8,
2921 };
2922
2923 /// Netlink socket address
2924 pub const nl = extern struct {
2925 family: sa_family_t = AF.NETLINK,
2926 __pad1: c_ushort = 0,
2927
2928 /// port ID
2929 pid: u32,
29092930
2910/// UNIX domain socket address2931 /// multicast groups mask
2911pub const sockaddr_un = extern struct {2932 groups: u32,
2912 family: sa_family_t = AF_UNIX,2933 };
2913 path: [108]u8,2934
2935 pub const xdp = extern struct {
2936 family: u16 = AF.XDP,
2937 flags: u16,
2938 ifindex: u32,
2939 queue_id: u32,
2940 shared_umem_fd: u32,
2941 };
2914};2942};
29152943
2916pub const mmsghdr = extern struct {2944pub const mmsghdr = extern struct {
...@@ -3584,43 +3612,47 @@ pub const addrinfo = extern struct {...@@ -3584,43 +3612,47 @@ pub const addrinfo = extern struct {
35843612
3585pub const IPPORT_RESERVED = 1024;3613pub const IPPORT_RESERVED = 1024;
35863614
3587pub const IPPROTO_IP = 0;3615pub const IPPROTO = struct {
3588pub const IPPROTO_HOPOPTS = 0;3616 pub const IP = 0;
3589pub const IPPROTO_ICMP = 1;3617 pub const HOPOPTS = 0;
3590pub const IPPROTO_IGMP = 2;3618 pub const ICMP = 1;
3591pub const IPPROTO_IPIP = 4;3619 pub const IGMP = 2;
3592pub const IPPROTO_TCP = 6;3620 pub const IPIP = 4;
3593pub const IPPROTO_EGP = 8;3621 pub const TCP = 6;
3594pub const IPPROTO_PUP = 12;3622 pub const EGP = 8;
3595pub const IPPROTO_UDP = 17;3623 pub const PUP = 12;
3596pub const IPPROTO_IDP = 22;3624 pub const UDP = 17;
3597pub const IPPROTO_TP = 29;3625 pub const IDP = 22;
3598pub const IPPROTO_DCCP = 33;3626 pub const TP = 29;
3599pub const IPPROTO_IPV6 = 41;3627 pub const DCCP = 33;
3600pub const IPPROTO_ROUTING = 43;3628 pub const IPV6 = 41;
3601pub const IPPROTO_FRAGMENT = 44;3629 pub const ROUTING = 43;
3602pub const IPPROTO_RSVP = 46;3630 pub const FRAGMENT = 44;
3603pub const IPPROTO_GRE = 47;3631 pub const RSVP = 46;
3604pub const IPPROTO_ESP = 50;3632 pub const GRE = 47;
3605pub const IPPROTO_AH = 51;3633 pub const ESP = 50;
3606pub const IPPROTO_ICMPV6 = 58;3634 pub const AH = 51;
3607pub const IPPROTO_NONE = 59;3635 pub const ICMPV6 = 58;
3608pub const IPPROTO_DSTOPTS = 60;3636 pub const NONE = 59;
3609pub const IPPROTO_MTP = 92;3637 pub const DSTOPTS = 60;
3610pub const IPPROTO_BEETPH = 94;3638 pub const MTP = 92;
3611pub const IPPROTO_ENCAP = 98;3639 pub const BEETPH = 94;
3612pub const IPPROTO_PIM = 103;3640 pub const ENCAP = 98;
3613pub const IPPROTO_COMP = 108;3641 pub const PIM = 103;
3614pub const IPPROTO_SCTP = 132;3642 pub const COMP = 108;
3615pub const IPPROTO_MH = 135;3643 pub const SCTP = 132;
3616pub const IPPROTO_UDPLITE = 136;3644 pub const MH = 135;
3617pub const IPPROTO_MPLS = 137;3645 pub const UDPLITE = 136;
3618pub const IPPROTO_RAW = 255;3646 pub const MPLS = 137;
3619pub const IPPROTO_MAX = 256;3647 pub const RAW = 255;
36203648 pub const MAX = 256;
3621pub const RR_A = 1;3649};
3622pub const RR_CNAME = 5;3650
3623pub const RR_AAAA = 28;3651pub const RR = struct {
3652 pub const A = 1;
3653 pub const CNAME = 5;
3654 pub const AAAA = 28;
3655};
36243656
3625/// Turn off Nagle's algorithm3657/// Turn off Nagle's algorithm
3626pub const TCP_NODELAY = 1;3658pub const TCP_NODELAY = 1;
...@@ -3746,14 +3778,16 @@ pub const pollfd = extern struct {...@@ -3746,14 +3778,16 @@ pub const pollfd = extern struct {
3746 revents: i16,3778 revents: i16,
3747};3779};
37483780
3749pub const POLLIN = 0x001;3781pub const POLL = struct {
3750pub const POLLPRI = 0x002;3782 pub const IN = 0x001;
3751pub const POLLOUT = 0x004;3783 pub const PRI = 0x002;
3752pub const POLLERR = 0x008;3784 pub const OUT = 0x004;
3753pub const POLLHUP = 0x010;3785 pub const ERR = 0x008;
3754pub const POLLNVAL = 0x020;3786 pub const HUP = 0x010;
3755pub const POLLRDNORM = 0x040;3787 pub const NVAL = 0x020;
3756pub const POLLRDBAND = 0x080;3788 pub const RDNORM = 0x040;
3789 pub const RDBAND = 0x080;
3790};
37573791
3758pub const MFD_CLOEXEC = 0x0001;3792pub const MFD_CLOEXEC = 0x0001;
3759pub const MFD_ALLOW_SEALING = 0x0002;3793pub const MFD_ALLOW_SEALING = 0x0002;
...@@ -4097,11 +4131,13 @@ pub const rlimit_resource = enum(c_int) {...@@ -4097,11 +4131,13 @@ pub const rlimit_resource = enum(c_int) {
40974131
4098pub const rlim_t = u64;4132pub const rlim_t = u64;
40994133
4100/// No limit4134pub const RLIM = struct {
4101pub const RLIM_INFINITY = ~@as(rlim_t, 0);4135 /// No limit
4136 pub const INFINITY = ~@as(rlim_t, 0);
41024137
4103pub const RLIM_SAVED_MAX = RLIM_INFINITY;4138 pub const SAVED_MAX = INFINITY;
4104pub const RLIM_SAVED_CUR = RLIM_INFINITY;4139 pub const SAVED_CUR = INFINITY;
4140};
41054141
4106pub const rlimit = extern struct {4142pub const rlimit = extern struct {
4107 /// Soft limit4143 /// Soft limit
...@@ -4189,14 +4225,6 @@ pub const XDP = struct {...@@ -4189,14 +4225,6 @@ pub const XDP = struct {
4189 pub const UMEM_PGOFF_COMPLETION_RING = 0x180000000;4225 pub const UMEM_PGOFF_COMPLETION_RING = 0x180000000;
4190};4226};
41914227
4192pub const sockaddr_xdp = extern struct {
4193 family: u16 = AF_XDP,
4194 flags: u16,
4195 ifindex: u32,
4196 queue_id: u32,
4197 shared_umem_fd: u32,
4198};
4199
4200pub const xdp_ring_offset = extern struct {4228pub const xdp_ring_offset = extern struct {
4201 producer: u64,4229 producer: u64,
4202 consumer: u64,4230 consumer: u64,
...@@ -4673,18 +4701,6 @@ pub const NetlinkMessageType = enum(u16) {...@@ -4673,18 +4701,6 @@ pub const NetlinkMessageType = enum(u16) {
4673 _,4701 _,
4674};4702};
46754703
4676/// Netlink socket address
4677pub const sockaddr_nl = extern struct {
4678 family: sa_family_t = AF_NETLINK,
4679 __pad1: c_ushort = 0,
4680
4681 /// port ID
4682 pid: u32,
4683
4684 /// multicast groups mask
4685 groups: u32,
4686};
4687
4688/// Netlink message header4704/// Netlink message header
4689/// Specified in RFC 3549 Section 2.3.24705/// Specified in RFC 3549 Section 2.3.2
4690pub const nlmsghdr = extern struct {4706pub const nlmsghdr = extern struct {
lib/std/os/linux/arm-eabi.zig+20-19
...@@ -575,26 +575,27 @@ pub const F_GETOWN_EX = 16;...@@ -575,26 +575,27 @@ pub const F_GETOWN_EX = 16;
575575
576pub const F_GETOWNER_UIDS = 17;576pub const F_GETOWNER_UIDS = 17;
577577
578pub const LOCK_SH = 1;578pub const LOCK = struct {
579pub const LOCK_EX = 2;579 pub const SH = 1;
580pub const LOCK_UN = 8;580 pub const EX = 2;
581pub const LOCK_NB = 4;581 pub const UN = 8;
582582 pub const NB = 4;
583/// stack-like segment583};
584pub const MAP_GROWSDOWN = 0x0100;
585
586/// ETXTBSY
587pub const MAP_DENYWRITE = 0x0800;
588
589/// mark it as an executable
590pub const MAP_EXECUTABLE = 0x1000;
591
592/// pages are locked
593pub const MAP_LOCKED = 0x2000;
594
595/// don't check for reservations
596pub const MAP_NORESERVE = 0x4000;
597584
585pub const MAP = struct {
586 /// stack-like segment
587 pub const GROWSDOWN = 0x0100;
588 /// ETXTBSY
589 pub const DENYWRITE = 0x0800;
590 /// mark it as an executable
591 pub const EXECUTABLE = 0x1000;
592 /// pages are locked
593 pub const LOCKED = 0x2000;
594 /// don't check for reservations
595 pub const NORESERVE = 0x4000;
596 /// Only used by libc to communicate failure.
597 pub const FAILED = @intToPtr(*c_void, maxInt(usize));
598};
598pub const VDSO_CGT_SYM = "__vdso_clock_gettime";599pub const VDSO_CGT_SYM = "__vdso_clock_gettime";
599pub const VDSO_CGT_VER = "LINUX_2.6";600pub const VDSO_CGT_VER = "LINUX_2.6";
600601
lib/std/os/linux/arm64.zig+20-19
...@@ -449,31 +449,32 @@ pub const F_RDLCK = 0;...@@ -449,31 +449,32 @@ pub const F_RDLCK = 0;
449pub const F_WRLCK = 1;449pub const F_WRLCK = 1;
450pub const F_UNLCK = 2;450pub const F_UNLCK = 2;
451451
452pub const LOCK_SH = 1;452pub const LOCK = struct {
453pub const LOCK_EX = 2;453 pub const SH = 1;
454pub const LOCK_UN = 8;454 pub const EX = 2;
455pub const LOCK_NB = 4;455 pub const UN = 8;
456 pub const NB = 4;
457};
456458
457pub const F_SETOWN_EX = 15;459pub const F_SETOWN_EX = 15;
458pub const F_GETOWN_EX = 16;460pub const F_GETOWN_EX = 16;
459461
460pub const F_GETOWNER_UIDS = 17;462pub const F_GETOWNER_UIDS = 17;
461463
462/// stack-like segment464pub const MAP = struct {
463pub const MAP_GROWSDOWN = 0x0100;465 /// stack-like segment
464466 pub const GROWSDOWN = 0x0100;
465/// ETXTBSY467 /// ETXTBSY
466pub const MAP_DENYWRITE = 0x0800;468 pub const DENYWRITE = 0x0800;
467469 /// mark it as an executable
468/// mark it as an executable470 pub const EXECUTABLE = 0x1000;
469pub const MAP_EXECUTABLE = 0x1000;471 /// pages are locked
470472 pub const LOCKED = 0x2000;
471/// pages are locked473 /// don't check for reservations
472pub const MAP_LOCKED = 0x2000;474 pub const NORESERVE = 0x4000;
473475 /// Only used by libc to communicate failure.
474/// don't check for reservations476 pub const FAILED = @intToPtr(*c_void, maxInt(usize));
475pub const MAP_NORESERVE = 0x4000;477};
476
477pub const VDSO_CGT_SYM = "__kernel_clock_gettime";478pub const VDSO_CGT_SYM = "__kernel_clock_gettime";
478pub const VDSO_CGT_VER = "LINUX_2.6.39";479pub const VDSO_CGT_VER = "LINUX_2.6.39";
479480
lib/std/os/linux/i386.zig+3
...@@ -671,6 +671,9 @@ pub const MAP = struct {...@@ -671,6 +671,9 @@ pub const MAP = struct {
671 pub const EXECUTABLE = 0x1000;671 pub const EXECUTABLE = 0x1000;
672 pub const LOCKED = 0x2000;672 pub const LOCKED = 0x2000;
673 pub const @"32BIT" = 0x40;673 pub const @"32BIT" = 0x40;
674
675 /// Only used by libc to communicate failure.
676 pub const FAILED = @intToPtr(*c_void, maxInt(usize));
674};677};
675678
676pub const MMAP2_UNIT = 4096;679pub const MMAP2_UNIT = 4096;
lib/std/os/linux/io_uring.zig+8-8
...@@ -535,7 +535,7 @@ pub const IO_Uring = struct {...@@ -535,7 +535,7 @@ pub const IO_Uring = struct {
535 /// `0` if the timeout completed after the specified number of events, or `-ECANCELED` if the535 /// `0` if the timeout completed after the specified number of events, or `-ECANCELED` if the
536 /// timeout was removed before it expired.536 /// timeout was removed before it expired.
537 ///537 ///
538 /// io_uring timeouts use the `CLOCK_MONOTONIC` clock source.538 /// io_uring timeouts use the `CLOCK.MONOTONIC` clock source.
539 pub fn timeout(539 pub fn timeout(
540 self: *IO_Uring,540 self: *IO_Uring,
541 user_data: u64,541 user_data: u64,
...@@ -736,8 +736,8 @@ pub const SubmissionQueue = struct {...@@ -736,8 +736,8 @@ pub const SubmissionQueue = struct {
736 const mmap = try os.mmap(736 const mmap = try os.mmap(
737 null,737 null,
738 size,738 size,
739 os.PROT_READ | os.PROT_WRITE,739 os.PROT.READ | os.PROT.WRITE,
740 os.MAP_SHARED | os.MAP_POPULATE,740 os.MAP.SHARED | os.MAP.POPULATE,
741 fd,741 fd,
742 linux.IORING_OFF_SQ_RING,742 linux.IORING_OFF_SQ_RING,
743 );743 );
...@@ -750,8 +750,8 @@ pub const SubmissionQueue = struct {...@@ -750,8 +750,8 @@ pub const SubmissionQueue = struct {
750 const mmap_sqes = try os.mmap(750 const mmap_sqes = try os.mmap(
751 null,751 null,
752 size_sqes,752 size_sqes,
753 os.PROT_READ | os.PROT_WRITE,753 os.PROT.READ | os.PROT.WRITE,
754 os.MAP_SHARED | os.MAP_POPULATE,754 os.MAP.SHARED | os.MAP.POPULATE,
755 fd,755 fd,
756 linux.IORING_OFF_SQES,756 linux.IORING_OFF_SQES,
757 );757 );
...@@ -1372,9 +1372,9 @@ test "accept/connect/send/recv" {...@@ -1372,9 +1372,9 @@ test "accept/connect/send/recv" {
13721372
1373 const address = try net.Address.parseIp4("127.0.0.1", 3131);1373 const address = try net.Address.parseIp4("127.0.0.1", 3131);
1374 const kernel_backlog = 1;1374 const kernel_backlog = 1;
1375 const server = try os.socket(address.any.family, os.SOCK_STREAM | os.SOCK_CLOEXEC, 0);1375 const server = try os.socket(address.any.family, os.SOCK.STREAM | os.SOCK.CLOEXEC, 0);
1376 defer os.close(server);1376 defer os.close(server);
1377 try os.setsockopt(server, os.SOL_SOCKET, os.SO_REUSEADDR, &mem.toBytes(@as(c_int, 1)));1377 try os.setsockopt(server, os.SOL.SOCKET, os.SO.REUSEADDR, &mem.toBytes(@as(c_int, 1)));
1378 try os.bind(server, &address.any, address.getOsSockLen());1378 try os.bind(server, &address.any, address.getOsSockLen());
1379 try os.listen(server, kernel_backlog);1379 try os.listen(server, kernel_backlog);
13801380
...@@ -1386,7 +1386,7 @@ test "accept/connect/send/recv" {...@@ -1386,7 +1386,7 @@ test "accept/connect/send/recv" {
1386 _ = try ring.accept(0xaaaaaaaa, server, &accept_addr, &accept_addr_len, 0);1386 _ = try ring.accept(0xaaaaaaaa, server, &accept_addr, &accept_addr_len, 0);
1387 try testing.expectEqual(@as(u32, 1), try ring.submit());1387 try testing.expectEqual(@as(u32, 1), try ring.submit());
13881388
1389 const client = try os.socket(address.any.family, os.SOCK_STREAM | os.SOCK_CLOEXEC, 0);1389 const client = try os.socket(address.any.family, os.SOCK.STREAM | os.SOCK.CLOEXEC, 0);
1390 defer os.close(client);1390 defer os.close(client);
1391 _ = try ring.connect(0xcccccccc, client, &address.any, address.getOsSockLen());1391 _ = try ring.connect(0xcccccccc, client, &address.any, address.getOsSockLen());
1392 try testing.expectEqual(@as(u32, 1), try ring.submit());1392 try testing.expectEqual(@as(u32, 1), try ring.submit());
lib/std/os/linux/mips.zig+46-38
...@@ -668,10 +668,12 @@ pub const F_RDLCK = 0;...@@ -668,10 +668,12 @@ pub const F_RDLCK = 0;
668pub const F_WRLCK = 1;668pub const F_WRLCK = 1;
669pub const F_UNLCK = 2;669pub const F_UNLCK = 2;
670670
671pub const LOCK_SH = 1;671pub const LOCK = struct {
672pub const LOCK_EX = 2;672 pub const SH = 1;
673pub const LOCK_UN = 8;673 pub const EX = 2;
674pub const LOCK_NB = 4;674 pub const UN = 8;
675 pub const NB = 4;
676};
675677
676pub const F_SETOWN_EX = 15;678pub const F_SETOWN_EX = 15;
677pub const F_GETOWN_EX = 16;679pub const F_GETOWN_EX = 16;
...@@ -680,40 +682,46 @@ pub const F_GETOWNER_UIDS = 17;...@@ -680,40 +682,46 @@ pub const F_GETOWNER_UIDS = 17;
680682
681pub const MMAP2_UNIT = 4096;683pub const MMAP2_UNIT = 4096;
682684
683pub const MAP_NORESERVE = 0x0400;685pub const MAP = struct {
684pub const MAP_GROWSDOWN = 0x1000;686 pub const NORESERVE = 0x0400;
685pub const MAP_DENYWRITE = 0x2000;687 pub const GROWSDOWN = 0x1000;
686pub const MAP_EXECUTABLE = 0x4000;688 pub const DENYWRITE = 0x2000;
687pub const MAP_LOCKED = 0x8000;689 pub const EXECUTABLE = 0x4000;
688pub const MAP_32BIT = 0x40;690 pub const LOCKED = 0x8000;
689691 pub const @"32BIT" = 0x40;
690pub const SO_DEBUG = 1;692 /// Only used by libc to communicate failure.
691pub const SO_REUSEADDR = 0x0004;693 pub const FAILED = @intToPtr(*c_void, maxInt(usize));
692pub const SO_KEEPALIVE = 0x0008;694};
693pub const SO_DONTROUTE = 0x0010;695
694pub const SO_BROADCAST = 0x0020;696pub const SO = struct {
695pub const SO_LINGER = 0x0080;697 pub const DEBUG = 1;
696pub const SO_OOBINLINE = 0x0100;698 pub const REUSEADDR = 0x0004;
697pub const SO_REUSEPORT = 0x0200;699 pub const KEEPALIVE = 0x0008;
698pub const SO_SNDBUF = 0x1001;700 pub const DONTROUTE = 0x0010;
699pub const SO_RCVBUF = 0x1002;701 pub const BROADCAST = 0x0020;
700pub const SO_SNDLOWAT = 0x1003;702 pub const LINGER = 0x0080;
701pub const SO_RCVLOWAT = 0x1004;703 pub const OOBINLINE = 0x0100;
702pub const SO_RCVTIMEO = 0x1006;704 pub const REUSEPORT = 0x0200;
703pub const SO_SNDTIMEO = 0x1005;705 pub const SNDBUF = 0x1001;
704pub const SO_ERROR = 0x1007;706 pub const RCVBUF = 0x1002;
705pub const SO_TYPE = 0x1008;707 pub const SNDLOWAT = 0x1003;
706pub const SO_ACCEPTCONN = 0x1009;708 pub const RCVLOWAT = 0x1004;
707pub const SO_PROTOCOL = 0x1028;709 pub const RCVTIMEO = 0x1006;
708pub const SO_DOMAIN = 0x1029;710 pub const SNDTIMEO = 0x1005;
709pub const SO_NO_CHECK = 11;711 pub const ERROR = 0x1007;
710pub const SO_PRIORITY = 12;712 pub const TYPE = 0x1008;
711pub const SO_BSDCOMPAT = 14;713 pub const ACCEPTCONN = 0x1009;
712pub const SO_PASSCRED = 17;714 pub const PROTOCOL = 0x1028;
713pub const SO_PEERCRED = 18;715 pub const DOMAIN = 0x1029;
714pub const SO_PEERSEC = 30;716 pub const NO_CHECK = 11;
715pub const SO_SNDBUFFORCE = 31;717 pub const PRIORITY = 12;
716pub const SO_RCVBUFFORCE = 33;718 pub const BSDCOMPAT = 14;
719 pub const PASSCRED = 17;
720 pub const PEERCRED = 18;
721 pub const PEERSEC = 30;
722 pub const SNDBUFFORCE = 31;
723 pub const RCVBUFFORCE = 33;
724};
717725
718pub const VDSO_CGT_SYM = "__kernel_clock_gettime";726pub const VDSO_CGT_SYM = "__kernel_clock_gettime";
719pub const VDSO_CGT_VER = "LINUX_2.6.39";727pub const VDSO_CGT_VER = "LINUX_2.6.39";
lib/std/os/linux/powerpc.zig+20-19
...@@ -605,26 +605,27 @@ pub const F_RDLCK = 0;...@@ -605,26 +605,27 @@ pub const F_RDLCK = 0;
605pub const F_WRLCK = 1;605pub const F_WRLCK = 1;
606pub const F_UNLCK = 2;606pub const F_UNLCK = 2;
607607
608pub const LOCK_SH = 1;608pub const LOCK = struct {
609pub const LOCK_EX = 2;609 pub const SH = 1;
610pub const LOCK_UN = 8;610 pub const EX = 2;
611pub const LOCK_NB = 4;611 pub const UN = 8;
612612 pub const NB = 4;
613/// stack-like segment613};
614pub const MAP_GROWSDOWN = 0x0100;
615
616/// ETXTBSY
617pub const MAP_DENYWRITE = 0x0800;
618
619/// mark it as an executable
620pub const MAP_EXECUTABLE = 0x1000;
621
622/// pages are locked
623pub const MAP_LOCKED = 0x0080;
624
625/// don't check for reservations
626pub const MAP_NORESERVE = 0x0040;
627614
615pub const MAP = struct {
616 /// stack-like segment
617 pub const GROWSDOWN = 0x0100;
618 /// ETXTBSY
619 pub const DENYWRITE = 0x0800;
620 /// mark it as an executable
621 pub const EXECUTABLE = 0x1000;
622 /// pages are locked
623 pub const LOCKED = 0x0080;
624 /// don't check for reservations
625 pub const NORESERVE = 0x0040;
626 /// Only used by libc to communicate failure.
627 pub const FAILED = @intToPtr(*c_void, maxInt(usize));
628};
628pub const VDSO_CGT_SYM = "__kernel_clock_gettime";629pub const VDSO_CGT_SYM = "__kernel_clock_gettime";
629pub const VDSO_CGT_VER = "LINUX_2.6.15";630pub const VDSO_CGT_VER = "LINUX_2.6.15";
630631
lib/std/os/linux/powerpc64.zig+20-18
...@@ -575,30 +575,32 @@ pub const F_RDLCK = 0;...@@ -575,30 +575,32 @@ pub const F_RDLCK = 0;
575pub const F_WRLCK = 1;575pub const F_WRLCK = 1;
576pub const F_UNLCK = 2;576pub const F_UNLCK = 2;
577577
578pub const LOCK_SH = 1;578pub const LOCK = struct {
579pub const LOCK_EX = 2;579 pub const SH = 1;
580pub const LOCK_UN = 8;580 pub const EX = 2;
581pub const LOCK_NB = 4;581 pub const UN = 8;
582 pub const NB = 4;
583};
582584
583pub const F_SETOWN_EX = 15;585pub const F_SETOWN_EX = 15;
584pub const F_GETOWN_EX = 16;586pub const F_GETOWN_EX = 16;
585587
586pub const F_GETOWNER_UIDS = 17;588pub const F_GETOWNER_UIDS = 17;
587589
588/// stack-like segment590pub const MAP = struct {
589pub const MAP_GROWSDOWN = 0x0100;591 /// stack-like segment
590592 pub const GROWSDOWN = 0x0100;
591/// ETXTBSY593 /// ETXTBSY
592pub const MAP_DENYWRITE = 0x0800;594 pub const DENYWRITE = 0x0800;
593595 /// mark it as an executable
594/// mark it as an executable596 pub const EXECUTABLE = 0x1000;
595pub const MAP_EXECUTABLE = 0x1000;597 /// pages are locked
596598 pub const LOCKED = 0x0080;
597/// pages are locked599 /// don't check for reservations
598pub const MAP_LOCKED = 0x0080;600 pub const NORESERVE = 0x0040;
599601 /// Only used by libc to communicate failure.
600/// don't check for reservations602 pub const FAILED = @intToPtr(*c_void, maxInt(usize));
601pub const MAP_NORESERVE = 0x0040;603};
602604
603pub const VDSO_CGT_SYM = "__kernel_clock_gettime";605pub const VDSO_CGT_SYM = "__kernel_clock_gettime";
604pub const VDSO_CGT_VER = "LINUX_2.6.15";606pub const VDSO_CGT_VER = "LINUX_2.6.15";
lib/std/os/linux/riscv64.zig+6-4
...@@ -444,10 +444,12 @@ pub const F_RDLCK = 0;...@@ -444,10 +444,12 @@ pub const F_RDLCK = 0;
444pub const F_WRLCK = 1;444pub const F_WRLCK = 1;
445pub const F_UNLCK = 2;445pub const F_UNLCK = 2;
446446
447pub const LOCK_SH = 1;447pub const LOCK = struct {
448pub const LOCK_EX = 2;448 pub const SH = 1;
449pub const LOCK_UN = 8;449 pub const EX = 2;
450pub const LOCK_NB = 4;450 pub const UN = 8;
451 pub const NB = 4;
452};
451453
452pub const F_SETOWN_EX = 15;454pub const F_SETOWN_EX = 15;
453pub const F_GETOWN_EX = 16;455pub const F_GETOWN_EX = 16;
lib/std/os/linux/sparc64.zig+20-19
...@@ -612,26 +612,27 @@ pub const F_GETOWN_EX = 16;...@@ -612,26 +612,27 @@ pub const F_GETOWN_EX = 16;
612612
613pub const F_GETOWNER_UIDS = 17;613pub const F_GETOWNER_UIDS = 17;
614614
615pub const LOCK_SH = 1;615pub const LOCK = struct {
616pub const LOCK_EX = 2;616 pub const SH = 1;
617pub const LOCK_NB = 4;617 pub const EX = 2;
618pub const LOCK_UN = 8;618 pub const NB = 4;
619619 pub const UN = 8;
620/// stack-like segment620};
621pub const MAP_GROWSDOWN = 0x0200;
622
623/// ETXTBSY
624pub const MAP_DENYWRITE = 0x0800;
625
626/// mark it as an executable
627pub const MAP_EXECUTABLE = 0x1000;
628
629/// pages are locked
630pub const MAP_LOCKED = 0x0100;
631
632/// don't check for reservations
633pub const MAP_NORESERVE = 0x0040;
634621
622pub const MAP = struct {
623 /// stack-like segment
624 pub const GROWSDOWN = 0x0200;
625 /// ETXTBSY
626 pub const DENYWRITE = 0x0800;
627 /// mark it as an executable
628 pub const EXECUTABLE = 0x1000;
629 /// pages are locked
630 pub const LOCKED = 0x0100;
631 /// don't check for reservations
632 pub const NORESERVE = 0x0040;
633 /// Only used by libc to communicate failure.
634 pub const FAILED = @intToPtr(*c_void, maxInt(usize));
635};
635pub const VDSO_CGT_SYM = "__vdso_clock_gettime";636pub const VDSO_CGT_SYM = "__vdso_clock_gettime";
636pub const VDSO_CGT_VER = "LINUX_2.6";637pub const VDSO_CGT_VER = "LINUX_2.6";
637638
lib/std/os/linux/test.zig+6-6
...@@ -35,7 +35,7 @@ test "timer" {...@@ -35,7 +35,7 @@ test "timer" {
35 var err: linux.E = linux.getErrno(epoll_fd);35 var err: linux.E = linux.getErrno(epoll_fd);
36 try expect(err == .SUCCESS);36 try expect(err == .SUCCESS);
3737
38 const timer_fd = linux.timerfd_create(linux.CLOCK_MONOTONIC, 0);38 const timer_fd = linux.timerfd_create(linux.CLOCK.MONOTONIC, 0);
39 try expect(linux.getErrno(timer_fd) == .SUCCESS);39 try expect(linux.getErrno(timer_fd) == .SUCCESS);
4040
41 const time_interval = linux.timespec{41 const time_interval = linux.timespec{
...@@ -52,11 +52,11 @@ test "timer" {...@@ -52,11 +52,11 @@ test "timer" {
52 try expect(err == .SUCCESS);52 try expect(err == .SUCCESS);
5353
54 var event = linux.epoll_event{54 var event = linux.epoll_event{
55 .events = linux.EPOLLIN | linux.EPOLLOUT | linux.EPOLLET,55 .events = linux.EPOLL.IN | linux.EPOLL.OUT | linux.EPOLL.ET,
56 .data = linux.epoll_data{ .ptr = 0 },56 .data = linux.epoll_data{ .ptr = 0 },
57 };57 };
5858
59 err = linux.getErrno(linux.epoll_ctl(@intCast(i32, epoll_fd), linux.EPOLL_CTL_ADD, @intCast(i32, timer_fd), &event));59 err = linux.getErrno(linux.epoll_ctl(@intCast(i32, epoll_fd), linux.EPOLL.CTL_ADD, @intCast(i32, timer_fd), &event));
60 try expect(err == .SUCCESS);60 try expect(err == .SUCCESS);
6161
62 const events_one: linux.epoll_event = undefined;62 const events_one: linux.epoll_event = undefined;
...@@ -75,7 +75,7 @@ test "statx" {...@@ -75,7 +75,7 @@ test "statx" {
75 }75 }
7676
77 var statx_buf: linux.Statx = undefined;77 var statx_buf: linux.Statx = undefined;
78 switch (linux.getErrno(linux.statx(file.handle, "", linux.AT_EMPTY_PATH, linux.STATX_BASIC_STATS, &statx_buf))) {78 switch (linux.getErrno(linux.statx(file.handle, "", linux.AT.EMPTY_PATH, linux.STATX_BASIC_STATS, &statx_buf))) {
79 .SUCCESS => {},79 .SUCCESS => {},
80 // The statx syscall was only introduced in linux 4.1180 // The statx syscall was only introduced in linux 4.11
81 .NOSYS => return error.SkipZigTest,81 .NOSYS => return error.SkipZigTest,
...@@ -83,7 +83,7 @@ test "statx" {...@@ -83,7 +83,7 @@ test "statx" {
83 }83 }
8484
85 var stat_buf: linux.Stat = undefined;85 var stat_buf: linux.Stat = undefined;
86 switch (linux.getErrno(linux.fstatat(file.handle, "", &stat_buf, linux.AT_EMPTY_PATH))) {86 switch (linux.getErrno(linux.fstatat(file.handle, "", &stat_buf, linux.AT.EMPTY_PATH))) {
87 .SUCCESS => {},87 .SUCCESS => {},
88 else => unreachable,88 else => unreachable,
89 }89 }
...@@ -119,7 +119,7 @@ test "fadvise" {...@@ -119,7 +119,7 @@ test "fadvise" {
119 file.handle,119 file.handle,
120 0,120 0,
121 0,121 0,
122 linux.POSIX_FADV_SEQUENTIAL,122 linux.POSIX_FADV.SEQUENTIAL,
123 );123 );
124 try expectEqual(@as(usize, 0), ret);124 try expectEqual(@as(usize, 0), ret);
125}125}
lib/std/os/linux/x86_64.zig+3-17
...@@ -1,4 +1,5 @@...@@ -1,4 +1,5 @@
1const std = @import("../../std.zig");1const std = @import("../../std.zig");
2const maxInt = std.math.maxInt;
2const linux = std.os.linux;3const linux = std.os.linux;
3const iovec = std.os.iovec;4const iovec = std.os.iovec;
4const iovec_const = std.os.iovec_const;5const iovec_const = std.os.iovec_const;
...@@ -527,59 +528,44 @@ pub const F = struct {...@@ -527,59 +528,44 @@ pub const F = struct {
527pub const MAP = struct {528pub const MAP = struct {
528 /// Share changes529 /// Share changes
529 pub const SHARED = 0x01;530 pub const SHARED = 0x01;
530
531 /// Changes are private531 /// Changes are private
532 pub const PRIVATE = 0x02;532 pub const PRIVATE = 0x02;
533
534 /// share + validate extension flags533 /// share + validate extension flags
535 pub const SHARED_VALIDATE = 0x03;534 pub const SHARED_VALIDATE = 0x03;
536
537 /// Mask for type of mapping535 /// Mask for type of mapping
538 pub const TYPE = 0x0f;536 pub const TYPE = 0x0f;
539
540 /// Interpret addr exactly537 /// Interpret addr exactly
541 pub const FIXED = 0x10;538 pub const FIXED = 0x10;
542
543 /// don't use a file539 /// don't use a file
544 pub const ANONYMOUS = 0x20;540 pub const ANONYMOUS = 0x20;
545
546 /// populate (prefault) pagetables541 /// populate (prefault) pagetables
547 pub const POPULATE = 0x8000;542 pub const POPULATE = 0x8000;
548
549 /// do not block on IO543 /// do not block on IO
550 pub const NONBLOCK = 0x10000;544 pub const NONBLOCK = 0x10000;
551
552 /// give out an address that is best suited for process/thread stacks545 /// give out an address that is best suited for process/thread stacks
553 pub const STACK = 0x20000;546 pub const STACK = 0x20000;
554
555 /// create a huge page mapping547 /// create a huge page mapping
556 pub const HUGETLB = 0x40000;548 pub const HUGETLB = 0x40000;
557
558 /// perform synchronous page faults for the mapping549 /// perform synchronous page faults for the mapping
559 pub const SYNC = 0x80000;550 pub const SYNC = 0x80000;
560
561 /// FIXED which doesn't unmap underlying mapping551 /// FIXED which doesn't unmap underlying mapping
562 pub const FIXED_NOREPLACE = 0x100000;552 pub const FIXED_NOREPLACE = 0x100000;
563
564 /// For anonymous mmap, memory could be uninitialized553 /// For anonymous mmap, memory could be uninitialized
565 pub const UNINITIALIZED = 0x4000000;554 pub const UNINITIALIZED = 0x4000000;
566 /// only give out 32bit addresses555 /// only give out 32bit addresses
567 pub const @"32BIT" = 0x40;556 pub const @"32BIT" = 0x40;
568
569 /// stack-like segment557 /// stack-like segment
570 pub const GROWSDOWN = 0x0100;558 pub const GROWSDOWN = 0x0100;
571
572 /// ETXTBSY559 /// ETXTBSY
573 pub const DENYWRITE = 0x0800;560 pub const DENYWRITE = 0x0800;
574
575 /// mark it as an executable561 /// mark it as an executable
576 pub const EXECUTABLE = 0x1000;562 pub const EXECUTABLE = 0x1000;
577
578 /// pages are locked563 /// pages are locked
579 pub const LOCKED = 0x2000;564 pub const LOCKED = 0x2000;
580
581 /// don't check for reservations565 /// don't check for reservations
582 pub const NORESERVE = 0x4000;566 pub const NORESERVE = 0x4000;
567 /// Only used by libc to communicate failure.
568 pub const FAILED = @intToPtr(*c_void, maxInt(usize));
583};569};
584570
585pub const VDSO = struct {571pub const VDSO = struct {
lib/std/os/test.zig+37-37
...@@ -70,21 +70,21 @@ test "open smoke test" {...@@ -70,21 +70,21 @@ test "open smoke test" {
7070
71 // Create some file using `open`.71 // Create some file using `open`.
72 file_path = try fs.path.join(&arena.allocator, &[_][]const u8{ base_path, "some_file" });72 file_path = try fs.path.join(&arena.allocator, &[_][]const u8{ base_path, "some_file" });
73 fd = try os.open(file_path, os.O_RDWR | os.O_CREAT | os.O_EXCL, mode);73 fd = try os.open(file_path, os.O.RDWR | os.O.CREAT | os.O.EXCL, mode);
74 os.close(fd);74 os.close(fd);
7575
76 // Try this again with the same flags. This op should fail with error.PathAlreadyExists.76 // Try this again with the same flags. This op should fail with error.PathAlreadyExists.
77 file_path = try fs.path.join(&arena.allocator, &[_][]const u8{ base_path, "some_file" });77 file_path = try fs.path.join(&arena.allocator, &[_][]const u8{ base_path, "some_file" });
78 try expectError(error.PathAlreadyExists, os.open(file_path, os.O_RDWR | os.O_CREAT | os.O_EXCL, mode));78 try expectError(error.PathAlreadyExists, os.open(file_path, os.O.RDWR | os.O.CREAT | os.O.EXCL, mode));
7979
80 // Try opening without `O_EXCL` flag.80 // Try opening without `O.EXCL` flag.
81 file_path = try fs.path.join(&arena.allocator, &[_][]const u8{ base_path, "some_file" });81 file_path = try fs.path.join(&arena.allocator, &[_][]const u8{ base_path, "some_file" });
82 fd = try os.open(file_path, os.O_RDWR | os.O_CREAT, mode);82 fd = try os.open(file_path, os.O.RDWR | os.O.CREAT, mode);
83 os.close(fd);83 os.close(fd);
8484
85 // Try opening as a directory which should fail.85 // Try opening as a directory which should fail.
86 file_path = try fs.path.join(&arena.allocator, &[_][]const u8{ base_path, "some_file" });86 file_path = try fs.path.join(&arena.allocator, &[_][]const u8{ base_path, "some_file" });
87 try expectError(error.NotDir, os.open(file_path, os.O_RDWR | os.O_DIRECTORY, mode));87 try expectError(error.NotDir, os.open(file_path, os.O.RDWR | os.O.DIRECTORY, mode));
8888
89 // Create some directory89 // Create some directory
90 file_path = try fs.path.join(&arena.allocator, &[_][]const u8{ base_path, "some_dir" });90 file_path = try fs.path.join(&arena.allocator, &[_][]const u8{ base_path, "some_dir" });
...@@ -92,12 +92,12 @@ test "open smoke test" {...@@ -92,12 +92,12 @@ test "open smoke test" {
9292
93 // Open dir using `open`93 // Open dir using `open`
94 file_path = try fs.path.join(&arena.allocator, &[_][]const u8{ base_path, "some_dir" });94 file_path = try fs.path.join(&arena.allocator, &[_][]const u8{ base_path, "some_dir" });
95 fd = try os.open(file_path, os.O_RDONLY | os.O_DIRECTORY, mode);95 fd = try os.open(file_path, os.O.RDONLY | os.O.DIRECTORY, mode);
96 os.close(fd);96 os.close(fd);
9797
98 // Try opening as file which should fail.98 // Try opening as file which should fail.
99 file_path = try fs.path.join(&arena.allocator, &[_][]const u8{ base_path, "some_dir" });99 file_path = try fs.path.join(&arena.allocator, &[_][]const u8{ base_path, "some_dir" });
100 try expectError(error.IsDir, os.open(file_path, os.O_RDWR, mode));100 try expectError(error.IsDir, os.open(file_path, os.O.RDWR, mode));
101}101}
102102
103test "openat smoke test" {103test "openat smoke test" {
...@@ -112,28 +112,28 @@ test "openat smoke test" {...@@ -112,28 +112,28 @@ test "openat smoke test" {
112 const mode: os.mode_t = if (native_os == .windows) 0 else 0o666;112 const mode: os.mode_t = if (native_os == .windows) 0 else 0o666;
113113
114 // Create some file using `openat`.114 // Create some file using `openat`.
115 fd = try os.openat(tmp.dir.fd, "some_file", os.O_RDWR | os.O_CREAT | os.O_EXCL, mode);115 fd = try os.openat(tmp.dir.fd, "some_file", os.O.RDWR | os.O.CREAT | os.O.EXCL, mode);
116 os.close(fd);116 os.close(fd);
117117
118 // Try this again with the same flags. This op should fail with error.PathAlreadyExists.118 // Try this again with the same flags. This op should fail with error.PathAlreadyExists.
119 try expectError(error.PathAlreadyExists, os.openat(tmp.dir.fd, "some_file", os.O_RDWR | os.O_CREAT | os.O_EXCL, mode));119 try expectError(error.PathAlreadyExists, os.openat(tmp.dir.fd, "some_file", os.O.RDWR | os.O.CREAT | os.O.EXCL, mode));
120120
121 // Try opening without `O_EXCL` flag.121 // Try opening without `O.EXCL` flag.
122 fd = try os.openat(tmp.dir.fd, "some_file", os.O_RDWR | os.O_CREAT, mode);122 fd = try os.openat(tmp.dir.fd, "some_file", os.O.RDWR | os.O.CREAT, mode);
123 os.close(fd);123 os.close(fd);
124124
125 // Try opening as a directory which should fail.125 // Try opening as a directory which should fail.
126 try expectError(error.NotDir, os.openat(tmp.dir.fd, "some_file", os.O_RDWR | os.O_DIRECTORY, mode));126 try expectError(error.NotDir, os.openat(tmp.dir.fd, "some_file", os.O.RDWR | os.O.DIRECTORY, mode));
127127
128 // Create some directory128 // Create some directory
129 try os.mkdirat(tmp.dir.fd, "some_dir", mode);129 try os.mkdirat(tmp.dir.fd, "some_dir", mode);
130130
131 // Open dir using `open`131 // Open dir using `open`
132 fd = try os.openat(tmp.dir.fd, "some_dir", os.O_RDONLY | os.O_DIRECTORY, mode);132 fd = try os.openat(tmp.dir.fd, "some_dir", os.O.RDONLY | os.O.DIRECTORY, mode);
133 os.close(fd);133 os.close(fd);
134134
135 // Try opening as file which should fail.135 // Try opening as file which should fail.
136 try expectError(error.IsDir, os.openat(tmp.dir.fd, "some_dir", os.O_RDWR, mode));136 try expectError(error.IsDir, os.openat(tmp.dir.fd, "some_dir", os.O.RDWR, mode));
137}137}
138138
139test "symlink with relative paths" {139test "symlink with relative paths" {
...@@ -273,7 +273,7 @@ test "fstatat" {...@@ -273,7 +273,7 @@ test "fstatat" {
273 defer file.close();273 defer file.close();
274274
275 // now repeat but using `fstatat` instead275 // now repeat but using `fstatat` instead
276 const flags = if (native_os == .wasi) 0x0 else os.AT_SYMLINK_NOFOLLOW;276 const flags = if (native_os == .wasi) 0x0 else os.AT.SYMLINK_NOFOLLOW;
277 const statat = try os.fstatat(tmp.dir.fd, "file.txt", flags);277 const statat = try os.fstatat(tmp.dir.fd, "file.txt", flags);
278 try expectEqual(stat, statat);278 try expectEqual(stat, statat);
279}279}
...@@ -508,8 +508,8 @@ test "mmap" {...@@ -508,8 +508,8 @@ test "mmap" {
508 const data = try os.mmap(508 const data = try os.mmap(
509 null,509 null,
510 1234,510 1234,
511 os.PROT_READ | os.PROT_WRITE,511 os.PROT.READ | os.PROT.WRITE,
512 os.MAP_ANONYMOUS | os.MAP_PRIVATE,512 os.MAP.ANONYMOUS | os.MAP.PRIVATE,
513 -1,513 -1,
514 0,514 0,
515 );515 );
...@@ -550,8 +550,8 @@ test "mmap" {...@@ -550,8 +550,8 @@ test "mmap" {
550 const data = try os.mmap(550 const data = try os.mmap(
551 null,551 null,
552 alloc_size,552 alloc_size,
553 os.PROT_READ,553 os.PROT.READ,
554 os.MAP_PRIVATE,554 os.MAP.PRIVATE,
555 file.handle,555 file.handle,
556 0,556 0,
557 );557 );
...@@ -574,8 +574,8 @@ test "mmap" {...@@ -574,8 +574,8 @@ test "mmap" {
574 const data = try os.mmap(574 const data = try os.mmap(
575 null,575 null,
576 alloc_size / 2,576 alloc_size / 2,
577 os.PROT_READ,577 os.PROT.READ,
578 os.MAP_PRIVATE,578 os.MAP.PRIVATE,
579 file.handle,579 file.handle,
580 alloc_size / 2,580 alloc_size / 2,
581 );581 );
...@@ -616,19 +616,19 @@ test "fcntl" {...@@ -616,19 +616,19 @@ test "fcntl" {
616 tmp.dir.deleteFile(test_out_file) catch {};616 tmp.dir.deleteFile(test_out_file) catch {};
617 }617 }
618618
619 // Note: The test assumes createFile opens the file with O_CLOEXEC619 // Note: The test assumes createFile opens the file with O.CLOEXEC
620 {620 {
621 const flags = try os.fcntl(file.handle, os.F_GETFD, 0);621 const flags = try os.fcntl(file.handle, os.F.GETFD, 0);
622 try expect((flags & os.FD_CLOEXEC) != 0);622 try expect((flags & os.FD_CLOEXEC) != 0);
623 }623 }
624 {624 {
625 _ = try os.fcntl(file.handle, os.F_SETFD, 0);625 _ = try os.fcntl(file.handle, os.F.SETFD, 0);
626 const flags = try os.fcntl(file.handle, os.F_GETFD, 0);626 const flags = try os.fcntl(file.handle, os.F.GETFD, 0);
627 try expect((flags & os.FD_CLOEXEC) == 0);627 try expect((flags & os.FD_CLOEXEC) == 0);
628 }628 }
629 {629 {
630 _ = try os.fcntl(file.handle, os.F_SETFD, os.FD_CLOEXEC);630 _ = try os.fcntl(file.handle, os.F.SETFD, os.FD_CLOEXEC);
631 const flags = try os.fcntl(file.handle, os.F_GETFD, 0);631 const flags = try os.fcntl(file.handle, os.F.GETFD, 0);
632 try expect((flags & os.FD_CLOEXEC) != 0);632 try expect((flags & os.FD_CLOEXEC) != 0);
633 }633 }
634}634}
...@@ -698,7 +698,7 @@ test "shutdown socket" {...@@ -698,7 +698,7 @@ test "shutdown socket" {
698 std.os.windows.WSACleanup() catch unreachable;698 std.os.windows.WSACleanup() catch unreachable;
699 }699 }
700 }700 }
701 const sock = try os.socket(os.AF_INET, os.SOCK_STREAM, 0);701 const sock = try os.socket(os.AF.INET, os.SOCK.STREAM, 0);
702 os.shutdown(sock, .both) catch |err| switch (err) {702 os.shutdown(sock, .both) catch |err| switch (err) {
703 error.SocketNotConnected => {},703 error.SocketNotConnected => {},
704 else => |e| return e,704 else => |e| return e,
...@@ -722,11 +722,11 @@ test "sigaction" {...@@ -722,11 +722,11 @@ test "sigaction" {
722 // Check that we received the correct signal.722 // Check that we received the correct signal.
723 switch (native_os) {723 switch (native_os) {
724 .netbsd => {724 .netbsd => {
725 if (sig == os.SIGUSR1 and sig == info.info.signo)725 if (sig == os.SIG.USR1 and sig == info.info.signo)
726 signal_test_failed = false;726 signal_test_failed = false;
727 },727 },
728 else => {728 else => {
729 if (sig == os.SIGUSR1 and sig == info.signo)729 if (sig == os.SIG.USR1 and sig == info.signo)
730 signal_test_failed = false;730 signal_test_failed = false;
731 },731 },
732 }732 }
...@@ -736,21 +736,21 @@ test "sigaction" {...@@ -736,21 +736,21 @@ test "sigaction" {
736 var sa = os.Sigaction{736 var sa = os.Sigaction{
737 .handler = .{ .sigaction = S.handler },737 .handler = .{ .sigaction = S.handler },
738 .mask = os.empty_sigset,738 .mask = os.empty_sigset,
739 .flags = os.SA_SIGINFO | os.SA_RESETHAND,739 .flags = os.SA.SIGINFO | os.SA.RESETHAND,
740 };740 };
741 var old_sa: os.Sigaction = undefined;741 var old_sa: os.Sigaction = undefined;
742 // Install the new signal handler.742 // Install the new signal handler.
743 os.sigaction(os.SIGUSR1, &sa, null);743 os.sigaction(os.SIG.USR1, &sa, null);
744 // Check that we can read it back correctly.744 // Check that we can read it back correctly.
745 os.sigaction(os.SIGUSR1, null, &old_sa);745 os.sigaction(os.SIG.USR1, null, &old_sa);
746 try testing.expectEqual(S.handler, old_sa.handler.sigaction.?);746 try testing.expectEqual(S.handler, old_sa.handler.sigaction.?);
747 try testing.expect((old_sa.flags & os.SA_SIGINFO) != 0);747 try testing.expect((old_sa.flags & os.SA.SIGINFO) != 0);
748 // Invoke the handler.748 // Invoke the handler.
749 try os.raise(os.SIGUSR1);749 try os.raise(os.SIG.USR1);
750 try testing.expect(signal_test_failed == false);750 try testing.expect(signal_test_failed == false);
751 // Check if the handler has been correctly reset to SIG_DFL751 // Check if the handler has been correctly reset to SIG_DFL
752 os.sigaction(os.SIGUSR1, null, &old_sa);752 os.sigaction(os.SIG.USR1, null, &old_sa);
753 try testing.expectEqual(os.SIG_DFL, old_sa.handler.sigaction);753 try testing.expectEqual(os.SIG.DFL, old_sa.handler.sigaction);
754}754}
755755
756test "dup & dup2" {756test "dup & dup2" {
lib/std/os/wasi.zig+14-9
...@@ -382,8 +382,14 @@ pub const prestat_u_t = extern union {...@@ -382,8 +382,14 @@ pub const prestat_u_t = extern union {
382};382};
383383
384pub const riflags_t = u16;384pub const riflags_t = u16;
385pub const SOCK_RECV_PEEK: riflags_t = 0x0001;385pub const roflags_t = u16;
386pub const SOCK_RECV_WAITALL: riflags_t = 0x0002;386
387pub const SOCK = struct {
388 pub const RECV_PEEK: riflags_t = 0x0001;
389 pub const RECV_WAITALL: riflags_t = 0x0002;
390
391 pub const RECV_DATA_TRUNCATED: roflags_t = 0x0001;
392};
387393
388pub const rights_t = u64;394pub const rights_t = u64;
389pub const RIGHT_FD_DATASYNC: rights_t = 0x0000000000000001;395pub const RIGHT_FD_DATASYNC: rights_t = 0x0000000000000001;
...@@ -445,9 +451,6 @@ pub const RIGHT_ALL: rights_t = RIGHT_FD_DATASYNC |...@@ -445,9 +451,6 @@ pub const RIGHT_ALL: rights_t = RIGHT_FD_DATASYNC |
445 RIGHT_POLL_FD_READWRITE |451 RIGHT_POLL_FD_READWRITE |
446 RIGHT_SOCK_SHUTDOWN;452 RIGHT_SOCK_SHUTDOWN;
447453
448pub const roflags_t = u16;
449pub const SOCK_RECV_DATA_TRUNCATED: roflags_t = 0x0001;
450
451pub const sdflags_t = u8;454pub const sdflags_t = u8;
452pub const SHUT_RD: sdflags_t = 0x01;455pub const SHUT_RD: sdflags_t = 0x01;
453pub const SHUT_WR: sdflags_t = 0x02;456pub const SHUT_WR: sdflags_t = 0x02;
...@@ -541,7 +544,9 @@ pub const SEEK_SET = WHENCE_SET;...@@ -541,7 +544,9 @@ pub const SEEK_SET = WHENCE_SET;
541pub const SEEK_CUR = WHENCE_CUR;544pub const SEEK_CUR = WHENCE_CUR;
542pub const SEEK_END = WHENCE_END;545pub const SEEK_END = WHENCE_END;
543546
544pub const LOCK_SH = 0x1;547pub const LOCK = struct {
545pub const LOCK_EX = 0x2;548 pub const SH = 0x1;
546pub const LOCK_NB = 0x4;549 pub const EX = 0x2;
547pub const LOCK_UN = 0x8;550 pub const NB = 0x4;
551 pub const UN = 0x8;
552};
lib/std/os/windows/ws2_32.zig+207-169
...@@ -178,7 +178,6 @@ pub const RIO_CORRUPT_CQ = 4294967295;...@@ -178,7 +178,6 @@ pub const RIO_CORRUPT_CQ = 4294967295;
178pub const WINDOWS_AF_IRDA = 26;178pub const WINDOWS_AF_IRDA = 26;
179pub const WCE_AF_IRDA = 22;179pub const WCE_AF_IRDA = 22;
180pub const IRDA_PROTO_SOCK_STREAM = 1;180pub const IRDA_PROTO_SOCK_STREAM = 1;
181pub const SOL_IRLMP = 255;
182pub const IRLMP_ENUMDEVICES = 16;181pub const IRLMP_ENUMDEVICES = 16;
183pub const IRLMP_IAS_SET = 17;182pub const IRLMP_IAS_SET = 17;
184pub const IRLMP_IAS_QUERY = 18;183pub const IRLMP_IAS_QUERY = 18;
...@@ -237,7 +236,6 @@ pub const IPX_MAX_ADAPTER_NUM = 16397;...@@ -237,7 +236,6 @@ pub const IPX_MAX_ADAPTER_NUM = 16397;
237pub const IPX_RERIPNETNUMBER = 16398;236pub const IPX_RERIPNETNUMBER = 16398;
238pub const IPX_RECEIVE_BROADCAST = 16399;237pub const IPX_RECEIVE_BROADCAST = 16399;
239pub const IPX_IMMEDIATESPXACK = 16400;238pub const IPX_IMMEDIATESPXACK = 16400;
240pub const IPPROTO_RM = 113;
241pub const MAX_MCAST_TTL = 255;239pub const MAX_MCAST_TTL = 255;
242pub const RM_OPTIONSBASE = 1000;240pub const RM_OPTIONSBASE = 1000;
243pub const RM_RATE_WINDOW_SIZE = 1001;241pub const RM_RATE_WINDOW_SIZE = 1001;
...@@ -449,75 +447,117 @@ pub const TCP_ICMP_ERROR_INFO = 19;...@@ -449,75 +447,117 @@ pub const TCP_ICMP_ERROR_INFO = 19;
449pub const UDP_SEND_MSG_SIZE = 2;447pub const UDP_SEND_MSG_SIZE = 2;
450pub const UDP_RECV_MAX_COALESCED_SIZE = 3;448pub const UDP_RECV_MAX_COALESCED_SIZE = 3;
451pub const UDP_COALESCED_INFO = 3;449pub const UDP_COALESCED_INFO = 3;
452pub const AF_UNSPEC = 0;450
453pub const AF_UNIX = 1;451pub const AF = struct {
454pub const AF_INET = 2;452 pub const UNSPEC = 0;
455pub const AF_IMPLINK = 3;453 pub const UNIX = 1;
456pub const AF_PUP = 4;454 pub const INET = 2;
457pub const AF_CHAOS = 5;455 pub const IMPLINK = 3;
458pub const AF_NS = 6;456 pub const PUP = 4;
459pub const AF_ISO = 7;457 pub const CHAOS = 5;
460pub const AF_ECMA = 8;458 pub const NS = 6;
461pub const AF_DATAKIT = 9;459 pub const IPX = 6;
462pub const AF_CCITT = 10;460 pub const ISO = 7;
463pub const AF_SNA = 11;461 pub const ECMA = 8;
464pub const AF_DECnet = 12;462 pub const DATAKIT = 9;
465pub const AF_DLI = 13;463 pub const CCITT = 10;
466pub const AF_LAT = 14;464 pub const SNA = 11;
467pub const AF_HYLINK = 15;465 pub const DECnet = 12;
468pub const AF_APPLETALK = 16;466 pub const DLI = 13;
469pub const AF_NETBIOS = 17;467 pub const LAT = 14;
470pub const AF_VOICEVIEW = 18;468 pub const HYLINK = 15;
471pub const AF_FIREFOX = 19;469 pub const APPLETALK = 16;
472pub const AF_UNKNOWN1 = 20;470 pub const NETBIOS = 17;
473pub const AF_BAN = 21;471 pub const VOICEVIEW = 18;
474pub const AF_ATM = 22;472 pub const FIREFOX = 19;
475pub const AF_INET6 = 23;473 pub const UNKNOWN1 = 20;
476pub const AF_CLUSTER = 24;474 pub const BAN = 21;
477pub const AF_12844 = 25;475 pub const ATM = 22;
478pub const AF_IRDA = 26;476 pub const INET6 = 23;
479pub const AF_NETDES = 28;477 pub const CLUSTER = 24;
480pub const AF_MAX = 29;478 pub const @"12844" = 25;
481pub const AF_TCNPROCESS = 29;479 pub const IRDA = 26;
482pub const AF_TCNMESSAGE = 30;480 pub const NETDES = 28;
483pub const AF_ICLFXBM = 31;481 pub const MAX = 29;
484pub const AF_LINK = 33;482 pub const TCNPROCESS = 29;
485pub const AF_HYPERV = 34;483 pub const TCNMESSAGE = 30;
486pub const SOCK_STREAM = 1;484 pub const ICLFXBM = 31;
487pub const SOCK_DGRAM = 2;485 pub const LINK = 33;
488pub const SOCK_RAW = 3;486 pub const HYPERV = 34;
489pub const SOCK_RDM = 4;487};
490pub const SOCK_SEQPACKET = 5;488
491pub const SOL_SOCKET = 65535;489pub const SOCK = struct {
492pub const SO_DEBUG = 1;490 pub const STREAM = 1;
493pub const SO_ACCEPTCONN = 2;491 pub const DGRAM = 2;
494pub const SO_REUSEADDR = 4;492 pub const RAW = 3;
495pub const SO_KEEPALIVE = 8;493 pub const RDM = 4;
496pub const SO_DONTROUTE = 16;494 pub const SEQPACKET = 5;
497pub const SO_BROADCAST = 32;495
498pub const SO_USELOOPBACK = 64;496 /// WARNING: this flag is not supported by windows socket functions directly,
499pub const SO_LINGER = 128;497 /// it is only supported by std.os.socket. Be sure that this value does
500pub const SO_OOBINLINE = 256;498 /// not share any bits with any of the `SOCK` values.
501pub const SO_SNDBUF = 4097;499 pub const CLOEXEC = 0x10000;
502pub const SO_RCVBUF = 4098;500 /// WARNING: this flag is not supported by windows socket functions directly,
503pub const SO_SNDLOWAT = 4099;501 /// it is only supported by std.os.socket. Be sure that this value does
504pub const SO_RCVLOWAT = 4100;502 /// not share any bits with any of the `SOCK` values.
505pub const SO_SNDTIMEO = 4101;503 pub const NONBLOCK = 0x20000;
506pub const SO_RCVTIMEO = 4102;504};
507pub const SO_ERROR = 4103;505
508pub const SO_TYPE = 4104;506pub const SOL = struct {
509pub const SO_BSP_STATE = 4105;507 pub const IRLMP = 255;
510pub const SO_GROUP_ID = 8193;508 pub const SOCKET = 65535;
511pub const SO_GROUP_PRIORITY = 8194;509};
512pub const SO_MAX_MSG_SIZE = 8195;510
513pub const SO_CONDITIONAL_ACCEPT = 12290;511pub const SO = struct {
514pub const SO_PAUSE_ACCEPT = 12291;512 pub const DEBUG = 1;
515pub const SO_COMPARTMENT_ID = 12292;513 pub const ACCEPTCONN = 2;
516pub const SO_RANDOMIZE_PORT = 12293;514 pub const REUSEADDR = 4;
517pub const SO_PORT_SCALABILITY = 12294;515 pub const KEEPALIVE = 8;
518pub const SO_REUSE_UNICASTPORT = 12295;516 pub const DONTROUTE = 16;
519pub const SO_REUSE_MULTICASTPORT = 12296;517 pub const BROADCAST = 32;
520pub const SO_ORIGINAL_DST = 12303;518 pub const USELOOPBACK = 64;
519 pub const LINGER = 128;
520 pub const OOBINLINE = 256;
521 pub const SNDBUF = 4097;
522 pub const RCVBUF = 4098;
523 pub const SNDLOWAT = 4099;
524 pub const RCVLOWAT = 4100;
525 pub const SNDTIMEO = 4101;
526 pub const RCVTIMEO = 4102;
527 pub const ERROR = 4103;
528 pub const TYPE = 4104;
529 pub const BSP_STATE = 4105;
530 pub const GROUP_ID = 8193;
531 pub const GROUP_PRIORITY = 8194;
532 pub const MAX_MSG_SIZE = 8195;
533 pub const CONDITIONAL_ACCEPT = 12290;
534 pub const PAUSE_ACCEPT = 12291;
535 pub const COMPARTMENT_ID = 12292;
536 pub const RANDOMIZE_PORT = 12293;
537 pub const PORT_SCALABILITY = 12294;
538 pub const REUSE_UNICASTPORT = 12295;
539 pub const REUSE_MULTICASTPORT = 12296;
540 pub const ORIGINAL_DST = 12303;
541 pub const PROTOCOL_INFOA = 8196;
542 pub const PROTOCOL_INFOW = 8197;
543 pub const CONNDATA = 28672;
544 pub const CONNOPT = 28673;
545 pub const DISCDATA = 28674;
546 pub const DISCOPT = 28675;
547 pub const CONNDATALEN = 28676;
548 pub const CONNOPTLEN = 28677;
549 pub const DISCDATALEN = 28678;
550 pub const DISCOPTLEN = 28679;
551 pub const OPENTYPE = 28680;
552 pub const SYNCHRONOUS_ALERT = 16;
553 pub const SYNCHRONOUS_NONALERT = 32;
554 pub const MAXDG = 28681;
555 pub const MAXPATHDG = 28682;
556 pub const UPDATE_ACCEPT_CONTEXT = 28683;
557 pub const CONNECT_TIME = 28684;
558 pub const UPDATE_CONNECT_CONTEXT = 28688;
559};
560
521pub const WSK_SO_BASE = 16384;561pub const WSK_SO_BASE = 16384;
522pub const TCP_NODELAY = 1;562pub const TCP_NODELAY = 1;
523pub const IOC_UNIX = 0;563pub const IOC_UNIX = 0;
...@@ -529,7 +569,6 @@ pub const SIO_BSP_HANDLE = IOC_OUT | IOC_WS2 | 27;...@@ -529,7 +569,6 @@ pub const SIO_BSP_HANDLE = IOC_OUT | IOC_WS2 | 27;
529pub const SIO_BSP_HANDLE_SELECT = IOC_OUT | IOC_WS2 | 28;569pub const SIO_BSP_HANDLE_SELECT = IOC_OUT | IOC_WS2 | 28;
530pub const SIO_BSP_HANDLE_POLL = IOC_OUT | IOC_WS2 | 29;570pub const SIO_BSP_HANDLE_POLL = IOC_OUT | IOC_WS2 | 29;
531pub const SIO_BASE_HANDLE = IOC_OUT | IOC_WS2 | 34;571pub const SIO_BASE_HANDLE = IOC_OUT | IOC_WS2 | 34;
532pub const IPPROTO_IP = 0;
533pub const IPPORT_TCPMUX = 1;572pub const IPPORT_TCPMUX = 1;
534pub const IPPORT_ECHO = 7;573pub const IPPORT_ECHO = 7;
535pub const IPPORT_DISCARD = 9;574pub const IPPORT_DISCARD = 9;
...@@ -596,27 +635,41 @@ pub const IOCPARM_MASK = 127;...@@ -596,27 +635,41 @@ pub const IOCPARM_MASK = 127;
596pub const IOC_VOID = 536870912;635pub const IOC_VOID = 536870912;
597pub const IOC_OUT = 1073741824;636pub const IOC_OUT = 1073741824;
598pub const IOC_IN = 2147483648;637pub const IOC_IN = 2147483648;
599pub const MSG_TRUNC = 256;638
600pub const MSG_CTRUNC = 512;639pub const MSG = struct {
601pub const MSG_BCAST = 1024;640 pub const TRUNC = 256;
602pub const MSG_MCAST = 2048;641 pub const CTRUNC = 512;
603pub const MSG_ERRQUEUE = 4096;642 pub const BCAST = 1024;
604pub const AI_PASSIVE = 1;643 pub const MCAST = 2048;
605pub const AI_CANONNAME = 2;644 pub const ERRQUEUE = 4096;
606pub const AI_NUMERICHOST = 4;645
607pub const AI_NUMERICSERV = 8;646 pub const PEEK = 2;
608pub const AI_DNS_ONLY = 16;647 pub const WAITALL = 8;
609pub const AI_ALL = 256;648 pub const PUSH_IMMEDIATE = 32;
610pub const AI_ADDRCONFIG = 1024;649 pub const PARTIAL = 32768;
611pub const AI_V4MAPPED = 2048;650 pub const INTERRUPT = 16;
612pub const AI_NON_AUTHORITATIVE = 16384;651 pub const MAXIOVLEN = 16;
613pub const AI_SECURE = 32768;652};
614pub const AI_RETURN_PREFERRED_NAMES = 65536;653
615pub const AI_FQDN = 131072;654pub const AI = struct {
616pub const AI_FILESERVER = 262144;655 pub const PASSIVE = 1;
617pub const AI_DISABLE_IDN_ENCODING = 524288;656 pub const CANONNAME = 2;
618pub const AI_EXTENDED = 2147483648;657 pub const NUMERICHOST = 4;
619pub const AI_RESOLUTION_HANDLE = 1073741824;658 pub const NUMERICSERV = 8;
659 pub const DNS_ONLY = 16;
660 pub const ALL = 256;
661 pub const ADDRCONFIG = 1024;
662 pub const V4MAPPED = 2048;
663 pub const NON_AUTHORITATIVE = 16384;
664 pub const SECURE = 32768;
665 pub const RETURN_PREFERRED_NAMES = 65536;
666 pub const FQDN = 131072;
667 pub const FILESERVER = 262144;
668 pub const DISABLE_IDN_ENCODING = 524288;
669 pub const EXTENDED = 2147483648;
670 pub const RESOLUTION_HANDLE = 1073741824;
671};
672
620pub const FIONBIO = -2147195266;673pub const FIONBIO = -2147195266;
621pub const ADDRINFOEX_VERSION_2 = 2;674pub const ADDRINFOEX_VERSION_2 = 2;
622pub const ADDRINFOEX_VERSION_3 = 3;675pub const ADDRINFOEX_VERSION_3 = 3;
...@@ -660,16 +713,8 @@ pub const WSADESCRIPTION_LEN = 256;...@@ -660,16 +713,8 @@ pub const WSADESCRIPTION_LEN = 256;
660pub const WSASYS_STATUS_LEN = 128;713pub const WSASYS_STATUS_LEN = 128;
661pub const SOCKET_ERROR = -1;714pub const SOCKET_ERROR = -1;
662pub const FROM_PROTOCOL_INFO = -1;715pub const FROM_PROTOCOL_INFO = -1;
663pub const SO_PROTOCOL_INFOA = 8196;
664pub const SO_PROTOCOL_INFOW = 8197;
665pub const PVD_CONFIG = 12289;716pub const PVD_CONFIG = 12289;
666pub const SOMAXCONN = 2147483647;717pub const SOMAXCONN = 2147483647;
667pub const MSG_PEEK = 2;
668pub const MSG_WAITALL = 8;
669pub const MSG_PUSH_IMMEDIATE = 32;
670pub const MSG_PARTIAL = 32768;
671pub const MSG_INTERRUPT = 16;
672pub const MSG_MAXIOVLEN = 16;
673pub const MAXGETHOSTSTRUCT = 1024;718pub const MAXGETHOSTSTRUCT = 1024;
674pub const FD_READ_BIT = 0;719pub const FD_READ_BIT = 0;
675pub const FD_WRITE_BIT = 1;720pub const FD_WRITE_BIT = 1;
...@@ -770,30 +815,18 @@ pub const RESULT_IS_ALIAS = 1;...@@ -770,30 +815,18 @@ pub const RESULT_IS_ALIAS = 1;
770pub const RESULT_IS_ADDED = 16;815pub const RESULT_IS_ADDED = 16;
771pub const RESULT_IS_CHANGED = 32;816pub const RESULT_IS_CHANGED = 32;
772pub const RESULT_IS_DELETED = 64;817pub const RESULT_IS_DELETED = 64;
773pub const POLLRDNORM = 256;818
774pub const POLLRDBAND = 512;819pub const POLL = struct {
775pub const POLLPRI = 1024;820 pub const RDNORM = 256;
776pub const POLLWRNORM = 16;821 pub const RDBAND = 512;
777pub const POLLWRBAND = 32;822 pub const PRI = 1024;
778pub const POLLERR = 1;823 pub const WRNORM = 16;
779pub const POLLHUP = 2;824 pub const WRBAND = 32;
780pub const POLLNVAL = 4;825 pub const ERR = 1;
781pub const SO_CONNDATA = 28672;826 pub const HUP = 2;
782pub const SO_CONNOPT = 28673;827 pub const NVAL = 4;
783pub const SO_DISCDATA = 28674;828};
784pub const SO_DISCOPT = 28675;829
785pub const SO_CONNDATALEN = 28676;
786pub const SO_CONNOPTLEN = 28677;
787pub const SO_DISCDATALEN = 28678;
788pub const SO_DISCOPTLEN = 28679;
789pub const SO_OPENTYPE = 28680;
790pub const SO_SYNCHRONOUS_ALERT = 16;
791pub const SO_SYNCHRONOUS_NONALERT = 32;
792pub const SO_MAXDG = 28681;
793pub const SO_MAXPATHDG = 28682;
794pub const SO_UPDATE_ACCEPT_CONTEXT = 28683;
795pub const SO_CONNECT_TIME = 28684;
796pub const SO_UPDATE_CONNECT_CONTEXT = 28688;
797pub const TCP_BSDURGENT = 28672;830pub const TCP_BSDURGENT = 28672;
798pub const TF_DISCONNECT = 1;831pub const TF_DISCONNECT = 1;
799pub const TF_REUSE_SOCKET = 2;832pub const TF_REUSE_SOCKET = 2;
...@@ -817,20 +850,25 @@ pub const LSP_INBOUND_MODIFY = 16;...@@ -817,20 +850,25 @@ pub const LSP_INBOUND_MODIFY = 16;
817pub const LSP_OUTBOUND_MODIFY = 32;850pub const LSP_OUTBOUND_MODIFY = 32;
818pub const LSP_CRYPTO_COMPRESS = 64;851pub const LSP_CRYPTO_COMPRESS = 64;
819pub const LSP_LOCAL_CACHE = 128;852pub const LSP_LOCAL_CACHE = 128;
820pub const IPPROTO_ICMP = 1;853
821pub const IPPROTO_IGMP = 2;854pub const IPPROTO = struct {
822pub const IPPROTO_GGP = 3;855 pub const IP = 0;
823pub const IPPROTO_TCP = 6;856 pub const ICMP = 1;
824pub const IPPROTO_PUP = 12;857 pub const IGMP = 2;
825pub const IPPROTO_UDP = 17;858 pub const GGP = 3;
826pub const IPPROTO_IDP = 22;859 pub const TCP = 6;
827pub const IPPROTO_ND = 77;860 pub const PUP = 12;
828pub const IPPROTO_RAW = 255;861 pub const UDP = 17;
829pub const IPPROTO_MAX = 256;862 pub const IDP = 22;
863 pub const ND = 77;
864 pub const RM = 113;
865 pub const RAW = 255;
866 pub const MAX = 256;
867};
868
830pub const IP_DEFAULT_MULTICAST_TTL = 1;869pub const IP_DEFAULT_MULTICAST_TTL = 1;
831pub const IP_DEFAULT_MULTICAST_LOOP = 1;870pub const IP_DEFAULT_MULTICAST_LOOP = 1;
832pub const IP_MAX_MEMBERSHIPS = 20;871pub const IP_MAX_MEMBERSHIPS = 20;
833pub const AF_IPX = 6;
834pub const FD_READ = 1;872pub const FD_READ = 1;
835pub const FD_WRITE = 2;873pub const FD_WRITE = 2;
836pub const FD_OOB = 4;874pub const FD_OOB = 4;
...@@ -1051,31 +1089,31 @@ pub const addrinfoexA = extern struct {...@@ -1051,31 +1089,31 @@ pub const addrinfoexA = extern struct {
1051pub const sockaddr = extern struct {1089pub const sockaddr = extern struct {
1052 family: ADDRESS_FAMILY,1090 family: ADDRESS_FAMILY,
1053 data: [14]u8,1091 data: [14]u8,
1054};
10551092
1056pub const sockaddr_storage = std.x.os.Socket.Address.Native.Storage;1093 pub const storage = std.x.os.Socket.Address.Native.Storage;
10571094
1058/// IPv4 socket address1095 /// IPv4 socket address
1059pub const sockaddr_in = extern struct {1096 pub const in = extern struct {
1060 family: ADDRESS_FAMILY = AF_INET,1097 family: ADDRESS_FAMILY = AF.INET,
1061 port: USHORT,1098 port: USHORT,
1062 addr: u32,1099 addr: u32,
1063 zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },1100 zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },
1064};1101 };
10651102
1066/// IPv6 socket address1103 /// IPv6 socket address
1067pub const sockaddr_in6 = extern struct {1104 pub const in6 = extern struct {
1068 family: ADDRESS_FAMILY = AF_INET6,1105 family: ADDRESS_FAMILY = AF.INET6,
1069 port: USHORT,1106 port: USHORT,
1070 flowinfo: u32,1107 flowinfo: u32,
1071 addr: [16]u8,1108 addr: [16]u8,
1072 scope_id: u32,1109 scope_id: u32,
1073};1110 };
10741111
1075/// UNIX domain socket address1112 /// UNIX domain socket address
1076pub const sockaddr_un = extern struct {1113 pub const un = extern struct {
1077 family: ADDRESS_FAMILY = AF_UNIX,1114 family: ADDRESS_FAMILY = AF.UNIX,
1078 path: [108]u8,1115 path: [108]u8,
1116 };
1079};1117};
10801118
1081pub const WSABUF = extern struct {1119pub const WSABUF = extern struct {
...@@ -1237,9 +1275,9 @@ pub const WinsockError = enum(u16) {...@@ -1237,9 +1275,9 @@ pub const WinsockError = enum(u16) {
12371275
1238 /// Permission denied.1276 /// Permission denied.
1239 /// An attempt was made to access a socket in a way forbidden by its access permissions.1277 /// An attempt was made to access a socket in a way forbidden by its access permissions.
1240 /// An example is using a broadcast address for sendto without broadcast permission being set using setsockopt(SO_BROADCAST).1278 /// An example is using a broadcast address for sendto without broadcast permission being set using setsockopt(SO.BROADCAST).
1241 /// Another possible reason for the WSAEACCES error is that when the bind function is called (on Windows NT 4.0 with SP4 and later), another application, service, or kernel mode driver is bound to the same address with exclusive access.1279 /// Another possible reason for the WSAEACCES error is that when the bind function is called (on Windows NT 4.0 with SP4 and later), another application, service, or kernel mode driver is bound to the same address with exclusive access.
1242 /// Such exclusive access is a new feature of Windows NT 4.0 with SP4 and later, and is implemented by using the SO_EXCLUSIVEADDRUSE option.1280 /// Such exclusive access is a new feature of Windows NT 4.0 with SP4 and later, and is implemented by using the SO.EXCLUSIVEADDRUSE option.
1243 WSAEACCES = 10013,1281 WSAEACCES = 10013,
12441282
1245 /// Bad address.1283 /// Bad address.
...@@ -1260,7 +1298,7 @@ pub const WinsockError = enum(u16) {...@@ -1260,7 +1298,7 @@ pub const WinsockError = enum(u16) {
1260 /// Resource temporarily unavailable.1298 /// Resource temporarily unavailable.
1261 /// This error is returned from operations on nonblocking sockets that cannot be completed immediately, for example recv when no data is queued to be read from the socket.1299 /// This error is returned from operations on nonblocking sockets that cannot be completed immediately, for example recv when no data is queued to be read from the socket.
1262 /// It is a nonfatal error, and the operation should be retried later.1300 /// It is a nonfatal error, and the operation should be retried later.
1263 /// It is normal for WSAEWOULDBLOCK to be reported as the result from calling connect on a nonblocking SOCK_STREAM socket, since some time must elapse for the connection to be established.1301 /// It is normal for WSAEWOULDBLOCK to be reported as the result from calling connect on a nonblocking SOCK.STREAM socket, since some time must elapse for the connection to be established.
1264 WSAEWOULDBLOCK = 10035,1302 WSAEWOULDBLOCK = 10035,
12651303
1266 /// Operation now in progress.1304 /// Operation now in progress.
...@@ -1288,7 +1326,7 @@ pub const WinsockError = enum(u16) {...@@ -1288,7 +1326,7 @@ pub const WinsockError = enum(u16) {
12881326
1289 /// Protocol wrong type for socket.1327 /// Protocol wrong type for socket.
1290 /// A protocol was specified in the socket function call that does not support the semantics of the socket type requested.1328 /// A protocol was specified in the socket function call that does not support the semantics of the socket type requested.
1291 /// For example, the ARPA Internet UDP protocol cannot be specified with a socket type of SOCK_STREAM.1329 /// For example, the ARPA Internet UDP protocol cannot be specified with a socket type of SOCK.STREAM.
1292 WSAEPROTOTYPE = 10041,1330 WSAEPROTOTYPE = 10041,
12931331
1294 /// Bad protocol option.1332 /// Bad protocol option.
...@@ -1297,12 +1335,12 @@ pub const WinsockError = enum(u16) {...@@ -1297,12 +1335,12 @@ pub const WinsockError = enum(u16) {
12971335
1298 /// Protocol not supported.1336 /// Protocol not supported.
1299 /// The requested protocol has not been configured into the system, or no implementation for it exists.1337 /// The requested protocol has not been configured into the system, or no implementation for it exists.
1300 /// For example, a socket call requests a SOCK_DGRAM socket, but specifies a stream protocol.1338 /// For example, a socket call requests a SOCK.DGRAM socket, but specifies a stream protocol.
1301 WSAEPROTONOSUPPORT = 10043,1339 WSAEPROTONOSUPPORT = 10043,
13021340
1303 /// Socket type not supported.1341 /// Socket type not supported.
1304 /// The support for the specified socket type does not exist in this address family.1342 /// The support for the specified socket type does not exist in this address family.
1305 /// For example, the optional type SOCK_RAW might be selected in a socket call, and the implementation does not support SOCK_RAW sockets at all.1343 /// For example, the optional type SOCK.RAW might be selected in a socket call, and the implementation does not support SOCK.RAW sockets at all.
1306 WSAESOCKTNOSUPPORT = 10044,1344 WSAESOCKTNOSUPPORT = 10044,
13071345
1308 /// Operation not supported.1346 /// Operation not supported.
...@@ -1318,14 +1356,14 @@ pub const WinsockError = enum(u16) {...@@ -1318,14 +1356,14 @@ pub const WinsockError = enum(u16) {
13181356
1319 /// Address family not supported by protocol family.1357 /// Address family not supported by protocol family.
1320 /// An address incompatible with the requested protocol was used.1358 /// An address incompatible with the requested protocol was used.
1321 /// All sockets are created with an associated address family (that is, AF_INET for Internet Protocols) and a generic protocol type (that is, SOCK_STREAM).1359 /// All sockets are created with an associated address family (that is, AF.INET for Internet Protocols) and a generic protocol type (that is, SOCK.STREAM).
1322 /// This error is returned if an incorrect protocol is explicitly requested in the socket call, or if an address of the wrong family is used for a socket, for example, in sendto.1360 /// This error is returned if an incorrect protocol is explicitly requested in the socket call, or if an address of the wrong family is used for a socket, for example, in sendto.
1323 WSAEAFNOSUPPORT = 10047,1361 WSAEAFNOSUPPORT = 10047,
13241362
1325 /// Address already in use.1363 /// Address already in use.
1326 /// Typically, only one usage of each socket address (protocol/IP address/port) is permitted.1364 /// Typically, only one usage of each socket address (protocol/IP address/port) is permitted.
1327 /// This error occurs if an application attempts to bind a socket to an IP address/port that has already been used for an existing socket, or a socket that was not closed properly, or one that is still in the process of closing.1365 /// This error occurs if an application attempts to bind a socket to an IP address/port that has already been used for an existing socket, or a socket that was not closed properly, or one that is still in the process of closing.
1328 /// For server applications that need to bind multiple sockets to the same port number, consider using setsockopt (SO_REUSEADDR).1366 /// For server applications that need to bind multiple sockets to the same port number, consider using setsockopt (SO.REUSEADDR).
1329 /// Client applications usually need not call bind at all—connect chooses an unused port automatically.1367 /// Client applications usually need not call bind at all—connect chooses an unused port automatically.
1330 /// When bind is called with a wildcard address (involving ADDR_ANY), a WSAEADDRINUSE error could be delayed until the specific address is committed.1368 /// When bind is called with a wildcard address (involving ADDR_ANY), a WSAEADDRINUSE error could be delayed until the specific address is committed.
1331 /// This could happen with a call to another function later, including connect, listen, WSAConnect, or WSAJoinLeaf.1369 /// This could happen with a call to another function later, including connect, listen, WSAConnect, or WSAJoinLeaf.
...@@ -1349,7 +1387,7 @@ pub const WinsockError = enum(u16) {...@@ -1349,7 +1387,7 @@ pub const WinsockError = enum(u16) {
13491387
1350 /// Network dropped connection on reset.1388 /// Network dropped connection on reset.
1351 /// The connection has been broken due to keep-alive activity detecting a failure while the operation was in progress.1389 /// The connection has been broken due to keep-alive activity detecting a failure while the operation was in progress.
1352 /// It can also be returned by setsockopt if an attempt is made to set SO_KEEPALIVE on a connection that has already failed.1390 /// It can also be returned by setsockopt if an attempt is made to set SO.KEEPALIVE on a connection that has already failed.
1353 WSAENETRESET = 10052,1391 WSAENETRESET = 10052,
13541392
1355 /// Software caused connection abort.1393 /// Software caused connection abort.
...@@ -1358,7 +1396,7 @@ pub const WinsockError = enum(u16) {...@@ -1358,7 +1396,7 @@ pub const WinsockError = enum(u16) {
13581396
1359 /// Connection reset by peer.1397 /// Connection reset by peer.
1360 /// An existing connection was forcibly closed by the remote host.1398 /// An existing connection was forcibly closed by the remote host.
1361 /// This normally results if the peer application on the remote host is suddenly stopped, the host is rebooted, the host or remote network interface is disabled, or the remote host uses a hard close (see setsockopt for more information on the SO_LINGER option on the remote socket).1399 /// This normally results if the peer application on the remote host is suddenly stopped, the host is rebooted, the host or remote network interface is disabled, or the remote host uses a hard close (see setsockopt for more information on the SO.LINGER option on the remote socket).
1362 /// This error may also result if a connection was broken due to keep-alive activity detecting a failure while one or more operations are in progress.1400 /// This error may also result if a connection was broken due to keep-alive activity detecting a failure while one or more operations are in progress.
1363 /// Operations that were in progress fail with WSAENETRESET. Subsequent operations fail with WSAECONNRESET.1401 /// Operations that were in progress fail with WSAENETRESET. Subsequent operations fail with WSAECONNRESET.
1364 WSAECONNRESET = 10054,1402 WSAECONNRESET = 10054,
...@@ -1369,12 +1407,12 @@ pub const WinsockError = enum(u16) {...@@ -1369,12 +1407,12 @@ pub const WinsockError = enum(u16) {
13691407
1370 /// Socket is already connected.1408 /// Socket is already connected.
1371 /// A connect request was made on an already-connected socket.1409 /// A connect request was made on an already-connected socket.
1372 /// Some implementations also return this error if sendto is called on a connected SOCK_DGRAM socket (for SOCK_STREAM sockets, the to parameter in sendto is ignored) although other implementations treat this as a legal occurrence.1410 /// Some implementations also return this error if sendto is called on a connected SOCK.DGRAM socket (for SOCK.STREAM sockets, the to parameter in sendto is ignored) although other implementations treat this as a legal occurrence.
1373 WSAEISCONN = 10056,1411 WSAEISCONN = 10056,
13741412
1375 /// Socket is not connected.1413 /// Socket is not connected.
1376 /// A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using sendto) no address was supplied.1414 /// A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using sendto) no address was supplied.
1377 /// Any other type of operation might also return this error—for example, setsockopt setting SO_KEEPALIVE if the connection has been reset.1415 /// Any other type of operation might also return this error—for example, setsockopt setting SO.KEEPALIVE if the connection has been reset.
1378 WSAENOTCONN = 10057,1416 WSAENOTCONN = 10057,
13791417
1380 /// Cannot send after socket shutdown.1418 /// Cannot send after socket shutdown.
lib/std/time.zig+2-2
...@@ -86,12 +86,12 @@ pub fn nanoTimestamp() i128 {...@@ -86,12 +86,12 @@ pub fn nanoTimestamp() i128 {
86 }86 }
87 if (builtin.os.tag == .wasi and !builtin.link_libc) {87 if (builtin.os.tag == .wasi and !builtin.link_libc) {
88 var ns: os.wasi.timestamp_t = undefined;88 var ns: os.wasi.timestamp_t = undefined;
89 const err = os.wasi.clock_time_get(os.wasi.CLOCK_REALTIME, 1, &ns);89 const err = os.wasi.clock_time_get(os.wasi.CLOCK.REALTIME, 1, &ns);
90 assert(err == .SUCCESS);90 assert(err == .SUCCESS);
91 return ns;91 return ns;
92 }92 }
93 var ts: os.timespec = undefined;93 var ts: os.timespec = undefined;
94 os.clock_gettime(os.CLOCK_REALTIME, &ts) catch |err| switch (err) {94 os.clock_gettime(os.CLOCK.REALTIME, &ts) catch |err| switch (err) {
95 error.UnsupportedClock, error.Unexpected => return 0, // "Precision of timing depends on hardware and OS".95 error.UnsupportedClock, error.Unexpected => return 0, // "Precision of timing depends on hardware and OS".
96 };96 };
97 return (@as(i128, ts.tv_sec) * ns_per_s) + ts.tv_nsec;97 return (@as(i128, ts.tv_sec) * ns_per_s) + ts.tv_nsec;
lib/std/x/net/tcp.zig+9-9
...@@ -46,8 +46,8 @@ pub const Connection = struct {...@@ -46,8 +46,8 @@ pub const Connection = struct {
4646
47/// Possible domains that a TCP client/listener may operate over.47/// Possible domains that a TCP client/listener may operate over.
48pub const Domain = enum(u16) {48pub const Domain = enum(u16) {
49 ip = os.AF_INET,49 ip = os.AF.INET,
50 ipv6 = os.AF_INET6,50 ipv6 = os.AF.INET6,
51};51};
5252
53/// A TCP client.53/// A TCP client.
...@@ -81,8 +81,8 @@ pub const Client = struct {...@@ -81,8 +81,8 @@ pub const Client = struct {
81 return Client{81 return Client{
82 .socket = try Socket.init(82 .socket = try Socket.init(
83 @enumToInt(domain),83 @enumToInt(domain),
84 os.SOCK_STREAM,84 os.SOCK.STREAM,
85 os.IPPROTO_TCP,85 os.IPPROTO.TCP,
86 flags,86 flags,
87 ),87 ),
88 };88 };
...@@ -195,7 +195,7 @@ pub const Client = struct {...@@ -195,7 +195,7 @@ pub const Client = struct {
195 pub fn setNoDelay(self: Client, enabled: bool) !void {195 pub fn setNoDelay(self: Client, enabled: bool) !void {
196 if (comptime @hasDecl(os, "TCP_NODELAY")) {196 if (comptime @hasDecl(os, "TCP_NODELAY")) {
197 const bytes = mem.asBytes(&@as(usize, @boolToInt(enabled)));197 const bytes = mem.asBytes(&@as(usize, @boolToInt(enabled)));
198 return self.socket.setOption(os.IPPROTO_TCP, os.TCP_NODELAY, bytes);198 return self.socket.setOption(os.IPPROTO.TCP, os.TCP_NODELAY, bytes);
199 }199 }
200 return error.UnsupportedSocketOption;200 return error.UnsupportedSocketOption;
201 }201 }
...@@ -204,7 +204,7 @@ pub const Client = struct {...@@ -204,7 +204,7 @@ pub const Client = struct {
204 /// `error.UnsupportedSocketOption` if the host does not support TCP Quick ACK.204 /// `error.UnsupportedSocketOption` if the host does not support TCP Quick ACK.
205 pub fn setQuickACK(self: Client, enabled: bool) !void {205 pub fn setQuickACK(self: Client, enabled: bool) !void {
206 if (comptime @hasDecl(os, "TCP_QUICKACK")) {206 if (comptime @hasDecl(os, "TCP_QUICKACK")) {
207 return self.socket.setOption(os.IPPROTO_TCP, os.TCP_QUICKACK, mem.asBytes(&@as(u32, @boolToInt(enabled))));207 return self.socket.setOption(os.IPPROTO.TCP, os.TCP_QUICKACK, mem.asBytes(&@as(u32, @boolToInt(enabled))));
208 }208 }
209 return error.UnsupportedSocketOption;209 return error.UnsupportedSocketOption;
210 }210 }
...@@ -244,8 +244,8 @@ pub const Listener = struct {...@@ -244,8 +244,8 @@ pub const Listener = struct {
244 return Listener{244 return Listener{
245 .socket = try Socket.init(245 .socket = try Socket.init(
246 @enumToInt(domain),246 @enumToInt(domain),
247 os.SOCK_STREAM,247 os.SOCK.STREAM,
248 os.IPPROTO_TCP,248 os.IPPROTO.TCP,
249 flags,249 flags,
250 ),250 ),
251 };251 };
...@@ -305,7 +305,7 @@ pub const Listener = struct {...@@ -305,7 +305,7 @@ pub const Listener = struct {
305 /// support TCP Fast Open.305 /// support TCP Fast Open.
306 pub fn setFastOpen(self: Listener, enabled: bool) !void {306 pub fn setFastOpen(self: Listener, enabled: bool) !void {
307 if (comptime @hasDecl(os, "TCP_FASTOPEN")) {307 if (comptime @hasDecl(os, "TCP_FASTOPEN")) {
308 return self.socket.setOption(os.IPPROTO_TCP, os.TCP_FASTOPEN, mem.asBytes(&@as(u32, @boolToInt(enabled))));308 return self.socket.setOption(os.IPPROTO.TCP, os.TCP_FASTOPEN, mem.asBytes(&@as(u32, @boolToInt(enabled))));
309 }309 }
310 return error.UnsupportedSocketOption;310 return error.UnsupportedSocketOption;
311 }311 }
lib/std/x/os/io.zig+14-13
...@@ -4,6 +4,7 @@ const os = std.os;...@@ -4,6 +4,7 @@ const os = std.os;
4const mem = std.mem;4const mem = std.mem;
5const testing = std.testing;5const testing = std.testing;
6const native_os = std.Target.current.os;6const native_os = std.Target.current.os;
7const linux = std.os.linux;
78
8/// POSIX `iovec`, or Windows `WSABUF`. The difference between the two are the ordering9/// POSIX `iovec`, or Windows `WSABUF`. The difference between the two are the ordering
9/// of fields, alongside the length being represented as either a ULONG or a size_t.10/// of fields, alongside the length being represented as either a ULONG or a size_t.
...@@ -67,7 +68,7 @@ pub const Reactor = struct {...@@ -67,7 +68,7 @@ pub const Reactor = struct {
67 pub fn init(flags: std.enums.EnumFieldStruct(Reactor.InitFlags, bool, false)) !Reactor {68 pub fn init(flags: std.enums.EnumFieldStruct(Reactor.InitFlags, bool, false)) !Reactor {
68 var raw_flags: u32 = 0;69 var raw_flags: u32 = 0;
69 const set = std.EnumSet(Reactor.InitFlags).init(flags);70 const set = std.EnumSet(Reactor.InitFlags).init(flags);
70 if (set.contains(.close_on_exec)) raw_flags |= os.EPOLL_CLOEXEC;71 if (set.contains(.close_on_exec)) raw_flags |= linux.EPOLL.CLOEXEC;
71 return Reactor{ .fd = try os.epoll_create1(raw_flags) };72 return Reactor{ .fd = try os.epoll_create1(raw_flags) };
72 }73 }
7374
...@@ -77,31 +78,31 @@ pub const Reactor = struct {...@@ -77,31 +78,31 @@ pub const Reactor = struct {
7778
78 pub fn update(self: Reactor, fd: os.fd_t, identifier: usize, interest: Reactor.Interest) !void {79 pub fn update(self: Reactor, fd: os.fd_t, identifier: usize, interest: Reactor.Interest) !void {
79 var flags: u32 = 0;80 var flags: u32 = 0;
80 flags |= if (interest.oneshot) os.EPOLLONESHOT else os.EPOLLET;81 flags |= if (interest.oneshot) linux.EPOLL.ONESHOT else linux.EPOLL.ET;
81 if (interest.hup) flags |= os.EPOLLRDHUP;82 if (interest.hup) flags |= linux.EPOLL.RDHUP;
82 if (interest.readable) flags |= os.EPOLLIN;83 if (interest.readable) flags |= linux.EPOLL.IN;
83 if (interest.writable) flags |= os.EPOLLOUT;84 if (interest.writable) flags |= linux.EPOLL.OUT;
8485
85 const event = &os.epoll_event{86 const event = &linux.epoll_event{
86 .events = flags,87 .events = flags,
87 .data = .{ .ptr = identifier },88 .data = .{ .ptr = identifier },
88 };89 };
8990
90 os.epoll_ctl(self.fd, os.EPOLL_CTL_MOD, fd, event) catch |err| switch (err) {91 os.epoll_ctl(self.fd, linux.EPOLL.CTL_MOD, fd, event) catch |err| switch (err) {
91 error.FileDescriptorNotRegistered => try os.epoll_ctl(self.fd, os.EPOLL_CTL_ADD, fd, event),92 error.FileDescriptorNotRegistered => try os.epoll_ctl(self.fd, linux.EPOLL.CTL_ADD, fd, event),
92 else => return err,93 else => return err,
93 };94 };
94 }95 }
9596
96 pub fn poll(self: Reactor, comptime max_num_events: comptime_int, closure: anytype, timeout_milliseconds: ?u64) !void {97 pub fn poll(self: Reactor, comptime max_num_events: comptime_int, closure: anytype, timeout_milliseconds: ?u64) !void {
97 var events: [max_num_events]os.epoll_event = undefined;98 var events: [max_num_events]linux.epoll_event = undefined;
9899
99 const num_events = os.epoll_wait(self.fd, &events, if (timeout_milliseconds) |ms| @intCast(i32, ms) else -1);100 const num_events = os.epoll_wait(self.fd, &events, if (timeout_milliseconds) |ms| @intCast(i32, ms) else -1);
100 for (events[0..num_events]) |ev| {101 for (events[0..num_events]) |ev| {
101 const is_error = ev.events & os.EPOLLERR != 0;102 const is_error = ev.events & linux.EPOLL.ERR != 0;
102 const is_hup = ev.events & (os.EPOLLHUP | os.EPOLLRDHUP) != 0;103 const is_hup = ev.events & (linux.EPOLL.HUP | linux.EPOLL.RDHUP) != 0;
103 const is_readable = ev.events & os.EPOLLIN != 0;104 const is_readable = ev.events & linux.EPOLL.IN != 0;
104 const is_writable = ev.events & os.EPOLLOUT != 0;105 const is_writable = ev.events & linux.EPOLL.OUT != 0;
105106
106 try closure.call(Reactor.Event{107 try closure.call(Reactor.Event{
107 .data = ev.data.ptr,108 .data = ev.data.ptr,
lib/std/x/os/net.zig+1-1
...@@ -22,7 +22,7 @@ pub fn resolveScopeID(name: []const u8) !u32 {...@@ -22,7 +22,7 @@ pub fn resolveScopeID(name: []const u8) !u32 {
22 return os.windows.ws2_32.if_nametoindex(@ptrCast([*:0]const u8, &interface_name));22 return os.windows.ws2_32.if_nametoindex(@ptrCast([*:0]const u8, &interface_name));
23 }23 }
2424
25 const fd = try os.socket(os.AF_UNIX, os.SOCK_DGRAM, 0);25 const fd = try os.socket(os.AF.UNIX, os.SOCK.DGRAM, 0);
26 defer os.closeSocket(fd);26 defer os.closeSocket(fd);
2727
28 var f: os.ifreq = undefined;28 var f: os.ifreq = undefined;
lib/std/x/os/socket.zig+9-9
...@@ -35,7 +35,7 @@ pub const Socket = struct {...@@ -35,7 +35,7 @@ pub const Socket = struct {
3535
36 pub const Family = if (requires_prepended_length) u8 else c_ushort;36 pub const Family = if (requires_prepended_length) u8 else c_ushort;
3737
38 /// POSIX `sockaddr_storage`. The expected size and alignment is specified in IETF RFC 2553.38 /// POSIX `sockaddr.storage`. The expected size and alignment is specified in IETF RFC 2553.
39 pub const Storage = extern struct {39 pub const Storage = extern struct {
40 pub const expected_size = 128;40 pub const expected_size = 128;
41 pub const expected_alignment = 8;41 pub const expected_alignment = 8;
...@@ -71,14 +71,14 @@ pub const Socket = struct {...@@ -71,14 +71,14 @@ pub const Socket = struct {
71 /// Parses a `sockaddr` into a generic socket address.71 /// Parses a `sockaddr` into a generic socket address.
72 pub fn fromNative(address: *align(4) const os.sockaddr) Socket.Address {72 pub fn fromNative(address: *align(4) const os.sockaddr) Socket.Address {
73 switch (address.family) {73 switch (address.family) {
74 os.AF_INET => {74 os.AF.INET => {
75 const info = @ptrCast(*const os.sockaddr_in, address);75 const info = @ptrCast(*const os.sockaddr.in, address);
76 const host = net.IPv4{ .octets = @bitCast([4]u8, info.addr) };76 const host = net.IPv4{ .octets = @bitCast([4]u8, info.addr) };
77 const port = mem.bigToNative(u16, info.port);77 const port = mem.bigToNative(u16, info.port);
78 return Socket.Address.initIPv4(host, port);78 return Socket.Address.initIPv4(host, port);
79 },79 },
80 os.AF_INET6 => {80 os.AF.INET6 => {
81 const info = @ptrCast(*const os.sockaddr_in6, address);81 const info = @ptrCast(*const os.sockaddr.in6, address);
82 const host = net.IPv6{ .octets = info.addr, .scope_id = info.scope_id };82 const host = net.IPv6{ .octets = info.addr, .scope_id = info.scope_id };
83 const port = mem.bigToNative(u16, info.port);83 const port = mem.bigToNative(u16, info.port);
84 return Socket.Address.initIPv6(host, port);84 return Socket.Address.initIPv6(host, port);
...@@ -90,8 +90,8 @@ pub const Socket = struct {...@@ -90,8 +90,8 @@ pub const Socket = struct {
90 /// Encodes a generic socket address into an extern union that may be reliably90 /// Encodes a generic socket address into an extern union that may be reliably
91 /// casted into a `sockaddr` which may be passed into socket syscalls.91 /// casted into a `sockaddr` which may be passed into socket syscalls.
92 pub fn toNative(self: Socket.Address) extern union {92 pub fn toNative(self: Socket.Address) extern union {
93 ipv4: os.sockaddr_in,93 ipv4: os.sockaddr.in,
94 ipv6: os.sockaddr_in6,94 ipv6: os.sockaddr.in6,
95 } {95 } {
96 return switch (self) {96 return switch (self) {
97 .ipv4 => |address| .{97 .ipv4 => |address| .{
...@@ -114,8 +114,8 @@ pub const Socket = struct {...@@ -114,8 +114,8 @@ pub const Socket = struct {
114 /// Returns the number of bytes that make up the `sockaddr` equivalent to the address.114 /// Returns the number of bytes that make up the `sockaddr` equivalent to the address.
115 pub fn getNativeSize(self: Socket.Address) u32 {115 pub fn getNativeSize(self: Socket.Address) u32 {
116 return switch (self) {116 return switch (self) {
117 .ipv4 => @sizeOf(os.sockaddr_in),117 .ipv4 => @sizeOf(os.sockaddr.in),
118 .ipv6 => @sizeOf(os.sockaddr_in6),118 .ipv6 => @sizeOf(os.sockaddr.in6),
119 };119 };
120 }120 }
121121
lib/std/x/os/socket_posix.zig+18-18
...@@ -10,8 +10,8 @@ pub fn Mixin(comptime Socket: type) type {...@@ -10,8 +10,8 @@ pub fn Mixin(comptime Socket: type) type {
10 pub fn init(domain: u32, socket_type: u32, protocol: u32, flags: std.enums.EnumFieldStruct(Socket.InitFlags, bool, false)) !Socket {10 pub fn init(domain: u32, socket_type: u32, protocol: u32, flags: std.enums.EnumFieldStruct(Socket.InitFlags, bool, false)) !Socket {
11 var raw_flags: u32 = socket_type;11 var raw_flags: u32 = socket_type;
12 const set = std.EnumSet(Socket.InitFlags).init(flags);12 const set = std.EnumSet(Socket.InitFlags).init(flags);
13 if (set.contains(.close_on_exec)) raw_flags |= os.SOCK_CLOEXEC;13 if (set.contains(.close_on_exec)) raw_flags |= os.SOCK.CLOEXEC;
14 if (set.contains(.nonblocking)) raw_flags |= os.SOCK_NONBLOCK;14 if (set.contains(.nonblocking)) raw_flags |= os.SOCK.NONBLOCK;
15 return Socket{ .fd = try os.socket(domain, raw_flags, protocol) };15 return Socket{ .fd = try os.socket(domain, raw_flags, protocol) };
16 }16 }
1717
...@@ -48,8 +48,8 @@ pub fn Mixin(comptime Socket: type) type {...@@ -48,8 +48,8 @@ pub fn Mixin(comptime Socket: type) type {
4848
49 var raw_flags: u32 = 0;49 var raw_flags: u32 = 0;
50 const set = std.EnumSet(Socket.InitFlags).init(flags);50 const set = std.EnumSet(Socket.InitFlags).init(flags);
51 if (set.contains(.close_on_exec)) raw_flags |= os.SOCK_CLOEXEC;51 if (set.contains(.close_on_exec)) raw_flags |= os.SOCK.CLOEXEC;
52 if (set.contains(.nonblocking)) raw_flags |= os.SOCK_NONBLOCK;52 if (set.contains(.nonblocking)) raw_flags |= os.SOCK.NONBLOCK;
5353
54 const socket = Socket{ .fd = try os.accept(self.fd, @ptrCast(*os.sockaddr, &address), &address_len, raw_flags) };54 const socket = Socket{ .fd = try os.accept(self.fd, @ptrCast(*os.sockaddr, &address), &address_len, raw_flags) };
55 const socket_address = Socket.Address.fromNative(@ptrCast(*os.sockaddr, &address));55 const socket_address = Socket.Address.fromNative(@ptrCast(*os.sockaddr, &address));
...@@ -156,7 +156,7 @@ pub fn Mixin(comptime Socket: type) type {...@@ -156,7 +156,7 @@ pub fn Mixin(comptime Socket: type) type {
156 var value: u32 = undefined;156 var value: u32 = undefined;
157 var value_len: u32 = @sizeOf(u32);157 var value_len: u32 = @sizeOf(u32);
158158
159 const rc = os.system.getsockopt(self.fd, os.SOL_SOCKET, os.SO_RCVBUF, mem.asBytes(&value), &value_len);159 const rc = os.system.getsockopt(self.fd, os.SOL.SOCKET, os.SO.RCVBUF, mem.asBytes(&value), &value_len);
160 return switch (os.errno(rc)) {160 return switch (os.errno(rc)) {
161 .SUCCESS => value,161 .SUCCESS => value,
162 .BADF => error.BadFileDescriptor,162 .BADF => error.BadFileDescriptor,
...@@ -173,7 +173,7 @@ pub fn Mixin(comptime Socket: type) type {...@@ -173,7 +173,7 @@ pub fn Mixin(comptime Socket: type) type {
173 var value: u32 = undefined;173 var value: u32 = undefined;
174 var value_len: u32 = @sizeOf(u32);174 var value_len: u32 = @sizeOf(u32);
175175
176 const rc = os.system.getsockopt(self.fd, os.SOL_SOCKET, os.SO_SNDBUF, mem.asBytes(&value), &value_len);176 const rc = os.system.getsockopt(self.fd, os.SOL.SOCKET, os.SO.SNDBUF, mem.asBytes(&value), &value_len);
177 return switch (os.errno(rc)) {177 return switch (os.errno(rc)) {
178 .SUCCESS => value,178 .SUCCESS => value,
179 .BADF => error.BadFileDescriptor,179 .BADF => error.BadFileDescriptor,
...@@ -195,9 +195,9 @@ pub fn Mixin(comptime Socket: type) type {...@@ -195,9 +195,9 @@ pub fn Mixin(comptime Socket: type) type {
195 /// if the host does not support the option for a socket to linger around up until a timeout specified in195 /// if the host does not support the option for a socket to linger around up until a timeout specified in
196 /// seconds.196 /// seconds.
197 pub fn setLinger(self: Socket, timeout_seconds: ?u16) !void {197 pub fn setLinger(self: Socket, timeout_seconds: ?u16) !void {
198 if (comptime @hasDecl(os, "SO_LINGER")) {198 if (@hasDecl(os.SO, "LINGER")) {
199 const settings = Socket.Linger.init(timeout_seconds);199 const settings = Socket.Linger.init(timeout_seconds);
200 return self.setOption(os.SOL_SOCKET, os.SO_LINGER, mem.asBytes(&settings));200 return self.setOption(os.SOL.SOCKET, os.SO.LINGER, mem.asBytes(&settings));
201 }201 }
202202
203 return error.UnsupportedSocketOption;203 return error.UnsupportedSocketOption;
...@@ -207,8 +207,8 @@ pub fn Mixin(comptime Socket: type) type {...@@ -207,8 +207,8 @@ pub fn Mixin(comptime Socket: type) type {
207 /// messages are sent are dependant on operating system settings. It returns `error.UnsupportedSocketOption` if207 /// messages are sent are dependant on operating system settings. It returns `error.UnsupportedSocketOption` if
208 /// the host does not support periodically sending keep-alive messages on connection-oriented sockets. 208 /// the host does not support periodically sending keep-alive messages on connection-oriented sockets.
209 pub fn setKeepAlive(self: Socket, enabled: bool) !void {209 pub fn setKeepAlive(self: Socket, enabled: bool) !void {
210 if (comptime @hasDecl(os, "SO_KEEPALIVE")) {210 if (@hasDecl(os.SO, "KEEPALIVE")) {
211 return self.setOption(os.SOL_SOCKET, os.SO_KEEPALIVE, mem.asBytes(&@as(u32, @boolToInt(enabled))));211 return self.setOption(os.SOL.SOCKET, os.SO.KEEPALIVE, mem.asBytes(&@as(u32, @boolToInt(enabled))));
212 }212 }
213 return error.UnsupportedSocketOption;213 return error.UnsupportedSocketOption;
214 }214 }
...@@ -216,8 +216,8 @@ pub fn Mixin(comptime Socket: type) type {...@@ -216,8 +216,8 @@ pub fn Mixin(comptime Socket: type) type {
216 /// Allow multiple sockets on the same host to listen on the same address. It returns `error.UnsupportedSocketOption` if216 /// Allow multiple sockets on the same host to listen on the same address. It returns `error.UnsupportedSocketOption` if
217 /// the host does not support sockets listening the same address.217 /// the host does not support sockets listening the same address.
218 pub fn setReuseAddress(self: Socket, enabled: bool) !void {218 pub fn setReuseAddress(self: Socket, enabled: bool) !void {
219 if (comptime @hasDecl(os, "SO_REUSEADDR")) {219 if (@hasDecl(os.SO, "REUSEADDR")) {
220 return self.setOption(os.SOL_SOCKET, os.SO_REUSEADDR, mem.asBytes(&@as(u32, @boolToInt(enabled))));220 return self.setOption(os.SOL.SOCKET, os.SO.REUSEADDR, mem.asBytes(&@as(u32, @boolToInt(enabled))));
221 }221 }
222 return error.UnsupportedSocketOption;222 return error.UnsupportedSocketOption;
223 }223 }
...@@ -225,20 +225,20 @@ pub fn Mixin(comptime Socket: type) type {...@@ -225,20 +225,20 @@ pub fn Mixin(comptime Socket: type) type {
225 /// Allow multiple sockets on the same host to listen on the same port. It returns `error.UnsupportedSocketOption` if225 /// Allow multiple sockets on the same host to listen on the same port. It returns `error.UnsupportedSocketOption` if
226 /// the host does not supports sockets listening on the same port.226 /// the host does not supports sockets listening on the same port.
227 pub fn setReusePort(self: Socket, enabled: bool) !void {227 pub fn setReusePort(self: Socket, enabled: bool) !void {
228 if (comptime @hasDecl(os, "SO_REUSEPORT")) {228 if (@hasDecl(os.SO, "REUSEPORT")) {
229 return self.setOption(os.SOL_SOCKET, os.SO_REUSEPORT, mem.asBytes(&@as(u32, @boolToInt(enabled))));229 return self.setOption(os.SOL.SOCKET, os.SO.REUSEPORT, mem.asBytes(&@as(u32, @boolToInt(enabled))));
230 }230 }
231 return error.UnsupportedSocketOption;231 return error.UnsupportedSocketOption;
232 }232 }
233233
234 /// Set the write buffer size of the socket.234 /// Set the write buffer size of the socket.
235 pub fn setWriteBufferSize(self: Socket, size: u32) !void {235 pub fn setWriteBufferSize(self: Socket, size: u32) !void {
236 return self.setOption(os.SOL_SOCKET, os.SO_SNDBUF, mem.asBytes(&size));236 return self.setOption(os.SOL.SOCKET, os.SO.SNDBUF, mem.asBytes(&size));
237 }237 }
238238
239 /// Set the read buffer size of the socket.239 /// Set the read buffer size of the socket.
240 pub fn setReadBufferSize(self: Socket, size: u32) !void {240 pub fn setReadBufferSize(self: Socket, size: u32) !void {
241 return self.setOption(os.SOL_SOCKET, os.SO_RCVBUF, mem.asBytes(&size));241 return self.setOption(os.SOL.SOCKET, os.SO.RCVBUF, mem.asBytes(&size));
242 }242 }
243243
244 /// WARNING: Timeouts only affect blocking sockets. It is undefined behavior if a timeout is244 /// WARNING: Timeouts only affect blocking sockets. It is undefined behavior if a timeout is
...@@ -253,7 +253,7 @@ pub fn Mixin(comptime Socket: type) type {...@@ -253,7 +253,7 @@ pub fn Mixin(comptime Socket: type) type {
253 .tv_usec = @intCast(i32, (milliseconds % time.ms_per_s) * time.us_per_ms),253 .tv_usec = @intCast(i32, (milliseconds % time.ms_per_s) * time.us_per_ms),
254 };254 };
255255
256 return self.setOption(os.SOL_SOCKET, os.SO_SNDTIMEO, mem.asBytes(&timeout));256 return self.setOption(os.SOL.SOCKET, os.SO.SNDTIMEO, mem.asBytes(&timeout));
257 }257 }
258258
259 /// WARNING: Timeouts only affect blocking sockets. It is undefined behavior if a timeout is259 /// WARNING: Timeouts only affect blocking sockets. It is undefined behavior if a timeout is
...@@ -269,7 +269,7 @@ pub fn Mixin(comptime Socket: type) type {...@@ -269,7 +269,7 @@ pub fn Mixin(comptime Socket: type) type {
269 .tv_usec = @intCast(i32, (milliseconds % time.ms_per_s) * time.us_per_ms),269 .tv_usec = @intCast(i32, (milliseconds % time.ms_per_s) * time.us_per_ms),
270 };270 };
271271
272 return self.setOption(os.SOL_SOCKET, os.SO_RCVTIMEO, mem.asBytes(&timeout));272 return self.setOption(os.SOL.SOCKET, os.SO.RCVTIMEO, mem.asBytes(&timeout));
273 }273 }
274 };274 };
275}275}
lib/std/x/os/socket_windows.zig+9-9
...@@ -399,39 +399,39 @@ pub fn Mixin(comptime Socket: type) type {...@@ -399,39 +399,39 @@ pub fn Mixin(comptime Socket: type) type {
399 /// seconds.399 /// seconds.
400 pub fn setLinger(self: Socket, timeout_seconds: ?u16) !void {400 pub fn setLinger(self: Socket, timeout_seconds: ?u16) !void {
401 const settings = Socket.Linger.init(timeout_seconds);401 const settings = Socket.Linger.init(timeout_seconds);
402 return self.setOption(ws2_32.SOL_SOCKET, ws2_32.SO_LINGER, mem.asBytes(&settings));402 return self.setOption(ws2_32.SOL.SOCKET, ws2_32.SO.LINGER, mem.asBytes(&settings));
403 }403 }
404404
405 /// On connection-oriented sockets, have keep-alive messages be sent periodically. The timing in which keep-alive405 /// On connection-oriented sockets, have keep-alive messages be sent periodically. The timing in which keep-alive
406 /// messages are sent are dependant on operating system settings. It returns `error.UnsupportedSocketOption` if406 /// messages are sent are dependant on operating system settings. It returns `error.UnsupportedSocketOption` if
407 /// the host does not support periodically sending keep-alive messages on connection-oriented sockets.407 /// the host does not support periodically sending keep-alive messages on connection-oriented sockets.
408 pub fn setKeepAlive(self: Socket, enabled: bool) !void {408 pub fn setKeepAlive(self: Socket, enabled: bool) !void {
409 return self.setOption(ws2_32.SOL_SOCKET, ws2_32.SO_KEEPALIVE, mem.asBytes(&@as(u32, @boolToInt(enabled))));409 return self.setOption(ws2_32.SOL.SOCKET, ws2_32.SO.KEEPALIVE, mem.asBytes(&@as(u32, @boolToInt(enabled))));
410 }410 }
411411
412 /// Allow multiple sockets on the same host to listen on the same address. It returns `error.UnsupportedSocketOption` if412 /// Allow multiple sockets on the same host to listen on the same address. It returns `error.UnsupportedSocketOption` if
413 /// the host does not support sockets listening the same address.413 /// the host does not support sockets listening the same address.
414 pub fn setReuseAddress(self: Socket, enabled: bool) !void {414 pub fn setReuseAddress(self: Socket, enabled: bool) !void {
415 return self.setOption(ws2_32.SOL_SOCKET, ws2_32.SO_REUSEADDR, mem.asBytes(&@as(u32, @boolToInt(enabled))));415 return self.setOption(ws2_32.SOL.SOCKET, ws2_32.SO.REUSEADDR, mem.asBytes(&@as(u32, @boolToInt(enabled))));
416 }416 }
417417
418 /// Allow multiple sockets on the same host to listen on the same port. It returns `error.UnsupportedSocketOption` if418 /// Allow multiple sockets on the same host to listen on the same port. It returns `error.UnsupportedSocketOption` if
419 /// the host does not supports sockets listening on the same port.419 /// the host does not supports sockets listening on the same port.
420 ///420 ///
421 /// TODO: verify if this truly mimicks SO_REUSEPORT behavior, or if SO_REUSE_UNICASTPORT provides the correct behavior421 /// TODO: verify if this truly mimicks SO.REUSEPORT behavior, or if SO.REUSE_UNICASTPORT provides the correct behavior
422 pub fn setReusePort(self: Socket, enabled: bool) !void {422 pub fn setReusePort(self: Socket, enabled: bool) !void {
423 try self.setOption(ws2_32.SOL_SOCKET, ws2_32.SO_BROADCAST, mem.asBytes(&@as(u32, @boolToInt(enabled))));423 try self.setOption(ws2_32.SOL.SOCKET, ws2_32.SO.BROADCAST, mem.asBytes(&@as(u32, @boolToInt(enabled))));
424 try self.setReuseAddress(enabled);424 try self.setReuseAddress(enabled);
425 }425 }
426426
427 /// Set the write buffer size of the socket.427 /// Set the write buffer size of the socket.
428 pub fn setWriteBufferSize(self: Socket, size: u32) !void {428 pub fn setWriteBufferSize(self: Socket, size: u32) !void {
429 return self.setOption(ws2_32.SOL_SOCKET, ws2_32.SO_SNDBUF, mem.asBytes(&size));429 return self.setOption(ws2_32.SOL.SOCKET, ws2_32.SO.SNDBUF, mem.asBytes(&size));
430 }430 }
431431
432 /// Set the read buffer size of the socket.432 /// Set the read buffer size of the socket.
433 pub fn setReadBufferSize(self: Socket, size: u32) !void {433 pub fn setReadBufferSize(self: Socket, size: u32) !void {
434 return self.setOption(ws2_32.SOL_SOCKET, ws2_32.SO_RCVBUF, mem.asBytes(&size));434 return self.setOption(ws2_32.SOL.SOCKET, ws2_32.SO.RCVBUF, mem.asBytes(&size));
435 }435 }
436436
437 /// WARNING: Timeouts only affect blocking sockets. It is undefined behavior if a timeout is437 /// WARNING: Timeouts only affect blocking sockets. It is undefined behavior if a timeout is
...@@ -441,7 +441,7 @@ pub fn Mixin(comptime Socket: type) type {...@@ -441,7 +441,7 @@ pub fn Mixin(comptime Socket: type) type {
441 /// to its bound destination after a specified number of milliseconds. A subsequent write441 /// to its bound destination after a specified number of milliseconds. A subsequent write
442 /// to the socket will thereafter return `error.WouldBlock` should the timeout be exceeded.442 /// to the socket will thereafter return `error.WouldBlock` should the timeout be exceeded.
443 pub fn setWriteTimeout(self: Socket, milliseconds: u32) !void {443 pub fn setWriteTimeout(self: Socket, milliseconds: u32) !void {
444 return self.setOption(ws2_32.SOL_SOCKET, ws2_32.SO_SNDTIMEO, mem.asBytes(&milliseconds));444 return self.setOption(ws2_32.SOL.SOCKET, ws2_32.SO.SNDTIMEO, mem.asBytes(&milliseconds));
445 }445 }
446446
447 /// WARNING: Timeouts only affect blocking sockets. It is undefined behavior if a timeout is447 /// WARNING: Timeouts only affect blocking sockets. It is undefined behavior if a timeout is
...@@ -452,7 +452,7 @@ pub fn Mixin(comptime Socket: type) type {...@@ -452,7 +452,7 @@ pub fn Mixin(comptime Socket: type) type {
452 /// read from the socket will thereafter return `error.WouldBlock` should the timeout be452 /// read from the socket will thereafter return `error.WouldBlock` should the timeout be
453 /// exceeded.453 /// exceeded.
454 pub fn setReadTimeout(self: Socket, milliseconds: u32) !void {454 pub fn setReadTimeout(self: Socket, milliseconds: u32) !void {
455 return self.setOption(ws2_32.SOL_SOCKET, ws2_32.SO_RCVTIMEO, mem.asBytes(&milliseconds));455 return self.setOption(ws2_32.SOL.SOCKET, ws2_32.SO.RCVTIMEO, mem.asBytes(&milliseconds));
456 }456 }
457 };457 };
458}458}
src/main.zig+2-2
...@@ -3836,7 +3836,7 @@ fn gimmeMoreOfThoseSweetSweetFileDescriptors() void {...@@ -3836,7 +3836,7 @@ fn gimmeMoreOfThoseSweetSweetFileDescriptors() void {
3836 // On Darwin, `NOFILE` is bounded by a hardcoded value `OPEN_MAX`.3836 // On Darwin, `NOFILE` is bounded by a hardcoded value `OPEN_MAX`.
3837 // According to the man pages for setrlimit():3837 // According to the man pages for setrlimit():
3838 // setrlimit() now returns with errno set to EINVAL in places that historically succeeded.3838 // setrlimit() now returns with errno set to EINVAL in places that historically succeeded.
3839 // It no longer accepts "rlim_cur = RLIM_INFINITY" for RLIM_NOFILE.3839 // It no longer accepts "rlim_cur = RLIM.INFINITY" for RLIM.NOFILE.
3840 // Use "rlim_cur = min(OPEN_MAX, rlim_max)".3840 // Use "rlim_cur = min(OPEN_MAX, rlim_max)".
3841 lim.max = std.math.min(std.os.darwin.OPEN_MAX, lim.max);3841 lim.max = std.math.min(std.os.darwin.OPEN_MAX, lim.max);
3842 }3842 }
...@@ -3846,7 +3846,7 @@ fn gimmeMoreOfThoseSweetSweetFileDescriptors() void {...@@ -3846,7 +3846,7 @@ fn gimmeMoreOfThoseSweetSweetFileDescriptors() void {
3846 var min: posix.rlim_t = lim.cur;3846 var min: posix.rlim_t = lim.cur;
3847 var max: posix.rlim_t = 1 << 20;3847 var max: posix.rlim_t = 1 << 20;
3848 // But if there's a defined upper bound, don't search, just set it.3848 // But if there's a defined upper bound, don't search, just set it.
3849 if (lim.max != posix.RLIM_INFINITY) {3849 if (lim.max != posix.RLIM.INFINITY) {
3850 min = lim.max;3850 min = lim.max;
3851 max = lim.max;3851 max = lim.max;
3852 }3852 }