authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-08-28 15:34:17-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-09-01 17:54:06-07:00
logc05a20fc8c36742dab8792d15e79716da1a55759
treebb232f4e121d172ec66f68127f96dc15a28e0ef1
parent7884d84315f4080bfe429d3e29f7ebedf9f3f623

std: reorganization that allows new usingnamespace semantics

The proposal #9629 is now accepted, usingnamespace stays but no longer puts identifiers in scope.

51 files changed, 2115 insertions(+), 2072 deletions(-)

CMakeLists.txt-1
...@@ -431,7 +431,6 @@ set(ZIG_STAGE2_SOURCES...@@ -431,7 +431,6 @@ set(ZIG_STAGE2_SOURCES
431 "${CMAKE_SOURCE_DIR}/lib/std/os/linux/io_uring.zig"431 "${CMAKE_SOURCE_DIR}/lib/std/os/linux/io_uring.zig"
432 "${CMAKE_SOURCE_DIR}/lib/std/os/linux/x86_64.zig"432 "${CMAKE_SOURCE_DIR}/lib/std/os/linux/x86_64.zig"
433 "${CMAKE_SOURCE_DIR}/lib/std/os/windows.zig"433 "${CMAKE_SOURCE_DIR}/lib/std/os/windows.zig"
434 "${CMAKE_SOURCE_DIR}/lib/std/os/windows/bits.zig"
435 "${CMAKE_SOURCE_DIR}/lib/std/os/windows/ntstatus.zig"434 "${CMAKE_SOURCE_DIR}/lib/std/os/windows/ntstatus.zig"
436 "${CMAKE_SOURCE_DIR}/lib/std/os/windows/win32error.zig"435 "${CMAKE_SOURCE_DIR}/lib/std/os/windows/win32error.zig"
437 "${CMAKE_SOURCE_DIR}/lib/std/Progress.zig"436 "${CMAKE_SOURCE_DIR}/lib/std/Progress.zig"
lib/std/builtin.zig+1-1
...@@ -27,7 +27,7 @@ pub const code_model = builtin.code_model;...@@ -27,7 +27,7 @@ pub const code_model = builtin.code_model;
27/// used rather than `explicit_subsystem`.27/// used rather than `explicit_subsystem`.
28/// On non-Windows targets, this is `null`.28/// On non-Windows targets, this is `null`.
29pub const subsystem: ?std.Target.SubSystem = blk: {29pub const subsystem: ?std.Target.SubSystem = blk: {
30 if (@hasDecl(builtin, "explicit_subsystem")) break :blk explicit_subsystem;30 if (@hasDecl(builtin, "explicit_subsystem")) break :blk builtin.explicit_subsystem;
31 switch (os.tag) {31 switch (os.tag) {
32 .windows => {32 .windows => {
33 if (is_test) {33 if (is_test) {
lib/std/c.zig+211-287
...@@ -1,181 +1,17 @@...@@ -1,181 +1,17 @@
1const std = @import("std");1const std = @import("std");
2const builtin = std.builtin;2const builtin = std.builtin;
3const c = @This();
3const page_size = std.mem.page_size;4const page_size = std.mem.page_size;
4const iovec = std.os.iovec;5const iovec = std.os.iovec;
5const iovec_const = std.os.iovec_const;6const iovec_const = std.os.iovec_const;
67
7pub const tokenizer = @import("c/tokenizer.zig");
8pub const Token = tokenizer.Token;
9pub const Tokenizer = tokenizer.Tokenizer;
10
11test {8test {
12 _ = tokenizer;9 _ = tokenizer;
13}10}
1411
15const generic = @import("c/generic.zig");12pub const tokenizer = @import("c/tokenizer.zig");
16const system = switch (builtin.os.tag) {13pub const Token = tokenizer.Token;
17 .linux => @import("c/linux.zig"),14pub const Tokenizer = tokenizer.Tokenizer;
18 .windows => @import("c/windows.zig"),
19 .macos, .ios, .tvos, .watchos => @import("c/darwin.zig"),
20 .freebsd, .kfreebsd => @import("c/freebsd.zig"),
21 .netbsd => @import("c/netbsd.zig"),
22 .dragonfly => @import("c/dragonfly.zig"),
23 .openbsd => @import("c/openbsd.zig"),
24 .haiku => @import("c/haiku.zig"),
25 .hermit => @import("c/hermit.zig"),
26 .solaris => @import("c/solaris.zig"),
27 .fuchsia => @import("c/fuchsia.zig"),
28 .minix => @import("c/minix.zig"),
29 .emscripten => @import("c/emscripten.zig"),
30 .wasi => @import("c/wasi.zig"),
31 else => struct {},
32};
33
34pub const _errno = system._errno;
35pub const copy_file_range = system.copy_file_range;
36pub const fallocate64 = system.fallocate64;
37pub const fopen64 = system.fopen64;
38pub const fstat64 = system.fstat64;
39pub const fstatat64 = system.fstatat64;
40pub const ftruncate64 = system.ftruncate64;
41pub const getrlimit64 = system.getrlimit64;
42pub const lseek64 = system.lseek64;
43pub const mmap64 = system.mmap64;
44pub const open64 = system.open64;
45pub const openat64 = system.openat64;
46pub const pread64 = system.pread64;
47pub const preadv64 = system.preadv64;
48pub const pwrite64 = system.pwrite64;
49pub const pwritev64 = system.pwritev64;
50pub const sendfile64 = system.sendfile64;
51pub const setrlimit64 = system.setrlimit64;
52
53pub const AF = system.AF;
54pub const AI = system.AI;
55pub const AT = system.AT;
56pub const CLOCK = system.CLOCK;
57pub const CPU_COUNT = system.CPU_COUNT;
58pub const E = system.E;
59pub const EAI = system.EAI;
60pub const F = system.F;
61pub const FD_CLOEXEC = system.FD_CLOEXEC;
62pub const F_OK = system.F_OK;
63pub const HOST_NAME_MAX = system.HOST_NAME_MAX;
64pub const IFNAMESIZE = system.IFNAMESIZE;
65pub const IOV_MAX = system.IOV_MAX;
66pub const IPPROTO = system.IPPROTO;
67pub const LOCK = system.LOCK;
68pub const MADV = system.MADV;
69pub const MAP = system.MAP;
70pub const NAME_MAX = system.NAME_MAX;
71pub const NI = system.NI;
72pub const O = system.O;
73pub const PATH_MAX = system.PATH_MAX;
74pub const POLL = system.POLL;
75pub const PROT = system.PROT;
76pub const REG = system.REG;
77pub const RLIM = system.RLIM;
78pub const RTLD = system.RTLD;
79pub const R_OK = system.R_OK;
80pub const S = system.S;
81pub const SA = system.SA;
82pub const SEEK = system.SEEK;
83pub const SHUT = system.SHUT;
84pub const SIG = system.SIG;
85pub const SIOCGIFINDEX = system.SIOCGIFINDEX;
86pub const SO = system.SO;
87pub const SOCK = system.SOCK;
88pub const SOL = system.SOL;
89pub const STDERR_FILENO = system.STDERR_FILENO;
90pub const STDIN_FILENO = system.STDIN_FILENO;
91pub const STDOUT_FILENO = system.STDOUT_FILENO;
92pub const Sigaction = system.Sigaction;
93pub const Stat = system.Stat;
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;
100pub const dl_iterate_phdr_callback = system.dl_iterate_phdr_callback;
101pub const dl_phdr_info = system.dl_phdr_info;
102pub const empty_sigset = system.empty_sigset;
103pub const epoll_create1 = system.epoll_create1;
104pub const epoll_ctl = system.epoll_ctl;
105pub const epoll_pwait = system.epoll_pwait;
106pub const epoll_wait = system.epoll_wait;
107pub const eventfd = system.eventfd;
108pub const fallocate = system.fallocate;
109pub const fd_t = system.fd_t;
110pub const getauxval = system.getauxval;
111pub const getdents = system.getdents;
112pub const getrandom = system.getrandom;
113pub const gid_t = system.gid_t;
114pub const ifreq = system.ifreq;
115pub const ino_t = system.ino_t;
116pub const inotify_add_watch = system.inotify_add_watch;
117pub const inotify_init1 = system.inotify_init1;
118pub const inotify_rm_watch = system.inotify_rm_watch;
119pub const madvise = system.madvise;
120pub const malloc_usable_size = system.malloc_usable_size;
121pub const memfd_create = system.memfd_create;
122pub const mode_t = system.mode_t;
123pub const nfds_t = system.nfds_t;
124pub const off_t = system.off_t;
125pub const pid_t = system.pid_t;
126pub const pipe2 = system.pipe2;
127pub const pollfd = system.pollfd;
128pub const posix_memalign = system.posix_memalign;
129pub const prlimit = system.prlimit;
130pub const pthread_attr_t = system.pthread_attr_t;
131pub const pthread_cond_t = system.pthread_cond_t;
132pub const pthread_getname_np = system.pthread_getname_np;
133pub const pthread_mutex_t = system.pthread_mutex_t;
134pub const pthread_rwlock_t = system.pthread_rwlock_t;
135pub const pthread_setname_np = system.pthread_setname_np;
136pub const rlim_t = system.rlim_t;
137pub const rlimit = system.rlimit;
138pub const rlimit_resource = system.rlimit_resource;
139pub const sched_getaffinity = system.sched_getaffinity;
140pub const sem_t = system.sem_t;
141pub const sendfile = system.sendfile;
142pub const sigaltstack = system.sigaltstack;
143pub const siginfo_t = system.siginfo_t;
144pub const signalfd = system.signalfd;
145pub const sigset_t = system.sigset_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;
151pub const ucontext_t = system.ucontext_t;
152pub const uid_t = system.uid_t;
153pub const utsname = system.utsname;
154
155pub const alarm = if (@hasDecl(system, "alarm")) system.alarm else generic.alarm;
156pub const clock_getres = if (@hasDecl(system, "clock_getres")) system.clock_getres else generic.clock_getres;
157pub const clock_gettime = if (@hasDecl(system, "clock_gettime")) system.clock_gettime else generic.clock_gettime;
158pub const fstat = if (@hasDecl(system, "fstat")) system.fstat else generic.fstat;
159pub const fstatat = if (@hasDecl(system, "fstatat")) system.fstatat else generic.fstatat;
160pub const getrusage = if (@hasDecl(system, "getrusage")) system.getrusage else generic.getrusage;
161pub const gettimeofday = if (@hasDecl(system, "gettimeofday")) system.gettimeofday else generic.gettimeofday;
162pub const nanosleep = if (@hasDecl(system, "nanosleep")) system.nanosleep else generic.nanosleep;
163pub const realpath = if (@hasDecl(system, "realpath")) system.realpath else generic.realpath;
164pub const sched_yield = if (@hasDecl(system, "sched_yield")) system.sched_yield else generic.sched_yield;
165pub const sigaction = if (@hasDecl(system, "sigaction")) system.sigaction else generic.sigaction;
166pub const sigfillset = if (@hasDecl(system, "sigfillset")) system.sigfillset else generic.sigfillset;
167pub const sigprocmask = if (@hasDecl(system, "sigprocmask")) system.sigprocmask else generic.sigprocmask;
168pub const sigwait = if (@hasDecl(system, "sigwait")) system.sigwait else generic.sigwait;
169pub const socket = if (@hasDecl(system, "socket")) system.socket else generic.socket;
170pub const stat = if (@hasDecl(system, "stat")) system.stat else generic.stat;
171
172pub fn getErrno(rc: anytype) E {
173 if (rc == -1) {
174 return @intToEnum(E, _errno().*);
175 } else {
176 return .SUCCESS;
177 }
178}
17915
180/// The return type is `type` to force comptime function call execution.16/// The return type is `type` to force comptime function call execution.
181/// TODO: https://github.com/ziglang/zig/issues/42517/// TODO: https://github.com/ziglang/zig/issues/425
...@@ -203,6 +39,94 @@ pub fn versionCheck(glibc_version: builtin.Version) type {...@@ -203,6 +39,94 @@ pub fn versionCheck(glibc_version: builtin.Version) type {
203 };39 };
204}40}
20541
42pub usingnamespace switch (builtin.os.tag) {
43 .linux => @import("c/linux.zig"),
44 .windows => @import("c/windows.zig"),
45 .macos, .ios, .tvos, .watchos => @import("c/darwin.zig"),
46 .freebsd, .kfreebsd => @import("c/freebsd.zig"),
47 .netbsd => @import("c/netbsd.zig"),
48 .dragonfly => @import("c/dragonfly.zig"),
49 .openbsd => @import("c/openbsd.zig"),
50 .haiku => @import("c/haiku.zig"),
51 .hermit => @import("c/hermit.zig"),
52 .solaris => @import("c/solaris.zig"),
53 .fuchsia => @import("c/fuchsia.zig"),
54 .minix => @import("c/minix.zig"),
55 .emscripten => @import("c/emscripten.zig"),
56 .wasi => @import("c/wasi.zig"),
57 else => struct {},
58};
59
60pub usingnamespace switch (builtin.os.tag) {
61 .netbsd => struct {},
62 .macos, .ios, .watchos, .tvos => struct {
63 // XXX: close -> close$NOCANCEL
64 // XXX: getdirentries -> _getdirentries64
65 pub extern "c" fn clock_getres(clk_id: c_int, tp: *c.timespec) c_int;
66 pub extern "c" fn clock_gettime(clk_id: c_int, tp: *c.timespec) c_int;
67 pub extern "c" fn getrusage(who: c_int, usage: *c.rusage) c_int;
68 pub extern "c" fn gettimeofday(noalias tv: ?*c.timeval, noalias tz: ?*c.timezone) c_int;
69 pub extern "c" fn nanosleep(rqtp: *const c.timespec, rmtp: ?*c.timespec) c_int;
70 pub extern "c" fn sched_yield() c_int;
71 pub extern "c" fn sigaction(sig: c_int, noalias act: ?*const c.Sigaction, noalias oact: ?*c.Sigaction) c_int;
72 pub extern "c" fn sigprocmask(how: c_int, noalias set: ?*const c.sigset_t, noalias oset: ?*c.sigset_t) c_int;
73 pub extern "c" fn socket(domain: c_uint, sock_type: c_uint, protocol: c_uint) c_int;
74 pub extern "c" fn stat(noalias path: [*:0]const u8, noalias buf: *c.Stat) c_int;
75 pub extern "c" fn sigfillset(set: ?*c.sigset_t) void;
76 pub extern "c" fn alarm(seconds: c_uint) c_uint;
77 pub extern "c" fn sigwait(set: ?*c.sigset_t, sig: ?*c_int) c_int;
78 },
79 .windows => struct {
80 // TODO: copied the else case and removed the socket function (because its in ws2_32)
81 // need to verify which of these is actually supported on windows
82 pub extern "c" fn clock_getres(clk_id: c_int, tp: *c.timespec) c_int;
83 pub extern "c" fn clock_gettime(clk_id: c_int, tp: *c.timespec) c_int;
84 pub extern "c" fn fstat(fd: c.fd_t, buf: *c.Stat) c_int;
85 pub extern "c" fn getrusage(who: c_int, usage: *c.rusage) c_int;
86 pub extern "c" fn gettimeofday(noalias tv: ?*c.timeval, noalias tz: ?*c.timezone) c_int;
87 pub extern "c" fn nanosleep(rqtp: *const c.timespec, rmtp: ?*c.timespec) c_int;
88 pub extern "c" fn sched_yield() c_int;
89 pub extern "c" fn sigaction(sig: c_int, noalias act: ?*const c.Sigaction, noalias oact: ?*c.Sigaction) c_int;
90 pub extern "c" fn sigprocmask(how: c_int, noalias set: ?*const c.sigset_t, noalias oset: ?*c.sigset_t) c_int;
91 pub extern "c" fn stat(noalias path: [*:0]const u8, noalias buf: *c.Stat) c_int;
92 pub extern "c" fn sigfillset(set: ?*c.sigset_t) void;
93 pub extern "c" fn alarm(seconds: c_uint) c_uint;
94 pub extern "c" fn sigwait(set: ?*c.sigset_t, sig: ?*c_int) c_int;
95 },
96 else => struct {
97 pub extern "c" fn clock_getres(clk_id: c_int, tp: *c.timespec) c_int;
98 pub extern "c" fn clock_gettime(clk_id: c_int, tp: *c.timespec) c_int;
99 pub extern "c" fn fstat(fd: c.fd_t, buf: *c.Stat) c_int;
100 pub extern "c" fn getrusage(who: c_int, usage: *c.rusage) c_int;
101 pub extern "c" fn gettimeofday(noalias tv: ?*c.timeval, noalias tz: ?*c.timezone) c_int;
102 pub extern "c" fn nanosleep(rqtp: *const c.timespec, rmtp: ?*c.timespec) c_int;
103 pub extern "c" fn sched_yield() c_int;
104 pub extern "c" fn sigaction(sig: c_int, noalias act: ?*const c.Sigaction, noalias oact: ?*c.Sigaction) c_int;
105 pub extern "c" fn sigprocmask(how: c_int, noalias set: ?*const c.sigset_t, noalias oset: ?*c.sigset_t) c_int;
106 pub extern "c" fn socket(domain: c_uint, sock_type: c_uint, protocol: c_uint) c_int;
107 pub extern "c" fn stat(noalias path: [*:0]const u8, noalias buf: *c.Stat) c_int;
108 pub extern "c" fn sigfillset(set: ?*c.sigset_t) void;
109 pub extern "c" fn alarm(seconds: c_uint) c_uint;
110 pub extern "c" fn sigwait(set: ?*c.sigset_t, sig: ?*c_int) c_int;
111 },
112};
113
114pub usingnamespace switch (builtin.os.tag) {
115 .macos, .ios, .watchos, .tvos => struct {},
116 else => struct {
117 pub extern "c" fn realpath(noalias file_name: [*:0]const u8, noalias resolved_name: [*]u8) ?[*:0]u8;
118 pub extern "c" fn fstatat(dirfd: c.fd_t, path: [*:0]const u8, stat_buf: *c.Stat, flags: u32) c_int;
119 },
120};
121
122pub fn getErrno(rc: anytype) c.E {
123 if (rc == -1) {
124 return @intToEnum(c.E, c._errno().*);
125 } else {
126 return .SUCCESS;
127 }
128}
129
206pub extern "c" var environ: [*:null]?[*:0]u8;130pub extern "c" var environ: [*:null]?[*:0]u8;
207131
208pub extern "c" fn fopen(noalias filename: [*:0]const u8, noalias modes: [*:0]const u8) ?*FILE;132pub extern "c" fn fopen(noalias filename: [*:0]const u8, noalias modes: [*:0]const u8) ?*FILE;
...@@ -214,175 +138,175 @@ pub extern "c" fn printf(format: [*:0]const u8, ...) c_int;...@@ -214,175 +138,175 @@ pub extern "c" fn printf(format: [*:0]const u8, ...) c_int;
214pub extern "c" fn abort() noreturn;138pub extern "c" fn abort() noreturn;
215pub extern "c" fn exit(code: c_int) noreturn;139pub extern "c" fn exit(code: c_int) noreturn;
216pub extern "c" fn _exit(code: c_int) noreturn;140pub extern "c" fn _exit(code: c_int) noreturn;
217pub extern "c" fn isatty(fd: fd_t) c_int;141pub extern "c" fn isatty(fd: c.fd_t) c_int;
218pub extern "c" fn close(fd: fd_t) c_int;142pub extern "c" fn close(fd: c.fd_t) c_int;
219pub extern "c" fn lseek(fd: fd_t, offset: off_t, whence: c_int) off_t;143pub extern "c" fn lseek(fd: c.fd_t, offset: c.off_t, whence: c_int) c.off_t;
220pub extern "c" fn open(path: [*:0]const u8, oflag: c_uint, ...) c_int;144pub extern "c" fn open(path: [*:0]const u8, oflag: c_uint, ...) c_int;
221pub extern "c" fn openat(fd: c_int, path: [*:0]const u8, oflag: c_uint, ...) c_int;145pub extern "c" fn openat(fd: c_int, path: [*:0]const u8, oflag: c_uint, ...) c_int;
222pub extern "c" fn ftruncate(fd: c_int, length: off_t) c_int;146pub extern "c" fn ftruncate(fd: c_int, length: c.off_t) c_int;
223pub extern "c" fn raise(sig: c_int) c_int;147pub extern "c" fn raise(sig: c_int) c_int;
224pub extern "c" fn read(fd: fd_t, buf: [*]u8, nbyte: usize) isize;148pub extern "c" fn read(fd: c.fd_t, buf: [*]u8, nbyte: usize) isize;
225pub extern "c" fn readv(fd: c_int, iov: [*]const iovec, iovcnt: c_uint) isize;149pub extern "c" fn readv(fd: c_int, iov: [*]const iovec, iovcnt: c_uint) isize;
226pub extern "c" fn pread(fd: fd_t, buf: [*]u8, nbyte: usize, offset: off_t) isize;150pub extern "c" fn pread(fd: c.fd_t, buf: [*]u8, nbyte: usize, offset: c.off_t) isize;
227pub extern "c" fn preadv(fd: c_int, iov: [*]const iovec, iovcnt: c_uint, offset: off_t) isize;151pub extern "c" fn preadv(fd: c_int, iov: [*]const iovec, iovcnt: c_uint, offset: c.off_t) isize;
228pub extern "c" fn writev(fd: c_int, iov: [*]const iovec_const, iovcnt: c_uint) isize;152pub extern "c" fn writev(fd: c_int, iov: [*]const iovec_const, iovcnt: c_uint) isize;
229pub extern "c" fn pwritev(fd: c_int, iov: [*]const iovec_const, iovcnt: c_uint, offset: off_t) isize;153pub extern "c" fn pwritev(fd: c_int, iov: [*]const iovec_const, iovcnt: c_uint, offset: c.off_t) isize;
230pub extern "c" fn write(fd: fd_t, buf: [*]const u8, nbyte: usize) isize;154pub extern "c" fn write(fd: c.fd_t, buf: [*]const u8, nbyte: usize) isize;
231pub extern "c" fn pwrite(fd: fd_t, buf: [*]const u8, nbyte: usize, offset: off_t) isize;155pub extern "c" fn pwrite(fd: c.fd_t, buf: [*]const u8, nbyte: usize, offset: c.off_t) isize;
232pub extern "c" fn mmap(addr: ?*align(page_size) c_void, len: usize, prot: c_uint, flags: c_uint, fd: fd_t, offset: off_t) *c_void;156pub extern "c" fn mmap(addr: ?*align(page_size) c_void, len: usize, prot: c_uint, flags: c_uint, fd: c.fd_t, offset: c.off_t) *c_void;
233pub extern "c" fn munmap(addr: *align(page_size) const c_void, len: usize) c_int;157pub extern "c" fn munmap(addr: *align(page_size) const c_void, len: usize) c_int;
234pub extern "c" fn mprotect(addr: *align(page_size) c_void, len: usize, prot: c_uint) c_int;158pub extern "c" fn mprotect(addr: *align(page_size) c_void, len: usize, prot: c_uint) c_int;
235pub extern "c" fn link(oldpath: [*:0]const u8, newpath: [*:0]const u8, flags: c_int) c_int;159pub extern "c" fn link(oldpath: [*:0]const u8, newpath: [*:0]const u8, flags: c_int) c_int;
236pub extern "c" fn linkat(oldfd: fd_t, oldpath: [*:0]const u8, newfd: fd_t, newpath: [*:0]const u8, flags: c_int) c_int;160pub extern "c" fn linkat(oldfd: c.fd_t, oldpath: [*:0]const u8, newfd: c.fd_t, newpath: [*:0]const u8, flags: c_int) c_int;
237pub extern "c" fn unlink(path: [*:0]const u8) c_int;161pub extern "c" fn unlink(path: [*:0]const u8) c_int;
238pub extern "c" fn unlinkat(dirfd: fd_t, path: [*:0]const u8, flags: c_uint) c_int;162pub extern "c" fn unlinkat(dirfd: c.fd_t, path: [*:0]const u8, flags: c_uint) c_int;
239pub extern "c" fn getcwd(buf: [*]u8, size: usize) ?[*]u8;163pub extern "c" fn getcwd(buf: [*]u8, size: usize) ?[*]u8;
240pub extern "c" fn waitpid(pid: pid_t, stat_loc: ?*c_int, options: c_int) pid_t;164pub extern "c" fn waitpid(pid: c.pid_t, stat_loc: ?*c_int, options: c_int) c.pid_t;
241pub extern "c" fn fork() c_int;165pub extern "c" fn fork() c_int;
242pub extern "c" fn access(path: [*:0]const u8, mode: c_uint) c_int;166pub extern "c" fn access(path: [*:0]const u8, mode: c_uint) c_int;
243pub extern "c" fn faccessat(dirfd: fd_t, path: [*:0]const u8, mode: c_uint, flags: c_uint) c_int;167pub extern "c" fn faccessat(dirfd: c.fd_t, path: [*:0]const u8, mode: c_uint, flags: c_uint) c_int;
244pub extern "c" fn pipe(fds: *[2]fd_t) c_int;168pub extern "c" fn pipe(fds: *[2]c.fd_t) c_int;
245pub extern "c" fn mkdir(path: [*:0]const u8, mode: c_uint) c_int;169pub extern "c" fn mkdir(path: [*:0]const u8, mode: c_uint) c_int;
246pub extern "c" fn mkdirat(dirfd: fd_t, path: [*:0]const u8, mode: u32) c_int;170pub extern "c" fn mkdirat(dirfd: c.fd_t, path: [*:0]const u8, mode: u32) c_int;
247pub extern "c" fn symlink(existing: [*:0]const u8, new: [*:0]const u8) c_int;171pub extern "c" fn symlink(existing: [*:0]const u8, new: [*:0]const u8) c_int;
248pub extern "c" fn symlinkat(oldpath: [*:0]const u8, newdirfd: fd_t, newpath: [*:0]const u8) c_int;172pub extern "c" fn symlinkat(oldpath: [*:0]const u8, newdirfd: c.fd_t, newpath: [*:0]const u8) c_int;
249pub extern "c" fn rename(old: [*:0]const u8, new: [*:0]const u8) c_int;173pub extern "c" fn rename(old: [*:0]const u8, new: [*:0]const u8) c_int;
250pub extern "c" fn renameat(olddirfd: fd_t, old: [*:0]const u8, newdirfd: fd_t, new: [*:0]const u8) c_int;174pub extern "c" fn renameat(olddirfd: c.fd_t, old: [*:0]const u8, newdirfd: c.fd_t, new: [*:0]const u8) c_int;
251pub extern "c" fn chdir(path: [*:0]const u8) c_int;175pub extern "c" fn chdir(path: [*:0]const u8) c_int;
252pub extern "c" fn fchdir(fd: fd_t) c_int;176pub extern "c" fn fchdir(fd: c.fd_t) c_int;
253pub extern "c" fn execve(path: [*:0]const u8, argv: [*:null]const ?[*:0]const u8, envp: [*:null]const ?[*:0]const u8) c_int;177pub extern "c" fn execve(path: [*:0]const u8, argv: [*:null]const ?[*:0]const u8, envp: [*:null]const ?[*:0]const u8) c_int;
254pub extern "c" fn dup(fd: fd_t) c_int;178pub extern "c" fn dup(fd: c.fd_t) c_int;
255pub extern "c" fn dup2(old_fd: fd_t, new_fd: fd_t) c_int;179pub extern "c" fn dup2(old_fd: c.fd_t, new_fd: c.fd_t) c_int;
256pub extern "c" fn readlink(noalias path: [*:0]const u8, noalias buf: [*]u8, bufsize: usize) isize;180pub extern "c" fn readlink(noalias path: [*:0]const u8, noalias buf: [*]u8, bufsize: usize) isize;
257pub extern "c" fn readlinkat(dirfd: fd_t, noalias path: [*:0]const u8, noalias buf: [*]u8, bufsize: usize) isize;181pub extern "c" fn readlinkat(dirfd: c.fd_t, noalias path: [*:0]const u8, noalias buf: [*]u8, bufsize: usize) isize;
258182
259pub extern "c" fn rmdir(path: [*:0]const u8) c_int;183pub extern "c" fn rmdir(path: [*:0]const u8) c_int;
260pub extern "c" fn getenv(name: [*:0]const u8) ?[*:0]u8;184pub extern "c" fn getenv(name: [*:0]const u8) ?[*:0]u8;
261pub extern "c" fn sysctl(name: [*]const c_int, namelen: c_uint, oldp: ?*c_void, oldlenp: ?*usize, newp: ?*c_void, newlen: usize) c_int;185pub extern "c" fn sysctl(name: [*]const c_int, namelen: c_uint, oldp: ?*c_void, oldlenp: ?*usize, newp: ?*c_void, newlen: usize) c_int;
262pub extern "c" fn sysctlbyname(name: [*:0]const u8, oldp: ?*c_void, oldlenp: ?*usize, newp: ?*c_void, newlen: usize) c_int;186pub extern "c" fn sysctlbyname(name: [*:0]const u8, oldp: ?*c_void, oldlenp: ?*usize, newp: ?*c_void, newlen: usize) c_int;
263pub extern "c" fn sysctlnametomib(name: [*:0]const u8, mibp: ?*c_int, sizep: ?*usize) c_int;187pub extern "c" fn sysctlnametomib(name: [*:0]const u8, mibp: ?*c_int, sizep: ?*usize) c_int;
264pub extern "c" fn tcgetattr(fd: fd_t, termios_p: *termios) c_int;188pub extern "c" fn tcgetattr(fd: c.fd_t, termios_p: *c.termios) c_int;
265pub extern "c" fn tcsetattr(fd: fd_t, optional_action: TCSA, termios_p: *const termios) c_int;189pub extern "c" fn tcsetattr(fd: c.fd_t, optional_action: c.TCSA, termios_p: *const c.termios) c_int;
266pub extern "c" fn fcntl(fd: fd_t, cmd: c_int, ...) c_int;190pub extern "c" fn fcntl(fd: c.fd_t, cmd: c_int, ...) c_int;
267pub extern "c" fn flock(fd: fd_t, operation: c_int) c_int;191pub extern "c" fn flock(fd: c.fd_t, operation: c_int) c_int;
268pub extern "c" fn ioctl(fd: fd_t, request: c_int, ...) c_int;192pub extern "c" fn ioctl(fd: c.fd_t, request: c_int, ...) c_int;
269pub extern "c" fn uname(buf: *utsname) c_int;193pub extern "c" fn uname(buf: *c.utsname) c_int;
270194
271pub extern "c" fn gethostname(name: [*]u8, len: usize) c_int;195pub extern "c" fn gethostname(name: [*]u8, len: usize) c_int;
272pub extern "c" fn shutdown(socket: fd_t, how: c_int) c_int;196pub extern "c" fn shutdown(socket: c.fd_t, how: c_int) c_int;
273pub extern "c" fn bind(socket: fd_t, address: ?*const sockaddr, address_len: socklen_t) c_int;197pub extern "c" fn bind(socket: c.fd_t, address: ?*const c.sockaddr, address_len: c.socklen_t) c_int;
274pub extern "c" fn socketpair(domain: c_uint, sock_type: c_uint, protocol: c_uint, sv: *[2]fd_t) c_int;198pub extern "c" fn socketpair(domain: c_uint, sock_type: c_uint, protocol: c_uint, sv: *[2]c.fd_t) c_int;
275pub extern "c" fn listen(sockfd: fd_t, backlog: c_uint) c_int;199pub extern "c" fn listen(sockfd: c.fd_t, backlog: c_uint) c_int;
276pub extern "c" fn getsockname(sockfd: fd_t, noalias addr: *sockaddr, noalias addrlen: *socklen_t) c_int;200pub extern "c" fn getsockname(sockfd: c.fd_t, noalias addr: *c.sockaddr, noalias addrlen: *c.socklen_t) c_int;
277pub extern "c" fn getpeername(sockfd: fd_t, noalias addr: *sockaddr, noalias addrlen: *socklen_t) c_int;201pub extern "c" fn getpeername(sockfd: c.fd_t, noalias addr: *c.sockaddr, noalias addrlen: *c.socklen_t) c_int;
278pub extern "c" fn connect(sockfd: fd_t, sock_addr: *const sockaddr, addrlen: socklen_t) c_int;202pub extern "c" fn connect(sockfd: c.fd_t, sock_addr: *const c.sockaddr, addrlen: c.socklen_t) c_int;
279pub extern "c" fn accept(sockfd: fd_t, noalias addr: ?*sockaddr, noalias addrlen: ?*socklen_t) c_int;203pub extern "c" fn accept(sockfd: c.fd_t, noalias addr: ?*c.sockaddr, noalias addrlen: ?*c.socklen_t) c_int;
280pub extern "c" fn accept4(sockfd: fd_t, noalias addr: ?*sockaddr, noalias addrlen: ?*socklen_t, flags: c_uint) c_int;204pub extern "c" fn accept4(sockfd: c.fd_t, noalias addr: ?*c.sockaddr, noalias addrlen: ?*c.socklen_t, flags: c_uint) c_int;
281pub extern "c" fn getsockopt(sockfd: fd_t, level: u32, optname: u32, noalias optval: ?*c_void, noalias optlen: *socklen_t) c_int;205pub extern "c" fn getsockopt(sockfd: c.fd_t, level: u32, optname: u32, noalias optval: ?*c_void, noalias optlen: *c.socklen_t) c_int;
282pub extern "c" fn setsockopt(sockfd: fd_t, level: u32, optname: u32, optval: ?*const c_void, optlen: socklen_t) c_int;206pub extern "c" fn setsockopt(sockfd: c.fd_t, level: u32, optname: u32, optval: ?*const c_void, optlen: c.socklen_t) c_int;
283pub extern "c" fn send(sockfd: fd_t, buf: *const c_void, len: usize, flags: u32) isize;207pub extern "c" fn send(sockfd: c.fd_t, buf: *const c_void, len: usize, flags: u32) isize;
284pub extern "c" fn sendto(208pub extern "c" fn sendto(
285 sockfd: fd_t,209 sockfd: c.fd_t,
286 buf: *const c_void,210 buf: *const c_void,
287 len: usize,211 len: usize,
288 flags: u32,212 flags: u32,
289 dest_addr: ?*const sockaddr,213 dest_addr: ?*const c.sockaddr,
290 addrlen: socklen_t,214 addrlen: c.socklen_t,
291) isize;215) isize;
292pub extern "c" fn sendmsg(sockfd: fd_t, msg: *const std.x.os.Socket.Message, flags: c_int) isize;216pub extern "c" fn sendmsg(sockfd: c.fd_t, msg: *const std.x.os.Socket.Message, flags: c_int) isize;
293217
294pub extern "c" fn recv(sockfd: fd_t, arg1: ?*c_void, arg2: usize, arg3: c_int) isize;218pub extern "c" fn recv(sockfd: c.fd_t, arg1: ?*c_void, arg2: usize, arg3: c_int) isize;
295pub extern "c" fn recvfrom(219pub extern "c" fn recvfrom(
296 sockfd: fd_t,220 sockfd: c.fd_t,
297 noalias buf: *c_void,221 noalias buf: *c_void,
298 len: usize,222 len: usize,
299 flags: u32,223 flags: u32,
300 noalias src_addr: ?*sockaddr,224 noalias src_addr: ?*c.sockaddr,
301 noalias addrlen: ?*socklen_t,225 noalias addrlen: ?*c.socklen_t,
302) isize;226) isize;
303pub extern "c" fn recvmsg(sockfd: fd_t, msg: *std.x.os.Socket.Message, flags: c_int) isize;227pub extern "c" fn recvmsg(sockfd: c.fd_t, msg: *std.x.os.Socket.Message, flags: c_int) isize;
304228
305pub extern "c" fn kill(pid: pid_t, sig: c_int) c_int;229pub extern "c" fn kill(pid: c.pid_t, sig: c_int) c_int;
306pub extern "c" fn getdirentries(fd: fd_t, buf_ptr: [*]u8, nbytes: usize, basep: *i64) isize;230pub extern "c" fn getdirentries(fd: c.fd_t, buf_ptr: [*]u8, nbytes: usize, basep: *i64) isize;
307231
308pub extern "c" fn setuid(uid: uid_t) c_int;232pub extern "c" fn setuid(uid: c.uid_t) c_int;
309pub extern "c" fn setgid(gid: gid_t) c_int;233pub extern "c" fn setgid(gid: c.gid_t) c_int;
310pub extern "c" fn seteuid(euid: uid_t) c_int;234pub extern "c" fn seteuid(euid: c.uid_t) c_int;
311pub extern "c" fn setegid(egid: gid_t) c_int;235pub extern "c" fn setegid(egid: c.gid_t) c_int;
312pub extern "c" fn setreuid(ruid: uid_t, euid: uid_t) c_int;236pub extern "c" fn setreuid(ruid: c.uid_t, euid: c.uid_t) c_int;
313pub extern "c" fn setregid(rgid: gid_t, egid: gid_t) c_int;237pub extern "c" fn setregid(rgid: c.gid_t, egid: c.gid_t) c_int;
314pub extern "c" fn setresuid(ruid: uid_t, euid: uid_t, suid: uid_t) c_int;238pub extern "c" fn setresuid(ruid: c.uid_t, euid: c.uid_t, suid: c.uid_t) c_int;
315pub extern "c" fn setresgid(rgid: gid_t, egid: gid_t, sgid: gid_t) c_int;239pub extern "c" fn setresgid(rgid: c.gid_t, egid: c.gid_t, sgid: c.gid_t) c_int;
316240
317pub extern "c" fn malloc(usize) ?*c_void;241pub extern "c" fn malloc(usize) ?*c_void;
318pub extern "c" fn realloc(?*c_void, usize) ?*c_void;242pub extern "c" fn realloc(?*c_void, usize) ?*c_void;
319pub extern "c" fn free(?*c_void) void;243pub extern "c" fn free(?*c_void) void;
320244
321pub extern "c" fn futimes(fd: fd_t, times: *[2]timeval) c_int;245pub extern "c" fn futimes(fd: c.fd_t, times: *[2]c.timeval) c_int;
322pub extern "c" fn utimes(path: [*:0]const u8, times: *[2]timeval) c_int;246pub extern "c" fn utimes(path: [*:0]const u8, times: *[2]c.timeval) c_int;
323247
324pub extern "c" fn utimensat(dirfd: fd_t, pathname: [*:0]const u8, times: *[2]timespec, flags: u32) c_int;248pub extern "c" fn utimensat(dirfd: c.fd_t, pathname: [*:0]const u8, times: *[2]c.timespec, flags: u32) c_int;
325pub extern "c" fn futimens(fd: fd_t, times: *const [2]timespec) c_int;249pub extern "c" fn futimens(fd: c.fd_t, times: *const [2]c.timespec) c_int;
326250
327pub extern "c" fn pthread_create(noalias newthread: *pthread_t, noalias attr: ?*const pthread_attr_t, start_routine: fn (?*c_void) callconv(.C) ?*c_void, noalias arg: ?*c_void) E;251pub extern "c" fn pthread_create(noalias newthread: *pthread_t, noalias attr: ?*const c.pthread_attr_t, start_routine: fn (?*c_void) callconv(.C) ?*c_void, noalias arg: ?*c_void) c.E;
328pub extern "c" fn pthread_attr_init(attr: *pthread_attr_t) E;252pub extern "c" fn pthread_attr_init(attr: *c.pthread_attr_t) c.E;
329pub extern "c" fn pthread_attr_setstack(attr: *pthread_attr_t, stackaddr: *c_void, stacksize: usize) E;253pub extern "c" fn pthread_attr_setstack(attr: *c.pthread_attr_t, stackaddr: *c_void, stacksize: usize) c.E;
330pub extern "c" fn pthread_attr_setstacksize(attr: *pthread_attr_t, stacksize: usize) E;254pub extern "c" fn pthread_attr_setstacksize(attr: *c.pthread_attr_t, stacksize: usize) c.E;
331pub extern "c" fn pthread_attr_setguardsize(attr: *pthread_attr_t, guardsize: usize) E;255pub extern "c" fn pthread_attr_setguardsize(attr: *c.pthread_attr_t, guardsize: usize) c.E;
332pub extern "c" fn pthread_attr_destroy(attr: *pthread_attr_t) E;256pub extern "c" fn pthread_attr_destroy(attr: *c.pthread_attr_t) c.E;
333pub extern "c" fn pthread_self() pthread_t;257pub extern "c" fn pthread_self() pthread_t;
334pub extern "c" fn pthread_join(thread: pthread_t, arg_return: ?*?*c_void) E;258pub extern "c" fn pthread_join(thread: pthread_t, arg_return: ?*?*c_void) c.E;
335pub extern "c" fn pthread_detach(thread: pthread_t) E;259pub extern "c" fn pthread_detach(thread: pthread_t) c.E;
336pub extern "c" fn pthread_atfork(260pub extern "c" fn pthread_atfork(
337 prepare: ?fn () callconv(.C) void,261 prepare: ?fn () callconv(.C) void,
338 parent: ?fn () callconv(.C) void,262 parent: ?fn () callconv(.C) void,
339 child: ?fn () callconv(.C) void,263 child: ?fn () callconv(.C) void,
340) c_int;264) c_int;
341pub extern "c" fn pthread_key_create(key: *pthread_key_t, destructor: ?fn (value: *c_void) callconv(.C) void) E;265pub extern "c" fn pthread_key_create(key: *c.pthread_key_t, destructor: ?fn (value: *c_void) callconv(.C) void) c.E;
342pub extern "c" fn pthread_key_delete(key: pthread_key_t) E;266pub extern "c" fn pthread_key_delete(key: c.pthread_key_t) c.E;
343pub extern "c" fn pthread_getspecific(key: pthread_key_t) ?*c_void;267pub extern "c" fn pthread_getspecific(key: c.pthread_key_t) ?*c_void;
344pub extern "c" fn pthread_setspecific(key: pthread_key_t, value: ?*c_void) c_int;268pub extern "c" fn pthread_setspecific(key: c.pthread_key_t, value: ?*c_void) c_int;
345pub extern "c" fn sem_init(sem: *sem_t, pshared: c_int, value: c_uint) c_int;269pub extern "c" fn sem_init(sem: *c.sem_t, pshared: c_int, value: c_uint) c_int;
346pub extern "c" fn sem_destroy(sem: *sem_t) c_int;270pub extern "c" fn sem_destroy(sem: *c.sem_t) c_int;
347pub extern "c" fn sem_post(sem: *sem_t) c_int;271pub extern "c" fn sem_post(sem: *c.sem_t) c_int;
348pub extern "c" fn sem_wait(sem: *sem_t) c_int;272pub extern "c" fn sem_wait(sem: *c.sem_t) c_int;
349pub extern "c" fn sem_trywait(sem: *sem_t) c_int;273pub extern "c" fn sem_trywait(sem: *c.sem_t) c_int;
350pub extern "c" fn sem_timedwait(sem: *sem_t, abs_timeout: *const timespec) c_int;274pub extern "c" fn sem_timedwait(sem: *c.sem_t, abs_timeout: *const c.timespec) c_int;
351pub extern "c" fn sem_getvalue(sem: *sem_t, sval: *c_int) c_int;275pub extern "c" fn sem_getvalue(sem: *c.sem_t, sval: *c_int) c_int;
352276
353pub extern "c" fn kqueue() c_int;277pub extern "c" fn kqueue() c_int;
354pub extern "c" fn kevent(278pub extern "c" fn kevent(
355 kq: c_int,279 kq: c_int,
356 changelist: [*]const Kevent,280 changelist: [*]const c.Kevent,
357 nchanges: c_int,281 nchanges: c_int,
358 eventlist: [*]Kevent,282 eventlist: [*]c.Kevent,
359 nevents: c_int,283 nevents: c_int,
360 timeout: ?*const timespec,284 timeout: ?*const c.timespec,
361) c_int;285) c_int;
362286
363pub extern "c" fn getaddrinfo(287pub extern "c" fn getaddrinfo(
364 noalias node: ?[*:0]const u8,288 noalias node: ?[*:0]const u8,
365 noalias service: ?[*:0]const u8,289 noalias service: ?[*:0]const u8,
366 noalias hints: ?*const addrinfo,290 noalias hints: ?*const c.addrinfo,
367 noalias res: **addrinfo,291 noalias res: **c.addrinfo,
368) EAI;292) c.EAI;
369293
370pub extern "c" fn freeaddrinfo(res: *addrinfo) void;294pub extern "c" fn freeaddrinfo(res: *c.addrinfo) void;
371295
372pub extern "c" fn getnameinfo(296pub extern "c" fn getnameinfo(
373 noalias addr: *const sockaddr,297 noalias addr: *const c.sockaddr,
374 addrlen: socklen_t,298 addrlen: c.socklen_t,
375 noalias host: [*]u8,299 noalias host: [*]u8,
376 hostlen: socklen_t,300 hostlen: c.socklen_t,
377 noalias serv: [*]u8,301 noalias serv: [*]u8,
378 servlen: socklen_t,302 servlen: c.socklen_t,
379 flags: u32,303 flags: u32,
380) EAI;304) c.EAI;
381305
382pub extern "c" fn gai_strerror(errcode: EAI) [*:0]const u8;306pub extern "c" fn gai_strerror(errcode: c.EAI) [*:0]const u8;
383307
384pub extern "c" fn poll(fds: [*]pollfd, nfds: nfds_t, timeout: c_int) c_int;308pub extern "c" fn poll(fds: [*]c.pollfd, nfds: c.nfds_t, timeout: c_int) c_int;
385pub extern "c" fn ppoll(fds: [*]pollfd, nfds: nfds_t, timeout: ?*const timespec, sigmask: ?*const sigset_t) c_int;309pub extern "c" fn ppoll(fds: [*]c.pollfd, nfds: c.nfds_t, timeout: ?*const c.timespec, sigmask: ?*const c.sigset_t) c_int;
386310
387pub extern "c" fn dn_expand(311pub extern "c" fn dn_expand(
388 msg: [*:0]const u8,312 msg: [*:0]const u8,
...@@ -392,25 +316,25 @@ pub extern "c" fn dn_expand(...@@ -392,25 +316,25 @@ pub extern "c" fn dn_expand(
392 length: c_int,316 length: c_int,
393) c_int;317) c_int;
394318
395pub const PTHREAD_MUTEX_INITIALIZER = pthread_mutex_t{};319pub const PTHREAD_MUTEX_INITIALIZER = c.pthread_mutex_t{};
396pub extern "c" fn pthread_mutex_lock(mutex: *pthread_mutex_t) E;320pub extern "c" fn pthread_mutex_lock(mutex: *c.pthread_mutex_t) c.E;
397pub extern "c" fn pthread_mutex_unlock(mutex: *pthread_mutex_t) E;321pub extern "c" fn pthread_mutex_unlock(mutex: *c.pthread_mutex_t) c.E;
398pub extern "c" fn pthread_mutex_trylock(mutex: *pthread_mutex_t) E;322pub extern "c" fn pthread_mutex_trylock(mutex: *c.pthread_mutex_t) c.E;
399pub extern "c" fn pthread_mutex_destroy(mutex: *pthread_mutex_t) E;323pub extern "c" fn pthread_mutex_destroy(mutex: *c.pthread_mutex_t) c.E;
400324
401pub const PTHREAD_COND_INITIALIZER = pthread_cond_t{};325pub const PTHREAD_COND_INITIALIZER = c.pthread_cond_t{};
402pub extern "c" fn pthread_cond_wait(noalias cond: *pthread_cond_t, noalias mutex: *pthread_mutex_t) E;326pub extern "c" fn pthread_cond_wait(noalias cond: *c.pthread_cond_t, noalias mutex: *c.pthread_mutex_t) c.E;
403pub extern "c" fn pthread_cond_timedwait(noalias cond: *pthread_cond_t, noalias mutex: *pthread_mutex_t, noalias abstime: *const timespec) E;327pub extern "c" fn pthread_cond_timedwait(noalias cond: *c.pthread_cond_t, noalias mutex: *c.pthread_mutex_t, noalias abstime: *const c.timespec) c.E;
404pub extern "c" fn pthread_cond_signal(cond: *pthread_cond_t) E;328pub extern "c" fn pthread_cond_signal(cond: *c.pthread_cond_t) c.E;
405pub extern "c" fn pthread_cond_broadcast(cond: *pthread_cond_t) E;329pub extern "c" fn pthread_cond_broadcast(cond: *c.pthread_cond_t) c.E;
406pub extern "c" fn pthread_cond_destroy(cond: *pthread_cond_t) E;330pub extern "c" fn pthread_cond_destroy(cond: *c.pthread_cond_t) c.E;
407331
408pub extern "c" fn pthread_rwlock_destroy(rwl: *pthread_rwlock_t) callconv(.C) E;332pub extern "c" fn pthread_rwlock_destroy(rwl: *c.pthread_rwlock_t) callconv(.C) c.E;
409pub extern "c" fn pthread_rwlock_rdlock(rwl: *pthread_rwlock_t) callconv(.C) E;333pub extern "c" fn pthread_rwlock_rdlock(rwl: *c.pthread_rwlock_t) callconv(.C) c.E;
410pub extern "c" fn pthread_rwlock_wrlock(rwl: *pthread_rwlock_t) callconv(.C) E;334pub extern "c" fn pthread_rwlock_wrlock(rwl: *c.pthread_rwlock_t) callconv(.C) c.E;
411pub extern "c" fn pthread_rwlock_tryrdlock(rwl: *pthread_rwlock_t) callconv(.C) E;335pub extern "c" fn pthread_rwlock_tryrdlock(rwl: *c.pthread_rwlock_t) callconv(.C) c.E;
412pub extern "c" fn pthread_rwlock_trywrlock(rwl: *pthread_rwlock_t) callconv(.C) E;336pub extern "c" fn pthread_rwlock_trywrlock(rwl: *c.pthread_rwlock_t) callconv(.C) c.E;
413pub extern "c" fn pthread_rwlock_unlock(rwl: *pthread_rwlock_t) callconv(.C) E;337pub extern "c" fn pthread_rwlock_unlock(rwl: *c.pthread_rwlock_t) callconv(.C) c.E;
414338
415pub const pthread_t = *opaque {};339pub const pthread_t = *opaque {};
416pub const FILE = opaque {};340pub const FILE = opaque {};
...@@ -426,8 +350,8 @@ pub extern "c" fn fdatasync(fd: c_int) c_int;...@@ -426,8 +350,8 @@ pub extern "c" fn fdatasync(fd: c_int) c_int;
426350
427pub extern "c" fn prctl(option: c_int, ...) c_int;351pub extern "c" fn prctl(option: c_int, ...) c_int;
428352
429pub extern "c" fn getrlimit(resource: rlimit_resource, rlim: *rlimit) c_int;353pub extern "c" fn getrlimit(resource: c.rlimit_resource, rlim: *c.rlimit) c_int;
430pub extern "c" fn setrlimit(resource: rlimit_resource, rlim: *const rlimit) c_int;354pub extern "c" fn setrlimit(resource: c.rlimit_resource, rlim: *const c.rlimit) c_int;
431355
432pub extern "c" fn fmemopen(noalias buf: ?*c_void, size: usize, noalias mode: [*:0]const u8) ?*FILE;356pub extern "c" fn fmemopen(noalias buf: ?*c_void, size: usize, noalias mode: [*:0]const u8) ?*FILE;
433357
lib/std/c/darwin.zig+117-167
...@@ -4,6 +4,7 @@ const builtin = @import("builtin");...@@ -4,6 +4,7 @@ const builtin = @import("builtin");
4const macho = std.macho;4const macho = std.macho;
5const native_arch = builtin.target.cpu.arch;5const native_arch = builtin.target.cpu.arch;
6const maxInt = std.math.maxInt;6const maxInt = std.math.maxInt;
7const iovec_const = std.os.iovec_const;
78
8extern "c" fn __error() *c_int;9extern "c" fn __error() *c_int;
9pub extern "c" fn NSVersionOfRunTimeLibrary(library_name: [*:0]const u8) u32;10pub extern "c" fn NSVersionOfRunTimeLibrary(library_name: [*:0]const u8) u32;
...@@ -84,8 +85,6 @@ pub const _errno = __error;...@@ -84,8 +85,6 @@ pub const _errno = __error;
84pub extern "c" fn @"close$NOCANCEL"(fd: fd_t) c_int;85pub extern "c" fn @"close$NOCANCEL"(fd: fd_t) c_int;
85pub extern "c" fn mach_host_self() mach_port_t;86pub extern "c" fn mach_host_self() mach_port_t;
86pub extern "c" fn clock_get_time(clock_serv: clock_serv_t, cur_time: *mach_timespec_t) kern_return_t;87pub extern "c" fn clock_get_time(clock_serv: clock_serv_t, cur_time: *mach_timespec_t) kern_return_t;
87pub extern "c" fn host_get_clock_service(host: host_t, clock_id: clock_id_t, clock_serv: ?[*]clock_serv_t) kern_return_t;
88pub extern "c" fn mach_port_deallocate(task: ipc_space_t, name: mach_port_name_t) kern_return_t;
8988
90pub const sf_hdtr = extern struct {89pub const sf_hdtr = extern struct {
91 headers: [*]const iovec_const,90 headers: [*]const iovec_const,
...@@ -1550,19 +1549,17 @@ pub fn S_IWHT(m: u32) bool {...@@ -1550,19 +1549,17 @@ pub fn S_IWHT(m: u32) bool {
15501549
1551pub const HOST_NAME_MAX = 72;1550pub const HOST_NAME_MAX = 72;
15521551
1553pub const AT_FDCWD = -2;1552pub const AT = struct {
15541553 pub const FDCWD = -2;
1555/// Use effective ids in access check1554 /// Use effective ids in access check
1556pub const AT_EACCESS = 0x0010;1555 pub const EACCESS = 0x0010;
15571556 /// Act on the symlink itself not the target
1558/// Act on the symlink itself not the target1557 pub const SYMLINK_NOFOLLOW = 0x0020;
1559pub const AT_SYMLINK_NOFOLLOW = 0x0020;1558 /// Act on target of symlink
15601559 pub const SYMLINK_FOLLOW = 0x0040;
1561/// Act on target of symlink1560 /// Path refers to directory
1562pub const AT_SYMLINK_FOLLOW = 0x0040;1561 pub const REMOVEDIR = 0x0080;
15631562};
1564/// Path refers to directory
1565pub const AT_REMOVEDIR = 0x0080;
15661563
1567pub const addrinfo = extern struct {1564pub const addrinfo = extern struct {
1568 flags: i32,1565 flags: i32,
...@@ -1590,164 +1587,117 @@ pub const RTLD = struct {...@@ -1590,164 +1587,117 @@ pub const RTLD = struct {
1590 pub const MAIN_ONLY = @intToPtr(*c_void, @bitCast(usize, @as(isize, -5)));1587 pub const MAIN_ONLY = @intToPtr(*c_void, @bitCast(usize, @as(isize, -5)));
1591};1588};
15921589
1593/// duplicate file descriptor1590pub const F = struct {
1594pub const F_DUPFD = 0;1591 /// duplicate file descriptor
15951592 pub const DUPFD = 0;
1596/// get file descriptor flags1593 /// get file descriptor flags
1597pub const F_GETFD = 1;1594 pub const GETFD = 1;
15981595 /// set file descriptor flags
1599/// set file descriptor flags1596 pub const SETFD = 2;
1600pub const F_SETFD = 2;1597 /// get file status flags
16011598 pub const GETFL = 3;
1602/// get file status flags1599 /// set file status flags
1603pub const F_GETFL = 3;1600 pub const SETFL = 4;
16041601 /// get SIGIO/SIGURG proc/pgrp
1605/// set file status flags1602 pub const GETOWN = 5;
1606pub const F_SETFL = 4;1603 /// set SIGIO/SIGURG proc/pgrp
16071604 pub const SETOWN = 6;
1608/// get SIGIO/SIGURG proc/pgrp1605 /// get record locking information
1609pub const F_GETOWN = 5;1606 pub const GETLK = 7;
16101607 /// set record locking information
1611/// set SIGIO/SIGURG proc/pgrp1608 pub const SETLK = 8;
1612pub const F_SETOWN = 6;1609 /// F.SETLK; wait if blocked
16131610 pub const SETLKW = 9;
1614/// get record locking information1611 /// F.SETLK; wait if blocked, return on timeout
1615pub const F_GETLK = 7;1612 pub const SETLKWTIMEOUT = 10;
16161613 pub const FLUSH_DATA = 40;
1617/// set record locking information1614 /// Used for regression test
1618pub const F_SETLK = 8;1615 pub const CHKCLEAN = 41;
16191616 /// Preallocate storage
1620/// F_SETLK; wait if blocked1617 pub const PREALLOCATE = 42;
1621pub const F_SETLKW = 9;1618 /// Truncate a file without zeroing space
16221619 pub const SETSIZE = 43;
1623/// F_SETLK; wait if blocked, return on timeout1620 /// Issue an advisory read async with no copy to user
1624pub const F_SETLKWTIMEOUT = 10;1621 pub const RDADVISE = 44;
1625pub const F_FLUSH_DATA = 40;1622 /// turn read ahead off/on for this fd
16261623 pub const RDAHEAD = 45;
1627/// Used for regression test1624 /// turn data caching off/on for this fd
1628pub const F_CHKCLEAN = 41;1625 pub const NOCACHE = 48;
16291626 /// file offset to device offset
1630/// Preallocate storage1627 pub const LOG2PHYS = 49;
1631pub const F_PREALLOCATE = 42;1628 /// return the full path of the fd
16321629 pub const GETPATH = 50;
1633/// Truncate a file without zeroing space1630 /// fsync + ask the drive to flush to the media
1634pub const F_SETSIZE = 43;1631 pub const FULLFSYNC = 51;
16351632 /// find which component (if any) is a package
1636/// Issue an advisory read async with no copy to user1633 pub const PATHPKG_CHECK = 52;
1637pub const F_RDADVISE = 44;1634 /// "freeze" all fs operations
16381635 pub const FREEZE_FS = 53;
1639/// turn read ahead off/on for this fd1636 /// "thaw" all fs operations
1640pub const F_RDAHEAD = 45;1637 pub const THAW_FS = 54;
16411638 /// turn data caching off/on (globally) for this file
1642/// turn data caching off/on for this fd1639 pub const GLOBAL_NOCACHE = 55;
1643pub const F_NOCACHE = 48;1640 /// add detached signatures
16441641 pub const ADDSIGS = 59;
1645/// file offset to device offset1642 /// add signature from same file (used by dyld for shared libs)
1646pub const F_LOG2PHYS = 49;1643 pub const ADDFILESIGS = 61;
16471644 /// used in conjunction with F.NOCACHE to indicate that DIRECT, synchonous writes
1648/// return the full path of the fd1645 /// should not be used (i.e. its ok to temporaily create cached pages)
1649pub const F_GETPATH = 50;1646 pub const NODIRECT = 62;
16501647 ///Get the protection class of a file from the EA, returns int
1651/// fsync + ask the drive to flush to the media1648 pub const GETPROTECTIONCLASS = 63;
1652pub const F_FULLFSYNC = 51;1649 ///Set the protection class of a file for the EA, requires int
16531650 pub const SETPROTECTIONCLASS = 64;
1654/// find which component (if any) is a package1651 ///file offset to device offset, extended
1655pub const F_PATHPKG_CHECK = 52;1652 pub const LOG2PHYS_EXT = 65;
16561653 ///get record locking information, per-process
1657/// "freeze" all fs operations1654 pub const GETLKPID = 66;
1658pub const F_FREEZE_FS = 53;1655 ///Mark the file as being the backing store for another filesystem
16591656 pub const SETBACKINGSTORE = 70;
1660/// "thaw" all fs operations1657 ///return the full path of the FD, but error in specific mtmd circumstances
1661pub const F_THAW_FS = 54;1658 pub const GETPATH_MTMINFO = 71;
16621659 ///Returns the code directory, with associated hashes, to the caller
1663/// turn data caching off/on (globally) for this file1660 pub const GETCODEDIR = 72;
1664pub const F_GLOBAL_NOCACHE = 55;1661 ///No SIGPIPE generated on EPIPE
16651662 pub const SETNOSIGPIPE = 73;
1666/// add detached signatures1663 ///Status of SIGPIPE for this fd
1667pub const F_ADDSIGS = 59;1664 pub const GETNOSIGPIPE = 74;
16681665 ///For some cases, we need to rewrap the key for AKS/MKB
1669/// add signature from same file (used by dyld for shared libs)1666 pub const TRANSCODEKEY = 75;
1670pub const F_ADDFILESIGS = 61;1667 ///file being written to a by single writer... if throttling enabled, writes
16711668 ///may be broken into smaller chunks with throttling in between
1672/// used in conjunction with F_NOCACHE to indicate that DIRECT, synchonous writes1669 pub const SINGLE_WRITER = 76;
1673/// should not be used (i.e. its ok to temporaily create cached pages)1670 ///Get the protection version number for this filesystem
1674pub const F_NODIRECT = 62;1671 pub const GETPROTECTIONLEVEL = 77;
16751672 ///Add detached code signatures (used by dyld for shared libs)
1676///Get the protection class of a file from the EA, returns int1673 pub const FINDSIGS = 78;
1677pub const F_GETPROTECTIONCLASS = 63;1674 ///Add signature from same file, only if it is signed by Apple (used by dyld for simulator)
16781675 pub const ADDFILESIGS_FOR_DYLD_SIM = 83;
1679///Set the protection class of a file for the EA, requires int1676 ///fsync + issue barrier to drive
1680pub const F_SETPROTECTIONCLASS = 64;1677 pub const BARRIERFSYNC = 85;
16811678 ///Add signature from same file, return end offset in structure on success
1682///file offset to device offset, extended1679 pub const ADDFILESIGS_RETURN = 97;
1683pub const F_LOG2PHYS_EXT = 65;1680 ///Check if Library Validation allows this Mach-O file to be mapped into the calling process
16841681 pub const CHECK_LV = 98;
1685///get record locking information, per-process1682 ///Deallocate a range of the file
1686pub const F_GETLKPID = 66;1683 pub const PUNCHHOLE = 99;
16871684 ///Trim an active file
1688///Mark the file as being the backing store for another filesystem1685 pub const TRIM_ACTIVE_FILE = 100;
1689pub const F_SETBACKINGSTORE = 70;1686 ///mark the dup with FD_CLOEXEC
16901687 pub const DUPFD_CLOEXEC = 67;
1691///return the full path of the FD, but error in specific mtmd circumstances1688 /// shared or read lock
1692pub const F_GETPATH_MTMINFO = 71;1689 pub const RDLCK = 1;
16931690 /// unlock
1694///Returns the code directory, with associated hashes, to the caller1691 pub const UNLCK = 2;
1695pub const F_GETCODEDIR = 72;1692 /// exclusive or write lock
16961693 pub const WRLCK = 3;
1697///No SIGPIPE generated on EPIPE1694};
1698pub const F_SETNOSIGPIPE = 73;
1699
1700///Status of SIGPIPE for this fd
1701pub const F_GETNOSIGPIPE = 74;
1702
1703///For some cases, we need to rewrap the key for AKS/MKB
1704pub const F_TRANSCODEKEY = 75;
1705
1706///file being written to a by single writer... if throttling enabled, writes
1707///may be broken into smaller chunks with throttling in between
1708pub const F_SINGLE_WRITER = 76;
1709
1710///Get the protection version number for this filesystem
1711pub const F_GETPROTECTIONLEVEL = 77;
1712
1713///Add detached code signatures (used by dyld for shared libs)
1714pub const F_FINDSIGS = 78;
1715
1716///Add signature from same file, only if it is signed by Apple (used by dyld for simulator)
1717pub const F_ADDFILESIGS_FOR_DYLD_SIM = 83;
1718
1719///fsync + issue barrier to drive
1720pub const F_BARRIERFSYNC = 85;
1721
1722///Add signature from same file, return end offset in structure on success
1723pub const F_ADDFILESIGS_RETURN = 97;
1724
1725///Check if Library Validation allows this Mach-O file to be mapped into the calling process
1726pub const F_CHECK_LV = 98;
1727
1728///Deallocate a range of the file
1729pub const F_PUNCHHOLE = 99;
1730
1731///Trim an active file
1732pub const F_TRIM_ACTIVE_FILE = 100;
17331695
1734pub const FCNTL_FS_SPECIFIC_BASE = 0x00010000;1696pub const FCNTL_FS_SPECIFIC_BASE = 0x00010000;
17351697
1736///mark the dup with FD_CLOEXEC
1737pub const F_DUPFD_CLOEXEC = 67;
1738
1739///close-on-exec flag1698///close-on-exec flag
1740pub const FD_CLOEXEC = 1;1699pub const FD_CLOEXEC = 1;
17411700
1742/// shared or read lock
1743pub const F_RDLCK = 1;
1744
1745/// unlock
1746pub const F_UNLCK = 2;
1747
1748/// exclusive or write lock
1749pub const F_WRLCK = 3;
1750
1751pub const LOCK = struct {1701pub const LOCK = struct {
1752 pub const SH = 1;1702 pub const SH = 1;
1753 pub const EX = 2;1703 pub const EX = 2;
lib/std/c/dragonfly.zig+32-27
...@@ -1,5 +1,6 @@...@@ -1,5 +1,6 @@
1const std = @import("../std.zig");1const std = @import("../std.zig");
2const maxInt = std.math.maxInt;2const maxInt = std.math.maxInt;
3const iovec = std.os.iovec;
34
4extern "c" threadlocal var errno: c_int;5extern "c" threadlocal var errno: c_int;
5pub fn _errno() *c_int {6pub fn _errno() *c_int {
...@@ -353,18 +354,39 @@ pub const SEEK_END = 2;...@@ -353,18 +354,39 @@ pub const SEEK_END = 2;
353pub const SEEK_DATA = 3;354pub const SEEK_DATA = 3;
354pub const SEEK_HOLE = 4;355pub const SEEK_HOLE = 4;
355356
356pub const F_ULOCK = 0;357pub const F = struct {
357pub const F_LOCK = 1;358 pub const ULOCK = 0;
358pub const F_TLOCK = 2;359 pub const LOCK = 1;
359pub const F_TEST = 3;360 pub const TLOCK = 2;
361 pub const TEST = 3;
362
363 pub const DUPFD = 0;
364 pub const GETFD = 1;
365 pub const RDLCK = 1;
366 pub const SETFD = 2;
367 pub const UNLCK = 2;
368 pub const WRLCK = 3;
369 pub const GETFL = 3;
370 pub const SETFL = 4;
371 pub const GETOWN = 5;
372 pub const SETOWN = 6;
373 pub const GETLK = 7;
374 pub const SETLK = 8;
375 pub const SETLKW = 9;
376 pub const DUP2FD = 10;
377 pub const DUPFD_CLOEXEC = 17;
378 pub const DUP2FD_CLOEXEC = 18;
379};
360380
361pub const FD_CLOEXEC = 1;381pub const FD_CLOEXEC = 1;
362382
363pub const AT_FDCWD = -328243;383pub const AT = struct {
364pub const AT_SYMLINK_NOFOLLOW = 1;384 pub const FDCWD = -328243;
365pub const AT_REMOVEDIR = 2;385 pub const SYMLINK_NOFOLLOW = 1;
366pub const AT_EACCESS = 4;386 pub const REMOVEDIR = 2;
367pub const AT_SYMLINK_FOLLOW = 8;387 pub const EACCESS = 4;
388 pub const SYMLINK_FOLLOW = 8;
389};
368390
369pub fn WEXITSTATUS(s: u32) u8 {391pub fn WEXITSTATUS(s: u32) u8 {
370 return @intCast(u8, (s & 0xff00) >> 8);392 return @intCast(u8, (s & 0xff00) >> 8);
...@@ -715,7 +737,7 @@ pub const PF = struct {...@@ -715,7 +737,7 @@ pub const PF = struct {
715 pub const ISDN = AF.ISDN;737 pub const ISDN = AF.ISDN;
716 pub const RTIP = AF.pseudo_RTIP;738 pub const RTIP = AF.pseudo_RTIP;
717 pub const LAT = AF.LAT;739 pub const LAT = AF.LAT;
718 pub const UNIX = PF_LOCAL;740 pub const UNIX = PF.LOCAL;
719 pub const XTP = AF.pseudo_XTP;741 pub const XTP = AF.pseudo_XTP;
720 pub const DECnet = AF.DECnet;742 pub const DECnet = AF.DECnet;
721};743};
...@@ -868,23 +890,6 @@ pub const MADV = struct {...@@ -868,23 +890,6 @@ pub const MADV = struct {
868 pub const SETMAP = 11;890 pub const SETMAP = 11;
869};891};
870892
871pub const F_DUPFD = 0;
872pub const F_GETFD = 1;
873pub const F_RDLCK = 1;
874pub const F_SETFD = 2;
875pub const F_UNLCK = 2;
876pub const F_WRLCK = 3;
877pub const F_GETFL = 3;
878pub const F_SETFL = 4;
879pub const F_GETOWN = 5;
880pub const F_SETOWN = 6;
881pub const F_GETLK = 7;
882pub const F_SETLK = 8;
883pub const F_SETLKW = 9;
884pub const F_DUP2FD = 10;
885pub const F_DUPFD_CLOEXEC = 17;
886pub const F_DUP2FD_CLOEXEC = 18;
887
888pub const LOCK = struct {893pub const LOCK = struct {
889 pub const SH = 1;894 pub const SH = 1;
890 pub const EX = 2;895 pub const EX = 2;
lib/std/c/freebsd.zig+134-129
...@@ -1,5 +1,8 @@...@@ -1,5 +1,8 @@
1const std = @import("../std.zig");1const std = @import("../std.zig");
2const builtin = @import("builtin");
2const maxInt = std.math.maxInt;3const maxInt = std.math.maxInt;
4const iovec = std.os.iovec;
5const iovec_const = std.os.iovec_const;
36
4extern "c" fn __error() *c_int;7extern "c" fn __error() *c_int;
5pub const _errno = __error;8pub const _errno = __error;
...@@ -400,60 +403,100 @@ pub const MAP = struct {...@@ -400,60 +403,100 @@ pub const MAP = struct {
400 pub const @"32BIT" = 0x00080000;403 pub const @"32BIT" = 0x00080000;
401};404};
402405
403pub const WNOHANG = 1;406pub const W = struct {
404pub const WUNTRACED = 2;407 pub const NOHANG = 1;
405pub const WSTOPPED = WUNTRACED;408 pub const UNTRACED = 2;
406pub const WCONTINUED = 4;409 pub const STOPPED = UNTRACED;
407pub const WNOWAIT = 8;410 pub const CONTINUED = 4;
408pub const WEXITED = 16;411 pub const NOWAIT = 8;
409pub const WTRAPPED = 32;412 pub const EXITED = 16;
410413 pub const TRAPPED = 32;
411pub const SA_ONSTACK = 0x0001;414};
412pub const SA_RESTART = 0x0002;415
413pub const SA_RESETHAND = 0x0004;416pub const SA = struct {
414pub const SA_NOCLDSTOP = 0x0008;417 pub const ONSTACK = 0x0001;
415pub const SA_NODEFER = 0x0010;418 pub const RESTART = 0x0002;
416pub const SA_NOCLDWAIT = 0x0020;419 pub const RESETHAND = 0x0004;
417pub const SA_SIGINFO = 0x0040;420 pub const NOCLDSTOP = 0x0008;
418421 pub const NODEFER = 0x0010;
419pub const SIGHUP = 1;422 pub const NOCLDWAIT = 0x0020;
420pub const SIGINT = 2;423 pub const SIGINFO = 0x0040;
421pub const SIGQUIT = 3;424};
422pub const SIGILL = 4;425
423pub const SIGTRAP = 5;426pub const SIG = struct {
424pub const SIGABRT = 6;427 pub const HUP = 1;
425pub const SIGIOT = SIGABRT;428 pub const INT = 2;
426pub const SIGEMT = 7;429 pub const QUIT = 3;
427pub const SIGFPE = 8;430 pub const ILL = 4;
428pub const SIGKILL = 9;431 pub const TRAP = 5;
429pub const SIGBUS = 10;432 pub const ABRT = 6;
430pub const SIGSEGV = 11;433 pub const IOT = ABRT;
431pub const SIGSYS = 12;434 pub const EMT = 7;
432pub const SIGPIPE = 13;435 pub const FPE = 8;
433pub const SIGALRM = 14;436 pub const KILL = 9;
434pub const SIGTERM = 15;437 pub const BUS = 10;
435pub const SIGURG = 16;438 pub const SEGV = 11;
436pub const SIGSTOP = 17;439 pub const SYS = 12;
437pub const SIGTSTP = 18;440 pub const PIPE = 13;
438pub const SIGCONT = 19;441 pub const ALRM = 14;
439pub const SIGCHLD = 20;442 pub const TERM = 15;
440pub const SIGTTIN = 21;443 pub const URG = 16;
441pub const SIGTTOU = 22;444 pub const STOP = 17;
442pub const SIGIO = 23;445 pub const TSTP = 18;
443pub const SIGXCPU = 24;446 pub const CONT = 19;
444pub const SIGXFSZ = 25;447 pub const CHLD = 20;
445pub const SIGVTALRM = 26;448 pub const TTIN = 21;
446pub const SIGPROF = 27;449 pub const TTOU = 22;
447pub const SIGWINCH = 28;450 pub const IO = 23;
448pub const SIGINFO = 29;451 pub const XCPU = 24;
449pub const SIGUSR1 = 30;452 pub const XFSZ = 25;
450pub const SIGUSR2 = 31;453 pub const VTALRM = 26;
451pub const SIGTHR = 32;454 pub const PROF = 27;
452pub const SIGLWP = SIGTHR;455 pub const WINCH = 28;
453pub const SIGLIBRT = 33;456 pub const INFO = 29;
454457 pub const USR1 = 30;
455pub const SIGRTMIN = 65;458 pub const USR2 = 31;
456pub const SIGRTMAX = 126;459 pub const THR = 32;
460 pub const LWP = THR;
461 pub const LIBRT = 33;
462
463 pub const RTMIN = 65;
464 pub const RTMAX = 126;
465
466 pub const BLOCK = 1;
467 pub const UNBLOCK = 2;
468 pub const SETMASK = 3;
469
470 pub const DFL = @intToPtr(?Sigaction.sigaction_fn, 0);
471 pub const IGN = @intToPtr(?Sigaction.sigaction_fn, 1);
472 pub const ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize));
473
474 pub const WORDS = 4;
475 pub const MAXSIG = 128;
476
477 pub inline fn IDX(sig: usize) usize {
478 return sig - 1;
479 }
480 pub inline fn WORD(sig: usize) usize {
481 return IDX(sig) >> 5;
482 }
483 pub inline fn BIT(sig: usize) usize {
484 return 1 << (IDX(sig) & 31);
485 }
486 pub inline fn VALID(sig: usize) usize {
487 return sig <= MAXSIG and sig > 0;
488 }
489};
490pub const sigval = extern union {
491 int: c_int,
492 ptr: ?*c_void,
493};
494
495pub const sigset_t = extern struct {
496 __bits: [SIG.WORDS]u32,
497};
498
499pub const empty_sigset = sigset_t{ .__bits = [_]u32{0} ** SIG.WORDS };
457500
458// access function501// access function
459pub const F_OK = 0; // test for existence of file502pub const F_OK = 0; // test for existence of file
...@@ -489,22 +532,29 @@ pub const O_PATH = 0o10000000;...@@ -489,22 +532,29 @@ pub const O_PATH = 0o10000000;
489pub const O_TMPFILE = 0o20200000;532pub const O_TMPFILE = 0o20200000;
490pub const O_NDELAY = O_NONBLOCK;533pub const O_NDELAY = O_NONBLOCK;
491534
492pub const F_DUPFD = 0;535pub const F = struct {
493pub const F_GETFD = 1;536 pub const DUPFD = 0;
494pub const F_SETFD = 2;537 pub const GETFD = 1;
495pub const F_GETFL = 3;538 pub const SETFD = 2;
496pub const F_SETFL = 4;539 pub const GETFL = 3;
540 pub const SETFL = 4;
541
542 pub const GETOWN = 5;
543 pub const SETOWN = 6;
497544
498pub const F_GETOWN = 5;545 pub const GETLK = 11;
499pub const F_SETOWN = 6;546 pub const SETLK = 12;
547 pub const SETLKW = 13;
500548
501pub const F_GETLK = 11;549 pub const RDLCK = 1;
502pub const F_SETLK = 12;550 pub const WRLCK = 3;
503pub const F_SETLKW = 13;551 pub const UNLCK = 2;
504552
505pub const F_RDLCK = 1;553 pub const SETOWN_EX = 15;
506pub const F_WRLCK = 3;554 pub const GETOWN_EX = 16;
507pub const F_UNLCK = 2;555
556 pub const GETOWNER_UIDS = 17;
557};
508558
509pub const LOCK = struct {559pub const LOCK = struct {
510 pub const SH = 1;560 pub const SH = 1;
...@@ -513,21 +563,12 @@ pub const LOCK = struct {...@@ -513,21 +563,12 @@ pub const LOCK = struct {
513 pub const NB = 4;563 pub const NB = 4;
514};564};
515565
516pub const F_SETOWN_EX = 15;
517pub const F_GETOWN_EX = 16;
518
519pub const F_GETOWNER_UIDS = 17;
520
521pub const FD_CLOEXEC = 1;566pub const FD_CLOEXEC = 1;
522567
523pub const SEEK_SET = 0;568pub const SEEK_SET = 0;
524pub const SEEK_CUR = 1;569pub const SEEK_CUR = 1;
525pub const SEEK_END = 2;570pub const SEEK_END = 2;
526571
527pub const SIG_BLOCK = 1;
528pub const SIG_UNBLOCK = 2;
529pub const SIG_SETMASK = 3;
530
531pub const SOCK = struct {572pub const SOCK = struct {
532 pub const STREAM = 1;573 pub const STREAM = 1;
533 pub const DGRAM = 2;574 pub const DGRAM = 2;
...@@ -890,10 +931,6 @@ pub const winsize = extern struct {...@@ -890,10 +931,6 @@ pub const winsize = extern struct {
890931
891const NSIG = 32;932const NSIG = 32;
892933
893pub const SIG_DFL = @intToPtr(?Sigaction.sigaction_fn, 0);
894pub const SIG_IGN = @intToPtr(?Sigaction.sigaction_fn, 1);
895pub const SIG_ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize));
896
897/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.934/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.
898pub const Sigaction = extern struct {935pub const Sigaction = extern struct {
899 pub const handler_fn = fn (c_int) callconv(.C) void;936 pub const handler_fn = fn (c_int) callconv(.C) void;
...@@ -942,34 +979,7 @@ pub const siginfo_t = extern struct {...@@ -942,34 +979,7 @@ pub const siginfo_t = extern struct {
942 },979 },
943};980};
944981
945pub const sigval = extern union {982pub usingnamespace switch (builtin.cpu.arch) {
946 int: c_int,
947 ptr: ?*c_void,
948};
949
950pub const _SIG_WORDS = 4;
951pub const _SIG_MAXSIG = 128;
952
953pub inline fn _SIG_IDX(sig: usize) usize {
954 return sig - 1;
955}
956pub inline fn _SIG_WORD(sig: usize) usize {
957 return_SIG_IDX(sig) >> 5;
958}
959pub inline fn _SIG_BIT(sig: usize) usize {
960 return 1 << (_SIG_IDX(sig) & 31);
961}
962pub inline fn _SIG_VALID(sig: usize) usize {
963 return sig <= _SIG_MAXSIG and sig > 0;
964}
965
966pub const sigset_t = extern struct {
967 __bits: [_SIG_WORDS]u32,
968};
969
970pub const empty_sigset = sigset_t{ .__bits = [_]u32{0} ** _SIG_WORDS };
971
972const arch_bits = switch (builtin.cpu.arch) {
973 .x86_64 => struct {983 .x86_64 => struct {
974 pub const ucontext_t = extern struct {984 pub const ucontext_t = extern struct {
975 sigmask: sigset_t,985 sigmask: sigset_t,
...@@ -1015,8 +1025,6 @@ const arch_bits = switch (builtin.cpu.arch) {...@@ -1015,8 +1025,6 @@ const arch_bits = switch (builtin.cpu.arch) {
1015 },1025 },
1016 else => struct {},1026 else => struct {},
1017};1027};
1018pub const ucontext_t = arch_bits.ucontext_t;
1019pub const mcontext_t = arch_bits.mcontext_t;
10201028
1021pub const E = enum(u16) {1029pub const E = enum(u16) {
1022 /// No error occurred.1030 /// No error occurred.
...@@ -1224,22 +1232,22 @@ pub fn S_IWHT(m: u32) bool {...@@ -1224,22 +1232,22 @@ pub fn S_IWHT(m: u32) bool {
12241232
1225pub const HOST_NAME_MAX = 255;1233pub const HOST_NAME_MAX = 255;
12261234
1227/// Magic value that specify the use of the current working directory1235pub const AT = struct {
1228/// to determine the target of relative file paths in the openat() and1236 /// Magic value that specify the use of the current working directory
1229/// similar syscalls.1237 /// to determine the target of relative file paths in the openat() and
1230pub const AT_FDCWD = -100;1238 /// similar syscalls.
12311239 pub const FDCWD = -100;
1232/// Check access using effective user and group ID1240 /// Check access using effective user and group ID
1233pub const AT_EACCESS = 0x0100;1241 pub const EACCESS = 0x0100;
12341242 /// Do not follow symbolic links
1235/// Do not follow symbolic links1243 pub const SYMLINK_NOFOLLOW = 0x0200;
1236pub const AT_SYMLINK_NOFOLLOW = 0x0200;1244 /// Follow symbolic link
12371245 pub const SYMLINK_FOLLOW = 0x0400;
1238/// Follow symbolic link1246 /// Remove directory instead of file
1239pub const AT_SYMLINK_FOLLOW = 0x0400;1247 pub const REMOVEDIR = 0x0800;
12401248 /// Fail if not under dirfd
1241/// Remove directory instead of file1249 pub const BENEATH = 0x1000;
1242pub const AT_REMOVEDIR = 0x0800;1250};
12431251
1244pub const addrinfo = extern struct {1252pub const addrinfo = extern struct {
1245 flags: i32,1253 flags: i32,
...@@ -1252,9 +1260,6 @@ pub const addrinfo = extern struct {...@@ -1252,9 +1260,6 @@ pub const addrinfo = extern struct {
1252 next: ?*addrinfo,1260 next: ?*addrinfo,
1253};1261};
12541262
1255/// Fail if not under dirfd
1256pub const AT_BENEATH = 0x1000;
1257
1258pub const IPPROTO = struct {1263pub const IPPROTO = struct {
1259 /// dummy for IP1264 /// dummy for IP
1260 pub const IP = 0;1265 pub const IP = 0;
lib/std/c/generic.zig deleted-23
...@@ -1,23 +0,0 @@
1const std = @import("../std.zig");
2const Stat = std.c.Stat;
3const timespec = std.c.timespec;
4const Sigaction = std.c.Sigaction;
5const sigset_t = std.c.sigset_t;
6const rusage = std.c.rusage;
7
8pub extern "c" fn realpath(noalias file_name: [*:0]const u8, noalias resolved_name: [*]u8) ?[*:0]u8;
9pub extern "c" fn fstatat(dirfd: fd_t, path: [*:0]const u8, stat_buf: *Stat, flags: u32) c_int;
10pub extern "c" fn clock_getres(clk_id: c_int, tp: *timespec) c_int;
11pub extern "c" fn clock_gettime(clk_id: c_int, tp: *timespec) c_int;
12pub extern "c" fn fstat(fd: fd_t, buf: *Stat) c_int;
13pub extern "c" fn getrusage(who: c_int, usage: *rusage) c_int;
14pub extern "c" fn gettimeofday(noalias tv: ?*timeval, noalias tz: ?*timezone) c_int;
15pub extern "c" fn nanosleep(rqtp: *const timespec, rmtp: ?*timespec) c_int;
16pub extern "c" fn sched_yield() c_int;
17pub extern "c" fn sigaction(sig: c_int, noalias act: ?*const Sigaction, noalias oact: ?*Sigaction) c_int;
18pub extern "c" fn sigprocmask(how: c_int, noalias set: ?*const sigset_t, noalias oset: ?*sigset_t) c_int;
19pub extern "c" fn socket(domain: c_uint, sock_type: c_uint, protocol: c_uint) c_int;
20pub extern "c" fn stat(noalias path: [*:0]const u8, noalias buf: *Stat) c_int;
21pub extern "c" fn sigfillset(set: ?*sigset_t) void;
22pub extern "c" fn alarm(seconds: c_uint) c_uint;
23pub extern "c" fn sigwait(set: ?*sigset_t, sig: ?*c_int) c_int;
lib/std/c/haiku.zig+99-96
...@@ -1,5 +1,8 @@...@@ -1,5 +1,8 @@
1const std = @import("../std.zig");1const std = @import("../std.zig");
2const builtin = @import("builtin");
2const maxInt = std.math.maxInt;3const maxInt = std.math.maxInt;
4const iovec = std.os.iovec;
5const iovec_const = std.os.iovec_const;
36
4extern "c" fn _errnop() *c_int;7extern "c" fn _errnop() *c_int;
58
...@@ -421,43 +424,64 @@ pub const SA_NOMASK = SA_NODEFER;...@@ -421,43 +424,64 @@ pub const SA_NOMASK = SA_NODEFER;
421pub const SA_STACK = SA_ONSTACK;424pub const SA_STACK = SA_ONSTACK;
422pub const SA_ONESHOT = SA_RESETHAND;425pub const SA_ONESHOT = SA_RESETHAND;
423426
424pub const SIGHUP = 1;427pub const SIG = struct {
425pub const SIGINT = 2;428 pub const HUP = 1;
426pub const SIGQUIT = 3;429 pub const INT = 2;
427pub const SIGILL = 4;430 pub const QUIT = 3;
428pub const SIGCHLD = 5;431 pub const ILL = 4;
429pub const SIGABRT = 6;432 pub const CHLD = 5;
430pub const SIGIOT = SIGABRT;433 pub const ABRT = 6;
431pub const SIGPIPE = 7;434 pub const IOT = ABRT;
432pub const SIGFPE = 8;435 pub const PIPE = 7;
433pub const SIGKILL = 9;436 pub const FPE = 8;
434pub const SIGSTOP = 10;437 pub const KILL = 9;
435pub const SIGSEGV = 11;438 pub const STOP = 10;
436pub const SIGCONT = 12;439 pub const SEGV = 11;
437pub const SIGTSTP = 13;440 pub const CONT = 12;
438pub const SIGALRM = 14;441 pub const TSTP = 13;
439pub const SIGTERM = 15;442 pub const ALRM = 14;
440pub const SIGTTIN = 16;443 pub const TERM = 15;
441pub const SIGTTOU = 17;444 pub const TTIN = 16;
442pub const SIGUSR1 = 18;445 pub const TTOU = 17;
443pub const SIGUSR2 = 19;446 pub const USR1 = 18;
444pub const SIGWINCH = 20;447 pub const USR2 = 19;
445pub const SIGKILLTHR = 21;448 pub const WINCH = 20;
446pub const SIGTRAP = 22;449 pub const KILLTHR = 21;
447pub const SIGPOLL = 23;450 pub const TRAP = 22;
448pub const SIGPROF = 24;451 pub const POLL = 23;
449pub const SIGSYS = 25;452 pub const PROF = 24;
450pub const SIGURG = 26;453 pub const SYS = 25;
451pub const SIGVTALRM = 27;454 pub const URG = 26;
452pub const SIGXCPU = 28;455 pub const VTALRM = 27;
453pub const SIGXFSZ = 29;456 pub const XCPU = 28;
454pub const SIGBUS = 30;457 pub const XFSZ = 29;
455pub const SIGRESERVED1 = 31;458 pub const BUS = 30;
456pub const SIGRESERVED2 = 32;459 pub const RESERVED1 = 31;
457460 pub const RESERVED2 = 32;
458// TODO: check461
459pub const SIGRTMIN = 65;462 // TODO: check
460pub const SIGRTMAX = 126;463 pub const RTMIN = 65;
464 pub const RTMAX = 126;
465
466 pub const BLOCK = 1;
467 pub const UNBLOCK = 2;
468 pub const SETMASK = 3;
469
470 pub const WORDS = 4;
471 pub const MAXSIG = 128;
472 pub inline fn IDX(sig: usize) usize {
473 return sig - 1;
474 }
475 pub inline fn WORD(sig: usize) usize {
476 return IDX(sig) >> 5;
477 }
478 pub inline fn BIT(sig: usize) usize {
479 return 1 << (IDX(sig) & 31);
480 }
481 pub inline fn VALID(sig: usize) usize {
482 return sig <= MAXSIG and sig > 0;
483 }
484};
461485
462// access function486// access function
463pub const F_OK = 0; // test for existence of file487pub const F_OK = 0; // test for existence of file
...@@ -493,22 +517,29 @@ pub const O_PATH = 0o10000000;...@@ -493,22 +517,29 @@ pub const O_PATH = 0o10000000;
493pub const O_TMPFILE = 0o20200000;517pub const O_TMPFILE = 0o20200000;
494pub const O_NDELAY = O_NONBLOCK;518pub const O_NDELAY = O_NONBLOCK;
495519
496pub const F_DUPFD = 0;520pub const F = struct {
497pub const F_GETFD = 1;521 pub const DUPFD = 0;
498pub const F_SETFD = 2;522 pub const GETFD = 1;
499pub const F_GETFL = 3;523 pub const SETFD = 2;
500pub const F_SETFL = 4;524 pub const GETFL = 3;
525 pub const SETFL = 4;
526
527 pub const GETOWN = 5;
528 pub const SETOWN = 6;
501529
502pub const F_GETOWN = 5;530 pub const GETLK = 11;
503pub const F_SETOWN = 6;531 pub const SETLK = 12;
532 pub const SETLKW = 13;
504533
505pub const F_GETLK = 11;534 pub const RDLCK = 1;
506pub const F_SETLK = 12;535 pub const WRLCK = 3;
507pub const F_SETLKW = 13;536 pub const UNLCK = 2;
508537
509pub const F_RDLCK = 1;538 pub const SETOWN_EX = 15;
510pub const F_WRLCK = 3;539 pub const GETOWN_EX = 16;
511pub const F_UNLCK = 2;540
541 pub const GETOWNER_UIDS = 17;
542};
512543
513pub const LOCK = struct {544pub const LOCK = struct {
514 pub const SH = 1;545 pub const SH = 1;
...@@ -517,21 +548,12 @@ pub const LOCK = struct {...@@ -517,21 +548,12 @@ pub const LOCK = struct {
517 pub const NB = 4;548 pub const NB = 4;
518};549};
519550
520pub const F_SETOWN_EX = 15;
521pub const F_GETOWN_EX = 16;
522
523pub const F_GETOWNER_UIDS = 17;
524
525pub const FD_CLOEXEC = 1;551pub const FD_CLOEXEC = 1;
526552
527pub const SEEK_SET = 0;553pub const SEEK_SET = 0;
528pub const SEEK_CUR = 1;554pub const SEEK_CUR = 1;
529pub const SEEK_END = 2;555pub const SEEK_END = 2;
530556
531pub const SIG_BLOCK = 1;
532pub const SIG_UNBLOCK = 2;
533pub const SIG_SETMASK = 3;
534
535pub const SOCK = struct {557pub const SOCK = struct {
536 pub const STREAM = 1;558 pub const STREAM = 1;
537 pub const DGRAM = 2;559 pub const DGRAM = 2;
...@@ -615,7 +637,7 @@ pub const PF = struct {...@@ -615,7 +637,7 @@ pub const PF = struct {
615 pub const SIP = AF.SIP;637 pub const SIP = AF.SIP;
616 pub const IPX = AF.IPX;638 pub const IPX = AF.IPX;
617 pub const RTIP = AF.pseudo_RTIP;639 pub const RTIP = AF.pseudo_RTIP;
618 pub const PIP = psuedo_AF.PIP;640 pub const PIP = AF.pseudo_PIP;
619 pub const ISDN = AF.ISDN;641 pub const ISDN = AF.ISDN;
620 pub const KEY = AF.pseudo_KEY;642 pub const KEY = AF.pseudo_KEY;
621 pub const INET6 = AF.pseudo_INET6;643 pub const INET6 = AF.pseudo_INET6;
...@@ -816,7 +838,6 @@ pub const Sigaction = extern struct {...@@ -816,7 +838,6 @@ pub const Sigaction = extern struct {
816 /// signal handler838 /// signal handler
817 __sigaction_u: extern union {839 __sigaction_u: extern union {
818 __sa_handler: fn (i32) callconv(.C) void,840 __sa_handler: fn (i32) callconv(.C) void,
819 __sa_sigaction: fn (i32, *__siginfo, usize) callconv(.C) void,
820 },841 },
821842
822 /// see signal options843 /// see signal options
...@@ -826,23 +847,8 @@ pub const Sigaction = extern struct {...@@ -826,23 +847,8 @@ pub const Sigaction = extern struct {
826 sa_mask: sigset_t,847 sa_mask: sigset_t,
827};848};
828849
829pub const _SIG_WORDS = 4;
830pub const _SIG_MAXSIG = 128;
831pub inline fn _SIG_IDX(sig: usize) usize {
832 return sig - 1;
833}
834pub inline fn _SIG_WORD(sig: usize) usize {
835 return_SIG_IDX(sig) >> 5;
836}
837pub inline fn _SIG_BIT(sig: usize) usize {
838 return 1 << (_SIG_IDX(sig) & 31);
839}
840pub inline fn _SIG_VALID(sig: usize) usize {
841 return sig <= _SIG_MAXSIG and sig > 0;
842}
843
844pub const sigset_t = extern struct {850pub const sigset_t = extern struct {
845 __bits: [_SIG_WORDS]u32,851 __bits: [SIG.WORDS]u32,
846};852};
847853
848pub const E = enum(i32) {854pub const E = enum(i32) {
...@@ -1047,22 +1053,22 @@ pub fn S_IWHT(m: u32) bool {...@@ -1047,22 +1053,22 @@ pub fn S_IWHT(m: u32) bool {
10471053
1048pub const HOST_NAME_MAX = 255;1054pub const HOST_NAME_MAX = 255;
10491055
1050/// Magic value that specify the use of the current working directory1056pub const AT = struct {
1051/// to determine the target of relative file paths in the openat() and1057 /// Magic value that specify the use of the current working directory
1052/// similar syscalls.1058 /// to determine the target of relative file paths in the openat() and
1053pub const AT_FDCWD = -100;1059 /// similar syscalls.
10541060 pub const FDCWD = -100;
1055/// Check access using effective user and group ID1061 /// Check access using effective user and group ID
1056pub const AT_EACCESS = 0x0100;1062 pub const EACCESS = 0x0100;
10571063 /// Do not follow symbolic links
1058/// Do not follow symbolic links1064 pub const SYMLINK_NOFOLLOW = 0x0200;
1059pub const AT_SYMLINK_NOFOLLOW = 0x0200;1065 /// Follow symbolic link
10601066 pub const SYMLINK_FOLLOW = 0x0400;
1061/// Follow symbolic link1067 /// Remove directory instead of file
1062pub const AT_SYMLINK_FOLLOW = 0x0400;1068 pub const REMOVEDIR = 0x0800;
10631069 /// Fail if not under dirfd
1064/// Remove directory instead of file1070 pub const BENEATH = 0x1000;
1065pub const AT_REMOVEDIR = 0x0800;1071};
10661072
1067pub const addrinfo = extern struct {1073pub const addrinfo = extern struct {
1068 flags: i32,1074 flags: i32,
...@@ -1075,9 +1081,6 @@ pub const addrinfo = extern struct {...@@ -1075,9 +1081,6 @@ pub const addrinfo = extern struct {
1075 next: ?*addrinfo,1081 next: ?*addrinfo,
1076};1082};
10771083
1078/// Fail if not under dirfd
1079pub const AT_BENEATH = 0x1000;
1080
1081pub const IPPROTO = struct {1084pub const IPPROTO = struct {
1082 /// dummy for IP1085 /// dummy for IP
1083 pub const IP = 0;1086 pub const IP = 0;
lib/std/c/hermit.zig+4-1
...@@ -1,3 +1,6 @@...@@ -1,3 +1,6 @@
1const std = @import("std");
2const maxInt = std.math.maxInt;
3
1pub const pthread_mutex_t = extern struct {4pub const pthread_mutex_t = extern struct {
2 inner: usize = ~@as(usize, 0),5 inner: usize = ~@as(usize, 0),
3};6};
...@@ -5,5 +8,5 @@ pub const pthread_cond_t = extern struct {...@@ -5,5 +8,5 @@ pub const pthread_cond_t = extern struct {
5 inner: usize = ~@as(usize, 0),8 inner: usize = ~@as(usize, 0),
6};9};
7pub const pthread_rwlock_t = extern struct {10pub const pthread_rwlock_t = extern struct {
8 ptr: usize = std.math.maxInt(usize),11 ptr: usize = maxInt(usize),
9};12};
lib/std/c/linux.zig+1
...@@ -6,6 +6,7 @@ const native_arch = builtin.cpu.arch;...@@ -6,6 +6,7 @@ const native_arch = builtin.cpu.arch;
6const linux = std.os.linux;6const linux = std.os.linux;
7const iovec = std.os.iovec;7const iovec = std.os.iovec;
8const iovec_const = std.os.iovec_const;8const iovec_const = std.os.iovec_const;
9const FILE = std.c.FILE;
910
10pub const AF = linux.AF;11pub const AF = linux.AF;
11pub const ARCH = linux.ARCH;12pub const ARCH = linux.ARCH;
lib/std/c/netbsd.zig+141-124
...@@ -1,6 +1,10 @@...@@ -1,6 +1,10 @@
1const std = @import("../std.zig");1const std = @import("../std.zig");
2const builtin = @import("builtin");2const builtin = @import("builtin");
3const maxInt = std.math.maxInt;3const maxInt = std.math.maxInt;
4const iovec = std.os.iovec;
5const iovec_const = std.os.iovec_const;
6const timezone = std.c.timezone;
7const rusage = std.c.rusage;
48
5extern "c" fn __errno() *c_int;9extern "c" fn __errno() *c_int;
6pub const _errno = __errno;10pub const _errno = __errno;
...@@ -12,56 +16,81 @@ pub extern "c" fn _lwp_self() lwpid_t;...@@ -12,56 +16,81 @@ pub extern "c" fn _lwp_self() lwpid_t;
1216
13pub extern "c" fn pipe2(fds: *[2]fd_t, flags: u32) c_int;17pub extern "c" fn pipe2(fds: *[2]fd_t, flags: u32) c_int;
14pub extern "c" fn arc4random_buf(buf: [*]u8, len: usize) void;18pub extern "c" fn arc4random_buf(buf: [*]u8, len: usize) void;
19
15pub extern "c" fn __fstat50(fd: fd_t, buf: *Stat) c_int;20pub extern "c" fn __fstat50(fd: fd_t, buf: *Stat) c_int;
21pub const fstat = __fstat50;
22
16pub extern "c" fn __stat50(path: [*:0]const u8, buf: *Stat) c_int;23pub extern "c" fn __stat50(path: [*:0]const u8, buf: *Stat) c_int;
24pub const stat = __stat50;
25
17pub extern "c" fn __clock_gettime50(clk_id: c_int, tp: *timespec) c_int;26pub extern "c" fn __clock_gettime50(clk_id: c_int, tp: *timespec) c_int;
27pub const clock_gettime = __clock_gettime50;
28
18pub extern "c" fn __clock_getres50(clk_id: c_int, tp: *timespec) c_int;29pub extern "c" fn __clock_getres50(clk_id: c_int, tp: *timespec) c_int;
30pub const clock_getres = __clock_getres50;
31
19pub extern "c" fn __getdents30(fd: c_int, buf_ptr: [*]u8, nbytes: usize) c_int;32pub extern "c" fn __getdents30(fd: c_int, buf_ptr: [*]u8, nbytes: usize) c_int;
33pub const getdents = __getdents30;
34
20pub extern "c" fn __sigaltstack14(ss: ?*stack_t, old_ss: ?*stack_t) c_int;35pub extern "c" fn __sigaltstack14(ss: ?*stack_t, old_ss: ?*stack_t) c_int;
36pub const sigaltstack = __sigaltstack14;
37
21pub extern "c" fn __nanosleep50(rqtp: *const timespec, rmtp: ?*timespec) c_int;38pub extern "c" fn __nanosleep50(rqtp: *const timespec, rmtp: ?*timespec) c_int;
39pub const nanosleep = __nanosleep50;
40
22pub extern "c" fn __sigaction14(sig: c_int, noalias act: ?*const Sigaction, noalias oact: ?*Sigaction) c_int;41pub extern "c" fn __sigaction14(sig: c_int, noalias act: ?*const Sigaction, noalias oact: ?*Sigaction) c_int;
42pub const sigaction = __sigaction14;
43
23pub extern "c" fn __sigprocmask14(how: c_int, noalias set: ?*const sigset_t, noalias oset: ?*sigset_t) c_int;44pub extern "c" fn __sigprocmask14(how: c_int, noalias set: ?*const sigset_t, noalias oset: ?*sigset_t) c_int;
45pub const sigprocmask = __sigaction14;
46
24pub extern "c" fn __socket30(domain: c_uint, sock_type: c_uint, protocol: c_uint) c_int;47pub extern "c" fn __socket30(domain: c_uint, sock_type: c_uint, protocol: c_uint) c_int;
48pub const socket = __socket30;
49
25pub extern "c" fn __gettimeofday50(noalias tv: ?*timeval, noalias tz: ?*timezone) c_int;50pub extern "c" fn __gettimeofday50(noalias tv: ?*timeval, noalias tz: ?*timezone) c_int;
51pub const gettimeofday = __gettimeofday50;
52
26pub extern "c" fn __getrusage50(who: c_int, usage: *rusage) c_int;53pub extern "c" fn __getrusage50(who: c_int, usage: *rusage) c_int;
27// libc aliases this as sched_yield54pub const getrusage = __getrusage50;
55
28pub extern "c" fn __libc_thr_yield() c_int;56pub extern "c" fn __libc_thr_yield() c_int;
57pub const sched_yield = __libc_thr_yield;
2958
30pub extern "c" fn posix_memalign(memptr: *?*c_void, alignment: usize, size: usize) c_int;59pub extern "c" fn posix_memalign(memptr: *?*c_void, alignment: usize, size: usize) c_int;
3160
32pub const pthread_mutex_t = extern struct {61pub const pthread_mutex_t = extern struct {
33 ptm_magic: u32 = 0x33330003,62 magic: u32 = 0x33330003,
34 ptm_errorcheck: padded_pthread_spin_t = 0,63 errorcheck: padded_pthread_spin_t = 0,
35 ptm_ceiling: padded_pthread_spin_t = 0,64 ceiling: padded_pthread_spin_t = 0,
36 ptm_owner: usize = 0,65 owner: usize = 0,
37 ptm_waiters: ?*u8 = null,66 waiters: ?*u8 = null,
38 ptm_recursed: u32 = 0,67 recursed: u32 = 0,
39 ptm_spare2: ?*c_void = null,68 spare2: ?*c_void = null,
40};69};
4170
42pub const pthread_cond_t = extern struct {71pub const pthread_cond_t = extern struct {
43 ptc_magic: u32 = 0x55550005,72 magic: u32 = 0x55550005,
44 ptc_lock: pthread_spin_t = 0,73 lock: pthread_spin_t = 0,
45 ptc_waiters_first: ?*u8 = null,74 waiters_first: ?*u8 = null,
46 ptc_waiters_last: ?*u8 = null,75 waiters_last: ?*u8 = null,
47 ptc_mutex: ?*pthread_mutex_t = null,76 mutex: ?*pthread_mutex_t = null,
48 ptc_private: ?*c_void = null,77 private: ?*c_void = null,
49};78};
5079
51pub const pthread_rwlock_t = extern struct {80pub const pthread_rwlock_t = extern struct {
52 ptr_magic: c_uint = 0x99990009,81 magic: c_uint = 0x99990009,
53 ptr_interlock: switch (builtin.cpu.arch) {82 interlock: switch (builtin.cpu.arch) {
54 .aarch64, .sparc, .x86_64, .i386 => u8,83 .aarch64, .sparc, .x86_64, .i386 => u8,
55 .arm, .powerpc => c_int,84 .arm, .powerpc => c_int,
56 else => unreachable,85 else => unreachable,
57 } = 0,86 } = 0,
58 ptr_rblocked_first: ?*u8 = null,87 rblocked_first: ?*u8 = null,
59 ptr_rblocked_last: ?*u8 = null,88 rblocked_last: ?*u8 = null,
60 ptr_wblocked_first: ?*u8 = null,89 wblocked_first: ?*u8 = null,
61 ptr_wblocked_last: ?*u8 = null,90 wblocked_last: ?*u8 = null,
62 ptr_nreaders: c_uint = 0,91 nreaders: c_uint = 0,
63 ptr_owner: std.c.pthread_t = null,92 owner: std.c.pthread_t = null,
64 ptr_private: ?*c_void = null,93 private: ?*c_void = null,
65};94};
6695
67const pthread_spin_t = switch (builtin.cpu.arch) {96const pthread_spin_t = switch (builtin.cpu.arch) {
...@@ -92,20 +121,6 @@ pub const sem_t = ?*opaque {};...@@ -92,20 +121,6 @@ pub const sem_t = ?*opaque {};
92pub extern "c" fn pthread_setname_np(thread: std.c.pthread_t, name: [*:0]const u8, arg: ?*c_void) E;121pub extern "c" fn pthread_setname_np(thread: std.c.pthread_t, name: [*:0]const u8, arg: ?*c_void) E;
93pub extern "c" fn pthread_getname_np(thread: std.c.pthread_t, name: [*:0]u8, len: usize) E;122pub extern "c" fn pthread_getname_np(thread: std.c.pthread_t, name: [*:0]u8, len: usize) E;
94123
95pub const clock_getres = __clock_getres50;
96pub const clock_gettime = __clock_gettime50;
97pub const fstat = __fstat50;
98pub const getdents = __getdents30;
99pub const getrusage = __getrusage50;
100pub const gettimeofday = __gettimeofday50;
101pub const nanosleep = __nanosleep50;
102pub const sched_yield = __libc_thr_yield;
103pub const sigaction = __sigaction14;
104pub const sigaltstack = __sigaltstack14;
105pub const sigprocmask = __sigprocmask14;
106pub const socket = __socket30;
107pub const stat = __stat50;
108
109pub const blkcnt_t = i64;124pub const blkcnt_t = i64;
110pub const blksize_t = i32;125pub const blksize_t = i32;
111pub const clock_t = u32;126pub const clock_t = u32;
...@@ -568,43 +583,6 @@ pub const SA_NODEFER = 0x0010;...@@ -568,43 +583,6 @@ pub const SA_NODEFER = 0x0010;
568pub const SA_NOCLDWAIT = 0x0020;583pub const SA_NOCLDWAIT = 0x0020;
569pub const SA_SIGINFO = 0x0040;584pub const SA_SIGINFO = 0x0040;
570585
571pub const SIGHUP = 1;
572pub const SIGINT = 2;
573pub const SIGQUIT = 3;
574pub const SIGILL = 4;
575pub const SIGTRAP = 5;
576pub const SIGABRT = 6;
577pub const SIGIOT = SIGABRT;
578pub const SIGEMT = 7;
579pub const SIGFPE = 8;
580pub const SIGKILL = 9;
581pub const SIGBUS = 10;
582pub const SIGSEGV = 11;
583pub const SIGSYS = 12;
584pub const SIGPIPE = 13;
585pub const SIGALRM = 14;
586pub const SIGTERM = 15;
587pub const SIGURG = 16;
588pub const SIGSTOP = 17;
589pub const SIGTSTP = 18;
590pub const SIGCONT = 19;
591pub const SIGCHLD = 20;
592pub const SIGTTIN = 21;
593pub const SIGTTOU = 22;
594pub const SIGIO = 23;
595pub const SIGXCPU = 24;
596pub const SIGXFSZ = 25;
597pub const SIGVTALRM = 26;
598pub const SIGPROF = 27;
599pub const SIGWINCH = 28;
600pub const SIGINFO = 29;
601pub const SIGUSR1 = 30;
602pub const SIGUSR2 = 31;
603pub const SIGPWR = 32;
604
605pub const SIGRTMIN = 33;
606pub const SIGRTMAX = 63;
607
608// access function586// access function
609pub const F_OK = 0; // test for existence of file587pub const F_OK = 0; // test for existence of file
610pub const X_OK = 1; // test for execute or search permission588pub const X_OK = 1; // test for execute or search permission
...@@ -677,22 +655,24 @@ pub const O_CLOEXEC = 0x00400000;...@@ -677,22 +655,24 @@ pub const O_CLOEXEC = 0x00400000;
677/// skip search permission checks655/// skip search permission checks
678pub const O_SEARCH = 0x00800000;656pub const O_SEARCH = 0x00800000;
679657
680pub const F_DUPFD = 0;658pub const F = struct {
681pub const F_GETFD = 1;659 pub const DUPFD = 0;
682pub const F_SETFD = 2;660 pub const GETFD = 1;
683pub const F_GETFL = 3;661 pub const SETFD = 2;
684pub const F_SETFL = 4;662 pub const GETFL = 3;
663 pub const SETFL = 4;
685664
686pub const F_GETOWN = 5;665 pub const GETOWN = 5;
687pub const F_SETOWN = 6;666 pub const SETOWN = 6;
688667
689pub const F_GETLK = 7;668 pub const GETLK = 7;
690pub const F_SETLK = 8;669 pub const SETLK = 8;
691pub const F_SETLKW = 9;670 pub const SETLKW = 9;
692671
693pub const F_RDLCK = 1;672 pub const RDLCK = 1;
694pub const F_WRLCK = 3;673 pub const WRLCK = 3;
695pub const F_UNLCK = 2;674 pub const UNLCK = 2;
675};
696676
697pub const LOCK = struct {677pub const LOCK = struct {
698 pub const SH = 1;678 pub const SH = 1;
...@@ -918,9 +898,64 @@ pub const winsize = extern struct {...@@ -918,9 +898,64 @@ pub const winsize = extern struct {
918898
919const NSIG = 32;899const NSIG = 32;
920900
921pub const SIG_DFL = @intToPtr(?Sigaction.sigaction_fn, 0);901pub const SIG = struct {
922pub const SIG_IGN = @intToPtr(?Sigaction.sigaction_fn, 1);902 pub const DFL = @intToPtr(?Sigaction.sigaction_fn, 0);
923pub const SIG_ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize));903 pub const IGN = @intToPtr(?Sigaction.sigaction_fn, 1);
904 pub const ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize));
905
906 pub const WORDS = 4;
907 pub const MAXSIG = 128;
908
909 pub const HUP = 1;
910 pub const INT = 2;
911 pub const QUIT = 3;
912 pub const ILL = 4;
913 pub const TRAP = 5;
914 pub const ABRT = 6;
915 pub const IOT = ABRT;
916 pub const EMT = 7;
917 pub const FPE = 8;
918 pub const KILL = 9;
919 pub const BUS = 10;
920 pub const SEGV = 11;
921 pub const SYS = 12;
922 pub const PIPE = 13;
923 pub const ALRM = 14;
924 pub const TERM = 15;
925 pub const URG = 16;
926 pub const STOP = 17;
927 pub const TSTP = 18;
928 pub const CONT = 19;
929 pub const CHLD = 20;
930 pub const TTIN = 21;
931 pub const TTOU = 22;
932 pub const IO = 23;
933 pub const XCPU = 24;
934 pub const XFSZ = 25;
935 pub const VTALRM = 26;
936 pub const PROF = 27;
937 pub const WINCH = 28;
938 pub const INFO = 29;
939 pub const USR1 = 30;
940 pub const USR2 = 31;
941 pub const PWR = 32;
942
943 pub const RTMIN = 33;
944 pub const RTMAX = 63;
945
946 pub inline fn IDX(sig: usize) usize {
947 return sig - 1;
948 }
949 pub inline fn WORD(sig: usize) usize {
950 return IDX(sig) >> 5;
951 }
952 pub inline fn BIT(sig: usize) usize {
953 return 1 << (IDX(sig) & 31);
954 }
955 pub inline fn VALID(sig: usize) usize {
956 return sig <= MAXSIG and sig > 0;
957 }
958};
924959
925/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.960/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.
926pub const Sigaction = extern struct {961pub const Sigaction = extern struct {
...@@ -993,27 +1028,11 @@ pub const _ksiginfo = extern struct {...@@ -993,27 +1028,11 @@ pub const _ksiginfo = extern struct {
993 } align(@sizeOf(usize)),1028 } align(@sizeOf(usize)),
994};1029};
9951030
996pub const _SIG_WORDS = 4;
997pub const _SIG_MAXSIG = 128;
998
999pub inline fn _SIG_IDX(sig: usize) usize {
1000 return sig - 1;
1001}
1002pub inline fn _SIG_WORD(sig: usize) usize {
1003 return_SIG_IDX(sig) >> 5;
1004}
1005pub inline fn _SIG_BIT(sig: usize) usize {
1006 return 1 << (_SIG_IDX(sig) & 31);
1007}
1008pub inline fn _SIG_VALID(sig: usize) usize {
1009 return sig <= _SIG_MAXSIG and sig > 0;
1010}
1011
1012pub const sigset_t = extern struct {1031pub const sigset_t = extern struct {
1013 __bits: [_SIG_WORDS]u32,1032 __bits: [SIG.WORDS]u32,
1014};1033};
10151034
1016pub const empty_sigset = sigset_t{ .__bits = [_]u32{0} ** _SIG_WORDS };1035pub const empty_sigset = sigset_t{ .__bits = [_]u32{0} ** SIG.WORDS };
10171036
1018// XXX x86_64 specific1037// XXX x86_64 specific
1019pub const mcontext_t = extern struct {1038pub const mcontext_t = extern struct {
...@@ -1253,22 +1272,20 @@ pub fn S_IWHT(m: u32) bool {...@@ -1253,22 +1272,20 @@ pub fn S_IWHT(m: u32) bool {
1253 return m & S_IFMT == S_IFWHT;1272 return m & S_IFMT == S_IFWHT;
1254}1273}
12551274
1256/// Magic value that specify the use of the current working directory1275pub const AT = struct {
1257/// to determine the target of relative file paths in the openat() and1276 /// Magic value that specify the use of the current working directory
1258/// similar syscalls.1277 /// to determine the target of relative file paths in the openat() and
1259pub const AT_FDCWD = -100;1278 /// similar syscalls.
12601279 pub const FDCWD = -100;
1261/// Check access using effective user and group ID1280 /// Check access using effective user and group ID
1262pub const AT_EACCESS = 0x0100;1281 pub const EACCESS = 0x0100;
12631282 /// Do not follow symbolic links
1264/// Do not follow symbolic links1283 pub const SYMLINK_NOFOLLOW = 0x0200;
1265pub const AT_SYMLINK_NOFOLLOW = 0x0200;1284 /// Follow symbolic link
12661285 pub const SYMLINK_FOLLOW = 0x0400;
1267/// Follow symbolic link1286 /// Remove directory instead of file
1268pub const AT_SYMLINK_FOLLOW = 0x0400;1287 pub const REMOVEDIR = 0x0800;
12691288};
1270/// Remove directory instead of file
1271pub const AT_REMOVEDIR = 0x0800;
12721289
1273pub const HOST_NAME_MAX = 255;1290pub const HOST_NAME_MAX = 255;
12741291
lib/std/c/openbsd.zig+32-30
...@@ -1,6 +1,8 @@...@@ -1,6 +1,8 @@
1const std = @import("../std.zig");1const std = @import("../std.zig");
2const maxInt = std.math.maxInt;2const maxInt = std.math.maxInt;
3const builtin = @import("builtin");3const builtin = @import("builtin");
4const iovec = std.os.iovec;
5const iovec_const = std.os.iovec_const;
46
5extern "c" fn __errno() *c_int;7extern "c" fn __errno() *c_int;
6pub const _errno = __errno;8pub const _errno = __errno;
...@@ -466,22 +468,24 @@ pub const O_DIRECTORY = 0x20000;...@@ -466,22 +468,24 @@ pub const O_DIRECTORY = 0x20000;
466/// set close on exec468/// set close on exec
467pub const O_CLOEXEC = 0x10000;469pub const O_CLOEXEC = 0x10000;
468470
469pub const F_DUPFD = 0;471pub const F = struct {
470pub const F_GETFD = 1;472 pub const DUPFD = 0;
471pub const F_SETFD = 2;473 pub const GETFD = 1;
472pub const F_GETFL = 3;474 pub const SETFD = 2;
473pub const F_SETFL = 4;475 pub const GETFL = 3;
476 pub const SETFL = 4;
474477
475pub const F_GETOWN = 5;478 pub const GETOWN = 5;
476pub const F_SETOWN = 6;479 pub const SETOWN = 6;
477480
478pub const F_GETLK = 7;481 pub const GETLK = 7;
479pub const F_SETLK = 8;482 pub const SETLK = 8;
480pub const F_SETLKW = 9;483 pub const SETLKW = 9;
481484
482pub const F_RDLCK = 1;485 pub const RDLCK = 1;
483pub const F_UNLCK = 2;486 pub const UNLCK = 2;
484pub const F_WRLCK = 3;487 pub const WRLCK = 3;
488};
485489
486pub const LOCK = struct {490pub const LOCK = struct {
487 pub const SH = 0x01;491 pub const SH = 0x01;
...@@ -840,7 +844,7 @@ const arch_bits = switch (builtin.cpu.arch) {...@@ -840,7 +844,7 @@ const arch_bits = switch (builtin.cpu.arch) {
840 sc_rsp: c_long,844 sc_rsp: c_long,
841 sc_ss: c_long,845 sc_ss: c_long,
842846
843 sc_fpstate: fxsave64,847 sc_fpstate: arch_bits.fxsave64,
844 __sc_unused: c_int,848 __sc_unused: c_int,
845 sc_mask: c_int,849 sc_mask: c_int,
846 sc_cookie: c_long,850 sc_cookie: c_long,
...@@ -1063,22 +1067,20 @@ pub fn S_ISSOCK(m: u32) bool {...@@ -1063,22 +1067,20 @@ pub fn S_ISSOCK(m: u32) bool {
1063 return m & S_IFMT == S_IFSOCK;1067 return m & S_IFMT == S_IFSOCK;
1064}1068}
10651069
1066/// Magic value that specify the use of the current working directory1070pub const AT = struct {
1067/// to determine the target of relative file paths in the openat() and1071 /// Magic value that specify the use of the current working directory
1068/// similar syscalls.1072 /// to determine the target of relative file paths in the openat() and
1069pub const AT_FDCWD = -100;1073 /// similar syscalls.
10701074 pub const FDCWD = -100;
1071/// Check access using effective user and group ID1075 /// Check access using effective user and group ID
1072pub const AT_EACCESS = 0x01;1076 pub const EACCESS = 0x01;
10731077 /// Do not follow symbolic links
1074/// Do not follow symbolic links1078 pub const SYMLINK_NOFOLLOW = 0x02;
1075pub const AT_SYMLINK_NOFOLLOW = 0x02;1079 /// Follow symbolic link
10761080 pub const SYMLINK_FOLLOW = 0x04;
1077/// Follow symbolic link1081 /// Remove directory instead of file
1078pub const AT_SYMLINK_FOLLOW = 0x04;1082 pub const REMOVEDIR = 0x08;
10791083};
1080/// Remove directory instead of file
1081pub const AT_REMOVEDIR = 0x08;
10821084
1083pub const HOST_NAME_MAX = 255;1085pub const HOST_NAME_MAX = 255;
10841086
lib/std/c/wasi.zig+19-5
...@@ -1,3 +1,7 @@...@@ -1,3 +1,7 @@
1const std = @import("../std.zig");
2const wasi = std.os.wasi;
3const FDFLAG = wasi.FDFLAG;
4
1extern threadlocal var errno: c_int;5extern threadlocal var errno: c_int;
26
3pub fn _errno() *c_int {7pub fn _errno() *c_int {
...@@ -9,6 +13,10 @@ pub const pid_t = c_int;...@@ -9,6 +13,10 @@ pub const pid_t = c_int;
9pub const uid_t = u32;13pub const uid_t = u32;
10pub const gid_t = u32;14pub const gid_t = u32;
11pub const off_t = i64;15pub const off_t = i64;
16pub const ino_t = wasi.ino_t;
17pub const mode_t = wasi.mode_t;
18pub const time_t = wasi.time_t;
19pub const timespec = wasi.timespec;
1220
13pub const Stat = extern struct {21pub const Stat = extern struct {
14 dev: i32,22 dev: i32,
...@@ -57,22 +65,28 @@ pub const Stat = extern struct {...@@ -57,22 +65,28 @@ pub const Stat = extern struct {
57/// https://github.com/WebAssembly/wasi-libc/blob/main/expected/wasm32-wasi/predefined-macros.txt65/// https://github.com/WebAssembly/wasi-libc/blob/main/expected/wasm32-wasi/predefined-macros.txt
58pub const O = struct {66pub const O = struct {
59 pub const ACCMODE = (EXEC | RDWR | SEARCH);67 pub const ACCMODE = (EXEC | RDWR | SEARCH);
60 pub const APPEND = FDFLAG_APPEND;68 pub const APPEND = FDFLAG.APPEND;
61 pub const CLOEXEC = (0);69 pub const CLOEXEC = (0);
62 pub const CREAT = ((1 << 0) << 12); // = __WASI_OFLAGS_CREAT << 1270 pub const CREAT = ((1 << 0) << 12); // = __WASI_OFLAGS_CREAT << 12
63 pub const DIRECTORY = ((1 << 1) << 12); // = __WASI_OFLAGS_DIRECTORY << 1271 pub const DIRECTORY = ((1 << 1) << 12); // = __WASI_OFLAGS_DIRECTORY << 12
64 pub const DSYNC = FDFLAG_DSYNC;72 pub const DSYNC = FDFLAG.DSYNC;
65 pub const EXCL = ((1 << 2) << 12); // = __WASI_OFLAGS_EXCL << 1273 pub const EXCL = ((1 << 2) << 12); // = __WASI_OFLAGS_EXCL << 12
66 pub const EXEC = (0x02000000);74 pub const EXEC = (0x02000000);
67 pub const NOCTTY = (0);75 pub const NOCTTY = (0);
68 pub const NOFOLLOW = (0x01000000);76 pub const NOFOLLOW = (0x01000000);
69 pub const NONBLOCK = (1 << FDFLAG_NONBLOCK);77 pub const NONBLOCK = (1 << FDFLAG.NONBLOCK);
70 pub const RDONLY = (0x04000000);78 pub const RDONLY = (0x04000000);
71 pub const RDWR = (RDONLY | WRONLY);79 pub const RDWR = (RDONLY | WRONLY);
72 pub const RSYNC = (1 << FDFLAG_RSYNC);80 pub const RSYNC = (1 << FDFLAG.RSYNC);
73 pub const SEARCH = (0x08000000);81 pub const SEARCH = (0x08000000);
74 pub const SYNC = (1 << FDFLAG_SYNC);82 pub const SYNC = (1 << FDFLAG.SYNC);
75 pub const TRUNC = ((1 << 3) << 12); // = __WASI_OFLAGS_TRUNC << 1283 pub const TRUNC = ((1 << 3) << 12); // = __WASI_OFLAGS_TRUNC << 12
76 pub const TTY_INIT = (0);84 pub const TTY_INIT = (0);
77 pub const WRONLY = (0x10000000);85 pub const WRONLY = (0x10000000);
78};86};
87
88pub const SEEK = struct {
89 pub const SET: wasi.whence_t = .SET;
90 pub const CUR: wasi.whence_t = .CUR;
91 pub const END: wasi.whence_t = .END;
92};
lib/std/c/windows.zig+40-46
...@@ -1,7 +1,6 @@...@@ -1,7 +1,6 @@
1//! The reference for these types and values is Microsoft Windows's ucrt (Universal C RunTime).1//! The reference for these types and values is Microsoft Windows's ucrt (Universal C RunTime).
2const std = @import("../std.zig");2const std = @import("../std.zig");
3const ws2_32 = std.os.windows.ws2_32;3const ws2_32 = std.os.windows.ws2_32;
4
5const windows = std.os.windows;4const windows = std.os.windows;
65
7pub extern "c" fn _errno() *c_int;6pub extern "c" fn _errno() *c_int;
...@@ -43,56 +42,51 @@ pub const timeval = extern struct {...@@ -43,56 +42,51 @@ pub const timeval = extern struct {
43 tv_usec: c_long,42 tv_usec: c_long,
44};43};
4544
45pub const Stat = @compileError("TODO windows Stat definition");
46
46pub const sig_atomic_t = c_int;47pub const sig_atomic_t = c_int;
4748
49pub const sigset_t = @compileError("TODO windows sigset_t definition");
50pub const Sigaction = @compileError("TODO windows Sigaction definition");
51pub const timezone = @compileError("TODO windows timezone definition");
52pub const rusage = @compileError("TODO windows rusage definition");
53
48/// maximum signal number + 154/// maximum signal number + 1
49pub const NSIG = 23;55pub const NSIG = 23;
5056
51// Signal types57/// Signal types
5258pub const SIG = struct {
53/// interrupt59 /// interrupt
54pub const SIGINT = 2;60 pub const INT = 2;
5561 /// illegal instruction - invalid function image
56/// illegal instruction - invalid function image62 pub const ILL = 4;
57pub const SIGILL = 4;63 /// floating point exception
5864 pub const FPE = 8;
59/// floating point exception65 /// segment violation
60pub const SIGFPE = 8;66 pub const SEGV = 11;
6167 /// Software termination signal from kill
62/// segment violation68 pub const TERM = 15;
63pub const SIGSEGV = 11;69 /// Ctrl-Break sequence
6470 pub const BREAK = 21;
65/// Software termination signal from kill71 /// abnormal termination triggered by abort call
66pub const SIGTERM = 15;72 pub const ABRT = 22;
6773 /// SIGABRT compatible with other platforms, same as SIGABRT
68/// Ctrl-Break sequence74 pub const ABRT_COMPAT = 6;
69pub const SIGBREAK = 21;75
7076 // Signal action codes
71/// abnormal termination triggered by abort call77 /// default signal action
72pub const SIGABRT = 22;78 pub const DFL = 0;
7379 /// ignore signal
74/// SIGABRT compatible with other platforms, same as SIGABRT80 pub const IGN = 1;
75pub const SIGABRT_COMPAT = 6;81 /// return current value
7682 pub const GET = 2;
77// Signal action codes83 /// signal gets error
7884 pub const SGE = 3;
79/// default signal action85 /// acknowledge
80pub const SIG_DFL = 0;86 pub const ACK = 4;
8187 /// Signal error value (returned by signal call on error)
82/// ignore signal88 pub const ERR = -1;
83pub const SIG_IGN = 1;89};
84
85/// return current value
86pub const SIG_GET = 2;
87
88/// signal gets error
89pub const SIG_SGE = 3;
90
91/// acknowledge
92pub const SIG_ACK = 4;
93
94/// Signal error value (returned by signal call on error)
95pub const SIG_ERR = -1;
9690
97pub const SEEK_SET = 0;91pub const SEEK_SET = 0;
98pub const SEEK_CUR = 1;92pub const SEEK_CUR = 1;
lib/std/crypto/25519/curve25519.zig+1-3
...@@ -40,9 +40,7 @@ pub const Curve25519 = struct {...@@ -40,9 +40,7 @@ pub const Curve25519 = struct {
40 }40 }
4141
42 /// Multiply a point by the cofactor42 /// Multiply a point by the cofactor
43 pub fn clearCofactor(p: Edwards25519) Edwards25519 {43 pub const clearCofactor = @compileError("TODO what was this function supposed to do? it didn't compile successfully");
44 return p.dbl().dbl().dbl();
45 }
4644
47 fn ladder(p: Curve25519, s: [32]u8, comptime bits: usize) IdentityElementError!Curve25519 {45 fn ladder(p: Curve25519, s: [32]u8, comptime bits: usize) IdentityElementError!Curve25519 {
48 var x1 = p.x;46 var x1 = p.x;
lib/std/debug.zig+2-2
...@@ -1341,7 +1341,7 @@ pub const ModuleDebugInfo = switch (native_os) {...@@ -1341,7 +1341,7 @@ pub const ModuleDebugInfo = switch (native_os) {
1341 if (o_file_di.findCompileUnit(relocated_address_o)) |compile_unit| {1341 if (o_file_di.findCompileUnit(relocated_address_o)) |compile_unit| {
1342 return SymbolInfo{1342 return SymbolInfo{
1343 .symbol_name = o_file_di.getSymbolName(relocated_address_o) orelse "???",1343 .symbol_name = o_file_di.getSymbolName(relocated_address_o) orelse "???",
1344 .compile_unit_name = compile_unit.die.getAttrString(&o_file_di, DW.AT_name) catch |err| switch (err) {1344 .compile_unit_name = compile_unit.die.getAttrString(&o_file_di, DW.AT.name) catch |err| switch (err) {
1345 error.MissingDebugInfo, error.InvalidDebugInfo => "???",1345 error.MissingDebugInfo, error.InvalidDebugInfo => "???",
1346 else => return err,1346 else => return err,
1347 },1347 },
...@@ -1438,7 +1438,7 @@ fn getSymbolFromDwarf(address: u64, di: *DW.DwarfInfo) !SymbolInfo {...@@ -1438,7 +1438,7 @@ fn getSymbolFromDwarf(address: u64, di: *DW.DwarfInfo) !SymbolInfo {
1438 if (nosuspend di.findCompileUnit(address)) |compile_unit| {1438 if (nosuspend di.findCompileUnit(address)) |compile_unit| {
1439 return SymbolInfo{1439 return SymbolInfo{
1440 .symbol_name = nosuspend di.getSymbolName(address) orelse "???",1440 .symbol_name = nosuspend di.getSymbolName(address) orelse "???",
1441 .compile_unit_name = compile_unit.die.getAttrString(di, DW.AT_name) catch |err| switch (err) {1441 .compile_unit_name = compile_unit.die.getAttrString(di, DW.AT.name) catch |err| switch (err) {
1442 error.MissingDebugInfo, error.InvalidDebugInfo => "???",1442 error.MissingDebugInfo, error.InvalidDebugInfo => "???",
1443 else => return err,1443 else => return err,
1444 },1444 },
lib/std/dwarf.zig+277-61
...@@ -9,7 +9,223 @@ const leb = @import("leb128.zig");...@@ -9,7 +9,223 @@ const leb = @import("leb128.zig");
99
10const ArrayList = std.ArrayList;10const ArrayList = std.ArrayList;
1111
12pub usingnamespace @import("dwarf_bits.zig");12pub const TAG = @import("dwarf/TAG.zig");
13pub const AT = @import("dwarf/AT.zig");
14pub const OP = @import("dwarf/OP.zig");
15
16pub const FORM = struct {
17 pub const addr = 0x01;
18 pub const block2 = 0x03;
19 pub const block4 = 0x04;
20 pub const data2 = 0x05;
21 pub const data4 = 0x06;
22 pub const data8 = 0x07;
23 pub const string = 0x08;
24 pub const block = 0x09;
25 pub const block1 = 0x0a;
26 pub const data1 = 0x0b;
27 pub const flag = 0x0c;
28 pub const sdata = 0x0d;
29 pub const strp = 0x0e;
30 pub const udata = 0x0f;
31 pub const ref_addr = 0x10;
32 pub const ref1 = 0x11;
33 pub const ref2 = 0x12;
34 pub const ref4 = 0x13;
35 pub const ref8 = 0x14;
36 pub const ref_udata = 0x15;
37 pub const indirect = 0x16;
38 pub const sec_offset = 0x17;
39 pub const exprloc = 0x18;
40 pub const flag_present = 0x19;
41 pub const ref_sig8 = 0x20;
42
43 // Extensions for Fission. See http://gcc.gnu.org/wiki/DebugFission.
44 pub const GNU_addr_index = 0x1f01;
45 pub const GNU_str_index = 0x1f02;
46
47 // Extensions for DWZ multifile.
48 // See http://www.dwarfstd.org/ShowIssue.php?issue=120604.1&type=open .
49 pub const GNU_ref_alt = 0x1f20;
50 pub const GNU_strp_alt = 0x1f21;
51};
52
53pub const ATE = struct {
54 pub const @"void" = 0x0;
55 pub const address = 0x1;
56 pub const boolean = 0x2;
57 pub const complex_float = 0x3;
58 pub const float = 0x4;
59 pub const signed = 0x5;
60 pub const signed_char = 0x6;
61 pub const unsigned = 0x7;
62 pub const unsigned_char = 0x8;
63
64 // DWARF 3.
65 pub const imaginary_float = 0x9;
66 pub const packed_decimal = 0xa;
67 pub const numeric_string = 0xb;
68 pub const edited = 0xc;
69 pub const signed_fixed = 0xd;
70 pub const unsigned_fixed = 0xe;
71 pub const decimal_float = 0xf;
72
73 // DWARF 4.
74 pub const UTF = 0x10;
75
76 pub const lo_user = 0x80;
77 pub const hi_user = 0xff;
78
79 // HP extensions.
80 pub const HP_float80 = 0x80; // Floating-point (80 bit).
81 pub const HP_complex_float80 = 0x81; // Complex floating-point (80 bit).
82 pub const HP_float128 = 0x82; // Floating-point (128 bit).
83 pub const HP_complex_float128 = 0x83; // Complex fp (128 bit).
84 pub const HP_floathpintel = 0x84; // Floating-point (82 bit IA64).
85 pub const HP_imaginary_float80 = 0x85;
86 pub const HP_imaginary_float128 = 0x86;
87 pub const HP_VAX_float = 0x88; // F or G floating.
88 pub const HP_VAX_float_d = 0x89; // D floating.
89 pub const HP_packed_decimal = 0x8a; // Cobol.
90 pub const HP_zoned_decimal = 0x8b; // Cobol.
91 pub const HP_edited = 0x8c; // Cobol.
92 pub const HP_signed_fixed = 0x8d; // Cobol.
93 pub const HP_unsigned_fixed = 0x8e; // Cobol.
94 pub const HP_VAX_complex_float = 0x8f; // F or G floating complex.
95 pub const HP_VAX_complex_float_d = 0x90; // D floating complex.
96};
97
98pub const CFA = struct {
99 pub const advance_loc = 0x40;
100 pub const offset = 0x80;
101 pub const restore = 0xc0;
102 pub const nop = 0x00;
103 pub const set_loc = 0x01;
104 pub const advance_loc1 = 0x02;
105 pub const advance_loc2 = 0x03;
106 pub const advance_loc4 = 0x04;
107 pub const offset_extended = 0x05;
108 pub const restore_extended = 0x06;
109 pub const @"undefined" = 0x07;
110 pub const same_value = 0x08;
111 pub const register = 0x09;
112 pub const remember_state = 0x0a;
113 pub const restore_state = 0x0b;
114 pub const def_cfa = 0x0c;
115 pub const def_cfa_register = 0x0d;
116 pub const def_cfa_offset = 0x0e;
117
118 // DWARF 3.
119 pub const def_cfa_expression = 0x0f;
120 pub const expression = 0x10;
121 pub const offset_extended_sf = 0x11;
122 pub const def_cfa_sf = 0x12;
123 pub const def_cfa_offset_sf = 0x13;
124 pub const val_offset = 0x14;
125 pub const val_offset_sf = 0x15;
126 pub const val_expression = 0x16;
127
128 pub const lo_user = 0x1c;
129 pub const hi_user = 0x3f;
130
131 // SGI/MIPS specific.
132 pub const MIPS_advance_loc8 = 0x1d;
133
134 // GNU extensions.
135 pub const GNU_window_save = 0x2d;
136 pub const GNU_args_size = 0x2e;
137 pub const GNU_negative_offset_extended = 0x2f;
138};
139
140pub const CHILDREN = struct {
141 pub const no = 0x00;
142 pub const yes = 0x01;
143};
144
145pub const LNS = struct {
146 pub const extended_op = 0x00;
147 pub const copy = 0x01;
148 pub const advance_pc = 0x02;
149 pub const advance_line = 0x03;
150 pub const set_file = 0x04;
151 pub const set_column = 0x05;
152 pub const negate_stmt = 0x06;
153 pub const set_basic_block = 0x07;
154 pub const const_add_pc = 0x08;
155 pub const fixed_advance_pc = 0x09;
156 pub const set_prologue_end = 0x0a;
157 pub const set_epilogue_begin = 0x0b;
158 pub const set_isa = 0x0c;
159};
160
161pub const LNE = struct {
162 pub const end_sequence = 0x01;
163 pub const set_address = 0x02;
164 pub const define_file = 0x03;
165 pub const set_discriminator = 0x04;
166 pub const lo_user = 0x80;
167 pub const hi_user = 0xff;
168};
169
170pub const LANG = struct {
171 pub const C89 = 0x0001;
172 pub const C = 0x0002;
173 pub const Ada83 = 0x0003;
174 pub const C_plus_plus = 0x0004;
175 pub const Cobol74 = 0x0005;
176 pub const Cobol85 = 0x0006;
177 pub const Fortran77 = 0x0007;
178 pub const Fortran90 = 0x0008;
179 pub const Pascal83 = 0x0009;
180 pub const Modula2 = 0x000a;
181 pub const Java = 0x000b;
182 pub const C99 = 0x000c;
183 pub const Ada95 = 0x000d;
184 pub const Fortran95 = 0x000e;
185 pub const PLI = 0x000f;
186 pub const ObjC = 0x0010;
187 pub const ObjC_plus_plus = 0x0011;
188 pub const UPC = 0x0012;
189 pub const D = 0x0013;
190 pub const Python = 0x0014;
191 pub const Go = 0x0016;
192 pub const C_plus_plus_11 = 0x001a;
193 pub const Rust = 0x001c;
194 pub const C11 = 0x001d;
195 pub const C_plus_plus_14 = 0x0021;
196 pub const Fortran03 = 0x0022;
197 pub const Fortran08 = 0x0023;
198 pub const lo_user = 0x8000;
199 pub const hi_user = 0xffff;
200 pub const Mips_Assembler = 0x8001;
201 pub const Upc = 0x8765;
202 pub const HP_Bliss = 0x8003;
203 pub const HP_Basic91 = 0x8004;
204 pub const HP_Pascal91 = 0x8005;
205 pub const HP_IMacro = 0x8006;
206 pub const HP_Assembler = 0x8007;
207};
208
209pub const UT = struct {
210 pub const compile = 0x01;
211 pub const @"type" = 0x02;
212 pub const partial = 0x03;
213 pub const skeleton = 0x04;
214 pub const split_compile = 0x05;
215 pub const split_type = 0x06;
216 pub const lo_user = 0x80;
217 pub const hi_user = 0xff;
218};
219
220pub const LNCT = struct {
221 pub const path = 0x1;
222 pub const directory_index = 0x2;
223 pub const timestamp = 0x3;
224 pub const size = 0x4;
225 pub const MD5 = 0x5;
226 pub const lo_user = 0x2000;
227 pub const hi_user = 0x3fff;
228};
13229
14const PcRange = struct {230const PcRange = struct {
15 start: u64,231 start: u64,
...@@ -322,43 +538,43 @@ fn parseFormValueRef(allocator: *mem.Allocator, in_stream: anytype, endian: buil...@@ -322,43 +538,43 @@ fn parseFormValueRef(allocator: *mem.Allocator, in_stream: anytype, endian: buil
322// TODO the nosuspends here are workarounds538// TODO the nosuspends here are workarounds
323fn parseFormValue(allocator: *mem.Allocator, in_stream: anytype, form_id: u64, endian: builtin.Endian, is_64: bool) anyerror!FormValue {539fn parseFormValue(allocator: *mem.Allocator, in_stream: anytype, form_id: u64, endian: builtin.Endian, is_64: bool) anyerror!FormValue {
324 return switch (form_id) {540 return switch (form_id) {
325 FORM_addr => FormValue{ .Address = try readAddress(in_stream, endian, @sizeOf(usize) == 8) },541 FORM.addr => FormValue{ .Address = try readAddress(in_stream, endian, @sizeOf(usize) == 8) },
326 FORM_block1 => parseFormValueBlock(allocator, in_stream, endian, 1),542 FORM.block1 => parseFormValueBlock(allocator, in_stream, endian, 1),
327 FORM_block2 => parseFormValueBlock(allocator, in_stream, endian, 2),543 FORM.block2 => parseFormValueBlock(allocator, in_stream, endian, 2),
328 FORM_block4 => parseFormValueBlock(allocator, in_stream, endian, 4),544 FORM.block4 => parseFormValueBlock(allocator, in_stream, endian, 4),
329 FORM_block => {545 FORM.block => {
330 const block_len = try nosuspend leb.readULEB128(usize, in_stream);546 const block_len = try nosuspend leb.readULEB128(usize, in_stream);
331 return parseFormValueBlockLen(allocator, in_stream, block_len);547 return parseFormValueBlockLen(allocator, in_stream, block_len);
332 },548 },
333 FORM_data1 => parseFormValueConstant(allocator, in_stream, false, endian, 1),549 FORM.data1 => parseFormValueConstant(allocator, in_stream, false, endian, 1),
334 FORM_data2 => parseFormValueConstant(allocator, in_stream, false, endian, 2),550 FORM.data2 => parseFormValueConstant(allocator, in_stream, false, endian, 2),
335 FORM_data4 => parseFormValueConstant(allocator, in_stream, false, endian, 4),551 FORM.data4 => parseFormValueConstant(allocator, in_stream, false, endian, 4),
336 FORM_data8 => parseFormValueConstant(allocator, in_stream, false, endian, 8),552 FORM.data8 => parseFormValueConstant(allocator, in_stream, false, endian, 8),
337 FORM_udata, FORM_sdata => {553 FORM.udata, FORM.sdata => {
338 const signed = form_id == FORM_sdata;554 const signed = form_id == FORM.sdata;
339 return parseFormValueConstant(allocator, in_stream, signed, endian, -1);555 return parseFormValueConstant(allocator, in_stream, signed, endian, -1);
340 },556 },
341 FORM_exprloc => {557 FORM.exprloc => {
342 const size = try nosuspend leb.readULEB128(usize, in_stream);558 const size = try nosuspend leb.readULEB128(usize, in_stream);
343 const buf = try readAllocBytes(allocator, in_stream, size);559 const buf = try readAllocBytes(allocator, in_stream, size);
344 return FormValue{ .ExprLoc = buf };560 return FormValue{ .ExprLoc = buf };
345 },561 },
346 FORM_flag => FormValue{ .Flag = (try nosuspend in_stream.readByte()) != 0 },562 FORM.flag => FormValue{ .Flag = (try nosuspend in_stream.readByte()) != 0 },
347 FORM_flag_present => FormValue{ .Flag = true },563 FORM.flag_present => FormValue{ .Flag = true },
348 FORM_sec_offset => FormValue{ .SecOffset = try readAddress(in_stream, endian, is_64) },564 FORM.sec_offset => FormValue{ .SecOffset = try readAddress(in_stream, endian, is_64) },
349565
350 FORM_ref1 => parseFormValueRef(allocator, in_stream, endian, 1),566 FORM.ref1 => parseFormValueRef(allocator, in_stream, endian, 1),
351 FORM_ref2 => parseFormValueRef(allocator, in_stream, endian, 2),567 FORM.ref2 => parseFormValueRef(allocator, in_stream, endian, 2),
352 FORM_ref4 => parseFormValueRef(allocator, in_stream, endian, 4),568 FORM.ref4 => parseFormValueRef(allocator, in_stream, endian, 4),
353 FORM_ref8 => parseFormValueRef(allocator, in_stream, endian, 8),569 FORM.ref8 => parseFormValueRef(allocator, in_stream, endian, 8),
354 FORM_ref_udata => parseFormValueRef(allocator, in_stream, endian, -1),570 FORM.ref_udata => parseFormValueRef(allocator, in_stream, endian, -1),
355571
356 FORM_ref_addr => FormValue{ .RefAddr = try readAddress(in_stream, endian, is_64) },572 FORM.ref_addr => FormValue{ .RefAddr = try readAddress(in_stream, endian, is_64) },
357 FORM_ref_sig8 => FormValue{ .Ref = try nosuspend in_stream.readInt(u64, endian) },573 FORM.ref_sig8 => FormValue{ .Ref = try nosuspend in_stream.readInt(u64, endian) },
358574
359 FORM_string => FormValue{ .String = try in_stream.readUntilDelimiterAlloc(allocator, 0, math.maxInt(usize)) },575 FORM.string => FormValue{ .String = try in_stream.readUntilDelimiterAlloc(allocator, 0, math.maxInt(usize)) },
360 FORM_strp => FormValue{ .StrPtr = try readAddress(in_stream, endian, is_64) },576 FORM.strp => FormValue{ .StrPtr = try readAddress(in_stream, endian, is_64) },
361 FORM_indirect => {577 FORM.indirect => {
362 const child_form_id = try nosuspend leb.readULEB128(u64, in_stream);578 const child_form_id = try nosuspend leb.readULEB128(u64, in_stream);
363 const F = @TypeOf(async parseFormValue(allocator, in_stream, child_form_id, endian, is_64));579 const F = @TypeOf(async parseFormValue(allocator, in_stream, child_form_id, endian, is_64));
364 var frame = try allocator.create(F);580 var frame = try allocator.create(F);
...@@ -441,24 +657,24 @@ pub const DwarfInfo = struct {...@@ -441,24 +657,24 @@ pub const DwarfInfo = struct {
441 const after_die_offset = try seekable.getPos();657 const after_die_offset = try seekable.getPos();
442658
443 switch (die_obj.tag_id) {659 switch (die_obj.tag_id) {
444 TAG_subprogram, TAG_inlined_subroutine, TAG_subroutine, TAG_entry_point => {660 TAG.subprogram, TAG.inlined_subroutine, TAG.subroutine, TAG.entry_point => {
445 const fn_name = x: {661 const fn_name = x: {
446 var depth: i32 = 3;662 var depth: i32 = 3;
447 var this_die_obj = die_obj;663 var this_die_obj = die_obj;
448 // Prenvent endless loops664 // Prenvent endless loops
449 while (depth > 0) : (depth -= 1) {665 while (depth > 0) : (depth -= 1) {
450 if (this_die_obj.getAttr(AT_name)) |_| {666 if (this_die_obj.getAttr(AT.name)) |_| {
451 const name = try this_die_obj.getAttrString(di, AT_name);667 const name = try this_die_obj.getAttrString(di, AT.name);
452 break :x name;668 break :x name;
453 } else if (this_die_obj.getAttr(AT_abstract_origin)) |_| {669 } else if (this_die_obj.getAttr(AT.abstract_origin)) |_| {
454 // Follow the DIE it points to and repeat670 // Follow the DIE it points to and repeat
455 const ref_offset = try this_die_obj.getAttrRef(AT_abstract_origin);671 const ref_offset = try this_die_obj.getAttrRef(AT.abstract_origin);
456 if (ref_offset > next_offset) return error.InvalidDebugInfo;672 if (ref_offset > next_offset) return error.InvalidDebugInfo;
457 try seekable.seekTo(this_unit_offset + ref_offset);673 try seekable.seekTo(this_unit_offset + ref_offset);
458 this_die_obj = (try di.parseDie(in, abbrev_table, is_64)) orelse return error.InvalidDebugInfo;674 this_die_obj = (try di.parseDie(in, abbrev_table, is_64)) orelse return error.InvalidDebugInfo;
459 } else if (this_die_obj.getAttr(AT_specification)) |_| {675 } else if (this_die_obj.getAttr(AT.specification)) |_| {
460 // Follow the DIE it points to and repeat676 // Follow the DIE it points to and repeat
461 const ref_offset = try this_die_obj.getAttrRef(AT_specification);677 const ref_offset = try this_die_obj.getAttrRef(AT.specification);
462 if (ref_offset > next_offset) return error.InvalidDebugInfo;678 if (ref_offset > next_offset) return error.InvalidDebugInfo;
463 try seekable.seekTo(this_unit_offset + ref_offset);679 try seekable.seekTo(this_unit_offset + ref_offset);
464 this_die_obj = (try di.parseDie(in, abbrev_table, is_64)) orelse return error.InvalidDebugInfo;680 this_die_obj = (try di.parseDie(in, abbrev_table, is_64)) orelse return error.InvalidDebugInfo;
...@@ -471,8 +687,8 @@ pub const DwarfInfo = struct {...@@ -471,8 +687,8 @@ pub const DwarfInfo = struct {
471 };687 };
472688
473 const pc_range = x: {689 const pc_range = x: {
474 if (die_obj.getAttrAddr(AT_low_pc)) |low_pc| {690 if (die_obj.getAttrAddr(AT.low_pc)) |low_pc| {
475 if (die_obj.getAttr(AT_high_pc)) |high_pc_value| {691 if (die_obj.getAttr(AT.high_pc)) |high_pc_value| {
476 const pc_end = switch (high_pc_value.*) {692 const pc_end = switch (high_pc_value.*) {
477 FormValue.Address => |value| value,693 FormValue.Address => |value| value,
478 FormValue.Const => |value| b: {694 FormValue.Const => |value| b: {
...@@ -539,11 +755,11 @@ pub const DwarfInfo = struct {...@@ -539,11 +755,11 @@ pub const DwarfInfo = struct {
539 const compile_unit_die = try di.allocator().create(Die);755 const compile_unit_die = try di.allocator().create(Die);
540 compile_unit_die.* = (try di.parseDie(in, abbrev_table, is_64)) orelse return error.InvalidDebugInfo;756 compile_unit_die.* = (try di.parseDie(in, abbrev_table, is_64)) orelse return error.InvalidDebugInfo;
541757
542 if (compile_unit_die.tag_id != TAG_compile_unit) return error.InvalidDebugInfo;758 if (compile_unit_die.tag_id != TAG.compile_unit) return error.InvalidDebugInfo;
543759
544 const pc_range = x: {760 const pc_range = x: {
545 if (compile_unit_die.getAttrAddr(AT_low_pc)) |low_pc| {761 if (compile_unit_die.getAttrAddr(AT.low_pc)) |low_pc| {
546 if (compile_unit_die.getAttr(AT_high_pc)) |high_pc_value| {762 if (compile_unit_die.getAttr(AT.high_pc)) |high_pc_value| {
547 const pc_end = switch (high_pc_value.*) {763 const pc_end = switch (high_pc_value.*) {
548 FormValue.Address => |value| value,764 FormValue.Address => |value| value,
549 FormValue.Const => |value| b: {765 FormValue.Const => |value| b: {
...@@ -582,16 +798,16 @@ pub const DwarfInfo = struct {...@@ -582,16 +798,16 @@ pub const DwarfInfo = struct {
582 if (target_address >= range.start and target_address < range.end) return compile_unit;798 if (target_address >= range.start and target_address < range.end) return compile_unit;
583 }799 }
584 if (di.debug_ranges) |debug_ranges| {800 if (di.debug_ranges) |debug_ranges| {
585 if (compile_unit.die.getAttrSecOffset(AT_ranges)) |ranges_offset| {801 if (compile_unit.die.getAttrSecOffset(AT.ranges)) |ranges_offset| {
586 var stream = io.fixedBufferStream(debug_ranges);802 var stream = io.fixedBufferStream(debug_ranges);
587 const in = &stream.reader();803 const in = &stream.reader();
588 const seekable = &stream.seekableStream();804 const seekable = &stream.seekableStream();
589805
590 // All the addresses in the list are relative to the value806 // All the addresses in the list are relative to the value
591 // specified by DW_AT_low_pc or to some other value encoded807 // specified by DW_AT.low_pc or to some other value encoded
592 // in the list itself.808 // in the list itself.
593 // If no starting value is specified use zero.809 // If no starting value is specified use zero.
594 var base_address = compile_unit.die.getAttrAddr(AT_low_pc) catch |err| switch (err) {810 var base_address = compile_unit.die.getAttrAddr(AT.low_pc) catch |err| switch (err) {
595 error.MissingDebugInfo => 0,811 error.MissingDebugInfo => 0,
596 else => return err,812 else => return err,
597 };813 };
...@@ -651,7 +867,7 @@ pub const DwarfInfo = struct {...@@ -651,7 +867,7 @@ pub const DwarfInfo = struct {
651 try result.append(AbbrevTableEntry{867 try result.append(AbbrevTableEntry{
652 .abbrev_code = abbrev_code,868 .abbrev_code = abbrev_code,
653 .tag_id = try leb.readULEB128(u64, in),869 .tag_id = try leb.readULEB128(u64, in),
654 .has_children = (try in.readByte()) == CHILDREN_yes,870 .has_children = (try in.readByte()) == CHILDREN.yes,
655 .attrs = ArrayList(AbbrevAttr).init(di.allocator()),871 .attrs = ArrayList(AbbrevAttr).init(di.allocator()),
656 });872 });
657 const attrs = &result.items[result.items.len - 1].attrs;873 const attrs = &result.items[result.items.len - 1].attrs;
...@@ -693,8 +909,8 @@ pub const DwarfInfo = struct {...@@ -693,8 +909,8 @@ pub const DwarfInfo = struct {
693 const in = &stream.reader();909 const in = &stream.reader();
694 const seekable = &stream.seekableStream();910 const seekable = &stream.seekableStream();
695911
696 const compile_unit_cwd = try compile_unit.die.getAttrString(di, AT_comp_dir);912 const compile_unit_cwd = try compile_unit.die.getAttrString(di, AT.comp_dir);
697 const line_info_offset = try compile_unit.die.getAttrSecOffset(AT_stmt_list);913 const line_info_offset = try compile_unit.die.getAttrSecOffset(AT.stmt_list);
698914
699 try seekable.seekTo(line_info_offset);915 try seekable.seekTo(line_info_offset);
700916
...@@ -769,21 +985,21 @@ pub const DwarfInfo = struct {...@@ -769,21 +985,21 @@ pub const DwarfInfo = struct {
769 while ((try seekable.getPos()) < next_unit_pos) {985 while ((try seekable.getPos()) < next_unit_pos) {
770 const opcode = try in.readByte();986 const opcode = try in.readByte();
771987
772 if (opcode == LNS_extended_op) {988 if (opcode == LNS.extended_op) {
773 const op_size = try leb.readULEB128(u64, in);989 const op_size = try leb.readULEB128(u64, in);
774 if (op_size < 1) return error.InvalidDebugInfo;990 if (op_size < 1) return error.InvalidDebugInfo;
775 var sub_op = try in.readByte();991 var sub_op = try in.readByte();
776 switch (sub_op) {992 switch (sub_op) {
777 LNE_end_sequence => {993 LNE.end_sequence => {
778 prog.end_sequence = true;994 prog.end_sequence = true;
779 if (try prog.checkLineMatch()) |info| return info;995 if (try prog.checkLineMatch()) |info| return info;
780 prog.reset();996 prog.reset();
781 },997 },
782 LNE_set_address => {998 LNE.set_address => {
783 const addr = try in.readInt(usize, di.endian);999 const addr = try in.readInt(usize, di.endian);
784 prog.address = addr;1000 prog.address = addr;
785 },1001 },
786 LNE_define_file => {1002 LNE.define_file => {
787 const file_name = try in.readUntilDelimiterAlloc(di.allocator(), 0, math.maxInt(usize));1003 const file_name = try in.readUntilDelimiterAlloc(di.allocator(), 0, math.maxInt(usize));
788 const dir_index = try leb.readULEB128(usize, in);1004 const dir_index = try leb.readULEB128(usize, in);
789 const mtime = try leb.readULEB128(usize, in);1005 const mtime = try leb.readULEB128(usize, in);
...@@ -811,41 +1027,41 @@ pub const DwarfInfo = struct {...@@ -811,41 +1027,41 @@ pub const DwarfInfo = struct {
811 prog.basic_block = false;1027 prog.basic_block = false;
812 } else {1028 } else {
813 switch (opcode) {1029 switch (opcode) {
814 LNS_copy => {1030 LNS.copy => {
815 if (try prog.checkLineMatch()) |info| return info;1031 if (try prog.checkLineMatch()) |info| return info;
816 prog.basic_block = false;1032 prog.basic_block = false;
817 },1033 },
818 LNS_advance_pc => {1034 LNS.advance_pc => {
819 const arg = try leb.readULEB128(usize, in);1035 const arg = try leb.readULEB128(usize, in);
820 prog.address += arg * minimum_instruction_length;1036 prog.address += arg * minimum_instruction_length;
821 },1037 },
822 LNS_advance_line => {1038 LNS.advance_line => {
823 const arg = try leb.readILEB128(i64, in);1039 const arg = try leb.readILEB128(i64, in);
824 prog.line += arg;1040 prog.line += arg;
825 },1041 },
826 LNS_set_file => {1042 LNS.set_file => {
827 const arg = try leb.readULEB128(usize, in);1043 const arg = try leb.readULEB128(usize, in);
828 prog.file = arg;1044 prog.file = arg;
829 },1045 },
830 LNS_set_column => {1046 LNS.set_column => {
831 const arg = try leb.readULEB128(u64, in);1047 const arg = try leb.readULEB128(u64, in);
832 prog.column = arg;1048 prog.column = arg;
833 },1049 },
834 LNS_negate_stmt => {1050 LNS.negate_stmt => {
835 prog.is_stmt = !prog.is_stmt;1051 prog.is_stmt = !prog.is_stmt;
836 },1052 },
837 LNS_set_basic_block => {1053 LNS.set_basic_block => {
838 prog.basic_block = true;1054 prog.basic_block = true;
839 },1055 },
840 LNS_const_add_pc => {1056 LNS.const_add_pc => {
841 const inc_addr = minimum_instruction_length * ((255 - opcode_base) / line_range);1057 const inc_addr = minimum_instruction_length * ((255 - opcode_base) / line_range);
842 prog.address += inc_addr;1058 prog.address += inc_addr;
843 },1059 },
844 LNS_fixed_advance_pc => {1060 LNS.fixed_advance_pc => {
845 const arg = try in.readInt(u16, di.endian);1061 const arg = try in.readInt(u16, di.endian);
846 prog.address += arg;1062 prog.address += arg;
847 },1063 },
848 LNS_set_prologue_end => {},1064 LNS.set_prologue_end => {},
849 else => {1065 else => {
850 if (opcode - 1 >= standard_opcode_lengths.len) return error.InvalidDebugInfo;1066 if (opcode - 1 >= standard_opcode_lengths.len) return error.InvalidDebugInfo;
851 const len_bytes = standard_opcode_lengths[opcode - 1];1067 const len_bytes = standard_opcode_lengths[opcode - 1];
lib/std/dwarf/AT.zig created+198
...@@ -0,0 +1,198 @@
1pub const sibling = 0x01;
2pub const location = 0x02;
3pub const name = 0x03;
4pub const ordering = 0x09;
5pub const subscr_data = 0x0a;
6pub const byte_size = 0x0b;
7pub const bit_offset = 0x0c;
8pub const bit_size = 0x0d;
9pub const element_list = 0x0f;
10pub const stmt_list = 0x10;
11pub const low_pc = 0x11;
12pub const high_pc = 0x12;
13pub const language = 0x13;
14pub const member = 0x14;
15pub const discr = 0x15;
16pub const discr_value = 0x16;
17pub const visibility = 0x17;
18pub const import = 0x18;
19pub const string_length = 0x19;
20pub const common_reference = 0x1a;
21pub const comp_dir = 0x1b;
22pub const const_value = 0x1c;
23pub const containing_type = 0x1d;
24pub const default_value = 0x1e;
25pub const @"inline" = 0x20;
26pub const is_optional = 0x21;
27pub const lower_bound = 0x22;
28pub const producer = 0x25;
29pub const prototyped = 0x27;
30pub const return_addr = 0x2a;
31pub const start_scope = 0x2c;
32pub const bit_stride = 0x2e;
33pub const upper_bound = 0x2f;
34pub const abstract_origin = 0x31;
35pub const accessibility = 0x32;
36pub const address_class = 0x33;
37pub const artificial = 0x34;
38pub const base_types = 0x35;
39pub const calling_convention = 0x36;
40pub const count = 0x37;
41pub const data_member_location = 0x38;
42pub const decl_column = 0x39;
43pub const decl_file = 0x3a;
44pub const decl_line = 0x3b;
45pub const declaration = 0x3c;
46pub const discr_list = 0x3d;
47pub const encoding = 0x3e;
48pub const external = 0x3f;
49pub const frame_base = 0x40;
50pub const friend = 0x41;
51pub const identifier_case = 0x42;
52pub const macro_info = 0x43;
53pub const namelist_items = 0x44;
54pub const priority = 0x45;
55pub const segment = 0x46;
56pub const specification = 0x47;
57pub const static_link = 0x48;
58pub const @"type" = 0x49;
59pub const use_location = 0x4a;
60pub const variable_parameter = 0x4b;
61pub const virtuality = 0x4c;
62pub const vtable_elem_location = 0x4d;
63
64// DWARF 3 values.
65pub const allocated = 0x4e;
66pub const associated = 0x4f;
67pub const data_location = 0x50;
68pub const byte_stride = 0x51;
69pub const entry_pc = 0x52;
70pub const use_UTF8 = 0x53;
71pub const extension = 0x54;
72pub const ranges = 0x55;
73pub const trampoline = 0x56;
74pub const call_column = 0x57;
75pub const call_file = 0x58;
76pub const call_line = 0x59;
77pub const description = 0x5a;
78pub const binary_scale = 0x5b;
79pub const decimal_scale = 0x5c;
80pub const small = 0x5d;
81pub const decimal_sign = 0x5e;
82pub const digit_count = 0x5f;
83pub const picture_string = 0x60;
84pub const mutable = 0x61;
85pub const threads_scaled = 0x62;
86pub const explicit = 0x63;
87pub const object_pointer = 0x64;
88pub const endianity = 0x65;
89pub const elemental = 0x66;
90pub const pure = 0x67;
91pub const recursive = 0x68;
92
93// DWARF 4.
94pub const signature = 0x69;
95pub const main_subprogram = 0x6a;
96pub const data_bit_offset = 0x6b;
97pub const const_expr = 0x6c;
98pub const enum_class = 0x6d;
99pub const linkage_name = 0x6e;
100
101// DWARF 5
102pub const alignment = 0x88;
103
104pub const lo_user = 0x2000; // Implementation-defined range start.
105pub const hi_user = 0x3fff; // Implementation-defined range end.
106
107// SGI/MIPS extensions.
108pub const MIPS_fde = 0x2001;
109pub const MIPS_loop_begin = 0x2002;
110pub const MIPS_tail_loop_begin = 0x2003;
111pub const MIPS_epilog_begin = 0x2004;
112pub const MIPS_loop_unroll_factor = 0x2005;
113pub const MIPS_software_pipeline_depth = 0x2006;
114pub const MIPS_linkage_name = 0x2007;
115pub const MIPS_stride = 0x2008;
116pub const MIPS_abstract_name = 0x2009;
117pub const MIPS_clone_origin = 0x200a;
118pub const MIPS_has_inlines = 0x200b;
119
120// HP extensions.
121pub const HP_block_index = 0x2000;
122pub const HP_unmodifiable = 0x2001; // Same as AT.MIPS_fde.
123pub const HP_prologue = 0x2005; // Same as AT.MIPS_loop_unroll.
124pub const HP_epilogue = 0x2008; // Same as AT.MIPS_stride.
125pub const HP_actuals_stmt_list = 0x2010;
126pub const HP_proc_per_section = 0x2011;
127pub const HP_raw_data_ptr = 0x2012;
128pub const HP_pass_by_reference = 0x2013;
129pub const HP_opt_level = 0x2014;
130pub const HP_prof_version_id = 0x2015;
131pub const HP_opt_flags = 0x2016;
132pub const HP_cold_region_low_pc = 0x2017;
133pub const HP_cold_region_high_pc = 0x2018;
134pub const HP_all_variables_modifiable = 0x2019;
135pub const HP_linkage_name = 0x201a;
136pub const HP_prof_flags = 0x201b; // In comp unit of procs_info for -g.
137pub const HP_unit_name = 0x201f;
138pub const HP_unit_size = 0x2020;
139pub const HP_widened_byte_size = 0x2021;
140pub const HP_definition_points = 0x2022;
141pub const HP_default_location = 0x2023;
142pub const HP_is_result_param = 0x2029;
143
144// GNU extensions.
145pub const sf_names = 0x2101;
146pub const src_info = 0x2102;
147pub const mac_info = 0x2103;
148pub const src_coords = 0x2104;
149pub const body_begin = 0x2105;
150pub const body_end = 0x2106;
151pub const GNU_vector = 0x2107;
152// Thread-safety annotations.
153// See http://gcc.gnu.org/wiki/ThreadSafetyAnnotation .
154pub const GNU_guarded_by = 0x2108;
155pub const GNU_pt_guarded_by = 0x2109;
156pub const GNU_guarded = 0x210a;
157pub const GNU_pt_guarded = 0x210b;
158pub const GNU_locks_excluded = 0x210c;
159pub const GNU_exclusive_locks_required = 0x210d;
160pub const GNU_shared_locks_required = 0x210e;
161// One-definition rule violation detection.
162// See http://gcc.gnu.org/wiki/DwarfSeparateTypeInfo .
163pub const GNU_odr_signature = 0x210f;
164// Template template argument name.
165// See http://gcc.gnu.org/wiki/TemplateParmsDwarf .
166pub const GNU_template_name = 0x2110;
167// The GNU call site extension.
168// See http://www.dwarfstd.org/ShowIssue.php?issue=100909.2&type=open .
169pub const GNU_call_site_value = 0x2111;
170pub const GNU_call_site_data_value = 0x2112;
171pub const GNU_call_site_target = 0x2113;
172pub const GNU_call_site_target_clobbered = 0x2114;
173pub const GNU_tail_call = 0x2115;
174pub const GNU_all_tail_call_sites = 0x2116;
175pub const GNU_all_call_sites = 0x2117;
176pub const GNU_all_source_call_sites = 0x2118;
177// Section offset into .debug_macro section.
178pub const GNU_macros = 0x2119;
179// Extensions for Fission. See http://gcc.gnu.org/wiki/DebugFission.
180pub const GNU_dwo_name = 0x2130;
181pub const GNU_dwo_id = 0x2131;
182pub const GNU_ranges_base = 0x2132;
183pub const GNU_addr_base = 0x2133;
184pub const GNU_pubnames = 0x2134;
185pub const GNU_pubtypes = 0x2135;
186// VMS extensions.
187pub const VMS_rtnbeg_pd_address = 0x2201;
188// GNAT extensions.
189// GNAT descriptive type.
190// See http://gcc.gnu.org/wiki/DW_AT_GNAT_descriptive_type .
191pub const use_GNAT_descriptive_type = 0x2301;
192pub const GNAT_descriptive_type = 0x2302;
193// UPC extension.
194pub const upc_threads_scaled = 0x3210;
195// PGI (STMicroelectronics) extensions.
196pub const PGI_lbase = 0x3a00;
197pub const PGI_soffset = 0x3a01;
198pub const PGI_lstride = 0x3a02;
lib/std/dwarf/OP.zig created+195
...@@ -0,0 +1,195 @@
1pub const addr = 0x03;
2pub const deref = 0x06;
3pub const const1u = 0x08;
4pub const const1s = 0x09;
5pub const const2u = 0x0a;
6pub const const2s = 0x0b;
7pub const const4u = 0x0c;
8pub const const4s = 0x0d;
9pub const const8u = 0x0e;
10pub const const8s = 0x0f;
11pub const constu = 0x10;
12pub const consts = 0x11;
13pub const dup = 0x12;
14pub const drop = 0x13;
15pub const over = 0x14;
16pub const pick = 0x15;
17pub const swap = 0x16;
18pub const rot = 0x17;
19pub const xderef = 0x18;
20pub const abs = 0x19;
21pub const @"and" = 0x1a;
22pub const div = 0x1b;
23pub const minus = 0x1c;
24pub const mod = 0x1d;
25pub const mul = 0x1e;
26pub const neg = 0x1f;
27pub const not = 0x20;
28pub const @"or" = 0x21;
29pub const plus = 0x22;
30pub const plus_uconst = 0x23;
31pub const shl = 0x24;
32pub const shr = 0x25;
33pub const shra = 0x26;
34pub const xor = 0x27;
35pub const bra = 0x28;
36pub const eq = 0x29;
37pub const ge = 0x2a;
38pub const gt = 0x2b;
39pub const le = 0x2c;
40pub const lt = 0x2d;
41pub const ne = 0x2e;
42pub const skip = 0x2f;
43pub const lit0 = 0x30;
44pub const lit1 = 0x31;
45pub const lit2 = 0x32;
46pub const lit3 = 0x33;
47pub const lit4 = 0x34;
48pub const lit5 = 0x35;
49pub const lit6 = 0x36;
50pub const lit7 = 0x37;
51pub const lit8 = 0x38;
52pub const lit9 = 0x39;
53pub const lit10 = 0x3a;
54pub const lit11 = 0x3b;
55pub const lit12 = 0x3c;
56pub const lit13 = 0x3d;
57pub const lit14 = 0x3e;
58pub const lit15 = 0x3f;
59pub const lit16 = 0x40;
60pub const lit17 = 0x41;
61pub const lit18 = 0x42;
62pub const lit19 = 0x43;
63pub const lit20 = 0x44;
64pub const lit21 = 0x45;
65pub const lit22 = 0x46;
66pub const lit23 = 0x47;
67pub const lit24 = 0x48;
68pub const lit25 = 0x49;
69pub const lit26 = 0x4a;
70pub const lit27 = 0x4b;
71pub const lit28 = 0x4c;
72pub const lit29 = 0x4d;
73pub const lit30 = 0x4e;
74pub const lit31 = 0x4f;
75pub const reg0 = 0x50;
76pub const reg1 = 0x51;
77pub const reg2 = 0x52;
78pub const reg3 = 0x53;
79pub const reg4 = 0x54;
80pub const reg5 = 0x55;
81pub const reg6 = 0x56;
82pub const reg7 = 0x57;
83pub const reg8 = 0x58;
84pub const reg9 = 0x59;
85pub const reg10 = 0x5a;
86pub const reg11 = 0x5b;
87pub const reg12 = 0x5c;
88pub const reg13 = 0x5d;
89pub const reg14 = 0x5e;
90pub const reg15 = 0x5f;
91pub const reg16 = 0x60;
92pub const reg17 = 0x61;
93pub const reg18 = 0x62;
94pub const reg19 = 0x63;
95pub const reg20 = 0x64;
96pub const reg21 = 0x65;
97pub const reg22 = 0x66;
98pub const reg23 = 0x67;
99pub const reg24 = 0x68;
100pub const reg25 = 0x69;
101pub const reg26 = 0x6a;
102pub const reg27 = 0x6b;
103pub const reg28 = 0x6c;
104pub const reg29 = 0x6d;
105pub const reg30 = 0x6e;
106pub const reg31 = 0x6f;
107pub const breg0 = 0x70;
108pub const breg1 = 0x71;
109pub const breg2 = 0x72;
110pub const breg3 = 0x73;
111pub const breg4 = 0x74;
112pub const breg5 = 0x75;
113pub const breg6 = 0x76;
114pub const breg7 = 0x77;
115pub const breg8 = 0x78;
116pub const breg9 = 0x79;
117pub const breg10 = 0x7a;
118pub const breg11 = 0x7b;
119pub const breg12 = 0x7c;
120pub const breg13 = 0x7d;
121pub const breg14 = 0x7e;
122pub const breg15 = 0x7f;
123pub const breg16 = 0x80;
124pub const breg17 = 0x81;
125pub const breg18 = 0x82;
126pub const breg19 = 0x83;
127pub const breg20 = 0x84;
128pub const breg21 = 0x85;
129pub const breg22 = 0x86;
130pub const breg23 = 0x87;
131pub const breg24 = 0x88;
132pub const breg25 = 0x89;
133pub const breg26 = 0x8a;
134pub const breg27 = 0x8b;
135pub const breg28 = 0x8c;
136pub const breg29 = 0x8d;
137pub const breg30 = 0x8e;
138pub const breg31 = 0x8f;
139pub const regx = 0x90;
140pub const fbreg = 0x91;
141pub const bregx = 0x92;
142pub const piece = 0x93;
143pub const deref_size = 0x94;
144pub const xderef_size = 0x95;
145pub const nop = 0x96;
146
147// DWARF 3 extensions.
148pub const push_object_address = 0x97;
149pub const call2 = 0x98;
150pub const call4 = 0x99;
151pub const call_ref = 0x9a;
152pub const form_tls_address = 0x9b;
153pub const call_frame_cfa = 0x9c;
154pub const bit_piece = 0x9d;
155
156// DWARF 4 extensions.
157pub const implicit_value = 0x9e;
158pub const stack_value = 0x9f;
159
160pub const lo_user = 0xe0; // Implementation-defined range start.
161pub const hi_user = 0xff; // Implementation-defined range end.
162
163// GNU extensions.
164pub const GNU_push_tls_address = 0xe0;
165// The following is for marking variables that are uninitialized.
166pub const GNU_uninit = 0xf0;
167pub const GNU_encoded_addr = 0xf1;
168// The GNU implicit pointer extension.
169// See http://www.dwarfstd.org/ShowIssue.php?issue=100831.1&type=open .
170pub const GNU_implicit_pointer = 0xf2;
171// The GNU entry value extension.
172// See http://www.dwarfstd.org/ShowIssue.php?issue=100909.1&type=open .
173pub const GNU_entry_value = 0xf3;
174// The GNU typed stack extension.
175// See http://www.dwarfstd.org/doc/040408.1.html .
176pub const GNU_const_type = 0xf4;
177pub const GNU_regval_type = 0xf5;
178pub const GNU_deref_type = 0xf6;
179pub const GNU_convert = 0xf7;
180pub const GNU_reinterpret = 0xf9;
181// The GNU parameter ref extension.
182pub const GNU_parameter_ref = 0xfa;
183// Extension for Fission. See http://gcc.gnu.org/wiki/DebugFission.
184pub const GNU_addr_index = 0xfb;
185pub const GNU_const_index = 0xfc;
186// HP extensions.
187pub const HP_unknown = 0xe0; // Ouch, the same as GNU_push_tls_address.
188pub const HP_is_value = 0xe1;
189pub const HP_fltconst4 = 0xe2;
190pub const HP_fltconst8 = 0xe3;
191pub const HP_mod_range = 0xe4;
192pub const HP_unmod_range = 0xe5;
193pub const HP_tls = 0xe6;
194// PGI (STMicroelectronics) extensions.
195pub const PGI_omp_thread_num = 0xf8;
lib/std/dwarf/TAG.zig created+108
...@@ -0,0 +1,108 @@
1pub const padding = 0x00;
2pub const array_type = 0x01;
3pub const class_type = 0x02;
4pub const entry_point = 0x03;
5pub const enumeration_type = 0x04;
6pub const formal_parameter = 0x05;
7pub const imported_declaration = 0x08;
8pub const label = 0x0a;
9pub const lexical_block = 0x0b;
10pub const member = 0x0d;
11pub const pointer_type = 0x0f;
12pub const reference_type = 0x10;
13pub const compile_unit = 0x11;
14pub const string_type = 0x12;
15pub const structure_type = 0x13;
16pub const subroutine = 0x14;
17pub const subroutine_type = 0x15;
18pub const typedef = 0x16;
19pub const union_type = 0x17;
20pub const unspecified_parameters = 0x18;
21pub const variant = 0x19;
22pub const common_block = 0x1a;
23pub const common_inclusion = 0x1b;
24pub const inheritance = 0x1c;
25pub const inlined_subroutine = 0x1d;
26pub const module = 0x1e;
27pub const ptr_to_member_type = 0x1f;
28pub const set_type = 0x20;
29pub const subrange_type = 0x21;
30pub const with_stmt = 0x22;
31pub const access_declaration = 0x23;
32pub const base_type = 0x24;
33pub const catch_block = 0x25;
34pub const const_type = 0x26;
35pub const constant = 0x27;
36pub const enumerator = 0x28;
37pub const file_type = 0x29;
38pub const friend = 0x2a;
39pub const namelist = 0x2b;
40pub const namelist_item = 0x2c;
41pub const packed_type = 0x2d;
42pub const subprogram = 0x2e;
43pub const template_type_param = 0x2f;
44pub const template_value_param = 0x30;
45pub const thrown_type = 0x31;
46pub const try_block = 0x32;
47pub const variant_part = 0x33;
48pub const variable = 0x34;
49pub const volatile_type = 0x35;
50
51// DWARF 3
52pub const dwarf_procedure = 0x36;
53pub const restrict_type = 0x37;
54pub const interface_type = 0x38;
55pub const namespace = 0x39;
56pub const imported_module = 0x3a;
57pub const unspecified_type = 0x3b;
58pub const partial_unit = 0x3c;
59pub const imported_unit = 0x3d;
60pub const condition = 0x3f;
61pub const shared_type = 0x40;
62
63// DWARF 4
64pub const type_unit = 0x41;
65pub const rvalue_reference_type = 0x42;
66pub const template_alias = 0x43;
67
68pub const lo_user = 0x4080;
69pub const hi_user = 0xffff;
70
71// SGI/MIPS Extensions.
72pub const MIPS_loop = 0x4081;
73
74// HP extensions. See: ftp://ftp.hp.com/pub/lang/tools/WDB/wdb-4.0.tar.gz .
75pub const HP_array_descriptor = 0x4090;
76pub const HP_Bliss_field = 0x4091;
77pub const HP_Bliss_field_set = 0x4092;
78
79// GNU extensions.
80pub const format_label = 0x4101; // For FORTRAN 77 and Fortran 90.
81pub const function_template = 0x4102; // For C++.
82pub const class_template = 0x4103; //For C++.
83pub const GNU_BINCL = 0x4104;
84pub const GNU_EINCL = 0x4105;
85
86// Template template parameter.
87// See http://gcc.gnu.org/wiki/TemplateParmsDwarf .
88pub const GNU_template_template_param = 0x4106;
89
90// Template parameter pack extension = specified at
91// http://wiki.dwarfstd.org/index.php?title=C%2B%2B0x:_Variadic_templates
92// The values of these two TAGS are in the DW_TAG_GNU_* space until the tags
93// are properly part of DWARF 5.
94pub const GNU_template_parameter_pack = 0x4107;
95pub const GNU_formal_parameter_pack = 0x4108;
96// The GNU call site extension = specified at
97// http://www.dwarfstd.org/ShowIssue.php?issue=100909.2&type=open .
98// The values of these two TAGS are in the DW_TAG_GNU_* space until the tags
99// are properly part of DWARF 5.
100pub const GNU_call_site = 0x4109;
101pub const GNU_call_site_parameter = 0x410a;
102// Extensions for UPC. See: http://dwarfstd.org/doc/DWARF4.pdf.
103pub const upc_shared_type = 0x8765;
104pub const upc_strict_type = 0x8766;
105pub const upc_relaxed_type = 0x8767;
106// PGI (STMicroelectronics; extensions. No documentation available.
107pub const PGI_kanji_type = 0xA000;
108pub const PGI_interface_block = 0xA020;
lib/std/dwarf_bits.zig deleted-699
...@@ -1,699 +0,0 @@
1pub const TAG_padding = 0x00;
2pub const TAG_array_type = 0x01;
3pub const TAG_class_type = 0x02;
4pub const TAG_entry_point = 0x03;
5pub const TAG_enumeration_type = 0x04;
6pub const TAG_formal_parameter = 0x05;
7pub const TAG_imported_declaration = 0x08;
8pub const TAG_label = 0x0a;
9pub const TAG_lexical_block = 0x0b;
10pub const TAG_member = 0x0d;
11pub const TAG_pointer_type = 0x0f;
12pub const TAG_reference_type = 0x10;
13pub const TAG_compile_unit = 0x11;
14pub const TAG_string_type = 0x12;
15pub const TAG_structure_type = 0x13;
16pub const TAG_subroutine = 0x14;
17pub const TAG_subroutine_type = 0x15;
18pub const TAG_typedef = 0x16;
19pub const TAG_union_type = 0x17;
20pub const TAG_unspecified_parameters = 0x18;
21pub const TAG_variant = 0x19;
22pub const TAG_common_block = 0x1a;
23pub const TAG_common_inclusion = 0x1b;
24pub const TAG_inheritance = 0x1c;
25pub const TAG_inlined_subroutine = 0x1d;
26pub const TAG_module = 0x1e;
27pub const TAG_ptr_to_member_type = 0x1f;
28pub const TAG_set_type = 0x20;
29pub const TAG_subrange_type = 0x21;
30pub const TAG_with_stmt = 0x22;
31pub const TAG_access_declaration = 0x23;
32pub const TAG_base_type = 0x24;
33pub const TAG_catch_block = 0x25;
34pub const TAG_const_type = 0x26;
35pub const TAG_constant = 0x27;
36pub const TAG_enumerator = 0x28;
37pub const TAG_file_type = 0x29;
38pub const TAG_friend = 0x2a;
39pub const TAG_namelist = 0x2b;
40pub const TAG_namelist_item = 0x2c;
41pub const TAG_packed_type = 0x2d;
42pub const TAG_subprogram = 0x2e;
43pub const TAG_template_type_param = 0x2f;
44pub const TAG_template_value_param = 0x30;
45pub const TAG_thrown_type = 0x31;
46pub const TAG_try_block = 0x32;
47pub const TAG_variant_part = 0x33;
48pub const TAG_variable = 0x34;
49pub const TAG_volatile_type = 0x35;
50
51// DWARF 3
52pub const TAG_dwarf_procedure = 0x36;
53pub const TAG_restrict_type = 0x37;
54pub const TAG_interface_type = 0x38;
55pub const TAG_namespace = 0x39;
56pub const TAG_imported_module = 0x3a;
57pub const TAG_unspecified_type = 0x3b;
58pub const TAG_partial_unit = 0x3c;
59pub const TAG_imported_unit = 0x3d;
60pub const TAG_condition = 0x3f;
61pub const TAG_shared_type = 0x40;
62
63// DWARF 4
64pub const TAG_type_unit = 0x41;
65pub const TAG_rvalue_reference_type = 0x42;
66pub const TAG_template_alias = 0x43;
67
68pub const TAG_lo_user = 0x4080;
69pub const TAG_hi_user = 0xffff;
70
71// SGI/MIPS Extensions.
72pub const TAG_MIPS_loop = 0x4081;
73
74// HP extensions. See: ftp://ftp.hp.com/pub/lang/tools/WDB/wdb-4.0.tar.gz .
75pub const TAG_HP_array_descriptor = 0x4090;
76pub const TAG_HP_Bliss_field = 0x4091;
77pub const TAG_HP_Bliss_field_set = 0x4092;
78
79// GNU extensions.
80pub const TAG_format_label = 0x4101; // For FORTRAN 77 and Fortran 90.
81pub const TAG_function_template = 0x4102; // For C++.
82pub const TAG_class_template = 0x4103; //For C++.
83pub const TAG_GNU_BINCL = 0x4104;
84pub const TAG_GNU_EINCL = 0x4105;
85
86// Template template parameter.
87// See http://gcc.gnu.org/wiki/TemplateParmsDwarf .
88pub const TAG_GNU_template_template_param = 0x4106;
89
90// Template parameter pack extension = specified at
91// http://wiki.dwarfstd.org/index.php?title=C%2B%2B0x:_Variadic_templates
92// The values of these two TAGS are in the DW_TAG_GNU_* space until the tags
93// are properly part of DWARF 5.
94pub const TAG_GNU_template_parameter_pack = 0x4107;
95pub const TAG_GNU_formal_parameter_pack = 0x4108;
96// The GNU call site extension = specified at
97// http://www.dwarfstd.org/ShowIssue.php?issue=100909.2&type=open .
98// The values of these two TAGS are in the DW_TAG_GNU_* space until the tags
99// are properly part of DWARF 5.
100pub const TAG_GNU_call_site = 0x4109;
101pub const TAG_GNU_call_site_parameter = 0x410a;
102// Extensions for UPC. See: http://dwarfstd.org/doc/DWARF4.pdf.
103pub const TAG_upc_shared_type = 0x8765;
104pub const TAG_upc_strict_type = 0x8766;
105pub const TAG_upc_relaxed_type = 0x8767;
106// PGI (STMicroelectronics; extensions. No documentation available.
107pub const TAG_PGI_kanji_type = 0xA000;
108pub const TAG_PGI_interface_block = 0xA020;
109
110pub const FORM_addr = 0x01;
111pub const FORM_block2 = 0x03;
112pub const FORM_block4 = 0x04;
113pub const FORM_data2 = 0x05;
114pub const FORM_data4 = 0x06;
115pub const FORM_data8 = 0x07;
116pub const FORM_string = 0x08;
117pub const FORM_block = 0x09;
118pub const FORM_block1 = 0x0a;
119pub const FORM_data1 = 0x0b;
120pub const FORM_flag = 0x0c;
121pub const FORM_sdata = 0x0d;
122pub const FORM_strp = 0x0e;
123pub const FORM_udata = 0x0f;
124pub const FORM_ref_addr = 0x10;
125pub const FORM_ref1 = 0x11;
126pub const FORM_ref2 = 0x12;
127pub const FORM_ref4 = 0x13;
128pub const FORM_ref8 = 0x14;
129pub const FORM_ref_udata = 0x15;
130pub const FORM_indirect = 0x16;
131pub const FORM_sec_offset = 0x17;
132pub const FORM_exprloc = 0x18;
133pub const FORM_flag_present = 0x19;
134pub const FORM_ref_sig8 = 0x20;
135
136// Extensions for Fission. See http://gcc.gnu.org/wiki/DebugFission.
137pub const FORM_GNU_addr_index = 0x1f01;
138pub const FORM_GNU_str_index = 0x1f02;
139
140// Extensions for DWZ multifile.
141// See http://www.dwarfstd.org/ShowIssue.php?issue=120604.1&type=open .
142pub const FORM_GNU_ref_alt = 0x1f20;
143pub const FORM_GNU_strp_alt = 0x1f21;
144
145pub const AT_sibling = 0x01;
146pub const AT_location = 0x02;
147pub const AT_name = 0x03;
148pub const AT_ordering = 0x09;
149pub const AT_subscr_data = 0x0a;
150pub const AT_byte_size = 0x0b;
151pub const AT_bit_offset = 0x0c;
152pub const AT_bit_size = 0x0d;
153pub const AT_element_list = 0x0f;
154pub const AT_stmt_list = 0x10;
155pub const AT_low_pc = 0x11;
156pub const AT_high_pc = 0x12;
157pub const AT_language = 0x13;
158pub const AT_member = 0x14;
159pub const AT_discr = 0x15;
160pub const AT_discr_value = 0x16;
161pub const AT_visibility = 0x17;
162pub const AT_import = 0x18;
163pub const AT_string_length = 0x19;
164pub const AT_common_reference = 0x1a;
165pub const AT_comp_dir = 0x1b;
166pub const AT_const_value = 0x1c;
167pub const AT_containing_type = 0x1d;
168pub const AT_default_value = 0x1e;
169pub const AT_inline = 0x20;
170pub const AT_is_optional = 0x21;
171pub const AT_lower_bound = 0x22;
172pub const AT_producer = 0x25;
173pub const AT_prototyped = 0x27;
174pub const AT_return_addr = 0x2a;
175pub const AT_start_scope = 0x2c;
176pub const AT_bit_stride = 0x2e;
177pub const AT_upper_bound = 0x2f;
178pub const AT_abstract_origin = 0x31;
179pub const AT_accessibility = 0x32;
180pub const AT_address_class = 0x33;
181pub const AT_artificial = 0x34;
182pub const AT_base_types = 0x35;
183pub const AT_calling_convention = 0x36;
184pub const AT_count = 0x37;
185pub const AT_data_member_location = 0x38;
186pub const AT_decl_column = 0x39;
187pub const AT_decl_file = 0x3a;
188pub const AT_decl_line = 0x3b;
189pub const AT_declaration = 0x3c;
190pub const AT_discr_list = 0x3d;
191pub const AT_encoding = 0x3e;
192pub const AT_external = 0x3f;
193pub const AT_frame_base = 0x40;
194pub const AT_friend = 0x41;
195pub const AT_identifier_case = 0x42;
196pub const AT_macro_info = 0x43;
197pub const AT_namelist_items = 0x44;
198pub const AT_priority = 0x45;
199pub const AT_segment = 0x46;
200pub const AT_specification = 0x47;
201pub const AT_static_link = 0x48;
202pub const AT_type = 0x49;
203pub const AT_use_location = 0x4a;
204pub const AT_variable_parameter = 0x4b;
205pub const AT_virtuality = 0x4c;
206pub const AT_vtable_elem_location = 0x4d;
207
208// DWARF 3 values.
209pub const AT_allocated = 0x4e;
210pub const AT_associated = 0x4f;
211pub const AT_data_location = 0x50;
212pub const AT_byte_stride = 0x51;
213pub const AT_entry_pc = 0x52;
214pub const AT_use_UTF8 = 0x53;
215pub const AT_extension = 0x54;
216pub const AT_ranges = 0x55;
217pub const AT_trampoline = 0x56;
218pub const AT_call_column = 0x57;
219pub const AT_call_file = 0x58;
220pub const AT_call_line = 0x59;
221pub const AT_description = 0x5a;
222pub const AT_binary_scale = 0x5b;
223pub const AT_decimal_scale = 0x5c;
224pub const AT_small = 0x5d;
225pub const AT_decimal_sign = 0x5e;
226pub const AT_digit_count = 0x5f;
227pub const AT_picture_string = 0x60;
228pub const AT_mutable = 0x61;
229pub const AT_threads_scaled = 0x62;
230pub const AT_explicit = 0x63;
231pub const AT_object_pointer = 0x64;
232pub const AT_endianity = 0x65;
233pub const AT_elemental = 0x66;
234pub const AT_pure = 0x67;
235pub const AT_recursive = 0x68;
236
237// DWARF 4.
238pub const AT_signature = 0x69;
239pub const AT_main_subprogram = 0x6a;
240pub const AT_data_bit_offset = 0x6b;
241pub const AT_const_expr = 0x6c;
242pub const AT_enum_class = 0x6d;
243pub const AT_linkage_name = 0x6e;
244
245// DWARF 5
246pub const AT_alignment = 0x88;
247
248pub const AT_lo_user = 0x2000; // Implementation-defined range start.
249pub const AT_hi_user = 0x3fff; // Implementation-defined range end.
250
251// SGI/MIPS extensions.
252pub const AT_MIPS_fde = 0x2001;
253pub const AT_MIPS_loop_begin = 0x2002;
254pub const AT_MIPS_tail_loop_begin = 0x2003;
255pub const AT_MIPS_epilog_begin = 0x2004;
256pub const AT_MIPS_loop_unroll_factor = 0x2005;
257pub const AT_MIPS_software_pipeline_depth = 0x2006;
258pub const AT_MIPS_linkage_name = 0x2007;
259pub const AT_MIPS_stride = 0x2008;
260pub const AT_MIPS_abstract_name = 0x2009;
261pub const AT_MIPS_clone_origin = 0x200a;
262pub const AT_MIPS_has_inlines = 0x200b;
263
264// HP extensions.
265pub const AT_HP_block_index = 0x2000;
266pub const AT_HP_unmodifiable = 0x2001; // Same as AT_MIPS_fde.
267pub const AT_HP_prologue = 0x2005; // Same as AT_MIPS_loop_unroll.
268pub const AT_HP_epilogue = 0x2008; // Same as AT_MIPS_stride.
269pub const AT_HP_actuals_stmt_list = 0x2010;
270pub const AT_HP_proc_per_section = 0x2011;
271pub const AT_HP_raw_data_ptr = 0x2012;
272pub const AT_HP_pass_by_reference = 0x2013;
273pub const AT_HP_opt_level = 0x2014;
274pub const AT_HP_prof_version_id = 0x2015;
275pub const AT_HP_opt_flags = 0x2016;
276pub const AT_HP_cold_region_low_pc = 0x2017;
277pub const AT_HP_cold_region_high_pc = 0x2018;
278pub const AT_HP_all_variables_modifiable = 0x2019;
279pub const AT_HP_linkage_name = 0x201a;
280pub const AT_HP_prof_flags = 0x201b; // In comp unit of procs_info for -g.
281pub const AT_HP_unit_name = 0x201f;
282pub const AT_HP_unit_size = 0x2020;
283pub const AT_HP_widened_byte_size = 0x2021;
284pub const AT_HP_definition_points = 0x2022;
285pub const AT_HP_default_location = 0x2023;
286pub const AT_HP_is_result_param = 0x2029;
287
288// GNU extensions.
289pub const AT_sf_names = 0x2101;
290pub const AT_src_info = 0x2102;
291pub const AT_mac_info = 0x2103;
292pub const AT_src_coords = 0x2104;
293pub const AT_body_begin = 0x2105;
294pub const AT_body_end = 0x2106;
295pub const AT_GNU_vector = 0x2107;
296// Thread-safety annotations.
297// See http://gcc.gnu.org/wiki/ThreadSafetyAnnotation .
298pub const AT_GNU_guarded_by = 0x2108;
299pub const AT_GNU_pt_guarded_by = 0x2109;
300pub const AT_GNU_guarded = 0x210a;
301pub const AT_GNU_pt_guarded = 0x210b;
302pub const AT_GNU_locks_excluded = 0x210c;
303pub const AT_GNU_exclusive_locks_required = 0x210d;
304pub const AT_GNU_shared_locks_required = 0x210e;
305// One-definition rule violation detection.
306// See http://gcc.gnu.org/wiki/DwarfSeparateTypeInfo .
307pub const AT_GNU_odr_signature = 0x210f;
308// Template template argument name.
309// See http://gcc.gnu.org/wiki/TemplateParmsDwarf .
310pub const AT_GNU_template_name = 0x2110;
311// The GNU call site extension.
312// See http://www.dwarfstd.org/ShowIssue.php?issue=100909.2&type=open .
313pub const AT_GNU_call_site_value = 0x2111;
314pub const AT_GNU_call_site_data_value = 0x2112;
315pub const AT_GNU_call_site_target = 0x2113;
316pub const AT_GNU_call_site_target_clobbered = 0x2114;
317pub const AT_GNU_tail_call = 0x2115;
318pub const AT_GNU_all_tail_call_sites = 0x2116;
319pub const AT_GNU_all_call_sites = 0x2117;
320pub const AT_GNU_all_source_call_sites = 0x2118;
321// Section offset into .debug_macro section.
322pub const AT_GNU_macros = 0x2119;
323// Extensions for Fission. See http://gcc.gnu.org/wiki/DebugFission.
324pub const AT_GNU_dwo_name = 0x2130;
325pub const AT_GNU_dwo_id = 0x2131;
326pub const AT_GNU_ranges_base = 0x2132;
327pub const AT_GNU_addr_base = 0x2133;
328pub const AT_GNU_pubnames = 0x2134;
329pub const AT_GNU_pubtypes = 0x2135;
330// VMS extensions.
331pub const AT_VMS_rtnbeg_pd_address = 0x2201;
332// GNAT extensions.
333// GNAT descriptive type.
334// See http://gcc.gnu.org/wiki/DW_AT_GNAT_descriptive_type .
335pub const AT_use_GNAT_descriptive_type = 0x2301;
336pub const AT_GNAT_descriptive_type = 0x2302;
337// UPC extension.
338pub const AT_upc_threads_scaled = 0x3210;
339// PGI (STMicroelectronics) extensions.
340pub const AT_PGI_lbase = 0x3a00;
341pub const AT_PGI_soffset = 0x3a01;
342pub const AT_PGI_lstride = 0x3a02;
343
344pub const OP_addr = 0x03;
345pub const OP_deref = 0x06;
346pub const OP_const1u = 0x08;
347pub const OP_const1s = 0x09;
348pub const OP_const2u = 0x0a;
349pub const OP_const2s = 0x0b;
350pub const OP_const4u = 0x0c;
351pub const OP_const4s = 0x0d;
352pub const OP_const8u = 0x0e;
353pub const OP_const8s = 0x0f;
354pub const OP_constu = 0x10;
355pub const OP_consts = 0x11;
356pub const OP_dup = 0x12;
357pub const OP_drop = 0x13;
358pub const OP_over = 0x14;
359pub const OP_pick = 0x15;
360pub const OP_swap = 0x16;
361pub const OP_rot = 0x17;
362pub const OP_xderef = 0x18;
363pub const OP_abs = 0x19;
364pub const OP_and = 0x1a;
365pub const OP_div = 0x1b;
366pub const OP_minus = 0x1c;
367pub const OP_mod = 0x1d;
368pub const OP_mul = 0x1e;
369pub const OP_neg = 0x1f;
370pub const OP_not = 0x20;
371pub const OP_or = 0x21;
372pub const OP_plus = 0x22;
373pub const OP_plus_uconst = 0x23;
374pub const OP_shl = 0x24;
375pub const OP_shr = 0x25;
376pub const OP_shra = 0x26;
377pub const OP_xor = 0x27;
378pub const OP_bra = 0x28;
379pub const OP_eq = 0x29;
380pub const OP_ge = 0x2a;
381pub const OP_gt = 0x2b;
382pub const OP_le = 0x2c;
383pub const OP_lt = 0x2d;
384pub const OP_ne = 0x2e;
385pub const OP_skip = 0x2f;
386pub const OP_lit0 = 0x30;
387pub const OP_lit1 = 0x31;
388pub const OP_lit2 = 0x32;
389pub const OP_lit3 = 0x33;
390pub const OP_lit4 = 0x34;
391pub const OP_lit5 = 0x35;
392pub const OP_lit6 = 0x36;
393pub const OP_lit7 = 0x37;
394pub const OP_lit8 = 0x38;
395pub const OP_lit9 = 0x39;
396pub const OP_lit10 = 0x3a;
397pub const OP_lit11 = 0x3b;
398pub const OP_lit12 = 0x3c;
399pub const OP_lit13 = 0x3d;
400pub const OP_lit14 = 0x3e;
401pub const OP_lit15 = 0x3f;
402pub const OP_lit16 = 0x40;
403pub const OP_lit17 = 0x41;
404pub const OP_lit18 = 0x42;
405pub const OP_lit19 = 0x43;
406pub const OP_lit20 = 0x44;
407pub const OP_lit21 = 0x45;
408pub const OP_lit22 = 0x46;
409pub const OP_lit23 = 0x47;
410pub const OP_lit24 = 0x48;
411pub const OP_lit25 = 0x49;
412pub const OP_lit26 = 0x4a;
413pub const OP_lit27 = 0x4b;
414pub const OP_lit28 = 0x4c;
415pub const OP_lit29 = 0x4d;
416pub const OP_lit30 = 0x4e;
417pub const OP_lit31 = 0x4f;
418pub const OP_reg0 = 0x50;
419pub const OP_reg1 = 0x51;
420pub const OP_reg2 = 0x52;
421pub const OP_reg3 = 0x53;
422pub const OP_reg4 = 0x54;
423pub const OP_reg5 = 0x55;
424pub const OP_reg6 = 0x56;
425pub const OP_reg7 = 0x57;
426pub const OP_reg8 = 0x58;
427pub const OP_reg9 = 0x59;
428pub const OP_reg10 = 0x5a;
429pub const OP_reg11 = 0x5b;
430pub const OP_reg12 = 0x5c;
431pub const OP_reg13 = 0x5d;
432pub const OP_reg14 = 0x5e;
433pub const OP_reg15 = 0x5f;
434pub const OP_reg16 = 0x60;
435pub const OP_reg17 = 0x61;
436pub const OP_reg18 = 0x62;
437pub const OP_reg19 = 0x63;
438pub const OP_reg20 = 0x64;
439pub const OP_reg21 = 0x65;
440pub const OP_reg22 = 0x66;
441pub const OP_reg23 = 0x67;
442pub const OP_reg24 = 0x68;
443pub const OP_reg25 = 0x69;
444pub const OP_reg26 = 0x6a;
445pub const OP_reg27 = 0x6b;
446pub const OP_reg28 = 0x6c;
447pub const OP_reg29 = 0x6d;
448pub const OP_reg30 = 0x6e;
449pub const OP_reg31 = 0x6f;
450pub const OP_breg0 = 0x70;
451pub const OP_breg1 = 0x71;
452pub const OP_breg2 = 0x72;
453pub const OP_breg3 = 0x73;
454pub const OP_breg4 = 0x74;
455pub const OP_breg5 = 0x75;
456pub const OP_breg6 = 0x76;
457pub const OP_breg7 = 0x77;
458pub const OP_breg8 = 0x78;
459pub const OP_breg9 = 0x79;
460pub const OP_breg10 = 0x7a;
461pub const OP_breg11 = 0x7b;
462pub const OP_breg12 = 0x7c;
463pub const OP_breg13 = 0x7d;
464pub const OP_breg14 = 0x7e;
465pub const OP_breg15 = 0x7f;
466pub const OP_breg16 = 0x80;
467pub const OP_breg17 = 0x81;
468pub const OP_breg18 = 0x82;
469pub const OP_breg19 = 0x83;
470pub const OP_breg20 = 0x84;
471pub const OP_breg21 = 0x85;
472pub const OP_breg22 = 0x86;
473pub const OP_breg23 = 0x87;
474pub const OP_breg24 = 0x88;
475pub const OP_breg25 = 0x89;
476pub const OP_breg26 = 0x8a;
477pub const OP_breg27 = 0x8b;
478pub const OP_breg28 = 0x8c;
479pub const OP_breg29 = 0x8d;
480pub const OP_breg30 = 0x8e;
481pub const OP_breg31 = 0x8f;
482pub const OP_regx = 0x90;
483pub const OP_fbreg = 0x91;
484pub const OP_bregx = 0x92;
485pub const OP_piece = 0x93;
486pub const OP_deref_size = 0x94;
487pub const OP_xderef_size = 0x95;
488pub const OP_nop = 0x96;
489
490// DWARF 3 extensions.
491pub const OP_push_object_address = 0x97;
492pub const OP_call2 = 0x98;
493pub const OP_call4 = 0x99;
494pub const OP_call_ref = 0x9a;
495pub const OP_form_tls_address = 0x9b;
496pub const OP_call_frame_cfa = 0x9c;
497pub const OP_bit_piece = 0x9d;
498
499// DWARF 4 extensions.
500pub const OP_implicit_value = 0x9e;
501pub const OP_stack_value = 0x9f;
502
503pub const OP_lo_user = 0xe0; // Implementation-defined range start.
504pub const OP_hi_user = 0xff; // Implementation-defined range end.
505
506// GNU extensions.
507pub const OP_GNU_push_tls_address = 0xe0;
508// The following is for marking variables that are uninitialized.
509pub const OP_GNU_uninit = 0xf0;
510pub const OP_GNU_encoded_addr = 0xf1;
511// The GNU implicit pointer extension.
512// See http://www.dwarfstd.org/ShowIssue.php?issue=100831.1&type=open .
513pub const OP_GNU_implicit_pointer = 0xf2;
514// The GNU entry value extension.
515// See http://www.dwarfstd.org/ShowIssue.php?issue=100909.1&type=open .
516pub const OP_GNU_entry_value = 0xf3;
517// The GNU typed stack extension.
518// See http://www.dwarfstd.org/doc/040408.1.html .
519pub const OP_GNU_const_type = 0xf4;
520pub const OP_GNU_regval_type = 0xf5;
521pub const OP_GNU_deref_type = 0xf6;
522pub const OP_GNU_convert = 0xf7;
523pub const OP_GNU_reinterpret = 0xf9;
524// The GNU parameter ref extension.
525pub const OP_GNU_parameter_ref = 0xfa;
526// Extension for Fission. See http://gcc.gnu.org/wiki/DebugFission.
527pub const OP_GNU_addr_index = 0xfb;
528pub const OP_GNU_const_index = 0xfc;
529// HP extensions.
530pub const OP_HP_unknown = 0xe0; // Ouch, the same as GNU_push_tls_address.
531pub const OP_HP_is_value = 0xe1;
532pub const OP_HP_fltconst4 = 0xe2;
533pub const OP_HP_fltconst8 = 0xe3;
534pub const OP_HP_mod_range = 0xe4;
535pub const OP_HP_unmod_range = 0xe5;
536pub const OP_HP_tls = 0xe6;
537// PGI (STMicroelectronics) extensions.
538pub const OP_PGI_omp_thread_num = 0xf8;
539
540pub const ATE_void = 0x0;
541pub const ATE_address = 0x1;
542pub const ATE_boolean = 0x2;
543pub const ATE_complex_float = 0x3;
544pub const ATE_float = 0x4;
545pub const ATE_signed = 0x5;
546pub const ATE_signed_char = 0x6;
547pub const ATE_unsigned = 0x7;
548pub const ATE_unsigned_char = 0x8;
549
550// DWARF 3.
551pub const ATE_imaginary_float = 0x9;
552pub const ATE_packed_decimal = 0xa;
553pub const ATE_numeric_string = 0xb;
554pub const ATE_edited = 0xc;
555pub const ATE_signed_fixed = 0xd;
556pub const ATE_unsigned_fixed = 0xe;
557pub const ATE_decimal_float = 0xf;
558
559// DWARF 4.
560pub const ATE_UTF = 0x10;
561
562pub const ATE_lo_user = 0x80;
563pub const ATE_hi_user = 0xff;
564
565// HP extensions.
566pub const ATE_HP_float80 = 0x80; // Floating-point (80 bit).
567pub const ATE_HP_complex_float80 = 0x81; // Complex floating-point (80 bit).
568pub const ATE_HP_float128 = 0x82; // Floating-point (128 bit).
569pub const ATE_HP_complex_float128 = 0x83; // Complex fp (128 bit).
570pub const ATE_HP_floathpintel = 0x84; // Floating-point (82 bit IA64).
571pub const ATE_HP_imaginary_float80 = 0x85;
572pub const ATE_HP_imaginary_float128 = 0x86;
573pub const ATE_HP_VAX_float = 0x88; // F or G floating.
574pub const ATE_HP_VAX_float_d = 0x89; // D floating.
575pub const ATE_HP_packed_decimal = 0x8a; // Cobol.
576pub const ATE_HP_zoned_decimal = 0x8b; // Cobol.
577pub const ATE_HP_edited = 0x8c; // Cobol.
578pub const ATE_HP_signed_fixed = 0x8d; // Cobol.
579pub const ATE_HP_unsigned_fixed = 0x8e; // Cobol.
580pub const ATE_HP_VAX_complex_float = 0x8f; // F or G floating complex.
581pub const ATE_HP_VAX_complex_float_d = 0x90; // D floating complex.
582
583pub const CFA_advance_loc = 0x40;
584pub const CFA_offset = 0x80;
585pub const CFA_restore = 0xc0;
586pub const CFA_nop = 0x00;
587pub const CFA_set_loc = 0x01;
588pub const CFA_advance_loc1 = 0x02;
589pub const CFA_advance_loc2 = 0x03;
590pub const CFA_advance_loc4 = 0x04;
591pub const CFA_offset_extended = 0x05;
592pub const CFA_restore_extended = 0x06;
593pub const CFA_undefined = 0x07;
594pub const CFA_same_value = 0x08;
595pub const CFA_register = 0x09;
596pub const CFA_remember_state = 0x0a;
597pub const CFA_restore_state = 0x0b;
598pub const CFA_def_cfa = 0x0c;
599pub const CFA_def_cfa_register = 0x0d;
600pub const CFA_def_cfa_offset = 0x0e;
601
602// DWARF 3.
603pub const CFA_def_cfa_expression = 0x0f;
604pub const CFA_expression = 0x10;
605pub const CFA_offset_extended_sf = 0x11;
606pub const CFA_def_cfa_sf = 0x12;
607pub const CFA_def_cfa_offset_sf = 0x13;
608pub const CFA_val_offset = 0x14;
609pub const CFA_val_offset_sf = 0x15;
610pub const CFA_val_expression = 0x16;
611
612pub const CFA_lo_user = 0x1c;
613pub const CFA_hi_user = 0x3f;
614
615// SGI/MIPS specific.
616pub const CFA_MIPS_advance_loc8 = 0x1d;
617
618// GNU extensions.
619pub const CFA_GNU_window_save = 0x2d;
620pub const CFA_GNU_args_size = 0x2e;
621pub const CFA_GNU_negative_offset_extended = 0x2f;
622
623pub const CHILDREN_no = 0x00;
624pub const CHILDREN_yes = 0x01;
625
626pub const LNS_extended_op = 0x00;
627pub const LNS_copy = 0x01;
628pub const LNS_advance_pc = 0x02;
629pub const LNS_advance_line = 0x03;
630pub const LNS_set_file = 0x04;
631pub const LNS_set_column = 0x05;
632pub const LNS_negate_stmt = 0x06;
633pub const LNS_set_basic_block = 0x07;
634pub const LNS_const_add_pc = 0x08;
635pub const LNS_fixed_advance_pc = 0x09;
636pub const LNS_set_prologue_end = 0x0a;
637pub const LNS_set_epilogue_begin = 0x0b;
638pub const LNS_set_isa = 0x0c;
639
640pub const LNE_end_sequence = 0x01;
641pub const LNE_set_address = 0x02;
642pub const LNE_define_file = 0x03;
643pub const LNE_set_discriminator = 0x04;
644pub const LNE_lo_user = 0x80;
645pub const LNE_hi_user = 0xff;
646
647pub const LANG_C89 = 0x0001;
648pub const LANG_C = 0x0002;
649pub const LANG_Ada83 = 0x0003;
650pub const LANG_C_plus_plus = 0x0004;
651pub const LANG_Cobol74 = 0x0005;
652pub const LANG_Cobol85 = 0x0006;
653pub const LANG_Fortran77 = 0x0007;
654pub const LANG_Fortran90 = 0x0008;
655pub const LANG_Pascal83 = 0x0009;
656pub const LANG_Modula2 = 0x000a;
657pub const LANG_Java = 0x000b;
658pub const LANG_C99 = 0x000c;
659pub const LANG_Ada95 = 0x000d;
660pub const LANG_Fortran95 = 0x000e;
661pub const LANG_PLI = 0x000f;
662pub const LANG_ObjC = 0x0010;
663pub const LANG_ObjC_plus_plus = 0x0011;
664pub const LANG_UPC = 0x0012;
665pub const LANG_D = 0x0013;
666pub const LANG_Python = 0x0014;
667pub const LANG_Go = 0x0016;
668pub const LANG_C_plus_plus_11 = 0x001a;
669pub const LANG_Rust = 0x001c;
670pub const LANG_C11 = 0x001d;
671pub const LANG_C_plus_plus_14 = 0x0021;
672pub const LANG_Fortran03 = 0x0022;
673pub const LANG_Fortran08 = 0x0023;
674pub const LANG_lo_user = 0x8000;
675pub const LANG_hi_user = 0xffff;
676pub const LANG_Mips_Assembler = 0x8001;
677pub const LANG_Upc = 0x8765;
678pub const LANG_HP_Bliss = 0x8003;
679pub const LANG_HP_Basic91 = 0x8004;
680pub const LANG_HP_Pascal91 = 0x8005;
681pub const LANG_HP_IMacro = 0x8006;
682pub const LANG_HP_Assembler = 0x8007;
683
684pub const UT_compile = 0x01;
685pub const UT_type = 0x02;
686pub const UT_partial = 0x03;
687pub const UT_skeleton = 0x04;
688pub const UT_split_compile = 0x05;
689pub const UT_split_type = 0x06;
690pub const UT_lo_user = 0x80;
691pub const UT_hi_user = 0xff;
692
693pub const LNCT_path = 0x1;
694pub const LNCT_directory_index = 0x2;
695pub const LNCT_timestamp = 0x3;
696pub const LNCT_size = 0x4;
697pub const LNCT_MD5 = 0x5;
698pub const LNCT_lo_user = 0x2000;
699pub const LNCT_hi_user = 0x3fff;
lib/std/event/rwlock.zig+1
...@@ -4,6 +4,7 @@ const assert = std.debug.assert;...@@ -4,6 +4,7 @@ const assert = std.debug.assert;
4const testing = std.testing;4const testing = std.testing;
5const mem = std.mem;5const mem = std.mem;
6const Loop = std.event.Loop;6const Loop = std.event.Loop;
7const Allocator = std.mem.Allocator;
78
8/// Thread-safe async/await lock.9/// Thread-safe async/await lock.
9/// Functions which are waiting for the lock are suspended, and10/// Functions which are waiting for the lock are suspended, and
lib/std/fmt.zig+1-1
...@@ -902,7 +902,7 @@ pub fn formatText(...@@ -902,7 +902,7 @@ pub fn formatText(
902 } else if (comptime std.mem.eql(u8, fmt, "Z")) {902 } else if (comptime std.mem.eql(u8, fmt, "Z")) {
903 @compileError("specifier 'Z' has been deprecated, wrap your argument in std.zig.fmtEscapes instead");903 @compileError("specifier 'Z' has been deprecated, wrap your argument in std.zig.fmtEscapes instead");
904 } else {904 } else {
905 @compileError("Unsupported format string '" ++ fmt ++ "' for type '" ++ @typeName(@TypeOf(value)) ++ "'");905 @compileError("Unsupported format string '" ++ fmt ++ "' when formatting text");
906 }906 }
907}907}
908908
lib/std/fs.zig+45-45
...@@ -880,20 +880,20 @@ pub const Dir = struct {...@@ -880,20 +880,20 @@ pub const Dir = struct {
880 var fdflags: w.fdflags_t = 0x0;880 var fdflags: w.fdflags_t = 0x0;
881 var base: w.rights_t = 0x0;881 var base: w.rights_t = 0x0;
882 if (flags.read) {882 if (flags.read) {
883 base |= w.RIGHT_FD_READ | w.RIGHT_FD_TELL | w.RIGHT_FD_SEEK | w.RIGHT_FD_FILESTAT_GET;883 base |= w.RIGHT.FD_READ | w.RIGHT.FD_TELL | w.RIGHT.FD_SEEK | w.RIGHT.FD_FILESTAT_GET;
884 }884 }
885 if (flags.write) {885 if (flags.write) {
886 fdflags |= w.FDFLAG_APPEND;886 fdflags |= w.FDFLAG.APPEND;
887 base |= w.RIGHT_FD_WRITE |887 base |= w.RIGHT.FD_WRITE |
888 w.RIGHT_FD_TELL |888 w.RIGHT.FD_TELL |
889 w.RIGHT_FD_SEEK |889 w.RIGHT.FD_SEEK |
890 w.RIGHT_FD_DATASYNC |890 w.RIGHT.FD_DATASYNC |
891 w.RIGHT_FD_FDSTAT_SET_FLAGS |891 w.RIGHT.FD_FDSTAT_SET_FLAGS |
892 w.RIGHT_FD_SYNC |892 w.RIGHT.FD_SYNC |
893 w.RIGHT_FD_ALLOCATE |893 w.RIGHT.FD_ALLOCATE |
894 w.RIGHT_FD_ADVISE |894 w.RIGHT.FD_ADVISE |
895 w.RIGHT_FD_FILESTAT_SET_TIMES |895 w.RIGHT.FD_FILESTAT_SET_TIMES |
896 w.RIGHT_FD_FILESTAT_SET_SIZE;896 w.RIGHT.FD_FILESTAT_SET_SIZE;
897 }897 }
898 const fd = try os.openatWasi(self.fd, sub_path, 0x0, 0x0, fdflags, base, 0x0);898 const fd = try os.openatWasi(self.fd, sub_path, 0x0, 0x0, fdflags, base, 0x0);
899 return File{ .handle = fd };899 return File{ .handle = fd };
...@@ -958,14 +958,14 @@ pub const Dir = struct {...@@ -958,14 +958,14 @@ pub const Dir = struct {
958 }958 }
959959
960 if (has_flock_open_flags and flags.lock_nonblocking) {960 if (has_flock_open_flags and flags.lock_nonblocking) {
961 var fl_flags = os.fcntl(fd, os.F_GETFL, 0) catch |err| switch (err) {961 var fl_flags = os.fcntl(fd, os.F.GETFL, 0) catch |err| switch (err) {
962 error.FileBusy => unreachable,962 error.FileBusy => unreachable,
963 error.Locked => unreachable,963 error.Locked => unreachable,
964 error.PermissionDenied => unreachable,964 error.PermissionDenied => unreachable,
965 else => |e| return e,965 else => |e| return e,
966 };966 };
967 fl_flags &= ~@as(usize, os.O.NONBLOCK);967 fl_flags &= ~@as(usize, os.O.NONBLOCK);
968 _ = os.fcntl(fd, os.F_SETFL, fl_flags) catch |err| switch (err) {968 _ = os.fcntl(fd, os.F.SETFL, fl_flags) catch |err| switch (err) {
969 error.FileBusy => unreachable,969 error.FileBusy => unreachable,
970 error.Locked => unreachable,970 error.Locked => unreachable,
971 error.PermissionDenied => unreachable,971 error.PermissionDenied => unreachable,
...@@ -1040,19 +1040,19 @@ pub const Dir = struct {...@@ -1040,19 +1040,19 @@ pub const Dir = struct {
1040 pub fn createFileWasi(self: Dir, sub_path: []const u8, flags: File.CreateFlags) File.OpenError!File {1040 pub fn createFileWasi(self: Dir, sub_path: []const u8, flags: File.CreateFlags) File.OpenError!File {
1041 const w = os.wasi;1041 const w = os.wasi;
1042 var oflags = w.O.CREAT;1042 var oflags = w.O.CREAT;
1043 var base: w.rights_t = w.RIGHT_FD_WRITE |1043 var base: w.rights_t = w.RIGHT.FD_WRITE |
1044 w.RIGHT_FD_DATASYNC |1044 w.RIGHT.FD_DATASYNC |
1045 w.RIGHT_FD_SEEK |1045 w.RIGHT.FD_SEEK |
1046 w.RIGHT_FD_TELL |1046 w.RIGHT.FD_TELL |
1047 w.RIGHT_FD_FDSTAT_SET_FLAGS |1047 w.RIGHT.FD_FDSTAT_SET_FLAGS |
1048 w.RIGHT_FD_SYNC |1048 w.RIGHT.FD_SYNC |
1049 w.RIGHT_FD_ALLOCATE |1049 w.RIGHT.FD_ALLOCATE |
1050 w.RIGHT_FD_ADVISE |1050 w.RIGHT.FD_ADVISE |
1051 w.RIGHT_FD_FILESTAT_SET_TIMES |1051 w.RIGHT.FD_FILESTAT_SET_TIMES |
1052 w.RIGHT_FD_FILESTAT_SET_SIZE |1052 w.RIGHT.FD_FILESTAT_SET_SIZE |
1053 w.RIGHT_FD_FILESTAT_GET;1053 w.RIGHT.FD_FILESTAT_GET;
1054 if (flags.read) {1054 if (flags.read) {
1055 base |= w.RIGHT_FD_READ;1055 base |= w.RIGHT.FD_READ;
1056 }1056 }
1057 if (flags.truncate) {1057 if (flags.truncate) {
1058 oflags |= w.O.TRUNC;1058 oflags |= w.O.TRUNC;
...@@ -1112,14 +1112,14 @@ pub const Dir = struct {...@@ -1112,14 +1112,14 @@ pub const Dir = struct {
1112 }1112 }
11131113
1114 if (has_flock_open_flags and flags.lock_nonblocking) {1114 if (has_flock_open_flags and flags.lock_nonblocking) {
1115 var fl_flags = os.fcntl(fd, os.F_GETFL, 0) catch |err| switch (err) {1115 var fl_flags = os.fcntl(fd, os.F.GETFL, 0) catch |err| switch (err) {
1116 error.FileBusy => unreachable,1116 error.FileBusy => unreachable,
1117 error.Locked => unreachable,1117 error.Locked => unreachable,
1118 error.PermissionDenied => unreachable,1118 error.PermissionDenied => unreachable,
1119 else => |e| return e,1119 else => |e| return e,
1120 };1120 };
1121 fl_flags &= ~@as(usize, os.O.NONBLOCK);1121 fl_flags &= ~@as(usize, os.O.NONBLOCK);
1122 _ = os.fcntl(fd, os.F_SETFL, fl_flags) catch |err| switch (err) {1122 _ = os.fcntl(fd, os.F.SETFL, fl_flags) catch |err| switch (err) {
1123 error.FileBusy => unreachable,1123 error.FileBusy => unreachable,
1124 error.Locked => unreachable,1124 error.Locked => unreachable,
1125 error.PermissionDenied => unreachable,1125 error.PermissionDenied => unreachable,
...@@ -1402,27 +1402,27 @@ pub const Dir = struct {...@@ -1402,27 +1402,27 @@ pub const Dir = struct {
1402 /// Same as `openDir` except only WASI.1402 /// Same as `openDir` except only WASI.
1403 pub fn openDirWasi(self: Dir, sub_path: []const u8, args: OpenDirOptions) OpenError!Dir {1403 pub fn openDirWasi(self: Dir, sub_path: []const u8, args: OpenDirOptions) OpenError!Dir {
1404 const w = os.wasi;1404 const w = os.wasi;
1405 var base: w.rights_t = w.RIGHT_FD_FILESTAT_GET | w.RIGHT_FD_FDSTAT_SET_FLAGS | w.RIGHT_FD_FILESTAT_SET_TIMES;1405 var base: w.rights_t = w.RIGHT.FD_FILESTAT_GET | w.RIGHT.FD_FDSTAT_SET_FLAGS | w.RIGHT.FD_FILESTAT_SET_TIMES;
1406 if (args.access_sub_paths) {1406 if (args.access_sub_paths) {
1407 base |= w.RIGHT_FD_READDIR |1407 base |= w.RIGHT.FD_READDIR |
1408 w.RIGHT_PATH_CREATE_DIRECTORY |1408 w.RIGHT.PATH_CREATE_DIRECTORY |
1409 w.RIGHT_PATH_CREATE_FILE |1409 w.RIGHT.PATH_CREATE_FILE |
1410 w.RIGHT_PATH_LINK_SOURCE |1410 w.RIGHT.PATH_LINK_SOURCE |
1411 w.RIGHT_PATH_LINK_TARGET |1411 w.RIGHT.PATH_LINK_TARGET |
1412 w.RIGHT_PATH_OPEN |1412 w.RIGHT.PATH_OPEN |
1413 w.RIGHT_PATH_READLINK |1413 w.RIGHT.PATH_READLINK |
1414 w.RIGHT_PATH_RENAME_SOURCE |1414 w.RIGHT.PATH_RENAME_SOURCE |
1415 w.RIGHT_PATH_RENAME_TARGET |1415 w.RIGHT.PATH_RENAME_TARGET |
1416 w.RIGHT_PATH_FILESTAT_GET |1416 w.RIGHT.PATH_FILESTAT_GET |
1417 w.RIGHT_PATH_FILESTAT_SET_SIZE |1417 w.RIGHT.PATH_FILESTAT_SET_SIZE |
1418 w.RIGHT_PATH_FILESTAT_SET_TIMES |1418 w.RIGHT.PATH_FILESTAT_SET_TIMES |
1419 w.RIGHT_PATH_SYMLINK |1419 w.RIGHT.PATH_SYMLINK |
1420 w.RIGHT_PATH_REMOVE_DIRECTORY |1420 w.RIGHT.PATH_REMOVE_DIRECTORY |
1421 w.RIGHT_PATH_UNLINK_FILE;1421 w.RIGHT.PATH_UNLINK_FILE;
1422 }1422 }
1423 const symlink_flags: w.lookupflags_t = if (args.no_follow) 0x0 else w.LOOKUP_SYMLINK_FOLLOW;1423 const symlink_flags: w.lookupflags_t = if (args.no_follow) 0x0 else w.LOOKUP_SYMLINK_FOLLOW;
1424 // TODO do we really need all the rights here?1424 // TODO do we really need all the rights here?
1425 const inheriting: w.rights_t = w.RIGHT_ALL ^ w.RIGHT_SOCK_SHUTDOWN;1425 const inheriting: w.rights_t = w.RIGHT.ALL ^ w.RIGHT.SOCK_SHUTDOWN;
14261426
1427 const result = os.openatWasi(self.fd, sub_path, symlink_flags, w.O.DIRECTORY, 0x0, base, inheriting);1427 const result = os.openatWasi(self.fd, sub_path, symlink_flags, w.O.DIRECTORY, 0x0, base, inheriting);
1428 const fd = result catch |err| switch (err) {1428 const fd = result catch |err| switch (err) {
lib/std/fs/wasi.zig+4-2
...@@ -4,6 +4,8 @@ const mem = std.mem;...@@ -4,6 +4,8 @@ const mem = std.mem;
4const math = std.math;4const math = std.math;
5const Allocator = mem.Allocator;5const Allocator = mem.Allocator;
6const wasi = std.os.wasi;6const wasi = std.os.wasi;
7const fd_t = wasi.fd_t;
8const prestat_t = wasi.prestat_t;
79
8/// Type-tag of WASI preopen.10/// Type-tag of WASI preopen.
9///11///
...@@ -114,7 +116,7 @@ pub const PreopenList = struct {...@@ -114,7 +116,7 @@ pub const PreopenList = struct {
114116
115 while (true) {117 while (true) {
116 var buf: prestat_t = undefined;118 var buf: prestat_t = undefined;
117 switch (fd_prestat_get(fd, &buf)) {119 switch (wasi.fd_prestat_get(fd, &buf)) {
118 .SUCCESS => {},120 .SUCCESS => {},
119 .OPNOTSUPP => {121 .OPNOTSUPP => {
120 // not a preopen, so keep going122 // not a preopen, so keep going
...@@ -130,7 +132,7 @@ pub const PreopenList = struct {...@@ -130,7 +132,7 @@ pub const PreopenList = struct {
130 const preopen_len = buf.u.dir.pr_name_len;132 const preopen_len = buf.u.dir.pr_name_len;
131 const path_buf = try self.buffer.allocator.alloc(u8, preopen_len);133 const path_buf = try self.buffer.allocator.alloc(u8, preopen_len);
132 mem.set(u8, path_buf, 0);134 mem.set(u8, path_buf, 0);
133 switch (fd_prestat_dir_name(fd, path_buf.ptr, preopen_len)) {135 switch (wasi.fd_prestat_dir_name(fd, path_buf.ptr, preopen_len)) {
134 .SUCCESS => {},136 .SUCCESS => {},
135 else => |err| return os.unexpectedErrno(err),137 else => |err| return os.unexpectedErrno(err),
136 }138 }
lib/std/hash_map.zig+6-2
...@@ -622,8 +622,12 @@ pub fn HashMap(...@@ -622,8 +622,12 @@ pub fn HashMap(
622 return other.promoteContext(self.allocator, new_ctx);622 return other.promoteContext(self.allocator, new_ctx);
623 }623 }
624624
625 /// Creates a copy of this map, using a specified allocator and context625 /// Creates a copy of this map, using a specified allocator and context.
626 pub fn cloneWithAllocatorAndContext(new_allocator: *Allocator, new_ctx: anytype) !HashMap(K, V, @TypeOf(new_ctx), max_load_percentage) {626 pub fn cloneWithAllocatorAndContext(
627 self: Self,
628 new_allocator: *Allocator,
629 new_ctx: anytype,
630 ) !HashMap(K, V, @TypeOf(new_ctx), max_load_percentage) {
627 var other = try self.unmanaged.cloneContext(new_allocator, new_ctx);631 var other = try self.unmanaged.cloneContext(new_allocator, new_ctx);
628 return other.promoteContext(new_allocator, new_ctx);632 return other.promoteContext(new_allocator, new_ctx);
629 }633 }
lib/std/heap.zig+4-4
...@@ -88,12 +88,12 @@ const CAllocator = struct {...@@ -88,12 +88,12 @@ const CAllocator = struct {
8888
89 fn alignedAllocSize(ptr: [*]u8) usize {89 fn alignedAllocSize(ptr: [*]u8) usize {
90 if (supports_posix_memalign) {90 if (supports_posix_memalign) {
91 return malloc_size(ptr);91 return CAllocator.malloc_size(ptr);
92 }92 }
9393
94 const unaligned_ptr = getHeader(ptr).*;94 const unaligned_ptr = getHeader(ptr).*;
95 const delta = @ptrToInt(ptr) - @ptrToInt(unaligned_ptr);95 const delta = @ptrToInt(ptr) - @ptrToInt(unaligned_ptr);
96 return malloc_size(unaligned_ptr) - delta;96 return CAllocator.malloc_size(unaligned_ptr) - delta;
97 }97 }
9898
99 fn alloc(99 fn alloc(
...@@ -113,7 +113,7 @@ const CAllocator = struct {...@@ -113,7 +113,7 @@ const CAllocator = struct {
113 return ptr[0..len];113 return ptr[0..len];
114 }114 }
115 const full_len = init: {115 const full_len = init: {
116 if (supports_malloc_size) {116 if (CAllocator.supports_malloc_size) {
117 const s = alignedAllocSize(ptr);117 const s = alignedAllocSize(ptr);
118 assert(s >= len);118 assert(s >= len);
119 break :init s;119 break :init s;
...@@ -141,7 +141,7 @@ const CAllocator = struct {...@@ -141,7 +141,7 @@ const CAllocator = struct {
141 if (new_len <= buf.len) {141 if (new_len <= buf.len) {
142 return mem.alignAllocLen(buf.len, new_len, len_align);142 return mem.alignAllocLen(buf.len, new_len, len_align);
143 }143 }
144 if (supports_malloc_size) {144 if (CAllocator.supports_malloc_size) {
145 const full_len = alignedAllocSize(buf.ptr);145 const full_len = alignedAllocSize(buf.ptr);
146 if (new_len <= full_len) {146 if (new_len <= full_len) {
147 return mem.alignAllocLen(full_len, new_len, len_align);147 return mem.alignAllocLen(full_len, new_len, len_align);
lib/std/io/c_writer.zig+1
...@@ -2,6 +2,7 @@ const std = @import("../std.zig");...@@ -2,6 +2,7 @@ const std = @import("../std.zig");
2const builtin = std.builtin;2const builtin = std.builtin;
3const io = std.io;3const io = std.io;
4const testing = std.testing;4const testing = std.testing;
5const os = std.os;
56
6pub const CWriter = io.Writer(*std.c.FILE, std.fs.File.WriteError, cWriterWrite);7pub const CWriter = io.Writer(*std.c.FILE, std.fs.File.WriteError, cWriterWrite);
78
lib/std/json.zig+1-1
...@@ -1405,7 +1405,7 @@ fn parsedEqual(a: anytype, b: @TypeOf(a)) bool {...@@ -1405,7 +1405,7 @@ fn parsedEqual(a: anytype, b: @TypeOf(a)) bool {
1405 if (a == null or b == null) return false;1405 if (a == null or b == null) return false;
1406 return parsedEqual(a.?, b.?);1406 return parsedEqual(a.?, b.?);
1407 },1407 },
1408 .Union => {1408 .Union => |info| {
1409 if (info.tag_type) |UnionTag| {1409 if (info.tag_type) |UnionTag| {
1410 const tag_a = std.meta.activeTag(a);1410 const tag_a = std.meta.activeTag(a);
1411 const tag_b = std.meta.activeTag(b);1411 const tag_b = std.meta.activeTag(b);
lib/std/math/big/int.zig+1-2
...@@ -672,10 +672,9 @@ pub const Mutable = struct {...@@ -672,10 +672,9 @@ pub const Mutable = struct {
672 ///672 ///
673 /// `limbs_buffer` is used for temporary storage during the operation.673 /// `limbs_buffer` is used for temporary storage during the operation.
674 pub fn gcdNoAlias(rma: *Mutable, x: Const, y: Const, limbs_buffer: *std.ArrayList(Limb)) !void {674 pub fn gcdNoAlias(rma: *Mutable, x: Const, y: Const, limbs_buffer: *std.ArrayList(Limb)) !void {
675 _ = limbs_buffer;
676 assert(rma.limbs.ptr != x.limbs.ptr); // illegal aliasing675 assert(rma.limbs.ptr != x.limbs.ptr); // illegal aliasing
677 assert(rma.limbs.ptr != y.limbs.ptr); // illegal aliasing676 assert(rma.limbs.ptr != y.limbs.ptr); // illegal aliasing
678 return gcdLehmer(rma, x, y, allocator);677 return gcdLehmer(rma, x, y, limbs_buffer);
679 }678 }
680679
681 fn gcdLehmer(result: *Mutable, xa: Const, ya: Const, limbs_buffer: *std.ArrayList(Limb)) !void {680 fn gcdLehmer(result: *Mutable, xa: Const, ya: Const, limbs_buffer: *std.ArrayList(Limb)) !void {
lib/std/os.zig+26-14
...@@ -78,6 +78,7 @@ pub const HOST_NAME_MAX = system.HOST_NAME_MAX;...@@ -78,6 +78,7 @@ pub const HOST_NAME_MAX = system.HOST_NAME_MAX;
78pub const IFNAMESIZE = system.IFNAMESIZE;78pub const IFNAMESIZE = system.IFNAMESIZE;
79pub const IOV_MAX = system.IOV_MAX;79pub const IOV_MAX = system.IOV_MAX;
80pub const IPPROTO = system.IPPROTO;80pub const IPPROTO = system.IPPROTO;
81pub const Kevent = system.Kevent;
81pub const LOCK = system.LOCK;82pub const LOCK = system.LOCK;
82pub const MADV = system.MADV;83pub const MADV = system.MADV;
83pub const MAP = system.MAP;84pub const MAP = system.MAP;
...@@ -89,8 +90,10 @@ pub const O = system.O;...@@ -89,8 +90,10 @@ pub const O = system.O;
89pub const PATH_MAX = system.PATH_MAX;90pub const PATH_MAX = system.PATH_MAX;
90pub const POLL = system.POLL;91pub const POLL = system.POLL;
91pub const POSIX_FADV = system.POSIX_FADV;92pub const POSIX_FADV = system.POSIX_FADV;
93pub const PR = system.PR;
92pub const PROT = system.PROT;94pub const PROT = system.PROT;
93pub const REG = system.REG;95pub const REG = system.REG;
96pub const RIGHT = system.RIGHT;
94pub const RLIM = system.RLIM;97pub const RLIM = system.RLIM;
95pub const RR = system.RR;98pub const RR = system.RR;
96pub const R_OK = system.R_OK;99pub const R_OK = system.R_OK;
...@@ -110,6 +113,7 @@ pub const STDOUT_FILENO = system.STDOUT_FILENO;...@@ -110,6 +113,7 @@ pub const STDOUT_FILENO = system.STDOUT_FILENO;
110pub const SYS = system.SYS;113pub const SYS = system.SYS;
111pub const Sigaction = system.Sigaction;114pub const Sigaction = system.Sigaction;
112pub const Stat = system.Stat;115pub const Stat = system.Stat;
116pub const TCSA = system.TCSA;
113pub const VDSO = system.VDSO;117pub const VDSO = system.VDSO;
114pub const W = system.W;118pub const W = system.W;
115pub const W_OK = system.W_OK;119pub const W_OK = system.W_OK;
...@@ -123,9 +127,12 @@ pub const dev_t = system.dev_t;...@@ -123,9 +127,12 @@ pub const dev_t = system.dev_t;
123pub const dl_phdr_info = system.dl_phdr_info;127pub const dl_phdr_info = system.dl_phdr_info;
124pub const empty_sigset = system.empty_sigset;128pub const empty_sigset = system.empty_sigset;
125pub const fd_t = system.fd_t;129pub const fd_t = system.fd_t;
130pub const fdflags_t = system.fdflags_t;
131pub const fdstat_t = system.fdstat_t;
126pub const gid_t = system.gid_t;132pub const gid_t = system.gid_t;
127pub const ifreq = system.ifreq;133pub const ifreq = system.ifreq;
128pub const ino_t = system.ino_t;134pub const ino_t = system.ino_t;
135pub const lookupflags_t = system.lookupflags_t;
129pub const mcontext_t = system.mcontext_t;136pub const mcontext_t = system.mcontext_t;
130pub const mode_t = system.mode_t;137pub const mode_t = system.mode_t;
131pub const msghdr = system.msghdr;138pub const msghdr = system.msghdr;
...@@ -133,19 +140,24 @@ pub const msghdr_const = system.msghdr_const;...@@ -133,19 +140,24 @@ pub const msghdr_const = system.msghdr_const;
133pub const nfds_t = system.nfds_t;140pub const nfds_t = system.nfds_t;
134pub const nlink_t = system.nlink_t;141pub const nlink_t = system.nlink_t;
135pub const off_t = system.off_t;142pub const off_t = system.off_t;
143pub const oflags_t = system.oflags_t;
136pub const pid_t = system.pid_t;144pub const pid_t = system.pid_t;
137pub const pollfd = system.pollfd;145pub const pollfd = system.pollfd;
146pub const rights_t = system.rights_t;
138pub const rlim_t = system.rlim_t;147pub const rlim_t = system.rlim_t;
139pub const rlimit = system.rlimit;148pub const rlimit = system.rlimit;
140pub const rlimit_resource = system.rlimit_resource;149pub const rlimit_resource = system.rlimit_resource;
150pub const rusage = system.rusage;
141pub const sa_family_t = system.sa_family_t;151pub const sa_family_t = system.sa_family_t;
142pub const siginfo_t = system.siginfo_t;152pub const siginfo_t = system.siginfo_t;
143pub const sigset_t = system.sigset_t;153pub const sigset_t = system.sigset_t;
144pub const sockaddr = system.sockaddr;154pub const sockaddr = system.sockaddr;
145pub const socklen_t = system.socklen_t;155pub const socklen_t = system.socklen_t;
146pub const stack_t = system.stack_t;156pub const stack_t = system.stack_t;
157pub const termios = system.termios;
147pub const time_t = system.time_t;158pub const time_t = system.time_t;
148pub const timespec = system.timespec;159pub const timespec = system.timespec;
160pub const timestamp_t = system.timestamp_t;
149pub const timeval = system.timeval;161pub const timeval = system.timeval;
150pub const timezone = system.timezone;162pub const timezone = system.timezone;
151pub const ucontext_t = system.ucontext_t;163pub const ucontext_t = system.ucontext_t;
...@@ -2770,8 +2782,8 @@ pub fn isatty(handle: fd_t) bool {...@@ -2770,8 +2782,8 @@ pub fn isatty(handle: fd_t) bool {
2770 }2782 }
27712783
2772 // A tty is a character device that we can't seek or tell on.2784 // A tty is a character device that we can't seek or tell on.
2773 if (statbuf.fs_filetype != FILETYPE_CHARACTER_DEVICE or2785 if (statbuf.fs_filetype != .CHARACTER_DEVICE or
2774 (statbuf.fs_rights_base & (RIGHT_FD_SEEK | RIGHT_FD_TELL)) != 0)2786 (statbuf.fs_rights_base & (RIGHT.FD_SEEK | RIGHT.FD_TELL)) != 0)
2775 {2787 {
2776 // errno = ENOTTY;2788 // errno = ENOTTY;
2777 return false;2789 return false;
...@@ -3933,7 +3945,7 @@ pub const AccessError = error{...@@ -3933,7 +3945,7 @@ pub const AccessError = error{
3933} || UnexpectedError;3945} || UnexpectedError;
39343946
3935/// check user's permissions for a file3947/// check user's permissions for a file
3936/// TODO currently this assumes `mode` is `F_OK` on Windows.3948/// TODO currently this assumes `mode` is `F.OK` on Windows.
3937pub fn access(path: []const u8, mode: u32) AccessError!void {3949pub fn access(path: []const u8, mode: u32) AccessError!void {
3938 if (builtin.os.tag == .windows) {3950 if (builtin.os.tag == .windows) {
3939 const path_w = try windows.sliceToPrefixedFileW(path);3951 const path_w = try windows.sliceToPrefixedFileW(path);
...@@ -4104,10 +4116,10 @@ pub fn pipe2(flags: u32) PipeError![2]fd_t {...@@ -4104,10 +4116,10 @@ pub fn pipe2(flags: u32) PipeError![2]fd_t {
4104 return fds;4116 return fds;
41054117
4106 // O.CLOEXEC is special, it's a file descriptor flag and must be set using4118 // O.CLOEXEC is special, it's a file descriptor flag and must be set using
4107 // F_SETFD.4119 // F.SETFD.
4108 if (flags & O.CLOEXEC != 0) {4120 if (flags & O.CLOEXEC != 0) {
4109 for (fds) |fd| {4121 for (fds) |fd| {
4110 switch (errno(system.fcntl(fd, F_SETFD, @as(u32, FD_CLOEXEC)))) {4122 switch (errno(system.fcntl(fd, F.SETFD, @as(u32, FD_CLOEXEC)))) {
4111 .SUCCESS => {},4123 .SUCCESS => {},
4112 .INVAL => unreachable, // Invalid flags4124 .INVAL => unreachable, // Invalid flags
4113 .BADF => unreachable, // Always a race condition4125 .BADF => unreachable, // Always a race condition
...@@ -4117,10 +4129,10 @@ pub fn pipe2(flags: u32) PipeError![2]fd_t {...@@ -4117,10 +4129,10 @@ pub fn pipe2(flags: u32) PipeError![2]fd_t {
4117 }4129 }
41184130
4119 const new_flags = flags & ~@as(u32, O.CLOEXEC);4131 const new_flags = flags & ~@as(u32, O.CLOEXEC);
4120 // Set every other flag affecting the file status using F_SETFL.4132 // Set every other flag affecting the file status using F.SETFL.
4121 if (new_flags != 0) {4133 if (new_flags != 0) {
4122 for (fds) |fd| {4134 for (fds) |fd| {
4123 switch (errno(system.fcntl(fd, F_SETFL, new_flags))) {4135 switch (errno(system.fcntl(fd, F.SETFL, new_flags))) {
4124 .SUCCESS => {},4136 .SUCCESS => {},
4125 .INVAL => unreachable, // Invalid flags4137 .INVAL => unreachable, // Invalid flags
4126 .BADF => unreachable, // Always a race condition4138 .BADF => unreachable, // Always a race condition
...@@ -4425,14 +4437,14 @@ fn setSockFlags(sock: socket_t, flags: u32) !void {...@@ -4425,14 +4437,14 @@ fn setSockFlags(sock: socket_t, flags: u32) !void {
4425 if (builtin.os.tag == .windows) {4437 if (builtin.os.tag == .windows) {
4426 // TODO: Find out if this is supported for sockets4438 // TODO: Find out if this is supported for sockets
4427 } else {4439 } else {
4428 var fd_flags = fcntl(sock, F_GETFD, 0) catch |err| switch (err) {4440 var fd_flags = fcntl(sock, F.GETFD, 0) catch |err| switch (err) {
4429 error.FileBusy => unreachable,4441 error.FileBusy => unreachable,
4430 error.Locked => unreachable,4442 error.Locked => unreachable,
4431 error.PermissionDenied => unreachable,4443 error.PermissionDenied => unreachable,
4432 else => |e| return e,4444 else => |e| return e,
4433 };4445 };
4434 fd_flags |= FD_CLOEXEC;4446 fd_flags |= FD_CLOEXEC;
4435 _ = fcntl(sock, F_SETFD, fd_flags) catch |err| switch (err) {4447 _ = fcntl(sock, F.SETFD, fd_flags) catch |err| switch (err) {
4436 error.FileBusy => unreachable,4448 error.FileBusy => unreachable,
4437 error.Locked => unreachable,4449 error.Locked => unreachable,
4438 error.PermissionDenied => unreachable,4450 error.PermissionDenied => unreachable,
...@@ -4453,14 +4465,14 @@ fn setSockFlags(sock: socket_t, flags: u32) !void {...@@ -4453,14 +4465,14 @@ fn setSockFlags(sock: socket_t, flags: u32) !void {
4453 }4465 }
4454 }4466 }
4455 } else {4467 } else {
4456 var fl_flags = fcntl(sock, F_GETFL, 0) catch |err| switch (err) {4468 var fl_flags = fcntl(sock, F.GETFL, 0) catch |err| switch (err) {
4457 error.FileBusy => unreachable,4469 error.FileBusy => unreachable,
4458 error.Locked => unreachable,4470 error.Locked => unreachable,
4459 error.PermissionDenied => unreachable,4471 error.PermissionDenied => unreachable,
4460 else => |e| return e,4472 else => |e| return e,
4461 };4473 };
4462 fl_flags |= O.NONBLOCK;4474 fl_flags |= O.NONBLOCK;
4463 _ = fcntl(sock, F_SETFL, fl_flags) catch |err| switch (err) {4475 _ = fcntl(sock, F.SETFL, fl_flags) catch |err| switch (err) {
4464 error.FileBusy => unreachable,4476 error.FileBusy => unreachable,
4465 error.Locked => unreachable,4477 error.Locked => unreachable,
4466 error.PermissionDenied => unreachable,4478 error.PermissionDenied => unreachable,
...@@ -4625,14 +4637,14 @@ pub fn getFdPath(fd: fd_t, out_buffer: *[MAX_PATH_BYTES]u8) RealPathError![]u8 {...@@ -4625,14 +4637,14 @@ pub fn getFdPath(fd: fd_t, out_buffer: *[MAX_PATH_BYTES]u8) RealPathError![]u8 {
4625 return out_buffer[0..end_index];4637 return out_buffer[0..end_index];
4626 },4638 },
4627 .macos, .ios, .watchos, .tvos => {4639 .macos, .ios, .watchos, .tvos => {
4628 // On macOS, we can use F_GETPATH fcntl command to query the OS for4640 // On macOS, we can use F.GETPATH fcntl command to query the OS for
4629 // the path to the file descriptor.4641 // the path to the file descriptor.
4630 @memset(out_buffer, 0, MAX_PATH_BYTES);4642 @memset(out_buffer, 0, MAX_PATH_BYTES);
4631 switch (errno(system.fcntl(fd, F_GETPATH, out_buffer))) {4643 switch (errno(system.fcntl(fd, F.GETPATH, out_buffer))) {
4632 .SUCCESS => {},4644 .SUCCESS => {},
4633 .BADF => return error.FileNotFound,4645 .BADF => return error.FileNotFound,
4634 // TODO man pages for fcntl on macOS don't really tell you what4646 // TODO man pages for fcntl on macOS don't really tell you what
4635 // errno values to expect when command is F_GETPATH...4647 // errno values to expect when command is F.GETPATH...
4636 else => |err| return unexpectedErrno(err),4648 else => |err| return unexpectedErrno(err),
4637 }4649 }
4638 const len = mem.indexOfScalar(u8, out_buffer[0..], @as(u8, 0)) orelse MAX_PATH_BYTES;4650 const len = mem.indexOfScalar(u8, out_buffer[0..], @as(u8, 0)) orelse MAX_PATH_BYTES;
lib/std/os/linux.zig+36-32
...@@ -50,8 +50,12 @@ pub const syscall3 = syscall_bits.syscall3;...@@ -50,8 +50,12 @@ pub const syscall3 = syscall_bits.syscall3;
50pub const syscall4 = syscall_bits.syscall4;50pub const syscall4 = syscall_bits.syscall4;
51pub const syscall5 = syscall_bits.syscall5;51pub const syscall5 = syscall_bits.syscall5;
52pub const syscall6 = syscall_bits.syscall6;52pub const syscall6 = syscall_bits.syscall6;
53pub const syscall7 = syscall_bits.syscall7;
53pub const restore = syscall_bits.restore;54pub const restore = syscall_bits.restore;
54pub const restore_rt = syscall_bits.restore_rt;55pub const restore_rt = syscall_bits.restore_rt;
56pub const socketcall = syscall_bits.socketcall;
57pub const syscall_pipe = syscall_bits.syscall_pipe;
58pub const syscall_fork = syscall_bits.syscall_fork;
5559
56pub const clone = arch_bits.clone;60pub const clone = arch_bits.clone;
57pub const ARCH = arch_bits.ARCH;61pub const ARCH = arch_bits.ARCH;
...@@ -181,7 +185,7 @@ pub fn dup2(old: i32, new: i32) usize {...@@ -181,7 +185,7 @@ pub fn dup2(old: i32, new: i32) usize {
181 } else {185 } else {
182 if (old == new) {186 if (old == new) {
183 if (std.debug.runtime_safety) {187 if (std.debug.runtime_safety) {
184 const rc = syscall2(.fcntl, @bitCast(usize, @as(isize, old)), F_GETFD);188 const rc = syscall2(.fcntl, @bitCast(usize, @as(isize, old)), F.GETFD);
185 if (@bitCast(isize, rc) < 0) return rc;189 if (@bitCast(isize, rc) < 0) return rc;
186 }190 }
187 return @intCast(usize, old);191 return @intCast(usize, old);
...@@ -217,7 +221,7 @@ pub fn fork() usize {...@@ -217,7 +221,7 @@ pub fn fork() usize {
217 } else if (@hasField(SYS, "fork")) {221 } else if (@hasField(SYS, "fork")) {
218 return syscall0(.fork);222 return syscall0(.fork);
219 } else {223 } else {
220 return syscall2(.clone, SIGCHLD, 0);224 return syscall2(.clone, SIG.CHLD, 0);
221 }225 }
222}226}
223227
...@@ -821,7 +825,7 @@ var vdso_clock_gettime = @ptrCast(?*const c_void, init_vdso_clock_gettime);...@@ -821,7 +825,7 @@ var vdso_clock_gettime = @ptrCast(?*const c_void, init_vdso_clock_gettime);
821const vdso_clock_gettime_ty = fn (i32, *timespec) callconv(.C) usize;825const vdso_clock_gettime_ty = fn (i32, *timespec) callconv(.C) usize;
822826
823pub fn clock_gettime(clk_id: i32, tp: *timespec) usize {827pub fn clock_gettime(clk_id: i32, tp: *timespec) usize {
824 if (@hasDecl(@This(), "VDSO_CGT_SYM")) {828 if (@hasDecl(VDSO, "CGT_SYM")) {
825 const ptr = @atomicLoad(?*const c_void, &vdso_clock_gettime, .Unordered);829 const ptr = @atomicLoad(?*const c_void, &vdso_clock_gettime, .Unordered);
826 if (ptr) |fn_ptr| {830 if (ptr) |fn_ptr| {
827 const f = @ptrCast(vdso_clock_gettime_ty, fn_ptr);831 const f = @ptrCast(vdso_clock_gettime_ty, fn_ptr);
...@@ -836,7 +840,7 @@ pub fn clock_gettime(clk_id: i32, tp: *timespec) usize {...@@ -836,7 +840,7 @@ pub fn clock_gettime(clk_id: i32, tp: *timespec) usize {
836}840}
837841
838fn init_vdso_clock_gettime(clk: i32, ts: *timespec) callconv(.C) usize {842fn init_vdso_clock_gettime(clk: i32, ts: *timespec) callconv(.C) usize {
839 const ptr = @intToPtr(?*const c_void, vdso.lookup(VDSO_CGT_VER, VDSO_CGT_SYM));843 const ptr = @intToPtr(?*const c_void, vdso.lookup(VDSO.CGT_VER, VDSO.CGT_SYM));
840 // Note that we may not have a VDSO at all, update the stub address anyway844 // Note that we may not have a VDSO at all, update the stub address anyway
841 // so that clock_gettime will fall back on the good old (and slow) syscall845 // so that clock_gettime will fall back on the good old (and slow) syscall
842 @atomicStore(?*const c_void, &vdso_clock_gettime, ptr, .Monotonic);846 @atomicStore(?*const c_void, &vdso_clock_gettime, ptr, .Monotonic);
...@@ -1070,42 +1074,42 @@ pub fn sigismember(set: *const sigset_t, sig: u6) bool {...@@ -1070,42 +1074,42 @@ pub fn sigismember(set: *const sigset_t, sig: u6) bool {
10701074
1071pub fn getsockname(fd: i32, noalias addr: *sockaddr, noalias len: *socklen_t) usize {1075pub fn getsockname(fd: i32, noalias addr: *sockaddr, noalias len: *socklen_t) usize {
1072 if (native_arch == .i386) {1076 if (native_arch == .i386) {
1073 return socketcall(SC_getsockname, &[3]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len) });1077 return socketcall(SC.getsockname, &[3]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len) });
1074 }1078 }
1075 return syscall3(.getsockname, @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len));1079 return syscall3(.getsockname, @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len));
1076}1080}
10771081
1078pub fn getpeername(fd: i32, noalias addr: *sockaddr, noalias len: *socklen_t) usize {1082pub fn getpeername(fd: i32, noalias addr: *sockaddr, noalias len: *socklen_t) usize {
1079 if (native_arch == .i386) {1083 if (native_arch == .i386) {
1080 return socketcall(SC_getpeername, &[3]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len) });1084 return socketcall(SC.getpeername, &[3]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len) });
1081 }1085 }
1082 return syscall3(.getpeername, @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len));1086 return syscall3(.getpeername, @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len));
1083}1087}
10841088
1085pub fn socket(domain: u32, socket_type: u32, protocol: u32) usize {1089pub fn socket(domain: u32, socket_type: u32, protocol: u32) usize {
1086 if (native_arch == .i386) {1090 if (native_arch == .i386) {
1087 return socketcall(SC_socket, &[3]usize{ domain, socket_type, protocol });1091 return socketcall(SC.socket, &[3]usize{ domain, socket_type, protocol });
1088 }1092 }
1089 return syscall3(.socket, domain, socket_type, protocol);1093 return syscall3(.socket, domain, socket_type, protocol);
1090}1094}
10911095
1092pub fn setsockopt(fd: i32, level: u32, optname: u32, optval: [*]const u8, optlen: socklen_t) usize {1096pub fn setsockopt(fd: i32, level: u32, optname: u32, optval: [*]const u8, optlen: socklen_t) usize {
1093 if (native_arch == .i386) {1097 if (native_arch == .i386) {
1094 return socketcall(SC_setsockopt, &[5]usize{ @bitCast(usize, @as(isize, fd)), level, optname, @ptrToInt(optval), @intCast(usize, optlen) });1098 return socketcall(SC.setsockopt, &[5]usize{ @bitCast(usize, @as(isize, fd)), level, optname, @ptrToInt(optval), @intCast(usize, optlen) });
1095 }1099 }
1096 return syscall5(.setsockopt, @bitCast(usize, @as(isize, fd)), level, optname, @ptrToInt(optval), @intCast(usize, optlen));1100 return syscall5(.setsockopt, @bitCast(usize, @as(isize, fd)), level, optname, @ptrToInt(optval), @intCast(usize, optlen));
1097}1101}
10981102
1099pub fn getsockopt(fd: i32, level: u32, optname: u32, noalias optval: [*]u8, noalias optlen: *socklen_t) usize {1103pub fn getsockopt(fd: i32, level: u32, optname: u32, noalias optval: [*]u8, noalias optlen: *socklen_t) usize {
1100 if (native_arch == .i386) {1104 if (native_arch == .i386) {
1101 return socketcall(SC_getsockopt, &[5]usize{ @bitCast(usize, @as(isize, fd)), level, optname, @ptrToInt(optval), @ptrToInt(optlen) });1105 return socketcall(SC.getsockopt, &[5]usize{ @bitCast(usize, @as(isize, fd)), level, optname, @ptrToInt(optval), @ptrToInt(optlen) });
1102 }1106 }
1103 return syscall5(.getsockopt, @bitCast(usize, @as(isize, fd)), level, optname, @ptrToInt(optval), @ptrToInt(optlen));1107 return syscall5(.getsockopt, @bitCast(usize, @as(isize, fd)), level, optname, @ptrToInt(optval), @ptrToInt(optlen));
1104}1108}
11051109
1106pub fn sendmsg(fd: i32, msg: *const std.x.os.Socket.Message, flags: c_int) usize {1110pub fn sendmsg(fd: i32, msg: *const std.x.os.Socket.Message, flags: c_int) usize {
1107 if (native_arch == .i386) {1111 if (native_arch == .i386) {
1108 return socketcall(SC_sendmsg, &[3]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(msg), @bitCast(usize, @as(isize, flags)) });1112 return socketcall(SC.sendmsg, &[3]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(msg), @bitCast(usize, @as(isize, flags)) });
1109 }1113 }
1110 return syscall3(.sendmsg, @bitCast(usize, @as(isize, fd)), @ptrToInt(msg), @bitCast(usize, @as(isize, flags)));1114 return syscall3(.sendmsg, @bitCast(usize, @as(isize, fd)), @ptrToInt(msg), @bitCast(usize, @as(isize, flags)));
1111}1115}
...@@ -1152,49 +1156,49 @@ pub fn sendmmsg(fd: i32, msgvec: [*]mmsghdr_const, vlen: u32, flags: u32) usize...@@ -1152,49 +1156,49 @@ pub fn sendmmsg(fd: i32, msgvec: [*]mmsghdr_const, vlen: u32, flags: u32) usize
11521156
1153pub fn connect(fd: i32, addr: *const c_void, len: socklen_t) usize {1157pub fn connect(fd: i32, addr: *const c_void, len: socklen_t) usize {
1154 if (native_arch == .i386) {1158 if (native_arch == .i386) {
1155 return socketcall(SC_connect, &[3]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), len });1159 return socketcall(SC.connect, &[3]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), len });
1156 }1160 }
1157 return syscall3(.connect, @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), len);1161 return syscall3(.connect, @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), len);
1158}1162}
11591163
1160pub fn recvmsg(fd: i32, msg: *std.x.os.Socket.Message, flags: c_int) usize {1164pub fn recvmsg(fd: i32, msg: *std.x.os.Socket.Message, flags: c_int) usize {
1161 if (native_arch == .i386) {1165 if (native_arch == .i386) {
1162 return socketcall(SC_recvmsg, &[3]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(msg), @bitCast(usize, @as(isize, flags)) });1166 return socketcall(SC.recvmsg, &[3]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(msg), @bitCast(usize, @as(isize, flags)) });
1163 }1167 }
1164 return syscall3(.recvmsg, @bitCast(usize, @as(isize, fd)), @ptrToInt(msg), @bitCast(usize, @as(isize, flags)));1168 return syscall3(.recvmsg, @bitCast(usize, @as(isize, fd)), @ptrToInt(msg), @bitCast(usize, @as(isize, flags)));
1165}1169}
11661170
1167pub fn recvfrom(fd: i32, noalias buf: [*]u8, len: usize, flags: u32, noalias addr: ?*sockaddr, noalias alen: ?*socklen_t) usize {1171pub fn recvfrom(fd: i32, noalias buf: [*]u8, len: usize, flags: u32, noalias addr: ?*sockaddr, noalias alen: ?*socklen_t) usize {
1168 if (native_arch == .i386) {1172 if (native_arch == .i386) {
1169 return socketcall(SC_recvfrom, &[6]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(buf), len, flags, @ptrToInt(addr), @ptrToInt(alen) });1173 return socketcall(SC.recvfrom, &[6]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(buf), len, flags, @ptrToInt(addr), @ptrToInt(alen) });
1170 }1174 }
1171 return syscall6(.recvfrom, @bitCast(usize, @as(isize, fd)), @ptrToInt(buf), len, flags, @ptrToInt(addr), @ptrToInt(alen));1175 return syscall6(.recvfrom, @bitCast(usize, @as(isize, fd)), @ptrToInt(buf), len, flags, @ptrToInt(addr), @ptrToInt(alen));
1172}1176}
11731177
1174pub fn shutdown(fd: i32, how: i32) usize {1178pub fn shutdown(fd: i32, how: i32) usize {
1175 if (native_arch == .i386) {1179 if (native_arch == .i386) {
1176 return socketcall(SC_shutdown, &[2]usize{ @bitCast(usize, @as(isize, fd)), @bitCast(usize, @as(isize, how)) });1180 return socketcall(SC.shutdown, &[2]usize{ @bitCast(usize, @as(isize, fd)), @bitCast(usize, @as(isize, how)) });
1177 }1181 }
1178 return syscall2(.shutdown, @bitCast(usize, @as(isize, fd)), @bitCast(usize, @as(isize, how)));1182 return syscall2(.shutdown, @bitCast(usize, @as(isize, fd)), @bitCast(usize, @as(isize, how)));
1179}1183}
11801184
1181pub fn bind(fd: i32, addr: *const sockaddr, len: socklen_t) usize {1185pub fn bind(fd: i32, addr: *const sockaddr, len: socklen_t) usize {
1182 if (native_arch == .i386) {1186 if (native_arch == .i386) {
1183 return socketcall(SC_bind, &[3]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @intCast(usize, len) });1187 return socketcall(SC.bind, &[3]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @intCast(usize, len) });
1184 }1188 }
1185 return syscall3(.bind, @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @intCast(usize, len));1189 return syscall3(.bind, @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @intCast(usize, len));
1186}1190}
11871191
1188pub fn listen(fd: i32, backlog: u32) usize {1192pub fn listen(fd: i32, backlog: u32) usize {
1189 if (native_arch == .i386) {1193 if (native_arch == .i386) {
1190 return socketcall(SC_listen, &[2]usize{ @bitCast(usize, @as(isize, fd)), backlog });1194 return socketcall(SC.listen, &[2]usize{ @bitCast(usize, @as(isize, fd)), backlog });
1191 }1195 }
1192 return syscall2(.listen, @bitCast(usize, @as(isize, fd)), backlog);1196 return syscall2(.listen, @bitCast(usize, @as(isize, fd)), backlog);
1193}1197}
11941198
1195pub fn sendto(fd: i32, buf: [*]const u8, len: usize, flags: u32, addr: ?*const sockaddr, alen: socklen_t) usize {1199pub fn sendto(fd: i32, buf: [*]const u8, len: usize, flags: u32, addr: ?*const sockaddr, alen: socklen_t) usize {
1196 if (native_arch == .i386) {1200 if (native_arch == .i386) {
1197 return socketcall(SC_sendto, &[6]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(buf), len, flags, @ptrToInt(addr), @intCast(usize, alen) });1201 return socketcall(SC.sendto, &[6]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(buf), len, flags, @ptrToInt(addr), @intCast(usize, alen) });
1198 }1202 }
1199 return syscall6(.sendto, @bitCast(usize, @as(isize, fd)), @ptrToInt(buf), len, flags, @ptrToInt(addr), @intCast(usize, alen));1203 return syscall6(.sendto, @bitCast(usize, @as(isize, fd)), @ptrToInt(buf), len, flags, @ptrToInt(addr), @intCast(usize, alen));
1200}1204}
...@@ -1221,21 +1225,21 @@ pub fn sendfile(outfd: i32, infd: i32, offset: ?*i64, count: usize) usize {...@@ -1221,21 +1225,21 @@ pub fn sendfile(outfd: i32, infd: i32, offset: ?*i64, count: usize) usize {
12211225
1222pub fn socketpair(domain: i32, socket_type: i32, protocol: i32, fd: [2]i32) usize {1226pub fn socketpair(domain: i32, socket_type: i32, protocol: i32, fd: [2]i32) usize {
1223 if (native_arch == .i386) {1227 if (native_arch == .i386) {
1224 return socketcall(SC_socketpair, &[4]usize{ @intCast(usize, domain), @intCast(usize, socket_type), @intCast(usize, protocol), @ptrToInt(&fd[0]) });1228 return socketcall(SC.socketpair, &[4]usize{ @intCast(usize, domain), @intCast(usize, socket_type), @intCast(usize, protocol), @ptrToInt(&fd[0]) });
1225 }1229 }
1226 return syscall4(.socketpair, @intCast(usize, domain), @intCast(usize, socket_type), @intCast(usize, protocol), @ptrToInt(&fd[0]));1230 return syscall4(.socketpair, @intCast(usize, domain), @intCast(usize, socket_type), @intCast(usize, protocol), @ptrToInt(&fd[0]));
1227}1231}
12281232
1229pub fn accept(fd: i32, noalias addr: ?*sockaddr, noalias len: ?*socklen_t) usize {1233pub fn accept(fd: i32, noalias addr: ?*sockaddr, noalias len: ?*socklen_t) usize {
1230 if (native_arch == .i386) {1234 if (native_arch == .i386) {
1231 return socketcall(SC_accept, &[4]usize{ fd, addr, len, 0 });1235 return socketcall(SC.accept, &[4]usize{ fd, addr, len, 0 });
1232 }1236 }
1233 return accept4(fd, addr, len, 0);1237 return accept4(fd, addr, len, 0);
1234}1238}
12351239
1236pub fn accept4(fd: i32, noalias addr: ?*sockaddr, noalias len: ?*socklen_t, flags: u32) usize {1240pub fn accept4(fd: i32, noalias addr: ?*sockaddr, noalias len: ?*socklen_t, flags: u32) usize {
1237 if (native_arch == .i386) {1241 if (native_arch == .i386) {
1238 return socketcall(SC_accept4, &[4]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len), flags });1242 return socketcall(SC.accept4, &[4]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len), flags });
1239 }1243 }
1240 return syscall4(.accept4, @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len), flags);1244 return syscall4(.accept4, @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len), flags);
1241}1245}
...@@ -1435,11 +1439,11 @@ pub fn getrusage(who: i32, usage: *rusage) usize {...@@ -1435,11 +1439,11 @@ pub fn getrusage(who: i32, usage: *rusage) usize {
1435}1439}
14361440
1437pub fn tcgetattr(fd: fd_t, termios_p: *termios) usize {1441pub fn tcgetattr(fd: fd_t, termios_p: *termios) usize {
1438 return syscall3(.ioctl, @bitCast(usize, @as(isize, fd)), TCGETS, @ptrToInt(termios_p));1442 return syscall3(.ioctl, @bitCast(usize, @as(isize, fd)), T.CGETS, @ptrToInt(termios_p));
1439}1443}
14401444
1441pub fn tcsetattr(fd: fd_t, optional_action: TCSA, termios_p: *const termios) usize {1445pub fn tcsetattr(fd: fd_t, optional_action: TCSA, termios_p: *const termios) usize {
1442 return syscall3(.ioctl, @bitCast(usize, @as(isize, fd)), TCSETS + @enumToInt(optional_action), @ptrToInt(termios_p));1446 return syscall3(.ioctl, @bitCast(usize, @as(isize, fd)), T.CSETS + @enumToInt(optional_action), @ptrToInt(termios_p));
1443}1447}
14441448
1445pub fn ioctl(fd: fd_t, request: u32, arg: usize) usize {1449pub fn ioctl(fd: fd_t, request: u32, arg: usize) usize {
...@@ -1900,7 +1904,7 @@ pub const SIG = if (is_mips) struct {...@@ -1900,7 +1904,7 @@ pub const SIG = if (is_mips) struct {
1900 pub const IOT = ABRT;1904 pub const IOT = ABRT;
1901 pub const CLD = CHLD;1905 pub const CLD = CHLD;
1902 pub const PWR = LOST;1906 pub const PWR = LOST;
1903 pub const IO = POLL;1907 pub const IO = SIG.POLL;
19041908
1905 pub const ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize));1909 pub const ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize));
1906 pub const DFL = @intToPtr(?Sigaction.sigaction_fn, 0);1910 pub const DFL = @intToPtr(?Sigaction.sigaction_fn, 0);
...@@ -1996,8 +2000,8 @@ pub const SOCK = struct {...@@ -1996,8 +2000,8 @@ pub const SOCK = struct {
1996pub const PF = struct {2000pub const PF = struct {
1997 pub const UNSPEC = 0;2001 pub const UNSPEC = 0;
1998 pub const LOCAL = 1;2002 pub const LOCAL = 1;
1999 pub const UNIX = PF_LOCAL;2003 pub const UNIX = LOCAL;
2000 pub const FILE = PF_LOCAL;2004 pub const FILE = LOCAL;
2001 pub const INET = 2;2005 pub const INET = 2;
2002 pub const AX25 = 3;2006 pub const AX25 = 3;
2003 pub const IPX = 4;2007 pub const IPX = 4;
...@@ -2013,7 +2017,7 @@ pub const PF = struct {...@@ -2013,7 +2017,7 @@ pub const PF = struct {
2013 pub const SECURITY = 14;2017 pub const SECURITY = 14;
2014 pub const KEY = 15;2018 pub const KEY = 15;
2015 pub const NETLINK = 16;2019 pub const NETLINK = 16;
2016 pub const ROUTE = PF_NETLINK;2020 pub const ROUTE = PF.NETLINK;
2017 pub const PACKET = 17;2021 pub const PACKET = 17;
2018 pub const ASH = 18;2022 pub const ASH = 18;
2019 pub const ECONET = 19;2023 pub const ECONET = 19;
...@@ -2357,7 +2361,7 @@ pub const IP = struct {...@@ -2357,7 +2361,7 @@ pub const IP = struct {
2357 pub const PASSSEC = 18;2361 pub const PASSSEC = 18;
2358 pub const TRANSPARENT = 19;2362 pub const TRANSPARENT = 19;
2359 pub const ORIGDSTADDR = 20;2363 pub const ORIGDSTADDR = 20;
2360 pub const RECVORIGDSTADDR = IP_ORIGDSTADDR;2364 pub const RECVORIGDSTADDR = IP.ORIGDSTADDR;
2361 pub const MINTTL = 21;2365 pub const MINTTL = 21;
2362 pub const NODEFRAG = 22;2366 pub const NODEFRAG = 22;
2363 pub const CHECKSUM = 23;2367 pub const CHECKSUM = 23;
...@@ -2376,7 +2380,7 @@ pub const IP = struct {...@@ -2376,7 +2380,7 @@ pub const IP = struct {
2376 pub const MULTICAST_ALL = 49;2380 pub const MULTICAST_ALL = 49;
2377 pub const UNICAST_IF = 50;2381 pub const UNICAST_IF = 50;
23782382
2379 pub const RECVRETOPTS = IP_RETOPTS;2383 pub const RECVRETOPTS = IP.RETOPTS;
23802384
2381 pub const PMTUDISC_DONT = 0;2385 pub const PMTUDISC_DONT = 0;
2382 pub const PMTUDISC_WANT = 1;2386 pub const PMTUDISC_WANT = 1;
...@@ -2418,7 +2422,7 @@ pub const IPV6 = struct {...@@ -2418,7 +2422,7 @@ pub const IPV6 = struct {
2418 pub const JOIN_ANYCAST = 27;2422 pub const JOIN_ANYCAST = 27;
2419 pub const LEAVE_ANYCAST = 28;2423 pub const LEAVE_ANYCAST = 28;
24202424
2421 // IPV6_MTU_DISCOVER values2425 // IPV6.MTU_DISCOVER values
2422 pub const PMTUDISC_DONT = 0;2426 pub const PMTUDISC_DONT = 0;
2423 pub const PMTUDISC_WANT = 1;2427 pub const PMTUDISC_WANT = 1;
2424 pub const PMTUDISC_DO = 2;2428 pub const PMTUDISC_DO = 2;
...@@ -2470,7 +2474,7 @@ pub const IPV6 = struct {...@@ -2470,7 +2474,7 @@ pub const IPV6 = struct {
2470 pub const MINHOPCOUNT = 73;2474 pub const MINHOPCOUNT = 73;
24712475
2472 pub const ORIGDSTADDR = 74;2476 pub const ORIGDSTADDR = 74;
2473 pub const RECVORIGDSTADDR = IPV6_ORIGDSTADDR;2477 pub const RECVORIGDSTADDR = IPV6.ORIGDSTADDR;
2474 pub const TRANSPARENT = 75;2478 pub const TRANSPARENT = 75;
2475 pub const UNICAST_IF = 76;2479 pub const UNICAST_IF = 76;
2476 pub const RECVFRAGSIZE = 77;2480 pub const RECVFRAGSIZE = 77;
...@@ -3924,8 +3928,8 @@ pub const V = switch (native_arch) {...@@ -3924,8 +3928,8 @@ pub const V = switch (native_arch) {
3924 pub const DISCARD = 13;3928 pub const DISCARD = 13;
3925 pub const WERASE = 14;3929 pub const WERASE = 14;
3926 pub const LNEXT = 15;3930 pub const LNEXT = 15;
3927 pub const MIN = VEOF;3931 pub const MIN = EOF;
3928 pub const TIME = VEOL;3932 pub const TIME = EOL;
3929 },3933 },
3930 .mips, .mipsel, .mips64, .mips64el => struct {3934 .mips, .mipsel, .mips64, .mips64el => struct {
3931 pub const INTR = 0;3935 pub const INTR = 0;
lib/std/os/linux/arm-eabi.zig+25-23
...@@ -551,29 +551,31 @@ pub const O_PATH = 0o10000000;...@@ -551,29 +551,31 @@ pub const O_PATH = 0o10000000;
551pub const O_TMPFILE = 0o20040000;551pub const O_TMPFILE = 0o20040000;
552pub const O_NDELAY = O_NONBLOCK;552pub const O_NDELAY = O_NONBLOCK;
553553
554pub const F_DUPFD = 0;554pub const F = struct {
555pub const F_GETFD = 1;555 pub const DUPFD = 0;
556pub const F_SETFD = 2;556 pub const GETFD = 1;
557pub const F_GETFL = 3;557 pub const SETFD = 2;
558pub const F_SETFL = 4;558 pub const GETFL = 3;
559559 pub const SETFL = 4;
560pub const F_SETOWN = 8;560
561pub const F_GETOWN = 9;561 pub const SETOWN = 8;
562pub const F_SETSIG = 10;562 pub const GETOWN = 9;
563pub const F_GETSIG = 11;563 pub const SETSIG = 10;
564564 pub const GETSIG = 11;
565pub const F_GETLK = 12;565
566pub const F_SETLK = 13;566 pub const GETLK = 12;
567pub const F_SETLKW = 14;567 pub const SETLK = 13;
568568 pub const SETLKW = 14;
569pub const F_RDLCK = 0;569
570pub const F_WRLCK = 1;570 pub const RDLCK = 0;
571pub const F_UNLCK = 2;571 pub const WRLCK = 1;
572572 pub const UNLCK = 2;
573pub const F_SETOWN_EX = 15;573
574pub const F_GETOWN_EX = 16;574 pub const SETOWN_EX = 15;
575575 pub const GETOWN_EX = 16;
576pub const F_GETOWNER_UIDS = 17;576
577 pub const GETOWNER_UIDS = 17;
578};
577579
578pub const LOCK = struct {580pub const LOCK = struct {
579 pub const SH = 1;581 pub const SH = 1;
lib/std/os/linux/arm64.zig+25-23
...@@ -430,24 +430,31 @@ pub const O_PATH = 0o10000000;...@@ -430,24 +430,31 @@ pub const O_PATH = 0o10000000;
430pub const O_TMPFILE = 0o20040000;430pub const O_TMPFILE = 0o20040000;
431pub const O_NDELAY = O_NONBLOCK;431pub const O_NDELAY = O_NONBLOCK;
432432
433pub const F_DUPFD = 0;433pub const F = struct {
434pub const F_GETFD = 1;434 pub const DUPFD = 0;
435pub const F_SETFD = 2;435 pub const GETFD = 1;
436pub const F_GETFL = 3;436 pub const SETFD = 2;
437pub const F_SETFL = 4;437 pub const GETFL = 3;
438438 pub const SETFL = 4;
439pub const F_SETOWN = 8;439
440pub const F_GETOWN = 9;440 pub const SETOWN = 8;
441pub const F_SETSIG = 10;441 pub const GETOWN = 9;
442pub const F_GETSIG = 11;442 pub const SETSIG = 10;
443443 pub const GETSIG = 11;
444pub const F_GETLK = 5;444
445pub const F_SETLK = 6;445 pub const GETLK = 5;
446pub const F_SETLKW = 7;446 pub const SETLK = 6;
447447 pub const SETLKW = 7;
448pub const F_RDLCK = 0;448
449pub const F_WRLCK = 1;449 pub const RDLCK = 0;
450pub const F_UNLCK = 2;450 pub const WRLCK = 1;
451 pub const UNLCK = 2;
452
453 pub const SETOWN_EX = 15;
454 pub const GETOWN_EX = 16;
455
456 pub const GETOWNER_UIDS = 17;
457};
451458
452pub const LOCK = struct {459pub const LOCK = struct {
453 pub const SH = 1;460 pub const SH = 1;
...@@ -456,11 +463,6 @@ pub const LOCK = struct {...@@ -456,11 +463,6 @@ pub const LOCK = struct {
456 pub const NB = 4;463 pub const NB = 4;
457};464};
458465
459pub const F_SETOWN_EX = 15;
460pub const F_GETOWN_EX = 16;
461
462pub const F_GETOWNER_UIDS = 17;
463
464pub const MAP = struct {466pub const MAP = struct {
465 /// stack-like segment467 /// stack-like segment
466 pub const GROWSDOWN = 0x0100;468 pub const GROWSDOWN = 0x0100;
lib/std/os/linux/io_uring.zig+3-3
...@@ -1297,12 +1297,12 @@ test "openat" {...@@ -1297,12 +1297,12 @@ test "openat" {
12971297
1298 const flags: u32 = os.O_CLOEXEC | os.O_RDWR | os.O_CREAT;1298 const flags: u32 = os.O_CLOEXEC | os.O_RDWR | os.O_CREAT;
1299 const mode: os.mode_t = 0o666;1299 const mode: os.mode_t = 0o666;
1300 const sqe_openat = try ring.openat(0x33333333, linux.AT_FDCWD, path, flags, mode);1300 const sqe_openat = try ring.openat(0x33333333, linux.AT.FDCWD, path, flags, mode);
1301 try testing.expectEqual(io_uring_sqe{1301 try testing.expectEqual(io_uring_sqe{
1302 .opcode = .OPENAT,1302 .opcode = .OPENAT,
1303 .flags = 0,1303 .flags = 0,
1304 .ioprio = 0,1304 .ioprio = 0,
1305 .fd = linux.AT_FDCWD,1305 .fd = linux.AT.FDCWD,
1306 .off = 0,1306 .off = 0,
1307 .addr = @ptrToInt(path),1307 .addr = @ptrToInt(path),
1308 .len = mode,1308 .len = mode,
...@@ -1318,7 +1318,7 @@ test "openat" {...@@ -1318,7 +1318,7 @@ test "openat" {
1318 const cqe_openat = try ring.copy_cqe();1318 const cqe_openat = try ring.copy_cqe();
1319 try testing.expectEqual(@as(u64, 0x33333333), cqe_openat.user_data);1319 try testing.expectEqual(@as(u64, 0x33333333), cqe_openat.user_data);
1320 if (cqe_openat.err() == .INVAL) return error.SkipZigTest;1320 if (cqe_openat.err() == .INVAL) return error.SkipZigTest;
1321 // AT_FDCWD is not fully supported before kernel 5.6:1321 // AT.FDCWD is not fully supported before kernel 5.6:
1322 // See https://lore.kernel.org/io-uring/20200207155039.12819-1-axboe@kernel.dk/T/1322 // See https://lore.kernel.org/io-uring/20200207155039.12819-1-axboe@kernel.dk/T/
1323 // We use IORING_FEAT_RW_CUR_POS to know if we are pre-5.6 since that feature was added in 5.6.1323 // We use IORING_FEAT_RW_CUR_POS to know if we are pre-5.6 since that feature was added in 5.6.
1324 if (cqe_openat.err() == .BADF and (ring.features & linux.IORING_FEAT_RW_CUR_POS) == 0) {1324 if (cqe_openat.err() == .BADF and (ring.features & linux.IORING_FEAT_RW_CUR_POS) == 0) {
lib/std/os/linux/mips.zig+25-23
...@@ -649,24 +649,31 @@ pub const O_PATH = 0o010000000;...@@ -649,24 +649,31 @@ pub const O_PATH = 0o010000000;
649pub const O_TMPFILE = 0o020200000;649pub const O_TMPFILE = 0o020200000;
650pub const O_NDELAY = O_NONBLOCK;650pub const O_NDELAY = O_NONBLOCK;
651651
652pub const F_DUPFD = 0;652pub const F = struct {
653pub const F_GETFD = 1;653 pub const DUPFD = 0;
654pub const F_SETFD = 2;654 pub const GETFD = 1;
655pub const F_GETFL = 3;655 pub const SETFD = 2;
656pub const F_SETFL = 4;656 pub const GETFL = 3;
657657 pub const SETFL = 4;
658pub const F_SETOWN = 24;658
659pub const F_GETOWN = 23;659 pub const SETOWN = 24;
660pub const F_SETSIG = 10;660 pub const GETOWN = 23;
661pub const F_GETSIG = 11;661 pub const SETSIG = 10;
662662 pub const GETSIG = 11;
663pub const F_GETLK = 33;663
664pub const F_SETLK = 34;664 pub const GETLK = 33;
665pub const F_SETLKW = 35;665 pub const SETLK = 34;
666666 pub const SETLKW = 35;
667pub const F_RDLCK = 0;667
668pub const F_WRLCK = 1;668 pub const RDLCK = 0;
669pub const F_UNLCK = 2;669 pub const WRLCK = 1;
670 pub const UNLCK = 2;
671
672 pub const SETOWN_EX = 15;
673 pub const GETOWN_EX = 16;
674
675 pub const GETOWNER_UIDS = 17;
676};
670677
671pub const LOCK = struct {678pub const LOCK = struct {
672 pub const SH = 1;679 pub const SH = 1;
...@@ -675,11 +682,6 @@ pub const LOCK = struct {...@@ -675,11 +682,6 @@ pub const LOCK = struct {
675 pub const NB = 4;682 pub const NB = 4;
676};683};
677684
678pub const F_SETOWN_EX = 15;
679pub const F_GETOWN_EX = 16;
680
681pub const F_GETOWNER_UIDS = 17;
682
683pub const MMAP2_UNIT = 4096;685pub const MMAP2_UNIT = 4096;
684686
685pub const MAP = struct {687pub const MAP = struct {
lib/std/os/linux/powerpc.zig+25-23
...@@ -581,29 +581,31 @@ pub const O_PATH = 0o10000000;...@@ -581,29 +581,31 @@ pub const O_PATH = 0o10000000;
581pub const O_TMPFILE = 0o20040000;581pub const O_TMPFILE = 0o20040000;
582pub const O_NDELAY = O_NONBLOCK;582pub const O_NDELAY = O_NONBLOCK;
583583
584pub const F_DUPFD = 0;584pub const F = struct {
585pub const F_GETFD = 1;585 pub const DUPFD = 0;
586pub const F_SETFD = 2;586 pub const GETFD = 1;
587pub const F_GETFL = 3;587 pub const SETFD = 2;
588pub const F_SETFL = 4;588 pub const GETFL = 3;
589589 pub const SETFL = 4;
590pub const F_SETOWN = 8;590
591pub const F_GETOWN = 9;591 pub const SETOWN = 8;
592pub const F_SETSIG = 10;592 pub const GETOWN = 9;
593pub const F_GETSIG = 11;593 pub const SETSIG = 10;
594594 pub const GETSIG = 11;
595pub const F_GETLK = 12;595
596pub const F_SETLK = 13;596 pub const GETLK = 12;
597pub const F_SETLKW = 14;597 pub const SETLK = 13;
598598 pub const SETLKW = 14;
599pub const F_SETOWN_EX = 15;599
600pub const F_GETOWN_EX = 16;600 pub const SETOWN_EX = 15;
601601 pub const GETOWN_EX = 16;
602pub const F_GETOWNER_UIDS = 17;602
603603 pub const GETOWNER_UIDS = 17;
604pub const F_RDLCK = 0;604
605pub const F_WRLCK = 1;605 pub const RDLCK = 0;
606pub const F_UNLCK = 2;606 pub const WRLCK = 1;
607 pub const UNLCK = 2;
608};
607609
608pub const LOCK = struct {610pub const LOCK = struct {
609 pub const SH = 1;611 pub const SH = 1;
lib/std/os/linux/powerpc64.zig+25-23
...@@ -556,24 +556,31 @@ pub const O_PATH = 0o10000000;...@@ -556,24 +556,31 @@ pub const O_PATH = 0o10000000;
556pub const O_TMPFILE = 0o20200000;556pub const O_TMPFILE = 0o20200000;
557pub const O_NDELAY = O_NONBLOCK;557pub const O_NDELAY = O_NONBLOCK;
558558
559pub const F_DUPFD = 0;559pub const F = struct {
560pub const F_GETFD = 1;560 pub const DUPFD = 0;
561pub const F_SETFD = 2;561 pub const GETFD = 1;
562pub const F_GETFL = 3;562 pub const SETFD = 2;
563pub const F_SETFL = 4;563 pub const GETFL = 3;
564564 pub const SETFL = 4;
565pub const F_SETOWN = 8;565
566pub const F_GETOWN = 9;566 pub const SETOWN = 8;
567pub const F_SETSIG = 10;567 pub const GETOWN = 9;
568pub const F_GETSIG = 11;568 pub const SETSIG = 10;
569569 pub const GETSIG = 11;
570pub const F_GETLK = 5;570
571pub const F_SETLK = 6;571 pub const GETLK = 5;
572pub const F_SETLKW = 7;572 pub const SETLK = 6;
573573 pub const SETLKW = 7;
574pub const F_RDLCK = 0;574
575pub const F_WRLCK = 1;575 pub const RDLCK = 0;
576pub const F_UNLCK = 2;576 pub const WRLCK = 1;
577 pub const UNLCK = 2;
578
579 pub const SETOWN_EX = 15;
580 pub const GETOWN_EX = 16;
581
582 pub const GETOWNER_UIDS = 17;
583};
577584
578pub const LOCK = struct {585pub const LOCK = struct {
579 pub const SH = 1;586 pub const SH = 1;
...@@ -582,11 +589,6 @@ pub const LOCK = struct {...@@ -582,11 +589,6 @@ pub const LOCK = struct {
582 pub const NB = 4;589 pub const NB = 4;
583};590};
584591
585pub const F_SETOWN_EX = 15;
586pub const F_GETOWN_EX = 16;
587
588pub const F_GETOWNER_UIDS = 17;
589
590pub const MAP = struct {592pub const MAP = struct {
591 /// stack-like segment593 /// stack-like segment
592 pub const GROWSDOWN = 0x0100;594 pub const GROWSDOWN = 0x0100;
lib/std/os/linux/riscv64.zig+22-20
...@@ -427,22 +427,29 @@ pub const O_PATH = 0o10000000;...@@ -427,22 +427,29 @@ pub const O_PATH = 0o10000000;
427pub const O_TMPFILE = 0o20200000;427pub const O_TMPFILE = 0o20200000;
428pub const O_NDELAY = O_NONBLOCK;428pub const O_NDELAY = O_NONBLOCK;
429429
430pub const F_DUPFD = 0;430pub const F = struct {
431pub const F_GETFD = 1;431 pub const DUPFD = 0;
432pub const F_SETFD = 2;432 pub const GETFD = 1;
433pub const F_GETFL = 3;433 pub const SETFD = 2;
434pub const F_SETFL = 4;434 pub const GETFL = 3;
435pub const F_GETLK = 5;435 pub const SETFL = 4;
436pub const F_SETLK = 6;436 pub const GETLK = 5;
437pub const F_SETLKW = 7;437 pub const SETLK = 6;
438pub const F_SETOWN = 8;438 pub const SETLKW = 7;
439pub const F_GETOWN = 9;439 pub const SETOWN = 8;
440pub const F_SETSIG = 10;440 pub const GETOWN = 9;
441pub const F_GETSIG = 11;441 pub const SETSIG = 10;
442 pub const GETSIG = 11;
442443
443pub const F_RDLCK = 0;444 pub const RDLCK = 0;
444pub const F_WRLCK = 1;445 pub const WRLCK = 1;
445pub const F_UNLCK = 2;446 pub const UNLCK = 2;
447
448 pub const SETOWN_EX = 15;
449 pub const GETOWN_EX = 16;
450
451 pub const GETOWNER_UIDS = 17;
452};
446453
447pub const LOCK = struct {454pub const LOCK = struct {
448 pub const SH = 1;455 pub const SH = 1;
...@@ -451,11 +458,6 @@ pub const LOCK = struct {...@@ -451,11 +458,6 @@ pub const LOCK = struct {
451 pub const NB = 4;458 pub const NB = 4;
452};459};
453460
454pub const F_SETOWN_EX = 15;
455pub const F_GETOWN_EX = 16;
456
457pub const F_GETOWNER_UIDS = 17;
458
459pub const blksize_t = i32;461pub const blksize_t = i32;
460pub const nlink_t = u32;462pub const nlink_t = u32;
461pub const time_t = isize;463pub const time_t = isize;
lib/std/os/linux/sparc64.zig+22-20
...@@ -591,26 +591,28 @@ pub const O_PATH = 0x1000000;...@@ -591,26 +591,28 @@ pub const O_PATH = 0x1000000;
591pub const O_TMPFILE = 0x2010000;591pub const O_TMPFILE = 0x2010000;
592pub const O_NDELAY = O_NONBLOCK | 0x4;592pub const O_NDELAY = O_NONBLOCK | 0x4;
593593
594pub const F_DUPFD = 0;594pub const F = struct {
595pub const F_GETFD = 1;595 pub const DUPFD = 0;
596pub const F_SETFD = 2;596 pub const GETFD = 1;
597pub const F_GETFL = 3;597 pub const SETFD = 2;
598pub const F_SETFL = 4;598 pub const GETFL = 3;
599599 pub const SETFL = 4;
600pub const F_SETOWN = 5;600
601pub const F_GETOWN = 6;601 pub const SETOWN = 5;
602pub const F_GETLK = 7;602 pub const GETOWN = 6;
603pub const F_SETLK = 8;603 pub const GETLK = 7;
604pub const F_SETLKW = 9;604 pub const SETLK = 8;
605605 pub const SETLKW = 9;
606pub const F_RDLCK = 1;606
607pub const F_WRLCK = 2;607 pub const RDLCK = 1;
608pub const F_UNLCK = 3;608 pub const WRLCK = 2;
609609 pub const UNLCK = 3;
610pub const F_SETOWN_EX = 15;610
611pub const F_GETOWN_EX = 16;611 pub const SETOWN_EX = 15;
612612 pub const GETOWN_EX = 16;
613pub const F_GETOWNER_UIDS = 17;613
614 pub const GETOWNER_UIDS = 17;
615};
614616
615pub const LOCK = struct {617pub const LOCK = struct {
616 pub const SH = 1;618 pub const SH = 1;
lib/std/os/linux/thumb.zig+3
...@@ -3,6 +3,9 @@...@@ -3,6 +3,9 @@
3//! reserved for the frame pointer.3//! reserved for the frame pointer.
4//! Save and restore r7 around the syscall without touching the stack pointer not4//! Save and restore r7 around the syscall without touching the stack pointer not
5//! to break the frame chain.5//! to break the frame chain.
6const std = @import("../../std.zig");
7const linux = std.os.linux;
8const SYS = linux.SYS;
69
7pub fn syscall0(number: SYS) usize {10pub fn syscall0(number: SYS) usize {
8 @setRuntimeSafety(false);11 @setRuntimeSafety(false);
lib/std/os/wasi.zig+96-93
...@@ -149,8 +149,10 @@ pub const Stat = struct {...@@ -149,8 +149,10 @@ pub const Stat = struct {
149149
150pub const IOV_MAX = 1024;150pub const IOV_MAX = 1024;
151151
152pub const AT_REMOVEDIR: u32 = 0x4;152pub const AT = struct {
153pub const AT_FDCWD: fd_t = -2;153 pub const REMOVEDIR: u32 = 0x4;
154 pub const FDCWD: fd_t = -2;
155};
154156
155// As defined in the wasi_snapshot_preview1 spec file:157// As defined in the wasi_snapshot_preview1 spec file:
156// https://github.com/WebAssembly/WASI/blob/master/phases/snapshot/witx/typenames.witx158// https://github.com/WebAssembly/WASI/blob/master/phases/snapshot/witx/typenames.witx
...@@ -293,11 +295,13 @@ pub const exitcode_t = u32;...@@ -293,11 +295,13 @@ pub const exitcode_t = u32;
293pub const fd_t = u32;295pub const fd_t = u32;
294296
295pub const fdflags_t = u16;297pub const fdflags_t = u16;
296pub const FDFLAG_APPEND: fdflags_t = 0x0001;298pub const FDFLAG = struct {
297pub const FDFLAG_DSYNC: fdflags_t = 0x0002;299 pub const APPEND: fdflags_t = 0x0001;
298pub const FDFLAG_NONBLOCK: fdflags_t = 0x0004;300 pub const DSYNC: fdflags_t = 0x0002;
299pub const FDFLAG_RSYNC: fdflags_t = 0x0008;301 pub const NONBLOCK: fdflags_t = 0x0004;
300pub const FDFLAG_SYNC: fdflags_t = 0x0010;302 pub const RSYNC: fdflags_t = 0x0008;
303 pub const SYNC: fdflags_t = 0x0010;
304};
301305
302pub const fdstat_t = extern struct {306pub const fdstat_t = extern struct {
303 fs_filetype: filetype_t,307 fs_filetype: filetype_t,
...@@ -333,15 +337,17 @@ pub const filestat_t = extern struct {...@@ -333,15 +337,17 @@ pub const filestat_t = extern struct {
333 }337 }
334};338};
335339
336pub const filetype_t = u8;340pub const filetype_t = enum(u8) {
337pub const FILETYPE_UNKNOWN: filetype_t = 0;341 UNKNOWN,
338pub const FILETYPE_BLOCK_DEVICE: filetype_t = 1;342 BLOCK_DEVICE,
339pub const FILETYPE_CHARACTER_DEVICE: filetype_t = 2;343 CHARACTER_DEVICE,
340pub const FILETYPE_DIRECTORY: filetype_t = 3;344 DIRECTORY,
341pub const FILETYPE_REGULAR_FILE: filetype_t = 4;345 REGULAR_FILE,
342pub const FILETYPE_SOCKET_DGRAM: filetype_t = 5;346 SOCKET_DGRAM,
343pub const FILETYPE_SOCKET_STREAM: filetype_t = 6;347 SOCKET_STREAM,
344pub const FILETYPE_SYMBOLIC_LINK: filetype_t = 7;348 SYMBOLIC_LINK,
349 _,
350};
345351
346pub const fstflags_t = u16;352pub const fstflags_t = u16;
347pub const FILESTAT_SET_ATIM: fstflags_t = 0x0001;353pub const FILESTAT_SET_ATIM: fstflags_t = 0x0001;
...@@ -392,64 +398,66 @@ pub const SOCK = struct {...@@ -392,64 +398,66 @@ pub const SOCK = struct {
392};398};
393399
394pub const rights_t = u64;400pub const rights_t = u64;
395pub const RIGHT_FD_DATASYNC: rights_t = 0x0000000000000001;401pub const RIGHT = struct {
396pub const RIGHT_FD_READ: rights_t = 0x0000000000000002;402 pub const FD_DATASYNC: rights_t = 0x0000000000000001;
397pub const RIGHT_FD_SEEK: rights_t = 0x0000000000000004;403 pub const FD_READ: rights_t = 0x0000000000000002;
398pub const RIGHT_FD_FDSTAT_SET_FLAGS: rights_t = 0x0000000000000008;404 pub const FD_SEEK: rights_t = 0x0000000000000004;
399pub const RIGHT_FD_SYNC: rights_t = 0x0000000000000010;405 pub const FD_FDSTAT_SET_FLAGS: rights_t = 0x0000000000000008;
400pub const RIGHT_FD_TELL: rights_t = 0x0000000000000020;406 pub const FD_SYNC: rights_t = 0x0000000000000010;
401pub const RIGHT_FD_WRITE: rights_t = 0x0000000000000040;407 pub const FD_TELL: rights_t = 0x0000000000000020;
402pub const RIGHT_FD_ADVISE: rights_t = 0x0000000000000080;408 pub const FD_WRITE: rights_t = 0x0000000000000040;
403pub const RIGHT_FD_ALLOCATE: rights_t = 0x0000000000000100;409 pub const FD_ADVISE: rights_t = 0x0000000000000080;
404pub const RIGHT_PATH_CREATE_DIRECTORY: rights_t = 0x0000000000000200;410 pub const FD_ALLOCATE: rights_t = 0x0000000000000100;
405pub const RIGHT_PATH_CREATE_FILE: rights_t = 0x0000000000000400;411 pub const PATH_CREATE_DIRECTORY: rights_t = 0x0000000000000200;
406pub const RIGHT_PATH_LINK_SOURCE: rights_t = 0x0000000000000800;412 pub const PATH_CREATE_FILE: rights_t = 0x0000000000000400;
407pub const RIGHT_PATH_LINK_TARGET: rights_t = 0x0000000000001000;413 pub const PATH_LINK_SOURCE: rights_t = 0x0000000000000800;
408pub const RIGHT_PATH_OPEN: rights_t = 0x0000000000002000;414 pub const PATH_LINK_TARGET: rights_t = 0x0000000000001000;
409pub const RIGHT_FD_READDIR: rights_t = 0x0000000000004000;415 pub const PATH_OPEN: rights_t = 0x0000000000002000;
410pub const RIGHT_PATH_READLINK: rights_t = 0x0000000000008000;416 pub const FD_READDIR: rights_t = 0x0000000000004000;
411pub const RIGHT_PATH_RENAME_SOURCE: rights_t = 0x0000000000010000;417 pub const PATH_READLINK: rights_t = 0x0000000000008000;
412pub const RIGHT_PATH_RENAME_TARGET: rights_t = 0x0000000000020000;418 pub const PATH_RENAME_SOURCE: rights_t = 0x0000000000010000;
413pub const RIGHT_PATH_FILESTAT_GET: rights_t = 0x0000000000040000;419 pub const PATH_RENAME_TARGET: rights_t = 0x0000000000020000;
414pub const RIGHT_PATH_FILESTAT_SET_SIZE: rights_t = 0x0000000000080000;420 pub const PATH_FILESTAT_GET: rights_t = 0x0000000000040000;
415pub const RIGHT_PATH_FILESTAT_SET_TIMES: rights_t = 0x0000000000100000;421 pub const PATH_FILESTAT_SET_SIZE: rights_t = 0x0000000000080000;
416pub const RIGHT_FD_FILESTAT_GET: rights_t = 0x0000000000200000;422 pub const PATH_FILESTAT_SET_TIMES: rights_t = 0x0000000000100000;
417pub const RIGHT_FD_FILESTAT_SET_SIZE: rights_t = 0x0000000000400000;423 pub const FD_FILESTAT_GET: rights_t = 0x0000000000200000;
418pub const RIGHT_FD_FILESTAT_SET_TIMES: rights_t = 0x0000000000800000;424 pub const FD_FILESTAT_SET_SIZE: rights_t = 0x0000000000400000;
419pub const RIGHT_PATH_SYMLINK: rights_t = 0x0000000001000000;425 pub const FD_FILESTAT_SET_TIMES: rights_t = 0x0000000000800000;
420pub const RIGHT_PATH_REMOVE_DIRECTORY: rights_t = 0x0000000002000000;426 pub const PATH_SYMLINK: rights_t = 0x0000000001000000;
421pub const RIGHT_PATH_UNLINK_FILE: rights_t = 0x0000000004000000;427 pub const PATH_REMOVE_DIRECTORY: rights_t = 0x0000000002000000;
422pub const RIGHT_POLL_FD_READWRITE: rights_t = 0x0000000008000000;428 pub const PATH_UNLINK_FILE: rights_t = 0x0000000004000000;
423pub const RIGHT_SOCK_SHUTDOWN: rights_t = 0x0000000010000000;429 pub const POLL_FD_READWRITE: rights_t = 0x0000000008000000;
424pub const RIGHT_ALL: rights_t = RIGHT_FD_DATASYNC |430 pub const SOCK_SHUTDOWN: rights_t = 0x0000000010000000;
425 RIGHT_FD_READ |431 pub const ALL: rights_t = FD_DATASYNC |
426 RIGHT_FD_SEEK |432 FD_READ |
427 RIGHT_FD_FDSTAT_SET_FLAGS |433 FD_SEEK |
428 RIGHT_FD_SYNC |434 FD_FDSTAT_SET_FLAGS |
429 RIGHT_FD_TELL |435 FD_SYNC |
430 RIGHT_FD_WRITE |436 FD_TELL |
431 RIGHT_FD_ADVISE |437 FD_WRITE |
432 RIGHT_FD_ALLOCATE |438 FD_ADVISE |
433 RIGHT_PATH_CREATE_DIRECTORY |439 FD_ALLOCATE |
434 RIGHT_PATH_CREATE_FILE |440 PATH_CREATE_DIRECTORY |
435 RIGHT_PATH_LINK_SOURCE |441 PATH_CREATE_FILE |
436 RIGHT_PATH_LINK_TARGET |442 PATH_LINK_SOURCE |
437 RIGHT_PATH_OPEN |443 PATH_LINK_TARGET |
438 RIGHT_FD_READDIR |444 PATH_OPEN |
439 RIGHT_PATH_READLINK |445 FD_READDIR |
440 RIGHT_PATH_RENAME_SOURCE |446 PATH_READLINK |
441 RIGHT_PATH_RENAME_TARGET |447 PATH_RENAME_SOURCE |
442 RIGHT_PATH_FILESTAT_GET |448 PATH_RENAME_TARGET |
443 RIGHT_PATH_FILESTAT_SET_SIZE |449 PATH_FILESTAT_GET |
444 RIGHT_PATH_FILESTAT_SET_TIMES |450 PATH_FILESTAT_SET_SIZE |
445 RIGHT_FD_FILESTAT_GET |451 PATH_FILESTAT_SET_TIMES |
446 RIGHT_FD_FILESTAT_SET_SIZE |452 FD_FILESTAT_GET |
447 RIGHT_FD_FILESTAT_SET_TIMES |453 FD_FILESTAT_SET_SIZE |
448 RIGHT_PATH_SYMLINK |454 FD_FILESTAT_SET_TIMES |
449 RIGHT_PATH_REMOVE_DIRECTORY |455 PATH_SYMLINK |
450 RIGHT_PATH_UNLINK_FILE |456 PATH_REMOVE_DIRECTORY |
451 RIGHT_POLL_FD_READWRITE |457 PATH_UNLINK_FILE |
452 RIGHT_SOCK_SHUTDOWN;458 POLL_FD_READWRITE |
459 SOCK_SHUTDOWN;
460};
453461
454pub const sdflags_t = u8;462pub const sdflags_t = u8;
455pub const SHUT_RD: sdflags_t = 0x01;463pub const SHUT_RD: sdflags_t = 0x01;
...@@ -524,25 +532,20 @@ pub const timestamp_t = u64;...@@ -524,25 +532,20 @@ pub const timestamp_t = u64;
524532
525pub const userdata_t = u64;533pub const userdata_t = u64;
526534
527pub const whence_t = u8;535pub const whence_t = enum(u8) { SET, CUR, END };
528pub const WHENCE_SET: whence_t = 0;536
529pub const WHENCE_CUR: whence_t = 1;537pub const S = struct {
530pub const WHENCE_END: whence_t = 2;538 pub const IEXEC = @compileError("TODO audit this");
531539 pub const IFBLK = 0x6000;
532pub const S_IEXEC = S_IXUSR;540 pub const IFCHR = 0x2000;
533pub const S_IFBLK = 0x6000;541 pub const IFDIR = 0x4000;
534pub const S_IFCHR = 0x2000;542 pub const IFIFO = 0xc000;
535pub const S_IFDIR = 0x4000;543 pub const IFLNK = 0xa000;
536pub const S_IFIFO = 0xc000;544 pub const IFMT = IFBLK | IFCHR | IFDIR | IFIFO | IFLNK | IFREG | IFSOCK;
537pub const S_IFLNK = 0xa000;545 pub const IFREG = 0x8000;
538pub const S_IFMT = S_IFBLK | S_IFCHR | S_IFDIR | S_IFIFO | S_IFLNK | S_IFREG | S_IFSOCK;546 // There's no concept of UNIX domain socket but we define this value here in order to line with other OSes.
539pub const S_IFREG = 0x8000;547 pub const IFSOCK = 0x1;
540// There's no concept of UNIX domain socket but we define this value here in order to line with other OSes.548};
541pub const S_IFSOCK = 0x1;
542
543pub const SEEK_SET = WHENCE_SET;
544pub const SEEK_CUR = WHENCE_CUR;
545pub const SEEK_END = WHENCE_END;
546549
547pub const LOCK = struct {550pub const LOCK = struct {
548 pub const SH = 0x1;551 pub const SH = 0x1;
lib/std/os/windows.zig+6-11
...@@ -2971,7 +2971,7 @@ pub const EXCEPTION_RECORD = extern struct {...@@ -2971,7 +2971,7 @@ pub const EXCEPTION_RECORD = extern struct {
2971 ExceptionInformation: [15]usize,2971 ExceptionInformation: [15]usize,
2972};2972};
29732973
2974const arch_bits = switch (native_arch) {2974pub usingnamespace switch (native_arch) {
2975 .i386 => struct {2975 .i386 => struct {
2976 pub const FLOATING_SAVE_AREA = extern struct {2976 pub const FLOATING_SAVE_AREA = extern struct {
2977 ControlWord: DWORD,2977 ControlWord: DWORD,
...@@ -3037,8 +3037,8 @@ const arch_bits = switch (native_arch) {...@@ -3037,8 +3037,8 @@ const arch_bits = switch (native_arch) {
3037 Reserved3: WORD,3037 Reserved3: WORD,
3038 MxCsr: DWORD,3038 MxCsr: DWORD,
3039 MxCsr_Mask: DWORD,3039 MxCsr_Mask: DWORD,
3040 FloatRegisters: [8]arch_bits.M128A,3040 FloatRegisters: [8]M128A,
3041 XmmRegisters: [16]arch_bits.M128A,3041 XmmRegisters: [16]M128A,
3042 Reserved4: [96]BYTE,3042 Reserved4: [96]BYTE,
3043 };3043 };
30443044
...@@ -3082,8 +3082,8 @@ const arch_bits = switch (native_arch) {...@@ -3082,8 +3082,8 @@ const arch_bits = switch (native_arch) {
3082 R15: DWORD64,3082 R15: DWORD64,
3083 Rip: DWORD64,3083 Rip: DWORD64,
3084 DUMMYUNIONNAME: extern union {3084 DUMMYUNIONNAME: extern union {
3085 FltSave: arch_bits.XMM_SAVE_AREA32,3085 FltSave: XMM_SAVE_AREA32,
3086 FloatSave: arch_bits.XMM_SAVE_AREA32,3086 FloatSave: XMM_SAVE_AREA32,
3087 DUMMYSTRUCTNAME: extern struct {3087 DUMMYSTRUCTNAME: extern struct {
3088 Header: [2]M128A,3088 Header: [2]M128A,
3089 Legacy: [8]M128A,3089 Legacy: [8]M128A,
...@@ -3189,15 +3189,10 @@ const arch_bits = switch (native_arch) {...@@ -3189,15 +3189,10 @@ const arch_bits = switch (native_arch) {
3189 },3189 },
3190 else => struct {},3190 else => struct {},
3191};3191};
3192pub const M128A = arch_bits.M128A;
3193pub const XMM_SAVE_AREA32 = arch_bits.XMM_SAVE_AREA32;
3194pub const CONTEXT = arch_bits.CONTEXT;
3195pub const FLOATING_SAVE_AREA = arch_bits.FLOATING_SAVE_AREA;
3196pub const NEON128 = arch_bits.NEON128;
31973192
3198pub const EXCEPTION_POINTERS = extern struct {3193pub const EXCEPTION_POINTERS = extern struct {
3199 ExceptionRecord: *EXCEPTION_RECORD,3194 ExceptionRecord: *EXCEPTION_RECORD,
3200 ContextRecord: *CONTEXT,3195 ContextRecord: *@This().CONTEXT,
3201};3196};
32023197
3203pub const VECTORED_EXCEPTION_HANDLER = fn (ExceptionInfo: *EXCEPTION_POINTERS) callconv(WINAPI) c_long;3198pub const VECTORED_EXCEPTION_HANDLER = fn (ExceptionInfo: *EXCEPTION_POINTERS) callconv(WINAPI) c_long;
lib/std/os/windows/gdi32.zig+2
...@@ -5,6 +5,8 @@ const DWORD = windows.DWORD;...@@ -5,6 +5,8 @@ const DWORD = windows.DWORD;
5const WINAPI = windows.WINAPI;5const WINAPI = windows.WINAPI;
6const HDC = windows.HDC;6const HDC = windows.HDC;
7const HGLRC = windows.HGLRC;7const HGLRC = windows.HGLRC;
8const WORD = windows.WORD;
9const BYTE = windows.BYTE;
810
9pub const PIXELFORMATDESCRIPTOR = extern struct {11pub const PIXELFORMATDESCRIPTOR = extern struct {
10 nSize: WORD = @sizeOf(PIXELFORMATDESCRIPTOR),12 nSize: WORD = @sizeOf(PIXELFORMATDESCRIPTOR),
lib/std/os/windows/kernel32.zig+20
...@@ -36,6 +36,26 @@ const HLOCAL = windows.HLOCAL;...@@ -36,6 +36,26 @@ const HLOCAL = windows.HLOCAL;
36const FILETIME = windows.FILETIME;36const FILETIME = windows.FILETIME;
37const STARTUPINFOW = windows.STARTUPINFOW;37const STARTUPINFOW = windows.STARTUPINFOW;
38const PROCESS_INFORMATION = windows.PROCESS_INFORMATION;38const PROCESS_INFORMATION = windows.PROCESS_INFORMATION;
39const OVERLAPPED_ENTRY = windows.OVERLAPPED_ENTRY;
40const LPHEAP_SUMMARY = windows.LPHEAP_SUMMARY;
41const ULONG_PTR = windows.ULONG_PTR;
42const FILE_NOTIFY_INFORMATION = windows.FILE_NOTIFY_INFORMATION;
43const HANDLER_ROUTINE = windows.HANDLER_ROUTINE;
44const ULONG = windows.ULONG;
45const PVOID = windows.PVOID;
46const LPSTR = windows.LPSTR;
47const PENUM_PAGE_FILE_CALLBACKA = windows.PENUM_PAGE_FILE_CALLBACKA;
48const PENUM_PAGE_FILE_CALLBACKW = windows.PENUM_PAGE_FILE_CALLBACKW;
49const INIT_ONCE = windows.INIT_ONCE;
50const CRITICAL_SECTION = windows.CRITICAL_SECTION;
51const WIN32_FIND_DATAW = windows.WIN32_FIND_DATAW;
52const CHAR = windows.CHAR;
53const BY_HANDLE_FILE_INFORMATION = windows.BY_HANDLE_FILE_INFORMATION;
54const SYSTEM_INFO = windows.SYSTEM_INFO;
55const LPOVERLAPPED_COMPLETION_ROUTINE = windows.LPOVERLAPPED_COMPLETION_ROUTINE;
56const UCHAR = windows.UCHAR;
57const FARPROC = windows.FARPROC;
58const INIT_ONCE_FN = windows.INIT_ONCE_FN;
3959
40pub extern "kernel32" fn AddVectoredExceptionHandler(First: c_ulong, Handler: ?VECTORED_EXCEPTION_HANDLER) callconv(WINAPI) ?*c_void;60pub extern "kernel32" fn AddVectoredExceptionHandler(First: c_ulong, Handler: ?VECTORED_EXCEPTION_HANDLER) callconv(WINAPI) ?*c_void;
41pub extern "kernel32" fn RemoveVectoredExceptionHandler(Handle: HANDLE) callconv(WINAPI) c_ulong;61pub extern "kernel32" fn RemoveVectoredExceptionHandler(Handle: HANDLE) callconv(WINAPI) c_ulong;
lib/std/os/windows/ntdll.zig+1
...@@ -21,6 +21,7 @@ const UNICODE_STRING = windows.UNICODE_STRING;...@@ -21,6 +21,7 @@ const UNICODE_STRING = windows.UNICODE_STRING;
21const RTL_OSVERSIONINFOW = windows.RTL_OSVERSIONINFOW;21const RTL_OSVERSIONINFOW = windows.RTL_OSVERSIONINFOW;
22const FILE_BASIC_INFORMATION = windows.FILE_BASIC_INFORMATION;22const FILE_BASIC_INFORMATION = windows.FILE_BASIC_INFORMATION;
23const SIZE_T = windows.SIZE_T;23const SIZE_T = windows.SIZE_T;
24const CURDIR = windows.CURDIR;
2425
25pub extern "NtDll" fn RtlGetVersion(26pub extern "NtDll" fn RtlGetVersion(
26 lpVersionInformation: *RTL_OSVERSIONINFOW,27 lpVersionInformation: *RTL_OSVERSIONINFOW,
lib/std/os/windows/psapi.zig+43
...@@ -2,6 +2,49 @@ const std = @import("../../std.zig");...@@ -2,6 +2,49 @@ const std = @import("../../std.zig");
2const windows = std.os.windows;2const windows = std.os.windows;
3const WINAPI = windows.WINAPI;3const WINAPI = windows.WINAPI;
4const DWORD = windows.DWORD;4const DWORD = windows.DWORD;
5const HANDLE = windows.HANDLE;
6const PENUM_PAGE_FILE_CALLBACKW = windows.PENUM_PAGE_FILE_CALLBACKW;
7const HMODULE = windows.HMODULE;
8const BOOL = windows.BOOL;
9const BOOLEAN = windows.BOOLEAN;
10const CONDITION_VARIABLE = windows.CONDITION_VARIABLE;
11const CONSOLE_SCREEN_BUFFER_INFO = windows.CONSOLE_SCREEN_BUFFER_INFO;
12const COORD = windows.COORD;
13const FILE_INFO_BY_HANDLE_CLASS = windows.FILE_INFO_BY_HANDLE_CLASS;
14const HRESULT = windows.HRESULT;
15const LARGE_INTEGER = windows.LARGE_INTEGER;
16const LPCWSTR = windows.LPCWSTR;
17const LPTHREAD_START_ROUTINE = windows.LPTHREAD_START_ROUTINE;
18const LPVOID = windows.LPVOID;
19const LPWSTR = windows.LPWSTR;
20const MODULEINFO = windows.MODULEINFO;
21const OVERLAPPED = windows.OVERLAPPED;
22const PERFORMANCE_INFORMATION = windows.PERFORMANCE_INFORMATION;
23const PROCESS_MEMORY_COUNTERS = windows.PROCESS_MEMORY_COUNTERS;
24const PSAPI_WS_WATCH_INFORMATION = windows.PSAPI_WS_WATCH_INFORMATION;
25const PSAPI_WS_WATCH_INFORMATION_EX = windows.PSAPI_WS_WATCH_INFORMATION_EX;
26const SECURITY_ATTRIBUTES = windows.SECURITY_ATTRIBUTES;
27const SIZE_T = windows.SIZE_T;
28const SRWLOCK = windows.SRWLOCK;
29const UINT = windows.UINT;
30const VECTORED_EXCEPTION_HANDLER = windows.VECTORED_EXCEPTION_HANDLER;
31const WCHAR = windows.WCHAR;
32const WORD = windows.WORD;
33const Win32Error = windows.Win32Error;
34const va_list = windows.va_list;
35const HLOCAL = windows.HLOCAL;
36const FILETIME = windows.FILETIME;
37const STARTUPINFOW = windows.STARTUPINFOW;
38const PROCESS_INFORMATION = windows.PROCESS_INFORMATION;
39const OVERLAPPED_ENTRY = windows.OVERLAPPED_ENTRY;
40const LPHEAP_SUMMARY = windows.LPHEAP_SUMMARY;
41const ULONG_PTR = windows.ULONG_PTR;
42const FILE_NOTIFY_INFORMATION = windows.FILE_NOTIFY_INFORMATION;
43const HANDLER_ROUTINE = windows.HANDLER_ROUTINE;
44const ULONG = windows.ULONG;
45const PVOID = windows.PVOID;
46const LPSTR = windows.LPSTR;
47const PENUM_PAGE_FILE_CALLBACKA = windows.PENUM_PAGE_FILE_CALLBACKA;
548
6pub extern "psapi" fn EmptyWorkingSet(hProcess: HANDLE) callconv(WINAPI) BOOL;49pub extern "psapi" fn EmptyWorkingSet(hProcess: HANDLE) callconv(WINAPI) BOOL;
7pub extern "psapi" fn EnumDeviceDrivers(lpImageBase: [*]LPVOID, cb: DWORD, lpcbNeeded: *DWORD) callconv(WINAPI) BOOL;50pub extern "psapi" fn EnumDeviceDrivers(lpImageBase: [*]LPVOID, cb: DWORD, lpcbNeeded: *DWORD) callconv(WINAPI) BOOL;
lib/std/os/windows/user32.zig+24-2
...@@ -1,9 +1,31 @@...@@ -1,9 +1,31 @@
1const std = @import("../../std.zig");1const std = @import("../../std.zig");
2const assert = std.debug.assert;2const assert = std.debug.assert;
3
3const windows = std.os.windows;4const windows = std.os.windows;
4const unexpectedError = windows.unexpectedError;
5const GetLastError = windows.kernel32.GetLastError;5const GetLastError = windows.kernel32.GetLastError;
6const SetLastError = windows.kernel32.SetLastError;6const SetLastError = windows.kernel32.SetLastError;
7const unexpectedError = windows.unexpectedError;
8const HWND = windows.HWND;
9const UINT = windows.UINT;
10const HDC = windows.HDC;
11const LONG = windows.LONG;
12const LONG_PTR = windows.LONG_PTR;
13const WINAPI = windows.WINAPI;
14const RECT = windows.RECT;
15const DWORD = windows.DWORD;
16const BOOL = windows.BOOL;
17const TRUE = windows.TRUE;
18const HMENU = windows.HMENU;
19const HINSTANCE = windows.HINSTANCE;
20const LPVOID = windows.LPVOID;
21const ATOM = windows.ATOM;
22const WPARAM = windows.WPARAM;
23const LRESULT = windows.LRESULT;
24const HICON = windows.HICON;
25const LPARAM = windows.LPARAM;
26const POINT = windows.POINT;
27const HCURSOR = windows.HCURSOR;
28const HBRUSH = windows.HBRUSH;
729
8fn selectSymbol(comptime function_static: anytype, function_dynamic: @TypeOf(function_static), comptime os: std.Target.Os.WindowsVersion) @TypeOf(function_static) {30fn selectSymbol(comptime function_static: anytype, function_dynamic: @TypeOf(function_static), comptime os: std.Target.Os.WindowsVersion) @TypeOf(function_static) {
9 comptime {31 comptime {
...@@ -1316,7 +1338,7 @@ pub fn showWindow(hWnd: HWND, nCmdShow: i32) bool {...@@ -1316,7 +1338,7 @@ pub fn showWindow(hWnd: HWND, nCmdShow: i32) bool {
13161338
1317pub extern "user32" fn UpdateWindow(hWnd: HWND) callconv(WINAPI) BOOL;1339pub extern "user32" fn UpdateWindow(hWnd: HWND) callconv(WINAPI) BOOL;
1318pub fn updateWindow(hWnd: HWND) !void {1340pub fn updateWindow(hWnd: HWND) !void {
1319 if (ShowWindow(hWnd, nCmdShow) == 0) {1341 if (UpdateWindow(hWnd) == 0) {
1320 switch (GetLastError()) {1342 switch (GetLastError()) {
1321 .INVALID_WINDOW_HANDLE => unreachable,1343 .INVALID_WINDOW_HANDLE => unreachable,
1322 .INVALID_PARAMETER => unreachable,1344 .INVALID_PARAMETER => unreachable,
lib/std/os/windows/ws2_32.zig+10
...@@ -8,6 +8,16 @@ const DWORD = windows.DWORD;...@@ -8,6 +8,16 @@ const DWORD = windows.DWORD;
8const GUID = windows.GUID;8const GUID = windows.GUID;
9const USHORT = windows.USHORT;9const USHORT = windows.USHORT;
10const WCHAR = windows.WCHAR;10const WCHAR = windows.WCHAR;
11const BOOL = windows.BOOL;
12const HANDLE = windows.HANDLE;
13const timeval = windows.timeval;
14const HWND = windows.HWND;
15const INT = windows.INT;
16const SHORT = windows.SHORT;
17const CHAR = windows.CHAR;
18const ULONG = windows.ULONG;
19const LPARAM = windows.LPARAM;
20const FARPROC = windows.FARPROC;
1121
12pub const SOCKET = *opaque {};22pub const SOCKET = *opaque {};
13pub const INVALID_SOCKET = @intToPtr(SOCKET, ~@as(usize, 0));23pub const INVALID_SOCKET = @intToPtr(SOCKET, ~@as(usize, 0));
lib/std/time.zig-2
...@@ -200,8 +200,6 @@ pub const Timer = struct {...@@ -200,8 +200,6 @@ pub const Timer = struct {
200 .frequency = {},200 .frequency = {},
201 };201 };
202 }202 }
203
204 return self;
205 }203 }
206204
207 /// Reads the timer value since start or the last reset in nanoseconds205 /// Reads the timer value since start or the last reset in nanoseconds
lib/std/zig.zig-1
...@@ -157,7 +157,6 @@ pub fn binNameAlloc(allocator: *std.mem.Allocator, options: BinNameOptions) erro...@@ -157,7 +157,6 @@ pub fn binNameAlloc(allocator: *std.mem.Allocator, options: BinNameOptions) erro
157 }157 }
158 },158 },
159 }159 }
160 return std.fmt.allocPrint(allocator, "{s}{s}{s}", .{ target.libPrefix(), root_name, suffix });
161 },160 },
162 .Obj => return std.fmt.allocPrint(allocator, "{s}.o", .{root_name}),161 .Obj => return std.fmt.allocPrint(allocator, "{s}.o", .{root_name}),
163 },162 },