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
431431 "${CMAKE_SOURCE_DIR}/lib/std/os/linux/io_uring.zig"
432432 "${CMAKE_SOURCE_DIR}/lib/std/os/linux/x86_64.zig"
433433 "${CMAKE_SOURCE_DIR}/lib/std/os/windows.zig"
434 "${CMAKE_SOURCE_DIR}/lib/std/os/windows/bits.zig"
435434 "${CMAKE_SOURCE_DIR}/lib/std/os/windows/ntstatus.zig"
436435 "${CMAKE_SOURCE_DIR}/lib/std/os/windows/win32error.zig"
437436 "${CMAKE_SOURCE_DIR}/lib/std/Progress.zig"
lib/std/builtin.zig+1-1
......@@ -27,7 +27,7 @@ pub const code_model = builtin.code_model;
2727/// used rather than `explicit_subsystem`.
2828/// On non-Windows targets, this is `null`.
2929pub 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;
3131 switch (os.tag) {
3232 .windows => {
3333 if (is_test) {
lib/std/c.zig+211-287
......@@ -1,181 +1,17 @@
11const std = @import("std");
22const builtin = std.builtin;
3const c = @This();
34const page_size = std.mem.page_size;
45const iovec = std.os.iovec;
56const 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
118test {
129 _ = tokenizer;
1310}
1411
15const generic = @import("c/generic.zig");
16const system = switch (builtin.os.tag) {
17 .linux => @import("c/linux.zig"),
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}
12pub const tokenizer = @import("c/tokenizer.zig");
13pub const Token = tokenizer.Token;
14pub const Tokenizer = tokenizer.Tokenizer;
17915
18016/// The return type is `type` to force comptime function call execution.
18117/// TODO: https://github.com/ziglang/zig/issues/425
......@@ -203,6 +39,94 @@ pub fn versionCheck(glibc_version: builtin.Version) type {
20339 };
20440}
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
206130pub extern "c" var environ: [*:null]?[*:0]u8;
207131
208132pub 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;
214138pub extern "c" fn abort() noreturn;
215139pub extern "c" fn exit(code: c_int) noreturn;
216140pub extern "c" fn _exit(code: c_int) noreturn;
217pub extern "c" fn isatty(fd: fd_t) c_int;
218pub extern "c" fn close(fd: fd_t) c_int;
219pub extern "c" fn lseek(fd: fd_t, offset: off_t, whence: c_int) off_t;
141pub extern "c" fn isatty(fd: c.fd_t) c_int;
142pub extern "c" fn close(fd: c.fd_t) c_int;
143pub extern "c" fn lseek(fd: c.fd_t, offset: c.off_t, whence: c_int) c.off_t;
220144pub extern "c" fn open(path: [*:0]const u8, oflag: c_uint, ...) c_int;
221145pub 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;
223147pub 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;
225149pub 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;
227pub extern "c" fn preadv(fd: c_int, iov: [*]const iovec, iovcnt: c_uint, offset: off_t) isize;
150pub extern "c" fn pread(fd: c.fd_t, buf: [*]u8, nbyte: usize, offset: c.off_t) isize;
151pub extern "c" fn preadv(fd: c_int, iov: [*]const iovec, iovcnt: c_uint, offset: c.off_t) isize;
228152pub 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;
230pub extern "c" fn write(fd: 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;
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;
153pub extern "c" fn pwritev(fd: c_int, iov: [*]const iovec_const, iovcnt: c_uint, offset: c.off_t) isize;
154pub extern "c" fn write(fd: c.fd_t, buf: [*]const u8, nbyte: usize) isize;
155pub extern "c" fn pwrite(fd: c.fd_t, buf: [*]const u8, nbyte: usize, offset: c.off_t) isize;
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;
233157pub extern "c" fn munmap(addr: *align(page_size) const c_void, len: usize) c_int;
234158pub extern "c" fn mprotect(addr: *align(page_size) c_void, len: usize, prot: c_uint) c_int;
235159pub 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;
237161pub 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;
239163pub 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;
241165pub extern "c" fn fork() c_int;
242166pub 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;
244pub extern "c" fn pipe(fds: *[2]fd_t) c_int;
167pub extern "c" fn faccessat(dirfd: c.fd_t, path: [*:0]const u8, mode: c_uint, flags: c_uint) c_int;
168pub extern "c" fn pipe(fds: *[2]c.fd_t) c_int;
245169pub 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;
247171pub 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;
249173pub 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;
251175pub 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;
253177pub 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;
255pub extern "c" fn dup2(old_fd: fd_t, new_fd: fd_t) c_int;
178pub extern "c" fn dup(fd: c.fd_t) c_int;
179pub extern "c" fn dup2(old_fd: c.fd_t, new_fd: c.fd_t) c_int;
256180pub 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
259183pub extern "c" fn rmdir(path: [*:0]const u8) c_int;
260184pub extern "c" fn getenv(name: [*:0]const u8) ?[*:0]u8;
261185pub extern "c" fn sysctl(name: [*]const c_int, namelen: c_uint, oldp: ?*c_void, oldlenp: ?*usize, newp: ?*c_void, newlen: usize) c_int;
262186pub extern "c" fn sysctlbyname(name: [*:0]const u8, oldp: ?*c_void, oldlenp: ?*usize, newp: ?*c_void, newlen: usize) c_int;
263187pub 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;
265pub extern "c" fn tcsetattr(fd: fd_t, optional_action: TCSA, termios_p: *const termios) c_int;
266pub extern "c" fn fcntl(fd: fd_t, cmd: c_int, ...) c_int;
267pub extern "c" fn flock(fd: fd_t, operation: c_int) c_int;
268pub extern "c" fn ioctl(fd: fd_t, request: c_int, ...) c_int;
269pub extern "c" fn uname(buf: *utsname) c_int;
188pub extern "c" fn tcgetattr(fd: c.fd_t, termios_p: *c.termios) c_int;
189pub extern "c" fn tcsetattr(fd: c.fd_t, optional_action: c.TCSA, termios_p: *const c.termios) c_int;
190pub extern "c" fn fcntl(fd: c.fd_t, cmd: c_int, ...) c_int;
191pub extern "c" fn flock(fd: c.fd_t, operation: c_int) c_int;
192pub extern "c" fn ioctl(fd: c.fd_t, request: c_int, ...) c_int;
193pub extern "c" fn uname(buf: *c.utsname) c_int;
270194
271195pub extern "c" fn gethostname(name: [*]u8, len: usize) c_int;
272pub extern "c" fn shutdown(socket: fd_t, how: c_int) c_int;
273pub extern "c" fn bind(socket: fd_t, address: ?*const sockaddr, address_len: 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;
275pub extern "c" fn listen(sockfd: fd_t, backlog: c_uint) c_int;
276pub extern "c" fn getsockname(sockfd: fd_t, noalias addr: *sockaddr, noalias addrlen: *socklen_t) c_int;
277pub extern "c" fn getpeername(sockfd: fd_t, noalias addr: *sockaddr, noalias addrlen: *socklen_t) c_int;
278pub extern "c" fn connect(sockfd: fd_t, sock_addr: *const sockaddr, addrlen: socklen_t) c_int;
279pub extern "c" fn accept(sockfd: fd_t, noalias addr: ?*sockaddr, noalias addrlen: ?*socklen_t) c_int;
280pub extern "c" fn accept4(sockfd: fd_t, noalias addr: ?*sockaddr, noalias addrlen: ?*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;
282pub extern "c" fn setsockopt(sockfd: fd_t, level: u32, optname: u32, optval: ?*const c_void, optlen: socklen_t) c_int;
283pub extern "c" fn send(sockfd: fd_t, buf: *const c_void, len: usize, flags: u32) isize;
196pub extern "c" fn shutdown(socket: c.fd_t, how: c_int) c_int;
197pub extern "c" fn bind(socket: c.fd_t, address: ?*const c.sockaddr, address_len: c.socklen_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;
199pub extern "c" fn listen(sockfd: c.fd_t, backlog: c_uint) c_int;
200pub extern "c" fn getsockname(sockfd: c.fd_t, noalias addr: *c.sockaddr, noalias addrlen: *c.socklen_t) c_int;
201pub extern "c" fn getpeername(sockfd: c.fd_t, noalias addr: *c.sockaddr, noalias addrlen: *c.socklen_t) c_int;
202pub extern "c" fn connect(sockfd: c.fd_t, sock_addr: *const c.sockaddr, addrlen: c.socklen_t) c_int;
203pub extern "c" fn accept(sockfd: c.fd_t, noalias addr: ?*c.sockaddr, noalias addrlen: ?*c.socklen_t) 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;
205pub extern "c" fn getsockopt(sockfd: c.fd_t, level: u32, optname: u32, noalias optval: ?*c_void, noalias optlen: *c.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;
207pub extern "c" fn send(sockfd: c.fd_t, buf: *const c_void, len: usize, flags: u32) isize;
284208pub extern "c" fn sendto(
285 sockfd: fd_t,
209 sockfd: c.fd_t,
286210 buf: *const c_void,
287211 len: usize,
288212 flags: u32,
289 dest_addr: ?*const sockaddr,
290 addrlen: socklen_t,
213 dest_addr: ?*const c.sockaddr,
214 addrlen: c.socklen_t,
291215) 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;
295219pub extern "c" fn recvfrom(
296 sockfd: fd_t,
220 sockfd: c.fd_t,
297221 noalias buf: *c_void,
298222 len: usize,
299223 flags: u32,
300 noalias src_addr: ?*sockaddr,
301 noalias addrlen: ?*socklen_t,
224 noalias src_addr: ?*c.sockaddr,
225 noalias addrlen: ?*c.socklen_t,
302226) 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;
306pub extern "c" fn getdirentries(fd: fd_t, buf_ptr: [*]u8, nbytes: usize, basep: *i64) isize;
229pub extern "c" fn kill(pid: c.pid_t, sig: c_int) c_int;
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;
309pub extern "c" fn setgid(gid: gid_t) c_int;
310pub extern "c" fn seteuid(euid: uid_t) c_int;
311pub extern "c" fn setegid(egid: gid_t) c_int;
312pub extern "c" fn setreuid(ruid: uid_t, euid: uid_t) c_int;
313pub extern "c" fn setregid(rgid: gid_t, egid: gid_t) c_int;
314pub extern "c" fn setresuid(ruid: uid_t, euid: uid_t, suid: uid_t) c_int;
315pub extern "c" fn setresgid(rgid: gid_t, egid: gid_t, sgid: gid_t) c_int;
232pub extern "c" fn setuid(uid: c.uid_t) c_int;
233pub extern "c" fn setgid(gid: c.gid_t) c_int;
234pub extern "c" fn seteuid(euid: c.uid_t) c_int;
235pub extern "c" fn setegid(egid: c.gid_t) c_int;
236pub extern "c" fn setreuid(ruid: c.uid_t, euid: c.uid_t) c_int;
237pub extern "c" fn setregid(rgid: c.gid_t, egid: c.gid_t) c_int;
238pub extern "c" fn setresuid(ruid: c.uid_t, euid: c.uid_t, suid: c.uid_t) c_int;
239pub extern "c" fn setresgid(rgid: c.gid_t, egid: c.gid_t, sgid: c.gid_t) c_int;
316240
317241pub extern "c" fn malloc(usize) ?*c_void;
318242pub extern "c" fn realloc(?*c_void, usize) ?*c_void;
319243pub extern "c" fn free(?*c_void) void;
320244
321pub extern "c" fn futimes(fd: fd_t, times: *[2]timeval) c_int;
322pub extern "c" fn utimes(path: [*:0]const u8, times: *[2]timeval) c_int;
245pub extern "c" fn futimes(fd: c.fd_t, times: *[2]c.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;
325pub extern "c" fn futimens(fd: fd_t, times: *const [2]timespec) c_int;
248pub extern "c" fn utimensat(dirfd: c.fd_t, pathname: [*:0]const u8, times: *[2]c.timespec, flags: u32) 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;
328pub extern "c" fn pthread_attr_init(attr: *pthread_attr_t) E;
329pub extern "c" fn pthread_attr_setstack(attr: *pthread_attr_t, stackaddr: *c_void, stacksize: usize) E;
330pub extern "c" fn pthread_attr_setstacksize(attr: *pthread_attr_t, stacksize: usize) E;
331pub extern "c" fn pthread_attr_setguardsize(attr: *pthread_attr_t, guardsize: usize) E;
332pub extern "c" fn pthread_attr_destroy(attr: *pthread_attr_t) 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;
252pub extern "c" fn pthread_attr_init(attr: *c.pthread_attr_t) c.E;
253pub extern "c" fn pthread_attr_setstack(attr: *c.pthread_attr_t, stackaddr: *c_void, stacksize: usize) c.E;
254pub extern "c" fn pthread_attr_setstacksize(attr: *c.pthread_attr_t, stacksize: usize) c.E;
255pub extern "c" fn pthread_attr_setguardsize(attr: *c.pthread_attr_t, guardsize: usize) c.E;
256pub extern "c" fn pthread_attr_destroy(attr: *c.pthread_attr_t) c.E;
333257pub extern "c" fn pthread_self() pthread_t;
334pub extern "c" fn pthread_join(thread: pthread_t, arg_return: ?*?*c_void) E;
335pub extern "c" fn pthread_detach(thread: pthread_t) E;
258pub extern "c" fn pthread_join(thread: pthread_t, arg_return: ?*?*c_void) c.E;
259pub extern "c" fn pthread_detach(thread: pthread_t) c.E;
336260pub extern "c" fn pthread_atfork(
337261 prepare: ?fn () callconv(.C) void,
338262 parent: ?fn () callconv(.C) void,
339263 child: ?fn () callconv(.C) void,
340264) c_int;
341pub extern "c" fn pthread_key_create(key: *pthread_key_t, destructor: ?fn (value: *c_void) callconv(.C) void) E;
342pub extern "c" fn pthread_key_delete(key: pthread_key_t) E;
343pub extern "c" fn pthread_getspecific(key: pthread_key_t) ?*c_void;
344pub extern "c" fn pthread_setspecific(key: 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;
346pub extern "c" fn sem_destroy(sem: *sem_t) c_int;
347pub extern "c" fn sem_post(sem: *sem_t) c_int;
348pub extern "c" fn sem_wait(sem: *sem_t) c_int;
349pub extern "c" fn sem_trywait(sem: *sem_t) c_int;
350pub extern "c" fn sem_timedwait(sem: *sem_t, abs_timeout: *const timespec) c_int;
351pub extern "c" fn sem_getvalue(sem: *sem_t, sval: *c_int) c_int;
265pub extern "c" fn pthread_key_create(key: *c.pthread_key_t, destructor: ?fn (value: *c_void) callconv(.C) void) c.E;
266pub extern "c" fn pthread_key_delete(key: c.pthread_key_t) c.E;
267pub extern "c" fn pthread_getspecific(key: c.pthread_key_t) ?*c_void;
268pub extern "c" fn pthread_setspecific(key: c.pthread_key_t, value: ?*c_void) c_int;
269pub extern "c" fn sem_init(sem: *c.sem_t, pshared: c_int, value: c_uint) c_int;
270pub extern "c" fn sem_destroy(sem: *c.sem_t) c_int;
271pub extern "c" fn sem_post(sem: *c.sem_t) c_int;
272pub extern "c" fn sem_wait(sem: *c.sem_t) c_int;
273pub extern "c" fn sem_trywait(sem: *c.sem_t) c_int;
274pub extern "c" fn sem_timedwait(sem: *c.sem_t, abs_timeout: *const c.timespec) c_int;
275pub extern "c" fn sem_getvalue(sem: *c.sem_t, sval: *c_int) c_int;
352276
353277pub extern "c" fn kqueue() c_int;
354278pub extern "c" fn kevent(
355279 kq: c_int,
356 changelist: [*]const Kevent,
280 changelist: [*]const c.Kevent,
357281 nchanges: c_int,
358 eventlist: [*]Kevent,
282 eventlist: [*]c.Kevent,
359283 nevents: c_int,
360 timeout: ?*const timespec,
284 timeout: ?*const c.timespec,
361285) c_int;
362286
363287pub extern "c" fn getaddrinfo(
364288 noalias node: ?[*:0]const u8,
365289 noalias service: ?[*:0]const u8,
366 noalias hints: ?*const addrinfo,
367 noalias res: **addrinfo,
368) EAI;
290 noalias hints: ?*const c.addrinfo,
291 noalias res: **c.addrinfo,
292) c.EAI;
369293
370pub extern "c" fn freeaddrinfo(res: *addrinfo) void;
294pub extern "c" fn freeaddrinfo(res: *c.addrinfo) void;
371295
372296pub extern "c" fn getnameinfo(
373 noalias addr: *const sockaddr,
374 addrlen: socklen_t,
297 noalias addr: *const c.sockaddr,
298 addrlen: c.socklen_t,
375299 noalias host: [*]u8,
376 hostlen: socklen_t,
300 hostlen: c.socklen_t,
377301 noalias serv: [*]u8,
378 servlen: socklen_t,
302 servlen: c.socklen_t,
379303 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;
385pub extern "c" fn ppoll(fds: [*]pollfd, nfds: nfds_t, timeout: ?*const timespec, sigmask: ?*const sigset_t) c_int;
308pub extern "c" fn poll(fds: [*]c.pollfd, nfds: c.nfds_t, timeout: c_int) 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
387311pub extern "c" fn dn_expand(
388312 msg: [*:0]const u8,
......@@ -392,25 +316,25 @@ pub extern "c" fn dn_expand(
392316 length: c_int,
393317) c_int;
394318
395pub const PTHREAD_MUTEX_INITIALIZER = pthread_mutex_t{};
396pub extern "c" fn pthread_mutex_lock(mutex: *pthread_mutex_t) E;
397pub extern "c" fn pthread_mutex_unlock(mutex: *pthread_mutex_t) E;
398pub extern "c" fn pthread_mutex_trylock(mutex: *pthread_mutex_t) E;
399pub extern "c" fn pthread_mutex_destroy(mutex: *pthread_mutex_t) E;
400
401pub const PTHREAD_COND_INITIALIZER = pthread_cond_t{};
402pub extern "c" fn pthread_cond_wait(noalias cond: *pthread_cond_t, noalias mutex: *pthread_mutex_t) E;
403pub extern "c" fn pthread_cond_timedwait(noalias cond: *pthread_cond_t, noalias mutex: *pthread_mutex_t, noalias abstime: *const timespec) E;
404pub extern "c" fn pthread_cond_signal(cond: *pthread_cond_t) E;
405pub extern "c" fn pthread_cond_broadcast(cond: *pthread_cond_t) E;
406pub extern "c" fn pthread_cond_destroy(cond: *pthread_cond_t) E;
407
408pub extern "c" fn pthread_rwlock_destroy(rwl: *pthread_rwlock_t) callconv(.C) E;
409pub extern "c" fn pthread_rwlock_rdlock(rwl: *pthread_rwlock_t) callconv(.C) E;
410pub extern "c" fn pthread_rwlock_wrlock(rwl: *pthread_rwlock_t) callconv(.C) E;
411pub extern "c" fn pthread_rwlock_tryrdlock(rwl: *pthread_rwlock_t) callconv(.C) E;
412pub extern "c" fn pthread_rwlock_trywrlock(rwl: *pthread_rwlock_t) callconv(.C) E;
413pub extern "c" fn pthread_rwlock_unlock(rwl: *pthread_rwlock_t) callconv(.C) E;
319pub const PTHREAD_MUTEX_INITIALIZER = c.pthread_mutex_t{};
320pub extern "c" fn pthread_mutex_lock(mutex: *c.pthread_mutex_t) c.E;
321pub extern "c" fn pthread_mutex_unlock(mutex: *c.pthread_mutex_t) c.E;
322pub extern "c" fn pthread_mutex_trylock(mutex: *c.pthread_mutex_t) c.E;
323pub extern "c" fn pthread_mutex_destroy(mutex: *c.pthread_mutex_t) c.E;
324
325pub const PTHREAD_COND_INITIALIZER = c.pthread_cond_t{};
326pub extern "c" fn pthread_cond_wait(noalias cond: *c.pthread_cond_t, noalias mutex: *c.pthread_mutex_t) c.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;
328pub extern "c" fn pthread_cond_signal(cond: *c.pthread_cond_t) c.E;
329pub extern "c" fn pthread_cond_broadcast(cond: *c.pthread_cond_t) c.E;
330pub extern "c" fn pthread_cond_destroy(cond: *c.pthread_cond_t) c.E;
331
332pub extern "c" fn pthread_rwlock_destroy(rwl: *c.pthread_rwlock_t) callconv(.C) c.E;
333pub extern "c" fn pthread_rwlock_rdlock(rwl: *c.pthread_rwlock_t) callconv(.C) c.E;
334pub extern "c" fn pthread_rwlock_wrlock(rwl: *c.pthread_rwlock_t) callconv(.C) c.E;
335pub extern "c" fn pthread_rwlock_tryrdlock(rwl: *c.pthread_rwlock_t) callconv(.C) c.E;
336pub extern "c" fn pthread_rwlock_trywrlock(rwl: *c.pthread_rwlock_t) callconv(.C) c.E;
337pub extern "c" fn pthread_rwlock_unlock(rwl: *c.pthread_rwlock_t) callconv(.C) c.E;
414338
415339pub const pthread_t = *opaque {};
416340pub const FILE = opaque {};
......@@ -426,8 +350,8 @@ pub extern "c" fn fdatasync(fd: c_int) c_int;
426350
427351pub extern "c" fn prctl(option: c_int, ...) c_int;
428352
429pub extern "c" fn getrlimit(resource: rlimit_resource, rlim: *rlimit) c_int;
430pub extern "c" fn setrlimit(resource: rlimit_resource, rlim: *const rlimit) c_int;
353pub extern "c" fn getrlimit(resource: c.rlimit_resource, rlim: *c.rlimit) c_int;
354pub extern "c" fn setrlimit(resource: c.rlimit_resource, rlim: *const c.rlimit) c_int;
431355
432356pub 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");
44const macho = std.macho;
55const native_arch = builtin.target.cpu.arch;
66const maxInt = std.math.maxInt;
7const iovec_const = std.os.iovec_const;
78
89extern "c" fn __error() *c_int;
910pub extern "c" fn NSVersionOfRunTimeLibrary(library_name: [*:0]const u8) u32;
......@@ -84,8 +85,6 @@ pub const _errno = __error;
8485pub extern "c" fn @"close$NOCANCEL"(fd: fd_t) c_int;
8586pub extern "c" fn mach_host_self() mach_port_t;
8687pub 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
9089pub const sf_hdtr = extern struct {
9190 headers: [*]const iovec_const,
......@@ -1550,19 +1549,17 @@ pub fn S_IWHT(m: u32) bool {
15501549
15511550pub const HOST_NAME_MAX = 72;
15521551
1553pub const AT_FDCWD = -2;
1554
1555/// Use effective ids in access check
1556pub const AT_EACCESS = 0x0010;
1557
1558/// Act on the symlink itself not the target
1559pub const AT_SYMLINK_NOFOLLOW = 0x0020;
1560
1561/// Act on target of symlink
1562pub const AT_SYMLINK_FOLLOW = 0x0040;
1563
1564/// Path refers to directory
1565pub const AT_REMOVEDIR = 0x0080;
1552pub const AT = struct {
1553 pub const FDCWD = -2;
1554 /// Use effective ids in access check
1555 pub const EACCESS = 0x0010;
1556 /// Act on the symlink itself not the target
1557 pub const SYMLINK_NOFOLLOW = 0x0020;
1558 /// Act on target of symlink
1559 pub const SYMLINK_FOLLOW = 0x0040;
1560 /// Path refers to directory
1561 pub const REMOVEDIR = 0x0080;
1562};
15661563
15671564pub const addrinfo = extern struct {
15681565 flags: i32,
......@@ -1590,164 +1587,117 @@ pub const RTLD = struct {
15901587 pub const MAIN_ONLY = @intToPtr(*c_void, @bitCast(usize, @as(isize, -5)));
15911588};
15921589
1593/// duplicate file descriptor
1594pub const F_DUPFD = 0;
1595
1596/// get file descriptor flags
1597pub const F_GETFD = 1;
1598
1599/// set file descriptor flags
1600pub const F_SETFD = 2;
1601
1602/// get file status flags
1603pub const F_GETFL = 3;
1604
1605/// set file status flags
1606pub const F_SETFL = 4;
1607
1608/// get SIGIO/SIGURG proc/pgrp
1609pub const F_GETOWN = 5;
1610
1611/// set SIGIO/SIGURG proc/pgrp
1612pub const F_SETOWN = 6;
1613
1614/// get record locking information
1615pub const F_GETLK = 7;
1616
1617/// set record locking information
1618pub const F_SETLK = 8;
1619
1620/// F_SETLK; wait if blocked
1621pub const F_SETLKW = 9;
1622
1623/// F_SETLK; wait if blocked, return on timeout
1624pub const F_SETLKWTIMEOUT = 10;
1625pub const F_FLUSH_DATA = 40;
1626
1627/// Used for regression test
1628pub const F_CHKCLEAN = 41;
1629
1630/// Preallocate storage
1631pub const F_PREALLOCATE = 42;
1632
1633/// Truncate a file without zeroing space
1634pub const F_SETSIZE = 43;
1635
1636/// Issue an advisory read async with no copy to user
1637pub const F_RDADVISE = 44;
1638
1639/// turn read ahead off/on for this fd
1640pub const F_RDAHEAD = 45;
1641
1642/// turn data caching off/on for this fd
1643pub const F_NOCACHE = 48;
1644
1645/// file offset to device offset
1646pub const F_LOG2PHYS = 49;
1647
1648/// return the full path of the fd
1649pub const F_GETPATH = 50;
1650
1651/// fsync + ask the drive to flush to the media
1652pub const F_FULLFSYNC = 51;
1653
1654/// find which component (if any) is a package
1655pub const F_PATHPKG_CHECK = 52;
1656
1657/// "freeze" all fs operations
1658pub const F_FREEZE_FS = 53;
1659
1660/// "thaw" all fs operations
1661pub const F_THAW_FS = 54;
1662
1663/// turn data caching off/on (globally) for this file
1664pub const F_GLOBAL_NOCACHE = 55;
1665
1666/// add detached signatures
1667pub const F_ADDSIGS = 59;
1668
1669/// add signature from same file (used by dyld for shared libs)
1670pub const F_ADDFILESIGS = 61;
1671
1672/// used in conjunction with F_NOCACHE to indicate that DIRECT, synchonous writes
1673/// should not be used (i.e. its ok to temporaily create cached pages)
1674pub const F_NODIRECT = 62;
1675
1676///Get the protection class of a file from the EA, returns int
1677pub const F_GETPROTECTIONCLASS = 63;
1678
1679///Set the protection class of a file for the EA, requires int
1680pub const F_SETPROTECTIONCLASS = 64;
1681
1682///file offset to device offset, extended
1683pub const F_LOG2PHYS_EXT = 65;
1684
1685///get record locking information, per-process
1686pub const F_GETLKPID = 66;
1687
1688///Mark the file as being the backing store for another filesystem
1689pub const F_SETBACKINGSTORE = 70;
1690
1691///return the full path of the FD, but error in specific mtmd circumstances
1692pub const F_GETPATH_MTMINFO = 71;
1693
1694///Returns the code directory, with associated hashes, to the caller
1695pub const F_GETCODEDIR = 72;
1696
1697///No SIGPIPE generated on EPIPE
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;
1590pub const F = struct {
1591 /// duplicate file descriptor
1592 pub const DUPFD = 0;
1593 /// get file descriptor flags
1594 pub const GETFD = 1;
1595 /// set file descriptor flags
1596 pub const SETFD = 2;
1597 /// get file status flags
1598 pub const GETFL = 3;
1599 /// set file status flags
1600 pub const SETFL = 4;
1601 /// get SIGIO/SIGURG proc/pgrp
1602 pub const GETOWN = 5;
1603 /// set SIGIO/SIGURG proc/pgrp
1604 pub const SETOWN = 6;
1605 /// get record locking information
1606 pub const GETLK = 7;
1607 /// set record locking information
1608 pub const SETLK = 8;
1609 /// F.SETLK; wait if blocked
1610 pub const SETLKW = 9;
1611 /// F.SETLK; wait if blocked, return on timeout
1612 pub const SETLKWTIMEOUT = 10;
1613 pub const FLUSH_DATA = 40;
1614 /// Used for regression test
1615 pub const CHKCLEAN = 41;
1616 /// Preallocate storage
1617 pub const PREALLOCATE = 42;
1618 /// Truncate a file without zeroing space
1619 pub const SETSIZE = 43;
1620 /// Issue an advisory read async with no copy to user
1621 pub const RDADVISE = 44;
1622 /// turn read ahead off/on for this fd
1623 pub const RDAHEAD = 45;
1624 /// turn data caching off/on for this fd
1625 pub const NOCACHE = 48;
1626 /// file offset to device offset
1627 pub const LOG2PHYS = 49;
1628 /// return the full path of the fd
1629 pub const GETPATH = 50;
1630 /// fsync + ask the drive to flush to the media
1631 pub const FULLFSYNC = 51;
1632 /// find which component (if any) is a package
1633 pub const PATHPKG_CHECK = 52;
1634 /// "freeze" all fs operations
1635 pub const FREEZE_FS = 53;
1636 /// "thaw" all fs operations
1637 pub const THAW_FS = 54;
1638 /// turn data caching off/on (globally) for this file
1639 pub const GLOBAL_NOCACHE = 55;
1640 /// add detached signatures
1641 pub const ADDSIGS = 59;
1642 /// add signature from same file (used by dyld for shared libs)
1643 pub const ADDFILESIGS = 61;
1644 /// used in conjunction with F.NOCACHE to indicate that DIRECT, synchonous writes
1645 /// should not be used (i.e. its ok to temporaily create cached pages)
1646 pub const NODIRECT = 62;
1647 ///Get the protection class of a file from the EA, returns int
1648 pub const GETPROTECTIONCLASS = 63;
1649 ///Set the protection class of a file for the EA, requires int
1650 pub const SETPROTECTIONCLASS = 64;
1651 ///file offset to device offset, extended
1652 pub const LOG2PHYS_EXT = 65;
1653 ///get record locking information, per-process
1654 pub const GETLKPID = 66;
1655 ///Mark the file as being the backing store for another filesystem
1656 pub const SETBACKINGSTORE = 70;
1657 ///return the full path of the FD, but error in specific mtmd circumstances
1658 pub const GETPATH_MTMINFO = 71;
1659 ///Returns the code directory, with associated hashes, to the caller
1660 pub const GETCODEDIR = 72;
1661 ///No SIGPIPE generated on EPIPE
1662 pub const SETNOSIGPIPE = 73;
1663 ///Status of SIGPIPE for this fd
1664 pub const GETNOSIGPIPE = 74;
1665 ///For some cases, we need to rewrap the key for AKS/MKB
1666 pub const TRANSCODEKEY = 75;
1667 ///file being written to a by single writer... if throttling enabled, writes
1668 ///may be broken into smaller chunks with throttling in between
1669 pub const SINGLE_WRITER = 76;
1670 ///Get the protection version number for this filesystem
1671 pub const GETPROTECTIONLEVEL = 77;
1672 ///Add detached code signatures (used by dyld for shared libs)
1673 pub const FINDSIGS = 78;
1674 ///Add signature from same file, only if it is signed by Apple (used by dyld for simulator)
1675 pub const ADDFILESIGS_FOR_DYLD_SIM = 83;
1676 ///fsync + issue barrier to drive
1677 pub const BARRIERFSYNC = 85;
1678 ///Add signature from same file, return end offset in structure on success
1679 pub const ADDFILESIGS_RETURN = 97;
1680 ///Check if Library Validation allows this Mach-O file to be mapped into the calling process
1681 pub const CHECK_LV = 98;
1682 ///Deallocate a range of the file
1683 pub const PUNCHHOLE = 99;
1684 ///Trim an active file
1685 pub const TRIM_ACTIVE_FILE = 100;
1686 ///mark the dup with FD_CLOEXEC
1687 pub const DUPFD_CLOEXEC = 67;
1688 /// shared or read lock
1689 pub const RDLCK = 1;
1690 /// unlock
1691 pub const UNLCK = 2;
1692 /// exclusive or write lock
1693 pub const WRLCK = 3;
1694};
17331695
17341696pub const FCNTL_FS_SPECIFIC_BASE = 0x00010000;
17351697
1736///mark the dup with FD_CLOEXEC
1737pub const F_DUPFD_CLOEXEC = 67;
1738
17391698///close-on-exec flag
17401699pub 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
17511701pub const LOCK = struct {
17521702 pub const SH = 1;
17531703 pub const EX = 2;
lib/std/c/dragonfly.zig+32-27
......@@ -1,5 +1,6 @@
11const std = @import("../std.zig");
22const maxInt = std.math.maxInt;
3const iovec = std.os.iovec;
34
45extern "c" threadlocal var errno: c_int;
56pub fn _errno() *c_int {
......@@ -353,18 +354,39 @@ pub const SEEK_END = 2;
353354pub const SEEK_DATA = 3;
354355pub const SEEK_HOLE = 4;
355356
356pub const F_ULOCK = 0;
357pub const F_LOCK = 1;
358pub const F_TLOCK = 2;
359pub const F_TEST = 3;
357pub const F = struct {
358 pub const ULOCK = 0;
359 pub const LOCK = 1;
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
361381pub const FD_CLOEXEC = 1;
362382
363pub const AT_FDCWD = -328243;
364pub const AT_SYMLINK_NOFOLLOW = 1;
365pub const AT_REMOVEDIR = 2;
366pub const AT_EACCESS = 4;
367pub const AT_SYMLINK_FOLLOW = 8;
383pub const AT = struct {
384 pub const FDCWD = -328243;
385 pub const SYMLINK_NOFOLLOW = 1;
386 pub const REMOVEDIR = 2;
387 pub const EACCESS = 4;
388 pub const SYMLINK_FOLLOW = 8;
389};
368390
369391pub fn WEXITSTATUS(s: u32) u8 {
370392 return @intCast(u8, (s & 0xff00) >> 8);
......@@ -715,7 +737,7 @@ pub const PF = struct {
715737 pub const ISDN = AF.ISDN;
716738 pub const RTIP = AF.pseudo_RTIP;
717739 pub const LAT = AF.LAT;
718 pub const UNIX = PF_LOCAL;
740 pub const UNIX = PF.LOCAL;
719741 pub const XTP = AF.pseudo_XTP;
720742 pub const DECnet = AF.DECnet;
721743};
......@@ -868,23 +890,6 @@ pub const MADV = struct {
868890 pub const SETMAP = 11;
869891};
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
888893pub const LOCK = struct {
889894 pub const SH = 1;
890895 pub const EX = 2;
lib/std/c/freebsd.zig+134-129
......@@ -1,5 +1,8 @@
11const std = @import("../std.zig");
2const builtin = @import("builtin");
23const maxInt = std.math.maxInt;
4const iovec = std.os.iovec;
5const iovec_const = std.os.iovec_const;
36
47extern "c" fn __error() *c_int;
58pub const _errno = __error;
......@@ -400,60 +403,100 @@ pub const MAP = struct {
400403 pub const @"32BIT" = 0x00080000;
401404};
402405
403pub const WNOHANG = 1;
404pub const WUNTRACED = 2;
405pub const WSTOPPED = WUNTRACED;
406pub const WCONTINUED = 4;
407pub const WNOWAIT = 8;
408pub const WEXITED = 16;
409pub const WTRAPPED = 32;
410
411pub const SA_ONSTACK = 0x0001;
412pub const SA_RESTART = 0x0002;
413pub const SA_RESETHAND = 0x0004;
414pub const SA_NOCLDSTOP = 0x0008;
415pub const SA_NODEFER = 0x0010;
416pub const SA_NOCLDWAIT = 0x0020;
417pub const SA_SIGINFO = 0x0040;
418
419pub const SIGHUP = 1;
420pub const SIGINT = 2;
421pub const SIGQUIT = 3;
422pub const SIGILL = 4;
423pub const SIGTRAP = 5;
424pub const SIGABRT = 6;
425pub const SIGIOT = SIGABRT;
426pub const SIGEMT = 7;
427pub const SIGFPE = 8;
428pub const SIGKILL = 9;
429pub const SIGBUS = 10;
430pub const SIGSEGV = 11;
431pub const SIGSYS = 12;
432pub const SIGPIPE = 13;
433pub const SIGALRM = 14;
434pub const SIGTERM = 15;
435pub const SIGURG = 16;
436pub const SIGSTOP = 17;
437pub const SIGTSTP = 18;
438pub const SIGCONT = 19;
439pub const SIGCHLD = 20;
440pub const SIGTTIN = 21;
441pub const SIGTTOU = 22;
442pub const SIGIO = 23;
443pub const SIGXCPU = 24;
444pub const SIGXFSZ = 25;
445pub const SIGVTALRM = 26;
446pub const SIGPROF = 27;
447pub const SIGWINCH = 28;
448pub const SIGINFO = 29;
449pub const SIGUSR1 = 30;
450pub const SIGUSR2 = 31;
451pub const SIGTHR = 32;
452pub const SIGLWP = SIGTHR;
453pub const SIGLIBRT = 33;
454
455pub const SIGRTMIN = 65;
456pub const SIGRTMAX = 126;
406pub const W = struct {
407 pub const NOHANG = 1;
408 pub const UNTRACED = 2;
409 pub const STOPPED = UNTRACED;
410 pub const CONTINUED = 4;
411 pub const NOWAIT = 8;
412 pub const EXITED = 16;
413 pub const TRAPPED = 32;
414};
415
416pub const SA = struct {
417 pub const ONSTACK = 0x0001;
418 pub const RESTART = 0x0002;
419 pub const RESETHAND = 0x0004;
420 pub const NOCLDSTOP = 0x0008;
421 pub const NODEFER = 0x0010;
422 pub const NOCLDWAIT = 0x0020;
423 pub const SIGINFO = 0x0040;
424};
425
426pub const SIG = struct {
427 pub const HUP = 1;
428 pub const INT = 2;
429 pub const QUIT = 3;
430 pub const ILL = 4;
431 pub const TRAP = 5;
432 pub const ABRT = 6;
433 pub const IOT = ABRT;
434 pub const EMT = 7;
435 pub const FPE = 8;
436 pub const KILL = 9;
437 pub const BUS = 10;
438 pub const SEGV = 11;
439 pub const SYS = 12;
440 pub const PIPE = 13;
441 pub const ALRM = 14;
442 pub const TERM = 15;
443 pub const URG = 16;
444 pub const STOP = 17;
445 pub const TSTP = 18;
446 pub const CONT = 19;
447 pub const CHLD = 20;
448 pub const TTIN = 21;
449 pub const TTOU = 22;
450 pub const IO = 23;
451 pub const XCPU = 24;
452 pub const XFSZ = 25;
453 pub const VTALRM = 26;
454 pub const PROF = 27;
455 pub const WINCH = 28;
456 pub const INFO = 29;
457 pub const USR1 = 30;
458 pub const USR2 = 31;
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
458501// access function
459502pub const F_OK = 0; // test for existence of file
......@@ -489,22 +532,29 @@ pub const O_PATH = 0o10000000;
489532pub const O_TMPFILE = 0o20200000;
490533pub const O_NDELAY = O_NONBLOCK;
491534
492pub const F_DUPFD = 0;
493pub const F_GETFD = 1;
494pub const F_SETFD = 2;
495pub const F_GETFL = 3;
496pub const F_SETFL = 4;
535pub const F = struct {
536 pub const DUPFD = 0;
537 pub const GETFD = 1;
538 pub const SETFD = 2;
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;
499pub const F_SETOWN = 6;
545 pub const GETLK = 11;
546 pub const SETLK = 12;
547 pub const SETLKW = 13;
500548
501pub const F_GETLK = 11;
502pub const F_SETLK = 12;
503pub const F_SETLKW = 13;
549 pub const RDLCK = 1;
550 pub const WRLCK = 3;
551 pub const UNLCK = 2;
504552
505pub const F_RDLCK = 1;
506pub const F_WRLCK = 3;
507pub const F_UNLCK = 2;
553 pub const SETOWN_EX = 15;
554 pub const GETOWN_EX = 16;
555
556 pub const GETOWNER_UIDS = 17;
557};
508558
509559pub const LOCK = struct {
510560 pub const SH = 1;
......@@ -513,21 +563,12 @@ pub const LOCK = struct {
513563 pub const NB = 4;
514564};
515565
516pub const F_SETOWN_EX = 15;
517pub const F_GETOWN_EX = 16;
518
519pub const F_GETOWNER_UIDS = 17;
520
521566pub const FD_CLOEXEC = 1;
522567
523568pub const SEEK_SET = 0;
524569pub const SEEK_CUR = 1;
525570pub const SEEK_END = 2;
526571
527pub const SIG_BLOCK = 1;
528pub const SIG_UNBLOCK = 2;
529pub const SIG_SETMASK = 3;
530
531572pub const SOCK = struct {
532573 pub const STREAM = 1;
533574 pub const DGRAM = 2;
......@@ -890,10 +931,6 @@ pub const winsize = extern struct {
890931
891932const 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
897934/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.
898935pub const Sigaction = extern struct {
899936 pub const handler_fn = fn (c_int) callconv(.C) void;
......@@ -942,34 +979,7 @@ pub const siginfo_t = extern struct {
942979 },
943980};
944981
945pub const sigval = extern union {
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) {
982pub usingnamespace switch (builtin.cpu.arch) {
973983 .x86_64 => struct {
974984 pub const ucontext_t = extern struct {
975985 sigmask: sigset_t,
......@@ -1015,8 +1025,6 @@ const arch_bits = switch (builtin.cpu.arch) {
10151025 },
10161026 else => struct {},
10171027};
1018pub const ucontext_t = arch_bits.ucontext_t;
1019pub const mcontext_t = arch_bits.mcontext_t;
10201028
10211029pub const E = enum(u16) {
10221030 /// No error occurred.
......@@ -1224,22 +1232,22 @@ pub fn S_IWHT(m: u32) bool {
12241232
12251233pub const HOST_NAME_MAX = 255;
12261234
1227/// Magic value that specify the use of the current working directory
1228/// to determine the target of relative file paths in the openat() and
1229/// similar syscalls.
1230pub const AT_FDCWD = -100;
1231
1232/// Check access using effective user and group ID
1233pub const AT_EACCESS = 0x0100;
1234
1235/// Do not follow symbolic links
1236pub const AT_SYMLINK_NOFOLLOW = 0x0200;
1237
1238/// Follow symbolic link
1239pub const AT_SYMLINK_FOLLOW = 0x0400;
1240
1241/// Remove directory instead of file
1242pub const AT_REMOVEDIR = 0x0800;
1235pub const AT = struct {
1236 /// Magic value that specify the use of the current working directory
1237 /// to determine the target of relative file paths in the openat() and
1238 /// similar syscalls.
1239 pub const FDCWD = -100;
1240 /// Check access using effective user and group ID
1241 pub const EACCESS = 0x0100;
1242 /// Do not follow symbolic links
1243 pub const SYMLINK_NOFOLLOW = 0x0200;
1244 /// Follow symbolic link
1245 pub const SYMLINK_FOLLOW = 0x0400;
1246 /// Remove directory instead of file
1247 pub const REMOVEDIR = 0x0800;
1248 /// Fail if not under dirfd
1249 pub const BENEATH = 0x1000;
1250};
12431251
12441252pub const addrinfo = extern struct {
12451253 flags: i32,
......@@ -1252,9 +1260,6 @@ pub const addrinfo = extern struct {
12521260 next: ?*addrinfo,
12531261};
12541262
1255/// Fail if not under dirfd
1256pub const AT_BENEATH = 0x1000;
1257
12581263pub const IPPROTO = struct {
12591264 /// dummy for IP
12601265 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 @@
11const std = @import("../std.zig");
2const builtin = @import("builtin");
23const maxInt = std.math.maxInt;
4const iovec = std.os.iovec;
5const iovec_const = std.os.iovec_const;
36
47extern "c" fn _errnop() *c_int;
58
......@@ -421,43 +424,64 @@ pub const SA_NOMASK = SA_NODEFER;
421424pub const SA_STACK = SA_ONSTACK;
422425pub const SA_ONESHOT = SA_RESETHAND;
423426
424pub const SIGHUP = 1;
425pub const SIGINT = 2;
426pub const SIGQUIT = 3;
427pub const SIGILL = 4;
428pub const SIGCHLD = 5;
429pub const SIGABRT = 6;
430pub const SIGIOT = SIGABRT;
431pub const SIGPIPE = 7;
432pub const SIGFPE = 8;
433pub const SIGKILL = 9;
434pub const SIGSTOP = 10;
435pub const SIGSEGV = 11;
436pub const SIGCONT = 12;
437pub const SIGTSTP = 13;
438pub const SIGALRM = 14;
439pub const SIGTERM = 15;
440pub const SIGTTIN = 16;
441pub const SIGTTOU = 17;
442pub const SIGUSR1 = 18;
443pub const SIGUSR2 = 19;
444pub const SIGWINCH = 20;
445pub const SIGKILLTHR = 21;
446pub const SIGTRAP = 22;
447pub const SIGPOLL = 23;
448pub const SIGPROF = 24;
449pub const SIGSYS = 25;
450pub const SIGURG = 26;
451pub const SIGVTALRM = 27;
452pub const SIGXCPU = 28;
453pub const SIGXFSZ = 29;
454pub const SIGBUS = 30;
455pub const SIGRESERVED1 = 31;
456pub const SIGRESERVED2 = 32;
457
458// TODO: check
459pub const SIGRTMIN = 65;
460pub const SIGRTMAX = 126;
427pub const SIG = struct {
428 pub const HUP = 1;
429 pub const INT = 2;
430 pub const QUIT = 3;
431 pub const ILL = 4;
432 pub const CHLD = 5;
433 pub const ABRT = 6;
434 pub const IOT = ABRT;
435 pub const PIPE = 7;
436 pub const FPE = 8;
437 pub const KILL = 9;
438 pub const STOP = 10;
439 pub const SEGV = 11;
440 pub const CONT = 12;
441 pub const TSTP = 13;
442 pub const ALRM = 14;
443 pub const TERM = 15;
444 pub const TTIN = 16;
445 pub const TTOU = 17;
446 pub const USR1 = 18;
447 pub const USR2 = 19;
448 pub const WINCH = 20;
449 pub const KILLTHR = 21;
450 pub const TRAP = 22;
451 pub const POLL = 23;
452 pub const PROF = 24;
453 pub const SYS = 25;
454 pub const URG = 26;
455 pub const VTALRM = 27;
456 pub const XCPU = 28;
457 pub const XFSZ = 29;
458 pub const BUS = 30;
459 pub const RESERVED1 = 31;
460 pub const RESERVED2 = 32;
461
462 // TODO: check
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
462486// access function
463487pub const F_OK = 0; // test for existence of file
......@@ -493,22 +517,29 @@ pub const O_PATH = 0o10000000;
493517pub const O_TMPFILE = 0o20200000;
494518pub const O_NDELAY = O_NONBLOCK;
495519
496pub const F_DUPFD = 0;
497pub const F_GETFD = 1;
498pub const F_SETFD = 2;
499pub const F_GETFL = 3;
500pub const F_SETFL = 4;
520pub const F = struct {
521 pub const DUPFD = 0;
522 pub const GETFD = 1;
523 pub const SETFD = 2;
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;
503pub const F_SETOWN = 6;
530 pub const GETLK = 11;
531 pub const SETLK = 12;
532 pub const SETLKW = 13;
504533
505pub const F_GETLK = 11;
506pub const F_SETLK = 12;
507pub const F_SETLKW = 13;
534 pub const RDLCK = 1;
535 pub const WRLCK = 3;
536 pub const UNLCK = 2;
508537
509pub const F_RDLCK = 1;
510pub const F_WRLCK = 3;
511pub const F_UNLCK = 2;
538 pub const SETOWN_EX = 15;
539 pub const GETOWN_EX = 16;
540
541 pub const GETOWNER_UIDS = 17;
542};
512543
513544pub const LOCK = struct {
514545 pub const SH = 1;
......@@ -517,21 +548,12 @@ pub const LOCK = struct {
517548 pub const NB = 4;
518549};
519550
520pub const F_SETOWN_EX = 15;
521pub const F_GETOWN_EX = 16;
522
523pub const F_GETOWNER_UIDS = 17;
524
525551pub const FD_CLOEXEC = 1;
526552
527553pub const SEEK_SET = 0;
528554pub const SEEK_CUR = 1;
529555pub const SEEK_END = 2;
530556
531pub const SIG_BLOCK = 1;
532pub const SIG_UNBLOCK = 2;
533pub const SIG_SETMASK = 3;
534
535557pub const SOCK = struct {
536558 pub const STREAM = 1;
537559 pub const DGRAM = 2;
......@@ -615,7 +637,7 @@ pub const PF = struct {
615637 pub const SIP = AF.SIP;
616638 pub const IPX = AF.IPX;
617639 pub const RTIP = AF.pseudo_RTIP;
618 pub const PIP = psuedo_AF.PIP;
640 pub const PIP = AF.pseudo_PIP;
619641 pub const ISDN = AF.ISDN;
620642 pub const KEY = AF.pseudo_KEY;
621643 pub const INET6 = AF.pseudo_INET6;
......@@ -816,7 +838,6 @@ pub const Sigaction = extern struct {
816838 /// signal handler
817839 __sigaction_u: extern union {
818840 __sa_handler: fn (i32) callconv(.C) void,
819 __sa_sigaction: fn (i32, *__siginfo, usize) callconv(.C) void,
820841 },
821842
822843 /// see signal options
......@@ -826,23 +847,8 @@ pub const Sigaction = extern struct {
826847 sa_mask: sigset_t,
827848};
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
844850pub const sigset_t = extern struct {
845 __bits: [_SIG_WORDS]u32,
851 __bits: [SIG.WORDS]u32,
846852};
847853
848854pub const E = enum(i32) {
......@@ -1047,22 +1053,22 @@ pub fn S_IWHT(m: u32) bool {
10471053
10481054pub const HOST_NAME_MAX = 255;
10491055
1050/// Magic value that specify the use of the current working directory
1051/// to determine the target of relative file paths in the openat() and
1052/// similar syscalls.
1053pub const AT_FDCWD = -100;
1054
1055/// Check access using effective user and group ID
1056pub const AT_EACCESS = 0x0100;
1057
1058/// Do not follow symbolic links
1059pub const AT_SYMLINK_NOFOLLOW = 0x0200;
1060
1061/// Follow symbolic link
1062pub const AT_SYMLINK_FOLLOW = 0x0400;
1063
1064/// Remove directory instead of file
1065pub const AT_REMOVEDIR = 0x0800;
1056pub const AT = struct {
1057 /// Magic value that specify the use of the current working directory
1058 /// to determine the target of relative file paths in the openat() and
1059 /// similar syscalls.
1060 pub const FDCWD = -100;
1061 /// Check access using effective user and group ID
1062 pub const EACCESS = 0x0100;
1063 /// Do not follow symbolic links
1064 pub const SYMLINK_NOFOLLOW = 0x0200;
1065 /// Follow symbolic link
1066 pub const SYMLINK_FOLLOW = 0x0400;
1067 /// Remove directory instead of file
1068 pub const REMOVEDIR = 0x0800;
1069 /// Fail if not under dirfd
1070 pub const BENEATH = 0x1000;
1071};
10661072
10671073pub const addrinfo = extern struct {
10681074 flags: i32,
......@@ -1075,9 +1081,6 @@ pub const addrinfo = extern struct {
10751081 next: ?*addrinfo,
10761082};
10771083
1078/// Fail if not under dirfd
1079pub const AT_BENEATH = 0x1000;
1080
10811084pub const IPPROTO = struct {
10821085 /// dummy for IP
10831086 pub const IP = 0;
lib/std/c/hermit.zig+4-1
......@@ -1,3 +1,6 @@
1const std = @import("std");
2const maxInt = std.math.maxInt;
3
14pub const pthread_mutex_t = extern struct {
25 inner: usize = ~@as(usize, 0),
36};
......@@ -5,5 +8,5 @@ pub const pthread_cond_t = extern struct {
58 inner: usize = ~@as(usize, 0),
69};
710pub const pthread_rwlock_t = extern struct {
8 ptr: usize = std.math.maxInt(usize),
11 ptr: usize = maxInt(usize),
912};
lib/std/c/linux.zig+1
......@@ -6,6 +6,7 @@ const native_arch = builtin.cpu.arch;
66const linux = std.os.linux;
77const iovec = std.os.iovec;
88const iovec_const = std.os.iovec_const;
9const FILE = std.c.FILE;
910
1011pub const AF = linux.AF;
1112pub const ARCH = linux.ARCH;
lib/std/c/netbsd.zig+141-124
......@@ -1,6 +1,10 @@
11const std = @import("../std.zig");
22const builtin = @import("builtin");
33const 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
59extern "c" fn __errno() *c_int;
610pub const _errno = __errno;
......@@ -12,56 +16,81 @@ pub extern "c" fn _lwp_self() lwpid_t;
1216
1317pub extern "c" fn pipe2(fds: *[2]fd_t, flags: u32) c_int;
1418pub extern "c" fn arc4random_buf(buf: [*]u8, len: usize) void;
19
1520pub extern "c" fn __fstat50(fd: fd_t, buf: *Stat) c_int;
21pub const fstat = __fstat50;
22
1623pub extern "c" fn __stat50(path: [*:0]const u8, buf: *Stat) c_int;
24pub const stat = __stat50;
25
1726pub extern "c" fn __clock_gettime50(clk_id: c_int, tp: *timespec) c_int;
27pub const clock_gettime = __clock_gettime50;
28
1829pub extern "c" fn __clock_getres50(clk_id: c_int, tp: *timespec) c_int;
30pub const clock_getres = __clock_getres50;
31
1932pub extern "c" fn __getdents30(fd: c_int, buf_ptr: [*]u8, nbytes: usize) c_int;
33pub const getdents = __getdents30;
34
2035pub extern "c" fn __sigaltstack14(ss: ?*stack_t, old_ss: ?*stack_t) c_int;
36pub const sigaltstack = __sigaltstack14;
37
2138pub extern "c" fn __nanosleep50(rqtp: *const timespec, rmtp: ?*timespec) c_int;
39pub const nanosleep = __nanosleep50;
40
2241pub extern "c" fn __sigaction14(sig: c_int, noalias act: ?*const Sigaction, noalias oact: ?*Sigaction) c_int;
42pub const sigaction = __sigaction14;
43
2344pub extern "c" fn __sigprocmask14(how: c_int, noalias set: ?*const sigset_t, noalias oset: ?*sigset_t) c_int;
45pub const sigprocmask = __sigaction14;
46
2447pub extern "c" fn __socket30(domain: c_uint, sock_type: c_uint, protocol: c_uint) c_int;
48pub const socket = __socket30;
49
2550pub extern "c" fn __gettimeofday50(noalias tv: ?*timeval, noalias tz: ?*timezone) c_int;
51pub const gettimeofday = __gettimeofday50;
52
2653pub extern "c" fn __getrusage50(who: c_int, usage: *rusage) c_int;
27// libc aliases this as sched_yield
54pub const getrusage = __getrusage50;
55
2856pub extern "c" fn __libc_thr_yield() c_int;
57pub const sched_yield = __libc_thr_yield;
2958
3059pub extern "c" fn posix_memalign(memptr: *?*c_void, alignment: usize, size: usize) c_int;
3160
3261pub const pthread_mutex_t = extern struct {
33 ptm_magic: u32 = 0x33330003,
34 ptm_errorcheck: padded_pthread_spin_t = 0,
35 ptm_ceiling: padded_pthread_spin_t = 0,
36 ptm_owner: usize = 0,
37 ptm_waiters: ?*u8 = null,
38 ptm_recursed: u32 = 0,
39 ptm_spare2: ?*c_void = null,
62 magic: u32 = 0x33330003,
63 errorcheck: padded_pthread_spin_t = 0,
64 ceiling: padded_pthread_spin_t = 0,
65 owner: usize = 0,
66 waiters: ?*u8 = null,
67 recursed: u32 = 0,
68 spare2: ?*c_void = null,
4069};
4170
4271pub const pthread_cond_t = extern struct {
43 ptc_magic: u32 = 0x55550005,
44 ptc_lock: pthread_spin_t = 0,
45 ptc_waiters_first: ?*u8 = null,
46 ptc_waiters_last: ?*u8 = null,
47 ptc_mutex: ?*pthread_mutex_t = null,
48 ptc_private: ?*c_void = null,
72 magic: u32 = 0x55550005,
73 lock: pthread_spin_t = 0,
74 waiters_first: ?*u8 = null,
75 waiters_last: ?*u8 = null,
76 mutex: ?*pthread_mutex_t = null,
77 private: ?*c_void = null,
4978};
5079
5180pub const pthread_rwlock_t = extern struct {
52 ptr_magic: c_uint = 0x99990009,
53 ptr_interlock: switch (builtin.cpu.arch) {
81 magic: c_uint = 0x99990009,
82 interlock: switch (builtin.cpu.arch) {
5483 .aarch64, .sparc, .x86_64, .i386 => u8,
5584 .arm, .powerpc => c_int,
5685 else => unreachable,
5786 } = 0,
58 ptr_rblocked_first: ?*u8 = null,
59 ptr_rblocked_last: ?*u8 = null,
60 ptr_wblocked_first: ?*u8 = null,
61 ptr_wblocked_last: ?*u8 = null,
62 ptr_nreaders: c_uint = 0,
63 ptr_owner: std.c.pthread_t = null,
64 ptr_private: ?*c_void = null,
87 rblocked_first: ?*u8 = null,
88 rblocked_last: ?*u8 = null,
89 wblocked_first: ?*u8 = null,
90 wblocked_last: ?*u8 = null,
91 nreaders: c_uint = 0,
92 owner: std.c.pthread_t = null,
93 private: ?*c_void = null,
6594};
6695
6796const pthread_spin_t = switch (builtin.cpu.arch) {
......@@ -92,20 +121,6 @@ pub const sem_t = ?*opaque {};
92121pub extern "c" fn pthread_setname_np(thread: std.c.pthread_t, name: [*:0]const u8, arg: ?*c_void) E;
93122pub 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
109124pub const blkcnt_t = i64;
110125pub const blksize_t = i32;
111126pub const clock_t = u32;
......@@ -568,43 +583,6 @@ pub const SA_NODEFER = 0x0010;
568583pub const SA_NOCLDWAIT = 0x0020;
569584pub 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
608586// access function
609587pub const F_OK = 0; // test for existence of file
610588pub const X_OK = 1; // test for execute or search permission
......@@ -677,22 +655,24 @@ pub const O_CLOEXEC = 0x00400000;
677655/// skip search permission checks
678656pub const O_SEARCH = 0x00800000;
679657
680pub const F_DUPFD = 0;
681pub const F_GETFD = 1;
682pub const F_SETFD = 2;
683pub const F_GETFL = 3;
684pub const F_SETFL = 4;
658pub const F = struct {
659 pub const DUPFD = 0;
660 pub const GETFD = 1;
661 pub const SETFD = 2;
662 pub const GETFL = 3;
663 pub const SETFL = 4;
685664
686pub const F_GETOWN = 5;
687pub const F_SETOWN = 6;
665 pub const GETOWN = 5;
666 pub const SETOWN = 6;
688667
689pub const F_GETLK = 7;
690pub const F_SETLK = 8;
691pub const F_SETLKW = 9;
668 pub const GETLK = 7;
669 pub const SETLK = 8;
670 pub const SETLKW = 9;
692671
693pub const F_RDLCK = 1;
694pub const F_WRLCK = 3;
695pub const F_UNLCK = 2;
672 pub const RDLCK = 1;
673 pub const WRLCK = 3;
674 pub const UNLCK = 2;
675};
696676
697677pub const LOCK = struct {
698678 pub const SH = 1;
......@@ -918,9 +898,64 @@ pub const winsize = extern struct {
918898
919899const NSIG = 32;
920900
921pub const SIG_DFL = @intToPtr(?Sigaction.sigaction_fn, 0);
922pub const SIG_IGN = @intToPtr(?Sigaction.sigaction_fn, 1);
923pub const SIG_ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize));
901pub const SIG = struct {
902 pub const DFL = @intToPtr(?Sigaction.sigaction_fn, 0);
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
925960/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.
926961pub const Sigaction = extern struct {
......@@ -993,27 +1028,11 @@ pub const _ksiginfo = extern struct {
9931028 } align(@sizeOf(usize)),
9941029};
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
10121031pub const sigset_t = extern struct {
1013 __bits: [_SIG_WORDS]u32,
1032 __bits: [SIG.WORDS]u32,
10141033};
10151034
1016pub const empty_sigset = sigset_t{ .__bits = [_]u32{0} ** _SIG_WORDS };
1035pub const empty_sigset = sigset_t{ .__bits = [_]u32{0} ** SIG.WORDS };
10171036
10181037// XXX x86_64 specific
10191038pub const mcontext_t = extern struct {
......@@ -1253,22 +1272,20 @@ pub fn S_IWHT(m: u32) bool {
12531272 return m & S_IFMT == S_IFWHT;
12541273}
12551274
1256/// Magic value that specify the use of the current working directory
1257/// to determine the target of relative file paths in the openat() and
1258/// similar syscalls.
1259pub const AT_FDCWD = -100;
1260
1261/// Check access using effective user and group ID
1262pub const AT_EACCESS = 0x0100;
1263
1264/// Do not follow symbolic links
1265pub const AT_SYMLINK_NOFOLLOW = 0x0200;
1266
1267/// Follow symbolic link
1268pub const AT_SYMLINK_FOLLOW = 0x0400;
1269
1270/// Remove directory instead of file
1271pub const AT_REMOVEDIR = 0x0800;
1275pub const AT = struct {
1276 /// Magic value that specify the use of the current working directory
1277 /// to determine the target of relative file paths in the openat() and
1278 /// similar syscalls.
1279 pub const FDCWD = -100;
1280 /// Check access using effective user and group ID
1281 pub const EACCESS = 0x0100;
1282 /// Do not follow symbolic links
1283 pub const SYMLINK_NOFOLLOW = 0x0200;
1284 /// Follow symbolic link
1285 pub const SYMLINK_FOLLOW = 0x0400;
1286 /// Remove directory instead of file
1287 pub const REMOVEDIR = 0x0800;
1288};
12721289
12731290pub const HOST_NAME_MAX = 255;
12741291
lib/std/c/openbsd.zig+32-30
......@@ -1,6 +1,8 @@
11const std = @import("../std.zig");
22const maxInt = std.math.maxInt;
33const builtin = @import("builtin");
4const iovec = std.os.iovec;
5const iovec_const = std.os.iovec_const;
46
57extern "c" fn __errno() *c_int;
68pub const _errno = __errno;
......@@ -466,22 +468,24 @@ pub const O_DIRECTORY = 0x20000;
466468/// set close on exec
467469pub const O_CLOEXEC = 0x10000;
468470
469pub const F_DUPFD = 0;
470pub const F_GETFD = 1;
471pub const F_SETFD = 2;
472pub const F_GETFL = 3;
473pub const F_SETFL = 4;
471pub const F = struct {
472 pub const DUPFD = 0;
473 pub const GETFD = 1;
474 pub const SETFD = 2;
475 pub const GETFL = 3;
476 pub const SETFL = 4;
474477
475pub const F_GETOWN = 5;
476pub const F_SETOWN = 6;
478 pub const GETOWN = 5;
479 pub const SETOWN = 6;
477480
478pub const F_GETLK = 7;
479pub const F_SETLK = 8;
480pub const F_SETLKW = 9;
481 pub const GETLK = 7;
482 pub const SETLK = 8;
483 pub const SETLKW = 9;
481484
482pub const F_RDLCK = 1;
483pub const F_UNLCK = 2;
484pub const F_WRLCK = 3;
485 pub const RDLCK = 1;
486 pub const UNLCK = 2;
487 pub const WRLCK = 3;
488};
485489
486490pub const LOCK = struct {
487491 pub const SH = 0x01;
......@@ -840,7 +844,7 @@ const arch_bits = switch (builtin.cpu.arch) {
840844 sc_rsp: c_long,
841845 sc_ss: c_long,
842846
843 sc_fpstate: fxsave64,
847 sc_fpstate: arch_bits.fxsave64,
844848 __sc_unused: c_int,
845849 sc_mask: c_int,
846850 sc_cookie: c_long,
......@@ -1063,22 +1067,20 @@ pub fn S_ISSOCK(m: u32) bool {
10631067 return m & S_IFMT == S_IFSOCK;
10641068}
10651069
1066/// Magic value that specify the use of the current working directory
1067/// to determine the target of relative file paths in the openat() and
1068/// similar syscalls.
1069pub const AT_FDCWD = -100;
1070
1071/// Check access using effective user and group ID
1072pub const AT_EACCESS = 0x01;
1073
1074/// Do not follow symbolic links
1075pub const AT_SYMLINK_NOFOLLOW = 0x02;
1076
1077/// Follow symbolic link
1078pub const AT_SYMLINK_FOLLOW = 0x04;
1079
1080/// Remove directory instead of file
1081pub const AT_REMOVEDIR = 0x08;
1070pub const AT = struct {
1071 /// Magic value that specify the use of the current working directory
1072 /// to determine the target of relative file paths in the openat() and
1073 /// similar syscalls.
1074 pub const FDCWD = -100;
1075 /// Check access using effective user and group ID
1076 pub const EACCESS = 0x01;
1077 /// Do not follow symbolic links
1078 pub const SYMLINK_NOFOLLOW = 0x02;
1079 /// Follow symbolic link
1080 pub const SYMLINK_FOLLOW = 0x04;
1081 /// Remove directory instead of file
1082 pub const REMOVEDIR = 0x08;
1083};
10821084
10831085pub const HOST_NAME_MAX = 255;
10841086
lib/std/c/wasi.zig+19-5
......@@ -1,3 +1,7 @@
1const std = @import("../std.zig");
2const wasi = std.os.wasi;
3const FDFLAG = wasi.FDFLAG;
4
15extern threadlocal var errno: c_int;
26
37pub fn _errno() *c_int {
......@@ -9,6 +13,10 @@ pub const pid_t = c_int;
913pub const uid_t = u32;
1014pub const gid_t = u32;
1115pub 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
1321pub const Stat = extern struct {
1422 dev: i32,
......@@ -57,22 +65,28 @@ pub const Stat = extern struct {
5765/// https://github.com/WebAssembly/wasi-libc/blob/main/expected/wasm32-wasi/predefined-macros.txt
5866pub const O = struct {
5967 pub const ACCMODE = (EXEC | RDWR | SEARCH);
60 pub const APPEND = FDFLAG_APPEND;
68 pub const APPEND = FDFLAG.APPEND;
6169 pub const CLOEXEC = (0);
6270 pub const CREAT = ((1 << 0) << 12); // = __WASI_OFLAGS_CREAT << 12
6371 pub const DIRECTORY = ((1 << 1) << 12); // = __WASI_OFLAGS_DIRECTORY << 12
64 pub const DSYNC = FDFLAG_DSYNC;
72 pub const DSYNC = FDFLAG.DSYNC;
6573 pub const EXCL = ((1 << 2) << 12); // = __WASI_OFLAGS_EXCL << 12
6674 pub const EXEC = (0x02000000);
6775 pub const NOCTTY = (0);
6876 pub const NOFOLLOW = (0x01000000);
69 pub const NONBLOCK = (1 << FDFLAG_NONBLOCK);
77 pub const NONBLOCK = (1 << FDFLAG.NONBLOCK);
7078 pub const RDONLY = (0x04000000);
7179 pub const RDWR = (RDONLY | WRONLY);
72 pub const RSYNC = (1 << FDFLAG_RSYNC);
80 pub const RSYNC = (1 << FDFLAG.RSYNC);
7381 pub const SEARCH = (0x08000000);
74 pub const SYNC = (1 << FDFLAG_SYNC);
82 pub const SYNC = (1 << FDFLAG.SYNC);
7583 pub const TRUNC = ((1 << 3) << 12); // = __WASI_OFLAGS_TRUNC << 12
7684 pub const TTY_INIT = (0);
7785 pub const WRONLY = (0x10000000);
7886};
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 @@
11//! The reference for these types and values is Microsoft Windows's ucrt (Universal C RunTime).
22const std = @import("../std.zig");
33const ws2_32 = std.os.windows.ws2_32;
4
54const windows = std.os.windows;
65
76pub extern "c" fn _errno() *c_int;
......@@ -43,56 +42,51 @@ pub const timeval = extern struct {
4342 tv_usec: c_long,
4443};
4544
45pub const Stat = @compileError("TODO windows Stat definition");
46
4647pub 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
4854/// maximum signal number + 1
4955pub const NSIG = 23;
5056
51// Signal types
52
53/// interrupt
54pub const SIGINT = 2;
55
56/// illegal instruction - invalid function image
57pub const SIGILL = 4;
58
59/// floating point exception
60pub const SIGFPE = 8;
61
62/// segment violation
63pub const SIGSEGV = 11;
64
65/// Software termination signal from kill
66pub const SIGTERM = 15;
67
68/// Ctrl-Break sequence
69pub const SIGBREAK = 21;
70
71/// abnormal termination triggered by abort call
72pub const SIGABRT = 22;
73
74/// SIGABRT compatible with other platforms, same as SIGABRT
75pub const SIGABRT_COMPAT = 6;
76
77// Signal action codes
78
79/// default signal action
80pub const SIG_DFL = 0;
81
82/// ignore signal
83pub const SIG_IGN = 1;
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;
57/// Signal types
58pub const SIG = struct {
59 /// interrupt
60 pub const INT = 2;
61 /// illegal instruction - invalid function image
62 pub const ILL = 4;
63 /// floating point exception
64 pub const FPE = 8;
65 /// segment violation
66 pub const SEGV = 11;
67 /// Software termination signal from kill
68 pub const TERM = 15;
69 /// Ctrl-Break sequence
70 pub const BREAK = 21;
71 /// abnormal termination triggered by abort call
72 pub const ABRT = 22;
73 /// SIGABRT compatible with other platforms, same as SIGABRT
74 pub const ABRT_COMPAT = 6;
75
76 // Signal action codes
77 /// default signal action
78 pub const DFL = 0;
79 /// ignore signal
80 pub const IGN = 1;
81 /// return current value
82 pub const GET = 2;
83 /// signal gets error
84 pub const SGE = 3;
85 /// acknowledge
86 pub const ACK = 4;
87 /// Signal error value (returned by signal call on error)
88 pub const ERR = -1;
89};
9690
9791pub const SEEK_SET = 0;
9892pub const SEEK_CUR = 1;
lib/std/crypto/25519/curve25519.zig+1-3
......@@ -40,9 +40,7 @@ pub const Curve25519 = struct {
4040 }
4141
4242 /// Multiply a point by the cofactor
43 pub fn clearCofactor(p: Edwards25519) Edwards25519 {
44 return p.dbl().dbl().dbl();
45 }
43 pub const clearCofactor = @compileError("TODO what was this function supposed to do? it didn't compile successfully");
4644
4745 fn ladder(p: Curve25519, s: [32]u8, comptime bits: usize) IdentityElementError!Curve25519 {
4846 var x1 = p.x;
lib/std/debug.zig+2-2
......@@ -1341,7 +1341,7 @@ pub const ModuleDebugInfo = switch (native_os) {
13411341 if (o_file_di.findCompileUnit(relocated_address_o)) |compile_unit| {
13421342 return SymbolInfo{
13431343 .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) {
13451345 error.MissingDebugInfo, error.InvalidDebugInfo => "???",
13461346 else => return err,
13471347 },
......@@ -1438,7 +1438,7 @@ fn getSymbolFromDwarf(address: u64, di: *DW.DwarfInfo) !SymbolInfo {
14381438 if (nosuspend di.findCompileUnit(address)) |compile_unit| {
14391439 return SymbolInfo{
14401440 .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) {
14421442 error.MissingDebugInfo, error.InvalidDebugInfo => "???",
14431443 else => return err,
14441444 },
lib/std/dwarf.zig+277-61
......@@ -9,7 +9,223 @@ const leb = @import("leb128.zig");
99
1010const 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
14230const PcRange = struct {
15231 start: u64,
......@@ -322,43 +538,43 @@ fn parseFormValueRef(allocator: *mem.Allocator, in_stream: anytype, endian: buil
322538// TODO the nosuspends here are workarounds
323539fn parseFormValue(allocator: *mem.Allocator, in_stream: anytype, form_id: u64, endian: builtin.Endian, is_64: bool) anyerror!FormValue {
324540 return switch (form_id) {
325 FORM_addr => FormValue{ .Address = try readAddress(in_stream, endian, @sizeOf(usize) == 8) },
326 FORM_block1 => parseFormValueBlock(allocator, in_stream, endian, 1),
327 FORM_block2 => parseFormValueBlock(allocator, in_stream, endian, 2),
328 FORM_block4 => parseFormValueBlock(allocator, in_stream, endian, 4),
329 FORM_block => {
541 FORM.addr => FormValue{ .Address = try readAddress(in_stream, endian, @sizeOf(usize) == 8) },
542 FORM.block1 => parseFormValueBlock(allocator, in_stream, endian, 1),
543 FORM.block2 => parseFormValueBlock(allocator, in_stream, endian, 2),
544 FORM.block4 => parseFormValueBlock(allocator, in_stream, endian, 4),
545 FORM.block => {
330546 const block_len = try nosuspend leb.readULEB128(usize, in_stream);
331547 return parseFormValueBlockLen(allocator, in_stream, block_len);
332548 },
333 FORM_data1 => parseFormValueConstant(allocator, in_stream, false, endian, 1),
334 FORM_data2 => parseFormValueConstant(allocator, in_stream, false, endian, 2),
335 FORM_data4 => parseFormValueConstant(allocator, in_stream, false, endian, 4),
336 FORM_data8 => parseFormValueConstant(allocator, in_stream, false, endian, 8),
337 FORM_udata, FORM_sdata => {
338 const signed = form_id == FORM_sdata;
549 FORM.data1 => parseFormValueConstant(allocator, in_stream, false, endian, 1),
550 FORM.data2 => parseFormValueConstant(allocator, in_stream, false, endian, 2),
551 FORM.data4 => parseFormValueConstant(allocator, in_stream, false, endian, 4),
552 FORM.data8 => parseFormValueConstant(allocator, in_stream, false, endian, 8),
553 FORM.udata, FORM.sdata => {
554 const signed = form_id == FORM.sdata;
339555 return parseFormValueConstant(allocator, in_stream, signed, endian, -1);
340556 },
341 FORM_exprloc => {
557 FORM.exprloc => {
342558 const size = try nosuspend leb.readULEB128(usize, in_stream);
343559 const buf = try readAllocBytes(allocator, in_stream, size);
344560 return FormValue{ .ExprLoc = buf };
345561 },
346 FORM_flag => FormValue{ .Flag = (try nosuspend in_stream.readByte()) != 0 },
347 FORM_flag_present => FormValue{ .Flag = true },
348 FORM_sec_offset => FormValue{ .SecOffset = try readAddress(in_stream, endian, is_64) },
349
350 FORM_ref1 => parseFormValueRef(allocator, in_stream, endian, 1),
351 FORM_ref2 => parseFormValueRef(allocator, in_stream, endian, 2),
352 FORM_ref4 => parseFormValueRef(allocator, in_stream, endian, 4),
353 FORM_ref8 => parseFormValueRef(allocator, in_stream, endian, 8),
354 FORM_ref_udata => parseFormValueRef(allocator, in_stream, endian, -1),
355
356 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) },
358
359 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) },
361 FORM_indirect => {
562 FORM.flag => FormValue{ .Flag = (try nosuspend in_stream.readByte()) != 0 },
563 FORM.flag_present => FormValue{ .Flag = true },
564 FORM.sec_offset => FormValue{ .SecOffset = try readAddress(in_stream, endian, is_64) },
565
566 FORM.ref1 => parseFormValueRef(allocator, in_stream, endian, 1),
567 FORM.ref2 => parseFormValueRef(allocator, in_stream, endian, 2),
568 FORM.ref4 => parseFormValueRef(allocator, in_stream, endian, 4),
569 FORM.ref8 => parseFormValueRef(allocator, in_stream, endian, 8),
570 FORM.ref_udata => parseFormValueRef(allocator, in_stream, endian, -1),
571
572 FORM.ref_addr => FormValue{ .RefAddr = try readAddress(in_stream, endian, is_64) },
573 FORM.ref_sig8 => FormValue{ .Ref = try nosuspend in_stream.readInt(u64, endian) },
574
575 FORM.string => FormValue{ .String = try in_stream.readUntilDelimiterAlloc(allocator, 0, math.maxInt(usize)) },
576 FORM.strp => FormValue{ .StrPtr = try readAddress(in_stream, endian, is_64) },
577 FORM.indirect => {
362578 const child_form_id = try nosuspend leb.readULEB128(u64, in_stream);
363579 const F = @TypeOf(async parseFormValue(allocator, in_stream, child_form_id, endian, is_64));
364580 var frame = try allocator.create(F);
......@@ -441,24 +657,24 @@ pub const DwarfInfo = struct {
441657 const after_die_offset = try seekable.getPos();
442658
443659 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 => {
445661 const fn_name = x: {
446662 var depth: i32 = 3;
447663 var this_die_obj = die_obj;
448664 // Prenvent endless loops
449665 while (depth > 0) : (depth -= 1) {
450 if (this_die_obj.getAttr(AT_name)) |_| {
451 const name = try this_die_obj.getAttrString(di, AT_name);
666 if (this_die_obj.getAttr(AT.name)) |_| {
667 const name = try this_die_obj.getAttrString(di, AT.name);
452668 break :x name;
453 } else if (this_die_obj.getAttr(AT_abstract_origin)) |_| {
669 } else if (this_die_obj.getAttr(AT.abstract_origin)) |_| {
454670 // 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);
456672 if (ref_offset > next_offset) return error.InvalidDebugInfo;
457673 try seekable.seekTo(this_unit_offset + ref_offset);
458674 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)) |_| {
460676 // 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);
462678 if (ref_offset > next_offset) return error.InvalidDebugInfo;
463679 try seekable.seekTo(this_unit_offset + ref_offset);
464680 this_die_obj = (try di.parseDie(in, abbrev_table, is_64)) orelse return error.InvalidDebugInfo;
......@@ -471,8 +687,8 @@ pub const DwarfInfo = struct {
471687 };
472688
473689 const pc_range = x: {
474 if (die_obj.getAttrAddr(AT_low_pc)) |low_pc| {
475 if (die_obj.getAttr(AT_high_pc)) |high_pc_value| {
690 if (die_obj.getAttrAddr(AT.low_pc)) |low_pc| {
691 if (die_obj.getAttr(AT.high_pc)) |high_pc_value| {
476692 const pc_end = switch (high_pc_value.*) {
477693 FormValue.Address => |value| value,
478694 FormValue.Const => |value| b: {
......@@ -539,11 +755,11 @@ pub const DwarfInfo = struct {
539755 const compile_unit_die = try di.allocator().create(Die);
540756 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
544760 const pc_range = x: {
545 if (compile_unit_die.getAttrAddr(AT_low_pc)) |low_pc| {
546 if (compile_unit_die.getAttr(AT_high_pc)) |high_pc_value| {
761 if (compile_unit_die.getAttrAddr(AT.low_pc)) |low_pc| {
762 if (compile_unit_die.getAttr(AT.high_pc)) |high_pc_value| {
547763 const pc_end = switch (high_pc_value.*) {
548764 FormValue.Address => |value| value,
549765 FormValue.Const => |value| b: {
......@@ -582,16 +798,16 @@ pub const DwarfInfo = struct {
582798 if (target_address >= range.start and target_address < range.end) return compile_unit;
583799 }
584800 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| {
586802 var stream = io.fixedBufferStream(debug_ranges);
587803 const in = &stream.reader();
588804 const seekable = &stream.seekableStream();
589805
590806 // All the addresses in the list are relative to the value
591 // specified by DW_AT_low_pc or to some other value encoded
807 // specified by DW_AT.low_pc or to some other value encoded
592808 // in the list itself.
593809 // 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) {
595811 error.MissingDebugInfo => 0,
596812 else => return err,
597813 };
......@@ -651,7 +867,7 @@ pub const DwarfInfo = struct {
651867 try result.append(AbbrevTableEntry{
652868 .abbrev_code = abbrev_code,
653869 .tag_id = try leb.readULEB128(u64, in),
654 .has_children = (try in.readByte()) == CHILDREN_yes,
870 .has_children = (try in.readByte()) == CHILDREN.yes,
655871 .attrs = ArrayList(AbbrevAttr).init(di.allocator()),
656872 });
657873 const attrs = &result.items[result.items.len - 1].attrs;
......@@ -693,8 +909,8 @@ pub const DwarfInfo = struct {
693909 const in = &stream.reader();
694910 const seekable = &stream.seekableStream();
695911
696 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);
912 const compile_unit_cwd = try compile_unit.die.getAttrString(di, AT.comp_dir);
913 const line_info_offset = try compile_unit.die.getAttrSecOffset(AT.stmt_list);
698914
699915 try seekable.seekTo(line_info_offset);
700916
......@@ -769,21 +985,21 @@ pub const DwarfInfo = struct {
769985 while ((try seekable.getPos()) < next_unit_pos) {
770986 const opcode = try in.readByte();
771987
772 if (opcode == LNS_extended_op) {
988 if (opcode == LNS.extended_op) {
773989 const op_size = try leb.readULEB128(u64, in);
774990 if (op_size < 1) return error.InvalidDebugInfo;
775991 var sub_op = try in.readByte();
776992 switch (sub_op) {
777 LNE_end_sequence => {
993 LNE.end_sequence => {
778994 prog.end_sequence = true;
779995 if (try prog.checkLineMatch()) |info| return info;
780996 prog.reset();
781997 },
782 LNE_set_address => {
998 LNE.set_address => {
783999 const addr = try in.readInt(usize, di.endian);
7841000 prog.address = addr;
7851001 },
786 LNE_define_file => {
1002 LNE.define_file => {
7871003 const file_name = try in.readUntilDelimiterAlloc(di.allocator(), 0, math.maxInt(usize));
7881004 const dir_index = try leb.readULEB128(usize, in);
7891005 const mtime = try leb.readULEB128(usize, in);
......@@ -811,41 +1027,41 @@ pub const DwarfInfo = struct {
8111027 prog.basic_block = false;
8121028 } else {
8131029 switch (opcode) {
814 LNS_copy => {
1030 LNS.copy => {
8151031 if (try prog.checkLineMatch()) |info| return info;
8161032 prog.basic_block = false;
8171033 },
818 LNS_advance_pc => {
1034 LNS.advance_pc => {
8191035 const arg = try leb.readULEB128(usize, in);
8201036 prog.address += arg * minimum_instruction_length;
8211037 },
822 LNS_advance_line => {
1038 LNS.advance_line => {
8231039 const arg = try leb.readILEB128(i64, in);
8241040 prog.line += arg;
8251041 },
826 LNS_set_file => {
1042 LNS.set_file => {
8271043 const arg = try leb.readULEB128(usize, in);
8281044 prog.file = arg;
8291045 },
830 LNS_set_column => {
1046 LNS.set_column => {
8311047 const arg = try leb.readULEB128(u64, in);
8321048 prog.column = arg;
8331049 },
834 LNS_negate_stmt => {
1050 LNS.negate_stmt => {
8351051 prog.is_stmt = !prog.is_stmt;
8361052 },
837 LNS_set_basic_block => {
1053 LNS.set_basic_block => {
8381054 prog.basic_block = true;
8391055 },
840 LNS_const_add_pc => {
1056 LNS.const_add_pc => {
8411057 const inc_addr = minimum_instruction_length * ((255 - opcode_base) / line_range);
8421058 prog.address += inc_addr;
8431059 },
844 LNS_fixed_advance_pc => {
1060 LNS.fixed_advance_pc => {
8451061 const arg = try in.readInt(u16, di.endian);
8461062 prog.address += arg;
8471063 },
848 LNS_set_prologue_end => {},
1064 LNS.set_prologue_end => {},
8491065 else => {
8501066 if (opcode - 1 >= standard_opcode_lengths.len) return error.InvalidDebugInfo;
8511067 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;
44const testing = std.testing;
55const mem = std.mem;
66const Loop = std.event.Loop;
7const Allocator = std.mem.Allocator;
78
89/// Thread-safe async/await lock.
910/// Functions which are waiting for the lock are suspended, and
lib/std/fmt.zig+1-1
......@@ -902,7 +902,7 @@ pub fn formatText(
902902 } else if (comptime std.mem.eql(u8, fmt, "Z")) {
903903 @compileError("specifier 'Z' has been deprecated, wrap your argument in std.zig.fmtEscapes instead");
904904 } else {
905 @compileError("Unsupported format string '" ++ fmt ++ "' for type '" ++ @typeName(@TypeOf(value)) ++ "'");
905 @compileError("Unsupported format string '" ++ fmt ++ "' when formatting text");
906906 }
907907}
908908
lib/std/fs.zig+45-45
......@@ -880,20 +880,20 @@ pub const Dir = struct {
880880 var fdflags: w.fdflags_t = 0x0;
881881 var base: w.rights_t = 0x0;
882882 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;
884884 }
885885 if (flags.write) {
886 fdflags |= w.FDFLAG_APPEND;
887 base |= w.RIGHT_FD_WRITE |
888 w.RIGHT_FD_TELL |
889 w.RIGHT_FD_SEEK |
890 w.RIGHT_FD_DATASYNC |
891 w.RIGHT_FD_FDSTAT_SET_FLAGS |
892 w.RIGHT_FD_SYNC |
893 w.RIGHT_FD_ALLOCATE |
894 w.RIGHT_FD_ADVISE |
895 w.RIGHT_FD_FILESTAT_SET_TIMES |
896 w.RIGHT_FD_FILESTAT_SET_SIZE;
886 fdflags |= w.FDFLAG.APPEND;
887 base |= w.RIGHT.FD_WRITE |
888 w.RIGHT.FD_TELL |
889 w.RIGHT.FD_SEEK |
890 w.RIGHT.FD_DATASYNC |
891 w.RIGHT.FD_FDSTAT_SET_FLAGS |
892 w.RIGHT.FD_SYNC |
893 w.RIGHT.FD_ALLOCATE |
894 w.RIGHT.FD_ADVISE |
895 w.RIGHT.FD_FILESTAT_SET_TIMES |
896 w.RIGHT.FD_FILESTAT_SET_SIZE;
897897 }
898898 const fd = try os.openatWasi(self.fd, sub_path, 0x0, 0x0, fdflags, base, 0x0);
899899 return File{ .handle = fd };
......@@ -958,14 +958,14 @@ pub const Dir = struct {
958958 }
959959
960960 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) {
962962 error.FileBusy => unreachable,
963963 error.Locked => unreachable,
964964 error.PermissionDenied => unreachable,
965965 else => |e| return e,
966966 };
967967 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) {
969969 error.FileBusy => unreachable,
970970 error.Locked => unreachable,
971971 error.PermissionDenied => unreachable,
......@@ -1040,19 +1040,19 @@ pub const Dir = struct {
10401040 pub fn createFileWasi(self: Dir, sub_path: []const u8, flags: File.CreateFlags) File.OpenError!File {
10411041 const w = os.wasi;
10421042 var oflags = w.O.CREAT;
1043 var base: w.rights_t = w.RIGHT_FD_WRITE |
1044 w.RIGHT_FD_DATASYNC |
1045 w.RIGHT_FD_SEEK |
1046 w.RIGHT_FD_TELL |
1047 w.RIGHT_FD_FDSTAT_SET_FLAGS |
1048 w.RIGHT_FD_SYNC |
1049 w.RIGHT_FD_ALLOCATE |
1050 w.RIGHT_FD_ADVISE |
1051 w.RIGHT_FD_FILESTAT_SET_TIMES |
1052 w.RIGHT_FD_FILESTAT_SET_SIZE |
1053 w.RIGHT_FD_FILESTAT_GET;
1043 var base: w.rights_t = w.RIGHT.FD_WRITE |
1044 w.RIGHT.FD_DATASYNC |
1045 w.RIGHT.FD_SEEK |
1046 w.RIGHT.FD_TELL |
1047 w.RIGHT.FD_FDSTAT_SET_FLAGS |
1048 w.RIGHT.FD_SYNC |
1049 w.RIGHT.FD_ALLOCATE |
1050 w.RIGHT.FD_ADVISE |
1051 w.RIGHT.FD_FILESTAT_SET_TIMES |
1052 w.RIGHT.FD_FILESTAT_SET_SIZE |
1053 w.RIGHT.FD_FILESTAT_GET;
10541054 if (flags.read) {
1055 base |= w.RIGHT_FD_READ;
1055 base |= w.RIGHT.FD_READ;
10561056 }
10571057 if (flags.truncate) {
10581058 oflags |= w.O.TRUNC;
......@@ -1112,14 +1112,14 @@ pub const Dir = struct {
11121112 }
11131113
11141114 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) {
11161116 error.FileBusy => unreachable,
11171117 error.Locked => unreachable,
11181118 error.PermissionDenied => unreachable,
11191119 else => |e| return e,
11201120 };
11211121 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) {
11231123 error.FileBusy => unreachable,
11241124 error.Locked => unreachable,
11251125 error.PermissionDenied => unreachable,
......@@ -1402,27 +1402,27 @@ pub const Dir = struct {
14021402 /// Same as `openDir` except only WASI.
14031403 pub fn openDirWasi(self: Dir, sub_path: []const u8, args: OpenDirOptions) OpenError!Dir {
14041404 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;
14061406 if (args.access_sub_paths) {
1407 base |= w.RIGHT_FD_READDIR |
1408 w.RIGHT_PATH_CREATE_DIRECTORY |
1409 w.RIGHT_PATH_CREATE_FILE |
1410 w.RIGHT_PATH_LINK_SOURCE |
1411 w.RIGHT_PATH_LINK_TARGET |
1412 w.RIGHT_PATH_OPEN |
1413 w.RIGHT_PATH_READLINK |
1414 w.RIGHT_PATH_RENAME_SOURCE |
1415 w.RIGHT_PATH_RENAME_TARGET |
1416 w.RIGHT_PATH_FILESTAT_GET |
1417 w.RIGHT_PATH_FILESTAT_SET_SIZE |
1418 w.RIGHT_PATH_FILESTAT_SET_TIMES |
1419 w.RIGHT_PATH_SYMLINK |
1420 w.RIGHT_PATH_REMOVE_DIRECTORY |
1421 w.RIGHT_PATH_UNLINK_FILE;
1407 base |= w.RIGHT.FD_READDIR |
1408 w.RIGHT.PATH_CREATE_DIRECTORY |
1409 w.RIGHT.PATH_CREATE_FILE |
1410 w.RIGHT.PATH_LINK_SOURCE |
1411 w.RIGHT.PATH_LINK_TARGET |
1412 w.RIGHT.PATH_OPEN |
1413 w.RIGHT.PATH_READLINK |
1414 w.RIGHT.PATH_RENAME_SOURCE |
1415 w.RIGHT.PATH_RENAME_TARGET |
1416 w.RIGHT.PATH_FILESTAT_GET |
1417 w.RIGHT.PATH_FILESTAT_SET_SIZE |
1418 w.RIGHT.PATH_FILESTAT_SET_TIMES |
1419 w.RIGHT.PATH_SYMLINK |
1420 w.RIGHT.PATH_REMOVE_DIRECTORY |
1421 w.RIGHT.PATH_UNLINK_FILE;
14221422 }
14231423 const symlink_flags: w.lookupflags_t = if (args.no_follow) 0x0 else w.LOOKUP_SYMLINK_FOLLOW;
14241424 // 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
14271427 const result = os.openatWasi(self.fd, sub_path, symlink_flags, w.O.DIRECTORY, 0x0, base, inheriting);
14281428 const fd = result catch |err| switch (err) {
lib/std/fs/wasi.zig+4-2
......@@ -4,6 +4,8 @@ const mem = std.mem;
44const math = std.math;
55const Allocator = mem.Allocator;
66const wasi = std.os.wasi;
7const fd_t = wasi.fd_t;
8const prestat_t = wasi.prestat_t;
79
810/// Type-tag of WASI preopen.
911///
......@@ -114,7 +116,7 @@ pub const PreopenList = struct {
114116
115117 while (true) {
116118 var buf: prestat_t = undefined;
117 switch (fd_prestat_get(fd, &buf)) {
119 switch (wasi.fd_prestat_get(fd, &buf)) {
118120 .SUCCESS => {},
119121 .OPNOTSUPP => {
120122 // not a preopen, so keep going
......@@ -130,7 +132,7 @@ pub const PreopenList = struct {
130132 const preopen_len = buf.u.dir.pr_name_len;
131133 const path_buf = try self.buffer.allocator.alloc(u8, preopen_len);
132134 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)) {
134136 .SUCCESS => {},
135137 else => |err| return os.unexpectedErrno(err),
136138 }
lib/std/hash_map.zig+6-2
......@@ -622,8 +622,12 @@ pub fn HashMap(
622622 return other.promoteContext(self.allocator, new_ctx);
623623 }
624624
625 /// 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) {
625 /// Creates a copy of this map, using a specified allocator and context.
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) {
627631 var other = try self.unmanaged.cloneContext(new_allocator, new_ctx);
628632 return other.promoteContext(new_allocator, new_ctx);
629633 }
lib/std/heap.zig+4-4
......@@ -88,12 +88,12 @@ const CAllocator = struct {
8888
8989 fn alignedAllocSize(ptr: [*]u8) usize {
9090 if (supports_posix_memalign) {
91 return malloc_size(ptr);
91 return CAllocator.malloc_size(ptr);
9292 }
9393
9494 const unaligned_ptr = getHeader(ptr).*;
9595 const delta = @ptrToInt(ptr) - @ptrToInt(unaligned_ptr);
96 return malloc_size(unaligned_ptr) - delta;
96 return CAllocator.malloc_size(unaligned_ptr) - delta;
9797 }
9898
9999 fn alloc(
......@@ -113,7 +113,7 @@ const CAllocator = struct {
113113 return ptr[0..len];
114114 }
115115 const full_len = init: {
116 if (supports_malloc_size) {
116 if (CAllocator.supports_malloc_size) {
117117 const s = alignedAllocSize(ptr);
118118 assert(s >= len);
119119 break :init s;
......@@ -141,7 +141,7 @@ const CAllocator = struct {
141141 if (new_len <= buf.len) {
142142 return mem.alignAllocLen(buf.len, new_len, len_align);
143143 }
144 if (supports_malloc_size) {
144 if (CAllocator.supports_malloc_size) {
145145 const full_len = alignedAllocSize(buf.ptr);
146146 if (new_len <= full_len) {
147147 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");
22const builtin = std.builtin;
33const io = std.io;
44const testing = std.testing;
5const os = std.os;
56
67pub 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 {
14051405 if (a == null or b == null) return false;
14061406 return parsedEqual(a.?, b.?);
14071407 },
1408 .Union => {
1408 .Union => |info| {
14091409 if (info.tag_type) |UnionTag| {
14101410 const tag_a = std.meta.activeTag(a);
14111411 const tag_b = std.meta.activeTag(b);
lib/std/math/big/int.zig+1-2
......@@ -672,10 +672,9 @@ pub const Mutable = struct {
672672 ///
673673 /// `limbs_buffer` is used for temporary storage during the operation.
674674 pub fn gcdNoAlias(rma: *Mutable, x: Const, y: Const, limbs_buffer: *std.ArrayList(Limb)) !void {
675 _ = limbs_buffer;
676675 assert(rma.limbs.ptr != x.limbs.ptr); // illegal aliasing
677676 assert(rma.limbs.ptr != y.limbs.ptr); // illegal aliasing
678 return gcdLehmer(rma, x, y, allocator);
677 return gcdLehmer(rma, x, y, limbs_buffer);
679678 }
680679
681680 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;
7878pub const IFNAMESIZE = system.IFNAMESIZE;
7979pub const IOV_MAX = system.IOV_MAX;
8080pub const IPPROTO = system.IPPROTO;
81pub const Kevent = system.Kevent;
8182pub const LOCK = system.LOCK;
8283pub const MADV = system.MADV;
8384pub const MAP = system.MAP;
......@@ -89,8 +90,10 @@ pub const O = system.O;
8990pub const PATH_MAX = system.PATH_MAX;
9091pub const POLL = system.POLL;
9192pub const POSIX_FADV = system.POSIX_FADV;
93pub const PR = system.PR;
9294pub const PROT = system.PROT;
9395pub const REG = system.REG;
96pub const RIGHT = system.RIGHT;
9497pub const RLIM = system.RLIM;
9598pub const RR = system.RR;
9699pub const R_OK = system.R_OK;
......@@ -110,6 +113,7 @@ pub const STDOUT_FILENO = system.STDOUT_FILENO;
110113pub const SYS = system.SYS;
111114pub const Sigaction = system.Sigaction;
112115pub const Stat = system.Stat;
116pub const TCSA = system.TCSA;
113117pub const VDSO = system.VDSO;
114118pub const W = system.W;
115119pub const W_OK = system.W_OK;
......@@ -123,9 +127,12 @@ pub const dev_t = system.dev_t;
123127pub const dl_phdr_info = system.dl_phdr_info;
124128pub const empty_sigset = system.empty_sigset;
125129pub const fd_t = system.fd_t;
130pub const fdflags_t = system.fdflags_t;
131pub const fdstat_t = system.fdstat_t;
126132pub const gid_t = system.gid_t;
127133pub const ifreq = system.ifreq;
128134pub const ino_t = system.ino_t;
135pub const lookupflags_t = system.lookupflags_t;
129136pub const mcontext_t = system.mcontext_t;
130137pub const mode_t = system.mode_t;
131138pub const msghdr = system.msghdr;
......@@ -133,19 +140,24 @@ pub const msghdr_const = system.msghdr_const;
133140pub const nfds_t = system.nfds_t;
134141pub const nlink_t = system.nlink_t;
135142pub const off_t = system.off_t;
143pub const oflags_t = system.oflags_t;
136144pub const pid_t = system.pid_t;
137145pub const pollfd = system.pollfd;
146pub const rights_t = system.rights_t;
138147pub const rlim_t = system.rlim_t;
139148pub const rlimit = system.rlimit;
140149pub const rlimit_resource = system.rlimit_resource;
150pub const rusage = system.rusage;
141151pub const sa_family_t = system.sa_family_t;
142152pub const siginfo_t = system.siginfo_t;
143153pub const sigset_t = system.sigset_t;
144154pub const sockaddr = system.sockaddr;
145155pub const socklen_t = system.socklen_t;
146156pub const stack_t = system.stack_t;
157pub const termios = system.termios;
147158pub const time_t = system.time_t;
148159pub const timespec = system.timespec;
160pub const timestamp_t = system.timestamp_t;
149161pub const timeval = system.timeval;
150162pub const timezone = system.timezone;
151163pub const ucontext_t = system.ucontext_t;
......@@ -2770,8 +2782,8 @@ pub fn isatty(handle: fd_t) bool {
27702782 }
27712783
27722784 // A tty is a character device that we can't seek or tell on.
2773 if (statbuf.fs_filetype != FILETYPE_CHARACTER_DEVICE or
2774 (statbuf.fs_rights_base & (RIGHT_FD_SEEK | RIGHT_FD_TELL)) != 0)
2785 if (statbuf.fs_filetype != .CHARACTER_DEVICE or
2786 (statbuf.fs_rights_base & (RIGHT.FD_SEEK | RIGHT.FD_TELL)) != 0)
27752787 {
27762788 // errno = ENOTTY;
27772789 return false;
......@@ -3933,7 +3945,7 @@ pub const AccessError = error{
39333945} || UnexpectedError;
39343946
39353947/// 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.
39373949pub fn access(path: []const u8, mode: u32) AccessError!void {
39383950 if (builtin.os.tag == .windows) {
39393951 const path_w = try windows.sliceToPrefixedFileW(path);
......@@ -4104,10 +4116,10 @@ pub fn pipe2(flags: u32) PipeError![2]fd_t {
41044116 return fds;
41054117
41064118 // O.CLOEXEC is special, it's a file descriptor flag and must be set using
4107 // F_SETFD.
4119 // F.SETFD.
41084120 if (flags & O.CLOEXEC != 0) {
41094121 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)))) {
41114123 .SUCCESS => {},
41124124 .INVAL => unreachable, // Invalid flags
41134125 .BADF => unreachable, // Always a race condition
......@@ -4117,10 +4129,10 @@ pub fn pipe2(flags: u32) PipeError![2]fd_t {
41174129 }
41184130
41194131 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.
41214133 if (new_flags != 0) {
41224134 for (fds) |fd| {
4123 switch (errno(system.fcntl(fd, F_SETFL, new_flags))) {
4135 switch (errno(system.fcntl(fd, F.SETFL, new_flags))) {
41244136 .SUCCESS => {},
41254137 .INVAL => unreachable, // Invalid flags
41264138 .BADF => unreachable, // Always a race condition
......@@ -4425,14 +4437,14 @@ fn setSockFlags(sock: socket_t, flags: u32) !void {
44254437 if (builtin.os.tag == .windows) {
44264438 // TODO: Find out if this is supported for sockets
44274439 } 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) {
44294441 error.FileBusy => unreachable,
44304442 error.Locked => unreachable,
44314443 error.PermissionDenied => unreachable,
44324444 else => |e| return e,
44334445 };
44344446 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) {
44364448 error.FileBusy => unreachable,
44374449 error.Locked => unreachable,
44384450 error.PermissionDenied => unreachable,
......@@ -4453,14 +4465,14 @@ fn setSockFlags(sock: socket_t, flags: u32) !void {
44534465 }
44544466 }
44554467 } 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) {
44574469 error.FileBusy => unreachable,
44584470 error.Locked => unreachable,
44594471 error.PermissionDenied => unreachable,
44604472 else => |e| return e,
44614473 };
44624474 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) {
44644476 error.FileBusy => unreachable,
44654477 error.Locked => unreachable,
44664478 error.PermissionDenied => unreachable,
......@@ -4625,14 +4637,14 @@ pub fn getFdPath(fd: fd_t, out_buffer: *[MAX_PATH_BYTES]u8) RealPathError![]u8 {
46254637 return out_buffer[0..end_index];
46264638 },
46274639 .macos, .ios, .watchos, .tvos => {
4628 // On macOS, we can use F_GETPATH fcntl command to query the OS for
4640 // On macOS, we can use F.GETPATH fcntl command to query the OS for
46294641 // the path to the file descriptor.
46304642 @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))) {
46324644 .SUCCESS => {},
46334645 .BADF => return error.FileNotFound,
46344646 // 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...
46364648 else => |err| return unexpectedErrno(err),
46374649 }
46384650 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;
5050pub const syscall4 = syscall_bits.syscall4;
5151pub const syscall5 = syscall_bits.syscall5;
5252pub const syscall6 = syscall_bits.syscall6;
53pub const syscall7 = syscall_bits.syscall7;
5354pub const restore = syscall_bits.restore;
5455pub 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
5660pub const clone = arch_bits.clone;
5761pub const ARCH = arch_bits.ARCH;
......@@ -181,7 +185,7 @@ pub fn dup2(old: i32, new: i32) usize {
181185 } else {
182186 if (old == new) {
183187 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);
185189 if (@bitCast(isize, rc) < 0) return rc;
186190 }
187191 return @intCast(usize, old);
......@@ -217,7 +221,7 @@ pub fn fork() usize {
217221 } else if (@hasField(SYS, "fork")) {
218222 return syscall0(.fork);
219223 } else {
220 return syscall2(.clone, SIGCHLD, 0);
224 return syscall2(.clone, SIG.CHLD, 0);
221225 }
222226}
223227
......@@ -821,7 +825,7 @@ var vdso_clock_gettime = @ptrCast(?*const c_void, init_vdso_clock_gettime);
821825const vdso_clock_gettime_ty = fn (i32, *timespec) callconv(.C) usize;
822826
823827pub fn clock_gettime(clk_id: i32, tp: *timespec) usize {
824 if (@hasDecl(@This(), "VDSO_CGT_SYM")) {
828 if (@hasDecl(VDSO, "CGT_SYM")) {
825829 const ptr = @atomicLoad(?*const c_void, &vdso_clock_gettime, .Unordered);
826830 if (ptr) |fn_ptr| {
827831 const f = @ptrCast(vdso_clock_gettime_ty, fn_ptr);
......@@ -836,7 +840,7 @@ pub fn clock_gettime(clk_id: i32, tp: *timespec) usize {
836840}
837841
838842fn 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));
840844 // Note that we may not have a VDSO at all, update the stub address anyway
841845 // so that clock_gettime will fall back on the good old (and slow) syscall
842846 @atomicStore(?*const c_void, &vdso_clock_gettime, ptr, .Monotonic);
......@@ -1070,42 +1074,42 @@ pub fn sigismember(set: *const sigset_t, sig: u6) bool {
10701074
10711075pub fn getsockname(fd: i32, noalias addr: *sockaddr, noalias len: *socklen_t) usize {
10721076 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) });
10741078 }
10751079 return syscall3(.getsockname, @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len));
10761080}
10771081
10781082pub fn getpeername(fd: i32, noalias addr: *sockaddr, noalias len: *socklen_t) usize {
10791083 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) });
10811085 }
10821086 return syscall3(.getpeername, @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len));
10831087}
10841088
10851089pub fn socket(domain: u32, socket_type: u32, protocol: u32) usize {
10861090 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 });
10881092 }
10891093 return syscall3(.socket, domain, socket_type, protocol);
10901094}
10911095
10921096pub fn setsockopt(fd: i32, level: u32, optname: u32, optval: [*]const u8, optlen: socklen_t) usize {
10931097 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) });
10951099 }
10961100 return syscall5(.setsockopt, @bitCast(usize, @as(isize, fd)), level, optname, @ptrToInt(optval), @intCast(usize, optlen));
10971101}
10981102
10991103pub fn getsockopt(fd: i32, level: u32, optname: u32, noalias optval: [*]u8, noalias optlen: *socklen_t) usize {
11001104 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) });
11021106 }
11031107 return syscall5(.getsockopt, @bitCast(usize, @as(isize, fd)), level, optname, @ptrToInt(optval), @ptrToInt(optlen));
11041108}
11051109
11061110pub fn sendmsg(fd: i32, msg: *const std.x.os.Socket.Message, flags: c_int) usize {
11071111 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)) });
11091113 }
11101114 return syscall3(.sendmsg, @bitCast(usize, @as(isize, fd)), @ptrToInt(msg), @bitCast(usize, @as(isize, flags)));
11111115}
......@@ -1152,49 +1156,49 @@ pub fn sendmmsg(fd: i32, msgvec: [*]mmsghdr_const, vlen: u32, flags: u32) usize
11521156
11531157pub fn connect(fd: i32, addr: *const c_void, len: socklen_t) usize {
11541158 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 });
11561160 }
11571161 return syscall3(.connect, @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), len);
11581162}
11591163
11601164pub fn recvmsg(fd: i32, msg: *std.x.os.Socket.Message, flags: c_int) usize {
11611165 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)) });
11631167 }
11641168 return syscall3(.recvmsg, @bitCast(usize, @as(isize, fd)), @ptrToInt(msg), @bitCast(usize, @as(isize, flags)));
11651169}
11661170
11671171pub fn recvfrom(fd: i32, noalias buf: [*]u8, len: usize, flags: u32, noalias addr: ?*sockaddr, noalias alen: ?*socklen_t) usize {
11681172 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) });
11701174 }
11711175 return syscall6(.recvfrom, @bitCast(usize, @as(isize, fd)), @ptrToInt(buf), len, flags, @ptrToInt(addr), @ptrToInt(alen));
11721176}
11731177
11741178pub fn shutdown(fd: i32, how: i32) usize {
11751179 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)) });
11771181 }
11781182 return syscall2(.shutdown, @bitCast(usize, @as(isize, fd)), @bitCast(usize, @as(isize, how)));
11791183}
11801184
11811185pub fn bind(fd: i32, addr: *const sockaddr, len: socklen_t) usize {
11821186 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) });
11841188 }
11851189 return syscall3(.bind, @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @intCast(usize, len));
11861190}
11871191
11881192pub fn listen(fd: i32, backlog: u32) usize {
11891193 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 });
11911195 }
11921196 return syscall2(.listen, @bitCast(usize, @as(isize, fd)), backlog);
11931197}
11941198
11951199pub fn sendto(fd: i32, buf: [*]const u8, len: usize, flags: u32, addr: ?*const sockaddr, alen: socklen_t) usize {
11961200 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) });
11981202 }
11991203 return syscall6(.sendto, @bitCast(usize, @as(isize, fd)), @ptrToInt(buf), len, flags, @ptrToInt(addr), @intCast(usize, alen));
12001204}
......@@ -1221,21 +1225,21 @@ pub fn sendfile(outfd: i32, infd: i32, offset: ?*i64, count: usize) usize {
12211225
12221226pub fn socketpair(domain: i32, socket_type: i32, protocol: i32, fd: [2]i32) usize {
12231227 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]) });
12251229 }
12261230 return syscall4(.socketpair, @intCast(usize, domain), @intCast(usize, socket_type), @intCast(usize, protocol), @ptrToInt(&fd[0]));
12271231}
12281232
12291233pub fn accept(fd: i32, noalias addr: ?*sockaddr, noalias len: ?*socklen_t) usize {
12301234 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 });
12321236 }
12331237 return accept4(fd, addr, len, 0);
12341238}
12351239
12361240pub fn accept4(fd: i32, noalias addr: ?*sockaddr, noalias len: ?*socklen_t, flags: u32) usize {
12371241 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 });
12391243 }
12401244 return syscall4(.accept4, @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len), flags);
12411245}
......@@ -1435,11 +1439,11 @@ pub fn getrusage(who: i32, usage: *rusage) usize {
14351439}
14361440
14371441pub 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));
14391443}
14401444
14411445pub 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));
14431447}
14441448
14451449pub fn ioctl(fd: fd_t, request: u32, arg: usize) usize {
......@@ -1900,7 +1904,7 @@ pub const SIG = if (is_mips) struct {
19001904 pub const IOT = ABRT;
19011905 pub const CLD = CHLD;
19021906 pub const PWR = LOST;
1903 pub const IO = POLL;
1907 pub const IO = SIG.POLL;
19041908
19051909 pub const ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize));
19061910 pub const DFL = @intToPtr(?Sigaction.sigaction_fn, 0);
......@@ -1996,8 +2000,8 @@ pub const SOCK = struct {
19962000pub const PF = struct {
19972001 pub const UNSPEC = 0;
19982002 pub const LOCAL = 1;
1999 pub const UNIX = PF_LOCAL;
2000 pub const FILE = PF_LOCAL;
2003 pub const UNIX = LOCAL;
2004 pub const FILE = LOCAL;
20012005 pub const INET = 2;
20022006 pub const AX25 = 3;
20032007 pub const IPX = 4;
......@@ -2013,7 +2017,7 @@ pub const PF = struct {
20132017 pub const SECURITY = 14;
20142018 pub const KEY = 15;
20152019 pub const NETLINK = 16;
2016 pub const ROUTE = PF_NETLINK;
2020 pub const ROUTE = PF.NETLINK;
20172021 pub const PACKET = 17;
20182022 pub const ASH = 18;
20192023 pub const ECONET = 19;
......@@ -2357,7 +2361,7 @@ pub const IP = struct {
23572361 pub const PASSSEC = 18;
23582362 pub const TRANSPARENT = 19;
23592363 pub const ORIGDSTADDR = 20;
2360 pub const RECVORIGDSTADDR = IP_ORIGDSTADDR;
2364 pub const RECVORIGDSTADDR = IP.ORIGDSTADDR;
23612365 pub const MINTTL = 21;
23622366 pub const NODEFRAG = 22;
23632367 pub const CHECKSUM = 23;
......@@ -2376,7 +2380,7 @@ pub const IP = struct {
23762380 pub const MULTICAST_ALL = 49;
23772381 pub const UNICAST_IF = 50;
23782382
2379 pub const RECVRETOPTS = IP_RETOPTS;
2383 pub const RECVRETOPTS = IP.RETOPTS;
23802384
23812385 pub const PMTUDISC_DONT = 0;
23822386 pub const PMTUDISC_WANT = 1;
......@@ -2418,7 +2422,7 @@ pub const IPV6 = struct {
24182422 pub const JOIN_ANYCAST = 27;
24192423 pub const LEAVE_ANYCAST = 28;
24202424
2421 // IPV6_MTU_DISCOVER values
2425 // IPV6.MTU_DISCOVER values
24222426 pub const PMTUDISC_DONT = 0;
24232427 pub const PMTUDISC_WANT = 1;
24242428 pub const PMTUDISC_DO = 2;
......@@ -2470,7 +2474,7 @@ pub const IPV6 = struct {
24702474 pub const MINHOPCOUNT = 73;
24712475
24722476 pub const ORIGDSTADDR = 74;
2473 pub const RECVORIGDSTADDR = IPV6_ORIGDSTADDR;
2477 pub const RECVORIGDSTADDR = IPV6.ORIGDSTADDR;
24742478 pub const TRANSPARENT = 75;
24752479 pub const UNICAST_IF = 76;
24762480 pub const RECVFRAGSIZE = 77;
......@@ -3924,8 +3928,8 @@ pub const V = switch (native_arch) {
39243928 pub const DISCARD = 13;
39253929 pub const WERASE = 14;
39263930 pub const LNEXT = 15;
3927 pub const MIN = VEOF;
3928 pub const TIME = VEOL;
3931 pub const MIN = EOF;
3932 pub const TIME = EOL;
39293933 },
39303934 .mips, .mipsel, .mips64, .mips64el => struct {
39313935 pub const INTR = 0;
lib/std/os/linux/arm-eabi.zig+25-23
......@@ -551,29 +551,31 @@ pub const O_PATH = 0o10000000;
551551pub const O_TMPFILE = 0o20040000;
552552pub const O_NDELAY = O_NONBLOCK;
553553
554pub const F_DUPFD = 0;
555pub const F_GETFD = 1;
556pub const F_SETFD = 2;
557pub const F_GETFL = 3;
558pub const F_SETFL = 4;
559
560pub const F_SETOWN = 8;
561pub const F_GETOWN = 9;
562pub const F_SETSIG = 10;
563pub const F_GETSIG = 11;
564
565pub const F_GETLK = 12;
566pub const F_SETLK = 13;
567pub const F_SETLKW = 14;
568
569pub const F_RDLCK = 0;
570pub const F_WRLCK = 1;
571pub const F_UNLCK = 2;
572
573pub const F_SETOWN_EX = 15;
574pub const F_GETOWN_EX = 16;
575
576pub const F_GETOWNER_UIDS = 17;
554pub const F = struct {
555 pub const DUPFD = 0;
556 pub const GETFD = 1;
557 pub const SETFD = 2;
558 pub const GETFL = 3;
559 pub const SETFL = 4;
560
561 pub const SETOWN = 8;
562 pub const GETOWN = 9;
563 pub const SETSIG = 10;
564 pub const GETSIG = 11;
565
566 pub const GETLK = 12;
567 pub const SETLK = 13;
568 pub const SETLKW = 14;
569
570 pub const RDLCK = 0;
571 pub const WRLCK = 1;
572 pub const UNLCK = 2;
573
574 pub const SETOWN_EX = 15;
575 pub const GETOWN_EX = 16;
576
577 pub const GETOWNER_UIDS = 17;
578};
577579
578580pub const LOCK = struct {
579581 pub const SH = 1;
lib/std/os/linux/arm64.zig+25-23
......@@ -430,24 +430,31 @@ pub const O_PATH = 0o10000000;
430430pub const O_TMPFILE = 0o20040000;
431431pub const O_NDELAY = O_NONBLOCK;
432432
433pub const F_DUPFD = 0;
434pub const F_GETFD = 1;
435pub const F_SETFD = 2;
436pub const F_GETFL = 3;
437pub const F_SETFL = 4;
438
439pub const F_SETOWN = 8;
440pub const F_GETOWN = 9;
441pub const F_SETSIG = 10;
442pub const F_GETSIG = 11;
443
444pub const F_GETLK = 5;
445pub const F_SETLK = 6;
446pub const F_SETLKW = 7;
447
448pub const F_RDLCK = 0;
449pub const F_WRLCK = 1;
450pub const F_UNLCK = 2;
433pub const F = struct {
434 pub const DUPFD = 0;
435 pub const GETFD = 1;
436 pub const SETFD = 2;
437 pub const GETFL = 3;
438 pub const SETFL = 4;
439
440 pub const SETOWN = 8;
441 pub const GETOWN = 9;
442 pub const SETSIG = 10;
443 pub const GETSIG = 11;
444
445 pub const GETLK = 5;
446 pub const SETLK = 6;
447 pub const SETLKW = 7;
448
449 pub const RDLCK = 0;
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
452459pub const LOCK = struct {
453460 pub const SH = 1;
......@@ -456,11 +463,6 @@ pub const LOCK = struct {
456463 pub const NB = 4;
457464};
458465
459pub const F_SETOWN_EX = 15;
460pub const F_GETOWN_EX = 16;
461
462pub const F_GETOWNER_UIDS = 17;
463
464466pub const MAP = struct {
465467 /// stack-like segment
466468 pub const GROWSDOWN = 0x0100;
lib/std/os/linux/io_uring.zig+3-3
......@@ -1297,12 +1297,12 @@ test "openat" {
12971297
12981298 const flags: u32 = os.O_CLOEXEC | os.O_RDWR | os.O_CREAT;
12991299 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);
13011301 try testing.expectEqual(io_uring_sqe{
13021302 .opcode = .OPENAT,
13031303 .flags = 0,
13041304 .ioprio = 0,
1305 .fd = linux.AT_FDCWD,
1305 .fd = linux.AT.FDCWD,
13061306 .off = 0,
13071307 .addr = @ptrToInt(path),
13081308 .len = mode,
......@@ -1318,7 +1318,7 @@ test "openat" {
13181318 const cqe_openat = try ring.copy_cqe();
13191319 try testing.expectEqual(@as(u64, 0x33333333), cqe_openat.user_data);
13201320 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:
13221322 // See https://lore.kernel.org/io-uring/20200207155039.12819-1-axboe@kernel.dk/T/
13231323 // We use IORING_FEAT_RW_CUR_POS to know if we are pre-5.6 since that feature was added in 5.6.
13241324 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;
649649pub const O_TMPFILE = 0o020200000;
650650pub const O_NDELAY = O_NONBLOCK;
651651
652pub const F_DUPFD = 0;
653pub const F_GETFD = 1;
654pub const F_SETFD = 2;
655pub const F_GETFL = 3;
656pub const F_SETFL = 4;
657
658pub const F_SETOWN = 24;
659pub const F_GETOWN = 23;
660pub const F_SETSIG = 10;
661pub const F_GETSIG = 11;
662
663pub const F_GETLK = 33;
664pub const F_SETLK = 34;
665pub const F_SETLKW = 35;
666
667pub const F_RDLCK = 0;
668pub const F_WRLCK = 1;
669pub const F_UNLCK = 2;
652pub const F = struct {
653 pub const DUPFD = 0;
654 pub const GETFD = 1;
655 pub const SETFD = 2;
656 pub const GETFL = 3;
657 pub const SETFL = 4;
658
659 pub const SETOWN = 24;
660 pub const GETOWN = 23;
661 pub const SETSIG = 10;
662 pub const GETSIG = 11;
663
664 pub const GETLK = 33;
665 pub const SETLK = 34;
666 pub const SETLKW = 35;
667
668 pub const RDLCK = 0;
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
671678pub const LOCK = struct {
672679 pub const SH = 1;
......@@ -675,11 +682,6 @@ pub const LOCK = struct {
675682 pub const NB = 4;
676683};
677684
678pub const F_SETOWN_EX = 15;
679pub const F_GETOWN_EX = 16;
680
681pub const F_GETOWNER_UIDS = 17;
682
683685pub const MMAP2_UNIT = 4096;
684686
685687pub const MAP = struct {
lib/std/os/linux/powerpc.zig+25-23
......@@ -581,29 +581,31 @@ pub const O_PATH = 0o10000000;
581581pub const O_TMPFILE = 0o20040000;
582582pub const O_NDELAY = O_NONBLOCK;
583583
584pub const F_DUPFD = 0;
585pub const F_GETFD = 1;
586pub const F_SETFD = 2;
587pub const F_GETFL = 3;
588pub const F_SETFL = 4;
589
590pub const F_SETOWN = 8;
591pub const F_GETOWN = 9;
592pub const F_SETSIG = 10;
593pub const F_GETSIG = 11;
594
595pub const F_GETLK = 12;
596pub const F_SETLK = 13;
597pub const F_SETLKW = 14;
598
599pub const F_SETOWN_EX = 15;
600pub const F_GETOWN_EX = 16;
601
602pub const F_GETOWNER_UIDS = 17;
603
604pub const F_RDLCK = 0;
605pub const F_WRLCK = 1;
606pub const F_UNLCK = 2;
584pub const F = struct {
585 pub const DUPFD = 0;
586 pub const GETFD = 1;
587 pub const SETFD = 2;
588 pub const GETFL = 3;
589 pub const SETFL = 4;
590
591 pub const SETOWN = 8;
592 pub const GETOWN = 9;
593 pub const SETSIG = 10;
594 pub const GETSIG = 11;
595
596 pub const GETLK = 12;
597 pub const SETLK = 13;
598 pub const SETLKW = 14;
599
600 pub const SETOWN_EX = 15;
601 pub const GETOWN_EX = 16;
602
603 pub const GETOWNER_UIDS = 17;
604
605 pub const RDLCK = 0;
606 pub const WRLCK = 1;
607 pub const UNLCK = 2;
608};
607609
608610pub const LOCK = struct {
609611 pub const SH = 1;
lib/std/os/linux/powerpc64.zig+25-23
......@@ -556,24 +556,31 @@ pub const O_PATH = 0o10000000;
556556pub const O_TMPFILE = 0o20200000;
557557pub const O_NDELAY = O_NONBLOCK;
558558
559pub const F_DUPFD = 0;
560pub const F_GETFD = 1;
561pub const F_SETFD = 2;
562pub const F_GETFL = 3;
563pub const F_SETFL = 4;
564
565pub const F_SETOWN = 8;
566pub const F_GETOWN = 9;
567pub const F_SETSIG = 10;
568pub const F_GETSIG = 11;
569
570pub const F_GETLK = 5;
571pub const F_SETLK = 6;
572pub const F_SETLKW = 7;
573
574pub const F_RDLCK = 0;
575pub const F_WRLCK = 1;
576pub const F_UNLCK = 2;
559pub const F = struct {
560 pub const DUPFD = 0;
561 pub const GETFD = 1;
562 pub const SETFD = 2;
563 pub const GETFL = 3;
564 pub const SETFL = 4;
565
566 pub const SETOWN = 8;
567 pub const GETOWN = 9;
568 pub const SETSIG = 10;
569 pub const GETSIG = 11;
570
571 pub const GETLK = 5;
572 pub const SETLK = 6;
573 pub const SETLKW = 7;
574
575 pub const RDLCK = 0;
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
578585pub const LOCK = struct {
579586 pub const SH = 1;
......@@ -582,11 +589,6 @@ pub const LOCK = struct {
582589 pub const NB = 4;
583590};
584591
585pub const F_SETOWN_EX = 15;
586pub const F_GETOWN_EX = 16;
587
588pub const F_GETOWNER_UIDS = 17;
589
590592pub const MAP = struct {
591593 /// stack-like segment
592594 pub const GROWSDOWN = 0x0100;
lib/std/os/linux/riscv64.zig+22-20
......@@ -427,22 +427,29 @@ pub const O_PATH = 0o10000000;
427427pub const O_TMPFILE = 0o20200000;
428428pub const O_NDELAY = O_NONBLOCK;
429429
430pub const F_DUPFD = 0;
431pub const F_GETFD = 1;
432pub const F_SETFD = 2;
433pub const F_GETFL = 3;
434pub const F_SETFL = 4;
435pub const F_GETLK = 5;
436pub const F_SETLK = 6;
437pub const F_SETLKW = 7;
438pub const F_SETOWN = 8;
439pub const F_GETOWN = 9;
440pub const F_SETSIG = 10;
441pub const F_GETSIG = 11;
430pub const F = struct {
431 pub const DUPFD = 0;
432 pub const GETFD = 1;
433 pub const SETFD = 2;
434 pub const GETFL = 3;
435 pub const SETFL = 4;
436 pub const GETLK = 5;
437 pub const SETLK = 6;
438 pub const SETLKW = 7;
439 pub const SETOWN = 8;
440 pub const GETOWN = 9;
441 pub const SETSIG = 10;
442 pub const GETSIG = 11;
442443
443pub const F_RDLCK = 0;
444pub const F_WRLCK = 1;
445pub const F_UNLCK = 2;
444 pub const RDLCK = 0;
445 pub const WRLCK = 1;
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
447454pub const LOCK = struct {
448455 pub const SH = 1;
......@@ -451,11 +458,6 @@ pub const LOCK = struct {
451458 pub const NB = 4;
452459};
453460
454pub const F_SETOWN_EX = 15;
455pub const F_GETOWN_EX = 16;
456
457pub const F_GETOWNER_UIDS = 17;
458
459461pub const blksize_t = i32;
460462pub const nlink_t = u32;
461463pub const time_t = isize;
lib/std/os/linux/sparc64.zig+22-20
......@@ -591,26 +591,28 @@ pub const O_PATH = 0x1000000;
591591pub const O_TMPFILE = 0x2010000;
592592pub const O_NDELAY = O_NONBLOCK | 0x4;
593593
594pub const F_DUPFD = 0;
595pub const F_GETFD = 1;
596pub const F_SETFD = 2;
597pub const F_GETFL = 3;
598pub const F_SETFL = 4;
599
600pub const F_SETOWN = 5;
601pub const F_GETOWN = 6;
602pub const F_GETLK = 7;
603pub const F_SETLK = 8;
604pub const F_SETLKW = 9;
605
606pub const F_RDLCK = 1;
607pub const F_WRLCK = 2;
608pub const F_UNLCK = 3;
609
610pub const F_SETOWN_EX = 15;
611pub const F_GETOWN_EX = 16;
612
613pub const F_GETOWNER_UIDS = 17;
594pub const F = struct {
595 pub const DUPFD = 0;
596 pub const GETFD = 1;
597 pub const SETFD = 2;
598 pub const GETFL = 3;
599 pub const SETFL = 4;
600
601 pub const SETOWN = 5;
602 pub const GETOWN = 6;
603 pub const GETLK = 7;
604 pub const SETLK = 8;
605 pub const SETLKW = 9;
606
607 pub const RDLCK = 1;
608 pub const WRLCK = 2;
609 pub const UNLCK = 3;
610
611 pub const SETOWN_EX = 15;
612 pub const GETOWN_EX = 16;
613
614 pub const GETOWNER_UIDS = 17;
615};
614616
615617pub const LOCK = struct {
616618 pub const SH = 1;
lib/std/os/linux/thumb.zig+3
......@@ -3,6 +3,9 @@
33//! reserved for the frame pointer.
44//! Save and restore r7 around the syscall without touching the stack pointer not
55//! to break the frame chain.
6const std = @import("../../std.zig");
7const linux = std.os.linux;
8const SYS = linux.SYS;
69
710pub fn syscall0(number: SYS) usize {
811 @setRuntimeSafety(false);
lib/std/os/wasi.zig+96-93
......@@ -149,8 +149,10 @@ pub const Stat = struct {
149149
150150pub const IOV_MAX = 1024;
151151
152pub const AT_REMOVEDIR: u32 = 0x4;
153pub const AT_FDCWD: fd_t = -2;
152pub const AT = struct {
153 pub const REMOVEDIR: u32 = 0x4;
154 pub const FDCWD: fd_t = -2;
155};
154156
155157// As defined in the wasi_snapshot_preview1 spec file:
156158// https://github.com/WebAssembly/WASI/blob/master/phases/snapshot/witx/typenames.witx
......@@ -293,11 +295,13 @@ pub const exitcode_t = u32;
293295pub const fd_t = u32;
294296
295297pub const fdflags_t = u16;
296pub const FDFLAG_APPEND: fdflags_t = 0x0001;
297pub const FDFLAG_DSYNC: fdflags_t = 0x0002;
298pub const FDFLAG_NONBLOCK: fdflags_t = 0x0004;
299pub const FDFLAG_RSYNC: fdflags_t = 0x0008;
300pub const FDFLAG_SYNC: fdflags_t = 0x0010;
298pub const FDFLAG = struct {
299 pub const APPEND: fdflags_t = 0x0001;
300 pub const DSYNC: fdflags_t = 0x0002;
301 pub const NONBLOCK: fdflags_t = 0x0004;
302 pub const RSYNC: fdflags_t = 0x0008;
303 pub const SYNC: fdflags_t = 0x0010;
304};
301305
302306pub const fdstat_t = extern struct {
303307 fs_filetype: filetype_t,
......@@ -333,15 +337,17 @@ pub const filestat_t = extern struct {
333337 }
334338};
335339
336pub const filetype_t = u8;
337pub const FILETYPE_UNKNOWN: filetype_t = 0;
338pub const FILETYPE_BLOCK_DEVICE: filetype_t = 1;
339pub const FILETYPE_CHARACTER_DEVICE: filetype_t = 2;
340pub const FILETYPE_DIRECTORY: filetype_t = 3;
341pub const FILETYPE_REGULAR_FILE: filetype_t = 4;
342pub const FILETYPE_SOCKET_DGRAM: filetype_t = 5;
343pub const FILETYPE_SOCKET_STREAM: filetype_t = 6;
344pub const FILETYPE_SYMBOLIC_LINK: filetype_t = 7;
340pub const filetype_t = enum(u8) {
341 UNKNOWN,
342 BLOCK_DEVICE,
343 CHARACTER_DEVICE,
344 DIRECTORY,
345 REGULAR_FILE,
346 SOCKET_DGRAM,
347 SOCKET_STREAM,
348 SYMBOLIC_LINK,
349 _,
350};
345351
346352pub const fstflags_t = u16;
347353pub const FILESTAT_SET_ATIM: fstflags_t = 0x0001;
......@@ -392,64 +398,66 @@ pub const SOCK = struct {
392398};
393399
394400pub const rights_t = u64;
395pub const RIGHT_FD_DATASYNC: rights_t = 0x0000000000000001;
396pub const RIGHT_FD_READ: rights_t = 0x0000000000000002;
397pub const RIGHT_FD_SEEK: rights_t = 0x0000000000000004;
398pub const RIGHT_FD_FDSTAT_SET_FLAGS: rights_t = 0x0000000000000008;
399pub const RIGHT_FD_SYNC: rights_t = 0x0000000000000010;
400pub const RIGHT_FD_TELL: rights_t = 0x0000000000000020;
401pub const RIGHT_FD_WRITE: rights_t = 0x0000000000000040;
402pub const RIGHT_FD_ADVISE: rights_t = 0x0000000000000080;
403pub const RIGHT_FD_ALLOCATE: rights_t = 0x0000000000000100;
404pub const RIGHT_PATH_CREATE_DIRECTORY: rights_t = 0x0000000000000200;
405pub const RIGHT_PATH_CREATE_FILE: rights_t = 0x0000000000000400;
406pub const RIGHT_PATH_LINK_SOURCE: rights_t = 0x0000000000000800;
407pub const RIGHT_PATH_LINK_TARGET: rights_t = 0x0000000000001000;
408pub const RIGHT_PATH_OPEN: rights_t = 0x0000000000002000;
409pub const RIGHT_FD_READDIR: rights_t = 0x0000000000004000;
410pub const RIGHT_PATH_READLINK: rights_t = 0x0000000000008000;
411pub const RIGHT_PATH_RENAME_SOURCE: rights_t = 0x0000000000010000;
412pub const RIGHT_PATH_RENAME_TARGET: rights_t = 0x0000000000020000;
413pub const RIGHT_PATH_FILESTAT_GET: rights_t = 0x0000000000040000;
414pub const RIGHT_PATH_FILESTAT_SET_SIZE: rights_t = 0x0000000000080000;
415pub const RIGHT_PATH_FILESTAT_SET_TIMES: rights_t = 0x0000000000100000;
416pub const RIGHT_FD_FILESTAT_GET: rights_t = 0x0000000000200000;
417pub const RIGHT_FD_FILESTAT_SET_SIZE: rights_t = 0x0000000000400000;
418pub const RIGHT_FD_FILESTAT_SET_TIMES: rights_t = 0x0000000000800000;
419pub const RIGHT_PATH_SYMLINK: rights_t = 0x0000000001000000;
420pub const RIGHT_PATH_REMOVE_DIRECTORY: rights_t = 0x0000000002000000;
421pub const RIGHT_PATH_UNLINK_FILE: rights_t = 0x0000000004000000;
422pub const RIGHT_POLL_FD_READWRITE: rights_t = 0x0000000008000000;
423pub const RIGHT_SOCK_SHUTDOWN: rights_t = 0x0000000010000000;
424pub const RIGHT_ALL: rights_t = RIGHT_FD_DATASYNC |
425 RIGHT_FD_READ |
426 RIGHT_FD_SEEK |
427 RIGHT_FD_FDSTAT_SET_FLAGS |
428 RIGHT_FD_SYNC |
429 RIGHT_FD_TELL |
430 RIGHT_FD_WRITE |
431 RIGHT_FD_ADVISE |
432 RIGHT_FD_ALLOCATE |
433 RIGHT_PATH_CREATE_DIRECTORY |
434 RIGHT_PATH_CREATE_FILE |
435 RIGHT_PATH_LINK_SOURCE |
436 RIGHT_PATH_LINK_TARGET |
437 RIGHT_PATH_OPEN |
438 RIGHT_FD_READDIR |
439 RIGHT_PATH_READLINK |
440 RIGHT_PATH_RENAME_SOURCE |
441 RIGHT_PATH_RENAME_TARGET |
442 RIGHT_PATH_FILESTAT_GET |
443 RIGHT_PATH_FILESTAT_SET_SIZE |
444 RIGHT_PATH_FILESTAT_SET_TIMES |
445 RIGHT_FD_FILESTAT_GET |
446 RIGHT_FD_FILESTAT_SET_SIZE |
447 RIGHT_FD_FILESTAT_SET_TIMES |
448 RIGHT_PATH_SYMLINK |
449 RIGHT_PATH_REMOVE_DIRECTORY |
450 RIGHT_PATH_UNLINK_FILE |
451 RIGHT_POLL_FD_READWRITE |
452 RIGHT_SOCK_SHUTDOWN;
401pub const RIGHT = struct {
402 pub const FD_DATASYNC: rights_t = 0x0000000000000001;
403 pub const FD_READ: rights_t = 0x0000000000000002;
404 pub const FD_SEEK: rights_t = 0x0000000000000004;
405 pub const FD_FDSTAT_SET_FLAGS: rights_t = 0x0000000000000008;
406 pub const FD_SYNC: rights_t = 0x0000000000000010;
407 pub const FD_TELL: rights_t = 0x0000000000000020;
408 pub const FD_WRITE: rights_t = 0x0000000000000040;
409 pub const FD_ADVISE: rights_t = 0x0000000000000080;
410 pub const FD_ALLOCATE: rights_t = 0x0000000000000100;
411 pub const PATH_CREATE_DIRECTORY: rights_t = 0x0000000000000200;
412 pub const PATH_CREATE_FILE: rights_t = 0x0000000000000400;
413 pub const PATH_LINK_SOURCE: rights_t = 0x0000000000000800;
414 pub const PATH_LINK_TARGET: rights_t = 0x0000000000001000;
415 pub const PATH_OPEN: rights_t = 0x0000000000002000;
416 pub const FD_READDIR: rights_t = 0x0000000000004000;
417 pub const PATH_READLINK: rights_t = 0x0000000000008000;
418 pub const PATH_RENAME_SOURCE: rights_t = 0x0000000000010000;
419 pub const PATH_RENAME_TARGET: rights_t = 0x0000000000020000;
420 pub const PATH_FILESTAT_GET: rights_t = 0x0000000000040000;
421 pub const PATH_FILESTAT_SET_SIZE: rights_t = 0x0000000000080000;
422 pub const PATH_FILESTAT_SET_TIMES: rights_t = 0x0000000000100000;
423 pub const FD_FILESTAT_GET: rights_t = 0x0000000000200000;
424 pub const FD_FILESTAT_SET_SIZE: rights_t = 0x0000000000400000;
425 pub const FD_FILESTAT_SET_TIMES: rights_t = 0x0000000000800000;
426 pub const PATH_SYMLINK: rights_t = 0x0000000001000000;
427 pub const PATH_REMOVE_DIRECTORY: rights_t = 0x0000000002000000;
428 pub const PATH_UNLINK_FILE: rights_t = 0x0000000004000000;
429 pub const POLL_FD_READWRITE: rights_t = 0x0000000008000000;
430 pub const SOCK_SHUTDOWN: rights_t = 0x0000000010000000;
431 pub const ALL: rights_t = FD_DATASYNC |
432 FD_READ |
433 FD_SEEK |
434 FD_FDSTAT_SET_FLAGS |
435 FD_SYNC |
436 FD_TELL |
437 FD_WRITE |
438 FD_ADVISE |
439 FD_ALLOCATE |
440 PATH_CREATE_DIRECTORY |
441 PATH_CREATE_FILE |
442 PATH_LINK_SOURCE |
443 PATH_LINK_TARGET |
444 PATH_OPEN |
445 FD_READDIR |
446 PATH_READLINK |
447 PATH_RENAME_SOURCE |
448 PATH_RENAME_TARGET |
449 PATH_FILESTAT_GET |
450 PATH_FILESTAT_SET_SIZE |
451 PATH_FILESTAT_SET_TIMES |
452 FD_FILESTAT_GET |
453 FD_FILESTAT_SET_SIZE |
454 FD_FILESTAT_SET_TIMES |
455 PATH_SYMLINK |
456 PATH_REMOVE_DIRECTORY |
457 PATH_UNLINK_FILE |
458 POLL_FD_READWRITE |
459 SOCK_SHUTDOWN;
460};
453461
454462pub const sdflags_t = u8;
455463pub const SHUT_RD: sdflags_t = 0x01;
......@@ -524,25 +532,20 @@ pub const timestamp_t = u64;
524532
525533pub const userdata_t = u64;
526534
527pub const whence_t = u8;
528pub const WHENCE_SET: whence_t = 0;
529pub const WHENCE_CUR: whence_t = 1;
530pub const WHENCE_END: whence_t = 2;
531
532pub const S_IEXEC = S_IXUSR;
533pub const S_IFBLK = 0x6000;
534pub const S_IFCHR = 0x2000;
535pub const S_IFDIR = 0x4000;
536pub const S_IFIFO = 0xc000;
537pub const S_IFLNK = 0xa000;
538pub const S_IFMT = S_IFBLK | S_IFCHR | S_IFDIR | S_IFIFO | S_IFLNK | S_IFREG | S_IFSOCK;
539pub const S_IFREG = 0x8000;
540// There's no concept of UNIX domain socket but we define this value here in order to line with other OSes.
541pub const S_IFSOCK = 0x1;
542
543pub const SEEK_SET = WHENCE_SET;
544pub const SEEK_CUR = WHENCE_CUR;
545pub const SEEK_END = WHENCE_END;
535pub const whence_t = enum(u8) { SET, CUR, END };
536
537pub const S = struct {
538 pub const IEXEC = @compileError("TODO audit this");
539 pub const IFBLK = 0x6000;
540 pub const IFCHR = 0x2000;
541 pub const IFDIR = 0x4000;
542 pub const IFIFO = 0xc000;
543 pub const IFLNK = 0xa000;
544 pub const IFMT = IFBLK | IFCHR | IFDIR | IFIFO | IFLNK | IFREG | IFSOCK;
545 pub const IFREG = 0x8000;
546 // There's no concept of UNIX domain socket but we define this value here in order to line with other OSes.
547 pub const IFSOCK = 0x1;
548};
546549
547550pub const LOCK = struct {
548551 pub const SH = 0x1;
lib/std/os/windows.zig+6-11
......@@ -2971,7 +2971,7 @@ pub const EXCEPTION_RECORD = extern struct {
29712971 ExceptionInformation: [15]usize,
29722972};
29732973
2974const arch_bits = switch (native_arch) {
2974pub usingnamespace switch (native_arch) {
29752975 .i386 => struct {
29762976 pub const FLOATING_SAVE_AREA = extern struct {
29772977 ControlWord: DWORD,
......@@ -3037,8 +3037,8 @@ const arch_bits = switch (native_arch) {
30373037 Reserved3: WORD,
30383038 MxCsr: DWORD,
30393039 MxCsr_Mask: DWORD,
3040 FloatRegisters: [8]arch_bits.M128A,
3041 XmmRegisters: [16]arch_bits.M128A,
3040 FloatRegisters: [8]M128A,
3041 XmmRegisters: [16]M128A,
30423042 Reserved4: [96]BYTE,
30433043 };
30443044
......@@ -3082,8 +3082,8 @@ const arch_bits = switch (native_arch) {
30823082 R15: DWORD64,
30833083 Rip: DWORD64,
30843084 DUMMYUNIONNAME: extern union {
3085 FltSave: arch_bits.XMM_SAVE_AREA32,
3086 FloatSave: arch_bits.XMM_SAVE_AREA32,
3085 FltSave: XMM_SAVE_AREA32,
3086 FloatSave: XMM_SAVE_AREA32,
30873087 DUMMYSTRUCTNAME: extern struct {
30883088 Header: [2]M128A,
30893089 Legacy: [8]M128A,
......@@ -3189,15 +3189,10 @@ const arch_bits = switch (native_arch) {
31893189 },
31903190 else => struct {},
31913191};
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
31983193pub const EXCEPTION_POINTERS = extern struct {
31993194 ExceptionRecord: *EXCEPTION_RECORD,
3200 ContextRecord: *CONTEXT,
3195 ContextRecord: *@This().CONTEXT,
32013196};
32023197
32033198pub 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;
55const WINAPI = windows.WINAPI;
66const HDC = windows.HDC;
77const HGLRC = windows.HGLRC;
8const WORD = windows.WORD;
9const BYTE = windows.BYTE;
810
911pub const PIXELFORMATDESCRIPTOR = extern struct {
1012 nSize: WORD = @sizeOf(PIXELFORMATDESCRIPTOR),
lib/std/os/windows/kernel32.zig+20
......@@ -36,6 +36,26 @@ const HLOCAL = windows.HLOCAL;
3636const FILETIME = windows.FILETIME;
3737const STARTUPINFOW = windows.STARTUPINFOW;
3838const 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
4060pub extern "kernel32" fn AddVectoredExceptionHandler(First: c_ulong, Handler: ?VECTORED_EXCEPTION_HANDLER) callconv(WINAPI) ?*c_void;
4161pub 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;
2121const RTL_OSVERSIONINFOW = windows.RTL_OSVERSIONINFOW;
2222const FILE_BASIC_INFORMATION = windows.FILE_BASIC_INFORMATION;
2323const SIZE_T = windows.SIZE_T;
24const CURDIR = windows.CURDIR;
2425
2526pub extern "NtDll" fn RtlGetVersion(
2627 lpVersionInformation: *RTL_OSVERSIONINFOW,
lib/std/os/windows/psapi.zig+43
......@@ -2,6 +2,49 @@ const std = @import("../../std.zig");
22const windows = std.os.windows;
33const WINAPI = windows.WINAPI;
44const 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
649pub extern "psapi" fn EmptyWorkingSet(hProcess: HANDLE) callconv(WINAPI) BOOL;
750pub 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 @@
11const std = @import("../../std.zig");
22const assert = std.debug.assert;
3
34const windows = std.os.windows;
4const unexpectedError = windows.unexpectedError;
55const GetLastError = windows.kernel32.GetLastError;
66const 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
830fn selectSymbol(comptime function_static: anytype, function_dynamic: @TypeOf(function_static), comptime os: std.Target.Os.WindowsVersion) @TypeOf(function_static) {
931 comptime {
......@@ -1316,7 +1338,7 @@ pub fn showWindow(hWnd: HWND, nCmdShow: i32) bool {
13161338
13171339pub extern "user32" fn UpdateWindow(hWnd: HWND) callconv(WINAPI) BOOL;
13181340pub fn updateWindow(hWnd: HWND) !void {
1319 if (ShowWindow(hWnd, nCmdShow) == 0) {
1341 if (UpdateWindow(hWnd) == 0) {
13201342 switch (GetLastError()) {
13211343 .INVALID_WINDOW_HANDLE => unreachable,
13221344 .INVALID_PARAMETER => unreachable,
lib/std/os/windows/ws2_32.zig+10
......@@ -8,6 +8,16 @@ const DWORD = windows.DWORD;
88const GUID = windows.GUID;
99const USHORT = windows.USHORT;
1010const 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
1222pub const SOCKET = *opaque {};
1323pub const INVALID_SOCKET = @intToPtr(SOCKET, ~@as(usize, 0));
lib/std/time.zig-2
......@@ -200,8 +200,6 @@ pub const Timer = struct {
200200 .frequency = {},
201201 };
202202 }
203
204 return self;
205203 }
206204
207205 /// 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
157157 }
158158 },
159159 }
160 return std.fmt.allocPrint(allocator, "{s}{s}{s}", .{ target.libPrefix(), root_name, suffix });
161160 },
162161 .Obj => return std.fmt.allocPrint(allocator, "{s}.o", .{root_name}),
163162 },