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 {
877877 const mapped = os.mmap(
878878 null,
879879 map_bytes,
880 os.PROT_NONE,
881 os.MAP_PRIVATE | os.MAP_ANONYMOUS,
880 os.PROT.NONE,
881 os.MAP.PRIVATE | os.MAP.ANONYMOUS,
882882 -1,
883883 0,
884884 ) catch |err| switch (err) {
......@@ -893,7 +893,7 @@ const LinuxThreadImpl = struct {
893893 // map everything but the guard page as read/write
894894 os.mprotect(
895895 mapped[guard_offset..],
896 os.PROT_READ | os.PROT_WRITE,
896 os.PROT.READ | os.PROT.WRITE,
897897 ) catch |err| switch (err) {
898898 error.AccessDenied => unreachable,
899899 else => |e| return e,
......@@ -923,10 +923,10 @@ const LinuxThreadImpl = struct {
923923 .thread = .{ .mapped = mapped },
924924 };
925925
926 const flags: u32 = os.CLONE_THREAD | os.CLONE_DETACHED |
927 os.CLONE_VM | os.CLONE_FS | os.CLONE_FILES |
928 os.CLONE_PARENT_SETTID | os.CLONE_CHILD_CLEARTID |
929 os.CLONE_SIGHAND | os.CLONE_SYSVSEM | os.CLONE_SETTLS;
926 const flags: u32 = linux.CLONE.THREAD | linux.CLONE.DETACHED |
927 linux.CLONE.VM | linux.CLONE.FS | linux.CLONE.FILES |
928 linux.CLONE.PARENT_SETTID | linux.CLONE.CHILD_CLEARTID |
929 linux.CLONE.SIGHAND | linux.CLONE.SYSVSEM | linux.CLONE.SETTLS;
930930
931931 switch (linux.getErrno(linux.clone(
932932 Instance.entryFn,
......@@ -978,7 +978,7 @@ const LinuxThreadImpl = struct {
978978
979979 switch (linux.getErrno(linux.futex_wait(
980980 &self.thread.child_tid.value,
981 linux.FUTEX_WAIT,
981 linux.FUTEX.WAIT,
982982 tid,
983983 null,
984984 ))) {
lib/std/Thread/Futex.zig+3-3
......@@ -142,7 +142,7 @@ const LinuxFutex = struct {
142142
143143 switch (linux.getErrno(linux.futex_wait(
144144 @ptrCast(*const i32, ptr),
145 linux.FUTEX_PRIVATE_FLAG | linux.FUTEX_WAIT,
145 linux.FUTEX.PRIVATE_FLAG | linux.FUTEX.WAIT,
146146 @bitCast(i32, expect),
147147 ts_ptr,
148148 ))) {
......@@ -159,7 +159,7 @@ const LinuxFutex = struct {
159159 fn wake(ptr: *const Atomic(u32), num_waiters: u32) void {
160160 switch (linux.getErrno(linux.futex_wake(
161161 @ptrCast(*const i32, ptr),
162 linux.FUTEX_PRIVATE_FLAG | linux.FUTEX_WAKE,
162 linux.FUTEX.PRIVATE_FLAG | linux.FUTEX.WAKE,
163163 std.math.cast(i32, num_waiters) catch std.math.maxInt(i32),
164164 ))) {
165165 .SUCCESS => {}, // successful wake up
......@@ -352,7 +352,7 @@ const PosixFutex = struct {
352352 var ts_ptr: ?*const std.os.timespec = null;
353353 if (timeout) |timeout_ns| {
354354 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;
356356 ts.tv_sec += @intCast(@TypeOf(ts.tv_sec), timeout_ns / std.time.ns_per_s);
357357 ts.tv_nsec += @intCast(@TypeOf(ts.tv_nsec), timeout_ns % std.time.ns_per_s);
358358 if (ts.tv_nsec >= std.time.ns_per_s) {
lib/std/Thread/ResetEvent.zig+1-1
......@@ -152,7 +152,7 @@ pub const PosixEvent = struct {
152152 pub fn timedWait(ev: *PosixEvent, timeout_ns: u64) TimedWaitResult {
153153 var ts: os.timespec = undefined;
154154 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;
156156 timeout_abs += @intCast(u64, ts.tv_sec) * time.ns_per_s;
157157 timeout_abs += @intCast(u64, ts.tv_nsec);
158158 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 @@
11const std = @import("std");
22const builtin = std.builtin;
33const page_size = std.mem.page_size;
4const iovec = std.os.iovec;
5const iovec_const = std.os.iovec_const;
46
57pub const tokenizer = @import("c/tokenizer.zig");
68pub const Token = tokenizer.Token;
......@@ -28,14 +30,9 @@ const system = switch (builtin.os.tag) {
2830 .wasi => @import("c/wasi.zig"),
2931 else => struct {},
3032};
31pub const E = system.E;
33
3234pub const _errno = system._errno;
33pub const MAP_FAILED = system.MAP_FAILED;
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;
35pub const copy_file_range = system.copy_file_range;
3936pub const fallocate64 = system.fallocate64;
4037pub const fopen64 = system.fopen64;
4138pub const fstat64 = system.fstat64;
......@@ -53,21 +50,53 @@ pub const pwritev64 = system.pwritev64;
5350pub const sendfile64 = system.sendfile64;
5451pub const setrlimit64 = system.setrlimit64;
5552
53pub const AF = system.AF;
54pub const AI = system.AI;
5655pub const AT = system.AT;
5756pub 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;
5865pub 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;
5970pub const NAME_MAX = system.NAME_MAX;
71pub const NI = system.NI;
72pub const O = system.O;
6073pub const PATH_MAX = system.PATH_MAX;
74pub const POLL = system.POLL;
6175pub const PROT = system.PROT;
76pub const REG = system.REG;
77pub const RLIM = system.RLIM;
6278pub const RTLD = system.RTLD;
79pub const R_OK = system.R_OK;
6380pub const S = system.S;
6481pub const SA = system.SA;
82pub const SEEK = system.SEEK;
83pub const SHUT = system.SHUT;
6584pub const SIG = system.SIG;
85pub const SIOCGIFINDEX = system.SIOCGIFINDEX;
86pub const SO = system.SO;
87pub const SOCK = system.SOCK;
88pub const SOL = system.SOL;
6689pub const STDERR_FILENO = system.STDIN_FILENO;
6790pub const STDIN_FILENO = system.STDIN_FILENO;
6891pub const STDOUT_FILENO = system.STDIN_FILENO;
92pub const Sigaction = system.Sigaction;
6993pub 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;
71100pub const dl_iterate_phdr_callback = system.dl_iterate_phdr_callback;
72101pub const dl_phdr_info = system.dl_phdr_info;
73102pub const empty_sigset = system.empty_sigset;
......@@ -81,12 +110,19 @@ pub const fd_t = system.fd_t;
81110pub const getauxval = system.getauxval;
82111pub const getdents = system.getdents;
83112pub const getrandom = system.getrandom;
113pub const gid_t = system.gid_t;
114pub const ifreq = system.ifreq;
115pub const ino_t = system.ino_t;
84116pub const inotify_add_watch = system.inotify_add_watch;
85117pub const inotify_init1 = system.inotify_init1;
86118pub const inotify_rm_watch = system.inotify_rm_watch;
87119pub const madvise = system.madvise;
88120pub const malloc_usable_size = system.malloc_usable_size;
89121pub 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;
90126pub const pipe2 = system.pipe2;
91127pub const pollfd = system.pollfd;
92128pub const posix_memalign = system.posix_memalign;
......@@ -97,6 +133,7 @@ pub const pthread_getname_np = system.pthread_getname_np;
97133pub const pthread_mutex_t = system.pthread_mutex_t;
98134pub const pthread_rwlock_t = system.pthread_rwlock_t;
99135pub const pthread_setname_np = system.pthread_setname_np;
136pub const rlim_t = system.rlim_t;
100137pub const rlimit = system.rlimit;
101138pub const rlimit_resource = system.rlimit_resource;
102139pub const sched_getaffinity = system.sched_getaffinity;
......@@ -106,14 +143,14 @@ pub const sigaltstack = system.sigaltstack;
106143pub const siginfo_t = system.siginfo_t;
107144pub const signalfd = system.signalfd;
108145pub const sigset_t = system.sigset_t;
109pub const MAP = system.MAP;
110pub const LOCK = system.LOCK;
111pub const REG = system.REG;
112pub const dl_iterate_phdr = system.dl_iterate_phdr;
113pub const ino_t = system.ino_t;
114pub const mode_t = system.mode_t;
146pub const sockaddr = system.sockaddr;
147pub const socklen_t = system.socklen_t;
148pub const stack_t = system.stack_t;
149pub const timespec = system.timespec;
150pub const timeval = system.timeval;
115151pub const ucontext_t = system.ucontext_t;
116pub const O = system.O;
152pub const uid_t = system.uid_t;
153pub const utsname = system.utsname;
117154
118155pub const alarm = if (@hasDecl(system, "alarm")) system.alarm else generic.alarm;
119156pub 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 {
109109
110110pub extern "c" fn sigaltstack(ss: ?*stack_t, old_ss: ?*stack_t) c_int;
111111
112/// get address to use bind()
113pub const AI_PASSIVE = 0x00000001;
114
115/// fill ai_canonname
116pub const AI_CANONNAME = 0x00000002;
117
118/// prevent host name resolution
119pub const AI_NUMERICHOST = 0x00000004;
120
121/// prevent service name resolution
122pub const AI_NUMERICSERV = 0x00001000;
112pub const AI = struct {
113 /// get address to use bind()
114 pub const PASSIVE = 0x00000001;
115 /// fill ai_canonname
116 pub const CANONNAME = 0x00000002;
117 /// prevent host name resolution
118 pub const NUMERICHOST = 0x00000004;
119 /// prevent service name resolution
120 pub const NUMERICSERV = 0x00001000;
121};
123122
124123pub const EAI = enum(c_int) {
125124 /// address family for hostname not supported
......@@ -292,31 +291,31 @@ pub const sockaddr = extern struct {
292291 len: u8,
293292 family: sa_family_t,
294293 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 socket
314pub const sockaddr_un = extern struct {
315 len: u8 = @sizeOf(sockaddr_un),
316 family: sa_family_t = AF_UNIX,
317 path: [104]u8,
295 pub const storage = std.x.os.Socket.Address.Native.Storage;
296 pub const in = extern struct {
297 len: u8 = @sizeOf(in),
298 family: sa_family_t = AF.INET,
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 };
318318};
319
320319pub const timeval = extern struct {
321320 tv_sec: c_long,
322321 tv_usec: i32,
......@@ -521,30 +520,25 @@ pub const PROT_WRITE = 0x02;
521520/// [MC2] pages can be executed
522521pub const PROT_EXEC = 0x04;
523522
524/// allocated from memory, swap space
525pub const MAP_ANONYMOUS = 0x1000;
526
527/// map from file (default)
528pub const MAP_FILE = 0x0000;
529
530/// interpret addr exactly
531pub const MAP_FIXED = 0x0010;
532
533/// region may contain semaphores
534pub const MAP_HASSEMAPHORE = 0x0200;
535
536/// changes are private
537pub const MAP_PRIVATE = 0x0002;
538
539/// share changes
540pub const MAP_SHARED = 0x0001;
541
542/// don't cache pages for this mapping
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));
523pub const MAP = struct {
524 /// allocated from memory, swap space
525 pub const ANONYMOUS = 0x1000;
526 /// map from file (default)
527 pub const FILE = 0x0000;
528 /// interpret addr exactly
529 pub const FIXED = 0x0010;
530 /// region may contain semaphores
531 pub const HASSEMAPHORE = 0x0200;
532 /// changes are private
533 pub const PRIVATE = 0x0002;
534 /// share changes
535 pub const SHARED = 0x0001;
536 /// don't cache pages for this mapping
537 pub const NOCACHE = 0x0400;
538 /// don't reserve needed swap area
539 pub const NORESERVE = 0x0040;
540 pub const FAILED = @intToPtr(*c_void, maxInt(usize));
541};
548542
549543/// [XSI] no hang in wait/no child to reap
550544pub const WNOHANG = 0x00000001;
......@@ -980,136 +974,148 @@ pub const NOTE_MACH_CONTINUOUS_TIME = 0x00000080;
980974/// data is mach absolute time units
981975pub const NOTE_MACHTIME = 0x00000100;
982976
983pub const AF_UNSPEC = 0;
984pub const AF_LOCAL = 1;
985pub const AF_UNIX = AF_LOCAL;
986pub const AF_INET = 2;
987pub const AF_SYS_CONTROL = 2;
988pub const AF_IMPLINK = 3;
989pub const AF_PUP = 4;
990pub const AF_CHAOS = 5;
991pub const AF_NS = 6;
992pub const AF_ISO = 7;
993pub const AF_OSI = AF_ISO;
994pub const AF_ECMA = 8;
995pub const AF_DATAKIT = 9;
996pub const AF_CCITT = 10;
997pub const AF_SNA = 11;
998pub const AF_DECnet = 12;
999pub const AF_DLI = 13;
1000pub const AF_LAT = 14;
1001pub const AF_HYLINK = 15;
1002pub const AF_APPLETALK = 16;
1003pub const AF_ROUTE = 17;
1004pub const AF_LINK = 18;
1005pub const AF_XTP = 19;
1006pub const AF_COIP = 20;
1007pub const AF_CNT = 21;
1008pub const AF_RTIP = 22;
1009pub const AF_IPX = 23;
1010pub const AF_SIP = 24;
1011pub const AF_PIP = 25;
1012pub const AF_ISDN = 28;
1013pub const AF_E164 = AF_ISDN;
1014pub const AF_KEY = 29;
1015pub const AF_INET6 = 30;
1016pub const AF_NATM = 31;
1017pub const AF_SYSTEM = 32;
1018pub const AF_NETBIOS = 33;
1019pub const AF_PPP = 34;
1020pub const AF_MAX = 40;
1021
1022pub const PF_UNSPEC = AF_UNSPEC;
1023pub const PF_LOCAL = AF_LOCAL;
1024pub const PF_UNIX = PF_LOCAL;
1025pub const PF_INET = AF_INET;
1026pub const PF_IMPLINK = AF_IMPLINK;
1027pub const PF_PUP = AF_PUP;
1028pub const PF_CHAOS = AF_CHAOS;
1029pub const PF_NS = AF_NS;
1030pub const PF_ISO = AF_ISO;
1031pub const PF_OSI = AF_ISO;
1032pub const PF_ECMA = AF_ECMA;
1033pub const PF_DATAKIT = AF_DATAKIT;
1034pub const PF_CCITT = AF_CCITT;
1035pub const PF_SNA = AF_SNA;
1036pub const PF_DECnet = AF_DECnet;
1037pub const PF_DLI = AF_DLI;
1038pub const PF_LAT = AF_LAT;
1039pub const PF_HYLINK = AF_HYLINK;
1040pub const PF_APPLETALK = AF_APPLETALK;
1041pub const PF_ROUTE = AF_ROUTE;
1042pub const PF_LINK = AF_LINK;
1043pub const PF_XTP = AF_XTP;
1044pub const PF_COIP = AF_COIP;
1045pub const PF_CNT = AF_CNT;
1046pub const PF_SIP = AF_SIP;
1047pub const PF_IPX = AF_IPX;
1048pub const PF_RTIP = AF_RTIP;
1049pub const PF_PIP = AF_PIP;
1050pub const PF_ISDN = AF_ISDN;
1051pub const PF_KEY = AF_KEY;
1052pub const PF_INET6 = AF_INET6;
1053pub const PF_NATM = AF_NATM;
1054pub const PF_SYSTEM = AF_SYSTEM;
1055pub const PF_NETBIOS = AF_NETBIOS;
1056pub const PF_PPP = AF_PPP;
1057pub const PF_MAX = AF_MAX;
977pub const AF = struct {
978 pub const UNSPEC = 0;
979 pub const LOCAL = 1;
980 pub const UNIX = LOCAL;
981 pub const INET = 2;
982 pub const SYS_CONTROL = 2;
983 pub const IMPLINK = 3;
984 pub const PUP = 4;
985 pub const CHAOS = 5;
986 pub const NS = 6;
987 pub const ISO = 7;
988 pub const OSI = ISO;
989 pub const ECMA = 8;
990 pub const DATAKIT = 9;
991 pub const CCITT = 10;
992 pub const SNA = 11;
993 pub const DECnet = 12;
994 pub const DLI = 13;
995 pub const LAT = 14;
996 pub const HYLINK = 15;
997 pub const APPLETALK = 16;
998 pub const ROUTE = 17;
999 pub const LINK = 18;
1000 pub const XTP = 19;
1001 pub const COIP = 20;
1002 pub const CNT = 21;
1003 pub const RTIP = 22;
1004 pub const IPX = 23;
1005 pub const SIP = 24;
1006 pub const PIP = 25;
1007 pub const ISDN = 28;
1008 pub const E164 = ISDN;
1009 pub const KEY = 29;
1010 pub const INET6 = 30;
1011 pub const NATM = 31;
1012 pub const SYSTEM = 32;
1013 pub const NETBIOS = 33;
1014 pub const PPP = 34;
1015 pub const MAX = 40;
1016};
1017
1018pub const PF = struct {
1019 pub const UNSPEC = AF.UNSPEC;
1020 pub const LOCAL = AF.LOCAL;
1021 pub const UNIX = PF.LOCAL;
1022 pub const INET = AF.INET;
1023 pub const IMPLINK = AF.IMPLINK;
1024 pub const PUP = AF.PUP;
1025 pub const CHAOS = AF.CHAOS;
1026 pub const NS = AF.NS;
1027 pub const ISO = AF.ISO;
1028 pub const OSI = AF.ISO;
1029 pub const ECMA = AF.ECMA;
1030 pub const DATAKIT = AF.DATAKIT;
1031 pub const CCITT = AF.CCITT;
1032 pub const SNA = AF.SNA;
1033 pub const DECnet = AF.DECnet;
1034 pub const DLI = AF.DLI;
1035 pub const LAT = AF.LAT;
1036 pub const HYLINK = AF.HYLINK;
1037 pub const APPLETALK = AF.APPLETALK;
1038 pub const ROUTE = AF.ROUTE;
1039 pub const LINK = AF.LINK;
1040 pub const XTP = AF.XTP;
1041 pub const COIP = AF.COIP;
1042 pub const CNT = AF.CNT;
1043 pub const SIP = AF.SIP;
1044 pub const IPX = AF.IPX;
1045 pub const RTIP = AF.RTIP;
1046 pub const PIP = AF.PIP;
1047 pub const ISDN = AF.ISDN;
1048 pub const KEY = AF.KEY;
1049 pub const INET6 = AF.INET6;
1050 pub const NATM = AF.NATM;
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
10591057pub const SYSPROTO_EVENT = 1;
10601058pub const SYSPROTO_CONTROL = 2;
10611059
1062pub const SOCK_STREAM = 1;
1063pub const SOCK_DGRAM = 2;
1064pub const SOCK_RAW = 3;
1065pub const SOCK_RDM = 4;
1066pub const SOCK_SEQPACKET = 5;
1067pub const SOCK_MAXADDRLEN = 255;
1068
1069/// Not actually supported by Darwin, but Zig supplies a shim.
1070/// This numerical value is not ABI-stable. It need only not conflict
1071/// with any other "SOCK_" bits.
1072pub const SOCK_CLOEXEC = 1 << 15;
1073/// Not actually supported by Darwin, but Zig supplies a shim.
1074/// This numerical value is not ABI-stable. It need only not conflict
1075/// with any other "SOCK_" bits.
1076pub const SOCK_NONBLOCK = 1 << 16;
1077
1078pub const IPPROTO_ICMP = 1;
1079pub const IPPROTO_ICMPV6 = 58;
1080pub const IPPROTO_TCP = 6;
1081pub const IPPROTO_UDP = 17;
1082pub const IPPROTO_IP = 0;
1083pub const IPPROTO_IPV6 = 41;
1084
1085pub const SOL_SOCKET = 0xffff;
1086
1087pub const SO_DEBUG = 0x0001;
1088pub const SO_ACCEPTCONN = 0x0002;
1089pub const SO_REUSEADDR = 0x0004;
1090pub const SO_KEEPALIVE = 0x0008;
1091pub const SO_DONTROUTE = 0x0010;
1092pub const SO_BROADCAST = 0x0020;
1093pub const SO_USELOOPBACK = 0x0040;
1094pub const SO_LINGER = 0x1080;
1095pub const SO_OOBINLINE = 0x0100;
1096pub const SO_REUSEPORT = 0x0200;
1097pub const SO_ACCEPTFILTER = 0x1000;
1098pub const SO_SNDBUF = 0x1001;
1099pub const SO_RCVBUF = 0x1002;
1100pub const SO_SNDLOWAT = 0x1003;
1101pub const SO_RCVLOWAT = 0x1004;
1102pub const SO_SNDTIMEO = 0x1005;
1103pub const SO_RCVTIMEO = 0x1006;
1104pub const SO_ERROR = 0x1007;
1105pub const SO_TYPE = 0x1008;
1106
1107pub const SO_NREAD = 0x1020;
1108pub const SO_NKE = 0x1021;
1109pub const SO_NOSIGPIPE = 0x1022;
1110pub const SO_NOADDRERR = 0x1023;
1111pub const SO_NWRITE = 0x1024;
1112pub const SO_REUSESHAREUID = 0x1025;
1060pub const SOCK = struct {
1061 pub const STREAM = 1;
1062 pub const DGRAM = 2;
1063 pub const RAW = 3;
1064 pub const RDM = 4;
1065 pub const SEQPACKET = 5;
1066 pub const MAXADDRLEN = 255;
1067
1068 /// Not actually supported by Darwin, but Zig supplies a shim.
1069 /// This numerical value is not ABI-stable. It need only not conflict
1070 /// with any other `SOCK` bits.
1071 pub const CLOEXEC = 1 << 15;
1072 /// Not actually supported by Darwin, but Zig supplies a shim.
1073 /// This numerical value is not ABI-stable. It need only not conflict
1074 /// with any other `SOCK` bits.
1075 pub const NONBLOCK = 1 << 16;
1076};
1077
1078pub const IPPROTO = struct {
1079 pub const ICMP = 1;
1080 pub const ICMPV6 = 58;
1081 pub const TCP = 6;
1082 pub const UDP = 17;
1083 pub const IP = 0;
1084 pub const IPV6 = 41;
1085};
1086
1087pub const SOL = struct {
1088 pub const SOCKET = 0xffff;
1089};
1090
1091pub const SO = struct {
1092 pub const DEBUG = 0x0001;
1093 pub const ACCEPTCONN = 0x0002;
1094 pub const REUSEADDR = 0x0004;
1095 pub const KEEPALIVE = 0x0008;
1096 pub const DONTROUTE = 0x0010;
1097 pub const BROADCAST = 0x0020;
1098 pub const USELOOPBACK = 0x0040;
1099 pub const LINGER = 0x1080;
1100 pub const OOBINLINE = 0x0100;
1101 pub const REUSEPORT = 0x0200;
1102 pub const ACCEPTFILTER = 0x1000;
1103 pub const SNDBUF = 0x1001;
1104 pub const RCVBUF = 0x1002;
1105 pub const SNDLOWAT = 0x1003;
1106 pub const RCVLOWAT = 0x1004;
1107 pub const SNDTIMEO = 0x1005;
1108 pub const RCVTIMEO = 0x1006;
1109 pub const ERROR = 0x1007;
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
11141120fn wstatus(x: u32) u32 {
11151121 return x & 0o177;
......@@ -1569,18 +1575,20 @@ pub const addrinfo = extern struct {
15691575 next: ?*addrinfo,
15701576};
15711577
1572pub const RTLD_LAZY = 0x1;
1573pub const RTLD_NOW = 0x2;
1574pub const RTLD_LOCAL = 0x4;
1575pub const RTLD_GLOBAL = 0x8;
1576pub const RTLD_NOLOAD = 0x10;
1577pub const RTLD_NODELETE = 0x80;
1578pub const RTLD_FIRST = 0x100;
1579
1580pub const RTLD_NEXT = @intToPtr(*c_void, @bitCast(usize, @as(isize, -1)));
1581pub const RTLD_DEFAULT = @intToPtr(*c_void, @bitCast(usize, @as(isize, -2)));
1582pub const RTLD_SELF = @intToPtr(*c_void, @bitCast(usize, @as(isize, -3)));
1583pub const RTLD_MAIN_ONLY = @intToPtr(*c_void, @bitCast(usize, @as(isize, -5)));
1578pub const RTLD = struct {
1579 pub const LAZY = 0x1;
1580 pub const NOW = 0x2;
1581 pub const LOCAL = 0x4;
1582 pub const GLOBAL = 0x8;
1583 pub const NOLOAD = 0x10;
1584 pub const NODELETE = 0x80;
1585 pub const FIRST = 0x100;
1586
1587 pub const NEXT = @intToPtr(*c_void, @bitCast(usize, @as(isize, -1)));
1588 pub const DEFAULT = @intToPtr(*c_void, @bitCast(usize, @as(isize, -2)));
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
15851593/// duplicate file descriptor
15861594pub const F_DUPFD = 0;
......@@ -1740,10 +1748,12 @@ pub const F_UNLCK = 2;
17401748/// exclusive or write lock
17411749pub const F_WRLCK = 3;
17421750
1743pub const LOCK_SH = 1;
1744pub const LOCK_EX = 2;
1745pub const LOCK_UN = 8;
1746pub const LOCK_NB = 4;
1751pub const LOCK = struct {
1752 pub const SH = 1;
1753 pub const EX = 2;
1754 pub const UN = 8;
1755 pub const NB = 4;
1756};
17471757
17481758pub const nfds_t = u32;
17491759pub const pollfd = extern struct {
......@@ -1752,33 +1762,37 @@ pub const pollfd = extern struct {
17521762 revents: i16,
17531763};
17541764
1755pub const POLLIN = 0x001;
1756pub const POLLPRI = 0x002;
1757pub const POLLOUT = 0x004;
1758pub const POLLRDNORM = 0x040;
1759pub const POLLWRNORM = POLLOUT;
1760pub const POLLRDBAND = 0x080;
1761pub const POLLWRBAND = 0x100;
1762
1763pub const POLLEXTEND = 0x0200;
1764pub const POLLATTRIB = 0x0400;
1765pub const POLLNLINK = 0x0800;
1766pub const POLLWRITE = 0x1000;
1767
1768pub const POLLERR = 0x008;
1769pub const POLLHUP = 0x010;
1770pub const POLLNVAL = 0x020;
1771
1772pub const POLLSTANDARD = POLLIN | POLLPRI | POLLOUT | POLLRDNORM | POLLRDBAND | POLLWRBAND | POLLERR | POLLHUP | POLLNVAL;
1773
1774pub const CLOCK_REALTIME = 0;
1775pub const CLOCK_MONOTONIC = 6;
1776pub const CLOCK_MONOTONIC_RAW = 4;
1777pub const CLOCK_MONOTONIC_RAW_APPROX = 5;
1778pub const CLOCK_UPTIME_RAW = 8;
1779pub const CLOCK_UPTIME_RAW_APPROX = 9;
1780pub const CLOCK_PROCESS_CPUTIME_ID = 12;
1781pub const CLOCK_THREAD_CPUTIME_ID = 16;
1765pub const POLL = struct {
1766 pub const IN = 0x001;
1767 pub const PRI = 0x002;
1768 pub const OUT = 0x004;
1769 pub const RDNORM = 0x040;
1770 pub const WRNORM = OUT;
1771 pub const RDBAND = 0x080;
1772 pub const WRBAND = 0x100;
1773
1774 pub const EXTEND = 0x0200;
1775 pub const ATTRIB = 0x0400;
1776 pub const NLINK = 0x0800;
1777 pub const WRITE = 0x1000;
1778
1779 pub const ERR = 0x008;
1780 pub const HUP = 0x010;
1781 pub const NVAL = 0x020;
1782
1783 pub const STANDARD = IN | PRI | OUT | RDNORM | RDBAND | WRBAND | ERR | HUP | NVAL;
1784};
1785
1786pub const CLOCK = struct {
1787 pub const REALTIME = 0;
1788 pub const MONOTONIC = 6;
1789 pub const MONOTONIC_RAW = 4;
1790 pub const MONOTONIC_RAW_APPROX = 5;
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
17831797/// Max open files per process
17841798/// 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) {
18221836
18231837pub const rlim_t = u64;
18241838
1825/// No limit
1826pub const RLIM_INFINITY: rlim_t = (1 << 63) - 1;
1839pub const RLIM = struct {
1840 /// No limit
1841 pub const INFINITY: rlim_t = (1 << 63) - 1;
18271842
1828pub const RLIM_SAVED_MAX = RLIM_INFINITY;
1829pub const RLIM_SAVED_CUR = RLIM_INFINITY;
1843 pub const SAVED_MAX = INFINITY;
1844 pub const SAVED_CUR = INFINITY;
1845};
18301846
18311847pub const rlimit = extern struct {
18321848 /// Soft limit
lib/std/c/dragonfly.zig+357-329
......@@ -161,25 +161,27 @@ pub const PROT_READ = 1;
161161pub const PROT_WRITE = 2;
162162pub const PROT_EXEC = 4;
163163
164pub const MAP_FILE = 0;
165pub const MAP_FAILED = @intToPtr(*c_void, maxInt(usize));
166pub const MAP_ANONYMOUS = MAP_ANON;
167pub const MAP_COPY = MAP_PRIVATE;
168pub const MAP_SHARED = 1;
169pub const MAP_PRIVATE = 2;
170pub const MAP_FIXED = 16;
171pub const MAP_RENAME = 32;
172pub const MAP_NORESERVE = 64;
173pub const MAP_INHERIT = 128;
174pub const MAP_NOEXTEND = 256;
175pub const MAP_HASSEMAPHORE = 512;
176pub const MAP_STACK = 1024;
177pub const MAP_NOSYNC = 2048;
178pub const MAP_ANON = 4096;
179pub const MAP_VPAGETABLE = 8192;
180pub const MAP_TRYFIXED = 65536;
181pub const MAP_NOCORE = 131072;
182pub const MAP_SIZEALIGN = 262144;
164pub const MAP = struct {
165 pub const FILE = 0;
166 pub const FAILED = @intToPtr(*c_void, maxInt(usize));
167 pub const ANONYMOUS = ANON;
168 pub const COPY = PRIVATE;
169 pub const SHARED = 1;
170 pub const PRIVATE = 2;
171 pub const FIXED = 16;
172 pub const RENAME = 32;
173 pub const NORESERVE = 64;
174 pub const INHERIT = 128;
175 pub const NOEXTEND = 256;
176 pub const HASSEMAPHORE = 512;
177 pub const STACK = 1024;
178 pub const NOSYNC = 2048;
179 pub const ANON = 4096;
180 pub const VPAGETABLE = 8192;
181 pub const TRYFIXED = 65536;
182 pub const NOCORE = 131072;
183 pub const SIZEALIGN = 262144;
184};
183185
184186pub const WNOHANG = 0x0001;
185187pub const WUNTRACED = 0x0002;
......@@ -407,28 +409,47 @@ pub const DT_SOCK = 12;
407409pub const DT_WHT = 14;
408410pub const DT_DBF = 15;
409411
410pub const CLOCK_REALTIME = 0;
411pub const CLOCK_VIRTUAL = 1;
412pub const CLOCK_PROF = 2;
413pub const CLOCK_MONOTONIC = 4;
414pub const CLOCK_UPTIME = 5;
415pub const CLOCK_UPTIME_PRECISE = 7;
416pub const CLOCK_UPTIME_FAST = 8;
417pub const CLOCK_REALTIME_PRECISE = 9;
418pub const CLOCK_REALTIME_FAST = 10;
419pub const CLOCK_MONOTONIC_PRECISE = 11;
420pub const CLOCK_MONOTONIC_FAST = 12;
421pub const CLOCK_SECOND = 13;
422pub const CLOCK_THREAD_CPUTIME_ID = 14;
423pub const CLOCK_PROCESS_CPUTIME_ID = 15;
412pub const CLOCK = struct {
413 pub const REALTIME = 0;
414 pub const VIRTUAL = 1;
415 pub const PROF = 2;
416 pub const MONOTONIC = 4;
417 pub const UPTIME = 5;
418 pub const UPTIME_PRECISE = 7;
419 pub const UPTIME_FAST = 8;
420 pub const REALTIME_PRECISE = 9;
421 pub const REALTIME_FAST = 10;
422 pub const MONOTONIC_PRECISE = 11;
423 pub const MONOTONIC_FAST = 12;
424 pub const SECOND = 13;
425 pub const THREAD_CPUTIME_ID = 14;
426 pub const PROCESS_CPUTIME_ID = 15;
427};
424428
425429pub const sockaddr = extern struct {
426430 len: u8,
427431 family: u8,
428432 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
433454pub const Kevent = extern struct {
434455 ident: usize,
......@@ -616,135 +637,128 @@ pub const Sigaction = extern struct {
616637
617638pub const sig_t = [*c]fn (c_int) callconv(.C) void;
618639
619pub const SOCK_STREAM = 1;
620pub const SOCK_DGRAM = 2;
621pub const SOCK_RAW = 3;
622pub const SOCK_RDM = 4;
623pub const SOCK_SEQPACKET = 5;
624pub const SOCK_MAXADDRLEN = 255;
625pub const SOCK_CLOEXEC = 0x10000000;
626pub const SOCK_NONBLOCK = 0x20000000;
627
628pub const SO_DEBUG = 0x0001;
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;
640pub const SOCK = struct {
641 pub const STREAM = 1;
642 pub const DGRAM = 2;
643 pub const RAW = 3;
644 pub const RDM = 4;
645 pub const SEQPACKET = 5;
646 pub const MAXADDRLEN = 255;
647 pub const CLOEXEC = 0x10000000;
648 pub const NONBLOCK = 0x20000000;
649};
726650
727pub const in_port_t = u16;
728pub const sa_family_t = u8;
729pub const socklen_t = u32;
651pub const SO = struct {
652 pub const DEBUG = 0x0001;
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 {
732 len: u8 = @sizeOf(sockaddr_in),
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 },
680pub const SOL = struct {
681 pub const SOCKET = 0xffff;
737682};
738683
739pub const sockaddr_in6 = extern struct {
740 len: u8 = @sizeOf(sockaddr_in6),
741 family: sa_family_t = AF_INET6,
742 port: in_port_t,
743 flowinfo: u32,
744 addr: [16]u8,
745 scope_id: u32,
684pub const PF = struct {
685 pub const INET6 = AF.INET6;
686 pub const IMPLINK = AF.IMPLINK;
687 pub const ROUTE = AF.ROUTE;
688 pub const ISO = AF.ISO;
689 pub const PIP = AF.pseudo_PIP;
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;
746721};
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
748762pub const EAI = enum(c_int) {
749763 ADDRFAMILY = 1,
750764 AGAIN = 2,
......@@ -763,30 +777,34 @@ pub const EAI = enum(c_int) {
763777 _,
764778};
765779
766pub const AI_PASSIVE = 0x00000001;
767pub const AI_CANONNAME = 0x00000002;
768pub const AI_NUMERICHOST = 0x00000004;
769pub const AI_NUMERICSERV = 0x00000008;
770pub const AI_MASK = AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST | AI_NUMERICSERV | AI_ADDRCONFIG;
771pub const AI_ALL = 0x00000100;
772pub const AI_V4MAPPED_CFG = 0x00000200;
773pub const AI_ADDRCONFIG = 0x00000400;
774pub const AI_V4MAPPED = 0x00000800;
775pub const AI_DEFAULT = AI_V4MAPPED_CFG | AI_ADDRCONFIG;
776
777pub const RTLD_LAZY = 1;
778pub const RTLD_NOW = 2;
779pub const RTLD_MODEMASK = 0x3;
780pub const RTLD_GLOBAL = 0x100;
781pub const RTLD_LOCAL = 0;
782pub const RTLD_TRACE = 0x200;
783pub const RTLD_NODELETE = 0x01000;
784pub const RTLD_NOLOAD = 0x02000;
785
786pub const RTLD_NEXT = @intToPtr(*c_void, @bitCast(usize, @as(isize, -1)));
787pub const RTLD_DEFAULT = @intToPtr(*c_void, @bitCast(usize, @as(isize, -2)));
788pub const RTLD_SELF = @intToPtr(*c_void, @bitCast(usize, @as(isize, -3)));
789pub const RTLD_ALL = @intToPtr(*c_void, @bitCast(usize, @as(isize, -4)));
780pub const AI = struct {
781 pub const PASSIVE = 0x00000001;
782 pub const CANONNAME = 0x00000002;
783 pub const NUMERICHOST = 0x00000004;
784 pub const NUMERICSERV = 0x00000008;
785 pub const MASK = PASSIVE | CANONNAME | NUMERICHOST | NUMERICSERV | ADDRCONFIG;
786 pub const ALL = 0x00000100;
787 pub const V4MAPPED_CFG = 0x00000200;
788 pub const ADDRCONFIG = 0x00000400;
789 pub const V4MAPPED = 0x00000800;
790 pub const DEFAULT = V4MAPPED_CFG | ADDRCONFIG;
791};
792
793pub const RTLD = struct {
794 pub const LAZY = 1;
795 pub const NOW = 2;
796 pub const MODEMASK = 0x3;
797 pub const GLOBAL = 0x100;
798 pub const LOCAL = 0;
799 pub const TRACE = 0x200;
800 pub const NODELETE = 0x01000;
801 pub const NOLOAD = 0x02000;
802
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
791809pub const dl_phdr_info = extern struct {
792810 dlpi_addr: usize,
......@@ -833,20 +851,22 @@ pub const POSIX_MADV_DONTNEED = 4;
833851pub const POSIX_MADV_NORMAL = 0;
834852pub const POSIX_MADV_WILLNEED = 3;
835853
836pub const MADV_SEQUENTIAL = 2;
837pub const MADV_CONTROL_END = MADV_SETMAP;
838pub const MADV_DONTNEED = 4;
839pub const MADV_RANDOM = 1;
840pub const MADV_WILLNEED = 3;
841pub const MADV_NORMAL = 0;
842pub const MADV_CONTROL_START = MADV_INVAL;
843pub const MADV_FREE = 5;
844pub const MADV_NOSYNC = 6;
845pub const MADV_AUTOSYNC = 7;
846pub const MADV_NOCORE = 8;
847pub const MADV_CORE = 9;
848pub const MADV_INVAL = 10;
849pub const MADV_SETMAP = 11;
854pub const MADV = struct {
855 pub const SEQUENTIAL = 2;
856 pub const CONTROL_END = SETMAP;
857 pub const DONTNEED = 4;
858 pub const RANDOM = 1;
859 pub const WILLNEED = 3;
860 pub const NORMAL = 0;
861 pub const CONTROL_START = INVAL;
862 pub const FREE = 5;
863 pub const NOSYNC = 6;
864 pub const AUTOSYNC = 7;
865 pub const NOCORE = 8;
866 pub const CORE = 9;
867 pub const INVAL = 10;
868 pub const SETMAP = 11;
869};
850870
851871pub const F_DUPFD = 0;
852872pub const F_GETFD = 1;
......@@ -865,10 +885,12 @@ pub const F_DUP2FD = 10;
865885pub const F_DUPFD_CLOEXEC = 17;
866886pub const F_DUP2FD_CLOEXEC = 18;
867887
868pub const LOCK_SH = 1;
869pub const LOCK_EX = 2;
870pub const LOCK_UN = 8;
871pub const LOCK_NB = 4;
888pub const LOCK = struct {
889 pub const SH = 1;
890 pub const EX = 2;
891 pub const UN = 8;
892 pub const NB = 4;
893};
872894
873895pub const Flock = extern struct {
874896 l_start: off_t,
......@@ -889,118 +911,120 @@ pub const addrinfo = extern struct {
889911 next: ?*addrinfo,
890912};
891913
892pub const IPPROTO_IP = 0;
893pub const IPPROTO_ICMP = 1;
894pub const IPPROTO_TCP = 6;
895pub const IPPROTO_UDP = 17;
896pub const IPPROTO_IPV6 = 41;
897pub const IPPROTO_RAW = 255;
898pub const IPPROTO_HOPOPTS = 0;
899pub const IPPROTO_IGMP = 2;
900pub const IPPROTO_GGP = 3;
901pub const IPPROTO_IPV4 = 4;
902pub const IPPROTO_IPIP = IPPROTO_IPV4;
903pub const IPPROTO_ST = 7;
904pub const IPPROTO_EGP = 8;
905pub const IPPROTO_PIGP = 9;
906pub const IPPROTO_RCCMON = 10;
907pub const IPPROTO_NVPII = 11;
908pub const IPPROTO_PUP = 12;
909pub const IPPROTO_ARGUS = 13;
910pub const IPPROTO_EMCON = 14;
911pub const IPPROTO_XNET = 15;
912pub const IPPROTO_CHAOS = 16;
913pub const IPPROTO_MUX = 18;
914pub const IPPROTO_MEAS = 19;
915pub const IPPROTO_HMP = 20;
916pub const IPPROTO_PRM = 21;
917pub const IPPROTO_IDP = 22;
918pub const IPPROTO_TRUNK1 = 23;
919pub const IPPROTO_TRUNK2 = 24;
920pub const IPPROTO_LEAF1 = 25;
921pub const IPPROTO_LEAF2 = 26;
922pub const IPPROTO_RDP = 27;
923pub const IPPROTO_IRTP = 28;
924pub const IPPROTO_TP = 29;
925pub const IPPROTO_BLT = 30;
926pub const IPPROTO_NSP = 31;
927pub const IPPROTO_INP = 32;
928pub const IPPROTO_SEP = 33;
929pub const IPPROTO_3PC = 34;
930pub const IPPROTO_IDPR = 35;
931pub const IPPROTO_XTP = 36;
932pub const IPPROTO_DDP = 37;
933pub const IPPROTO_CMTP = 38;
934pub const IPPROTO_TPXX = 39;
935pub const IPPROTO_IL = 40;
936pub const IPPROTO_SDRP = 42;
937pub const IPPROTO_ROUTING = 43;
938pub const IPPROTO_FRAGMENT = 44;
939pub const IPPROTO_IDRP = 45;
940pub const IPPROTO_RSVP = 46;
941pub const IPPROTO_GRE = 47;
942pub const IPPROTO_MHRP = 48;
943pub const IPPROTO_BHA = 49;
944pub const IPPROTO_ESP = 50;
945pub const IPPROTO_AH = 51;
946pub const IPPROTO_INLSP = 52;
947pub const IPPROTO_SWIPE = 53;
948pub const IPPROTO_NHRP = 54;
949pub const IPPROTO_MOBILE = 55;
950pub const IPPROTO_TLSP = 56;
951pub const IPPROTO_SKIP = 57;
952pub const IPPROTO_ICMPV6 = 58;
953pub const IPPROTO_NONE = 59;
954pub const IPPROTO_DSTOPTS = 60;
955pub const IPPROTO_AHIP = 61;
956pub const IPPROTO_CFTP = 62;
957pub const IPPROTO_HELLO = 63;
958pub const IPPROTO_SATEXPAK = 64;
959pub const IPPROTO_KRYPTOLAN = 65;
960pub const IPPROTO_RVD = 66;
961pub const IPPROTO_IPPC = 67;
962pub const IPPROTO_ADFS = 68;
963pub const IPPROTO_SATMON = 69;
964pub const IPPROTO_VISA = 70;
965pub const IPPROTO_IPCV = 71;
966pub const IPPROTO_CPNX = 72;
967pub const IPPROTO_CPHB = 73;
968pub const IPPROTO_WSN = 74;
969pub const IPPROTO_PVP = 75;
970pub const IPPROTO_BRSATMON = 76;
971pub const IPPROTO_ND = 77;
972pub const IPPROTO_WBMON = 78;
973pub const IPPROTO_WBEXPAK = 79;
974pub const IPPROTO_EON = 80;
975pub const IPPROTO_VMTP = 81;
976pub const IPPROTO_SVMTP = 82;
977pub const IPPROTO_VINES = 83;
978pub const IPPROTO_TTP = 84;
979pub const IPPROTO_IGP = 85;
980pub const IPPROTO_DGP = 86;
981pub const IPPROTO_TCF = 87;
982pub const IPPROTO_IGRP = 88;
983pub const IPPROTO_OSPFIGP = 89;
984pub const IPPROTO_SRPC = 90;
985pub const IPPROTO_LARP = 91;
986pub const IPPROTO_MTP = 92;
987pub const IPPROTO_AX25 = 93;
988pub const IPPROTO_IPEIP = 94;
989pub const IPPROTO_MICP = 95;
990pub const IPPROTO_SCCSP = 96;
991pub const IPPROTO_ETHERIP = 97;
992pub const IPPROTO_ENCAP = 98;
993pub const IPPROTO_APES = 99;
994pub const IPPROTO_GMTP = 100;
995pub const IPPROTO_IPCOMP = 108;
996pub const IPPROTO_PIM = 103;
997pub const IPPROTO_CARP = 112;
998pub const IPPROTO_PGM = 113;
999pub const IPPROTO_PFSYNC = 240;
1000pub const IPPROTO_DIVERT = 254;
1001pub const IPPROTO_MAX = 256;
1002pub const IPPROTO_DONE = 257;
1003pub const IPPROTO_UNKNOWN = 258;
914pub const IPPROTO = struct {
915 pub const IP = 0;
916 pub const ICMP = 1;
917 pub const TCP = 6;
918 pub const UDP = 17;
919 pub const IPV6 = 41;
920 pub const RAW = 255;
921 pub const HOPOPTS = 0;
922 pub const IGMP = 2;
923 pub const GGP = 3;
924 pub const IPV4 = 4;
925 pub const IPIP = IPV4;
926 pub const ST = 7;
927 pub const EGP = 8;
928 pub const PIGP = 9;
929 pub const RCCMON = 10;
930 pub const NVPII = 11;
931 pub const PUP = 12;
932 pub const ARGUS = 13;
933 pub const EMCON = 14;
934 pub const XNET = 15;
935 pub const CHAOS = 16;
936 pub const MUX = 18;
937 pub const MEAS = 19;
938 pub const HMP = 20;
939 pub const PRM = 21;
940 pub const IDP = 22;
941 pub const TRUNK1 = 23;
942 pub const TRUNK2 = 24;
943 pub const LEAF1 = 25;
944 pub const LEAF2 = 26;
945 pub const RDP = 27;
946 pub const IRTP = 28;
947 pub const TP = 29;
948 pub const BLT = 30;
949 pub const NSP = 31;
950 pub const INP = 32;
951 pub const SEP = 33;
952 pub const @"3PC" = 34;
953 pub const IDPR = 35;
954 pub const XTP = 36;
955 pub const DDP = 37;
956 pub const CMTP = 38;
957 pub const TPXX = 39;
958 pub const IL = 40;
959 pub const SDRP = 42;
960 pub const ROUTING = 43;
961 pub const FRAGMENT = 44;
962 pub const IDRP = 45;
963 pub const RSVP = 46;
964 pub const GRE = 47;
965 pub const MHRP = 48;
966 pub const BHA = 49;
967 pub const ESP = 50;
968 pub const AH = 51;
969 pub const INLSP = 52;
970 pub const SWIPE = 53;
971 pub const NHRP = 54;
972 pub const MOBILE = 55;
973 pub const TLSP = 56;
974 pub const SKIP = 57;
975 pub const ICMPV6 = 58;
976 pub const NONE = 59;
977 pub const DSTOPTS = 60;
978 pub const AHIP = 61;
979 pub const CFTP = 62;
980 pub const HELLO = 63;
981 pub const SATEXPAK = 64;
982 pub const KRYPTOLAN = 65;
983 pub const RVD = 66;
984 pub const IPPC = 67;
985 pub const ADFS = 68;
986 pub const SATMON = 69;
987 pub const VISA = 70;
988 pub const IPCV = 71;
989 pub const CPNX = 72;
990 pub const CPHB = 73;
991 pub const WSN = 74;
992 pub const PVP = 75;
993 pub const BRSATMON = 76;
994 pub const ND = 77;
995 pub const WBMON = 78;
996 pub const WBEXPAK = 79;
997 pub const EON = 80;
998 pub const VMTP = 81;
999 pub const SVMTP = 82;
1000 pub const VINES = 83;
1001 pub const TTP = 84;
1002 pub const IGP = 85;
1003 pub const DGP = 86;
1004 pub const TCF = 87;
1005 pub const IGRP = 88;
1006 pub const OSPFIGP = 89;
1007 pub const SRPC = 90;
1008 pub const LARP = 91;
1009 pub const MTP = 92;
1010 pub const AX25 = 93;
1011 pub const IPEIP = 94;
1012 pub const MICP = 95;
1013 pub const SCCSP = 96;
1014 pub const ETHERIP = 97;
1015 pub const ENCAP = 98;
1016 pub const APES = 99;
1017 pub const GMTP = 100;
1018 pub const IPCOMP = 108;
1019 pub const PIM = 103;
1020 pub const CARP = 112;
1021 pub const PGM = 113;
1022 pub const PFSYNC = 240;
1023 pub const DIVERT = 254;
1024 pub const MAX = 256;
1025 pub const DONE = 257;
1026 pub const UNKNOWN = 258;
1027};
10041028
10051029pub const rlimit_resource = enum(c_int) {
10061030 CPU = 0,
......@@ -1022,11 +1046,13 @@ pub const rlimit_resource = enum(c_int) {
10221046
10231047pub const rlim_t = i64;
10241048
1025/// No limit
1026pub const RLIM_INFINITY: rlim_t = (1 << 63) - 1;
1049pub const RLIM = struct {
1050 /// No limit
1051 pub const INFINITY: rlim_t = (1 << 63) - 1;
10271052
1028pub const RLIM_SAVED_MAX = RLIM_INFINITY;
1029pub const RLIM_SAVED_CUR = RLIM_INFINITY;
1053 pub const SAVED_MAX = INFINITY;
1054 pub const SAVED_CUR = INFINITY;
1055};
10301056
10311057pub const rlimit = extern struct {
10321058 /// Soft limit
......@@ -1047,16 +1073,18 @@ pub const pollfd = extern struct {
10471073 revents: i16,
10481074};
10491075
1050/// Requestable events.
1051pub const POLLIN = 0x0001;
1052pub const POLLPRI = 0x0002;
1053pub const POLLOUT = 0x0004;
1054pub const POLLRDNORM = 0x0040;
1055pub const POLLWRNORM = POLLOUT;
1056pub const POLLRDBAND = 0x0080;
1057pub const POLLWRBAND = 0x0100;
1058
1059/// These events are set if they occur regardless of whether they were requested.
1060pub const POLLERR = 0x0008;
1061pub const POLLHUP = 0x0010;
1062pub const POLLNVAL = 0x0020;
1076pub const POLL = struct {
1077 /// Requestable events.
1078 pub const IN = 0x0001;
1079 pub const PRI = 0x0002;
1080 pub const OUT = 0x0004;
1081 pub const RDNORM = 0x0040;
1082 pub const WRNORM = OUT;
1083 pub const RDBAND = 0x0080;
1084 pub const WRBAND = 0x0100;
1085
1086 /// These events are set if they occur regardless of whether they were requested.
1087 pub const ERR = 0x0008;
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) {
107107
108108pub const EAI_MAX = 15;
109109
110/// get address to use bind()
111pub const AI_PASSIVE = 0x00000001;
112
113/// fill ai_canonname
114pub const AI_CANONNAME = 0x00000002;
115
116/// prevent host name resolution
117pub const AI_NUMERICHOST = 0x00000004;
118
119/// prevent service name resolution
120pub const AI_NUMERICSERV = 0x00000008;
121
122/// valid flags for addrinfo (not a standard def, apps should not use it)
123pub const AI_MASK = (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST | AI_NUMERICSERV | AI_ADDRCONFIG | AI_ALL | AI_V4MAPPED);
124
125/// IPv6 and IPv4-mapped (with AI_V4MAPPED)
126pub const AI_ALL = 0x00000100;
127
128/// accept IPv4-mapped if kernel supports
129pub const AI_V4MAPPED_CFG = 0x00000200;
130
131/// only if any address is assigned
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);
110pub const AI = struct {
111 /// get address to use bind()
112 pub const PASSIVE = 0x00000001;
113 /// fill ai_canonname
114 pub const CANONNAME = 0x00000002;
115 /// prevent host name resolution
116 pub const NUMERICHOST = 0x00000004;
117 /// prevent service name resolution
118 pub const NUMERICSERV = 0x00000008;
119 /// valid flags for addrinfo (not a standard def, apps should not use it)
120 pub const MASK = (PASSIVE | CANONNAME | NUMERICHOST | NUMERICSERV | ADDRCONFIG | ALL | V4MAPPED);
121 /// IPv6 and IPv4-mapped (with V4MAPPED)
122 pub const ALL = 0x00000100;
123 /// accept IPv4-mapped if kernel supports
124 pub const V4MAPPED_CFG = 0x00000200;
125 /// only if any address is assigned
126 pub const ADDRCONFIG = 0x00000400;
127 /// accept IPv4-mapped IPv6 address
128 pub const V4MAPPED = 0x00000800;
129 /// special recommended flags for getipnodebyname
130 pub const DEFAULT = (V4MAPPED_CFG | ADDRCONFIG);
131};
139132
140133pub const blksize_t = i32;
141134pub const blkcnt_t = i64;
......@@ -172,29 +165,23 @@ pub const Kevent = extern struct {
172165// Modes and flags for dlopen()
173166// include/dlfcn.h
174167
175/// Bind function calls lazily.
176pub const RTLD_LAZY = 1;
177
178/// Bind function calls immediately.
179pub const RTLD_NOW = 2;
180
181pub const RTLD_MODEMASK = 0x3;
182
183/// Make symbols globally available.
184pub const RTLD_GLOBAL = 0x100;
185
186/// Opposite of RTLD_GLOBAL, and the default.
187pub const RTLD_LOCAL = 0;
188
189/// Trace loaded objects and exit.
190pub const RTLD_TRACE = 0x200;
191
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
168pub const RTLD = struct {
169 /// Bind function calls lazily.
170 pub const LAZY = 1;
171 /// Bind function calls immediately.
172 pub const NOW = 2;
173 pub const MODEMASK = 0x3;
174 /// Make symbols globally available.
175 pub const GLOBAL = 0x100;
176 /// Opposite of GLOBAL, and the default.
177 pub const LOCAL = 0;
178 /// Trace loaded objects and exit.
179 pub const TRACE = 0x200;
180 /// Do not remove members.
181 pub const NODELETE = 0x01000;
182 /// Do not load if not already loaded.
183 pub const NOLOAD = 0x02000;
184};
198185pub const dl_phdr_info = extern struct {
199186 dlpi_addr: usize,
200187 dlpi_name: ?[*:0]const u8,
......@@ -328,37 +315,35 @@ pub const sa_family_t = u8;
328315pub const sockaddr = extern struct {
329316 /// total length
330317 len: u8,
331
332318 /// address family
333319 family: sa_family_t,
334
335320 /// actually longer; address value
336321 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 {
350 len: u8 = @sizeOf(sockaddr_in6),
351 family: sa_family_t = AF_INET6,
352 port: in_port_t,
353 flowinfo: u32,
354 addr: [16]u8,
355 scope_id: u32,
356};
357
358pub const sockaddr_un = extern struct {
359 len: u8 = @sizeOf(sockaddr_un),
360 family: sa_family_t = AF_UNIX,
361 path: [104]u8,
323 pub const storage = std.x.os.Socket.Address.Native.Storage;
324
325 pub const in = extern struct {
326 len: u8 = @sizeOf(in),
327 family: sa_family_t = AF.INET,
328 port: in_port_t,
329 addr: u32,
330 zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },
331 };
332
333 pub const in6 = extern struct {
334 len: u8 = @sizeOf(in6),
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 };
362347};
363348
364349pub const CTL_KERN = 1;
......@@ -380,36 +365,40 @@ pub const PROT_READ = 1;
380365pub const PROT_WRITE = 2;
381366pub const PROT_EXEC = 4;
382367
383pub const CLOCK_REALTIME = 0;
384pub const CLOCK_VIRTUAL = 1;
385pub const CLOCK_PROF = 2;
386pub const CLOCK_MONOTONIC = 4;
387pub const CLOCK_UPTIME = 5;
388pub const CLOCK_UPTIME_PRECISE = 7;
389pub const CLOCK_UPTIME_FAST = 8;
390pub const CLOCK_REALTIME_PRECISE = 9;
391pub const CLOCK_REALTIME_FAST = 10;
392pub const CLOCK_MONOTONIC_PRECISE = 11;
393pub const CLOCK_MONOTONIC_FAST = 12;
394pub const CLOCK_SECOND = 13;
395pub const CLOCK_THREAD_CPUTIME_ID = 14;
396pub const CLOCK_PROCESS_CPUTIME_ID = 15;
397
398pub const MAP_FAILED = @intToPtr(*c_void, maxInt(usize));
399pub const MAP_SHARED = 0x0001;
400pub const MAP_PRIVATE = 0x0002;
401pub const MAP_FIXED = 0x0010;
402pub const MAP_STACK = 0x0400;
403pub const MAP_NOSYNC = 0x0800;
404pub const MAP_ANON = 0x1000;
405pub const MAP_ANONYMOUS = MAP_ANON;
406pub const MAP_FILE = 0;
407
408pub const MAP_GUARD = 0x00002000;
409pub const MAP_EXCL = 0x00004000;
410pub const MAP_NOCORE = 0x00020000;
411pub const MAP_PREFAULT_READ = 0x00040000;
412pub const MAP_32BIT = 0x00080000;
368pub const CLOCK = struct {
369 pub const REALTIME = 0;
370 pub const VIRTUAL = 1;
371 pub const PROF = 2;
372 pub const MONOTONIC = 4;
373 pub const UPTIME = 5;
374 pub const UPTIME_PRECISE = 7;
375 pub const UPTIME_FAST = 8;
376 pub const REALTIME_PRECISE = 9;
377 pub const REALTIME_FAST = 10;
378 pub const MONOTONIC_PRECISE = 11;
379 pub const MONOTONIC_FAST = 12;
380 pub const SECOND = 13;
381 pub const THREAD_CPUTIME_ID = 14;
382 pub const PROCESS_CPUTIME_ID = 15;
383};
384
385pub const MAP = struct {
386 pub const FAILED = @intToPtr(*c_void, maxInt(usize));
387 pub const SHARED = 0x0001;
388 pub const PRIVATE = 0x0002;
389 pub const FIXED = 0x0010;
390 pub const STACK = 0x0400;
391 pub const NOSYNC = 0x0800;
392 pub const ANON = 0x1000;
393 pub const ANONYMOUS = ANON;
394 pub const FILE = 0;
395
396 pub const GUARD = 0x00002000;
397 pub const EXCL = 0x00004000;
398 pub const NOCORE = 0x00020000;
399 pub const PREFAULT_READ = 0x00040000;
400 pub const @"32BIT" = 0x00080000;
401};
413402
414403pub const WNOHANG = 1;
415404pub const WUNTRACED = 2;
......@@ -517,10 +506,12 @@ pub const F_RDLCK = 1;
517506pub const F_WRLCK = 3;
518507pub const F_UNLCK = 2;
519508
520pub const LOCK_SH = 1;
521pub const LOCK_EX = 2;
522pub const LOCK_UN = 8;
523pub const LOCK_NB = 4;
509pub const LOCK = struct {
510 pub const SH = 1;
511 pub const EX = 2;
512 pub const UN = 8;
513 pub const NB = 4;
514};
524515
525516pub const F_SETOWN_EX = 15;
526517pub const F_GETOWN_EX = 16;
......@@ -537,143 +528,153 @@ pub const SIG_BLOCK = 1;
537528pub const SIG_UNBLOCK = 2;
538529pub const SIG_SETMASK = 3;
539530
540pub const SOCK_STREAM = 1;
541pub const SOCK_DGRAM = 2;
542pub const SOCK_RAW = 3;
543pub const SOCK_RDM = 4;
544pub const SOCK_SEQPACKET = 5;
545
546pub const SOCK_CLOEXEC = 0x10000000;
547pub const SOCK_NONBLOCK = 0x20000000;
548
549pub const SO_DEBUG = 0x00000001;
550pub const SO_ACCEPTCONN = 0x00000002;
551pub const SO_REUSEADDR = 0x00000004;
552pub const SO_KEEPALIVE = 0x00000008;
553pub const SO_DONTROUTE = 0x00000010;
554pub const SO_BROADCAST = 0x00000020;
555pub const SO_USELOOPBACK = 0x00000040;
556pub const SO_LINGER = 0x00000080;
557pub const SO_OOBINLINE = 0x00000100;
558pub const SO_REUSEPORT = 0x00000200;
559pub const SO_TIMESTAMP = 0x00000400;
560pub const SO_NOSIGPIPE = 0x00000800;
561pub const SO_ACCEPTFILTER = 0x00001000;
562pub const SO_BINTIME = 0x00002000;
563pub const SO_NO_OFFLOAD = 0x00004000;
564pub const SO_NO_DDP = 0x00008000;
565pub const SO_REUSEPORT_LB = 0x00010000;
566
567pub const SO_SNDBUF = 0x1001;
568pub const SO_RCVBUF = 0x1002;
569pub const SO_SNDLOWAT = 0x1003;
570pub const SO_RCVLOWAT = 0x1004;
571pub const SO_SNDTIMEO = 0x1005;
572pub const SO_RCVTIMEO = 0x1006;
573pub const SO_ERROR = 0x1007;
574pub const SO_TYPE = 0x1008;
575pub const SO_LABEL = 0x1009;
576pub const SO_PEERLABEL = 0x1010;
577pub const SO_LISTENQLIMIT = 0x1011;
578pub const SO_LISTENQLEN = 0x1012;
579pub const SO_LISTENINCQLEN = 0x1013;
580pub const SO_SETFIB = 0x1014;
581pub const SO_USER_COOKIE = 0x1015;
582pub const SO_PROTOCOL = 0x1016;
583pub const SO_PROTOTYPE = SO_PROTOCOL;
584pub const SO_TS_CLOCK = 0x1017;
585pub const SO_MAX_PACING_RATE = 0x1018;
586pub const SO_DOMAIN = 0x1019;
587
588pub const SOL_SOCKET = 0xffff;
589
590pub const PF_UNSPEC = AF_UNSPEC;
591pub const PF_LOCAL = AF_LOCAL;
592pub const PF_UNIX = PF_LOCAL;
593pub const PF_INET = AF_INET;
594pub const PF_IMPLINK = AF_IMPLINK;
595pub const PF_PUP = AF_PUP;
596pub const PF_CHAOS = AF_CHAOS;
597pub const PF_NETBIOS = AF_NETBIOS;
598pub const PF_ISO = AF_ISO;
599pub const PF_OSI = AF_ISO;
600pub const PF_ECMA = AF_ECMA;
601pub const PF_DATAKIT = AF_DATAKIT;
602pub const PF_CCITT = AF_CCITT;
603pub const PF_DECnet = AF_DECnet;
604pub const PF_DLI = AF_DLI;
605pub const PF_LAT = AF_LAT;
606pub const PF_HYLINK = AF_HYLINK;
607pub const PF_APPLETALK = AF_APPLETALK;
608pub const PF_ROUTE = AF_ROUTE;
609pub const PF_LINK = AF_LINK;
610pub const PF_XTP = pseudo_AF_XTP;
611pub const PF_COIP = AF_COIP;
612pub const PF_CNT = AF_CNT;
613pub const PF_SIP = AF_SIP;
614pub const PF_IPX = AF_IPX;
615pub const PF_RTIP = pseudo_AF_RTIP;
616pub const PF_PIP = psuedo_AF_PIP;
617pub const PF_ISDN = AF_ISDN;
618pub const PF_KEY = pseudo_AF_KEY;
619pub const PF_INET6 = pseudo_AF_INET6;
620pub const PF_NATM = AF_NATM;
621pub const PF_ATM = AF_ATM;
622pub const PF_NETGRAPH = AF_NETGRAPH;
623pub const PF_SLOW = AF_SLOW;
624pub const PF_SCLUSTER = AF_SCLUSTER;
625pub const PF_ARP = AF_ARP;
626pub const PF_BLUETOOTH = AF_BLUETOOTH;
627pub const PF_IEEE80211 = AF_IEEE80211;
628pub const PF_INET_SDP = AF_INET_SDP;
629pub const PF_INET6_SDP = AF_INET6_SDP;
630pub const PF_MAX = AF_MAX;
631
632pub const AF_UNSPEC = 0;
633pub const AF_UNIX = 1;
634pub const AF_LOCAL = AF_UNIX;
635pub const AF_FILE = AF_LOCAL;
636pub const AF_INET = 2;
637pub const AF_IMPLINK = 3;
638pub const AF_PUP = 4;
639pub const AF_CHAOS = 5;
640pub const AF_NETBIOS = 6;
641pub const AF_ISO = 7;
642pub const AF_OSI = AF_ISO;
643pub const AF_ECMA = 8;
644pub const AF_DATAKIT = 9;
645pub const AF_CCITT = 10;
646pub const AF_SNA = 11;
647pub const AF_DECnet = 12;
648pub const AF_DLI = 13;
649pub const AF_LAT = 14;
650pub const AF_HYLINK = 15;
651pub const AF_APPLETALK = 16;
652pub const AF_ROUTE = 17;
653pub const AF_LINK = 18;
654pub const pseudo_AF_XTP = 19;
655pub const AF_COIP = 20;
656pub const AF_CNT = 21;
657pub const pseudo_AF_RTIP = 22;
658pub const AF_IPX = 23;
659pub const AF_SIP = 24;
660pub const pseudo_AF_PIP = 25;
661pub const AF_ISDN = 26;
662pub const AF_E164 = AF_ISDN;
663pub const pseudo_AF_KEY = 27;
664pub const AF_INET6 = 28;
665pub const AF_NATM = 29;
666pub const AF_ATM = 30;
667pub const pseudo_AF_HDRCMPLT = 31;
668pub const AF_NETGRAPH = 32;
669pub const AF_SLOW = 33;
670pub const AF_SCLUSTER = 34;
671pub const AF_ARP = 35;
672pub const AF_BLUETOOTH = 36;
673pub const AF_IEEE80211 = 37;
674pub const AF_INET_SDP = 40;
675pub const AF_INET6_SDP = 42;
676pub const AF_MAX = 42;
531pub const SOCK = struct {
532 pub const STREAM = 1;
533 pub const DGRAM = 2;
534 pub const RAW = 3;
535 pub const RDM = 4;
536 pub const SEQPACKET = 5;
537
538 pub const CLOEXEC = 0x10000000;
539 pub const NONBLOCK = 0x20000000;
540};
541
542pub const SO = struct {
543 pub const DEBUG = 0x00000001;
544 pub const ACCEPTCONN = 0x00000002;
545 pub const REUSEADDR = 0x00000004;
546 pub const KEEPALIVE = 0x00000008;
547 pub const DONTROUTE = 0x00000010;
548 pub const BROADCAST = 0x00000020;
549 pub const USELOOPBACK = 0x00000040;
550 pub const LINGER = 0x00000080;
551 pub const OOBINLINE = 0x00000100;
552 pub const REUSEPORT = 0x00000200;
553 pub const TIMESTAMP = 0x00000400;
554 pub const NOSIGPIPE = 0x00000800;
555 pub const ACCEPTFILTER = 0x00001000;
556 pub const BINTIME = 0x00002000;
557 pub const NO_OFFLOAD = 0x00004000;
558 pub const NO_DDP = 0x00008000;
559 pub const REUSEPORT_LB = 0x00010000;
560
561 pub const SNDBUF = 0x1001;
562 pub const RCVBUF = 0x1002;
563 pub const SNDLOWAT = 0x1003;
564 pub const RCVLOWAT = 0x1004;
565 pub const SNDTIMEO = 0x1005;
566 pub const RCVTIMEO = 0x1006;
567 pub const ERROR = 0x1007;
568 pub const TYPE = 0x1008;
569 pub const LABEL = 0x1009;
570 pub const PEERLABEL = 0x1010;
571 pub const LISTENQLIMIT = 0x1011;
572 pub const LISTENQLEN = 0x1012;
573 pub const LISTENINCQLEN = 0x1013;
574 pub const SETFIB = 0x1014;
575 pub const USER_COOKIE = 0x1015;
576 pub const PROTOCOL = 0x1016;
577 pub const PROTOTYPE = PROTOCOL;
578 pub const TS_CLOCK = 0x1017;
579 pub const MAX_PACING_RATE = 0x1018;
580 pub const DOMAIN = 0x1019;
581};
582
583pub const SOL = struct {
584 pub const SOCKET = 0xffff;
585};
586
587pub const PF = struct {
588 pub const UNSPEC = AF.UNSPEC;
589 pub const LOCAL = AF.LOCAL;
590 pub const UNIX = PF.LOCAL;
591 pub const INET = AF.INET;
592 pub const IMPLINK = AF.IMPLINK;
593 pub const PUP = AF.PUP;
594 pub const CHAOS = AF.CHAOS;
595 pub const NETBIOS = AF.NETBIOS;
596 pub const ISO = AF.ISO;
597 pub const OSI = AF.ISO;
598 pub const ECMA = AF.ECMA;
599 pub const DATAKIT = AF.DATAKIT;
600 pub const CCITT = AF.CCITT;
601 pub const DECnet = AF.DECnet;
602 pub const DLI = AF.DLI;
603 pub const LAT = AF.LAT;
604 pub const HYLINK = AF.HYLINK;
605 pub const APPLETALK = AF.APPLETALK;
606 pub const ROUTE = AF.ROUTE;
607 pub const LINK = AF.LINK;
608 pub const XTP = AF.pseudo_XTP;
609 pub const COIP = AF.COIP;
610 pub const CNT = AF.CNT;
611 pub const SIP = AF.SIP;
612 pub const IPX = AF.IPX;
613 pub const RTIP = AF.pseudo_RTIP;
614 pub const PIP = AF.pseudo_PIP;
615 pub const ISDN = AF.ISDN;
616 pub const KEY = AF.pseudo_KEY;
617 pub const INET6 = AF.pseudo_INET6;
618 pub const NATM = AF.NATM;
619 pub const ATM = AF.ATM;
620 pub const NETGRAPH = AF.NETGRAPH;
621 pub const SLOW = AF.SLOW;
622 pub const SCLUSTER = AF.SCLUSTER;
623 pub const ARP = AF.ARP;
624 pub const BLUETOOTH = AF.BLUETOOTH;
625 pub const IEEE80211 = AF.IEEE80211;
626 pub const INET_SDP = AF.INET_SDP;
627 pub const INET6_SDP = AF.INET6_SDP;
628 pub const MAX = AF.MAX;
629};
630
631pub const AF = struct {
632 pub const UNSPEC = 0;
633 pub const UNIX = 1;
634 pub const LOCAL = UNIX;
635 pub const FILE = LOCAL;
636 pub const INET = 2;
637 pub const IMPLINK = 3;
638 pub const PUP = 4;
639 pub const CHAOS = 5;
640 pub const NETBIOS = 6;
641 pub const ISO = 7;
642 pub const OSI = ISO;
643 pub const ECMA = 8;
644 pub const DATAKIT = 9;
645 pub const CCITT = 10;
646 pub const SNA = 11;
647 pub const DECnet = 12;
648 pub const DLI = 13;
649 pub const LAT = 14;
650 pub const HYLINK = 15;
651 pub const APPLETALK = 16;
652 pub const ROUTE = 17;
653 pub const LINK = 18;
654 pub const pseudo_XTP = 19;
655 pub const COIP = 20;
656 pub const CNT = 21;
657 pub const pseudo_RTIP = 22;
658 pub const IPX = 23;
659 pub const SIP = 24;
660 pub const pseudo_PIP = 25;
661 pub const ISDN = 26;
662 pub const E164 = ISDN;
663 pub const pseudo_KEY = 27;
664 pub const INET6 = 28;
665 pub const NATM = 29;
666 pub const ATM = 30;
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
678679pub const DT_UNKNOWN = 0;
679680pub const DT_FIFO = 1;
......@@ -1252,353 +1253,240 @@ pub const addrinfo = extern struct {
12521253/// Fail if not under dirfd
12531254pub const AT_BENEATH = 0x1000;
12541255
1255/// dummy for IP
1256pub const IPPROTO_IP = 0;
1257
1258/// control message protocol
1259pub const IPPROTO_ICMP = 1;
1260
1261/// tcp
1262pub const IPPROTO_TCP = 6;
1263
1264/// user datagram protocol
1265pub const IPPROTO_UDP = 17;
1266
1267/// IP6 header
1268pub const IPPROTO_IPV6 = 41;
1269
1270/// raw IP packet
1271pub const IPPROTO_RAW = 255;
1272
1273/// IP6 hop-by-hop options
1274pub const IPPROTO_HOPOPTS = 0;
1275
1276/// group mgmt protocol
1277pub const IPPROTO_IGMP = 2;
1278
1279/// gateway^2 (deprecated)
1280pub const IPPROTO_GGP = 3;
1281
1282/// IPv4 encapsulation
1283pub const IPPROTO_IPV4 = 4;
1284
1285/// for compatibility
1286pub const IPPROTO_IPIP = IPPROTO_IPV4;
1287
1288/// Stream protocol II
1289pub const IPPROTO_ST = 7;
1290
1291/// exterior gateway protocol
1292pub const IPPROTO_EGP = 8;
1293
1294/// private interior gateway
1295pub const IPPROTO_PIGP = 9;
1296
1297/// BBN RCC Monitoring
1298pub const IPPROTO_RCCMON = 10;
1299
1300/// network voice protocol
1301pub const IPPROTO_NVPII = 11;
1302
1303/// pup
1304pub const IPPROTO_PUP = 12;
1305
1306/// Argus
1307pub const IPPROTO_ARGUS = 13;
1308
1309/// EMCON
1310pub const IPPROTO_EMCON = 14;
1311
1312/// Cross Net Debugger
1313pub const IPPROTO_XNET = 15;
1314
1315/// Chaos
1316pub const IPPROTO_CHAOS = 16;
1317
1318/// Multiplexing
1319pub const IPPROTO_MUX = 18;
1320
1321/// DCN Measurement Subsystems
1322pub const IPPROTO_MEAS = 19;
1323
1324/// Host Monitoring
1325pub const IPPROTO_HMP = 20;
1326
1327/// Packet Radio Measurement
1328pub const IPPROTO_PRM = 21;
1329
1330/// xns idp
1331pub const IPPROTO_IDP = 22;
1332
1333/// Trunk-1
1334pub const IPPROTO_TRUNK1 = 23;
1335
1336/// Trunk-2
1337pub const IPPROTO_TRUNK2 = 24;
1338
1339/// Leaf-1
1340pub const IPPROTO_LEAF1 = 25;
1341
1342/// Leaf-2
1343pub const IPPROTO_LEAF2 = 26;
1344
1345/// Reliable Data
1346pub const IPPROTO_RDP = 27;
1347
1348/// Reliable Transaction
1349pub const IPPROTO_IRTP = 28;
1350
1351/// tp-4 w/ class negotiation
1352pub const IPPROTO_TP = 29;
1353
1354/// Bulk Data Transfer
1355pub const IPPROTO_BLT = 30;
1356
1357/// Network Services
1358pub const IPPROTO_NSP = 31;
1359
1360/// Merit Internodal
1361pub const IPPROTO_INP = 32;
1362
1363/// Datagram Congestion Control Protocol
1364pub const IPPROTO_DCCP = 33;
1365
1366/// Third Party Connect
1367pub const IPPROTO_3PC = 34;
1368
1369/// InterDomain Policy Routing
1370pub const IPPROTO_IDPR = 35;
1371
1372/// XTP
1373pub const IPPROTO_XTP = 36;
1374
1375/// Datagram Delivery
1376pub const IPPROTO_DDP = 37;
1377
1378/// Control Message Transport
1379pub const IPPROTO_CMTP = 38;
1380
1381/// TP++ Transport
1382pub const IPPROTO_TPXX = 39;
1383
1384/// IL transport protocol
1385pub const IPPROTO_IL = 40;
1386
1387/// Source Demand Routing
1388pub const IPPROTO_SDRP = 42;
1389
1390/// IP6 routing header
1391pub const IPPROTO_ROUTING = 43;
1392
1393/// IP6 fragmentation header
1394pub const IPPROTO_FRAGMENT = 44;
1395
1396/// InterDomain Routing
1397pub const IPPROTO_IDRP = 45;
1398
1399/// resource reservation
1400pub const IPPROTO_RSVP = 46;
1401
1402/// General Routing Encap.
1403pub const IPPROTO_GRE = 47;
1404
1405/// Mobile Host Routing
1406pub const IPPROTO_MHRP = 48;
1407
1408/// BHA
1409pub const IPPROTO_BHA = 49;
1410
1411/// IP6 Encap Sec. Payload
1412pub const IPPROTO_ESP = 50;
1413
1414/// IP6 Auth Header
1415pub const IPPROTO_AH = 51;
1416
1417/// Integ. Net Layer Security
1418pub const IPPROTO_INLSP = 52;
1419
1420/// IP with encryption
1421pub const IPPROTO_SWIPE = 53;
1422
1423/// Next Hop Resolution
1424pub const IPPROTO_NHRP = 54;
1425
1426/// IP Mobility
1427pub const IPPROTO_MOBILE = 55;
1428
1429/// Transport Layer Security
1430pub const IPPROTO_TLSP = 56;
1431
1432/// SKIP
1433pub const IPPROTO_SKIP = 57;
1434
1435/// ICMP6
1436pub const IPPROTO_ICMPV6 = 58;
1437
1438/// IP6 no next header
1439pub const IPPROTO_NONE = 59;
1440
1441/// IP6 destination option
1442pub const IPPROTO_DSTOPTS = 60;
1443
1444/// any host internal protocol
1445pub const IPPROTO_AHIP = 61;
1446
1447/// CFTP
1448pub const IPPROTO_CFTP = 62;
1449
1450/// "hello" routing protocol
1451pub const IPPROTO_HELLO = 63;
1452
1453/// SATNET/Backroom EXPAK
1454pub const IPPROTO_SATEXPAK = 64;
1455
1456/// Kryptolan
1457pub const IPPROTO_KRYPTOLAN = 65;
1458
1459/// Remote Virtual Disk
1460pub const IPPROTO_RVD = 66;
1461
1462/// Pluribus Packet Core
1463pub const IPPROTO_IPPC = 67;
1464
1465/// Any distributed FS
1466pub const IPPROTO_ADFS = 68;
1467
1468/// Satnet Monitoring
1469pub const IPPROTO_SATMON = 69;
1470
1471/// VISA Protocol
1472pub const IPPROTO_VISA = 70;
1473
1474/// Packet Core Utility
1475pub const IPPROTO_IPCV = 71;
1476
1477/// Comp. Prot. Net. Executive
1478pub const IPPROTO_CPNX = 72;
1479
1480/// Comp. Prot. HeartBeat
1481pub const IPPROTO_CPHB = 73;
1482
1483/// Wang Span Network
1484pub const IPPROTO_WSN = 74;
1485
1486/// Packet Video Protocol
1487pub const IPPROTO_PVP = 75;
1488
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;
1256pub const IPPROTO = struct {
1257 /// dummy for IP
1258 pub const IP = 0;
1259 /// control message protocol
1260 pub const ICMP = 1;
1261 /// tcp
1262 pub const TCP = 6;
1263 /// user datagram protocol
1264 pub const UDP = 17;
1265 /// IP6 header
1266 pub const IPV6 = 41;
1267 /// raw IP packet
1268 pub const RAW = 255;
1269 /// IP6 hop-by-hop options
1270 pub const HOPOPTS = 0;
1271 /// group mgmt protocol
1272 pub const IGMP = 2;
1273 /// gateway^2 (deprecated)
1274 pub const GGP = 3;
1275 /// IPv4 encapsulation
1276 pub const IPV4 = 4;
1277 /// for compatibility
1278 pub const IPIP = IPV4;
1279 /// Stream protocol II
1280 pub const ST = 7;
1281 /// exterior gateway protocol
1282 pub const EGP = 8;
1283 /// private interior gateway
1284 pub const PIGP = 9;
1285 /// BBN RCC Monitoring
1286 pub const RCCMON = 10;
1287 /// network voice protocol
1288 pub const NVPII = 11;
1289 /// pup
1290 pub const PUP = 12;
1291 /// Argus
1292 pub const ARGUS = 13;
1293 /// EMCON
1294 pub const EMCON = 14;
1295 /// Cross Net Debugger
1296 pub const XNET = 15;
1297 /// Chaos
1298 pub const CHAOS = 16;
1299 /// Multiplexing
1300 pub const MUX = 18;
1301 /// DCN Measurement Subsystems
1302 pub const MEAS = 19;
1303 /// Host Monitoring
1304 pub const HMP = 20;
1305 /// Packet Radio Measurement
1306 pub const PRM = 21;
1307 /// xns idp
1308 pub const IDP = 22;
1309 /// Trunk-1
1310 pub const TRUNK1 = 23;
1311 /// Trunk-2
1312 pub const TRUNK2 = 24;
1313 /// Leaf-1
1314 pub const LEAF1 = 25;
1315 /// Leaf-2
1316 pub const LEAF2 = 26;
1317 /// Reliable Data
1318 pub const RDP = 27;
1319 /// Reliable Transaction
1320 pub const IRTP = 28;
1321 /// tp-4 w/ class negotiation
1322 pub const TP = 29;
1323 /// Bulk Data Transfer
1324 pub const BLT = 30;
1325 /// Network Services
1326 pub const NSP = 31;
1327 /// Merit Internodal
1328 pub const INP = 32;
1329 /// Datagram Congestion Control Protocol
1330 pub const DCCP = 33;
1331 /// Third Party Connect
1332 pub const @"3PC" = 34;
1333 /// InterDomain Policy Routing
1334 pub const IDPR = 35;
1335 /// XTP
1336 pub const XTP = 36;
1337 /// Datagram Delivery
1338 pub const DDP = 37;
1339 /// Control Message Transport
1340 pub const CMTP = 38;
1341 /// TP++ Transport
1342 pub const TPXX = 39;
1343 /// IL transport protocol
1344 pub const IL = 40;
1345 /// Source Demand Routing
1346 pub const SDRP = 42;
1347 /// IP6 routing header
1348 pub const ROUTING = 43;
1349 /// IP6 fragmentation header
1350 pub const FRAGMENT = 44;
1351 /// InterDomain Routing
1352 pub const IDRP = 45;
1353 /// resource reservation
1354 pub const RSVP = 46;
1355 /// General Routing Encap.
1356 pub const GRE = 47;
1357 /// Mobile Host Routing
1358 pub const MHRP = 48;
1359 /// BHA
1360 pub const BHA = 49;
1361 /// IP6 Encap Sec. Payload
1362 pub const ESP = 50;
1363 /// IP6 Auth Header
1364 pub const AH = 51;
1365 /// Integ. Net Layer Security
1366 pub const INLSP = 52;
1367 /// IP with encryption
1368 pub const SWIPE = 53;
1369 /// Next Hop Resolution
1370 pub const NHRP = 54;
1371 /// IP Mobility
1372 pub const MOBILE = 55;
1373 /// Transport Layer Security
1374 pub const TLSP = 56;
1375 /// SKIP
1376 pub const SKIP = 57;
1377 /// ICMP6
1378 pub const ICMPV6 = 58;
1379 /// IP6 no next header
1380 pub const NONE = 59;
1381 /// IP6 destination option
1382 pub const DSTOPTS = 60;
1383 /// any host internal protocol
1384 pub const AHIP = 61;
1385 /// CFTP
1386 pub const CFTP = 62;
1387 /// "hello" routing protocol
1388 pub const HELLO = 63;
1389 /// SATNET/Backroom EXPAK
1390 pub const SATEXPAK = 64;
1391 /// Kryptolan
1392 pub const KRYPTOLAN = 65;
1393 /// Remote Virtual Disk
1394 pub const RVD = 66;
1395 /// Pluribus Packet Core
1396 pub const IPPC = 67;
1397 /// Any distributed FS
1398 pub const ADFS = 68;
1399 /// Satnet Monitoring
1400 pub const SATMON = 69;
1401 /// VISA Protocol
1402 pub const VISA = 70;
1403 /// Packet Core Utility
1404 pub const IPCV = 71;
1405 /// Comp. Prot. Net. Executive
1406 pub const CPNX = 72;
1407 /// Comp. Prot. HeartBeat
1408 pub const CPHB = 73;
1409 /// Wang Span Network
1410 pub const WSN = 74;
1411 /// Packet Video Protocol
1412 pub const PVP = 75;
1413 /// BackRoom SATNET Monitoring
1414 pub const BRSATMON = 76;
1415 /// Sun net disk proto (temp.)
1416 pub const ND = 77;
1417 /// WIDEBAND Monitoring
1418 pub const WBMON = 78;
1419 /// WIDEBAND EXPAK
1420 pub const WBEXPAK = 79;
1421 /// ISO cnlp
1422 pub const EON = 80;
1423 /// VMTP
1424 pub const VMTP = 81;
1425 /// Secure VMTP
1426 pub const SVMTP = 82;
1427 /// Banyon VINES
1428 pub const VINES = 83;
1429 /// TTP
1430 pub const TTP = 84;
1431 /// NSFNET-IGP
1432 pub const IGP = 85;
1433 /// dissimilar gateway prot.
1434 pub const DGP = 86;
1435 /// TCF
1436 pub const TCF = 87;
1437 /// Cisco/GXS IGRP
1438 pub const IGRP = 88;
1439 /// OSPFIGP
1440 pub const OSPFIGP = 89;
1441 /// Strite RPC protocol
1442 pub const SRPC = 90;
1443 /// Locus Address Resoloution
1444 pub const LARP = 91;
1445 /// Multicast Transport
1446 pub const MTP = 92;
1447 /// AX.25 Frames
1448 pub const AX25 = 93;
1449 /// IP encapsulated in IP
1450 pub const IPEIP = 94;
1451 /// Mobile Int.ing control
1452 pub const MICP = 95;
1453 /// Semaphore Comm. security
1454 pub const SCCSP = 96;
1455 /// Ethernet IP encapsulation
1456 pub const ETHERIP = 97;
1457 /// encapsulation header
1458 pub const ENCAP = 98;
1459 /// any private encr. scheme
1460 pub const APES = 99;
1461 /// GMTP
1462 pub const GMTP = 100;
1463 /// payload compression (IPComp)
1464 pub const IPCOMP = 108;
1465 /// SCTP
1466 pub const SCTP = 132;
1467 /// IPv6 Mobility Header
1468 pub const MH = 135;
1469 /// UDP-Lite
1470 pub const UDPLITE = 136;
1471 /// IP6 Host Identity Protocol
1472 pub const HIP = 139;
1473 /// IP6 Shim6 Protocol
1474 pub const SHIM6 = 140;
1475 /// Protocol Independent Mcast
1476 pub const PIM = 103;
1477 /// CARP
1478 pub const CARP = 112;
1479 /// PGM
1480 pub const PGM = 113;
1481 /// MPLS-in-IP
1482 pub const MPLS = 137;
1483 /// PFSYNC
1484 pub const PFSYNC = 240;
1485 /// Reserved
1486 pub const RESERVED_253 = 253;
1487 /// Reserved
1488 pub const RESERVED_254 = 254;
1489};
16021490
16031491pub const rlimit_resource = enum(c_int) {
16041492 CPU = 0,
......@@ -1623,11 +1511,13 @@ pub const rlimit_resource = enum(c_int) {
16231511
16241512pub const rlim_t = i64;
16251513
1626/// No limit
1627pub const RLIM_INFINITY: rlim_t = (1 << 63) - 1;
1514pub const RLIM = struct {
1515 /// No limit
1516 pub const INFINITY: rlim_t = (1 << 63) - 1;
16281517
1629pub const RLIM_SAVED_MAX = RLIM_INFINITY;
1630pub const RLIM_SAVED_CUR = RLIM_INFINITY;
1518 pub const SAVED_MAX = INFINITY;
1519 pub const SAVED_CUR = INFINITY;
1520};
16311521
16321522pub const rlimit = extern struct {
16331523 /// Soft limit
......@@ -1648,28 +1538,29 @@ pub const pollfd = extern struct {
16481538 revents: i16,
16491539};
16501540
1651/// any readable data available.
1652pub const POLLIN = 0x0001;
1653/// OOB/Urgent readable data.
1654pub const POLLPRI = 0x0002;
1655/// file descriptor is writeable.
1656pub const POLLOUT = 0x0004;
1657/// non-OOB/URG data available.
1658pub const POLLRDNORM = 0x0040;
1659/// no write type differentiation.
1660pub const POLLWRNORM = POLLOUT;
1661/// OOB/Urgent readable data.
1662pub const POLLRDBAND = 0x0080;
1663/// OOB/Urgent data can be written.
1664pub const POLLWRBAND = 0x0100;
1665/// like POLLIN, except ignore EOF.
1666pub const POLLINIGNEOF = 0x2000;
1667/// some poll error occurred.
1668pub const POLLERR = 0x0008;
1669/// file descriptor was "hung up".
1670pub const POLLHUP = 0x0010;
1671/// requested events "invalid".
1672pub const POLLNVAL = 0x0020;
1673
1674pub const POLLSTANDARD = POLLIN | POLLPRI | POLLOUT | POLLRDNORM | POLLRDBAND |
1675 POLLWRBAND | POLLERR | POLLHUP | POLLNVAL;
1541pub const POLL = struct {
1542 /// any readable data available.
1543 pub const IN = 0x0001;
1544 /// OOB/Urgent readable data.
1545 pub const PRI = 0x0002;
1546 /// file descriptor is writeable.
1547 pub const OUT = 0x0004;
1548 /// non-OOB/URG data available.
1549 pub const RDNORM = 0x0040;
1550 /// no write type differentiation.
1551 pub const WRNORM = OUT;
1552 /// OOB/Urgent readable data.
1553 pub const RDBAND = 0x0080;
1554 /// OOB/Urgent data can be written.
1555 pub const WRBAND = 0x0100;
1556 /// like IN, except ignore EOF.
1557 pub const INIGNEOF = 0x2000;
1558 /// some poll error occurred.
1559 pub const ERR = 0x0008;
1560 /// file descriptor was "hung up".
1561 pub const HUP = 0x0010;
1562 /// requested events "invalid".
1563 pub const NVAL = 0x0020;
1564
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 {
133133// Modes and flags for dlopen()
134134// include/dlfcn.h
135135
136pub const POLLIN = 0x0001;
137pub const POLLERR = 0x0004;
138pub const POLLNVAL = 0x1000;
139pub const POLLHUP = 0x0080;
140
141/// Bind function calls lazily.
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;
136pub const POLL = struct {
137 pub const IN = 0x0001;
138 pub const ERR = 0x0004;
139 pub const NVAL = 0x1000;
140 pub const HUP = 0x0080;
141};
160142
161/// Do not load if not already loaded.
162pub const RTLD_NOLOAD = 0x02000;
143pub const RTLD = struct {
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
164161pub const dl_phdr_info = extern struct {
165162 dlpi_addr: usize,
......@@ -336,37 +333,35 @@ pub const sa_family_t = u8;
336333pub const sockaddr = extern struct {
337334 /// total length
338335 len: u8,
339
340336 /// address family
341337 family: sa_family_t,
342
343338 /// actually longer; address value
344339 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 {
358 len: u8 = @sizeOf(sockaddr_in6),
359 family: sa_family_t = AF_INET6,
360 port: in_port_t,
361 flowinfo: u32,
362 addr: [16]u8,
363 scope_id: u32,
364};
365
366pub const sockaddr_un = extern struct {
367 len: u8 = @sizeOf(sockaddr_un),
368 family: sa_family_t = AF_UNIX,
369 path: [104]u8,
341 pub const storage = std.x.os.Socket.Address.Native.Storage;
342
343 pub const in = extern struct {
344 len: u8 = @sizeOf(in),
345 family: sa_family_t = AF.INET,
346 port: in_port_t,
347 addr: u32,
348 zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },
349 };
350
351 pub const in6 = extern struct {
352 len: u8 = @sizeOf(in6),
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 };
370365};
371366
372367pub const CTL_KERN = 1;
......@@ -386,27 +381,30 @@ pub const PROT_READ = 1;
386381pub const PROT_WRITE = 2;
387382pub const PROT_EXEC = 4;
388383
389pub const CLOCK_MONOTONIC = 0;
390pub const CLOCK_REALTIME = -1;
391pub const CLOCK_PROCESS_CPUTIME_ID = -2;
392pub const CLOCK_THREAD_CPUTIME_ID = -3;
393
394pub const MAP_FAILED = @intToPtr(*c_void, maxInt(usize));
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;
384pub const CLOCK = struct {
385 pub const MONOTONIC = 0;
386 pub const REALTIME = -1;
387 pub const PROCESS_CPUTIME_ID = -2;
388 pub const THREAD_CPUTIME_ID = -3;
389};
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};
410408pub const WNOHANG = 0x1;
411409pub const WUNTRACED = 0x2;
412410pub const WSTOPPED = 0x10;
......@@ -514,10 +512,12 @@ pub const F_RDLCK = 1;
514512pub const F_WRLCK = 3;
515513pub const F_UNLCK = 2;
516514
517pub const LOCK_SH = 1;
518pub const LOCK_EX = 2;
519pub const LOCK_UN = 8;
520pub const LOCK_NB = 4;
515pub const LOCK = struct {
516 pub const SH = 1;
517 pub const EX = 2;
518 pub const UN = 8;
519 pub const NB = 4;
520};
521521
522522pub const F_SETOWN_EX = 15;
523523pub const F_GETOWN_EX = 16;
......@@ -534,143 +534,153 @@ pub const SIG_BLOCK = 1;
534534pub const SIG_UNBLOCK = 2;
535535pub const SIG_SETMASK = 3;
536536
537pub const SOCK_STREAM = 1;
538pub const SOCK_DGRAM = 2;
539pub const SOCK_RAW = 3;
540pub const SOCK_RDM = 4;
541pub const SOCK_SEQPACKET = 5;
542
543pub const SOCK_CLOEXEC = 0x10000000;
544pub const SOCK_NONBLOCK = 0x20000000;
545
546pub const SO_DEBUG = 0x00000001;
547pub const SO_ACCEPTCONN = 0x00000002;
548pub const SO_REUSEADDR = 0x00000004;
549pub const SO_KEEPALIVE = 0x00000008;
550pub const SO_DONTROUTE = 0x00000010;
551pub const SO_BROADCAST = 0x00000020;
552pub const SO_USELOOPBACK = 0x00000040;
553pub const SO_LINGER = 0x00000080;
554pub const SO_OOBINLINE = 0x00000100;
555pub const SO_REUSEPORT = 0x00000200;
556pub const SO_TIMESTAMP = 0x00000400;
557pub const SO_NOSIGPIPE = 0x00000800;
558pub const SO_ACCEPTFILTER = 0x00001000;
559pub const SO_BINTIME = 0x00002000;
560pub const SO_NO_OFFLOAD = 0x00004000;
561pub const SO_NO_DDP = 0x00008000;
562pub const SO_REUSEPORT_LB = 0x00010000;
563
564pub const SO_SNDBUF = 0x1001;
565pub const SO_RCVBUF = 0x1002;
566pub const SO_SNDLOWAT = 0x1003;
567pub const SO_RCVLOWAT = 0x1004;
568pub const SO_SNDTIMEO = 0x1005;
569pub const SO_RCVTIMEO = 0x1006;
570pub const SO_ERROR = 0x1007;
571pub const SO_TYPE = 0x1008;
572pub const SO_LABEL = 0x1009;
573pub const SO_PEERLABEL = 0x1010;
574pub const SO_LISTENQLIMIT = 0x1011;
575pub const SO_LISTENQLEN = 0x1012;
576pub const SO_LISTENINCQLEN = 0x1013;
577pub const SO_SETFIB = 0x1014;
578pub const SO_USER_COOKIE = 0x1015;
579pub const SO_PROTOCOL = 0x1016;
580pub const SO_PROTOTYPE = SO_PROTOCOL;
581pub const SO_TS_CLOCK = 0x1017;
582pub const SO_MAX_PACING_RATE = 0x1018;
583pub const SO_DOMAIN = 0x1019;
584
585pub const SOL_SOCKET = 0xffff;
586
587pub const PF_UNSPEC = AF_UNSPEC;
588pub const PF_LOCAL = AF_LOCAL;
589pub const PF_UNIX = PF_LOCAL;
590pub const PF_INET = AF_INET;
591pub const PF_IMPLINK = AF_IMPLINK;
592pub const PF_PUP = AF_PUP;
593pub const PF_CHAOS = AF_CHAOS;
594pub const PF_NETBIOS = AF_NETBIOS;
595pub const PF_ISO = AF_ISO;
596pub const PF_OSI = AF_ISO;
597pub const PF_ECMA = AF_ECMA;
598pub const PF_DATAKIT = AF_DATAKIT;
599pub const PF_CCITT = AF_CCITT;
600pub const PF_DECnet = AF_DECnet;
601pub const PF_DLI = AF_DLI;
602pub const PF_LAT = AF_LAT;
603pub const PF_HYLINK = AF_HYLINK;
604pub const PF_APPLETALK = AF_APPLETALK;
605pub const PF_ROUTE = AF_ROUTE;
606pub const PF_LINK = AF_LINK;
607pub const PF_XTP = pseudo_AF_XTP;
608pub const PF_COIP = AF_COIP;
609pub const PF_CNT = AF_CNT;
610pub const PF_SIP = AF_SIP;
611pub const PF_IPX = AF_IPX;
612pub const PF_RTIP = pseudo_AF_RTIP;
613pub const PF_PIP = psuedo_AF_PIP;
614pub const PF_ISDN = AF_ISDN;
615pub const PF_KEY = pseudo_AF_KEY;
616pub const PF_INET6 = pseudo_AF_INET6;
617pub const PF_NATM = AF_NATM;
618pub const PF_ATM = AF_ATM;
619pub const PF_NETGRAPH = AF_NETGRAPH;
620pub const PF_SLOW = AF_SLOW;
621pub const PF_SCLUSTER = AF_SCLUSTER;
622pub const PF_ARP = AF_ARP;
623pub const PF_BLUETOOTH = AF_BLUETOOTH;
624pub const PF_IEEE80211 = AF_IEEE80211;
625pub const PF_INET_SDP = AF_INET_SDP;
626pub const PF_INET6_SDP = AF_INET6_SDP;
627pub const PF_MAX = AF_MAX;
628
629pub const AF_UNSPEC = 0;
630pub const AF_UNIX = 1;
631pub const AF_LOCAL = AF_UNIX;
632pub const AF_FILE = AF_LOCAL;
633pub const AF_INET = 2;
634pub const AF_IMPLINK = 3;
635pub const AF_PUP = 4;
636pub const AF_CHAOS = 5;
637pub const AF_NETBIOS = 6;
638pub const AF_ISO = 7;
639pub const AF_OSI = AF_ISO;
640pub const AF_ECMA = 8;
641pub const AF_DATAKIT = 9;
642pub const AF_CCITT = 10;
643pub const AF_SNA = 11;
644pub const AF_DECnet = 12;
645pub const AF_DLI = 13;
646pub const AF_LAT = 14;
647pub const AF_HYLINK = 15;
648pub const AF_APPLETALK = 16;
649pub const AF_ROUTE = 17;
650pub const AF_LINK = 18;
651pub const pseudo_AF_XTP = 19;
652pub const AF_COIP = 20;
653pub const AF_CNT = 21;
654pub const pseudo_AF_RTIP = 22;
655pub const AF_IPX = 23;
656pub const AF_SIP = 24;
657pub const pseudo_AF_PIP = 25;
658pub const AF_ISDN = 26;
659pub const AF_E164 = AF_ISDN;
660pub const pseudo_AF_KEY = 27;
661pub const AF_INET6 = 28;
662pub const AF_NATM = 29;
663pub const AF_ATM = 30;
664pub const pseudo_AF_HDRCMPLT = 31;
665pub const AF_NETGRAPH = 32;
666pub const AF_SLOW = 33;
667pub const AF_SCLUSTER = 34;
668pub const AF_ARP = 35;
669pub const AF_BLUETOOTH = 36;
670pub const AF_IEEE80211 = 37;
671pub const AF_INET_SDP = 40;
672pub const AF_INET6_SDP = 42;
673pub const AF_MAX = 42;
537pub const SOCK = struct {
538 pub const STREAM = 1;
539 pub const DGRAM = 2;
540 pub const RAW = 3;
541 pub const RDM = 4;
542 pub const SEQPACKET = 5;
543
544 pub const CLOEXEC = 0x10000000;
545 pub const NONBLOCK = 0x20000000;
546};
547
548pub const SO = struct {
549 pub const DEBUG = 0x00000001;
550 pub const ACCEPTCONN = 0x00000002;
551 pub const REUSEADDR = 0x00000004;
552 pub const KEEPALIVE = 0x00000008;
553 pub const DONTROUTE = 0x00000010;
554 pub const BROADCAST = 0x00000020;
555 pub const USELOOPBACK = 0x00000040;
556 pub const LINGER = 0x00000080;
557 pub const OOBINLINE = 0x00000100;
558 pub const REUSEPORT = 0x00000200;
559 pub const TIMESTAMP = 0x00000400;
560 pub const NOSIGPIPE = 0x00000800;
561 pub const ACCEPTFILTER = 0x00001000;
562 pub const BINTIME = 0x00002000;
563 pub const NO_OFFLOAD = 0x00004000;
564 pub const NO_DDP = 0x00008000;
565 pub const REUSEPORT_LB = 0x00010000;
566
567 pub const SNDBUF = 0x1001;
568 pub const RCVBUF = 0x1002;
569 pub const SNDLOWAT = 0x1003;
570 pub const RCVLOWAT = 0x1004;
571 pub const SNDTIMEO = 0x1005;
572 pub const RCVTIMEO = 0x1006;
573 pub const ERROR = 0x1007;
574 pub const TYPE = 0x1008;
575 pub const LABEL = 0x1009;
576 pub const PEERLABEL = 0x1010;
577 pub const LISTENQLIMIT = 0x1011;
578 pub const LISTENQLEN = 0x1012;
579 pub const LISTENINCQLEN = 0x1013;
580 pub const SETFIB = 0x1014;
581 pub const USER_COOKIE = 0x1015;
582 pub const PROTOCOL = 0x1016;
583 pub const PROTOTYPE = PROTOCOL;
584 pub const TS_CLOCK = 0x1017;
585 pub const MAX_PACING_RATE = 0x1018;
586 pub const DOMAIN = 0x1019;
587};
588
589pub const SOL = struct {
590 pub const SOCKET = 0xffff;
591};
592
593pub const PF = struct {
594 pub const UNSPEC = AF.UNSPEC;
595 pub const LOCAL = AF.LOCAL;
596 pub const UNIX = PF.LOCAL;
597 pub const INET = AF.INET;
598 pub const IMPLINK = AF.IMPLINK;
599 pub const PUP = AF.PUP;
600 pub const CHAOS = AF.CHAOS;
601 pub const NETBIOS = AF.NETBIOS;
602 pub const ISO = AF.ISO;
603 pub const OSI = AF.ISO;
604 pub const ECMA = AF.ECMA;
605 pub const DATAKIT = AF.DATAKIT;
606 pub const CCITT = AF.CCITT;
607 pub const DECnet = AF.DECnet;
608 pub const DLI = AF.DLI;
609 pub const LAT = AF.LAT;
610 pub const HYLINK = AF.HYLINK;
611 pub const APPLETALK = AF.APPLETALK;
612 pub const ROUTE = AF.ROUTE;
613 pub const LINK = AF.LINK;
614 pub const XTP = AF.pseudo_XTP;
615 pub const COIP = AF.COIP;
616 pub const CNT = AF.CNT;
617 pub const SIP = AF.SIP;
618 pub const IPX = AF.IPX;
619 pub const RTIP = AF.pseudo_RTIP;
620 pub const PIP = psuedo_AF.PIP;
621 pub const ISDN = AF.ISDN;
622 pub const KEY = AF.pseudo_KEY;
623 pub const INET6 = AF.pseudo_INET6;
624 pub const NATM = AF.NATM;
625 pub const ATM = AF.ATM;
626 pub const NETGRAPH = AF.NETGRAPH;
627 pub const SLOW = AF.SLOW;
628 pub const SCLUSTER = AF.SCLUSTER;
629 pub const ARP = AF.ARP;
630 pub const BLUETOOTH = AF.BLUETOOTH;
631 pub const IEEE80211 = AF.IEEE80211;
632 pub const INET_SDP = AF.INET_SDP;
633 pub const INET6_SDP = AF.INET6_SDP;
634 pub const MAX = AF.MAX;
635};
636
637pub const AF = struct {
638 pub const UNSPEC = 0;
639 pub const UNIX = 1;
640 pub const LOCAL = UNIX;
641 pub const FILE = LOCAL;
642 pub const INET = 2;
643 pub const IMPLINK = 3;
644 pub const PUP = 4;
645 pub const CHAOS = 5;
646 pub const NETBIOS = 6;
647 pub const ISO = 7;
648 pub const OSI = ISO;
649 pub const ECMA = 8;
650 pub const DATAKIT = 9;
651 pub const CCITT = 10;
652 pub const SNA = 11;
653 pub const DECnet = 12;
654 pub const DLI = 13;
655 pub const LAT = 14;
656 pub const HYLINK = 15;
657 pub const APPLETALK = 16;
658 pub const ROUTE = 17;
659 pub const LINK = 18;
660 pub const pseudo_XTP = 19;
661 pub const COIP = 20;
662 pub const CNT = 21;
663 pub const pseudo_RTIP = 22;
664 pub const IPX = 23;
665 pub const SIP = 24;
666 pub const pseudo_PIP = 25;
667 pub const ISDN = 26;
668 pub const E164 = ISDN;
669 pub const pseudo_KEY = 27;
670 pub const INET6 = 28;
671 pub const NATM = 29;
672 pub const ATM = 30;
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
675685pub const DT_UNKNOWN = 0;
676686pub const DT_FIFO = 1;
......@@ -1070,353 +1080,240 @@ pub const addrinfo = extern struct {
10701080/// Fail if not under dirfd
10711081pub const AT_BENEATH = 0x1000;
10721082
1073/// dummy for IP
1074pub const IPPROTO_IP = 0;
1075
1076/// control message protocol
1077pub const IPPROTO_ICMP = 1;
1078
1079/// tcp
1080pub const IPPROTO_TCP = 6;
1081
1082/// user datagram protocol
1083pub const IPPROTO_UDP = 17;
1084
1085/// IP6 header
1086pub const IPPROTO_IPV6 = 41;
1087
1088/// raw IP packet
1089pub const IPPROTO_RAW = 255;
1090
1091/// IP6 hop-by-hop options
1092pub const IPPROTO_HOPOPTS = 0;
1093
1094/// group mgmt protocol
1095pub const IPPROTO_IGMP = 2;
1096
1097/// gateway^2 (deprecated)
1098pub const IPPROTO_GGP = 3;
1099
1100/// IPv4 encapsulation
1101pub const IPPROTO_IPV4 = 4;
1102
1103/// for compatibility
1104pub const IPPROTO_IPIP = IPPROTO_IPV4;
1105
1106/// Stream protocol II
1107pub const IPPROTO_ST = 7;
1108
1109/// exterior gateway protocol
1110pub const IPPROTO_EGP = 8;
1111
1112/// private interior gateway
1113pub const IPPROTO_PIGP = 9;
1114
1115/// BBN RCC Monitoring
1116pub const IPPROTO_RCCMON = 10;
1117
1118/// network voice protocol
1119pub const IPPROTO_NVPII = 11;
1120
1121/// pup
1122pub const IPPROTO_PUP = 12;
1123
1124/// Argus
1125pub const IPPROTO_ARGUS = 13;
1126
1127/// EMCON
1128pub const IPPROTO_EMCON = 14;
1129
1130/// Cross Net Debugger
1131pub const IPPROTO_XNET = 15;
1132
1133/// Chaos
1134pub const IPPROTO_CHAOS = 16;
1135
1136/// Multiplexing
1137pub const IPPROTO_MUX = 18;
1138
1139/// DCN Measurement Subsystems
1140pub const IPPROTO_MEAS = 19;
1141
1142/// Host Monitoring
1143pub const IPPROTO_HMP = 20;
1144
1145/// Packet Radio Measurement
1146pub const IPPROTO_PRM = 21;
1147
1148/// xns idp
1149pub const IPPROTO_IDP = 22;
1150
1151/// Trunk-1
1152pub const IPPROTO_TRUNK1 = 23;
1153
1154/// Trunk-2
1155pub const IPPROTO_TRUNK2 = 24;
1156
1157/// Leaf-1
1158pub const IPPROTO_LEAF1 = 25;
1159
1160/// Leaf-2
1161pub const IPPROTO_LEAF2 = 26;
1162
1163/// Reliable Data
1164pub const IPPROTO_RDP = 27;
1165
1166/// Reliable Transaction
1167pub const IPPROTO_IRTP = 28;
1168
1169/// tp-4 w/ class negotiation
1170pub const IPPROTO_TP = 29;
1171
1172/// Bulk Data Transfer
1173pub const IPPROTO_BLT = 30;
1174
1175/// Network Services
1176pub const IPPROTO_NSP = 31;
1177
1178/// Merit Internodal
1179pub const IPPROTO_INP = 32;
1180
1181/// Datagram Congestion Control Protocol
1182pub const IPPROTO_DCCP = 33;
1183
1184/// Third Party Connect
1185pub const IPPROTO_3PC = 34;
1186
1187/// InterDomain Policy Routing
1188pub const IPPROTO_IDPR = 35;
1189
1190/// XTP
1191pub const IPPROTO_XTP = 36;
1192
1193/// Datagram Delivery
1194pub const IPPROTO_DDP = 37;
1195
1196/// Control Message Transport
1197pub const IPPROTO_CMTP = 38;
1198
1199/// TP++ Transport
1200pub const IPPROTO_TPXX = 39;
1201
1202/// IL transport protocol
1203pub const IPPROTO_IL = 40;
1204
1205/// Source Demand Routing
1206pub const IPPROTO_SDRP = 42;
1207
1208/// IP6 routing header
1209pub const IPPROTO_ROUTING = 43;
1210
1211/// IP6 fragmentation header
1212pub const IPPROTO_FRAGMENT = 44;
1213
1214/// InterDomain Routing
1215pub const IPPROTO_IDRP = 45;
1216
1217/// resource reservation
1218pub const IPPROTO_RSVP = 46;
1219
1220/// General Routing Encap.
1221pub const IPPROTO_GRE = 47;
1222
1223/// Mobile Host Routing
1224pub const IPPROTO_MHRP = 48;
1225
1226/// BHA
1227pub const IPPROTO_BHA = 49;
1228
1229/// IP6 Encap Sec. Payload
1230pub const IPPROTO_ESP = 50;
1231
1232/// IP6 Auth Header
1233pub const IPPROTO_AH = 51;
1234
1235/// Integ. Net Layer Security
1236pub const IPPROTO_INLSP = 52;
1237
1238/// IP with encryption
1239pub const IPPROTO_SWIPE = 53;
1240
1241/// Next Hop Resolution
1242pub const IPPROTO_NHRP = 54;
1243
1244/// IP Mobility
1245pub const IPPROTO_MOBILE = 55;
1246
1247/// Transport Layer Security
1248pub const IPPROTO_TLSP = 56;
1249
1250/// SKIP
1251pub const IPPROTO_SKIP = 57;
1252
1253/// ICMP6
1254pub const IPPROTO_ICMPV6 = 58;
1255
1256/// IP6 no next header
1257pub const IPPROTO_NONE = 59;
1258
1259/// IP6 destination option
1260pub const IPPROTO_DSTOPTS = 60;
1261
1262/// any host internal protocol
1263pub const IPPROTO_AHIP = 61;
1264
1265/// CFTP
1266pub const IPPROTO_CFTP = 62;
1267
1268/// "hello" routing protocol
1269pub const IPPROTO_HELLO = 63;
1270
1271/// SATNET/Backroom EXPAK
1272pub const IPPROTO_SATEXPAK = 64;
1273
1274/// Kryptolan
1275pub const IPPROTO_KRYPTOLAN = 65;
1276
1277/// Remote Virtual Disk
1278pub const IPPROTO_RVD = 66;
1279
1280/// Pluribus Packet Core
1281pub const IPPROTO_IPPC = 67;
1282
1283/// Any distributed FS
1284pub const IPPROTO_ADFS = 68;
1285
1286/// Satnet Monitoring
1287pub const IPPROTO_SATMON = 69;
1288
1289/// VISA Protocol
1290pub const IPPROTO_VISA = 70;
1291
1292/// Packet Core Utility
1293pub const IPPROTO_IPCV = 71;
1294
1295/// Comp. Prot. Net. Executive
1296pub const IPPROTO_CPNX = 72;
1297
1298/// Comp. Prot. HeartBeat
1299pub const IPPROTO_CPHB = 73;
1300
1301/// Wang Span Network
1302pub const IPPROTO_WSN = 74;
1303
1304/// Packet Video Protocol
1305pub const IPPROTO_PVP = 75;
1306
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;
1083pub const IPPROTO = struct {
1084 /// dummy for IP
1085 pub const IP = 0;
1086 /// control message protocol
1087 pub const ICMP = 1;
1088 /// tcp
1089 pub const TCP = 6;
1090 /// user datagram protocol
1091 pub const UDP = 17;
1092 /// IP6 header
1093 pub const IPV6 = 41;
1094 /// raw IP packet
1095 pub const RAW = 255;
1096 /// IP6 hop-by-hop options
1097 pub const HOPOPTS = 0;
1098 /// group mgmt protocol
1099 pub const IGMP = 2;
1100 /// gateway^2 (deprecated)
1101 pub const GGP = 3;
1102 /// IPv4 encapsulation
1103 pub const IPV4 = 4;
1104 /// for compatibility
1105 pub const IPIP = IPV4;
1106 /// Stream protocol II
1107 pub const ST = 7;
1108 /// exterior gateway protocol
1109 pub const EGP = 8;
1110 /// private interior gateway
1111 pub const PIGP = 9;
1112 /// BBN RCC Monitoring
1113 pub const RCCMON = 10;
1114 /// network voice protocol
1115 pub const NVPII = 11;
1116 /// pup
1117 pub const PUP = 12;
1118 /// Argus
1119 pub const ARGUS = 13;
1120 /// EMCON
1121 pub const EMCON = 14;
1122 /// Cross Net Debugger
1123 pub const XNET = 15;
1124 /// Chaos
1125 pub const CHAOS = 16;
1126 /// Multiplexing
1127 pub const MUX = 18;
1128 /// DCN Measurement Subsystems
1129 pub const MEAS = 19;
1130 /// Host Monitoring
1131 pub const HMP = 20;
1132 /// Packet Radio Measurement
1133 pub const PRM = 21;
1134 /// xns idp
1135 pub const IDP = 22;
1136 /// Trunk-1
1137 pub const TRUNK1 = 23;
1138 /// Trunk-2
1139 pub const TRUNK2 = 24;
1140 /// Leaf-1
1141 pub const LEAF1 = 25;
1142 /// Leaf-2
1143 pub const LEAF2 = 26;
1144 /// Reliable Data
1145 pub const RDP = 27;
1146 /// Reliable Transaction
1147 pub const IRTP = 28;
1148 /// tp-4 w/ class negotiation
1149 pub const TP = 29;
1150 /// Bulk Data Transfer
1151 pub const BLT = 30;
1152 /// Network Services
1153 pub const NSP = 31;
1154 /// Merit Internodal
1155 pub const INP = 32;
1156 /// Datagram Congestion Control Protocol
1157 pub const DCCP = 33;
1158 /// Third Party Connect
1159 pub const @"3PC" = 34;
1160 /// InterDomain Policy Routing
1161 pub const IDPR = 35;
1162 /// XTP
1163 pub const XTP = 36;
1164 /// Datagram Delivery
1165 pub const DDP = 37;
1166 /// Control Message Transport
1167 pub const CMTP = 38;
1168 /// TP++ Transport
1169 pub const TPXX = 39;
1170 /// IL transport protocol
1171 pub const IL = 40;
1172 /// Source Demand Routing
1173 pub const SDRP = 42;
1174 /// IP6 routing header
1175 pub const ROUTING = 43;
1176 /// IP6 fragmentation header
1177 pub const FRAGMENT = 44;
1178 /// InterDomain Routing
1179 pub const IDRP = 45;
1180 /// resource reservation
1181 pub const RSVP = 46;
1182 /// General Routing Encap.
1183 pub const GRE = 47;
1184 /// Mobile Host Routing
1185 pub const MHRP = 48;
1186 /// BHA
1187 pub const BHA = 49;
1188 /// IP6 Encap Sec. Payload
1189 pub const ESP = 50;
1190 /// IP6 Auth Header
1191 pub const AH = 51;
1192 /// Integ. Net Layer Security
1193 pub const INLSP = 52;
1194 /// IP with encryption
1195 pub const SWIPE = 53;
1196 /// Next Hop Resolution
1197 pub const NHRP = 54;
1198 /// IP Mobility
1199 pub const MOBILE = 55;
1200 /// Transport Layer Security
1201 pub const TLSP = 56;
1202 /// SKIP
1203 pub const SKIP = 57;
1204 /// ICMP6
1205 pub const ICMPV6 = 58;
1206 /// IP6 no next header
1207 pub const NONE = 59;
1208 /// IP6 destination option
1209 pub const DSTOPTS = 60;
1210 /// any host internal protocol
1211 pub const AHIP = 61;
1212 /// CFTP
1213 pub const CFTP = 62;
1214 /// "hello" routing protocol
1215 pub const HELLO = 63;
1216 /// SATNET/Backroom EXPAK
1217 pub const SATEXPAK = 64;
1218 /// Kryptolan
1219 pub const KRYPTOLAN = 65;
1220 /// Remote Virtual Disk
1221 pub const RVD = 66;
1222 /// Pluribus Packet Core
1223 pub const IPPC = 67;
1224 /// Any distributed FS
1225 pub const ADFS = 68;
1226 /// Satnet Monitoring
1227 pub const SATMON = 69;
1228 /// VISA Protocol
1229 pub const VISA = 70;
1230 /// Packet Core Utility
1231 pub const IPCV = 71;
1232 /// Comp. Prot. Net. Executive
1233 pub const CPNX = 72;
1234 /// Comp. Prot. HeartBeat
1235 pub const CPHB = 73;
1236 /// Wang Span Network
1237 pub const WSN = 74;
1238 /// Packet Video Protocol
1239 pub const PVP = 75;
1240 /// BackRoom SATNET Monitoring
1241 pub const BRSATMON = 76;
1242 /// Sun net disk proto (temp.)
1243 pub const ND = 77;
1244 /// WIDEBAND Monitoring
1245 pub const WBMON = 78;
1246 /// WIDEBAND EXPAK
1247 pub const WBEXPAK = 79;
1248 /// ISO cnlp
1249 pub const EON = 80;
1250 /// VMTP
1251 pub const VMTP = 81;
1252 /// Secure VMTP
1253 pub const SVMTP = 82;
1254 /// Banyon VINES
1255 pub const VINES = 83;
1256 /// TTP
1257 pub const TTP = 84;
1258 /// NSFNET-IGP
1259 pub const IGP = 85;
1260 /// dissimilar gateway prot.
1261 pub const DGP = 86;
1262 /// TCF
1263 pub const TCF = 87;
1264 /// Cisco/GXS IGRP
1265 pub const IGRP = 88;
1266 /// OSPFIGP
1267 pub const OSPFIGP = 89;
1268 /// Strite RPC protocol
1269 pub const SRPC = 90;
1270 /// Locus Address Resoloution
1271 pub const LARP = 91;
1272 /// Multicast Transport
1273 pub const MTP = 92;
1274 /// AX.25 Frames
1275 pub const AX25 = 93;
1276 /// IP encapsulated in IP
1277 pub const IPEIP = 94;
1278 /// Mobile Int.ing control
1279 pub const MICP = 95;
1280 /// Semaphore Comm. security
1281 pub const SCCSP = 96;
1282 /// Ethernet IP encapsulation
1283 pub const ETHERIP = 97;
1284 /// encapsulation header
1285 pub const ENCAP = 98;
1286 /// any private encr. scheme
1287 pub const APES = 99;
1288 /// GMTP
1289 pub const GMTP = 100;
1290 /// payload compression (IPComp)
1291 pub const IPCOMP = 108;
1292 /// SCTP
1293 pub const SCTP = 132;
1294 /// IPv6 Mobility Header
1295 pub const MH = 135;
1296 /// UDP-Lite
1297 pub const UDPLITE = 136;
1298 /// IP6 Host Identity Protocol
1299 pub const HIP = 139;
1300 /// IP6 Shim6 Protocol
1301 pub const SHIM6 = 140;
1302 /// Protocol Independent Mcast
1303 pub const PIM = 103;
1304 /// CARP
1305 pub const CARP = 112;
1306 /// PGM
1307 pub const PGM = 113;
1308 /// MPLS-in-IP
1309 pub const MPLS = 137;
1310 /// PFSYNC
1311 pub const PFSYNC = 240;
1312 /// Reserved
1313 pub const RESERVED_253 = 253;
1314 /// Reserved
1315 pub const RESERVED_254 = 254;
1316};
14201317
14211318pub const rlimit_resource = enum(c_int) {
14221319 CPU = 0,
......@@ -1441,11 +1338,13 @@ pub const rlimit_resource = enum(c_int) {
14411338
14421339pub const rlim_t = i64;
14431340
1444/// No limit
1445pub const RLIM_INFINITY: rlim_t = (1 << 63) - 1;
1341pub const RLIM = struct {
1342 /// No limit
1343 pub const INFINITY: rlim_t = (1 << 63) - 1;
14461344
1447pub const RLIM_SAVED_MAX = RLIM_INFINITY;
1448pub const RLIM_SAVED_CUR = RLIM_INFINITY;
1345 pub const SAVED_MAX = INFINITY;
1346 pub const SAVED_CUR = INFINITY;
1347};
14491348
14501349pub const rlimit = extern struct {
14511350 /// Soft limit
lib/std/c/linux.zig+58-28
......@@ -4,61 +4,93 @@ const maxInt = std.math.maxInt;
44const native_abi = builtin.abi;
55const native_arch = builtin.cpu.arch;
66const linux = std.os.linux;
7const iovec = std.os.iovec;
8const iovec_const = std.os.iovec_const;
79
8pub const E = linux.E;
9pub const Sigaction = linux.Sigaction;
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;
10pub const AF = linux.AF;
11pub const ARCH = linux.ARCH;
2112pub const AT = linux.AT;
22pub const PROT = linux.PROT;
2313pub const CLOCK = linux.CLOCK;
24pub const SIG = linux.SIG;
25pub const empty_sigset = linux.empty_sigset;
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;
14pub const CPU_COUNT = linux.CPU_COUNT;
15pub const E = linux.E;
3216pub const Elf_Symndx = linux.Elf_Symndx;
3317pub const F = linux.F;
18pub const FD_CLOEXEC = linux.FD_CLOEXEC;
19pub const F_OK = linux.F_OK;
3420pub 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;
3525pub const LOCK = linux.LOCK;
26pub const MADV = linux.MADV;
3627pub const MAP = linux.MAP;
3728pub const MMAP2_UNIT = linux.MMAP2_UNIT;
29pub const NAME_MAX = linux.NAME_MAX;
3830pub const O = linux.O;
31pub const PATH_MAX = linux.PATH_MAX;
32pub const POLL = linux.POLL;
33pub const PROT = linux.PROT;
3934pub 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;
4039pub 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;
4150pub const SYS = linux.SYS;
51pub const Sigaction = linux.Sigaction;
4252pub 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;
4357pub const blkcnt_t = linux.blkcnt_t;
4458pub const blksize_t = linux.blksize_t;
59pub const clock_t = linux.clock_t;
60pub const cpu_set_t = linux.cpu_set_t;
4561pub 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;
4668pub const ino_t = linux.ino_t;
4769pub const mcontext_t = linux.mcontext_t;
4870pub const mode_t = linux.mode_t;
4971pub const msghdr = linux.msghdr;
5072pub const msghdr_const = linux.msghdr_const;
73pub const nfds_t = linux.nfds_t;
5174pub const nlink_t = linux.nlink_t;
5275pub 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;
5386pub const time_t = linux.time_t;
87pub const timespec = linux.timespec;
5488pub const timeval = linux.timeval;
5589pub const timezone = linux.timezone;
5690pub const ucontext_t = linux.ucontext_t;
57pub const user_desc = linux.user_desc;
58pub const pid_t = linux.pid_t;
5991pub const uid_t = linux.uid_t;
60pub const gid_t = linux.gid_t;
61pub const clock_t = linux.clock_t;
92pub const user_desc = linux.user_desc;
93pub const utsname = linux.utsname;
6294
6395pub const _errno = switch (native_abi) {
6496 .android => struct {
......@@ -140,8 +172,6 @@ pub const Stat = switch (native_arch) {
140172 else => std.os.linux.Stat, // libc stat is the same as kernel stat.
141173};
142174
143pub const MAP_FAILED = @intToPtr(*c_void, maxInt(usize));
144
145175pub const AI = struct {
146176 pub const PASSIVE = 0x01;
147177 pub const CANONNAME = 0x02;
lib/std/c/netbsd.zig+306-324
......@@ -135,16 +135,18 @@ pub const Kevent = extern struct {
135135 udata: usize,
136136};
137137
138pub const RTLD_LAZY = 1;
139pub const RTLD_NOW = 2;
140pub const RTLD_GLOBAL = 0x100;
141pub const RTLD_LOCAL = 0x200;
142pub const RTLD_NODELETE = 0x01000;
143pub const RTLD_NOLOAD = 0x02000;
144
145pub const RTLD_NEXT = @intToPtr(*c_void, @bitCast(usize, @as(isize, -1)));
146pub const RTLD_DEFAULT = @intToPtr(*c_void, @bitCast(usize, @as(isize, -2)));
147pub const RTLD_SELF = @intToPtr(*c_void, @bitCast(usize, @as(isize, -3)));
138pub const RTLD = struct {
139 pub const LAZY = 1;
140 pub const NOW = 2;
141 pub const GLOBAL = 0x100;
142 pub const LOCAL = 0x200;
143 pub const NODELETE = 0x01000;
144 pub const NOLOAD = 0x02000;
145
146 pub const NEXT = @intToPtr(*c_void, @bitCast(usize, @as(isize, -1)));
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
149151pub const dl_phdr_info = extern struct {
150152 dlpi_addr: usize,
......@@ -325,120 +327,130 @@ pub const dirent = extern struct {
325327 }
326328};
327329
328pub const SOCK_STREAM = 1;
329pub const SOCK_DGRAM = 2;
330pub const SOCK_RAW = 3;
331pub const SOCK_RDM = 4;
332pub const SOCK_SEQPACKET = 5;
333pub const SOCK_CONN_DGRAM = 6;
334pub const SOCK_DCCP = SOCK_CONN_DGRAM;
335
336pub const SOCK_CLOEXEC = 0x10000000;
337pub const SOCK_NONBLOCK = 0x20000000;
338pub const SOCK_NOSIGPIPE = 0x40000000;
339pub const SOCK_FLAGS_MASK = 0xf0000000;
340
341pub const SO_DEBUG = 0x0001;
342pub const SO_ACCEPTCONN = 0x0002;
343pub const SO_REUSEADDR = 0x0004;
344pub const SO_KEEPALIVE = 0x0008;
345pub const SO_DONTROUTE = 0x0010;
346pub const SO_BROADCAST = 0x0020;
347pub const SO_USELOOPBACK = 0x0040;
348pub const SO_LINGER = 0x0080;
349pub const SO_OOBINLINE = 0x0100;
350pub const SO_REUSEPORT = 0x0200;
351pub const SO_NOSIGPIPE = 0x0800;
352pub const SO_ACCEPTFILTER = 0x1000;
353pub const SO_TIMESTAMP = 0x2000;
354pub const SO_RERROR = 0x4000;
355
356pub const SO_SNDBUF = 0x1001;
357pub const SO_RCVBUF = 0x1002;
358pub const SO_SNDLOWAT = 0x1003;
359pub const SO_RCVLOWAT = 0x1004;
360pub const SO_ERROR = 0x1007;
361pub const SO_TYPE = 0x1008;
362pub const SO_OVERFLOWED = 0x1009;
363
364pub const SO_NOHEADER = 0x100a;
365pub const SO_SNDTIMEO = 0x100b;
366pub const SO_RCVTIMEO = 0x100c;
367
368pub const SOL_SOCKET = 0xffff;
369
370pub const PF_UNSPEC = AF_UNSPEC;
371pub const PF_LOCAL = AF_LOCAL;
372pub const PF_UNIX = PF_LOCAL;
373pub const PF_INET = AF_INET;
374pub const PF_IMPLINK = AF_IMPLINK;
375pub const PF_PUP = AF_PUP;
376pub const PF_CHAOS = AF_CHAOS;
377pub const PF_NS = AF_NS;
378pub const PF_ISO = AF_ISO;
379pub const PF_OSI = AF_ISO;
380pub const PF_ECMA = AF_ECMA;
381pub const PF_DATAKIT = AF_DATAKIT;
382pub const PF_CCITT = AF_CCITT;
383pub const PF_SNA = AF_SNA;
384pub const PF_DECnet = AF_DECnet;
385pub const PF_DLI = AF_DLI;
386pub const PF_LAT = AF_LAT;
387pub const PF_HYLINK = AF_HYLINK;
388pub const PF_APPLETALK = AF_APPLETALK;
389pub const PF_OROUTE = AF_OROUTE;
390pub const PF_LINK = AF_LINK;
391pub const PF_COIP = AF_COIP;
392pub const PF_CNT = AF_CNT;
393pub const PF_INET6 = AF_INET6;
394pub const PF_IPX = AF_IPX;
395pub const PF_ISDN = AF_ISDN;
396pub const PF_E164 = AF_E164;
397pub const PF_NATM = AF_NATM;
398pub const PF_ARP = AF_ARP;
399pub const PF_BLUETOOTH = AF_BLUETOOTH;
400pub const PF_MPLS = AF_MPLS;
401pub const PF_ROUTE = AF_ROUTE;
402pub const PF_CAN = AF_CAN;
403pub const PF_ETHER = AF_ETHER;
404pub const PF_MAX = AF_MAX;
405
406pub const AF_UNSPEC = 0;
407pub const AF_LOCAL = 1;
408pub const AF_UNIX = AF_LOCAL;
409pub const AF_INET = 2;
410pub const AF_IMPLINK = 3;
411pub const AF_PUP = 4;
412pub const AF_CHAOS = 5;
413pub const AF_NS = 6;
414pub const AF_ISO = 7;
415pub const AF_OSI = AF_ISO;
416pub const AF_ECMA = 8;
417pub const AF_DATAKIT = 9;
418pub const AF_CCITT = 10;
419pub const AF_SNA = 11;
420pub const AF_DECnet = 12;
421pub const AF_DLI = 13;
422pub const AF_LAT = 14;
423pub const AF_HYLINK = 15;
424pub const AF_APPLETALK = 16;
425pub const AF_OROUTE = 17;
426pub const AF_LINK = 18;
427pub const AF_COIP = 20;
428pub const AF_CNT = 21;
429pub const AF_IPX = 23;
430pub const AF_INET6 = 24;
431pub const AF_ISDN = 26;
432pub const AF_E164 = AF_ISDN;
433pub const AF_NATM = 27;
434pub const AF_ARP = 28;
435pub const AF_BLUETOOTH = 31;
436pub const AF_IEEE80211 = 32;
437pub const AF_MPLS = 33;
438pub const AF_ROUTE = 34;
439pub const AF_CAN = 35;
440pub const AF_ETHER = 36;
441pub const AF_MAX = 37;
330pub const SOCK = struct {
331 pub const STREAM = 1;
332 pub const DGRAM = 2;
333 pub const RAW = 3;
334 pub const RDM = 4;
335 pub const SEQPACKET = 5;
336 pub const CONN_DGRAM = 6;
337 pub const DCCP = CONN_DGRAM;
338
339 pub const CLOEXEC = 0x10000000;
340 pub const NONBLOCK = 0x20000000;
341 pub const NOSIGPIPE = 0x40000000;
342 pub const FLAGS_MASK = 0xf0000000;
343};
344
345pub const SO = struct {
346 pub const DEBUG = 0x0001;
347 pub const ACCEPTCONN = 0x0002;
348 pub const REUSEADDR = 0x0004;
349 pub const KEEPALIVE = 0x0008;
350 pub const DONTROUTE = 0x0010;
351 pub const BROADCAST = 0x0020;
352 pub const USELOOPBACK = 0x0040;
353 pub const LINGER = 0x0080;
354 pub const OOBINLINE = 0x0100;
355 pub const REUSEPORT = 0x0200;
356 pub const NOSIGPIPE = 0x0800;
357 pub const ACCEPTFILTER = 0x1000;
358 pub const TIMESTAMP = 0x2000;
359 pub const RERROR = 0x4000;
360
361 pub const SNDBUF = 0x1001;
362 pub const RCVBUF = 0x1002;
363 pub const SNDLOWAT = 0x1003;
364 pub const RCVLOWAT = 0x1004;
365 pub const ERROR = 0x1007;
366 pub const TYPE = 0x1008;
367 pub const OVERFLOWED = 0x1009;
368
369 pub const NOHEADER = 0x100a;
370 pub const SNDTIMEO = 0x100b;
371 pub const RCVTIMEO = 0x100c;
372};
373
374pub const SOL = struct {
375 pub const SOCKET = 0xffff;
376};
377
378pub const PF = struct {
379 pub const UNSPEC = AF.UNSPEC;
380 pub const LOCAL = AF.LOCAL;
381 pub const UNIX = PF.LOCAL;
382 pub const INET = AF.INET;
383 pub const IMPLINK = AF.IMPLINK;
384 pub const PUP = AF.PUP;
385 pub const CHAOS = AF.CHAOS;
386 pub const NS = AF.NS;
387 pub const ISO = AF.ISO;
388 pub const OSI = AF.ISO;
389 pub const ECMA = AF.ECMA;
390 pub const DATAKIT = AF.DATAKIT;
391 pub const CCITT = AF.CCITT;
392 pub const SNA = AF.SNA;
393 pub const DECnet = AF.DECnet;
394 pub const DLI = AF.DLI;
395 pub const LAT = AF.LAT;
396 pub const HYLINK = AF.HYLINK;
397 pub const APPLETALK = AF.APPLETALK;
398 pub const OROUTE = AF.OROUTE;
399 pub const LINK = AF.LINK;
400 pub const COIP = AF.COIP;
401 pub const CNT = AF.CNT;
402 pub const INET6 = AF.INET6;
403 pub const IPX = AF.IPX;
404 pub const ISDN = AF.ISDN;
405 pub const E164 = AF.E164;
406 pub const NATM = AF.NATM;
407 pub const ARP = AF.ARP;
408 pub const BLUETOOTH = AF.BLUETOOTH;
409 pub const MPLS = AF.MPLS;
410 pub const ROUTE = AF.ROUTE;
411 pub const CAN = AF.CAN;
412 pub const ETHER = AF.ETHER;
413 pub const MAX = AF.MAX;
414};
415
416pub const AF = struct {
417 pub const UNSPEC = 0;
418 pub const LOCAL = 1;
419 pub const UNIX = LOCAL;
420 pub const INET = 2;
421 pub const IMPLINK = 3;
422 pub const PUP = 4;
423 pub const CHAOS = 5;
424 pub const NS = 6;
425 pub const ISO = 7;
426 pub const OSI = ISO;
427 pub const ECMA = 8;
428 pub const DATAKIT = 9;
429 pub const CCITT = 10;
430 pub const SNA = 11;
431 pub const DECnet = 12;
432 pub const DLI = 13;
433 pub const LAT = 14;
434 pub const HYLINK = 15;
435 pub const APPLETALK = 16;
436 pub const OROUTE = 17;
437 pub const LINK = 18;
438 pub const COIP = 20;
439 pub const CNT = 21;
440 pub const IPX = 23;
441 pub const INET6 = 24;
442 pub const ISDN = 26;
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
443455pub const in_port_t = u16;
444456pub const sa_family_t = u8;
......@@ -446,60 +458,55 @@ pub const sa_family_t = u8;
446458pub const sockaddr = extern struct {
447459 /// total length
448460 len: u8,
449
450461 /// address family
451462 family: sa_family_t,
452
453463 /// actually longer; address value
454464 data: [14]u8,
455};
456
457pub const sockaddr_storage = std.x.os.Socket.Address.Native.Storage;
458465
459pub const sockaddr_in = extern struct {
460 len: u8 = @sizeOf(sockaddr_in),
461 family: sa_family_t = AF_INET,
462 port: in_port_t,
463 addr: u32,
464 zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },
466 pub const storage = std.x.os.Socket.Address.Native.Storage;
467
468 pub const in = extern struct {
469 len: u8 = @sizeOf(in),
470 family: sa_family_t = AF.INET,
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 };
465495};
466496
467pub const sockaddr_in6 = extern struct {
468 len: u8 = @sizeOf(sockaddr_in6),
469 family: sa_family_t = AF_INET6,
470 port: in_port_t,
471 flowinfo: u32,
472 addr: [16]u8,
473 scope_id: u32,
497pub const AI = struct {
498 /// get address to use bind()
499 pub const PASSIVE = 0x00000001;
500 /// fill ai_canonname
501 pub const CANONNAME = 0x00000002;
502 /// prevent host name resolution
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;
474508};
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
503510pub const CTL_KERN = 1;
504511pub const CTL_DEBUG = 5;
505512
......@@ -519,31 +526,34 @@ pub const PROT_READ = 1;
519526pub const PROT_WRITE = 2;
520527pub const PROT_EXEC = 4;
521528
522pub const CLOCK_REALTIME = 0;
523pub const CLOCK_VIRTUAL = 1;
524pub const CLOCK_PROF = 2;
525pub const CLOCK_MONOTONIC = 3;
526pub const CLOCK_THREAD_CPUTIME_ID = 0x20000000;
527pub const CLOCK_PROCESS_CPUTIME_ID = 0x40000000;
528
529pub const MAP_FAILED = @intToPtr(*c_void, maxInt(usize));
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;
529pub const CLOCK = struct {
530 pub const REALTIME = 0;
531 pub const VIRTUAL = 1;
532 pub const PROF = 2;
533 pub const MONOTONIC = 3;
534 pub const THREAD_CPUTIME_ID = 0x20000000;
535 pub const PROCESS_CPUTIME_ID = 0x40000000;
536};
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};
547557pub const WNOHANG = 0x00000001;
548558pub const WUNTRACED = 0x00000002;
549559pub const WSTOPPED = WUNTRACED;
......@@ -686,10 +696,12 @@ pub const F_RDLCK = 1;
686696pub const F_WRLCK = 3;
687697pub const F_UNLCK = 2;
688698
689pub const LOCK_SH = 1;
690pub const LOCK_EX = 2;
691pub const LOCK_UN = 8;
692pub const LOCK_NB = 4;
699pub const LOCK = struct {
700 pub const SH = 1;
701 pub const EX = 2;
702 pub const UN = 8;
703 pub const NB = 4;
704};
693705
694706pub const FD_CLOEXEC = 1;
695707
......@@ -1262,116 +1274,82 @@ pub const AT_REMOVEDIR = 0x0800;
12621274
12631275pub const HOST_NAME_MAX = 255;
12641276
1265/// dummy for IP
1266pub const IPPROTO_IP = 0;
1267
1268/// IP6 hop-by-hop options
1269pub const IPPROTO_HOPOPTS = 0;
1270
1271/// control message protocol
1272pub const IPPROTO_ICMP = 1;
1273
1274/// group mgmt protocol
1275pub const IPPROTO_IGMP = 2;
1276
1277/// gateway^2 (deprecated)
1278pub const IPPROTO_GGP = 3;
1279
1280/// IP header
1281pub const IPPROTO_IPV4 = 4;
1282
1283/// IP inside IP
1284pub const IPPROTO_IPIP = 4;
1285
1286/// tcp
1287pub const IPPROTO_TCP = 6;
1288
1289/// exterior gateway protocol
1290pub const IPPROTO_EGP = 8;
1291
1292/// pup
1293pub const IPPROTO_PUP = 12;
1294
1295/// user datagram protocol
1296pub const IPPROTO_UDP = 17;
1297
1298/// xns idp
1299pub const IPPROTO_IDP = 22;
1300
1301/// tp-4 w/ class negotiation
1302pub const IPPROTO_TP = 29;
1303
1304/// DCCP
1305pub const IPPROTO_DCCP = 33;
1306
1307/// IP6 header
1308pub const IPPROTO_IPV6 = 41;
1309
1310/// IP6 routing header
1311pub const IPPROTO_ROUTING = 43;
1312
1313/// IP6 fragmentation header
1314pub const IPPROTO_FRAGMENT = 44;
1315
1316/// resource reservation
1317pub const IPPROTO_RSVP = 46;
1318
1319/// GRE encaps RFC 1701
1320pub const IPPROTO_GRE = 47;
1321
1322/// encap. security payload
1323pub const IPPROTO_ESP = 50;
1324
1325/// authentication header
1326pub const IPPROTO_AH = 51;
1327
1328/// IP Mobility RFC 2004
1329pub const IPPROTO_MOBILE = 55;
1330
1331/// IPv6 ICMP
1332pub const IPPROTO_IPV6_ICMP = 58;
1333
1334/// ICMP6
1335pub const IPPROTO_ICMPV6 = 58;
1336
1337/// IP6 no next header
1338pub const IPPROTO_NONE = 59;
1339
1340/// IP6 destination option
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;
1277pub const IPPROTO = struct {
1278 /// dummy for IP
1279 pub const IP = 0;
1280 /// IP6 hop-by-hop options
1281 pub const HOPOPTS = 0;
1282 /// control message protocol
1283 pub const ICMP = 1;
1284 /// group mgmt protocol
1285 pub const IGMP = 2;
1286 /// gateway^2 (deprecated)
1287 pub const GGP = 3;
1288 /// IP header
1289 pub const IPV4 = 4;
1290 /// IP inside IP
1291 pub const IPIP = 4;
1292 /// tcp
1293 pub const TCP = 6;
1294 /// exterior gateway protocol
1295 pub const EGP = 8;
1296 /// pup
1297 pub const PUP = 12;
1298 /// user datagram protocol
1299 pub const UDP = 17;
1300 /// xns idp
1301 pub const IDP = 22;
1302 /// tp-4 w/ class negotiation
1303 pub const TP = 29;
1304 /// DCCP
1305 pub const DCCP = 33;
1306 /// IP6 header
1307 pub const IPV6 = 41;
1308 /// IP6 routing header
1309 pub const ROUTING = 43;
1310 /// IP6 fragmentation header
1311 pub const FRAGMENT = 44;
1312 /// resource reservation
1313 pub const RSVP = 46;
1314 /// GRE encaps RFC 1701
1315 pub const GRE = 47;
1316 /// encap. security payload
1317 pub const ESP = 50;
1318 /// authentication header
1319 pub const AH = 51;
1320 /// IP Mobility RFC 2004
1321 pub const MOBILE = 55;
1322 /// IPv6 ICMP
1323 pub const IPV6_ICMP = 58;
1324 /// ICMP6
1325 pub const ICMPV6 = 58;
1326 /// IP6 no next header
1327 pub const NONE = 59;
1328 /// IP6 destination option
1329 pub const DSTOPTS = 60;
1330 /// ISO cnlp
1331 pub const EON = 80;
1332 /// Ethernet-in-IP
1333 pub const ETHERIP = 97;
1334 /// encapsulation header
1335 pub const ENCAP = 98;
1336 /// Protocol indep. multicast
1337 pub const PIM = 103;
1338 /// IP Payload Comp. Protocol
1339 pub const IPCOMP = 108;
1340 /// VRRP RFC 2338
1341 pub const VRRP = 112;
1342 /// Common Address Resolution Protocol
1343 pub const CARP = 112;
1344 /// L2TPv3
1345 pub const L2TP = 115;
1346 /// SCTP
1347 pub const SCTP = 132;
1348 /// PFSYNC
1349 pub const PFSYNC = 240;
1350 /// raw IP packet
1351 pub const RAW = 255;
1352};
13751353
13761354pub const rlimit_resource = enum(c_int) {
13771355 CPU = 0,
......@@ -1393,11 +1371,13 @@ pub const rlimit_resource = enum(c_int) {
13931371
13941372pub const rlim_t = u64;
13951373
1396/// No limit
1397pub const RLIM_INFINITY: rlim_t = (1 << 63) - 1;
1374pub const RLIM = struct {
1375 /// No limit
1376 pub const INFINITY: rlim_t = (1 << 63) - 1;
13981377
1399pub const RLIM_SAVED_MAX = RLIM_INFINITY;
1400pub const RLIM_SAVED_CUR = RLIM_INFINITY;
1378 pub const SAVED_MAX = INFINITY;
1379 pub const SAVED_CUR = INFINITY;
1380};
14011381
14021382pub const rlimit = extern struct {
14031383 /// Soft limit
......@@ -1418,16 +1398,18 @@ pub const pollfd = extern struct {
14181398 revents: i16,
14191399};
14201400
1421/// Testable events (may be specified in events field).
1422pub const POLLIN = 0x0001;
1423pub const POLLPRI = 0x0002;
1424pub const POLLOUT = 0x0004;
1425pub const POLLRDNORM = 0x0040;
1426pub const POLLWRNORM = POLLOUT;
1427pub const POLLRDBAND = 0x0080;
1428pub const POLLWRBAND = 0x0100;
1429
1430/// Non-testable events (may not be specified in events field).
1431pub const POLLERR = 0x0008;
1432pub const POLLHUP = 0x0010;
1433pub const POLLNVAL = 0x0020;
1401pub const POLL = struct {
1402 /// Testable events (may be specified in events field).
1403 pub const IN = 0x0001;
1404 pub const PRI = 0x0002;
1405 pub const OUT = 0x0004;
1406 pub const RDNORM = 0x0040;
1407 pub const WRNORM = OUT;
1408 pub const RDBAND = 0x0080;
1409 pub const WRBAND = 0x0100;
1410
1411 /// Non-testable events (may not be specified in events field).
1412 pub const ERR = 0x0008;
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 {
7171// Modes and flags for dlopen()
7272// include/dlfcn.h
7373
74/// Bind function calls lazily.
75pub const RTLD_LAZY = 1;
76
77/// Bind function calls immediately.
78pub const RTLD_NOW = 2;
79
80/// Make symbols globally available.
81pub const RTLD_GLOBAL = 0x100;
82
83/// Opposite of RTLD_GLOBAL, and the default.
84pub const RTLD_LOCAL = 0x000;
85
86/// Trace loaded objects and exit.
87pub const RTLD_TRACE = 0x200;
74pub const RTLD = struct {
75 /// Bind function calls lazily.
76 pub const LAZY = 1;
77 /// Bind function calls immediately.
78 pub const NOW = 2;
79 /// Make symbols globally available.
80 pub const GLOBAL = 0x100;
81 /// Opposite of GLOBAL, and the default.
82 pub const LOCAL = 0x000;
83 /// Trace loaded objects and exit.
84 pub const TRACE = 0x200;
85};
8886
8987pub const dl_phdr_info = extern struct {
9088 dlpi_addr: std.elf.Addr,
......@@ -274,60 +272,55 @@ pub const sa_family_t = u8;
274272pub const sockaddr = extern struct {
275273 /// total length
276274 len: u8,
277
278275 /// address family
279276 family: sa_family_t,
280
281277 /// actually longer; address value
282278 data: [14]u8,
283};
284
285pub const sockaddr_storage = std.x.os.Socket.Address.Native.Storage;
286279
287pub const sockaddr_in = extern struct {
288 len: u8 = @sizeOf(sockaddr_in),
289 family: sa_family_t = AF_INET,
290 port: in_port_t,
291 addr: u32,
292 zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },
280 pub const storage = std.x.os.Socket.Address.Native.Storage;
281
282 pub const in = extern struct {
283 len: u8 = @sizeOf(in),
284 family: sa_family_t = AF.INET,
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 };
293309};
294310
295pub const sockaddr_in6 = extern struct {
296 len: u8 = @sizeOf(sockaddr_in6),
297 family: sa_family_t = AF_INET6,
298 port: in_port_t,
299 flowinfo: u32,
300 addr: [16]u8,
301 scope_id: u32,
311pub const AI = struct {
312 /// get address to use bind()
313 pub const PASSIVE = 1;
314 /// fill ai_canonname
315 pub const CANONNAME = 2;
316 /// prevent host name resolution
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;
302322};
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
331324pub const PATH_MAX = 1024;
332325pub const IOV_MAX = 1024;
333326
......@@ -340,27 +333,30 @@ pub const PROT_READ = 1;
340333pub const PROT_WRITE = 2;
341334pub const PROT_EXEC = 4;
342335
343pub const CLOCK_REALTIME = 0;
344pub const CLOCK_PROCESS_CPUTIME_ID = 2;
345pub const CLOCK_MONOTONIC = 3;
346pub const CLOCK_THREAD_CPUTIME_ID = 4;
347
348pub const MAP_FAILED = @intToPtr(*c_void, maxInt(usize));
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;
336pub const CLOCK = struct {
337 pub const REALTIME = 0;
338 pub const PROCESS_CPUTIME_ID = 2;
339 pub const MONOTONIC = 3;
340 pub const THREAD_CPUTIME_ID = 4;
341};
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};
364360pub const WNOHANG = 1;
365361pub const WUNTRACED = 2;
366362pub const WCONTINUED = 8;
......@@ -487,10 +483,12 @@ pub const F_RDLCK = 1;
487483pub const F_UNLCK = 2;
488484pub const F_WRLCK = 3;
489485
490pub const LOCK_SH = 0x01;
491pub const LOCK_EX = 0x02;
492pub const LOCK_NB = 0x04;
493pub const LOCK_UN = 0x08;
486pub const LOCK = struct {
487 pub const SH = 0x01;
488 pub const EX = 0x02;
489 pub const NB = 0x04;
490 pub const UN = 0x08;
491};
494492
495493pub const FD_CLOEXEC = 1;
496494
......@@ -502,73 +500,83 @@ pub const SIG_BLOCK = 1;
502500pub const SIG_UNBLOCK = 2;
503501pub const SIG_SETMASK = 3;
504502
505pub const SOCK_STREAM = 1;
506pub const SOCK_DGRAM = 2;
507pub const SOCK_RAW = 3;
508pub const SOCK_RDM = 4;
509pub const SOCK_SEQPACKET = 5;
510
511pub const SOCK_CLOEXEC = 0x8000;
512pub const SOCK_NONBLOCK = 0x4000;
513
514pub const SO_DEBUG = 0x0001;
515pub const SO_ACCEPTCONN = 0x0002;
516pub const SO_REUSEADDR = 0x0004;
517pub const SO_KEEPALIVE = 0x0008;
518pub const SO_DONTROUTE = 0x0010;
519pub const SO_BROADCAST = 0x0020;
520pub const SO_USELOOPBACK = 0x0040;
521pub const SO_LINGER = 0x0080;
522pub const SO_OOBINLINE = 0x0100;
523pub const SO_REUSEPORT = 0x0200;
524pub const SO_TIMESTAMP = 0x0800;
525pub const SO_BINDANY = 0x1000;
526pub const SO_ZEROIZE = 0x2000;
527pub const SO_SNDBUF = 0x1001;
528pub const SO_RCVBUF = 0x1002;
529pub const SO_SNDLOWAT = 0x1003;
530pub const SO_RCVLOWAT = 0x1004;
531pub const SO_SNDTIMEO = 0x1005;
532pub const SO_RCVTIMEO = 0x1006;
533pub const SO_ERROR = 0x1007;
534pub const SO_TYPE = 0x1008;
535pub const SO_NETPROC = 0x1020;
536pub const SO_RTABLE = 0x1021;
537pub const SO_PEERCRED = 0x1022;
538pub const SO_SPLICE = 0x1023;
539pub const SO_DOMAIN = 0x1024;
540pub const SO_PROTOCOL = 0x1025;
541
542pub const SOL_SOCKET = 0xffff;
543
544pub const PF_UNSPEC = AF_UNSPEC;
545pub const PF_LOCAL = AF_LOCAL;
546pub const PF_UNIX = AF_UNIX;
547pub const PF_INET = AF_INET;
548pub const PF_APPLETALK = AF_APPLETALK;
549pub const PF_INET6 = AF_INET6;
550pub const PF_DECnet = AF_DECnet;
551pub const PF_KEY = AF_KEY;
552pub const PF_ROUTE = AF_ROUTE;
553pub const PF_SNA = AF_SNA;
554pub const PF_MPLS = AF_MPLS;
555pub const PF_BLUETOOTH = AF_BLUETOOTH;
556pub const PF_ISDN = AF_ISDN;
557pub const PF_MAX = AF_MAX;
558
559pub const AF_UNSPEC = 0;
560pub const AF_UNIX = 1;
561pub const AF_LOCAL = AF_UNIX;
562pub const AF_INET = 2;
563pub const AF_APPLETALK = 16;
564pub const AF_INET6 = 24;
565pub const AF_KEY = 30;
566pub const AF_ROUTE = 17;
567pub const AF_SNA = 11;
568pub const AF_MPLS = 33;
569pub const AF_BLUETOOTH = 32;
570pub const AF_ISDN = 26;
571pub const AF_MAX = 36;
503pub const SOCK = struct {
504 pub const STREAM = 1;
505 pub const DGRAM = 2;
506 pub const RAW = 3;
507 pub const RDM = 4;
508 pub const SEQPACKET = 5;
509
510 pub const CLOEXEC = 0x8000;
511 pub const NONBLOCK = 0x4000;
512};
513
514pub const SO = struct {
515 pub const DEBUG = 0x0001;
516 pub const ACCEPTCONN = 0x0002;
517 pub const REUSEADDR = 0x0004;
518 pub const KEEPALIVE = 0x0008;
519 pub const DONTROUTE = 0x0010;
520 pub const BROADCAST = 0x0020;
521 pub const USELOOPBACK = 0x0040;
522 pub const LINGER = 0x0080;
523 pub const OOBINLINE = 0x0100;
524 pub const REUSEPORT = 0x0200;
525 pub const TIMESTAMP = 0x0800;
526 pub const BINDANY = 0x1000;
527 pub const ZEROIZE = 0x2000;
528 pub const SNDBUF = 0x1001;
529 pub const RCVBUF = 0x1002;
530 pub const SNDLOWAT = 0x1003;
531 pub const RCVLOWAT = 0x1004;
532 pub const SNDTIMEO = 0x1005;
533 pub const RCVTIMEO = 0x1006;
534 pub const ERROR = 0x1007;
535 pub const TYPE = 0x1008;
536 pub const NETPROC = 0x1020;
537 pub const RTABLE = 0x1021;
538 pub const PEERCRED = 0x1022;
539 pub const SPLICE = 0x1023;
540 pub const DOMAIN = 0x1024;
541 pub const PROTOCOL = 0x1025;
542};
543
544pub const SOL = struct {
545 pub const SOCKET = 0xffff;
546};
547
548pub const PF = struct {
549 pub const UNSPEC = AF.UNSPEC;
550 pub const LOCAL = AF.LOCAL;
551 pub const UNIX = AF.UNIX;
552 pub const INET = AF.INET;
553 pub const APPLETALK = AF.APPLETALK;
554 pub const INET6 = AF.INET6;
555 pub const DECnet = AF.DECnet;
556 pub const KEY = AF.KEY;
557 pub const ROUTE = AF.ROUTE;
558 pub const SNA = AF.SNA;
559 pub const MPLS = AF.MPLS;
560 pub const BLUETOOTH = AF.BLUETOOTH;
561 pub const ISDN = AF.ISDN;
562 pub const MAX = AF.MAX;
563};
564
565pub const AF = struct {
566 pub const UNSPEC = 0;
567 pub const UNIX = 1;
568 pub const LOCAL = UNIX;
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
573581pub const DT_UNKNOWN = 0;
574582pub const DT_FIFO = 1;
......@@ -1072,107 +1080,76 @@ pub const AT_REMOVEDIR = 0x08;
10721080
10731081pub const HOST_NAME_MAX = 255;
10741082
1075/// dummy for IP
1076pub const IPPROTO_IP = 0;
1077
1078/// IP6 hop-by-hop options
1079pub const IPPROTO_HOPOPTS = IPPROTO_IP;
1080
1081/// control message protocol
1082pub const IPPROTO_ICMP = 1;
1083
1084/// group mgmt protocol
1085pub const IPPROTO_IGMP = 2;
1086
1087/// gateway^2 (deprecated)
1088pub const IPPROTO_GGP = 3;
1089
1090/// IP header
1091pub const IPPROTO_IPV4 = IPPROTO_IPIP;
1092
1093/// IP inside IP
1094pub const IPPROTO_IPIP = 4;
1095
1096/// tcp
1097pub const IPPROTO_TCP = 6;
1098
1099/// exterior gateway protocol
1100pub const IPPROTO_EGP = 8;
1101
1102/// pup
1103pub const IPPROTO_PUP = 12;
1104
1105/// user datagram protocol
1106pub const IPPROTO_UDP = 17;
1107
1108/// xns idp
1109pub const IPPROTO_IDP = 22;
1110
1111/// tp-4 w/ class negotiation
1112pub const IPPROTO_TP = 29;
1113
1114/// IP6 header
1115pub const IPPROTO_IPV6 = 41;
1116
1117/// IP6 routing header
1118pub const IPPROTO_ROUTING = 43;
1119
1120/// IP6 fragmentation header
1121pub const IPPROTO_FRAGMENT = 44;
1122
1123/// resource reservation
1124pub const IPPROTO_RSVP = 46;
1125
1126/// GRE encaps RFC 1701
1127pub const IPPROTO_GRE = 47;
1128
1129/// encap. security payload
1130pub const IPPROTO_ESP = 50;
1131
1132/// authentication header
1133pub const IPPROTO_AH = 51;
1134
1135/// IP Mobility RFC 2004
1136pub const IPPROTO_MOBILE = 55;
1137
1138/// IPv6 ICMP
1139pub const IPPROTO_IPV6_ICMP = 58;
1140
1141/// ICMP6
1142pub const IPPROTO_ICMPV6 = 58;
1143
1144/// IP6 no next header
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;
1083pub const IPPROTO = struct {
1084 /// dummy for IP
1085 pub const IP = 0;
1086 /// IP6 hop-by-hop options
1087 pub const HOPOPTS = IP;
1088 /// control message protocol
1089 pub const ICMP = 1;
1090 /// group mgmt protocol
1091 pub const IGMP = 2;
1092 /// gateway^2 (deprecated)
1093 pub const GGP = 3;
1094 /// IP header
1095 pub const IPV4 = IPIP;
1096 /// IP inside IP
1097 pub const IPIP = 4;
1098 /// tcp
1099 pub const TCP = 6;
1100 /// exterior gateway protocol
1101 pub const EGP = 8;
1102 /// pup
1103 pub const PUP = 12;
1104 /// user datagram protocol
1105 pub const UDP = 17;
1106 /// xns idp
1107 pub const IDP = 22;
1108 /// tp-4 w/ class negotiation
1109 pub const TP = 29;
1110 /// IP6 header
1111 pub const IPV6 = 41;
1112 /// IP6 routing header
1113 pub const ROUTING = 43;
1114 /// IP6 fragmentation header
1115 pub const FRAGMENT = 44;
1116 /// resource reservation
1117 pub const RSVP = 46;
1118 /// GRE encaps RFC 1701
1119 pub const GRE = 47;
1120 /// encap. security payload
1121 pub const ESP = 50;
1122 /// authentication header
1123 pub const AH = 51;
1124 /// IP Mobility RFC 2004
1125 pub const MOBILE = 55;
1126 /// IPv6 ICMP
1127 pub const IPV6_ICMP = 58;
1128 /// ICMP6
1129 pub const ICMPV6 = 58;
1130 /// IP6 no next header
1131 pub const NONE = 59;
1132 /// IP6 destination option
1133 pub const DSTOPTS = 60;
1134 /// ISO cnlp
1135 pub const EON = 80;
1136 /// Ethernet-in-IP
1137 pub const ETHERIP = 97;
1138 /// encapsulation header
1139 pub const ENCAP = 98;
1140 /// Protocol indep. multicast
1141 pub const PIM = 103;
1142 /// IP Payload Comp. Protocol
1143 pub const IPCOMP = 108;
1144 /// VRRP RFC 2338
1145 pub const VRRP = 112;
1146 /// Common Address Resolution Protocol
1147 pub const CARP = 112;
1148 /// PFSYNC
1149 pub const PFSYNC = 240;
1150 /// raw IP packet
1151 pub const RAW = 255;
1152};
11761153
11771154pub const rlimit_resource = enum(c_int) {
11781155 CPU,
......@@ -1190,11 +1167,13 @@ pub const rlimit_resource = enum(c_int) {
11901167
11911168pub const rlim_t = u64;
11921169
1193/// No limit
1194pub const RLIM_INFINITY: rlim_t = (1 << 63) - 1;
1170pub const RLIM = struct {
1171 /// No limit
1172 pub const INFINITY: rlim_t = (1 << 63) - 1;
11951173
1196pub const RLIM_SAVED_MAX = RLIM_INFINITY;
1197pub const RLIM_SAVED_CUR = RLIM_INFINITY;
1174 pub const SAVED_MAX = INFINITY;
1175 pub const SAVED_CUR = INFINITY;
1176};
11981177
11991178pub const rlimit = extern struct {
12001179 /// Soft limit
......@@ -1215,17 +1194,19 @@ pub const pollfd = extern struct {
12151194 revents: c_short,
12161195};
12171196
1218pub const POLLIN = 0x0001;
1219pub const POLLPRI = 0x0002;
1220pub const POLLOUT = 0x0004;
1221pub const POLLERR = 0x0008;
1222pub const POLLHUP = 0x0010;
1223pub const POLLNVAL = 0x0020;
1224pub const POLLRDNORM = 0x0040;
1225pub const POLLNORM = POLLRDNORM;
1226pub const POLLWRNORM = POLLOUT;
1227pub const POLLRDBAND = 0x0080;
1228pub const POLLWRBAND = 0x0100;
1197pub const POLL = struct {
1198 pub const IN = 0x0001;
1199 pub const PRI = 0x0002;
1200 pub const OUT = 0x0004;
1201 pub const ERR = 0x0008;
1202 pub const HUP = 0x0010;
1203 pub const NVAL = 0x0020;
1204 pub const RDNORM = 0x0040;
1205 pub const NORM = RDNORM;
1206 pub const WRNORM = OUT;
1207 pub const RDBAND = 0x0080;
1208 pub const WRBAND = 0x0100;
1209};
12291210
12301211// sysctl mib
12311212pub const CTL_UNSPEC = 0;
lib/std/c/windows.zig+6-105
......@@ -198,121 +198,22 @@ pub const sa_family_t = ws2_32.ADDRESS_FAMILY;
198198pub const socklen_t = ws2_32.socklen_t;
199199
200200pub 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
205202pub const in6_addr = [16]u8;
206203pub const in_addr = u32;
207204
208205pub const addrinfo = ws2_32.addrinfo;
209
210pub const AF_UNSPEC = ws2_32.AF_UNSPEC;
211pub const AF_UNIX = ws2_32.AF_UNIX;
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;
206pub const AF = ws2_32.AF;
207pub const SOCK = ws2_32.SOCK;
208pub const IPPROTO = ws2_32.IPPROTOP;
263209pub 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
269211pub const nfds_t = c_ulong;
270212pub const pollfd = ws2_32.pollfd;
271
272pub const POLLRDNORM = ws2_32.POLLRDNORM;
273pub const POLLRDBAND = ws2_32.POLLRDBAND;
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
213pub const POLL = ws2_32.POLL;
214pub const SOL = ws2_32.SOL;
215pub const SO = ws2_32.SO;
313216pub const PVD_CONFIG = ws2_32.PVD_CONFIG;
314pub const SO_CONDITIONAL_ACCEPT = ws2_32.SO_CONDITIONAL_ACCEPT;
315
316217pub const TCP_NODELAY = ws2_32.TCP_NODELAY;
317218
318219pub const O_RDONLY = 0o0;
lib/std/child_process.zig+19-18
......@@ -7,6 +7,7 @@ const os = std.os;
77const process = std.process;
88const File = std.fs.File;
99const windows = os.windows;
10const linux = os.linux;
1011const mem = std.mem;
1112const math = std.math;
1213const debug = std.debug;
......@@ -189,8 +190,8 @@ pub const ChildProcess = struct {
189190 max_output_bytes: usize,
190191 ) !void {
191192 var poll_fds = [_]os.pollfd{
192 .{ .fd = child.stdout.?.handle, .events = os.POLLIN, .revents = undefined },
193 .{ .fd = child.stderr.?.handle, .events = os.POLLIN, .revents = undefined },
193 .{ .fd = child.stdout.?.handle, .events = os.POLL.IN, .revents = undefined },
194 .{ .fd = child.stderr.?.handle, .events = os.POLL.IN, .revents = undefined },
194195 };
195196
196197 var dead_fds: usize = 0;
......@@ -199,7 +200,7 @@ pub const ChildProcess = struct {
199200 // of space an ArrayList will allocate grows exponentially.
200201 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
204205 while (dead_fds < poll_fds.len) {
205206 const events = try os.poll(&poll_fds, std.math.maxInt(i32));
......@@ -209,9 +210,9 @@ pub const ChildProcess = struct {
209210 var remove_stderr = false;
210211 // Try reading whatever is available before checking the error
211212 // conditions.
212 // It's still possible to read after a POLLHUP is received, always
213 // It's still possible to read after a POLL.HUP is received, always
213214 // 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) {
215216 // stdout is ready.
216217 const new_capacity = std.math.min(stdout.items.len + bump_amt, max_output_bytes);
217218 try stdout.ensureCapacity(new_capacity);
......@@ -226,7 +227,7 @@ pub const ChildProcess = struct {
226227 remove_stdout = poll_fds[0].revents & err_mask != 0;
227228 }
228229
229 if (poll_fds[1].revents & os.POLLIN != 0) {
230 if (poll_fds[1].revents & os.POLL.IN != 0) {
230231 // stderr is ready.
231232 const new_capacity = std.math.min(stderr.items.len + bump_amt, max_output_bytes);
232233 try stderr.ensureCapacity(new_capacity);
......@@ -461,7 +462,7 @@ pub const ChildProcess = struct {
461462 if (builtin.os.tag == .linux) {
462463 var fd = [1]std.os.pollfd{std.os.pollfd{
463464 .fd = self.err_pipe[0],
464 .events = std.os.POLLIN,
465 .events = std.os.POLL.IN,
465466 .revents = undefined,
466467 }};
467468
......@@ -471,7 +472,7 @@ pub const ChildProcess = struct {
471472
472473 // According to eventfd(2) the descriptro is readable if the counter
473474 // 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) {
475476 const err_int = try readIntFd(self.err_pipe[0]);
476477 return @errSetCast(SpawnError, @intToError(err_int));
477478 }
......@@ -494,18 +495,18 @@ pub const ChildProcess = struct {
494495 }
495496
496497 fn statusToTerm(status: u32) Term {
497 return if (os.WIFEXITED(status))
498 Term{ .Exited = os.WEXITSTATUS(status) }
499 else if (os.WIFSIGNALED(status))
500 Term{ .Signal = os.WTERMSIG(status) }
501 else if (os.WIFSTOPPED(status))
502 Term{ .Stopped = os.WSTOPSIG(status) }
498 return if (os.W.IFEXITED(status))
499 Term{ .Exited = os.W.EXITSTATUS(status) }
500 else if (os.W.IFSIGNALED(status))
501 Term{ .Signal = os.W.TERMSIG(status) }
502 else if (os.W.IFSTOPPED(status))
503 Term{ .Stopped = os.W.STOPSIG(status) }
503504 else
504505 Term{ .Unknown = status };
505506 }
506507
507508 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;
509510 const stdin_pipe = if (self.stdin_behavior == StdIo.Pipe) try os.pipe2(pipe_flags) else undefined;
510511 errdefer if (self.stdin_behavior == StdIo.Pipe) {
511512 destroyPipe(stdin_pipe);
......@@ -523,7 +524,7 @@ pub const ChildProcess = struct {
523524
524525 const any_ignore = (self.stdin_behavior == StdIo.Ignore or self.stdout_behavior == StdIo.Ignore or self.stderr_behavior == StdIo.Ignore);
525526 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) {
527528 error.PathAlreadyExists => unreachable,
528529 error.NoSpaceLeft => unreachable,
529530 error.FileTooBig => unreachable,
......@@ -575,12 +576,12 @@ pub const ChildProcess = struct {
575576 // and execve from the child process to the parent process.
576577 const err_pipe = blk: {
577578 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);
579580 // There's no distinction between the readable and the writeable
580581 // end with eventfd
581582 break :blk [2]os.fd_t{ fd, fd };
582583 } else {
583 break :blk try os.pipe2(os.O_CLOEXEC);
584 break :blk try os.pipe2(os.O.CLOEXEC);
584585 }
585586 };
586587 errdefer destroyPipe(err_pipe);
lib/std/crypto/tlcsprng.zig+3-3
......@@ -74,8 +74,8 @@ fn tlsCsprngFill(_: *const std.rand.Random, buffer: []u8) void {
7474 wipe_mem = os.mmap(
7575 null,
7676 @sizeOf(Context),
77 os.PROT_READ | os.PROT_WRITE,
78 os.MAP_PRIVATE | os.MAP_ANONYMOUS,
77 os.PROT.READ | os.PROT.WRITE,
78 os.MAP.PRIVATE | os.MAP.ANONYMOUS,
7979 -1,
8080 0,
8181 ) catch {
......@@ -111,7 +111,7 @@ fn tlsCsprngFill(_: *const std.rand.Random, buffer: []u8) void {
111111 break :wof;
112112 } 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)) |_| {
115115 return initAndFill(buffer);
116116 } else |_| {}
117117 }
lib/std/dynamic_library.zig+13-13
......@@ -115,7 +115,7 @@ pub const ElfDynLib = struct {
115115
116116 /// Trusts the file. Malicious file will be able to execute arbitrary code.
117117 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);
119119 defer os.close(fd);
120120
121121 const stat = try os.fstat(fd);
......@@ -126,8 +126,8 @@ pub const ElfDynLib = struct {
126126 const file_bytes = try os.mmap(
127127 null,
128128 mem.alignForward(size, mem.page_size),
129 os.PROT_READ,
130 os.MAP_PRIVATE,
129 os.PROT.READ,
130 os.MAP.PRIVATE,
131131 fd,
132132 0,
133133 );
......@@ -160,12 +160,12 @@ pub const ElfDynLib = struct {
160160 }
161161 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.
164164 const all_loaded_mem = try os.mmap(
165165 null,
166166 virt_addr_end,
167 os.PROT_NONE,
168 os.MAP_PRIVATE | os.MAP_ANONYMOUS,
167 os.PROT.NONE,
168 os.MAP.PRIVATE | os.MAP.ANONYMOUS,
169169 -1,
170170 0,
171171 );
......@@ -197,7 +197,7 @@ pub const ElfDynLib = struct {
197197 ptr,
198198 extended_memsz,
199199 prot,
200 os.MAP_PRIVATE | os.MAP_FIXED,
200 os.MAP.PRIVATE | os.MAP.FIXED,
201201 fd,
202202 ph.p_offset - extra_bytes,
203203 );
......@@ -206,7 +206,7 @@ pub const ElfDynLib = struct {
206206 ptr,
207207 extended_memsz,
208208 prot,
209 os.MAP_PRIVATE | os.MAP_FIXED | os.MAP_ANONYMOUS,
209 os.MAP.PRIVATE | os.MAP.FIXED | os.MAP.ANONYMOUS,
210210 -1,
211211 0,
212212 );
......@@ -294,10 +294,10 @@ pub const ElfDynLib = struct {
294294 }
295295
296296 fn elfToMmapProt(elf_prot: u64) u32 {
297 var result: u32 = os.PROT_NONE;
298 if ((elf_prot & elf.PF_R) != 0) result |= os.PROT_READ;
299 if ((elf_prot & elf.PF_W) != 0) result |= os.PROT_WRITE;
300 if ((elf_prot & elf.PF_X) != 0) result |= os.PROT_EXEC;
297 var result: u32 = os.PROT.NONE;
298 if ((elf_prot & elf.PF_R) != 0) result |= os.PROT.READ;
299 if ((elf_prot & elf.PF_W) != 0) result |= os.PROT.WRITE;
300 if ((elf_prot & elf.PF_X) != 0) result |= os.PROT.EXEC;
301301 return result;
302302 }
303303};
......@@ -373,7 +373,7 @@ pub const DlDynlib = struct {
373373
374374 pub fn openZ(path_c: [*:0]const u8) !DlDynlib {
375375 return DlDynlib{
376 .handle = system.dlopen(path_c, system.RTLD_LAZY) orelse {
376 .handle = system.dlopen(path_c, system.RTLD.LAZY) orelse {
377377 return error.FileNotFound;
378378 },
379379 };
lib/std/event/loop.zig+4-4
......@@ -457,8 +457,8 @@ pub const Loop = struct {
457457 // Fall back to a blocking poll(). Ideally this codepath is never hit, since
458458 // epoll should be just fine. But this is better than incorrect behavior.
459459 var poll_flags: i16 = 0;
460 if ((flags & os.EPOLLIN) != 0) poll_flags |= os.POLLIN;
461 if ((flags & os.EPOLLOUT) != 0) poll_flags |= os.POLLOUT;
460 if ((flags & os.EPOLLIN) != 0) poll_flags |= os.POLL.IN;
461 if ((flags & os.EPOLLOUT) != 0) poll_flags |= os.POLL.OUT;
462462 var pfd = [1]os.pollfd{os.pollfd{
463463 .fd = fd,
464464 .events = poll_flags,
......@@ -903,12 +903,12 @@ pub const Loop = struct {
903903 /// will return a value greater than was supplied to the call.
904904 addr_size: *os.socklen_t,
905905 /// 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 the
906 /// * `SOCK.CLOEXEC` - Set the close-on-exec (`FD_CLOEXEC`) flag on the new file descriptor. See the
907907 /// description of the `O_CLOEXEC` flag in `open` for reasons why this may be useful.
908908 flags: u32,
909909 ) os.AcceptError!os.socket_t {
910910 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) {
912912 error.WouldBlock => {
913913 self.waitUntilFdReadable(sockfd);
914914 continue;
lib/std/fs.zig+23-22
......@@ -500,13 +500,14 @@ pub const Dir = struct {
500500 },
501501 .linux => struct {
502502 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`
504504 // 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)),
506506 index: usize,
507507 end_index: usize,
508508
509509 const Self = @This();
510 const linux = os.linux;
510511
511512 pub const Error = IteratorError;
512513
......@@ -515,8 +516,8 @@ pub const Dir = struct {
515516 pub fn next(self: *Self) Error!?Entry {
516517 start_over: while (true) {
517518 if (self.index >= self.end_index) {
518 const rc = os.linux.getdents64(self.dir.fd, &self.buf, self.buf.len);
519 switch (os.linux.getErrno(rc)) {
519 const rc = linux.getdents64(self.dir.fd, &self.buf, self.buf.len);
520 switch (linux.getErrno(rc)) {
520521 .SUCCESS => {},
521522 .BADF => unreachable, // Dir is invalid or was opened without iteration ability
522523 .FAULT => unreachable,
......@@ -528,7 +529,7 @@ pub const Dir = struct {
528529 self.index = 0;
529530 self.end_index = rc;
530531 }
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]);
532533 const next_index = self.index + linux_entry.reclen();
533534 self.index = next_index;
534535
......@@ -540,13 +541,13 @@ pub const Dir = struct {
540541 }
541542
542543 const entry_kind = switch (linux_entry.d_type) {
543 os.DT_BLK => Entry.Kind.BlockDevice,
544 os.DT_CHR => Entry.Kind.CharacterDevice,
545 os.DT_DIR => Entry.Kind.Directory,
546 os.DT_FIFO => Entry.Kind.NamedPipe,
547 os.DT_LNK => Entry.Kind.SymLink,
548 os.DT_REG => Entry.Kind.File,
549 os.DT_SOCK => Entry.Kind.UnixDomainSocket,
544 linux.DT.BLK => Entry.Kind.BlockDevice,
545 linux.DT.CHR => Entry.Kind.CharacterDevice,
546 linux.DT.DIR => Entry.Kind.Directory,
547 linux.DT.FIFO => Entry.Kind.NamedPipe,
548 linux.DT.LNK => Entry.Kind.SymLink,
549 linux.DT.REG => Entry.Kind.File,
550 linux.DT.SOCK => Entry.Kind.UnixDomainSocket,
550551 else => Entry.Kind.Unknown,
551552 };
552553 return Entry{
......@@ -1537,7 +1538,7 @@ pub const Dir = struct {
15371538 return self.deleteFileW(sub_path_w.span());
15381539 } else if (builtin.os.tag == .wasi and !builtin.link_libc) {
15391540 os.unlinkatWasi(self.fd, sub_path, 0) catch |err| switch (err) {
1540 error.DirNotEmpty => unreachable, // not passing AT_REMOVEDIR
1541 error.DirNotEmpty => unreachable, // not passing AT.REMOVEDIR
15411542 else => |e| return e,
15421543 };
15431544 } else {
......@@ -1551,13 +1552,13 @@ pub const Dir = struct {
15511552 /// Same as `deleteFile` except the parameter is null-terminated.
15521553 pub fn deleteFileZ(self: Dir, sub_path_c: [*:0]const u8) DeleteFileError!void {
15531554 os.unlinkatZ(self.fd, sub_path_c, 0) catch |err| switch (err) {
1554 error.DirNotEmpty => unreachable, // not passing AT_REMOVEDIR
1555 error.DirNotEmpty => unreachable, // not passing AT.REMOVEDIR
15551556 error.AccessDenied => |e| switch (builtin.os.tag) {
15561557 // non-Linux POSIX systems return EPERM when trying to delete a directory, so
15571558 // we need to handle that case specifically and translate the error
15581559 .macos, .ios, .freebsd, .netbsd, .dragonfly, .openbsd => {
15591560 // 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;
15611562 const is_dir = fstat.mode & os.S_IFMT == os.S_IFDIR;
15621563 return if (is_dir) error.IsDir else e;
15631564 },
......@@ -1570,7 +1571,7 @@ pub const Dir = struct {
15701571 /// Same as `deleteFile` except the parameter is WTF-16 encoded.
15711572 pub fn deleteFileW(self: Dir, sub_path_w: []const u16) DeleteFileError!void {
15721573 os.unlinkatW(self.fd, sub_path_w, 0) catch |err| switch (err) {
1573 error.DirNotEmpty => unreachable, // not passing AT_REMOVEDIR
1574 error.DirNotEmpty => unreachable, // not passing AT.REMOVEDIR
15741575 else => |e| return e,
15751576 };
15761577 }
......@@ -1599,8 +1600,8 @@ pub const Dir = struct {
15991600 const sub_path_w = try os.windows.sliceToPrefixedFileW(sub_path);
16001601 return self.deleteDirW(sub_path_w.span());
16011602 } 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 error.IsDir => unreachable, // not possible since we pass AT_REMOVEDIR
1603 os.unlinkat(self.fd, sub_path, os.AT.REMOVEDIR) catch |err| switch (err) {
1604 error.IsDir => unreachable, // not possible since we pass AT.REMOVEDIR
16041605 else => |e| return e,
16051606 };
16061607 } else {
......@@ -1611,8 +1612,8 @@ pub const Dir = struct {
16111612
16121613 /// Same as `deleteDir` except the parameter is null-terminated.
16131614 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 error.IsDir => unreachable, // not possible since we pass AT_REMOVEDIR
1615 os.unlinkatZ(self.fd, sub_path_c, os.AT.REMOVEDIR) catch |err| switch (err) {
1616 error.IsDir => unreachable, // not possible since we pass AT.REMOVEDIR
16161617 else => |e| return e,
16171618 };
16181619 }
......@@ -1620,8 +1621,8 @@ pub const Dir = struct {
16201621 /// Same as `deleteDir` except the parameter is UTF16LE, NT prefixed.
16211622 /// This function is Windows-only.
16221623 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 error.IsDir => unreachable, // not possible since we pass AT_REMOVEDIR
1624 os.unlinkatW(self.fd, sub_path_w, os.AT.REMOVEDIR) catch |err| switch (err) {
1625 error.IsDir => unreachable, // not possible since we pass AT.REMOVEDIR
16251626 else => |e| return e,
16261627 };
16271628 }
lib/std/fs/file.zig+8-8
......@@ -883,9 +883,9 @@ pub const File = struct {
883883 };
884884 } else {
885885 return os.flock(file.handle, switch (l) {
886 .None => os.LOCK_UN,
887 .Shared => os.LOCK_SH,
888 .Exclusive => os.LOCK_EX,
886 .None => os.LOCK.UN,
887 .Shared => os.LOCK.SH,
888 .Exclusive => os.LOCK.EX,
889889 }) catch |err| switch (err) {
890890 error.WouldBlock => unreachable, // non-blocking=false
891891 else => |e| return e,
......@@ -908,7 +908,7 @@ pub const File = struct {
908908 error.Unexpected => unreachable, // Resource deallocation must succeed.
909909 };
910910 } 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) {
912912 error.WouldBlock => unreachable, // unlocking can't block
913913 error.SystemResources => unreachable, // We are deallocating resources.
914914 error.Unexpected => unreachable, // Resource deallocation must succeed.
......@@ -949,9 +949,9 @@ pub const File = struct {
949949 };
950950 } else {
951951 os.flock(file.handle, switch (l) {
952 .None => os.LOCK_UN,
953 .Shared => os.LOCK_SH | os.LOCK_NB,
954 .Exclusive => os.LOCK_EX | os.LOCK_NB,
952 .None => os.LOCK.UN,
953 .Shared => os.LOCK.SH | os.LOCK.NB,
954 .Exclusive => os.LOCK.EX | os.LOCK.NB,
955955 }) catch |err| switch (err) {
956956 error.WouldBlock => return false,
957957 else => |e| return e,
......@@ -998,7 +998,7 @@ pub const File = struct {
998998 error.Unexpected => unreachable, // Resource deallocation must succeed.
999999 };
10001000 } 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) {
10021002 error.WouldBlock => unreachable, // File was not locked in exclusive mode.
10031003 else => |e| return e,
10041004 };
lib/std/net.zig+97-97
......@@ -10,7 +10,7 @@ const native_endian = builtin.target.cpu.arch.endian();
1010
1111// Windows 10 added support for unix sockets in build 17063, redstone 4 is the
1212// first release to support them.
13pub const has_unix_sockets = @hasDecl(os, "sockaddr_un") and
13pub const has_unix_sockets = @hasDecl(os.sockaddr, "un") and
1414 (builtin.target.os.tag != .windows or
1515 std.Target.current.os.version_range.windows.isAtLeast(.win10_rs4) orelse false);
1616
......@@ -18,7 +18,7 @@ pub const Address = extern union {
1818 any: os.sockaddr,
1919 in: Ip4Address,
2020 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
2323 /// Parse the given IP address string into an Address value.
2424 /// It is recommended to use `resolveIp` instead, to handle
......@@ -70,9 +70,9 @@ pub const Address = extern union {
7070
7171 pub fn parseExpectingFamily(name: []const u8, family: os.sa_family_t, port: u16) !Address {
7272 switch (family) {
73 os.AF_INET => return parseIp4(name, port),
74 os.AF_INET6 => return parseIp6(name, port),
75 os.AF_UNSPEC => return parseIp(name, port),
73 os.AF.INET => return parseIp4(name, port),
74 os.AF.INET6 => return parseIp6(name, port),
75 os.AF.UNSPEC => return parseIp(name, port),
7676 else => unreachable,
7777 }
7878 }
......@@ -98,8 +98,8 @@ pub const Address = extern union {
9898 }
9999
100100 pub fn initUnix(path: []const u8) !Address {
101 var sock_addr = os.sockaddr_un{
102 .family = os.AF_UNIX,
101 var sock_addr = os.sockaddr.un{
102 .family = os.AF.UNIX,
103103 .path = undefined,
104104 };
105105
......@@ -116,8 +116,8 @@ pub const Address = extern union {
116116 /// Asserts that the address is ip4 or ip6.
117117 pub fn getPort(self: Address) u16 {
118118 return switch (self.any.family) {
119 os.AF_INET => self.in.getPort(),
120 os.AF_INET6 => self.in6.getPort(),
119 os.AF.INET => self.in.getPort(),
120 os.AF.INET6 => self.in6.getPort(),
121121 else => unreachable,
122122 };
123123 }
......@@ -126,8 +126,8 @@ pub const Address = extern union {
126126 /// Asserts that the address is ip4 or ip6.
127127 pub fn setPort(self: *Address, port: u16) void {
128128 switch (self.any.family) {
129 os.AF_INET => self.in.setPort(port),
130 os.AF_INET6 => self.in6.setPort(port),
129 os.AF.INET => self.in.setPort(port),
130 os.AF.INET6 => self.in6.setPort(port),
131131 else => unreachable,
132132 }
133133 }
......@@ -137,8 +137,8 @@ pub const Address = extern union {
137137 /// on the address family.
138138 pub fn initPosix(addr: *align(4) const os.sockaddr) Address {
139139 switch (addr.family) {
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).* } },
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).* } },
142142 else => unreachable,
143143 }
144144 }
......@@ -150,9 +150,9 @@ pub const Address = extern union {
150150 out_stream: anytype,
151151 ) !void {
152152 switch (self.any.family) {
153 os.AF_INET => try self.in.format(fmt, options, out_stream),
154 os.AF_INET6 => try self.in6.format(fmt, options, out_stream),
155 os.AF_UNIX => {
153 os.AF.INET => try self.in.format(fmt, options, out_stream),
154 os.AF.INET6 => try self.in6.format(fmt, options, out_stream),
155 os.AF.UNIX => {
156156 if (!has_unix_sockets) {
157157 unreachable;
158158 }
......@@ -171,15 +171,15 @@ pub const Address = extern union {
171171
172172 pub fn getOsSockLen(self: Address) os.socklen_t {
173173 switch (self.any.family) {
174 os.AF_INET => return self.in.getOsSockLen(),
175 os.AF_INET6 => return self.in6.getOsSockLen(),
176 os.AF_UNIX => {
174 os.AF.INET => return self.in.getOsSockLen(),
175 os.AF.INET6 => return self.in6.getOsSockLen(),
176 os.AF.UNIX => {
177177 if (!has_unix_sockets) {
178178 unreachable;
179179 }
180180
181181 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);
183183 },
184184 else => unreachable,
185185 }
......@@ -187,7 +187,7 @@ pub const Address = extern union {
187187};
188188
189189pub const Ip4Address = extern struct {
190 sa: os.sockaddr_in,
190 sa: os.sockaddr.in,
191191
192192 pub fn parse(buf: []const u8, port: u16) !Ip4Address {
193193 var result = Ip4Address{
......@@ -249,7 +249,7 @@ pub const Ip4Address = extern struct {
249249
250250 pub fn init(addr: [4]u8, port: u16) Ip4Address {
251251 return Ip4Address{
252 .sa = os.sockaddr_in{
252 .sa = os.sockaddr.in{
253253 .port = mem.nativeToBig(u16, port),
254254 .addr = @ptrCast(*align(1) const u32, &addr).*,
255255 },
......@@ -288,19 +288,19 @@ pub const Ip4Address = extern struct {
288288
289289 pub fn getOsSockLen(self: Ip4Address) os.socklen_t {
290290 _ = self;
291 return @sizeOf(os.sockaddr_in);
291 return @sizeOf(os.sockaddr.in);
292292 }
293293};
294294
295295pub const Ip6Address = extern struct {
296 sa: os.sockaddr_in6,
296 sa: os.sockaddr.in6,
297297
298298 /// Parse a given IPv6 address string into an Address.
299299 /// Assumes the Scope ID of the address is fully numeric.
300300 /// For non-numeric addresses, see `resolveIp6`.
301301 pub fn parse(buf: []const u8, port: u16) !Ip6Address {
302302 var result = Ip6Address{
303 .sa = os.sockaddr_in6{
303 .sa = os.sockaddr.in6{
304304 .scope_id = 0,
305305 .port = mem.nativeToBig(u16, port),
306306 .flowinfo = 0,
......@@ -407,7 +407,7 @@ pub const Ip6Address = extern struct {
407407 pub fn resolve(buf: []const u8, port: u16) !Ip6Address {
408408 // TODO: Unify the implementations of resolveIp6 and parseIp6.
409409 var result = Ip6Address{
410 .sa = os.sockaddr_in6{
410 .sa = os.sockaddr.in6{
411411 .scope_id = 0,
412412 .port = mem.nativeToBig(u16, port),
413413 .flowinfo = 0,
......@@ -536,7 +536,7 @@ pub const Ip6Address = extern struct {
536536
537537 pub fn init(addr: [16]u8, port: u16, flowinfo: u32, scope_id: u32) Ip6Address {
538538 return Ip6Address{
539 .sa = os.sockaddr_in6{
539 .sa = os.sockaddr.in6{
540540 .addr = addr,
541541 .port = mem.nativeToBig(u16, port),
542542 .flowinfo = flowinfo,
......@@ -608,15 +608,15 @@ pub const Ip6Address = extern struct {
608608
609609 pub fn getOsSockLen(self: Ip6Address) os.socklen_t {
610610 _ = self;
611 return @sizeOf(os.sockaddr_in6);
611 return @sizeOf(os.sockaddr.in6);
612612 }
613613};
614614
615615pub 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;
617617 const sockfd = try os.socket(
618 os.AF_UNIX,
619 os.SOCK_STREAM | os.SOCK_CLOEXEC | opt_non_block,
618 os.AF.UNIX,
619 os.SOCK.STREAM | os.SOCK.CLOEXEC | opt_non_block,
620620 0,
621621 );
622622 errdefer os.closeSocket(sockfd);
......@@ -637,7 +637,7 @@ pub fn connectUnixSocket(path: []const u8) !Stream {
637637
638638fn if_nametoindex(name: []const u8) !u32 {
639639 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);
641641 defer os.closeSocket(sockfd);
642642
643643 std.mem.copy(u8, &ifr.ifrn.name, name);
......@@ -682,10 +682,10 @@ pub fn tcpConnectToHost(allocator: *mem.Allocator, name: []const u8, port: u16)
682682}
683683
684684pub fn tcpConnectToAddress(address: Address) !Stream {
685 const nonblock = if (std.io.is_async) os.SOCK_NONBLOCK else 0;
686 const sock_flags = os.SOCK_STREAM | nonblock |
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);
685 const nonblock = if (std.io.is_async) os.SOCK.NONBLOCK else 0;
686 const sock_flags = os.SOCK.STREAM | nonblock |
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);
689689 errdefer os.closeSocket(sockfd);
690690
691691 if (std.io.is_async) {
......@@ -724,10 +724,10 @@ pub fn getAddressList(allocator: *mem.Allocator, name: []const u8, port: u16) !*
724724
725725 const sys = if (builtin.target.os.tag == .windows) os.windows.ws2_32 else os.system;
726726 const hints = os.addrinfo{
727 .flags = sys.AI_NUMERICSERV,
728 .family = os.AF_UNSPEC,
729 .socktype = os.SOCK_STREAM,
730 .protocol = os.IPPROTO_TCP,
727 .flags = sys.AI.NUMERICSERV,
728 .family = os.AF.UNSPEC,
729 .socktype = os.SOCK.STREAM,
730 .protocol = os.IPPROTO.TCP,
731731 .canonname = null,
732732 .addr = null,
733733 .addrlen = 0,
......@@ -794,8 +794,8 @@ pub fn getAddressList(allocator: *mem.Allocator, name: []const u8, port: u16) !*
794794 return result;
795795 }
796796 if (builtin.target.os.tag == .linux) {
797 const flags = std.c.AI_NUMERICSERV;
798 const family = os.AF_UNSPEC;
797 const flags = std.c.AI.NUMERICSERV;
798 const family = os.AF.UNSPEC;
799799 var lookup_addrs = std.ArrayList(LookupAddr).init(allocator);
800800 defer lookup_addrs.deinit();
801801
......@@ -846,7 +846,7 @@ fn linuxLookupName(
846846 try canon.appendSlice(name);
847847 if (Address.parseExpectingFamily(name, family, port)) |addr| {
848848 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) {
850850 return name_err;
851851 } else {
852852 try linuxLookupNameFromHosts(addrs, canon, name, family, port);
......@@ -876,9 +876,9 @@ fn linuxLookupName(
876876
877877 // No further processing is needed if there are fewer than 2
878878 // 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;
880880 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;
882882 } else true;
883883 if (all_ip4) return;
884884
......@@ -891,19 +891,19 @@ fn linuxLookupName(
891891 // A more idiomatic "ziggy" implementation would be welcome.
892892 for (addrs.items) |*addr, i| {
893893 var key: i32 = 0;
894 var sa6: os.sockaddr_in6 = undefined;
895 @memset(@ptrCast([*]u8, &sa6), 0, @sizeOf(os.sockaddr_in6));
896 var da6 = os.sockaddr_in6{
897 .family = os.AF_INET6,
894 var sa6: os.sockaddr.in6 = undefined;
895 @memset(@ptrCast([*]u8, &sa6), 0, @sizeOf(os.sockaddr.in6));
896 var da6 = os.sockaddr.in6{
897 .family = os.AF.INET6,
898898 .scope_id = addr.addr.in6.sa.scope_id,
899899 .port = 65535,
900900 .flowinfo = 0,
901901 .addr = [1]u8{0} ** 16,
902902 };
903 var sa4: os.sockaddr_in = undefined;
904 @memset(@ptrCast([*]u8, &sa4), 0, @sizeOf(os.sockaddr_in));
905 var da4 = os.sockaddr_in{
906 .family = os.AF_INET,
903 var sa4: os.sockaddr.in = undefined;
904 @memset(@ptrCast([*]u8, &sa4), 0, @sizeOf(os.sockaddr.in));
905 var da4 = os.sockaddr.in{
906 .family = os.AF.INET,
907907 .port = 65535,
908908 .addr = 0,
909909 .zero = [1]u8{0} ** 8,
......@@ -912,21 +912,21 @@ fn linuxLookupName(
912912 var da: *align(4) os.sockaddr = undefined;
913913 var salen: os.socklen_t = undefined;
914914 var dalen: os.socklen_t = undefined;
915 if (addr.addr.any.family == os.AF_INET6) {
915 if (addr.addr.any.family == os.AF.INET6) {
916916 mem.copy(u8, &da6.addr, &addr.addr.in6.sa.addr);
917917 da = @ptrCast(*os.sockaddr, &da6);
918 dalen = @sizeOf(os.sockaddr_in6);
918 dalen = @sizeOf(os.sockaddr.in6);
919919 sa = @ptrCast(*os.sockaddr, &sa6);
920 salen = @sizeOf(os.sockaddr_in6);
920 salen = @sizeOf(os.sockaddr.in6);
921921 } else {
922922 mem.copy(u8, &sa6.addr, "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff");
923923 mem.copy(u8, &da6.addr, "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff");
924924 mem.writeIntNative(u32, da6.addr[12..], addr.addr.in.sa.addr);
925925 da4.addr = addr.addr.in.sa.addr;
926926 da = @ptrCast(*os.sockaddr, &da4);
927 dalen = @sizeOf(os.sockaddr_in);
927 dalen = @sizeOf(os.sockaddr.in);
928928 sa = @ptrCast(*os.sockaddr, &sa4);
929 salen = @sizeOf(os.sockaddr_in);
929 salen = @sizeOf(os.sockaddr.in);
930930 }
931931 const dpolicy = policyOf(da6.addr);
932932 const dscope: i32 = scopeOf(da6.addr);
......@@ -934,13 +934,13 @@ fn linuxLookupName(
934934 const dprec: i32 = dpolicy.prec;
935935 const MAXADDRS = 3;
936936 var prefixlen: i32 = 0;
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: {
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: {
939939 defer os.closeSocket(fd);
940940 os.connect(fd, da, dalen) catch break :syscalls;
941941 key |= DAS_USABLE;
942942 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) {
944944 // TODO sa6.addr[12..16] should return *[4]u8, making this cast unnecessary.
945945 mem.writeIntNative(u32, @ptrCast(*[4]u8, &sa6.addr[12]), sa4.addr);
946946 }
......@@ -1082,24 +1082,24 @@ fn linuxLookupNameFromNull(
10821082 flags: u32,
10831083 port: u16,
10841084) !void {
1085 if ((flags & std.c.AI_PASSIVE) != 0) {
1086 if (family != os.AF_INET6) {
1085 if ((flags & std.c.AI.PASSIVE) != 0) {
1086 if (family != os.AF.INET6) {
10871087 (try addrs.addOne()).* = LookupAddr{
10881088 .addr = Address.initIp4([1]u8{0} ** 4, port),
10891089 };
10901090 }
1091 if (family != os.AF_INET) {
1091 if (family != os.AF.INET) {
10921092 (try addrs.addOne()).* = LookupAddr{
10931093 .addr = Address.initIp6([1]u8{0} ** 16, port, 0, 0),
10941094 };
10951095 }
10961096 } else {
1097 if (family != os.AF_INET6) {
1097 if (family != os.AF.INET6) {
10981098 (try addrs.addOne()).* = LookupAddr{
10991099 .addr = Address.initIp4([4]u8{ 127, 0, 0, 1 }, port),
11001100 };
11011101 }
1102 if (family != os.AF_INET) {
1102 if (family != os.AF.INET) {
11031103 (try addrs.addOne()).* = LookupAddr{
11041104 .addr = Address.initIp6(([1]u8{0} ** 15) ++ [1]u8{1}, port, 0, 0),
11051105 };
......@@ -1252,8 +1252,8 @@ fn linuxLookupNameFromDns(
12521252 rr: u8,
12531253 };
12541254 const afrrs = [_]AfRr{
1255 AfRr{ .af = os.AF_INET6, .rr = os.RR_A },
1256 AfRr{ .af = os.AF_INET, .rr = os.RR_AAAA },
1255 AfRr{ .af = os.AF.INET6, .rr = os.RR.A },
1256 AfRr{ .af = os.AF.INET, .rr = os.RR.AAAA },
12571257 };
12581258 var qbuf: [2][280]u8 = undefined;
12591259 var abuf: [2][512]u8 = undefined;
......@@ -1386,8 +1386,8 @@ fn resMSendRc(
13861386 const timeout = 1000 * rc.timeout;
13871387 const attempts = rc.attempts;
13881388
1389 var sl: os.socklen_t = @sizeOf(os.sockaddr_in);
1390 var family: os.sa_family_t = os.AF_INET;
1389 var sl: os.socklen_t = @sizeOf(os.sockaddr.in);
1390 var family: os.sa_family_t = os.AF.INET;
13911391
13921392 var ns_list = std.ArrayList(Address).init(rc.ns.allocator);
13931393 defer ns_list.deinit();
......@@ -1398,9 +1398,9 @@ fn resMSendRc(
13981398 for (rc.ns.items) |iplit, i| {
13991399 ns[i] = iplit.addr;
14001400 assert(ns[i].getPort() == 53);
1401 if (iplit.addr.any.family != os.AF_INET) {
1402 sl = @sizeOf(os.sockaddr_in6);
1403 family = os.AF_INET6;
1401 if (iplit.addr.any.family != os.AF.INET) {
1402 sl = @sizeOf(os.sockaddr.in6);
1403 family = os.AF.INET6;
14041404 }
14051405 }
14061406
......@@ -1408,13 +1408,13 @@ fn resMSendRc(
14081408 var sa: Address = undefined;
14091409 @memset(@ptrCast([*]u8, &sa), 0, @sizeOf(Address));
14101410 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;
14121412 const fd = os.socket(family, flags, 0) catch |err| switch (err) {
14131413 error.AddressFamilyNotSupported => blk: {
14141414 // Handle case where system lacks IPv6 support
1415 if (family == os.AF_INET6) {
1416 family = os.AF_INET;
1417 break :blk try os.socket(os.AF_INET, flags, 0);
1415 if (family == os.AF.INET6) {
1416 family = os.AF.INET;
1417 break :blk try os.socket(os.AF.INET, flags, 0);
14181418 }
14191419 return err;
14201420 },
......@@ -1429,15 +1429,15 @@ fn resMSendRc(
14291429
14301430 // Convert any IPv4 addresses in a mixed environment to v4-mapped
14311431 // TODO
1432 //if (family == AF_INET6) {
1433 // setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &(int){0}, sizeof 0);
1432 //if (family == AF.INET6) {
1433 // setsockopt(fd, IPPROTO.IPV6, IPV6_V6ONLY, &(int){0}, sizeof 0);
14341434 // 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;
14361436 // memcpy(ns[i].sin6.sin6_addr.s6_addr+12,
14371437 // &ns[i].sin.sin_addr, 4);
14381438 // memcpy(ns[i].sin6.sin6_addr.s6_addr,
14391439 // "\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;
14411441 // ns[i].sin6.sin6_flowinfo = 0;
14421442 // ns[i].sin6.sin6_scope_id = 0;
14431443 // }
......@@ -1445,7 +1445,7 @@ fn resMSendRc(
14451445
14461446 var pfd = [1]os.pollfd{os.pollfd{
14471447 .fd = fd,
1448 .events = os.POLLIN,
1448 .events = os.POLL.IN,
14491449 .revents = undefined,
14501450 }};
14511451 const retry_interval = timeout / attempts;
......@@ -1465,9 +1465,9 @@ fn resMSendRc(
14651465 var j: usize = 0;
14661466 while (j < ns.len) : (j += 1) {
14671467 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;
14691469 } 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;
14711471 }
14721472 }
14731473 }
......@@ -1513,9 +1513,9 @@ fn resMSendRc(
15131513 2 => if (servfail_retry != 0) {
15141514 servfail_retry -= 1;
15151515 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;
15171517 } 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;
15191519 }
15201520 },
15211521 else => continue,
......@@ -1570,21 +1570,21 @@ fn dnsParse(
15701570
15711571fn dnsParseCallback(ctx: dpc_ctx, rr: u8, data: []const u8, packet: []const u8) !void {
15721572 switch (rr) {
1573 os.RR_A => {
1573 os.RR.A => {
15741574 if (data.len != 4) return error.InvalidDnsARecord;
15751575 const new_addr = try ctx.addrs.addOne();
15761576 new_addr.* = LookupAddr{
15771577 .addr = Address.initIp4(data[0..4].*, ctx.port),
15781578 };
15791579 },
1580 os.RR_AAAA => {
1580 os.RR.AAAA => {
15811581 if (data.len != 16) return error.InvalidDnsAAAARecord;
15821582 const new_addr = try ctx.addrs.addOne();
15831583 new_addr.* = LookupAddr{
15841584 .addr = Address.initIp6(data[0..16].*, ctx.port, 0, 0),
15851585 };
15861586 },
1587 os.RR_CNAME => {
1587 os.RR.CNAME => {
15881588 var tmp: [256]u8 = undefined;
15891589 // Returns len of compressed name. strlen to get canon name.
15901590 _ = try os.dn_expand(packet, data, &tmp);
......@@ -1700,7 +1700,7 @@ pub const StreamServer = struct {
17001700 /// seeing "Connection refused".
17011701 kernel_backlog: u31 = 128,
17021702
1703 /// Enable SO_REUSEADDR on the socket.
1703 /// Enable SO.REUSEADDR on the socket.
17041704 reuse_address: bool = false,
17051705 };
17061706
......@@ -1722,9 +1722,9 @@ pub const StreamServer = struct {
17221722 }
17231723
17241724 pub fn listen(self: *StreamServer, address: Address) !void {
1725 const nonblock = if (std.io.is_async) os.SOCK_NONBLOCK else 0;
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;
1725 const nonblock = if (std.io.is_async) os.SOCK.NONBLOCK else 0;
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;
17281728
17291729 const sockfd = try os.socket(address.any.family, sock_flags, proto);
17301730 self.sockfd = sockfd;
......@@ -1736,8 +1736,8 @@ pub const StreamServer = struct {
17361736 if (self.reuse_address) {
17371737 try os.setsockopt(
17381738 sockfd,
1739 os.SOL_SOCKET,
1740 os.SO_REUSEADDR,
1739 os.SOL.SOCKET,
1740 os.SO.REUSEADDR,
17411741 &mem.toBytes(@as(c_int, 1)),
17421742 );
17431743 }
......@@ -1801,9 +1801,9 @@ pub const StreamServer = struct {
18011801 const accept_result = blk: {
18021802 if (std.io.is_async) {
18031803 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);
18051805 } 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);
18071807 }
18081808 };
18091809
lib/std/os.zig+96-62
......@@ -62,27 +62,48 @@ else switch (builtin.os.tag) {
6262 .uefi => uefi,
6363 else => struct {},
6464};
65
66pub const AF = system.AF;
6567pub const ARCH = system.ARCH;
6668pub const AT = system.AT;
6769pub const CLOCK = system.CLOCK;
70pub const CPU_COUNT = system.CPU_COUNT;
6871pub const E = system.E;
6972pub const Elf_Symndx = system.Elf_Symndx;
7073pub const F = system.F;
74pub const FD_CLOEXEC = system.FD_CLOEXEC;
75pub const F_OK = system.F_OK;
7176pub const Flock = system.Flock;
77pub const HOST_NAME_MAX = system.HOST_NAME_MAX;
78pub const IFNAMESIZE = system.IFNAMESIZE;
7279pub const IOV_MAX = system.IOV_MAX;
80pub const IPPROTO = system.IPPROTO;
7381pub const LOCK = system.LOCK;
82pub const MADV = system.MADV;
7483pub const MAP = system.MAP;
7584pub const MAX_ADDR_LEN = system.MAX_ADDR_LEN;
7685pub const MMAP2_UNIT = system.MMAP2_UNIT;
86pub const MSG = system.MSG;
7787pub const NAME_MAX = system.NAME_MAX;
7888pub const O = system.O;
7989pub const PATH_MAX = system.PATH_MAX;
90pub const POLL = system.POLL;
91pub const POSIX_FADV = system.POSIX_FADV;
8092pub const PROT = system.PROT;
8193pub const REG = system.REG;
94pub const RLIM = system.RLIM;
95pub const RR = system.RR;
96pub const R_OK = system.R_OK;
8297pub const S = system.S;
8398pub const SA = system.SA;
8499pub const SC = system.SC;
100pub const SEEK = system.SEEK;
101pub const SHUT = system.SHUT;
85102pub const SIG = system.SIG;
103pub const SIOCGIFINDEX = system.SIOCGIFINDEX;
104pub const SO = system.SO;
105pub const SOCK = system.SOCK;
106pub const SOL = system.SOL;
86107pub const STDERR_FILENO = system.STDIN_FILENO;
87108pub const STDIN_FILENO = system.STDIN_FILENO;
88109pub const STDOUT_FILENO = system.STDIN_FILENO;
......@@ -90,27 +111,39 @@ pub const SYS = system.SYS;
90111pub const Sigaction = system.Sigaction;
91112pub const Stat = system.Stat;
92113pub 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;
93118pub const blkcnt_t = system.blkcnt_t;
94119pub const blksize_t = system.blksize_t;
95120pub const clock_t = system.clock_t;
121pub const cpu_set_t = system.cpu_set_t;
96122pub const dev_t = system.dev_t;
97123pub const dl_phdr_info = system.dl_phdr_info;
98124pub const empty_sigset = system.empty_sigset;
99125pub const fd_t = system.fd_t;
100126pub const gid_t = system.gid_t;
127pub const ifreq = system.ifreq;
101128pub const ino_t = system.ino_t;
102129pub const mcontext_t = system.mcontext_t;
103130pub const mode_t = system.mode_t;
104131pub const msghdr = system.msghdr;
105132pub const msghdr_const = system.msghdr_const;
133pub const nfds_t = system.nfds_t;
106134pub const nlink_t = system.nlink_t;
107135pub const off_t = system.off_t;
108136pub const pid_t = system.pid_t;
109137pub const pollfd = system.pollfd;
138pub const rlim_t = system.rlim_t;
110139pub const rlimit = system.rlimit;
111140pub const rlimit_resource = system.rlimit_resource;
141pub const sa_family_t = system.sa_family_t;
112142pub const siginfo_t = system.siginfo_t;
113143pub 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;
114147pub const time_t = system.time_t;
115148pub const timespec = system.timespec;
116149pub const timeval = system.timeval;
......@@ -118,6 +151,7 @@ pub const timezone = system.timezone;
118151pub const ucontext_t = system.ucontext_t;
119152pub const uid_t = system.uid_t;
120153pub const user_desc = system.user_desc;
154pub const utsname = system.utsname;
121155
122156pub const iovec = extern struct {
123157 iov_base: [*]u8,
......@@ -251,11 +285,11 @@ pub fn getrandom(buffer: []u8) GetRandomError!void {
251285}
252286
253287fn 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);
255289 defer close(fd);
256290
257291 const st = try fstat(fd);
258 if (!S_ISCHR(st.mode)) {
292 if (!S.ISCHR(st.mode)) {
259293 return error.NoDevice;
260294 }
261295
......@@ -1113,18 +1147,18 @@ pub const OpenError = error{
11131147 /// for 64-bit targets, as well as when opening directories.
11141148 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.
11171151 IsDir,
11181152
11191153 /// 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.
11211155 NoSpaceLeft,
11221156
11231157 /// 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.
11251159 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.
11281162 PathAlreadyExists,
11291163 DeviceBusy,
11301164
......@@ -1196,20 +1230,20 @@ fn openOptionsFromFlags(flags: u32) windows.OpenFileOptions {
11961230 const w = windows;
11971231
11981232 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) {
12001234 access_mask |= w.GENERIC_READ | w.GENERIC_WRITE;
1201 } else if (flags & O_WRONLY != 0) {
1235 } else if (flags & O.WRONLY != 0) {
12021236 access_mask |= w.GENERIC_WRITE;
12031237 } else {
12041238 access_mask |= w.GENERIC_READ | w.GENERIC_WRITE;
12051239 }
12061240
1207 const open_dir: bool = flags & O_DIRECTORY != 0;
1208 const follow_symlinks: bool = flags & O_NOFOLLOW == 0;
1241 const open_dir: bool = flags & O.DIRECTORY != 0;
1242 const follow_symlinks: bool = flags & O.NOFOLLOW == 0;
12091243
12101244 const creation: w.ULONG = blk: {
1211 if (flags & O_CREAT != 0) {
1212 if (flags & O_EXCL != 0) {
1245 if (flags & O.CREAT != 0) {
1246 if (flags & O.EXCL != 0) {
12131247 break :blk w.FILE_CREATE;
12141248 }
12151249 }
......@@ -2812,10 +2846,10 @@ pub const SocketError = error{
28122846
28132847pub fn socket(domain: u32, socket_type: u32, protocol: u32) SocketError!socket_t {
28142848 if (builtin.os.tag == .windows) {
2815 // NOTE: windows translates the SOCK_NONBLOCK/SOCK_CLOEXEC flags into
2849 // NOTE: windows translates the SOCK.NONBLOCK/SOCK.CLOEXEC flags into
28162850 // windows-analagous operations
2817 const filtered_sock_type = socket_type & ~@as(u32, SOCK_NONBLOCK | SOCK_CLOEXEC);
2818 const flags: u32 = if ((socket_type & SOCK_CLOEXEC) != 0)
2851 const filtered_sock_type = socket_type & ~@as(u32, SOCK.NONBLOCK | SOCK.CLOEXEC);
2852 const flags: u32 = if ((socket_type & SOCK.CLOEXEC) != 0)
28192853 windows.ws2_32.WSA_FLAG_NO_HANDLE_INHERIT
28202854 else
28212855 0;
......@@ -2828,7 +2862,7 @@ pub fn socket(domain: u32, socket_type: u32, protocol: u32) SocketError!socket_t
28282862 flags,
28292863 );
28302864 errdefer windows.closesocket(rc) catch unreachable;
2831 if ((socket_type & SOCK_NONBLOCK) != 0) {
2865 if ((socket_type & SOCK.NONBLOCK) != 0) {
28322866 var mode: c_ulong = 1; // nonblocking
28332867 if (windows.ws2_32.SOCKET_ERROR == windows.ws2_32.ioctlsocket(rc, windows.ws2_32.FIONBIO, &mode)) {
28342868 switch (windows.ws2_32.WSAGetLastError()) {
......@@ -2842,7 +2876,7 @@ pub fn socket(domain: u32, socket_type: u32, protocol: u32) SocketError!socket_t
28422876
28432877 const have_sock_flags = comptime !std.Target.current.isDarwin();
28442878 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)
28462880 else
28472881 socket_type;
28482882 const rc = system.socket(domain, filtered_sock_type, protocol);
......@@ -2905,9 +2939,9 @@ pub fn shutdown(sock: socket_t, how: ShutdownHow) ShutdownError!void {
29052939 };
29062940 } else {
29072941 const rc = system.shutdown(sock, switch (how) {
2908 .recv => SHUT_RD,
2909 .send => SHUT_WR,
2910 .both => SHUT_RDWR,
2942 .recv => SHUT.RD,
2943 .send => SHUT.WR,
2944 .both => SHUT.RDWR,
29112945 });
29122946 switch (errno(rc)) {
29132947 .SUCCESS => return,
......@@ -3132,15 +3166,15 @@ pub fn accept(
31323166 /// will return a value greater than was supplied to the call.
31333167 addr_size: ?*socklen_t,
31343168 /// 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`)
31363170 /// referred to by the new file descriptor. Using this flag saves extra calls to `fcntl` to achieve
31373171 /// the same result.
3138 /// * `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.
3172 /// * `SOCK.CLOEXEC` - Set the close-on-exec (`FD_CLOEXEC`) flag on the new file descriptor. See the
3173 /// description of the `O.CLOEXEC` flag in `open` for reasons why this may be useful.
31403174 flags: u32,
31413175) AcceptError!socket_t {
31423176 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
31453179 const accepted_sock = while (true) {
31463180 const rc = if (have_accept4)
......@@ -3250,7 +3284,7 @@ pub const EpollCtlError = error{
32503284 FileDescriptorIncompatibleWithEpoll,
32513285} || 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 {
32543288 const rc = system.epoll_ctl(epfd, op, fd, event);
32553289 switch (errno(rc)) {
32563290 .SUCCESS => return,
......@@ -3270,7 +3304,7 @@ pub fn epoll_ctl(epfd: i32, op: u32, fd: i32, event: ?*epoll_event) EpollCtlErro
32703304/// Waits for an I/O event on an epoll file descriptor.
32713305/// Returns the number of file descriptors ready for the requested I/O,
32723306/// 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 {
32743308 while (true) {
32753309 // TODO get rid of the @intCast
32763310 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
34723506 .NOTSOCK => unreachable, // The file descriptor sockfd does not refer to a socket.
34733507 .PROTOTYPE => unreachable, // The socket type does not support the requested communications protocol.
34743508 .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.
34763510 else => |err| return unexpectedErrno(err),
34773511 }
34783512 }
......@@ -3481,7 +3515,7 @@ pub fn connect(sock: socket_t, sock_addr: *const sockaddr, len: socklen_t) Conne
34813515pub fn getsockoptError(sockfd: fd_t) ConnectError!void {
34823516 var err_code: i32 = undefined;
34833517 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);
34853519 assert(size == 4);
34863520 switch (errno(rc)) {
34873521 .SUCCESS => switch (@intToEnum(E, err_code)) {
......@@ -3813,8 +3847,8 @@ pub const MMapError = error{
38133847 MemoryMappingNotSupported,
38143848
38153849 /// 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 requested
3817 /// and `PROT_WRITE` is set, but the file descriptor is not open in `O_RDWR` mode.
3850 /// but the file descriptor is not open for reading. Or `MAP.SHARED` was requested
3851 /// and `PROT_WRITE` is set, but the file descriptor is not open in `O.RDWR` mode.
38183852 /// Or `PROT_WRITE` is set, but the file is append-only.
38193853 AccessDenied,
38203854
......@@ -3846,7 +3880,7 @@ pub fn mmap(
38463880 const ioffset = @bitCast(i64, offset); // the OS treats this as unsigned
38473881 const rc = mmap_sym(ptr, length, prot, flags, fd, ioffset);
38483882 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];
38503884 break :blk @intToEnum(E, system._errno().*);
38513885 } else blk: {
38523886 const err = errno(rc);
......@@ -4069,9 +4103,9 @@ pub fn pipe2(flags: u32) PipeError![2]fd_t {
40694103 if (flags == 0)
40704104 return fds;
40714105
4072 // O_CLOEXEC is special, it's a file descriptor flag and must be set using
4106 // O.CLOEXEC is special, it's a file descriptor flag and must be set using
40734107 // F_SETFD.
4074 if (flags & O_CLOEXEC != 0) {
4108 if (flags & O.CLOEXEC != 0) {
40754109 for (fds) |fd| {
40764110 switch (errno(system.fcntl(fd, F_SETFD, @as(u32, FD_CLOEXEC)))) {
40774111 .SUCCESS => {},
......@@ -4082,7 +4116,7 @@ pub fn pipe2(flags: u32) PipeError![2]fd_t {
40824116 }
40834117 }
40844118
4085 const new_flags = flags & ~@as(u32, O_CLOEXEC);
4119 const new_flags = flags & ~@as(u32, O.CLOEXEC);
40864120 // Set every other flag affecting the file status using F_SETFL.
40874121 if (new_flags != 0) {
40884122 for (fds) |fd| {
......@@ -4176,7 +4210,7 @@ pub const SeekError = error{
41764210pub fn lseek_SET(fd: fd_t, offset: u64) SeekError!void {
41774211 if (builtin.os.tag == .linux and !builtin.link_libc and @sizeOf(usize) == 4) {
41784212 var result: u64 = undefined;
4179 switch (errno(system.llseek(fd, offset, &result, SEEK_SET))) {
4213 switch (errno(system.llseek(fd, offset, &result, SEEK.SET))) {
41804214 .SUCCESS => return,
41814215 .BADF => unreachable, // always a race condition
41824216 .INVAL => return error.Unseekable,
......@@ -4209,7 +4243,7 @@ pub fn lseek_SET(fd: fd_t, offset: u64) SeekError!void {
42094243 system.lseek;
42104244
42114245 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))) {
42134247 .SUCCESS => return,
42144248 .BADF => unreachable, // always a race condition
42154249 .INVAL => return error.Unseekable,
......@@ -4224,7 +4258,7 @@ pub fn lseek_SET(fd: fd_t, offset: u64) SeekError!void {
42244258pub fn lseek_CUR(fd: fd_t, offset: i64) SeekError!void {
42254259 if (builtin.os.tag == .linux and !builtin.link_libc and @sizeOf(usize) == 4) {
42264260 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))) {
42284262 .SUCCESS => return,
42294263 .BADF => unreachable, // always a race condition
42304264 .INVAL => return error.Unseekable,
......@@ -4256,7 +4290,7 @@ pub fn lseek_CUR(fd: fd_t, offset: i64) SeekError!void {
42564290 system.lseek;
42574291
42584292 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))) {
42604294 .SUCCESS => return,
42614295 .BADF => unreachable, // always a race condition
42624296 .INVAL => return error.Unseekable,
......@@ -4271,7 +4305,7 @@ pub fn lseek_CUR(fd: fd_t, offset: i64) SeekError!void {
42714305pub fn lseek_END(fd: fd_t, offset: i64) SeekError!void {
42724306 if (builtin.os.tag == .linux and !builtin.link_libc and @sizeOf(usize) == 4) {
42734307 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))) {
42754309 .SUCCESS => return,
42764310 .BADF => unreachable, // always a race condition
42774311 .INVAL => return error.Unseekable,
......@@ -4303,7 +4337,7 @@ pub fn lseek_END(fd: fd_t, offset: i64) SeekError!void {
43034337 system.lseek;
43044338
43054339 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))) {
43074341 .SUCCESS => return,
43084342 .BADF => unreachable, // always a race condition
43094343 .INVAL => return error.Unseekable,
......@@ -4318,7 +4352,7 @@ pub fn lseek_END(fd: fd_t, offset: i64) SeekError!void {
43184352pub fn lseek_CUR_get(fd: fd_t) SeekError!u64 {
43194353 if (builtin.os.tag == .linux and !builtin.link_libc and @sizeOf(usize) == 4) {
43204354 var result: u64 = undefined;
4321 switch (errno(system.llseek(fd, 0, &result, SEEK_CUR))) {
4355 switch (errno(system.llseek(fd, 0, &result, SEEK.CUR))) {
43224356 .SUCCESS => return result,
43234357 .BADF => unreachable, // always a race condition
43244358 .INVAL => return error.Unseekable,
......@@ -4349,7 +4383,7 @@ pub fn lseek_CUR_get(fd: fd_t) SeekError!u64 {
43494383 else
43504384 system.lseek;
43514385
4352 const rc = lseek_sym(fd, 0, SEEK_CUR);
4386 const rc = lseek_sym(fd, 0, SEEK.CUR);
43534387 switch (errno(rc)) {
43544388 .SUCCESS => return @bitCast(u64, rc),
43554389 .BADF => unreachable, // always a race condition
......@@ -4387,7 +4421,7 @@ pub fn fcntl(fd: fd_t, cmd: i32, arg: usize) FcntlError!usize {
43874421}
43884422
43894423fn setSockFlags(sock: socket_t, flags: u32) !void {
4390 if ((flags & SOCK_CLOEXEC) != 0) {
4424 if ((flags & SOCK.CLOEXEC) != 0) {
43914425 if (builtin.os.tag == .windows) {
43924426 // TODO: Find out if this is supported for sockets
43934427 } else {
......@@ -4406,7 +4440,7 @@ fn setSockFlags(sock: socket_t, flags: u32) !void {
44064440 };
44074441 }
44084442 }
4409 if ((flags & SOCK_NONBLOCK) != 0) {
4443 if ((flags & SOCK.NONBLOCK) != 0) {
44104444 if (builtin.os.tag == .windows) {
44114445 var mode: c_ulong = 1;
44124446 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 {
44254459 error.PermissionDenied => unreachable,
44264460 else => |e| return e,
44274461 };
4428 fl_flags |= O_NONBLOCK;
4462 fl_flags |= O.NONBLOCK;
44294463 _ = fcntl(sock, F_SETFL, fl_flags) catch |err| switch (err) {
44304464 error.FileBusy => unreachable,
44314465 error.Locked => unreachable,
......@@ -4512,7 +4546,7 @@ pub fn realpathZ(pathname: [*:0]const u8, out_buffer: *[MAX_PATH_BYTES]u8) RealP
45124546 return realpathW(pathname_w.span(), out_buffer);
45134547 }
45144548 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;
45164550 const fd = openZ(pathname, flags, 0) catch |err| switch (err) {
45174551 error.FileLocksNotSupported => unreachable,
45184552 error.WouldBlock => unreachable,
......@@ -5043,7 +5077,7 @@ pub const SendError = error{
50435077 SystemResources,
50445078
50455079 /// 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.
50475081 BrokenPipe,
50485082
50495083 FileDescriptorNotASocket,
......@@ -5059,13 +5093,13 @@ pub const SendMsgError = SendError || error{
50595093 /// The passed address didn't have the correct address family in its sa_family field.
50605094 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.
50635097 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.
50665100 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.
50695103 FileNotFound,
50705104 NotDir,
50715105
......@@ -5158,7 +5192,7 @@ pub const SendToError = SendMsgError;
51585192///
51595193/// sendto(sockfd, buf, len, flags, NULL, 0);
51605194///
5161/// If sendto() is used on a connection-mode (`SOCK_STREAM`, `SOCK_SEQPACKET`) socket, the arguments
5195/// If sendto() is used on a connection-mode (`SOCK.STREAM`, `SOCK.SEQPACKET`) socket, the arguments
51625196/// `dest_addr` and `addrlen` are asserted to be `null` and `0` respectively, and asserted
51635197/// that the socket was actually connected.
51645198/// Otherwise, the address of the target is given by `dest_addr` with `addrlen` specifying its size.
......@@ -5398,7 +5432,7 @@ pub fn sendfile(
53985432 // * Descriptor is not valid or locked
53995433 // * an mmap(2)-like operation is not available for in_fd
54005434 // * count is negative
5401 // * out_fd has the O_APPEND flag set
5435 // * out_fd has the O.APPEND flag set
54025436 // Because of the "mmap(2)-like operation" possibility, we fall back to doing read/write
54035437 // manually, the same as ENOSYS.
54045438 break :sf;
......@@ -5464,7 +5498,7 @@ pub fn sendfile(
54645498 .INVAL, .OPNOTSUPP, .NOTSOCK, .NOSYS => {
54655499 // EINVAL could be any of the following situations:
54665500 // * 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.
54685502 // * The offset argument is negative.
54695503 // Because of some of these possibilities, we fall back to doing read/write
54705504 // manually, the same as ENOSYS.
......@@ -5606,7 +5640,7 @@ pub const CopyFileRangeError = error{
56065640 FileTooBig,
56075641 InputOutput,
56085642 /// `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`.
56105644 FilesOpenedWithWrongFlags,
56115645 IsDir,
56125646 OutOfMemory,
......@@ -6222,27 +6256,27 @@ pub fn setrlimit(resource: rlimit_resource, limits: rlimit) SetrlimitError!void
62226256}
62236257
62246258pub 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.
62266260 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.
62286262 PermissionDenied,
62296263 /// A kernel resource was temporarily unavailable.
62306264 SystemResources,
62316265 /// One of the following:
62326266 /// * addr is not page-aligned or length is negative
62336267 /// * advice is not valid
6234 /// * advice is MADV_DONTNEED or MADV_REMOVE and the specified address range
6268 /// * advice is MADV.DONTNEED or MADV.REMOVE and the specified address range
62356269 /// includes locked, Huge TLB pages, or VM_PFNMAP pages.
6236 /// * advice is MADV_MERGEABLE or MADV_UNMERGEABLE, but the kernel was not
6270 /// * advice is MADV.MERGEABLE or MADV.UNMERGEABLE, but the kernel was not
62376271 /// configured with CONFIG_KSM.
6238 /// * advice is MADV_FREE or MADV_WIPEONFORK but the specified address range
6239 /// includes file, Huge TLB, MAP_SHARED, or VM_PFNMAP ranges.
6272 /// * advice is MADV.FREE or MADV.WIPEONFORK but the specified address range
6273 /// includes file, Huge TLB, MAP.SHARED, or VM_PFNMAP ranges.
62406274 InvalidSyscall,
6241 /// (for MADV_WILLNEED) Paging in this area would exceed the process's
6275 /// (for MADV.WILLNEED) Paging in this area would exceed the process's
62426276 /// maximum resident set size.
62436277 WouldExceedMaximumResidentSetSize,
62446278 /// One of the following:
6245 /// * (for MADV_WILLNEED) Not enough memory: paging in failed.
6279 /// * (for MADV.WILLNEED) Not enough memory: paging in failed.
62466280 /// * Addresses in the specified range are not currently mapped, or
62476281 /// are outside the address space of the process.
62486282 OutOfMemory,
lib/std/os/linux.zig+126-110
......@@ -17,6 +17,8 @@ const is_mips = native_arch.isMIPS();
1717const is_ppc = native_arch.isPPC();
1818const is_ppc64 = native_arch.isPPC64();
1919const is_sparc = native_arch.isSPARC();
20const iovec = std.os.iovec;
21const iovec_const = std.os.iovec_const;
2022
2123test {
2224 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
306308 if (@hasField(SYS, "readlink")) {
307309 return syscall3(.readlink, @ptrToInt(path), @ptrToInt(buf_ptr), buf_len);
308310 } 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);
310312 }
311313}
312314
......@@ -318,7 +320,7 @@ pub fn mkdir(path: [*:0]const u8, mode: u32) usize {
318320 if (@hasField(SYS, "mkdir")) {
319321 return syscall2(.mkdir, @ptrToInt(path), mode);
320322 } 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);
322324 }
323325}
324326
......@@ -330,7 +332,7 @@ pub fn mknod(path: [*:0]const u8, mode: u32, dev: u32) usize {
330332 if (@hasField(SYS, "mknod")) {
331333 return syscall3(.mknod, @ptrToInt(path), mode, dev);
332334 } else {
333 return mknodat(AT_FDCWD, path, mode, dev);
335 return mknodat(AT.FDCWD, path, mode, dev);
334336 }
335337}
336338
......@@ -477,7 +479,7 @@ pub fn rmdir(path: [*:0]const u8) usize {
477479 if (@hasField(SYS, "rmdir")) {
478480 return syscall1(.rmdir, @ptrToInt(path));
479481 } 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);
481483 }
482484}
483485
......@@ -485,7 +487,7 @@ pub fn symlink(existing: [*:0]const u8, new: [*:0]const u8) usize {
485487 if (@hasField(SYS, "symlink")) {
486488 return syscall2(.symlink, @ptrToInt(existing), @ptrToInt(new));
487489 } 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));
489491 }
490492}
491493
......@@ -518,9 +520,12 @@ pub fn pread(fd: i32, buf: [*]u8, count: usize, offset: i64) usize {
518520 }
519521 } else {
520522 // 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;
522527 return syscall4(
523 S,
528 syscall_number,
524529 @bitCast(usize, @as(isize, fd)),
525530 @ptrToInt(buf),
526531 count,
......@@ -533,7 +538,7 @@ pub fn access(path: [*:0]const u8, mode: u32) usize {
533538 if (@hasField(SYS, "access")) {
534539 return syscall2(.access, @ptrToInt(path), mode);
535540 } 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);
537542 }
538543}
539544
......@@ -613,9 +618,12 @@ pub fn pwrite(fd: i32, buf: [*]const u8, count: usize, offset: i64) usize {
613618 }
614619 } else {
615620 // 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;
617625 return syscall4(
618 S,
626 syscall_number,
619627 @bitCast(usize, @as(isize, fd)),
620628 @ptrToInt(buf),
621629 count,
......@@ -628,9 +636,9 @@ pub fn rename(old: [*:0]const u8, new: [*:0]const u8) usize {
628636 if (@hasField(SYS, "rename")) {
629637 return syscall2(.rename, @ptrToInt(old), @ptrToInt(new));
630638 } 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));
632640 } 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);
634642 }
635643}
636644
......@@ -672,7 +680,7 @@ pub fn open(path: [*:0]const u8, flags: u32, perm: mode_t) usize {
672680 } else {
673681 return syscall4(
674682 .openat,
675 @bitCast(usize, @as(isize, AT_FDCWD)),
683 @bitCast(usize, @as(isize, AT.FDCWD)),
676684 @ptrToInt(path),
677685 flags,
678686 perm,
......@@ -685,7 +693,7 @@ pub fn create(path: [*:0]const u8, perm: mode_t) usize {
685693}
686694
687695pub fn openat(dirfd: i32, path: [*:0]const u8, flags: u32, mode: mode_t) usize {
688 // dirfd could be negative, for example AT_FDCWD is -100
696 // dirfd could be negative, for example AT.FDCWD is -100
689697 return syscall4(.openat, @bitCast(usize, @as(isize, dirfd)), @ptrToInt(path), flags, mode);
690698}
691699
......@@ -759,9 +767,9 @@ pub fn link(oldpath: [*:0]const u8, newpath: [*:0]const u8, flags: i32) usize {
759767 } else {
760768 return syscall5(
761769 .linkat,
762 @bitCast(usize, @as(isize, AT_FDCWD)),
770 @bitCast(usize, @as(isize, AT.FDCWD)),
763771 @ptrToInt(oldpath),
764 @bitCast(usize, @as(isize, AT_FDCWD)),
772 @bitCast(usize, @as(isize, AT.FDCWD)),
765773 @ptrToInt(newpath),
766774 @bitCast(usize, @as(isize, flags)),
767775 );
......@@ -783,7 +791,7 @@ pub fn unlink(path: [*:0]const u8) usize {
783791 if (@hasField(SYS, "unlink")) {
784792 return syscall1(.unlink, @ptrToInt(path));
785793 } 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);
787795 }
788796}
789797
......@@ -1131,7 +1139,7 @@ pub fn sendmmsg(fd: i32, msgvec: [*]mmsghdr_const, vlen: u32, flags: u32) usize
11311139 }
11321140 }
11331141 }
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)
11351143 const batch_size = kvlen - next_unsent;
11361144 const r = syscall4(.sendmmsg, @bitCast(usize, @as(isize, fd)), @ptrToInt(&msgvec[next_unsent]), batch_size, flags);
11371145 if (getErrno(r) != 0) return r;
......@@ -1759,10 +1767,10 @@ pub const W = struct {
17591767 return s & 0x7f;
17601768 }
17611769 pub fn STOPSIG(s: u32) u32 {
1762 return WEXITSTATUS(s);
1770 return EXITSTATUS(s);
17631771 }
17641772 pub fn IFEXITED(s: u32) bool {
1765 return WTERMSIG(s) == 0;
1773 return TERMSIG(s) == 0;
17661774 }
17671775 pub fn IFSTOPPED(s: u32) bool {
17681776 return @intCast(u16, ((s & 0xffff) *% 0x10001) >> 8) > 0x7f00;
......@@ -2886,31 +2894,51 @@ pub const socklen_t = u32;
28862894pub const sockaddr = extern struct {
28872895 family: sa_family_t,
28882896 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 address
2894pub const sockaddr_in = extern struct {
2895 family: sa_family_t = AF_INET,
2896 port: in_port_t,
2897 addr: u32,
2898 zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },
2899};
2900 /// IPv4 socket address
2901 pub const in = extern struct {
2902 family: sa_family_t = AF.INET,
2903 port: in_port_t,
2904 addr: u32,
2905 zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },
2906 };
29002907
2901/// IPv6 socket address
2902pub const sockaddr_in6 = extern struct {
2903 family: sa_family_t = AF_INET6,
2904 port: in_port_t,
2905 flowinfo: u32,
2906 addr: [16]u8,
2907 scope_id: u32,
2908};
2908 /// IPv6 socket address
2909 pub const in6 = extern struct {
2910 family: sa_family_t = AF.INET6,
2911 port: in_port_t,
2912 flowinfo: u32,
2913 addr: [16]u8,
2914 scope_id: u32,
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 address
2911pub const sockaddr_un = extern struct {
2912 family: sa_family_t = AF_UNIX,
2913 path: [108]u8,
2931 /// multicast groups mask
2932 groups: u32,
2933 };
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 };
29142942};
29152943
29162944pub const mmsghdr = extern struct {
......@@ -3584,43 +3612,47 @@ pub const addrinfo = extern struct {
35843612
35853613pub const IPPORT_RESERVED = 1024;
35863614
3587pub const IPPROTO_IP = 0;
3588pub const IPPROTO_HOPOPTS = 0;
3589pub const IPPROTO_ICMP = 1;
3590pub const IPPROTO_IGMP = 2;
3591pub const IPPROTO_IPIP = 4;
3592pub const IPPROTO_TCP = 6;
3593pub const IPPROTO_EGP = 8;
3594pub const IPPROTO_PUP = 12;
3595pub const IPPROTO_UDP = 17;
3596pub const IPPROTO_IDP = 22;
3597pub const IPPROTO_TP = 29;
3598pub const IPPROTO_DCCP = 33;
3599pub const IPPROTO_IPV6 = 41;
3600pub const IPPROTO_ROUTING = 43;
3601pub const IPPROTO_FRAGMENT = 44;
3602pub const IPPROTO_RSVP = 46;
3603pub const IPPROTO_GRE = 47;
3604pub const IPPROTO_ESP = 50;
3605pub const IPPROTO_AH = 51;
3606pub const IPPROTO_ICMPV6 = 58;
3607pub const IPPROTO_NONE = 59;
3608pub const IPPROTO_DSTOPTS = 60;
3609pub const IPPROTO_MTP = 92;
3610pub const IPPROTO_BEETPH = 94;
3611pub const IPPROTO_ENCAP = 98;
3612pub const IPPROTO_PIM = 103;
3613pub const IPPROTO_COMP = 108;
3614pub const IPPROTO_SCTP = 132;
3615pub const IPPROTO_MH = 135;
3616pub const IPPROTO_UDPLITE = 136;
3617pub const IPPROTO_MPLS = 137;
3618pub const IPPROTO_RAW = 255;
3619pub const IPPROTO_MAX = 256;
3620
3621pub const RR_A = 1;
3622pub const RR_CNAME = 5;
3623pub const RR_AAAA = 28;
3615pub const IPPROTO = struct {
3616 pub const IP = 0;
3617 pub const HOPOPTS = 0;
3618 pub const ICMP = 1;
3619 pub const IGMP = 2;
3620 pub const IPIP = 4;
3621 pub const TCP = 6;
3622 pub const EGP = 8;
3623 pub const PUP = 12;
3624 pub const UDP = 17;
3625 pub const IDP = 22;
3626 pub const TP = 29;
3627 pub const DCCP = 33;
3628 pub const IPV6 = 41;
3629 pub const ROUTING = 43;
3630 pub const FRAGMENT = 44;
3631 pub const RSVP = 46;
3632 pub const GRE = 47;
3633 pub const ESP = 50;
3634 pub const AH = 51;
3635 pub const ICMPV6 = 58;
3636 pub const NONE = 59;
3637 pub const DSTOPTS = 60;
3638 pub const MTP = 92;
3639 pub const BEETPH = 94;
3640 pub const ENCAP = 98;
3641 pub const PIM = 103;
3642 pub const COMP = 108;
3643 pub const SCTP = 132;
3644 pub const MH = 135;
3645 pub const UDPLITE = 136;
3646 pub const MPLS = 137;
3647 pub const RAW = 255;
3648 pub const MAX = 256;
3649};
3650
3651pub const RR = struct {
3652 pub const A = 1;
3653 pub const CNAME = 5;
3654 pub const AAAA = 28;
3655};
36243656
36253657/// Turn off Nagle's algorithm
36263658pub const TCP_NODELAY = 1;
......@@ -3746,14 +3778,16 @@ pub const pollfd = extern struct {
37463778 revents: i16,
37473779};
37483780
3749pub const POLLIN = 0x001;
3750pub const POLLPRI = 0x002;
3751pub const POLLOUT = 0x004;
3752pub const POLLERR = 0x008;
3753pub const POLLHUP = 0x010;
3754pub const POLLNVAL = 0x020;
3755pub const POLLRDNORM = 0x040;
3756pub const POLLRDBAND = 0x080;
3781pub const POLL = struct {
3782 pub const IN = 0x001;
3783 pub const PRI = 0x002;
3784 pub const OUT = 0x004;
3785 pub const ERR = 0x008;
3786 pub const HUP = 0x010;
3787 pub const NVAL = 0x020;
3788 pub const RDNORM = 0x040;
3789 pub const RDBAND = 0x080;
3790};
37573791
37583792pub const MFD_CLOEXEC = 0x0001;
37593793pub const MFD_ALLOW_SEALING = 0x0002;
......@@ -4097,11 +4131,13 @@ pub const rlimit_resource = enum(c_int) {
40974131
40984132pub const rlim_t = u64;
40994133
4100/// No limit
4101pub const RLIM_INFINITY = ~@as(rlim_t, 0);
4134pub const RLIM = struct {
4135 /// No limit
4136 pub const INFINITY = ~@as(rlim_t, 0);
41024137
4103pub const RLIM_SAVED_MAX = RLIM_INFINITY;
4104pub const RLIM_SAVED_CUR = RLIM_INFINITY;
4138 pub const SAVED_MAX = INFINITY;
4139 pub const SAVED_CUR = INFINITY;
4140};
41054141
41064142pub const rlimit = extern struct {
41074143 /// Soft limit
......@@ -4189,14 +4225,6 @@ pub const XDP = struct {
41894225 pub const UMEM_PGOFF_COMPLETION_RING = 0x180000000;
41904226};
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
42004228pub const xdp_ring_offset = extern struct {
42014229 producer: u64,
42024230 consumer: u64,
......@@ -4673,18 +4701,6 @@ pub const NetlinkMessageType = enum(u16) {
46734701 _,
46744702};
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
46884704/// Netlink message header
46894705/// Specified in RFC 3549 Section 2.3.2
46904706pub const nlmsghdr = extern struct {
lib/std/os/linux/arm-eabi.zig+20-19
......@@ -575,26 +575,27 @@ pub const F_GETOWN_EX = 16;
575575
576576pub const F_GETOWNER_UIDS = 17;
577577
578pub const LOCK_SH = 1;
579pub const LOCK_EX = 2;
580pub const LOCK_UN = 8;
581pub const LOCK_NB = 4;
582
583/// stack-like segment
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;
578pub const LOCK = struct {
579 pub const SH = 1;
580 pub const EX = 2;
581 pub const UN = 8;
582 pub const NB = 4;
583};
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};
598599pub const VDSO_CGT_SYM = "__vdso_clock_gettime";
599600pub 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;
449449pub const F_WRLCK = 1;
450450pub const F_UNLCK = 2;
451451
452pub const LOCK_SH = 1;
453pub const LOCK_EX = 2;
454pub const LOCK_UN = 8;
455pub const LOCK_NB = 4;
452pub const LOCK = struct {
453 pub const SH = 1;
454 pub const EX = 2;
455 pub const UN = 8;
456 pub const NB = 4;
457};
456458
457459pub const F_SETOWN_EX = 15;
458460pub const F_GETOWN_EX = 16;
459461
460462pub const F_GETOWNER_UIDS = 17;
461463
462/// stack-like segment
463pub const MAP_GROWSDOWN = 0x0100;
464
465/// ETXTBSY
466pub const MAP_DENYWRITE = 0x0800;
467
468/// mark it as an executable
469pub const MAP_EXECUTABLE = 0x1000;
470
471/// pages are locked
472pub const MAP_LOCKED = 0x2000;
473
474/// don't check for reservations
475pub const MAP_NORESERVE = 0x4000;
476
464pub const MAP = struct {
465 /// stack-like segment
466 pub const GROWSDOWN = 0x0100;
467 /// ETXTBSY
468 pub const DENYWRITE = 0x0800;
469 /// mark it as an executable
470 pub const EXECUTABLE = 0x1000;
471 /// pages are locked
472 pub const LOCKED = 0x2000;
473 /// don't check for reservations
474 pub const NORESERVE = 0x4000;
475 /// Only used by libc to communicate failure.
476 pub const FAILED = @intToPtr(*c_void, maxInt(usize));
477};
477478pub const VDSO_CGT_SYM = "__kernel_clock_gettime";
478479pub const VDSO_CGT_VER = "LINUX_2.6.39";
479480
lib/std/os/linux/i386.zig+3
......@@ -671,6 +671,9 @@ pub const MAP = struct {
671671 pub const EXECUTABLE = 0x1000;
672672 pub const LOCKED = 0x2000;
673673 pub const @"32BIT" = 0x40;
674
675 /// Only used by libc to communicate failure.
676 pub const FAILED = @intToPtr(*c_void, maxInt(usize));
674677};
675678
676679pub const MMAP2_UNIT = 4096;
lib/std/os/linux/io_uring.zig+8-8
......@@ -535,7 +535,7 @@ pub const IO_Uring = struct {
535535 /// `0` if the timeout completed after the specified number of events, or `-ECANCELED` if the
536536 /// timeout was removed before it expired.
537537 ///
538 /// io_uring timeouts use the `CLOCK_MONOTONIC` clock source.
538 /// io_uring timeouts use the `CLOCK.MONOTONIC` clock source.
539539 pub fn timeout(
540540 self: *IO_Uring,
541541 user_data: u64,
......@@ -736,8 +736,8 @@ pub const SubmissionQueue = struct {
736736 const mmap = try os.mmap(
737737 null,
738738 size,
739 os.PROT_READ | os.PROT_WRITE,
740 os.MAP_SHARED | os.MAP_POPULATE,
739 os.PROT.READ | os.PROT.WRITE,
740 os.MAP.SHARED | os.MAP.POPULATE,
741741 fd,
742742 linux.IORING_OFF_SQ_RING,
743743 );
......@@ -750,8 +750,8 @@ pub const SubmissionQueue = struct {
750750 const mmap_sqes = try os.mmap(
751751 null,
752752 size_sqes,
753 os.PROT_READ | os.PROT_WRITE,
754 os.MAP_SHARED | os.MAP_POPULATE,
753 os.PROT.READ | os.PROT.WRITE,
754 os.MAP.SHARED | os.MAP.POPULATE,
755755 fd,
756756 linux.IORING_OFF_SQES,
757757 );
......@@ -1372,9 +1372,9 @@ test "accept/connect/send/recv" {
13721372
13731373 const address = try net.Address.parseIp4("127.0.0.1", 3131);
13741374 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);
13761376 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)));
13781378 try os.bind(server, &address.any, address.getOsSockLen());
13791379 try os.listen(server, kernel_backlog);
13801380
......@@ -1386,7 +1386,7 @@ test "accept/connect/send/recv" {
13861386 _ = try ring.accept(0xaaaaaaaa, server, &accept_addr, &accept_addr_len, 0);
13871387 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);
13901390 defer os.close(client);
13911391 _ = try ring.connect(0xcccccccc, client, &address.any, address.getOsSockLen());
13921392 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;
668668pub const F_WRLCK = 1;
669669pub const F_UNLCK = 2;
670670
671pub const LOCK_SH = 1;
672pub const LOCK_EX = 2;
673pub const LOCK_UN = 8;
674pub const LOCK_NB = 4;
671pub const LOCK = struct {
672 pub const SH = 1;
673 pub const EX = 2;
674 pub const UN = 8;
675 pub const NB = 4;
676};
675677
676678pub const F_SETOWN_EX = 15;
677679pub const F_GETOWN_EX = 16;
......@@ -680,40 +682,46 @@ pub const F_GETOWNER_UIDS = 17;
680682
681683pub const MMAP2_UNIT = 4096;
682684
683pub const MAP_NORESERVE = 0x0400;
684pub const MAP_GROWSDOWN = 0x1000;
685pub const MAP_DENYWRITE = 0x2000;
686pub const MAP_EXECUTABLE = 0x4000;
687pub const MAP_LOCKED = 0x8000;
688pub const MAP_32BIT = 0x40;
689
690pub const SO_DEBUG = 1;
691pub const SO_REUSEADDR = 0x0004;
692pub const SO_KEEPALIVE = 0x0008;
693pub const SO_DONTROUTE = 0x0010;
694pub const SO_BROADCAST = 0x0020;
695pub const SO_LINGER = 0x0080;
696pub const SO_OOBINLINE = 0x0100;
697pub const SO_REUSEPORT = 0x0200;
698pub const SO_SNDBUF = 0x1001;
699pub const SO_RCVBUF = 0x1002;
700pub const SO_SNDLOWAT = 0x1003;
701pub const SO_RCVLOWAT = 0x1004;
702pub const SO_RCVTIMEO = 0x1006;
703pub const SO_SNDTIMEO = 0x1005;
704pub const SO_ERROR = 0x1007;
705pub const SO_TYPE = 0x1008;
706pub const SO_ACCEPTCONN = 0x1009;
707pub const SO_PROTOCOL = 0x1028;
708pub const SO_DOMAIN = 0x1029;
709pub const SO_NO_CHECK = 11;
710pub const SO_PRIORITY = 12;
711pub const SO_BSDCOMPAT = 14;
712pub const SO_PASSCRED = 17;
713pub const SO_PEERCRED = 18;
714pub const SO_PEERSEC = 30;
715pub const SO_SNDBUFFORCE = 31;
716pub const SO_RCVBUFFORCE = 33;
685pub const MAP = struct {
686 pub const NORESERVE = 0x0400;
687 pub const GROWSDOWN = 0x1000;
688 pub const DENYWRITE = 0x2000;
689 pub const EXECUTABLE = 0x4000;
690 pub const LOCKED = 0x8000;
691 pub const @"32BIT" = 0x40;
692 /// Only used by libc to communicate failure.
693 pub const FAILED = @intToPtr(*c_void, maxInt(usize));
694};
695
696pub const SO = struct {
697 pub const DEBUG = 1;
698 pub const REUSEADDR = 0x0004;
699 pub const KEEPALIVE = 0x0008;
700 pub const DONTROUTE = 0x0010;
701 pub const BROADCAST = 0x0020;
702 pub const LINGER = 0x0080;
703 pub const OOBINLINE = 0x0100;
704 pub const REUSEPORT = 0x0200;
705 pub const SNDBUF = 0x1001;
706 pub const RCVBUF = 0x1002;
707 pub const SNDLOWAT = 0x1003;
708 pub const RCVLOWAT = 0x1004;
709 pub const RCVTIMEO = 0x1006;
710 pub const SNDTIMEO = 0x1005;
711 pub const ERROR = 0x1007;
712 pub const TYPE = 0x1008;
713 pub const ACCEPTCONN = 0x1009;
714 pub const PROTOCOL = 0x1028;
715 pub const DOMAIN = 0x1029;
716 pub const NO_CHECK = 11;
717 pub const PRIORITY = 12;
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
718726pub const VDSO_CGT_SYM = "__kernel_clock_gettime";
719727pub 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;
605605pub const F_WRLCK = 1;
606606pub const F_UNLCK = 2;
607607
608pub const LOCK_SH = 1;
609pub const LOCK_EX = 2;
610pub const LOCK_UN = 8;
611pub const LOCK_NB = 4;
612
613/// stack-like segment
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;
608pub const LOCK = struct {
609 pub const SH = 1;
610 pub const EX = 2;
611 pub const UN = 8;
612 pub const NB = 4;
613};
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};
628629pub const VDSO_CGT_SYM = "__kernel_clock_gettime";
629630pub 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;
575575pub const F_WRLCK = 1;
576576pub const F_UNLCK = 2;
577577
578pub const LOCK_SH = 1;
579pub const LOCK_EX = 2;
580pub const LOCK_UN = 8;
581pub const LOCK_NB = 4;
578pub const LOCK = struct {
579 pub const SH = 1;
580 pub const EX = 2;
581 pub const UN = 8;
582 pub const NB = 4;
583};
582584
583585pub const F_SETOWN_EX = 15;
584586pub const F_GETOWN_EX = 16;
585587
586588pub const F_GETOWNER_UIDS = 17;
587589
588/// stack-like segment
589pub const MAP_GROWSDOWN = 0x0100;
590
591/// ETXTBSY
592pub const MAP_DENYWRITE = 0x0800;
593
594/// mark it as an executable
595pub const MAP_EXECUTABLE = 0x1000;
596
597/// pages are locked
598pub const MAP_LOCKED = 0x0080;
599
600/// don't check for reservations
601pub const MAP_NORESERVE = 0x0040;
590pub const MAP = struct {
591 /// stack-like segment
592 pub const GROWSDOWN = 0x0100;
593 /// ETXTBSY
594 pub const DENYWRITE = 0x0800;
595 /// mark it as an executable
596 pub const EXECUTABLE = 0x1000;
597 /// pages are locked
598 pub const LOCKED = 0x0080;
599 /// don't check for reservations
600 pub const NORESERVE = 0x0040;
601 /// Only used by libc to communicate failure.
602 pub const FAILED = @intToPtr(*c_void, maxInt(usize));
603};
602604
603605pub const VDSO_CGT_SYM = "__kernel_clock_gettime";
604606pub 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;
444444pub const F_WRLCK = 1;
445445pub const F_UNLCK = 2;
446446
447pub const LOCK_SH = 1;
448pub const LOCK_EX = 2;
449pub const LOCK_UN = 8;
450pub const LOCK_NB = 4;
447pub const LOCK = struct {
448 pub const SH = 1;
449 pub const EX = 2;
450 pub const UN = 8;
451 pub const NB = 4;
452};
451453
452454pub const F_SETOWN_EX = 15;
453455pub const F_GETOWN_EX = 16;
lib/std/os/linux/sparc64.zig+20-19
......@@ -612,26 +612,27 @@ pub const F_GETOWN_EX = 16;
612612
613613pub const F_GETOWNER_UIDS = 17;
614614
615pub const LOCK_SH = 1;
616pub const LOCK_EX = 2;
617pub const LOCK_NB = 4;
618pub const LOCK_UN = 8;
619
620/// stack-like segment
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;
615pub const LOCK = struct {
616 pub const SH = 1;
617 pub const EX = 2;
618 pub const NB = 4;
619 pub const UN = 8;
620};
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};
635636pub const VDSO_CGT_SYM = "__vdso_clock_gettime";
636637pub const VDSO_CGT_VER = "LINUX_2.6";
637638
lib/std/os/linux/test.zig+6-6
......@@ -35,7 +35,7 @@ test "timer" {
3535 var err: linux.E = linux.getErrno(epoll_fd);
3636 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);
3939 try expect(linux.getErrno(timer_fd) == .SUCCESS);
4040
4141 const time_interval = linux.timespec{
......@@ -52,11 +52,11 @@ test "timer" {
5252 try expect(err == .SUCCESS);
5353
5454 var event = linux.epoll_event{
55 .events = linux.EPOLLIN | linux.EPOLLOUT | linux.EPOLLET,
55 .events = linux.EPOLL.IN | linux.EPOLL.OUT | linux.EPOLL.ET,
5656 .data = linux.epoll_data{ .ptr = 0 },
5757 };
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));
6060 try expect(err == .SUCCESS);
6161
6262 const events_one: linux.epoll_event = undefined;
......@@ -75,7 +75,7 @@ test "statx" {
7575 }
7676
7777 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))) {
7979 .SUCCESS => {},
8080 // The statx syscall was only introduced in linux 4.11
8181 .NOSYS => return error.SkipZigTest,
......@@ -83,7 +83,7 @@ test "statx" {
8383 }
8484
8585 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))) {
8787 .SUCCESS => {},
8888 else => unreachable,
8989 }
......@@ -119,7 +119,7 @@ test "fadvise" {
119119 file.handle,
120120 0,
121121 0,
122 linux.POSIX_FADV_SEQUENTIAL,
122 linux.POSIX_FADV.SEQUENTIAL,
123123 );
124124 try expectEqual(@as(usize, 0), ret);
125125}
lib/std/os/linux/x86_64.zig+3-17
......@@ -1,4 +1,5 @@
11const std = @import("../../std.zig");
2const maxInt = std.math.maxInt;
23const linux = std.os.linux;
34const iovec = std.os.iovec;
45const iovec_const = std.os.iovec_const;
......@@ -527,59 +528,44 @@ pub const F = struct {
527528pub const MAP = struct {
528529 /// Share changes
529530 pub const SHARED = 0x01;
530
531531 /// Changes are private
532532 pub const PRIVATE = 0x02;
533
534533 /// share + validate extension flags
535534 pub const SHARED_VALIDATE = 0x03;
536
537535 /// Mask for type of mapping
538536 pub const TYPE = 0x0f;
539
540537 /// Interpret addr exactly
541538 pub const FIXED = 0x10;
542
543539 /// don't use a file
544540 pub const ANONYMOUS = 0x20;
545
546541 /// populate (prefault) pagetables
547542 pub const POPULATE = 0x8000;
548
549543 /// do not block on IO
550544 pub const NONBLOCK = 0x10000;
551
552545 /// give out an address that is best suited for process/thread stacks
553546 pub const STACK = 0x20000;
554
555547 /// create a huge page mapping
556548 pub const HUGETLB = 0x40000;
557
558549 /// perform synchronous page faults for the mapping
559550 pub const SYNC = 0x80000;
560
561551 /// FIXED which doesn't unmap underlying mapping
562552 pub const FIXED_NOREPLACE = 0x100000;
563
564553 /// For anonymous mmap, memory could be uninitialized
565554 pub const UNINITIALIZED = 0x4000000;
566555 /// only give out 32bit addresses
567556 pub const @"32BIT" = 0x40;
568
569557 /// stack-like segment
570558 pub const GROWSDOWN = 0x0100;
571
572559 /// ETXTBSY
573560 pub const DENYWRITE = 0x0800;
574
575561 /// mark it as an executable
576562 pub const EXECUTABLE = 0x1000;
577
578563 /// pages are locked
579564 pub const LOCKED = 0x2000;
580
581565 /// don't check for reservations
582566 pub const NORESERVE = 0x4000;
567 /// Only used by libc to communicate failure.
568 pub const FAILED = @intToPtr(*c_void, maxInt(usize));
583569};
584570
585571pub const VDSO = struct {
lib/std/os/test.zig+37-37
......@@ -70,21 +70,21 @@ test "open smoke test" {
7070
7171 // Create some file using `open`.
7272 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);
7474 os.close(fd);
7575
7676 // Try this again with the same flags. This op should fail with error.PathAlreadyExists.
7777 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.
8181 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);
8383 os.close(fd);
8484
8585 // Try opening as a directory which should fail.
8686 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
8989 // Create some directory
9090 file_path = try fs.path.join(&arena.allocator, &[_][]const u8{ base_path, "some_dir" });
......@@ -92,12 +92,12 @@ test "open smoke test" {
9292
9393 // Open dir using `open`
9494 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);
9696 os.close(fd);
9797
9898 // Try opening as file which should fail.
9999 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));
101101}
102102
103103test "openat smoke test" {
......@@ -112,28 +112,28 @@ test "openat smoke test" {
112112 const mode: os.mode_t = if (native_os == .windows) 0 else 0o666;
113113
114114 // 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);
116116 os.close(fd);
117117
118118 // 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.
122 fd = try os.openat(tmp.dir.fd, "some_file", os.O_RDWR | os.O_CREAT, mode);
121 // Try opening without `O.EXCL` flag.
122 fd = try os.openat(tmp.dir.fd, "some_file", os.O.RDWR | os.O.CREAT, mode);
123123 os.close(fd);
124124
125125 // 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
128128 // Create some directory
129129 try os.mkdirat(tmp.dir.fd, "some_dir", mode);
130130
131131 // 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);
133133 os.close(fd);
134134
135135 // 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));
137137}
138138
139139test "symlink with relative paths" {
......@@ -273,7 +273,7 @@ test "fstatat" {
273273 defer file.close();
274274
275275 // 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;
277277 const statat = try os.fstatat(tmp.dir.fd, "file.txt", flags);
278278 try expectEqual(stat, statat);
279279}
......@@ -508,8 +508,8 @@ test "mmap" {
508508 const data = try os.mmap(
509509 null,
510510 1234,
511 os.PROT_READ | os.PROT_WRITE,
512 os.MAP_ANONYMOUS | os.MAP_PRIVATE,
511 os.PROT.READ | os.PROT.WRITE,
512 os.MAP.ANONYMOUS | os.MAP.PRIVATE,
513513 -1,
514514 0,
515515 );
......@@ -550,8 +550,8 @@ test "mmap" {
550550 const data = try os.mmap(
551551 null,
552552 alloc_size,
553 os.PROT_READ,
554 os.MAP_PRIVATE,
553 os.PROT.READ,
554 os.MAP.PRIVATE,
555555 file.handle,
556556 0,
557557 );
......@@ -574,8 +574,8 @@ test "mmap" {
574574 const data = try os.mmap(
575575 null,
576576 alloc_size / 2,
577 os.PROT_READ,
578 os.MAP_PRIVATE,
577 os.PROT.READ,
578 os.MAP.PRIVATE,
579579 file.handle,
580580 alloc_size / 2,
581581 );
......@@ -616,19 +616,19 @@ test "fcntl" {
616616 tmp.dir.deleteFile(test_out_file) catch {};
617617 }
618618
619 // Note: The test assumes createFile opens the file with O_CLOEXEC
619 // Note: The test assumes createFile opens the file with O.CLOEXEC
620620 {
621 const flags = try os.fcntl(file.handle, os.F_GETFD, 0);
621 const flags = try os.fcntl(file.handle, os.F.GETFD, 0);
622622 try expect((flags & os.FD_CLOEXEC) != 0);
623623 }
624624 {
625 _ = try os.fcntl(file.handle, os.F_SETFD, 0);
626 const flags = try os.fcntl(file.handle, os.F_GETFD, 0);
625 _ = try os.fcntl(file.handle, os.F.SETFD, 0);
626 const flags = try os.fcntl(file.handle, os.F.GETFD, 0);
627627 try expect((flags & os.FD_CLOEXEC) == 0);
628628 }
629629 {
630 _ = try os.fcntl(file.handle, os.F_SETFD, os.FD_CLOEXEC);
631 const flags = try os.fcntl(file.handle, os.F_GETFD, 0);
630 _ = try os.fcntl(file.handle, os.F.SETFD, os.FD_CLOEXEC);
631 const flags = try os.fcntl(file.handle, os.F.GETFD, 0);
632632 try expect((flags & os.FD_CLOEXEC) != 0);
633633 }
634634}
......@@ -698,7 +698,7 @@ test "shutdown socket" {
698698 std.os.windows.WSACleanup() catch unreachable;
699699 }
700700 }
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);
702702 os.shutdown(sock, .both) catch |err| switch (err) {
703703 error.SocketNotConnected => {},
704704 else => |e| return e,
......@@ -722,11 +722,11 @@ test "sigaction" {
722722 // Check that we received the correct signal.
723723 switch (native_os) {
724724 .netbsd => {
725 if (sig == os.SIGUSR1 and sig == info.info.signo)
725 if (sig == os.SIG.USR1 and sig == info.info.signo)
726726 signal_test_failed = false;
727727 },
728728 else => {
729 if (sig == os.SIGUSR1 and sig == info.signo)
729 if (sig == os.SIG.USR1 and sig == info.signo)
730730 signal_test_failed = false;
731731 },
732732 }
......@@ -736,21 +736,21 @@ test "sigaction" {
736736 var sa = os.Sigaction{
737737 .handler = .{ .sigaction = S.handler },
738738 .mask = os.empty_sigset,
739 .flags = os.SA_SIGINFO | os.SA_RESETHAND,
739 .flags = os.SA.SIGINFO | os.SA.RESETHAND,
740740 };
741741 var old_sa: os.Sigaction = undefined;
742742 // Install the new signal handler.
743 os.sigaction(os.SIGUSR1, &sa, null);
743 os.sigaction(os.SIG.USR1, &sa, null);
744744 // 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);
746746 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);
748748 // Invoke the handler.
749 try os.raise(os.SIGUSR1);
749 try os.raise(os.SIG.USR1);
750750 try testing.expect(signal_test_failed == false);
751751 // Check if the handler has been correctly reset to SIG_DFL
752 os.sigaction(os.SIGUSR1, null, &old_sa);
753 try testing.expectEqual(os.SIG_DFL, old_sa.handler.sigaction);
752 os.sigaction(os.SIG.USR1, null, &old_sa);
753 try testing.expectEqual(os.SIG.DFL, old_sa.handler.sigaction);
754754}
755755
756756test "dup & dup2" {
lib/std/os/wasi.zig+14-9
......@@ -382,8 +382,14 @@ pub const prestat_u_t = extern union {
382382};
383383
384384pub const riflags_t = u16;
385pub const SOCK_RECV_PEEK: riflags_t = 0x0001;
386pub const SOCK_RECV_WAITALL: riflags_t = 0x0002;
385pub const roflags_t = u16;
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
388394pub const rights_t = u64;
389395pub const RIGHT_FD_DATASYNC: rights_t = 0x0000000000000001;
......@@ -445,9 +451,6 @@ pub const RIGHT_ALL: rights_t = RIGHT_FD_DATASYNC |
445451 RIGHT_POLL_FD_READWRITE |
446452 RIGHT_SOCK_SHUTDOWN;
447453
448pub const roflags_t = u16;
449pub const SOCK_RECV_DATA_TRUNCATED: roflags_t = 0x0001;
450
451454pub const sdflags_t = u8;
452455pub const SHUT_RD: sdflags_t = 0x01;
453456pub const SHUT_WR: sdflags_t = 0x02;
......@@ -541,7 +544,9 @@ pub const SEEK_SET = WHENCE_SET;
541544pub const SEEK_CUR = WHENCE_CUR;
542545pub const SEEK_END = WHENCE_END;
543546
544pub const LOCK_SH = 0x1;
545pub const LOCK_EX = 0x2;
546pub const LOCK_NB = 0x4;
547pub const LOCK_UN = 0x8;
547pub const LOCK = struct {
548 pub const SH = 0x1;
549 pub const EX = 0x2;
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;
178178pub const WINDOWS_AF_IRDA = 26;
179179pub const WCE_AF_IRDA = 22;
180180pub const IRDA_PROTO_SOCK_STREAM = 1;
181pub const SOL_IRLMP = 255;
182181pub const IRLMP_ENUMDEVICES = 16;
183182pub const IRLMP_IAS_SET = 17;
184183pub const IRLMP_IAS_QUERY = 18;
......@@ -237,7 +236,6 @@ pub const IPX_MAX_ADAPTER_NUM = 16397;
237236pub const IPX_RERIPNETNUMBER = 16398;
238237pub const IPX_RECEIVE_BROADCAST = 16399;
239238pub const IPX_IMMEDIATESPXACK = 16400;
240pub const IPPROTO_RM = 113;
241239pub const MAX_MCAST_TTL = 255;
242240pub const RM_OPTIONSBASE = 1000;
243241pub const RM_RATE_WINDOW_SIZE = 1001;
......@@ -449,75 +447,117 @@ pub const TCP_ICMP_ERROR_INFO = 19;
449447pub const UDP_SEND_MSG_SIZE = 2;
450448pub const UDP_RECV_MAX_COALESCED_SIZE = 3;
451449pub const UDP_COALESCED_INFO = 3;
452pub const AF_UNSPEC = 0;
453pub const AF_UNIX = 1;
454pub const AF_INET = 2;
455pub const AF_IMPLINK = 3;
456pub const AF_PUP = 4;
457pub const AF_CHAOS = 5;
458pub const AF_NS = 6;
459pub const AF_ISO = 7;
460pub const AF_ECMA = 8;
461pub const AF_DATAKIT = 9;
462pub const AF_CCITT = 10;
463pub const AF_SNA = 11;
464pub const AF_DECnet = 12;
465pub const AF_DLI = 13;
466pub const AF_LAT = 14;
467pub const AF_HYLINK = 15;
468pub const AF_APPLETALK = 16;
469pub const AF_NETBIOS = 17;
470pub const AF_VOICEVIEW = 18;
471pub const AF_FIREFOX = 19;
472pub const AF_UNKNOWN1 = 20;
473pub const AF_BAN = 21;
474pub const AF_ATM = 22;
475pub const AF_INET6 = 23;
476pub const AF_CLUSTER = 24;
477pub const AF_12844 = 25;
478pub const AF_IRDA = 26;
479pub const AF_NETDES = 28;
480pub const AF_MAX = 29;
481pub const AF_TCNPROCESS = 29;
482pub const AF_TCNMESSAGE = 30;
483pub const AF_ICLFXBM = 31;
484pub const AF_LINK = 33;
485pub const AF_HYPERV = 34;
486pub const SOCK_STREAM = 1;
487pub const SOCK_DGRAM = 2;
488pub const SOCK_RAW = 3;
489pub const SOCK_RDM = 4;
490pub const SOCK_SEQPACKET = 5;
491pub const SOL_SOCKET = 65535;
492pub const SO_DEBUG = 1;
493pub const SO_ACCEPTCONN = 2;
494pub const SO_REUSEADDR = 4;
495pub const SO_KEEPALIVE = 8;
496pub const SO_DONTROUTE = 16;
497pub const SO_BROADCAST = 32;
498pub const SO_USELOOPBACK = 64;
499pub const SO_LINGER = 128;
500pub const SO_OOBINLINE = 256;
501pub const SO_SNDBUF = 4097;
502pub const SO_RCVBUF = 4098;
503pub const SO_SNDLOWAT = 4099;
504pub const SO_RCVLOWAT = 4100;
505pub const SO_SNDTIMEO = 4101;
506pub const SO_RCVTIMEO = 4102;
507pub const SO_ERROR = 4103;
508pub const SO_TYPE = 4104;
509pub const SO_BSP_STATE = 4105;
510pub const SO_GROUP_ID = 8193;
511pub const SO_GROUP_PRIORITY = 8194;
512pub const SO_MAX_MSG_SIZE = 8195;
513pub const SO_CONDITIONAL_ACCEPT = 12290;
514pub const SO_PAUSE_ACCEPT = 12291;
515pub const SO_COMPARTMENT_ID = 12292;
516pub const SO_RANDOMIZE_PORT = 12293;
517pub const SO_PORT_SCALABILITY = 12294;
518pub const SO_REUSE_UNICASTPORT = 12295;
519pub const SO_REUSE_MULTICASTPORT = 12296;
520pub const SO_ORIGINAL_DST = 12303;
450
451pub const AF = struct {
452 pub const UNSPEC = 0;
453 pub const UNIX = 1;
454 pub const INET = 2;
455 pub const IMPLINK = 3;
456 pub const PUP = 4;
457 pub const CHAOS = 5;
458 pub const NS = 6;
459 pub const IPX = 6;
460 pub const ISO = 7;
461 pub const ECMA = 8;
462 pub const DATAKIT = 9;
463 pub const CCITT = 10;
464 pub const SNA = 11;
465 pub const DECnet = 12;
466 pub const DLI = 13;
467 pub const LAT = 14;
468 pub const HYLINK = 15;
469 pub const APPLETALK = 16;
470 pub const NETBIOS = 17;
471 pub const VOICEVIEW = 18;
472 pub const FIREFOX = 19;
473 pub const UNKNOWN1 = 20;
474 pub const BAN = 21;
475 pub const ATM = 22;
476 pub const INET6 = 23;
477 pub const CLUSTER = 24;
478 pub const @"12844" = 25;
479 pub const IRDA = 26;
480 pub const NETDES = 28;
481 pub const MAX = 29;
482 pub const TCNPROCESS = 29;
483 pub const TCNMESSAGE = 30;
484 pub const ICLFXBM = 31;
485 pub const LINK = 33;
486 pub const HYPERV = 34;
487};
488
489pub const SOCK = struct {
490 pub const STREAM = 1;
491 pub const DGRAM = 2;
492 pub const RAW = 3;
493 pub const RDM = 4;
494 pub const SEQPACKET = 5;
495
496 /// WARNING: this flag is not supported by windows socket functions directly,
497 /// it is only supported by std.os.socket. Be sure that this value does
498 /// not share any bits with any of the `SOCK` values.
499 pub const CLOEXEC = 0x10000;
500 /// WARNING: this flag is not supported by windows socket functions directly,
501 /// it is only supported by std.os.socket. Be sure that this value does
502 /// not share any bits with any of the `SOCK` values.
503 pub const NONBLOCK = 0x20000;
504};
505
506pub const SOL = struct {
507 pub const IRLMP = 255;
508 pub const SOCKET = 65535;
509};
510
511pub const SO = struct {
512 pub const DEBUG = 1;
513 pub const ACCEPTCONN = 2;
514 pub const REUSEADDR = 4;
515 pub const KEEPALIVE = 8;
516 pub const DONTROUTE = 16;
517 pub const BROADCAST = 32;
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
521561pub const WSK_SO_BASE = 16384;
522562pub const TCP_NODELAY = 1;
523563pub const IOC_UNIX = 0;
......@@ -529,7 +569,6 @@ pub const SIO_BSP_HANDLE = IOC_OUT | IOC_WS2 | 27;
529569pub const SIO_BSP_HANDLE_SELECT = IOC_OUT | IOC_WS2 | 28;
530570pub const SIO_BSP_HANDLE_POLL = IOC_OUT | IOC_WS2 | 29;
531571pub const SIO_BASE_HANDLE = IOC_OUT | IOC_WS2 | 34;
532pub const IPPROTO_IP = 0;
533572pub const IPPORT_TCPMUX = 1;
534573pub const IPPORT_ECHO = 7;
535574pub const IPPORT_DISCARD = 9;
......@@ -596,27 +635,41 @@ pub const IOCPARM_MASK = 127;
596635pub const IOC_VOID = 536870912;
597636pub const IOC_OUT = 1073741824;
598637pub const IOC_IN = 2147483648;
599pub const MSG_TRUNC = 256;
600pub const MSG_CTRUNC = 512;
601pub const MSG_BCAST = 1024;
602pub const MSG_MCAST = 2048;
603pub const MSG_ERRQUEUE = 4096;
604pub const AI_PASSIVE = 1;
605pub const AI_CANONNAME = 2;
606pub const AI_NUMERICHOST = 4;
607pub const AI_NUMERICSERV = 8;
608pub const AI_DNS_ONLY = 16;
609pub const AI_ALL = 256;
610pub const AI_ADDRCONFIG = 1024;
611pub const AI_V4MAPPED = 2048;
612pub const AI_NON_AUTHORITATIVE = 16384;
613pub const AI_SECURE = 32768;
614pub const AI_RETURN_PREFERRED_NAMES = 65536;
615pub const AI_FQDN = 131072;
616pub const AI_FILESERVER = 262144;
617pub const AI_DISABLE_IDN_ENCODING = 524288;
618pub const AI_EXTENDED = 2147483648;
619pub const AI_RESOLUTION_HANDLE = 1073741824;
638
639pub const MSG = struct {
640 pub const TRUNC = 256;
641 pub const CTRUNC = 512;
642 pub const BCAST = 1024;
643 pub const MCAST = 2048;
644 pub const ERRQUEUE = 4096;
645
646 pub const PEEK = 2;
647 pub const WAITALL = 8;
648 pub const PUSH_IMMEDIATE = 32;
649 pub const PARTIAL = 32768;
650 pub const INTERRUPT = 16;
651 pub const MAXIOVLEN = 16;
652};
653
654pub const AI = struct {
655 pub const PASSIVE = 1;
656 pub const CANONNAME = 2;
657 pub const NUMERICHOST = 4;
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
620673pub const FIONBIO = -2147195266;
621674pub const ADDRINFOEX_VERSION_2 = 2;
622675pub const ADDRINFOEX_VERSION_3 = 3;
......@@ -660,16 +713,8 @@ pub const WSADESCRIPTION_LEN = 256;
660713pub const WSASYS_STATUS_LEN = 128;
661714pub const SOCKET_ERROR = -1;
662715pub const FROM_PROTOCOL_INFO = -1;
663pub const SO_PROTOCOL_INFOA = 8196;
664pub const SO_PROTOCOL_INFOW = 8197;
665716pub const PVD_CONFIG = 12289;
666717pub 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;
673718pub const MAXGETHOSTSTRUCT = 1024;
674719pub const FD_READ_BIT = 0;
675720pub const FD_WRITE_BIT = 1;
......@@ -770,30 +815,18 @@ pub const RESULT_IS_ALIAS = 1;
770815pub const RESULT_IS_ADDED = 16;
771816pub const RESULT_IS_CHANGED = 32;
772817pub const RESULT_IS_DELETED = 64;
773pub const POLLRDNORM = 256;
774pub const POLLRDBAND = 512;
775pub const POLLPRI = 1024;
776pub const POLLWRNORM = 16;
777pub const POLLWRBAND = 32;
778pub const POLLERR = 1;
779pub const POLLHUP = 2;
780pub const POLLNVAL = 4;
781pub const SO_CONNDATA = 28672;
782pub const SO_CONNOPT = 28673;
783pub const SO_DISCDATA = 28674;
784pub const SO_DISCOPT = 28675;
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;
818
819pub const POLL = struct {
820 pub const RDNORM = 256;
821 pub const RDBAND = 512;
822 pub const PRI = 1024;
823 pub const WRNORM = 16;
824 pub const WRBAND = 32;
825 pub const ERR = 1;
826 pub const HUP = 2;
827 pub const NVAL = 4;
828};
829
797830pub const TCP_BSDURGENT = 28672;
798831pub const TF_DISCONNECT = 1;
799832pub const TF_REUSE_SOCKET = 2;
......@@ -817,20 +850,25 @@ pub const LSP_INBOUND_MODIFY = 16;
817850pub const LSP_OUTBOUND_MODIFY = 32;
818851pub const LSP_CRYPTO_COMPRESS = 64;
819852pub const LSP_LOCAL_CACHE = 128;
820pub const IPPROTO_ICMP = 1;
821pub const IPPROTO_IGMP = 2;
822pub const IPPROTO_GGP = 3;
823pub const IPPROTO_TCP = 6;
824pub const IPPROTO_PUP = 12;
825pub const IPPROTO_UDP = 17;
826pub const IPPROTO_IDP = 22;
827pub const IPPROTO_ND = 77;
828pub const IPPROTO_RAW = 255;
829pub const IPPROTO_MAX = 256;
853
854pub const IPPROTO = struct {
855 pub const IP = 0;
856 pub const ICMP = 1;
857 pub const IGMP = 2;
858 pub const GGP = 3;
859 pub const TCP = 6;
860 pub const PUP = 12;
861 pub const UDP = 17;
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
830869pub const IP_DEFAULT_MULTICAST_TTL = 1;
831870pub const IP_DEFAULT_MULTICAST_LOOP = 1;
832871pub const IP_MAX_MEMBERSHIPS = 20;
833pub const AF_IPX = 6;
834872pub const FD_READ = 1;
835873pub const FD_WRITE = 2;
836874pub const FD_OOB = 4;
......@@ -1051,31 +1089,31 @@ pub const addrinfoexA = extern struct {
10511089pub const sockaddr = extern struct {
10521090 family: ADDRESS_FAMILY,
10531091 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 address
1059pub const sockaddr_in = extern struct {
1060 family: ADDRESS_FAMILY = AF_INET,
1061 port: USHORT,
1062 addr: u32,
1063 zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },
1064};
1095 /// IPv4 socket address
1096 pub const in = extern struct {
1097 family: ADDRESS_FAMILY = AF.INET,
1098 port: USHORT,
1099 addr: u32,
1100 zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },
1101 };
10651102
1066/// IPv6 socket address
1067pub const sockaddr_in6 = extern struct {
1068 family: ADDRESS_FAMILY = AF_INET6,
1069 port: USHORT,
1070 flowinfo: u32,
1071 addr: [16]u8,
1072 scope_id: u32,
1073};
1103 /// IPv6 socket address
1104 pub const in6 = extern struct {
1105 family: ADDRESS_FAMILY = AF.INET6,
1106 port: USHORT,
1107 flowinfo: u32,
1108 addr: [16]u8,
1109 scope_id: u32,
1110 };
10741111
1075/// UNIX domain socket address
1076pub const sockaddr_un = extern struct {
1077 family: ADDRESS_FAMILY = AF_UNIX,
1078 path: [108]u8,
1112 /// UNIX domain socket address
1113 pub const un = extern struct {
1114 family: ADDRESS_FAMILY = AF.UNIX,
1115 path: [108]u8,
1116 };
10791117};
10801118
10811119pub const WSABUF = extern struct {
......@@ -1237,9 +1275,9 @@ pub const WinsockError = enum(u16) {
12371275
12381276 /// Permission denied.
12391277 /// 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).
12411279 /// 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.
12431281 WSAEACCES = 10013,
12441282
12451283 /// Bad address.
......@@ -1260,7 +1298,7 @@ pub const WinsockError = enum(u16) {
12601298 /// Resource temporarily unavailable.
12611299 /// 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.
12621300 /// 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.
12641302 WSAEWOULDBLOCK = 10035,
12651303
12661304 /// Operation now in progress.
......@@ -1288,7 +1326,7 @@ pub const WinsockError = enum(u16) {
12881326
12891327 /// Protocol wrong type for socket.
12901328 /// 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.
12921330 WSAEPROTOTYPE = 10041,
12931331
12941332 /// Bad protocol option.
......@@ -1297,12 +1335,12 @@ pub const WinsockError = enum(u16) {
12971335
12981336 /// Protocol not supported.
12991337 /// 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.
13011339 WSAEPROTONOSUPPORT = 10043,
13021340
13031341 /// Socket type not supported.
13041342 /// 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.
13061344 WSAESOCKTNOSUPPORT = 10044,
13071345
13081346 /// Operation not supported.
......@@ -1318,14 +1356,14 @@ pub const WinsockError = enum(u16) {
13181356
13191357 /// Address family not supported by protocol family.
13201358 /// 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).
13221360 /// 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.
13231361 WSAEAFNOSUPPORT = 10047,
13241362
13251363 /// Address already in use.
13261364 /// Typically, only one usage of each socket address (protocol/IP address/port) is permitted.
13271365 /// 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).
13291367 /// Client applications usually need not call bind at all—connect chooses an unused port automatically.
13301368 /// When bind is called with a wildcard address (involving ADDR_ANY), a WSAEADDRINUSE error could be delayed until the specific address is committed.
13311369 /// 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) {
13491387
13501388 /// Network dropped connection on reset.
13511389 /// 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.
13531391 WSAENETRESET = 10052,
13541392
13551393 /// Software caused connection abort.
......@@ -1358,7 +1396,7 @@ pub const WinsockError = enum(u16) {
13581396
13591397 /// Connection reset by peer.
13601398 /// 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).
13621400 /// 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.
13631401 /// Operations that were in progress fail with WSAENETRESET. Subsequent operations fail with WSAECONNRESET.
13641402 WSAECONNRESET = 10054,
......@@ -1369,12 +1407,12 @@ pub const WinsockError = enum(u16) {
13691407
13701408 /// Socket is already connected.
13711409 /// 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.
13731411 WSAEISCONN = 10056,
13741412
13751413 /// Socket is not connected.
13761414 /// 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.
13781416 WSAENOTCONN = 10057,
13791417
13801418 /// Cannot send after socket shutdown.
lib/std/time.zig+2-2
......@@ -86,12 +86,12 @@ pub fn nanoTimestamp() i128 {
8686 }
8787 if (builtin.os.tag == .wasi and !builtin.link_libc) {
8888 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);
9090 assert(err == .SUCCESS);
9191 return ns;
9292 }
9393 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) {
9595 error.UnsupportedClock, error.Unexpected => return 0, // "Precision of timing depends on hardware and OS".
9696 };
9797 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 {
4646
4747/// Possible domains that a TCP client/listener may operate over.
4848pub const Domain = enum(u16) {
49 ip = os.AF_INET,
50 ipv6 = os.AF_INET6,
49 ip = os.AF.INET,
50 ipv6 = os.AF.INET6,
5151};
5252
5353/// A TCP client.
......@@ -81,8 +81,8 @@ pub const Client = struct {
8181 return Client{
8282 .socket = try Socket.init(
8383 @enumToInt(domain),
84 os.SOCK_STREAM,
85 os.IPPROTO_TCP,
84 os.SOCK.STREAM,
85 os.IPPROTO.TCP,
8686 flags,
8787 ),
8888 };
......@@ -195,7 +195,7 @@ pub const Client = struct {
195195 pub fn setNoDelay(self: Client, enabled: bool) !void {
196196 if (comptime @hasDecl(os, "TCP_NODELAY")) {
197197 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);
199199 }
200200 return error.UnsupportedSocketOption;
201201 }
......@@ -204,7 +204,7 @@ pub const Client = struct {
204204 /// `error.UnsupportedSocketOption` if the host does not support TCP Quick ACK.
205205 pub fn setQuickACK(self: Client, enabled: bool) !void {
206206 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))));
208208 }
209209 return error.UnsupportedSocketOption;
210210 }
......@@ -244,8 +244,8 @@ pub const Listener = struct {
244244 return Listener{
245245 .socket = try Socket.init(
246246 @enumToInt(domain),
247 os.SOCK_STREAM,
248 os.IPPROTO_TCP,
247 os.SOCK.STREAM,
248 os.IPPROTO.TCP,
249249 flags,
250250 ),
251251 };
......@@ -305,7 +305,7 @@ pub const Listener = struct {
305305 /// support TCP Fast Open.
306306 pub fn setFastOpen(self: Listener, enabled: bool) !void {
307307 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))));
309309 }
310310 return error.UnsupportedSocketOption;
311311 }
lib/std/x/os/io.zig+14-13
......@@ -4,6 +4,7 @@ const os = std.os;
44const mem = std.mem;
55const testing = std.testing;
66const native_os = std.Target.current.os;
7const linux = std.os.linux;
78
89/// POSIX `iovec`, or Windows `WSABUF`. The difference between the two are the ordering
910/// of fields, alongside the length being represented as either a ULONG or a size_t.
......@@ -67,7 +68,7 @@ pub const Reactor = struct {
6768 pub fn init(flags: std.enums.EnumFieldStruct(Reactor.InitFlags, bool, false)) !Reactor {
6869 var raw_flags: u32 = 0;
6970 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;
7172 return Reactor{ .fd = try os.epoll_create1(raw_flags) };
7273 }
7374
......@@ -77,31 +78,31 @@ pub const Reactor = struct {
7778
7879 pub fn update(self: Reactor, fd: os.fd_t, identifier: usize, interest: Reactor.Interest) !void {
7980 var flags: u32 = 0;
80 flags |= if (interest.oneshot) os.EPOLLONESHOT else os.EPOLLET;
81 if (interest.hup) flags |= os.EPOLLRDHUP;
82 if (interest.readable) flags |= os.EPOLLIN;
83 if (interest.writable) flags |= os.EPOLLOUT;
81 flags |= if (interest.oneshot) linux.EPOLL.ONESHOT else linux.EPOLL.ET;
82 if (interest.hup) flags |= linux.EPOLL.RDHUP;
83 if (interest.readable) flags |= linux.EPOLL.IN;
84 if (interest.writable) flags |= linux.EPOLL.OUT;
8485
85 const event = &os.epoll_event{
86 const event = &linux.epoll_event{
8687 .events = flags,
8788 .data = .{ .ptr = identifier },
8889 };
8990
90 os.epoll_ctl(self.fd, os.EPOLL_CTL_MOD, fd, event) catch |err| switch (err) {
91 error.FileDescriptorNotRegistered => try os.epoll_ctl(self.fd, os.EPOLL_CTL_ADD, fd, event),
91 os.epoll_ctl(self.fd, linux.EPOLL.CTL_MOD, fd, event) catch |err| switch (err) {
92 error.FileDescriptorNotRegistered => try os.epoll_ctl(self.fd, linux.EPOLL.CTL_ADD, fd, event),
9293 else => return err,
9394 };
9495 }
9596
9697 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
99100 const num_events = os.epoll_wait(self.fd, &events, if (timeout_milliseconds) |ms| @intCast(i32, ms) else -1);
100101 for (events[0..num_events]) |ev| {
101 const is_error = ev.events & os.EPOLLERR != 0;
102 const is_hup = ev.events & (os.EPOLLHUP | os.EPOLLRDHUP) != 0;
103 const is_readable = ev.events & os.EPOLLIN != 0;
104 const is_writable = ev.events & os.EPOLLOUT != 0;
102 const is_error = ev.events & linux.EPOLL.ERR != 0;
103 const is_hup = ev.events & (linux.EPOLL.HUP | linux.EPOLL.RDHUP) != 0;
104 const is_readable = ev.events & linux.EPOLL.IN != 0;
105 const is_writable = ev.events & linux.EPOLL.OUT != 0;
105106
106107 try closure.call(Reactor.Event{
107108 .data = ev.data.ptr,
lib/std/x/os/net.zig+1-1
......@@ -22,7 +22,7 @@ pub fn resolveScopeID(name: []const u8) !u32 {
2222 return os.windows.ws2_32.if_nametoindex(@ptrCast([*:0]const u8, &interface_name));
2323 }
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);
2626 defer os.closeSocket(fd);
2727
2828 var f: os.ifreq = undefined;
lib/std/x/os/socket.zig+9-9
......@@ -35,7 +35,7 @@ pub const Socket = struct {
3535
3636 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.
3939 pub const Storage = extern struct {
4040 pub const expected_size = 128;
4141 pub const expected_alignment = 8;
......@@ -71,14 +71,14 @@ pub const Socket = struct {
7171 /// Parses a `sockaddr` into a generic socket address.
7272 pub fn fromNative(address: *align(4) const os.sockaddr) Socket.Address {
7373 switch (address.family) {
74 os.AF_INET => {
75 const info = @ptrCast(*const os.sockaddr_in, address);
74 os.AF.INET => {
75 const info = @ptrCast(*const os.sockaddr.in, address);
7676 const host = net.IPv4{ .octets = @bitCast([4]u8, info.addr) };
7777 const port = mem.bigToNative(u16, info.port);
7878 return Socket.Address.initIPv4(host, port);
7979 },
80 os.AF_INET6 => {
81 const info = @ptrCast(*const os.sockaddr_in6, address);
80 os.AF.INET6 => {
81 const info = @ptrCast(*const os.sockaddr.in6, address);
8282 const host = net.IPv6{ .octets = info.addr, .scope_id = info.scope_id };
8383 const port = mem.bigToNative(u16, info.port);
8484 return Socket.Address.initIPv6(host, port);
......@@ -90,8 +90,8 @@ pub const Socket = struct {
9090 /// Encodes a generic socket address into an extern union that may be reliably
9191 /// casted into a `sockaddr` which may be passed into socket syscalls.
9292 pub fn toNative(self: Socket.Address) extern union {
93 ipv4: os.sockaddr_in,
94 ipv6: os.sockaddr_in6,
93 ipv4: os.sockaddr.in,
94 ipv6: os.sockaddr.in6,
9595 } {
9696 return switch (self) {
9797 .ipv4 => |address| .{
......@@ -114,8 +114,8 @@ pub const Socket = struct {
114114 /// Returns the number of bytes that make up the `sockaddr` equivalent to the address.
115115 pub fn getNativeSize(self: Socket.Address) u32 {
116116 return switch (self) {
117 .ipv4 => @sizeOf(os.sockaddr_in),
118 .ipv6 => @sizeOf(os.sockaddr_in6),
117 .ipv4 => @sizeOf(os.sockaddr.in),
118 .ipv6 => @sizeOf(os.sockaddr.in6),
119119 };
120120 }
121121
lib/std/x/os/socket_posix.zig+18-18
......@@ -10,8 +10,8 @@ pub fn Mixin(comptime Socket: type) type {
1010 pub fn init(domain: u32, socket_type: u32, protocol: u32, flags: std.enums.EnumFieldStruct(Socket.InitFlags, bool, false)) !Socket {
1111 var raw_flags: u32 = socket_type;
1212 const set = std.EnumSet(Socket.InitFlags).init(flags);
13 if (set.contains(.close_on_exec)) raw_flags |= os.SOCK_CLOEXEC;
14 if (set.contains(.nonblocking)) raw_flags |= os.SOCK_NONBLOCK;
13 if (set.contains(.close_on_exec)) raw_flags |= os.SOCK.CLOEXEC;
14 if (set.contains(.nonblocking)) raw_flags |= os.SOCK.NONBLOCK;
1515 return Socket{ .fd = try os.socket(domain, raw_flags, protocol) };
1616 }
1717
......@@ -48,8 +48,8 @@ pub fn Mixin(comptime Socket: type) type {
4848
4949 var raw_flags: u32 = 0;
5050 const set = std.EnumSet(Socket.InitFlags).init(flags);
51 if (set.contains(.close_on_exec)) raw_flags |= os.SOCK_CLOEXEC;
52 if (set.contains(.nonblocking)) raw_flags |= os.SOCK_NONBLOCK;
51 if (set.contains(.close_on_exec)) raw_flags |= os.SOCK.CLOEXEC;
52 if (set.contains(.nonblocking)) raw_flags |= os.SOCK.NONBLOCK;
5353
5454 const socket = Socket{ .fd = try os.accept(self.fd, @ptrCast(*os.sockaddr, &address), &address_len, raw_flags) };
5555 const socket_address = Socket.Address.fromNative(@ptrCast(*os.sockaddr, &address));
......@@ -156,7 +156,7 @@ pub fn Mixin(comptime Socket: type) type {
156156 var value: u32 = undefined;
157157 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);
160160 return switch (os.errno(rc)) {
161161 .SUCCESS => value,
162162 .BADF => error.BadFileDescriptor,
......@@ -173,7 +173,7 @@ pub fn Mixin(comptime Socket: type) type {
173173 var value: u32 = undefined;
174174 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);
177177 return switch (os.errno(rc)) {
178178 .SUCCESS => value,
179179 .BADF => error.BadFileDescriptor,
......@@ -195,9 +195,9 @@ pub fn Mixin(comptime Socket: type) type {
195195 /// if the host does not support the option for a socket to linger around up until a timeout specified in
196196 /// seconds.
197197 pub fn setLinger(self: Socket, timeout_seconds: ?u16) !void {
198 if (comptime @hasDecl(os, "SO_LINGER")) {
198 if (@hasDecl(os.SO, "LINGER")) {
199199 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));
201201 }
202202
203203 return error.UnsupportedSocketOption;
......@@ -207,8 +207,8 @@ pub fn Mixin(comptime Socket: type) type {
207207 /// messages are sent are dependant on operating system settings. It returns `error.UnsupportedSocketOption` if
208208 /// the host does not support periodically sending keep-alive messages on connection-oriented sockets.
209209 pub fn setKeepAlive(self: Socket, enabled: bool) !void {
210 if (comptime @hasDecl(os, "SO_KEEPALIVE")) {
211 return self.setOption(os.SOL_SOCKET, os.SO_KEEPALIVE, mem.asBytes(&@as(u32, @boolToInt(enabled))));
210 if (@hasDecl(os.SO, "KEEPALIVE")) {
211 return self.setOption(os.SOL.SOCKET, os.SO.KEEPALIVE, mem.asBytes(&@as(u32, @boolToInt(enabled))));
212212 }
213213 return error.UnsupportedSocketOption;
214214 }
......@@ -216,8 +216,8 @@ pub fn Mixin(comptime Socket: type) type {
216216 /// Allow multiple sockets on the same host to listen on the same address. It returns `error.UnsupportedSocketOption` if
217217 /// the host does not support sockets listening the same address.
218218 pub fn setReuseAddress(self: Socket, enabled: bool) !void {
219 if (comptime @hasDecl(os, "SO_REUSEADDR")) {
220 return self.setOption(os.SOL_SOCKET, os.SO_REUSEADDR, mem.asBytes(&@as(u32, @boolToInt(enabled))));
219 if (@hasDecl(os.SO, "REUSEADDR")) {
220 return self.setOption(os.SOL.SOCKET, os.SO.REUSEADDR, mem.asBytes(&@as(u32, @boolToInt(enabled))));
221221 }
222222 return error.UnsupportedSocketOption;
223223 }
......@@ -225,20 +225,20 @@ pub fn Mixin(comptime Socket: type) type {
225225 /// Allow multiple sockets on the same host to listen on the same port. It returns `error.UnsupportedSocketOption` if
226226 /// the host does not supports sockets listening on the same port.
227227 pub fn setReusePort(self: Socket, enabled: bool) !void {
228 if (comptime @hasDecl(os, "SO_REUSEPORT")) {
229 return self.setOption(os.SOL_SOCKET, os.SO_REUSEPORT, mem.asBytes(&@as(u32, @boolToInt(enabled))));
228 if (@hasDecl(os.SO, "REUSEPORT")) {
229 return self.setOption(os.SOL.SOCKET, os.SO.REUSEPORT, mem.asBytes(&@as(u32, @boolToInt(enabled))));
230230 }
231231 return error.UnsupportedSocketOption;
232232 }
233233
234234 /// Set the write buffer size of the socket.
235235 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));
237237 }
238238
239239 /// Set the read buffer size of the socket.
240240 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));
242242 }
243243
244244 /// 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 {
253253 .tv_usec = @intCast(i32, (milliseconds % time.ms_per_s) * time.us_per_ms),
254254 };
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));
257257 }
258258
259259 /// 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 {
269269 .tv_usec = @intCast(i32, (milliseconds % time.ms_per_s) * time.us_per_ms),
270270 };
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));
273273 }
274274 };
275275}
lib/std/x/os/socket_windows.zig+9-9
......@@ -399,39 +399,39 @@ pub fn Mixin(comptime Socket: type) type {
399399 /// seconds.
400400 pub fn setLinger(self: Socket, timeout_seconds: ?u16) !void {
401401 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));
403403 }
404404
405405 /// On connection-oriented sockets, have keep-alive messages be sent periodically. The timing in which keep-alive
406406 /// messages are sent are dependant on operating system settings. It returns `error.UnsupportedSocketOption` if
407407 /// the host does not support periodically sending keep-alive messages on connection-oriented sockets.
408408 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))));
410410 }
411411
412412 /// Allow multiple sockets on the same host to listen on the same address. It returns `error.UnsupportedSocketOption` if
413413 /// the host does not support sockets listening the same address.
414414 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))));
416416 }
417417
418418 /// Allow multiple sockets on the same host to listen on the same port. It returns `error.UnsupportedSocketOption` if
419419 /// the host does not supports sockets listening on the same port.
420420 ///
421 /// TODO: verify if this truly mimicks SO_REUSEPORT behavior, or if SO_REUSE_UNICASTPORT provides the correct behavior
421 /// TODO: verify if this truly mimicks SO.REUSEPORT behavior, or if SO.REUSE_UNICASTPORT provides the correct behavior
422422 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))));
424424 try self.setReuseAddress(enabled);
425425 }
426426
427427 /// Set the write buffer size of the socket.
428428 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));
430430 }
431431
432432 /// Set the read buffer size of the socket.
433433 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));
435435 }
436436
437437 /// 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 {
441441 /// to its bound destination after a specified number of milliseconds. A subsequent write
442442 /// to the socket will thereafter return `error.WouldBlock` should the timeout be exceeded.
443443 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));
445445 }
446446
447447 /// 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 {
452452 /// read from the socket will thereafter return `error.WouldBlock` should the timeout be
453453 /// exceeded.
454454 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));
456456 }
457457 };
458458}
src/main.zig+2-2
......@@ -3836,7 +3836,7 @@ fn gimmeMoreOfThoseSweetSweetFileDescriptors() void {
38363836 // On Darwin, `NOFILE` is bounded by a hardcoded value `OPEN_MAX`.
38373837 // According to the man pages for setrlimit():
38383838 // 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.
38403840 // Use "rlim_cur = min(OPEN_MAX, rlim_max)".
38413841 lim.max = std.math.min(std.os.darwin.OPEN_MAX, lim.max);
38423842 }
......@@ -3846,7 +3846,7 @@ fn gimmeMoreOfThoseSweetSweetFileDescriptors() void {
38463846 var min: posix.rlim_t = lim.cur;
38473847 var max: posix.rlim_t = 1 << 20;
38483848 // 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) {
38503850 min = lim.max;
38513851 max = lim.max;
38523852 }