diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8cfe9e89e039..5b1d20f671b6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -363,7 +363,9 @@ set(ZIG_STAGE2_SOURCES
"${CMAKE_SOURCE_DIR}/lib/std/crypto/siphash.zig"
"${CMAKE_SOURCE_DIR}/lib/std/debug.zig"
"${CMAKE_SOURCE_DIR}/lib/std/dwarf.zig"
- "${CMAKE_SOURCE_DIR}/lib/std/dwarf_bits.zig"
+ "${CMAKE_SOURCE_DIR}/lib/std/dwarf/AT.zig"
+ "${CMAKE_SOURCE_DIR}/lib/std/dwarf/OP.zig"
+ "${CMAKE_SOURCE_DIR}/lib/std/dwarf/TAG.zig"
"${CMAKE_SOURCE_DIR}/lib/std/elf.zig"
"${CMAKE_SOURCE_DIR}/lib/std/event.zig"
"${CMAKE_SOURCE_DIR}/lib/std/event/batch.zig"
@@ -424,18 +426,13 @@ set(ZIG_STAGE2_SOURCES
"${CMAKE_SOURCE_DIR}/lib/std/meta/trait.zig"
"${CMAKE_SOURCE_DIR}/lib/std/multi_array_list.zig"
"${CMAKE_SOURCE_DIR}/lib/std/os.zig"
- "${CMAKE_SOURCE_DIR}/lib/std/os/bits.zig"
- "${CMAKE_SOURCE_DIR}/lib/std/os/bits/linux.zig"
- "${CMAKE_SOURCE_DIR}/lib/std/os/bits/linux/errno/generic.zig"
- "${CMAKE_SOURCE_DIR}/lib/std/os/bits/linux/netlink.zig"
- "${CMAKE_SOURCE_DIR}/lib/std/os/bits/linux/prctl.zig"
- "${CMAKE_SOURCE_DIR}/lib/std/os/bits/linux/securebits.zig"
- "${CMAKE_SOURCE_DIR}/lib/std/os/bits/linux/x86_64.zig"
+ "${CMAKE_SOURCE_DIR}/lib/std/os/linux.zig"
+ "${CMAKE_SOURCE_DIR}/lib/std/os/linux/errno/generic.zig"
+ "${CMAKE_SOURCE_DIR}/lib/std/os/linux/x86_64.zig"
"${CMAKE_SOURCE_DIR}/lib/std/os/linux.zig"
"${CMAKE_SOURCE_DIR}/lib/std/os/linux/io_uring.zig"
"${CMAKE_SOURCE_DIR}/lib/std/os/linux/x86_64.zig"
"${CMAKE_SOURCE_DIR}/lib/std/os/windows.zig"
- "${CMAKE_SOURCE_DIR}/lib/std/os/windows/bits.zig"
"${CMAKE_SOURCE_DIR}/lib/std/os/windows/ntstatus.zig"
"${CMAKE_SOURCE_DIR}/lib/std/os/windows/win32error.zig"
"${CMAKE_SOURCE_DIR}/lib/std/Progress.zig"
@@ -532,7 +529,7 @@ set(ZIG_STAGE2_SOURCES
"${CMAKE_SOURCE_DIR}/lib/std/time.zig"
"${CMAKE_SOURCE_DIR}/lib/std/unicode.zig"
"${CMAKE_SOURCE_DIR}/lib/std/zig.zig"
- "${CMAKE_SOURCE_DIR}/lib/std/zig/ast.zig"
+ "${CMAKE_SOURCE_DIR}/lib/std/zig/Ast.zig"
"${CMAKE_SOURCE_DIR}/lib/std/zig/cross_target.zig"
"${CMAKE_SOURCE_DIR}/lib/std/zig/parse.zig"
"${CMAKE_SOURCE_DIR}/lib/std/zig/render.zig"
diff --git a/doc/docgen.zig b/doc/docgen.zig
index 8d920dcf6a56..4b4606d255b2 100644
--- a/doc/docgen.zig
+++ b/doc/docgen.zig
@@ -1100,7 +1100,7 @@ fn genHtml(
try tokenizeAndPrint(allocator, tokenizer, out, code.source_token);
try out.writeAll("");
- if (!do_code_tests) {
+ if (!do_code_tests or code.is_inline) {
continue;
}
diff --git a/doc/langref.html.in b/doc/langref.html.in
index cad6dee59f2c..00ed5752f5be 100644
--- a/doc/langref.html.in
+++ b/doc/langref.html.in
@@ -5812,32 +5812,20 @@ test "@intToPtr for pointer to zero bit type" {
{#header_open|usingnamespace#}
- {#syntax#}usingnamespace{#endsyntax#} is a declaration that imports all the public declarations of
- the operand, which must be a {#link|struct#}, {#link|union#}, or {#link|enum#}, into the current scope:
+ {#syntax#}usingnamespace{#endsyntax#} is a declaration that mixes all the public
+ declarations of the operand, which must be a {#link|struct#}, {#link|union#}, {#link|enum#},
+ or {#link|opaque#}, into the namespace:
{#code_begin|test|usingnamespace#}
-usingnamespace @import("std");
-
test "using std namespace" {
- try testing.expect(true);
-}
- {#code_end#}
-
- {#syntax#}usingnamespace{#endsyntax#} can also be used in containers:
-
- {#code_begin|test|usingnamespace_inside_struct#}
-test "using namespace inside struct" {
- const L = struct {
- usingnamespace struct {
- pub fn f() void {}
- };
+ const S = struct {
+ usingnamespace @import("std");
};
- L.f();
+ try S.testing.expect(true);
}
{#code_end#}
- Instead of the above pattern, it is generally recommended to explicitly alias individual declarations.
- However, {#syntax#}usingnamespace{#endsyntax#} has an important use case when organizing the public
+ {#syntax#}usingnamespace{#endsyntax#} has an important use case when organizing the public
API of a file or package. For example, one might have c.zig
with all of the
{#link|C imports|Import from C Header File#}:
@@ -5858,6 +5846,7 @@ pub usingnamespace @cImport({
{#header_close#}
+
{#header_open|comptime#}
Zig places importance on the concept of whether an expression is known at compile-time.
diff --git a/lib/std/Thread.zig b/lib/std/Thread.zig
index e322485037d2..1fe8ca89d20a 100644
--- a/lib/std/Thread.zig
+++ b/lib/std/Thread.zig
@@ -558,7 +558,7 @@ const PosixThreadImpl = struct {
.openbsd => {
var count: c_int = undefined;
var count_size: usize = @sizeOf(c_int);
- const mib = [_]c_int{ os.CTL_HW, os.HW_NCPUONLINE };
+ const mib = [_]c_int{ os.CTL.HW, os.system.HW_NCPUONLINE };
os.sysctl(&mib, &count, &count_size, null, 0) catch |err| switch (err) {
error.NameTooLong, error.UnknownName => unreachable,
else => |e| return e,
@@ -877,8 +877,8 @@ const LinuxThreadImpl = struct {
const mapped = os.mmap(
null,
map_bytes,
- os.PROT_NONE,
- os.MAP_PRIVATE | os.MAP_ANONYMOUS,
+ os.PROT.NONE,
+ os.MAP.PRIVATE | os.MAP.ANONYMOUS,
-1,
0,
) catch |err| switch (err) {
@@ -893,7 +893,7 @@ const LinuxThreadImpl = struct {
// map everything but the guard page as read/write
os.mprotect(
mapped[guard_offset..],
- os.PROT_READ | os.PROT_WRITE,
+ os.PROT.READ | os.PROT.WRITE,
) catch |err| switch (err) {
error.AccessDenied => unreachable,
else => |e| return e,
@@ -923,10 +923,10 @@ const LinuxThreadImpl = struct {
.thread = .{ .mapped = mapped },
};
- const flags: u32 = os.CLONE_THREAD | os.CLONE_DETACHED |
- os.CLONE_VM | os.CLONE_FS | os.CLONE_FILES |
- os.CLONE_PARENT_SETTID | os.CLONE_CHILD_CLEARTID |
- os.CLONE_SIGHAND | os.CLONE_SYSVSEM | os.CLONE_SETTLS;
+ const flags: u32 = linux.CLONE.THREAD | linux.CLONE.DETACHED |
+ linux.CLONE.VM | linux.CLONE.FS | linux.CLONE.FILES |
+ linux.CLONE.PARENT_SETTID | linux.CLONE.CHILD_CLEARTID |
+ linux.CLONE.SIGHAND | linux.CLONE.SYSVSEM | linux.CLONE.SETTLS;
switch (linux.getErrno(linux.clone(
Instance.entryFn,
@@ -978,7 +978,7 @@ const LinuxThreadImpl = struct {
switch (linux.getErrno(linux.futex_wait(
&self.thread.child_tid.value,
- linux.FUTEX_WAIT,
+ linux.FUTEX.WAIT,
tid,
null,
))) {
diff --git a/lib/std/Thread/Futex.zig b/lib/std/Thread/Futex.zig
index 5a3da5cd9489..841104116662 100644
--- a/lib/std/Thread/Futex.zig
+++ b/lib/std/Thread/Futex.zig
@@ -142,7 +142,7 @@ const LinuxFutex = struct {
switch (linux.getErrno(linux.futex_wait(
@ptrCast(*const i32, ptr),
- linux.FUTEX_PRIVATE_FLAG | linux.FUTEX_WAIT,
+ linux.FUTEX.PRIVATE_FLAG | linux.FUTEX.WAIT,
@bitCast(i32, expect),
ts_ptr,
))) {
@@ -159,7 +159,7 @@ const LinuxFutex = struct {
fn wake(ptr: *const Atomic(u32), num_waiters: u32) void {
switch (linux.getErrno(linux.futex_wake(
@ptrCast(*const i32, ptr),
- linux.FUTEX_PRIVATE_FLAG | linux.FUTEX_WAKE,
+ linux.FUTEX.PRIVATE_FLAG | linux.FUTEX.WAKE,
std.math.cast(i32, num_waiters) catch std.math.maxInt(i32),
))) {
.SUCCESS => {}, // successful wake up
@@ -352,7 +352,7 @@ const PosixFutex = struct {
var ts_ptr: ?*const std.os.timespec = null;
if (timeout) |timeout_ns| {
ts_ptr = &ts;
- std.os.clock_gettime(std.os.CLOCK_REALTIME, &ts) catch unreachable;
+ std.os.clock_gettime(std.os.CLOCK.REALTIME, &ts) catch unreachable;
ts.tv_sec += @intCast(@TypeOf(ts.tv_sec), timeout_ns / std.time.ns_per_s);
ts.tv_nsec += @intCast(@TypeOf(ts.tv_nsec), timeout_ns % std.time.ns_per_s);
if (ts.tv_nsec >= std.time.ns_per_s) {
diff --git a/lib/std/Thread/Mutex.zig b/lib/std/Thread/Mutex.zig
index ee54a1582bbf..a337809a1849 100644
--- a/lib/std/Thread/Mutex.zig
+++ b/lib/std/Thread/Mutex.zig
@@ -133,7 +133,7 @@ pub const AtomicMutex = struct {
.linux => {
switch (linux.getErrno(linux.futex_wait(
@ptrCast(*const i32, &m.state),
- linux.FUTEX_PRIVATE_FLAG | linux.FUTEX_WAIT,
+ linux.FUTEX.PRIVATE_FLAG | linux.FUTEX.WAIT,
@enumToInt(new_state),
null,
))) {
@@ -155,7 +155,7 @@ pub const AtomicMutex = struct {
.linux => {
switch (linux.getErrno(linux.futex_wake(
@ptrCast(*const i32, &m.state),
- linux.FUTEX_PRIVATE_FLAG | linux.FUTEX_WAKE,
+ linux.FUTEX.PRIVATE_FLAG | linux.FUTEX.WAKE,
1,
))) {
.SUCCESS => {},
diff --git a/lib/std/Thread/ResetEvent.zig b/lib/std/Thread/ResetEvent.zig
index d9304dd70b76..d85cf7f13363 100644
--- a/lib/std/Thread/ResetEvent.zig
+++ b/lib/std/Thread/ResetEvent.zig
@@ -152,7 +152,7 @@ pub const PosixEvent = struct {
pub fn timedWait(ev: *PosixEvent, timeout_ns: u64) TimedWaitResult {
var ts: os.timespec = undefined;
var timeout_abs = timeout_ns;
- os.clock_gettime(os.CLOCK_REALTIME, &ts) catch return .timed_out;
+ os.clock_gettime(os.CLOCK.REALTIME, &ts) catch return .timed_out;
timeout_abs += @intCast(u64, ts.tv_sec) * time.ns_per_s;
timeout_abs += @intCast(u64, ts.tv_nsec);
ts.tv_sec = @intCast(@TypeOf(ts.tv_sec), @divFloor(timeout_abs, time.ns_per_s));
diff --git a/lib/std/Thread/StaticResetEvent.zig b/lib/std/Thread/StaticResetEvent.zig
index d779a4de9e2c..29fdf3e48908 100644
--- a/lib/std/Thread/StaticResetEvent.zig
+++ b/lib/std/Thread/StaticResetEvent.zig
@@ -194,7 +194,7 @@ pub const AtomicEvent = struct {
_ = wake_count;
const waiting = std.math.maxInt(i32); // wake_count
const ptr = @ptrCast(*const i32, waiters);
- const rc = linux.futex_wake(ptr, linux.FUTEX_WAKE | linux.FUTEX_PRIVATE_FLAG, waiting);
+ const rc = linux.futex_wake(ptr, linux.FUTEX.WAKE | linux.FUTEX.PRIVATE_FLAG, waiting);
assert(linux.getErrno(rc) == .SUCCESS);
}
@@ -213,7 +213,7 @@ pub const AtomicEvent = struct {
return;
const expected = @intCast(i32, waiting);
const ptr = @ptrCast(*const i32, waiters);
- const rc = linux.futex_wait(ptr, linux.FUTEX_WAIT | linux.FUTEX_PRIVATE_FLAG, expected, ts_ptr);
+ const rc = linux.futex_wait(ptr, linux.FUTEX.WAIT | linux.FUTEX.PRIVATE_FLAG, expected, ts_ptr);
switch (linux.getErrno(rc)) {
.SUCCESS => continue,
.TIMEDOUT => return error.TimedOut,
diff --git a/lib/std/array_list.zig b/lib/std/array_list.zig
index f6ee5cdad26c..3a66b9bb3600 100644
--- a/lib/std/array_list.zig
+++ b/lib/std/array_list.zig
@@ -236,21 +236,23 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type {
mem.copy(T, self.items[old_len..], items);
}
- pub usingnamespace if (T != u8) struct {} else struct {
- pub const Writer = std.io.Writer(*Self, error{OutOfMemory}, appendWrite);
+ pub const Writer = if (T != u8)
+ @compileError("The Writer interface is only defined for ArrayList(u8) " ++
+ "but the given type is ArrayList(" ++ @typeName(T) ++ ")")
+ else
+ std.io.Writer(*Self, error{OutOfMemory}, appendWrite);
- /// Initializes a Writer which will append to the list.
- pub fn writer(self: *Self) Writer {
- return .{ .context = self };
- }
+ /// Initializes a Writer which will append to the list.
+ pub fn writer(self: *Self) Writer {
+ return .{ .context = self };
+ }
- /// Same as `append` except it returns the number of bytes written, which is always the same
- /// as `m.len`. The purpose of this function existing is to match `std.io.Writer` API.
- fn appendWrite(self: *Self, m: []const u8) !usize {
- try self.appendSlice(m);
- return m.len;
- }
- };
+ /// Same as `append` except it returns the number of bytes written, which is always the same
+ /// as `m.len`. The purpose of this function existing is to match `std.io.Writer` API.
+ fn appendWrite(self: *Self, m: []const u8) !usize {
+ try self.appendSlice(m);
+ return m.len;
+ }
/// Append a value to the list `n` times.
/// Allocates more memory as necessary.
diff --git a/lib/std/builtin.zig b/lib/std/builtin.zig
index bb35d6137518..7f6c40c6f59d 100644
--- a/lib/std/builtin.zig
+++ b/lib/std/builtin.zig
@@ -27,7 +27,7 @@ pub const code_model = builtin.code_model;
/// used rather than `explicit_subsystem`.
/// On non-Windows targets, this is `null`.
pub const subsystem: ?std.Target.SubSystem = blk: {
- if (@hasDecl(builtin, "explicit_subsystem")) break :blk explicit_subsystem;
+ if (@hasDecl(builtin, "explicit_subsystem")) break :blk builtin.explicit_subsystem;
switch (os.tag) {
.windows => {
if (is_test) {
diff --git a/lib/std/c.zig b/lib/std/c.zig
index 0ad69f873fde..6a2624a93e30 100644
--- a/lib/std/c.zig
+++ b/lib/std/c.zig
@@ -1,18 +1,45 @@
const std = @import("std");
const builtin = std.builtin;
+const c = @This();
const page_size = std.mem.page_size;
+const iovec = std.os.iovec;
+const iovec_const = std.os.iovec_const;
+
+test {
+ _ = tokenizer;
+}
pub const tokenizer = @import("c/tokenizer.zig");
pub const Token = tokenizer.Token;
pub const Tokenizer = tokenizer.Tokenizer;
-test {
- _ = tokenizer;
+/// The return type is `type` to force comptime function call execution.
+/// TODO: https://github.com/ziglang/zig/issues/425
+/// If not linking libc, returns struct{pub const ok = false;}
+/// If linking musl libc, returns struct{pub const ok = true;}
+/// If linking gnu libc (glibc), the `ok` value will be true if the target
+/// version is greater than or equal to `glibc_version`.
+/// If linking a libc other than these, returns `false`.
+pub fn versionCheck(glibc_version: builtin.Version) type {
+ return struct {
+ pub const ok = blk: {
+ if (!builtin.link_libc) break :blk false;
+ if (builtin.abi.isMusl()) break :blk true;
+ if (builtin.target.isGnuLibC()) {
+ const ver = builtin.os.version_range.linux.glibc;
+ const order = ver.order(glibc_version);
+ break :blk switch (order) {
+ .gt, .eq => true,
+ .lt => false,
+ };
+ } else {
+ break :blk false;
+ }
+ };
+ };
}
-pub usingnamespace @import("os/bits.zig");
-
-pub usingnamespace switch (std.Target.current.os.tag) {
+pub usingnamespace switch (builtin.os.tag) {
.linux => @import("c/linux.zig"),
.windows => @import("c/windows.zig"),
.macos, .ios, .tvos, .watchos => @import("c/darwin.zig"),
@@ -30,40 +57,44 @@ pub usingnamespace switch (std.Target.current.os.tag) {
else => struct {},
};
-pub fn getErrno(rc: anytype) E {
+pub const whence_t = if (builtin.os.tag == .wasi) std.os.wasi.whence_t else c_int;
+
+pub usingnamespace switch (builtin.os.tag) {
+ .netbsd, .macos, .ios, .watchos, .tvos, .windows => struct {},
+ else => struct {
+ pub extern "c" fn clock_getres(clk_id: c_int, tp: *c.timespec) c_int;
+ pub extern "c" fn clock_gettime(clk_id: c_int, tp: *c.timespec) c_int;
+ pub extern "c" fn fstat(fd: c.fd_t, buf: *c.Stat) c_int;
+ pub extern "c" fn getrusage(who: c_int, usage: *c.rusage) c_int;
+ pub extern "c" fn gettimeofday(noalias tv: ?*c.timeval, noalias tz: ?*c.timezone) c_int;
+ pub extern "c" fn nanosleep(rqtp: *const c.timespec, rmtp: ?*c.timespec) c_int;
+ pub extern "c" fn sched_yield() c_int;
+ pub extern "c" fn sigaction(sig: c_int, noalias act: ?*const c.Sigaction, noalias oact: ?*c.Sigaction) c_int;
+ pub extern "c" fn sigprocmask(how: c_int, noalias set: ?*const c.sigset_t, noalias oset: ?*c.sigset_t) c_int;
+ pub extern "c" fn socket(domain: c_uint, sock_type: c_uint, protocol: c_uint) c_int;
+ pub extern "c" fn stat(noalias path: [*:0]const u8, noalias buf: *c.Stat) c_int;
+ pub extern "c" fn sigfillset(set: ?*c.sigset_t) void;
+ pub extern "c" fn alarm(seconds: c_uint) c_uint;
+ pub extern "c" fn sigwait(set: ?*c.sigset_t, sig: ?*c_int) c_int;
+ },
+};
+
+pub usingnamespace switch (builtin.os.tag) {
+ .macos, .ios, .watchos, .tvos => struct {},
+ else => struct {
+ pub extern "c" fn realpath(noalias file_name: [*:0]const u8, noalias resolved_name: [*]u8) ?[*:0]u8;
+ pub extern "c" fn fstatat(dirfd: c.fd_t, path: [*:0]const u8, stat_buf: *c.Stat, flags: u32) c_int;
+ },
+};
+
+pub fn getErrno(rc: anytype) c.E {
if (rc == -1) {
- return @intToEnum(E, _errno().*);
+ return @intToEnum(c.E, c._errno().*);
} else {
return .SUCCESS;
}
}
-/// The return type is `type` to force comptime function call execution.
-/// TODO: https://github.com/ziglang/zig/issues/425
-/// If not linking libc, returns struct{pub const ok = false;}
-/// If linking musl libc, returns struct{pub const ok = true;}
-/// If linking gnu libc (glibc), the `ok` value will be true if the target
-/// version is greater than or equal to `glibc_version`.
-/// If linking a libc other than these, returns `false`.
-pub fn versionCheck(glibc_version: builtin.Version) type {
- return struct {
- pub const ok = blk: {
- if (!builtin.link_libc) break :blk false;
- if (std.Target.current.abi.isMusl()) break :blk true;
- if (std.Target.current.isGnuLibC()) {
- const ver = std.Target.current.os.version_range.linux.glibc;
- const order = ver.order(glibc_version);
- break :blk switch (order) {
- .gt, .eq => true,
- .lt => false,
- };
- } else {
- break :blk false;
- }
- };
- };
-}
-
pub extern "c" var environ: [*:null]?[*:0]u8;
pub extern "c" fn fopen(noalias filename: [*:0]const u8, noalias modes: [*:0]const u8) ?*FILE;
@@ -75,255 +106,175 @@ pub extern "c" fn printf(format: [*:0]const u8, ...) c_int;
pub extern "c" fn abort() noreturn;
pub extern "c" fn exit(code: c_int) noreturn;
pub extern "c" fn _exit(code: c_int) noreturn;
-pub extern "c" fn isatty(fd: fd_t) c_int;
-pub extern "c" fn close(fd: fd_t) c_int;
-pub extern "c" fn lseek(fd: fd_t, offset: off_t, whence: c_int) off_t;
+pub extern "c" fn isatty(fd: c.fd_t) c_int;
+pub extern "c" fn close(fd: c.fd_t) c_int;
+pub extern "c" fn lseek(fd: c.fd_t, offset: c.off_t, whence: whence_t) c.off_t;
pub extern "c" fn open(path: [*:0]const u8, oflag: c_uint, ...) c_int;
pub extern "c" fn openat(fd: c_int, path: [*:0]const u8, oflag: c_uint, ...) c_int;
-pub extern "c" fn ftruncate(fd: c_int, length: off_t) c_int;
+pub extern "c" fn ftruncate(fd: c_int, length: c.off_t) c_int;
pub extern "c" fn raise(sig: c_int) c_int;
-pub extern "c" fn read(fd: fd_t, buf: [*]u8, nbyte: usize) isize;
+pub extern "c" fn read(fd: c.fd_t, buf: [*]u8, nbyte: usize) isize;
pub extern "c" fn readv(fd: c_int, iov: [*]const iovec, iovcnt: c_uint) isize;
-pub extern "c" fn pread(fd: fd_t, buf: [*]u8, nbyte: usize, offset: off_t) isize;
-pub extern "c" fn preadv(fd: c_int, iov: [*]const iovec, iovcnt: c_uint, offset: off_t) isize;
+pub extern "c" fn pread(fd: c.fd_t, buf: [*]u8, nbyte: usize, offset: c.off_t) isize;
+pub extern "c" fn preadv(fd: c_int, iov: [*]const iovec, iovcnt: c_uint, offset: c.off_t) isize;
pub extern "c" fn writev(fd: c_int, iov: [*]const iovec_const, iovcnt: c_uint) isize;
-pub extern "c" fn pwritev(fd: c_int, iov: [*]const iovec_const, iovcnt: c_uint, offset: off_t) isize;
-pub extern "c" fn write(fd: fd_t, buf: [*]const u8, nbyte: usize) isize;
-pub extern "c" fn pwrite(fd: fd_t, buf: [*]const u8, nbyte: usize, offset: off_t) isize;
-pub 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;
+pub extern "c" fn pwritev(fd: c_int, iov: [*]const iovec_const, iovcnt: c_uint, offset: c.off_t) isize;
+pub extern "c" fn write(fd: c.fd_t, buf: [*]const u8, nbyte: usize) isize;
+pub extern "c" fn pwrite(fd: c.fd_t, buf: [*]const u8, nbyte: usize, offset: c.off_t) isize;
+pub 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;
pub extern "c" fn munmap(addr: *align(page_size) const c_void, len: usize) c_int;
pub extern "c" fn mprotect(addr: *align(page_size) c_void, len: usize, prot: c_uint) c_int;
pub extern "c" fn link(oldpath: [*:0]const u8, newpath: [*:0]const u8, flags: c_int) c_int;
-pub extern "c" fn linkat(oldfd: fd_t, oldpath: [*:0]const u8, newfd: fd_t, newpath: [*:0]const u8, flags: c_int) c_int;
+pub 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;
pub extern "c" fn unlink(path: [*:0]const u8) c_int;
-pub extern "c" fn unlinkat(dirfd: fd_t, path: [*:0]const u8, flags: c_uint) c_int;
+pub extern "c" fn unlinkat(dirfd: c.fd_t, path: [*:0]const u8, flags: c_uint) c_int;
pub extern "c" fn getcwd(buf: [*]u8, size: usize) ?[*]u8;
-pub extern "c" fn waitpid(pid: pid_t, stat_loc: ?*c_int, options: c_int) pid_t;
+pub extern "c" fn waitpid(pid: c.pid_t, stat_loc: ?*c_int, options: c_int) c.pid_t;
pub extern "c" fn fork() c_int;
pub extern "c" fn access(path: [*:0]const u8, mode: c_uint) c_int;
-pub extern "c" fn faccessat(dirfd: fd_t, path: [*:0]const u8, mode: c_uint, flags: c_uint) c_int;
-pub extern "c" fn pipe(fds: *[2]fd_t) c_int;
+pub extern "c" fn faccessat(dirfd: c.fd_t, path: [*:0]const u8, mode: c_uint, flags: c_uint) c_int;
+pub extern "c" fn pipe(fds: *[2]c.fd_t) c_int;
pub extern "c" fn mkdir(path: [*:0]const u8, mode: c_uint) c_int;
-pub extern "c" fn mkdirat(dirfd: fd_t, path: [*:0]const u8, mode: u32) c_int;
+pub extern "c" fn mkdirat(dirfd: c.fd_t, path: [*:0]const u8, mode: u32) c_int;
pub extern "c" fn symlink(existing: [*:0]const u8, new: [*:0]const u8) c_int;
-pub extern "c" fn symlinkat(oldpath: [*:0]const u8, newdirfd: fd_t, newpath: [*:0]const u8) c_int;
+pub extern "c" fn symlinkat(oldpath: [*:0]const u8, newdirfd: c.fd_t, newpath: [*:0]const u8) c_int;
pub extern "c" fn rename(old: [*:0]const u8, new: [*:0]const u8) c_int;
-pub extern "c" fn renameat(olddirfd: fd_t, old: [*:0]const u8, newdirfd: fd_t, new: [*:0]const u8) c_int;
+pub extern "c" fn renameat(olddirfd: c.fd_t, old: [*:0]const u8, newdirfd: c.fd_t, new: [*:0]const u8) c_int;
pub extern "c" fn chdir(path: [*:0]const u8) c_int;
-pub extern "c" fn fchdir(fd: fd_t) c_int;
+pub extern "c" fn fchdir(fd: c.fd_t) c_int;
pub extern "c" fn execve(path: [*:0]const u8, argv: [*:null]const ?[*:0]const u8, envp: [*:null]const ?[*:0]const u8) c_int;
-pub extern "c" fn dup(fd: fd_t) c_int;
-pub extern "c" fn dup2(old_fd: fd_t, new_fd: fd_t) c_int;
+pub extern "c" fn dup(fd: c.fd_t) c_int;
+pub extern "c" fn dup2(old_fd: c.fd_t, new_fd: c.fd_t) c_int;
pub extern "c" fn readlink(noalias path: [*:0]const u8, noalias buf: [*]u8, bufsize: usize) isize;
-pub extern "c" fn readlinkat(dirfd: fd_t, noalias path: [*:0]const u8, noalias buf: [*]u8, bufsize: usize) isize;
-
-pub usingnamespace switch (builtin.os.tag) {
- .macos, .ios, .watchos, .tvos => struct {
- pub const realpath = @"realpath$DARWIN_EXTSN";
- pub const fstatat = _fstatat;
- },
- else => struct {
- pub extern "c" fn realpath(noalias file_name: [*:0]const u8, noalias resolved_name: [*]u8) ?[*:0]u8;
- pub extern "c" fn fstatat(dirfd: fd_t, path: [*:0]const u8, stat_buf: *libc_stat, flags: u32) c_int;
- },
-};
+pub extern "c" fn readlinkat(dirfd: c.fd_t, noalias path: [*:0]const u8, noalias buf: [*]u8, bufsize: usize) isize;
pub extern "c" fn rmdir(path: [*:0]const u8) c_int;
pub extern "c" fn getenv(name: [*:0]const u8) ?[*:0]u8;
pub extern "c" fn sysctl(name: [*]const c_int, namelen: c_uint, oldp: ?*c_void, oldlenp: ?*usize, newp: ?*c_void, newlen: usize) c_int;
pub extern "c" fn sysctlbyname(name: [*:0]const u8, oldp: ?*c_void, oldlenp: ?*usize, newp: ?*c_void, newlen: usize) c_int;
pub extern "c" fn sysctlnametomib(name: [*:0]const u8, mibp: ?*c_int, sizep: ?*usize) c_int;
-pub extern "c" fn tcgetattr(fd: fd_t, termios_p: *termios) c_int;
-pub extern "c" fn tcsetattr(fd: fd_t, optional_action: TCSA, termios_p: *const termios) c_int;
-pub extern "c" fn fcntl(fd: fd_t, cmd: c_int, ...) c_int;
-pub extern "c" fn flock(fd: fd_t, operation: c_int) c_int;
-pub extern "c" fn ioctl(fd: fd_t, request: c_int, ...) c_int;
-pub extern "c" fn uname(buf: *utsname) c_int;
+pub extern "c" fn tcgetattr(fd: c.fd_t, termios_p: *c.termios) c_int;
+pub extern "c" fn tcsetattr(fd: c.fd_t, optional_action: c.TCSA, termios_p: *const c.termios) c_int;
+pub extern "c" fn fcntl(fd: c.fd_t, cmd: c_int, ...) c_int;
+pub extern "c" fn flock(fd: c.fd_t, operation: c_int) c_int;
+pub extern "c" fn ioctl(fd: c.fd_t, request: c_int, ...) c_int;
+pub extern "c" fn uname(buf: *c.utsname) c_int;
pub extern "c" fn gethostname(name: [*]u8, len: usize) c_int;
-pub extern "c" fn shutdown(socket: fd_t, how: c_int) c_int;
-pub extern "c" fn bind(socket: fd_t, address: ?*const sockaddr, address_len: socklen_t) c_int;
-pub extern "c" fn socketpair(domain: c_uint, sock_type: c_uint, protocol: c_uint, sv: *[2]fd_t) c_int;
-pub extern "c" fn listen(sockfd: fd_t, backlog: c_uint) c_int;
-pub extern "c" fn getsockname(sockfd: fd_t, noalias addr: *sockaddr, noalias addrlen: *socklen_t) c_int;
-pub extern "c" fn getpeername(sockfd: fd_t, noalias addr: *sockaddr, noalias addrlen: *socklen_t) c_int;
-pub extern "c" fn connect(sockfd: fd_t, sock_addr: *const sockaddr, addrlen: socklen_t) c_int;
-pub extern "c" fn accept(sockfd: fd_t, noalias addr: ?*sockaddr, noalias addrlen: ?*socklen_t) c_int;
-pub extern "c" fn accept4(sockfd: fd_t, noalias addr: ?*sockaddr, noalias addrlen: ?*socklen_t, flags: c_uint) c_int;
-pub extern "c" fn getsockopt(sockfd: fd_t, level: u32, optname: u32, noalias optval: ?*c_void, noalias optlen: *socklen_t) c_int;
-pub extern "c" fn setsockopt(sockfd: fd_t, level: u32, optname: u32, optval: ?*const c_void, optlen: socklen_t) c_int;
-pub extern "c" fn send(sockfd: fd_t, buf: *const c_void, len: usize, flags: u32) isize;
+pub extern "c" fn shutdown(socket: c.fd_t, how: c_int) c_int;
+pub extern "c" fn bind(socket: c.fd_t, address: ?*const c.sockaddr, address_len: c.socklen_t) c_int;
+pub extern "c" fn socketpair(domain: c_uint, sock_type: c_uint, protocol: c_uint, sv: *[2]c.fd_t) c_int;
+pub extern "c" fn listen(sockfd: c.fd_t, backlog: c_uint) c_int;
+pub extern "c" fn getsockname(sockfd: c.fd_t, noalias addr: *c.sockaddr, noalias addrlen: *c.socklen_t) c_int;
+pub extern "c" fn getpeername(sockfd: c.fd_t, noalias addr: *c.sockaddr, noalias addrlen: *c.socklen_t) c_int;
+pub extern "c" fn connect(sockfd: c.fd_t, sock_addr: *const c.sockaddr, addrlen: c.socklen_t) c_int;
+pub extern "c" fn accept(sockfd: c.fd_t, noalias addr: ?*c.sockaddr, noalias addrlen: ?*c.socklen_t) c_int;
+pub extern "c" fn accept4(sockfd: c.fd_t, noalias addr: ?*c.sockaddr, noalias addrlen: ?*c.socklen_t, flags: c_uint) c_int;
+pub extern "c" fn getsockopt(sockfd: c.fd_t, level: u32, optname: u32, noalias optval: ?*c_void, noalias optlen: *c.socklen_t) c_int;
+pub extern "c" fn setsockopt(sockfd: c.fd_t, level: u32, optname: u32, optval: ?*const c_void, optlen: c.socklen_t) c_int;
+pub extern "c" fn send(sockfd: c.fd_t, buf: *const c_void, len: usize, flags: u32) isize;
pub extern "c" fn sendto(
- sockfd: fd_t,
+ sockfd: c.fd_t,
buf: *const c_void,
len: usize,
flags: u32,
- dest_addr: ?*const sockaddr,
- addrlen: socklen_t,
+ dest_addr: ?*const c.sockaddr,
+ addrlen: c.socklen_t,
) isize;
-pub extern "c" fn sendmsg(sockfd: fd_t, msg: *const std.x.os.Socket.Message, flags: c_int) isize;
+pub extern "c" fn sendmsg(sockfd: c.fd_t, msg: *const std.x.os.Socket.Message, flags: c_int) isize;
-pub extern "c" fn recv(sockfd: fd_t, arg1: ?*c_void, arg2: usize, arg3: c_int) isize;
+pub extern "c" fn recv(sockfd: c.fd_t, arg1: ?*c_void, arg2: usize, arg3: c_int) isize;
pub extern "c" fn recvfrom(
- sockfd: fd_t,
+ sockfd: c.fd_t,
noalias buf: *c_void,
len: usize,
flags: u32,
- noalias src_addr: ?*sockaddr,
- noalias addrlen: ?*socklen_t,
+ noalias src_addr: ?*c.sockaddr,
+ noalias addrlen: ?*c.socklen_t,
) isize;
-pub extern "c" fn recvmsg(sockfd: fd_t, msg: *std.x.os.Socket.Message, flags: c_int) isize;
-
-pub usingnamespace switch (builtin.os.tag) {
- .netbsd => struct {
- pub const clock_getres = __clock_getres50;
- pub const clock_gettime = __clock_gettime50;
- pub const fstat = __fstat50;
- pub const getdents = __getdents30;
- pub const getrusage = __getrusage50;
- pub const gettimeofday = __gettimeofday50;
- pub const nanosleep = __nanosleep50;
- pub const sched_yield = __libc_thr_yield;
- pub const sigaction = __sigaction14;
- pub const sigaltstack = __sigaltstack14;
- pub const sigprocmask = __sigprocmask14;
- pub const socket = __socket30;
- pub const stat = __stat50;
- },
- .macos, .ios, .watchos, .tvos => struct {
- // XXX: close -> close$NOCANCEL
- // XXX: getdirentries -> _getdirentries64
- pub extern "c" fn clock_getres(clk_id: c_int, tp: *timespec) c_int;
- pub extern "c" fn clock_gettime(clk_id: c_int, tp: *timespec) c_int;
- pub const fstat = _fstat;
- pub extern "c" fn getrusage(who: c_int, usage: *rusage) c_int;
- pub extern "c" fn gettimeofday(noalias tv: ?*timeval, noalias tz: ?*timezone) c_int;
- pub extern "c" fn nanosleep(rqtp: *const timespec, rmtp: ?*timespec) c_int;
- pub extern "c" fn sched_yield() c_int;
- pub extern "c" fn sigaction(sig: c_int, noalias act: ?*const Sigaction, noalias oact: ?*Sigaction) c_int;
- pub extern "c" fn sigprocmask(how: c_int, noalias set: ?*const sigset_t, noalias oset: ?*sigset_t) c_int;
- pub extern "c" fn socket(domain: c_uint, sock_type: c_uint, protocol: c_uint) c_int;
- pub extern "c" fn stat(noalias path: [*:0]const u8, noalias buf: *libc_stat) c_int;
- pub extern "c" fn sigfillset(set: ?*sigset_t) void;
- pub extern "c" fn alarm(seconds: c_uint) c_uint;
- pub extern "c" fn sigwait(set: ?*sigset_t, sig: ?*c_int) c_int;
- },
- .windows => struct {
- // TODO: copied the else case and removed the socket function (because its in ws2_32)
- // need to verify which of these is actually supported on windows
- pub extern "c" fn clock_getres(clk_id: c_int, tp: *timespec) c_int;
- pub extern "c" fn clock_gettime(clk_id: c_int, tp: *timespec) c_int;
- pub extern "c" fn fstat(fd: fd_t, buf: *libc_stat) c_int;
- pub extern "c" fn getrusage(who: c_int, usage: *rusage) c_int;
- pub extern "c" fn gettimeofday(noalias tv: ?*timeval, noalias tz: ?*timezone) c_int;
- pub extern "c" fn nanosleep(rqtp: *const timespec, rmtp: ?*timespec) c_int;
- pub extern "c" fn sched_yield() c_int;
- pub extern "c" fn sigaction(sig: c_int, noalias act: ?*const Sigaction, noalias oact: ?*Sigaction) c_int;
- pub extern "c" fn sigprocmask(how: c_int, noalias set: ?*const sigset_t, noalias oset: ?*sigset_t) c_int;
- pub extern "c" fn stat(noalias path: [*:0]const u8, noalias buf: *libc_stat) c_int;
- pub extern "c" fn sigfillset(set: ?*sigset_t) void;
- pub extern "c" fn alarm(seconds: c_uint) c_uint;
- pub extern "c" fn sigwait(set: ?*sigset_t, sig: ?*c_int) c_int;
- },
- else => struct {
- pub extern "c" fn clock_getres(clk_id: c_int, tp: *timespec) c_int;
- pub extern "c" fn clock_gettime(clk_id: c_int, tp: *timespec) c_int;
- pub extern "c" fn fstat(fd: fd_t, buf: *libc_stat) c_int;
- pub extern "c" fn getrusage(who: c_int, usage: *rusage) c_int;
- pub extern "c" fn gettimeofday(noalias tv: ?*timeval, noalias tz: ?*timezone) c_int;
- pub extern "c" fn nanosleep(rqtp: *const timespec, rmtp: ?*timespec) c_int;
- pub extern "c" fn sched_yield() c_int;
- pub extern "c" fn sigaction(sig: c_int, noalias act: ?*const Sigaction, noalias oact: ?*Sigaction) c_int;
- pub extern "c" fn sigprocmask(how: c_int, noalias set: ?*const sigset_t, noalias oset: ?*sigset_t) c_int;
- pub extern "c" fn socket(domain: c_uint, sock_type: c_uint, protocol: c_uint) c_int;
- pub extern "c" fn stat(noalias path: [*:0]const u8, noalias buf: *libc_stat) c_int;
- pub extern "c" fn sigfillset(set: ?*sigset_t) void;
- pub extern "c" fn alarm(seconds: c_uint) c_uint;
- pub extern "c" fn sigwait(set: ?*sigset_t, sig: ?*c_int) c_int;
- },
-};
+pub extern "c" fn recvmsg(sockfd: c.fd_t, msg: *std.x.os.Socket.Message, flags: c_int) isize;
-pub extern "c" fn kill(pid: pid_t, sig: c_int) c_int;
-pub extern "c" fn getdirentries(fd: fd_t, buf_ptr: [*]u8, nbytes: usize, basep: *i64) isize;
+pub extern "c" fn kill(pid: c.pid_t, sig: c_int) c_int;
+pub extern "c" fn getdirentries(fd: c.fd_t, buf_ptr: [*]u8, nbytes: usize, basep: *i64) isize;
-pub extern "c" fn setuid(uid: uid_t) c_int;
-pub extern "c" fn setgid(gid: gid_t) c_int;
-pub extern "c" fn seteuid(euid: uid_t) c_int;
-pub extern "c" fn setegid(egid: gid_t) c_int;
-pub extern "c" fn setreuid(ruid: uid_t, euid: uid_t) c_int;
-pub extern "c" fn setregid(rgid: gid_t, egid: gid_t) c_int;
-pub extern "c" fn setresuid(ruid: uid_t, euid: uid_t, suid: uid_t) c_int;
-pub extern "c" fn setresgid(rgid: gid_t, egid: gid_t, sgid: gid_t) c_int;
+pub extern "c" fn setuid(uid: c.uid_t) c_int;
+pub extern "c" fn setgid(gid: c.gid_t) c_int;
+pub extern "c" fn seteuid(euid: c.uid_t) c_int;
+pub extern "c" fn setegid(egid: c.gid_t) c_int;
+pub extern "c" fn setreuid(ruid: c.uid_t, euid: c.uid_t) c_int;
+pub extern "c" fn setregid(rgid: c.gid_t, egid: c.gid_t) c_int;
+pub extern "c" fn setresuid(ruid: c.uid_t, euid: c.uid_t, suid: c.uid_t) c_int;
+pub extern "c" fn setresgid(rgid: c.gid_t, egid: c.gid_t, sgid: c.gid_t) c_int;
pub extern "c" fn malloc(usize) ?*c_void;
pub extern "c" fn realloc(?*c_void, usize) ?*c_void;
pub extern "c" fn free(?*c_void) void;
-pub extern "c" fn futimes(fd: fd_t, times: *[2]timeval) c_int;
-pub extern "c" fn utimes(path: [*:0]const u8, times: *[2]timeval) c_int;
+pub extern "c" fn futimes(fd: c.fd_t, times: *[2]c.timeval) c_int;
+pub extern "c" fn utimes(path: [*:0]const u8, times: *[2]c.timeval) c_int;
-pub extern "c" fn utimensat(dirfd: fd_t, pathname: [*:0]const u8, times: *[2]timespec, flags: u32) c_int;
-pub extern "c" fn futimens(fd: fd_t, times: *const [2]timespec) c_int;
+pub extern "c" fn utimensat(dirfd: c.fd_t, pathname: [*:0]const u8, times: *[2]c.timespec, flags: u32) c_int;
+pub extern "c" fn futimens(fd: c.fd_t, times: *const [2]c.timespec) c_int;
-pub 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;
-pub extern "c" fn pthread_attr_init(attr: *pthread_attr_t) E;
-pub extern "c" fn pthread_attr_setstack(attr: *pthread_attr_t, stackaddr: *c_void, stacksize: usize) E;
-pub extern "c" fn pthread_attr_setstacksize(attr: *pthread_attr_t, stacksize: usize) E;
-pub extern "c" fn pthread_attr_setguardsize(attr: *pthread_attr_t, guardsize: usize) E;
-pub extern "c" fn pthread_attr_destroy(attr: *pthread_attr_t) E;
+pub 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;
+pub extern "c" fn pthread_attr_init(attr: *c.pthread_attr_t) c.E;
+pub extern "c" fn pthread_attr_setstack(attr: *c.pthread_attr_t, stackaddr: *c_void, stacksize: usize) c.E;
+pub extern "c" fn pthread_attr_setstacksize(attr: *c.pthread_attr_t, stacksize: usize) c.E;
+pub extern "c" fn pthread_attr_setguardsize(attr: *c.pthread_attr_t, guardsize: usize) c.E;
+pub extern "c" fn pthread_attr_destroy(attr: *c.pthread_attr_t) c.E;
pub extern "c" fn pthread_self() pthread_t;
-pub extern "c" fn pthread_join(thread: pthread_t, arg_return: ?*?*c_void) E;
-pub extern "c" fn pthread_detach(thread: pthread_t) E;
+pub extern "c" fn pthread_join(thread: pthread_t, arg_return: ?*?*c_void) c.E;
+pub extern "c" fn pthread_detach(thread: pthread_t) c.E;
pub extern "c" fn pthread_atfork(
prepare: ?fn () callconv(.C) void,
parent: ?fn () callconv(.C) void,
child: ?fn () callconv(.C) void,
) c_int;
-pub extern "c" fn pthread_key_create(key: *pthread_key_t, destructor: ?fn (value: *c_void) callconv(.C) void) E;
-pub extern "c" fn pthread_key_delete(key: pthread_key_t) E;
-pub extern "c" fn pthread_getspecific(key: pthread_key_t) ?*c_void;
-pub extern "c" fn pthread_setspecific(key: pthread_key_t, value: ?*c_void) c_int;
-pub extern "c" fn sem_init(sem: *sem_t, pshared: c_int, value: c_uint) c_int;
-pub extern "c" fn sem_destroy(sem: *sem_t) c_int;
-pub extern "c" fn sem_post(sem: *sem_t) c_int;
-pub extern "c" fn sem_wait(sem: *sem_t) c_int;
-pub extern "c" fn sem_trywait(sem: *sem_t) c_int;
-pub extern "c" fn sem_timedwait(sem: *sem_t, abs_timeout: *const timespec) c_int;
-pub extern "c" fn sem_getvalue(sem: *sem_t, sval: *c_int) c_int;
+pub extern "c" fn pthread_key_create(key: *c.pthread_key_t, destructor: ?fn (value: *c_void) callconv(.C) void) c.E;
+pub extern "c" fn pthread_key_delete(key: c.pthread_key_t) c.E;
+pub extern "c" fn pthread_getspecific(key: c.pthread_key_t) ?*c_void;
+pub extern "c" fn pthread_setspecific(key: c.pthread_key_t, value: ?*c_void) c_int;
+pub extern "c" fn sem_init(sem: *c.sem_t, pshared: c_int, value: c_uint) c_int;
+pub extern "c" fn sem_destroy(sem: *c.sem_t) c_int;
+pub extern "c" fn sem_post(sem: *c.sem_t) c_int;
+pub extern "c" fn sem_wait(sem: *c.sem_t) c_int;
+pub extern "c" fn sem_trywait(sem: *c.sem_t) c_int;
+pub extern "c" fn sem_timedwait(sem: *c.sem_t, abs_timeout: *const c.timespec) c_int;
+pub extern "c" fn sem_getvalue(sem: *c.sem_t, sval: *c_int) c_int;
pub extern "c" fn kqueue() c_int;
pub extern "c" fn kevent(
kq: c_int,
- changelist: [*]const Kevent,
+ changelist: [*]const c.Kevent,
nchanges: c_int,
- eventlist: [*]Kevent,
+ eventlist: [*]c.Kevent,
nevents: c_int,
- timeout: ?*const timespec,
+ timeout: ?*const c.timespec,
) c_int;
pub extern "c" fn getaddrinfo(
noalias node: ?[*:0]const u8,
noalias service: ?[*:0]const u8,
- noalias hints: ?*const addrinfo,
- noalias res: **addrinfo,
-) EAI;
+ noalias hints: ?*const c.addrinfo,
+ noalias res: **c.addrinfo,
+) c.EAI;
-pub extern "c" fn freeaddrinfo(res: *addrinfo) void;
+pub extern "c" fn freeaddrinfo(res: *c.addrinfo) void;
pub extern "c" fn getnameinfo(
- noalias addr: *const sockaddr,
- addrlen: socklen_t,
+ noalias addr: *const c.sockaddr,
+ addrlen: c.socklen_t,
noalias host: [*]u8,
- hostlen: socklen_t,
+ hostlen: c.socklen_t,
noalias serv: [*]u8,
- servlen: socklen_t,
+ servlen: c.socklen_t,
flags: u32,
-) EAI;
+) c.EAI;
-pub extern "c" fn gai_strerror(errcode: EAI) [*:0]const u8;
+pub extern "c" fn gai_strerror(errcode: c.EAI) [*:0]const u8;
-pub extern "c" fn poll(fds: [*]pollfd, nfds: nfds_t, timeout: c_int) c_int;
-pub extern "c" fn ppoll(fds: [*]pollfd, nfds: nfds_t, timeout: ?*const timespec, sigmask: ?*const sigset_t) c_int;
+pub extern "c" fn poll(fds: [*]c.pollfd, nfds: c.nfds_t, timeout: c_int) c_int;
+pub extern "c" fn ppoll(fds: [*]c.pollfd, nfds: c.nfds_t, timeout: ?*const c.timespec, sigmask: ?*const c.sigset_t) c_int;
pub extern "c" fn dn_expand(
msg: [*:0]const u8,
@@ -333,25 +284,25 @@ pub extern "c" fn dn_expand(
length: c_int,
) c_int;
-pub const PTHREAD_MUTEX_INITIALIZER = pthread_mutex_t{};
-pub extern "c" fn pthread_mutex_lock(mutex: *pthread_mutex_t) E;
-pub extern "c" fn pthread_mutex_unlock(mutex: *pthread_mutex_t) E;
-pub extern "c" fn pthread_mutex_trylock(mutex: *pthread_mutex_t) E;
-pub extern "c" fn pthread_mutex_destroy(mutex: *pthread_mutex_t) E;
-
-pub const PTHREAD_COND_INITIALIZER = pthread_cond_t{};
-pub extern "c" fn pthread_cond_wait(noalias cond: *pthread_cond_t, noalias mutex: *pthread_mutex_t) E;
-pub extern "c" fn pthread_cond_timedwait(noalias cond: *pthread_cond_t, noalias mutex: *pthread_mutex_t, noalias abstime: *const timespec) E;
-pub extern "c" fn pthread_cond_signal(cond: *pthread_cond_t) E;
-pub extern "c" fn pthread_cond_broadcast(cond: *pthread_cond_t) E;
-pub extern "c" fn pthread_cond_destroy(cond: *pthread_cond_t) E;
-
-pub extern "c" fn pthread_rwlock_destroy(rwl: *pthread_rwlock_t) callconv(.C) E;
-pub extern "c" fn pthread_rwlock_rdlock(rwl: *pthread_rwlock_t) callconv(.C) E;
-pub extern "c" fn pthread_rwlock_wrlock(rwl: *pthread_rwlock_t) callconv(.C) E;
-pub extern "c" fn pthread_rwlock_tryrdlock(rwl: *pthread_rwlock_t) callconv(.C) E;
-pub extern "c" fn pthread_rwlock_trywrlock(rwl: *pthread_rwlock_t) callconv(.C) E;
-pub extern "c" fn pthread_rwlock_unlock(rwl: *pthread_rwlock_t) callconv(.C) E;
+pub const PTHREAD_MUTEX_INITIALIZER = c.pthread_mutex_t{};
+pub extern "c" fn pthread_mutex_lock(mutex: *c.pthread_mutex_t) c.E;
+pub extern "c" fn pthread_mutex_unlock(mutex: *c.pthread_mutex_t) c.E;
+pub extern "c" fn pthread_mutex_trylock(mutex: *c.pthread_mutex_t) c.E;
+pub extern "c" fn pthread_mutex_destroy(mutex: *c.pthread_mutex_t) c.E;
+
+pub const PTHREAD_COND_INITIALIZER = c.pthread_cond_t{};
+pub extern "c" fn pthread_cond_wait(noalias cond: *c.pthread_cond_t, noalias mutex: *c.pthread_mutex_t) c.E;
+pub 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;
+pub extern "c" fn pthread_cond_signal(cond: *c.pthread_cond_t) c.E;
+pub extern "c" fn pthread_cond_broadcast(cond: *c.pthread_cond_t) c.E;
+pub extern "c" fn pthread_cond_destroy(cond: *c.pthread_cond_t) c.E;
+
+pub extern "c" fn pthread_rwlock_destroy(rwl: *c.pthread_rwlock_t) callconv(.C) c.E;
+pub extern "c" fn pthread_rwlock_rdlock(rwl: *c.pthread_rwlock_t) callconv(.C) c.E;
+pub extern "c" fn pthread_rwlock_wrlock(rwl: *c.pthread_rwlock_t) callconv(.C) c.E;
+pub extern "c" fn pthread_rwlock_tryrdlock(rwl: *c.pthread_rwlock_t) callconv(.C) c.E;
+pub extern "c" fn pthread_rwlock_trywrlock(rwl: *c.pthread_rwlock_t) callconv(.C) c.E;
+pub extern "c" fn pthread_rwlock_unlock(rwl: *c.pthread_rwlock_t) callconv(.C) c.E;
pub const pthread_t = *opaque {};
pub const FILE = opaque {};
@@ -367,8 +318,8 @@ pub extern "c" fn fdatasync(fd: c_int) c_int;
pub extern "c" fn prctl(option: c_int, ...) c_int;
-pub extern "c" fn getrlimit(resource: rlimit_resource, rlim: *rlimit) c_int;
-pub extern "c" fn setrlimit(resource: rlimit_resource, rlim: *const rlimit) c_int;
+pub extern "c" fn getrlimit(resource: c.rlimit_resource, rlim: *c.rlimit) c_int;
+pub extern "c" fn setrlimit(resource: c.rlimit_resource, rlim: *const c.rlimit) c_int;
pub extern "c" fn fmemopen(noalias buf: ?*c_void, size: usize, noalias mode: [*:0]const u8) ?*FILE;
@@ -377,9 +328,9 @@ pub extern "c" fn openlog(ident: [*:0]const u8, logopt: c_int, facility: c_int)
pub extern "c" fn closelog() void;
pub extern "c" fn setlogmask(maskpri: c_int) c_int;
-pub const max_align_t = if (std.Target.current.abi == .msvc)
+pub const max_align_t = if (builtin.abi == .msvc)
f64
-else if (std.Target.current.isDarwin())
+else if (builtin.target.isDarwin())
c_longdouble
else
extern struct {
diff --git a/lib/std/c/darwin.zig b/lib/std/c/darwin.zig
index 7fa07719a886..8bb30efab336 100644
--- a/lib/std/c/darwin.zig
+++ b/lib/std/c/darwin.zig
@@ -3,8 +3,8 @@ const assert = std.debug.assert;
const builtin = @import("builtin");
const macho = std.macho;
const native_arch = builtin.target.cpu.arch;
-
-usingnamespace @import("../os/bits.zig");
+const maxInt = std.math.maxInt;
+const iovec_const = std.os.iovec_const;
extern "c" fn __error() *c_int;
pub extern "c" fn NSVersionOfRunTimeLibrary(library_name: [*:0]const u8) u32;
@@ -23,20 +23,25 @@ pub const copyfile_state_t = *opaque {};
pub extern "c" fn fcopyfile(from: fd_t, to: fd_t, state: ?copyfile_state_t, flags: u32) c_int;
pub extern "c" fn @"realpath$DARWIN_EXTSN"(noalias file_name: [*:0]const u8, noalias resolved_name: [*]u8) ?[*:0]u8;
+pub const realpath = @"realpath$DARWIN_EXTSN";
pub extern "c" fn __getdirentries64(fd: c_int, buf_ptr: [*]u8, buf_len: usize, basep: *i64) isize;
-extern "c" fn fstat(fd: fd_t, buf: *libc_stat) c_int;
-/// On x86_64 Darwin, fstat has to be manully linked with $INODE64 suffix to force 64bit version.
-/// Note that this is fixed on aarch64 and no longer necessary.
-extern "c" fn @"fstat$INODE64"(fd: fd_t, buf: *libc_stat) c_int;
-pub const _fstat = if (native_arch == .aarch64) fstat else @"fstat$INODE64";
+const private = struct {
+ extern "c" fn fstat(fd: fd_t, buf: *Stat) c_int;
+ /// On x86_64 Darwin, fstat has to be manully linked with $INODE64 suffix to
+ /// force 64bit version.
+ /// Note that this is fixed on aarch64 and no longer necessary.
+ extern "c" fn @"fstat$INODE64"(fd: fd_t, buf: *Stat) c_int;
-extern "c" fn fstatat(dirfd: fd_t, path: [*:0]const u8, stat_buf: *libc_stat, flags: u32) c_int;
-/// On x86_64 Darwin, fstatat has to be manully linked with $INODE64 suffix to force 64bit version.
-/// Note that this is fixed on aarch64 and no longer necessary.
-extern "c" fn @"fstatat$INODE64"(dirfd: fd_t, path_name: [*:0]const u8, buf: *libc_stat, flags: u32) c_int;
-pub const _fstatat = if (native_arch == .aarch64) fstatat else @"fstatat$INODE64";
+ extern "c" fn fstatat(dirfd: fd_t, path: [*:0]const u8, stat_buf: *Stat, flags: u32) c_int;
+ /// On x86_64 Darwin, fstatat has to be manully linked with $INODE64 suffix to
+ /// force 64bit version.
+ /// Note that this is fixed on aarch64 and no longer necessary.
+ extern "c" fn @"fstatat$INODE64"(dirfd: fd_t, path_name: [*:0]const u8, buf: *Stat, flags: u32) c_int;
+};
+pub const fstat = if (native_arch == .aarch64) private.fstat else private.@"fstat$INODE64";
+pub const fstatat = if (native_arch == .aarch64) private.fstatat else private.@"fstatat$INODE64";
pub extern "c" fn mach_absolute_time() u64;
pub extern "c" fn mach_timebase_info(tinfo: ?*mach_timebase_info_data) void;
@@ -80,8 +85,6 @@ pub const _errno = __error;
pub extern "c" fn @"close$NOCANCEL"(fd: fd_t) c_int;
pub extern "c" fn mach_host_self() mach_port_t;
pub extern "c" fn clock_get_time(clock_serv: clock_serv_t, cur_time: *mach_timespec_t) kern_return_t;
-pub extern "c" fn host_get_clock_service(host: host_t, clock_id: clock_id_t, clock_serv: ?[*]clock_serv_t) kern_return_t;
-pub extern "c" fn mach_port_deallocate(task: ipc_space_t, name: mach_port_name_t) kern_return_t;
pub const sf_hdtr = extern struct {
headers: [*]const iovec_const,
@@ -105,17 +108,16 @@ pub fn sigaddset(set: *sigset_t, signo: u5) void {
pub extern "c" fn sigaltstack(ss: ?*stack_t, old_ss: ?*stack_t) c_int;
-/// get address to use bind()
-pub const AI_PASSIVE = 0x00000001;
-
-/// fill ai_canonname
-pub const AI_CANONNAME = 0x00000002;
-
-/// prevent host name resolution
-pub const AI_NUMERICHOST = 0x00000004;
-
-/// prevent service name resolution
-pub const AI_NUMERICSERV = 0x00001000;
+pub const AI = struct {
+ /// get address to use bind()
+ pub const PASSIVE = 0x00000001;
+ /// fill ai_canonname
+ pub const CANONNAME = 0x00000002;
+ /// prevent host name resolution
+ pub const NUMERICHOST = 0x00000004;
+ /// prevent service name resolution
+ pub const NUMERICSERV = 0x00001000;
+};
pub const EAI = enum(c_int) {
/// address family for hostname not supported
@@ -256,3 +258,1726 @@ pub extern "c" fn os_unfair_lock_unlock(o: os_unfair_lock_t) void;
pub extern "c" fn os_unfair_lock_trylock(o: os_unfair_lock_t) bool;
pub extern "c" fn os_unfair_lock_assert_owner(o: os_unfair_lock_t) void;
pub extern "c" fn os_unfair_lock_assert_not_owner(o: os_unfair_lock_t) void;
+
+// XXX: close -> close$NOCANCEL
+// XXX: getdirentries -> _getdirentries64
+pub extern "c" fn clock_getres(clk_id: c_int, tp: *timespec) c_int;
+pub extern "c" fn clock_gettime(clk_id: c_int, tp: *timespec) c_int;
+pub extern "c" fn getrusage(who: c_int, usage: *rusage) c_int;
+pub extern "c" fn gettimeofday(noalias tv: ?*timeval, noalias tz: ?*timezone) c_int;
+pub extern "c" fn nanosleep(rqtp: *const timespec, rmtp: ?*timespec) c_int;
+pub extern "c" fn sched_yield() c_int;
+pub extern "c" fn sigaction(sig: c_int, noalias act: ?*const Sigaction, noalias oact: ?*Sigaction) c_int;
+pub extern "c" fn sigprocmask(how: c_int, noalias set: ?*const sigset_t, noalias oset: ?*sigset_t) c_int;
+pub extern "c" fn socket(domain: c_uint, sock_type: c_uint, protocol: c_uint) c_int;
+pub extern "c" fn stat(noalias path: [*:0]const u8, noalias buf: *Stat) c_int;
+pub extern "c" fn sigfillset(set: ?*sigset_t) void;
+pub extern "c" fn alarm(seconds: c_uint) c_uint;
+pub extern "c" fn sigwait(set: ?*sigset_t, sig: ?*c_int) c_int;
+
+// See: https://opensource.apple.com/source/xnu/xnu-6153.141.1/bsd/sys/_types.h.auto.html
+// TODO: audit mode_t/pid_t, should likely be u16/i32
+pub const fd_t = c_int;
+pub const pid_t = c_int;
+pub const mode_t = c_uint;
+pub const uid_t = u32;
+pub const gid_t = u32;
+
+pub const in_port_t = u16;
+pub const sa_family_t = u8;
+pub const socklen_t = u32;
+pub const sockaddr = extern struct {
+ len: u8,
+ family: sa_family_t,
+ data: [14]u8,
+
+ pub const storage = std.x.os.Socket.Address.Native.Storage;
+ pub const in = extern struct {
+ len: u8 = @sizeOf(in),
+ family: sa_family_t = AF.INET,
+ port: in_port_t,
+ addr: u32,
+ zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },
+ };
+ pub const in6 = extern struct {
+ len: u8 = @sizeOf(in6),
+ family: sa_family_t = AF.INET6,
+ port: in_port_t,
+ flowinfo: u32,
+ addr: [16]u8,
+ scope_id: u32,
+ };
+
+ /// UNIX domain socket
+ pub const un = extern struct {
+ len: u8 = @sizeOf(un),
+ family: sa_family_t = AF.UNIX,
+ path: [104]u8,
+ };
+};
+pub const timeval = extern struct {
+ tv_sec: c_long,
+ tv_usec: i32,
+};
+
+pub const timezone = extern struct {
+ tz_minuteswest: i32,
+ tz_dsttime: i32,
+};
+
+pub const mach_timebase_info_data = extern struct {
+ numer: u32,
+ denom: u32,
+};
+
+pub const off_t = i64;
+pub const ino_t = u64;
+
+pub const Flock = extern struct {
+ l_start: off_t,
+ l_len: off_t,
+ l_pid: pid_t,
+ l_type: i16,
+ l_whence: i16,
+};
+
+pub const Stat = extern struct {
+ dev: i32,
+ mode: u16,
+ nlink: u16,
+ ino: ino_t,
+ uid: uid_t,
+ gid: gid_t,
+ rdev: i32,
+ atimesec: isize,
+ atimensec: isize,
+ mtimesec: isize,
+ mtimensec: isize,
+ ctimesec: isize,
+ ctimensec: isize,
+ birthtimesec: isize,
+ birthtimensec: isize,
+ size: off_t,
+ blocks: i64,
+ blksize: i32,
+ flags: u32,
+ gen: u32,
+ lspare: i32,
+ qspare: [2]i64,
+
+ pub fn atime(self: @This()) timespec {
+ return timespec{
+ .tv_sec = self.atimesec,
+ .tv_nsec = self.atimensec,
+ };
+ }
+
+ pub fn mtime(self: @This()) timespec {
+ return timespec{
+ .tv_sec = self.mtimesec,
+ .tv_nsec = self.mtimensec,
+ };
+ }
+
+ pub fn ctime(self: @This()) timespec {
+ return timespec{
+ .tv_sec = self.ctimesec,
+ .tv_nsec = self.ctimensec,
+ };
+ }
+};
+
+pub const timespec = extern struct {
+ tv_sec: isize,
+ tv_nsec: isize,
+};
+
+pub const sigset_t = u32;
+pub const empty_sigset: sigset_t = 0;
+
+pub const SIG = struct {
+ pub const ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize));
+ pub const DFL = @intToPtr(?Sigaction.sigaction_fn, 0);
+ pub const IGN = @intToPtr(?Sigaction.sigaction_fn, 1);
+ pub const HOLD = @intToPtr(?Sigaction.sigaction_fn, 5);
+
+ /// block specified signal set
+ pub const _BLOCK = 1;
+ /// unblock specified signal set
+ pub const _UNBLOCK = 2;
+ /// set specified signal set
+ pub const _SETMASK = 3;
+ /// hangup
+ pub const HUP = 1;
+ /// interrupt
+ pub const INT = 2;
+ /// quit
+ pub const QUIT = 3;
+ /// illegal instruction (not reset when caught)
+ pub const ILL = 4;
+ /// trace trap (not reset when caught)
+ pub const TRAP = 5;
+ /// abort()
+ pub const ABRT = 6;
+ /// pollable event ([XSR] generated, not supported)
+ pub const POLL = 7;
+ /// compatibility
+ pub const IOT = ABRT;
+ /// EMT instruction
+ pub const EMT = 7;
+ /// floating point exception
+ pub const FPE = 8;
+ /// kill (cannot be caught or ignored)
+ pub const KILL = 9;
+ /// bus error
+ pub const BUS = 10;
+ /// segmentation violation
+ pub const SEGV = 11;
+ /// bad argument to system call
+ pub const SYS = 12;
+ /// write on a pipe with no one to read it
+ pub const PIPE = 13;
+ /// alarm clock
+ pub const ALRM = 14;
+ /// software termination signal from kill
+ pub const TERM = 15;
+ /// urgent condition on IO channel
+ pub const URG = 16;
+ /// sendable stop signal not from tty
+ pub const STOP = 17;
+ /// stop signal from tty
+ pub const TSTP = 18;
+ /// continue a stopped process
+ pub const CONT = 19;
+ /// to parent on child stop or exit
+ pub const CHLD = 20;
+ /// to readers pgrp upon background tty read
+ pub const TTIN = 21;
+ /// like TTIN for output if (tp->t_local<OSTOP)
+ pub const TTOU = 22;
+ /// input/output possible signal
+ pub const IO = 23;
+ /// exceeded CPU time limit
+ pub const XCPU = 24;
+ /// exceeded file size limit
+ pub const XFSZ = 25;
+ /// virtual time alarm
+ pub const VTALRM = 26;
+ /// profiling time alarm
+ pub const PROF = 27;
+ /// window size changes
+ pub const WINCH = 28;
+ /// information request
+ pub const INFO = 29;
+ /// user defined signal 1
+ pub const USR1 = 30;
+ /// user defined signal 2
+ pub const USR2 = 31;
+};
+
+pub const siginfo_t = extern struct {
+ signo: c_int,
+ errno: c_int,
+ code: c_int,
+ pid: pid_t,
+ uid: uid_t,
+ status: c_int,
+ addr: *c_void,
+ value: extern union {
+ int: c_int,
+ ptr: *c_void,
+ },
+ si_band: c_long,
+ _pad: [7]c_ulong,
+};
+
+/// Renamed from `sigaction` to `Sigaction` to avoid conflict with function name.
+pub const Sigaction = extern struct {
+ pub const handler_fn = fn (c_int) callconv(.C) void;
+ pub const sigaction_fn = fn (c_int, *const siginfo_t, ?*const c_void) callconv(.C) void;
+
+ handler: extern union {
+ handler: ?handler_fn,
+ sigaction: ?sigaction_fn,
+ },
+ mask: sigset_t,
+ flags: c_uint,
+};
+
+pub const dirent = extern struct {
+ d_ino: usize,
+ d_seekoff: usize,
+ d_reclen: u16,
+ d_namlen: u16,
+ d_type: u8,
+ d_name: u8, // field address is address of first byte of name
+
+ pub fn reclen(self: dirent) u16 {
+ return self.d_reclen;
+ }
+};
+
+/// Renamed from `kevent` to `Kevent` to avoid conflict with function name.
+pub const Kevent = extern struct {
+ ident: usize,
+ filter: i16,
+ flags: u16,
+ fflags: u32,
+ data: isize,
+ udata: usize,
+};
+
+// sys/types.h on macos uses #pragma pack(4) so these checks are
+// to make sure the struct is laid out the same. These values were
+// produced from C code using the offsetof macro.
+comptime {
+ assert(@offsetOf(Kevent, "ident") == 0);
+ assert(@offsetOf(Kevent, "filter") == 8);
+ assert(@offsetOf(Kevent, "flags") == 10);
+ assert(@offsetOf(Kevent, "fflags") == 12);
+ assert(@offsetOf(Kevent, "data") == 16);
+ assert(@offsetOf(Kevent, "udata") == 24);
+}
+
+pub const kevent64_s = extern struct {
+ ident: u64,
+ filter: i16,
+ flags: u16,
+ fflags: u32,
+ data: i64,
+ udata: u64,
+ ext: [2]u64,
+};
+
+// sys/types.h on macos uses #pragma pack() so these checks are
+// to make sure the struct is laid out the same. These values were
+// produced from C code using the offsetof macro.
+comptime {
+ assert(@offsetOf(kevent64_s, "ident") == 0);
+ assert(@offsetOf(kevent64_s, "filter") == 8);
+ assert(@offsetOf(kevent64_s, "flags") == 10);
+ assert(@offsetOf(kevent64_s, "fflags") == 12);
+ assert(@offsetOf(kevent64_s, "data") == 16);
+ assert(@offsetOf(kevent64_s, "udata") == 24);
+ assert(@offsetOf(kevent64_s, "ext") == 32);
+}
+
+pub const mach_port_t = c_uint;
+pub const clock_serv_t = mach_port_t;
+pub const clock_res_t = c_int;
+pub const mach_port_name_t = natural_t;
+pub const natural_t = c_uint;
+pub const mach_timespec_t = extern struct {
+ tv_sec: c_uint,
+ tv_nsec: clock_res_t,
+};
+pub const kern_return_t = c_int;
+pub const host_t = mach_port_t;
+pub const CALENDAR_CLOCK = 1;
+
+pub const PATH_MAX = 1024;
+pub const IOV_MAX = 16;
+
+pub const STDIN_FILENO = 0;
+pub const STDOUT_FILENO = 1;
+pub const STDERR_FILENO = 2;
+
+pub const PROT = struct {
+ /// [MC2] no permissions
+ pub const NONE = 0x00;
+ /// [MC2] pages can be read
+ pub const READ = 0x01;
+ /// [MC2] pages can be written
+ pub const WRITE = 0x02;
+ /// [MC2] pages can be executed
+ pub const EXEC = 0x04;
+};
+
+pub const MAP = struct {
+ /// allocated from memory, swap space
+ pub const ANONYMOUS = 0x1000;
+ /// map from file (default)
+ pub const FILE = 0x0000;
+ /// interpret addr exactly
+ pub const FIXED = 0x0010;
+ /// region may contain semaphores
+ pub const HASSEMAPHORE = 0x0200;
+ /// changes are private
+ pub const PRIVATE = 0x0002;
+ /// share changes
+ pub const SHARED = 0x0001;
+ /// don't cache pages for this mapping
+ pub const NOCACHE = 0x0400;
+ /// don't reserve needed swap area
+ pub const NORESERVE = 0x0040;
+ pub const FAILED = @intToPtr(*c_void, maxInt(usize));
+};
+
+pub const SA = struct {
+ /// take signal on signal stack
+ pub const ONSTACK = 0x0001;
+ /// restart system on signal return
+ pub const RESTART = 0x0002;
+ /// reset to SIG.DFL when taking signal
+ pub const RESETHAND = 0x0004;
+ /// do not generate SIG.CHLD on child stop
+ pub const NOCLDSTOP = 0x0008;
+ /// don't mask the signal we're delivering
+ pub const NODEFER = 0x0010;
+ /// don't keep zombies around
+ pub const NOCLDWAIT = 0x0020;
+ /// signal handler with SIGINFO args
+ pub const SIGINFO = 0x0040;
+ /// do not bounce off kernel's sigtramp
+ pub const USERTRAMP = 0x0100;
+ /// signal handler with SIGINFO args with 64bit regs information
+ pub const @"64REGSET" = 0x0200;
+};
+
+pub const F_OK = 0;
+pub const X_OK = 1;
+pub const W_OK = 2;
+pub const R_OK = 4;
+
+pub const O = struct {
+ pub const PATH = 0x0000;
+ /// open for reading only
+ pub const RDONLY = 0x0000;
+ /// open for writing only
+ pub const WRONLY = 0x0001;
+ /// open for reading and writing
+ pub const RDWR = 0x0002;
+ /// do not block on open or for data to become available
+ pub const NONBLOCK = 0x0004;
+ /// append on each write
+ pub const APPEND = 0x0008;
+ /// create file if it does not exist
+ pub const CREAT = 0x0200;
+ /// truncate size to 0
+ pub const TRUNC = 0x0400;
+ /// error if CREAT and the file exists
+ pub const EXCL = 0x0800;
+ /// atomically obtain a shared lock
+ pub const SHLOCK = 0x0010;
+ /// atomically obtain an exclusive lock
+ pub const EXLOCK = 0x0020;
+ /// do not follow symlinks
+ pub const NOFOLLOW = 0x0100;
+ /// allow open of symlinks
+ pub const SYMLINK = 0x200000;
+ /// descriptor requested for event notifications only
+ pub const EVTONLY = 0x8000;
+ /// mark as close-on-exec
+ pub const CLOEXEC = 0x1000000;
+ pub const ACCMODE = 3;
+ pub const ALERT = 536870912;
+ pub const ASYNC = 64;
+ pub const DIRECTORY = 1048576;
+ pub const DP_GETRAWENCRYPTED = 1;
+ pub const DP_GETRAWUNENCRYPTED = 2;
+ pub const DSYNC = 4194304;
+ pub const FSYNC = SYNC;
+ pub const NOCTTY = 131072;
+ pub const POPUP = 2147483648;
+ pub const SYNC = 128;
+};
+
+pub const SEEK = struct {
+ pub const SET = 0x0;
+ pub const CUR = 0x1;
+ pub const END = 0x2;
+};
+
+pub const DT = struct {
+ pub const UNKNOWN = 0;
+ pub const FIFO = 1;
+ pub const CHR = 2;
+ pub const DIR = 4;
+ pub const BLK = 6;
+ pub const REG = 8;
+ pub const LNK = 10;
+ pub const SOCK = 12;
+ pub const WHT = 14;
+};
+
+/// no flag value
+pub const KEVENT_FLAG_NONE = 0x000;
+
+/// immediate timeout
+pub const KEVENT_FLAG_IMMEDIATE = 0x001;
+
+/// output events only include change
+pub const KEVENT_FLAG_ERROR_EVENTS = 0x002;
+
+/// add event to kq (implies enable)
+pub const EV_ADD = 0x0001;
+
+/// delete event from kq
+pub const EV_DELETE = 0x0002;
+
+/// enable event
+pub const EV_ENABLE = 0x0004;
+
+/// disable event (not reported)
+pub const EV_DISABLE = 0x0008;
+
+/// only report one occurrence
+pub const EV_ONESHOT = 0x0010;
+
+/// clear event state after reporting
+pub const EV_CLEAR = 0x0020;
+
+/// force immediate event output
+/// ... with or without EV_ERROR
+/// ... use KEVENT_FLAG_ERROR_EVENTS
+/// on syscalls supporting flags
+pub const EV_RECEIPT = 0x0040;
+
+/// disable event after reporting
+pub const EV_DISPATCH = 0x0080;
+
+/// unique kevent per udata value
+pub const EV_UDATA_SPECIFIC = 0x0100;
+
+/// ... in combination with EV_DELETE
+/// will defer delete until udata-specific
+/// event enabled. EINPROGRESS will be
+/// returned to indicate the deferral
+pub const EV_DISPATCH2 = EV_DISPATCH | EV_UDATA_SPECIFIC;
+
+/// report that source has vanished
+/// ... only valid with EV_DISPATCH2
+pub const EV_VANISHED = 0x0200;
+
+/// reserved by system
+pub const EV_SYSFLAGS = 0xF000;
+
+/// filter-specific flag
+pub const EV_FLAG0 = 0x1000;
+
+/// filter-specific flag
+pub const EV_FLAG1 = 0x2000;
+
+/// EOF detected
+pub const EV_EOF = 0x8000;
+
+/// error, data contains errno
+pub const EV_ERROR = 0x4000;
+
+pub const EV_POLL = EV_FLAG0;
+pub const EV_OOBAND = EV_FLAG1;
+
+pub const EVFILT_READ = -1;
+pub const EVFILT_WRITE = -2;
+
+/// attached to aio requests
+pub const EVFILT_AIO = -3;
+
+/// attached to vnodes
+pub const EVFILT_VNODE = -4;
+
+/// attached to struct proc
+pub const EVFILT_PROC = -5;
+
+/// attached to struct proc
+pub const EVFILT_SIGNAL = -6;
+
+/// timers
+pub const EVFILT_TIMER = -7;
+
+/// Mach portsets
+pub const EVFILT_MACHPORT = -8;
+
+/// Filesystem events
+pub const EVFILT_FS = -9;
+
+/// User events
+pub const EVFILT_USER = -10;
+
+/// Virtual memory events
+pub const EVFILT_VM = -12;
+
+/// Exception events
+pub const EVFILT_EXCEPT = -15;
+
+pub const EVFILT_SYSCOUNT = 17;
+
+/// On input, NOTE_TRIGGER causes the event to be triggered for output.
+pub const NOTE_TRIGGER = 0x01000000;
+
+/// ignore input fflags
+pub const NOTE_FFNOP = 0x00000000;
+
+/// and fflags
+pub const NOTE_FFAND = 0x40000000;
+
+/// or fflags
+pub const NOTE_FFOR = 0x80000000;
+
+/// copy fflags
+pub const NOTE_FFCOPY = 0xc0000000;
+
+/// mask for operations
+pub const NOTE_FFCTRLMASK = 0xc0000000;
+pub const NOTE_FFLAGSMASK = 0x00ffffff;
+
+/// low water mark
+pub const NOTE_LOWAT = 0x00000001;
+
+/// OOB data
+pub const NOTE_OOB = 0x00000002;
+
+/// vnode was removed
+pub const NOTE_DELETE = 0x00000001;
+
+/// data contents changed
+pub const NOTE_WRITE = 0x00000002;
+
+/// size increased
+pub const NOTE_EXTEND = 0x00000004;
+
+/// attributes changed
+pub const NOTE_ATTRIB = 0x00000008;
+
+/// link count changed
+pub const NOTE_LINK = 0x00000010;
+
+/// vnode was renamed
+pub const NOTE_RENAME = 0x00000020;
+
+/// vnode access was revoked
+pub const NOTE_REVOKE = 0x00000040;
+
+/// No specific vnode event: to test for EVFILT_READ activation
+pub const NOTE_NONE = 0x00000080;
+
+/// vnode was unlocked by flock(2)
+pub const NOTE_FUNLOCK = 0x00000100;
+
+/// process exited
+pub const NOTE_EXIT = 0x80000000;
+
+/// process forked
+pub const NOTE_FORK = 0x40000000;
+
+/// process exec'd
+pub const NOTE_EXEC = 0x20000000;
+
+/// shared with EVFILT_SIGNAL
+pub const NOTE_SIGNAL = 0x08000000;
+
+/// exit status to be returned, valid for child process only
+pub const NOTE_EXITSTATUS = 0x04000000;
+
+/// provide details on reasons for exit
+pub const NOTE_EXIT_DETAIL = 0x02000000;
+
+/// mask for signal & exit status
+pub const NOTE_PDATAMASK = 0x000fffff;
+pub const NOTE_PCTRLMASK = (~NOTE_PDATAMASK);
+
+pub const NOTE_EXIT_DETAIL_MASK = 0x00070000;
+pub const NOTE_EXIT_DECRYPTFAIL = 0x00010000;
+pub const NOTE_EXIT_MEMORY = 0x00020000;
+pub const NOTE_EXIT_CSERROR = 0x00040000;
+
+/// will react on memory pressure
+pub const NOTE_VM_PRESSURE = 0x80000000;
+
+/// will quit on memory pressure, possibly after cleaning up dirty state
+pub const NOTE_VM_PRESSURE_TERMINATE = 0x40000000;
+
+/// will quit immediately on memory pressure
+pub const NOTE_VM_PRESSURE_SUDDEN_TERMINATE = 0x20000000;
+
+/// there was an error
+pub const NOTE_VM_ERROR = 0x10000000;
+
+/// data is seconds
+pub const NOTE_SECONDS = 0x00000001;
+
+/// data is microseconds
+pub const NOTE_USECONDS = 0x00000002;
+
+/// data is nanoseconds
+pub const NOTE_NSECONDS = 0x00000004;
+
+/// absolute timeout
+pub const NOTE_ABSOLUTE = 0x00000008;
+
+/// ext[1] holds leeway for power aware timers
+pub const NOTE_LEEWAY = 0x00000010;
+
+/// system does minimal timer coalescing
+pub const NOTE_CRITICAL = 0x00000020;
+
+/// system does maximum timer coalescing
+pub const NOTE_BACKGROUND = 0x00000040;
+pub const NOTE_MACH_CONTINUOUS_TIME = 0x00000080;
+
+/// data is mach absolute time units
+pub const NOTE_MACHTIME = 0x00000100;
+
+pub const AF = struct {
+ pub const UNSPEC = 0;
+ pub const LOCAL = 1;
+ pub const UNIX = LOCAL;
+ pub const INET = 2;
+ pub const SYS_CONTROL = 2;
+ pub const IMPLINK = 3;
+ pub const PUP = 4;
+ pub const CHAOS = 5;
+ pub const NS = 6;
+ pub const ISO = 7;
+ pub const OSI = ISO;
+ pub const ECMA = 8;
+ pub const DATAKIT = 9;
+ pub const CCITT = 10;
+ pub const SNA = 11;
+ pub const DECnet = 12;
+ pub const DLI = 13;
+ pub const LAT = 14;
+ pub const HYLINK = 15;
+ pub const APPLETALK = 16;
+ pub const ROUTE = 17;
+ pub const LINK = 18;
+ pub const XTP = 19;
+ pub const COIP = 20;
+ pub const CNT = 21;
+ pub const RTIP = 22;
+ pub const IPX = 23;
+ pub const SIP = 24;
+ pub const PIP = 25;
+ pub const ISDN = 28;
+ pub const E164 = ISDN;
+ pub const KEY = 29;
+ pub const INET6 = 30;
+ pub const NATM = 31;
+ pub const SYSTEM = 32;
+ pub const NETBIOS = 33;
+ pub const PPP = 34;
+ pub const MAX = 40;
+};
+
+pub const PF = struct {
+ pub const UNSPEC = AF.UNSPEC;
+ pub const LOCAL = AF.LOCAL;
+ pub const UNIX = PF.LOCAL;
+ pub const INET = AF.INET;
+ pub const IMPLINK = AF.IMPLINK;
+ pub const PUP = AF.PUP;
+ pub const CHAOS = AF.CHAOS;
+ pub const NS = AF.NS;
+ pub const ISO = AF.ISO;
+ pub const OSI = AF.ISO;
+ pub const ECMA = AF.ECMA;
+ pub const DATAKIT = AF.DATAKIT;
+ pub const CCITT = AF.CCITT;
+ pub const SNA = AF.SNA;
+ pub const DECnet = AF.DECnet;
+ pub const DLI = AF.DLI;
+ pub const LAT = AF.LAT;
+ pub const HYLINK = AF.HYLINK;
+ pub const APPLETALK = AF.APPLETALK;
+ pub const ROUTE = AF.ROUTE;
+ pub const LINK = AF.LINK;
+ pub const XTP = AF.XTP;
+ pub const COIP = AF.COIP;
+ pub const CNT = AF.CNT;
+ pub const SIP = AF.SIP;
+ pub const IPX = AF.IPX;
+ pub const RTIP = AF.RTIP;
+ pub const PIP = AF.PIP;
+ pub const ISDN = AF.ISDN;
+ pub const KEY = AF.KEY;
+ pub const INET6 = AF.INET6;
+ pub const NATM = AF.NATM;
+ pub const SYSTEM = AF.SYSTEM;
+ pub const NETBIOS = AF.NETBIOS;
+ pub const PPP = AF.PPP;
+ pub const MAX = AF.MAX;
+};
+
+pub const SYSPROTO_EVENT = 1;
+pub const SYSPROTO_CONTROL = 2;
+
+pub const SOCK = struct {
+ pub const STREAM = 1;
+ pub const DGRAM = 2;
+ pub const RAW = 3;
+ pub const RDM = 4;
+ pub const SEQPACKET = 5;
+ pub const MAXADDRLEN = 255;
+
+ /// Not actually supported by Darwin, but Zig supplies a shim.
+ /// This numerical value is not ABI-stable. It need only not conflict
+ /// with any other `SOCK` bits.
+ pub const CLOEXEC = 1 << 15;
+ /// Not actually supported by Darwin, but Zig supplies a shim.
+ /// This numerical value is not ABI-stable. It need only not conflict
+ /// with any other `SOCK` bits.
+ pub const NONBLOCK = 1 << 16;
+};
+
+pub const IPPROTO = struct {
+ pub const ICMP = 1;
+ pub const ICMPV6 = 58;
+ pub const TCP = 6;
+ pub const UDP = 17;
+ pub const IP = 0;
+ pub const IPV6 = 41;
+};
+
+pub const SOL = struct {
+ pub const SOCKET = 0xffff;
+};
+
+pub const SO = struct {
+ pub const DEBUG = 0x0001;
+ pub const ACCEPTCONN = 0x0002;
+ pub const REUSEADDR = 0x0004;
+ pub const KEEPALIVE = 0x0008;
+ pub const DONTROUTE = 0x0010;
+ pub const BROADCAST = 0x0020;
+ pub const USELOOPBACK = 0x0040;
+ pub const LINGER = 0x1080;
+ pub const OOBINLINE = 0x0100;
+ pub const REUSEPORT = 0x0200;
+ pub const ACCEPTFILTER = 0x1000;
+ pub const SNDBUF = 0x1001;
+ pub const RCVBUF = 0x1002;
+ pub const SNDLOWAT = 0x1003;
+ pub const RCVLOWAT = 0x1004;
+ pub const SNDTIMEO = 0x1005;
+ pub const RCVTIMEO = 0x1006;
+ pub const ERROR = 0x1007;
+ pub const TYPE = 0x1008;
+
+ pub const NREAD = 0x1020;
+ pub const NKE = 0x1021;
+ pub const NOSIGPIPE = 0x1022;
+ pub const NOADDRERR = 0x1023;
+ pub const NWRITE = 0x1024;
+ pub const REUSESHAREUID = 0x1025;
+};
+
+pub const W = struct {
+ /// [XSI] no hang in wait/no child to reap
+ pub const NOHANG = 0x00000001;
+ /// [XSI] notify on stop, untraced child
+ pub const UNTRACED = 0x00000002;
+
+ pub fn EXITSTATUS(x: u32) u8 {
+ return @intCast(u8, x >> 8);
+ }
+ pub fn TERMSIG(x: u32) u32 {
+ return status(x);
+ }
+ pub fn STOPSIG(x: u32) u32 {
+ return x >> 8;
+ }
+ pub fn IFEXITED(x: u32) bool {
+ return status(x) == 0;
+ }
+ pub fn IFSTOPPED(x: u32) bool {
+ return status(x) == stopped and STOPSIG(x) != 0x13;
+ }
+ pub fn IFSIGNALED(x: u32) bool {
+ return status(x) != stopped and status(x) != 0;
+ }
+
+ fn status(x: u32) u32 {
+ return x & 0o177;
+ }
+ const stopped = 0o177;
+};
+
+pub const E = enum(u16) {
+ /// No error occurred.
+ SUCCESS = 0,
+
+ /// Operation not permitted
+ PERM = 1,
+
+ /// No such file or directory
+ NOENT = 2,
+
+ /// No such process
+ SRCH = 3,
+
+ /// Interrupted system call
+ INTR = 4,
+
+ /// Input/output error
+ IO = 5,
+
+ /// Device not configured
+ NXIO = 6,
+
+ /// Argument list too long
+ @"2BIG" = 7,
+
+ /// Exec format error
+ NOEXEC = 8,
+
+ /// Bad file descriptor
+ BADF = 9,
+
+ /// No child processes
+ CHILD = 10,
+
+ /// Resource deadlock avoided
+ DEADLK = 11,
+
+ /// Cannot allocate memory
+ NOMEM = 12,
+
+ /// Permission denied
+ ACCES = 13,
+
+ /// Bad address
+ FAULT = 14,
+
+ /// Block device required
+ NOTBLK = 15,
+
+ /// Device / Resource busy
+ BUSY = 16,
+
+ /// File exists
+ EXIST = 17,
+
+ /// Cross-device link
+ XDEV = 18,
+
+ /// Operation not supported by device
+ NODEV = 19,
+
+ /// Not a directory
+ NOTDIR = 20,
+
+ /// Is a directory
+ ISDIR = 21,
+
+ /// Invalid argument
+ INVAL = 22,
+
+ /// Too many open files in system
+ NFILE = 23,
+
+ /// Too many open files
+ MFILE = 24,
+
+ /// Inappropriate ioctl for device
+ NOTTY = 25,
+
+ /// Text file busy
+ TXTBSY = 26,
+
+ /// File too large
+ FBIG = 27,
+
+ /// No space left on device
+ NOSPC = 28,
+
+ /// Illegal seek
+ SPIPE = 29,
+
+ /// Read-only file system
+ ROFS = 30,
+
+ /// Too many links
+ MLINK = 31,
+
+ /// Broken pipe
+ PIPE = 32,
+
+ // math software
+
+ /// Numerical argument out of domain
+ DOM = 33,
+
+ /// Result too large
+ RANGE = 34,
+
+ // non-blocking and interrupt i/o
+
+ /// Resource temporarily unavailable
+ /// This is the same code used for `WOULDBLOCK`.
+ AGAIN = 35,
+
+ /// Operation now in progress
+ INPROGRESS = 36,
+
+ /// Operation already in progress
+ ALREADY = 37,
+
+ // ipc/network software -- argument errors
+
+ /// Socket operation on non-socket
+ NOTSOCK = 38,
+
+ /// Destination address required
+ DESTADDRREQ = 39,
+
+ /// Message too long
+ MSGSIZE = 40,
+
+ /// Protocol wrong type for socket
+ PROTOTYPE = 41,
+
+ /// Protocol not available
+ NOPROTOOPT = 42,
+
+ /// Protocol not supported
+ PROTONOSUPPORT = 43,
+
+ /// Socket type not supported
+ SOCKTNOSUPPORT = 44,
+
+ /// Operation not supported
+ /// The same code is used for `NOTSUP`.
+ OPNOTSUPP = 45,
+
+ /// Protocol family not supported
+ PFNOSUPPORT = 46,
+
+ /// Address family not supported by protocol family
+ AFNOSUPPORT = 47,
+
+ /// Address already in use
+ ADDRINUSE = 48,
+ /// Can't assign requested address
+
+ // ipc/network software -- operational errors
+ ADDRNOTAVAIL = 49,
+
+ /// Network is down
+ NETDOWN = 50,
+
+ /// Network is unreachable
+ NETUNREACH = 51,
+
+ /// Network dropped connection on reset
+ NETRESET = 52,
+
+ /// Software caused connection abort
+ CONNABORTED = 53,
+
+ /// Connection reset by peer
+ CONNRESET = 54,
+
+ /// No buffer space available
+ NOBUFS = 55,
+
+ /// Socket is already connected
+ ISCONN = 56,
+
+ /// Socket is not connected
+ NOTCONN = 57,
+
+ /// Can't send after socket shutdown
+ SHUTDOWN = 58,
+
+ /// Too many references: can't splice
+ TOOMANYREFS = 59,
+
+ /// Operation timed out
+ TIMEDOUT = 60,
+
+ /// Connection refused
+ CONNREFUSED = 61,
+
+ /// Too many levels of symbolic links
+ LOOP = 62,
+
+ /// File name too long
+ NAMETOOLONG = 63,
+
+ /// Host is down
+ HOSTDOWN = 64,
+
+ /// No route to host
+ HOSTUNREACH = 65,
+ /// Directory not empty
+
+ // quotas & mush
+ NOTEMPTY = 66,
+
+ /// Too many processes
+ PROCLIM = 67,
+
+ /// Too many users
+ USERS = 68,
+ /// Disc quota exceeded
+
+ // Network File System
+ DQUOT = 69,
+
+ /// Stale NFS file handle
+ STALE = 70,
+
+ /// Too many levels of remote in path
+ REMOTE = 71,
+
+ /// RPC struct is bad
+ BADRPC = 72,
+
+ /// RPC version wrong
+ RPCMISMATCH = 73,
+
+ /// RPC prog. not avail
+ PROGUNAVAIL = 74,
+
+ /// Program version wrong
+ PROGMISMATCH = 75,
+
+ /// Bad procedure for program
+ PROCUNAVAIL = 76,
+
+ /// No locks available
+ NOLCK = 77,
+
+ /// Function not implemented
+ NOSYS = 78,
+
+ /// Inappropriate file type or format
+ FTYPE = 79,
+
+ /// Authentication error
+ AUTH = 80,
+
+ /// Need authenticator
+ NEEDAUTH = 81,
+
+ // Intelligent device errors
+
+ /// Device power is off
+ PWROFF = 82,
+
+ /// Device error, e.g. paper out
+ DEVERR = 83,
+
+ /// Value too large to be stored in data type
+ OVERFLOW = 84,
+
+ // Program loading errors
+
+ /// Bad executable
+ BADEXEC = 85,
+
+ /// Bad CPU type in executable
+ BADARCH = 86,
+
+ /// Shared library version mismatch
+ SHLIBVERS = 87,
+
+ /// Malformed Macho file
+ BADMACHO = 88,
+
+ /// Operation canceled
+ CANCELED = 89,
+
+ /// Identifier removed
+ IDRM = 90,
+
+ /// No message of desired type
+ NOMSG = 91,
+
+ /// Illegal byte sequence
+ ILSEQ = 92,
+
+ /// Attribute not found
+ NOATTR = 93,
+
+ /// Bad message
+ BADMSG = 94,
+
+ /// Reserved
+ MULTIHOP = 95,
+
+ /// No message available on STREAM
+ NODATA = 96,
+
+ /// Reserved
+ NOLINK = 97,
+
+ /// No STREAM resources
+ NOSR = 98,
+
+ /// Not a STREAM
+ NOSTR = 99,
+
+ /// Protocol error
+ PROTO = 100,
+
+ /// STREAM ioctl timeout
+ TIME = 101,
+
+ /// No such policy registered
+ NOPOLICY = 103,
+
+ /// State not recoverable
+ NOTRECOVERABLE = 104,
+
+ /// Previous owner died
+ OWNERDEAD = 105,
+
+ /// Interface output queue is full
+ QFULL = 106,
+
+ _,
+};
+
+pub const SIGSTKSZ = 131072;
+pub const MINSIGSTKSZ = 32768;
+
+pub const SS_ONSTACK = 1;
+pub const SS_DISABLE = 4;
+
+pub const stack_t = extern struct {
+ sp: [*]u8,
+ size: isize,
+ flags: i32,
+};
+
+pub const S = struct {
+ pub const IFMT = 0o170000;
+
+ pub const IFIFO = 0o010000;
+ pub const IFCHR = 0o020000;
+ pub const IFDIR = 0o040000;
+ pub const IFBLK = 0o060000;
+ pub const IFREG = 0o100000;
+ pub const IFLNK = 0o120000;
+ pub const IFSOCK = 0o140000;
+ pub const IFWHT = 0o160000;
+
+ pub const ISUID = 0o4000;
+ pub const ISGID = 0o2000;
+ pub const ISVTX = 0o1000;
+ pub const IRWXU = 0o700;
+ pub const IRUSR = 0o400;
+ pub const IWUSR = 0o200;
+ pub const IXUSR = 0o100;
+ pub const IRWXG = 0o070;
+ pub const IRGRP = 0o040;
+ pub const IWGRP = 0o020;
+ pub const IXGRP = 0o010;
+ pub const IRWXO = 0o007;
+ pub const IROTH = 0o004;
+ pub const IWOTH = 0o002;
+ pub const IXOTH = 0o001;
+
+ pub fn ISFIFO(m: u32) bool {
+ return m & IFMT == IFIFO;
+ }
+
+ pub fn ISCHR(m: u32) bool {
+ return m & IFMT == IFCHR;
+ }
+
+ pub fn ISDIR(m: u32) bool {
+ return m & IFMT == IFDIR;
+ }
+
+ pub fn ISBLK(m: u32) bool {
+ return m & IFMT == IFBLK;
+ }
+
+ pub fn ISREG(m: u32) bool {
+ return m & IFMT == IFREG;
+ }
+
+ pub fn ISLNK(m: u32) bool {
+ return m & IFMT == IFLNK;
+ }
+
+ pub fn ISSOCK(m: u32) bool {
+ return m & IFMT == IFSOCK;
+ }
+
+ pub fn IWHT(m: u32) bool {
+ return m & IFMT == IFWHT;
+ }
+};
+
+pub const HOST_NAME_MAX = 72;
+
+pub const AT = struct {
+ pub const FDCWD = -2;
+ /// Use effective ids in access check
+ pub const EACCESS = 0x0010;
+ /// Act on the symlink itself not the target
+ pub const SYMLINK_NOFOLLOW = 0x0020;
+ /// Act on target of symlink
+ pub const SYMLINK_FOLLOW = 0x0040;
+ /// Path refers to directory
+ pub const REMOVEDIR = 0x0080;
+};
+
+pub const addrinfo = extern struct {
+ flags: i32,
+ family: i32,
+ socktype: i32,
+ protocol: i32,
+ addrlen: socklen_t,
+ canonname: ?[*:0]u8,
+ addr: ?*sockaddr,
+ next: ?*addrinfo,
+};
+
+pub const RTLD = struct {
+ pub const LAZY = 0x1;
+ pub const NOW = 0x2;
+ pub const LOCAL = 0x4;
+ pub const GLOBAL = 0x8;
+ pub const NOLOAD = 0x10;
+ pub const NODELETE = 0x80;
+ pub const FIRST = 0x100;
+
+ pub const NEXT = @intToPtr(*c_void, @bitCast(usize, @as(isize, -1)));
+ pub const DEFAULT = @intToPtr(*c_void, @bitCast(usize, @as(isize, -2)));
+ pub const SELF = @intToPtr(*c_void, @bitCast(usize, @as(isize, -3)));
+ pub const MAIN_ONLY = @intToPtr(*c_void, @bitCast(usize, @as(isize, -5)));
+};
+
+pub const F = struct {
+ /// duplicate file descriptor
+ pub const DUPFD = 0;
+ /// get file descriptor flags
+ pub const GETFD = 1;
+ /// set file descriptor flags
+ pub const SETFD = 2;
+ /// get file status flags
+ pub const GETFL = 3;
+ /// set file status flags
+ pub const SETFL = 4;
+ /// get SIGIO/SIGURG proc/pgrp
+ pub const GETOWN = 5;
+ /// set SIGIO/SIGURG proc/pgrp
+ pub const SETOWN = 6;
+ /// get record locking information
+ pub const GETLK = 7;
+ /// set record locking information
+ pub const SETLK = 8;
+ /// F.SETLK; wait if blocked
+ pub const SETLKW = 9;
+ /// F.SETLK; wait if blocked, return on timeout
+ pub const SETLKWTIMEOUT = 10;
+ pub const FLUSH_DATA = 40;
+ /// Used for regression test
+ pub const CHKCLEAN = 41;
+ /// Preallocate storage
+ pub const PREALLOCATE = 42;
+ /// Truncate a file without zeroing space
+ pub const SETSIZE = 43;
+ /// Issue an advisory read async with no copy to user
+ pub const RDADVISE = 44;
+ /// turn read ahead off/on for this fd
+ pub const RDAHEAD = 45;
+ /// turn data caching off/on for this fd
+ pub const NOCACHE = 48;
+ /// file offset to device offset
+ pub const LOG2PHYS = 49;
+ /// return the full path of the fd
+ pub const GETPATH = 50;
+ /// fsync + ask the drive to flush to the media
+ pub const FULLFSYNC = 51;
+ /// find which component (if any) is a package
+ pub const PATHPKG_CHECK = 52;
+ /// "freeze" all fs operations
+ pub const FREEZE_FS = 53;
+ /// "thaw" all fs operations
+ pub const THAW_FS = 54;
+ /// turn data caching off/on (globally) for this file
+ pub const GLOBAL_NOCACHE = 55;
+ /// add detached signatures
+ pub const ADDSIGS = 59;
+ /// add signature from same file (used by dyld for shared libs)
+ pub const ADDFILESIGS = 61;
+ /// used in conjunction with F.NOCACHE to indicate that DIRECT, synchonous writes
+ /// should not be used (i.e. its ok to temporaily create cached pages)
+ pub const NODIRECT = 62;
+ ///Get the protection class of a file from the EA, returns int
+ pub const GETPROTECTIONCLASS = 63;
+ ///Set the protection class of a file for the EA, requires int
+ pub const SETPROTECTIONCLASS = 64;
+ ///file offset to device offset, extended
+ pub const LOG2PHYS_EXT = 65;
+ ///get record locking information, per-process
+ pub const GETLKPID = 66;
+ ///Mark the file as being the backing store for another filesystem
+ pub const SETBACKINGSTORE = 70;
+ ///return the full path of the FD, but error in specific mtmd circumstances
+ pub const GETPATH_MTMINFO = 71;
+ ///Returns the code directory, with associated hashes, to the caller
+ pub const GETCODEDIR = 72;
+ ///No SIGPIPE generated on EPIPE
+ pub const SETNOSIGPIPE = 73;
+ ///Status of SIGPIPE for this fd
+ pub const GETNOSIGPIPE = 74;
+ ///For some cases, we need to rewrap the key for AKS/MKB
+ pub const TRANSCODEKEY = 75;
+ ///file being written to a by single writer... if throttling enabled, writes
+ ///may be broken into smaller chunks with throttling in between
+ pub const SINGLE_WRITER = 76;
+ ///Get the protection version number for this filesystem
+ pub const GETPROTECTIONLEVEL = 77;
+ ///Add detached code signatures (used by dyld for shared libs)
+ pub const FINDSIGS = 78;
+ ///Add signature from same file, only if it is signed by Apple (used by dyld for simulator)
+ pub const ADDFILESIGS_FOR_DYLD_SIM = 83;
+ ///fsync + issue barrier to drive
+ pub const BARRIERFSYNC = 85;
+ ///Add signature from same file, return end offset in structure on success
+ pub const ADDFILESIGS_RETURN = 97;
+ ///Check if Library Validation allows this Mach-O file to be mapped into the calling process
+ pub const CHECK_LV = 98;
+ ///Deallocate a range of the file
+ pub const PUNCHHOLE = 99;
+ ///Trim an active file
+ pub const TRIM_ACTIVE_FILE = 100;
+ ///mark the dup with FD_CLOEXEC
+ pub const DUPFD_CLOEXEC = 67;
+ /// shared or read lock
+ pub const RDLCK = 1;
+ /// unlock
+ pub const UNLCK = 2;
+ /// exclusive or write lock
+ pub const WRLCK = 3;
+};
+
+pub const FCNTL_FS_SPECIFIC_BASE = 0x00010000;
+
+///close-on-exec flag
+pub const FD_CLOEXEC = 1;
+
+pub const LOCK = struct {
+ pub const SH = 1;
+ pub const EX = 2;
+ pub const UN = 8;
+ pub const NB = 4;
+};
+
+pub const nfds_t = u32;
+pub const pollfd = extern struct {
+ fd: fd_t,
+ events: i16,
+ revents: i16,
+};
+
+pub const POLL = struct {
+ pub const IN = 0x001;
+ pub const PRI = 0x002;
+ pub const OUT = 0x004;
+ pub const RDNORM = 0x040;
+ pub const WRNORM = OUT;
+ pub const RDBAND = 0x080;
+ pub const WRBAND = 0x100;
+
+ pub const EXTEND = 0x0200;
+ pub const ATTRIB = 0x0400;
+ pub const NLINK = 0x0800;
+ pub const WRITE = 0x1000;
+
+ pub const ERR = 0x008;
+ pub const HUP = 0x010;
+ pub const NVAL = 0x020;
+
+ pub const STANDARD = IN | PRI | OUT | RDNORM | RDBAND | WRBAND | ERR | HUP | NVAL;
+};
+
+pub const CLOCK = struct {
+ pub const REALTIME = 0;
+ pub const MONOTONIC = 6;
+ pub const MONOTONIC_RAW = 4;
+ pub const MONOTONIC_RAW_APPROX = 5;
+ pub const UPTIME_RAW = 8;
+ pub const UPTIME_RAW_APPROX = 9;
+ pub const PROCESS_CPUTIME_ID = 12;
+ pub const THREAD_CPUTIME_ID = 16;
+};
+
+/// Max open files per process
+/// https://opensource.apple.com/source/xnu/xnu-4903.221.2/bsd/sys/syslimits.h.auto.html
+pub const OPEN_MAX = 10240;
+pub const RUSAGE_SELF = 0;
+pub const RUSAGE_CHILDREN = -1;
+
+pub const rusage = extern struct {
+ utime: timeval,
+ stime: timeval,
+ maxrss: isize,
+ ixrss: isize,
+ idrss: isize,
+ isrss: isize,
+ minflt: isize,
+ majflt: isize,
+ nswap: isize,
+ inblock: isize,
+ oublock: isize,
+ msgsnd: isize,
+ msgrcv: isize,
+ nsignals: isize,
+ nvcsw: isize,
+ nivcsw: isize,
+};
+
+pub const rlimit_resource = enum(c_int) {
+ CPU = 0,
+ FSIZE = 1,
+ DATA = 2,
+ STACK = 3,
+ CORE = 4,
+ RSS = 5,
+ MEMLOCK = 6,
+ NPROC = 7,
+ NOFILE = 8,
+ _,
+
+ pub const AS: rlimit_resource = .RSS;
+};
+
+pub const rlim_t = u64;
+
+pub const RLIM = struct {
+ /// No limit
+ pub const INFINITY: rlim_t = (1 << 63) - 1;
+
+ pub const SAVED_MAX = INFINITY;
+ pub const SAVED_CUR = INFINITY;
+};
+
+pub const rlimit = extern struct {
+ /// Soft limit
+ cur: rlim_t,
+ /// Hard limit
+ max: rlim_t,
+};
+
+pub const SHUT = struct {
+ pub const RD = 0;
+ pub const WR = 1;
+ pub const RDWR = 2;
+};
+
+// Term
+pub const VEOF = 0;
+pub const VEOL = 1;
+pub const VEOL2 = 2;
+pub const VERASE = 3;
+pub const VWERASE = 4;
+pub const VKILL = 5;
+pub const VREPRINT = 6;
+pub const VINTR = 8;
+pub const VQUIT = 9;
+pub const VSUSP = 10;
+pub const VDSUSP = 11;
+pub const VSTART = 12;
+pub const VSTOP = 13;
+pub const VLNEXT = 14;
+pub const VDISCARD = 15;
+pub const VMIN = 16;
+pub const VTIME = 17;
+pub const VSTATUS = 18;
+pub const NCCS = 20; // 2 spares (7, 19)
+
+pub const IGNBRK = 0x00000001; // ignore BREAK condition
+pub const BRKINT = 0x00000002; // map BREAK to SIGINTR
+pub const IGNPAR = 0x00000004; // ignore (discard) parity errors
+pub const PARMRK = 0x00000008; // mark parity and framing errors
+pub const INPCK = 0x00000010; // enable checking of parity errors
+pub const ISTRIP = 0x00000020; // strip 8th bit off chars
+pub const INLCR = 0x00000040; // map NL into CR
+pub const IGNCR = 0x00000080; // ignore CR
+pub const ICRNL = 0x00000100; // map CR to NL (ala CRMOD)
+pub const IXON = 0x00000200; // enable output flow control
+pub const IXOFF = 0x00000400; // enable input flow control
+pub const IXANY = 0x00000800; // any char will restart after stop
+pub const IMAXBEL = 0x00002000; // ring bell on input queue full
+pub const IUTF8 = 0x00004000; // maintain state for UTF-8 VERASE
+
+pub const OPOST = 0x00000001; //enable following output processing
+pub const ONLCR = 0x00000002; // map NL to CR-NL (ala CRMOD)
+pub const OXTABS = 0x00000004; // expand tabs to spaces
+pub const ONOEOT = 0x00000008; // discard EOT's (^D) on output)
+
+pub const OCRNL = 0x00000010; // map CR to NL on output
+pub const ONOCR = 0x00000020; // no CR output at column 0
+pub const ONLRET = 0x00000040; // NL performs CR function
+pub const OFILL = 0x00000080; // use fill characters for delay
+pub const NLDLY = 0x00000300; // \n delay
+pub const TABDLY = 0x00000c04; // horizontal tab delay
+pub const CRDLY = 0x00003000; // \r delay
+pub const FFDLY = 0x00004000; // form feed delay
+pub const BSDLY = 0x00008000; // \b delay
+pub const VTDLY = 0x00010000; // vertical tab delay
+pub const OFDEL = 0x00020000; // fill is DEL, else NUL
+
+pub const NL0 = 0x00000000;
+pub const NL1 = 0x00000100;
+pub const NL2 = 0x00000200;
+pub const NL3 = 0x00000300;
+pub const TAB0 = 0x00000000;
+pub const TAB1 = 0x00000400;
+pub const TAB2 = 0x00000800;
+pub const TAB3 = 0x00000004;
+pub const CR0 = 0x00000000;
+pub const CR1 = 0x00001000;
+pub const CR2 = 0x00002000;
+pub const CR3 = 0x00003000;
+pub const FF0 = 0x00000000;
+pub const FF1 = 0x00004000;
+pub const BS0 = 0x00000000;
+pub const BS1 = 0x00008000;
+pub const VT0 = 0x00000000;
+pub const VT1 = 0x00010000;
+
+pub const CIGNORE = 0x00000001; // ignore control flags
+pub const CSIZE = 0x00000300; // character size mask
+pub const CS5 = 0x00000000; // 5 bits (pseudo)
+pub const CS6 = 0x00000100; // 6 bits
+pub const CS7 = 0x00000200; // 7 bits
+pub const CS8 = 0x00000300; // 8 bits
+pub const CSTOPB = 0x0000040; // send 2 stop bits
+pub const CREAD = 0x00000800; // enable receiver
+pub const PARENB = 0x00001000; // parity enable
+pub const PARODD = 0x00002000; // odd parity, else even
+pub const HUPCL = 0x00004000; // hang up on last close
+pub const CLOCAL = 0x00008000; // ignore modem status lines
+pub const CCTS_OFLOW = 0x00010000; // CTS flow control of output
+pub const CRTSCTS = (CCTS_OFLOW | CRTS_IFLOW);
+pub const CRTS_IFLOW = 0x00020000; // RTS flow control of input
+pub const CDTR_IFLOW = 0x00040000; // DTR flow control of input
+pub const CDSR_OFLOW = 0x00080000; // DSR flow control of output
+pub const CCAR_OFLOW = 0x00100000; // DCD flow control of output
+pub const MDMBUF = 0x00100000; // old name for CCAR_OFLOW
+
+pub const ECHOKE = 0x00000001; // visual erase for line kill
+pub const ECHOE = 0x00000002; // visually erase chars
+pub const ECHOK = 0x00000004; // echo NL after line kill
+pub const ECHO = 0x00000008; // enable echoing
+pub const ECHONL = 0x00000010; // echo NL even if ECHO is off
+pub const ECHOPRT = 0x00000020; // visual erase mode for hardcopy
+pub const ECHOCTL = 0x00000040; // echo control chars as ^(Char)
+pub const ISIG = 0x00000080; // enable signals INTR, QUIT, [D]SUSP
+pub const ICANON = 0x00000100; // canonicalize input lines
+pub const ALTWERASE = 0x00000200; // use alternate WERASE algorithm
+pub const IEXTEN = 0x00000400; // enable DISCARD and LNEXT
+pub const EXTPROC = 0x00000800; // external processing
+pub const TOSTOP = 0x00400000; // stop background jobs from output
+pub const FLUSHO = 0x00800000; // output being flushed (state)
+pub const NOKERNINFO = 0x02000000; // no kernel output from VSTATUS
+pub const PENDIN = 0x20000000; // XXX retype pending input (state)
+pub const NOFLSH = 0x80000000; // don't flush after interrupt
+
+pub const TCSANOW = 0; // make change immediate
+pub const TCSADRAIN = 1; // drain output, then change
+pub const TCSAFLUSH = 2; // drain output, flush input
+pub const TCSASOFT = 0x10; // flag - don't alter h.w. state
+pub const TCSA = enum(c_uint) {
+ NOW,
+ DRAIN,
+ FLUSH,
+ _,
+};
+
+pub const B0 = 0;
+pub const B50 = 50;
+pub const B75 = 75;
+pub const B110 = 110;
+pub const B134 = 134;
+pub const B150 = 150;
+pub const B200 = 200;
+pub const B300 = 300;
+pub const B600 = 600;
+pub const B1200 = 1200;
+pub const B1800 = 1800;
+pub const B2400 = 2400;
+pub const B4800 = 4800;
+pub const B9600 = 9600;
+pub const B19200 = 19200;
+pub const B38400 = 38400;
+pub const B7200 = 7200;
+pub const B14400 = 14400;
+pub const B28800 = 28800;
+pub const B57600 = 57600;
+pub const B76800 = 76800;
+pub const B115200 = 115200;
+pub const B230400 = 230400;
+pub const EXTA = 19200;
+pub const EXTB = 38400;
+
+pub const TCIFLUSH = 1;
+pub const TCOFLUSH = 2;
+pub const TCIOFLUSH = 3;
+pub const TCOOFF = 1;
+pub const TCOON = 2;
+pub const TCIOFF = 3;
+pub const TCION = 4;
+
+pub const cc_t = u8;
+pub const speed_t = u64;
+pub const tcflag_t = u64;
+
+pub const termios = extern struct {
+ iflag: tcflag_t, // input flags
+ oflag: tcflag_t, // output flags
+ cflag: tcflag_t, // control flags
+ lflag: tcflag_t, // local flags
+ cc: [NCCS]cc_t, // control chars
+ ispeed: speed_t align(8), // input speed
+ ospeed: speed_t, // output speed
+};
+
+pub const winsize = extern struct {
+ ws_row: u16,
+ ws_col: u16,
+ ws_xpixel: u16,
+ ws_ypixel: u16,
+};
+
+pub const T = struct {
+ pub const IOCGWINSZ = ior(0x40000000, 't', 104, @sizeOf(winsize));
+};
+pub const IOCPARM_MASK = 0x1fff;
+
+fn ior(inout: u32, group: usize, num: usize, len: usize) usize {
+ return (inout | ((len & IOCPARM_MASK) << 16) | ((group) << 8) | (num));
+}
+
+// CPU families mapping
+pub const CPUFAMILY = enum(u32) {
+ UNKNOWN = 0,
+ POWERPC_G3 = 0xcee41549,
+ POWERPC_G4 = 0x77c184ae,
+ POWERPC_G5 = 0xed76d8aa,
+ INTEL_6_13 = 0xaa33392b,
+ INTEL_PENRYN = 0x78ea4fbc,
+ INTEL_NEHALEM = 0x6b5a4cd2,
+ INTEL_WESTMERE = 0x573b5eec,
+ INTEL_SANDYBRIDGE = 0x5490b78c,
+ INTEL_IVYBRIDGE = 0x1f65e835,
+ INTEL_HASWELL = 0x10b282dc,
+ INTEL_BROADWELL = 0x582ed09c,
+ INTEL_SKYLAKE = 0x37fc219f,
+ INTEL_KABYLAKE = 0x0f817246,
+ ARM_9 = 0xe73283ae,
+ ARM_11 = 0x8ff620d8,
+ ARM_XSCALE = 0x53b005f5,
+ ARM_12 = 0xbd1b0ae9,
+ ARM_13 = 0x0cc90e64,
+ ARM_14 = 0x96077ef1,
+ ARM_15 = 0xa8511bca,
+ ARM_SWIFT = 0x1e2d6381,
+ ARM_CYCLONE = 0x37a09642,
+ ARM_TYPHOON = 0x2c91a47e,
+ ARM_TWISTER = 0x92fb37c8,
+ ARM_HURRICANE = 0x67ceee93,
+ ARM_MONSOON_MISTRAL = 0xe81e7ef6,
+ ARM_VORTEX_TEMPEST = 0x07d34b9f,
+ ARM_LIGHTNING_THUNDER = 0x462504d2,
+ ARM_FIRESTORM_ICESTORM = 0x1b588bb3,
+ _,
+};
diff --git a/lib/std/c/dragonfly.zig b/lib/std/c/dragonfly.zig
index e5786d2bd400..35bbeac6a398 100644
--- a/lib/std/c/dragonfly.zig
+++ b/lib/std/c/dragonfly.zig
@@ -1,5 +1,7 @@
const std = @import("../std.zig");
-usingnamespace std.c;
+const maxInt = std.math.maxInt;
+const iovec = std.os.iovec;
+
extern "c" threadlocal var errno: c_int;
pub fn _errno() *c_int {
return &errno;
@@ -30,3 +32,1087 @@ pub const pthread_attr_t = extern struct { // copied from freebsd
};
pub const sem_t = ?*opaque {};
+
+// See:
+// - https://gitweb.dragonflybsd.org/dragonfly.git/blob/HEAD:/include/unistd.h
+// - https://gitweb.dragonflybsd.org/dragonfly.git/blob/HEAD:/sys/sys/types.h
+// TODO: mode_t should probably be changed to a u16, audit pid_t/off_t as well
+pub const fd_t = c_int;
+pub const pid_t = c_int;
+pub const off_t = c_long;
+pub const mode_t = c_uint;
+pub const uid_t = u32;
+pub const gid_t = u32;
+pub const time_t = isize;
+pub const suseconds_t = c_long;
+
+pub const E = enum(u16) {
+ /// No error occurred.
+ SUCCESS = 0,
+
+ PERM = 1,
+ NOENT = 2,
+ SRCH = 3,
+ INTR = 4,
+ IO = 5,
+ NXIO = 6,
+ @"2BIG" = 7,
+ NOEXEC = 8,
+ BADF = 9,
+ CHILD = 10,
+ DEADLK = 11,
+ NOMEM = 12,
+ ACCES = 13,
+ FAULT = 14,
+ NOTBLK = 15,
+ BUSY = 16,
+ EXIST = 17,
+ XDEV = 18,
+ NODEV = 19,
+ NOTDIR = 20,
+ ISDIR = 21,
+ INVAL = 22,
+ NFILE = 23,
+ MFILE = 24,
+ NOTTY = 25,
+ TXTBSY = 26,
+ FBIG = 27,
+ NOSPC = 28,
+ SPIPE = 29,
+ ROFS = 30,
+ MLINK = 31,
+ PIPE = 32,
+ DOM = 33,
+ RANGE = 34,
+ /// This code is also used for `WOULDBLOCK`.
+ AGAIN = 35,
+ INPROGRESS = 36,
+ ALREADY = 37,
+ NOTSOCK = 38,
+ DESTADDRREQ = 39,
+ MSGSIZE = 40,
+ PROTOTYPE = 41,
+ NOPROTOOPT = 42,
+ PROTONOSUPPORT = 43,
+ SOCKTNOSUPPORT = 44,
+ /// This code is also used for `NOTSUP`.
+ OPNOTSUPP = 45,
+ PFNOSUPPORT = 46,
+ AFNOSUPPORT = 47,
+ ADDRINUSE = 48,
+ ADDRNOTAVAIL = 49,
+ NETDOWN = 50,
+ NETUNREACH = 51,
+ NETRESET = 52,
+ CONNABORTED = 53,
+ CONNRESET = 54,
+ NOBUFS = 55,
+ ISCONN = 56,
+ NOTCONN = 57,
+ SHUTDOWN = 58,
+ TOOMANYREFS = 59,
+ TIMEDOUT = 60,
+ CONNREFUSED = 61,
+ LOOP = 62,
+ NAMETOOLONG = 63,
+ HOSTDOWN = 64,
+ HOSTUNREACH = 65,
+ NOTEMPTY = 66,
+ PROCLIM = 67,
+ USERS = 68,
+ DQUOT = 69,
+ STALE = 70,
+ REMOTE = 71,
+ BADRPC = 72,
+ RPCMISMATCH = 73,
+ PROGUNAVAIL = 74,
+ PROGMISMATCH = 75,
+ PROCUNAVAIL = 76,
+ NOLCK = 77,
+ NOSYS = 78,
+ FTYPE = 79,
+ AUTH = 80,
+ NEEDAUTH = 81,
+ IDRM = 82,
+ NOMSG = 83,
+ OVERFLOW = 84,
+ CANCELED = 85,
+ ILSEQ = 86,
+ NOATTR = 87,
+ DOOFUS = 88,
+ BADMSG = 89,
+ MULTIHOP = 90,
+ NOLINK = 91,
+ PROTO = 92,
+ NOMEDIUM = 93,
+ ASYNC = 99,
+ _,
+};
+
+pub const STDIN_FILENO = 0;
+pub const STDOUT_FILENO = 1;
+pub const STDERR_FILENO = 2;
+
+pub const PROT = struct {
+ pub const NONE = 0;
+ pub const READ = 1;
+ pub const WRITE = 2;
+ pub const EXEC = 4;
+};
+
+pub const MAP = struct {
+ pub const FILE = 0;
+ pub const FAILED = @intToPtr(*c_void, maxInt(usize));
+ pub const ANONYMOUS = ANON;
+ pub const COPY = PRIVATE;
+ pub const SHARED = 1;
+ pub const PRIVATE = 2;
+ pub const FIXED = 16;
+ pub const RENAME = 32;
+ pub const NORESERVE = 64;
+ pub const INHERIT = 128;
+ pub const NOEXTEND = 256;
+ pub const HASSEMAPHORE = 512;
+ pub const STACK = 1024;
+ pub const NOSYNC = 2048;
+ pub const ANON = 4096;
+ pub const VPAGETABLE = 8192;
+ pub const TRYFIXED = 65536;
+ pub const NOCORE = 131072;
+ pub const SIZEALIGN = 262144;
+};
+
+pub const W = struct {
+ pub const NOHANG = 0x0001;
+ pub const UNTRACED = 0x0002;
+ pub const CONTINUED = 0x0004;
+ pub const STOPPED = UNTRACED;
+ pub const NOWAIT = 0x0008;
+ pub const EXITED = 0x0010;
+ pub const TRAPPED = 0x0020;
+
+ pub fn EXITSTATUS(s: u32) u8 {
+ return @intCast(u8, (s & 0xff00) >> 8);
+ }
+ pub fn TERMSIG(s: u32) u32 {
+ return s & 0x7f;
+ }
+ pub fn STOPSIG(s: u32) u32 {
+ return EXITSTATUS(s);
+ }
+ pub fn IFEXITED(s: u32) bool {
+ return TERMSIG(s) == 0;
+ }
+ pub fn IFSTOPPED(s: u32) bool {
+ return @truncate(u16, (((s & 0xffff) *% 0x10001) >> 8)) > 0x7f00;
+ }
+ pub fn IFSIGNALED(s: u32) bool {
+ return (s & 0xffff) -% 1 < 0xff;
+ }
+};
+
+pub const SA = struct {
+ pub const ONSTACK = 0x0001;
+ pub const RESTART = 0x0002;
+ pub const RESETHAND = 0x0004;
+ pub const NODEFER = 0x0010;
+ pub const NOCLDWAIT = 0x0020;
+ pub const SIGINFO = 0x0040;
+};
+
+pub const PATH_MAX = 1024;
+pub const IOV_MAX = KERN.IOV_MAX;
+
+pub const ino_t = c_ulong;
+
+pub const Stat = extern struct {
+ ino: ino_t,
+ nlink: c_uint,
+ dev: c_uint,
+ mode: c_ushort,
+ padding1: u16,
+ uid: uid_t,
+ gid: gid_t,
+ rdev: c_uint,
+ atim: timespec,
+ mtim: timespec,
+ ctim: timespec,
+ size: c_ulong,
+ blocks: i64,
+ blksize: u32,
+ flags: u32,
+ gen: u32,
+ lspare: i32,
+ qspare1: i64,
+ qspare2: i64,
+ pub fn atime(self: @This()) timespec {
+ return self.atim;
+ }
+
+ pub fn mtime(self: @This()) timespec {
+ return self.mtim;
+ }
+
+ pub fn ctime(self: @This()) timespec {
+ return self.ctim;
+ }
+};
+
+pub const timespec = extern struct {
+ tv_sec: c_long,
+ tv_nsec: c_long,
+};
+
+pub const timeval = extern struct {
+ /// seconds
+ tv_sec: time_t,
+ /// microseconds
+ tv_usec: suseconds_t,
+};
+
+pub const CTL = struct {
+ pub const UNSPEC = 0;
+ pub const KERN = 1;
+ pub const VM = 2;
+ pub const VFS = 3;
+ pub const NET = 4;
+ pub const DEBUG = 5;
+ pub const HW = 6;
+ pub const MACHDEP = 7;
+ pub const USER = 8;
+ pub const LWKT = 10;
+ pub const MAXID = 11;
+ pub const MAXNAME = 12;
+};
+
+pub const KERN = struct {
+ pub const PROC_ALL = 0;
+ pub const OSTYPE = 1;
+ pub const PROC_PID = 1;
+ pub const OSRELEASE = 2;
+ pub const PROC_PGRP = 2;
+ pub const OSREV = 3;
+ pub const PROC_SESSION = 3;
+ pub const VERSION = 4;
+ pub const PROC_TTY = 4;
+ pub const MAXVNODES = 5;
+ pub const PROC_UID = 5;
+ pub const MAXPROC = 6;
+ pub const PROC_RUID = 6;
+ pub const MAXFILES = 7;
+ pub const PROC_ARGS = 7;
+ pub const ARGMAX = 8;
+ pub const PROC_CWD = 8;
+ pub const PROC_PATHNAME = 9;
+ pub const SECURELVL = 9;
+ pub const PROC_SIGTRAMP = 10;
+ pub const HOSTNAME = 10;
+ pub const HOSTID = 11;
+ pub const CLOCKRATE = 12;
+ pub const VNODE = 13;
+ pub const PROC = 14;
+ pub const FILE = 15;
+ pub const PROC_FLAGMASK = 16;
+ pub const PROF = 16;
+ pub const PROC_FLAG_LWP = 16;
+ pub const POSIX1 = 17;
+ pub const NGROUPS = 18;
+ pub const JOB_CONTROL = 19;
+ pub const SAVED_IDS = 20;
+ pub const BOOTTIME = 21;
+ pub const NISDOMAINNAME = 22;
+ pub const UPDATEINTERVAL = 23;
+ pub const OSRELDATE = 24;
+ pub const NTP_PLL = 25;
+ pub const BOOTFILE = 26;
+ pub const MAXFILESPERPROC = 27;
+ pub const MAXPROCPERUID = 28;
+ pub const DUMPDEV = 29;
+ pub const IPC = 30;
+ pub const DUMMY = 31;
+ pub const PS_STRINGS = 32;
+ pub const USRSTACK = 33;
+ pub const LOGSIGEXIT = 34;
+ pub const IOV_MAX = 35;
+ pub const MAXPOSIXLOCKSPERUID = 36;
+ pub const MAXID = 37;
+};
+
+pub const HOST_NAME_MAX = 255;
+
+// access function
+pub const F_OK = 0; // test for existence of file
+pub const X_OK = 1; // test for execute or search permission
+pub const W_OK = 2; // test for write permission
+pub const R_OK = 4; // test for read permission
+
+pub const O = struct {
+ pub const RDONLY = 0;
+ pub const NDELAY = NONBLOCK;
+ pub const WRONLY = 1;
+ pub const RDWR = 2;
+ pub const ACCMODE = 3;
+ pub const NONBLOCK = 4;
+ pub const APPEND = 8;
+ pub const SHLOCK = 16;
+ pub const EXLOCK = 32;
+ pub const ASYNC = 64;
+ pub const FSYNC = 128;
+ pub const SYNC = 128;
+ pub const NOFOLLOW = 256;
+ pub const CREAT = 512;
+ pub const TRUNC = 1024;
+ pub const EXCL = 2048;
+ pub const NOCTTY = 32768;
+ pub const DIRECT = 65536;
+ pub const CLOEXEC = 131072;
+ pub const FBLOCKING = 262144;
+ pub const FNONBLOCKING = 524288;
+ pub const FAPPEND = 1048576;
+ pub const FOFFSET = 2097152;
+ pub const FSYNCWRITE = 4194304;
+ pub const FASYNCWRITE = 8388608;
+ pub const DIRECTORY = 134217728;
+};
+
+pub const SEEK = struct {
+ pub const SET = 0;
+ pub const CUR = 1;
+ pub const END = 2;
+ pub const DATA = 3;
+ pub const HOLE = 4;
+};
+
+pub const F = struct {
+ pub const ULOCK = 0;
+ pub const LOCK = 1;
+ pub const TLOCK = 2;
+ pub const TEST = 3;
+
+ pub const DUPFD = 0;
+ pub const GETFD = 1;
+ pub const RDLCK = 1;
+ pub const SETFD = 2;
+ pub const UNLCK = 2;
+ pub const WRLCK = 3;
+ pub const GETFL = 3;
+ pub const SETFL = 4;
+ pub const GETOWN = 5;
+ pub const SETOWN = 6;
+ pub const GETLK = 7;
+ pub const SETLK = 8;
+ pub const SETLKW = 9;
+ pub const DUP2FD = 10;
+ pub const DUPFD_CLOEXEC = 17;
+ pub const DUP2FD_CLOEXEC = 18;
+};
+
+pub const FD_CLOEXEC = 1;
+
+pub const AT = struct {
+ pub const FDCWD = -328243;
+ pub const SYMLINK_NOFOLLOW = 1;
+ pub const REMOVEDIR = 2;
+ pub const EACCESS = 4;
+ pub const SYMLINK_FOLLOW = 8;
+};
+
+pub const dirent = extern struct {
+ d_fileno: c_ulong,
+ d_namlen: u16,
+ d_type: u8,
+ d_unused1: u8,
+ d_unused2: u32,
+ d_name: [256]u8,
+
+ pub fn reclen(self: dirent) u16 {
+ return (@offsetOf(dirent, "d_name") + self.d_namlen + 1 + 7) & ~@as(u16, 7);
+ }
+};
+
+pub const DT = struct {
+ pub const UNKNOWN = 0;
+ pub const FIFO = 1;
+ pub const CHR = 2;
+ pub const DIR = 4;
+ pub const BLK = 6;
+ pub const REG = 8;
+ pub const LNK = 10;
+ pub const SOCK = 12;
+ pub const WHT = 14;
+ pub const DBF = 15;
+};
+
+pub const CLOCK = struct {
+ pub const REALTIME = 0;
+ pub const VIRTUAL = 1;
+ pub const PROF = 2;
+ pub const MONOTONIC = 4;
+ pub const UPTIME = 5;
+ pub const UPTIME_PRECISE = 7;
+ pub const UPTIME_FAST = 8;
+ pub const REALTIME_PRECISE = 9;
+ pub const REALTIME_FAST = 10;
+ pub const MONOTONIC_PRECISE = 11;
+ pub const MONOTONIC_FAST = 12;
+ pub const SECOND = 13;
+ pub const THREAD_CPUTIME_ID = 14;
+ pub const PROCESS_CPUTIME_ID = 15;
+};
+
+pub const sockaddr = extern struct {
+ len: u8,
+ family: u8,
+ data: [14]u8,
+
+ pub const storage = std.x.os.Socket.Address.Native.Storage;
+
+ pub const in = extern struct {
+ len: u8 = @sizeOf(in),
+ family: sa_family_t = AF.INET,
+ port: in_port_t,
+ addr: u32,
+ zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },
+ };
+
+ pub const in6 = extern struct {
+ len: u8 = @sizeOf(in6),
+ family: sa_family_t = AF.INET6,
+ port: in_port_t,
+ flowinfo: u32,
+ addr: [16]u8,
+ scope_id: u32,
+ };
+};
+
+pub const Kevent = extern struct {
+ ident: usize,
+ filter: c_short,
+ flags: c_ushort,
+ fflags: c_uint,
+ data: isize,
+ udata: usize,
+};
+
+pub const EVFILT_FS = -10;
+pub const EVFILT_USER = -9;
+pub const EVFILT_EXCEPT = -8;
+pub const EVFILT_TIMER = -7;
+pub const EVFILT_SIGNAL = -6;
+pub const EVFILT_PROC = -5;
+pub const EVFILT_VNODE = -4;
+pub const EVFILT_AIO = -3;
+pub const EVFILT_WRITE = -2;
+pub const EVFILT_READ = -1;
+pub const EVFILT_SYSCOUNT = 10;
+pub const EVFILT_MARKER = 15;
+
+pub const EV_ADD = 1;
+pub const EV_DELETE = 2;
+pub const EV_ENABLE = 4;
+pub const EV_DISABLE = 8;
+pub const EV_ONESHOT = 16;
+pub const EV_CLEAR = 32;
+pub const EV_RECEIPT = 64;
+pub const EV_DISPATCH = 128;
+pub const EV_NODATA = 4096;
+pub const EV_FLAG1 = 8192;
+pub const EV_ERROR = 16384;
+pub const EV_EOF = 32768;
+pub const EV_SYSFLAGS = 61440;
+
+pub const NOTE_FFNOP = 0;
+pub const NOTE_TRACK = 1;
+pub const NOTE_DELETE = 1;
+pub const NOTE_LOWAT = 1;
+pub const NOTE_TRACKERR = 2;
+pub const NOTE_OOB = 2;
+pub const NOTE_WRITE = 2;
+pub const NOTE_EXTEND = 4;
+pub const NOTE_CHILD = 4;
+pub const NOTE_ATTRIB = 8;
+pub const NOTE_LINK = 16;
+pub const NOTE_RENAME = 32;
+pub const NOTE_REVOKE = 64;
+pub const NOTE_PDATAMASK = 1048575;
+pub const NOTE_FFLAGSMASK = 16777215;
+pub const NOTE_TRIGGER = 16777216;
+pub const NOTE_EXEC = 536870912;
+pub const NOTE_FFAND = 1073741824;
+pub const NOTE_FORK = 1073741824;
+pub const NOTE_EXIT = 2147483648;
+pub const NOTE_FFOR = 2147483648;
+pub const NOTE_FFCTRLMASK = 3221225472;
+pub const NOTE_FFCOPY = 3221225472;
+pub const NOTE_PCTRLMASK = 4026531840;
+
+pub const stack_t = extern struct {
+ sp: [*]u8,
+ size: isize,
+ flags: i32,
+};
+
+pub const S = struct {
+ pub const IREAD = IRUSR;
+ pub const IEXEC = IXUSR;
+ pub const IWRITE = IWUSR;
+ pub const IXOTH = 1;
+ pub const IWOTH = 2;
+ pub const IROTH = 4;
+ pub const IRWXO = 7;
+ pub const IXGRP = 8;
+ pub const IWGRP = 16;
+ pub const IRGRP = 32;
+ pub const IRWXG = 56;
+ pub const IXUSR = 64;
+ pub const IWUSR = 128;
+ pub const IRUSR = 256;
+ pub const IRWXU = 448;
+ pub const ISTXT = 512;
+ pub const BLKSIZE = 512;
+ pub const ISVTX = 512;
+ pub const ISGID = 1024;
+ pub const ISUID = 2048;
+ pub const IFIFO = 4096;
+ pub const IFCHR = 8192;
+ pub const IFDIR = 16384;
+ pub const IFBLK = 24576;
+ pub const IFREG = 32768;
+ pub const IFDB = 36864;
+ pub const IFLNK = 40960;
+ pub const IFSOCK = 49152;
+ pub const IFWHT = 57344;
+ pub const IFMT = 61440;
+
+ pub fn ISCHR(m: u32) bool {
+ return m & IFMT == IFCHR;
+ }
+};
+
+pub const BADSIG = SIG.ERR;
+
+pub const SIG = struct {
+ pub const DFL = @intToPtr(?Sigaction.sigaction_fn, 0);
+ pub const IGN = @intToPtr(?Sigaction.sigaction_fn, 1);
+ pub const ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize));
+
+ pub const BLOCK = 1;
+ pub const UNBLOCK = 2;
+ pub const SETMASK = 3;
+
+ pub const IOT = ABRT;
+ pub const HUP = 1;
+ pub const INT = 2;
+ pub const QUIT = 3;
+ pub const ILL = 4;
+ pub const TRAP = 5;
+ pub const ABRT = 6;
+ pub const EMT = 7;
+ pub const FPE = 8;
+ pub const KILL = 9;
+ pub const BUS = 10;
+ pub const SEGV = 11;
+ pub const SYS = 12;
+ pub const PIPE = 13;
+ pub const ALRM = 14;
+ pub const TERM = 15;
+ pub const URG = 16;
+ pub const STOP = 17;
+ pub const TSTP = 18;
+ pub const CONT = 19;
+ pub const CHLD = 20;
+ pub const TTIN = 21;
+ pub const TTOU = 22;
+ pub const IO = 23;
+ pub const XCPU = 24;
+ pub const XFSZ = 25;
+ pub const VTALRM = 26;
+ pub const PROF = 27;
+ pub const WINCH = 28;
+ pub const INFO = 29;
+ pub const USR1 = 30;
+ pub const USR2 = 31;
+ pub const THR = 32;
+ pub const CKPT = 33;
+ pub const CKPTEXIT = 34;
+};
+
+pub const siginfo_t = extern struct {
+ signo: c_int,
+ errno: c_int,
+ code: c_int,
+ pid: c_int,
+ uid: uid_t,
+ status: c_int,
+ addr: ?*c_void,
+ value: sigval,
+ band: c_long,
+ __spare__: [7]c_int,
+};
+
+pub const sigval = extern union {
+ sival_int: c_int,
+ sival_ptr: ?*c_void,
+};
+
+pub const _SIG_WORDS = 4;
+
+pub const sigset_t = extern struct {
+ __bits: [_SIG_WORDS]c_uint,
+};
+
+pub const empty_sigset = sigset_t{ .__bits = [_]c_uint{0} ** _SIG_WORDS };
+
+pub const sig_atomic_t = c_int;
+
+pub const Sigaction = extern struct {
+ pub const handler_fn = fn (c_int) callconv(.C) void;
+ pub const sigaction_fn = fn (c_int, *const siginfo_t, ?*const c_void) callconv(.C) void;
+
+ /// signal handler
+ handler: extern union {
+ handler: ?handler_fn,
+ sigaction: ?sigaction_fn,
+ },
+ flags: c_uint,
+ mask: sigset_t,
+};
+
+pub const sig_t = [*c]fn (c_int) callconv(.C) void;
+
+pub const SOCK = struct {
+ pub const STREAM = 1;
+ pub const DGRAM = 2;
+ pub const RAW = 3;
+ pub const RDM = 4;
+ pub const SEQPACKET = 5;
+ pub const MAXADDRLEN = 255;
+ pub const CLOEXEC = 0x10000000;
+ pub const NONBLOCK = 0x20000000;
+};
+
+pub const SO = struct {
+ pub const DEBUG = 0x0001;
+ pub const ACCEPTCONN = 0x0002;
+ pub const REUSEADDR = 0x0004;
+ pub const KEEPALIVE = 0x0008;
+ pub const DONTROUTE = 0x0010;
+ pub const BROADCAST = 0x0020;
+ pub const USELOOPBACK = 0x0040;
+ pub const LINGER = 0x0080;
+ pub const OOBINLINE = 0x0100;
+ pub const REUSEPORT = 0x0200;
+ pub const TIMESTAMP = 0x0400;
+ pub const NOSIGPIPE = 0x0800;
+ pub const ACCEPTFILTER = 0x1000;
+ pub const RERROR = 0x2000;
+ pub const PASSCRED = 0x4000;
+
+ pub const SNDBUF = 0x1001;
+ pub const RCVBUF = 0x1002;
+ pub const SNDLOWAT = 0x1003;
+ pub const RCVLOWAT = 0x1004;
+ pub const SNDTIMEO = 0x1005;
+ pub const RCVTIMEO = 0x1006;
+ pub const ERROR = 0x1007;
+ pub const TYPE = 0x1008;
+ pub const SNDSPACE = 0x100a;
+ pub const CPUHINT = 0x1030;
+};
+
+pub const SOL = struct {
+ pub const SOCKET = 0xffff;
+};
+
+pub const PF = struct {
+ pub const INET6 = AF.INET6;
+ pub const IMPLINK = AF.IMPLINK;
+ pub const ROUTE = AF.ROUTE;
+ pub const ISO = AF.ISO;
+ pub const PIP = AF.pseudo_PIP;
+ pub const CHAOS = AF.CHAOS;
+ pub const DATAKIT = AF.DATAKIT;
+ pub const INET = AF.INET;
+ pub const APPLETALK = AF.APPLETALK;
+ pub const SIP = AF.SIP;
+ pub const OSI = AF.ISO;
+ pub const CNT = AF.CNT;
+ pub const LINK = AF.LINK;
+ pub const HYLINK = AF.HYLINK;
+ pub const MAX = AF.MAX;
+ pub const KEY = AF.pseudo_KEY;
+ pub const PUP = AF.PUP;
+ pub const COIP = AF.COIP;
+ pub const SNA = AF.SNA;
+ pub const LOCAL = AF.LOCAL;
+ pub const NETBIOS = AF.NETBIOS;
+ pub const NATM = AF.NATM;
+ pub const BLUETOOTH = AF.BLUETOOTH;
+ pub const UNSPEC = AF.UNSPEC;
+ pub const NETGRAPH = AF.NETGRAPH;
+ pub const ECMA = AF.ECMA;
+ pub const IPX = AF.IPX;
+ pub const DLI = AF.DLI;
+ pub const ATM = AF.ATM;
+ pub const CCITT = AF.CCITT;
+ pub const ISDN = AF.ISDN;
+ pub const RTIP = AF.pseudo_RTIP;
+ pub const LAT = AF.LAT;
+ pub const UNIX = PF.LOCAL;
+ pub const XTP = AF.pseudo_XTP;
+ pub const DECnet = AF.DECnet;
+};
+
+pub const AF = struct {
+ pub const UNSPEC = 0;
+ pub const OSI = ISO;
+ pub const UNIX = LOCAL;
+ pub const LOCAL = 1;
+ pub const INET = 2;
+ pub const IMPLINK = 3;
+ pub const PUP = 4;
+ pub const CHAOS = 5;
+ pub const NETBIOS = 6;
+ pub const ISO = 7;
+ pub const ECMA = 8;
+ pub const DATAKIT = 9;
+ pub const CCITT = 10;
+ pub const SNA = 11;
+ pub const DLI = 13;
+ pub const LAT = 14;
+ pub const HYLINK = 15;
+ pub const APPLETALK = 16;
+ pub const ROUTE = 17;
+ pub const LINK = 18;
+ pub const COIP = 20;
+ pub const CNT = 21;
+ pub const IPX = 23;
+ pub const SIP = 24;
+ pub const ISDN = 26;
+ pub const INET6 = 28;
+ pub const NATM = 29;
+ pub const ATM = 30;
+ pub const NETGRAPH = 32;
+ pub const BLUETOOTH = 33;
+ pub const MPLS = 34;
+ pub const MAX = 36;
+};
+
+pub const in_port_t = u16;
+pub const sa_family_t = u8;
+pub const socklen_t = u32;
+
+pub const EAI = enum(c_int) {
+ ADDRFAMILY = 1,
+ AGAIN = 2,
+ BADFLAGS = 3,
+ FAIL = 4,
+ FAMILY = 5,
+ MEMORY = 6,
+ NODATA = 7,
+ NONAME = 8,
+ SERVICE = 9,
+ SOCKTYPE = 10,
+ SYSTEM = 11,
+ BADHINTS = 12,
+ PROTOCOL = 13,
+ OVERFLOW = 14,
+ _,
+};
+
+pub const AI = struct {
+ pub const PASSIVE = 0x00000001;
+ pub const CANONNAME = 0x00000002;
+ pub const NUMERICHOST = 0x00000004;
+ pub const NUMERICSERV = 0x00000008;
+ pub const MASK = PASSIVE | CANONNAME | NUMERICHOST | NUMERICSERV | ADDRCONFIG;
+ pub const ALL = 0x00000100;
+ pub const V4MAPPED_CFG = 0x00000200;
+ pub const ADDRCONFIG = 0x00000400;
+ pub const V4MAPPED = 0x00000800;
+ pub const DEFAULT = V4MAPPED_CFG | ADDRCONFIG;
+};
+
+pub const RTLD = struct {
+ pub const LAZY = 1;
+ pub const NOW = 2;
+ pub const MODEMASK = 0x3;
+ pub const GLOBAL = 0x100;
+ pub const LOCAL = 0;
+ pub const TRACE = 0x200;
+ pub const NODELETE = 0x01000;
+ pub const NOLOAD = 0x02000;
+
+ pub const NEXT = @intToPtr(*c_void, @bitCast(usize, @as(isize, -1)));
+ pub const DEFAULT = @intToPtr(*c_void, @bitCast(usize, @as(isize, -2)));
+ pub const SELF = @intToPtr(*c_void, @bitCast(usize, @as(isize, -3)));
+ pub const ALL = @intToPtr(*c_void, @bitCast(usize, @as(isize, -4)));
+};
+
+pub const dl_phdr_info = extern struct {
+ dlpi_addr: usize,
+ dlpi_name: ?[*:0]const u8,
+ dlpi_phdr: [*]std.elf.Phdr,
+ dlpi_phnum: u16,
+};
+pub const cmsghdr = extern struct {
+ cmsg_len: socklen_t,
+ cmsg_level: c_int,
+ cmsg_type: c_int,
+};
+pub const msghdr = extern struct {
+ msg_name: ?*c_void,
+ msg_namelen: socklen_t,
+ msg_iov: [*c]iovec,
+ msg_iovlen: c_int,
+ msg_control: ?*c_void,
+ msg_controllen: socklen_t,
+ msg_flags: c_int,
+};
+pub const cmsgcred = extern struct {
+ cmcred_pid: pid_t,
+ cmcred_uid: uid_t,
+ cmcred_euid: uid_t,
+ cmcred_gid: gid_t,
+ cmcred_ngroups: c_short,
+ cmcred_groups: [16]gid_t,
+};
+pub const sf_hdtr = extern struct {
+ headers: [*c]iovec,
+ hdr_cnt: c_int,
+ trailers: [*c]iovec,
+ trl_cnt: c_int,
+};
+
+pub const MS_SYNC = 0;
+pub const MS_ASYNC = 1;
+pub const MS_INVALIDATE = 2;
+
+pub const POSIX_MADV_SEQUENTIAL = 2;
+pub const POSIX_MADV_RANDOM = 1;
+pub const POSIX_MADV_DONTNEED = 4;
+pub const POSIX_MADV_NORMAL = 0;
+pub const POSIX_MADV_WILLNEED = 3;
+
+pub const MADV = struct {
+ pub const SEQUENTIAL = 2;
+ pub const CONTROL_END = SETMAP;
+ pub const DONTNEED = 4;
+ pub const RANDOM = 1;
+ pub const WILLNEED = 3;
+ pub const NORMAL = 0;
+ pub const CONTROL_START = INVAL;
+ pub const FREE = 5;
+ pub const NOSYNC = 6;
+ pub const AUTOSYNC = 7;
+ pub const NOCORE = 8;
+ pub const CORE = 9;
+ pub const INVAL = 10;
+ pub const SETMAP = 11;
+};
+
+pub const LOCK = struct {
+ pub const SH = 1;
+ pub const EX = 2;
+ pub const UN = 8;
+ pub const NB = 4;
+};
+
+pub const Flock = extern struct {
+ l_start: off_t,
+ l_len: off_t,
+ l_pid: pid_t,
+ l_type: c_short,
+ l_whence: c_short,
+};
+
+pub const addrinfo = extern struct {
+ flags: i32,
+ family: i32,
+ socktype: i32,
+ protocol: i32,
+ addrlen: socklen_t,
+ canonname: ?[*:0]u8,
+ addr: ?*sockaddr,
+ next: ?*addrinfo,
+};
+
+pub const IPPROTO = struct {
+ pub const IP = 0;
+ pub const ICMP = 1;
+ pub const TCP = 6;
+ pub const UDP = 17;
+ pub const IPV6 = 41;
+ pub const RAW = 255;
+ pub const HOPOPTS = 0;
+ pub const IGMP = 2;
+ pub const GGP = 3;
+ pub const IPV4 = 4;
+ pub const IPIP = IPV4;
+ pub const ST = 7;
+ pub const EGP = 8;
+ pub const PIGP = 9;
+ pub const RCCMON = 10;
+ pub const NVPII = 11;
+ pub const PUP = 12;
+ pub const ARGUS = 13;
+ pub const EMCON = 14;
+ pub const XNET = 15;
+ pub const CHAOS = 16;
+ pub const MUX = 18;
+ pub const MEAS = 19;
+ pub const HMP = 20;
+ pub const PRM = 21;
+ pub const IDP = 22;
+ pub const TRUNK1 = 23;
+ pub const TRUNK2 = 24;
+ pub const LEAF1 = 25;
+ pub const LEAF2 = 26;
+ pub const RDP = 27;
+ pub const IRTP = 28;
+ pub const TP = 29;
+ pub const BLT = 30;
+ pub const NSP = 31;
+ pub const INP = 32;
+ pub const SEP = 33;
+ pub const @"3PC" = 34;
+ pub const IDPR = 35;
+ pub const XTP = 36;
+ pub const DDP = 37;
+ pub const CMTP = 38;
+ pub const TPXX = 39;
+ pub const IL = 40;
+ pub const SDRP = 42;
+ pub const ROUTING = 43;
+ pub const FRAGMENT = 44;
+ pub const IDRP = 45;
+ pub const RSVP = 46;
+ pub const GRE = 47;
+ pub const MHRP = 48;
+ pub const BHA = 49;
+ pub const ESP = 50;
+ pub const AH = 51;
+ pub const INLSP = 52;
+ pub const SWIPE = 53;
+ pub const NHRP = 54;
+ pub const MOBILE = 55;
+ pub const TLSP = 56;
+ pub const SKIP = 57;
+ pub const ICMPV6 = 58;
+ pub const NONE = 59;
+ pub const DSTOPTS = 60;
+ pub const AHIP = 61;
+ pub const CFTP = 62;
+ pub const HELLO = 63;
+ pub const SATEXPAK = 64;
+ pub const KRYPTOLAN = 65;
+ pub const RVD = 66;
+ pub const IPPC = 67;
+ pub const ADFS = 68;
+ pub const SATMON = 69;
+ pub const VISA = 70;
+ pub const IPCV = 71;
+ pub const CPNX = 72;
+ pub const CPHB = 73;
+ pub const WSN = 74;
+ pub const PVP = 75;
+ pub const BRSATMON = 76;
+ pub const ND = 77;
+ pub const WBMON = 78;
+ pub const WBEXPAK = 79;
+ pub const EON = 80;
+ pub const VMTP = 81;
+ pub const SVMTP = 82;
+ pub const VINES = 83;
+ pub const TTP = 84;
+ pub const IGP = 85;
+ pub const DGP = 86;
+ pub const TCF = 87;
+ pub const IGRP = 88;
+ pub const OSPFIGP = 89;
+ pub const SRPC = 90;
+ pub const LARP = 91;
+ pub const MTP = 92;
+ pub const AX25 = 93;
+ pub const IPEIP = 94;
+ pub const MICP = 95;
+ pub const SCCSP = 96;
+ pub const ETHERIP = 97;
+ pub const ENCAP = 98;
+ pub const APES = 99;
+ pub const GMTP = 100;
+ pub const IPCOMP = 108;
+ pub const PIM = 103;
+ pub const CARP = 112;
+ pub const PGM = 113;
+ pub const PFSYNC = 240;
+ pub const DIVERT = 254;
+ pub const MAX = 256;
+ pub const DONE = 257;
+ pub const UNKNOWN = 258;
+};
+
+pub const rlimit_resource = enum(c_int) {
+ CPU = 0,
+ FSIZE = 1,
+ DATA = 2,
+ STACK = 3,
+ CORE = 4,
+ RSS = 5,
+ MEMLOCK = 6,
+ NPROC = 7,
+ NOFILE = 8,
+ SBSIZE = 9,
+ VMEM = 10,
+ POSIXLOCKS = 11,
+ _,
+
+ pub const AS: rlimit_resource = .VMEM;
+};
+
+pub const rlim_t = i64;
+
+pub const RLIM = struct {
+ /// No limit
+ pub const INFINITY: rlim_t = (1 << 63) - 1;
+
+ pub const SAVED_MAX = INFINITY;
+ pub const SAVED_CUR = INFINITY;
+};
+
+pub const rlimit = extern struct {
+ /// Soft limit
+ cur: rlim_t,
+ /// Hard limit
+ max: rlim_t,
+};
+
+pub const SHUT = struct {
+ pub const RD = 0;
+ pub const WR = 1;
+ pub const RDWR = 2;
+};
+
+pub const nfds_t = u32;
+
+pub const pollfd = extern struct {
+ fd: fd_t,
+ events: i16,
+ revents: i16,
+};
+
+pub const POLL = struct {
+ /// Requestable events.
+ pub const IN = 0x0001;
+ pub const PRI = 0x0002;
+ pub const OUT = 0x0004;
+ pub const RDNORM = 0x0040;
+ pub const WRNORM = OUT;
+ pub const RDBAND = 0x0080;
+ pub const WRBAND = 0x0100;
+
+ /// These events are set if they occur regardless of whether they were requested.
+ pub const ERR = 0x0008;
+ pub const HUP = 0x0010;
+ pub const NVAL = 0x0020;
+};
diff --git a/lib/std/c/freebsd.zig b/lib/std/c/freebsd.zig
index f7d1e07608db..f65af3f915a8 100644
--- a/lib/std/c/freebsd.zig
+++ b/lib/std/c/freebsd.zig
@@ -1,5 +1,8 @@
const std = @import("../std.zig");
-usingnamespace std.c;
+const builtin = @import("builtin");
+const maxInt = std.math.maxInt;
+const iovec = std.os.iovec;
+const iovec_const = std.os.iovec_const;
extern "c" fn __error() *c_int;
pub const _errno = __error;
@@ -107,32 +110,1482 @@ pub const EAI = enum(c_int) {
pub const EAI_MAX = 15;
-/// get address to use bind()
-pub const AI_PASSIVE = 0x00000001;
+pub const AI = struct {
+ /// get address to use bind()
+ pub const PASSIVE = 0x00000001;
+ /// fill ai_canonname
+ pub const CANONNAME = 0x00000002;
+ /// prevent host name resolution
+ pub const NUMERICHOST = 0x00000004;
+ /// prevent service name resolution
+ pub const NUMERICSERV = 0x00000008;
+ /// valid flags for addrinfo (not a standard def, apps should not use it)
+ pub const MASK = (PASSIVE | CANONNAME | NUMERICHOST | NUMERICSERV | ADDRCONFIG | ALL | V4MAPPED);
+ /// IPv6 and IPv4-mapped (with V4MAPPED)
+ pub const ALL = 0x00000100;
+ /// accept IPv4-mapped if kernel supports
+ pub const V4MAPPED_CFG = 0x00000200;
+ /// only if any address is assigned
+ pub const ADDRCONFIG = 0x00000400;
+ /// accept IPv4-mapped IPv6 address
+ pub const V4MAPPED = 0x00000800;
+ /// special recommended flags for getipnodebyname
+ pub const DEFAULT = (V4MAPPED_CFG | ADDRCONFIG);
+};
+
+pub const blksize_t = i32;
+pub const blkcnt_t = i64;
+pub const clockid_t = i32;
+pub const fsblkcnt_t = u64;
+pub const fsfilcnt_t = u64;
+pub const nlink_t = u64;
+pub const fd_t = i32;
+pub const pid_t = i32;
+pub const uid_t = u32;
+pub const gid_t = u32;
+pub const mode_t = u16;
+pub const off_t = i64;
+pub const ino_t = u64;
+pub const dev_t = u64;
+pub const time_t = i64;
+// The signedness is not constant across different architectures.
+pub const clock_t = isize;
+
+pub const socklen_t = u32;
+pub const suseconds_t = c_long;
+
+/// Renamed from `kevent` to `Kevent` to avoid conflict with function name.
+pub const Kevent = extern struct {
+ ident: usize,
+ filter: i16,
+ flags: u16,
+ fflags: u32,
+ data: i64,
+ udata: usize,
+ // TODO ext
+};
+
+// Modes and flags for dlopen()
+// include/dlfcn.h
+
+pub const RTLD = struct {
+ /// Bind function calls lazily.
+ pub const LAZY = 1;
+ /// Bind function calls immediately.
+ pub const NOW = 2;
+ pub const MODEMASK = 0x3;
+ /// Make symbols globally available.
+ pub const GLOBAL = 0x100;
+ /// Opposite of GLOBAL, and the default.
+ pub const LOCAL = 0;
+ /// Trace loaded objects and exit.
+ pub const TRACE = 0x200;
+ /// Do not remove members.
+ pub const NODELETE = 0x01000;
+ /// Do not load if not already loaded.
+ pub const NOLOAD = 0x02000;
+};
+pub const dl_phdr_info = extern struct {
+ dlpi_addr: usize,
+ dlpi_name: ?[*:0]const u8,
+ dlpi_phdr: [*]std.elf.Phdr,
+ dlpi_phnum: u16,
+};
+
+pub const Flock = extern struct {
+ l_start: off_t,
+ l_len: off_t,
+ l_pid: pid_t,
+ l_type: i16,
+ l_whence: i16,
+ l_sysid: i32,
+ __unused: [4]u8,
+};
+
+pub const msghdr = extern struct {
+ /// optional address
+ msg_name: ?*sockaddr,
+
+ /// size of address
+ msg_namelen: socklen_t,
+
+ /// scatter/gather array
+ msg_iov: [*]iovec,
+
+ /// # elements in msg_iov
+ msg_iovlen: i32,
+
+ /// ancillary data
+ msg_control: ?*c_void,
+
+ /// ancillary data buffer len
+ msg_controllen: socklen_t,
+
+ /// flags on received message
+ msg_flags: i32,
+};
+
+pub const msghdr_const = extern struct {
+ /// optional address
+ msg_name: ?*const sockaddr,
+
+ /// size of address
+ msg_namelen: socklen_t,
+
+ /// scatter/gather array
+ msg_iov: [*]iovec_const,
+
+ /// # elements in msg_iov
+ msg_iovlen: i32,
+
+ /// ancillary data
+ msg_control: ?*c_void,
+
+ /// ancillary data buffer len
+ msg_controllen: socklen_t,
+
+ /// flags on received message
+ msg_flags: i32,
+};
+
+pub const Stat = extern struct {
+ dev: dev_t,
+ ino: ino_t,
+ nlink: nlink_t,
+
+ mode: mode_t,
+ __pad0: u16,
+ uid: uid_t,
+ gid: gid_t,
+ __pad1: u32,
+ rdev: dev_t,
+
+ atim: timespec,
+ mtim: timespec,
+ ctim: timespec,
+ birthtim: timespec,
+
+ size: off_t,
+ blocks: i64,
+ blksize: isize,
+ flags: u32,
+ gen: u64,
+ __spare: [10]u64,
+
+ pub fn atime(self: @This()) timespec {
+ return self.atim;
+ }
+
+ pub fn mtime(self: @This()) timespec {
+ return self.mtim;
+ }
+
+ pub fn ctime(self: @This()) timespec {
+ return self.ctim;
+ }
+};
+
+pub const timespec = extern struct {
+ tv_sec: isize,
+ tv_nsec: isize,
+};
+
+pub const timeval = extern struct {
+ /// seconds
+ tv_sec: time_t,
+ /// microseconds
+ tv_usec: suseconds_t,
+};
+
+pub const dirent = extern struct {
+ d_fileno: usize,
+ d_off: i64,
+ d_reclen: u16,
+ d_type: u8,
+ d_pad0: u8,
+ d_namlen: u16,
+ d_pad1: u16,
+ d_name: [256]u8,
+
+ pub fn reclen(self: dirent) u16 {
+ return self.d_reclen;
+ }
+};
+
+pub const in_port_t = u16;
+pub const sa_family_t = u8;
+
+pub const sockaddr = extern struct {
+ /// total length
+ len: u8,
+ /// address family
+ family: sa_family_t,
+ /// actually longer; address value
+ data: [14]u8,
+
+ pub const storage = std.x.os.Socket.Address.Native.Storage;
+
+ pub const in = extern struct {
+ len: u8 = @sizeOf(in),
+ family: sa_family_t = AF.INET,
+ port: in_port_t,
+ addr: u32,
+ zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },
+ };
+
+ pub const in6 = extern struct {
+ len: u8 = @sizeOf(in6),
+ family: sa_family_t = AF.INET6,
+ port: in_port_t,
+ flowinfo: u32,
+ addr: [16]u8,
+ scope_id: u32,
+ };
+
+ pub const un = extern struct {
+ len: u8 = @sizeOf(un),
+ family: sa_family_t = AF.UNIX,
+ path: [104]u8,
+ };
+};
+
+pub const CTL = struct {
+ pub const KERN = 1;
+ pub const DEBUG = 5;
+};
+
+pub const KERN = struct {
+ pub const PROC = 14; // struct: process entries
+ pub const PROC_PATHNAME = 12; // path to executable
+ pub const IOV_MAX = 35;
+};
+
+pub const PATH_MAX = 1024;
+pub const IOV_MAX = KERN.IOV_MAX;
+
+pub const STDIN_FILENO = 0;
+pub const STDOUT_FILENO = 1;
+pub const STDERR_FILENO = 2;
+
+pub const PROT = struct {
+ pub const NONE = 0;
+ pub const READ = 1;
+ pub const WRITE = 2;
+ pub const EXEC = 4;
+};
+
+pub const CLOCK = struct {
+ pub const REALTIME = 0;
+ pub const VIRTUAL = 1;
+ pub const PROF = 2;
+ pub const MONOTONIC = 4;
+ pub const UPTIME = 5;
+ pub const UPTIME_PRECISE = 7;
+ pub const UPTIME_FAST = 8;
+ pub const REALTIME_PRECISE = 9;
+ pub const REALTIME_FAST = 10;
+ pub const MONOTONIC_PRECISE = 11;
+ pub const MONOTONIC_FAST = 12;
+ pub const SECOND = 13;
+ pub const THREAD_CPUTIME_ID = 14;
+ pub const PROCESS_CPUTIME_ID = 15;
+};
+
+pub const MAP = struct {
+ pub const FAILED = @intToPtr(*c_void, maxInt(usize));
+ pub const SHARED = 0x0001;
+ pub const PRIVATE = 0x0002;
+ pub const FIXED = 0x0010;
+ pub const STACK = 0x0400;
+ pub const NOSYNC = 0x0800;
+ pub const ANON = 0x1000;
+ pub const ANONYMOUS = ANON;
+ pub const FILE = 0;
+
+ pub const GUARD = 0x00002000;
+ pub const EXCL = 0x00004000;
+ pub const NOCORE = 0x00020000;
+ pub const PREFAULT_READ = 0x00040000;
+ pub const @"32BIT" = 0x00080000;
+};
+
+pub const W = struct {
+ pub const NOHANG = 1;
+ pub const UNTRACED = 2;
+ pub const STOPPED = UNTRACED;
+ pub const CONTINUED = 4;
+ pub const NOWAIT = 8;
+ pub const EXITED = 16;
+ pub const TRAPPED = 32;
+
+ pub fn EXITSTATUS(s: u32) u8 {
+ return @intCast(u8, (s & 0xff00) >> 8);
+ }
+ pub fn TERMSIG(s: u32) u32 {
+ return s & 0x7f;
+ }
+ pub fn STOPSIG(s: u32) u32 {
+ return EXITSTATUS(s);
+ }
+ pub fn IFEXITED(s: u32) bool {
+ return TERMSIG(s) == 0;
+ }
+ pub fn IFSTOPPED(s: u32) bool {
+ return @truncate(u16, (((s & 0xffff) *% 0x10001) >> 8)) > 0x7f00;
+ }
+ pub fn IFSIGNALED(s: u32) bool {
+ return (s & 0xffff) -% 1 < 0xff;
+ }
+};
+
+pub const SA = struct {
+ pub const ONSTACK = 0x0001;
+ pub const RESTART = 0x0002;
+ pub const RESETHAND = 0x0004;
+ pub const NOCLDSTOP = 0x0008;
+ pub const NODEFER = 0x0010;
+ pub const NOCLDWAIT = 0x0020;
+ pub const SIGINFO = 0x0040;
+};
+
+pub const SIG = struct {
+ pub const HUP = 1;
+ pub const INT = 2;
+ pub const QUIT = 3;
+ pub const ILL = 4;
+ pub const TRAP = 5;
+ pub const ABRT = 6;
+ pub const IOT = ABRT;
+ pub const EMT = 7;
+ pub const FPE = 8;
+ pub const KILL = 9;
+ pub const BUS = 10;
+ pub const SEGV = 11;
+ pub const SYS = 12;
+ pub const PIPE = 13;
+ pub const ALRM = 14;
+ pub const TERM = 15;
+ pub const URG = 16;
+ pub const STOP = 17;
+ pub const TSTP = 18;
+ pub const CONT = 19;
+ pub const CHLD = 20;
+ pub const TTIN = 21;
+ pub const TTOU = 22;
+ pub const IO = 23;
+ pub const XCPU = 24;
+ pub const XFSZ = 25;
+ pub const VTALRM = 26;
+ pub const PROF = 27;
+ pub const WINCH = 28;
+ pub const INFO = 29;
+ pub const USR1 = 30;
+ pub const USR2 = 31;
+ pub const THR = 32;
+ pub const LWP = THR;
+ pub const LIBRT = 33;
+
+ pub const RTMIN = 65;
+ pub const RTMAX = 126;
+
+ pub const BLOCK = 1;
+ pub const UNBLOCK = 2;
+ pub const SETMASK = 3;
+
+ pub const DFL = @intToPtr(?Sigaction.sigaction_fn, 0);
+ pub const IGN = @intToPtr(?Sigaction.sigaction_fn, 1);
+ pub const ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize));
+
+ pub const WORDS = 4;
+ pub const MAXSIG = 128;
+
+ pub inline fn IDX(sig: usize) usize {
+ return sig - 1;
+ }
+ pub inline fn WORD(sig: usize) usize {
+ return IDX(sig) >> 5;
+ }
+ pub inline fn BIT(sig: usize) usize {
+ return 1 << (IDX(sig) & 31);
+ }
+ pub inline fn VALID(sig: usize) usize {
+ return sig <= MAXSIG and sig > 0;
+ }
+};
+pub const sigval = extern union {
+ int: c_int,
+ ptr: ?*c_void,
+};
+
+pub const sigset_t = extern struct {
+ __bits: [SIG.WORDS]u32,
+};
+
+pub const empty_sigset = sigset_t{ .__bits = [_]u32{0} ** SIG.WORDS };
+
+// access function
+pub const F_OK = 0; // test for existence of file
+pub const X_OK = 1; // test for execute or search permission
+pub const W_OK = 2; // test for write permission
+pub const R_OK = 4; // test for read permission
+
+pub const O = struct {
+ pub const RDONLY = 0x0000;
+ pub const WRONLY = 0x0001;
+ pub const RDWR = 0x0002;
+ pub const ACCMODE = 0x0003;
+
+ pub const SHLOCK = 0x0010;
+ pub const EXLOCK = 0x0020;
+
+ pub const CREAT = 0x0200;
+ pub const EXCL = 0x0800;
+ pub const NOCTTY = 0x8000;
+ pub const TRUNC = 0x0400;
+ pub const APPEND = 0x0008;
+ pub const NONBLOCK = 0x0004;
+ pub const DSYNC = 0o10000;
+ pub const SYNC = 0x0080;
+ pub const RSYNC = 0o4010000;
+ pub const DIRECTORY = 0x20000;
+ pub const NOFOLLOW = 0x0100;
+ pub const CLOEXEC = 0x00100000;
+
+ pub const ASYNC = 0x0040;
+ pub const DIRECT = 0x00010000;
+ pub const NOATIME = 0o1000000;
+ pub const PATH = 0o10000000;
+ pub const TMPFILE = 0o20200000;
+ pub const NDELAY = NONBLOCK;
+};
+
+pub const F = struct {
+ pub const DUPFD = 0;
+ pub const GETFD = 1;
+ pub const SETFD = 2;
+ pub const GETFL = 3;
+ pub const SETFL = 4;
+
+ pub const GETOWN = 5;
+ pub const SETOWN = 6;
+
+ pub const GETLK = 11;
+ pub const SETLK = 12;
+ pub const SETLKW = 13;
+
+ pub const RDLCK = 1;
+ pub const WRLCK = 3;
+ pub const UNLCK = 2;
+
+ pub const SETOWN_EX = 15;
+ pub const GETOWN_EX = 16;
+
+ pub const GETOWNER_UIDS = 17;
+};
+
+pub const LOCK = struct {
+ pub const SH = 1;
+ pub const EX = 2;
+ pub const UN = 8;
+ pub const NB = 4;
+};
+
+pub const FD_CLOEXEC = 1;
+
+pub const SEEK = struct {
+ pub const SET = 0;
+ pub const CUR = 1;
+ pub const END = 2;
+};
+
+pub const SOCK = struct {
+ pub const STREAM = 1;
+ pub const DGRAM = 2;
+ pub const RAW = 3;
+ pub const RDM = 4;
+ pub const SEQPACKET = 5;
+
+ pub const CLOEXEC = 0x10000000;
+ pub const NONBLOCK = 0x20000000;
+};
+
+pub const SO = struct {
+ pub const DEBUG = 0x00000001;
+ pub const ACCEPTCONN = 0x00000002;
+ pub const REUSEADDR = 0x00000004;
+ pub const KEEPALIVE = 0x00000008;
+ pub const DONTROUTE = 0x00000010;
+ pub const BROADCAST = 0x00000020;
+ pub const USELOOPBACK = 0x00000040;
+ pub const LINGER = 0x00000080;
+ pub const OOBINLINE = 0x00000100;
+ pub const REUSEPORT = 0x00000200;
+ pub const TIMESTAMP = 0x00000400;
+ pub const NOSIGPIPE = 0x00000800;
+ pub const ACCEPTFILTER = 0x00001000;
+ pub const BINTIME = 0x00002000;
+ pub const NO_OFFLOAD = 0x00004000;
+ pub const NO_DDP = 0x00008000;
+ pub const REUSEPORT_LB = 0x00010000;
+
+ pub const SNDBUF = 0x1001;
+ pub const RCVBUF = 0x1002;
+ pub const SNDLOWAT = 0x1003;
+ pub const RCVLOWAT = 0x1004;
+ pub const SNDTIMEO = 0x1005;
+ pub const RCVTIMEO = 0x1006;
+ pub const ERROR = 0x1007;
+ pub const TYPE = 0x1008;
+ pub const LABEL = 0x1009;
+ pub const PEERLABEL = 0x1010;
+ pub const LISTENQLIMIT = 0x1011;
+ pub const LISTENQLEN = 0x1012;
+ pub const LISTENINCQLEN = 0x1013;
+ pub const SETFIB = 0x1014;
+ pub const USER_COOKIE = 0x1015;
+ pub const PROTOCOL = 0x1016;
+ pub const PROTOTYPE = PROTOCOL;
+ pub const TS_CLOCK = 0x1017;
+ pub const MAX_PACING_RATE = 0x1018;
+ pub const DOMAIN = 0x1019;
+};
+
+pub const SOL = struct {
+ pub const SOCKET = 0xffff;
+};
+
+pub const PF = struct {
+ pub const UNSPEC = AF.UNSPEC;
+ pub const LOCAL = AF.LOCAL;
+ pub const UNIX = PF.LOCAL;
+ pub const INET = AF.INET;
+ pub const IMPLINK = AF.IMPLINK;
+ pub const PUP = AF.PUP;
+ pub const CHAOS = AF.CHAOS;
+ pub const NETBIOS = AF.NETBIOS;
+ pub const ISO = AF.ISO;
+ pub const OSI = AF.ISO;
+ pub const ECMA = AF.ECMA;
+ pub const DATAKIT = AF.DATAKIT;
+ pub const CCITT = AF.CCITT;
+ pub const DECnet = AF.DECnet;
+ pub const DLI = AF.DLI;
+ pub const LAT = AF.LAT;
+ pub const HYLINK = AF.HYLINK;
+ pub const APPLETALK = AF.APPLETALK;
+ pub const ROUTE = AF.ROUTE;
+ pub const LINK = AF.LINK;
+ pub const XTP = AF.pseudo_XTP;
+ pub const COIP = AF.COIP;
+ pub const CNT = AF.CNT;
+ pub const SIP = AF.SIP;
+ pub const IPX = AF.IPX;
+ pub const RTIP = AF.pseudo_RTIP;
+ pub const PIP = AF.pseudo_PIP;
+ pub const ISDN = AF.ISDN;
+ pub const KEY = AF.pseudo_KEY;
+ pub const INET6 = AF.pseudo_INET6;
+ pub const NATM = AF.NATM;
+ pub const ATM = AF.ATM;
+ pub const NETGRAPH = AF.NETGRAPH;
+ pub const SLOW = AF.SLOW;
+ pub const SCLUSTER = AF.SCLUSTER;
+ pub const ARP = AF.ARP;
+ pub const BLUETOOTH = AF.BLUETOOTH;
+ pub const IEEE80211 = AF.IEEE80211;
+ pub const INET_SDP = AF.INET_SDP;
+ pub const INET6_SDP = AF.INET6_SDP;
+ pub const MAX = AF.MAX;
+};
+
+pub const AF = struct {
+ pub const UNSPEC = 0;
+ pub const UNIX = 1;
+ pub const LOCAL = UNIX;
+ pub const FILE = LOCAL;
+ pub const INET = 2;
+ pub const IMPLINK = 3;
+ pub const PUP = 4;
+ pub const CHAOS = 5;
+ pub const NETBIOS = 6;
+ pub const ISO = 7;
+ pub const OSI = ISO;
+ pub const ECMA = 8;
+ pub const DATAKIT = 9;
+ pub const CCITT = 10;
+ pub const SNA = 11;
+ pub const DECnet = 12;
+ pub const DLI = 13;
+ pub const LAT = 14;
+ pub const HYLINK = 15;
+ pub const APPLETALK = 16;
+ pub const ROUTE = 17;
+ pub const LINK = 18;
+ pub const pseudo_XTP = 19;
+ pub const COIP = 20;
+ pub const CNT = 21;
+ pub const pseudo_RTIP = 22;
+ pub const IPX = 23;
+ pub const SIP = 24;
+ pub const pseudo_PIP = 25;
+ pub const ISDN = 26;
+ pub const E164 = ISDN;
+ pub const pseudo_KEY = 27;
+ pub const INET6 = 28;
+ pub const NATM = 29;
+ pub const ATM = 30;
+ pub const pseudo_HDRCMPLT = 31;
+ pub const NETGRAPH = 32;
+ pub const SLOW = 33;
+ pub const SCLUSTER = 34;
+ pub const ARP = 35;
+ pub const BLUETOOTH = 36;
+ pub const IEEE80211 = 37;
+ pub const INET_SDP = 40;
+ pub const INET6_SDP = 42;
+ pub const MAX = 42;
+};
+
+pub const DT = struct {
+ pub const UNKNOWN = 0;
+ pub const FIFO = 1;
+ pub const CHR = 2;
+ pub const DIR = 4;
+ pub const BLK = 6;
+ pub const REG = 8;
+ pub const LNK = 10;
+ pub const SOCK = 12;
+ pub const WHT = 14;
+};
+
+/// add event to kq (implies enable)
+pub const EV_ADD = 0x0001;
+
+/// delete event from kq
+pub const EV_DELETE = 0x0002;
+
+/// enable event
+pub const EV_ENABLE = 0x0004;
+
+/// disable event (not reported)
+pub const EV_DISABLE = 0x0008;
-/// fill ai_canonname
-pub const AI_CANONNAME = 0x00000002;
+/// only report one occurrence
+pub const EV_ONESHOT = 0x0010;
-/// prevent host name resolution
-pub const AI_NUMERICHOST = 0x00000004;
+/// clear event state after reporting
+pub const EV_CLEAR = 0x0020;
-/// prevent service name resolution
-pub const AI_NUMERICSERV = 0x00000008;
+/// error, event data contains errno
+pub const EV_ERROR = 0x4000;
-/// valid flags for addrinfo (not a standard def, apps should not use it)
-pub const AI_MASK = (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST | AI_NUMERICSERV | AI_ADDRCONFIG | AI_ALL | AI_V4MAPPED);
+/// force immediate event output
+/// ... with or without EV_ERROR
+/// ... use KEVENT_FLAG_ERROR_EVENTS
+/// on syscalls supporting flags
+pub const EV_RECEIPT = 0x0040;
-/// IPv6 and IPv4-mapped (with AI_V4MAPPED)
-pub const AI_ALL = 0x00000100;
+/// disable event after reporting
+pub const EV_DISPATCH = 0x0080;
-/// accept IPv4-mapped if kernel supports
-pub const AI_V4MAPPED_CFG = 0x00000200;
+pub const EVFILT_READ = -1;
+pub const EVFILT_WRITE = -2;
-/// only if any address is assigned
-pub const AI_ADDRCONFIG = 0x00000400;
+/// attached to aio requests
+pub const EVFILT_AIO = -3;
-/// accept IPv4-mapped IPv6 address
-pub const AI_V4MAPPED = 0x00000800;
+/// attached to vnodes
+pub const EVFILT_VNODE = -4;
-/// special recommended flags for getipnodebyname
-pub const AI_DEFAULT = (AI_V4MAPPED_CFG | AI_ADDRCONFIG);
+/// attached to struct proc
+pub const EVFILT_PROC = -5;
+
+/// attached to struct proc
+pub const EVFILT_SIGNAL = -6;
+
+/// timers
+pub const EVFILT_TIMER = -7;
+
+/// Process descriptors
+pub const EVFILT_PROCDESC = -8;
+
+/// Filesystem events
+pub const EVFILT_FS = -9;
+
+pub const EVFILT_LIO = -10;
+
+/// User events
+pub const EVFILT_USER = -11;
+
+/// Sendfile events
+pub const EVFILT_SENDFILE = -12;
+
+pub const EVFILT_EMPTY = -13;
+
+/// On input, NOTE_TRIGGER causes the event to be triggered for output.
+pub const NOTE_TRIGGER = 0x01000000;
+
+/// ignore input fflags
+pub const NOTE_FFNOP = 0x00000000;
+
+/// and fflags
+pub const NOTE_FFAND = 0x40000000;
+
+/// or fflags
+pub const NOTE_FFOR = 0x80000000;
+
+/// copy fflags
+pub const NOTE_FFCOPY = 0xc0000000;
+
+/// mask for operations
+pub const NOTE_FFCTRLMASK = 0xc0000000;
+pub const NOTE_FFLAGSMASK = 0x00ffffff;
+
+/// low water mark
+pub const NOTE_LOWAT = 0x00000001;
+
+/// behave like poll()
+pub const NOTE_FILE_POLL = 0x00000002;
+
+/// vnode was removed
+pub const NOTE_DELETE = 0x00000001;
+
+/// data contents changed
+pub const NOTE_WRITE = 0x00000002;
+
+/// size increased
+pub const NOTE_EXTEND = 0x00000004;
+
+/// attributes changed
+pub const NOTE_ATTRIB = 0x00000008;
+
+/// link count changed
+pub const NOTE_LINK = 0x00000010;
+
+/// vnode was renamed
+pub const NOTE_RENAME = 0x00000020;
+
+/// vnode access was revoked
+pub const NOTE_REVOKE = 0x00000040;
+
+/// vnode was opened
+pub const NOTE_OPEN = 0x00000080;
+
+/// file closed, fd did not allow write
+pub const NOTE_CLOSE = 0x00000100;
+
+/// file closed, fd did allow write
+pub const NOTE_CLOSE_WRITE = 0x00000200;
+
+/// file was read
+pub const NOTE_READ = 0x00000400;
+
+/// process exited
+pub const NOTE_EXIT = 0x80000000;
+
+/// process forked
+pub const NOTE_FORK = 0x40000000;
+
+/// process exec'd
+pub const NOTE_EXEC = 0x20000000;
+
+/// mask for signal & exit status
+pub const NOTE_PDATAMASK = 0x000fffff;
+pub const NOTE_PCTRLMASK = (~NOTE_PDATAMASK);
+
+/// data is seconds
+pub const NOTE_SECONDS = 0x00000001;
+
+/// data is milliseconds
+pub const NOTE_MSECONDS = 0x00000002;
+
+/// data is microseconds
+pub const NOTE_USECONDS = 0x00000004;
+
+/// data is nanoseconds
+pub const NOTE_NSECONDS = 0x00000008;
+
+/// timeout is absolute
+pub const NOTE_ABSTIME = 0x00000010;
+
+pub const T = struct {
+ pub const IOCEXCL = 0x2000740d;
+ pub const IOCNXCL = 0x2000740e;
+ pub const IOCSCTTY = 0x20007461;
+ pub const IOCGPGRP = 0x40047477;
+ pub const IOCSPGRP = 0x80047476;
+ pub const IOCOUTQ = 0x40047473;
+ pub const IOCSTI = 0x80017472;
+ pub const IOCGWINSZ = 0x40087468;
+ pub const IOCSWINSZ = 0x80087467;
+ pub const IOCMGET = 0x4004746a;
+ pub const IOCMBIS = 0x8004746c;
+ pub const IOCMBIC = 0x8004746b;
+ pub const IOCMSET = 0x8004746d;
+ pub const FIONREAD = 0x4004667f;
+ pub const IOCCONS = 0x80047462;
+ pub const IOCPKT = 0x80047470;
+ pub const FIONBIO = 0x8004667e;
+ pub const IOCNOTTY = 0x20007471;
+ pub const IOCSETD = 0x8004741b;
+ pub const IOCGETD = 0x4004741a;
+ pub const IOCSBRK = 0x2000747b;
+ pub const IOCCBRK = 0x2000747a;
+ pub const IOCGSID = 0x40047463;
+ pub const IOCGPTN = 0x4004740f;
+ pub const IOCSIG = 0x2004745f;
+};
+
+pub const winsize = extern struct {
+ ws_row: u16,
+ ws_col: u16,
+ ws_xpixel: u16,
+ ws_ypixel: u16,
+};
+
+const NSIG = 32;
+
+/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.
+pub const Sigaction = extern struct {
+ pub const handler_fn = fn (c_int) callconv(.C) void;
+ pub const sigaction_fn = fn (c_int, *const siginfo_t, ?*const c_void) callconv(.C) void;
+
+ /// signal handler
+ handler: extern union {
+ handler: ?handler_fn,
+ sigaction: ?sigaction_fn,
+ },
+
+ /// see signal options
+ flags: c_uint,
+
+ /// signal mask to apply
+ mask: sigset_t,
+};
+
+pub const siginfo_t = extern struct {
+ signo: c_int,
+ errno: c_int,
+ code: c_int,
+ pid: pid_t,
+ uid: uid_t,
+ status: c_int,
+ addr: ?*c_void,
+ value: sigval,
+ reason: extern union {
+ fault: extern struct {
+ trapno: c_int,
+ },
+ timer: extern struct {
+ timerid: c_int,
+ overrun: c_int,
+ },
+ mesgq: extern struct {
+ mqd: c_int,
+ },
+ poll: extern struct {
+ band: c_long,
+ },
+ spare: extern struct {
+ spare1: c_long,
+ spare2: [7]c_int,
+ },
+ },
+};
+
+pub usingnamespace switch (builtin.cpu.arch) {
+ .x86_64 => struct {
+ pub const ucontext_t = extern struct {
+ sigmask: sigset_t,
+ mcontext: mcontext_t,
+ link: ?*ucontext_t,
+ stack: stack_t,
+ flags: c_int,
+ __spare__: [4]c_int,
+ };
+
+ /// XXX x86_64 specific
+ pub const mcontext_t = extern struct {
+ onstack: u64,
+ rdi: u64,
+ rsi: u64,
+ rdx: u64,
+ rcx: u64,
+ r8: u64,
+ r9: u64,
+ rax: u64,
+ rbx: u64,
+ rbp: u64,
+ r10: u64,
+ r11: u64,
+ r12: u64,
+ r13: u64,
+ r14: u64,
+ r15: u64,
+ trapno: u32,
+ fs: u16,
+ gs: u16,
+ addr: u64,
+ flags: u32,
+ es: u16,
+ ds: u16,
+ err: u64,
+ rip: u64,
+ cs: u64,
+ rflags: u64,
+ rsp: u64,
+ ss: u64,
+ };
+ },
+ else => struct {},
+};
+
+pub const E = enum(u16) {
+ /// No error occurred.
+ SUCCESS = 0,
+
+ PERM = 1, // Operation not permitted
+ NOENT = 2, // No such file or directory
+ SRCH = 3, // No such process
+ INTR = 4, // Interrupted system call
+ IO = 5, // Input/output error
+ NXIO = 6, // Device not configured
+ @"2BIG" = 7, // Argument list too long
+ NOEXEC = 8, // Exec format error
+ BADF = 9, // Bad file descriptor
+ CHILD = 10, // No child processes
+ DEADLK = 11, // Resource deadlock avoided
+ // 11 was AGAIN
+ NOMEM = 12, // Cannot allocate memory
+ ACCES = 13, // Permission denied
+ FAULT = 14, // Bad address
+ NOTBLK = 15, // Block device required
+ BUSY = 16, // Device busy
+ EXIST = 17, // File exists
+ XDEV = 18, // Cross-device link
+ NODEV = 19, // Operation not supported by device
+ NOTDIR = 20, // Not a directory
+ ISDIR = 21, // Is a directory
+ INVAL = 22, // Invalid argument
+ NFILE = 23, // Too many open files in system
+ MFILE = 24, // Too many open files
+ NOTTY = 25, // Inappropriate ioctl for device
+ TXTBSY = 26, // Text file busy
+ FBIG = 27, // File too large
+ NOSPC = 28, // No space left on device
+ SPIPE = 29, // Illegal seek
+ ROFS = 30, // Read-only filesystem
+ MLINK = 31, // Too many links
+ PIPE = 32, // Broken pipe
+
+ // math software
+ DOM = 33, // Numerical argument out of domain
+ RANGE = 34, // Result too large
+
+ // non-blocking and interrupt i/o
+
+ /// Resource temporarily unavailable
+ /// This code is also used for `WOULDBLOCK`: operation would block.
+ AGAIN = 35,
+ INPROGRESS = 36, // Operation now in progress
+ ALREADY = 37, // Operation already in progress
+
+ // ipc/network software -- argument errors
+ NOTSOCK = 38, // Socket operation on non-socket
+ DESTADDRREQ = 39, // Destination address required
+ MSGSIZE = 40, // Message too long
+ PROTOTYPE = 41, // Protocol wrong type for socket
+ NOPROTOOPT = 42, // Protocol not available
+ PROTONOSUPPORT = 43, // Protocol not supported
+ SOCKTNOSUPPORT = 44, // Socket type not supported
+ /// Operation not supported
+ /// This code is also used for `NOTSUP`.
+ OPNOTSUPP = 45,
+ PFNOSUPPORT = 46, // Protocol family not supported
+ AFNOSUPPORT = 47, // Address family not supported by protocol family
+ ADDRINUSE = 48, // Address already in use
+ ADDRNOTAVAIL = 49, // Can't assign requested address
+
+ // ipc/network software -- operational errors
+ NETDOWN = 50, // Network is down
+ NETUNREACH = 51, // Network is unreachable
+ NETRESET = 52, // Network dropped connection on reset
+ CONNABORTED = 53, // Software caused connection abort
+ CONNRESET = 54, // Connection reset by peer
+ NOBUFS = 55, // No buffer space available
+ ISCONN = 56, // Socket is already connected
+ NOTCONN = 57, // Socket is not connected
+ SHUTDOWN = 58, // Can't send after socket shutdown
+ TOOMANYREFS = 59, // Too many references: can't splice
+ TIMEDOUT = 60, // Operation timed out
+ CONNREFUSED = 61, // Connection refused
+
+ LOOP = 62, // Too many levels of symbolic links
+ NAMETOOLONG = 63, // File name too long
+
+ // should be rearranged
+ HOSTDOWN = 64, // Host is down
+ HOSTUNREACH = 65, // No route to host
+ NOTEMPTY = 66, // Directory not empty
+
+ // quotas & mush
+ PROCLIM = 67, // Too many processes
+ USERS = 68, // Too many users
+ DQUOT = 69, // Disc quota exceeded
+
+ // Network File System
+ STALE = 70, // Stale NFS file handle
+ REMOTE = 71, // Too many levels of remote in path
+ BADRPC = 72, // RPC struct is bad
+ RPCMISMATCH = 73, // RPC version wrong
+ PROGUNAVAIL = 74, // RPC prog. not avail
+ PROGMISMATCH = 75, // Program version wrong
+ PROCUNAVAIL = 76, // Bad procedure for program
+
+ NOLCK = 77, // No locks available
+ NOSYS = 78, // Function not implemented
+
+ FTYPE = 79, // Inappropriate file type or format
+ AUTH = 80, // Authentication error
+ NEEDAUTH = 81, // Need authenticator
+ IDRM = 82, // Identifier removed
+ NOMSG = 83, // No message of desired type
+ OVERFLOW = 84, // Value too large to be stored in data type
+ CANCELED = 85, // Operation canceled
+ ILSEQ = 86, // Illegal byte sequence
+ NOATTR = 87, // Attribute not found
+
+ DOOFUS = 88, // Programming error
+
+ BADMSG = 89, // Bad message
+ MULTIHOP = 90, // Multihop attempted
+ NOLINK = 91, // Link has been severed
+ PROTO = 92, // Protocol error
+
+ NOTCAPABLE = 93, // Capabilities insufficient
+ CAPMODE = 94, // Not permitted in capability mode
+ NOTRECOVERABLE = 95, // State not recoverable
+ OWNERDEAD = 96, // Previous owner died
+ _,
+};
+
+pub const MINSIGSTKSZ = switch (builtin.cpu.arch) {
+ .i386, .x86_64 => 2048,
+ .arm, .aarch64 => 4096,
+ else => @compileError("MINSIGSTKSZ not defined for this architecture"),
+};
+pub const SIGSTKSZ = MINSIGSTKSZ + 32768;
+
+pub const SS_ONSTACK = 1;
+pub const SS_DISABLE = 4;
+
+pub const stack_t = extern struct {
+ sp: [*]u8,
+ size: isize,
+ flags: i32,
+};
+
+pub const S = struct {
+ pub const IFMT = 0o170000;
+
+ pub const IFIFO = 0o010000;
+ pub const IFCHR = 0o020000;
+ pub const IFDIR = 0o040000;
+ pub const IFBLK = 0o060000;
+ pub const IFREG = 0o100000;
+ pub const IFLNK = 0o120000;
+ pub const IFSOCK = 0o140000;
+ pub const IFWHT = 0o160000;
+
+ pub const ISUID = 0o4000;
+ pub const ISGID = 0o2000;
+ pub const ISVTX = 0o1000;
+ pub const IRWXU = 0o700;
+ pub const IRUSR = 0o400;
+ pub const IWUSR = 0o200;
+ pub const IXUSR = 0o100;
+ pub const IRWXG = 0o070;
+ pub const IRGRP = 0o040;
+ pub const IWGRP = 0o020;
+ pub const IXGRP = 0o010;
+ pub const IRWXO = 0o007;
+ pub const IROTH = 0o004;
+ pub const IWOTH = 0o002;
+ pub const IXOTH = 0o001;
+
+ pub fn ISFIFO(m: u32) bool {
+ return m & IFMT == IFIFO;
+ }
+
+ pub fn ISCHR(m: u32) bool {
+ return m & IFMT == IFCHR;
+ }
+
+ pub fn ISDIR(m: u32) bool {
+ return m & IFMT == IFDIR;
+ }
+
+ pub fn ISBLK(m: u32) bool {
+ return m & IFMT == IFBLK;
+ }
+
+ pub fn ISREG(m: u32) bool {
+ return m & IFMT == IFREG;
+ }
+
+ pub fn ISLNK(m: u32) bool {
+ return m & IFMT == IFLNK;
+ }
+
+ pub fn ISSOCK(m: u32) bool {
+ return m & IFMT == IFSOCK;
+ }
+
+ pub fn IWHT(m: u32) bool {
+ return m & IFMT == IFWHT;
+ }
+};
+
+pub const HOST_NAME_MAX = 255;
+
+pub const AT = struct {
+ /// Magic value that specify the use of the current working directory
+ /// to determine the target of relative file paths in the openat() and
+ /// similar syscalls.
+ pub const FDCWD = -100;
+ /// Check access using effective user and group ID
+ pub const EACCESS = 0x0100;
+ /// Do not follow symbolic links
+ pub const SYMLINK_NOFOLLOW = 0x0200;
+ /// Follow symbolic link
+ pub const SYMLINK_FOLLOW = 0x0400;
+ /// Remove directory instead of file
+ pub const REMOVEDIR = 0x0800;
+ /// Fail if not under dirfd
+ pub const BENEATH = 0x1000;
+};
+
+pub const addrinfo = extern struct {
+ flags: i32,
+ family: i32,
+ socktype: i32,
+ protocol: i32,
+ addrlen: socklen_t,
+ canonname: ?[*:0]u8,
+ addr: ?*sockaddr,
+ next: ?*addrinfo,
+};
+
+pub const IPPROTO = struct {
+ /// dummy for IP
+ pub const IP = 0;
+ /// control message protocol
+ pub const ICMP = 1;
+ /// tcp
+ pub const TCP = 6;
+ /// user datagram protocol
+ pub const UDP = 17;
+ /// IP6 header
+ pub const IPV6 = 41;
+ /// raw IP packet
+ pub const RAW = 255;
+ /// IP6 hop-by-hop options
+ pub const HOPOPTS = 0;
+ /// group mgmt protocol
+ pub const IGMP = 2;
+ /// gateway^2 (deprecated)
+ pub const GGP = 3;
+ /// IPv4 encapsulation
+ pub const IPV4 = 4;
+ /// for compatibility
+ pub const IPIP = IPV4;
+ /// Stream protocol II
+ pub const ST = 7;
+ /// exterior gateway protocol
+ pub const EGP = 8;
+ /// private interior gateway
+ pub const PIGP = 9;
+ /// BBN RCC Monitoring
+ pub const RCCMON = 10;
+ /// network voice protocol
+ pub const NVPII = 11;
+ /// pup
+ pub const PUP = 12;
+ /// Argus
+ pub const ARGUS = 13;
+ /// EMCON
+ pub const EMCON = 14;
+ /// Cross Net Debugger
+ pub const XNET = 15;
+ /// Chaos
+ pub const CHAOS = 16;
+ /// Multiplexing
+ pub const MUX = 18;
+ /// DCN Measurement Subsystems
+ pub const MEAS = 19;
+ /// Host Monitoring
+ pub const HMP = 20;
+ /// Packet Radio Measurement
+ pub const PRM = 21;
+ /// xns idp
+ pub const IDP = 22;
+ /// Trunk-1
+ pub const TRUNK1 = 23;
+ /// Trunk-2
+ pub const TRUNK2 = 24;
+ /// Leaf-1
+ pub const LEAF1 = 25;
+ /// Leaf-2
+ pub const LEAF2 = 26;
+ /// Reliable Data
+ pub const RDP = 27;
+ /// Reliable Transaction
+ pub const IRTP = 28;
+ /// tp-4 w/ class negotiation
+ pub const TP = 29;
+ /// Bulk Data Transfer
+ pub const BLT = 30;
+ /// Network Services
+ pub const NSP = 31;
+ /// Merit Internodal
+ pub const INP = 32;
+ /// Datagram Congestion Control Protocol
+ pub const DCCP = 33;
+ /// Third Party Connect
+ pub const @"3PC" = 34;
+ /// InterDomain Policy Routing
+ pub const IDPR = 35;
+ /// XTP
+ pub const XTP = 36;
+ /// Datagram Delivery
+ pub const DDP = 37;
+ /// Control Message Transport
+ pub const CMTP = 38;
+ /// TP++ Transport
+ pub const TPXX = 39;
+ /// IL transport protocol
+ pub const IL = 40;
+ /// Source Demand Routing
+ pub const SDRP = 42;
+ /// IP6 routing header
+ pub const ROUTING = 43;
+ /// IP6 fragmentation header
+ pub const FRAGMENT = 44;
+ /// InterDomain Routing
+ pub const IDRP = 45;
+ /// resource reservation
+ pub const RSVP = 46;
+ /// General Routing Encap.
+ pub const GRE = 47;
+ /// Mobile Host Routing
+ pub const MHRP = 48;
+ /// BHA
+ pub const BHA = 49;
+ /// IP6 Encap Sec. Payload
+ pub const ESP = 50;
+ /// IP6 Auth Header
+ pub const AH = 51;
+ /// Integ. Net Layer Security
+ pub const INLSP = 52;
+ /// IP with encryption
+ pub const SWIPE = 53;
+ /// Next Hop Resolution
+ pub const NHRP = 54;
+ /// IP Mobility
+ pub const MOBILE = 55;
+ /// Transport Layer Security
+ pub const TLSP = 56;
+ /// SKIP
+ pub const SKIP = 57;
+ /// ICMP6
+ pub const ICMPV6 = 58;
+ /// IP6 no next header
+ pub const NONE = 59;
+ /// IP6 destination option
+ pub const DSTOPTS = 60;
+ /// any host internal protocol
+ pub const AHIP = 61;
+ /// CFTP
+ pub const CFTP = 62;
+ /// "hello" routing protocol
+ pub const HELLO = 63;
+ /// SATNET/Backroom EXPAK
+ pub const SATEXPAK = 64;
+ /// Kryptolan
+ pub const KRYPTOLAN = 65;
+ /// Remote Virtual Disk
+ pub const RVD = 66;
+ /// Pluribus Packet Core
+ pub const IPPC = 67;
+ /// Any distributed FS
+ pub const ADFS = 68;
+ /// Satnet Monitoring
+ pub const SATMON = 69;
+ /// VISA Protocol
+ pub const VISA = 70;
+ /// Packet Core Utility
+ pub const IPCV = 71;
+ /// Comp. Prot. Net. Executive
+ pub const CPNX = 72;
+ /// Comp. Prot. HeartBeat
+ pub const CPHB = 73;
+ /// Wang Span Network
+ pub const WSN = 74;
+ /// Packet Video Protocol
+ pub const PVP = 75;
+ /// BackRoom SATNET Monitoring
+ pub const BRSATMON = 76;
+ /// Sun net disk proto (temp.)
+ pub const ND = 77;
+ /// WIDEBAND Monitoring
+ pub const WBMON = 78;
+ /// WIDEBAND EXPAK
+ pub const WBEXPAK = 79;
+ /// ISO cnlp
+ pub const EON = 80;
+ /// VMTP
+ pub const VMTP = 81;
+ /// Secure VMTP
+ pub const SVMTP = 82;
+ /// Banyon VINES
+ pub const VINES = 83;
+ /// TTP
+ pub const TTP = 84;
+ /// NSFNET-IGP
+ pub const IGP = 85;
+ /// dissimilar gateway prot.
+ pub const DGP = 86;
+ /// TCF
+ pub const TCF = 87;
+ /// Cisco/GXS IGRP
+ pub const IGRP = 88;
+ /// OSPFIGP
+ pub const OSPFIGP = 89;
+ /// Strite RPC protocol
+ pub const SRPC = 90;
+ /// Locus Address Resoloution
+ pub const LARP = 91;
+ /// Multicast Transport
+ pub const MTP = 92;
+ /// AX.25 Frames
+ pub const AX25 = 93;
+ /// IP encapsulated in IP
+ pub const IPEIP = 94;
+ /// Mobile Int.ing control
+ pub const MICP = 95;
+ /// Semaphore Comm. security
+ pub const SCCSP = 96;
+ /// Ethernet IP encapsulation
+ pub const ETHERIP = 97;
+ /// encapsulation header
+ pub const ENCAP = 98;
+ /// any private encr. scheme
+ pub const APES = 99;
+ /// GMTP
+ pub const GMTP = 100;
+ /// payload compression (IPComp)
+ pub const IPCOMP = 108;
+ /// SCTP
+ pub const SCTP = 132;
+ /// IPv6 Mobility Header
+ pub const MH = 135;
+ /// UDP-Lite
+ pub const UDPLITE = 136;
+ /// IP6 Host Identity Protocol
+ pub const HIP = 139;
+ /// IP6 Shim6 Protocol
+ pub const SHIM6 = 140;
+ /// Protocol Independent Mcast
+ pub const PIM = 103;
+ /// CARP
+ pub const CARP = 112;
+ /// PGM
+ pub const PGM = 113;
+ /// MPLS-in-IP
+ pub const MPLS = 137;
+ /// PFSYNC
+ pub const PFSYNC = 240;
+ /// Reserved
+ pub const RESERVED_253 = 253;
+ /// Reserved
+ pub const RESERVED_254 = 254;
+};
+
+pub const rlimit_resource = enum(c_int) {
+ CPU = 0,
+ FSIZE = 1,
+ DATA = 2,
+ STACK = 3,
+ CORE = 4,
+ RSS = 5,
+ MEMLOCK = 6,
+ NPROC = 7,
+ NOFILE = 8,
+ SBSIZE = 9,
+ VMEM = 10,
+ NPTS = 11,
+ SWAP = 12,
+ KQUEUES = 13,
+ UMTXP = 14,
+ _,
+
+ pub const AS: rlimit_resource = .VMEM;
+};
+
+pub const rlim_t = i64;
+
+pub const RLIM = struct {
+ /// No limit
+ pub const INFINITY: rlim_t = (1 << 63) - 1;
+
+ pub const SAVED_MAX = INFINITY;
+ pub const SAVED_CUR = INFINITY;
+};
+
+pub const rlimit = extern struct {
+ /// Soft limit
+ cur: rlim_t,
+ /// Hard limit
+ max: rlim_t,
+};
+
+pub const SHUT = struct {
+ pub const RD = 0;
+ pub const WR = 1;
+ pub const RDWR = 2;
+};
+
+pub const nfds_t = u32;
+
+pub const pollfd = extern struct {
+ fd: fd_t,
+ events: i16,
+ revents: i16,
+};
+
+pub const POLL = struct {
+ /// any readable data available.
+ pub const IN = 0x0001;
+ /// OOB/Urgent readable data.
+ pub const PRI = 0x0002;
+ /// file descriptor is writeable.
+ pub const OUT = 0x0004;
+ /// non-OOB/URG data available.
+ pub const RDNORM = 0x0040;
+ /// no write type differentiation.
+ pub const WRNORM = OUT;
+ /// OOB/Urgent readable data.
+ pub const RDBAND = 0x0080;
+ /// OOB/Urgent data can be written.
+ pub const WRBAND = 0x0100;
+ /// like IN, except ignore EOF.
+ pub const INIGNEOF = 0x2000;
+ /// some poll error occurred.
+ pub const ERR = 0x0008;
+ /// file descriptor was "hung up".
+ pub const HUP = 0x0010;
+ /// requested events "invalid".
+ pub const NVAL = 0x0020;
+
+ pub const STANDARD = IN | PRI | OUT | RDNORM | RDBAND | WRBAND | ERR | HUP | NVAL;
+};
diff --git a/lib/std/c/haiku.zig b/lib/std/c/haiku.zig
index be6c180bed05..1ad51cfaddf7 100644
--- a/lib/std/c/haiku.zig
+++ b/lib/std/c/haiku.zig
@@ -1,8 +1,8 @@
-//
const std = @import("../std.zig");
-const builtin = std.builtin;
-
-usingnamespace std.c;
+const builtin = @import("builtin");
+const maxInt = std.math.maxInt;
+const iovec = std.os.iovec;
+const iovec_const = std.os.iovec_const;
extern "c" fn _errnop() *c_int;
@@ -19,7 +19,7 @@ pub extern "c" fn _get_next_image_info(team: c_int, cookie: *i32, image_info: *i
pub extern "c" fn _kern_read_dir(fd: c_int, buf_ptr: [*]u8, nbytes: usize, maxcount: u32) usize;
-pub extern "c" fn _kern_read_stat(fd: c_int, path_ptr: [*]u8, traverse_link: bool, libc_stat: *libc_stat, stat_size: i32) usize;
+pub extern "c" fn _kern_read_stat(fd: c_int, path_ptr: [*]u8, traverse_link: bool, st: *Stat, stat_size: i32) usize;
pub extern "c" fn _kern_get_current_team() i32;
@@ -111,3 +111,1296 @@ pub const EAI = enum(c_int) {
};
pub const EAI_MAX = 15;
+
+pub const fd_t = c_int;
+pub const pid_t = c_int;
+pub const uid_t = u32;
+pub const gid_t = u32;
+pub const mode_t = c_uint;
+
+pub const socklen_t = u32;
+
+/// Renamed from `kevent` to `Kevent` to avoid conflict with function name.
+pub const Kevent = extern struct {
+ ident: usize,
+ filter: i16,
+ flags: u16,
+ fflags: u32,
+ data: i64,
+ udata: usize,
+ // TODO ext
+};
+
+// Modes and flags for dlopen()
+// include/dlfcn.h
+
+pub const POLL = struct {
+ pub const IN = 0x0001;
+ pub const ERR = 0x0004;
+ pub const NVAL = 0x1000;
+ pub const HUP = 0x0080;
+};
+
+pub const RTLD = struct {
+ /// Bind function calls lazily.
+ pub const LAZY = 1;
+ /// Bind function calls immediately.
+ pub const NOW = 2;
+ pub const MODEMASK = 0x3;
+ /// Make symbols globally available.
+ pub const GLOBAL = 0x100;
+ /// Opposite of GLOBAL, and the default.
+ pub const LOCAL = 0;
+ /// Trace loaded objects and exit.
+ pub const TRACE = 0x200;
+ /// Do not remove members.
+ pub const NODELETE = 0x01000;
+ /// Do not load if not already loaded.
+ pub const NOLOAD = 0x02000;
+};
+
+pub const dl_phdr_info = extern struct {
+ dlpi_addr: usize,
+ dlpi_name: ?[*:0]const u8,
+ dlpi_phdr: [*]std.elf.Phdr,
+ dlpi_phnum: u16,
+};
+
+pub const Flock = extern struct {
+ l_start: off_t,
+ l_len: off_t,
+ l_pid: pid_t,
+ l_type: i16,
+ l_whence: i16,
+ l_sysid: i32,
+ __unused: [4]u8,
+};
+
+pub const msghdr = extern struct {
+ /// optional address
+ msg_name: ?*sockaddr,
+
+ /// size of address
+ msg_namelen: socklen_t,
+
+ /// scatter/gather array
+ msg_iov: [*]iovec,
+
+ /// # elements in msg_iov
+ msg_iovlen: i32,
+
+ /// ancillary data
+ msg_control: ?*c_void,
+
+ /// ancillary data buffer len
+ msg_controllen: socklen_t,
+
+ /// flags on received message
+ msg_flags: i32,
+};
+
+pub const msghdr_const = extern struct {
+ /// optional address
+ msg_name: ?*const sockaddr,
+
+ /// size of address
+ msg_namelen: socklen_t,
+
+ /// scatter/gather array
+ msg_iov: [*]iovec_const,
+
+ /// # elements in msg_iov
+ msg_iovlen: i32,
+
+ /// ancillary data
+ msg_control: ?*c_void,
+
+ /// ancillary data buffer len
+ msg_controllen: socklen_t,
+
+ /// flags on received message
+ msg_flags: i32,
+};
+
+pub const off_t = i64;
+pub const ino_t = u64;
+
+pub const nfds_t = u32;
+
+pub const pollfd = extern struct {
+ fd: i32,
+ events: i16,
+ revents: i16,
+};
+
+pub const Stat = extern struct {
+ dev: i32,
+ ino: u64,
+ mode: u32,
+ nlink: i32,
+ uid: i32,
+ gid: i32,
+ size: i64,
+ rdev: i32,
+ blksize: i32,
+ atim: timespec,
+ mtim: timespec,
+ ctim: timespec,
+ crtim: timespec,
+ st_type: u32,
+ blocks: i64,
+
+ pub fn atime(self: @This()) timespec {
+ return self.atim;
+ }
+ pub fn mtime(self: @This()) timespec {
+ return self.mtim;
+ }
+ pub fn ctime(self: @This()) timespec {
+ return self.ctim;
+ }
+ pub fn crtime(self: @This()) timespec {
+ return self.crtim;
+ }
+};
+
+pub const timespec = extern struct {
+ tv_sec: isize,
+ tv_nsec: isize,
+};
+
+pub const dirent = extern struct {
+ d_dev: i32,
+ d_pdev: i32,
+ d_ino: i64,
+ d_pino: i64,
+ d_reclen: u16,
+ d_name: [256]u8,
+
+ pub fn reclen(self: dirent) u16 {
+ return self.d_reclen;
+ }
+};
+
+pub const image_info = extern struct {
+ id: u32,
+ type: u32,
+ sequence: i32,
+ init_order: i32,
+ init_routine: *c_void,
+ term_routine: *c_void,
+ device: i32,
+ node: i32,
+ name: [1024]u8,
+ text: *c_void,
+ data: *c_void,
+ text_size: i32,
+ data_size: i32,
+ api_version: i32,
+ abi: i32,
+};
+
+pub const system_info = extern struct {
+ boot_time: i64,
+ cpu_count: u32,
+ max_pages: u64,
+ used_pages: u64,
+ cached_pages: u64,
+ block_cache_pages: u64,
+ ignored_pages: u64,
+ needed_memory: u64,
+ free_memory: u64,
+ max_swap_pages: u64,
+ free_swap_pages: u64,
+ page_faults: u32,
+ max_sems: u32,
+ used_sems: u32,
+ max_ports: u32,
+ used_ports: u32,
+ max_threads: u32,
+ used_threads: u32,
+ max_teams: u32,
+ used_teams: u32,
+ kernel_name: [256]u8,
+ kernel_build_date: [32]u8,
+ kernel_build_time: [32]u8,
+ kernel_version: i64,
+ abi: u32,
+};
+
+pub const in_port_t = u16;
+pub const sa_family_t = u8;
+
+pub const sockaddr = extern struct {
+ /// total length
+ len: u8,
+ /// address family
+ family: sa_family_t,
+ /// actually longer; address value
+ data: [14]u8,
+
+ pub const storage = std.x.os.Socket.Address.Native.Storage;
+
+ pub const in = extern struct {
+ len: u8 = @sizeOf(in),
+ family: sa_family_t = AF.INET,
+ port: in_port_t,
+ addr: u32,
+ zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },
+ };
+
+ pub const in6 = extern struct {
+ len: u8 = @sizeOf(in6),
+ family: sa_family_t = AF.INET6,
+ port: in_port_t,
+ flowinfo: u32,
+ addr: [16]u8,
+ scope_id: u32,
+ };
+
+ pub const un = extern struct {
+ len: u8 = @sizeOf(un),
+ family: sa_family_t = AF.UNIX,
+ path: [104]u8,
+ };
+};
+
+pub const CTL = struct {
+ pub const KERN = 1;
+ pub const DEBUG = 5;
+};
+
+pub const KERN = struct {
+ pub const PROC = 14; // struct: process entries
+ pub const PROC_PATHNAME = 12; // path to executable
+};
+
+pub const PATH_MAX = 1024;
+
+pub const STDIN_FILENO = 0;
+pub const STDOUT_FILENO = 1;
+pub const STDERR_FILENO = 2;
+
+pub const PROT = struct {
+ pub const NONE = 0;
+ pub const READ = 1;
+ pub const WRITE = 2;
+ pub const EXEC = 4;
+};
+
+pub const CLOCK = struct {
+ pub const MONOTONIC = 0;
+ pub const REALTIME = -1;
+ pub const PROCESS_CPUTIME_ID = -2;
+ pub const THREAD_CPUTIME_ID = -3;
+};
+
+pub const MAP = struct {
+ pub const FAILED = @intToPtr(*c_void, maxInt(usize));
+ pub const SHARED = 0x0001;
+ pub const PRIVATE = 0x0002;
+ pub const FIXED = 0x0010;
+ pub const STACK = 0x0400;
+ pub const NOSYNC = 0x0800;
+ pub const ANON = 0x1000;
+ pub const ANONYMOUS = ANON;
+ pub const FILE = 0;
+
+ pub const GUARD = 0x00002000;
+ pub const EXCL = 0x00004000;
+ pub const NOCORE = 0x00020000;
+ pub const PREFAULT_READ = 0x00040000;
+ pub const @"32BIT" = 0x00080000;
+};
+
+pub const W = struct {
+ pub const NOHANG = 0x1;
+ pub const UNTRACED = 0x2;
+ pub const STOPPED = 0x10;
+ pub const CONTINUED = 0x4;
+ pub const NOWAIT = 0x20;
+ pub const EXITED = 0x08;
+
+ pub fn EXITSTATUS(s: u32) u8 {
+ return @intCast(u8, s & 0xff);
+ }
+
+ pub fn TERMSIG(s: u32) u32 {
+ return (s >> 8) & 0xff;
+ }
+
+ pub fn STOPSIG(s: u32) u32 {
+ return EXITSTATUS(s);
+ }
+
+ pub fn IFEXITED(s: u32) bool {
+ return TERMSIG(s) == 0;
+ }
+
+ pub fn IFSTOPPED(s: u32) bool {
+ return ((s >> 16) & 0xff) != 0;
+ }
+
+ pub fn IFSIGNALED(s: u32) bool {
+ return ((s >> 8) & 0xff) != 0;
+ }
+};
+
+pub const SA = struct {
+ pub const ONSTACK = 0x20;
+ pub const RESTART = 0x10;
+ pub const RESETHAND = 0x04;
+ pub const NOCLDSTOP = 0x01;
+ pub const NODEFER = 0x08;
+ pub const NOCLDWAIT = 0x02;
+ pub const SIGINFO = 0x40;
+ pub const NOMASK = NODEFER;
+ pub const STACK = ONSTACK;
+ pub const ONESHOT = RESETHAND;
+};
+
+pub const SIG = struct {
+ pub const ERR = @intToPtr(fn (i32) callconv(.C) void, maxInt(usize));
+ pub const DFL = @intToPtr(fn (i32) callconv(.C) void, 0);
+ pub const IGN = @intToPtr(fn (i32) callconv(.C) void, 1);
+
+ pub const HUP = 1;
+ pub const INT = 2;
+ pub const QUIT = 3;
+ pub const ILL = 4;
+ pub const CHLD = 5;
+ pub const ABRT = 6;
+ pub const IOT = ABRT;
+ pub const PIPE = 7;
+ pub const FPE = 8;
+ pub const KILL = 9;
+ pub const STOP = 10;
+ pub const SEGV = 11;
+ pub const CONT = 12;
+ pub const TSTP = 13;
+ pub const ALRM = 14;
+ pub const TERM = 15;
+ pub const TTIN = 16;
+ pub const TTOU = 17;
+ pub const USR1 = 18;
+ pub const USR2 = 19;
+ pub const WINCH = 20;
+ pub const KILLTHR = 21;
+ pub const TRAP = 22;
+ pub const POLL = 23;
+ pub const PROF = 24;
+ pub const SYS = 25;
+ pub const URG = 26;
+ pub const VTALRM = 27;
+ pub const XCPU = 28;
+ pub const XFSZ = 29;
+ pub const BUS = 30;
+ pub const RESERVED1 = 31;
+ pub const RESERVED2 = 32;
+
+ // TODO: check
+ pub const RTMIN = 65;
+ pub const RTMAX = 126;
+
+ pub const BLOCK = 1;
+ pub const UNBLOCK = 2;
+ pub const SETMASK = 3;
+
+ pub const WORDS = 4;
+ pub const MAXSIG = 128;
+ pub inline fn IDX(sig: usize) usize {
+ return sig - 1;
+ }
+ pub inline fn WORD(sig: usize) usize {
+ return IDX(sig) >> 5;
+ }
+ pub inline fn BIT(sig: usize) usize {
+ return 1 << (IDX(sig) & 31);
+ }
+ pub inline fn VALID(sig: usize) usize {
+ return sig <= MAXSIG and sig > 0;
+ }
+};
+
+// access function
+pub const F_OK = 0; // test for existence of file
+pub const X_OK = 1; // test for execute or search permission
+pub const W_OK = 2; // test for write permission
+pub const R_OK = 4; // test for read permission
+
+pub const O = struct {
+ pub const RDONLY = 0x0000;
+ pub const WRONLY = 0x0001;
+ pub const RDWR = 0x0002;
+ pub const ACCMODE = 0x0003;
+
+ pub const SHLOCK = 0x0010;
+ pub const EXLOCK = 0x0020;
+
+ pub const CREAT = 0x0200;
+ pub const EXCL = 0x0800;
+ pub const NOCTTY = 0x8000;
+ pub const TRUNC = 0x0400;
+ pub const APPEND = 0x0008;
+ pub const NONBLOCK = 0x0004;
+ pub const DSYNC = 0o10000;
+ pub const SYNC = 0x0080;
+ pub const RSYNC = 0o4010000;
+ pub const DIRECTORY = 0x20000;
+ pub const NOFOLLOW = 0x0100;
+ pub const CLOEXEC = 0x00100000;
+
+ pub const ASYNC = 0x0040;
+ pub const DIRECT = 0x00010000;
+ pub const NOATIME = 0o1000000;
+ pub const PATH = 0o10000000;
+ pub const TMPFILE = 0o20200000;
+ pub const NDELAY = NONBLOCK;
+};
+
+pub const F = struct {
+ pub const DUPFD = 0;
+ pub const GETFD = 1;
+ pub const SETFD = 2;
+ pub const GETFL = 3;
+ pub const SETFL = 4;
+
+ pub const GETOWN = 5;
+ pub const SETOWN = 6;
+
+ pub const GETLK = 11;
+ pub const SETLK = 12;
+ pub const SETLKW = 13;
+
+ pub const RDLCK = 1;
+ pub const WRLCK = 3;
+ pub const UNLCK = 2;
+
+ pub const SETOWN_EX = 15;
+ pub const GETOWN_EX = 16;
+
+ pub const GETOWNER_UIDS = 17;
+};
+
+pub const LOCK = struct {
+ pub const SH = 1;
+ pub const EX = 2;
+ pub const UN = 8;
+ pub const NB = 4;
+};
+
+pub const FD_CLOEXEC = 1;
+
+pub const SEEK = struct {
+ pub const SET = 0;
+ pub const CUR = 1;
+ pub const END = 2;
+};
+
+pub const SOCK = struct {
+ pub const STREAM = 1;
+ pub const DGRAM = 2;
+ pub const RAW = 3;
+ pub const RDM = 4;
+ pub const SEQPACKET = 5;
+
+ pub const CLOEXEC = 0x10000000;
+ pub const NONBLOCK = 0x20000000;
+};
+
+pub const SO = struct {
+ pub const DEBUG = 0x00000001;
+ pub const ACCEPTCONN = 0x00000002;
+ pub const REUSEADDR = 0x00000004;
+ pub const KEEPALIVE = 0x00000008;
+ pub const DONTROUTE = 0x00000010;
+ pub const BROADCAST = 0x00000020;
+ pub const USELOOPBACK = 0x00000040;
+ pub const LINGER = 0x00000080;
+ pub const OOBINLINE = 0x00000100;
+ pub const REUSEPORT = 0x00000200;
+ pub const TIMESTAMP = 0x00000400;
+ pub const NOSIGPIPE = 0x00000800;
+ pub const ACCEPTFILTER = 0x00001000;
+ pub const BINTIME = 0x00002000;
+ pub const NO_OFFLOAD = 0x00004000;
+ pub const NO_DDP = 0x00008000;
+ pub const REUSEPORT_LB = 0x00010000;
+
+ pub const SNDBUF = 0x1001;
+ pub const RCVBUF = 0x1002;
+ pub const SNDLOWAT = 0x1003;
+ pub const RCVLOWAT = 0x1004;
+ pub const SNDTIMEO = 0x1005;
+ pub const RCVTIMEO = 0x1006;
+ pub const ERROR = 0x1007;
+ pub const TYPE = 0x1008;
+ pub const LABEL = 0x1009;
+ pub const PEERLABEL = 0x1010;
+ pub const LISTENQLIMIT = 0x1011;
+ pub const LISTENQLEN = 0x1012;
+ pub const LISTENINCQLEN = 0x1013;
+ pub const SETFIB = 0x1014;
+ pub const USER_COOKIE = 0x1015;
+ pub const PROTOCOL = 0x1016;
+ pub const PROTOTYPE = PROTOCOL;
+ pub const TS_CLOCK = 0x1017;
+ pub const MAX_PACING_RATE = 0x1018;
+ pub const DOMAIN = 0x1019;
+};
+
+pub const SOL = struct {
+ pub const SOCKET = 0xffff;
+};
+
+pub const PF = struct {
+ pub const UNSPEC = AF.UNSPEC;
+ pub const LOCAL = AF.LOCAL;
+ pub const UNIX = PF.LOCAL;
+ pub const INET = AF.INET;
+ pub const IMPLINK = AF.IMPLINK;
+ pub const PUP = AF.PUP;
+ pub const CHAOS = AF.CHAOS;
+ pub const NETBIOS = AF.NETBIOS;
+ pub const ISO = AF.ISO;
+ pub const OSI = AF.ISO;
+ pub const ECMA = AF.ECMA;
+ pub const DATAKIT = AF.DATAKIT;
+ pub const CCITT = AF.CCITT;
+ pub const DECnet = AF.DECnet;
+ pub const DLI = AF.DLI;
+ pub const LAT = AF.LAT;
+ pub const HYLINK = AF.HYLINK;
+ pub const APPLETALK = AF.APPLETALK;
+ pub const ROUTE = AF.ROUTE;
+ pub const LINK = AF.LINK;
+ pub const XTP = AF.pseudo_XTP;
+ pub const COIP = AF.COIP;
+ pub const CNT = AF.CNT;
+ pub const SIP = AF.SIP;
+ pub const IPX = AF.IPX;
+ pub const RTIP = AF.pseudo_RTIP;
+ pub const PIP = AF.pseudo_PIP;
+ pub const ISDN = AF.ISDN;
+ pub const KEY = AF.pseudo_KEY;
+ pub const INET6 = AF.pseudo_INET6;
+ pub const NATM = AF.NATM;
+ pub const ATM = AF.ATM;
+ pub const NETGRAPH = AF.NETGRAPH;
+ pub const SLOW = AF.SLOW;
+ pub const SCLUSTER = AF.SCLUSTER;
+ pub const ARP = AF.ARP;
+ pub const BLUETOOTH = AF.BLUETOOTH;
+ pub const IEEE80211 = AF.IEEE80211;
+ pub const INET_SDP = AF.INET_SDP;
+ pub const INET6_SDP = AF.INET6_SDP;
+ pub const MAX = AF.MAX;
+};
+
+pub const AF = struct {
+ pub const UNSPEC = 0;
+ pub const UNIX = 1;
+ pub const LOCAL = UNIX;
+ pub const FILE = LOCAL;
+ pub const INET = 2;
+ pub const IMPLINK = 3;
+ pub const PUP = 4;
+ pub const CHAOS = 5;
+ pub const NETBIOS = 6;
+ pub const ISO = 7;
+ pub const OSI = ISO;
+ pub const ECMA = 8;
+ pub const DATAKIT = 9;
+ pub const CCITT = 10;
+ pub const SNA = 11;
+ pub const DECnet = 12;
+ pub const DLI = 13;
+ pub const LAT = 14;
+ pub const HYLINK = 15;
+ pub const APPLETALK = 16;
+ pub const ROUTE = 17;
+ pub const LINK = 18;
+ pub const pseudo_XTP = 19;
+ pub const COIP = 20;
+ pub const CNT = 21;
+ pub const pseudo_RTIP = 22;
+ pub const IPX = 23;
+ pub const SIP = 24;
+ pub const pseudo_PIP = 25;
+ pub const ISDN = 26;
+ pub const E164 = ISDN;
+ pub const pseudo_KEY = 27;
+ pub const INET6 = 28;
+ pub const NATM = 29;
+ pub const ATM = 30;
+ pub const pseudo_HDRCMPLT = 31;
+ pub const NETGRAPH = 32;
+ pub const SLOW = 33;
+ pub const SCLUSTER = 34;
+ pub const ARP = 35;
+ pub const BLUETOOTH = 36;
+ pub const IEEE80211 = 37;
+ pub const INET_SDP = 40;
+ pub const INET6_SDP = 42;
+ pub const MAX = 42;
+};
+
+pub const DT = struct {
+ pub const UNKNOWN = 0;
+ pub const FIFO = 1;
+ pub const CHR = 2;
+ pub const DIR = 4;
+ pub const BLK = 6;
+ pub const REG = 8;
+ pub const LNK = 10;
+ pub const SOCK = 12;
+ pub const WHT = 14;
+};
+
+/// add event to kq (implies enable)
+pub const EV_ADD = 0x0001;
+
+/// delete event from kq
+pub const EV_DELETE = 0x0002;
+
+/// enable event
+pub const EV_ENABLE = 0x0004;
+
+/// disable event (not reported)
+pub const EV_DISABLE = 0x0008;
+
+/// only report one occurrence
+pub const EV_ONESHOT = 0x0010;
+
+/// clear event state after reporting
+pub const EV_CLEAR = 0x0020;
+
+/// force immediate event output
+/// ... with or without EV_ERROR
+/// ... use KEVENT_FLAG_ERROR_EVENTS
+/// on syscalls supporting flags
+pub const EV_RECEIPT = 0x0040;
+
+/// disable event after reporting
+pub const EV_DISPATCH = 0x0080;
+
+pub const EVFILT_READ = -1;
+pub const EVFILT_WRITE = -2;
+
+/// attached to aio requests
+pub const EVFILT_AIO = -3;
+
+/// attached to vnodes
+pub const EVFILT_VNODE = -4;
+
+/// attached to struct proc
+pub const EVFILT_PROC = -5;
+
+/// attached to struct proc
+pub const EVFILT_SIGNAL = -6;
+
+/// timers
+pub const EVFILT_TIMER = -7;
+
+/// Process descriptors
+pub const EVFILT_PROCDESC = -8;
+
+/// Filesystem events
+pub const EVFILT_FS = -9;
+
+pub const EVFILT_LIO = -10;
+
+/// User events
+pub const EVFILT_USER = -11;
+
+/// Sendfile events
+pub const EVFILT_SENDFILE = -12;
+
+pub const EVFILT_EMPTY = -13;
+
+pub const T = struct {
+ pub const CGETA = 0x8000;
+ pub const CSETA = 0x8001;
+ pub const CSETAW = 0x8004;
+ pub const CSETAF = 0x8003;
+ pub const CSBRK = 08005;
+ pub const CXONC = 0x8007;
+ pub const CFLSH = 0x8006;
+
+ pub const IOCSCTTY = 0x8017;
+ pub const IOCGPGRP = 0x8015;
+ pub const IOCSPGRP = 0x8016;
+ pub const IOCGWINSZ = 0x8012;
+ pub const IOCSWINSZ = 0x8013;
+ pub const IOCMGET = 0x8018;
+ pub const IOCMBIS = 0x8022;
+ pub const IOCMBIC = 0x8023;
+ pub const IOCMSET = 0x8019;
+ pub const FIONREAD = 0xbe000001;
+ pub const FIONBIO = 0xbe000000;
+ pub const IOCSBRK = 0x8020;
+ pub const IOCCBRK = 0x8021;
+ pub const IOCGSID = 0x8024;
+};
+
+pub const winsize = extern struct {
+ ws_row: u16,
+ ws_col: u16,
+ ws_xpixel: u16,
+ ws_ypixel: u16,
+};
+
+const NSIG = 32;
+
+/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.
+pub const Sigaction = extern struct {
+ /// signal handler
+ __sigaction_u: extern union {
+ __sa_handler: fn (i32) callconv(.C) void,
+ },
+
+ /// see signal options
+ sa_flags: u32,
+
+ /// signal mask to apply
+ sa_mask: sigset_t,
+};
+
+pub const sigset_t = extern struct {
+ __bits: [SIG.WORDS]u32,
+};
+
+pub const E = enum(i32) {
+ /// No error occurred.
+ SUCCESS = 0,
+ PERM = -0x7ffffff1, // Operation not permitted
+ NOENT = -0x7fff9ffd, // No such file or directory
+ SRCH = -0x7fff8ff3, // No such process
+ INTR = -0x7ffffff6, // Interrupted system call
+ IO = -0x7fffffff, // Input/output error
+ NXIO = -0x7fff8ff5, // Device not configured
+ @"2BIG" = -0x7fff8fff, // Argument list too long
+ NOEXEC = -0x7fffecfe, // Exec format error
+ CHILD = -0x7fff8ffe, // No child processes
+ DEADLK = -0x7fff8ffd, // Resource deadlock avoided
+ NOMEM = -0x80000000, // Cannot allocate memory
+ ACCES = -0x7ffffffe, // Permission denied
+ FAULT = -0x7fffecff, // Bad address
+ BUSY = -0x7ffffff2, // Device busy
+ EXIST = -0x7fff9ffe, // File exists
+ XDEV = -0x7fff9ff5, // Cross-device link
+ NODEV = -0x7fff8ff9, // Operation not supported by device
+ NOTDIR = -0x7fff9ffb, // Not a directory
+ ISDIR = -0x7fff9ff7, // Is a directory
+ INVAL = -0x7ffffffb, // Invalid argument
+ NFILE = -0x7fff8ffa, // Too many open files in system
+ MFILE = -0x7fff9ff6, // Too many open files
+ NOTTY = -0x7fff8ff6, // Inappropriate ioctl for device
+ TXTBSY = -0x7fff8fc5, // Text file busy
+ FBIG = -0x7fff8ffc, // File too large
+ NOSPC = -0x7fff9ff9, // No space left on device
+ SPIPE = -0x7fff8ff4, // Illegal seek
+ ROFS = -0x7fff9ff8, // Read-only filesystem
+ MLINK = -0x7fff8ffb, // Too many links
+ PIPE = -0x7fff9ff3, // Broken pipe
+ BADF = -0x7fffa000, // Bad file descriptor
+
+ // math software
+ DOM = 33, // Numerical argument out of domain
+ RANGE = 34, // Result too large
+
+ // non-blocking and interrupt i/o
+
+ /// Also used for `WOULDBLOCK`.
+ AGAIN = -0x7ffffff5,
+ INPROGRESS = -0x7fff8fdc,
+ ALREADY = -0x7fff8fdb,
+
+ // ipc/network software -- argument errors
+ NOTSOCK = 38, // Socket operation on non-socket
+ DESTADDRREQ = 39, // Destination address required
+ MSGSIZE = 40, // Message too long
+ PROTOTYPE = 41, // Protocol wrong type for socket
+ NOPROTOOPT = 42, // Protocol not available
+ PROTONOSUPPORT = 43, // Protocol not supported
+ SOCKTNOSUPPORT = 44, // Socket type not supported
+ /// Also used for `NOTSUP`.
+ OPNOTSUPP = 45, // Operation not supported
+ PFNOSUPPORT = 46, // Protocol family not supported
+ AFNOSUPPORT = 47, // Address family not supported by protocol family
+ ADDRINUSE = 48, // Address already in use
+ ADDRNOTAVAIL = 49, // Can't assign requested address
+
+ // ipc/network software -- operational errors
+ NETDOWN = 50, // Network is down
+ NETUNREACH = 51, // Network is unreachable
+ NETRESET = 52, // Network dropped connection on reset
+ CONNABORTED = 53, // Software caused connection abort
+ CONNRESET = 54, // Connection reset by peer
+ NOBUFS = 55, // No buffer space available
+ ISCONN = 56, // Socket is already connected
+ NOTCONN = 57, // Socket is not connected
+ SHUTDOWN = 58, // Can't send after socket shutdown
+ TOOMANYREFS = 59, // Too many references: can't splice
+ TIMEDOUT = 60, // Operation timed out
+ CONNREFUSED = 61, // Connection refused
+
+ LOOP = 62, // Too many levels of symbolic links
+ NAMETOOLONG = 63, // File name too long
+
+ // should be rearranged
+ HOSTDOWN = 64, // Host is down
+ HOSTUNREACH = 65, // No route to host
+ NOTEMPTY = 66, // Directory not empty
+
+ // quotas & mush
+ PROCLIM = 67, // Too many processes
+ USERS = 68, // Too many users
+ DQUOT = 69, // Disc quota exceeded
+
+ // Network File System
+ STALE = 70, // Stale NFS file handle
+ REMOTE = 71, // Too many levels of remote in path
+ BADRPC = 72, // RPC struct is bad
+ RPCMISMATCH = 73, // RPC version wrong
+ PROGUNAVAIL = 74, // RPC prog. not avail
+ PROGMISMATCH = 75, // Program version wrong
+ PROCUNAVAIL = 76, // Bad procedure for program
+
+ NOLCK = 77, // No locks available
+ NOSYS = 78, // Function not implemented
+
+ FTYPE = 79, // Inappropriate file type or format
+ AUTH = 80, // Authentication error
+ NEEDAUTH = 81, // Need authenticator
+ IDRM = 82, // Identifier removed
+ NOMSG = 83, // No message of desired type
+ OVERFLOW = 84, // Value too large to be stored in data type
+ CANCELED = 85, // Operation canceled
+ ILSEQ = 86, // Illegal byte sequence
+ NOATTR = 87, // Attribute not found
+
+ DOOFUS = 88, // Programming error
+
+ BADMSG = 89, // Bad message
+ MULTIHOP = 90, // Multihop attempted
+ NOLINK = 91, // Link has been severed
+ PROTO = 92, // Protocol error
+
+ NOTCAPABLE = 93, // Capabilities insufficient
+ CAPMODE = 94, // Not permitted in capability mode
+ NOTRECOVERABLE = 95, // State not recoverable
+ OWNERDEAD = 96, // Previous owner died
+
+ _,
+};
+
+pub const MINSIGSTKSZ = switch (builtin.cpu.arch) {
+ .i386, .x86_64 => 2048,
+ .arm, .aarch64 => 4096,
+ else => @compileError("MINSIGSTKSZ not defined for this architecture"),
+};
+pub const SIGSTKSZ = MINSIGSTKSZ + 32768;
+
+pub const SS_ONSTACK = 1;
+pub const SS_DISABLE = 4;
+
+pub const stack_t = extern struct {
+ sp: [*]u8,
+ size: isize,
+ flags: i32,
+};
+
+pub const S = struct {
+ pub const IFMT = 0o170000;
+
+ pub const IFIFO = 0o010000;
+ pub const IFCHR = 0o020000;
+ pub const IFDIR = 0o040000;
+ pub const IFBLK = 0o060000;
+ pub const IFREG = 0o100000;
+ pub const IFLNK = 0o120000;
+ pub const IFSOCK = 0o140000;
+ pub const IFWHT = 0o160000;
+
+ pub const ISUID = 0o4000;
+ pub const ISGID = 0o2000;
+ pub const ISVTX = 0o1000;
+ pub const IRWXU = 0o700;
+ pub const IRUSR = 0o400;
+ pub const IWUSR = 0o200;
+ pub const IXUSR = 0o100;
+ pub const IRWXG = 0o070;
+ pub const IRGRP = 0o040;
+ pub const IWGRP = 0o020;
+ pub const IXGRP = 0o010;
+ pub const IRWXO = 0o007;
+ pub const IROTH = 0o004;
+ pub const IWOTH = 0o002;
+ pub const IXOTH = 0o001;
+
+ pub fn ISFIFO(m: u32) bool {
+ return m & IFMT == IFIFO;
+ }
+
+ pub fn ISCHR(m: u32) bool {
+ return m & IFMT == IFCHR;
+ }
+
+ pub fn ISDIR(m: u32) bool {
+ return m & IFMT == IFDIR;
+ }
+
+ pub fn ISBLK(m: u32) bool {
+ return m & IFMT == IFBLK;
+ }
+
+ pub fn ISREG(m: u32) bool {
+ return m & IFMT == IFREG;
+ }
+
+ pub fn ISLNK(m: u32) bool {
+ return m & IFMT == IFLNK;
+ }
+
+ pub fn ISSOCK(m: u32) bool {
+ return m & IFMT == IFSOCK;
+ }
+
+ pub fn IWHT(m: u32) bool {
+ return m & IFMT == IFWHT;
+ }
+};
+
+pub const HOST_NAME_MAX = 255;
+
+pub const AT = struct {
+ /// Magic value that specify the use of the current working directory
+ /// to determine the target of relative file paths in the openat() and
+ /// similar syscalls.
+ pub const FDCWD = -100;
+ /// Check access using effective user and group ID
+ pub const EACCESS = 0x0100;
+ /// Do not follow symbolic links
+ pub const SYMLINK_NOFOLLOW = 0x0200;
+ /// Follow symbolic link
+ pub const SYMLINK_FOLLOW = 0x0400;
+ /// Remove directory instead of file
+ pub const REMOVEDIR = 0x0800;
+ /// Fail if not under dirfd
+ pub const BENEATH = 0x1000;
+};
+
+pub const addrinfo = extern struct {
+ flags: i32,
+ family: i32,
+ socktype: i32,
+ protocol: i32,
+ addrlen: socklen_t,
+ canonname: ?[*:0]u8,
+ addr: ?*sockaddr,
+ next: ?*addrinfo,
+};
+
+pub const IPPROTO = struct {
+ /// dummy for IP
+ pub const IP = 0;
+ /// control message protocol
+ pub const ICMP = 1;
+ /// tcp
+ pub const TCP = 6;
+ /// user datagram protocol
+ pub const UDP = 17;
+ /// IP6 header
+ pub const IPV6 = 41;
+ /// raw IP packet
+ pub const RAW = 255;
+ /// IP6 hop-by-hop options
+ pub const HOPOPTS = 0;
+ /// group mgmt protocol
+ pub const IGMP = 2;
+ /// gateway^2 (deprecated)
+ pub const GGP = 3;
+ /// IPv4 encapsulation
+ pub const IPV4 = 4;
+ /// for compatibility
+ pub const IPIP = IPV4;
+ /// Stream protocol II
+ pub const ST = 7;
+ /// exterior gateway protocol
+ pub const EGP = 8;
+ /// private interior gateway
+ pub const PIGP = 9;
+ /// BBN RCC Monitoring
+ pub const RCCMON = 10;
+ /// network voice protocol
+ pub const NVPII = 11;
+ /// pup
+ pub const PUP = 12;
+ /// Argus
+ pub const ARGUS = 13;
+ /// EMCON
+ pub const EMCON = 14;
+ /// Cross Net Debugger
+ pub const XNET = 15;
+ /// Chaos
+ pub const CHAOS = 16;
+ /// Multiplexing
+ pub const MUX = 18;
+ /// DCN Measurement Subsystems
+ pub const MEAS = 19;
+ /// Host Monitoring
+ pub const HMP = 20;
+ /// Packet Radio Measurement
+ pub const PRM = 21;
+ /// xns idp
+ pub const IDP = 22;
+ /// Trunk-1
+ pub const TRUNK1 = 23;
+ /// Trunk-2
+ pub const TRUNK2 = 24;
+ /// Leaf-1
+ pub const LEAF1 = 25;
+ /// Leaf-2
+ pub const LEAF2 = 26;
+ /// Reliable Data
+ pub const RDP = 27;
+ /// Reliable Transaction
+ pub const IRTP = 28;
+ /// tp-4 w/ class negotiation
+ pub const TP = 29;
+ /// Bulk Data Transfer
+ pub const BLT = 30;
+ /// Network Services
+ pub const NSP = 31;
+ /// Merit Internodal
+ pub const INP = 32;
+ /// Datagram Congestion Control Protocol
+ pub const DCCP = 33;
+ /// Third Party Connect
+ pub const @"3PC" = 34;
+ /// InterDomain Policy Routing
+ pub const IDPR = 35;
+ /// XTP
+ pub const XTP = 36;
+ /// Datagram Delivery
+ pub const DDP = 37;
+ /// Control Message Transport
+ pub const CMTP = 38;
+ /// TP++ Transport
+ pub const TPXX = 39;
+ /// IL transport protocol
+ pub const IL = 40;
+ /// Source Demand Routing
+ pub const SDRP = 42;
+ /// IP6 routing header
+ pub const ROUTING = 43;
+ /// IP6 fragmentation header
+ pub const FRAGMENT = 44;
+ /// InterDomain Routing
+ pub const IDRP = 45;
+ /// resource reservation
+ pub const RSVP = 46;
+ /// General Routing Encap.
+ pub const GRE = 47;
+ /// Mobile Host Routing
+ pub const MHRP = 48;
+ /// BHA
+ pub const BHA = 49;
+ /// IP6 Encap Sec. Payload
+ pub const ESP = 50;
+ /// IP6 Auth Header
+ pub const AH = 51;
+ /// Integ. Net Layer Security
+ pub const INLSP = 52;
+ /// IP with encryption
+ pub const SWIPE = 53;
+ /// Next Hop Resolution
+ pub const NHRP = 54;
+ /// IP Mobility
+ pub const MOBILE = 55;
+ /// Transport Layer Security
+ pub const TLSP = 56;
+ /// SKIP
+ pub const SKIP = 57;
+ /// ICMP6
+ pub const ICMPV6 = 58;
+ /// IP6 no next header
+ pub const NONE = 59;
+ /// IP6 destination option
+ pub const DSTOPTS = 60;
+ /// any host internal protocol
+ pub const AHIP = 61;
+ /// CFTP
+ pub const CFTP = 62;
+ /// "hello" routing protocol
+ pub const HELLO = 63;
+ /// SATNET/Backroom EXPAK
+ pub const SATEXPAK = 64;
+ /// Kryptolan
+ pub const KRYPTOLAN = 65;
+ /// Remote Virtual Disk
+ pub const RVD = 66;
+ /// Pluribus Packet Core
+ pub const IPPC = 67;
+ /// Any distributed FS
+ pub const ADFS = 68;
+ /// Satnet Monitoring
+ pub const SATMON = 69;
+ /// VISA Protocol
+ pub const VISA = 70;
+ /// Packet Core Utility
+ pub const IPCV = 71;
+ /// Comp. Prot. Net. Executive
+ pub const CPNX = 72;
+ /// Comp. Prot. HeartBeat
+ pub const CPHB = 73;
+ /// Wang Span Network
+ pub const WSN = 74;
+ /// Packet Video Protocol
+ pub const PVP = 75;
+ /// BackRoom SATNET Monitoring
+ pub const BRSATMON = 76;
+ /// Sun net disk proto (temp.)
+ pub const ND = 77;
+ /// WIDEBAND Monitoring
+ pub const WBMON = 78;
+ /// WIDEBAND EXPAK
+ pub const WBEXPAK = 79;
+ /// ISO cnlp
+ pub const EON = 80;
+ /// VMTP
+ pub const VMTP = 81;
+ /// Secure VMTP
+ pub const SVMTP = 82;
+ /// Banyon VINES
+ pub const VINES = 83;
+ /// TTP
+ pub const TTP = 84;
+ /// NSFNET-IGP
+ pub const IGP = 85;
+ /// dissimilar gateway prot.
+ pub const DGP = 86;
+ /// TCF
+ pub const TCF = 87;
+ /// Cisco/GXS IGRP
+ pub const IGRP = 88;
+ /// OSPFIGP
+ pub const OSPFIGP = 89;
+ /// Strite RPC protocol
+ pub const SRPC = 90;
+ /// Locus Address Resoloution
+ pub const LARP = 91;
+ /// Multicast Transport
+ pub const MTP = 92;
+ /// AX.25 Frames
+ pub const AX25 = 93;
+ /// IP encapsulated in IP
+ pub const IPEIP = 94;
+ /// Mobile Int.ing control
+ pub const MICP = 95;
+ /// Semaphore Comm. security
+ pub const SCCSP = 96;
+ /// Ethernet IP encapsulation
+ pub const ETHERIP = 97;
+ /// encapsulation header
+ pub const ENCAP = 98;
+ /// any private encr. scheme
+ pub const APES = 99;
+ /// GMTP
+ pub const GMTP = 100;
+ /// payload compression (IPComp)
+ pub const IPCOMP = 108;
+ /// SCTP
+ pub const SCTP = 132;
+ /// IPv6 Mobility Header
+ pub const MH = 135;
+ /// UDP-Lite
+ pub const UDPLITE = 136;
+ /// IP6 Host Identity Protocol
+ pub const HIP = 139;
+ /// IP6 Shim6 Protocol
+ pub const SHIM6 = 140;
+ /// Protocol Independent Mcast
+ pub const PIM = 103;
+ /// CARP
+ pub const CARP = 112;
+ /// PGM
+ pub const PGM = 113;
+ /// MPLS-in-IP
+ pub const MPLS = 137;
+ /// PFSYNC
+ pub const PFSYNC = 240;
+ /// Reserved
+ pub const RESERVED_253 = 253;
+ /// Reserved
+ pub const RESERVED_254 = 254;
+};
+
+pub const rlimit_resource = enum(c_int) {
+ CPU = 0,
+ FSIZE = 1,
+ DATA = 2,
+ STACK = 3,
+ CORE = 4,
+ RSS = 5,
+ MEMLOCK = 6,
+ NPROC = 7,
+ NOFILE = 8,
+ SBSIZE = 9,
+ VMEM = 10,
+ NPTS = 11,
+ SWAP = 12,
+ KQUEUES = 13,
+ UMTXP = 14,
+ _,
+
+ pub const AS: rlimit_resource = .VMEM;
+};
+
+pub const rlim_t = i64;
+
+pub const RLIM = struct {
+ /// No limit
+ pub const INFINITY: rlim_t = (1 << 63) - 1;
+
+ pub const SAVED_MAX = INFINITY;
+ pub const SAVED_CUR = INFINITY;
+};
+
+pub const rlimit = extern struct {
+ /// Soft limit
+ cur: rlim_t,
+ /// Hard limit
+ max: rlim_t,
+};
+
+pub const SHUT = struct {
+ pub const RD = 0;
+ pub const WR = 1;
+ pub const RDWR = 2;
+};
+
+// TODO fill out if needed
+pub const directory_which = enum(c_int) {
+ B_USER_SETTINGS_DIRECTORY = 0xbbe,
+
+ _,
+};
+
+pub const cc_t = u8;
+pub const speed_t = u8;
+pub const tcflag_t = u32;
+
+pub const NCCS = 32;
+
+pub const termios = extern struct {
+ c_iflag: tcflag_t,
+ c_oflag: tcflag_t,
+ c_cflag: tcflag_t,
+ c_lflag: tcflag_t,
+ c_line: cc_t,
+ c_ispeed: speed_t,
+ c_ospeed: speed_t,
+ cc_t: [NCCS]cc_t,
+};
diff --git a/lib/std/c/hermit.zig b/lib/std/c/hermit.zig
index ae13840e1656..879346ba13d7 100644
--- a/lib/std/c/hermit.zig
+++ b/lib/std/c/hermit.zig
@@ -1,3 +1,6 @@
+const std = @import("std");
+const maxInt = std.math.maxInt;
+
pub const pthread_mutex_t = extern struct {
inner: usize = ~@as(usize, 0),
};
@@ -5,5 +8,5 @@ pub const pthread_cond_t = extern struct {
inner: usize = ~@as(usize, 0),
};
pub const pthread_rwlock_t = extern struct {
- ptr: usize = std.math.maxInt(usize),
+ ptr: usize = maxInt(usize),
};
diff --git a/lib/std/c/linux.zig b/lib/std/c/linux.zig
index 808b05bd6db7..aa9d4087c229 100644
--- a/lib/std/c/linux.zig
+++ b/lib/std/c/linux.zig
@@ -1,11 +1,104 @@
const std = @import("../std.zig");
+const builtin = @import("builtin");
const maxInt = std.math.maxInt;
-const abi = std.Target.current.abi;
-const arch = std.Target.current.cpu.arch;
-const os_tag = std.Target.current.os.tag;
-usingnamespace std.c;
+const native_abi = builtin.abi;
+const native_arch = builtin.cpu.arch;
+const linux = std.os.linux;
+const iovec = std.os.iovec;
+const iovec_const = std.os.iovec_const;
+const FILE = std.c.FILE;
-pub const _errno = switch (abi) {
+pub const AF = linux.AF;
+pub const ARCH = linux.ARCH;
+pub const AT = linux.AT;
+pub const CLOCK = linux.CLOCK;
+pub const CPU_COUNT = linux.CPU_COUNT;
+pub const E = linux.E;
+pub const Elf_Symndx = linux.Elf_Symndx;
+pub const F = linux.F;
+pub const FD_CLOEXEC = linux.FD_CLOEXEC;
+pub const F_OK = linux.F_OK;
+pub const Flock = linux.Flock;
+pub const HOST_NAME_MAX = linux.HOST_NAME_MAX;
+pub const IFNAMESIZE = linux.IFNAMESIZE;
+pub const IOV_MAX = linux.IOV_MAX;
+pub const IPPROTO = linux.IPPROTO;
+pub const LOCK = linux.LOCK;
+pub const MADV = linux.MADV;
+pub const MAP = struct {
+ pub usingnamespace linux.MAP;
+ /// Only used by libc to communicate failure.
+ pub const FAILED = @intToPtr(*c_void, maxInt(usize));
+};
+pub const MMAP2_UNIT = linux.MMAP2_UNIT;
+pub const NAME_MAX = linux.NAME_MAX;
+pub const O = linux.O;
+pub const PATH_MAX = linux.PATH_MAX;
+pub const POLL = linux.POLL;
+pub const PROT = linux.PROT;
+pub const REG = linux.REG;
+pub const RLIM = linux.RLIM;
+pub const R_OK = linux.R_OK;
+pub const S = linux.S;
+pub const SA = linux.SA;
+pub const SC = linux.SC;
+pub const SEEK = linux.SEEK;
+pub const SHUT = linux.SHUT;
+pub const SIG = linux.SIG;
+pub const SIOCGIFINDEX = linux.SIOCGIFINDEX;
+pub const SO = linux.SO;
+pub const SOCK = linux.SOCK;
+pub const SOL = linux.SOL;
+pub const STDERR_FILENO = linux.STDERR_FILENO;
+pub const STDIN_FILENO = linux.STDIN_FILENO;
+pub const STDOUT_FILENO = linux.STDOUT_FILENO;
+pub const SYS = linux.SYS;
+pub const Sigaction = linux.Sigaction;
+pub const VDSO = linux.VDSO;
+pub const W = linux.W;
+pub const W_OK = linux.W_OK;
+pub const X_OK = linux.X_OK;
+pub const addrinfo = linux.addrinfo;
+pub const blkcnt_t = linux.blkcnt_t;
+pub const blksize_t = linux.blksize_t;
+pub const clock_t = linux.clock_t;
+pub const cpu_set_t = linux.cpu_set_t;
+pub const dev_t = linux.dev_t;
+pub const dl_phdr_info = linux.dl_phdr_info;
+pub const empty_sigset = linux.empty_sigset;
+pub const epoll_event = linux.epoll_event;
+pub const fd_t = linux.fd_t;
+pub const gid_t = linux.gid_t;
+pub const ifreq = linux.ifreq;
+pub const ino_t = linux.ino_t;
+pub const mcontext_t = linux.mcontext_t;
+pub const mode_t = linux.mode_t;
+pub const msghdr = linux.msghdr;
+pub const msghdr_const = linux.msghdr_const;
+pub const nfds_t = linux.nfds_t;
+pub const nlink_t = linux.nlink_t;
+pub const off_t = linux.off_t;
+pub const pid_t = linux.pid_t;
+pub const pollfd = linux.pollfd;
+pub const rlim_t = linux.rlim_t;
+pub const rlimit = linux.rlimit;
+pub const rlimit_resource = linux.rlimit_resource;
+pub const siginfo_t = linux.siginfo_t;
+pub const sigset_t = linux.sigset_t;
+pub const sockaddr = linux.sockaddr;
+pub const socklen_t = linux.socklen_t;
+pub const stack_t = linux.stack_t;
+pub const time_t = linux.time_t;
+pub const timespec = linux.timespec;
+pub const timeval = linux.timeval;
+pub const timezone = linux.timezone;
+pub const ucontext_t = linux.ucontext_t;
+pub const uid_t = linux.uid_t;
+pub const user_desc = linux.user_desc;
+pub const utsname = linux.utsname;
+pub const PR = linux.PR;
+
+pub const _errno = switch (native_abi) {
.android => struct {
extern "c" var __errno: c_int;
fn getErrno() *c_int {
@@ -17,22 +110,92 @@ pub const _errno = switch (abi) {
}.__errno_location,
};
-pub const MAP_FAILED = @intToPtr(*c_void, maxInt(usize));
+pub const Stat = switch (native_arch) {
+ .sparcv9 => extern struct {
+ dev: u64,
+ ino: ino_t,
+ mode: u32,
+ nlink: usize,
+
+ uid: u32,
+ gid: u32,
+ rdev: u64,
+ __pad0: u32,
+
+ size: off_t,
+ blksize: isize,
+ blocks: i64,
+
+ atim: timespec,
+ mtim: timespec,
+ ctim: timespec,
+ __unused: [2]isize,
+
+ pub fn atime(self: @This()) timespec {
+ return self.atim;
+ }
+
+ pub fn mtime(self: @This()) timespec {
+ return self.mtim;
+ }
+
+ pub fn ctime(self: @This()) timespec {
+ return self.ctim;
+ }
+ },
+ .mips, .mipsel => extern struct {
+ dev: dev_t,
+ __pad0: [2]u32,
+ ino: ino_t,
+ mode: mode_t,
+ nlink: nlink_t,
+ uid: uid_t,
+ gid: gid_t,
+ rdev: dev_t,
+ __pad1: [2]u32,
+ size: off_t,
+ atim: timespec,
+ mtim: timespec,
+ ctim: timespec,
+ blksize: blksize_t,
+ __pad3: u32,
+ blocks: blkcnt_t,
+ __pad4: [14]u32,
+
+ pub fn atime(self: @This()) timespec {
+ return self.atim;
+ }
+
+ pub fn mtime(self: @This()) timespec {
+ return self.mtim;
+ }
+
+ pub fn ctime(self: @This()) timespec {
+ return self.ctim;
+ }
+ },
+
+ else => std.os.linux.Stat, // libc stat is the same as kernel stat.
+};
-pub const AI_PASSIVE = 0x01;
-pub const AI_CANONNAME = 0x02;
-pub const AI_NUMERICHOST = 0x04;
-pub const AI_V4MAPPED = 0x08;
-pub const AI_ALL = 0x10;
-pub const AI_ADDRCONFIG = 0x20;
-pub const AI_NUMERICSERV = 0x400;
+pub const AI = struct {
+ pub const PASSIVE = 0x01;
+ pub const CANONNAME = 0x02;
+ pub const NUMERICHOST = 0x04;
+ pub const V4MAPPED = 0x08;
+ pub const ALL = 0x10;
+ pub const ADDRCONFIG = 0x20;
+ pub const NUMERICSERV = 0x400;
+};
-pub const NI_NUMERICHOST = 0x01;
-pub const NI_NUMERICSERV = 0x02;
-pub const NI_NOFQDN = 0x04;
-pub const NI_NAMEREQD = 0x08;
-pub const NI_DGRAM = 0x10;
-pub const NI_NUMERICSCOPE = 0x100;
+pub const NI = struct {
+ pub const NUMERICHOST = 0x01;
+ pub const NUMERICSERV = 0x02;
+ pub const NOFQDN = 0x04;
+ pub const NAMEREQD = 0x08;
+ pub const DGRAM = 0x10;
+ pub const NUMERICSCOPE = 0x100;
+};
pub const EAI = enum(c_int) {
BADFLAGS = -1,
@@ -60,8 +223,8 @@ pub const EAI = enum(c_int) {
pub extern "c" fn fallocate64(fd: fd_t, mode: c_int, offset: off_t, len: off_t) c_int;
pub extern "c" fn fopen64(noalias filename: [*:0]const u8, noalias modes: [*:0]const u8) ?*FILE;
-pub extern "c" fn fstat64(fd: fd_t, buf: *libc_stat) c_int;
-pub extern "c" fn fstatat64(dirfd: fd_t, path: [*:0]const u8, stat_buf: *libc_stat, flags: u32) c_int;
+pub extern "c" fn fstat64(fd: fd_t, buf: *Stat) c_int;
+pub extern "c" fn fstatat64(dirfd: fd_t, path: [*:0]const u8, stat_buf: *Stat, flags: u32) c_int;
pub extern "c" fn ftruncate64(fd: c_int, length: off_t) c_int;
pub extern "c" fn getrlimit64(resource: rlimit_resource, rlim: *rlimit) c_int;
pub extern "c" fn lseek64(fd: fd_t, offset: i64, whence: c_int) i64;
@@ -137,7 +300,7 @@ pub const pthread_mutex_t = extern struct {
pub const pthread_cond_t = extern struct {
size: [__SIZEOF_PTHREAD_COND_T]u8 align(@alignOf(usize)) = [_]u8{0} ** __SIZEOF_PTHREAD_COND_T,
};
-pub const pthread_rwlock_t = switch (abi) {
+pub const pthread_rwlock_t = switch (native_abi) {
.android => switch (@sizeOf(usize)) {
4 => extern struct {
lock: std.c.pthread_mutex_t = std.c.PTHREAD_MUTEX_INITIALIZER,
@@ -168,11 +331,11 @@ pub const sem_t = extern struct {
};
const __SIZEOF_PTHREAD_COND_T = 48;
-const __SIZEOF_PTHREAD_MUTEX_T = if (os_tag == .fuchsia) 40 else switch (abi) {
+const __SIZEOF_PTHREAD_MUTEX_T = switch (native_abi) {
.musl, .musleabi, .musleabihf => if (@sizeOf(usize) == 8) 40 else 24,
- .gnu, .gnuabin32, .gnuabi64, .gnueabi, .gnueabihf, .gnux32 => switch (arch) {
+ .gnu, .gnuabin32, .gnuabi64, .gnueabi, .gnueabihf, .gnux32 => switch (native_arch) {
.aarch64 => 48,
- .x86_64 => if (abi == .gnux32) 40 else 32,
+ .x86_64 => if (native_abi == .gnux32) 40 else 32,
.mips64, .powerpc64, .powerpc64le, .sparcv9 => 40,
else => if (@sizeOf(usize) == 8) 40 else 24,
},
@@ -184,9 +347,11 @@ const __SIZEOF_SEM_T = 4 * @sizeOf(usize);
pub extern "c" fn pthread_setname_np(thread: std.c.pthread_t, name: [*:0]const u8) E;
pub extern "c" fn pthread_getname_np(thread: std.c.pthread_t, name: [*:0]u8, len: usize) E;
-pub const RTLD_LAZY = 1;
-pub const RTLD_NOW = 2;
-pub const RTLD_NOLOAD = 4;
-pub const RTLD_NODELETE = 4096;
-pub const RTLD_GLOBAL = 256;
-pub const RTLD_LOCAL = 0;
+pub const RTLD = struct {
+ pub const LAZY = 1;
+ pub const NOW = 2;
+ pub const NOLOAD = 4;
+ pub const NODELETE = 4096;
+ pub const GLOBAL = 256;
+ pub const LOCAL = 0;
+};
diff --git a/lib/std/c/netbsd.zig b/lib/std/c/netbsd.zig
index e45dc85d34eb..e492ce60fea6 100644
--- a/lib/std/c/netbsd.zig
+++ b/lib/std/c/netbsd.zig
@@ -1,7 +1,10 @@
const std = @import("../std.zig");
-const builtin = std.builtin;
-
-usingnamespace std.c;
+const builtin = @import("builtin");
+const maxInt = std.math.maxInt;
+const iovec = std.os.iovec;
+const iovec_const = std.os.iovec_const;
+const timezone = std.c.timezone;
+const rusage = std.c.rusage;
extern "c" fn __errno() *c_int;
pub const _errno = __errno;
@@ -13,56 +16,81 @@ pub extern "c" fn _lwp_self() lwpid_t;
pub extern "c" fn pipe2(fds: *[2]fd_t, flags: u32) c_int;
pub extern "c" fn arc4random_buf(buf: [*]u8, len: usize) void;
-pub extern "c" fn __fstat50(fd: fd_t, buf: *libc_stat) c_int;
-pub extern "c" fn __stat50(path: [*:0]const u8, buf: *libc_stat) c_int;
+
+pub extern "c" fn __fstat50(fd: fd_t, buf: *Stat) c_int;
+pub const fstat = __fstat50;
+
+pub extern "c" fn __stat50(path: [*:0]const u8, buf: *Stat) c_int;
+pub const stat = __stat50;
+
pub extern "c" fn __clock_gettime50(clk_id: c_int, tp: *timespec) c_int;
+pub const clock_gettime = __clock_gettime50;
+
pub extern "c" fn __clock_getres50(clk_id: c_int, tp: *timespec) c_int;
+pub const clock_getres = __clock_getres50;
+
pub extern "c" fn __getdents30(fd: c_int, buf_ptr: [*]u8, nbytes: usize) c_int;
+pub const getdents = __getdents30;
+
pub extern "c" fn __sigaltstack14(ss: ?*stack_t, old_ss: ?*stack_t) c_int;
+pub const sigaltstack = __sigaltstack14;
+
pub extern "c" fn __nanosleep50(rqtp: *const timespec, rmtp: ?*timespec) c_int;
+pub const nanosleep = __nanosleep50;
+
pub extern "c" fn __sigaction14(sig: c_int, noalias act: ?*const Sigaction, noalias oact: ?*Sigaction) c_int;
+pub const sigaction = __sigaction14;
+
pub extern "c" fn __sigprocmask14(how: c_int, noalias set: ?*const sigset_t, noalias oset: ?*sigset_t) c_int;
+pub const sigprocmask = __sigaction14;
+
pub extern "c" fn __socket30(domain: c_uint, sock_type: c_uint, protocol: c_uint) c_int;
+pub const socket = __socket30;
+
pub extern "c" fn __gettimeofday50(noalias tv: ?*timeval, noalias tz: ?*timezone) c_int;
+pub const gettimeofday = __gettimeofday50;
+
pub extern "c" fn __getrusage50(who: c_int, usage: *rusage) c_int;
-// libc aliases this as sched_yield
+pub const getrusage = __getrusage50;
+
pub extern "c" fn __libc_thr_yield() c_int;
+pub const sched_yield = __libc_thr_yield;
pub extern "c" fn posix_memalign(memptr: *?*c_void, alignment: usize, size: usize) c_int;
pub const pthread_mutex_t = extern struct {
- ptm_magic: u32 = 0x33330003,
- ptm_errorcheck: padded_pthread_spin_t = 0,
- ptm_ceiling: padded_pthread_spin_t = 0,
- ptm_owner: usize = 0,
- ptm_waiters: ?*u8 = null,
- ptm_recursed: u32 = 0,
- ptm_spare2: ?*c_void = null,
+ magic: u32 = 0x33330003,
+ errorcheck: padded_pthread_spin_t = 0,
+ ceiling: padded_pthread_spin_t = 0,
+ owner: usize = 0,
+ waiters: ?*u8 = null,
+ recursed: u32 = 0,
+ spare2: ?*c_void = null,
};
pub const pthread_cond_t = extern struct {
- ptc_magic: u32 = 0x55550005,
- ptc_lock: pthread_spin_t = 0,
- ptc_waiters_first: ?*u8 = null,
- ptc_waiters_last: ?*u8 = null,
- ptc_mutex: ?*pthread_mutex_t = null,
- ptc_private: ?*c_void = null,
+ magic: u32 = 0x55550005,
+ lock: pthread_spin_t = 0,
+ waiters_first: ?*u8 = null,
+ waiters_last: ?*u8 = null,
+ mutex: ?*pthread_mutex_t = null,
+ private: ?*c_void = null,
};
pub const pthread_rwlock_t = extern struct {
- ptr_magic: c_uint = 0x99990009,
- ptr_interlock: switch (std.builtin.cpu.arch) {
+ magic: c_uint = 0x99990009,
+ interlock: switch (builtin.cpu.arch) {
.aarch64, .sparc, .x86_64, .i386 => u8,
.arm, .powerpc => c_int,
else => unreachable,
} = 0,
- ptr_rblocked_first: ?*u8 = null,
- ptr_rblocked_last: ?*u8 = null,
- ptr_wblocked_first: ?*u8 = null,
- ptr_wblocked_last: ?*u8 = null,
- ptr_nreaders: c_uint = 0,
- ptr_owner: std.c.pthread_t = null,
- ptr_private: ?*c_void = null,
+ rblocked_first: ?*u8 = null,
+ rblocked_last: ?*u8 = null,
+ wblocked_first: ?*u8 = null,
+ wblocked_last: ?*u8 = null,
+ nreaders: c_uint = 0,
+ owner: std.c.pthread_t = null,
+ private: ?*c_void = null,
};
const pthread_spin_t = switch (builtin.cpu.arch) {
@@ -92,3 +120,1315 @@ pub const sem_t = ?*opaque {};
pub extern "c" fn pthread_setname_np(thread: std.c.pthread_t, name: [*:0]const u8, arg: ?*c_void) E;
pub extern "c" fn pthread_getname_np(thread: std.c.pthread_t, name: [*:0]u8, len: usize) E;
+
+pub const blkcnt_t = i64;
+pub const blksize_t = i32;
+pub const clock_t = u32;
+pub const dev_t = u64;
+pub const fd_t = i32;
+pub const gid_t = u32;
+pub const ino_t = u64;
+pub const mode_t = u32;
+pub const nlink_t = u32;
+pub const off_t = i64;
+pub const pid_t = i32;
+pub const socklen_t = u32;
+pub const time_t = i64;
+pub const uid_t = u32;
+pub const lwpid_t = i32;
+pub const suseconds_t = c_int;
+
+/// Renamed from `kevent` to `Kevent` to avoid conflict with function name.
+pub const Kevent = extern struct {
+ ident: usize,
+ filter: i32,
+ flags: u32,
+ fflags: u32,
+ data: i64,
+ udata: usize,
+};
+
+pub const RTLD = struct {
+ pub const LAZY = 1;
+ pub const NOW = 2;
+ pub const GLOBAL = 0x100;
+ pub const LOCAL = 0x200;
+ pub const NODELETE = 0x01000;
+ pub const NOLOAD = 0x02000;
+
+ pub const NEXT = @intToPtr(*c_void, @bitCast(usize, @as(isize, -1)));
+ pub const DEFAULT = @intToPtr(*c_void, @bitCast(usize, @as(isize, -2)));
+ pub const SELF = @intToPtr(*c_void, @bitCast(usize, @as(isize, -3)));
+};
+
+pub const dl_phdr_info = extern struct {
+ dlpi_addr: usize,
+ dlpi_name: ?[*:0]const u8,
+ dlpi_phdr: [*]std.elf.Phdr,
+ dlpi_phnum: u16,
+};
+
+pub const Flock = extern struct {
+ l_start: off_t,
+ l_len: off_t,
+ l_pid: pid_t,
+ l_type: i16,
+ l_whence: i16,
+};
+
+pub const addrinfo = extern struct {
+ flags: i32,
+ family: i32,
+ socktype: i32,
+ protocol: i32,
+ addrlen: socklen_t,
+ canonname: ?[*:0]u8,
+ addr: ?*sockaddr,
+ next: ?*addrinfo,
+};
+
+pub const EAI = enum(c_int) {
+ /// address family for hostname not supported
+ ADDRFAMILY = 1,
+
+ /// name could not be resolved at this time
+ AGAIN = 2,
+
+ /// flags parameter had an invalid value
+ BADFLAGS = 3,
+
+ /// non-recoverable failure in name resolution
+ FAIL = 4,
+
+ /// address family not recognized
+ FAMILY = 5,
+
+ /// memory allocation failure
+ MEMORY = 6,
+
+ /// no address associated with hostname
+ NODATA = 7,
+
+ /// name does not resolve
+ NONAME = 8,
+
+ /// service not recognized for socket type
+ SERVICE = 9,
+
+ /// intended socket type was not recognized
+ SOCKTYPE = 10,
+
+ /// system error returned in errno
+ SYSTEM = 11,
+
+ /// invalid value for hints
+ BADHINTS = 12,
+
+ /// resolved protocol is unknown
+ PROTOCOL = 13,
+
+ /// argument buffer overflow
+ OVERFLOW = 14,
+
+ _,
+};
+
+pub const EAI_MAX = 15;
+
+pub const msghdr = extern struct {
+ /// optional address
+ msg_name: ?*sockaddr,
+
+ /// size of address
+ msg_namelen: socklen_t,
+
+ /// scatter/gather array
+ msg_iov: [*]iovec,
+
+ /// # elements in msg_iov
+ msg_iovlen: i32,
+
+ /// ancillary data
+ msg_control: ?*c_void,
+
+ /// ancillary data buffer len
+ msg_controllen: socklen_t,
+
+ /// flags on received message
+ msg_flags: i32,
+};
+
+pub const msghdr_const = extern struct {
+ /// optional address
+ msg_name: ?*const sockaddr,
+
+ /// size of address
+ msg_namelen: socklen_t,
+
+ /// scatter/gather array
+ msg_iov: [*]iovec_const,
+
+ /// # elements in msg_iov
+ msg_iovlen: i32,
+
+ /// ancillary data
+ msg_control: ?*c_void,
+
+ /// ancillary data buffer len
+ msg_controllen: socklen_t,
+
+ /// flags on received message
+ msg_flags: i32,
+};
+
+/// The stat structure used by libc.
+pub const Stat = extern struct {
+ dev: dev_t,
+ mode: mode_t,
+ ino: ino_t,
+ nlink: nlink_t,
+ uid: uid_t,
+ gid: gid_t,
+ rdev: dev_t,
+ atim: timespec,
+ mtim: timespec,
+ ctim: timespec,
+ birthtim: timespec,
+ size: off_t,
+ blocks: blkcnt_t,
+ blksize: blksize_t,
+ flags: u32,
+ gen: u32,
+ __spare: [2]u32,
+
+ pub fn atime(self: @This()) timespec {
+ return self.atim;
+ }
+
+ pub fn mtime(self: @This()) timespec {
+ return self.mtim;
+ }
+
+ pub fn ctime(self: @This()) timespec {
+ return self.ctim;
+ }
+};
+
+pub const timespec = extern struct {
+ tv_sec: i64,
+ tv_nsec: isize,
+};
+
+pub const timeval = extern struct {
+ /// seconds
+ tv_sec: time_t,
+ /// microseconds
+ tv_usec: suseconds_t,
+};
+
+pub const MAXNAMLEN = 511;
+
+pub const dirent = extern struct {
+ d_fileno: ino_t,
+ d_reclen: u16,
+ d_namlen: u16,
+ d_type: u8,
+ d_name: [MAXNAMLEN:0]u8,
+
+ pub fn reclen(self: dirent) u16 {
+ return self.d_reclen;
+ }
+};
+
+pub const SOCK = struct {
+ pub const STREAM = 1;
+ pub const DGRAM = 2;
+ pub const RAW = 3;
+ pub const RDM = 4;
+ pub const SEQPACKET = 5;
+ pub const CONN_DGRAM = 6;
+ pub const DCCP = CONN_DGRAM;
+
+ pub const CLOEXEC = 0x10000000;
+ pub const NONBLOCK = 0x20000000;
+ pub const NOSIGPIPE = 0x40000000;
+ pub const FLAGS_MASK = 0xf0000000;
+};
+
+pub const SO = struct {
+ pub const DEBUG = 0x0001;
+ pub const ACCEPTCONN = 0x0002;
+ pub const REUSEADDR = 0x0004;
+ pub const KEEPALIVE = 0x0008;
+ pub const DONTROUTE = 0x0010;
+ pub const BROADCAST = 0x0020;
+ pub const USELOOPBACK = 0x0040;
+ pub const LINGER = 0x0080;
+ pub const OOBINLINE = 0x0100;
+ pub const REUSEPORT = 0x0200;
+ pub const NOSIGPIPE = 0x0800;
+ pub const ACCEPTFILTER = 0x1000;
+ pub const TIMESTAMP = 0x2000;
+ pub const RERROR = 0x4000;
+
+ pub const SNDBUF = 0x1001;
+ pub const RCVBUF = 0x1002;
+ pub const SNDLOWAT = 0x1003;
+ pub const RCVLOWAT = 0x1004;
+ pub const ERROR = 0x1007;
+ pub const TYPE = 0x1008;
+ pub const OVERFLOWED = 0x1009;
+
+ pub const NOHEADER = 0x100a;
+ pub const SNDTIMEO = 0x100b;
+ pub const RCVTIMEO = 0x100c;
+};
+
+pub const SOL = struct {
+ pub const SOCKET = 0xffff;
+};
+
+pub const PF = struct {
+ pub const UNSPEC = AF.UNSPEC;
+ pub const LOCAL = AF.LOCAL;
+ pub const UNIX = PF.LOCAL;
+ pub const INET = AF.INET;
+ pub const IMPLINK = AF.IMPLINK;
+ pub const PUP = AF.PUP;
+ pub const CHAOS = AF.CHAOS;
+ pub const NS = AF.NS;
+ pub const ISO = AF.ISO;
+ pub const OSI = AF.ISO;
+ pub const ECMA = AF.ECMA;
+ pub const DATAKIT = AF.DATAKIT;
+ pub const CCITT = AF.CCITT;
+ pub const SNA = AF.SNA;
+ pub const DECnet = AF.DECnet;
+ pub const DLI = AF.DLI;
+ pub const LAT = AF.LAT;
+ pub const HYLINK = AF.HYLINK;
+ pub const APPLETALK = AF.APPLETALK;
+ pub const OROUTE = AF.OROUTE;
+ pub const LINK = AF.LINK;
+ pub const COIP = AF.COIP;
+ pub const CNT = AF.CNT;
+ pub const INET6 = AF.INET6;
+ pub const IPX = AF.IPX;
+ pub const ISDN = AF.ISDN;
+ pub const E164 = AF.E164;
+ pub const NATM = AF.NATM;
+ pub const ARP = AF.ARP;
+ pub const BLUETOOTH = AF.BLUETOOTH;
+ pub const MPLS = AF.MPLS;
+ pub const ROUTE = AF.ROUTE;
+ pub const CAN = AF.CAN;
+ pub const ETHER = AF.ETHER;
+ pub const MAX = AF.MAX;
+};
+
+pub const AF = struct {
+ pub const UNSPEC = 0;
+ pub const LOCAL = 1;
+ pub const UNIX = LOCAL;
+ pub const INET = 2;
+ pub const IMPLINK = 3;
+ pub const PUP = 4;
+ pub const CHAOS = 5;
+ pub const NS = 6;
+ pub const ISO = 7;
+ pub const OSI = ISO;
+ pub const ECMA = 8;
+ pub const DATAKIT = 9;
+ pub const CCITT = 10;
+ pub const SNA = 11;
+ pub const DECnet = 12;
+ pub const DLI = 13;
+ pub const LAT = 14;
+ pub const HYLINK = 15;
+ pub const APPLETALK = 16;
+ pub const OROUTE = 17;
+ pub const LINK = 18;
+ pub const COIP = 20;
+ pub const CNT = 21;
+ pub const IPX = 23;
+ pub const INET6 = 24;
+ pub const ISDN = 26;
+ pub const E164 = ISDN;
+ pub const NATM = 27;
+ pub const ARP = 28;
+ pub const BLUETOOTH = 31;
+ pub const IEEE80211 = 32;
+ pub const MPLS = 33;
+ pub const ROUTE = 34;
+ pub const CAN = 35;
+ pub const ETHER = 36;
+ pub const MAX = 37;
+};
+
+pub const in_port_t = u16;
+pub const sa_family_t = u8;
+
+pub const sockaddr = extern struct {
+ /// total length
+ len: u8,
+ /// address family
+ family: sa_family_t,
+ /// actually longer; address value
+ data: [14]u8,
+
+ pub const storage = std.x.os.Socket.Address.Native.Storage;
+
+ pub const in = extern struct {
+ len: u8 = @sizeOf(in),
+ family: sa_family_t = AF.INET,
+ port: in_port_t,
+ addr: u32,
+ zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },
+ };
+
+ pub const in6 = extern struct {
+ len: u8 = @sizeOf(in6),
+ family: sa_family_t = AF.INET6,
+ port: in_port_t,
+ flowinfo: u32,
+ addr: [16]u8,
+ scope_id: u32,
+ };
+
+ /// Definitions for UNIX IPC domain.
+ pub const un = extern struct {
+ /// total sockaddr length
+ len: u8 = @sizeOf(un),
+
+ family: sa_family_t = AF.LOCAL,
+
+ /// path name
+ path: [104]u8,
+ };
+};
+
+pub const AI = struct {
+ /// get address to use bind()
+ pub const PASSIVE = 0x00000001;
+ /// fill ai_canonname
+ pub const CANONNAME = 0x00000002;
+ /// prevent host name resolution
+ pub const NUMERICHOST = 0x00000004;
+ /// prevent service name resolution
+ pub const NUMERICSERV = 0x00000008;
+ /// only if any address is assigned
+ pub const ADDRCONFIG = 0x00000400;
+};
+
+pub const CTL = struct {
+ pub const KERN = 1;
+ pub const DEBUG = 5;
+};
+
+pub const KERN = struct {
+ pub const PROC_ARGS = 48; // struct: process argv/env
+ pub const PROC_PATHNAME = 5; // path to executable
+ pub const IOV_MAX = 38;
+};
+
+pub const PATH_MAX = 1024;
+pub const IOV_MAX = KERN.IOV_MAX;
+
+pub const STDIN_FILENO = 0;
+pub const STDOUT_FILENO = 1;
+pub const STDERR_FILENO = 2;
+
+pub const PROT = struct {
+ pub const NONE = 0;
+ pub const READ = 1;
+ pub const WRITE = 2;
+ pub const EXEC = 4;
+};
+
+pub const CLOCK = struct {
+ pub const REALTIME = 0;
+ pub const VIRTUAL = 1;
+ pub const PROF = 2;
+ pub const MONOTONIC = 3;
+ pub const THREAD_CPUTIME_ID = 0x20000000;
+ pub const PROCESS_CPUTIME_ID = 0x40000000;
+};
+
+pub const MAP = struct {
+ pub const FAILED = @intToPtr(*c_void, maxInt(usize));
+ pub const SHARED = 0x0001;
+ pub const PRIVATE = 0x0002;
+ pub const REMAPDUP = 0x0004;
+ pub const FIXED = 0x0010;
+ pub const RENAME = 0x0020;
+ pub const NORESERVE = 0x0040;
+ pub const INHERIT = 0x0080;
+ pub const HASSEMAPHORE = 0x0200;
+ pub const TRYFIXED = 0x0400;
+ pub const WIRED = 0x0800;
+
+ pub const FILE = 0x0000;
+ pub const NOSYNC = 0x0800;
+ pub const ANON = 0x1000;
+ pub const ANONYMOUS = ANON;
+ pub const STACK = 0x2000;
+};
+
+pub const W = struct {
+ pub const NOHANG = 0x00000001;
+ pub const UNTRACED = 0x00000002;
+ pub const STOPPED = UNTRACED;
+ pub const CONTINUED = 0x00000010;
+ pub const NOWAIT = 0x00010000;
+ pub const EXITED = 0x00000020;
+ pub const TRAPPED = 0x00000040;
+
+ pub fn EXITSTATUS(s: u32) u8 {
+ return @intCast(u8, (s >> 8) & 0xff);
+ }
+ pub fn TERMSIG(s: u32) u32 {
+ return s & 0x7f;
+ }
+ pub fn STOPSIG(s: u32) u32 {
+ return EXITSTATUS(s);
+ }
+ pub fn IFEXITED(s: u32) bool {
+ return TERMSIG(s) == 0;
+ }
+
+ pub fn IFCONTINUED(s: u32) bool {
+ return ((s & 0x7f) == 0xffff);
+ }
+
+ pub fn IFSTOPPED(s: u32) bool {
+ return ((s & 0x7f != 0x7f) and !IFCONTINUED(s));
+ }
+
+ pub fn IFSIGNALED(s: u32) bool {
+ return !IFSTOPPED(s) and !IFCONTINUED(s) and !IFEXITED(s);
+ }
+};
+
+pub const SA = struct {
+ pub const ONSTACK = 0x0001;
+ pub const RESTART = 0x0002;
+ pub const RESETHAND = 0x0004;
+ pub const NOCLDSTOP = 0x0008;
+ pub const NODEFER = 0x0010;
+ pub const NOCLDWAIT = 0x0020;
+ pub const SIGINFO = 0x0040;
+};
+
+// access function
+pub const F_OK = 0; // test for existence of file
+pub const X_OK = 1; // test for execute or search permission
+pub const W_OK = 2; // test for write permission
+pub const R_OK = 4; // test for read permission
+
+pub const O = struct {
+ /// open for reading only
+ pub const RDONLY = 0x00000000;
+ /// open for writing only
+ pub const WRONLY = 0x00000001;
+ /// open for reading and writing
+ pub const RDWR = 0x00000002;
+ /// mask for above modes
+ pub const ACCMODE = 0x00000003;
+ /// no delay
+ pub const NONBLOCK = 0x00000004;
+ /// set append mode
+ pub const APPEND = 0x00000008;
+ /// open with shared file lock
+ pub const SHLOCK = 0x00000010;
+ /// open with exclusive file lock
+ pub const EXLOCK = 0x00000020;
+ /// signal pgrp when data ready
+ pub const ASYNC = 0x00000040;
+ /// synchronous writes
+ pub const SYNC = 0x00000080;
+ /// don't follow symlinks on the last
+ pub const NOFOLLOW = 0x00000100;
+ /// create if nonexistent
+ pub const CREAT = 0x00000200;
+ /// truncate to zero length
+ pub const TRUNC = 0x00000400;
+ /// error if already exists
+ pub const EXCL = 0x00000800;
+ /// don't assign controlling terminal
+ pub const NOCTTY = 0x00008000;
+ /// write: I/O data completion
+ pub const DSYNC = 0x00010000;
+ /// read: I/O completion as for write
+ pub const RSYNC = 0x00020000;
+ /// use alternate i/o semantics
+ pub const ALT_IO = 0x00040000;
+ /// direct I/O hint
+ pub const DIRECT = 0x00080000;
+ /// fail if not a directory
+ pub const DIRECTORY = 0x00200000;
+ /// set close on exec
+ pub const CLOEXEC = 0x00400000;
+ /// skip search permission checks
+ pub const SEARCH = 0x00800000;
+};
+
+pub const F = struct {
+ pub const DUPFD = 0;
+ pub const GETFD = 1;
+ pub const SETFD = 2;
+ pub const GETFL = 3;
+ pub const SETFL = 4;
+
+ pub const GETOWN = 5;
+ pub const SETOWN = 6;
+
+ pub const GETLK = 7;
+ pub const SETLK = 8;
+ pub const SETLKW = 9;
+
+ pub const RDLCK = 1;
+ pub const WRLCK = 3;
+ pub const UNLCK = 2;
+};
+
+pub const LOCK = struct {
+ pub const SH = 1;
+ pub const EX = 2;
+ pub const UN = 8;
+ pub const NB = 4;
+};
+
+pub const FD_CLOEXEC = 1;
+
+pub const SEEK = struct {
+ pub const SET = 0;
+ pub const CUR = 1;
+ pub const END = 2;
+};
+
+pub const DT = struct {
+ pub const UNKNOWN = 0;
+ pub const FIFO = 1;
+ pub const CHR = 2;
+ pub const DIR = 4;
+ pub const BLK = 6;
+ pub const REG = 8;
+ pub const LNK = 10;
+ pub const SOCK = 12;
+ pub const WHT = 14;
+};
+
+/// add event to kq (implies enable)
+pub const EV_ADD = 0x0001;
+
+/// delete event from kq
+pub const EV_DELETE = 0x0002;
+
+/// enable event
+pub const EV_ENABLE = 0x0004;
+
+/// disable event (not reported)
+pub const EV_DISABLE = 0x0008;
+
+/// only report one occurrence
+pub const EV_ONESHOT = 0x0010;
+
+/// clear event state after reporting
+pub const EV_CLEAR = 0x0020;
+
+/// force immediate event output
+/// ... with or without EV_ERROR
+/// ... use KEVENT_FLAG_ERROR_EVENTS
+/// on syscalls supporting flags
+pub const EV_RECEIPT = 0x0040;
+
+/// disable event after reporting
+pub const EV_DISPATCH = 0x0080;
+
+pub const EVFILT_READ = 0;
+pub const EVFILT_WRITE = 1;
+
+/// attached to aio requests
+pub const EVFILT_AIO = 2;
+
+/// attached to vnodes
+pub const EVFILT_VNODE = 3;
+
+/// attached to struct proc
+pub const EVFILT_PROC = 4;
+
+/// attached to struct proc
+pub const EVFILT_SIGNAL = 5;
+
+/// timers
+pub const EVFILT_TIMER = 6;
+
+/// Filesystem events
+pub const EVFILT_FS = 7;
+
+/// On input, NOTE_TRIGGER causes the event to be triggered for output.
+pub const NOTE_TRIGGER = 0x08000000;
+
+/// low water mark
+pub const NOTE_LOWAT = 0x00000001;
+
+/// vnode was removed
+pub const NOTE_DELETE = 0x00000001;
+
+/// data contents changed
+pub const NOTE_WRITE = 0x00000002;
+
+/// size increased
+pub const NOTE_EXTEND = 0x00000004;
+
+/// attributes changed
+pub const NOTE_ATTRIB = 0x00000008;
+
+/// link count changed
+pub const NOTE_LINK = 0x00000010;
+
+/// vnode was renamed
+pub const NOTE_RENAME = 0x00000020;
+
+/// vnode access was revoked
+pub const NOTE_REVOKE = 0x00000040;
+
+/// process exited
+pub const NOTE_EXIT = 0x80000000;
+
+/// process forked
+pub const NOTE_FORK = 0x40000000;
+
+/// process exec'd
+pub const NOTE_EXEC = 0x20000000;
+
+/// mask for signal & exit status
+pub const NOTE_PDATAMASK = 0x000fffff;
+pub const NOTE_PCTRLMASK = 0xf0000000;
+
+pub const T = struct {
+ pub const IOCCBRK = 0x2000747a;
+ pub const IOCCDTR = 0x20007478;
+ pub const IOCCONS = 0x80047462;
+ pub const IOCDCDTIMESTAMP = 0x40107458;
+ pub const IOCDRAIN = 0x2000745e;
+ pub const IOCEXCL = 0x2000740d;
+ pub const IOCEXT = 0x80047460;
+ pub const IOCFLAG_CDTRCTS = 0x10;
+ pub const IOCFLAG_CLOCAL = 0x2;
+ pub const IOCFLAG_CRTSCTS = 0x4;
+ pub const IOCFLAG_MDMBUF = 0x8;
+ pub const IOCFLAG_SOFTCAR = 0x1;
+ pub const IOCFLUSH = 0x80047410;
+ pub const IOCGETA = 0x402c7413;
+ pub const IOCGETD = 0x4004741a;
+ pub const IOCGFLAGS = 0x4004745d;
+ pub const IOCGLINED = 0x40207442;
+ pub const IOCGPGRP = 0x40047477;
+ pub const IOCGQSIZE = 0x40047481;
+ pub const IOCGRANTPT = 0x20007447;
+ pub const IOCGSID = 0x40047463;
+ pub const IOCGSIZE = 0x40087468;
+ pub const IOCGWINSZ = 0x40087468;
+ pub const IOCMBIC = 0x8004746b;
+ pub const IOCMBIS = 0x8004746c;
+ pub const IOCMGET = 0x4004746a;
+ pub const IOCMSET = 0x8004746d;
+ pub const IOCM_CAR = 0x40;
+ pub const IOCM_CD = 0x40;
+ pub const IOCM_CTS = 0x20;
+ pub const IOCM_DSR = 0x100;
+ pub const IOCM_DTR = 0x2;
+ pub const IOCM_LE = 0x1;
+ pub const IOCM_RI = 0x80;
+ pub const IOCM_RNG = 0x80;
+ pub const IOCM_RTS = 0x4;
+ pub const IOCM_SR = 0x10;
+ pub const IOCM_ST = 0x8;
+ pub const IOCNOTTY = 0x20007471;
+ pub const IOCNXCL = 0x2000740e;
+ pub const IOCOUTQ = 0x40047473;
+ pub const IOCPKT = 0x80047470;
+ pub const IOCPKT_DATA = 0x0;
+ pub const IOCPKT_DOSTOP = 0x20;
+ pub const IOCPKT_FLUSHREAD = 0x1;
+ pub const IOCPKT_FLUSHWRITE = 0x2;
+ pub const IOCPKT_IOCTL = 0x40;
+ pub const IOCPKT_NOSTOP = 0x10;
+ pub const IOCPKT_START = 0x8;
+ pub const IOCPKT_STOP = 0x4;
+ pub const IOCPTMGET = 0x40287446;
+ pub const IOCPTSNAME = 0x40287448;
+ pub const IOCRCVFRAME = 0x80087445;
+ pub const IOCREMOTE = 0x80047469;
+ pub const IOCSBRK = 0x2000747b;
+ pub const IOCSCTTY = 0x20007461;
+ pub const IOCSDTR = 0x20007479;
+ pub const IOCSETA = 0x802c7414;
+ pub const IOCSETAF = 0x802c7416;
+ pub const IOCSETAW = 0x802c7415;
+ pub const IOCSETD = 0x8004741b;
+ pub const IOCSFLAGS = 0x8004745c;
+ pub const IOCSIG = 0x2000745f;
+ pub const IOCSLINED = 0x80207443;
+ pub const IOCSPGRP = 0x80047476;
+ pub const IOCSQSIZE = 0x80047480;
+ pub const IOCSSIZE = 0x80087467;
+ pub const IOCSTART = 0x2000746e;
+ pub const IOCSTAT = 0x80047465;
+ pub const IOCSTI = 0x80017472;
+ pub const IOCSTOP = 0x2000746f;
+ pub const IOCSWINSZ = 0x80087467;
+ pub const IOCUCNTL = 0x80047466;
+ pub const IOCXMTFRAME = 0x80087444;
+};
+
+pub const winsize = extern struct {
+ ws_row: u16,
+ ws_col: u16,
+ ws_xpixel: u16,
+ ws_ypixel: u16,
+};
+
+const NSIG = 32;
+
+pub const SIG = struct {
+ pub const DFL = @intToPtr(?Sigaction.sigaction_fn, 0);
+ pub const IGN = @intToPtr(?Sigaction.sigaction_fn, 1);
+ pub const ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize));
+
+ pub const WORDS = 4;
+ pub const MAXSIG = 128;
+
+ pub const BLOCK = 1;
+ pub const UNBLOCK = 2;
+ pub const SETMASK = 3;
+
+ pub const HUP = 1;
+ pub const INT = 2;
+ pub const QUIT = 3;
+ pub const ILL = 4;
+ pub const TRAP = 5;
+ pub const ABRT = 6;
+ pub const IOT = ABRT;
+ pub const EMT = 7;
+ pub const FPE = 8;
+ pub const KILL = 9;
+ pub const BUS = 10;
+ pub const SEGV = 11;
+ pub const SYS = 12;
+ pub const PIPE = 13;
+ pub const ALRM = 14;
+ pub const TERM = 15;
+ pub const URG = 16;
+ pub const STOP = 17;
+ pub const TSTP = 18;
+ pub const CONT = 19;
+ pub const CHLD = 20;
+ pub const TTIN = 21;
+ pub const TTOU = 22;
+ pub const IO = 23;
+ pub const XCPU = 24;
+ pub const XFSZ = 25;
+ pub const VTALRM = 26;
+ pub const PROF = 27;
+ pub const WINCH = 28;
+ pub const INFO = 29;
+ pub const USR1 = 30;
+ pub const USR2 = 31;
+ pub const PWR = 32;
+
+ pub const RTMIN = 33;
+ pub const RTMAX = 63;
+
+ pub inline fn IDX(sig: usize) usize {
+ return sig - 1;
+ }
+ pub inline fn WORD(sig: usize) usize {
+ return IDX(sig) >> 5;
+ }
+ pub inline fn BIT(sig: usize) usize {
+ return 1 << (IDX(sig) & 31);
+ }
+ pub inline fn VALID(sig: usize) usize {
+ return sig <= MAXSIG and sig > 0;
+ }
+};
+
+/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.
+pub const Sigaction = extern struct {
+ pub const handler_fn = fn (c_int) callconv(.C) void;
+ pub const sigaction_fn = fn (c_int, *const siginfo_t, ?*const c_void) callconv(.C) void;
+
+ /// signal handler
+ handler: extern union {
+ handler: ?handler_fn,
+ sigaction: ?sigaction_fn,
+ },
+ /// signal mask to apply
+ mask: sigset_t,
+ /// signal options
+ flags: c_uint,
+};
+
+pub const sigval_t = extern union {
+ int: i32,
+ ptr: ?*c_void,
+};
+
+pub const siginfo_t = extern union {
+ pad: [128]u8,
+ info: _ksiginfo,
+};
+
+pub const _ksiginfo = extern struct {
+ signo: i32,
+ code: i32,
+ errno: i32,
+ // 64bit architectures insert 4bytes of padding here, this is done by
+ // correctly aligning the reason field
+ reason: extern union {
+ rt: extern struct {
+ pid: pid_t,
+ uid: uid_t,
+ value: sigval_t,
+ },
+ child: extern struct {
+ pid: pid_t,
+ uid: uid_t,
+ status: i32,
+ utime: clock_t,
+ stime: clock_t,
+ },
+ fault: extern struct {
+ addr: ?*c_void,
+ trap: i32,
+ trap2: i32,
+ trap3: i32,
+ },
+ poll: extern struct {
+ band: i32,
+ fd: i32,
+ },
+ syscall: extern struct {
+ sysnum: i32,
+ retval: [2]i32,
+ @"error": i32,
+ args: [8]u64,
+ },
+ ptrace_state: extern struct {
+ pe_report_event: i32,
+ option: extern union {
+ pe_other_pid: pid_t,
+ pe_lwp: lwpid_t,
+ },
+ },
+ } align(@sizeOf(usize)),
+};
+
+pub const sigset_t = extern struct {
+ __bits: [SIG.WORDS]u32,
+};
+
+pub const empty_sigset = sigset_t{ .__bits = [_]u32{0} ** SIG.WORDS };
+
+// XXX x86_64 specific
+pub const mcontext_t = extern struct {
+ gregs: [26]u64,
+ mc_tlsbase: u64,
+ fpregs: [512]u8 align(8),
+};
+
+pub const REG = struct {
+ pub const RBP = 12;
+ pub const RIP = 21;
+ pub const RSP = 24;
+};
+
+pub const ucontext_t = extern struct {
+ flags: u32,
+ link: ?*ucontext_t,
+ sigmask: sigset_t,
+ stack: stack_t,
+ mcontext: mcontext_t,
+ __pad: [
+ switch (builtin.cpu.arch) {
+ .i386 => 4,
+ .mips, .mipsel, .mips64, .mips64el => 14,
+ .arm, .armeb, .thumb, .thumbeb => 1,
+ .sparc, .sparcel, .sparcv9 => if (@sizeOf(usize) == 4) 43 else 8,
+ else => 0,
+ }
+ ]u32,
+};
+
+pub const E = enum(u16) {
+ /// No error occurred.
+ SUCCESS = 0,
+ PERM = 1, // Operation not permitted
+ NOENT = 2, // No such file or directory
+ SRCH = 3, // No such process
+ INTR = 4, // Interrupted system call
+ IO = 5, // Input/output error
+ NXIO = 6, // Device not configured
+ @"2BIG" = 7, // Argument list too long
+ NOEXEC = 8, // Exec format error
+ BADF = 9, // Bad file descriptor
+ CHILD = 10, // No child processes
+ DEADLK = 11, // Resource deadlock avoided
+ // 11 was AGAIN
+ NOMEM = 12, // Cannot allocate memory
+ ACCES = 13, // Permission denied
+ FAULT = 14, // Bad address
+ NOTBLK = 15, // Block device required
+ BUSY = 16, // Device busy
+ EXIST = 17, // File exists
+ XDEV = 18, // Cross-device link
+ NODEV = 19, // Operation not supported by device
+ NOTDIR = 20, // Not a directory
+ ISDIR = 21, // Is a directory
+ INVAL = 22, // Invalid argument
+ NFILE = 23, // Too many open files in system
+ MFILE = 24, // Too many open files
+ NOTTY = 25, // Inappropriate ioctl for device
+ TXTBSY = 26, // Text file busy
+ FBIG = 27, // File too large
+ NOSPC = 28, // No space left on device
+ SPIPE = 29, // Illegal seek
+ ROFS = 30, // Read-only file system
+ MLINK = 31, // Too many links
+ PIPE = 32, // Broken pipe
+
+ // math software
+ DOM = 33, // Numerical argument out of domain
+ RANGE = 34, // Result too large or too small
+
+ // non-blocking and interrupt i/o
+ // also: WOULDBLOCK: operation would block
+ AGAIN = 35, // Resource temporarily unavailable
+ INPROGRESS = 36, // Operation now in progress
+ ALREADY = 37, // Operation already in progress
+
+ // ipc/network software -- argument errors
+ NOTSOCK = 38, // Socket operation on non-socket
+ DESTADDRREQ = 39, // Destination address required
+ MSGSIZE = 40, // Message too long
+ PROTOTYPE = 41, // Protocol wrong type for socket
+ NOPROTOOPT = 42, // Protocol option not available
+ PROTONOSUPPORT = 43, // Protocol not supported
+ SOCKTNOSUPPORT = 44, // Socket type not supported
+ OPNOTSUPP = 45, // Operation not supported
+ PFNOSUPPORT = 46, // Protocol family not supported
+ AFNOSUPPORT = 47, // Address family not supported by protocol family
+ ADDRINUSE = 48, // Address already in use
+ ADDRNOTAVAIL = 49, // Can't assign requested address
+
+ // ipc/network software -- operational errors
+ NETDOWN = 50, // Network is down
+ NETUNREACH = 51, // Network is unreachable
+ NETRESET = 52, // Network dropped connection on reset
+ CONNABORTED = 53, // Software caused connection abort
+ CONNRESET = 54, // Connection reset by peer
+ NOBUFS = 55, // No buffer space available
+ ISCONN = 56, // Socket is already connected
+ NOTCONN = 57, // Socket is not connected
+ SHUTDOWN = 58, // Can't send after socket shutdown
+ TOOMANYREFS = 59, // Too many references: can't splice
+ TIMEDOUT = 60, // Operation timed out
+ CONNREFUSED = 61, // Connection refused
+
+ LOOP = 62, // Too many levels of symbolic links
+ NAMETOOLONG = 63, // File name too long
+
+ // should be rearranged
+ HOSTDOWN = 64, // Host is down
+ HOSTUNREACH = 65, // No route to host
+ NOTEMPTY = 66, // Directory not empty
+
+ // quotas & mush
+ PROCLIM = 67, // Too many processes
+ USERS = 68, // Too many users
+ DQUOT = 69, // Disc quota exceeded
+
+ // Network File System
+ STALE = 70, // Stale NFS file handle
+ REMOTE = 71, // Too many levels of remote in path
+ BADRPC = 72, // RPC struct is bad
+ RPCMISMATCH = 73, // RPC version wrong
+ PROGUNAVAIL = 74, // RPC prog. not avail
+ PROGMISMATCH = 75, // Program version wrong
+ PROCUNAVAIL = 76, // Bad procedure for program
+
+ NOLCK = 77, // No locks available
+ NOSYS = 78, // Function not implemented
+
+ FTYPE = 79, // Inappropriate file type or format
+ AUTH = 80, // Authentication error
+ NEEDAUTH = 81, // Need authenticator
+
+ // SystemV IPC
+ IDRM = 82, // Identifier removed
+ NOMSG = 83, // No message of desired type
+ OVERFLOW = 84, // Value too large to be stored in data type
+
+ // Wide/multibyte-character handling, ISO/IEC 9899/AMD1:1995
+ ILSEQ = 85, // Illegal byte sequence
+
+ // From IEEE Std 1003.1-2001
+ // Base, Realtime, Threads or Thread Priority Scheduling option errors
+ NOTSUP = 86, // Not supported
+
+ // Realtime option errors
+ CANCELED = 87, // Operation canceled
+
+ // Realtime, XSI STREAMS option errors
+ BADMSG = 88, // Bad or Corrupt message
+
+ // XSI STREAMS option errors
+ NODATA = 89, // No message available
+ NOSR = 90, // No STREAM resources
+ NOSTR = 91, // Not a STREAM
+ TIME = 92, // STREAM ioctl timeout
+
+ // File system extended attribute errors
+ NOATTR = 93, // Attribute not found
+
+ // Realtime, XSI STREAMS option errors
+ MULTIHOP = 94, // Multihop attempted
+ NOLINK = 95, // Link has been severed
+ PROTO = 96, // Protocol error
+
+ _,
+};
+
+pub const MINSIGSTKSZ = 8192;
+pub const SIGSTKSZ = MINSIGSTKSZ + 32768;
+
+pub const SS_ONSTACK = 1;
+pub const SS_DISABLE = 4;
+
+pub const stack_t = extern struct {
+ sp: [*]u8,
+ size: isize,
+ flags: i32,
+};
+
+pub const S = struct {
+ pub const IFMT = 0o170000;
+
+ pub const IFIFO = 0o010000;
+ pub const IFCHR = 0o020000;
+ pub const IFDIR = 0o040000;
+ pub const IFBLK = 0o060000;
+ pub const IFREG = 0o100000;
+ pub const IFLNK = 0o120000;
+ pub const IFSOCK = 0o140000;
+ pub const IFWHT = 0o160000;
+
+ pub const ISUID = 0o4000;
+ pub const ISGID = 0o2000;
+ pub const ISVTX = 0o1000;
+ pub const IRWXU = 0o700;
+ pub const IRUSR = 0o400;
+ pub const IWUSR = 0o200;
+ pub const IXUSR = 0o100;
+ pub const IRWXG = 0o070;
+ pub const IRGRP = 0o040;
+ pub const IWGRP = 0o020;
+ pub const IXGRP = 0o010;
+ pub const IRWXO = 0o007;
+ pub const IROTH = 0o004;
+ pub const IWOTH = 0o002;
+ pub const IXOTH = 0o001;
+
+ pub fn ISFIFO(m: u32) bool {
+ return m & IFMT == IFIFO;
+ }
+
+ pub fn ISCHR(m: u32) bool {
+ return m & IFMT == IFCHR;
+ }
+
+ pub fn ISDIR(m: u32) bool {
+ return m & IFMT == IFDIR;
+ }
+
+ pub fn ISBLK(m: u32) bool {
+ return m & IFMT == IFBLK;
+ }
+
+ pub fn ISREG(m: u32) bool {
+ return m & IFMT == IFREG;
+ }
+
+ pub fn ISLNK(m: u32) bool {
+ return m & IFMT == IFLNK;
+ }
+
+ pub fn ISSOCK(m: u32) bool {
+ return m & IFMT == IFSOCK;
+ }
+
+ pub fn IWHT(m: u32) bool {
+ return m & IFMT == IFWHT;
+ }
+};
+
+pub const AT = struct {
+ /// Magic value that specify the use of the current working directory
+ /// to determine the target of relative file paths in the openat() and
+ /// similar syscalls.
+ pub const FDCWD = -100;
+ /// Check access using effective user and group ID
+ pub const EACCESS = 0x0100;
+ /// Do not follow symbolic links
+ pub const SYMLINK_NOFOLLOW = 0x0200;
+ /// Follow symbolic link
+ pub const SYMLINK_FOLLOW = 0x0400;
+ /// Remove directory instead of file
+ pub const REMOVEDIR = 0x0800;
+};
+
+pub const HOST_NAME_MAX = 255;
+
+pub const IPPROTO = struct {
+ /// dummy for IP
+ pub const IP = 0;
+ /// IP6 hop-by-hop options
+ pub const HOPOPTS = 0;
+ /// control message protocol
+ pub const ICMP = 1;
+ /// group mgmt protocol
+ pub const IGMP = 2;
+ /// gateway^2 (deprecated)
+ pub const GGP = 3;
+ /// IP header
+ pub const IPV4 = 4;
+ /// IP inside IP
+ pub const IPIP = 4;
+ /// tcp
+ pub const TCP = 6;
+ /// exterior gateway protocol
+ pub const EGP = 8;
+ /// pup
+ pub const PUP = 12;
+ /// user datagram protocol
+ pub const UDP = 17;
+ /// xns idp
+ pub const IDP = 22;
+ /// tp-4 w/ class negotiation
+ pub const TP = 29;
+ /// DCCP
+ pub const DCCP = 33;
+ /// IP6 header
+ pub const IPV6 = 41;
+ /// IP6 routing header
+ pub const ROUTING = 43;
+ /// IP6 fragmentation header
+ pub const FRAGMENT = 44;
+ /// resource reservation
+ pub const RSVP = 46;
+ /// GRE encaps RFC 1701
+ pub const GRE = 47;
+ /// encap. security payload
+ pub const ESP = 50;
+ /// authentication header
+ pub const AH = 51;
+ /// IP Mobility RFC 2004
+ pub const MOBILE = 55;
+ /// IPv6 ICMP
+ pub const IPV6_ICMP = 58;
+ /// ICMP6
+ pub const ICMPV6 = 58;
+ /// IP6 no next header
+ pub const NONE = 59;
+ /// IP6 destination option
+ pub const DSTOPTS = 60;
+ /// ISO cnlp
+ pub const EON = 80;
+ /// Ethernet-in-IP
+ pub const ETHERIP = 97;
+ /// encapsulation header
+ pub const ENCAP = 98;
+ /// Protocol indep. multicast
+ pub const PIM = 103;
+ /// IP Payload Comp. Protocol
+ pub const IPCOMP = 108;
+ /// VRRP RFC 2338
+ pub const VRRP = 112;
+ /// Common Address Resolution Protocol
+ pub const CARP = 112;
+ /// L2TPv3
+ pub const L2TP = 115;
+ /// SCTP
+ pub const SCTP = 132;
+ /// PFSYNC
+ pub const PFSYNC = 240;
+ /// raw IP packet
+ pub const RAW = 255;
+};
+
+pub const rlimit_resource = enum(c_int) {
+ CPU = 0,
+ FSIZE = 1,
+ DATA = 2,
+ STACK = 3,
+ CORE = 4,
+ RSS = 5,
+ MEMLOCK = 6,
+ NPROC = 7,
+ NOFILE = 8,
+ SBSIZE = 9,
+ VMEM = 10,
+ NTHR = 11,
+ _,
+
+ pub const AS: rlimit_resource = .VMEM;
+};
+
+pub const rlim_t = u64;
+
+pub const RLIM = struct {
+ /// No limit
+ pub const INFINITY: rlim_t = (1 << 63) - 1;
+
+ pub const SAVED_MAX = INFINITY;
+ pub const SAVED_CUR = INFINITY;
+};
+
+pub const rlimit = extern struct {
+ /// Soft limit
+ cur: rlim_t,
+ /// Hard limit
+ max: rlim_t,
+};
+
+pub const SHUT = struct {
+ pub const RD = 0;
+ pub const WR = 1;
+ pub const RDWR = 2;
+};
+
+pub const nfds_t = u32;
+
+pub const pollfd = extern struct {
+ fd: fd_t,
+ events: i16,
+ revents: i16,
+};
+
+pub const POLL = struct {
+ /// Testable events (may be specified in events field).
+ pub const IN = 0x0001;
+ pub const PRI = 0x0002;
+ pub const OUT = 0x0004;
+ pub const RDNORM = 0x0040;
+ pub const WRNORM = OUT;
+ pub const RDBAND = 0x0080;
+ pub const WRBAND = 0x0100;
+
+ /// Non-testable events (may not be specified in events field).
+ pub const ERR = 0x0008;
+ pub const HUP = 0x0010;
+ pub const NVAL = 0x0020;
+};
diff --git a/lib/std/c/openbsd.zig b/lib/std/c/openbsd.zig
index e5ded7f3fb83..b3919d472413 100644
--- a/lib/std/c/openbsd.zig
+++ b/lib/std/c/openbsd.zig
@@ -1,7 +1,8 @@
const std = @import("../std.zig");
-const builtin = std.builtin;
-
-usingnamespace std.c;
+const maxInt = std.math.maxInt;
+const builtin = @import("builtin");
+const iovec = std.os.iovec;
+const iovec_const = std.os.iovec_const;
extern "c" fn __errno() *c_int;
pub const _errno = __errno;
@@ -43,3 +44,1317 @@ pub extern "c" fn unveil(path: ?[*:0]const u8, permissions: ?[*:0]const u8) c_in
pub extern "c" fn pthread_set_name_np(thread: std.c.pthread_t, name: [*:0]const u8) void;
pub extern "c" fn pthread_get_name_np(thread: std.c.pthread_t, name: [*:0]u8, len: usize) void;
+
+pub const blkcnt_t = i64;
+pub const blksize_t = i32;
+pub const clock_t = i64;
+pub const dev_t = i32;
+pub const fd_t = c_int;
+pub const gid_t = u32;
+pub const ino_t = u64;
+pub const mode_t = u32;
+pub const nlink_t = u32;
+pub const off_t = i64;
+pub const pid_t = i32;
+pub const socklen_t = u32;
+pub const time_t = i64;
+pub const uid_t = u32;
+
+/// Renamed from `kevent` to `Kevent` to avoid conflict with function name.
+pub const Kevent = extern struct {
+ ident: usize,
+ filter: c_short,
+ flags: u16,
+ fflags: c_uint,
+ data: i64,
+ udata: usize,
+};
+
+// Modes and flags for dlopen()
+// include/dlfcn.h
+
+pub const RTLD = struct {
+ /// Bind function calls lazily.
+ pub const LAZY = 1;
+ /// Bind function calls immediately.
+ pub const NOW = 2;
+ /// Make symbols globally available.
+ pub const GLOBAL = 0x100;
+ /// Opposite of GLOBAL, and the default.
+ pub const LOCAL = 0x000;
+ /// Trace loaded objects and exit.
+ pub const TRACE = 0x200;
+};
+
+pub const dl_phdr_info = extern struct {
+ dlpi_addr: std.elf.Addr,
+ dlpi_name: ?[*:0]const u8,
+ dlpi_phdr: [*]std.elf.Phdr,
+ dlpi_phnum: std.elf.Half,
+};
+
+pub const Flock = extern struct {
+ l_start: off_t,
+ l_len: off_t,
+ l_pid: pid_t,
+ l_type: c_short,
+ l_whence: c_short,
+};
+
+pub const addrinfo = extern struct {
+ flags: c_int,
+ family: c_int,
+ socktype: c_int,
+ protocol: c_int,
+ addrlen: socklen_t,
+ addr: ?*sockaddr,
+ canonname: ?[*:0]u8,
+ next: ?*addrinfo,
+};
+
+pub const EAI = enum(c_int) {
+ /// address family for hostname not supported
+ ADDRFAMILY = -9,
+
+ /// name could not be resolved at this time
+ AGAIN = -3,
+
+ /// flags parameter had an invalid value
+ BADFLAGS = -1,
+
+ /// non-recoverable failure in name resolution
+ FAIL = -4,
+
+ /// address family not recognized
+ FAMILY = -6,
+
+ /// memory allocation failure
+ MEMORY = -10,
+
+ /// no address associated with hostname
+ NODATA = -5,
+
+ /// name does not resolve
+ NONAME = -2,
+
+ /// service not recognized for socket type
+ SERVICE = -8,
+
+ /// intended socket type was not recognized
+ SOCKTYPE = -7,
+
+ /// system error returned in errno
+ SYSTEM = -11,
+
+ /// invalid value for hints
+ BADHINTS = -12,
+
+ /// resolved protocol is unknown
+ PROTOCOL = -13,
+
+ /// argument buffer overflow
+ OVERFLOW = -14,
+
+ _,
+};
+
+pub const EAI_MAX = 15;
+
+pub const msghdr = extern struct {
+ /// optional address
+ msg_name: ?*sockaddr,
+
+ /// size of address
+ msg_namelen: socklen_t,
+
+ /// scatter/gather array
+ msg_iov: [*]iovec,
+
+ /// # elements in msg_iov
+ msg_iovlen: c_uint,
+
+ /// ancillary data
+ msg_control: ?*c_void,
+
+ /// ancillary data buffer len
+ msg_controllen: socklen_t,
+
+ /// flags on received message
+ msg_flags: c_int,
+};
+
+pub const msghdr_const = extern struct {
+ /// optional address
+ msg_name: ?*const sockaddr,
+
+ /// size of address
+ msg_namelen: socklen_t,
+
+ /// scatter/gather array
+ msg_iov: [*]iovec_const,
+
+ /// # elements in msg_iov
+ msg_iovlen: c_uint,
+
+ /// ancillary data
+ msg_control: ?*c_void,
+
+ /// ancillary data buffer len
+ msg_controllen: socklen_t,
+
+ /// flags on received message
+ msg_flags: c_int,
+};
+
+pub const Stat = extern struct {
+ mode: mode_t,
+ dev: dev_t,
+ ino: ino_t,
+ nlink: nlink_t,
+ uid: uid_t,
+ gid: gid_t,
+ rdev: dev_t,
+ atim: timespec,
+ mtim: timespec,
+ ctim: timespec,
+ size: off_t,
+ blocks: blkcnt_t,
+ blksize: blksize_t,
+ flags: u32,
+ gen: u32,
+ birthtim: timespec,
+
+ pub fn atime(self: @This()) timespec {
+ return self.atim;
+ }
+
+ pub fn mtime(self: @This()) timespec {
+ return self.mtim;
+ }
+
+ pub fn ctime(self: @This()) timespec {
+ return self.ctim;
+ }
+};
+
+pub const timespec = extern struct {
+ tv_sec: time_t,
+ tv_nsec: c_long,
+};
+
+pub const timeval = extern struct {
+ tv_sec: time_t,
+ tv_usec: c_long,
+};
+
+pub const timezone = extern struct {
+ tz_minuteswest: c_int,
+ tz_dsttime: c_int,
+};
+
+pub const MAXNAMLEN = 255;
+
+pub const dirent = extern struct {
+ d_fileno: ino_t,
+ d_off: off_t,
+ d_reclen: u16,
+ d_type: u8,
+ d_namlen: u8,
+ __d_padding: [4]u8,
+ d_name: [MAXNAMLEN + 1]u8,
+
+ pub fn reclen(self: dirent) u16 {
+ return self.d_reclen;
+ }
+};
+
+pub const in_port_t = u16;
+pub const sa_family_t = u8;
+
+pub const sockaddr = extern struct {
+ /// total length
+ len: u8,
+ /// address family
+ family: sa_family_t,
+ /// actually longer; address value
+ data: [14]u8,
+
+ pub const storage = std.x.os.Socket.Address.Native.Storage;
+
+ pub const in = extern struct {
+ len: u8 = @sizeOf(in),
+ family: sa_family_t = AF.INET,
+ port: in_port_t,
+ addr: u32,
+ zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },
+ };
+
+ pub const in6 = extern struct {
+ len: u8 = @sizeOf(in6),
+ family: sa_family_t = AF.INET6,
+ port: in_port_t,
+ flowinfo: u32,
+ addr: [16]u8,
+ scope_id: u32,
+ };
+
+ /// Definitions for UNIX IPC domain.
+ pub const un = extern struct {
+ /// total sockaddr length
+ len: u8 = @sizeOf(un),
+
+ family: sa_family_t = AF.LOCAL,
+
+ /// path name
+ path: [104]u8,
+ };
+};
+
+pub const AI = struct {
+ /// get address to use bind()
+ pub const PASSIVE = 1;
+ /// fill ai_canonname
+ pub const CANONNAME = 2;
+ /// prevent host name resolution
+ pub const NUMERICHOST = 4;
+ /// prevent service name resolution
+ pub const NUMERICSERV = 16;
+ /// only if any address is assigned
+ pub const ADDRCONFIG = 64;
+};
+
+pub const PATH_MAX = 1024;
+pub const IOV_MAX = 1024;
+
+pub const STDIN_FILENO = 0;
+pub const STDOUT_FILENO = 1;
+pub const STDERR_FILENO = 2;
+
+pub const PROT = struct {
+ pub const NONE = 0;
+ pub const READ = 1;
+ pub const WRITE = 2;
+ pub const EXEC = 4;
+};
+
+pub const CLOCK = struct {
+ pub const REALTIME = 0;
+ pub const PROCESS_CPUTIME_ID = 2;
+ pub const MONOTONIC = 3;
+ pub const THREAD_CPUTIME_ID = 4;
+};
+
+pub const MAP = struct {
+ pub const FAILED = @intToPtr(*c_void, maxInt(usize));
+ pub const SHARED = 0x0001;
+ pub const PRIVATE = 0x0002;
+ pub const FIXED = 0x0010;
+ pub const RENAME = 0;
+ pub const NORESERVE = 0;
+ pub const INHERIT = 0;
+ pub const HASSEMAPHORE = 0;
+ pub const TRYFIXED = 0;
+
+ pub const FILE = 0;
+ pub const ANON = 0x1000;
+ pub const ANONYMOUS = ANON;
+ pub const STACK = 0x4000;
+ pub const CONCEAL = 0x8000;
+};
+
+pub const W = struct {
+ pub const NOHANG = 1;
+ pub const UNTRACED = 2;
+ pub const CONTINUED = 8;
+
+ pub fn EXITSTATUS(s: u32) u8 {
+ return @intCast(u8, (s >> 8) & 0xff);
+ }
+ pub fn TERMSIG(s: u32) u32 {
+ return (s & 0x7f);
+ }
+ pub fn STOPSIG(s: u32) u32 {
+ return EXITSTATUS(s);
+ }
+ pub fn IFEXITED(s: u32) bool {
+ return TERMSIG(s) == 0;
+ }
+
+ pub fn IFCONTINUED(s: u32) bool {
+ return ((s & 0o177777) == 0o177777);
+ }
+
+ pub fn IFSTOPPED(s: u32) bool {
+ return (s & 0xff == 0o177);
+ }
+
+ pub fn IFSIGNALED(s: u32) bool {
+ return (((s) & 0o177) != 0o177) and (((s) & 0o177) != 0);
+ }
+};
+
+pub const SA = struct {
+ pub const ONSTACK = 0x0001;
+ pub const RESTART = 0x0002;
+ pub const RESETHAND = 0x0004;
+ pub const NOCLDSTOP = 0x0008;
+ pub const NODEFER = 0x0010;
+ pub const NOCLDWAIT = 0x0020;
+ pub const SIGINFO = 0x0040;
+};
+
+// access function
+pub const F_OK = 0; // test for existence of file
+pub const X_OK = 1; // test for execute or search permission
+pub const W_OK = 2; // test for write permission
+pub const R_OK = 4; // test for read permission
+
+pub const O = struct {
+ /// open for reading only
+ pub const RDONLY = 0x00000000;
+ /// open for writing only
+ pub const WRONLY = 0x00000001;
+ /// open for reading and writing
+ pub const RDWR = 0x00000002;
+ /// mask for above modes
+ pub const ACCMODE = 0x00000003;
+ /// no delay
+ pub const NONBLOCK = 0x00000004;
+ /// set append mode
+ pub const APPEND = 0x00000008;
+ /// open with shared file lock
+ pub const SHLOCK = 0x00000010;
+ /// open with exclusive file lock
+ pub const EXLOCK = 0x00000020;
+ /// signal pgrp when data ready
+ pub const ASYNC = 0x00000040;
+ /// synchronous writes
+ pub const SYNC = 0x00000080;
+ /// don't follow symlinks on the last
+ pub const NOFOLLOW = 0x00000100;
+ /// create if nonexistent
+ pub const CREAT = 0x00000200;
+ /// truncate to zero length
+ pub const TRUNC = 0x00000400;
+ /// error if already exists
+ pub const EXCL = 0x00000800;
+ /// don't assign controlling terminal
+ pub const NOCTTY = 0x00008000;
+ /// write: I/O data completion
+ pub const DSYNC = SYNC;
+ /// read: I/O completion as for write
+ pub const RSYNC = SYNC;
+ /// fail if not a directory
+ pub const DIRECTORY = 0x20000;
+ /// set close on exec
+ pub const CLOEXEC = 0x10000;
+};
+
+pub const F = struct {
+ pub const DUPFD = 0;
+ pub const GETFD = 1;
+ pub const SETFD = 2;
+ pub const GETFL = 3;
+ pub const SETFL = 4;
+
+ pub const GETOWN = 5;
+ pub const SETOWN = 6;
+
+ pub const GETLK = 7;
+ pub const SETLK = 8;
+ pub const SETLKW = 9;
+
+ pub const RDLCK = 1;
+ pub const UNLCK = 2;
+ pub const WRLCK = 3;
+};
+
+pub const LOCK = struct {
+ pub const SH = 0x01;
+ pub const EX = 0x02;
+ pub const NB = 0x04;
+ pub const UN = 0x08;
+};
+
+pub const FD_CLOEXEC = 1;
+
+pub const SEEK = struct {
+ pub const SET = 0;
+ pub const CUR = 1;
+ pub const END = 2;
+};
+
+pub const SOCK = struct {
+ pub const STREAM = 1;
+ pub const DGRAM = 2;
+ pub const RAW = 3;
+ pub const RDM = 4;
+ pub const SEQPACKET = 5;
+
+ pub const CLOEXEC = 0x8000;
+ pub const NONBLOCK = 0x4000;
+};
+
+pub const SO = struct {
+ pub const DEBUG = 0x0001;
+ pub const ACCEPTCONN = 0x0002;
+ pub const REUSEADDR = 0x0004;
+ pub const KEEPALIVE = 0x0008;
+ pub const DONTROUTE = 0x0010;
+ pub const BROADCAST = 0x0020;
+ pub const USELOOPBACK = 0x0040;
+ pub const LINGER = 0x0080;
+ pub const OOBINLINE = 0x0100;
+ pub const REUSEPORT = 0x0200;
+ pub const TIMESTAMP = 0x0800;
+ pub const BINDANY = 0x1000;
+ pub const ZEROIZE = 0x2000;
+ pub const SNDBUF = 0x1001;
+ pub const RCVBUF = 0x1002;
+ pub const SNDLOWAT = 0x1003;
+ pub const RCVLOWAT = 0x1004;
+ pub const SNDTIMEO = 0x1005;
+ pub const RCVTIMEO = 0x1006;
+ pub const ERROR = 0x1007;
+ pub const TYPE = 0x1008;
+ pub const NETPROC = 0x1020;
+ pub const RTABLE = 0x1021;
+ pub const PEERCRED = 0x1022;
+ pub const SPLICE = 0x1023;
+ pub const DOMAIN = 0x1024;
+ pub const PROTOCOL = 0x1025;
+};
+
+pub const SOL = struct {
+ pub const SOCKET = 0xffff;
+};
+
+pub const PF = struct {
+ pub const UNSPEC = AF.UNSPEC;
+ pub const LOCAL = AF.LOCAL;
+ pub const UNIX = AF.UNIX;
+ pub const INET = AF.INET;
+ pub const APPLETALK = AF.APPLETALK;
+ pub const INET6 = AF.INET6;
+ pub const DECnet = AF.DECnet;
+ pub const KEY = AF.KEY;
+ pub const ROUTE = AF.ROUTE;
+ pub const SNA = AF.SNA;
+ pub const MPLS = AF.MPLS;
+ pub const BLUETOOTH = AF.BLUETOOTH;
+ pub const ISDN = AF.ISDN;
+ pub const MAX = AF.MAX;
+};
+
+pub const AF = struct {
+ pub const UNSPEC = 0;
+ pub const UNIX = 1;
+ pub const LOCAL = UNIX;
+ pub const INET = 2;
+ pub const APPLETALK = 16;
+ pub const INET6 = 24;
+ pub const KEY = 30;
+ pub const ROUTE = 17;
+ pub const SNA = 11;
+ pub const MPLS = 33;
+ pub const BLUETOOTH = 32;
+ pub const ISDN = 26;
+ pub const MAX = 36;
+};
+
+pub const DT = struct {
+ pub const UNKNOWN = 0;
+ pub const FIFO = 1;
+ pub const CHR = 2;
+ pub const DIR = 4;
+ pub const BLK = 6;
+ pub const REG = 8;
+ pub const LNK = 10;
+ pub const SOCK = 12;
+ pub const WHT = 14; // XXX
+};
+
+pub const EV_ADD = 0x0001;
+pub const EV_DELETE = 0x0002;
+pub const EV_ENABLE = 0x0004;
+pub const EV_DISABLE = 0x0008;
+pub const EV_ONESHOT = 0x0010;
+pub const EV_CLEAR = 0x0020;
+pub const EV_RECEIPT = 0x0040;
+pub const EV_DISPATCH = 0x0080;
+pub const EV_FLAG1 = 0x2000;
+pub const EV_ERROR = 0x4000;
+pub const EV_EOF = 0x8000;
+
+pub const EVFILT_READ = -1;
+pub const EVFILT_WRITE = -2;
+pub const EVFILT_AIO = -3;
+pub const EVFILT_VNODE = -4;
+pub const EVFILT_PROC = -5;
+pub const EVFILT_SIGNAL = -6;
+pub const EVFILT_TIMER = -7;
+pub const EVFILT_EXCEPT = -9;
+
+// data/hint flags for EVFILT_{READ|WRITE}
+pub const NOTE_LOWAT = 0x0001;
+pub const NOTE_EOF = 0x0002;
+
+// data/hint flags for EVFILT_EXCEPT and EVFILT_{READ|WRITE}
+pub const NOTE_OOB = 0x0004;
+
+// data/hint flags for EVFILT_VNODE
+pub const NOTE_DELETE = 0x0001;
+pub const NOTE_WRITE = 0x0002;
+pub const NOTE_EXTEND = 0x0004;
+pub const NOTE_ATTRIB = 0x0008;
+pub const NOTE_LINK = 0x0010;
+pub const NOTE_RENAME = 0x0020;
+pub const NOTE_REVOKE = 0x0040;
+pub const NOTE_TRUNCATE = 0x0080;
+
+// data/hint flags for EVFILT_PROC
+pub const NOTE_EXIT = 0x80000000;
+pub const NOTE_FORK = 0x40000000;
+pub const NOTE_EXEC = 0x20000000;
+pub const NOTE_PDATAMASK = 0x000fffff;
+pub const NOTE_PCTRLMASK = 0xf0000000;
+pub const NOTE_TRACK = 0x00000001;
+pub const NOTE_TRACKERR = 0x00000002;
+pub const NOTE_CHILD = 0x00000004;
+
+// data/hint flags for EVFILT_DEVICE
+pub const NOTE_CHANGE = 0x00000001;
+
+pub const T = struct {
+ pub const IOCCBRK = 0x2000747a;
+ pub const IOCCDTR = 0x20007478;
+ pub const IOCCONS = 0x80047462;
+ pub const IOCDCDTIMESTAMP = 0x40107458;
+ pub const IOCDRAIN = 0x2000745e;
+ pub const IOCEXCL = 0x2000740d;
+ pub const IOCEXT = 0x80047460;
+ pub const IOCFLAG_CDTRCTS = 0x10;
+ pub const IOCFLAG_CLOCAL = 0x2;
+ pub const IOCFLAG_CRTSCTS = 0x4;
+ pub const IOCFLAG_MDMBUF = 0x8;
+ pub const IOCFLAG_SOFTCAR = 0x1;
+ pub const IOCFLUSH = 0x80047410;
+ pub const IOCGETA = 0x402c7413;
+ pub const IOCGETD = 0x4004741a;
+ pub const IOCGFLAGS = 0x4004745d;
+ pub const IOCGLINED = 0x40207442;
+ pub const IOCGPGRP = 0x40047477;
+ pub const IOCGQSIZE = 0x40047481;
+ pub const IOCGRANTPT = 0x20007447;
+ pub const IOCGSID = 0x40047463;
+ pub const IOCGSIZE = 0x40087468;
+ pub const IOCGWINSZ = 0x40087468;
+ pub const IOCMBIC = 0x8004746b;
+ pub const IOCMBIS = 0x8004746c;
+ pub const IOCMGET = 0x4004746a;
+ pub const IOCMSET = 0x8004746d;
+ pub const IOCM_CAR = 0x40;
+ pub const IOCM_CD = 0x40;
+ pub const IOCM_CTS = 0x20;
+ pub const IOCM_DSR = 0x100;
+ pub const IOCM_DTR = 0x2;
+ pub const IOCM_LE = 0x1;
+ pub const IOCM_RI = 0x80;
+ pub const IOCM_RNG = 0x80;
+ pub const IOCM_RTS = 0x4;
+ pub const IOCM_SR = 0x10;
+ pub const IOCM_ST = 0x8;
+ pub const IOCNOTTY = 0x20007471;
+ pub const IOCNXCL = 0x2000740e;
+ pub const IOCOUTQ = 0x40047473;
+ pub const IOCPKT = 0x80047470;
+ pub const IOCPKT_DATA = 0x0;
+ pub const IOCPKT_DOSTOP = 0x20;
+ pub const IOCPKT_FLUSHREAD = 0x1;
+ pub const IOCPKT_FLUSHWRITE = 0x2;
+ pub const IOCPKT_IOCTL = 0x40;
+ pub const IOCPKT_NOSTOP = 0x10;
+ pub const IOCPKT_START = 0x8;
+ pub const IOCPKT_STOP = 0x4;
+ pub const IOCPTMGET = 0x40287446;
+ pub const IOCPTSNAME = 0x40287448;
+ pub const IOCRCVFRAME = 0x80087445;
+ pub const IOCREMOTE = 0x80047469;
+ pub const IOCSBRK = 0x2000747b;
+ pub const IOCSCTTY = 0x20007461;
+ pub const IOCSDTR = 0x20007479;
+ pub const IOCSETA = 0x802c7414;
+ pub const IOCSETAF = 0x802c7416;
+ pub const IOCSETAW = 0x802c7415;
+ pub const IOCSETD = 0x8004741b;
+ pub const IOCSFLAGS = 0x8004745c;
+ pub const IOCSIG = 0x2000745f;
+ pub const IOCSLINED = 0x80207443;
+ pub const IOCSPGRP = 0x80047476;
+ pub const IOCSQSIZE = 0x80047480;
+ pub const IOCSSIZE = 0x80087467;
+ pub const IOCSTART = 0x2000746e;
+ pub const IOCSTAT = 0x80047465;
+ pub const IOCSTI = 0x80017472;
+ pub const IOCSTOP = 0x2000746f;
+ pub const IOCSWINSZ = 0x80087467;
+ pub const IOCUCNTL = 0x80047466;
+ pub const IOCXMTFRAME = 0x80087444;
+};
+
+pub const winsize = extern struct {
+ ws_row: c_ushort,
+ ws_col: c_ushort,
+ ws_xpixel: c_ushort,
+ ws_ypixel: c_ushort,
+};
+
+const NSIG = 33;
+
+pub const SIG = struct {
+ pub const DFL = @intToPtr(?Sigaction.sigaction_fn, 0);
+ pub const IGN = @intToPtr(?Sigaction.sigaction_fn, 1);
+ pub const ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize));
+ pub const CATCH = @intToPtr(?Sigaction.sigaction_fn, 2);
+ pub const HOLD = @intToPtr(?Sigaction.sigaction_fn, 3);
+
+ pub const HUP = 1;
+ pub const INT = 2;
+ pub const QUIT = 3;
+ pub const ILL = 4;
+ pub const TRAP = 5;
+ pub const ABRT = 6;
+ pub const IOT = ABRT;
+ pub const EMT = 7;
+ pub const FPE = 8;
+ pub const KILL = 9;
+ pub const BUS = 10;
+ pub const SEGV = 11;
+ pub const SYS = 12;
+ pub const PIPE = 13;
+ pub const ALRM = 14;
+ pub const TERM = 15;
+ pub const URG = 16;
+ pub const STOP = 17;
+ pub const TSTP = 18;
+ pub const CONT = 19;
+ pub const CHLD = 20;
+ pub const TTIN = 21;
+ pub const TTOU = 22;
+ pub const IO = 23;
+ pub const XCPU = 24;
+ pub const XFSZ = 25;
+ pub const VTALRM = 26;
+ pub const PROF = 27;
+ pub const WINCH = 28;
+ pub const INFO = 29;
+ pub const USR1 = 30;
+ pub const USR2 = 31;
+ pub const PWR = 32;
+
+ pub const BLOCK = 1;
+ pub const UNBLOCK = 2;
+ pub const SETMASK = 3;
+};
+
+/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.
+pub const Sigaction = extern struct {
+ pub const handler_fn = fn (c_int) callconv(.C) void;
+ pub const sigaction_fn = fn (c_int, *const siginfo_t, ?*const c_void) callconv(.C) void;
+
+ /// signal handler
+ handler: extern union {
+ handler: ?handler_fn,
+ sigaction: ?sigaction_fn,
+ },
+ /// signal mask to apply
+ mask: sigset_t,
+ /// signal options
+ flags: c_uint,
+};
+
+pub const sigval = extern union {
+ int: c_int,
+ ptr: ?*c_void,
+};
+
+pub const siginfo_t = extern struct {
+ signo: c_int,
+ code: c_int,
+ errno: c_int,
+ data: extern union {
+ proc: extern struct {
+ pid: pid_t,
+ pdata: extern union {
+ kill: extern struct {
+ uid: uid_t,
+ value: sigval,
+ },
+ cld: extern struct {
+ utime: clock_t,
+ stime: clock_t,
+ status: c_int,
+ },
+ },
+ },
+ fault: extern struct {
+ addr: ?*c_void,
+ trapno: c_int,
+ },
+ __pad: [128 - 3 * @sizeOf(c_int)]u8,
+ },
+};
+
+comptime {
+ if (@sizeOf(usize) == 4)
+ std.debug.assert(@sizeOf(siginfo_t) == 128)
+ else
+ // Take into account the padding between errno and data fields.
+ std.debug.assert(@sizeOf(siginfo_t) == 136);
+}
+
+const arch_bits = switch (builtin.cpu.arch) {
+ .x86_64 => struct {
+ pub const ucontext_t = extern struct {
+ sc_rdi: c_long,
+ sc_rsi: c_long,
+ sc_rdx: c_long,
+ sc_rcx: c_long,
+ sc_r8: c_long,
+ sc_r9: c_long,
+ sc_r10: c_long,
+ sc_r11: c_long,
+ sc_r12: c_long,
+ sc_r13: c_long,
+ sc_r14: c_long,
+ sc_r15: c_long,
+ sc_rbp: c_long,
+ sc_rbx: c_long,
+ sc_rax: c_long,
+ sc_gs: c_long,
+ sc_fs: c_long,
+ sc_es: c_long,
+ sc_ds: c_long,
+ sc_trapno: c_long,
+ sc_err: c_long,
+ sc_rip: c_long,
+ sc_cs: c_long,
+ sc_rflags: c_long,
+ sc_rsp: c_long,
+ sc_ss: c_long,
+
+ sc_fpstate: arch_bits.fxsave64,
+ __sc_unused: c_int,
+ sc_mask: c_int,
+ sc_cookie: c_long,
+ };
+
+ pub const fxsave64 = packed struct {
+ fx_fcw: u16,
+ fx_fsw: u16,
+ fx_ftw: u8,
+ fx_unused1: u8,
+ fx_fop: u16,
+ fx_rip: u64,
+ fx_rdp: u64,
+ fx_mxcsr: u32,
+ fx_mxcsr_mask: u32,
+ fx_st: [8][2]u64,
+ fx_xmm: [16][2]u64,
+ fx_unused3: [96]u8,
+ };
+ },
+ else => struct {},
+};
+pub const ucontext_t = arch_bits.ucontext_t;
+pub const fxsave64 = arch_bits.fxsave64;
+
+pub const sigset_t = c_uint;
+pub const empty_sigset: sigset_t = 0;
+
+pub const E = enum(u16) {
+ /// No error occurred.
+ SUCCESS = 0,
+ PERM = 1, // Operation not permitted
+ NOENT = 2, // No such file or directory
+ SRCH = 3, // No such process
+ INTR = 4, // Interrupted system call
+ IO = 5, // Input/output error
+ NXIO = 6, // Device not configured
+ @"2BIG" = 7, // Argument list too long
+ NOEXEC = 8, // Exec format error
+ BADF = 9, // Bad file descriptor
+ CHILD = 10, // No child processes
+ DEADLK = 11, // Resource deadlock avoided
+ // 11 was AGAIN
+ NOMEM = 12, // Cannot allocate memory
+ ACCES = 13, // Permission denied
+ FAULT = 14, // Bad address
+ NOTBLK = 15, // Block device required
+ BUSY = 16, // Device busy
+ EXIST = 17, // File exists
+ XDEV = 18, // Cross-device link
+ NODEV = 19, // Operation not supported by device
+ NOTDIR = 20, // Not a directory
+ ISDIR = 21, // Is a directory
+ INVAL = 22, // Invalid argument
+ NFILE = 23, // Too many open files in system
+ MFILE = 24, // Too many open files
+ NOTTY = 25, // Inappropriate ioctl for device
+ TXTBSY = 26, // Text file busy
+ FBIG = 27, // File too large
+ NOSPC = 28, // No space left on device
+ SPIPE = 29, // Illegal seek
+ ROFS = 30, // Read-only file system
+ MLINK = 31, // Too many links
+ PIPE = 32, // Broken pipe
+
+ // math software
+ DOM = 33, // Numerical argument out of domain
+ RANGE = 34, // Result too large or too small
+
+ // non-blocking and interrupt i/o
+ // also: WOULDBLOCK: operation would block
+ AGAIN = 35, // Resource temporarily unavailable
+ INPROGRESS = 36, // Operation now in progress
+ ALREADY = 37, // Operation already in progress
+
+ // ipc/network software -- argument errors
+ NOTSOCK = 38, // Socket operation on non-socket
+ DESTADDRREQ = 39, // Destination address required
+ MSGSIZE = 40, // Message too long
+ PROTOTYPE = 41, // Protocol wrong type for socket
+ NOPROTOOPT = 42, // Protocol option not available
+ PROTONOSUPPORT = 43, // Protocol not supported
+ SOCKTNOSUPPORT = 44, // Socket type not supported
+ OPNOTSUPP = 45, // Operation not supported
+ PFNOSUPPORT = 46, // Protocol family not supported
+ AFNOSUPPORT = 47, // Address family not supported by protocol family
+ ADDRINUSE = 48, // Address already in use
+ ADDRNOTAVAIL = 49, // Can't assign requested address
+
+ // ipc/network software -- operational errors
+ NETDOWN = 50, // Network is down
+ NETUNREACH = 51, // Network is unreachable
+ NETRESET = 52, // Network dropped connection on reset
+ CONNABORTED = 53, // Software caused connection abort
+ CONNRESET = 54, // Connection reset by peer
+ NOBUFS = 55, // No buffer space available
+ ISCONN = 56, // Socket is already connected
+ NOTCONN = 57, // Socket is not connected
+ SHUTDOWN = 58, // Can't send after socket shutdown
+ TOOMANYREFS = 59, // Too many references: can't splice
+ TIMEDOUT = 60, // Operation timed out
+ CONNREFUSED = 61, // Connection refused
+
+ LOOP = 62, // Too many levels of symbolic links
+ NAMETOOLONG = 63, // File name too long
+
+ // should be rearranged
+ HOSTDOWN = 64, // Host is down
+ HOSTUNREACH = 65, // No route to host
+ NOTEMPTY = 66, // Directory not empty
+
+ // quotas & mush
+ PROCLIM = 67, // Too many processes
+ USERS = 68, // Too many users
+ DQUOT = 69, // Disc quota exceeded
+
+ // Network File System
+ STALE = 70, // Stale NFS file handle
+ REMOTE = 71, // Too many levels of remote in path
+ BADRPC = 72, // RPC struct is bad
+ RPCMISMATCH = 73, // RPC version wrong
+ PROGUNAVAIL = 74, // RPC prog. not avail
+ PROGMISMATCH = 75, // Program version wrong
+ PROCUNAVAIL = 76, // Bad procedure for program
+
+ NOLCK = 77, // No locks available
+ NOSYS = 78, // Function not implemented
+
+ FTYPE = 79, // Inappropriate file type or format
+ AUTH = 80, // Authentication error
+ NEEDAUTH = 81, // Need authenticator
+ IPSEC = 82, // IPsec processing failure
+ NOATTR = 83, // Attribute not found
+
+ // Wide/multibyte-character handling, ISO/IEC 9899/AMD1:1995
+ ILSEQ = 84, // Illegal byte sequence
+
+ NOMEDIUM = 85, // No medium found
+ MEDIUMTYPE = 86, // Wrong medium type
+ OVERFLOW = 87, // Value too large to be stored in data type
+ CANCELED = 88, // Operation canceled
+ IDRM = 89, // Identifier removed
+ NOMSG = 90, // No message of desired type
+ NOTSUP = 91, // Not supported
+ BADMSG = 92, // Bad or Corrupt message
+ NOTRECOVERABLE = 93, // State not recoverable
+ OWNERDEAD = 94, // Previous owner died
+ PROTO = 95, // Protocol error
+
+ _,
+};
+
+const _MAX_PAGE_SHIFT = switch (builtin.cpu.arch) {
+ .i386 => 12,
+ .sparcv9 => 13,
+};
+pub const MINSIGSTKSZ = 1 << _MAX_PAGE_SHIFT;
+pub const SIGSTKSZ = MINSIGSTKSZ + (1 << _MAX_PAGE_SHIFT) * 4;
+
+pub const SS_ONSTACK = 0x0001;
+pub const SS_DISABLE = 0x0004;
+
+pub const stack_t = extern struct {
+ sp: [*]u8,
+ size: usize,
+ flags: c_int,
+};
+
+pub const S = struct {
+ pub const IFMT = 0o170000;
+
+ pub const IFIFO = 0o010000;
+ pub const IFCHR = 0o020000;
+ pub const IFDIR = 0o040000;
+ pub const IFBLK = 0o060000;
+ pub const IFREG = 0o100000;
+ pub const IFLNK = 0o120000;
+ pub const IFSOCK = 0o140000;
+
+ pub const ISUID = 0o4000;
+ pub const ISGID = 0o2000;
+ pub const ISVTX = 0o1000;
+ pub const IRWXU = 0o700;
+ pub const IRUSR = 0o400;
+ pub const IWUSR = 0o200;
+ pub const IXUSR = 0o100;
+ pub const IRWXG = 0o070;
+ pub const IRGRP = 0o040;
+ pub const IWGRP = 0o020;
+ pub const IXGRP = 0o010;
+ pub const IRWXO = 0o007;
+ pub const IROTH = 0o004;
+ pub const IWOTH = 0o002;
+ pub const IXOTH = 0o001;
+
+ pub fn ISFIFO(m: u32) bool {
+ return m & IFMT == IFIFO;
+ }
+
+ pub fn ISCHR(m: u32) bool {
+ return m & IFMT == IFCHR;
+ }
+
+ pub fn ISDIR(m: u32) bool {
+ return m & IFMT == IFDIR;
+ }
+
+ pub fn ISBLK(m: u32) bool {
+ return m & IFMT == IFBLK;
+ }
+
+ pub fn ISREG(m: u32) bool {
+ return m & IFMT == IFREG;
+ }
+
+ pub fn ISLNK(m: u32) bool {
+ return m & IFMT == IFLNK;
+ }
+
+ pub fn ISSOCK(m: u32) bool {
+ return m & IFMT == IFSOCK;
+ }
+};
+
+pub const AT = struct {
+ /// Magic value that specify the use of the current working directory
+ /// to determine the target of relative file paths in the openat() and
+ /// similar syscalls.
+ pub const FDCWD = -100;
+ /// Check access using effective user and group ID
+ pub const EACCESS = 0x01;
+ /// Do not follow symbolic links
+ pub const SYMLINK_NOFOLLOW = 0x02;
+ /// Follow symbolic link
+ pub const SYMLINK_FOLLOW = 0x04;
+ /// Remove directory instead of file
+ pub const REMOVEDIR = 0x08;
+};
+
+pub const HOST_NAME_MAX = 255;
+
+pub const IPPROTO = struct {
+ /// dummy for IP
+ pub const IP = 0;
+ /// IP6 hop-by-hop options
+ pub const HOPOPTS = IP;
+ /// control message protocol
+ pub const ICMP = 1;
+ /// group mgmt protocol
+ pub const IGMP = 2;
+ /// gateway^2 (deprecated)
+ pub const GGP = 3;
+ /// IP header
+ pub const IPV4 = IPIP;
+ /// IP inside IP
+ pub const IPIP = 4;
+ /// tcp
+ pub const TCP = 6;
+ /// exterior gateway protocol
+ pub const EGP = 8;
+ /// pup
+ pub const PUP = 12;
+ /// user datagram protocol
+ pub const UDP = 17;
+ /// xns idp
+ pub const IDP = 22;
+ /// tp-4 w/ class negotiation
+ pub const TP = 29;
+ /// IP6 header
+ pub const IPV6 = 41;
+ /// IP6 routing header
+ pub const ROUTING = 43;
+ /// IP6 fragmentation header
+ pub const FRAGMENT = 44;
+ /// resource reservation
+ pub const RSVP = 46;
+ /// GRE encaps RFC 1701
+ pub const GRE = 47;
+ /// encap. security payload
+ pub const ESP = 50;
+ /// authentication header
+ pub const AH = 51;
+ /// IP Mobility RFC 2004
+ pub const MOBILE = 55;
+ /// IPv6 ICMP
+ pub const IPV6_ICMP = 58;
+ /// ICMP6
+ pub const ICMPV6 = 58;
+ /// IP6 no next header
+ pub const NONE = 59;
+ /// IP6 destination option
+ pub const DSTOPTS = 60;
+ /// ISO cnlp
+ pub const EON = 80;
+ /// Ethernet-in-IP
+ pub const ETHERIP = 97;
+ /// encapsulation header
+ pub const ENCAP = 98;
+ /// Protocol indep. multicast
+ pub const PIM = 103;
+ /// IP Payload Comp. Protocol
+ pub const IPCOMP = 108;
+ /// VRRP RFC 2338
+ pub const VRRP = 112;
+ /// Common Address Resolution Protocol
+ pub const CARP = 112;
+ /// PFSYNC
+ pub const PFSYNC = 240;
+ /// raw IP packet
+ pub const RAW = 255;
+};
+
+pub const rlimit_resource = enum(c_int) {
+ CPU,
+ FSIZE,
+ DATA,
+ STACK,
+ CORE,
+ RSS,
+ MEMLOCK,
+ NPROC,
+ NOFILE,
+
+ _,
+};
+
+pub const rlim_t = u64;
+
+pub const RLIM = struct {
+ /// No limit
+ pub const INFINITY: rlim_t = (1 << 63) - 1;
+
+ pub const SAVED_MAX = INFINITY;
+ pub const SAVED_CUR = INFINITY;
+};
+
+pub const rlimit = extern struct {
+ /// Soft limit
+ cur: rlim_t,
+ /// Hard limit
+ max: rlim_t,
+};
+
+pub const SHUT = struct {
+ pub const RD = 0;
+ pub const WR = 1;
+ pub const RDWR = 2;
+};
+
+pub const nfds_t = c_uint;
+
+pub const pollfd = extern struct {
+ fd: fd_t,
+ events: c_short,
+ revents: c_short,
+};
+
+pub const POLL = struct {
+ pub const IN = 0x0001;
+ pub const PRI = 0x0002;
+ pub const OUT = 0x0004;
+ pub const ERR = 0x0008;
+ pub const HUP = 0x0010;
+ pub const NVAL = 0x0020;
+ pub const RDNORM = 0x0040;
+ pub const NORM = RDNORM;
+ pub const WRNORM = OUT;
+ pub const RDBAND = 0x0080;
+ pub const WRBAND = 0x0100;
+};
+
+pub const CTL = struct {
+ pub const UNSPEC = 0;
+ pub const KERN = 1;
+ pub const VM = 2;
+ pub const FS = 3;
+ pub const NET = 4;
+ pub const DEBUG = 5;
+ pub const HW = 6;
+ pub const MACHDEP = 7;
+
+ pub const DDB = 9;
+ pub const VFS = 10;
+};
+
+pub const KERN = struct {
+ pub const OSTYPE = 1;
+ pub const OSRELEASE = 2;
+ pub const OSREV = 3;
+ pub const VERSION = 4;
+ pub const MAXVNODES = 5;
+ pub const MAXPROC = 6;
+ pub const MAXFILES = 7;
+ pub const ARGMAX = 8;
+ pub const SECURELVL = 9;
+ pub const HOSTNAME = 10;
+ pub const HOSTID = 11;
+ pub const CLOCKRATE = 12;
+
+ pub const PROF = 16;
+ pub const POSIX1 = 17;
+ pub const NGROUPS = 18;
+ pub const JOB_CONTROL = 19;
+ pub const SAVED_IDS = 20;
+ pub const BOOTTIME = 21;
+ pub const DOMAINNAME = 22;
+ pub const MAXPARTITIONS = 23;
+ pub const RAWPARTITION = 24;
+ pub const MAXTHREAD = 25;
+ pub const NTHREADS = 26;
+ pub const OSVERSION = 27;
+ pub const SOMAXCONN = 28;
+ pub const SOMINCONN = 29;
+
+ pub const NOSUIDCOREDUMP = 32;
+ pub const FSYNC = 33;
+ pub const SYSVMSG = 34;
+ pub const SYSVSEM = 35;
+ pub const SYSVSHM = 36;
+
+ pub const MSGBUFSIZE = 38;
+ pub const MALLOCSTATS = 39;
+ pub const CPTIME = 40;
+ pub const NCHSTATS = 41;
+ pub const FORKSTAT = 42;
+ pub const NSELCOLL = 43;
+ pub const TTY = 44;
+ pub const CCPU = 45;
+ pub const FSCALE = 46;
+ pub const NPROCS = 47;
+ pub const MSGBUF = 48;
+ pub const POOL = 49;
+ pub const STACKGAPRANDOM = 50;
+ pub const SYSVIPC_INFO = 51;
+ pub const ALLOWKMEM = 52;
+ pub const WITNESSWATCH = 53;
+ pub const SPLASSERT = 54;
+ pub const PROC_ARGS = 55;
+ pub const NFILES = 56;
+ pub const TTYCOUNT = 57;
+ pub const NUMVNODES = 58;
+ pub const MBSTAT = 59;
+ pub const WITNESS = 60;
+ pub const SEMINFO = 61;
+ pub const SHMINFO = 62;
+ pub const INTRCNT = 63;
+ pub const WATCHDOG = 64;
+ pub const ALLOWDT = 65;
+ pub const PROC = 66;
+ pub const MAXCLUSTERS = 67;
+ pub const EVCOUNT = 68;
+ pub const TIMECOUNTER = 69;
+ pub const MAXLOCKSPERUID = 70;
+ pub const CPTIME2 = 71;
+ pub const CACHEPCT = 72;
+ pub const FILE = 73;
+ pub const WXABORT = 74;
+ pub const CONSDEV = 75;
+ pub const NETLIVELOCKS = 76;
+ pub const POOL_DEBUG = 77;
+ pub const PROC_CWD = 78;
+ pub const PROC_NOBROADCASTKILL = 79;
+ pub const PROC_VMMAP = 80;
+ pub const GLOBAL_PTRACE = 81;
+ pub const CONSBUFSIZE = 82;
+ pub const CONSBUF = 83;
+ pub const AUDIO = 84;
+ pub const CPUSTATS = 85;
+ pub const PFSTATUS = 86;
+ pub const TIMEOUT_STATS = 87;
+ pub const UTC_OFFSET = 88;
+ pub const VIDEO = 89;
+
+ pub const PROC_ALL = 0;
+ pub const PROC_PID = 1;
+ pub const PROC_PGRP = 2;
+ pub const PROC_SESSION = 3;
+ pub const PROC_TTY = 4;
+ pub const PROC_UID = 5;
+ pub const PROC_RUID = 6;
+ pub const PROC_KTHREAD = 7;
+ pub const PROC_SHOW_THREADS = 0x40000000;
+
+ pub const PROC_ARGV = 1;
+ pub const PROC_NARGV = 2;
+ pub const PROC_ENV = 3;
+ pub const PROC_NENV = 4;
+};
+
+pub const HW_MACHINE = 1;
+pub const HW_MODEL = 2;
+pub const HW_NCPU = 3;
+pub const HW_BYTEORDER = 4;
+pub const HW_PHYSMEM = 5;
+pub const HW_USERMEM = 6;
+pub const HW_PAGESIZE = 7;
+pub const HW_DISKNAMES = 8;
+pub const HW_DISKSTATS = 9;
+pub const HW_DISKCOUNT = 10;
+pub const HW_SENSORS = 11;
+pub const HW_CPUSPEED = 12;
+pub const HW_SETPERF = 13;
+pub const HW_VENDOR = 14;
+pub const HW_PRODUCT = 15;
+pub const HW_VERSION = 16;
+pub const HW_SERIALNO = 17;
+pub const HW_UUID = 18;
+pub const HW_PHYSMEM64 = 19;
+pub const HW_USERMEM64 = 20;
+pub const HW_NCPUFOUND = 21;
+pub const HW_ALLOWPOWERDOWN = 22;
+pub const HW_PERFPOLICY = 23;
+pub const HW_SMT = 24;
+pub const HW_NCPUONLINE = 25;
diff --git a/lib/std/c/wasi.zig b/lib/std/c/wasi.zig
index 339bdcd127f5..d9fbed8e6d7a 100644
--- a/lib/std/c/wasi.zig
+++ b/lib/std/c/wasi.zig
@@ -1,4 +1,6 @@
-usingnamespace @import("../os/bits.zig");
+const std = @import("../std.zig");
+const wasi = std.os.wasi;
+const FDFLAG = wasi.FDFLAG;
extern threadlocal var errno: c_int;
@@ -6,12 +8,25 @@ pub fn _errno() *c_int {
return &errno;
}
+pub const fd_t = wasi.fd_t;
pub const pid_t = c_int;
pub const uid_t = u32;
pub const gid_t = u32;
pub const off_t = i64;
+pub const ino_t = wasi.ino_t;
+pub const mode_t = wasi.mode_t;
+pub const time_t = wasi.time_t;
+pub const timespec = wasi.timespec;
+pub const STDERR_FILENO = wasi.STDERR_FILENO;
+pub const STDIN_FILENO = wasi.STDIN_FILENO;
+pub const STDOUT_FILENO = wasi.STDOUT_FILENO;
+pub const E = wasi.E;
+pub const CLOCK = wasi.CLOCK;
+pub const S = wasi.S;
+pub const IOV_MAX = wasi.IOV_MAX;
+pub const AT = wasi.AT;
-pub const libc_stat = extern struct {
+pub const Stat = extern struct {
dev: i32,
ino: ino_t,
nlink: u64,
@@ -53,3 +68,33 @@ pub const libc_stat = extern struct {
};
}
};
+
+/// Derived from
+/// https://github.com/WebAssembly/wasi-libc/blob/main/expected/wasm32-wasi/predefined-macros.txt
+pub const O = struct {
+ pub const ACCMODE = (EXEC | RDWR | SEARCH);
+ pub const APPEND = FDFLAG.APPEND;
+ pub const CLOEXEC = (0);
+ pub const CREAT = ((1 << 0) << 12); // = __WASI_OFLAGS_CREAT << 12
+ pub const DIRECTORY = ((1 << 1) << 12); // = __WASI_OFLAGS_DIRECTORY << 12
+ pub const DSYNC = FDFLAG.DSYNC;
+ pub const EXCL = ((1 << 2) << 12); // = __WASI_OFLAGS_EXCL << 12
+ pub const EXEC = (0x02000000);
+ pub const NOCTTY = (0);
+ pub const NOFOLLOW = (0x01000000);
+ pub const NONBLOCK = (1 << FDFLAG.NONBLOCK);
+ pub const RDONLY = (0x04000000);
+ pub const RDWR = (RDONLY | WRONLY);
+ pub const RSYNC = (1 << FDFLAG.RSYNC);
+ pub const SEARCH = (0x08000000);
+ pub const SYNC = (1 << FDFLAG.SYNC);
+ pub const TRUNC = ((1 << 3) << 12); // = __WASI_OFLAGS_TRUNC << 12
+ pub const TTY_INIT = (0);
+ pub const WRONLY = (0x10000000);
+};
+
+pub const SEEK = struct {
+ pub const SET: wasi.whence_t = .SET;
+ pub const CUR: wasi.whence_t = .CUR;
+ pub const END: wasi.whence_t = .END;
+};
diff --git a/lib/std/c/windows.zig b/lib/std/c/windows.zig
index a10715f0830e..00cec5f5f736 100644
--- a/lib/std/c/windows.zig
+++ b/lib/std/c/windows.zig
@@ -1,3 +1,246 @@
+//! The reference for these types and values is Microsoft Windows's ucrt (Universal C RunTime).
+const std = @import("../std.zig");
+const ws2_32 = std.os.windows.ws2_32;
+const windows = std.os.windows;
+
pub extern "c" fn _errno() *c_int;
pub extern "c" fn _msize(memblock: ?*c_void) usize;
+
+// TODO: copied the else case and removed the socket function (because its in ws2_32)
+// need to verify which of these is actually supported on windows
+pub extern "c" fn clock_getres(clk_id: c_int, tp: *timespec) c_int;
+pub extern "c" fn clock_gettime(clk_id: c_int, tp: *timespec) c_int;
+pub extern "c" fn fstat(fd: fd_t, buf: *Stat) c_int;
+pub extern "c" fn getrusage(who: c_int, usage: *rusage) c_int;
+pub extern "c" fn gettimeofday(noalias tv: ?*timeval, noalias tz: ?*timezone) c_int;
+pub extern "c" fn nanosleep(rqtp: *const timespec, rmtp: ?*timespec) c_int;
+pub extern "c" fn sched_yield() c_int;
+pub extern "c" fn sigaction(sig: c_int, noalias act: ?*const Sigaction, noalias oact: ?*Sigaction) c_int;
+pub extern "c" fn sigprocmask(how: c_int, noalias set: ?*const sigset_t, noalias oset: ?*sigset_t) c_int;
+pub extern "c" fn stat(noalias path: [*:0]const u8, noalias buf: *Stat) c_int;
+pub extern "c" fn sigfillset(set: ?*sigset_t) void;
+pub extern "c" fn alarm(seconds: c_uint) c_uint;
+pub extern "c" fn sigwait(set: ?*sigset_t, sig: ?*c_int) c_int;
+
+pub const fd_t = windows.HANDLE;
+pub const ino_t = windows.LARGE_INTEGER;
+pub const pid_t = windows.HANDLE;
+pub const mode_t = u0;
+
+pub const PATH_MAX = 260;
+
+pub const time_t = c_longlong;
+
+pub const timespec = extern struct {
+ tv_sec: time_t,
+ tv_nsec: c_long,
+};
+
+pub const timeval = extern struct {
+ tv_sec: c_long,
+ tv_usec: c_long,
+};
+
+pub const Stat = @compileError("TODO windows Stat definition");
+
+pub const sig_atomic_t = c_int;
+
+pub const sigset_t = @compileError("TODO windows sigset_t definition");
+pub const Sigaction = @compileError("TODO windows Sigaction definition");
+pub const timezone = @compileError("TODO windows timezone definition");
+pub const rusage = @compileError("TODO windows rusage definition");
+
+/// maximum signal number + 1
+pub const NSIG = 23;
+
+/// Signal types
+pub const SIG = struct {
+ /// interrupt
+ pub const INT = 2;
+ /// illegal instruction - invalid function image
+ pub const ILL = 4;
+ /// floating point exception
+ pub const FPE = 8;
+ /// segment violation
+ pub const SEGV = 11;
+ /// Software termination signal from kill
+ pub const TERM = 15;
+ /// Ctrl-Break sequence
+ pub const BREAK = 21;
+ /// abnormal termination triggered by abort call
+ pub const ABRT = 22;
+ /// SIGABRT compatible with other platforms, same as SIGABRT
+ pub const ABRT_COMPAT = 6;
+
+ // Signal action codes
+ /// default signal action
+ pub const DFL = 0;
+ /// ignore signal
+ pub const IGN = 1;
+ /// return current value
+ pub const GET = 2;
+ /// signal gets error
+ pub const SGE = 3;
+ /// acknowledge
+ pub const ACK = 4;
+ /// Signal error value (returned by signal call on error)
+ pub const ERR = -1;
+};
+
+pub const SEEK = struct {
+ pub const SET = 0;
+ pub const CUR = 1;
+ pub const END = 2;
+};
+
+pub const E = enum(u16) {
+ /// No error occurred.
+ SUCCESS = 0,
+ PERM = 1,
+ NOENT = 2,
+ SRCH = 3,
+ INTR = 4,
+ IO = 5,
+ NXIO = 6,
+ @"2BIG" = 7,
+ NOEXEC = 8,
+ BADF = 9,
+ CHILD = 10,
+ AGAIN = 11,
+ NOMEM = 12,
+ ACCES = 13,
+ FAULT = 14,
+ BUSY = 16,
+ EXIST = 17,
+ XDEV = 18,
+ NODEV = 19,
+ NOTDIR = 20,
+ ISDIR = 21,
+ NFILE = 23,
+ MFILE = 24,
+ NOTTY = 25,
+ FBIG = 27,
+ NOSPC = 28,
+ SPIPE = 29,
+ ROFS = 30,
+ MLINK = 31,
+ PIPE = 32,
+ DOM = 33,
+ /// Also means `DEADLOCK`.
+ DEADLK = 36,
+ NAMETOOLONG = 38,
+ NOLCK = 39,
+ NOSYS = 40,
+ NOTEMPTY = 41,
+
+ INVAL = 22,
+ RANGE = 34,
+ ILSEQ = 42,
+
+ // POSIX Supplement
+ ADDRINUSE = 100,
+ ADDRNOTAVAIL = 101,
+ AFNOSUPPORT = 102,
+ ALREADY = 103,
+ BADMSG = 104,
+ CANCELED = 105,
+ CONNABORTED = 106,
+ CONNREFUSED = 107,
+ CONNRESET = 108,
+ DESTADDRREQ = 109,
+ HOSTUNREACH = 110,
+ IDRM = 111,
+ INPROGRESS = 112,
+ ISCONN = 113,
+ LOOP = 114,
+ MSGSIZE = 115,
+ NETDOWN = 116,
+ NETRESET = 117,
+ NETUNREACH = 118,
+ NOBUFS = 119,
+ NODATA = 120,
+ NOLINK = 121,
+ NOMSG = 122,
+ NOPROTOOPT = 123,
+ NOSR = 124,
+ NOSTR = 125,
+ NOTCONN = 126,
+ NOTRECOVERABLE = 127,
+ NOTSOCK = 128,
+ NOTSUP = 129,
+ OPNOTSUPP = 130,
+ OTHER = 131,
+ OVERFLOW = 132,
+ OWNERDEAD = 133,
+ PROTO = 134,
+ PROTONOSUPPORT = 135,
+ PROTOTYPE = 136,
+ TIME = 137,
+ TIMEDOUT = 138,
+ TXTBSY = 139,
+ WOULDBLOCK = 140,
+ DQUOT = 10069,
+ _,
+};
+
+pub const STRUNCATE = 80;
+
+pub const F_OK = 0;
+
+/// Remove directory instead of unlinking file
+pub const AT = struct {
+ pub const REMOVEDIR = 0x200;
+};
+
+pub const in_port_t = u16;
+pub const sa_family_t = ws2_32.ADDRESS_FAMILY;
+pub const socklen_t = ws2_32.socklen_t;
+
+pub const sockaddr = ws2_32.sockaddr;
+
+pub const in6_addr = [16]u8;
+pub const in_addr = u32;
+
+pub const addrinfo = ws2_32.addrinfo;
+pub const AF = ws2_32.AF;
+pub const SOCK = ws2_32.SOCK;
+pub const IPPROTO = ws2_32.IPPROTO;
+pub const BTHPROTO_RFCOMM = ws2_32.BTHPROTO_RFCOMM;
+
+pub const nfds_t = c_ulong;
+pub const pollfd = ws2_32.pollfd;
+pub const POLL = ws2_32.POLL;
+pub const SOL = ws2_32.SOL;
+pub const SO = ws2_32.SO;
+pub const PVD_CONFIG = ws2_32.PVD_CONFIG;
+pub const TCP_NODELAY = ws2_32.TCP_NODELAY;
+
+pub const O = struct {
+ pub const RDONLY = 0o0;
+ pub const WRONLY = 0o1;
+ pub const RDWR = 0o2;
+
+ pub const CREAT = 0o100;
+ pub const EXCL = 0o200;
+ pub const NOCTTY = 0o400;
+ pub const TRUNC = 0o1000;
+ pub const APPEND = 0o2000;
+ pub const NONBLOCK = 0o4000;
+ pub const DSYNC = 0o10000;
+ pub const SYNC = 0o4010000;
+ pub const RSYNC = 0o4010000;
+ pub const DIRECTORY = 0o200000;
+ pub const NOFOLLOW = 0o400000;
+ pub const CLOEXEC = 0o2000000;
+
+ pub const ASYNC = 0o20000;
+ pub const DIRECT = 0o40000;
+ pub const LARGEFILE = 0;
+ pub const NOATIME = 0o1000000;
+ pub const PATH = 0o10000000;
+ pub const TMPFILE = 0o20200000;
+ pub const NDELAY = NONBLOCK;
+};
+
+pub const IFNAMESIZE = 30;
diff --git a/lib/std/child_process.zig b/lib/std/child_process.zig
index 7d8881a67995..b68d10d1c427 100644
--- a/lib/std/child_process.zig
+++ b/lib/std/child_process.zig
@@ -7,6 +7,7 @@ const os = std.os;
const process = std.process;
const File = std.fs.File;
const windows = os.windows;
+const linux = os.linux;
const mem = std.mem;
const math = std.math;
const debug = std.debug;
@@ -189,8 +190,8 @@ pub const ChildProcess = struct {
max_output_bytes: usize,
) !void {
var poll_fds = [_]os.pollfd{
- .{ .fd = child.stdout.?.handle, .events = os.POLLIN, .revents = undefined },
- .{ .fd = child.stderr.?.handle, .events = os.POLLIN, .revents = undefined },
+ .{ .fd = child.stdout.?.handle, .events = os.POLL.IN, .revents = undefined },
+ .{ .fd = child.stderr.?.handle, .events = os.POLL.IN, .revents = undefined },
};
var dead_fds: usize = 0;
@@ -199,7 +200,7 @@ pub const ChildProcess = struct {
// of space an ArrayList will allocate grows exponentially.
const bump_amt = 512;
- const err_mask = os.POLLERR | os.POLLNVAL | os.POLLHUP;
+ const err_mask = os.POLL.ERR | os.POLL.NVAL | os.POLL.HUP;
while (dead_fds < poll_fds.len) {
const events = try os.poll(&poll_fds, std.math.maxInt(i32));
@@ -209,9 +210,9 @@ pub const ChildProcess = struct {
var remove_stderr = false;
// Try reading whatever is available before checking the error
// conditions.
- // It's still possible to read after a POLLHUP is received, always
+ // It's still possible to read after a POLL.HUP is received, always
// check if there's some data waiting to be read first.
- if (poll_fds[0].revents & os.POLLIN != 0) {
+ if (poll_fds[0].revents & os.POLL.IN != 0) {
// stdout is ready.
const new_capacity = std.math.min(stdout.items.len + bump_amt, max_output_bytes);
try stdout.ensureCapacity(new_capacity);
@@ -226,7 +227,7 @@ pub const ChildProcess = struct {
remove_stdout = poll_fds[0].revents & err_mask != 0;
}
- if (poll_fds[1].revents & os.POLLIN != 0) {
+ if (poll_fds[1].revents & os.POLL.IN != 0) {
// stderr is ready.
const new_capacity = std.math.min(stderr.items.len + bump_amt, max_output_bytes);
try stderr.ensureCapacity(new_capacity);
@@ -461,7 +462,7 @@ pub const ChildProcess = struct {
if (builtin.os.tag == .linux) {
var fd = [1]std.os.pollfd{std.os.pollfd{
.fd = self.err_pipe[0],
- .events = std.os.POLLIN,
+ .events = std.os.POLL.IN,
.revents = undefined,
}};
@@ -471,7 +472,7 @@ pub const ChildProcess = struct {
// According to eventfd(2) the descriptro is readable if the counter
// has a value greater than 0
- if ((fd[0].revents & std.os.POLLIN) != 0) {
+ if ((fd[0].revents & std.os.POLL.IN) != 0) {
const err_int = try readIntFd(self.err_pipe[0]);
return @errSetCast(SpawnError, @intToError(err_int));
}
@@ -494,18 +495,18 @@ pub const ChildProcess = struct {
}
fn statusToTerm(status: u32) Term {
- return if (os.WIFEXITED(status))
- Term{ .Exited = os.WEXITSTATUS(status) }
- else if (os.WIFSIGNALED(status))
- Term{ .Signal = os.WTERMSIG(status) }
- else if (os.WIFSTOPPED(status))
- Term{ .Stopped = os.WSTOPSIG(status) }
+ return if (os.W.IFEXITED(status))
+ Term{ .Exited = os.W.EXITSTATUS(status) }
+ else if (os.W.IFSIGNALED(status))
+ Term{ .Signal = os.W.TERMSIG(status) }
+ else if (os.W.IFSTOPPED(status))
+ Term{ .Stopped = os.W.STOPSIG(status) }
else
Term{ .Unknown = status };
}
fn spawnPosix(self: *ChildProcess) SpawnError!void {
- const pipe_flags = if (io.is_async) os.O_NONBLOCK else 0;
+ const pipe_flags = if (io.is_async) os.O.NONBLOCK else 0;
const stdin_pipe = if (self.stdin_behavior == StdIo.Pipe) try os.pipe2(pipe_flags) else undefined;
errdefer if (self.stdin_behavior == StdIo.Pipe) {
destroyPipe(stdin_pipe);
@@ -523,7 +524,7 @@ pub const ChildProcess = struct {
const any_ignore = (self.stdin_behavior == StdIo.Ignore or self.stdout_behavior == StdIo.Ignore or self.stderr_behavior == StdIo.Ignore);
const dev_null_fd = if (any_ignore)
- os.openZ("/dev/null", os.O_RDWR, 0) catch |err| switch (err) {
+ os.openZ("/dev/null", os.O.RDWR, 0) catch |err| switch (err) {
error.PathAlreadyExists => unreachable,
error.NoSpaceLeft => unreachable,
error.FileTooBig => unreachable,
@@ -575,12 +576,12 @@ pub const ChildProcess = struct {
// and execve from the child process to the parent process.
const err_pipe = blk: {
if (builtin.os.tag == .linux) {
- const fd = try os.eventfd(0, os.EFD_CLOEXEC);
+ const fd = try os.eventfd(0, linux.EFD.CLOEXEC);
// There's no distinction between the readable and the writeable
// end with eventfd
break :blk [2]os.fd_t{ fd, fd };
} else {
- break :blk try os.pipe2(os.O_CLOEXEC);
+ break :blk try os.pipe2(os.O.CLOEXEC);
}
};
errdefer destroyPipe(err_pipe);
diff --git a/lib/std/crypto/25519/curve25519.zig b/lib/std/crypto/25519/curve25519.zig
index 44a19362e4e3..20b0dccaa01a 100644
--- a/lib/std/crypto/25519/curve25519.zig
+++ b/lib/std/crypto/25519/curve25519.zig
@@ -40,9 +40,7 @@ pub const Curve25519 = struct {
}
/// Multiply a point by the cofactor
- pub fn clearCofactor(p: Edwards25519) Edwards25519 {
- return p.dbl().dbl().dbl();
- }
+ pub const clearCofactor = @compileError("TODO what was this function supposed to do? it didn't compile successfully");
fn ladder(p: Curve25519, s: [32]u8, comptime bits: usize) IdentityElementError!Curve25519 {
var x1 = p.x;
diff --git a/lib/std/crypto/scrypt.zig b/lib/std/crypto/scrypt.zig
index 5dcba41531d6..89c5d6d7733b 100644
--- a/lib/std/crypto/scrypt.zig
+++ b/lib/std/crypto/scrypt.zig
@@ -523,7 +523,12 @@ pub fn strVerify(
}
}
-test "scrypt kdf" {
+// These tests take way too long to run, so I have disabled them.
+const run_long_tests = false;
+
+test "kdf" {
+ if (!run_long_tests) return error.SkipZigTest;
+
const password = "testpass";
const salt = "saltsalt";
@@ -537,7 +542,9 @@ test "scrypt kdf" {
try std.testing.expectEqualSlices(u8, &bytes, &dk);
}
-test "scrypt kdf rfc 1" {
+test "kdf rfc 1" {
+ if (!run_long_tests) return error.SkipZigTest;
+
const password = "";
const salt = "";
@@ -551,7 +558,9 @@ test "scrypt kdf rfc 1" {
try std.testing.expectEqualSlices(u8, &bytes, &dk);
}
-test "scrypt kdf rfc 2" {
+test "kdf rfc 2" {
+ if (!run_long_tests) return error.SkipZigTest;
+
const password = "password";
const salt = "NaCl";
@@ -565,7 +574,9 @@ test "scrypt kdf rfc 2" {
try std.testing.expectEqualSlices(u8, &bytes, &dk);
}
-test "scrypt kdf rfc 3" {
+test "kdf rfc 3" {
+ if (!run_long_tests) return error.SkipZigTest;
+
const password = "pleaseletmein";
const salt = "SodiumChloride";
@@ -579,11 +590,8 @@ test "scrypt kdf rfc 3" {
try std.testing.expectEqualSlices(u8, &bytes, &dk);
}
-test "scrypt kdf rfc 4" {
- // skip slow test
- if (true) {
- return error.SkipZigTest;
- }
+test "kdf rfc 4" {
+ if (!run_long_tests) return error.SkipZigTest;
const password = "pleaseletmein";
const salt = "SodiumChloride";
@@ -598,7 +606,9 @@ test "scrypt kdf rfc 4" {
try std.testing.expectEqualSlices(u8, &bytes, &dk);
}
-test "scrypt password hashing (crypt format)" {
+test "password hashing (crypt format)" {
+ if (!run_long_tests) return error.SkipZigTest;
+
const str = "$7$A6....1....TrXs5Zk6s8sWHpQgWDIXTR8kUU3s6Jc3s.DtdS8M2i4$a4ik5hGDN7foMuHOW.cp.CtX01UyCeO0.JAG.AHPpx5";
const password = "Y0!?iQa9M%5ekffW(`";
try CryptFormatHasher.verify(std.testing.allocator, str, password);
@@ -609,7 +619,9 @@ test "scrypt password hashing (crypt format)" {
try CryptFormatHasher.verify(std.testing.allocator, str2, password);
}
-test "scrypt strHash and strVerify" {
+test "strHash and strVerify" {
+ if (!run_long_tests) return error.SkipZigTest;
+
const alloc = std.testing.allocator;
const password = "testpass";
@@ -631,7 +643,9 @@ test "scrypt strHash and strVerify" {
try strVerify(s1, password, verify_options);
}
-test "scrypt unix-scrypt" {
+test "unix-scrypt" {
+ if (!run_long_tests) return error.SkipZigTest;
+
const alloc = std.testing.allocator;
// https://gitlab.com/jas/scrypt-unix-crypt/blob/master/unix-scrypt.txt
@@ -648,7 +662,7 @@ test "scrypt unix-scrypt" {
}
}
-test "scrypt crypt format" {
+test "crypt format" {
const str = "$7$C6..../....SodiumChloride$kBGj9fHznVYFQMEn/qDCfrDevf9YDtcDdKvEqHJLV8D";
const params = try crypt_format.deserialize(crypt_format.HashResult(32), str);
var buf: [str.len]u8 = undefined;
diff --git a/lib/std/crypto/tlcsprng.zig b/lib/std/crypto/tlcsprng.zig
index 46960cc0907a..d72262da53d3 100644
--- a/lib/std/crypto/tlcsprng.zig
+++ b/lib/std/crypto/tlcsprng.zig
@@ -74,8 +74,8 @@ fn tlsCsprngFill(_: *const std.rand.Random, buffer: []u8) void {
wipe_mem = os.mmap(
null,
@sizeOf(Context),
- os.PROT_READ | os.PROT_WRITE,
- os.MAP_PRIVATE | os.MAP_ANONYMOUS,
+ os.PROT.READ | os.PROT.WRITE,
+ os.MAP.PRIVATE | os.MAP.ANONYMOUS,
-1,
0,
) catch {
@@ -111,7 +111,7 @@ fn tlsCsprngFill(_: *const std.rand.Random, buffer: []u8) void {
break :wof;
} else |_| {}
- if (os.madvise(wipe_mem.ptr, wipe_mem.len, os.MADV_WIPEONFORK)) |_| {
+ if (os.madvise(wipe_mem.ptr, wipe_mem.len, os.MADV.WIPEONFORK)) |_| {
return initAndFill(buffer);
} else |_| {}
}
diff --git a/lib/std/debug.zig b/lib/std/debug.zig
index 4b715f2b1421..8517703566a1 100644
--- a/lib/std/debug.zig
+++ b/lib/std/debug.zig
@@ -948,8 +948,8 @@ fn mapWholeFile(file: File) ![]align(mem.page_size) const u8 {
const mapped_mem = try os.mmap(
null,
file_len,
- os.PROT_READ,
- os.MAP_SHARED,
+ os.PROT.READ,
+ os.MAP.SHARED,
file.handle,
0,
);
@@ -1341,7 +1341,7 @@ pub const ModuleDebugInfo = switch (native_os) {
if (o_file_di.findCompileUnit(relocated_address_o)) |compile_unit| {
return SymbolInfo{
.symbol_name = o_file_di.getSymbolName(relocated_address_o) orelse "???",
- .compile_unit_name = compile_unit.die.getAttrString(&o_file_di, DW.AT_name) catch |err| switch (err) {
+ .compile_unit_name = compile_unit.die.getAttrString(&o_file_di, DW.AT.name) catch |err| switch (err) {
error.MissingDebugInfo, error.InvalidDebugInfo => "???",
else => return err,
},
@@ -1438,7 +1438,7 @@ fn getSymbolFromDwarf(address: u64, di: *DW.DwarfInfo) !SymbolInfo {
if (nosuspend di.findCompileUnit(address)) |compile_unit| {
return SymbolInfo{
.symbol_name = nosuspend di.getSymbolName(address) orelse "???",
- .compile_unit_name = compile_unit.die.getAttrString(di, DW.AT_name) catch |err| switch (err) {
+ .compile_unit_name = compile_unit.die.getAttrString(di, DW.AT.name) catch |err| switch (err) {
error.MissingDebugInfo, error.InvalidDebugInfo => "???",
else => return err,
},
@@ -1470,7 +1470,7 @@ fn getDebugInfoAllocator() *mem.Allocator {
pub const have_segfault_handling_support = switch (native_os) {
.linux, .netbsd => true,
.windows => true,
- .freebsd, .openbsd => @hasDecl(os, "ucontext_t"),
+ .freebsd, .openbsd => @hasDecl(os.system, "ucontext_t"),
else => false,
};
pub const enable_segfault_handler: bool = if (@hasDecl(root, "enable_segfault_handler"))
@@ -1498,12 +1498,12 @@ pub fn attachSegfaultHandler() void {
var act = os.Sigaction{
.handler = .{ .sigaction = handleSegfaultLinux },
.mask = os.empty_sigset,
- .flags = (os.SA_SIGINFO | os.SA_RESTART | os.SA_RESETHAND),
+ .flags = (os.SA.SIGINFO | os.SA.RESTART | os.SA.RESETHAND),
};
- os.sigaction(os.SIGSEGV, &act, null);
- os.sigaction(os.SIGILL, &act, null);
- os.sigaction(os.SIGBUS, &act, null);
+ os.sigaction(os.SIG.SEGV, &act, null);
+ os.sigaction(os.SIG.ILL, &act, null);
+ os.sigaction(os.SIG.BUS, &act, null);
}
fn resetSegfaultHandler() void {
@@ -1515,13 +1515,13 @@ fn resetSegfaultHandler() void {
return;
}
var act = os.Sigaction{
- .handler = .{ .sigaction = os.SIG_DFL },
+ .handler = .{ .sigaction = os.SIG.DFL },
.mask = os.empty_sigset,
.flags = 0,
};
- os.sigaction(os.SIGSEGV, &act, null);
- os.sigaction(os.SIGILL, &act, null);
- os.sigaction(os.SIGBUS, &act, null);
+ os.sigaction(os.SIG.SEGV, &act, null);
+ os.sigaction(os.SIG.ILL, &act, null);
+ os.sigaction(os.SIG.BUS, &act, null);
}
fn handleSegfaultLinux(sig: i32, info: *const os.siginfo_t, ctx_ptr: ?*const c_void) callconv(.C) noreturn {
@@ -1542,9 +1542,9 @@ fn handleSegfaultLinux(sig: i32, info: *const os.siginfo_t, ctx_ptr: ?*const c_v
nosuspend {
const stderr = io.getStdErr().writer();
_ = switch (sig) {
- os.SIGSEGV => stderr.print("Segmentation fault at address 0x{x}\n", .{addr}),
- os.SIGILL => stderr.print("Illegal instruction at address 0x{x}\n", .{addr}),
- os.SIGBUS => stderr.print("Bus error at address 0x{x}\n", .{addr}),
+ os.SIG.SEGV => stderr.print("Segmentation fault at address 0x{x}\n", .{addr}),
+ os.SIG.ILL => stderr.print("Illegal instruction at address 0x{x}\n", .{addr}),
+ os.SIG.BUS => stderr.print("Bus error at address 0x{x}\n", .{addr}),
else => unreachable,
} catch os.abort();
}
@@ -1552,20 +1552,20 @@ fn handleSegfaultLinux(sig: i32, info: *const os.siginfo_t, ctx_ptr: ?*const c_v
switch (native_arch) {
.i386 => {
const ctx = @ptrCast(*const os.ucontext_t, @alignCast(@alignOf(os.ucontext_t), ctx_ptr));
- const ip = @intCast(usize, ctx.mcontext.gregs[os.REG_EIP]);
- const bp = @intCast(usize, ctx.mcontext.gregs[os.REG_EBP]);
+ const ip = @intCast(usize, ctx.mcontext.gregs[os.REG.EIP]);
+ const bp = @intCast(usize, ctx.mcontext.gregs[os.REG.EBP]);
dumpStackTraceFromBase(bp, ip);
},
.x86_64 => {
const ctx = @ptrCast(*const os.ucontext_t, @alignCast(@alignOf(os.ucontext_t), ctx_ptr));
const ip = switch (native_os) {
- .linux, .netbsd => @intCast(usize, ctx.mcontext.gregs[os.REG_RIP]),
+ .linux, .netbsd => @intCast(usize, ctx.mcontext.gregs[os.REG.RIP]),
.freebsd => @intCast(usize, ctx.mcontext.rip),
.openbsd => @intCast(usize, ctx.sc_rip),
else => unreachable,
};
const bp = switch (native_os) {
- .linux, .netbsd => @intCast(usize, ctx.mcontext.gregs[os.REG_RBP]),
+ .linux, .netbsd => @intCast(usize, ctx.mcontext.gregs[os.REG.RBP]),
.openbsd => @intCast(usize, ctx.sc_rbp),
.freebsd => @intCast(usize, ctx.mcontext.rbp),
else => unreachable,
diff --git a/lib/std/dwarf.zig b/lib/std/dwarf.zig
index 3a294c2dd362..8f14f88e2e33 100644
--- a/lib/std/dwarf.zig
+++ b/lib/std/dwarf.zig
@@ -9,7 +9,223 @@ const leb = @import("leb128.zig");
const ArrayList = std.ArrayList;
-pub usingnamespace @import("dwarf_bits.zig");
+pub const TAG = @import("dwarf/TAG.zig");
+pub const AT = @import("dwarf/AT.zig");
+pub const OP = @import("dwarf/OP.zig");
+
+pub const FORM = struct {
+ pub const addr = 0x01;
+ pub const block2 = 0x03;
+ pub const block4 = 0x04;
+ pub const data2 = 0x05;
+ pub const data4 = 0x06;
+ pub const data8 = 0x07;
+ pub const string = 0x08;
+ pub const block = 0x09;
+ pub const block1 = 0x0a;
+ pub const data1 = 0x0b;
+ pub const flag = 0x0c;
+ pub const sdata = 0x0d;
+ pub const strp = 0x0e;
+ pub const udata = 0x0f;
+ pub const ref_addr = 0x10;
+ pub const ref1 = 0x11;
+ pub const ref2 = 0x12;
+ pub const ref4 = 0x13;
+ pub const ref8 = 0x14;
+ pub const ref_udata = 0x15;
+ pub const indirect = 0x16;
+ pub const sec_offset = 0x17;
+ pub const exprloc = 0x18;
+ pub const flag_present = 0x19;
+ pub const ref_sig8 = 0x20;
+
+ // Extensions for Fission. See http://gcc.gnu.org/wiki/DebugFission.
+ pub const GNU_addr_index = 0x1f01;
+ pub const GNU_str_index = 0x1f02;
+
+ // Extensions for DWZ multifile.
+ // See http://www.dwarfstd.org/ShowIssue.php?issue=120604.1&type=open .
+ pub const GNU_ref_alt = 0x1f20;
+ pub const GNU_strp_alt = 0x1f21;
+};
+
+pub const ATE = struct {
+ pub const @"void" = 0x0;
+ pub const address = 0x1;
+ pub const boolean = 0x2;
+ pub const complex_float = 0x3;
+ pub const float = 0x4;
+ pub const signed = 0x5;
+ pub const signed_char = 0x6;
+ pub const unsigned = 0x7;
+ pub const unsigned_char = 0x8;
+
+ // DWARF 3.
+ pub const imaginary_float = 0x9;
+ pub const packed_decimal = 0xa;
+ pub const numeric_string = 0xb;
+ pub const edited = 0xc;
+ pub const signed_fixed = 0xd;
+ pub const unsigned_fixed = 0xe;
+ pub const decimal_float = 0xf;
+
+ // DWARF 4.
+ pub const UTF = 0x10;
+
+ pub const lo_user = 0x80;
+ pub const hi_user = 0xff;
+
+ // HP extensions.
+ pub const HP_float80 = 0x80; // Floating-point (80 bit).
+ pub const HP_complex_float80 = 0x81; // Complex floating-point (80 bit).
+ pub const HP_float128 = 0x82; // Floating-point (128 bit).
+ pub const HP_complex_float128 = 0x83; // Complex fp (128 bit).
+ pub const HP_floathpintel = 0x84; // Floating-point (82 bit IA64).
+ pub const HP_imaginary_float80 = 0x85;
+ pub const HP_imaginary_float128 = 0x86;
+ pub const HP_VAX_float = 0x88; // F or G floating.
+ pub const HP_VAX_float_d = 0x89; // D floating.
+ pub const HP_packed_decimal = 0x8a; // Cobol.
+ pub const HP_zoned_decimal = 0x8b; // Cobol.
+ pub const HP_edited = 0x8c; // Cobol.
+ pub const HP_signed_fixed = 0x8d; // Cobol.
+ pub const HP_unsigned_fixed = 0x8e; // Cobol.
+ pub const HP_VAX_complex_float = 0x8f; // F or G floating complex.
+ pub const HP_VAX_complex_float_d = 0x90; // D floating complex.
+};
+
+pub const CFA = struct {
+ pub const advance_loc = 0x40;
+ pub const offset = 0x80;
+ pub const restore = 0xc0;
+ pub const nop = 0x00;
+ pub const set_loc = 0x01;
+ pub const advance_loc1 = 0x02;
+ pub const advance_loc2 = 0x03;
+ pub const advance_loc4 = 0x04;
+ pub const offset_extended = 0x05;
+ pub const restore_extended = 0x06;
+ pub const @"undefined" = 0x07;
+ pub const same_value = 0x08;
+ pub const register = 0x09;
+ pub const remember_state = 0x0a;
+ pub const restore_state = 0x0b;
+ pub const def_cfa = 0x0c;
+ pub const def_cfa_register = 0x0d;
+ pub const def_cfa_offset = 0x0e;
+
+ // DWARF 3.
+ pub const def_cfa_expression = 0x0f;
+ pub const expression = 0x10;
+ pub const offset_extended_sf = 0x11;
+ pub const def_cfa_sf = 0x12;
+ pub const def_cfa_offset_sf = 0x13;
+ pub const val_offset = 0x14;
+ pub const val_offset_sf = 0x15;
+ pub const val_expression = 0x16;
+
+ pub const lo_user = 0x1c;
+ pub const hi_user = 0x3f;
+
+ // SGI/MIPS specific.
+ pub const MIPS_advance_loc8 = 0x1d;
+
+ // GNU extensions.
+ pub const GNU_window_save = 0x2d;
+ pub const GNU_args_size = 0x2e;
+ pub const GNU_negative_offset_extended = 0x2f;
+};
+
+pub const CHILDREN = struct {
+ pub const no = 0x00;
+ pub const yes = 0x01;
+};
+
+pub const LNS = struct {
+ pub const extended_op = 0x00;
+ pub const copy = 0x01;
+ pub const advance_pc = 0x02;
+ pub const advance_line = 0x03;
+ pub const set_file = 0x04;
+ pub const set_column = 0x05;
+ pub const negate_stmt = 0x06;
+ pub const set_basic_block = 0x07;
+ pub const const_add_pc = 0x08;
+ pub const fixed_advance_pc = 0x09;
+ pub const set_prologue_end = 0x0a;
+ pub const set_epilogue_begin = 0x0b;
+ pub const set_isa = 0x0c;
+};
+
+pub const LNE = struct {
+ pub const end_sequence = 0x01;
+ pub const set_address = 0x02;
+ pub const define_file = 0x03;
+ pub const set_discriminator = 0x04;
+ pub const lo_user = 0x80;
+ pub const hi_user = 0xff;
+};
+
+pub const LANG = struct {
+ pub const C89 = 0x0001;
+ pub const C = 0x0002;
+ pub const Ada83 = 0x0003;
+ pub const C_plus_plus = 0x0004;
+ pub const Cobol74 = 0x0005;
+ pub const Cobol85 = 0x0006;
+ pub const Fortran77 = 0x0007;
+ pub const Fortran90 = 0x0008;
+ pub const Pascal83 = 0x0009;
+ pub const Modula2 = 0x000a;
+ pub const Java = 0x000b;
+ pub const C99 = 0x000c;
+ pub const Ada95 = 0x000d;
+ pub const Fortran95 = 0x000e;
+ pub const PLI = 0x000f;
+ pub const ObjC = 0x0010;
+ pub const ObjC_plus_plus = 0x0011;
+ pub const UPC = 0x0012;
+ pub const D = 0x0013;
+ pub const Python = 0x0014;
+ pub const Go = 0x0016;
+ pub const C_plus_plus_11 = 0x001a;
+ pub const Rust = 0x001c;
+ pub const C11 = 0x001d;
+ pub const C_plus_plus_14 = 0x0021;
+ pub const Fortran03 = 0x0022;
+ pub const Fortran08 = 0x0023;
+ pub const lo_user = 0x8000;
+ pub const hi_user = 0xffff;
+ pub const Mips_Assembler = 0x8001;
+ pub const Upc = 0x8765;
+ pub const HP_Bliss = 0x8003;
+ pub const HP_Basic91 = 0x8004;
+ pub const HP_Pascal91 = 0x8005;
+ pub const HP_IMacro = 0x8006;
+ pub const HP_Assembler = 0x8007;
+};
+
+pub const UT = struct {
+ pub const compile = 0x01;
+ pub const @"type" = 0x02;
+ pub const partial = 0x03;
+ pub const skeleton = 0x04;
+ pub const split_compile = 0x05;
+ pub const split_type = 0x06;
+ pub const lo_user = 0x80;
+ pub const hi_user = 0xff;
+};
+
+pub const LNCT = struct {
+ pub const path = 0x1;
+ pub const directory_index = 0x2;
+ pub const timestamp = 0x3;
+ pub const size = 0x4;
+ pub const MD5 = 0x5;
+ pub const lo_user = 0x2000;
+ pub const hi_user = 0x3fff;
+};
const PcRange = struct {
start: u64,
@@ -322,43 +538,43 @@ fn parseFormValueRef(allocator: *mem.Allocator, in_stream: anytype, endian: buil
// TODO the nosuspends here are workarounds
fn parseFormValue(allocator: *mem.Allocator, in_stream: anytype, form_id: u64, endian: builtin.Endian, is_64: bool) anyerror!FormValue {
return switch (form_id) {
- FORM_addr => FormValue{ .Address = try readAddress(in_stream, endian, @sizeOf(usize) == 8) },
- FORM_block1 => parseFormValueBlock(allocator, in_stream, endian, 1),
- FORM_block2 => parseFormValueBlock(allocator, in_stream, endian, 2),
- FORM_block4 => parseFormValueBlock(allocator, in_stream, endian, 4),
- FORM_block => {
+ FORM.addr => FormValue{ .Address = try readAddress(in_stream, endian, @sizeOf(usize) == 8) },
+ FORM.block1 => parseFormValueBlock(allocator, in_stream, endian, 1),
+ FORM.block2 => parseFormValueBlock(allocator, in_stream, endian, 2),
+ FORM.block4 => parseFormValueBlock(allocator, in_stream, endian, 4),
+ FORM.block => {
const block_len = try nosuspend leb.readULEB128(usize, in_stream);
return parseFormValueBlockLen(allocator, in_stream, block_len);
},
- FORM_data1 => parseFormValueConstant(allocator, in_stream, false, endian, 1),
- FORM_data2 => parseFormValueConstant(allocator, in_stream, false, endian, 2),
- FORM_data4 => parseFormValueConstant(allocator, in_stream, false, endian, 4),
- FORM_data8 => parseFormValueConstant(allocator, in_stream, false, endian, 8),
- FORM_udata, FORM_sdata => {
- const signed = form_id == FORM_sdata;
+ FORM.data1 => parseFormValueConstant(allocator, in_stream, false, endian, 1),
+ FORM.data2 => parseFormValueConstant(allocator, in_stream, false, endian, 2),
+ FORM.data4 => parseFormValueConstant(allocator, in_stream, false, endian, 4),
+ FORM.data8 => parseFormValueConstant(allocator, in_stream, false, endian, 8),
+ FORM.udata, FORM.sdata => {
+ const signed = form_id == FORM.sdata;
return parseFormValueConstant(allocator, in_stream, signed, endian, -1);
},
- FORM_exprloc => {
+ FORM.exprloc => {
const size = try nosuspend leb.readULEB128(usize, in_stream);
const buf = try readAllocBytes(allocator, in_stream, size);
return FormValue{ .ExprLoc = buf };
},
- FORM_flag => FormValue{ .Flag = (try nosuspend in_stream.readByte()) != 0 },
- FORM_flag_present => FormValue{ .Flag = true },
- FORM_sec_offset => FormValue{ .SecOffset = try readAddress(in_stream, endian, is_64) },
-
- FORM_ref1 => parseFormValueRef(allocator, in_stream, endian, 1),
- FORM_ref2 => parseFormValueRef(allocator, in_stream, endian, 2),
- FORM_ref4 => parseFormValueRef(allocator, in_stream, endian, 4),
- FORM_ref8 => parseFormValueRef(allocator, in_stream, endian, 8),
- FORM_ref_udata => parseFormValueRef(allocator, in_stream, endian, -1),
-
- FORM_ref_addr => FormValue{ .RefAddr = try readAddress(in_stream, endian, is_64) },
- FORM_ref_sig8 => FormValue{ .Ref = try nosuspend in_stream.readInt(u64, endian) },
-
- FORM_string => FormValue{ .String = try in_stream.readUntilDelimiterAlloc(allocator, 0, math.maxInt(usize)) },
- FORM_strp => FormValue{ .StrPtr = try readAddress(in_stream, endian, is_64) },
- FORM_indirect => {
+ FORM.flag => FormValue{ .Flag = (try nosuspend in_stream.readByte()) != 0 },
+ FORM.flag_present => FormValue{ .Flag = true },
+ FORM.sec_offset => FormValue{ .SecOffset = try readAddress(in_stream, endian, is_64) },
+
+ FORM.ref1 => parseFormValueRef(allocator, in_stream, endian, 1),
+ FORM.ref2 => parseFormValueRef(allocator, in_stream, endian, 2),
+ FORM.ref4 => parseFormValueRef(allocator, in_stream, endian, 4),
+ FORM.ref8 => parseFormValueRef(allocator, in_stream, endian, 8),
+ FORM.ref_udata => parseFormValueRef(allocator, in_stream, endian, -1),
+
+ FORM.ref_addr => FormValue{ .RefAddr = try readAddress(in_stream, endian, is_64) },
+ FORM.ref_sig8 => FormValue{ .Ref = try nosuspend in_stream.readInt(u64, endian) },
+
+ FORM.string => FormValue{ .String = try in_stream.readUntilDelimiterAlloc(allocator, 0, math.maxInt(usize)) },
+ FORM.strp => FormValue{ .StrPtr = try readAddress(in_stream, endian, is_64) },
+ FORM.indirect => {
const child_form_id = try nosuspend leb.readULEB128(u64, in_stream);
const F = @TypeOf(async parseFormValue(allocator, in_stream, child_form_id, endian, is_64));
var frame = try allocator.create(F);
@@ -441,24 +657,24 @@ pub const DwarfInfo = struct {
const after_die_offset = try seekable.getPos();
switch (die_obj.tag_id) {
- TAG_subprogram, TAG_inlined_subroutine, TAG_subroutine, TAG_entry_point => {
+ TAG.subprogram, TAG.inlined_subroutine, TAG.subroutine, TAG.entry_point => {
const fn_name = x: {
var depth: i32 = 3;
var this_die_obj = die_obj;
// Prenvent endless loops
while (depth > 0) : (depth -= 1) {
- if (this_die_obj.getAttr(AT_name)) |_| {
- const name = try this_die_obj.getAttrString(di, AT_name);
+ if (this_die_obj.getAttr(AT.name)) |_| {
+ const name = try this_die_obj.getAttrString(di, AT.name);
break :x name;
- } else if (this_die_obj.getAttr(AT_abstract_origin)) |_| {
+ } else if (this_die_obj.getAttr(AT.abstract_origin)) |_| {
// Follow the DIE it points to and repeat
- const ref_offset = try this_die_obj.getAttrRef(AT_abstract_origin);
+ const ref_offset = try this_die_obj.getAttrRef(AT.abstract_origin);
if (ref_offset > next_offset) return error.InvalidDebugInfo;
try seekable.seekTo(this_unit_offset + ref_offset);
this_die_obj = (try di.parseDie(in, abbrev_table, is_64)) orelse return error.InvalidDebugInfo;
- } else if (this_die_obj.getAttr(AT_specification)) |_| {
+ } else if (this_die_obj.getAttr(AT.specification)) |_| {
// Follow the DIE it points to and repeat
- const ref_offset = try this_die_obj.getAttrRef(AT_specification);
+ const ref_offset = try this_die_obj.getAttrRef(AT.specification);
if (ref_offset > next_offset) return error.InvalidDebugInfo;
try seekable.seekTo(this_unit_offset + ref_offset);
this_die_obj = (try di.parseDie(in, abbrev_table, is_64)) orelse return error.InvalidDebugInfo;
@@ -471,8 +687,8 @@ pub const DwarfInfo = struct {
};
const pc_range = x: {
- if (die_obj.getAttrAddr(AT_low_pc)) |low_pc| {
- if (die_obj.getAttr(AT_high_pc)) |high_pc_value| {
+ if (die_obj.getAttrAddr(AT.low_pc)) |low_pc| {
+ if (die_obj.getAttr(AT.high_pc)) |high_pc_value| {
const pc_end = switch (high_pc_value.*) {
FormValue.Address => |value| value,
FormValue.Const => |value| b: {
@@ -539,11 +755,11 @@ pub const DwarfInfo = struct {
const compile_unit_die = try di.allocator().create(Die);
compile_unit_die.* = (try di.parseDie(in, abbrev_table, is_64)) orelse return error.InvalidDebugInfo;
- if (compile_unit_die.tag_id != TAG_compile_unit) return error.InvalidDebugInfo;
+ if (compile_unit_die.tag_id != TAG.compile_unit) return error.InvalidDebugInfo;
const pc_range = x: {
- if (compile_unit_die.getAttrAddr(AT_low_pc)) |low_pc| {
- if (compile_unit_die.getAttr(AT_high_pc)) |high_pc_value| {
+ if (compile_unit_die.getAttrAddr(AT.low_pc)) |low_pc| {
+ if (compile_unit_die.getAttr(AT.high_pc)) |high_pc_value| {
const pc_end = switch (high_pc_value.*) {
FormValue.Address => |value| value,
FormValue.Const => |value| b: {
@@ -582,16 +798,16 @@ pub const DwarfInfo = struct {
if (target_address >= range.start and target_address < range.end) return compile_unit;
}
if (di.debug_ranges) |debug_ranges| {
- if (compile_unit.die.getAttrSecOffset(AT_ranges)) |ranges_offset| {
+ if (compile_unit.die.getAttrSecOffset(AT.ranges)) |ranges_offset| {
var stream = io.fixedBufferStream(debug_ranges);
const in = &stream.reader();
const seekable = &stream.seekableStream();
// All the addresses in the list are relative to the value
- // specified by DW_AT_low_pc or to some other value encoded
+ // specified by DW_AT.low_pc or to some other value encoded
// in the list itself.
// If no starting value is specified use zero.
- var base_address = compile_unit.die.getAttrAddr(AT_low_pc) catch |err| switch (err) {
+ var base_address = compile_unit.die.getAttrAddr(AT.low_pc) catch |err| switch (err) {
error.MissingDebugInfo => 0,
else => return err,
};
@@ -651,7 +867,7 @@ pub const DwarfInfo = struct {
try result.append(AbbrevTableEntry{
.abbrev_code = abbrev_code,
.tag_id = try leb.readULEB128(u64, in),
- .has_children = (try in.readByte()) == CHILDREN_yes,
+ .has_children = (try in.readByte()) == CHILDREN.yes,
.attrs = ArrayList(AbbrevAttr).init(di.allocator()),
});
const attrs = &result.items[result.items.len - 1].attrs;
@@ -693,8 +909,8 @@ pub const DwarfInfo = struct {
const in = &stream.reader();
const seekable = &stream.seekableStream();
- const compile_unit_cwd = try compile_unit.die.getAttrString(di, AT_comp_dir);
- const line_info_offset = try compile_unit.die.getAttrSecOffset(AT_stmt_list);
+ const compile_unit_cwd = try compile_unit.die.getAttrString(di, AT.comp_dir);
+ const line_info_offset = try compile_unit.die.getAttrSecOffset(AT.stmt_list);
try seekable.seekTo(line_info_offset);
@@ -769,21 +985,21 @@ pub const DwarfInfo = struct {
while ((try seekable.getPos()) < next_unit_pos) {
const opcode = try in.readByte();
- if (opcode == LNS_extended_op) {
+ if (opcode == LNS.extended_op) {
const op_size = try leb.readULEB128(u64, in);
if (op_size < 1) return error.InvalidDebugInfo;
var sub_op = try in.readByte();
switch (sub_op) {
- LNE_end_sequence => {
+ LNE.end_sequence => {
prog.end_sequence = true;
if (try prog.checkLineMatch()) |info| return info;
prog.reset();
},
- LNE_set_address => {
+ LNE.set_address => {
const addr = try in.readInt(usize, di.endian);
prog.address = addr;
},
- LNE_define_file => {
+ LNE.define_file => {
const file_name = try in.readUntilDelimiterAlloc(di.allocator(), 0, math.maxInt(usize));
const dir_index = try leb.readULEB128(usize, in);
const mtime = try leb.readULEB128(usize, in);
@@ -811,41 +1027,41 @@ pub const DwarfInfo = struct {
prog.basic_block = false;
} else {
switch (opcode) {
- LNS_copy => {
+ LNS.copy => {
if (try prog.checkLineMatch()) |info| return info;
prog.basic_block = false;
},
- LNS_advance_pc => {
+ LNS.advance_pc => {
const arg = try leb.readULEB128(usize, in);
prog.address += arg * minimum_instruction_length;
},
- LNS_advance_line => {
+ LNS.advance_line => {
const arg = try leb.readILEB128(i64, in);
prog.line += arg;
},
- LNS_set_file => {
+ LNS.set_file => {
const arg = try leb.readULEB128(usize, in);
prog.file = arg;
},
- LNS_set_column => {
+ LNS.set_column => {
const arg = try leb.readULEB128(u64, in);
prog.column = arg;
},
- LNS_negate_stmt => {
+ LNS.negate_stmt => {
prog.is_stmt = !prog.is_stmt;
},
- LNS_set_basic_block => {
+ LNS.set_basic_block => {
prog.basic_block = true;
},
- LNS_const_add_pc => {
+ LNS.const_add_pc => {
const inc_addr = minimum_instruction_length * ((255 - opcode_base) / line_range);
prog.address += inc_addr;
},
- LNS_fixed_advance_pc => {
+ LNS.fixed_advance_pc => {
const arg = try in.readInt(u16, di.endian);
prog.address += arg;
},
- LNS_set_prologue_end => {},
+ LNS.set_prologue_end => {},
else => {
if (opcode - 1 >= standard_opcode_lengths.len) return error.InvalidDebugInfo;
const len_bytes = standard_opcode_lengths[opcode - 1];
diff --git a/lib/std/dwarf/AT.zig b/lib/std/dwarf/AT.zig
new file mode 100644
index 000000000000..a4d03ad3d36d
--- /dev/null
+++ b/lib/std/dwarf/AT.zig
@@ -0,0 +1,198 @@
+pub const sibling = 0x01;
+pub const location = 0x02;
+pub const name = 0x03;
+pub const ordering = 0x09;
+pub const subscr_data = 0x0a;
+pub const byte_size = 0x0b;
+pub const bit_offset = 0x0c;
+pub const bit_size = 0x0d;
+pub const element_list = 0x0f;
+pub const stmt_list = 0x10;
+pub const low_pc = 0x11;
+pub const high_pc = 0x12;
+pub const language = 0x13;
+pub const member = 0x14;
+pub const discr = 0x15;
+pub const discr_value = 0x16;
+pub const visibility = 0x17;
+pub const import = 0x18;
+pub const string_length = 0x19;
+pub const common_reference = 0x1a;
+pub const comp_dir = 0x1b;
+pub const const_value = 0x1c;
+pub const containing_type = 0x1d;
+pub const default_value = 0x1e;
+pub const @"inline" = 0x20;
+pub const is_optional = 0x21;
+pub const lower_bound = 0x22;
+pub const producer = 0x25;
+pub const prototyped = 0x27;
+pub const return_addr = 0x2a;
+pub const start_scope = 0x2c;
+pub const bit_stride = 0x2e;
+pub const upper_bound = 0x2f;
+pub const abstract_origin = 0x31;
+pub const accessibility = 0x32;
+pub const address_class = 0x33;
+pub const artificial = 0x34;
+pub const base_types = 0x35;
+pub const calling_convention = 0x36;
+pub const count = 0x37;
+pub const data_member_location = 0x38;
+pub const decl_column = 0x39;
+pub const decl_file = 0x3a;
+pub const decl_line = 0x3b;
+pub const declaration = 0x3c;
+pub const discr_list = 0x3d;
+pub const encoding = 0x3e;
+pub const external = 0x3f;
+pub const frame_base = 0x40;
+pub const friend = 0x41;
+pub const identifier_case = 0x42;
+pub const macro_info = 0x43;
+pub const namelist_items = 0x44;
+pub const priority = 0x45;
+pub const segment = 0x46;
+pub const specification = 0x47;
+pub const static_link = 0x48;
+pub const @"type" = 0x49;
+pub const use_location = 0x4a;
+pub const variable_parameter = 0x4b;
+pub const virtuality = 0x4c;
+pub const vtable_elem_location = 0x4d;
+
+// DWARF 3 values.
+pub const allocated = 0x4e;
+pub const associated = 0x4f;
+pub const data_location = 0x50;
+pub const byte_stride = 0x51;
+pub const entry_pc = 0x52;
+pub const use_UTF8 = 0x53;
+pub const extension = 0x54;
+pub const ranges = 0x55;
+pub const trampoline = 0x56;
+pub const call_column = 0x57;
+pub const call_file = 0x58;
+pub const call_line = 0x59;
+pub const description = 0x5a;
+pub const binary_scale = 0x5b;
+pub const decimal_scale = 0x5c;
+pub const small = 0x5d;
+pub const decimal_sign = 0x5e;
+pub const digit_count = 0x5f;
+pub const picture_string = 0x60;
+pub const mutable = 0x61;
+pub const threads_scaled = 0x62;
+pub const explicit = 0x63;
+pub const object_pointer = 0x64;
+pub const endianity = 0x65;
+pub const elemental = 0x66;
+pub const pure = 0x67;
+pub const recursive = 0x68;
+
+// DWARF 4.
+pub const signature = 0x69;
+pub const main_subprogram = 0x6a;
+pub const data_bit_offset = 0x6b;
+pub const const_expr = 0x6c;
+pub const enum_class = 0x6d;
+pub const linkage_name = 0x6e;
+
+// DWARF 5
+pub const alignment = 0x88;
+
+pub const lo_user = 0x2000; // Implementation-defined range start.
+pub const hi_user = 0x3fff; // Implementation-defined range end.
+
+// SGI/MIPS extensions.
+pub const MIPS_fde = 0x2001;
+pub const MIPS_loop_begin = 0x2002;
+pub const MIPS_tail_loop_begin = 0x2003;
+pub const MIPS_epilog_begin = 0x2004;
+pub const MIPS_loop_unroll_factor = 0x2005;
+pub const MIPS_software_pipeline_depth = 0x2006;
+pub const MIPS_linkage_name = 0x2007;
+pub const MIPS_stride = 0x2008;
+pub const MIPS_abstract_name = 0x2009;
+pub const MIPS_clone_origin = 0x200a;
+pub const MIPS_has_inlines = 0x200b;
+
+// HP extensions.
+pub const HP_block_index = 0x2000;
+pub const HP_unmodifiable = 0x2001; // Same as AT.MIPS_fde.
+pub const HP_prologue = 0x2005; // Same as AT.MIPS_loop_unroll.
+pub const HP_epilogue = 0x2008; // Same as AT.MIPS_stride.
+pub const HP_actuals_stmt_list = 0x2010;
+pub const HP_proc_per_section = 0x2011;
+pub const HP_raw_data_ptr = 0x2012;
+pub const HP_pass_by_reference = 0x2013;
+pub const HP_opt_level = 0x2014;
+pub const HP_prof_version_id = 0x2015;
+pub const HP_opt_flags = 0x2016;
+pub const HP_cold_region_low_pc = 0x2017;
+pub const HP_cold_region_high_pc = 0x2018;
+pub const HP_all_variables_modifiable = 0x2019;
+pub const HP_linkage_name = 0x201a;
+pub const HP_prof_flags = 0x201b; // In comp unit of procs_info for -g.
+pub const HP_unit_name = 0x201f;
+pub const HP_unit_size = 0x2020;
+pub const HP_widened_byte_size = 0x2021;
+pub const HP_definition_points = 0x2022;
+pub const HP_default_location = 0x2023;
+pub const HP_is_result_param = 0x2029;
+
+// GNU extensions.
+pub const sf_names = 0x2101;
+pub const src_info = 0x2102;
+pub const mac_info = 0x2103;
+pub const src_coords = 0x2104;
+pub const body_begin = 0x2105;
+pub const body_end = 0x2106;
+pub const GNU_vector = 0x2107;
+// Thread-safety annotations.
+// See http://gcc.gnu.org/wiki/ThreadSafetyAnnotation .
+pub const GNU_guarded_by = 0x2108;
+pub const GNU_pt_guarded_by = 0x2109;
+pub const GNU_guarded = 0x210a;
+pub const GNU_pt_guarded = 0x210b;
+pub const GNU_locks_excluded = 0x210c;
+pub const GNU_exclusive_locks_required = 0x210d;
+pub const GNU_shared_locks_required = 0x210e;
+// One-definition rule violation detection.
+// See http://gcc.gnu.org/wiki/DwarfSeparateTypeInfo .
+pub const GNU_odr_signature = 0x210f;
+// Template template argument name.
+// See http://gcc.gnu.org/wiki/TemplateParmsDwarf .
+pub const GNU_template_name = 0x2110;
+// The GNU call site extension.
+// See http://www.dwarfstd.org/ShowIssue.php?issue=100909.2&type=open .
+pub const GNU_call_site_value = 0x2111;
+pub const GNU_call_site_data_value = 0x2112;
+pub const GNU_call_site_target = 0x2113;
+pub const GNU_call_site_target_clobbered = 0x2114;
+pub const GNU_tail_call = 0x2115;
+pub const GNU_all_tail_call_sites = 0x2116;
+pub const GNU_all_call_sites = 0x2117;
+pub const GNU_all_source_call_sites = 0x2118;
+// Section offset into .debug_macro section.
+pub const GNU_macros = 0x2119;
+// Extensions for Fission. See http://gcc.gnu.org/wiki/DebugFission.
+pub const GNU_dwo_name = 0x2130;
+pub const GNU_dwo_id = 0x2131;
+pub const GNU_ranges_base = 0x2132;
+pub const GNU_addr_base = 0x2133;
+pub const GNU_pubnames = 0x2134;
+pub const GNU_pubtypes = 0x2135;
+// VMS extensions.
+pub const VMS_rtnbeg_pd_address = 0x2201;
+// GNAT extensions.
+// GNAT descriptive type.
+// See http://gcc.gnu.org/wiki/DW_AT_GNAT_descriptive_type .
+pub const use_GNAT_descriptive_type = 0x2301;
+pub const GNAT_descriptive_type = 0x2302;
+// UPC extension.
+pub const upc_threads_scaled = 0x3210;
+// PGI (STMicroelectronics) extensions.
+pub const PGI_lbase = 0x3a00;
+pub const PGI_soffset = 0x3a01;
+pub const PGI_lstride = 0x3a02;
diff --git a/lib/std/dwarf/OP.zig b/lib/std/dwarf/OP.zig
new file mode 100644
index 000000000000..92e13e815828
--- /dev/null
+++ b/lib/std/dwarf/OP.zig
@@ -0,0 +1,195 @@
+pub const addr = 0x03;
+pub const deref = 0x06;
+pub const const1u = 0x08;
+pub const const1s = 0x09;
+pub const const2u = 0x0a;
+pub const const2s = 0x0b;
+pub const const4u = 0x0c;
+pub const const4s = 0x0d;
+pub const const8u = 0x0e;
+pub const const8s = 0x0f;
+pub const constu = 0x10;
+pub const consts = 0x11;
+pub const dup = 0x12;
+pub const drop = 0x13;
+pub const over = 0x14;
+pub const pick = 0x15;
+pub const swap = 0x16;
+pub const rot = 0x17;
+pub const xderef = 0x18;
+pub const abs = 0x19;
+pub const @"and" = 0x1a;
+pub const div = 0x1b;
+pub const minus = 0x1c;
+pub const mod = 0x1d;
+pub const mul = 0x1e;
+pub const neg = 0x1f;
+pub const not = 0x20;
+pub const @"or" = 0x21;
+pub const plus = 0x22;
+pub const plus_uconst = 0x23;
+pub const shl = 0x24;
+pub const shr = 0x25;
+pub const shra = 0x26;
+pub const xor = 0x27;
+pub const bra = 0x28;
+pub const eq = 0x29;
+pub const ge = 0x2a;
+pub const gt = 0x2b;
+pub const le = 0x2c;
+pub const lt = 0x2d;
+pub const ne = 0x2e;
+pub const skip = 0x2f;
+pub const lit0 = 0x30;
+pub const lit1 = 0x31;
+pub const lit2 = 0x32;
+pub const lit3 = 0x33;
+pub const lit4 = 0x34;
+pub const lit5 = 0x35;
+pub const lit6 = 0x36;
+pub const lit7 = 0x37;
+pub const lit8 = 0x38;
+pub const lit9 = 0x39;
+pub const lit10 = 0x3a;
+pub const lit11 = 0x3b;
+pub const lit12 = 0x3c;
+pub const lit13 = 0x3d;
+pub const lit14 = 0x3e;
+pub const lit15 = 0x3f;
+pub const lit16 = 0x40;
+pub const lit17 = 0x41;
+pub const lit18 = 0x42;
+pub const lit19 = 0x43;
+pub const lit20 = 0x44;
+pub const lit21 = 0x45;
+pub const lit22 = 0x46;
+pub const lit23 = 0x47;
+pub const lit24 = 0x48;
+pub const lit25 = 0x49;
+pub const lit26 = 0x4a;
+pub const lit27 = 0x4b;
+pub const lit28 = 0x4c;
+pub const lit29 = 0x4d;
+pub const lit30 = 0x4e;
+pub const lit31 = 0x4f;
+pub const reg0 = 0x50;
+pub const reg1 = 0x51;
+pub const reg2 = 0x52;
+pub const reg3 = 0x53;
+pub const reg4 = 0x54;
+pub const reg5 = 0x55;
+pub const reg6 = 0x56;
+pub const reg7 = 0x57;
+pub const reg8 = 0x58;
+pub const reg9 = 0x59;
+pub const reg10 = 0x5a;
+pub const reg11 = 0x5b;
+pub const reg12 = 0x5c;
+pub const reg13 = 0x5d;
+pub const reg14 = 0x5e;
+pub const reg15 = 0x5f;
+pub const reg16 = 0x60;
+pub const reg17 = 0x61;
+pub const reg18 = 0x62;
+pub const reg19 = 0x63;
+pub const reg20 = 0x64;
+pub const reg21 = 0x65;
+pub const reg22 = 0x66;
+pub const reg23 = 0x67;
+pub const reg24 = 0x68;
+pub const reg25 = 0x69;
+pub const reg26 = 0x6a;
+pub const reg27 = 0x6b;
+pub const reg28 = 0x6c;
+pub const reg29 = 0x6d;
+pub const reg30 = 0x6e;
+pub const reg31 = 0x6f;
+pub const breg0 = 0x70;
+pub const breg1 = 0x71;
+pub const breg2 = 0x72;
+pub const breg3 = 0x73;
+pub const breg4 = 0x74;
+pub const breg5 = 0x75;
+pub const breg6 = 0x76;
+pub const breg7 = 0x77;
+pub const breg8 = 0x78;
+pub const breg9 = 0x79;
+pub const breg10 = 0x7a;
+pub const breg11 = 0x7b;
+pub const breg12 = 0x7c;
+pub const breg13 = 0x7d;
+pub const breg14 = 0x7e;
+pub const breg15 = 0x7f;
+pub const breg16 = 0x80;
+pub const breg17 = 0x81;
+pub const breg18 = 0x82;
+pub const breg19 = 0x83;
+pub const breg20 = 0x84;
+pub const breg21 = 0x85;
+pub const breg22 = 0x86;
+pub const breg23 = 0x87;
+pub const breg24 = 0x88;
+pub const breg25 = 0x89;
+pub const breg26 = 0x8a;
+pub const breg27 = 0x8b;
+pub const breg28 = 0x8c;
+pub const breg29 = 0x8d;
+pub const breg30 = 0x8e;
+pub const breg31 = 0x8f;
+pub const regx = 0x90;
+pub const fbreg = 0x91;
+pub const bregx = 0x92;
+pub const piece = 0x93;
+pub const deref_size = 0x94;
+pub const xderef_size = 0x95;
+pub const nop = 0x96;
+
+// DWARF 3 extensions.
+pub const push_object_address = 0x97;
+pub const call2 = 0x98;
+pub const call4 = 0x99;
+pub const call_ref = 0x9a;
+pub const form_tls_address = 0x9b;
+pub const call_frame_cfa = 0x9c;
+pub const bit_piece = 0x9d;
+
+// DWARF 4 extensions.
+pub const implicit_value = 0x9e;
+pub const stack_value = 0x9f;
+
+pub const lo_user = 0xe0; // Implementation-defined range start.
+pub const hi_user = 0xff; // Implementation-defined range end.
+
+// GNU extensions.
+pub const GNU_push_tls_address = 0xe0;
+// The following is for marking variables that are uninitialized.
+pub const GNU_uninit = 0xf0;
+pub const GNU_encoded_addr = 0xf1;
+// The GNU implicit pointer extension.
+// See http://www.dwarfstd.org/ShowIssue.php?issue=100831.1&type=open .
+pub const GNU_implicit_pointer = 0xf2;
+// The GNU entry value extension.
+// See http://www.dwarfstd.org/ShowIssue.php?issue=100909.1&type=open .
+pub const GNU_entry_value = 0xf3;
+// The GNU typed stack extension.
+// See http://www.dwarfstd.org/doc/040408.1.html .
+pub const GNU_const_type = 0xf4;
+pub const GNU_regval_type = 0xf5;
+pub const GNU_deref_type = 0xf6;
+pub const GNU_convert = 0xf7;
+pub const GNU_reinterpret = 0xf9;
+// The GNU parameter ref extension.
+pub const GNU_parameter_ref = 0xfa;
+// Extension for Fission. See http://gcc.gnu.org/wiki/DebugFission.
+pub const GNU_addr_index = 0xfb;
+pub const GNU_const_index = 0xfc;
+// HP extensions.
+pub const HP_unknown = 0xe0; // Ouch, the same as GNU_push_tls_address.
+pub const HP_is_value = 0xe1;
+pub const HP_fltconst4 = 0xe2;
+pub const HP_fltconst8 = 0xe3;
+pub const HP_mod_range = 0xe4;
+pub const HP_unmod_range = 0xe5;
+pub const HP_tls = 0xe6;
+// PGI (STMicroelectronics) extensions.
+pub const PGI_omp_thread_num = 0xf8;
diff --git a/lib/std/dwarf/TAG.zig b/lib/std/dwarf/TAG.zig
new file mode 100644
index 000000000000..a6434cf3ec47
--- /dev/null
+++ b/lib/std/dwarf/TAG.zig
@@ -0,0 +1,108 @@
+pub const padding = 0x00;
+pub const array_type = 0x01;
+pub const class_type = 0x02;
+pub const entry_point = 0x03;
+pub const enumeration_type = 0x04;
+pub const formal_parameter = 0x05;
+pub const imported_declaration = 0x08;
+pub const label = 0x0a;
+pub const lexical_block = 0x0b;
+pub const member = 0x0d;
+pub const pointer_type = 0x0f;
+pub const reference_type = 0x10;
+pub const compile_unit = 0x11;
+pub const string_type = 0x12;
+pub const structure_type = 0x13;
+pub const subroutine = 0x14;
+pub const subroutine_type = 0x15;
+pub const typedef = 0x16;
+pub const union_type = 0x17;
+pub const unspecified_parameters = 0x18;
+pub const variant = 0x19;
+pub const common_block = 0x1a;
+pub const common_inclusion = 0x1b;
+pub const inheritance = 0x1c;
+pub const inlined_subroutine = 0x1d;
+pub const module = 0x1e;
+pub const ptr_to_member_type = 0x1f;
+pub const set_type = 0x20;
+pub const subrange_type = 0x21;
+pub const with_stmt = 0x22;
+pub const access_declaration = 0x23;
+pub const base_type = 0x24;
+pub const catch_block = 0x25;
+pub const const_type = 0x26;
+pub const constant = 0x27;
+pub const enumerator = 0x28;
+pub const file_type = 0x29;
+pub const friend = 0x2a;
+pub const namelist = 0x2b;
+pub const namelist_item = 0x2c;
+pub const packed_type = 0x2d;
+pub const subprogram = 0x2e;
+pub const template_type_param = 0x2f;
+pub const template_value_param = 0x30;
+pub const thrown_type = 0x31;
+pub const try_block = 0x32;
+pub const variant_part = 0x33;
+pub const variable = 0x34;
+pub const volatile_type = 0x35;
+
+// DWARF 3
+pub const dwarf_procedure = 0x36;
+pub const restrict_type = 0x37;
+pub const interface_type = 0x38;
+pub const namespace = 0x39;
+pub const imported_module = 0x3a;
+pub const unspecified_type = 0x3b;
+pub const partial_unit = 0x3c;
+pub const imported_unit = 0x3d;
+pub const condition = 0x3f;
+pub const shared_type = 0x40;
+
+// DWARF 4
+pub const type_unit = 0x41;
+pub const rvalue_reference_type = 0x42;
+pub const template_alias = 0x43;
+
+pub const lo_user = 0x4080;
+pub const hi_user = 0xffff;
+
+// SGI/MIPS Extensions.
+pub const MIPS_loop = 0x4081;
+
+// HP extensions. See: ftp://ftp.hp.com/pub/lang/tools/WDB/wdb-4.0.tar.gz .
+pub const HP_array_descriptor = 0x4090;
+pub const HP_Bliss_field = 0x4091;
+pub const HP_Bliss_field_set = 0x4092;
+
+// GNU extensions.
+pub const format_label = 0x4101; // For FORTRAN 77 and Fortran 90.
+pub const function_template = 0x4102; // For C++.
+pub const class_template = 0x4103; //For C++.
+pub const GNU_BINCL = 0x4104;
+pub const GNU_EINCL = 0x4105;
+
+// Template template parameter.
+// See http://gcc.gnu.org/wiki/TemplateParmsDwarf .
+pub const GNU_template_template_param = 0x4106;
+
+// Template parameter pack extension = specified at
+// http://wiki.dwarfstd.org/index.php?title=C%2B%2B0x:_Variadic_templates
+// The values of these two TAGS are in the DW_TAG_GNU_* space until the tags
+// are properly part of DWARF 5.
+pub const GNU_template_parameter_pack = 0x4107;
+pub const GNU_formal_parameter_pack = 0x4108;
+// The GNU call site extension = specified at
+// http://www.dwarfstd.org/ShowIssue.php?issue=100909.2&type=open .
+// The values of these two TAGS are in the DW_TAG_GNU_* space until the tags
+// are properly part of DWARF 5.
+pub const GNU_call_site = 0x4109;
+pub const GNU_call_site_parameter = 0x410a;
+// Extensions for UPC. See: http://dwarfstd.org/doc/DWARF4.pdf.
+pub const upc_shared_type = 0x8765;
+pub const upc_strict_type = 0x8766;
+pub const upc_relaxed_type = 0x8767;
+// PGI (STMicroelectronics; extensions. No documentation available.
+pub const PGI_kanji_type = 0xA000;
+pub const PGI_interface_block = 0xA020;
diff --git a/lib/std/dwarf_bits.zig b/lib/std/dwarf_bits.zig
deleted file mode 100644
index a40fa8a27773..000000000000
--- a/lib/std/dwarf_bits.zig
+++ /dev/null
@@ -1,699 +0,0 @@
-pub const TAG_padding = 0x00;
-pub const TAG_array_type = 0x01;
-pub const TAG_class_type = 0x02;
-pub const TAG_entry_point = 0x03;
-pub const TAG_enumeration_type = 0x04;
-pub const TAG_formal_parameter = 0x05;
-pub const TAG_imported_declaration = 0x08;
-pub const TAG_label = 0x0a;
-pub const TAG_lexical_block = 0x0b;
-pub const TAG_member = 0x0d;
-pub const TAG_pointer_type = 0x0f;
-pub const TAG_reference_type = 0x10;
-pub const TAG_compile_unit = 0x11;
-pub const TAG_string_type = 0x12;
-pub const TAG_structure_type = 0x13;
-pub const TAG_subroutine = 0x14;
-pub const TAG_subroutine_type = 0x15;
-pub const TAG_typedef = 0x16;
-pub const TAG_union_type = 0x17;
-pub const TAG_unspecified_parameters = 0x18;
-pub const TAG_variant = 0x19;
-pub const TAG_common_block = 0x1a;
-pub const TAG_common_inclusion = 0x1b;
-pub const TAG_inheritance = 0x1c;
-pub const TAG_inlined_subroutine = 0x1d;
-pub const TAG_module = 0x1e;
-pub const TAG_ptr_to_member_type = 0x1f;
-pub const TAG_set_type = 0x20;
-pub const TAG_subrange_type = 0x21;
-pub const TAG_with_stmt = 0x22;
-pub const TAG_access_declaration = 0x23;
-pub const TAG_base_type = 0x24;
-pub const TAG_catch_block = 0x25;
-pub const TAG_const_type = 0x26;
-pub const TAG_constant = 0x27;
-pub const TAG_enumerator = 0x28;
-pub const TAG_file_type = 0x29;
-pub const TAG_friend = 0x2a;
-pub const TAG_namelist = 0x2b;
-pub const TAG_namelist_item = 0x2c;
-pub const TAG_packed_type = 0x2d;
-pub const TAG_subprogram = 0x2e;
-pub const TAG_template_type_param = 0x2f;
-pub const TAG_template_value_param = 0x30;
-pub const TAG_thrown_type = 0x31;
-pub const TAG_try_block = 0x32;
-pub const TAG_variant_part = 0x33;
-pub const TAG_variable = 0x34;
-pub const TAG_volatile_type = 0x35;
-
-// DWARF 3
-pub const TAG_dwarf_procedure = 0x36;
-pub const TAG_restrict_type = 0x37;
-pub const TAG_interface_type = 0x38;
-pub const TAG_namespace = 0x39;
-pub const TAG_imported_module = 0x3a;
-pub const TAG_unspecified_type = 0x3b;
-pub const TAG_partial_unit = 0x3c;
-pub const TAG_imported_unit = 0x3d;
-pub const TAG_condition = 0x3f;
-pub const TAG_shared_type = 0x40;
-
-// DWARF 4
-pub const TAG_type_unit = 0x41;
-pub const TAG_rvalue_reference_type = 0x42;
-pub const TAG_template_alias = 0x43;
-
-pub const TAG_lo_user = 0x4080;
-pub const TAG_hi_user = 0xffff;
-
-// SGI/MIPS Extensions.
-pub const TAG_MIPS_loop = 0x4081;
-
-// HP extensions. See: ftp://ftp.hp.com/pub/lang/tools/WDB/wdb-4.0.tar.gz .
-pub const TAG_HP_array_descriptor = 0x4090;
-pub const TAG_HP_Bliss_field = 0x4091;
-pub const TAG_HP_Bliss_field_set = 0x4092;
-
-// GNU extensions.
-pub const TAG_format_label = 0x4101; // For FORTRAN 77 and Fortran 90.
-pub const TAG_function_template = 0x4102; // For C++.
-pub const TAG_class_template = 0x4103; //For C++.
-pub const TAG_GNU_BINCL = 0x4104;
-pub const TAG_GNU_EINCL = 0x4105;
-
-// Template template parameter.
-// See http://gcc.gnu.org/wiki/TemplateParmsDwarf .
-pub const TAG_GNU_template_template_param = 0x4106;
-
-// Template parameter pack extension = specified at
-// http://wiki.dwarfstd.org/index.php?title=C%2B%2B0x:_Variadic_templates
-// The values of these two TAGS are in the DW_TAG_GNU_* space until the tags
-// are properly part of DWARF 5.
-pub const TAG_GNU_template_parameter_pack = 0x4107;
-pub const TAG_GNU_formal_parameter_pack = 0x4108;
-// The GNU call site extension = specified at
-// http://www.dwarfstd.org/ShowIssue.php?issue=100909.2&type=open .
-// The values of these two TAGS are in the DW_TAG_GNU_* space until the tags
-// are properly part of DWARF 5.
-pub const TAG_GNU_call_site = 0x4109;
-pub const TAG_GNU_call_site_parameter = 0x410a;
-// Extensions for UPC. See: http://dwarfstd.org/doc/DWARF4.pdf.
-pub const TAG_upc_shared_type = 0x8765;
-pub const TAG_upc_strict_type = 0x8766;
-pub const TAG_upc_relaxed_type = 0x8767;
-// PGI (STMicroelectronics; extensions. No documentation available.
-pub const TAG_PGI_kanji_type = 0xA000;
-pub const TAG_PGI_interface_block = 0xA020;
-
-pub const FORM_addr = 0x01;
-pub const FORM_block2 = 0x03;
-pub const FORM_block4 = 0x04;
-pub const FORM_data2 = 0x05;
-pub const FORM_data4 = 0x06;
-pub const FORM_data8 = 0x07;
-pub const FORM_string = 0x08;
-pub const FORM_block = 0x09;
-pub const FORM_block1 = 0x0a;
-pub const FORM_data1 = 0x0b;
-pub const FORM_flag = 0x0c;
-pub const FORM_sdata = 0x0d;
-pub const FORM_strp = 0x0e;
-pub const FORM_udata = 0x0f;
-pub const FORM_ref_addr = 0x10;
-pub const FORM_ref1 = 0x11;
-pub const FORM_ref2 = 0x12;
-pub const FORM_ref4 = 0x13;
-pub const FORM_ref8 = 0x14;
-pub const FORM_ref_udata = 0x15;
-pub const FORM_indirect = 0x16;
-pub const FORM_sec_offset = 0x17;
-pub const FORM_exprloc = 0x18;
-pub const FORM_flag_present = 0x19;
-pub const FORM_ref_sig8 = 0x20;
-
-// Extensions for Fission. See http://gcc.gnu.org/wiki/DebugFission.
-pub const FORM_GNU_addr_index = 0x1f01;
-pub const FORM_GNU_str_index = 0x1f02;
-
-// Extensions for DWZ multifile.
-// See http://www.dwarfstd.org/ShowIssue.php?issue=120604.1&type=open .
-pub const FORM_GNU_ref_alt = 0x1f20;
-pub const FORM_GNU_strp_alt = 0x1f21;
-
-pub const AT_sibling = 0x01;
-pub const AT_location = 0x02;
-pub const AT_name = 0x03;
-pub const AT_ordering = 0x09;
-pub const AT_subscr_data = 0x0a;
-pub const AT_byte_size = 0x0b;
-pub const AT_bit_offset = 0x0c;
-pub const AT_bit_size = 0x0d;
-pub const AT_element_list = 0x0f;
-pub const AT_stmt_list = 0x10;
-pub const AT_low_pc = 0x11;
-pub const AT_high_pc = 0x12;
-pub const AT_language = 0x13;
-pub const AT_member = 0x14;
-pub const AT_discr = 0x15;
-pub const AT_discr_value = 0x16;
-pub const AT_visibility = 0x17;
-pub const AT_import = 0x18;
-pub const AT_string_length = 0x19;
-pub const AT_common_reference = 0x1a;
-pub const AT_comp_dir = 0x1b;
-pub const AT_const_value = 0x1c;
-pub const AT_containing_type = 0x1d;
-pub const AT_default_value = 0x1e;
-pub const AT_inline = 0x20;
-pub const AT_is_optional = 0x21;
-pub const AT_lower_bound = 0x22;
-pub const AT_producer = 0x25;
-pub const AT_prototyped = 0x27;
-pub const AT_return_addr = 0x2a;
-pub const AT_start_scope = 0x2c;
-pub const AT_bit_stride = 0x2e;
-pub const AT_upper_bound = 0x2f;
-pub const AT_abstract_origin = 0x31;
-pub const AT_accessibility = 0x32;
-pub const AT_address_class = 0x33;
-pub const AT_artificial = 0x34;
-pub const AT_base_types = 0x35;
-pub const AT_calling_convention = 0x36;
-pub const AT_count = 0x37;
-pub const AT_data_member_location = 0x38;
-pub const AT_decl_column = 0x39;
-pub const AT_decl_file = 0x3a;
-pub const AT_decl_line = 0x3b;
-pub const AT_declaration = 0x3c;
-pub const AT_discr_list = 0x3d;
-pub const AT_encoding = 0x3e;
-pub const AT_external = 0x3f;
-pub const AT_frame_base = 0x40;
-pub const AT_friend = 0x41;
-pub const AT_identifier_case = 0x42;
-pub const AT_macro_info = 0x43;
-pub const AT_namelist_items = 0x44;
-pub const AT_priority = 0x45;
-pub const AT_segment = 0x46;
-pub const AT_specification = 0x47;
-pub const AT_static_link = 0x48;
-pub const AT_type = 0x49;
-pub const AT_use_location = 0x4a;
-pub const AT_variable_parameter = 0x4b;
-pub const AT_virtuality = 0x4c;
-pub const AT_vtable_elem_location = 0x4d;
-
-// DWARF 3 values.
-pub const AT_allocated = 0x4e;
-pub const AT_associated = 0x4f;
-pub const AT_data_location = 0x50;
-pub const AT_byte_stride = 0x51;
-pub const AT_entry_pc = 0x52;
-pub const AT_use_UTF8 = 0x53;
-pub const AT_extension = 0x54;
-pub const AT_ranges = 0x55;
-pub const AT_trampoline = 0x56;
-pub const AT_call_column = 0x57;
-pub const AT_call_file = 0x58;
-pub const AT_call_line = 0x59;
-pub const AT_description = 0x5a;
-pub const AT_binary_scale = 0x5b;
-pub const AT_decimal_scale = 0x5c;
-pub const AT_small = 0x5d;
-pub const AT_decimal_sign = 0x5e;
-pub const AT_digit_count = 0x5f;
-pub const AT_picture_string = 0x60;
-pub const AT_mutable = 0x61;
-pub const AT_threads_scaled = 0x62;
-pub const AT_explicit = 0x63;
-pub const AT_object_pointer = 0x64;
-pub const AT_endianity = 0x65;
-pub const AT_elemental = 0x66;
-pub const AT_pure = 0x67;
-pub const AT_recursive = 0x68;
-
-// DWARF 4.
-pub const AT_signature = 0x69;
-pub const AT_main_subprogram = 0x6a;
-pub const AT_data_bit_offset = 0x6b;
-pub const AT_const_expr = 0x6c;
-pub const AT_enum_class = 0x6d;
-pub const AT_linkage_name = 0x6e;
-
-// DWARF 5
-pub const AT_alignment = 0x88;
-
-pub const AT_lo_user = 0x2000; // Implementation-defined range start.
-pub const AT_hi_user = 0x3fff; // Implementation-defined range end.
-
-// SGI/MIPS extensions.
-pub const AT_MIPS_fde = 0x2001;
-pub const AT_MIPS_loop_begin = 0x2002;
-pub const AT_MIPS_tail_loop_begin = 0x2003;
-pub const AT_MIPS_epilog_begin = 0x2004;
-pub const AT_MIPS_loop_unroll_factor = 0x2005;
-pub const AT_MIPS_software_pipeline_depth = 0x2006;
-pub const AT_MIPS_linkage_name = 0x2007;
-pub const AT_MIPS_stride = 0x2008;
-pub const AT_MIPS_abstract_name = 0x2009;
-pub const AT_MIPS_clone_origin = 0x200a;
-pub const AT_MIPS_has_inlines = 0x200b;
-
-// HP extensions.
-pub const AT_HP_block_index = 0x2000;
-pub const AT_HP_unmodifiable = 0x2001; // Same as AT_MIPS_fde.
-pub const AT_HP_prologue = 0x2005; // Same as AT_MIPS_loop_unroll.
-pub const AT_HP_epilogue = 0x2008; // Same as AT_MIPS_stride.
-pub const AT_HP_actuals_stmt_list = 0x2010;
-pub const AT_HP_proc_per_section = 0x2011;
-pub const AT_HP_raw_data_ptr = 0x2012;
-pub const AT_HP_pass_by_reference = 0x2013;
-pub const AT_HP_opt_level = 0x2014;
-pub const AT_HP_prof_version_id = 0x2015;
-pub const AT_HP_opt_flags = 0x2016;
-pub const AT_HP_cold_region_low_pc = 0x2017;
-pub const AT_HP_cold_region_high_pc = 0x2018;
-pub const AT_HP_all_variables_modifiable = 0x2019;
-pub const AT_HP_linkage_name = 0x201a;
-pub const AT_HP_prof_flags = 0x201b; // In comp unit of procs_info for -g.
-pub const AT_HP_unit_name = 0x201f;
-pub const AT_HP_unit_size = 0x2020;
-pub const AT_HP_widened_byte_size = 0x2021;
-pub const AT_HP_definition_points = 0x2022;
-pub const AT_HP_default_location = 0x2023;
-pub const AT_HP_is_result_param = 0x2029;
-
-// GNU extensions.
-pub const AT_sf_names = 0x2101;
-pub const AT_src_info = 0x2102;
-pub const AT_mac_info = 0x2103;
-pub const AT_src_coords = 0x2104;
-pub const AT_body_begin = 0x2105;
-pub const AT_body_end = 0x2106;
-pub const AT_GNU_vector = 0x2107;
-// Thread-safety annotations.
-// See http://gcc.gnu.org/wiki/ThreadSafetyAnnotation .
-pub const AT_GNU_guarded_by = 0x2108;
-pub const AT_GNU_pt_guarded_by = 0x2109;
-pub const AT_GNU_guarded = 0x210a;
-pub const AT_GNU_pt_guarded = 0x210b;
-pub const AT_GNU_locks_excluded = 0x210c;
-pub const AT_GNU_exclusive_locks_required = 0x210d;
-pub const AT_GNU_shared_locks_required = 0x210e;
-// One-definition rule violation detection.
-// See http://gcc.gnu.org/wiki/DwarfSeparateTypeInfo .
-pub const AT_GNU_odr_signature = 0x210f;
-// Template template argument name.
-// See http://gcc.gnu.org/wiki/TemplateParmsDwarf .
-pub const AT_GNU_template_name = 0x2110;
-// The GNU call site extension.
-// See http://www.dwarfstd.org/ShowIssue.php?issue=100909.2&type=open .
-pub const AT_GNU_call_site_value = 0x2111;
-pub const AT_GNU_call_site_data_value = 0x2112;
-pub const AT_GNU_call_site_target = 0x2113;
-pub const AT_GNU_call_site_target_clobbered = 0x2114;
-pub const AT_GNU_tail_call = 0x2115;
-pub const AT_GNU_all_tail_call_sites = 0x2116;
-pub const AT_GNU_all_call_sites = 0x2117;
-pub const AT_GNU_all_source_call_sites = 0x2118;
-// Section offset into .debug_macro section.
-pub const AT_GNU_macros = 0x2119;
-// Extensions for Fission. See http://gcc.gnu.org/wiki/DebugFission.
-pub const AT_GNU_dwo_name = 0x2130;
-pub const AT_GNU_dwo_id = 0x2131;
-pub const AT_GNU_ranges_base = 0x2132;
-pub const AT_GNU_addr_base = 0x2133;
-pub const AT_GNU_pubnames = 0x2134;
-pub const AT_GNU_pubtypes = 0x2135;
-// VMS extensions.
-pub const AT_VMS_rtnbeg_pd_address = 0x2201;
-// GNAT extensions.
-// GNAT descriptive type.
-// See http://gcc.gnu.org/wiki/DW_AT_GNAT_descriptive_type .
-pub const AT_use_GNAT_descriptive_type = 0x2301;
-pub const AT_GNAT_descriptive_type = 0x2302;
-// UPC extension.
-pub const AT_upc_threads_scaled = 0x3210;
-// PGI (STMicroelectronics) extensions.
-pub const AT_PGI_lbase = 0x3a00;
-pub const AT_PGI_soffset = 0x3a01;
-pub const AT_PGI_lstride = 0x3a02;
-
-pub const OP_addr = 0x03;
-pub const OP_deref = 0x06;
-pub const OP_const1u = 0x08;
-pub const OP_const1s = 0x09;
-pub const OP_const2u = 0x0a;
-pub const OP_const2s = 0x0b;
-pub const OP_const4u = 0x0c;
-pub const OP_const4s = 0x0d;
-pub const OP_const8u = 0x0e;
-pub const OP_const8s = 0x0f;
-pub const OP_constu = 0x10;
-pub const OP_consts = 0x11;
-pub const OP_dup = 0x12;
-pub const OP_drop = 0x13;
-pub const OP_over = 0x14;
-pub const OP_pick = 0x15;
-pub const OP_swap = 0x16;
-pub const OP_rot = 0x17;
-pub const OP_xderef = 0x18;
-pub const OP_abs = 0x19;
-pub const OP_and = 0x1a;
-pub const OP_div = 0x1b;
-pub const OP_minus = 0x1c;
-pub const OP_mod = 0x1d;
-pub const OP_mul = 0x1e;
-pub const OP_neg = 0x1f;
-pub const OP_not = 0x20;
-pub const OP_or = 0x21;
-pub const OP_plus = 0x22;
-pub const OP_plus_uconst = 0x23;
-pub const OP_shl = 0x24;
-pub const OP_shr = 0x25;
-pub const OP_shra = 0x26;
-pub const OP_xor = 0x27;
-pub const OP_bra = 0x28;
-pub const OP_eq = 0x29;
-pub const OP_ge = 0x2a;
-pub const OP_gt = 0x2b;
-pub const OP_le = 0x2c;
-pub const OP_lt = 0x2d;
-pub const OP_ne = 0x2e;
-pub const OP_skip = 0x2f;
-pub const OP_lit0 = 0x30;
-pub const OP_lit1 = 0x31;
-pub const OP_lit2 = 0x32;
-pub const OP_lit3 = 0x33;
-pub const OP_lit4 = 0x34;
-pub const OP_lit5 = 0x35;
-pub const OP_lit6 = 0x36;
-pub const OP_lit7 = 0x37;
-pub const OP_lit8 = 0x38;
-pub const OP_lit9 = 0x39;
-pub const OP_lit10 = 0x3a;
-pub const OP_lit11 = 0x3b;
-pub const OP_lit12 = 0x3c;
-pub const OP_lit13 = 0x3d;
-pub const OP_lit14 = 0x3e;
-pub const OP_lit15 = 0x3f;
-pub const OP_lit16 = 0x40;
-pub const OP_lit17 = 0x41;
-pub const OP_lit18 = 0x42;
-pub const OP_lit19 = 0x43;
-pub const OP_lit20 = 0x44;
-pub const OP_lit21 = 0x45;
-pub const OP_lit22 = 0x46;
-pub const OP_lit23 = 0x47;
-pub const OP_lit24 = 0x48;
-pub const OP_lit25 = 0x49;
-pub const OP_lit26 = 0x4a;
-pub const OP_lit27 = 0x4b;
-pub const OP_lit28 = 0x4c;
-pub const OP_lit29 = 0x4d;
-pub const OP_lit30 = 0x4e;
-pub const OP_lit31 = 0x4f;
-pub const OP_reg0 = 0x50;
-pub const OP_reg1 = 0x51;
-pub const OP_reg2 = 0x52;
-pub const OP_reg3 = 0x53;
-pub const OP_reg4 = 0x54;
-pub const OP_reg5 = 0x55;
-pub const OP_reg6 = 0x56;
-pub const OP_reg7 = 0x57;
-pub const OP_reg8 = 0x58;
-pub const OP_reg9 = 0x59;
-pub const OP_reg10 = 0x5a;
-pub const OP_reg11 = 0x5b;
-pub const OP_reg12 = 0x5c;
-pub const OP_reg13 = 0x5d;
-pub const OP_reg14 = 0x5e;
-pub const OP_reg15 = 0x5f;
-pub const OP_reg16 = 0x60;
-pub const OP_reg17 = 0x61;
-pub const OP_reg18 = 0x62;
-pub const OP_reg19 = 0x63;
-pub const OP_reg20 = 0x64;
-pub const OP_reg21 = 0x65;
-pub const OP_reg22 = 0x66;
-pub const OP_reg23 = 0x67;
-pub const OP_reg24 = 0x68;
-pub const OP_reg25 = 0x69;
-pub const OP_reg26 = 0x6a;
-pub const OP_reg27 = 0x6b;
-pub const OP_reg28 = 0x6c;
-pub const OP_reg29 = 0x6d;
-pub const OP_reg30 = 0x6e;
-pub const OP_reg31 = 0x6f;
-pub const OP_breg0 = 0x70;
-pub const OP_breg1 = 0x71;
-pub const OP_breg2 = 0x72;
-pub const OP_breg3 = 0x73;
-pub const OP_breg4 = 0x74;
-pub const OP_breg5 = 0x75;
-pub const OP_breg6 = 0x76;
-pub const OP_breg7 = 0x77;
-pub const OP_breg8 = 0x78;
-pub const OP_breg9 = 0x79;
-pub const OP_breg10 = 0x7a;
-pub const OP_breg11 = 0x7b;
-pub const OP_breg12 = 0x7c;
-pub const OP_breg13 = 0x7d;
-pub const OP_breg14 = 0x7e;
-pub const OP_breg15 = 0x7f;
-pub const OP_breg16 = 0x80;
-pub const OP_breg17 = 0x81;
-pub const OP_breg18 = 0x82;
-pub const OP_breg19 = 0x83;
-pub const OP_breg20 = 0x84;
-pub const OP_breg21 = 0x85;
-pub const OP_breg22 = 0x86;
-pub const OP_breg23 = 0x87;
-pub const OP_breg24 = 0x88;
-pub const OP_breg25 = 0x89;
-pub const OP_breg26 = 0x8a;
-pub const OP_breg27 = 0x8b;
-pub const OP_breg28 = 0x8c;
-pub const OP_breg29 = 0x8d;
-pub const OP_breg30 = 0x8e;
-pub const OP_breg31 = 0x8f;
-pub const OP_regx = 0x90;
-pub const OP_fbreg = 0x91;
-pub const OP_bregx = 0x92;
-pub const OP_piece = 0x93;
-pub const OP_deref_size = 0x94;
-pub const OP_xderef_size = 0x95;
-pub const OP_nop = 0x96;
-
-// DWARF 3 extensions.
-pub const OP_push_object_address = 0x97;
-pub const OP_call2 = 0x98;
-pub const OP_call4 = 0x99;
-pub const OP_call_ref = 0x9a;
-pub const OP_form_tls_address = 0x9b;
-pub const OP_call_frame_cfa = 0x9c;
-pub const OP_bit_piece = 0x9d;
-
-// DWARF 4 extensions.
-pub const OP_implicit_value = 0x9e;
-pub const OP_stack_value = 0x9f;
-
-pub const OP_lo_user = 0xe0; // Implementation-defined range start.
-pub const OP_hi_user = 0xff; // Implementation-defined range end.
-
-// GNU extensions.
-pub const OP_GNU_push_tls_address = 0xe0;
-// The following is for marking variables that are uninitialized.
-pub const OP_GNU_uninit = 0xf0;
-pub const OP_GNU_encoded_addr = 0xf1;
-// The GNU implicit pointer extension.
-// See http://www.dwarfstd.org/ShowIssue.php?issue=100831.1&type=open .
-pub const OP_GNU_implicit_pointer = 0xf2;
-// The GNU entry value extension.
-// See http://www.dwarfstd.org/ShowIssue.php?issue=100909.1&type=open .
-pub const OP_GNU_entry_value = 0xf3;
-// The GNU typed stack extension.
-// See http://www.dwarfstd.org/doc/040408.1.html .
-pub const OP_GNU_const_type = 0xf4;
-pub const OP_GNU_regval_type = 0xf5;
-pub const OP_GNU_deref_type = 0xf6;
-pub const OP_GNU_convert = 0xf7;
-pub const OP_GNU_reinterpret = 0xf9;
-// The GNU parameter ref extension.
-pub const OP_GNU_parameter_ref = 0xfa;
-// Extension for Fission. See http://gcc.gnu.org/wiki/DebugFission.
-pub const OP_GNU_addr_index = 0xfb;
-pub const OP_GNU_const_index = 0xfc;
-// HP extensions.
-pub const OP_HP_unknown = 0xe0; // Ouch, the same as GNU_push_tls_address.
-pub const OP_HP_is_value = 0xe1;
-pub const OP_HP_fltconst4 = 0xe2;
-pub const OP_HP_fltconst8 = 0xe3;
-pub const OP_HP_mod_range = 0xe4;
-pub const OP_HP_unmod_range = 0xe5;
-pub const OP_HP_tls = 0xe6;
-// PGI (STMicroelectronics) extensions.
-pub const OP_PGI_omp_thread_num = 0xf8;
-
-pub const ATE_void = 0x0;
-pub const ATE_address = 0x1;
-pub const ATE_boolean = 0x2;
-pub const ATE_complex_float = 0x3;
-pub const ATE_float = 0x4;
-pub const ATE_signed = 0x5;
-pub const ATE_signed_char = 0x6;
-pub const ATE_unsigned = 0x7;
-pub const ATE_unsigned_char = 0x8;
-
-// DWARF 3.
-pub const ATE_imaginary_float = 0x9;
-pub const ATE_packed_decimal = 0xa;
-pub const ATE_numeric_string = 0xb;
-pub const ATE_edited = 0xc;
-pub const ATE_signed_fixed = 0xd;
-pub const ATE_unsigned_fixed = 0xe;
-pub const ATE_decimal_float = 0xf;
-
-// DWARF 4.
-pub const ATE_UTF = 0x10;
-
-pub const ATE_lo_user = 0x80;
-pub const ATE_hi_user = 0xff;
-
-// HP extensions.
-pub const ATE_HP_float80 = 0x80; // Floating-point (80 bit).
-pub const ATE_HP_complex_float80 = 0x81; // Complex floating-point (80 bit).
-pub const ATE_HP_float128 = 0x82; // Floating-point (128 bit).
-pub const ATE_HP_complex_float128 = 0x83; // Complex fp (128 bit).
-pub const ATE_HP_floathpintel = 0x84; // Floating-point (82 bit IA64).
-pub const ATE_HP_imaginary_float80 = 0x85;
-pub const ATE_HP_imaginary_float128 = 0x86;
-pub const ATE_HP_VAX_float = 0x88; // F or G floating.
-pub const ATE_HP_VAX_float_d = 0x89; // D floating.
-pub const ATE_HP_packed_decimal = 0x8a; // Cobol.
-pub const ATE_HP_zoned_decimal = 0x8b; // Cobol.
-pub const ATE_HP_edited = 0x8c; // Cobol.
-pub const ATE_HP_signed_fixed = 0x8d; // Cobol.
-pub const ATE_HP_unsigned_fixed = 0x8e; // Cobol.
-pub const ATE_HP_VAX_complex_float = 0x8f; // F or G floating complex.
-pub const ATE_HP_VAX_complex_float_d = 0x90; // D floating complex.
-
-pub const CFA_advance_loc = 0x40;
-pub const CFA_offset = 0x80;
-pub const CFA_restore = 0xc0;
-pub const CFA_nop = 0x00;
-pub const CFA_set_loc = 0x01;
-pub const CFA_advance_loc1 = 0x02;
-pub const CFA_advance_loc2 = 0x03;
-pub const CFA_advance_loc4 = 0x04;
-pub const CFA_offset_extended = 0x05;
-pub const CFA_restore_extended = 0x06;
-pub const CFA_undefined = 0x07;
-pub const CFA_same_value = 0x08;
-pub const CFA_register = 0x09;
-pub const CFA_remember_state = 0x0a;
-pub const CFA_restore_state = 0x0b;
-pub const CFA_def_cfa = 0x0c;
-pub const CFA_def_cfa_register = 0x0d;
-pub const CFA_def_cfa_offset = 0x0e;
-
-// DWARF 3.
-pub const CFA_def_cfa_expression = 0x0f;
-pub const CFA_expression = 0x10;
-pub const CFA_offset_extended_sf = 0x11;
-pub const CFA_def_cfa_sf = 0x12;
-pub const CFA_def_cfa_offset_sf = 0x13;
-pub const CFA_val_offset = 0x14;
-pub const CFA_val_offset_sf = 0x15;
-pub const CFA_val_expression = 0x16;
-
-pub const CFA_lo_user = 0x1c;
-pub const CFA_hi_user = 0x3f;
-
-// SGI/MIPS specific.
-pub const CFA_MIPS_advance_loc8 = 0x1d;
-
-// GNU extensions.
-pub const CFA_GNU_window_save = 0x2d;
-pub const CFA_GNU_args_size = 0x2e;
-pub const CFA_GNU_negative_offset_extended = 0x2f;
-
-pub const CHILDREN_no = 0x00;
-pub const CHILDREN_yes = 0x01;
-
-pub const LNS_extended_op = 0x00;
-pub const LNS_copy = 0x01;
-pub const LNS_advance_pc = 0x02;
-pub const LNS_advance_line = 0x03;
-pub const LNS_set_file = 0x04;
-pub const LNS_set_column = 0x05;
-pub const LNS_negate_stmt = 0x06;
-pub const LNS_set_basic_block = 0x07;
-pub const LNS_const_add_pc = 0x08;
-pub const LNS_fixed_advance_pc = 0x09;
-pub const LNS_set_prologue_end = 0x0a;
-pub const LNS_set_epilogue_begin = 0x0b;
-pub const LNS_set_isa = 0x0c;
-
-pub const LNE_end_sequence = 0x01;
-pub const LNE_set_address = 0x02;
-pub const LNE_define_file = 0x03;
-pub const LNE_set_discriminator = 0x04;
-pub const LNE_lo_user = 0x80;
-pub const LNE_hi_user = 0xff;
-
-pub const LANG_C89 = 0x0001;
-pub const LANG_C = 0x0002;
-pub const LANG_Ada83 = 0x0003;
-pub const LANG_C_plus_plus = 0x0004;
-pub const LANG_Cobol74 = 0x0005;
-pub const LANG_Cobol85 = 0x0006;
-pub const LANG_Fortran77 = 0x0007;
-pub const LANG_Fortran90 = 0x0008;
-pub const LANG_Pascal83 = 0x0009;
-pub const LANG_Modula2 = 0x000a;
-pub const LANG_Java = 0x000b;
-pub const LANG_C99 = 0x000c;
-pub const LANG_Ada95 = 0x000d;
-pub const LANG_Fortran95 = 0x000e;
-pub const LANG_PLI = 0x000f;
-pub const LANG_ObjC = 0x0010;
-pub const LANG_ObjC_plus_plus = 0x0011;
-pub const LANG_UPC = 0x0012;
-pub const LANG_D = 0x0013;
-pub const LANG_Python = 0x0014;
-pub const LANG_Go = 0x0016;
-pub const LANG_C_plus_plus_11 = 0x001a;
-pub const LANG_Rust = 0x001c;
-pub const LANG_C11 = 0x001d;
-pub const LANG_C_plus_plus_14 = 0x0021;
-pub const LANG_Fortran03 = 0x0022;
-pub const LANG_Fortran08 = 0x0023;
-pub const LANG_lo_user = 0x8000;
-pub const LANG_hi_user = 0xffff;
-pub const LANG_Mips_Assembler = 0x8001;
-pub const LANG_Upc = 0x8765;
-pub const LANG_HP_Bliss = 0x8003;
-pub const LANG_HP_Basic91 = 0x8004;
-pub const LANG_HP_Pascal91 = 0x8005;
-pub const LANG_HP_IMacro = 0x8006;
-pub const LANG_HP_Assembler = 0x8007;
-
-pub const UT_compile = 0x01;
-pub const UT_type = 0x02;
-pub const UT_partial = 0x03;
-pub const UT_skeleton = 0x04;
-pub const UT_split_compile = 0x05;
-pub const UT_split_type = 0x06;
-pub const UT_lo_user = 0x80;
-pub const UT_hi_user = 0xff;
-
-pub const LNCT_path = 0x1;
-pub const LNCT_directory_index = 0x2;
-pub const LNCT_timestamp = 0x3;
-pub const LNCT_size = 0x4;
-pub const LNCT_MD5 = 0x5;
-pub const LNCT_lo_user = 0x2000;
-pub const LNCT_hi_user = 0x3fff;
diff --git a/lib/std/dynamic_library.zig b/lib/std/dynamic_library.zig
index bd07003bad88..fb4cefed0a2d 100644
--- a/lib/std/dynamic_library.zig
+++ b/lib/std/dynamic_library.zig
@@ -115,7 +115,7 @@ pub const ElfDynLib = struct {
/// Trusts the file. Malicious file will be able to execute arbitrary code.
pub fn open(path: []const u8) !ElfDynLib {
- const fd = try os.open(path, 0, os.O_RDONLY | os.O_CLOEXEC);
+ const fd = try os.open(path, 0, os.O.RDONLY | os.O.CLOEXEC);
defer os.close(fd);
const stat = try os.fstat(fd);
@@ -126,8 +126,8 @@ pub const ElfDynLib = struct {
const file_bytes = try os.mmap(
null,
mem.alignForward(size, mem.page_size),
- os.PROT_READ,
- os.MAP_PRIVATE,
+ os.PROT.READ,
+ os.MAP.PRIVATE,
fd,
0,
);
@@ -160,12 +160,12 @@ pub const ElfDynLib = struct {
}
const dynv = maybe_dynv orelse return error.MissingDynamicLinkingInformation;
- // Reserve the entire range (with no permissions) so that we can do MAP_FIXED below.
+ // Reserve the entire range (with no permissions) so that we can do MAP.FIXED below.
const all_loaded_mem = try os.mmap(
null,
virt_addr_end,
- os.PROT_NONE,
- os.MAP_PRIVATE | os.MAP_ANONYMOUS,
+ os.PROT.NONE,
+ os.MAP.PRIVATE | os.MAP.ANONYMOUS,
-1,
0,
);
@@ -197,7 +197,7 @@ pub const ElfDynLib = struct {
ptr,
extended_memsz,
prot,
- os.MAP_PRIVATE | os.MAP_FIXED,
+ os.MAP.PRIVATE | os.MAP.FIXED,
fd,
ph.p_offset - extra_bytes,
);
@@ -206,7 +206,7 @@ pub const ElfDynLib = struct {
ptr,
extended_memsz,
prot,
- os.MAP_PRIVATE | os.MAP_FIXED | os.MAP_ANONYMOUS,
+ os.MAP.PRIVATE | os.MAP.FIXED | os.MAP.ANONYMOUS,
-1,
0,
);
@@ -294,10 +294,10 @@ pub const ElfDynLib = struct {
}
fn elfToMmapProt(elf_prot: u64) u32 {
- var result: u32 = os.PROT_NONE;
- if ((elf_prot & elf.PF_R) != 0) result |= os.PROT_READ;
- if ((elf_prot & elf.PF_W) != 0) result |= os.PROT_WRITE;
- if ((elf_prot & elf.PF_X) != 0) result |= os.PROT_EXEC;
+ var result: u32 = os.PROT.NONE;
+ if ((elf_prot & elf.PF_R) != 0) result |= os.PROT.READ;
+ if ((elf_prot & elf.PF_W) != 0) result |= os.PROT.WRITE;
+ if ((elf_prot & elf.PF_X) != 0) result |= os.PROT.EXEC;
return result;
}
};
@@ -373,7 +373,7 @@ pub const DlDynlib = struct {
pub fn openZ(path_c: [*:0]const u8) !DlDynlib {
return DlDynlib{
- .handle = system.dlopen(path_c, system.RTLD_LAZY) orelse {
+ .handle = system.dlopen(path_c, system.RTLD.LAZY) orelse {
return error.FileNotFound;
},
};
diff --git a/lib/std/event.zig b/lib/std/event.zig
index 6e608b54f04b..b0d61afbd968 100644
--- a/lib/std/event.zig
+++ b/lib/std/event.zig
@@ -9,7 +9,7 @@ pub const RwLocked = @import("event/rwlocked.zig").RwLocked;
pub const Loop = @import("event/loop.zig").Loop;
pub const WaitGroup = @import("event/wait_group.zig").WaitGroup;
-test "import event tests" {
+test {
_ = @import("event/channel.zig");
_ = @import("event/future.zig");
_ = @import("event/group.zig");
diff --git a/lib/std/event/loop.zig b/lib/std/event/loop.zig
index 50fb76ec9d11..21211c9af002 100644
--- a/lib/std/event/loop.zig
+++ b/lib/std/event/loop.zig
@@ -457,8 +457,8 @@ pub const Loop = struct {
// Fall back to a blocking poll(). Ideally this codepath is never hit, since
// epoll should be just fine. But this is better than incorrect behavior.
var poll_flags: i16 = 0;
- if ((flags & os.EPOLLIN) != 0) poll_flags |= os.POLLIN;
- if ((flags & os.EPOLLOUT) != 0) poll_flags |= os.POLLOUT;
+ if ((flags & os.EPOLLIN) != 0) poll_flags |= os.POLL.IN;
+ if ((flags & os.EPOLLOUT) != 0) poll_flags |= os.POLL.OUT;
var pfd = [1]os.pollfd{os.pollfd{
.fd = fd,
.events = poll_flags,
@@ -903,12 +903,12 @@ pub const Loop = struct {
/// will return a value greater than was supplied to the call.
addr_size: *os.socklen_t,
/// The following values can be bitwise ORed in flags to obtain different behavior:
- /// * `SOCK_CLOEXEC` - Set the close-on-exec (`FD_CLOEXEC`) flag on the new file descriptor. See the
- /// description of the `O_CLOEXEC` flag in `open` for reasons why this may be useful.
+ /// * `SOCK.CLOEXEC` - Set the close-on-exec (`FD_CLOEXEC`) flag on the new file descriptor. See the
+ /// description of the `O.CLOEXEC` flag in `open` for reasons why this may be useful.
flags: u32,
) os.AcceptError!os.socket_t {
while (true) {
- return os.accept(sockfd, addr, addr_size, flags | os.SOCK_NONBLOCK) catch |err| switch (err) {
+ return os.accept(sockfd, addr, addr_size, flags | os.SOCK.NONBLOCK) catch |err| switch (err) {
error.WouldBlock => {
self.waitUntilFdReadable(sockfd);
continue;
diff --git a/lib/std/event/rwlock.zig b/lib/std/event/rwlock.zig
index 43d41b860e84..951f305cff50 100644
--- a/lib/std/event/rwlock.zig
+++ b/lib/std/event/rwlock.zig
@@ -4,6 +4,7 @@ const assert = std.debug.assert;
const testing = std.testing;
const mem = std.mem;
const Loop = std.event.Loop;
+const Allocator = std.mem.Allocator;
/// Thread-safe async/await lock.
/// Functions which are waiting for the lock are suspended, and
diff --git a/lib/std/fmt.zig b/lib/std/fmt.zig
index 52bc25af00bc..563a67bc89a6 100644
--- a/lib/std/fmt.zig
+++ b/lib/std/fmt.zig
@@ -902,7 +902,7 @@ pub fn formatText(
} else if (comptime std.mem.eql(u8, fmt, "Z")) {
@compileError("specifier 'Z' has been deprecated, wrap your argument in std.zig.fmtEscapes instead");
} else {
- @compileError("Unsupported format string '" ++ fmt ++ "' for type '" ++ @typeName(@TypeOf(value)) ++ "'");
+ @compileError("Unsupported format string '" ++ fmt ++ "' when formatting text");
}
}
diff --git a/lib/std/fs.zig b/lib/std/fs.zig
index 1e02c0e805cd..66eb1d6642d9 100644
--- a/lib/std/fs.zig
+++ b/lib/std/fs.zig
@@ -304,7 +304,7 @@ pub const Dir = struct {
.macos, .ios, .freebsd, .netbsd, .dragonfly, .openbsd => struct {
dir: Dir,
seek: i64,
- buf: [8192]u8, // TODO align(@alignOf(os.dirent)),
+ buf: [8192]u8, // TODO align(@alignOf(os.system.dirent)),
index: usize,
end_index: usize,
@@ -344,7 +344,7 @@ pub const Dir = struct {
self.index = 0;
self.end_index = @intCast(usize, rc);
}
- const darwin_entry = @ptrCast(*align(1) os.dirent, &self.buf[self.index]);
+ const darwin_entry = @ptrCast(*align(1) os.system.dirent, &self.buf[self.index]);
const next_index = self.index + darwin_entry.reclen();
self.index = next_index;
@@ -355,14 +355,14 @@ pub const Dir = struct {
}
const entry_kind = switch (darwin_entry.d_type) {
- os.DT_BLK => Entry.Kind.BlockDevice,
- os.DT_CHR => Entry.Kind.CharacterDevice,
- os.DT_DIR => Entry.Kind.Directory,
- os.DT_FIFO => Entry.Kind.NamedPipe,
- os.DT_LNK => Entry.Kind.SymLink,
- os.DT_REG => Entry.Kind.File,
- os.DT_SOCK => Entry.Kind.UnixDomainSocket,
- os.DT_WHT => Entry.Kind.Whiteout,
+ os.DT.BLK => Entry.Kind.BlockDevice,
+ os.DT.CHR => Entry.Kind.CharacterDevice,
+ os.DT.DIR => Entry.Kind.Directory,
+ os.DT.FIFO => Entry.Kind.NamedPipe,
+ os.DT.LNK => Entry.Kind.SymLink,
+ os.DT.REG => Entry.Kind.File,
+ os.DT.SOCK => Entry.Kind.UnixDomainSocket,
+ os.DT.WHT => Entry.Kind.Whiteout,
else => Entry.Kind.Unknown,
};
return Entry{
@@ -391,7 +391,7 @@ pub const Dir = struct {
self.index = 0;
self.end_index = @intCast(usize, rc);
}
- const bsd_entry = @ptrCast(*align(1) os.dirent, &self.buf[self.index]);
+ const bsd_entry = @ptrCast(*align(1) os.system.dirent, &self.buf[self.index]);
const next_index = self.index + bsd_entry.reclen();
self.index = next_index;
@@ -409,14 +409,14 @@ pub const Dir = struct {
}
const entry_kind = switch (bsd_entry.d_type) {
- os.DT_BLK => Entry.Kind.BlockDevice,
- os.DT_CHR => Entry.Kind.CharacterDevice,
- os.DT_DIR => Entry.Kind.Directory,
- os.DT_FIFO => Entry.Kind.NamedPipe,
- os.DT_LNK => Entry.Kind.SymLink,
- os.DT_REG => Entry.Kind.File,
- os.DT_SOCK => Entry.Kind.UnixDomainSocket,
- os.DT_WHT => Entry.Kind.Whiteout,
+ os.DT.BLK => Entry.Kind.BlockDevice,
+ os.DT.CHR => Entry.Kind.CharacterDevice,
+ os.DT.DIR => Entry.Kind.Directory,
+ os.DT.FIFO => Entry.Kind.NamedPipe,
+ os.DT.LNK => Entry.Kind.SymLink,
+ os.DT.REG => Entry.Kind.File,
+ os.DT.SOCK => Entry.Kind.UnixDomainSocket,
+ os.DT.WHT => Entry.Kind.Whiteout,
else => Entry.Kind.Unknown,
};
return Entry{
@@ -462,7 +462,7 @@ pub const Dir = struct {
self.index = 0;
self.end_index = @intCast(usize, rc);
}
- const haiku_entry = @ptrCast(*align(1) os.dirent, &self.buf[self.index]);
+ const haiku_entry = @ptrCast(*align(1) os.system.dirent, &self.buf[self.index]);
const next_index = self.index + haiku_entry.reclen();
self.index = next_index;
const name = mem.spanZ(@ptrCast([*:0]u8, &haiku_entry.d_name));
@@ -471,7 +471,7 @@ pub const Dir = struct {
continue :start_over;
}
- var stat_info: os.libc_stat = undefined;
+ var stat_info: os.Stat = undefined;
_ = os.system._kern_read_stat(
self.dir.fd,
&haiku_entry.d_name,
@@ -479,15 +479,15 @@ pub const Dir = struct {
&stat_info,
0,
);
- const statmode = stat_info.mode & os.S_IFMT;
+ const statmode = stat_info.mode & os.S.IFMT;
const entry_kind = switch (statmode) {
- os.S_IFDIR => Entry.Kind.Directory,
- os.S_IFBLK => Entry.Kind.BlockDevice,
- os.S_IFCHR => Entry.Kind.CharacterDevice,
- os.S_IFLNK => Entry.Kind.SymLink,
- os.S_IFREG => Entry.Kind.File,
- os.S_IFIFO => Entry.Kind.NamedPipe,
+ os.S.IFDIR => Entry.Kind.Directory,
+ os.S.IFBLK => Entry.Kind.BlockDevice,
+ os.S.IFCHR => Entry.Kind.CharacterDevice,
+ os.S.IFLNK => Entry.Kind.SymLink,
+ os.S.IFREG => Entry.Kind.File,
+ os.S.IFIFO => Entry.Kind.NamedPipe,
else => Entry.Kind.Unknown,
};
@@ -500,13 +500,14 @@ pub const Dir = struct {
},
.linux => struct {
dir: Dir,
- // The if guard is solely there to prevent compile errors from missing `os.linux.dirent64`
+ // The if guard is solely there to prevent compile errors from missing `linux.dirent64`
// definition when compiling for other OSes. It doesn't do anything when compiling for Linux.
- buf: [8192]u8 align(if (builtin.os.tag != .linux) 1 else @alignOf(os.linux.dirent64)),
+ buf: [8192]u8 align(if (builtin.os.tag != .linux) 1 else @alignOf(linux.dirent64)),
index: usize,
end_index: usize,
const Self = @This();
+ const linux = os.linux;
pub const Error = IteratorError;
@@ -515,8 +516,8 @@ pub const Dir = struct {
pub fn next(self: *Self) Error!?Entry {
start_over: while (true) {
if (self.index >= self.end_index) {
- const rc = os.linux.getdents64(self.dir.fd, &self.buf, self.buf.len);
- switch (os.linux.getErrno(rc)) {
+ const rc = linux.getdents64(self.dir.fd, &self.buf, self.buf.len);
+ switch (linux.getErrno(rc)) {
.SUCCESS => {},
.BADF => unreachable, // Dir is invalid or was opened without iteration ability
.FAULT => unreachable,
@@ -528,7 +529,7 @@ pub const Dir = struct {
self.index = 0;
self.end_index = rc;
}
- const linux_entry = @ptrCast(*align(1) os.dirent64, &self.buf[self.index]);
+ const linux_entry = @ptrCast(*align(1) linux.dirent64, &self.buf[self.index]);
const next_index = self.index + linux_entry.reclen();
self.index = next_index;
@@ -540,13 +541,13 @@ pub const Dir = struct {
}
const entry_kind = switch (linux_entry.d_type) {
- os.DT_BLK => Entry.Kind.BlockDevice,
- os.DT_CHR => Entry.Kind.CharacterDevice,
- os.DT_DIR => Entry.Kind.Directory,
- os.DT_FIFO => Entry.Kind.NamedPipe,
- os.DT_LNK => Entry.Kind.SymLink,
- os.DT_REG => Entry.Kind.File,
- os.DT_SOCK => Entry.Kind.UnixDomainSocket,
+ linux.DT.BLK => Entry.Kind.BlockDevice,
+ linux.DT.CHR => Entry.Kind.CharacterDevice,
+ linux.DT.DIR => Entry.Kind.Directory,
+ linux.DT.FIFO => Entry.Kind.NamedPipe,
+ linux.DT.LNK => Entry.Kind.SymLink,
+ linux.DT.REG => Entry.Kind.File,
+ linux.DT.SOCK => Entry.Kind.UnixDomainSocket,
else => Entry.Kind.Unknown,
};
return Entry{
@@ -677,12 +678,12 @@ pub const Dir = struct {
}
const entry_kind = switch (entry.d_type) {
- w.FILETYPE_BLOCK_DEVICE => Entry.Kind.BlockDevice,
- w.FILETYPE_CHARACTER_DEVICE => Entry.Kind.CharacterDevice,
- w.FILETYPE_DIRECTORY => Entry.Kind.Directory,
- w.FILETYPE_SYMBOLIC_LINK => Entry.Kind.SymLink,
- w.FILETYPE_REGULAR_FILE => Entry.Kind.File,
- w.FILETYPE_SOCKET_STREAM, wasi.FILETYPE_SOCKET_DGRAM => Entry.Kind.UnixDomainSocket,
+ .BLOCK_DEVICE => Entry.Kind.BlockDevice,
+ .CHARACTER_DEVICE => Entry.Kind.CharacterDevice,
+ .DIRECTORY => Entry.Kind.Directory,
+ .SYMBOLIC_LINK => Entry.Kind.SymLink,
+ .REGULAR_FILE => Entry.Kind.File,
+ .SOCKET_STREAM, .SOCKET_DGRAM => Entry.Kind.UnixDomainSocket,
else => Entry.Kind.Unknown,
};
return Entry{
@@ -879,20 +880,20 @@ pub const Dir = struct {
var fdflags: w.fdflags_t = 0x0;
var base: w.rights_t = 0x0;
if (flags.read) {
- base |= w.RIGHT_FD_READ | w.RIGHT_FD_TELL | w.RIGHT_FD_SEEK | w.RIGHT_FD_FILESTAT_GET;
+ base |= w.RIGHT.FD_READ | w.RIGHT.FD_TELL | w.RIGHT.FD_SEEK | w.RIGHT.FD_FILESTAT_GET;
}
if (flags.write) {
- fdflags |= w.FDFLAG_APPEND;
- base |= w.RIGHT_FD_WRITE |
- w.RIGHT_FD_TELL |
- w.RIGHT_FD_SEEK |
- w.RIGHT_FD_DATASYNC |
- w.RIGHT_FD_FDSTAT_SET_FLAGS |
- w.RIGHT_FD_SYNC |
- w.RIGHT_FD_ALLOCATE |
- w.RIGHT_FD_ADVISE |
- w.RIGHT_FD_FILESTAT_SET_TIMES |
- w.RIGHT_FD_FILESTAT_SET_SIZE;
+ fdflags |= w.FDFLAG.APPEND;
+ base |= w.RIGHT.FD_WRITE |
+ w.RIGHT.FD_TELL |
+ w.RIGHT.FD_SEEK |
+ w.RIGHT.FD_DATASYNC |
+ w.RIGHT.FD_FDSTAT_SET_FLAGS |
+ w.RIGHT.FD_SYNC |
+ w.RIGHT.FD_ALLOCATE |
+ w.RIGHT.FD_ADVISE |
+ w.RIGHT.FD_FILESTAT_SET_TIMES |
+ w.RIGHT.FD_FILESTAT_SET_SIZE;
}
const fd = try os.openatWasi(self.fd, sub_path, 0x0, 0x0, fdflags, base, 0x0);
return File{ .handle = fd };
@@ -907,35 +908,35 @@ pub const Dir = struct {
return self.openFileW(path_w.span(), flags);
}
- var os_flags: u32 = os.O_CLOEXEC;
- // Use the O_ locking flags if the os supports them to acquire the lock
+ var os_flags: u32 = os.O.CLOEXEC;
+ // Use the O locking flags if the os supports them to acquire the lock
// atomically.
- const has_flock_open_flags = @hasDecl(os, "O_EXLOCK");
+ const has_flock_open_flags = @hasDecl(os.O, "EXLOCK");
if (has_flock_open_flags) {
- // Note that the O_NONBLOCK flag is removed after the openat() call
+ // Note that the O.NONBLOCK flag is removed after the openat() call
// is successful.
const nonblocking_lock_flag: u32 = if (flags.lock_nonblocking)
- os.O_NONBLOCK
+ os.O.NONBLOCK
else
0;
os_flags |= switch (flags.lock) {
.None => @as(u32, 0),
- .Shared => os.O_SHLOCK | nonblocking_lock_flag,
- .Exclusive => os.O_EXLOCK | nonblocking_lock_flag,
+ .Shared => os.O.SHLOCK | nonblocking_lock_flag,
+ .Exclusive => os.O.EXLOCK | nonblocking_lock_flag,
};
}
- if (@hasDecl(os, "O_LARGEFILE")) {
- os_flags |= os.O_LARGEFILE;
+ if (@hasDecl(os.O, "LARGEFILE")) {
+ os_flags |= os.O.LARGEFILE;
}
if (!flags.allow_ctty) {
- os_flags |= os.O_NOCTTY;
+ os_flags |= os.O.NOCTTY;
}
os_flags |= if (flags.write and flags.read)
- @as(u32, os.O_RDWR)
+ @as(u32, os.O.RDWR)
else if (flags.write)
- @as(u32, os.O_WRONLY)
+ @as(u32, os.O.WRONLY)
else
- @as(u32, os.O_RDONLY);
+ @as(u32, os.O.RDONLY);
const fd = if (flags.intended_io_mode != .blocking)
try std.event.Loop.instance.?.openatZ(self.fd, sub_path, os_flags, 0)
else
@@ -947,24 +948,24 @@ pub const Dir = struct {
if (builtin.target.os.tag != .wasi) {
if (!has_flock_open_flags and flags.lock != .None) {
// TODO: integrate async I/O
- const lock_nonblocking = if (flags.lock_nonblocking) os.LOCK_NB else @as(i32, 0);
+ const lock_nonblocking = if (flags.lock_nonblocking) os.LOCK.NB else @as(i32, 0);
try os.flock(fd, switch (flags.lock) {
.None => unreachable,
- .Shared => os.LOCK_SH | lock_nonblocking,
- .Exclusive => os.LOCK_EX | lock_nonblocking,
+ .Shared => os.LOCK.SH | lock_nonblocking,
+ .Exclusive => os.LOCK.EX | lock_nonblocking,
});
}
}
if (has_flock_open_flags and flags.lock_nonblocking) {
- var fl_flags = os.fcntl(fd, os.F_GETFL, 0) catch |err| switch (err) {
+ var fl_flags = os.fcntl(fd, os.F.GETFL, 0) catch |err| switch (err) {
error.FileBusy => unreachable,
error.Locked => unreachable,
error.PermissionDenied => unreachable,
else => |e| return e,
};
- fl_flags &= ~@as(usize, os.O_NONBLOCK);
- _ = os.fcntl(fd, os.F_SETFL, fl_flags) catch |err| switch (err) {
+ fl_flags &= ~@as(usize, os.O.NONBLOCK);
+ _ = os.fcntl(fd, os.F.SETFL, fl_flags) catch |err| switch (err) {
error.FileBusy => unreachable,
error.Locked => unreachable,
error.PermissionDenied => unreachable,
@@ -1038,26 +1039,26 @@ pub const Dir = struct {
/// Same as `createFile` but WASI only.
pub fn createFileWasi(self: Dir, sub_path: []const u8, flags: File.CreateFlags) File.OpenError!File {
const w = os.wasi;
- var oflags = w.O_CREAT;
- var base: w.rights_t = w.RIGHT_FD_WRITE |
- w.RIGHT_FD_DATASYNC |
- w.RIGHT_FD_SEEK |
- w.RIGHT_FD_TELL |
- w.RIGHT_FD_FDSTAT_SET_FLAGS |
- w.RIGHT_FD_SYNC |
- w.RIGHT_FD_ALLOCATE |
- w.RIGHT_FD_ADVISE |
- w.RIGHT_FD_FILESTAT_SET_TIMES |
- w.RIGHT_FD_FILESTAT_SET_SIZE |
- w.RIGHT_FD_FILESTAT_GET;
+ var oflags = w.O.CREAT;
+ var base: w.rights_t = w.RIGHT.FD_WRITE |
+ w.RIGHT.FD_DATASYNC |
+ w.RIGHT.FD_SEEK |
+ w.RIGHT.FD_TELL |
+ w.RIGHT.FD_FDSTAT_SET_FLAGS |
+ w.RIGHT.FD_SYNC |
+ w.RIGHT.FD_ALLOCATE |
+ w.RIGHT.FD_ADVISE |
+ w.RIGHT.FD_FILESTAT_SET_TIMES |
+ w.RIGHT.FD_FILESTAT_SET_SIZE |
+ w.RIGHT.FD_FILESTAT_GET;
if (flags.read) {
- base |= w.RIGHT_FD_READ;
+ base |= w.RIGHT.FD_READ;
}
if (flags.truncate) {
- oflags |= w.O_TRUNC;
+ oflags |= w.O.TRUNC;
}
if (flags.exclusive) {
- oflags |= w.O_EXCL;
+ oflags |= w.O.EXCL;
}
const fd = try os.openatWasi(self.fd, sub_path, 0x0, oflags, 0x0, base, 0x0);
return File{ .handle = fd };
@@ -1070,26 +1071,26 @@ pub const Dir = struct {
return self.createFileW(path_w.span(), flags);
}
- // Use the O_ locking flags if the os supports them to acquire the lock
+ // Use the O locking flags if the os supports them to acquire the lock
// atomically.
- const has_flock_open_flags = @hasDecl(os, "O_EXLOCK");
- // Note that the O_NONBLOCK flag is removed after the openat() call
+ const has_flock_open_flags = @hasDecl(os.O, "EXLOCK");
+ // Note that the O.NONBLOCK flag is removed after the openat() call
// is successful.
const nonblocking_lock_flag: u32 = if (has_flock_open_flags and flags.lock_nonblocking)
- os.O_NONBLOCK
+ os.O.NONBLOCK
else
0;
const lock_flag: u32 = if (has_flock_open_flags) switch (flags.lock) {
.None => @as(u32, 0),
- .Shared => os.O_SHLOCK | nonblocking_lock_flag,
- .Exclusive => os.O_EXLOCK | nonblocking_lock_flag,
+ .Shared => os.O.SHLOCK | nonblocking_lock_flag,
+ .Exclusive => os.O.EXLOCK | nonblocking_lock_flag,
} else 0;
- const O_LARGEFILE = if (@hasDecl(os, "O_LARGEFILE")) os.O_LARGEFILE else 0;
- const os_flags = lock_flag | O_LARGEFILE | os.O_CREAT | os.O_CLOEXEC |
- (if (flags.truncate) @as(u32, os.O_TRUNC) else 0) |
- (if (flags.read) @as(u32, os.O_RDWR) else os.O_WRONLY) |
- (if (flags.exclusive) @as(u32, os.O_EXCL) else 0);
+ const O_LARGEFILE = if (@hasDecl(os.O, "LARGEFILE")) os.O.LARGEFILE else 0;
+ const os_flags = lock_flag | O_LARGEFILE | os.O.CREAT | os.O.CLOEXEC |
+ (if (flags.truncate) @as(u32, os.O.TRUNC) else 0) |
+ (if (flags.read) @as(u32, os.O.RDWR) else os.O.WRONLY) |
+ (if (flags.exclusive) @as(u32, os.O.EXCL) else 0);
const fd = if (flags.intended_io_mode != .blocking)
try std.event.Loop.instance.?.openatZ(self.fd, sub_path_c, os_flags, flags.mode)
else
@@ -1101,24 +1102,24 @@ pub const Dir = struct {
if (builtin.target.os.tag != .wasi) {
if (!has_flock_open_flags and flags.lock != .None) {
// TODO: integrate async I/O
- const lock_nonblocking = if (flags.lock_nonblocking) os.LOCK_NB else @as(i32, 0);
+ const lock_nonblocking = if (flags.lock_nonblocking) os.LOCK.NB else @as(i32, 0);
try os.flock(fd, switch (flags.lock) {
.None => unreachable,
- .Shared => os.LOCK_SH | lock_nonblocking,
- .Exclusive => os.LOCK_EX | lock_nonblocking,
+ .Shared => os.LOCK.SH | lock_nonblocking,
+ .Exclusive => os.LOCK.EX | lock_nonblocking,
});
}
}
if (has_flock_open_flags and flags.lock_nonblocking) {
- var fl_flags = os.fcntl(fd, os.F_GETFL, 0) catch |err| switch (err) {
+ var fl_flags = os.fcntl(fd, os.F.GETFL, 0) catch |err| switch (err) {
error.FileBusy => unreachable,
error.Locked => unreachable,
error.PermissionDenied => unreachable,
else => |e| return e,
};
- fl_flags &= ~@as(usize, os.O_NONBLOCK);
- _ = os.fcntl(fd, os.F_SETFL, fl_flags) catch |err| switch (err) {
+ fl_flags &= ~@as(usize, os.O.NONBLOCK);
+ _ = os.fcntl(fd, os.F.SETFL, fl_flags) catch |err| switch (err) {
error.FileBusy => unreachable,
error.Locked => unreachable,
error.PermissionDenied => unreachable,
@@ -1262,7 +1263,7 @@ pub const Dir = struct {
return self.realpathW(pathname_w.span(), out_buffer);
}
- const flags = if (builtin.os.tag == .linux) os.O_PATH | os.O_NONBLOCK | os.O_CLOEXEC else os.O_NONBLOCK | os.O_CLOEXEC;
+ const flags = if (builtin.os.tag == .linux) os.O.PATH | os.O.NONBLOCK | os.O.CLOEXEC else os.O.NONBLOCK | os.O.CLOEXEC;
const fd = os.openatZ(self.fd, pathname, flags, 0) catch |err| switch (err) {
error.FileLocksNotSupported => unreachable,
else => |e| return e,
@@ -1401,34 +1402,34 @@ pub const Dir = struct {
/// Same as `openDir` except only WASI.
pub fn openDirWasi(self: Dir, sub_path: []const u8, args: OpenDirOptions) OpenError!Dir {
const w = os.wasi;
- var base: w.rights_t = w.RIGHT_FD_FILESTAT_GET | w.RIGHT_FD_FDSTAT_SET_FLAGS | w.RIGHT_FD_FILESTAT_SET_TIMES;
+ var base: w.rights_t = w.RIGHT.FD_FILESTAT_GET | w.RIGHT.FD_FDSTAT_SET_FLAGS | w.RIGHT.FD_FILESTAT_SET_TIMES;
if (args.access_sub_paths) {
- base |= w.RIGHT_FD_READDIR |
- w.RIGHT_PATH_CREATE_DIRECTORY |
- w.RIGHT_PATH_CREATE_FILE |
- w.RIGHT_PATH_LINK_SOURCE |
- w.RIGHT_PATH_LINK_TARGET |
- w.RIGHT_PATH_OPEN |
- w.RIGHT_PATH_READLINK |
- w.RIGHT_PATH_RENAME_SOURCE |
- w.RIGHT_PATH_RENAME_TARGET |
- w.RIGHT_PATH_FILESTAT_GET |
- w.RIGHT_PATH_FILESTAT_SET_SIZE |
- w.RIGHT_PATH_FILESTAT_SET_TIMES |
- w.RIGHT_PATH_SYMLINK |
- w.RIGHT_PATH_REMOVE_DIRECTORY |
- w.RIGHT_PATH_UNLINK_FILE;
+ base |= w.RIGHT.FD_READDIR |
+ w.RIGHT.PATH_CREATE_DIRECTORY |
+ w.RIGHT.PATH_CREATE_FILE |
+ w.RIGHT.PATH_LINK_SOURCE |
+ w.RIGHT.PATH_LINK_TARGET |
+ w.RIGHT.PATH_OPEN |
+ w.RIGHT.PATH_READLINK |
+ w.RIGHT.PATH_RENAME_SOURCE |
+ w.RIGHT.PATH_RENAME_TARGET |
+ w.RIGHT.PATH_FILESTAT_GET |
+ w.RIGHT.PATH_FILESTAT_SET_SIZE |
+ w.RIGHT.PATH_FILESTAT_SET_TIMES |
+ w.RIGHT.PATH_SYMLINK |
+ w.RIGHT.PATH_REMOVE_DIRECTORY |
+ w.RIGHT.PATH_UNLINK_FILE;
}
const symlink_flags: w.lookupflags_t = if (args.no_follow) 0x0 else w.LOOKUP_SYMLINK_FOLLOW;
// TODO do we really need all the rights here?
- const inheriting: w.rights_t = w.RIGHT_ALL ^ w.RIGHT_SOCK_SHUTDOWN;
+ const inheriting: w.rights_t = w.RIGHT.ALL ^ w.RIGHT.SOCK_SHUTDOWN;
- const result = os.openatWasi(self.fd, sub_path, symlink_flags, w.O_DIRECTORY, 0x0, base, inheriting);
+ const result = os.openatWasi(self.fd, sub_path, symlink_flags, w.O.DIRECTORY, 0x0, base, inheriting);
const fd = result catch |err| switch (err) {
error.FileTooBig => unreachable, // can't happen for directories
- error.IsDir => unreachable, // we're providing O_DIRECTORY
- error.NoSpaceLeft => unreachable, // not providing O_CREAT
- error.PathAlreadyExists => unreachable, // not providing O_CREAT
+ error.IsDir => unreachable, // we're providing O.DIRECTORY
+ error.NoSpaceLeft => unreachable, // not providing O.CREAT
+ error.PathAlreadyExists => unreachable, // not providing O.CREAT
error.FileLocksNotSupported => unreachable, // locking folders is not supported
error.WouldBlock => unreachable, // can't happen for directories
else => |e| return e,
@@ -1442,12 +1443,12 @@ pub const Dir = struct {
const sub_path_w = try os.windows.cStrToPrefixedFileW(sub_path_c);
return self.openDirW(sub_path_w.span().ptr, args);
}
- const symlink_flags: u32 = if (args.no_follow) os.O_NOFOLLOW else 0x0;
+ const symlink_flags: u32 = if (args.no_follow) os.O.NOFOLLOW else 0x0;
if (!args.iterate) {
- const O_PATH = if (@hasDecl(os, "O_PATH")) os.O_PATH else 0;
- return self.openDirFlagsZ(sub_path_c, os.O_DIRECTORY | os.O_RDONLY | os.O_CLOEXEC | O_PATH | symlink_flags);
+ const O_PATH = if (@hasDecl(os.O, "PATH")) os.O.PATH else 0;
+ return self.openDirFlagsZ(sub_path_c, os.O.DIRECTORY | os.O.RDONLY | os.O.CLOEXEC | O_PATH | symlink_flags);
} else {
- return self.openDirFlagsZ(sub_path_c, os.O_DIRECTORY | os.O_RDONLY | os.O_CLOEXEC | symlink_flags);
+ return self.openDirFlagsZ(sub_path_c, os.O.DIRECTORY | os.O.RDONLY | os.O.CLOEXEC | symlink_flags);
}
}
@@ -1462,7 +1463,7 @@ pub const Dir = struct {
return self.openDirAccessMaskW(sub_path_w, flags, args.no_follow);
}
- /// `flags` must contain `os.O_DIRECTORY`.
+ /// `flags` must contain `os.O.DIRECTORY`.
fn openDirFlagsZ(self: Dir, sub_path_c: [*:0]const u8, flags: u32) OpenError!Dir {
const result = if (need_async_thread)
std.event.Loop.instance.?.openatZ(self.fd, sub_path_c, flags, 0)
@@ -1470,9 +1471,9 @@ pub const Dir = struct {
os.openatZ(self.fd, sub_path_c, flags, 0);
const fd = result catch |err| switch (err) {
error.FileTooBig => unreachable, // can't happen for directories
- error.IsDir => unreachable, // we're providing O_DIRECTORY
- error.NoSpaceLeft => unreachable, // not providing O_CREAT
- error.PathAlreadyExists => unreachable, // not providing O_CREAT
+ error.IsDir => unreachable, // we're providing O.DIRECTORY
+ error.NoSpaceLeft => unreachable, // not providing O.CREAT
+ error.PathAlreadyExists => unreachable, // not providing O.CREAT
error.FileLocksNotSupported => unreachable, // locking folders is not supported
error.WouldBlock => unreachable, // can't happen for directories
else => |e| return e,
@@ -1537,7 +1538,7 @@ pub const Dir = struct {
return self.deleteFileW(sub_path_w.span());
} else if (builtin.os.tag == .wasi and !builtin.link_libc) {
os.unlinkatWasi(self.fd, sub_path, 0) catch |err| switch (err) {
- error.DirNotEmpty => unreachable, // not passing AT_REMOVEDIR
+ error.DirNotEmpty => unreachable, // not passing AT.REMOVEDIR
else => |e| return e,
};
} else {
@@ -1551,14 +1552,14 @@ pub const Dir = struct {
/// Same as `deleteFile` except the parameter is null-terminated.
pub fn deleteFileZ(self: Dir, sub_path_c: [*:0]const u8) DeleteFileError!void {
os.unlinkatZ(self.fd, sub_path_c, 0) catch |err| switch (err) {
- error.DirNotEmpty => unreachable, // not passing AT_REMOVEDIR
+ error.DirNotEmpty => unreachable, // not passing AT.REMOVEDIR
error.AccessDenied => |e| switch (builtin.os.tag) {
// non-Linux POSIX systems return EPERM when trying to delete a directory, so
// we need to handle that case specifically and translate the error
.macos, .ios, .freebsd, .netbsd, .dragonfly, .openbsd => {
// Don't follow symlinks to match unlinkat (which acts on symlinks rather than follows them)
- const fstat = os.fstatatZ(self.fd, sub_path_c, os.AT_SYMLINK_NOFOLLOW) catch return e;
- const is_dir = fstat.mode & os.S_IFMT == os.S_IFDIR;
+ const fstat = os.fstatatZ(self.fd, sub_path_c, os.AT.SYMLINK_NOFOLLOW) catch return e;
+ const is_dir = fstat.mode & os.S.IFMT == os.S.IFDIR;
return if (is_dir) error.IsDir else e;
},
else => return e,
@@ -1570,7 +1571,7 @@ pub const Dir = struct {
/// Same as `deleteFile` except the parameter is WTF-16 encoded.
pub fn deleteFileW(self: Dir, sub_path_w: []const u16) DeleteFileError!void {
os.unlinkatW(self.fd, sub_path_w, 0) catch |err| switch (err) {
- error.DirNotEmpty => unreachable, // not passing AT_REMOVEDIR
+ error.DirNotEmpty => unreachable, // not passing AT.REMOVEDIR
else => |e| return e,
};
}
@@ -1599,8 +1600,8 @@ pub const Dir = struct {
const sub_path_w = try os.windows.sliceToPrefixedFileW(sub_path);
return self.deleteDirW(sub_path_w.span());
} else if (builtin.os.tag == .wasi and !builtin.link_libc) {
- os.unlinkat(self.fd, sub_path, os.AT_REMOVEDIR) catch |err| switch (err) {
- error.IsDir => unreachable, // not possible since we pass AT_REMOVEDIR
+ os.unlinkat(self.fd, sub_path, os.AT.REMOVEDIR) catch |err| switch (err) {
+ error.IsDir => unreachable, // not possible since we pass AT.REMOVEDIR
else => |e| return e,
};
} else {
@@ -1611,8 +1612,8 @@ pub const Dir = struct {
/// Same as `deleteDir` except the parameter is null-terminated.
pub fn deleteDirZ(self: Dir, sub_path_c: [*:0]const u8) DeleteDirError!void {
- os.unlinkatZ(self.fd, sub_path_c, os.AT_REMOVEDIR) catch |err| switch (err) {
- error.IsDir => unreachable, // not possible since we pass AT_REMOVEDIR
+ os.unlinkatZ(self.fd, sub_path_c, os.AT.REMOVEDIR) catch |err| switch (err) {
+ error.IsDir => unreachable, // not possible since we pass AT.REMOVEDIR
else => |e| return e,
};
}
@@ -1620,8 +1621,8 @@ pub const Dir = struct {
/// Same as `deleteDir` except the parameter is UTF16LE, NT prefixed.
/// This function is Windows-only.
pub fn deleteDirW(self: Dir, sub_path_w: []const u16) DeleteDirError!void {
- os.unlinkatW(self.fd, sub_path_w, os.AT_REMOVEDIR) catch |err| switch (err) {
- error.IsDir => unreachable, // not possible since we pass AT_REMOVEDIR
+ os.unlinkatW(self.fd, sub_path_w, os.AT.REMOVEDIR) catch |err| switch (err) {
+ error.IsDir => unreachable, // not possible since we pass AT.REMOVEDIR
else => |e| return e,
};
}
@@ -2132,7 +2133,7 @@ pub fn cwd() Dir {
} else if (builtin.os.tag == .wasi and !builtin.link_libc) {
@compileError("WASI doesn't have a concept of cwd(); use std.fs.wasi.PreopenList to get available Dir handles instead");
} else {
- return Dir{ .fd = os.AT_FDCWD };
+ return Dir{ .fd = os.AT.FDCWD };
}
}
@@ -2441,14 +2442,14 @@ pub fn selfExePath(out_buffer: []u8) SelfExePathError![]u8 {
switch (builtin.os.tag) {
.linux => return os.readlinkZ("/proc/self/exe", out_buffer),
.freebsd, .dragonfly => {
- var mib = [4]c_int{ os.CTL_KERN, os.KERN_PROC, os.KERN_PROC_PATHNAME, -1 };
+ var mib = [4]c_int{ os.CTL.KERN, os.KERN.PROC, os.KERN.PROC_PATHNAME, -1 };
var out_len: usize = out_buffer.len;
try os.sysctl(&mib, out_buffer.ptr, &out_len, null, 0);
// TODO could this slice from 0 to out_len instead?
return mem.spanZ(std.meta.assumeSentinel(out_buffer.ptr, 0));
},
.netbsd => {
- var mib = [4]c_int{ os.CTL_KERN, os.KERN_PROC_ARGS, -1, os.KERN_PROC_PATHNAME };
+ var mib = [4]c_int{ os.CTL.KERN, os.KERN.PROC_ARGS, -1, os.KERN.PROC_PATHNAME };
var out_len: usize = out_buffer.len;
try os.sysctl(&mib, out_buffer.ptr, &out_len, null, 0);
// TODO could this slice from 0 to out_len instead?
diff --git a/lib/std/fs/file.zig b/lib/std/fs/file.zig
index 1dd5e8ba9890..d08b74391970 100644
--- a/lib/std/fs/file.zig
+++ b/lib/std/fs/file.zig
@@ -12,20 +12,23 @@ const is_windows = std.Target.current.os.tag == .windows;
pub const File = struct {
/// The OS-specific file descriptor or file handle.
- handle: os.fd_t,
+ handle: Handle,
- /// On some systems, such as Linux, file system file descriptors are incapable of non-blocking I/O.
- /// This forces us to perform asynchronous I/O on a dedicated thread, to achieve non-blocking
- /// file-system I/O. To do this, `File` must be aware of whether it is a file system file descriptor,
- /// or, more specifically, whether the I/O is always blocking.
+ /// On some systems, such as Linux, file system file descriptors are incapable
+ /// of non-blocking I/O. This forces us to perform asynchronous I/O on a dedicated thread,
+ /// to achieve non-blocking file-system I/O. To do this, `File` must be aware of whether
+ /// it is a file system file descriptor, or, more specifically, whether the I/O is always
+ /// blocking.
capable_io_mode: io.ModeOverride = io.default_mode,
- /// Furthermore, even when `std.io.mode` is async, it is still sometimes desirable to perform blocking I/O,
- /// although not by default. For example, when printing a stack trace to stderr.
- /// This field tracks both by acting as an overriding I/O mode. When not building in async I/O mode,
- /// the type only has the `.blocking` tag, making it a zero-bit type.
+ /// Furthermore, even when `std.io.mode` is async, it is still sometimes desirable
+ /// to perform blocking I/O, although not by default. For example, when printing a
+ /// stack trace to stderr. This field tracks both by acting as an overriding I/O mode.
+ /// When not building in async I/O mode, the type only has the `.blocking` tag, making
+ /// it a zero-bit type.
intended_io_mode: io.ModeOverride = io.default_mode,
+ pub const Handle = os.fd_t;
pub const Mode = os.mode_t;
pub const INode = os.ino_t;
@@ -103,7 +106,7 @@ pub const File = struct {
/// and `false` means `error.WouldBlock` is handled by the event loop.
lock_nonblocking: bool = false,
- /// Setting this to `.blocking` prevents `O_NONBLOCK` from being passed even
+ /// Setting this to `.blocking` prevents `O.NONBLOCK` from being passed even
/// if `std.io.is_async`. It allows the use of `nosuspend` when calling functions
/// related to opening the file, reading, writing, and locking.
intended_io_mode: io.ModeOverride = io.default_mode,
@@ -164,7 +167,7 @@ pub const File = struct {
/// be created with.
mode: Mode = default_mode,
- /// Setting this to `.blocking` prevents `O_NONBLOCK` from being passed even
+ /// Setting this to `.blocking` prevents `O.NONBLOCK` from being passed even
/// if `std.io.is_async`. It allows the use of `nosuspend` when calling functions
/// related to opening the file, reading, writing, and locking.
intended_io_mode: io.ModeOverride = io.default_mode,
@@ -322,21 +325,21 @@ pub const File = struct {
.size = @bitCast(u64, st.size),
.mode = st.mode,
.kind = if (builtin.os.tag == .wasi and !builtin.link_libc) switch (st.filetype) {
- os.FILETYPE_BLOCK_DEVICE => Kind.BlockDevice,
- os.FILETYPE_CHARACTER_DEVICE => Kind.CharacterDevice,
- os.FILETYPE_DIRECTORY => Kind.Directory,
- os.FILETYPE_SYMBOLIC_LINK => Kind.SymLink,
- os.FILETYPE_REGULAR_FILE => Kind.File,
- os.FILETYPE_SOCKET_STREAM, os.FILETYPE_SOCKET_DGRAM => Kind.UnixDomainSocket,
+ .BLOCK_DEVICE => Kind.BlockDevice,
+ .CHARACTER_DEVICE => Kind.CharacterDevice,
+ .DIRECTORY => Kind.Directory,
+ .SYMBOLIC_LINK => Kind.SymLink,
+ .REGULAR_FILE => Kind.File,
+ .SOCKET_STREAM, .SOCKET_DGRAM => Kind.UnixDomainSocket,
else => Kind.Unknown,
- } else switch (st.mode & os.S_IFMT) {
- os.S_IFBLK => Kind.BlockDevice,
- os.S_IFCHR => Kind.CharacterDevice,
- os.S_IFDIR => Kind.Directory,
- os.S_IFIFO => Kind.NamedPipe,
- os.S_IFLNK => Kind.SymLink,
- os.S_IFREG => Kind.File,
- os.S_IFSOCK => Kind.UnixDomainSocket,
+ } else switch (st.mode & os.S.IFMT) {
+ os.S.IFBLK => Kind.BlockDevice,
+ os.S.IFCHR => Kind.CharacterDevice,
+ os.S.IFDIR => Kind.Directory,
+ os.S.IFIFO => Kind.NamedPipe,
+ os.S.IFLNK => Kind.SymLink,
+ os.S.IFREG => Kind.File,
+ os.S.IFSOCK => Kind.UnixDomainSocket,
else => Kind.Unknown,
},
.atime = @as(i128, atime.tv_sec) * std.time.ns_per_s + atime.tv_nsec,
@@ -883,9 +886,9 @@ pub const File = struct {
};
} else {
return os.flock(file.handle, switch (l) {
- .None => os.LOCK_UN,
- .Shared => os.LOCK_SH,
- .Exclusive => os.LOCK_EX,
+ .None => os.LOCK.UN,
+ .Shared => os.LOCK.SH,
+ .Exclusive => os.LOCK.EX,
}) catch |err| switch (err) {
error.WouldBlock => unreachable, // non-blocking=false
else => |e| return e,
@@ -908,7 +911,7 @@ pub const File = struct {
error.Unexpected => unreachable, // Resource deallocation must succeed.
};
} else {
- return os.flock(file.handle, os.LOCK_UN) catch |err| switch (err) {
+ return os.flock(file.handle, os.LOCK.UN) catch |err| switch (err) {
error.WouldBlock => unreachable, // unlocking can't block
error.SystemResources => unreachable, // We are deallocating resources.
error.Unexpected => unreachable, // Resource deallocation must succeed.
@@ -949,9 +952,9 @@ pub const File = struct {
};
} else {
os.flock(file.handle, switch (l) {
- .None => os.LOCK_UN,
- .Shared => os.LOCK_SH | os.LOCK_NB,
- .Exclusive => os.LOCK_EX | os.LOCK_NB,
+ .None => os.LOCK.UN,
+ .Shared => os.LOCK.SH | os.LOCK.NB,
+ .Exclusive => os.LOCK.EX | os.LOCK.NB,
}) catch |err| switch (err) {
error.WouldBlock => return false,
else => |e| return e,
@@ -998,7 +1001,7 @@ pub const File = struct {
error.Unexpected => unreachable, // Resource deallocation must succeed.
};
} else {
- return os.flock(file.handle, os.LOCK_SH | os.LOCK_NB) catch |err| switch (err) {
+ return os.flock(file.handle, os.LOCK.SH | os.LOCK.NB) catch |err| switch (err) {
error.WouldBlock => unreachable, // File was not locked in exclusive mode.
else => |e| return e,
};
diff --git a/lib/std/fs/wasi.zig b/lib/std/fs/wasi.zig
index ad354e226f93..a6c6dac7117a 100644
--- a/lib/std/fs/wasi.zig
+++ b/lib/std/fs/wasi.zig
@@ -3,8 +3,9 @@ const os = std.os;
const mem = std.mem;
const math = std.math;
const Allocator = mem.Allocator;
-
-usingnamespace std.os.wasi;
+const wasi = std.os.wasi;
+const fd_t = wasi.fd_t;
+const prestat_t = wasi.prestat_t;
/// Type-tag of WASI preopen.
///
@@ -115,7 +116,7 @@ pub const PreopenList = struct {
while (true) {
var buf: prestat_t = undefined;
- switch (fd_prestat_get(fd, &buf)) {
+ switch (wasi.fd_prestat_get(fd, &buf)) {
.SUCCESS => {},
.OPNOTSUPP => {
// not a preopen, so keep going
@@ -131,7 +132,7 @@ pub const PreopenList = struct {
const preopen_len = buf.u.dir.pr_name_len;
const path_buf = try self.buffer.allocator.alloc(u8, preopen_len);
mem.set(u8, path_buf, 0);
- switch (fd_prestat_dir_name(fd, path_buf.ptr, preopen_len)) {
+ switch (wasi.fd_prestat_dir_name(fd, path_buf.ptr, preopen_len)) {
.SUCCESS => {},
else => |err| return os.unexpectedErrno(err),
}
@@ -174,5 +175,5 @@ test "extracting WASI preopens" {
try std.testing.expectEqual(@as(usize, 1), preopens.asSlice().len);
const preopen = preopens.find(PreopenType{ .Dir = "." }) orelse unreachable;
try std.testing.expect(preopen.@"type".eql(PreopenType{ .Dir = "." }));
- try std.testing.expectEqual(@as(usize, 3), preopen.fd);
+ try std.testing.expectEqual(@as(i32, 3), preopen.fd);
}
diff --git a/lib/std/fs/watch.zig b/lib/std/fs/watch.zig
index 7777793b29bd..117843bf95b0 100644
--- a/lib/std/fs/watch.zig
+++ b/lib/std/fs/watch.zig
@@ -250,7 +250,7 @@ pub fn Watch(comptime V: type) type {
};
// @TODO Can I close this fd and get an error from bsdWaitKev?
- const flags = if (comptime std.Target.current.isDarwin()) os.O_SYMLINK | os.O_EVTONLY else 0;
+ const flags = if (comptime std.Target.current.isDarwin()) os.O.SYMLINK | os.O.EVTONLY else 0;
const fd = try os.open(realpath, flags, 0);
gop.value_ptr.putter_frame = async self.kqPutEvents(fd, gop.key_ptr.*, gop.value_ptr.*);
return null;
diff --git a/lib/std/hash_map.zig b/lib/std/hash_map.zig
index 06071f0a0b9d..765add1e6871 100644
--- a/lib/std/hash_map.zig
+++ b/lib/std/hash_map.zig
@@ -622,8 +622,12 @@ pub fn HashMap(
return other.promoteContext(self.allocator, new_ctx);
}
- /// Creates a copy of this map, using a specified allocator and context
- pub fn cloneWithAllocatorAndContext(new_allocator: *Allocator, new_ctx: anytype) !HashMap(K, V, @TypeOf(new_ctx), max_load_percentage) {
+ /// Creates a copy of this map, using a specified allocator and context.
+ pub fn cloneWithAllocatorAndContext(
+ self: Self,
+ new_allocator: *Allocator,
+ new_ctx: anytype,
+ ) !HashMap(K, V, @TypeOf(new_ctx), max_load_percentage) {
var other = try self.unmanaged.cloneContext(new_allocator, new_ctx);
return other.promoteContext(new_allocator, new_ctx);
}
diff --git a/lib/std/heap.zig b/lib/std/heap.zig
index 9032225b394c..e6e7af4626f5 100644
--- a/lib/std/heap.zig
+++ b/lib/std/heap.zig
@@ -88,12 +88,12 @@ const CAllocator = struct {
fn alignedAllocSize(ptr: [*]u8) usize {
if (supports_posix_memalign) {
- return malloc_size(ptr);
+ return CAllocator.malloc_size(ptr);
}
const unaligned_ptr = getHeader(ptr).*;
const delta = @ptrToInt(ptr) - @ptrToInt(unaligned_ptr);
- return malloc_size(unaligned_ptr) - delta;
+ return CAllocator.malloc_size(unaligned_ptr) - delta;
}
fn alloc(
@@ -113,7 +113,7 @@ const CAllocator = struct {
return ptr[0..len];
}
const full_len = init: {
- if (supports_malloc_size) {
+ if (CAllocator.supports_malloc_size) {
const s = alignedAllocSize(ptr);
assert(s >= len);
break :init s;
@@ -141,7 +141,7 @@ const CAllocator = struct {
if (new_len <= buf.len) {
return mem.alignAllocLen(buf.len, new_len, len_align);
}
- if (supports_malloc_size) {
+ if (CAllocator.supports_malloc_size) {
const full_len = alignedAllocSize(buf.ptr);
if (new_len <= full_len) {
return mem.alignAllocLen(full_len, new_len, len_align);
@@ -304,8 +304,8 @@ const PageAllocator = struct {
const slice = os.mmap(
hint,
alloc_len,
- os.PROT_READ | os.PROT_WRITE,
- os.MAP_PRIVATE | os.MAP_ANONYMOUS,
+ os.PROT.READ | os.PROT.WRITE,
+ os.MAP.PRIVATE | os.MAP.ANONYMOUS,
-1,
0,
) catch return error.OutOfMemory;
diff --git a/lib/std/io/c_writer.zig b/lib/std/io/c_writer.zig
index 758df71165a2..07a719b0c2e5 100644
--- a/lib/std/io/c_writer.zig
+++ b/lib/std/io/c_writer.zig
@@ -2,6 +2,7 @@ const std = @import("../std.zig");
const builtin = std.builtin;
const io = std.io;
const testing = std.testing;
+const os = std.os;
pub const CWriter = io.Writer(*std.c.FILE, std.fs.File.WriteError, cWriterWrite);
diff --git a/lib/std/json.zig b/lib/std/json.zig
index ce9ed9af7db9..e8f9d9d39512 100644
--- a/lib/std/json.zig
+++ b/lib/std/json.zig
@@ -1405,7 +1405,7 @@ fn parsedEqual(a: anytype, b: @TypeOf(a)) bool {
if (a == null or b == null) return false;
return parsedEqual(a.?, b.?);
},
- .Union => {
+ .Union => |info| {
if (info.tag_type) |UnionTag| {
const tag_a = std.meta.activeTag(a);
const tag_b = std.meta.activeTag(b);
@@ -2657,7 +2657,7 @@ test "json.parser.dynamic" {
try testing.expect(mem.eql(u8, large_int.NumberString, "18446744073709551615"));
}
-test "import more json tests" {
+test {
_ = @import("json/test.zig");
_ = @import("json/write_stream.zig");
}
diff --git a/lib/std/math/big/int.zig b/lib/std/math/big/int.zig
index e289520e5790..9efd4d5752ee 100644
--- a/lib/std/math/big/int.zig
+++ b/lib/std/math/big/int.zig
@@ -672,10 +672,9 @@ pub const Mutable = struct {
///
/// `limbs_buffer` is used for temporary storage during the operation.
pub fn gcdNoAlias(rma: *Mutable, x: Const, y: Const, limbs_buffer: *std.ArrayList(Limb)) !void {
- _ = limbs_buffer;
assert(rma.limbs.ptr != x.limbs.ptr); // illegal aliasing
assert(rma.limbs.ptr != y.limbs.ptr); // illegal aliasing
- return gcdLehmer(rma, x, y, allocator);
+ return gcdLehmer(rma, x, y, limbs_buffer);
}
fn gcdLehmer(result: *Mutable, xa: Const, ya: Const, limbs_buffer: *std.ArrayList(Limb)) !void {
diff --git a/lib/std/net.zig b/lib/std/net.zig
index c7411d9ecc77..1f1a020028fa 100644
--- a/lib/std/net.zig
+++ b/lib/std/net.zig
@@ -10,7 +10,7 @@ const native_endian = builtin.target.cpu.arch.endian();
// Windows 10 added support for unix sockets in build 17063, redstone 4 is the
// first release to support them.
-pub const has_unix_sockets = @hasDecl(os, "sockaddr_un") and
+pub const has_unix_sockets = @hasDecl(os.sockaddr, "un") and
(builtin.target.os.tag != .windows or
std.Target.current.os.version_range.windows.isAtLeast(.win10_rs4) orelse false);
@@ -18,7 +18,7 @@ pub const Address = extern union {
any: os.sockaddr,
in: Ip4Address,
in6: Ip6Address,
- un: if (has_unix_sockets) os.sockaddr_un else void,
+ un: if (has_unix_sockets) os.sockaddr.un else void,
/// Parse the given IP address string into an Address value.
/// It is recommended to use `resolveIp` instead, to handle
@@ -70,9 +70,9 @@ pub const Address = extern union {
pub fn parseExpectingFamily(name: []const u8, family: os.sa_family_t, port: u16) !Address {
switch (family) {
- os.AF_INET => return parseIp4(name, port),
- os.AF_INET6 => return parseIp6(name, port),
- os.AF_UNSPEC => return parseIp(name, port),
+ os.AF.INET => return parseIp4(name, port),
+ os.AF.INET6 => return parseIp6(name, port),
+ os.AF.UNSPEC => return parseIp(name, port),
else => unreachable,
}
}
@@ -98,8 +98,8 @@ pub const Address = extern union {
}
pub fn initUnix(path: []const u8) !Address {
- var sock_addr = os.sockaddr_un{
- .family = os.AF_UNIX,
+ var sock_addr = os.sockaddr.un{
+ .family = os.AF.UNIX,
.path = undefined,
};
@@ -116,8 +116,8 @@ pub const Address = extern union {
/// Asserts that the address is ip4 or ip6.
pub fn getPort(self: Address) u16 {
return switch (self.any.family) {
- os.AF_INET => self.in.getPort(),
- os.AF_INET6 => self.in6.getPort(),
+ os.AF.INET => self.in.getPort(),
+ os.AF.INET6 => self.in6.getPort(),
else => unreachable,
};
}
@@ -126,8 +126,8 @@ pub const Address = extern union {
/// Asserts that the address is ip4 or ip6.
pub fn setPort(self: *Address, port: u16) void {
switch (self.any.family) {
- os.AF_INET => self.in.setPort(port),
- os.AF_INET6 => self.in6.setPort(port),
+ os.AF.INET => self.in.setPort(port),
+ os.AF.INET6 => self.in6.setPort(port),
else => unreachable,
}
}
@@ -137,8 +137,8 @@ pub const Address = extern union {
/// on the address family.
pub fn initPosix(addr: *align(4) const os.sockaddr) Address {
switch (addr.family) {
- os.AF_INET => return Address{ .in = Ip4Address{ .sa = @ptrCast(*const os.sockaddr_in, addr).* } },
- os.AF_INET6 => return Address{ .in6 = Ip6Address{ .sa = @ptrCast(*const os.sockaddr_in6, addr).* } },
+ os.AF.INET => return Address{ .in = Ip4Address{ .sa = @ptrCast(*const os.sockaddr.in, addr).* } },
+ os.AF.INET6 => return Address{ .in6 = Ip6Address{ .sa = @ptrCast(*const os.sockaddr.in6, addr).* } },
else => unreachable,
}
}
@@ -150,9 +150,9 @@ pub const Address = extern union {
out_stream: anytype,
) !void {
switch (self.any.family) {
- os.AF_INET => try self.in.format(fmt, options, out_stream),
- os.AF_INET6 => try self.in6.format(fmt, options, out_stream),
- os.AF_UNIX => {
+ os.AF.INET => try self.in.format(fmt, options, out_stream),
+ os.AF.INET6 => try self.in6.format(fmt, options, out_stream),
+ os.AF.UNIX => {
if (!has_unix_sockets) {
unreachable;
}
@@ -171,15 +171,15 @@ pub const Address = extern union {
pub fn getOsSockLen(self: Address) os.socklen_t {
switch (self.any.family) {
- os.AF_INET => return self.in.getOsSockLen(),
- os.AF_INET6 => return self.in6.getOsSockLen(),
- os.AF_UNIX => {
+ os.AF.INET => return self.in.getOsSockLen(),
+ os.AF.INET6 => return self.in6.getOsSockLen(),
+ os.AF.UNIX => {
if (!has_unix_sockets) {
unreachable;
}
const path_len = std.mem.len(std.meta.assumeSentinel(&self.un.path, 0));
- return @intCast(os.socklen_t, @sizeOf(os.sockaddr_un) - self.un.path.len + path_len);
+ return @intCast(os.socklen_t, @sizeOf(os.sockaddr.un) - self.un.path.len + path_len);
},
else => unreachable,
}
@@ -187,7 +187,7 @@ pub const Address = extern union {
};
pub const Ip4Address = extern struct {
- sa: os.sockaddr_in,
+ sa: os.sockaddr.in,
pub fn parse(buf: []const u8, port: u16) !Ip4Address {
var result = Ip4Address{
@@ -249,7 +249,7 @@ pub const Ip4Address = extern struct {
pub fn init(addr: [4]u8, port: u16) Ip4Address {
return Ip4Address{
- .sa = os.sockaddr_in{
+ .sa = os.sockaddr.in{
.port = mem.nativeToBig(u16, port),
.addr = @ptrCast(*align(1) const u32, &addr).*,
},
@@ -288,19 +288,19 @@ pub const Ip4Address = extern struct {
pub fn getOsSockLen(self: Ip4Address) os.socklen_t {
_ = self;
- return @sizeOf(os.sockaddr_in);
+ return @sizeOf(os.sockaddr.in);
}
};
pub const Ip6Address = extern struct {
- sa: os.sockaddr_in6,
+ sa: os.sockaddr.in6,
/// Parse a given IPv6 address string into an Address.
/// Assumes the Scope ID of the address is fully numeric.
/// For non-numeric addresses, see `resolveIp6`.
pub fn parse(buf: []const u8, port: u16) !Ip6Address {
var result = Ip6Address{
- .sa = os.sockaddr_in6{
+ .sa = os.sockaddr.in6{
.scope_id = 0,
.port = mem.nativeToBig(u16, port),
.flowinfo = 0,
@@ -407,7 +407,7 @@ pub const Ip6Address = extern struct {
pub fn resolve(buf: []const u8, port: u16) !Ip6Address {
// TODO: Unify the implementations of resolveIp6 and parseIp6.
var result = Ip6Address{
- .sa = os.sockaddr_in6{
+ .sa = os.sockaddr.in6{
.scope_id = 0,
.port = mem.nativeToBig(u16, port),
.flowinfo = 0,
@@ -536,7 +536,7 @@ pub const Ip6Address = extern struct {
pub fn init(addr: [16]u8, port: u16, flowinfo: u32, scope_id: u32) Ip6Address {
return Ip6Address{
- .sa = os.sockaddr_in6{
+ .sa = os.sockaddr.in6{
.addr = addr,
.port = mem.nativeToBig(u16, port),
.flowinfo = flowinfo,
@@ -608,15 +608,15 @@ pub const Ip6Address = extern struct {
pub fn getOsSockLen(self: Ip6Address) os.socklen_t {
_ = self;
- return @sizeOf(os.sockaddr_in6);
+ return @sizeOf(os.sockaddr.in6);
}
};
pub fn connectUnixSocket(path: []const u8) !Stream {
- const opt_non_block = if (std.io.is_async) os.SOCK_NONBLOCK else 0;
+ const opt_non_block = if (std.io.is_async) os.SOCK.NONBLOCK else 0;
const sockfd = try os.socket(
- os.AF_UNIX,
- os.SOCK_STREAM | os.SOCK_CLOEXEC | opt_non_block,
+ os.AF.UNIX,
+ os.SOCK.STREAM | os.SOCK.CLOEXEC | opt_non_block,
0,
);
errdefer os.closeSocket(sockfd);
@@ -637,7 +637,7 @@ pub fn connectUnixSocket(path: []const u8) !Stream {
fn if_nametoindex(name: []const u8) !u32 {
var ifr: os.ifreq = undefined;
- var sockfd = try os.socket(os.AF_UNIX, os.SOCK_DGRAM | os.SOCK_CLOEXEC, 0);
+ var sockfd = try os.socket(os.AF.UNIX, os.SOCK.DGRAM | os.SOCK.CLOEXEC, 0);
defer os.closeSocket(sockfd);
std.mem.copy(u8, &ifr.ifrn.name, name);
@@ -682,10 +682,10 @@ pub fn tcpConnectToHost(allocator: *mem.Allocator, name: []const u8, port: u16)
}
pub fn tcpConnectToAddress(address: Address) !Stream {
- const nonblock = if (std.io.is_async) os.SOCK_NONBLOCK else 0;
- const sock_flags = os.SOCK_STREAM | nonblock |
- (if (builtin.target.os.tag == .windows) 0 else os.SOCK_CLOEXEC);
- const sockfd = try os.socket(address.any.family, sock_flags, os.IPPROTO_TCP);
+ const nonblock = if (std.io.is_async) os.SOCK.NONBLOCK else 0;
+ const sock_flags = os.SOCK.STREAM | nonblock |
+ (if (builtin.target.os.tag == .windows) 0 else os.SOCK.CLOEXEC);
+ const sockfd = try os.socket(address.any.family, sock_flags, os.IPPROTO.TCP);
errdefer os.closeSocket(sockfd);
if (std.io.is_async) {
@@ -724,10 +724,10 @@ pub fn getAddressList(allocator: *mem.Allocator, name: []const u8, port: u16) !*
const sys = if (builtin.target.os.tag == .windows) os.windows.ws2_32 else os.system;
const hints = os.addrinfo{
- .flags = sys.AI_NUMERICSERV,
- .family = os.AF_UNSPEC,
- .socktype = os.SOCK_STREAM,
- .protocol = os.IPPROTO_TCP,
+ .flags = sys.AI.NUMERICSERV,
+ .family = os.AF.UNSPEC,
+ .socktype = os.SOCK.STREAM,
+ .protocol = os.IPPROTO.TCP,
.canonname = null,
.addr = null,
.addrlen = 0,
@@ -794,8 +794,8 @@ pub fn getAddressList(allocator: *mem.Allocator, name: []const u8, port: u16) !*
return result;
}
if (builtin.target.os.tag == .linux) {
- const flags = std.c.AI_NUMERICSERV;
- const family = os.AF_UNSPEC;
+ const flags = std.c.AI.NUMERICSERV;
+ const family = os.AF.UNSPEC;
var lookup_addrs = std.ArrayList(LookupAddr).init(allocator);
defer lookup_addrs.deinit();
@@ -846,7 +846,7 @@ fn linuxLookupName(
try canon.appendSlice(name);
if (Address.parseExpectingFamily(name, family, port)) |addr| {
try addrs.append(LookupAddr{ .addr = addr });
- } else |name_err| if ((flags & std.c.AI_NUMERICHOST) != 0) {
+ } else |name_err| if ((flags & std.c.AI.NUMERICHOST) != 0) {
return name_err;
} else {
try linuxLookupNameFromHosts(addrs, canon, name, family, port);
@@ -876,9 +876,9 @@ fn linuxLookupName(
// No further processing is needed if there are fewer than 2
// results or if there are only IPv4 results.
- if (addrs.items.len == 1 or family == os.AF_INET) return;
+ if (addrs.items.len == 1 or family == os.AF.INET) return;
const all_ip4 = for (addrs.items) |addr| {
- if (addr.addr.any.family != os.AF_INET) break false;
+ if (addr.addr.any.family != os.AF.INET) break false;
} else true;
if (all_ip4) return;
@@ -891,19 +891,19 @@ fn linuxLookupName(
// A more idiomatic "ziggy" implementation would be welcome.
for (addrs.items) |*addr, i| {
var key: i32 = 0;
- var sa6: os.sockaddr_in6 = undefined;
- @memset(@ptrCast([*]u8, &sa6), 0, @sizeOf(os.sockaddr_in6));
- var da6 = os.sockaddr_in6{
- .family = os.AF_INET6,
+ var sa6: os.sockaddr.in6 = undefined;
+ @memset(@ptrCast([*]u8, &sa6), 0, @sizeOf(os.sockaddr.in6));
+ var da6 = os.sockaddr.in6{
+ .family = os.AF.INET6,
.scope_id = addr.addr.in6.sa.scope_id,
.port = 65535,
.flowinfo = 0,
.addr = [1]u8{0} ** 16,
};
- var sa4: os.sockaddr_in = undefined;
- @memset(@ptrCast([*]u8, &sa4), 0, @sizeOf(os.sockaddr_in));
- var da4 = os.sockaddr_in{
- .family = os.AF_INET,
+ var sa4: os.sockaddr.in = undefined;
+ @memset(@ptrCast([*]u8, &sa4), 0, @sizeOf(os.sockaddr.in));
+ var da4 = os.sockaddr.in{
+ .family = os.AF.INET,
.port = 65535,
.addr = 0,
.zero = [1]u8{0} ** 8,
@@ -912,21 +912,21 @@ fn linuxLookupName(
var da: *align(4) os.sockaddr = undefined;
var salen: os.socklen_t = undefined;
var dalen: os.socklen_t = undefined;
- if (addr.addr.any.family == os.AF_INET6) {
+ if (addr.addr.any.family == os.AF.INET6) {
mem.copy(u8, &da6.addr, &addr.addr.in6.sa.addr);
da = @ptrCast(*os.sockaddr, &da6);
- dalen = @sizeOf(os.sockaddr_in6);
+ dalen = @sizeOf(os.sockaddr.in6);
sa = @ptrCast(*os.sockaddr, &sa6);
- salen = @sizeOf(os.sockaddr_in6);
+ salen = @sizeOf(os.sockaddr.in6);
} else {
mem.copy(u8, &sa6.addr, "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff");
mem.copy(u8, &da6.addr, "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff");
mem.writeIntNative(u32, da6.addr[12..], addr.addr.in.sa.addr);
da4.addr = addr.addr.in.sa.addr;
da = @ptrCast(*os.sockaddr, &da4);
- dalen = @sizeOf(os.sockaddr_in);
+ dalen = @sizeOf(os.sockaddr.in);
sa = @ptrCast(*os.sockaddr, &sa4);
- salen = @sizeOf(os.sockaddr_in);
+ salen = @sizeOf(os.sockaddr.in);
}
const dpolicy = policyOf(da6.addr);
const dscope: i32 = scopeOf(da6.addr);
@@ -934,13 +934,13 @@ fn linuxLookupName(
const dprec: i32 = dpolicy.prec;
const MAXADDRS = 3;
var prefixlen: i32 = 0;
- const sock_flags = os.SOCK_DGRAM | os.SOCK_CLOEXEC;
- if (os.socket(addr.addr.any.family, sock_flags, os.IPPROTO_UDP)) |fd| syscalls: {
+ const sock_flags = os.SOCK.DGRAM | os.SOCK.CLOEXEC;
+ if (os.socket(addr.addr.any.family, sock_flags, os.IPPROTO.UDP)) |fd| syscalls: {
defer os.closeSocket(fd);
os.connect(fd, da, dalen) catch break :syscalls;
key |= DAS_USABLE;
os.getsockname(fd, sa, &salen) catch break :syscalls;
- if (addr.addr.any.family == os.AF_INET) {
+ if (addr.addr.any.family == os.AF.INET) {
// TODO sa6.addr[12..16] should return *[4]u8, making this cast unnecessary.
mem.writeIntNative(u32, @ptrCast(*[4]u8, &sa6.addr[12]), sa4.addr);
}
@@ -1082,24 +1082,24 @@ fn linuxLookupNameFromNull(
flags: u32,
port: u16,
) !void {
- if ((flags & std.c.AI_PASSIVE) != 0) {
- if (family != os.AF_INET6) {
+ if ((flags & std.c.AI.PASSIVE) != 0) {
+ if (family != os.AF.INET6) {
(try addrs.addOne()).* = LookupAddr{
.addr = Address.initIp4([1]u8{0} ** 4, port),
};
}
- if (family != os.AF_INET) {
+ if (family != os.AF.INET) {
(try addrs.addOne()).* = LookupAddr{
.addr = Address.initIp6([1]u8{0} ** 16, port, 0, 0),
};
}
} else {
- if (family != os.AF_INET6) {
+ if (family != os.AF.INET6) {
(try addrs.addOne()).* = LookupAddr{
.addr = Address.initIp4([4]u8{ 127, 0, 0, 1 }, port),
};
}
- if (family != os.AF_INET) {
+ if (family != os.AF.INET) {
(try addrs.addOne()).* = LookupAddr{
.addr = Address.initIp6(([1]u8{0} ** 15) ++ [1]u8{1}, port, 0, 0),
};
@@ -1252,8 +1252,8 @@ fn linuxLookupNameFromDns(
rr: u8,
};
const afrrs = [_]AfRr{
- AfRr{ .af = os.AF_INET6, .rr = os.RR_A },
- AfRr{ .af = os.AF_INET, .rr = os.RR_AAAA },
+ AfRr{ .af = os.AF.INET6, .rr = os.RR.A },
+ AfRr{ .af = os.AF.INET, .rr = os.RR.AAAA },
};
var qbuf: [2][280]u8 = undefined;
var abuf: [2][512]u8 = undefined;
@@ -1386,8 +1386,8 @@ fn resMSendRc(
const timeout = 1000 * rc.timeout;
const attempts = rc.attempts;
- var sl: os.socklen_t = @sizeOf(os.sockaddr_in);
- var family: os.sa_family_t = os.AF_INET;
+ var sl: os.socklen_t = @sizeOf(os.sockaddr.in);
+ var family: os.sa_family_t = os.AF.INET;
var ns_list = std.ArrayList(Address).init(rc.ns.allocator);
defer ns_list.deinit();
@@ -1398,9 +1398,9 @@ fn resMSendRc(
for (rc.ns.items) |iplit, i| {
ns[i] = iplit.addr;
assert(ns[i].getPort() == 53);
- if (iplit.addr.any.family != os.AF_INET) {
- sl = @sizeOf(os.sockaddr_in6);
- family = os.AF_INET6;
+ if (iplit.addr.any.family != os.AF.INET) {
+ sl = @sizeOf(os.sockaddr.in6);
+ family = os.AF.INET6;
}
}
@@ -1408,13 +1408,13 @@ fn resMSendRc(
var sa: Address = undefined;
@memset(@ptrCast([*]u8, &sa), 0, @sizeOf(Address));
sa.any.family = family;
- const flags = os.SOCK_DGRAM | os.SOCK_CLOEXEC | os.SOCK_NONBLOCK;
+ const flags = os.SOCK.DGRAM | os.SOCK.CLOEXEC | os.SOCK.NONBLOCK;
const fd = os.socket(family, flags, 0) catch |err| switch (err) {
error.AddressFamilyNotSupported => blk: {
// Handle case where system lacks IPv6 support
- if (family == os.AF_INET6) {
- family = os.AF_INET;
- break :blk try os.socket(os.AF_INET, flags, 0);
+ if (family == os.AF.INET6) {
+ family = os.AF.INET;
+ break :blk try os.socket(os.AF.INET, flags, 0);
}
return err;
},
@@ -1429,15 +1429,15 @@ fn resMSendRc(
// Convert any IPv4 addresses in a mixed environment to v4-mapped
// TODO
- //if (family == AF_INET6) {
- // setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &(int){0}, sizeof 0);
+ //if (family == AF.INET6) {
+ // setsockopt(fd, IPPROTO.IPV6, IPV6_V6ONLY, &(int){0}, sizeof 0);
// for (i=0; i if (servfail_retry != 0) {
servfail_retry -= 1;
if (std.io.is_async) {
- _ = std.event.Loop.instance.?.sendto(fd, queries[i], os.MSG_NOSIGNAL, &ns[j].any, sl) catch undefined;
+ _ = std.event.Loop.instance.?.sendto(fd, queries[i], os.MSG.NOSIGNAL, &ns[j].any, sl) catch undefined;
} else {
- _ = os.sendto(fd, queries[i], os.MSG_NOSIGNAL, &ns[j].any, sl) catch undefined;
+ _ = os.sendto(fd, queries[i], os.MSG.NOSIGNAL, &ns[j].any, sl) catch undefined;
}
},
else => continue,
@@ -1570,21 +1570,21 @@ fn dnsParse(
fn dnsParseCallback(ctx: dpc_ctx, rr: u8, data: []const u8, packet: []const u8) !void {
switch (rr) {
- os.RR_A => {
+ os.RR.A => {
if (data.len != 4) return error.InvalidDnsARecord;
const new_addr = try ctx.addrs.addOne();
new_addr.* = LookupAddr{
.addr = Address.initIp4(data[0..4].*, ctx.port),
};
},
- os.RR_AAAA => {
+ os.RR.AAAA => {
if (data.len != 16) return error.InvalidDnsAAAARecord;
const new_addr = try ctx.addrs.addOne();
new_addr.* = LookupAddr{
.addr = Address.initIp6(data[0..16].*, ctx.port, 0, 0),
};
},
- os.RR_CNAME => {
+ os.RR.CNAME => {
var tmp: [256]u8 = undefined;
// Returns len of compressed name. strlen to get canon name.
_ = try os.dn_expand(packet, data, &tmp);
@@ -1700,7 +1700,7 @@ pub const StreamServer = struct {
/// seeing "Connection refused".
kernel_backlog: u31 = 128,
- /// Enable SO_REUSEADDR on the socket.
+ /// Enable SO.REUSEADDR on the socket.
reuse_address: bool = false,
};
@@ -1722,9 +1722,9 @@ pub const StreamServer = struct {
}
pub fn listen(self: *StreamServer, address: Address) !void {
- const nonblock = if (std.io.is_async) os.SOCK_NONBLOCK else 0;
- const sock_flags = os.SOCK_STREAM | os.SOCK_CLOEXEC | nonblock;
- const proto = if (address.any.family == os.AF_UNIX) @as(u32, 0) else os.IPPROTO_TCP;
+ const nonblock = if (std.io.is_async) os.SOCK.NONBLOCK else 0;
+ const sock_flags = os.SOCK.STREAM | os.SOCK.CLOEXEC | nonblock;
+ const proto = if (address.any.family == os.AF.UNIX) @as(u32, 0) else os.IPPROTO.TCP;
const sockfd = try os.socket(address.any.family, sock_flags, proto);
self.sockfd = sockfd;
@@ -1736,8 +1736,8 @@ pub const StreamServer = struct {
if (self.reuse_address) {
try os.setsockopt(
sockfd,
- os.SOL_SOCKET,
- os.SO_REUSEADDR,
+ os.SOL.SOCKET,
+ os.SO.REUSEADDR,
&mem.toBytes(@as(c_int, 1)),
);
}
@@ -1801,9 +1801,9 @@ pub const StreamServer = struct {
const accept_result = blk: {
if (std.io.is_async) {
const loop = std.event.Loop.instance orelse return error.UnexpectedError;
- break :blk loop.accept(self.sockfd.?, &accepted_addr.any, &adr_len, os.SOCK_CLOEXEC);
+ break :blk loop.accept(self.sockfd.?, &accepted_addr.any, &adr_len, os.SOCK.CLOEXEC);
} else {
- break :blk os.accept(self.sockfd.?, &accepted_addr.any, &adr_len, os.SOCK_CLOEXEC);
+ break :blk os.accept(self.sockfd.?, &accepted_addr.any, &adr_len, os.SOCK.CLOEXEC);
}
};
diff --git a/lib/std/os.zig b/lib/std/os.zig
index 294784c2bdbb..d2a76989e1ff 100644
--- a/lib/std/os.zig
+++ b/lib/std/os.zig
@@ -16,20 +16,21 @@
const root = @import("root");
const std = @import("std.zig");
-const builtin = std.builtin;
+const builtin = @import("builtin");
const assert = std.debug.assert;
const math = std.math;
const mem = std.mem;
const elf = std.elf;
const dl = @import("dynamic_library.zig");
const MAX_PATH_BYTES = std.fs.MAX_PATH_BYTES;
-
-pub const darwin = @import("os/darwin.zig");
-pub const dragonfly = @import("os/dragonfly.zig");
-pub const freebsd = @import("os/freebsd.zig");
-pub const haiku = @import("os/haiku.zig");
-pub const netbsd = @import("os/netbsd.zig");
-pub const openbsd = @import("os/openbsd.zig");
+const is_windows = builtin.os.tag == .windows;
+
+pub const darwin = std.c;
+pub const dragonfly = std.c;
+pub const freebsd = std.c;
+pub const haiku = std.c;
+pub const netbsd = std.c;
+pub const openbsd = std.c;
pub const linux = @import("os/linux.zig");
pub const uefi = @import("os/uefi.zig");
pub const wasi = @import("os/wasi.zig");
@@ -40,15 +41,10 @@ comptime {
}
test {
- _ = darwin;
- _ = freebsd;
_ = linux;
- _ = netbsd;
- _ = openbsd;
_ = uefi;
_ = wasi;
_ = windows;
- _ = haiku;
_ = @import("os/test.zig");
}
@@ -58,22 +54,149 @@ test {
/// When not linking libc, it is the OS-specific system interface.
pub const system = if (@hasDecl(root, "os") and root.os != @This())
root.os.system
-else if (builtin.link_libc)
+else if (builtin.link_libc or is_windows)
std.c
else switch (builtin.os.tag) {
- .macos, .ios, .watchos, .tvos => darwin,
- .freebsd => freebsd,
- .haiku => haiku,
.linux => linux,
- .netbsd => netbsd,
- .openbsd => openbsd,
- .dragonfly => dragonfly,
.wasi => wasi,
- .windows => windows,
+ .uefi => uefi,
else => struct {},
};
-pub usingnamespace @import("os/bits.zig");
+pub const AF = system.AF;
+pub const ARCH = system.ARCH;
+pub const AT = system.AT;
+pub const CLOCK = system.CLOCK;
+pub const CPU_COUNT = system.CPU_COUNT;
+pub const CTL = system.CTL;
+pub const DT = system.DT;
+pub const E = system.E;
+pub const Elf_Symndx = system.Elf_Symndx;
+pub const F = system.F;
+pub const FD_CLOEXEC = system.FD_CLOEXEC;
+pub const Flock = system.Flock;
+pub const HOST_NAME_MAX = system.HOST_NAME_MAX;
+pub const IFNAMESIZE = system.IFNAMESIZE;
+pub const IOV_MAX = system.IOV_MAX;
+pub const IPPROTO = system.IPPROTO;
+pub const KERN = system.KERN;
+pub const Kevent = system.Kevent;
+pub const LOCK = system.LOCK;
+pub const MADV = system.MADV;
+pub const MAP = system.MAP;
+pub const MAX_ADDR_LEN = system.MAX_ADDR_LEN;
+pub const MMAP2_UNIT = system.MMAP2_UNIT;
+pub const MSG = system.MSG;
+pub const NAME_MAX = system.NAME_MAX;
+pub const O = system.O;
+pub const PATH_MAX = system.PATH_MAX;
+pub const POLL = system.POLL;
+pub const POSIX_FADV = system.POSIX_FADV;
+pub const PR = system.PR;
+pub const PROT = system.PROT;
+pub const REG = system.REG;
+pub const RIGHT = system.RIGHT;
+pub const RLIM = system.RLIM;
+pub const RR = system.RR;
+pub const S = system.S;
+pub const SA = system.SA;
+pub const SC = system.SC;
+pub const SEEK = system.SEEK;
+pub const SHUT = system.SHUT;
+pub const SIG = system.SIG;
+pub const SIOCGIFINDEX = system.SIOCGIFINDEX;
+pub const SO = system.SO;
+pub const SOCK = system.SOCK;
+pub const SOL = system.SOL;
+pub const STDERR_FILENO = system.STDERR_FILENO;
+pub const STDIN_FILENO = system.STDIN_FILENO;
+pub const STDOUT_FILENO = system.STDOUT_FILENO;
+pub const SYS = system.SYS;
+pub const Sigaction = system.Sigaction;
+pub const Stat = system.Stat;
+pub const TCSA = system.TCSA;
+pub const VDSO = system.VDSO;
+pub const W = system.W;
+pub const addrinfo = system.addrinfo;
+pub const blkcnt_t = system.blkcnt_t;
+pub const blksize_t = system.blksize_t;
+pub const clock_t = system.clock_t;
+pub const cpu_set_t = system.cpu_set_t;
+pub const dev_t = system.dev_t;
+pub const dl_phdr_info = system.dl_phdr_info;
+pub const empty_sigset = system.empty_sigset;
+pub const fd_t = system.fd_t;
+pub const fdflags_t = system.fdflags_t;
+pub const fdstat_t = system.fdstat_t;
+pub const gid_t = system.gid_t;
+pub const ifreq = system.ifreq;
+pub const ino_t = system.ino_t;
+pub const lookupflags_t = system.lookupflags_t;
+pub const mcontext_t = system.mcontext_t;
+pub const mode_t = system.mode_t;
+pub const msghdr = system.msghdr;
+pub const msghdr_const = system.msghdr_const;
+pub const nfds_t = system.nfds_t;
+pub const nlink_t = system.nlink_t;
+pub const off_t = system.off_t;
+pub const oflags_t = system.oflags_t;
+pub const pid_t = system.pid_t;
+pub const pollfd = system.pollfd;
+pub const rights_t = system.rights_t;
+pub const rlim_t = system.rlim_t;
+pub const rlimit = system.rlimit;
+pub const rlimit_resource = system.rlimit_resource;
+pub const rusage = system.rusage;
+pub const sa_family_t = system.sa_family_t;
+pub const siginfo_t = system.siginfo_t;
+pub const sigset_t = system.sigset_t;
+pub const sockaddr = system.sockaddr;
+pub const socklen_t = system.socklen_t;
+pub const stack_t = system.stack_t;
+pub const termios = system.termios;
+pub const time_t = system.time_t;
+pub const timespec = system.timespec;
+pub const timestamp_t = system.timestamp_t;
+pub const timeval = system.timeval;
+pub const timezone = system.timezone;
+pub const ucontext_t = system.ucontext_t;
+pub const uid_t = system.uid_t;
+pub const user_desc = system.user_desc;
+pub const utsname = system.utsname;
+
+pub const F_OK = system.F_OK;
+pub const R_OK = system.R_OK;
+pub const W_OK = system.W_OK;
+pub const X_OK = system.X_OK;
+
+pub const iovec = extern struct {
+ iov_base: [*]u8,
+ iov_len: usize,
+};
+
+pub const iovec_const = extern struct {
+ iov_base: [*]const u8,
+ iov_len: usize,
+};
+
+pub const LOG = struct {
+ /// system is unusable
+ pub const EMERG = 0;
+ /// action must be taken immediately
+ pub const ALERT = 1;
+ /// critical conditions
+ pub const CRIT = 2;
+ /// error conditions
+ pub const ERR = 3;
+ /// warning conditions
+ pub const WARNING = 4;
+ /// normal but significant condition
+ pub const NOTICE = 5;
+ /// informational
+ pub const INFO = 6;
+ /// debug-level messages
+ pub const DEBUG = 7;
+};
pub const socket_t = if (builtin.os.tag == .windows) windows.ws2_32.SOCKET else fd_t;
@@ -136,7 +259,7 @@ pub fn getrandom(buffer: []u8) GetRandomError!void {
if (builtin.os.tag == .linux or builtin.os.tag == .freebsd) {
var buf = buffer;
const use_c = builtin.os.tag != .linux or
- std.c.versionCheck(builtin.Version{ .major = 2, .minor = 25, .patch = 0 }).ok;
+ std.c.versionCheck(std.builtin.Version{ .major = 2, .minor = 25, .patch = 0 }).ok;
while (buf.len != 0) {
const res = if (use_c) blk: {
@@ -178,11 +301,11 @@ pub fn getrandom(buffer: []u8) GetRandomError!void {
}
fn getRandomBytesDevURandom(buf: []u8) !void {
- const fd = try openZ("/dev/urandom", O_RDONLY | O_CLOEXEC, 0);
+ const fd = try openZ("/dev/urandom", O.RDONLY | O.CLOEXEC, 0);
defer close(fd);
const st = try fstat(fd);
- if (!S_ISCHR(st.mode)) {
+ if (!S.ISCHR(st.mode)) {
return error.NoDevice;
}
@@ -210,11 +333,11 @@ pub fn abort() noreturn {
windows.kernel32.ExitProcess(3);
}
if (!builtin.link_libc and builtin.os.tag == .linux) {
- raise(SIGABRT) catch {};
+ raise(SIG.ABRT) catch {};
// TODO the rest of the implementation of abort() from musl libc here
- raise(SIGKILL) catch {};
+ raise(SIG.KILL) catch {};
exit(127);
}
if (builtin.os.tag == .uefi) {
@@ -239,15 +362,15 @@ pub fn raise(sig: u8) RaiseError!void {
}
if (builtin.os.tag == .linux) {
- var set: linux.sigset_t = undefined;
+ var set: sigset_t = undefined;
// block application signals
- _ = linux.sigprocmask(SIG_BLOCK, &linux.app_mask, &set);
+ _ = linux.sigprocmask(SIG.BLOCK, &linux.app_mask, &set);
const tid = linux.gettid();
const rc = linux.tkill(tid, sig);
// restore signal mask
- _ = linux.sigprocmask(SIG_SETMASK, &set, null);
+ _ = linux.sigprocmask(SIG.SETMASK, &set, null);
switch (errno(rc)) {
.SUCCESS => return,
@@ -1040,18 +1163,18 @@ pub const OpenError = error{
/// for 64-bit targets, as well as when opening directories.
FileTooBig,
- /// The path refers to directory but the `O_DIRECTORY` flag was not provided.
+ /// The path refers to directory but the `O.DIRECTORY` flag was not provided.
IsDir,
/// A new path cannot be created because the device has no room for the new file.
- /// This error is only reachable when the `O_CREAT` flag is provided.
+ /// This error is only reachable when the `O.CREAT` flag is provided.
NoSpaceLeft,
/// A component used as a directory in the path was not, in fact, a directory, or
- /// `O_DIRECTORY` was specified and the path was not a directory.
+ /// `O.DIRECTORY` was specified and the path was not a directory.
NotDir,
- /// The path already exists and the `O_CREAT` and `O_EXCL` flags were provided.
+ /// The path already exists and the `O.CREAT` and `O.EXCL` flags were provided.
PathAlreadyExists,
DeviceBusy,
@@ -1123,20 +1246,20 @@ fn openOptionsFromFlags(flags: u32) windows.OpenFileOptions {
const w = windows;
var access_mask: w.ULONG = w.READ_CONTROL | w.FILE_WRITE_ATTRIBUTES | w.SYNCHRONIZE;
- if (flags & O_RDWR != 0) {
+ if (flags & O.RDWR != 0) {
access_mask |= w.GENERIC_READ | w.GENERIC_WRITE;
- } else if (flags & O_WRONLY != 0) {
+ } else if (flags & O.WRONLY != 0) {
access_mask |= w.GENERIC_WRITE;
} else {
access_mask |= w.GENERIC_READ | w.GENERIC_WRITE;
}
- const open_dir: bool = flags & O_DIRECTORY != 0;
- const follow_symlinks: bool = flags & O_NOFOLLOW == 0;
+ const open_dir: bool = flags & O.DIRECTORY != 0;
+ const follow_symlinks: bool = flags & O.NOFOLLOW == 0;
const creation: w.ULONG = blk: {
- if (flags & O_CREAT != 0) {
- if (flags & O_EXCL != 0) {
+ if (flags & O.CREAT != 0) {
+ if (flags & O.EXCL != 0) {
break :blk w.FILE_CREATE;
}
}
@@ -1842,7 +1965,7 @@ pub fn unlinkW(file_path_w: []const u16) UnlinkError!void {
}
pub const UnlinkatError = UnlinkError || error{
- /// When passing `AT_REMOVEDIR`, this error occurs when the named directory is not empty.
+ /// When passing `AT.REMOVEDIR`, this error occurs when the named directory is not empty.
DirNotEmpty,
};
@@ -1865,7 +1988,7 @@ pub const unlinkatC = @compileError("deprecated: renamed to unlinkatZ");
/// WASI-only. Same as `unlinkat` but targeting WASI.
/// See also `unlinkat`.
pub fn unlinkatWasi(dirfd: fd_t, file_path: []const u8, flags: u32) UnlinkatError!void {
- const remove_dir = (flags & AT_REMOVEDIR) != 0;
+ const remove_dir = (flags & AT.REMOVEDIR) != 0;
const res = if (remove_dir)
wasi.path_remove_directory(dirfd, file_path.ptr, file_path.len)
else
@@ -1925,7 +2048,7 @@ pub fn unlinkatZ(dirfd: fd_t, file_path_c: [*:0]const u8, flags: u32) UnlinkatEr
/// Same as `unlinkat` but `sub_path_w` is UTF16LE, NT prefixed. Windows only.
pub fn unlinkatW(dirfd: fd_t, sub_path_w: []const u16, flags: u32) UnlinkatError!void {
- const remove_dir = (flags & AT_REMOVEDIR) != 0;
+ const remove_dir = (flags & AT.REMOVEDIR) != 0;
return windows.DeleteFile(sub_path_w, .{ .dir = dirfd, .remove_dir = remove_dir });
}
@@ -2663,8 +2786,8 @@ pub fn isatty(handle: fd_t) bool {
}
// A tty is a character device that we can't seek or tell on.
- if (statbuf.fs_filetype != FILETYPE_CHARACTER_DEVICE or
- (statbuf.fs_rights_base & (RIGHT_FD_SEEK | RIGHT_FD_TELL)) != 0)
+ if (statbuf.fs_filetype != .CHARACTER_DEVICE or
+ (statbuf.fs_rights_base & (RIGHT.FD_SEEK | RIGHT.FD_TELL)) != 0)
{
// errno = ENOTTY;
return false;
@@ -2676,7 +2799,7 @@ pub fn isatty(handle: fd_t) bool {
while (true) {
var wsz: linux.winsize = undefined;
const fd = @bitCast(usize, @as(isize, handle));
- const rc = linux.syscall3(.ioctl, fd, linux.TIOCGWINSZ, @ptrToInt(&wsz));
+ const rc = linux.syscall3(.ioctl, fd, linux.T.IOCGWINSZ, @ptrToInt(&wsz));
switch (linux.getErrno(rc)) {
.SUCCESS => return true,
.INTR => continue,
@@ -2739,10 +2862,10 @@ pub const SocketError = error{
pub fn socket(domain: u32, socket_type: u32, protocol: u32) SocketError!socket_t {
if (builtin.os.tag == .windows) {
- // NOTE: windows translates the SOCK_NONBLOCK/SOCK_CLOEXEC flags into
+ // NOTE: windows translates the SOCK.NONBLOCK/SOCK.CLOEXEC flags into
// windows-analagous operations
- const filtered_sock_type = socket_type & ~@as(u32, SOCK_NONBLOCK | SOCK_CLOEXEC);
- const flags: u32 = if ((socket_type & SOCK_CLOEXEC) != 0)
+ const filtered_sock_type = socket_type & ~@as(u32, SOCK.NONBLOCK | SOCK.CLOEXEC);
+ const flags: u32 = if ((socket_type & SOCK.CLOEXEC) != 0)
windows.ws2_32.WSA_FLAG_NO_HANDLE_INHERIT
else
0;
@@ -2755,7 +2878,7 @@ pub fn socket(domain: u32, socket_type: u32, protocol: u32) SocketError!socket_t
flags,
);
errdefer windows.closesocket(rc) catch unreachable;
- if ((socket_type & SOCK_NONBLOCK) != 0) {
+ if ((socket_type & SOCK.NONBLOCK) != 0) {
var mode: c_ulong = 1; // nonblocking
if (windows.ws2_32.SOCKET_ERROR == windows.ws2_32.ioctlsocket(rc, windows.ws2_32.FIONBIO, &mode)) {
switch (windows.ws2_32.WSAGetLastError()) {
@@ -2769,7 +2892,7 @@ pub fn socket(domain: u32, socket_type: u32, protocol: u32) SocketError!socket_t
const have_sock_flags = comptime !std.Target.current.isDarwin();
const filtered_sock_type = if (!have_sock_flags)
- socket_type & ~@as(u32, SOCK_NONBLOCK | SOCK_CLOEXEC)
+ socket_type & ~@as(u32, SOCK.NONBLOCK | SOCK.CLOEXEC)
else
socket_type;
const rc = system.socket(domain, filtered_sock_type, protocol);
@@ -2832,9 +2955,9 @@ pub fn shutdown(sock: socket_t, how: ShutdownHow) ShutdownError!void {
};
} else {
const rc = system.shutdown(sock, switch (how) {
- .recv => SHUT_RD,
- .send => SHUT_WR,
- .both => SHUT_RDWR,
+ .recv => SHUT.RD,
+ .send => SHUT.WR,
+ .both => SHUT.RDWR,
});
switch (errno(rc)) {
.SUCCESS => return,
@@ -3059,15 +3182,15 @@ pub fn accept(
/// will return a value greater than was supplied to the call.
addr_size: ?*socklen_t,
/// The following values can be bitwise ORed in flags to obtain different behavior:
- /// * `SOCK_NONBLOCK` - Set the `O_NONBLOCK` file status flag on the open file description (see `open`)
+ /// * `SOCK.NONBLOCK` - Set the `O.NONBLOCK` file status flag on the open file description (see `open`)
/// referred to by the new file descriptor. Using this flag saves extra calls to `fcntl` to achieve
/// the same result.
- /// * `SOCK_CLOEXEC` - Set the close-on-exec (`FD_CLOEXEC`) flag on the new file descriptor. See the
- /// description of the `O_CLOEXEC` flag in `open` for reasons why this may be useful.
+ /// * `SOCK.CLOEXEC` - Set the close-on-exec (`FD_CLOEXEC`) flag on the new file descriptor. See the
+ /// description of the `O.CLOEXEC` flag in `open` for reasons why this may be useful.
flags: u32,
) AcceptError!socket_t {
const have_accept4 = comptime !(std.Target.current.isDarwin() or builtin.os.tag == .windows);
- assert(0 == (flags & ~@as(u32, SOCK_NONBLOCK | SOCK_CLOEXEC))); // Unsupported flag(s)
+ assert(0 == (flags & ~@as(u32, SOCK.NONBLOCK | SOCK.CLOEXEC))); // Unsupported flag(s)
const accepted_sock = while (true) {
const rc = if (have_accept4)
@@ -3177,7 +3300,7 @@ pub const EpollCtlError = error{
FileDescriptorIncompatibleWithEpoll,
} || UnexpectedError;
-pub fn epoll_ctl(epfd: i32, op: u32, fd: i32, event: ?*epoll_event) EpollCtlError!void {
+pub fn epoll_ctl(epfd: i32, op: u32, fd: i32, event: ?*linux.epoll_event) EpollCtlError!void {
const rc = system.epoll_ctl(epfd, op, fd, event);
switch (errno(rc)) {
.SUCCESS => return,
@@ -3197,7 +3320,7 @@ pub fn epoll_ctl(epfd: i32, op: u32, fd: i32, event: ?*epoll_event) EpollCtlErro
/// Waits for an I/O event on an epoll file descriptor.
/// Returns the number of file descriptors ready for the requested I/O,
/// or zero if no file descriptor became ready during the requested timeout milliseconds.
-pub fn epoll_wait(epfd: i32, events: []epoll_event, timeout: i32) usize {
+pub fn epoll_wait(epfd: i32, events: []linux.epoll_event, timeout: i32) usize {
while (true) {
// TODO get rid of the @intCast
const rc = system.epoll_wait(epfd, events.ptr, @intCast(u32, events.len), timeout);
@@ -3399,7 +3522,7 @@ pub fn connect(sock: socket_t, sock_addr: *const sockaddr, len: socklen_t) Conne
.NOTSOCK => unreachable, // The file descriptor sockfd does not refer to a socket.
.PROTOTYPE => unreachable, // The socket type does not support the requested communications protocol.
.TIMEDOUT => return error.ConnectionTimedOut,
- .NOENT => return error.FileNotFound, // Returned when socket is AF_UNIX and the given path does not exist.
+ .NOENT => return error.FileNotFound, // Returned when socket is AF.UNIX and the given path does not exist.
else => |err| return unexpectedErrno(err),
}
}
@@ -3408,7 +3531,7 @@ pub fn connect(sock: socket_t, sock_addr: *const sockaddr, len: socklen_t) Conne
pub fn getsockoptError(sockfd: fd_t) ConnectError!void {
var err_code: i32 = undefined;
var size: u32 = @sizeOf(u32);
- const rc = system.getsockopt(sockfd, SOL_SOCKET, SO_ERROR, @ptrCast([*]u8, &err_code), &size);
+ const rc = system.getsockopt(sockfd, SOL.SOCKET, SO.ERROR, @ptrCast([*]u8, &err_code), &size);
assert(size == 4);
switch (errno(rc)) {
.SUCCESS => switch (@intToEnum(E, err_code)) {
@@ -3463,11 +3586,6 @@ pub fn waitpid(pid: pid_t, flags: u32) WaitPidResult {
}
}
-pub const Stat = if (builtin.link_libc)
- system.libc_stat
-else
- system.kernel_stat;
-
pub const FStatError = error{
SystemResources,
@@ -3745,8 +3863,8 @@ pub const MMapError = error{
MemoryMappingNotSupported,
/// A file descriptor refers to a non-regular file. Or a file mapping was requested,
- /// but the file descriptor is not open for reading. Or `MAP_SHARED` was requested
- /// and `PROT_WRITE` is set, but the file descriptor is not open in `O_RDWR` mode.
+ /// but the file descriptor is not open for reading. Or `MAP.SHARED` was requested
+ /// and `PROT_WRITE` is set, but the file descriptor is not open in `O.RDWR` mode.
/// Or `PROT_WRITE` is set, but the file is append-only.
AccessDenied,
@@ -3778,7 +3896,7 @@ pub fn mmap(
const ioffset = @bitCast(i64, offset); // the OS treats this as unsigned
const rc = mmap_sym(ptr, length, prot, flags, fd, ioffset);
const err = if (builtin.link_libc) blk: {
- if (rc != std.c.MAP_FAILED) return @ptrCast([*]align(mem.page_size) u8, @alignCast(mem.page_size, rc))[0..length];
+ if (rc != std.c.MAP.FAILED) return @ptrCast([*]align(mem.page_size) u8, @alignCast(mem.page_size, rc))[0..length];
break :blk @intToEnum(E, system._errno().*);
} else blk: {
const err = errno(rc);
@@ -3831,7 +3949,7 @@ pub const AccessError = error{
} || UnexpectedError;
/// check user's permissions for a file
-/// TODO currently this assumes `mode` is `F_OK` on Windows.
+/// TODO currently this assumes `mode` is `F.OK` on Windows.
pub fn access(path: []const u8, mode: u32) AccessError!void {
if (builtin.os.tag == .windows) {
const path_w = try windows.sliceToPrefixedFileW(path);
@@ -4001,11 +4119,11 @@ pub fn pipe2(flags: u32) PipeError![2]fd_t {
if (flags == 0)
return fds;
- // O_CLOEXEC is special, it's a file descriptor flag and must be set using
- // F_SETFD.
- if (flags & O_CLOEXEC != 0) {
+ // O.CLOEXEC is special, it's a file descriptor flag and must be set using
+ // F.SETFD.
+ if (flags & O.CLOEXEC != 0) {
for (fds) |fd| {
- switch (errno(system.fcntl(fd, F_SETFD, @as(u32, FD_CLOEXEC)))) {
+ switch (errno(system.fcntl(fd, F.SETFD, @as(u32, FD_CLOEXEC)))) {
.SUCCESS => {},
.INVAL => unreachable, // Invalid flags
.BADF => unreachable, // Always a race condition
@@ -4014,11 +4132,11 @@ pub fn pipe2(flags: u32) PipeError![2]fd_t {
}
}
- const new_flags = flags & ~@as(u32, O_CLOEXEC);
- // Set every other flag affecting the file status using F_SETFL.
+ const new_flags = flags & ~@as(u32, O.CLOEXEC);
+ // Set every other flag affecting the file status using F.SETFL.
if (new_flags != 0) {
for (fds) |fd| {
- switch (errno(system.fcntl(fd, F_SETFL, new_flags))) {
+ switch (errno(system.fcntl(fd, F.SETFL, new_flags))) {
.SUCCESS => {},
.INVAL => unreachable, // Invalid flags
.BADF => unreachable, // Always a race condition
@@ -4108,7 +4226,7 @@ pub const SeekError = error{
pub fn lseek_SET(fd: fd_t, offset: u64) SeekError!void {
if (builtin.os.tag == .linux and !builtin.link_libc and @sizeOf(usize) == 4) {
var result: u64 = undefined;
- switch (errno(system.llseek(fd, offset, &result, SEEK_SET))) {
+ switch (errno(system.llseek(fd, offset, &result, SEEK.SET))) {
.SUCCESS => return,
.BADF => unreachable, // always a race condition
.INVAL => return error.Unseekable,
@@ -4123,7 +4241,7 @@ pub fn lseek_SET(fd: fd_t, offset: u64) SeekError!void {
}
if (builtin.os.tag == .wasi and !builtin.link_libc) {
var new_offset: wasi.filesize_t = undefined;
- switch (wasi.fd_seek(fd, @bitCast(wasi.filedelta_t, offset), wasi.WHENCE_SET, &new_offset)) {
+ switch (wasi.fd_seek(fd, @bitCast(wasi.filedelta_t, offset), .SET, &new_offset)) {
.SUCCESS => return,
.BADF => unreachable, // always a race condition
.INVAL => return error.Unseekable,
@@ -4141,7 +4259,7 @@ pub fn lseek_SET(fd: fd_t, offset: u64) SeekError!void {
system.lseek;
const ioffset = @bitCast(i64, offset); // the OS treats this as unsigned
- switch (errno(lseek_sym(fd, ioffset, SEEK_SET))) {
+ switch (errno(lseek_sym(fd, ioffset, SEEK.SET))) {
.SUCCESS => return,
.BADF => unreachable, // always a race condition
.INVAL => return error.Unseekable,
@@ -4156,7 +4274,7 @@ pub fn lseek_SET(fd: fd_t, offset: u64) SeekError!void {
pub fn lseek_CUR(fd: fd_t, offset: i64) SeekError!void {
if (builtin.os.tag == .linux and !builtin.link_libc and @sizeOf(usize) == 4) {
var result: u64 = undefined;
- switch (errno(system.llseek(fd, @bitCast(u64, offset), &result, SEEK_CUR))) {
+ switch (errno(system.llseek(fd, @bitCast(u64, offset), &result, SEEK.CUR))) {
.SUCCESS => return,
.BADF => unreachable, // always a race condition
.INVAL => return error.Unseekable,
@@ -4171,7 +4289,7 @@ pub fn lseek_CUR(fd: fd_t, offset: i64) SeekError!void {
}
if (builtin.os.tag == .wasi and !builtin.link_libc) {
var new_offset: wasi.filesize_t = undefined;
- switch (wasi.fd_seek(fd, offset, wasi.WHENCE_CUR, &new_offset)) {
+ switch (wasi.fd_seek(fd, offset, .CUR, &new_offset)) {
.SUCCESS => return,
.BADF => unreachable, // always a race condition
.INVAL => return error.Unseekable,
@@ -4188,7 +4306,7 @@ pub fn lseek_CUR(fd: fd_t, offset: i64) SeekError!void {
system.lseek;
const ioffset = @bitCast(i64, offset); // the OS treats this as unsigned
- switch (errno(lseek_sym(fd, ioffset, SEEK_CUR))) {
+ switch (errno(lseek_sym(fd, ioffset, SEEK.CUR))) {
.SUCCESS => return,
.BADF => unreachable, // always a race condition
.INVAL => return error.Unseekable,
@@ -4203,7 +4321,7 @@ pub fn lseek_CUR(fd: fd_t, offset: i64) SeekError!void {
pub fn lseek_END(fd: fd_t, offset: i64) SeekError!void {
if (builtin.os.tag == .linux and !builtin.link_libc and @sizeOf(usize) == 4) {
var result: u64 = undefined;
- switch (errno(system.llseek(fd, @bitCast(u64, offset), &result, SEEK_END))) {
+ switch (errno(system.llseek(fd, @bitCast(u64, offset), &result, SEEK.END))) {
.SUCCESS => return,
.BADF => unreachable, // always a race condition
.INVAL => return error.Unseekable,
@@ -4218,7 +4336,7 @@ pub fn lseek_END(fd: fd_t, offset: i64) SeekError!void {
}
if (builtin.os.tag == .wasi and !builtin.link_libc) {
var new_offset: wasi.filesize_t = undefined;
- switch (wasi.fd_seek(fd, offset, wasi.WHENCE_END, &new_offset)) {
+ switch (wasi.fd_seek(fd, offset, .END, &new_offset)) {
.SUCCESS => return,
.BADF => unreachable, // always a race condition
.INVAL => return error.Unseekable,
@@ -4235,7 +4353,7 @@ pub fn lseek_END(fd: fd_t, offset: i64) SeekError!void {
system.lseek;
const ioffset = @bitCast(i64, offset); // the OS treats this as unsigned
- switch (errno(lseek_sym(fd, ioffset, SEEK_END))) {
+ switch (errno(lseek_sym(fd, ioffset, SEEK.END))) {
.SUCCESS => return,
.BADF => unreachable, // always a race condition
.INVAL => return error.Unseekable,
@@ -4250,7 +4368,7 @@ pub fn lseek_END(fd: fd_t, offset: i64) SeekError!void {
pub fn lseek_CUR_get(fd: fd_t) SeekError!u64 {
if (builtin.os.tag == .linux and !builtin.link_libc and @sizeOf(usize) == 4) {
var result: u64 = undefined;
- switch (errno(system.llseek(fd, 0, &result, SEEK_CUR))) {
+ switch (errno(system.llseek(fd, 0, &result, SEEK.CUR))) {
.SUCCESS => return result,
.BADF => unreachable, // always a race condition
.INVAL => return error.Unseekable,
@@ -4265,7 +4383,7 @@ pub fn lseek_CUR_get(fd: fd_t) SeekError!u64 {
}
if (builtin.os.tag == .wasi and !builtin.link_libc) {
var new_offset: wasi.filesize_t = undefined;
- switch (wasi.fd_seek(fd, 0, wasi.WHENCE_CUR, &new_offset)) {
+ switch (wasi.fd_seek(fd, 0, .CUR, &new_offset)) {
.SUCCESS => return new_offset,
.BADF => unreachable, // always a race condition
.INVAL => return error.Unseekable,
@@ -4281,7 +4399,7 @@ pub fn lseek_CUR_get(fd: fd_t) SeekError!u64 {
else
system.lseek;
- const rc = lseek_sym(fd, 0, SEEK_CUR);
+ const rc = lseek_sym(fd, 0, SEEK.CUR);
switch (errno(rc)) {
.SUCCESS => return @bitCast(u64, rc),
.BADF => unreachable, // always a race condition
@@ -4319,18 +4437,18 @@ pub fn fcntl(fd: fd_t, cmd: i32, arg: usize) FcntlError!usize {
}
fn setSockFlags(sock: socket_t, flags: u32) !void {
- if ((flags & SOCK_CLOEXEC) != 0) {
+ if ((flags & SOCK.CLOEXEC) != 0) {
if (builtin.os.tag == .windows) {
// TODO: Find out if this is supported for sockets
} else {
- var fd_flags = fcntl(sock, F_GETFD, 0) catch |err| switch (err) {
+ var fd_flags = fcntl(sock, F.GETFD, 0) catch |err| switch (err) {
error.FileBusy => unreachable,
error.Locked => unreachable,
error.PermissionDenied => unreachable,
else => |e| return e,
};
fd_flags |= FD_CLOEXEC;
- _ = fcntl(sock, F_SETFD, fd_flags) catch |err| switch (err) {
+ _ = fcntl(sock, F.SETFD, fd_flags) catch |err| switch (err) {
error.FileBusy => unreachable,
error.Locked => unreachable,
error.PermissionDenied => unreachable,
@@ -4338,7 +4456,7 @@ fn setSockFlags(sock: socket_t, flags: u32) !void {
};
}
}
- if ((flags & SOCK_NONBLOCK) != 0) {
+ if ((flags & SOCK.NONBLOCK) != 0) {
if (builtin.os.tag == .windows) {
var mode: c_ulong = 1;
if (windows.ws2_32.ioctlsocket(sock, windows.ws2_32.FIONBIO, &mode) == windows.ws2_32.SOCKET_ERROR) {
@@ -4351,14 +4469,14 @@ fn setSockFlags(sock: socket_t, flags: u32) !void {
}
}
} else {
- var fl_flags = fcntl(sock, F_GETFL, 0) catch |err| switch (err) {
+ var fl_flags = fcntl(sock, F.GETFL, 0) catch |err| switch (err) {
error.FileBusy => unreachable,
error.Locked => unreachable,
error.PermissionDenied => unreachable,
else => |e| return e,
};
- fl_flags |= O_NONBLOCK;
- _ = fcntl(sock, F_SETFL, fl_flags) catch |err| switch (err) {
+ fl_flags |= O.NONBLOCK;
+ _ = fcntl(sock, F.SETFL, fl_flags) catch |err| switch (err) {
error.FileBusy => unreachable,
error.Locked => unreachable,
error.PermissionDenied => unreachable,
@@ -4444,7 +4562,7 @@ pub fn realpathZ(pathname: [*:0]const u8, out_buffer: *[MAX_PATH_BYTES]u8) RealP
return realpathW(pathname_w.span(), out_buffer);
}
if (!builtin.link_libc) {
- const flags = if (builtin.os.tag == .linux) O_PATH | O_NONBLOCK | O_CLOEXEC else O_NONBLOCK | O_CLOEXEC;
+ const flags = if (builtin.os.tag == .linux) O.PATH | O.NONBLOCK | O.CLOEXEC else O.NONBLOCK | O.CLOEXEC;
const fd = openZ(pathname, flags, 0) catch |err| switch (err) {
error.FileLocksNotSupported => unreachable,
error.WouldBlock => unreachable,
@@ -4523,14 +4641,14 @@ pub fn getFdPath(fd: fd_t, out_buffer: *[MAX_PATH_BYTES]u8) RealPathError![]u8 {
return out_buffer[0..end_index];
},
.macos, .ios, .watchos, .tvos => {
- // On macOS, we can use F_GETPATH fcntl command to query the OS for
+ // On macOS, we can use F.GETPATH fcntl command to query the OS for
// the path to the file descriptor.
@memset(out_buffer, 0, MAX_PATH_BYTES);
- switch (errno(system.fcntl(fd, F_GETPATH, out_buffer))) {
+ switch (errno(system.fcntl(fd, F.GETPATH, out_buffer))) {
.SUCCESS => {},
.BADF => return error.FileNotFound,
// TODO man pages for fcntl on macOS don't really tell you what
- // errno values to expect when command is F_GETPATH...
+ // errno values to expect when command is F.GETPATH...
else => |err| return unexpectedErrno(err),
}
const len = mem.indexOfScalar(u8, out_buffer[0..], @as(u8, 0)) orelse MAX_PATH_BYTES;
@@ -4679,7 +4797,7 @@ pub fn clock_gettime(clk_id: i32, tp: *timespec) ClockGetTimeError!void {
return;
}
if (std.Target.current.os.tag == .windows) {
- if (clk_id == CLOCK_REALTIME) {
+ if (clk_id == CLOCK.REALTIME) {
var ft: windows.FILETIME = undefined;
windows.kernel32.GetSystemTimeAsFileTime(&ft);
// FileTime has a granularity of 100 nanoseconds and uses the NTFS/Windows epoch.
@@ -4691,7 +4809,7 @@ pub fn clock_gettime(clk_id: i32, tp: *timespec) ClockGetTimeError!void {
};
return;
} else {
- // TODO POSIX implementation of CLOCK_MONOTONIC on Windows.
+ // TODO POSIX implementation of CLOCK.MONOTONIC on Windows.
return error.UnsupportedClock;
}
}
@@ -4929,7 +5047,7 @@ pub fn res_mkquery(
// Make a reasonably unpredictable id
var ts: timespec = undefined;
- clock_gettime(CLOCK_REALTIME, &ts) catch {};
+ clock_gettime(CLOCK.REALTIME, &ts) catch {};
const UInt = std.meta.Int(.unsigned, std.meta.bitCount(@TypeOf(ts.tv_nsec)));
const unsec = @bitCast(UInt, ts.tv_nsec);
const id = @truncate(u32, unsec + unsec / 65536);
@@ -4975,7 +5093,7 @@ pub const SendError = error{
SystemResources,
/// The local end has been shut down on a connection oriented socket. In this case, the
- /// process will also receive a SIGPIPE unless MSG_NOSIGNAL is set.
+ /// process will also receive a SIGPIPE unless MSG.NOSIGNAL is set.
BrokenPipe,
FileDescriptorNotASocket,
@@ -4991,13 +5109,13 @@ pub const SendMsgError = SendError || error{
/// The passed address didn't have the correct address family in its sa_family field.
AddressFamilyNotSupported,
- /// Returned when socket is AF_UNIX and the given path has a symlink loop.
+ /// Returned when socket is AF.UNIX and the given path has a symlink loop.
SymLinkLoop,
- /// Returned when socket is AF_UNIX and the given path length exceeds `MAX_PATH_BYTES` bytes.
+ /// Returned when socket is AF.UNIX and the given path length exceeds `MAX_PATH_BYTES` bytes.
NameTooLong,
- /// Returned when socket is AF_UNIX and the given path does not point to an existing file.
+ /// Returned when socket is AF.UNIX and the given path does not point to an existing file.
FileNotFound,
NotDir,
@@ -5090,7 +5208,7 @@ pub const SendToError = SendMsgError;
///
/// sendto(sockfd, buf, len, flags, NULL, 0);
///
-/// If sendto() is used on a connection-mode (`SOCK_STREAM`, `SOCK_SEQPACKET`) socket, the arguments
+/// If sendto() is used on a connection-mode (`SOCK.STREAM`, `SOCK.SEQPACKET`) socket, the arguments
/// `dest_addr` and `addrlen` are asserted to be `null` and `0` respectively, and asserted
/// that the socket was actually connected.
/// Otherwise, the address of the target is given by `dest_addr` with `addrlen` specifying its size.
@@ -5330,7 +5448,7 @@ pub fn sendfile(
// * Descriptor is not valid or locked
// * an mmap(2)-like operation is not available for in_fd
// * count is negative
- // * out_fd has the O_APPEND flag set
+ // * out_fd has the O.APPEND flag set
// Because of the "mmap(2)-like operation" possibility, we fall back to doing read/write
// manually, the same as ENOSYS.
break :sf;
@@ -5396,7 +5514,7 @@ pub fn sendfile(
.INVAL, .OPNOTSUPP, .NOTSOCK, .NOSYS => {
// EINVAL could be any of the following situations:
// * The fd argument is not a regular file.
- // * The s argument is not a SOCK_STREAM type socket.
+ // * The s argument is not a SOCK.STREAM type socket.
// * The offset argument is negative.
// Because of some of these possibilities, we fall back to doing read/write
// manually, the same as ENOSYS.
@@ -5538,7 +5656,7 @@ pub const CopyFileRangeError = error{
FileTooBig,
InputOutput,
/// `fd_in` is not open for reading; or `fd_out` is not open for writing;
- /// or the `O_APPEND` flag is set for `fd_out`.
+ /// or the `O.APPEND` flag is set for `fd_out`.
FilesOpenedWithWrongFlags,
IsDir,
OutOfMemory,
@@ -6154,27 +6272,27 @@ pub fn setrlimit(resource: rlimit_resource, limits: rlimit) SetrlimitError!void
}
pub const MadviseError = error{
- /// advice is MADV_REMOVE, but the specified address range is not a shared writable mapping.
+ /// advice is MADV.REMOVE, but the specified address range is not a shared writable mapping.
AccessDenied,
- /// advice is MADV_HWPOISON, but the caller does not have the CAP_SYS_ADMIN capability.
+ /// advice is MADV.HWPOISON, but the caller does not have the CAP_SYS_ADMIN capability.
PermissionDenied,
/// A kernel resource was temporarily unavailable.
SystemResources,
/// One of the following:
/// * addr is not page-aligned or length is negative
/// * advice is not valid
- /// * advice is MADV_DONTNEED or MADV_REMOVE and the specified address range
+ /// * advice is MADV.DONTNEED or MADV.REMOVE and the specified address range
/// includes locked, Huge TLB pages, or VM_PFNMAP pages.
- /// * advice is MADV_MERGEABLE or MADV_UNMERGEABLE, but the kernel was not
+ /// * advice is MADV.MERGEABLE or MADV.UNMERGEABLE, but the kernel was not
/// configured with CONFIG_KSM.
- /// * advice is MADV_FREE or MADV_WIPEONFORK but the specified address range
- /// includes file, Huge TLB, MAP_SHARED, or VM_PFNMAP ranges.
+ /// * advice is MADV.FREE or MADV.WIPEONFORK but the specified address range
+ /// includes file, Huge TLB, MAP.SHARED, or VM_PFNMAP ranges.
InvalidSyscall,
- /// (for MADV_WILLNEED) Paging in this area would exceed the process's
+ /// (for MADV.WILLNEED) Paging in this area would exceed the process's
/// maximum resident set size.
WouldExceedMaximumResidentSetSize,
/// One of the following:
- /// * (for MADV_WILLNEED) Not enough memory: paging in failed.
+ /// * (for MADV.WILLNEED) Not enough memory: paging in failed.
/// * Addresses in the specified range are not currently mapped, or
/// are outside the address space of the process.
OutOfMemory,
diff --git a/lib/std/os/bits.zig b/lib/std/os/bits.zig
deleted file mode 100644
index 36eda7707f96..000000000000
--- a/lib/std/os/bits.zig
+++ /dev/null
@@ -1,22 +0,0 @@
-//! Platform-dependent types and values that are used along with OS-specific APIs.
-//! These are imported into `std.c`, `std.os`, and `std.os.linux`.
-//! Root source files can define `os.bits` and these will additionally be added
-//! to the namespace.
-
-const std = @import("std");
-const root = @import("root");
-
-pub usingnamespace switch (std.Target.current.os.tag) {
- .macos, .ios, .tvos, .watchos => @import("bits/darwin.zig"),
- .dragonfly => @import("bits/dragonfly.zig"),
- .freebsd => @import("bits/freebsd.zig"),
- .haiku => @import("bits/haiku.zig"),
- .linux => @import("bits/linux.zig"),
- .netbsd => @import("bits/netbsd.zig"),
- .openbsd => @import("bits/openbsd.zig"),
- .wasi => @import("bits/wasi.zig"),
- .windows => @import("bits/windows.zig"),
- else => struct {},
-};
-
-pub usingnamespace if (@hasDecl(root, "os") and @hasDecl(root.os, "bits")) root.os.bits else struct {};
diff --git a/lib/std/os/bits/darwin.zig b/lib/std/os/bits/darwin.zig
deleted file mode 100644
index a0f5e5a400cf..000000000000
--- a/lib/std/os/bits/darwin.zig
+++ /dev/null
@@ -1,1785 +0,0 @@
-const std = @import("../../std.zig");
-const assert = std.debug.assert;
-const maxInt = std.math.maxInt;
-
-pub usingnamespace @import("posix.zig");
-
-// See: https://opensource.apple.com/source/xnu/xnu-6153.141.1/bsd/sys/_types.h.auto.html
-// TODO: audit mode_t/pid_t, should likely be u16/i32
-pub const fd_t = c_int;
-pub const pid_t = c_int;
-pub const mode_t = c_uint;
-pub const uid_t = u32;
-pub const gid_t = u32;
-
-pub const in_port_t = u16;
-pub const sa_family_t = u8;
-pub const socklen_t = u32;
-pub const sockaddr = extern struct {
- len: u8,
- family: sa_family_t,
- data: [14]u8,
-};
-pub const sockaddr_storage = std.x.os.Socket.Address.Native.Storage;
-pub const sockaddr_in = extern struct {
- len: u8 = @sizeOf(sockaddr_in),
- family: sa_family_t = AF_INET,
- port: in_port_t,
- addr: u32,
- zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },
-};
-pub const sockaddr_in6 = extern struct {
- len: u8 = @sizeOf(sockaddr_in6),
- family: sa_family_t = AF_INET6,
- port: in_port_t,
- flowinfo: u32,
- addr: [16]u8,
- scope_id: u32,
-};
-
-/// UNIX domain socket
-pub const sockaddr_un = extern struct {
- len: u8 = @sizeOf(sockaddr_un),
- family: sa_family_t = AF_UNIX,
- path: [104]u8,
-};
-
-pub const timeval = extern struct {
- tv_sec: c_long,
- tv_usec: i32,
-};
-
-pub const timezone = extern struct {
- tz_minuteswest: i32,
- tz_dsttime: i32,
-};
-
-pub const mach_timebase_info_data = extern struct {
- numer: u32,
- denom: u32,
-};
-
-pub const off_t = i64;
-pub const ino_t = u64;
-
-pub const Flock = extern struct {
- l_start: off_t,
- l_len: off_t,
- l_pid: pid_t,
- l_type: i16,
- l_whence: i16,
-};
-
-pub const libc_stat = extern struct {
- dev: i32,
- mode: u16,
- nlink: u16,
- ino: ino_t,
- uid: uid_t,
- gid: gid_t,
- rdev: i32,
- atimesec: isize,
- atimensec: isize,
- mtimesec: isize,
- mtimensec: isize,
- ctimesec: isize,
- ctimensec: isize,
- birthtimesec: isize,
- birthtimensec: isize,
- size: off_t,
- blocks: i64,
- blksize: i32,
- flags: u32,
- gen: u32,
- lspare: i32,
- qspare: [2]i64,
-
- pub fn atime(self: @This()) timespec {
- return timespec{
- .tv_sec = self.atimesec,
- .tv_nsec = self.atimensec,
- };
- }
-
- pub fn mtime(self: @This()) timespec {
- return timespec{
- .tv_sec = self.mtimesec,
- .tv_nsec = self.mtimensec,
- };
- }
-
- pub fn ctime(self: @This()) timespec {
- return timespec{
- .tv_sec = self.ctimesec,
- .tv_nsec = self.ctimensec,
- };
- }
-};
-
-pub const timespec = extern struct {
- tv_sec: isize,
- tv_nsec: isize,
-};
-
-pub const sigset_t = u32;
-pub const empty_sigset: sigset_t = 0;
-
-pub const SIG_ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize));
-pub const SIG_DFL = @intToPtr(?Sigaction.sigaction_fn, 0);
-pub const SIG_IGN = @intToPtr(?Sigaction.sigaction_fn, 1);
-pub const SIG_HOLD = @intToPtr(?Sigaction.sigaction_fn, 5);
-
-pub const siginfo_t = extern struct {
- signo: c_int,
- errno: c_int,
- code: c_int,
- pid: pid_t,
- uid: uid_t,
- status: c_int,
- addr: *c_void,
- value: extern union {
- int: c_int,
- ptr: *c_void,
- },
- si_band: c_long,
- _pad: [7]c_ulong,
-};
-
-/// Renamed from `sigaction` to `Sigaction` to avoid conflict with function name.
-pub const Sigaction = extern struct {
- pub const handler_fn = fn (c_int) callconv(.C) void;
- pub const sigaction_fn = fn (c_int, *const siginfo_t, ?*const c_void) callconv(.C) void;
-
- handler: extern union {
- handler: ?handler_fn,
- sigaction: ?sigaction_fn,
- },
- mask: sigset_t,
- flags: c_uint,
-};
-
-pub const dirent = extern struct {
- d_ino: usize,
- d_seekoff: usize,
- d_reclen: u16,
- d_namlen: u16,
- d_type: u8,
- d_name: u8, // field address is address of first byte of name
-
- pub fn reclen(self: dirent) u16 {
- return self.d_reclen;
- }
-};
-
-/// Renamed from `kevent` to `Kevent` to avoid conflict with function name.
-pub const Kevent = extern struct {
- ident: usize,
- filter: i16,
- flags: u16,
- fflags: u32,
- data: isize,
- udata: usize,
-};
-
-// sys/types.h on macos uses #pragma pack(4) so these checks are
-// to make sure the struct is laid out the same. These values were
-// produced from C code using the offsetof macro.
-comptime {
- assert(@offsetOf(Kevent, "ident") == 0);
- assert(@offsetOf(Kevent, "filter") == 8);
- assert(@offsetOf(Kevent, "flags") == 10);
- assert(@offsetOf(Kevent, "fflags") == 12);
- assert(@offsetOf(Kevent, "data") == 16);
- assert(@offsetOf(Kevent, "udata") == 24);
-}
-
-pub const kevent64_s = extern struct {
- ident: u64,
- filter: i16,
- flags: u16,
- fflags: u32,
- data: i64,
- udata: u64,
- ext: [2]u64,
-};
-
-// sys/types.h on macos uses #pragma pack() so these checks are
-// to make sure the struct is laid out the same. These values were
-// produced from C code using the offsetof macro.
-comptime {
- assert(@offsetOf(kevent64_s, "ident") == 0);
- assert(@offsetOf(kevent64_s, "filter") == 8);
- assert(@offsetOf(kevent64_s, "flags") == 10);
- assert(@offsetOf(kevent64_s, "fflags") == 12);
- assert(@offsetOf(kevent64_s, "data") == 16);
- assert(@offsetOf(kevent64_s, "udata") == 24);
- assert(@offsetOf(kevent64_s, "ext") == 32);
-}
-
-pub const mach_port_t = c_uint;
-pub const clock_serv_t = mach_port_t;
-pub const clock_res_t = c_int;
-pub const mach_port_name_t = natural_t;
-pub const natural_t = c_uint;
-pub const mach_timespec_t = extern struct {
- tv_sec: c_uint,
- tv_nsec: clock_res_t,
-};
-pub const kern_return_t = c_int;
-pub const host_t = mach_port_t;
-pub const CALENDAR_CLOCK = 1;
-
-pub const PATH_MAX = 1024;
-pub const IOV_MAX = 16;
-
-pub const STDIN_FILENO = 0;
-pub const STDOUT_FILENO = 1;
-pub const STDERR_FILENO = 2;
-
-/// [MC2] no permissions
-pub const PROT_NONE = 0x00;
-
-/// [MC2] pages can be read
-pub const PROT_READ = 0x01;
-
-/// [MC2] pages can be written
-pub const PROT_WRITE = 0x02;
-
-/// [MC2] pages can be executed
-pub const PROT_EXEC = 0x04;
-
-/// allocated from memory, swap space
-pub const MAP_ANONYMOUS = 0x1000;
-
-/// map from file (default)
-pub const MAP_FILE = 0x0000;
-
-/// interpret addr exactly
-pub const MAP_FIXED = 0x0010;
-
-/// region may contain semaphores
-pub const MAP_HASSEMAPHORE = 0x0200;
-
-/// changes are private
-pub const MAP_PRIVATE = 0x0002;
-
-/// share changes
-pub const MAP_SHARED = 0x0001;
-
-/// don't cache pages for this mapping
-pub const MAP_NOCACHE = 0x0400;
-
-/// don't reserve needed swap area
-pub const MAP_NORESERVE = 0x0040;
-pub const MAP_FAILED = @intToPtr(*c_void, maxInt(usize));
-
-/// [XSI] no hang in wait/no child to reap
-pub const WNOHANG = 0x00000001;
-
-/// [XSI] notify on stop, untraced child
-pub const WUNTRACED = 0x00000002;
-
-/// take signal on signal stack
-pub const SA_ONSTACK = 0x0001;
-
-/// restart system on signal return
-pub const SA_RESTART = 0x0002;
-
-/// reset to SIG_DFL when taking signal
-pub const SA_RESETHAND = 0x0004;
-
-/// do not generate SIGCHLD on child stop
-pub const SA_NOCLDSTOP = 0x0008;
-
-/// don't mask the signal we're delivering
-pub const SA_NODEFER = 0x0010;
-
-/// don't keep zombies around
-pub const SA_NOCLDWAIT = 0x0020;
-
-/// signal handler with SA_SIGINFO args
-pub const SA_SIGINFO = 0x0040;
-
-/// do not bounce off kernel's sigtramp
-pub const SA_USERTRAMP = 0x0100;
-
-/// signal handler with SA_SIGINFO args with 64bit regs information
-pub const SA_64REGSET = 0x0200;
-
-pub const O_PATH = 0x0000;
-
-pub const F_OK = 0;
-pub const X_OK = 1;
-pub const W_OK = 2;
-pub const R_OK = 4;
-
-/// open for reading only
-pub const O_RDONLY = 0x0000;
-
-/// open for writing only
-pub const O_WRONLY = 0x0001;
-
-/// open for reading and writing
-pub const O_RDWR = 0x0002;
-
-/// do not block on open or for data to become available
-pub const O_NONBLOCK = 0x0004;
-
-/// append on each write
-pub const O_APPEND = 0x0008;
-
-/// create file if it does not exist
-pub const O_CREAT = 0x0200;
-
-/// truncate size to 0
-pub const O_TRUNC = 0x0400;
-
-/// error if O_CREAT and the file exists
-pub const O_EXCL = 0x0800;
-
-/// atomically obtain a shared lock
-pub const O_SHLOCK = 0x0010;
-
-/// atomically obtain an exclusive lock
-pub const O_EXLOCK = 0x0020;
-
-/// do not follow symlinks
-pub const O_NOFOLLOW = 0x0100;
-
-/// allow open of symlinks
-pub const O_SYMLINK = 0x200000;
-
-/// descriptor requested for event notifications only
-pub const O_EVTONLY = 0x8000;
-
-/// mark as close-on-exec
-pub const O_CLOEXEC = 0x1000000;
-
-pub const O_ACCMODE = 3;
-pub const O_ALERT = 536870912;
-pub const O_ASYNC = 64;
-pub const O_DIRECTORY = 1048576;
-pub const O_DP_GETRAWENCRYPTED = 1;
-pub const O_DP_GETRAWUNENCRYPTED = 2;
-pub const O_DSYNC = 4194304;
-pub const O_FSYNC = O_SYNC;
-pub const O_NOCTTY = 131072;
-pub const O_POPUP = 2147483648;
-pub const O_SYNC = 128;
-
-pub const SEEK_SET = 0x0;
-pub const SEEK_CUR = 0x1;
-pub const SEEK_END = 0x2;
-
-pub const DT_UNKNOWN = 0;
-pub const DT_FIFO = 1;
-pub const DT_CHR = 2;
-pub const DT_DIR = 4;
-pub const DT_BLK = 6;
-pub const DT_REG = 8;
-pub const DT_LNK = 10;
-pub const DT_SOCK = 12;
-pub const DT_WHT = 14;
-
-/// block specified signal set
-pub const SIG_BLOCK = 1;
-
-/// unblock specified signal set
-pub const SIG_UNBLOCK = 2;
-
-/// set specified signal set
-pub const SIG_SETMASK = 3;
-
-/// hangup
-pub const SIGHUP = 1;
-
-/// interrupt
-pub const SIGINT = 2;
-
-/// quit
-pub const SIGQUIT = 3;
-
-/// illegal instruction (not reset when caught)
-pub const SIGILL = 4;
-
-/// trace trap (not reset when caught)
-pub const SIGTRAP = 5;
-
-/// abort()
-pub const SIGABRT = 6;
-
-/// pollable event ([XSR] generated, not supported)
-pub const SIGPOLL = 7;
-
-/// compatibility
-pub const SIGIOT = SIGABRT;
-
-/// EMT instruction
-pub const SIGEMT = 7;
-
-/// floating point exception
-pub const SIGFPE = 8;
-
-/// kill (cannot be caught or ignored)
-pub const SIGKILL = 9;
-
-/// bus error
-pub const SIGBUS = 10;
-
-/// segmentation violation
-pub const SIGSEGV = 11;
-
-/// bad argument to system call
-pub const SIGSYS = 12;
-
-/// write on a pipe with no one to read it
-pub const SIGPIPE = 13;
-
-/// alarm clock
-pub const SIGALRM = 14;
-
-/// software termination signal from kill
-pub const SIGTERM = 15;
-
-/// urgent condition on IO channel
-pub const SIGURG = 16;
-
-/// sendable stop signal not from tty
-pub const SIGSTOP = 17;
-
-/// stop signal from tty
-pub const SIGTSTP = 18;
-
-/// continue a stopped process
-pub const SIGCONT = 19;
-
-/// to parent on child stop or exit
-pub const SIGCHLD = 20;
-
-/// to readers pgrp upon background tty read
-pub const SIGTTIN = 21;
-
-/// like TTIN for output if (tp->t_local<OSTOP)
-pub const SIGTTOU = 22;
-
-/// input/output possible signal
-pub const SIGIO = 23;
-
-/// exceeded CPU time limit
-pub const SIGXCPU = 24;
-
-/// exceeded file size limit
-pub const SIGXFSZ = 25;
-
-/// virtual time alarm
-pub const SIGVTALRM = 26;
-
-/// profiling time alarm
-pub const SIGPROF = 27;
-
-/// window size changes
-pub const SIGWINCH = 28;
-
-/// information request
-pub const SIGINFO = 29;
-
-/// user defined signal 1
-pub const SIGUSR1 = 30;
-
-/// user defined signal 2
-pub const SIGUSR2 = 31;
-
-/// no flag value
-pub const KEVENT_FLAG_NONE = 0x000;
-
-/// immediate timeout
-pub const KEVENT_FLAG_IMMEDIATE = 0x001;
-
-/// output events only include change
-pub const KEVENT_FLAG_ERROR_EVENTS = 0x002;
-
-/// add event to kq (implies enable)
-pub const EV_ADD = 0x0001;
-
-/// delete event from kq
-pub const EV_DELETE = 0x0002;
-
-/// enable event
-pub const EV_ENABLE = 0x0004;
-
-/// disable event (not reported)
-pub const EV_DISABLE = 0x0008;
-
-/// only report one occurrence
-pub const EV_ONESHOT = 0x0010;
-
-/// clear event state after reporting
-pub const EV_CLEAR = 0x0020;
-
-/// force immediate event output
-/// ... with or without EV_ERROR
-/// ... use KEVENT_FLAG_ERROR_EVENTS
-/// on syscalls supporting flags
-pub const EV_RECEIPT = 0x0040;
-
-/// disable event after reporting
-pub const EV_DISPATCH = 0x0080;
-
-/// unique kevent per udata value
-pub const EV_UDATA_SPECIFIC = 0x0100;
-
-/// ... in combination with EV_DELETE
-/// will defer delete until udata-specific
-/// event enabled. EINPROGRESS will be
-/// returned to indicate the deferral
-pub const EV_DISPATCH2 = EV_DISPATCH | EV_UDATA_SPECIFIC;
-
-/// report that source has vanished
-/// ... only valid with EV_DISPATCH2
-pub const EV_VANISHED = 0x0200;
-
-/// reserved by system
-pub const EV_SYSFLAGS = 0xF000;
-
-/// filter-specific flag
-pub const EV_FLAG0 = 0x1000;
-
-/// filter-specific flag
-pub const EV_FLAG1 = 0x2000;
-
-/// EOF detected
-pub const EV_EOF = 0x8000;
-
-/// error, data contains errno
-pub const EV_ERROR = 0x4000;
-
-pub const EV_POLL = EV_FLAG0;
-pub const EV_OOBAND = EV_FLAG1;
-
-pub const EVFILT_READ = -1;
-pub const EVFILT_WRITE = -2;
-
-/// attached to aio requests
-pub const EVFILT_AIO = -3;
-
-/// attached to vnodes
-pub const EVFILT_VNODE = -4;
-
-/// attached to struct proc
-pub const EVFILT_PROC = -5;
-
-/// attached to struct proc
-pub const EVFILT_SIGNAL = -6;
-
-/// timers
-pub const EVFILT_TIMER = -7;
-
-/// Mach portsets
-pub const EVFILT_MACHPORT = -8;
-
-/// Filesystem events
-pub const EVFILT_FS = -9;
-
-/// User events
-pub const EVFILT_USER = -10;
-
-/// Virtual memory events
-pub const EVFILT_VM = -12;
-
-/// Exception events
-pub const EVFILT_EXCEPT = -15;
-
-pub const EVFILT_SYSCOUNT = 17;
-
-/// On input, NOTE_TRIGGER causes the event to be triggered for output.
-pub const NOTE_TRIGGER = 0x01000000;
-
-/// ignore input fflags
-pub const NOTE_FFNOP = 0x00000000;
-
-/// and fflags
-pub const NOTE_FFAND = 0x40000000;
-
-/// or fflags
-pub const NOTE_FFOR = 0x80000000;
-
-/// copy fflags
-pub const NOTE_FFCOPY = 0xc0000000;
-
-/// mask for operations
-pub const NOTE_FFCTRLMASK = 0xc0000000;
-pub const NOTE_FFLAGSMASK = 0x00ffffff;
-
-/// low water mark
-pub const NOTE_LOWAT = 0x00000001;
-
-/// OOB data
-pub const NOTE_OOB = 0x00000002;
-
-/// vnode was removed
-pub const NOTE_DELETE = 0x00000001;
-
-/// data contents changed
-pub const NOTE_WRITE = 0x00000002;
-
-/// size increased
-pub const NOTE_EXTEND = 0x00000004;
-
-/// attributes changed
-pub const NOTE_ATTRIB = 0x00000008;
-
-/// link count changed
-pub const NOTE_LINK = 0x00000010;
-
-/// vnode was renamed
-pub const NOTE_RENAME = 0x00000020;
-
-/// vnode access was revoked
-pub const NOTE_REVOKE = 0x00000040;
-
-/// No specific vnode event: to test for EVFILT_READ activation
-pub const NOTE_NONE = 0x00000080;
-
-/// vnode was unlocked by flock(2)
-pub const NOTE_FUNLOCK = 0x00000100;
-
-/// process exited
-pub const NOTE_EXIT = 0x80000000;
-
-/// process forked
-pub const NOTE_FORK = 0x40000000;
-
-/// process exec'd
-pub const NOTE_EXEC = 0x20000000;
-
-/// shared with EVFILT_SIGNAL
-pub const NOTE_SIGNAL = 0x08000000;
-
-/// exit status to be returned, valid for child process only
-pub const NOTE_EXITSTATUS = 0x04000000;
-
-/// provide details on reasons for exit
-pub const NOTE_EXIT_DETAIL = 0x02000000;
-
-/// mask for signal & exit status
-pub const NOTE_PDATAMASK = 0x000fffff;
-pub const NOTE_PCTRLMASK = (~NOTE_PDATAMASK);
-
-pub const NOTE_EXIT_DETAIL_MASK = 0x00070000;
-pub const NOTE_EXIT_DECRYPTFAIL = 0x00010000;
-pub const NOTE_EXIT_MEMORY = 0x00020000;
-pub const NOTE_EXIT_CSERROR = 0x00040000;
-
-/// will react on memory pressure
-pub const NOTE_VM_PRESSURE = 0x80000000;
-
-/// will quit on memory pressure, possibly after cleaning up dirty state
-pub const NOTE_VM_PRESSURE_TERMINATE = 0x40000000;
-
-/// will quit immediately on memory pressure
-pub const NOTE_VM_PRESSURE_SUDDEN_TERMINATE = 0x20000000;
-
-/// there was an error
-pub const NOTE_VM_ERROR = 0x10000000;
-
-/// data is seconds
-pub const NOTE_SECONDS = 0x00000001;
-
-/// data is microseconds
-pub const NOTE_USECONDS = 0x00000002;
-
-/// data is nanoseconds
-pub const NOTE_NSECONDS = 0x00000004;
-
-/// absolute timeout
-pub const NOTE_ABSOLUTE = 0x00000008;
-
-/// ext[1] holds leeway for power aware timers
-pub const NOTE_LEEWAY = 0x00000010;
-
-/// system does minimal timer coalescing
-pub const NOTE_CRITICAL = 0x00000020;
-
-/// system does maximum timer coalescing
-pub const NOTE_BACKGROUND = 0x00000040;
-pub const NOTE_MACH_CONTINUOUS_TIME = 0x00000080;
-
-/// data is mach absolute time units
-pub const NOTE_MACHTIME = 0x00000100;
-
-pub const AF_UNSPEC = 0;
-pub const AF_LOCAL = 1;
-pub const AF_UNIX = AF_LOCAL;
-pub const AF_INET = 2;
-pub const AF_SYS_CONTROL = 2;
-pub const AF_IMPLINK = 3;
-pub const AF_PUP = 4;
-pub const AF_CHAOS = 5;
-pub const AF_NS = 6;
-pub const AF_ISO = 7;
-pub const AF_OSI = AF_ISO;
-pub const AF_ECMA = 8;
-pub const AF_DATAKIT = 9;
-pub const AF_CCITT = 10;
-pub const AF_SNA = 11;
-pub const AF_DECnet = 12;
-pub const AF_DLI = 13;
-pub const AF_LAT = 14;
-pub const AF_HYLINK = 15;
-pub const AF_APPLETALK = 16;
-pub const AF_ROUTE = 17;
-pub const AF_LINK = 18;
-pub const AF_XTP = 19;
-pub const AF_COIP = 20;
-pub const AF_CNT = 21;
-pub const AF_RTIP = 22;
-pub const AF_IPX = 23;
-pub const AF_SIP = 24;
-pub const AF_PIP = 25;
-pub const AF_ISDN = 28;
-pub const AF_E164 = AF_ISDN;
-pub const AF_KEY = 29;
-pub const AF_INET6 = 30;
-pub const AF_NATM = 31;
-pub const AF_SYSTEM = 32;
-pub const AF_NETBIOS = 33;
-pub const AF_PPP = 34;
-pub const AF_MAX = 40;
-
-pub const PF_UNSPEC = AF_UNSPEC;
-pub const PF_LOCAL = AF_LOCAL;
-pub const PF_UNIX = PF_LOCAL;
-pub const PF_INET = AF_INET;
-pub const PF_IMPLINK = AF_IMPLINK;
-pub const PF_PUP = AF_PUP;
-pub const PF_CHAOS = AF_CHAOS;
-pub const PF_NS = AF_NS;
-pub const PF_ISO = AF_ISO;
-pub const PF_OSI = AF_ISO;
-pub const PF_ECMA = AF_ECMA;
-pub const PF_DATAKIT = AF_DATAKIT;
-pub const PF_CCITT = AF_CCITT;
-pub const PF_SNA = AF_SNA;
-pub const PF_DECnet = AF_DECnet;
-pub const PF_DLI = AF_DLI;
-pub const PF_LAT = AF_LAT;
-pub const PF_HYLINK = AF_HYLINK;
-pub const PF_APPLETALK = AF_APPLETALK;
-pub const PF_ROUTE = AF_ROUTE;
-pub const PF_LINK = AF_LINK;
-pub const PF_XTP = AF_XTP;
-pub const PF_COIP = AF_COIP;
-pub const PF_CNT = AF_CNT;
-pub const PF_SIP = AF_SIP;
-pub const PF_IPX = AF_IPX;
-pub const PF_RTIP = AF_RTIP;
-pub const PF_PIP = AF_PIP;
-pub const PF_ISDN = AF_ISDN;
-pub const PF_KEY = AF_KEY;
-pub const PF_INET6 = AF_INET6;
-pub const PF_NATM = AF_NATM;
-pub const PF_SYSTEM = AF_SYSTEM;
-pub const PF_NETBIOS = AF_NETBIOS;
-pub const PF_PPP = AF_PPP;
-pub const PF_MAX = AF_MAX;
-
-pub const SYSPROTO_EVENT = 1;
-pub const SYSPROTO_CONTROL = 2;
-
-pub const SOCK_STREAM = 1;
-pub const SOCK_DGRAM = 2;
-pub const SOCK_RAW = 3;
-pub const SOCK_RDM = 4;
-pub const SOCK_SEQPACKET = 5;
-pub const SOCK_MAXADDRLEN = 255;
-
-/// Not actually supported by Darwin, but Zig supplies a shim.
-/// This numerical value is not ABI-stable. It need only not conflict
-/// with any other "SOCK_" bits.
-pub const SOCK_CLOEXEC = 1 << 15;
-/// Not actually supported by Darwin, but Zig supplies a shim.
-/// This numerical value is not ABI-stable. It need only not conflict
-/// with any other "SOCK_" bits.
-pub const SOCK_NONBLOCK = 1 << 16;
-
-pub const IPPROTO_ICMP = 1;
-pub const IPPROTO_ICMPV6 = 58;
-pub const IPPROTO_TCP = 6;
-pub const IPPROTO_UDP = 17;
-pub const IPPROTO_IP = 0;
-pub const IPPROTO_IPV6 = 41;
-
-pub const SOL_SOCKET = 0xffff;
-
-pub const SO_DEBUG = 0x0001;
-pub const SO_ACCEPTCONN = 0x0002;
-pub const SO_REUSEADDR = 0x0004;
-pub const SO_KEEPALIVE = 0x0008;
-pub const SO_DONTROUTE = 0x0010;
-pub const SO_BROADCAST = 0x0020;
-pub const SO_USELOOPBACK = 0x0040;
-pub const SO_LINGER = 0x1080;
-pub const SO_OOBINLINE = 0x0100;
-pub const SO_REUSEPORT = 0x0200;
-pub const SO_ACCEPTFILTER = 0x1000;
-pub const SO_SNDBUF = 0x1001;
-pub const SO_RCVBUF = 0x1002;
-pub const SO_SNDLOWAT = 0x1003;
-pub const SO_RCVLOWAT = 0x1004;
-pub const SO_SNDTIMEO = 0x1005;
-pub const SO_RCVTIMEO = 0x1006;
-pub const SO_ERROR = 0x1007;
-pub const SO_TYPE = 0x1008;
-
-pub const SO_NREAD = 0x1020;
-pub const SO_NKE = 0x1021;
-pub const SO_NOSIGPIPE = 0x1022;
-pub const SO_NOADDRERR = 0x1023;
-pub const SO_NWRITE = 0x1024;
-pub const SO_REUSESHAREUID = 0x1025;
-
-fn wstatus(x: u32) u32 {
- return x & 0o177;
-}
-const wstopped = 0o177;
-pub fn WEXITSTATUS(x: u32) u8 {
- return @intCast(u8, x >> 8);
-}
-pub fn WTERMSIG(x: u32) u32 {
- return wstatus(x);
-}
-pub fn WSTOPSIG(x: u32) u32 {
- return x >> 8;
-}
-pub fn WIFEXITED(x: u32) bool {
- return wstatus(x) == 0;
-}
-pub fn WIFSTOPPED(x: u32) bool {
- return wstatus(x) == wstopped and WSTOPSIG(x) != 0x13;
-}
-pub fn WIFSIGNALED(x: u32) bool {
- return wstatus(x) != wstopped and wstatus(x) != 0;
-}
-
-pub const E = enum(u16) {
- /// No error occurred.
- SUCCESS = 0,
-
- /// Operation not permitted
- PERM = 1,
-
- /// No such file or directory
- NOENT = 2,
-
- /// No such process
- SRCH = 3,
-
- /// Interrupted system call
- INTR = 4,
-
- /// Input/output error
- IO = 5,
-
- /// Device not configured
- NXIO = 6,
-
- /// Argument list too long
- @"2BIG" = 7,
-
- /// Exec format error
- NOEXEC = 8,
-
- /// Bad file descriptor
- BADF = 9,
-
- /// No child processes
- CHILD = 10,
-
- /// Resource deadlock avoided
- DEADLK = 11,
-
- /// Cannot allocate memory
- NOMEM = 12,
-
- /// Permission denied
- ACCES = 13,
-
- /// Bad address
- FAULT = 14,
-
- /// Block device required
- NOTBLK = 15,
-
- /// Device / Resource busy
- BUSY = 16,
-
- /// File exists
- EXIST = 17,
-
- /// Cross-device link
- XDEV = 18,
-
- /// Operation not supported by device
- NODEV = 19,
-
- /// Not a directory
- NOTDIR = 20,
-
- /// Is a directory
- ISDIR = 21,
-
- /// Invalid argument
- INVAL = 22,
-
- /// Too many open files in system
- NFILE = 23,
-
- /// Too many open files
- MFILE = 24,
-
- /// Inappropriate ioctl for device
- NOTTY = 25,
-
- /// Text file busy
- TXTBSY = 26,
-
- /// File too large
- FBIG = 27,
-
- /// No space left on device
- NOSPC = 28,
-
- /// Illegal seek
- SPIPE = 29,
-
- /// Read-only file system
- ROFS = 30,
-
- /// Too many links
- MLINK = 31,
-
- /// Broken pipe
- PIPE = 32,
-
- // math software
-
- /// Numerical argument out of domain
- DOM = 33,
-
- /// Result too large
- RANGE = 34,
-
- // non-blocking and interrupt i/o
-
- /// Resource temporarily unavailable
- /// This is the same code used for `WOULDBLOCK`.
- AGAIN = 35,
-
- /// Operation now in progress
- INPROGRESS = 36,
-
- /// Operation already in progress
- ALREADY = 37,
-
- // ipc/network software -- argument errors
-
- /// Socket operation on non-socket
- NOTSOCK = 38,
-
- /// Destination address required
- DESTADDRREQ = 39,
-
- /// Message too long
- MSGSIZE = 40,
-
- /// Protocol wrong type for socket
- PROTOTYPE = 41,
-
- /// Protocol not available
- NOPROTOOPT = 42,
-
- /// Protocol not supported
- PROTONOSUPPORT = 43,
-
- /// Socket type not supported
- SOCKTNOSUPPORT = 44,
-
- /// Operation not supported
- /// The same code is used for `NOTSUP`.
- OPNOTSUPP = 45,
-
- /// Protocol family not supported
- PFNOSUPPORT = 46,
-
- /// Address family not supported by protocol family
- AFNOSUPPORT = 47,
-
- /// Address already in use
- ADDRINUSE = 48,
- /// Can't assign requested address
-
- // ipc/network software -- operational errors
- ADDRNOTAVAIL = 49,
-
- /// Network is down
- NETDOWN = 50,
-
- /// Network is unreachable
- NETUNREACH = 51,
-
- /// Network dropped connection on reset
- NETRESET = 52,
-
- /// Software caused connection abort
- CONNABORTED = 53,
-
- /// Connection reset by peer
- CONNRESET = 54,
-
- /// No buffer space available
- NOBUFS = 55,
-
- /// Socket is already connected
- ISCONN = 56,
-
- /// Socket is not connected
- NOTCONN = 57,
-
- /// Can't send after socket shutdown
- SHUTDOWN = 58,
-
- /// Too many references: can't splice
- TOOMANYREFS = 59,
-
- /// Operation timed out
- TIMEDOUT = 60,
-
- /// Connection refused
- CONNREFUSED = 61,
-
- /// Too many levels of symbolic links
- LOOP = 62,
-
- /// File name too long
- NAMETOOLONG = 63,
-
- /// Host is down
- HOSTDOWN = 64,
-
- /// No route to host
- HOSTUNREACH = 65,
- /// Directory not empty
-
- // quotas & mush
- NOTEMPTY = 66,
-
- /// Too many processes
- PROCLIM = 67,
-
- /// Too many users
- USERS = 68,
- /// Disc quota exceeded
-
- // Network File System
- DQUOT = 69,
-
- /// Stale NFS file handle
- STALE = 70,
-
- /// Too many levels of remote in path
- REMOTE = 71,
-
- /// RPC struct is bad
- BADRPC = 72,
-
- /// RPC version wrong
- RPCMISMATCH = 73,
-
- /// RPC prog. not avail
- PROGUNAVAIL = 74,
-
- /// Program version wrong
- PROGMISMATCH = 75,
-
- /// Bad procedure for program
- PROCUNAVAIL = 76,
-
- /// No locks available
- NOLCK = 77,
-
- /// Function not implemented
- NOSYS = 78,
-
- /// Inappropriate file type or format
- FTYPE = 79,
-
- /// Authentication error
- AUTH = 80,
-
- /// Need authenticator
- NEEDAUTH = 81,
-
- // Intelligent device errors
-
- /// Device power is off
- PWROFF = 82,
-
- /// Device error, e.g. paper out
- DEVERR = 83,
-
- /// Value too large to be stored in data type
- OVERFLOW = 84,
-
- // Program loading errors
-
- /// Bad executable
- BADEXEC = 85,
-
- /// Bad CPU type in executable
- BADARCH = 86,
-
- /// Shared library version mismatch
- SHLIBVERS = 87,
-
- /// Malformed Macho file
- BADMACHO = 88,
-
- /// Operation canceled
- CANCELED = 89,
-
- /// Identifier removed
- IDRM = 90,
-
- /// No message of desired type
- NOMSG = 91,
-
- /// Illegal byte sequence
- ILSEQ = 92,
-
- /// Attribute not found
- NOATTR = 93,
-
- /// Bad message
- BADMSG = 94,
-
- /// Reserved
- MULTIHOP = 95,
-
- /// No message available on STREAM
- NODATA = 96,
-
- /// Reserved
- NOLINK = 97,
-
- /// No STREAM resources
- NOSR = 98,
-
- /// Not a STREAM
- NOSTR = 99,
-
- /// Protocol error
- PROTO = 100,
-
- /// STREAM ioctl timeout
- TIME = 101,
-
- /// No such policy registered
- NOPOLICY = 103,
-
- /// State not recoverable
- NOTRECOVERABLE = 104,
-
- /// Previous owner died
- OWNERDEAD = 105,
-
- /// Interface output queue is full
- QFULL = 106,
-
- _,
-};
-
-pub const SIGSTKSZ = 131072;
-pub const MINSIGSTKSZ = 32768;
-
-pub const SS_ONSTACK = 1;
-pub const SS_DISABLE = 4;
-
-pub const stack_t = extern struct {
- ss_sp: [*]u8,
- ss_size: isize,
- ss_flags: i32,
-};
-
-pub const S_IFMT = 0o170000;
-
-pub const S_IFIFO = 0o010000;
-pub const S_IFCHR = 0o020000;
-pub const S_IFDIR = 0o040000;
-pub const S_IFBLK = 0o060000;
-pub const S_IFREG = 0o100000;
-pub const S_IFLNK = 0o120000;
-pub const S_IFSOCK = 0o140000;
-pub const S_IFWHT = 0o160000;
-
-pub const S_ISUID = 0o4000;
-pub const S_ISGID = 0o2000;
-pub const S_ISVTX = 0o1000;
-pub const S_IRWXU = 0o700;
-pub const S_IRUSR = 0o400;
-pub const S_IWUSR = 0o200;
-pub const S_IXUSR = 0o100;
-pub const S_IRWXG = 0o070;
-pub const S_IRGRP = 0o040;
-pub const S_IWGRP = 0o020;
-pub const S_IXGRP = 0o010;
-pub const S_IRWXO = 0o007;
-pub const S_IROTH = 0o004;
-pub const S_IWOTH = 0o002;
-pub const S_IXOTH = 0o001;
-
-pub fn S_ISFIFO(m: u32) bool {
- return m & S_IFMT == S_IFIFO;
-}
-
-pub fn S_ISCHR(m: u32) bool {
- return m & S_IFMT == S_IFCHR;
-}
-
-pub fn S_ISDIR(m: u32) bool {
- return m & S_IFMT == S_IFDIR;
-}
-
-pub fn S_ISBLK(m: u32) bool {
- return m & S_IFMT == S_IFBLK;
-}
-
-pub fn S_ISREG(m: u32) bool {
- return m & S_IFMT == S_IFREG;
-}
-
-pub fn S_ISLNK(m: u32) bool {
- return m & S_IFMT == S_IFLNK;
-}
-
-pub fn S_ISSOCK(m: u32) bool {
- return m & S_IFMT == S_IFSOCK;
-}
-
-pub fn S_IWHT(m: u32) bool {
- return m & S_IFMT == S_IFWHT;
-}
-
-pub const HOST_NAME_MAX = 72;
-
-pub const AT_FDCWD = -2;
-
-/// Use effective ids in access check
-pub const AT_EACCESS = 0x0010;
-
-/// Act on the symlink itself not the target
-pub const AT_SYMLINK_NOFOLLOW = 0x0020;
-
-/// Act on target of symlink
-pub const AT_SYMLINK_FOLLOW = 0x0040;
-
-/// Path refers to directory
-pub const AT_REMOVEDIR = 0x0080;
-
-pub const addrinfo = extern struct {
- flags: i32,
- family: i32,
- socktype: i32,
- protocol: i32,
- addrlen: socklen_t,
- canonname: ?[*:0]u8,
- addr: ?*sockaddr,
- next: ?*addrinfo,
-};
-
-pub const RTLD_LAZY = 0x1;
-pub const RTLD_NOW = 0x2;
-pub const RTLD_LOCAL = 0x4;
-pub const RTLD_GLOBAL = 0x8;
-pub const RTLD_NOLOAD = 0x10;
-pub const RTLD_NODELETE = 0x80;
-pub const RTLD_FIRST = 0x100;
-
-pub const RTLD_NEXT = @intToPtr(*c_void, @bitCast(usize, @as(isize, -1)));
-pub const RTLD_DEFAULT = @intToPtr(*c_void, @bitCast(usize, @as(isize, -2)));
-pub const RTLD_SELF = @intToPtr(*c_void, @bitCast(usize, @as(isize, -3)));
-pub const RTLD_MAIN_ONLY = @intToPtr(*c_void, @bitCast(usize, @as(isize, -5)));
-
-/// duplicate file descriptor
-pub const F_DUPFD = 0;
-
-/// get file descriptor flags
-pub const F_GETFD = 1;
-
-/// set file descriptor flags
-pub const F_SETFD = 2;
-
-/// get file status flags
-pub const F_GETFL = 3;
-
-/// set file status flags
-pub const F_SETFL = 4;
-
-/// get SIGIO/SIGURG proc/pgrp
-pub const F_GETOWN = 5;
-
-/// set SIGIO/SIGURG proc/pgrp
-pub const F_SETOWN = 6;
-
-/// get record locking information
-pub const F_GETLK = 7;
-
-/// set record locking information
-pub const F_SETLK = 8;
-
-/// F_SETLK; wait if blocked
-pub const F_SETLKW = 9;
-
-/// F_SETLK; wait if blocked, return on timeout
-pub const F_SETLKWTIMEOUT = 10;
-pub const F_FLUSH_DATA = 40;
-
-/// Used for regression test
-pub const F_CHKCLEAN = 41;
-
-/// Preallocate storage
-pub const F_PREALLOCATE = 42;
-
-/// Truncate a file without zeroing space
-pub const F_SETSIZE = 43;
-
-/// Issue an advisory read async with no copy to user
-pub const F_RDADVISE = 44;
-
-/// turn read ahead off/on for this fd
-pub const F_RDAHEAD = 45;
-
-/// turn data caching off/on for this fd
-pub const F_NOCACHE = 48;
-
-/// file offset to device offset
-pub const F_LOG2PHYS = 49;
-
-/// return the full path of the fd
-pub const F_GETPATH = 50;
-
-/// fsync + ask the drive to flush to the media
-pub const F_FULLFSYNC = 51;
-
-/// find which component (if any) is a package
-pub const F_PATHPKG_CHECK = 52;
-
-/// "freeze" all fs operations
-pub const F_FREEZE_FS = 53;
-
-/// "thaw" all fs operations
-pub const F_THAW_FS = 54;
-
-/// turn data caching off/on (globally) for this file
-pub const F_GLOBAL_NOCACHE = 55;
-
-/// add detached signatures
-pub const F_ADDSIGS = 59;
-
-/// add signature from same file (used by dyld for shared libs)
-pub const F_ADDFILESIGS = 61;
-
-/// used in conjunction with F_NOCACHE to indicate that DIRECT, synchonous writes
-/// should not be used (i.e. its ok to temporaily create cached pages)
-pub const F_NODIRECT = 62;
-
-///Get the protection class of a file from the EA, returns int
-pub const F_GETPROTECTIONCLASS = 63;
-
-///Set the protection class of a file for the EA, requires int
-pub const F_SETPROTECTIONCLASS = 64;
-
-///file offset to device offset, extended
-pub const F_LOG2PHYS_EXT = 65;
-
-///get record locking information, per-process
-pub const F_GETLKPID = 66;
-
-///Mark the file as being the backing store for another filesystem
-pub const F_SETBACKINGSTORE = 70;
-
-///return the full path of the FD, but error in specific mtmd circumstances
-pub const F_GETPATH_MTMINFO = 71;
-
-///Returns the code directory, with associated hashes, to the caller
-pub const F_GETCODEDIR = 72;
-
-///No SIGPIPE generated on EPIPE
-pub const F_SETNOSIGPIPE = 73;
-
-///Status of SIGPIPE for this fd
-pub const F_GETNOSIGPIPE = 74;
-
-///For some cases, we need to rewrap the key for AKS/MKB
-pub const F_TRANSCODEKEY = 75;
-
-///file being written to a by single writer... if throttling enabled, writes
-///may be broken into smaller chunks with throttling in between
-pub const F_SINGLE_WRITER = 76;
-
-///Get the protection version number for this filesystem
-pub const F_GETPROTECTIONLEVEL = 77;
-
-///Add detached code signatures (used by dyld for shared libs)
-pub const F_FINDSIGS = 78;
-
-///Add signature from same file, only if it is signed by Apple (used by dyld for simulator)
-pub const F_ADDFILESIGS_FOR_DYLD_SIM = 83;
-
-///fsync + issue barrier to drive
-pub const F_BARRIERFSYNC = 85;
-
-///Add signature from same file, return end offset in structure on success
-pub const F_ADDFILESIGS_RETURN = 97;
-
-///Check if Library Validation allows this Mach-O file to be mapped into the calling process
-pub const F_CHECK_LV = 98;
-
-///Deallocate a range of the file
-pub const F_PUNCHHOLE = 99;
-
-///Trim an active file
-pub const F_TRIM_ACTIVE_FILE = 100;
-
-pub const FCNTL_FS_SPECIFIC_BASE = 0x00010000;
-
-///mark the dup with FD_CLOEXEC
-pub const F_DUPFD_CLOEXEC = 67;
-
-///close-on-exec flag
-pub const FD_CLOEXEC = 1;
-
-/// shared or read lock
-pub const F_RDLCK = 1;
-
-/// unlock
-pub const F_UNLCK = 2;
-
-/// exclusive or write lock
-pub const F_WRLCK = 3;
-
-pub const LOCK_SH = 1;
-pub const LOCK_EX = 2;
-pub const LOCK_UN = 8;
-pub const LOCK_NB = 4;
-
-pub const nfds_t = u32;
-pub const pollfd = extern struct {
- fd: fd_t,
- events: i16,
- revents: i16,
-};
-
-pub const POLLIN = 0x001;
-pub const POLLPRI = 0x002;
-pub const POLLOUT = 0x004;
-pub const POLLRDNORM = 0x040;
-pub const POLLWRNORM = POLLOUT;
-pub const POLLRDBAND = 0x080;
-pub const POLLWRBAND = 0x100;
-
-pub const POLLEXTEND = 0x0200;
-pub const POLLATTRIB = 0x0400;
-pub const POLLNLINK = 0x0800;
-pub const POLLWRITE = 0x1000;
-
-pub const POLLERR = 0x008;
-pub const POLLHUP = 0x010;
-pub const POLLNVAL = 0x020;
-
-pub const POLLSTANDARD = POLLIN | POLLPRI | POLLOUT | POLLRDNORM | POLLRDBAND | POLLWRBAND | POLLERR | POLLHUP | POLLNVAL;
-
-pub const CLOCK_REALTIME = 0;
-pub const CLOCK_MONOTONIC = 6;
-pub const CLOCK_MONOTONIC_RAW = 4;
-pub const CLOCK_MONOTONIC_RAW_APPROX = 5;
-pub const CLOCK_UPTIME_RAW = 8;
-pub const CLOCK_UPTIME_RAW_APPROX = 9;
-pub const CLOCK_PROCESS_CPUTIME_ID = 12;
-pub const CLOCK_THREAD_CPUTIME_ID = 16;
-
-/// Max open files per process
-/// https://opensource.apple.com/source/xnu/xnu-4903.221.2/bsd/sys/syslimits.h.auto.html
-pub const OPEN_MAX = 10240;
-pub const RUSAGE_SELF = 0;
-pub const RUSAGE_CHILDREN = -1;
-
-pub const rusage = extern struct {
- utime: timeval,
- stime: timeval,
- maxrss: isize,
- ixrss: isize,
- idrss: isize,
- isrss: isize,
- minflt: isize,
- majflt: isize,
- nswap: isize,
- inblock: isize,
- oublock: isize,
- msgsnd: isize,
- msgrcv: isize,
- nsignals: isize,
- nvcsw: isize,
- nivcsw: isize,
-};
-
-pub const rlimit_resource = enum(c_int) {
- CPU = 0,
- FSIZE = 1,
- DATA = 2,
- STACK = 3,
- CORE = 4,
- RSS = 5,
- MEMLOCK = 6,
- NPROC = 7,
- NOFILE = 8,
- _,
-
- pub const AS: rlimit_resource = .RSS;
-};
-
-pub const rlim_t = u64;
-
-/// No limit
-pub const RLIM_INFINITY: rlim_t = (1 << 63) - 1;
-
-pub const RLIM_SAVED_MAX = RLIM_INFINITY;
-pub const RLIM_SAVED_CUR = RLIM_INFINITY;
-
-pub const rlimit = extern struct {
- /// Soft limit
- cur: rlim_t,
- /// Hard limit
- max: rlim_t,
-};
-
-pub const SHUT_RD = 0;
-pub const SHUT_WR = 1;
-pub const SHUT_RDWR = 2;
-
-// Term
-pub const VEOF = 0;
-pub const VEOL = 1;
-pub const VEOL2 = 2;
-pub const VERASE = 3;
-pub const VWERASE = 4;
-pub const VKILL = 5;
-pub const VREPRINT = 6;
-pub const VINTR = 8;
-pub const VQUIT = 9;
-pub const VSUSP = 10;
-pub const VDSUSP = 11;
-pub const VSTART = 12;
-pub const VSTOP = 13;
-pub const VLNEXT = 14;
-pub const VDISCARD = 15;
-pub const VMIN = 16;
-pub const VTIME = 17;
-pub const VSTATUS = 18;
-pub const NCCS = 20; // 2 spares (7, 19)
-
-pub const IGNBRK = 0x00000001; // ignore BREAK condition
-pub const BRKINT = 0x00000002; // map BREAK to SIGINTR
-pub const IGNPAR = 0x00000004; // ignore (discard) parity errors
-pub const PARMRK = 0x00000008; // mark parity and framing errors
-pub const INPCK = 0x00000010; // enable checking of parity errors
-pub const ISTRIP = 0x00000020; // strip 8th bit off chars
-pub const INLCR = 0x00000040; // map NL into CR
-pub const IGNCR = 0x00000080; // ignore CR
-pub const ICRNL = 0x00000100; // map CR to NL (ala CRMOD)
-pub const IXON = 0x00000200; // enable output flow control
-pub const IXOFF = 0x00000400; // enable input flow control
-pub const IXANY = 0x00000800; // any char will restart after stop
-pub const IMAXBEL = 0x00002000; // ring bell on input queue full
-pub const IUTF8 = 0x00004000; // maintain state for UTF-8 VERASE
-
-pub const OPOST = 0x00000001; //enable following output processing
-pub const ONLCR = 0x00000002; // map NL to CR-NL (ala CRMOD)
-pub const OXTABS = 0x00000004; // expand tabs to spaces
-pub const ONOEOT = 0x00000008; // discard EOT's (^D) on output)
-
-pub const OCRNL = 0x00000010; // map CR to NL on output
-pub const ONOCR = 0x00000020; // no CR output at column 0
-pub const ONLRET = 0x00000040; // NL performs CR function
-pub const OFILL = 0x00000080; // use fill characters for delay
-pub const NLDLY = 0x00000300; // \n delay
-pub const TABDLY = 0x00000c04; // horizontal tab delay
-pub const CRDLY = 0x00003000; // \r delay
-pub const FFDLY = 0x00004000; // form feed delay
-pub const BSDLY = 0x00008000; // \b delay
-pub const VTDLY = 0x00010000; // vertical tab delay
-pub const OFDEL = 0x00020000; // fill is DEL, else NUL
-
-pub const NL0 = 0x00000000;
-pub const NL1 = 0x00000100;
-pub const NL2 = 0x00000200;
-pub const NL3 = 0x00000300;
-pub const TAB0 = 0x00000000;
-pub const TAB1 = 0x00000400;
-pub const TAB2 = 0x00000800;
-pub const TAB3 = 0x00000004;
-pub const CR0 = 0x00000000;
-pub const CR1 = 0x00001000;
-pub const CR2 = 0x00002000;
-pub const CR3 = 0x00003000;
-pub const FF0 = 0x00000000;
-pub const FF1 = 0x00004000;
-pub const BS0 = 0x00000000;
-pub const BS1 = 0x00008000;
-pub const VT0 = 0x00000000;
-pub const VT1 = 0x00010000;
-
-pub const CIGNORE = 0x00000001; // ignore control flags
-pub const CSIZE = 0x00000300; // character size mask
-pub const CS5 = 0x00000000; // 5 bits (pseudo)
-pub const CS6 = 0x00000100; // 6 bits
-pub const CS7 = 0x00000200; // 7 bits
-pub const CS8 = 0x00000300; // 8 bits
-pub const CSTOPB = 0x0000040; // send 2 stop bits
-pub const CREAD = 0x00000800; // enable receiver
-pub const PARENB = 0x00001000; // parity enable
-pub const PARODD = 0x00002000; // odd parity, else even
-pub const HUPCL = 0x00004000; // hang up on last close
-pub const CLOCAL = 0x00008000; // ignore modem status lines
-pub const CCTS_OFLOW = 0x00010000; // CTS flow control of output
-pub const CRTSCTS = (CCTS_OFLOW | CRTS_IFLOW);
-pub const CRTS_IFLOW = 0x00020000; // RTS flow control of input
-pub const CDTR_IFLOW = 0x00040000; // DTR flow control of input
-pub const CDSR_OFLOW = 0x00080000; // DSR flow control of output
-pub const CCAR_OFLOW = 0x00100000; // DCD flow control of output
-pub const MDMBUF = 0x00100000; // old name for CCAR_OFLOW
-
-pub const ECHOKE = 0x00000001; // visual erase for line kill
-pub const ECHOE = 0x00000002; // visually erase chars
-pub const ECHOK = 0x00000004; // echo NL after line kill
-pub const ECHO = 0x00000008; // enable echoing
-pub const ECHONL = 0x00000010; // echo NL even if ECHO is off
-pub const ECHOPRT = 0x00000020; // visual erase mode for hardcopy
-pub const ECHOCTL = 0x00000040; // echo control chars as ^(Char)
-pub const ISIG = 0x00000080; // enable signals INTR, QUIT, [D]SUSP
-pub const ICANON = 0x00000100; // canonicalize input lines
-pub const ALTWERASE = 0x00000200; // use alternate WERASE algorithm
-pub const IEXTEN = 0x00000400; // enable DISCARD and LNEXT
-pub const EXTPROC = 0x00000800; // external processing
-pub const TOSTOP = 0x00400000; // stop background jobs from output
-pub const FLUSHO = 0x00800000; // output being flushed (state)
-pub const NOKERNINFO = 0x02000000; // no kernel output from VSTATUS
-pub const PENDIN = 0x20000000; // XXX retype pending input (state)
-pub const NOFLSH = 0x80000000; // don't flush after interrupt
-
-pub const TCSANOW = 0; // make change immediate
-pub const TCSADRAIN = 1; // drain output, then change
-pub const TCSAFLUSH = 2; // drain output, flush input
-pub const TCSASOFT = 0x10; // flag - don't alter h.w. state
-pub const TCSA = enum(c_uint) {
- NOW,
- DRAIN,
- FLUSH,
- _,
-};
-
-pub const B0 = 0;
-pub const B50 = 50;
-pub const B75 = 75;
-pub const B110 = 110;
-pub const B134 = 134;
-pub const B150 = 150;
-pub const B200 = 200;
-pub const B300 = 300;
-pub const B600 = 600;
-pub const B1200 = 1200;
-pub const B1800 = 1800;
-pub const B2400 = 2400;
-pub const B4800 = 4800;
-pub const B9600 = 9600;
-pub const B19200 = 19200;
-pub const B38400 = 38400;
-pub const B7200 = 7200;
-pub const B14400 = 14400;
-pub const B28800 = 28800;
-pub const B57600 = 57600;
-pub const B76800 = 76800;
-pub const B115200 = 115200;
-pub const B230400 = 230400;
-pub const EXTA = 19200;
-pub const EXTB = 38400;
-
-pub const TCIFLUSH = 1;
-pub const TCOFLUSH = 2;
-pub const TCIOFLUSH = 3;
-pub const TCOOFF = 1;
-pub const TCOON = 2;
-pub const TCIOFF = 3;
-pub const TCION = 4;
-
-pub const cc_t = u8;
-pub const speed_t = u64;
-pub const tcflag_t = u64;
-
-pub const termios = extern struct {
- iflag: tcflag_t, // input flags
- oflag: tcflag_t, // output flags
- cflag: tcflag_t, // control flags
- lflag: tcflag_t, // local flags
- cc: [NCCS]cc_t, // control chars
- ispeed: speed_t align(8), // input speed
- ospeed: speed_t, // output speed
-};
-
-pub const winsize = extern struct {
- ws_row: u16,
- ws_col: u16,
- ws_xpixel: u16,
- ws_ypixel: u16,
-};
-
-pub const TIOCGWINSZ = ior(0x40000000, 't', 104, @sizeOf(winsize));
-pub const IOCPARM_MASK = 0x1fff;
-
-fn ior(inout: u32, group: usize, num: usize, len: usize) usize {
- return (inout | ((len & IOCPARM_MASK) << 16) | ((group) << 8) | (num));
-}
-
-// CPU families mapping
-pub const CPUFAMILY = enum(u32) {
- UNKNOWN = 0,
- POWERPC_G3 = 0xcee41549,
- POWERPC_G4 = 0x77c184ae,
- POWERPC_G5 = 0xed76d8aa,
- INTEL_6_13 = 0xaa33392b,
- INTEL_PENRYN = 0x78ea4fbc,
- INTEL_NEHALEM = 0x6b5a4cd2,
- INTEL_WESTMERE = 0x573b5eec,
- INTEL_SANDYBRIDGE = 0x5490b78c,
- INTEL_IVYBRIDGE = 0x1f65e835,
- INTEL_HASWELL = 0x10b282dc,
- INTEL_BROADWELL = 0x582ed09c,
- INTEL_SKYLAKE = 0x37fc219f,
- INTEL_KABYLAKE = 0x0f817246,
- ARM_9 = 0xe73283ae,
- ARM_11 = 0x8ff620d8,
- ARM_XSCALE = 0x53b005f5,
- ARM_12 = 0xbd1b0ae9,
- ARM_13 = 0x0cc90e64,
- ARM_14 = 0x96077ef1,
- ARM_15 = 0xa8511bca,
- ARM_SWIFT = 0x1e2d6381,
- ARM_CYCLONE = 0x37a09642,
- ARM_TYPHOON = 0x2c91a47e,
- ARM_TWISTER = 0x92fb37c8,
- ARM_HURRICANE = 0x67ceee93,
- ARM_MONSOON_MISTRAL = 0xe81e7ef6,
- ARM_VORTEX_TEMPEST = 0x07d34b9f,
- ARM_LIGHTNING_THUNDER = 0x462504d2,
- ARM_FIRESTORM_ICESTORM = 0x1b588bb3,
- _,
-};
diff --git a/lib/std/os/bits/dragonfly.zig b/lib/std/os/bits/dragonfly.zig
deleted file mode 100644
index 4fe52a6f0acb..000000000000
--- a/lib/std/os/bits/dragonfly.zig
+++ /dev/null
@@ -1,1033 +0,0 @@
-const std = @import("../../std.zig");
-const maxInt = std.math.maxInt;
-
-pub usingnamespace @import("posix.zig");
-
-pub fn S_ISCHR(m: u32) bool {
- return m & S_IFMT == S_IFCHR;
-}
-
-// See:
-// - https://gitweb.dragonflybsd.org/dragonfly.git/blob/HEAD:/include/unistd.h
-// - https://gitweb.dragonflybsd.org/dragonfly.git/blob/HEAD:/sys/sys/types.h
-// TODO: mode_t should probably be changed to a u16, audit pid_t/off_t as well
-pub const fd_t = c_int;
-pub const pid_t = c_int;
-pub const off_t = c_long;
-pub const mode_t = c_uint;
-pub const uid_t = u32;
-pub const gid_t = u32;
-pub const time_t = isize;
-pub const suseconds_t = c_long;
-
-pub const E = enum(u16) {
- /// No error occurred.
- SUCCESS = 0,
-
- PERM = 1,
- NOENT = 2,
- SRCH = 3,
- INTR = 4,
- IO = 5,
- NXIO = 6,
- @"2BIG" = 7,
- NOEXEC = 8,
- BADF = 9,
- CHILD = 10,
- DEADLK = 11,
- NOMEM = 12,
- ACCES = 13,
- FAULT = 14,
- NOTBLK = 15,
- BUSY = 16,
- EXIST = 17,
- XDEV = 18,
- NODEV = 19,
- NOTDIR = 20,
- ISDIR = 21,
- INVAL = 22,
- NFILE = 23,
- MFILE = 24,
- NOTTY = 25,
- TXTBSY = 26,
- FBIG = 27,
- NOSPC = 28,
- SPIPE = 29,
- ROFS = 30,
- MLINK = 31,
- PIPE = 32,
- DOM = 33,
- RANGE = 34,
- /// This code is also used for `WOULDBLOCK`.
- AGAIN = 35,
- INPROGRESS = 36,
- ALREADY = 37,
- NOTSOCK = 38,
- DESTADDRREQ = 39,
- MSGSIZE = 40,
- PROTOTYPE = 41,
- NOPROTOOPT = 42,
- PROTONOSUPPORT = 43,
- SOCKTNOSUPPORT = 44,
- /// This code is also used for `NOTSUP`.
- OPNOTSUPP = 45,
- PFNOSUPPORT = 46,
- AFNOSUPPORT = 47,
- ADDRINUSE = 48,
- ADDRNOTAVAIL = 49,
- NETDOWN = 50,
- NETUNREACH = 51,
- NETRESET = 52,
- CONNABORTED = 53,
- CONNRESET = 54,
- NOBUFS = 55,
- ISCONN = 56,
- NOTCONN = 57,
- SHUTDOWN = 58,
- TOOMANYREFS = 59,
- TIMEDOUT = 60,
- CONNREFUSED = 61,
- LOOP = 62,
- NAMETOOLONG = 63,
- HOSTDOWN = 64,
- HOSTUNREACH = 65,
- NOTEMPTY = 66,
- PROCLIM = 67,
- USERS = 68,
- DQUOT = 69,
- STALE = 70,
- REMOTE = 71,
- BADRPC = 72,
- RPCMISMATCH = 73,
- PROGUNAVAIL = 74,
- PROGMISMATCH = 75,
- PROCUNAVAIL = 76,
- NOLCK = 77,
- NOSYS = 78,
- FTYPE = 79,
- AUTH = 80,
- NEEDAUTH = 81,
- IDRM = 82,
- NOMSG = 83,
- OVERFLOW = 84,
- CANCELED = 85,
- ILSEQ = 86,
- NOATTR = 87,
- DOOFUS = 88,
- BADMSG = 89,
- MULTIHOP = 90,
- NOLINK = 91,
- PROTO = 92,
- NOMEDIUM = 93,
- ASYNC = 99,
- _,
-};
-
-pub const STDIN_FILENO = 0;
-pub const STDOUT_FILENO = 1;
-pub const STDERR_FILENO = 2;
-
-pub const PROT_NONE = 0;
-pub const PROT_READ = 1;
-pub const PROT_WRITE = 2;
-pub const PROT_EXEC = 4;
-
-pub const MAP_FILE = 0;
-pub const MAP_FAILED = @intToPtr(*c_void, maxInt(usize));
-pub const MAP_ANONYMOUS = MAP_ANON;
-pub const MAP_COPY = MAP_PRIVATE;
-pub const MAP_SHARED = 1;
-pub const MAP_PRIVATE = 2;
-pub const MAP_FIXED = 16;
-pub const MAP_RENAME = 32;
-pub const MAP_NORESERVE = 64;
-pub const MAP_INHERIT = 128;
-pub const MAP_NOEXTEND = 256;
-pub const MAP_HASSEMAPHORE = 512;
-pub const MAP_STACK = 1024;
-pub const MAP_NOSYNC = 2048;
-pub const MAP_ANON = 4096;
-pub const MAP_VPAGETABLE = 8192;
-pub const MAP_TRYFIXED = 65536;
-pub const MAP_NOCORE = 131072;
-pub const MAP_SIZEALIGN = 262144;
-
-pub const WNOHANG = 0x0001;
-pub const WUNTRACED = 0x0002;
-pub const WCONTINUED = 0x0004;
-pub const WSTOPPED = WUNTRACED;
-pub const WNOWAIT = 0x0008;
-pub const WEXITED = 0x0010;
-pub const WTRAPPED = 0x0020;
-
-pub const SA_ONSTACK = 0x0001;
-pub const SA_RESTART = 0x0002;
-pub const SA_RESETHAND = 0x0004;
-pub const SA_NODEFER = 0x0010;
-pub const SA_NOCLDWAIT = 0x0020;
-pub const SA_SIGINFO = 0x0040;
-
-pub const PATH_MAX = 1024;
-pub const IOV_MAX = KERN_IOV_MAX;
-
-pub const ino_t = c_ulong;
-
-pub const libc_stat = extern struct {
- ino: ino_t,
- nlink: c_uint,
- dev: c_uint,
- mode: c_ushort,
- padding1: u16,
- uid: uid_t,
- gid: gid_t,
- rdev: c_uint,
- atim: timespec,
- mtim: timespec,
- ctim: timespec,
- size: c_ulong,
- blocks: i64,
- blksize: u32,
- flags: u32,
- gen: u32,
- lspare: i32,
- qspare1: i64,
- qspare2: i64,
- pub fn atime(self: @This()) timespec {
- return self.atim;
- }
-
- pub fn mtime(self: @This()) timespec {
- return self.mtim;
- }
-
- pub fn ctime(self: @This()) timespec {
- return self.ctim;
- }
-};
-
-pub const timespec = extern struct {
- tv_sec: c_long,
- tv_nsec: c_long,
-};
-
-pub const timeval = extern struct {
- /// seconds
- tv_sec: time_t,
- /// microseconds
- tv_usec: suseconds_t,
-};
-
-pub const CTL_UNSPEC = 0;
-pub const CTL_KERN = 1;
-pub const CTL_VM = 2;
-pub const CTL_VFS = 3;
-pub const CTL_NET = 4;
-pub const CTL_DEBUG = 5;
-pub const CTL_HW = 6;
-pub const CTL_MACHDEP = 7;
-pub const CTL_USER = 8;
-pub const CTL_LWKT = 10;
-pub const CTL_MAXID = 11;
-pub const CTL_MAXNAME = 12;
-
-pub const KERN_PROC_ALL = 0;
-pub const KERN_OSTYPE = 1;
-pub const KERN_PROC_PID = 1;
-pub const KERN_OSRELEASE = 2;
-pub const KERN_PROC_PGRP = 2;
-pub const KERN_OSREV = 3;
-pub const KERN_PROC_SESSION = 3;
-pub const KERN_VERSION = 4;
-pub const KERN_PROC_TTY = 4;
-pub const KERN_MAXVNODES = 5;
-pub const KERN_PROC_UID = 5;
-pub const KERN_MAXPROC = 6;
-pub const KERN_PROC_RUID = 6;
-pub const KERN_MAXFILES = 7;
-pub const KERN_PROC_ARGS = 7;
-pub const KERN_ARGMAX = 8;
-pub const KERN_PROC_CWD = 8;
-pub const KERN_PROC_PATHNAME = 9;
-pub const KERN_SECURELVL = 9;
-pub const KERN_PROC_SIGTRAMP = 10;
-pub const KERN_HOSTNAME = 10;
-pub const KERN_HOSTID = 11;
-pub const KERN_CLOCKRATE = 12;
-pub const KERN_VNODE = 13;
-pub const KERN_PROC = 14;
-pub const KERN_FILE = 15;
-pub const KERN_PROC_FLAGMASK = 16;
-pub const KERN_PROF = 16;
-pub const KERN_PROC_FLAG_LWP = 16;
-pub const KERN_POSIX1 = 17;
-pub const KERN_NGROUPS = 18;
-pub const KERN_JOB_CONTROL = 19;
-pub const KERN_SAVED_IDS = 20;
-pub const KERN_BOOTTIME = 21;
-pub const KERN_NISDOMAINNAME = 22;
-pub const KERN_UPDATEINTERVAL = 23;
-pub const KERN_OSRELDATE = 24;
-pub const KERN_NTP_PLL = 25;
-pub const KERN_BOOTFILE = 26;
-pub const KERN_MAXFILESPERPROC = 27;
-pub const KERN_MAXPROCPERUID = 28;
-pub const KERN_DUMPDEV = 29;
-pub const KERN_IPC = 30;
-pub const KERN_DUMMY = 31;
-pub const KERN_PS_STRINGS = 32;
-pub const KERN_USRSTACK = 33;
-pub const KERN_LOGSIGEXIT = 34;
-pub const KERN_IOV_MAX = 35;
-pub const KERN_MAXPOSIXLOCKSPERUID = 36;
-pub const KERN_MAXID = 37;
-
-pub const HOST_NAME_MAX = 255;
-
-// access function
-pub const F_OK = 0; // test for existence of file
-pub const X_OK = 1; // test for execute or search permission
-pub const W_OK = 2; // test for write permission
-pub const R_OK = 4; // test for read permission
-
-pub const O_RDONLY = 0;
-pub const O_NDELAY = O_NONBLOCK;
-pub const O_WRONLY = 1;
-pub const O_RDWR = 2;
-pub const O_ACCMODE = 3;
-pub const O_NONBLOCK = 4;
-pub const O_APPEND = 8;
-pub const O_SHLOCK = 16;
-pub const O_EXLOCK = 32;
-pub const O_ASYNC = 64;
-pub const O_FSYNC = 128;
-pub const O_SYNC = 128;
-pub const O_NOFOLLOW = 256;
-pub const O_CREAT = 512;
-pub const O_TRUNC = 1024;
-pub const O_EXCL = 2048;
-pub const O_NOCTTY = 32768;
-pub const O_DIRECT = 65536;
-pub const O_CLOEXEC = 131072;
-pub const O_FBLOCKING = 262144;
-pub const O_FNONBLOCKING = 524288;
-pub const O_FAPPEND = 1048576;
-pub const O_FOFFSET = 2097152;
-pub const O_FSYNCWRITE = 4194304;
-pub const O_FASYNCWRITE = 8388608;
-pub const O_DIRECTORY = 134217728;
-
-pub const SEEK_SET = 0;
-pub const SEEK_CUR = 1;
-pub const SEEK_END = 2;
-pub const SEEK_DATA = 3;
-pub const SEEK_HOLE = 4;
-
-pub const F_ULOCK = 0;
-pub const F_LOCK = 1;
-pub const F_TLOCK = 2;
-pub const F_TEST = 3;
-
-pub const FD_CLOEXEC = 1;
-
-pub const AT_FDCWD = -328243;
-pub const AT_SYMLINK_NOFOLLOW = 1;
-pub const AT_REMOVEDIR = 2;
-pub const AT_EACCESS = 4;
-pub const AT_SYMLINK_FOLLOW = 8;
-
-pub fn WEXITSTATUS(s: u32) u8 {
- return @intCast(u8, (s & 0xff00) >> 8);
-}
-pub fn WTERMSIG(s: u32) u32 {
- return s & 0x7f;
-}
-pub fn WSTOPSIG(s: u32) u32 {
- return WEXITSTATUS(s);
-}
-pub fn WIFEXITED(s: u32) bool {
- return WTERMSIG(s) == 0;
-}
-pub fn WIFSTOPPED(s: u32) bool {
- return @truncate(u16, (((s & 0xffff) *% 0x10001) >> 8)) > 0x7f00;
-}
-pub fn WIFSIGNALED(s: u32) bool {
- return (s & 0xffff) -% 1 < 0xff;
-}
-
-pub const dirent = extern struct {
- d_fileno: c_ulong,
- d_namlen: u16,
- d_type: u8,
- d_unused1: u8,
- d_unused2: u32,
- d_name: [256]u8,
-
- pub fn reclen(self: dirent) u16 {
- return (@offsetOf(dirent, "d_name") + self.d_namlen + 1 + 7) & ~@as(u16, 7);
- }
-};
-
-pub const DT_UNKNOWN = 0;
-pub const DT_FIFO = 1;
-pub const DT_CHR = 2;
-pub const DT_DIR = 4;
-pub const DT_BLK = 6;
-pub const DT_REG = 8;
-pub const DT_LNK = 10;
-pub const DT_SOCK = 12;
-pub const DT_WHT = 14;
-pub const DT_DBF = 15;
-
-pub const CLOCK_REALTIME = 0;
-pub const CLOCK_VIRTUAL = 1;
-pub const CLOCK_PROF = 2;
-pub const CLOCK_MONOTONIC = 4;
-pub const CLOCK_UPTIME = 5;
-pub const CLOCK_UPTIME_PRECISE = 7;
-pub const CLOCK_UPTIME_FAST = 8;
-pub const CLOCK_REALTIME_PRECISE = 9;
-pub const CLOCK_REALTIME_FAST = 10;
-pub const CLOCK_MONOTONIC_PRECISE = 11;
-pub const CLOCK_MONOTONIC_FAST = 12;
-pub const CLOCK_SECOND = 13;
-pub const CLOCK_THREAD_CPUTIME_ID = 14;
-pub const CLOCK_PROCESS_CPUTIME_ID = 15;
-
-pub const sockaddr = extern struct {
- len: u8,
- family: u8,
- data: [14]u8,
-};
-
-pub const sockaddr_storage = std.x.os.Socket.Address.Native.Storage;
-
-pub const Kevent = extern struct {
- ident: usize,
- filter: c_short,
- flags: c_ushort,
- fflags: c_uint,
- data: isize,
- udata: usize,
-};
-
-pub const EVFILT_FS = -10;
-pub const EVFILT_USER = -9;
-pub const EVFILT_EXCEPT = -8;
-pub const EVFILT_TIMER = -7;
-pub const EVFILT_SIGNAL = -6;
-pub const EVFILT_PROC = -5;
-pub const EVFILT_VNODE = -4;
-pub const EVFILT_AIO = -3;
-pub const EVFILT_WRITE = -2;
-pub const EVFILT_READ = -1;
-pub const EVFILT_SYSCOUNT = 10;
-pub const EVFILT_MARKER = 15;
-
-pub const EV_ADD = 1;
-pub const EV_DELETE = 2;
-pub const EV_ENABLE = 4;
-pub const EV_DISABLE = 8;
-pub const EV_ONESHOT = 16;
-pub const EV_CLEAR = 32;
-pub const EV_RECEIPT = 64;
-pub const EV_DISPATCH = 128;
-pub const EV_NODATA = 4096;
-pub const EV_FLAG1 = 8192;
-pub const EV_ERROR = 16384;
-pub const EV_EOF = 32768;
-pub const EV_SYSFLAGS = 61440;
-
-pub const NOTE_FFNOP = 0;
-pub const NOTE_TRACK = 1;
-pub const NOTE_DELETE = 1;
-pub const NOTE_LOWAT = 1;
-pub const NOTE_TRACKERR = 2;
-pub const NOTE_OOB = 2;
-pub const NOTE_WRITE = 2;
-pub const NOTE_EXTEND = 4;
-pub const NOTE_CHILD = 4;
-pub const NOTE_ATTRIB = 8;
-pub const NOTE_LINK = 16;
-pub const NOTE_RENAME = 32;
-pub const NOTE_REVOKE = 64;
-pub const NOTE_PDATAMASK = 1048575;
-pub const NOTE_FFLAGSMASK = 16777215;
-pub const NOTE_TRIGGER = 16777216;
-pub const NOTE_EXEC = 536870912;
-pub const NOTE_FFAND = 1073741824;
-pub const NOTE_FORK = 1073741824;
-pub const NOTE_EXIT = 2147483648;
-pub const NOTE_FFOR = 2147483648;
-pub const NOTE_FFCTRLMASK = 3221225472;
-pub const NOTE_FFCOPY = 3221225472;
-pub const NOTE_PCTRLMASK = 4026531840;
-
-pub const stack_t = extern struct {
- ss_sp: [*]u8,
- ss_size: isize,
- ss_flags: i32,
-};
-
-pub const S_IREAD = S_IRUSR;
-pub const S_IEXEC = S_IXUSR;
-pub const S_IWRITE = S_IWUSR;
-pub const S_IXOTH = 1;
-pub const S_IWOTH = 2;
-pub const S_IROTH = 4;
-pub const S_IRWXO = 7;
-pub const S_IXGRP = 8;
-pub const S_IWGRP = 16;
-pub const S_IRGRP = 32;
-pub const S_IRWXG = 56;
-pub const S_IXUSR = 64;
-pub const S_IWUSR = 128;
-pub const S_IRUSR = 256;
-pub const S_IRWXU = 448;
-pub const S_ISTXT = 512;
-pub const S_BLKSIZE = 512;
-pub const S_ISVTX = 512;
-pub const S_ISGID = 1024;
-pub const S_ISUID = 2048;
-pub const S_IFIFO = 4096;
-pub const S_IFCHR = 8192;
-pub const S_IFDIR = 16384;
-pub const S_IFBLK = 24576;
-pub const S_IFREG = 32768;
-pub const S_IFDB = 36864;
-pub const S_IFLNK = 40960;
-pub const S_IFSOCK = 49152;
-pub const S_IFWHT = 57344;
-pub const S_IFMT = 61440;
-
-pub const SIG_DFL = @intToPtr(?Sigaction.sigaction_fn, 0);
-pub const SIG_IGN = @intToPtr(?Sigaction.sigaction_fn, 1);
-pub const SIG_ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize));
-pub const BADSIG = SIG_ERR;
-
-pub const SIG_BLOCK = 1;
-pub const SIG_UNBLOCK = 2;
-pub const SIG_SETMASK = 3;
-
-pub const SIGIOT = SIGABRT;
-pub const SIGHUP = 1;
-pub const SIGINT = 2;
-pub const SIGQUIT = 3;
-pub const SIGILL = 4;
-pub const SIGTRAP = 5;
-pub const SIGABRT = 6;
-pub const SIGEMT = 7;
-pub const SIGFPE = 8;
-pub const SIGKILL = 9;
-pub const SIGBUS = 10;
-pub const SIGSEGV = 11;
-pub const SIGSYS = 12;
-pub const SIGPIPE = 13;
-pub const SIGALRM = 14;
-pub const SIGTERM = 15;
-pub const SIGURG = 16;
-pub const SIGSTOP = 17;
-pub const SIGTSTP = 18;
-pub const SIGCONT = 19;
-pub const SIGCHLD = 20;
-pub const SIGTTIN = 21;
-pub const SIGTTOU = 22;
-pub const SIGIO = 23;
-pub const SIGXCPU = 24;
-pub const SIGXFSZ = 25;
-pub const SIGVTALRM = 26;
-pub const SIGPROF = 27;
-pub const SIGWINCH = 28;
-pub const SIGINFO = 29;
-pub const SIGUSR1 = 30;
-pub const SIGUSR2 = 31;
-pub const SIGTHR = 32;
-pub const SIGCKPT = 33;
-pub const SIGCKPTEXIT = 34;
-
-pub const siginfo_t = extern struct {
- signo: c_int,
- errno: c_int,
- code: c_int,
- pid: c_int,
- uid: uid_t,
- status: c_int,
- addr: ?*c_void,
- value: sigval,
- band: c_long,
- __spare__: [7]c_int,
-};
-
-pub const sigval = extern union {
- sival_int: c_int,
- sival_ptr: ?*c_void,
-};
-
-pub const _SIG_WORDS = 4;
-
-pub const sigset_t = extern struct {
- __bits: [_SIG_WORDS]c_uint,
-};
-
-pub const empty_sigset = sigset_t{ .__bits = [_]c_uint{0} ** _SIG_WORDS };
-
-pub const sig_atomic_t = c_int;
-
-pub const Sigaction = extern struct {
- pub const handler_fn = fn (c_int) callconv(.C) void;
- pub const sigaction_fn = fn (c_int, *const siginfo_t, ?*const c_void) callconv(.C) void;
-
- /// signal handler
- handler: extern union {
- handler: ?handler_fn,
- sigaction: ?sigaction_fn,
- },
- flags: c_uint,
- mask: sigset_t,
-};
-
-pub const sig_t = [*c]fn (c_int) callconv(.C) void;
-
-pub const SOCK_STREAM = 1;
-pub const SOCK_DGRAM = 2;
-pub const SOCK_RAW = 3;
-pub const SOCK_RDM = 4;
-pub const SOCK_SEQPACKET = 5;
-pub const SOCK_MAXADDRLEN = 255;
-pub const SOCK_CLOEXEC = 0x10000000;
-pub const SOCK_NONBLOCK = 0x20000000;
-
-pub const SO_DEBUG = 0x0001;
-pub const SO_ACCEPTCONN = 0x0002;
-pub const SO_REUSEADDR = 0x0004;
-pub const SO_KEEPALIVE = 0x0008;
-pub const SO_DONTROUTE = 0x0010;
-pub const SO_BROADCAST = 0x0020;
-pub const SO_USELOOPBACK = 0x0040;
-pub const SO_LINGER = 0x0080;
-pub const SO_OOBINLINE = 0x0100;
-pub const SO_REUSEPORT = 0x0200;
-pub const SO_TIMESTAMP = 0x0400;
-pub const SO_NOSIGPIPE = 0x0800;
-pub const SO_ACCEPTFILTER = 0x1000;
-pub const SO_RERROR = 0x2000;
-pub const SO_PASSCRED = 0x4000;
-
-pub const SO_SNDBUF = 0x1001;
-pub const SO_RCVBUF = 0x1002;
-pub const SO_SNDLOWAT = 0x1003;
-pub const SO_RCVLOWAT = 0x1004;
-pub const SO_SNDTIMEO = 0x1005;
-pub const SO_RCVTIMEO = 0x1006;
-pub const SO_ERROR = 0x1007;
-pub const SO_TYPE = 0x1008;
-pub const SO_SNDSPACE = 0x100a;
-pub const SO_CPUHINT = 0x1030;
-
-pub const SOL_SOCKET = 0xffff;
-
-pub const PF_INET6 = AF_INET6;
-pub const PF_IMPLINK = AF_IMPLINK;
-pub const PF_ROUTE = AF_ROUTE;
-pub const PF_ISO = AF_ISO;
-pub const PF_PIP = pseudo_AF_PIP;
-pub const PF_CHAOS = AF_CHAOS;
-pub const PF_DATAKIT = AF_DATAKIT;
-pub const PF_INET = AF_INET;
-pub const PF_APPLETALK = AF_APPLETALK;
-pub const PF_SIP = AF_SIP;
-pub const PF_OSI = AF_ISO;
-pub const PF_CNT = AF_CNT;
-pub const PF_LINK = AF_LINK;
-pub const PF_HYLINK = AF_HYLINK;
-pub const PF_MAX = AF_MAX;
-pub const PF_KEY = pseudo_AF_KEY;
-pub const PF_PUP = AF_PUP;
-pub const PF_COIP = AF_COIP;
-pub const PF_SNA = AF_SNA;
-pub const PF_LOCAL = AF_LOCAL;
-pub const PF_NETBIOS = AF_NETBIOS;
-pub const PF_NATM = AF_NATM;
-pub const PF_BLUETOOTH = AF_BLUETOOTH;
-pub const PF_UNSPEC = AF_UNSPEC;
-pub const PF_NETGRAPH = AF_NETGRAPH;
-pub const PF_ECMA = AF_ECMA;
-pub const PF_IPX = AF_IPX;
-pub const PF_DLI = AF_DLI;
-pub const PF_ATM = AF_ATM;
-pub const PF_CCITT = AF_CCITT;
-pub const PF_ISDN = AF_ISDN;
-pub const PF_RTIP = pseudo_AF_RTIP;
-pub const PF_LAT = AF_LAT;
-pub const PF_UNIX = PF_LOCAL;
-pub const PF_XTP = pseudo_AF_XTP;
-pub const PF_DECnet = AF_DECnet;
-
-pub const AF_UNSPEC = 0;
-pub const AF_OSI = AF_ISO;
-pub const AF_UNIX = AF_LOCAL;
-pub const AF_LOCAL = 1;
-pub const AF_INET = 2;
-pub const AF_IMPLINK = 3;
-pub const AF_PUP = 4;
-pub const AF_CHAOS = 5;
-pub const AF_NETBIOS = 6;
-pub const AF_ISO = 7;
-pub const AF_ECMA = 8;
-pub const AF_DATAKIT = 9;
-pub const AF_CCITT = 10;
-pub const AF_SNA = 11;
-pub const AF_DLI = 13;
-pub const AF_LAT = 14;
-pub const AF_HYLINK = 15;
-pub const AF_APPLETALK = 16;
-pub const AF_ROUTE = 17;
-pub const AF_LINK = 18;
-pub const AF_COIP = 20;
-pub const AF_CNT = 21;
-pub const AF_IPX = 23;
-pub const AF_SIP = 24;
-pub const AF_ISDN = 26;
-pub const AF_INET6 = 28;
-pub const AF_NATM = 29;
-pub const AF_ATM = 30;
-pub const AF_NETGRAPH = 32;
-pub const AF_BLUETOOTH = 33;
-pub const AF_MPLS = 34;
-pub const AF_MAX = 36;
-
-pub const in_port_t = u16;
-pub const sa_family_t = u8;
-pub const socklen_t = u32;
-
-pub const sockaddr_in = extern struct {
- len: u8 = @sizeOf(sockaddr_in),
- family: sa_family_t = AF_INET,
- port: in_port_t,
- addr: u32,
- zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },
-};
-
-pub const sockaddr_in6 = extern struct {
- len: u8 = @sizeOf(sockaddr_in6),
- family: sa_family_t = AF_INET6,
- port: in_port_t,
- flowinfo: u32,
- addr: [16]u8,
- scope_id: u32,
-};
-
-pub const EAI = enum(c_int) {
- ADDRFAMILY = 1,
- AGAIN = 2,
- BADFLAGS = 3,
- FAIL = 4,
- FAMILY = 5,
- MEMORY = 6,
- NODATA = 7,
- NONAME = 8,
- SERVICE = 9,
- SOCKTYPE = 10,
- SYSTEM = 11,
- BADHINTS = 12,
- PROTOCOL = 13,
- OVERFLOW = 14,
- _,
-};
-
-pub const AI_PASSIVE = 0x00000001;
-pub const AI_CANONNAME = 0x00000002;
-pub const AI_NUMERICHOST = 0x00000004;
-pub const AI_NUMERICSERV = 0x00000008;
-pub const AI_MASK = AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST | AI_NUMERICSERV | AI_ADDRCONFIG;
-pub const AI_ALL = 0x00000100;
-pub const AI_V4MAPPED_CFG = 0x00000200;
-pub const AI_ADDRCONFIG = 0x00000400;
-pub const AI_V4MAPPED = 0x00000800;
-pub const AI_DEFAULT = AI_V4MAPPED_CFG | AI_ADDRCONFIG;
-
-pub const RTLD_LAZY = 1;
-pub const RTLD_NOW = 2;
-pub const RTLD_MODEMASK = 0x3;
-pub const RTLD_GLOBAL = 0x100;
-pub const RTLD_LOCAL = 0;
-pub const RTLD_TRACE = 0x200;
-pub const RTLD_NODELETE = 0x01000;
-pub const RTLD_NOLOAD = 0x02000;
-
-pub const RTLD_NEXT = @intToPtr(*c_void, @bitCast(usize, @as(isize, -1)));
-pub const RTLD_DEFAULT = @intToPtr(*c_void, @bitCast(usize, @as(isize, -2)));
-pub const RTLD_SELF = @intToPtr(*c_void, @bitCast(usize, @as(isize, -3)));
-pub const RTLD_ALL = @intToPtr(*c_void, @bitCast(usize, @as(isize, -4)));
-
-pub const dl_phdr_info = extern struct {
- dlpi_addr: usize,
- dlpi_name: ?[*:0]const u8,
- dlpi_phdr: [*]std.elf.Phdr,
- dlpi_phnum: u16,
-};
-pub const cmsghdr = extern struct {
- cmsg_len: socklen_t,
- cmsg_level: c_int,
- cmsg_type: c_int,
-};
-pub const msghdr = extern struct {
- msg_name: ?*c_void,
- msg_namelen: socklen_t,
- msg_iov: [*c]iovec,
- msg_iovlen: c_int,
- msg_control: ?*c_void,
- msg_controllen: socklen_t,
- msg_flags: c_int,
-};
-pub const cmsgcred = extern struct {
- cmcred_pid: pid_t,
- cmcred_uid: uid_t,
- cmcred_euid: uid_t,
- cmcred_gid: gid_t,
- cmcred_ngroups: c_short,
- cmcred_groups: [16]gid_t,
-};
-pub const sf_hdtr = extern struct {
- headers: [*c]iovec,
- hdr_cnt: c_int,
- trailers: [*c]iovec,
- trl_cnt: c_int,
-};
-
-pub const MS_SYNC = 0;
-pub const MS_ASYNC = 1;
-pub const MS_INVALIDATE = 2;
-
-pub const POSIX_MADV_SEQUENTIAL = 2;
-pub const POSIX_MADV_RANDOM = 1;
-pub const POSIX_MADV_DONTNEED = 4;
-pub const POSIX_MADV_NORMAL = 0;
-pub const POSIX_MADV_WILLNEED = 3;
-
-pub const MADV_SEQUENTIAL = 2;
-pub const MADV_CONTROL_END = MADV_SETMAP;
-pub const MADV_DONTNEED = 4;
-pub const MADV_RANDOM = 1;
-pub const MADV_WILLNEED = 3;
-pub const MADV_NORMAL = 0;
-pub const MADV_CONTROL_START = MADV_INVAL;
-pub const MADV_FREE = 5;
-pub const MADV_NOSYNC = 6;
-pub const MADV_AUTOSYNC = 7;
-pub const MADV_NOCORE = 8;
-pub const MADV_CORE = 9;
-pub const MADV_INVAL = 10;
-pub const MADV_SETMAP = 11;
-
-pub const F_DUPFD = 0;
-pub const F_GETFD = 1;
-pub const F_RDLCK = 1;
-pub const F_SETFD = 2;
-pub const F_UNLCK = 2;
-pub const F_WRLCK = 3;
-pub const F_GETFL = 3;
-pub const F_SETFL = 4;
-pub const F_GETOWN = 5;
-pub const F_SETOWN = 6;
-pub const F_GETLK = 7;
-pub const F_SETLK = 8;
-pub const F_SETLKW = 9;
-pub const F_DUP2FD = 10;
-pub const F_DUPFD_CLOEXEC = 17;
-pub const F_DUP2FD_CLOEXEC = 18;
-
-pub const LOCK_SH = 1;
-pub const LOCK_EX = 2;
-pub const LOCK_UN = 8;
-pub const LOCK_NB = 4;
-
-pub const Flock = extern struct {
- l_start: off_t,
- l_len: off_t,
- l_pid: pid_t,
- l_type: c_short,
- l_whence: c_short,
-};
-
-pub const addrinfo = extern struct {
- flags: i32,
- family: i32,
- socktype: i32,
- protocol: i32,
- addrlen: socklen_t,
- canonname: ?[*:0]u8,
- addr: ?*sockaddr,
- next: ?*addrinfo,
-};
-
-pub const IPPROTO_IP = 0;
-pub const IPPROTO_ICMP = 1;
-pub const IPPROTO_TCP = 6;
-pub const IPPROTO_UDP = 17;
-pub const IPPROTO_IPV6 = 41;
-pub const IPPROTO_RAW = 255;
-pub const IPPROTO_HOPOPTS = 0;
-pub const IPPROTO_IGMP = 2;
-pub const IPPROTO_GGP = 3;
-pub const IPPROTO_IPV4 = 4;
-pub const IPPROTO_IPIP = IPPROTO_IPV4;
-pub const IPPROTO_ST = 7;
-pub const IPPROTO_EGP = 8;
-pub const IPPROTO_PIGP = 9;
-pub const IPPROTO_RCCMON = 10;
-pub const IPPROTO_NVPII = 11;
-pub const IPPROTO_PUP = 12;
-pub const IPPROTO_ARGUS = 13;
-pub const IPPROTO_EMCON = 14;
-pub const IPPROTO_XNET = 15;
-pub const IPPROTO_CHAOS = 16;
-pub const IPPROTO_MUX = 18;
-pub const IPPROTO_MEAS = 19;
-pub const IPPROTO_HMP = 20;
-pub const IPPROTO_PRM = 21;
-pub const IPPROTO_IDP = 22;
-pub const IPPROTO_TRUNK1 = 23;
-pub const IPPROTO_TRUNK2 = 24;
-pub const IPPROTO_LEAF1 = 25;
-pub const IPPROTO_LEAF2 = 26;
-pub const IPPROTO_RDP = 27;
-pub const IPPROTO_IRTP = 28;
-pub const IPPROTO_TP = 29;
-pub const IPPROTO_BLT = 30;
-pub const IPPROTO_NSP = 31;
-pub const IPPROTO_INP = 32;
-pub const IPPROTO_SEP = 33;
-pub const IPPROTO_3PC = 34;
-pub const IPPROTO_IDPR = 35;
-pub const IPPROTO_XTP = 36;
-pub const IPPROTO_DDP = 37;
-pub const IPPROTO_CMTP = 38;
-pub const IPPROTO_TPXX = 39;
-pub const IPPROTO_IL = 40;
-pub const IPPROTO_SDRP = 42;
-pub const IPPROTO_ROUTING = 43;
-pub const IPPROTO_FRAGMENT = 44;
-pub const IPPROTO_IDRP = 45;
-pub const IPPROTO_RSVP = 46;
-pub const IPPROTO_GRE = 47;
-pub const IPPROTO_MHRP = 48;
-pub const IPPROTO_BHA = 49;
-pub const IPPROTO_ESP = 50;
-pub const IPPROTO_AH = 51;
-pub const IPPROTO_INLSP = 52;
-pub const IPPROTO_SWIPE = 53;
-pub const IPPROTO_NHRP = 54;
-pub const IPPROTO_MOBILE = 55;
-pub const IPPROTO_TLSP = 56;
-pub const IPPROTO_SKIP = 57;
-pub const IPPROTO_ICMPV6 = 58;
-pub const IPPROTO_NONE = 59;
-pub const IPPROTO_DSTOPTS = 60;
-pub const IPPROTO_AHIP = 61;
-pub const IPPROTO_CFTP = 62;
-pub const IPPROTO_HELLO = 63;
-pub const IPPROTO_SATEXPAK = 64;
-pub const IPPROTO_KRYPTOLAN = 65;
-pub const IPPROTO_RVD = 66;
-pub const IPPROTO_IPPC = 67;
-pub const IPPROTO_ADFS = 68;
-pub const IPPROTO_SATMON = 69;
-pub const IPPROTO_VISA = 70;
-pub const IPPROTO_IPCV = 71;
-pub const IPPROTO_CPNX = 72;
-pub const IPPROTO_CPHB = 73;
-pub const IPPROTO_WSN = 74;
-pub const IPPROTO_PVP = 75;
-pub const IPPROTO_BRSATMON = 76;
-pub const IPPROTO_ND = 77;
-pub const IPPROTO_WBMON = 78;
-pub const IPPROTO_WBEXPAK = 79;
-pub const IPPROTO_EON = 80;
-pub const IPPROTO_VMTP = 81;
-pub const IPPROTO_SVMTP = 82;
-pub const IPPROTO_VINES = 83;
-pub const IPPROTO_TTP = 84;
-pub const IPPROTO_IGP = 85;
-pub const IPPROTO_DGP = 86;
-pub const IPPROTO_TCF = 87;
-pub const IPPROTO_IGRP = 88;
-pub const IPPROTO_OSPFIGP = 89;
-pub const IPPROTO_SRPC = 90;
-pub const IPPROTO_LARP = 91;
-pub const IPPROTO_MTP = 92;
-pub const IPPROTO_AX25 = 93;
-pub const IPPROTO_IPEIP = 94;
-pub const IPPROTO_MICP = 95;
-pub const IPPROTO_SCCSP = 96;
-pub const IPPROTO_ETHERIP = 97;
-pub const IPPROTO_ENCAP = 98;
-pub const IPPROTO_APES = 99;
-pub const IPPROTO_GMTP = 100;
-pub const IPPROTO_IPCOMP = 108;
-pub const IPPROTO_PIM = 103;
-pub const IPPROTO_CARP = 112;
-pub const IPPROTO_PGM = 113;
-pub const IPPROTO_PFSYNC = 240;
-pub const IPPROTO_DIVERT = 254;
-pub const IPPROTO_MAX = 256;
-pub const IPPROTO_DONE = 257;
-pub const IPPROTO_UNKNOWN = 258;
-
-pub const rlimit_resource = enum(c_int) {
- CPU = 0,
- FSIZE = 1,
- DATA = 2,
- STACK = 3,
- CORE = 4,
- RSS = 5,
- MEMLOCK = 6,
- NPROC = 7,
- NOFILE = 8,
- SBSIZE = 9,
- VMEM = 10,
- POSIXLOCKS = 11,
- _,
-
- pub const AS: rlimit_resource = .VMEM;
-};
-
-pub const rlim_t = i64;
-
-/// No limit
-pub const RLIM_INFINITY: rlim_t = (1 << 63) - 1;
-
-pub const RLIM_SAVED_MAX = RLIM_INFINITY;
-pub const RLIM_SAVED_CUR = RLIM_INFINITY;
-
-pub const rlimit = extern struct {
- /// Soft limit
- cur: rlim_t,
- /// Hard limit
- max: rlim_t,
-};
-
-pub const SHUT_RD = 0;
-pub const SHUT_WR = 1;
-pub const SHUT_RDWR = 2;
-
-pub const nfds_t = u32;
-
-pub const pollfd = extern struct {
- fd: fd_t,
- events: i16,
- revents: i16,
-};
-
-/// Requestable events.
-pub const POLLIN = 0x0001;
-pub const POLLPRI = 0x0002;
-pub const POLLOUT = 0x0004;
-pub const POLLRDNORM = 0x0040;
-pub const POLLWRNORM = POLLOUT;
-pub const POLLRDBAND = 0x0080;
-pub const POLLWRBAND = 0x0100;
-
-/// These events are set if they occur regardless of whether they were requested.
-pub const POLLERR = 0x0008;
-pub const POLLHUP = 0x0010;
-pub const POLLNVAL = 0x0020;
diff --git a/lib/std/os/bits/freebsd.zig b/lib/std/os/bits/freebsd.zig
deleted file mode 100644
index b4ff21fbf04b..000000000000
--- a/lib/std/os/bits/freebsd.zig
+++ /dev/null
@@ -1,1542 +0,0 @@
-const std = @import("../../std.zig");
-const builtin = @import("builtin");
-const maxInt = std.math.maxInt;
-
-pub usingnamespace @import("posix.zig");
-
-pub const blksize_t = i32;
-pub const blkcnt_t = i64;
-pub const clockid_t = i32;
-pub const fsblkcnt_t = u64;
-pub const fsfilcnt_t = u64;
-pub const nlink_t = u64;
-pub const fd_t = i32;
-pub const pid_t = i32;
-pub const uid_t = u32;
-pub const gid_t = u32;
-pub const mode_t = u16;
-pub const off_t = i64;
-pub const ino_t = u64;
-pub const dev_t = u64;
-pub const time_t = i64;
-// The signedness is not constant across different architectures.
-pub const clock_t = isize;
-
-pub const socklen_t = u32;
-pub const suseconds_t = c_long;
-
-/// Renamed from `kevent` to `Kevent` to avoid conflict with function name.
-pub const Kevent = extern struct {
- ident: usize,
- filter: i16,
- flags: u16,
- fflags: u32,
- data: i64,
- udata: usize,
- // TODO ext
-};
-
-// Modes and flags for dlopen()
-// include/dlfcn.h
-
-/// Bind function calls lazily.
-pub const RTLD_LAZY = 1;
-
-/// Bind function calls immediately.
-pub const RTLD_NOW = 2;
-
-pub const RTLD_MODEMASK = 0x3;
-
-/// Make symbols globally available.
-pub const RTLD_GLOBAL = 0x100;
-
-/// Opposite of RTLD_GLOBAL, and the default.
-pub const RTLD_LOCAL = 0;
-
-/// Trace loaded objects and exit.
-pub const RTLD_TRACE = 0x200;
-
-/// Do not remove members.
-pub const RTLD_NODELETE = 0x01000;
-
-/// Do not load if not already loaded.
-pub const RTLD_NOLOAD = 0x02000;
-
-pub const dl_phdr_info = extern struct {
- dlpi_addr: usize,
- dlpi_name: ?[*:0]const u8,
- dlpi_phdr: [*]std.elf.Phdr,
- dlpi_phnum: u16,
-};
-
-pub const Flock = extern struct {
- l_start: off_t,
- l_len: off_t,
- l_pid: pid_t,
- l_type: i16,
- l_whence: i16,
- l_sysid: i32,
- __unused: [4]u8,
-};
-
-pub const msghdr = extern struct {
- /// optional address
- msg_name: ?*sockaddr,
-
- /// size of address
- msg_namelen: socklen_t,
-
- /// scatter/gather array
- msg_iov: [*]iovec,
-
- /// # elements in msg_iov
- msg_iovlen: i32,
-
- /// ancillary data
- msg_control: ?*c_void,
-
- /// ancillary data buffer len
- msg_controllen: socklen_t,
-
- /// flags on received message
- msg_flags: i32,
-};
-
-pub const msghdr_const = extern struct {
- /// optional address
- msg_name: ?*const sockaddr,
-
- /// size of address
- msg_namelen: socklen_t,
-
- /// scatter/gather array
- msg_iov: [*]iovec_const,
-
- /// # elements in msg_iov
- msg_iovlen: i32,
-
- /// ancillary data
- msg_control: ?*c_void,
-
- /// ancillary data buffer len
- msg_controllen: socklen_t,
-
- /// flags on received message
- msg_flags: i32,
-};
-
-pub const libc_stat = extern struct {
- dev: dev_t,
- ino: ino_t,
- nlink: nlink_t,
-
- mode: mode_t,
- __pad0: u16,
- uid: uid_t,
- gid: gid_t,
- __pad1: u32,
- rdev: dev_t,
-
- atim: timespec,
- mtim: timespec,
- ctim: timespec,
- birthtim: timespec,
-
- size: off_t,
- blocks: i64,
- blksize: isize,
- flags: u32,
- gen: u64,
- __spare: [10]u64,
-
- pub fn atime(self: @This()) timespec {
- return self.atim;
- }
-
- pub fn mtime(self: @This()) timespec {
- return self.mtim;
- }
-
- pub fn ctime(self: @This()) timespec {
- return self.ctim;
- }
-};
-
-pub const timespec = extern struct {
- tv_sec: isize,
- tv_nsec: isize,
-};
-
-pub const timeval = extern struct {
- /// seconds
- tv_sec: time_t,
- /// microseconds
- tv_usec: suseconds_t,
-};
-
-pub const dirent = extern struct {
- d_fileno: usize,
- d_off: i64,
- d_reclen: u16,
- d_type: u8,
- d_pad0: u8,
- d_namlen: u16,
- d_pad1: u16,
- d_name: [256]u8,
-
- pub fn reclen(self: dirent) u16 {
- return self.d_reclen;
- }
-};
-
-pub const in_port_t = u16;
-pub const sa_family_t = u8;
-
-pub const sockaddr = extern struct {
- /// total length
- len: u8,
-
- /// address family
- family: sa_family_t,
-
- /// actually longer; address value
- data: [14]u8,
-};
-
-pub const sockaddr_storage = std.x.os.Socket.Address.Native.Storage;
-
-pub const sockaddr_in = extern struct {
- len: u8 = @sizeOf(sockaddr_in),
- family: sa_family_t = AF_INET,
- port: in_port_t,
- addr: u32,
- zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },
-};
-
-pub const sockaddr_in6 = extern struct {
- len: u8 = @sizeOf(sockaddr_in6),
- family: sa_family_t = AF_INET6,
- port: in_port_t,
- flowinfo: u32,
- addr: [16]u8,
- scope_id: u32,
-};
-
-pub const sockaddr_un = extern struct {
- len: u8 = @sizeOf(sockaddr_un),
- family: sa_family_t = AF_UNIX,
- path: [104]u8,
-};
-
-pub const CTL_KERN = 1;
-pub const CTL_DEBUG = 5;
-
-pub const KERN_PROC = 14; // struct: process entries
-pub const KERN_PROC_PATHNAME = 12; // path to executable
-pub const KERN_IOV_MAX = 35;
-
-pub const PATH_MAX = 1024;
-pub const IOV_MAX = KERN_IOV_MAX;
-
-pub const STDIN_FILENO = 0;
-pub const STDOUT_FILENO = 1;
-pub const STDERR_FILENO = 2;
-
-pub const PROT_NONE = 0;
-pub const PROT_READ = 1;
-pub const PROT_WRITE = 2;
-pub const PROT_EXEC = 4;
-
-pub const CLOCK_REALTIME = 0;
-pub const CLOCK_VIRTUAL = 1;
-pub const CLOCK_PROF = 2;
-pub const CLOCK_MONOTONIC = 4;
-pub const CLOCK_UPTIME = 5;
-pub const CLOCK_UPTIME_PRECISE = 7;
-pub const CLOCK_UPTIME_FAST = 8;
-pub const CLOCK_REALTIME_PRECISE = 9;
-pub const CLOCK_REALTIME_FAST = 10;
-pub const CLOCK_MONOTONIC_PRECISE = 11;
-pub const CLOCK_MONOTONIC_FAST = 12;
-pub const CLOCK_SECOND = 13;
-pub const CLOCK_THREAD_CPUTIME_ID = 14;
-pub const CLOCK_PROCESS_CPUTIME_ID = 15;
-
-pub const MAP_FAILED = @intToPtr(*c_void, maxInt(usize));
-pub const MAP_SHARED = 0x0001;
-pub const MAP_PRIVATE = 0x0002;
-pub const MAP_FIXED = 0x0010;
-pub const MAP_STACK = 0x0400;
-pub const MAP_NOSYNC = 0x0800;
-pub const MAP_ANON = 0x1000;
-pub const MAP_ANONYMOUS = MAP_ANON;
-pub const MAP_FILE = 0;
-
-pub const MAP_GUARD = 0x00002000;
-pub const MAP_EXCL = 0x00004000;
-pub const MAP_NOCORE = 0x00020000;
-pub const MAP_PREFAULT_READ = 0x00040000;
-pub const MAP_32BIT = 0x00080000;
-
-pub const WNOHANG = 1;
-pub const WUNTRACED = 2;
-pub const WSTOPPED = WUNTRACED;
-pub const WCONTINUED = 4;
-pub const WNOWAIT = 8;
-pub const WEXITED = 16;
-pub const WTRAPPED = 32;
-
-pub const SA_ONSTACK = 0x0001;
-pub const SA_RESTART = 0x0002;
-pub const SA_RESETHAND = 0x0004;
-pub const SA_NOCLDSTOP = 0x0008;
-pub const SA_NODEFER = 0x0010;
-pub const SA_NOCLDWAIT = 0x0020;
-pub const SA_SIGINFO = 0x0040;
-
-pub const SIGHUP = 1;
-pub const SIGINT = 2;
-pub const SIGQUIT = 3;
-pub const SIGILL = 4;
-pub const SIGTRAP = 5;
-pub const SIGABRT = 6;
-pub const SIGIOT = SIGABRT;
-pub const SIGEMT = 7;
-pub const SIGFPE = 8;
-pub const SIGKILL = 9;
-pub const SIGBUS = 10;
-pub const SIGSEGV = 11;
-pub const SIGSYS = 12;
-pub const SIGPIPE = 13;
-pub const SIGALRM = 14;
-pub const SIGTERM = 15;
-pub const SIGURG = 16;
-pub const SIGSTOP = 17;
-pub const SIGTSTP = 18;
-pub const SIGCONT = 19;
-pub const SIGCHLD = 20;
-pub const SIGTTIN = 21;
-pub const SIGTTOU = 22;
-pub const SIGIO = 23;
-pub const SIGXCPU = 24;
-pub const SIGXFSZ = 25;
-pub const SIGVTALRM = 26;
-pub const SIGPROF = 27;
-pub const SIGWINCH = 28;
-pub const SIGINFO = 29;
-pub const SIGUSR1 = 30;
-pub const SIGUSR2 = 31;
-pub const SIGTHR = 32;
-pub const SIGLWP = SIGTHR;
-pub const SIGLIBRT = 33;
-
-pub const SIGRTMIN = 65;
-pub const SIGRTMAX = 126;
-
-// access function
-pub const F_OK = 0; // test for existence of file
-pub const X_OK = 1; // test for execute or search permission
-pub const W_OK = 2; // test for write permission
-pub const R_OK = 4; // test for read permission
-
-pub const O_RDONLY = 0x0000;
-pub const O_WRONLY = 0x0001;
-pub const O_RDWR = 0x0002;
-pub const O_ACCMODE = 0x0003;
-
-pub const O_SHLOCK = 0x0010;
-pub const O_EXLOCK = 0x0020;
-
-pub const O_CREAT = 0x0200;
-pub const O_EXCL = 0x0800;
-pub const O_NOCTTY = 0x8000;
-pub const O_TRUNC = 0x0400;
-pub const O_APPEND = 0x0008;
-pub const O_NONBLOCK = 0x0004;
-pub const O_DSYNC = 0o10000;
-pub const O_SYNC = 0x0080;
-pub const O_RSYNC = 0o4010000;
-pub const O_DIRECTORY = 0x20000;
-pub const O_NOFOLLOW = 0x0100;
-pub const O_CLOEXEC = 0x00100000;
-
-pub const O_ASYNC = 0x0040;
-pub const O_DIRECT = 0x00010000;
-pub const O_NOATIME = 0o1000000;
-pub const O_PATH = 0o10000000;
-pub const O_TMPFILE = 0o20200000;
-pub const O_NDELAY = O_NONBLOCK;
-
-pub const F_DUPFD = 0;
-pub const F_GETFD = 1;
-pub const F_SETFD = 2;
-pub const F_GETFL = 3;
-pub const F_SETFL = 4;
-
-pub const F_GETOWN = 5;
-pub const F_SETOWN = 6;
-
-pub const F_GETLK = 11;
-pub const F_SETLK = 12;
-pub const F_SETLKW = 13;
-
-pub const F_RDLCK = 1;
-pub const F_WRLCK = 3;
-pub const F_UNLCK = 2;
-
-pub const LOCK_SH = 1;
-pub const LOCK_EX = 2;
-pub const LOCK_UN = 8;
-pub const LOCK_NB = 4;
-
-pub const F_SETOWN_EX = 15;
-pub const F_GETOWN_EX = 16;
-
-pub const F_GETOWNER_UIDS = 17;
-
-pub const FD_CLOEXEC = 1;
-
-pub const SEEK_SET = 0;
-pub const SEEK_CUR = 1;
-pub const SEEK_END = 2;
-
-pub const SIG_BLOCK = 1;
-pub const SIG_UNBLOCK = 2;
-pub const SIG_SETMASK = 3;
-
-pub const SOCK_STREAM = 1;
-pub const SOCK_DGRAM = 2;
-pub const SOCK_RAW = 3;
-pub const SOCK_RDM = 4;
-pub const SOCK_SEQPACKET = 5;
-
-pub const SOCK_CLOEXEC = 0x10000000;
-pub const SOCK_NONBLOCK = 0x20000000;
-
-pub const SO_DEBUG = 0x00000001;
-pub const SO_ACCEPTCONN = 0x00000002;
-pub const SO_REUSEADDR = 0x00000004;
-pub const SO_KEEPALIVE = 0x00000008;
-pub const SO_DONTROUTE = 0x00000010;
-pub const SO_BROADCAST = 0x00000020;
-pub const SO_USELOOPBACK = 0x00000040;
-pub const SO_LINGER = 0x00000080;
-pub const SO_OOBINLINE = 0x00000100;
-pub const SO_REUSEPORT = 0x00000200;
-pub const SO_TIMESTAMP = 0x00000400;
-pub const SO_NOSIGPIPE = 0x00000800;
-pub const SO_ACCEPTFILTER = 0x00001000;
-pub const SO_BINTIME = 0x00002000;
-pub const SO_NO_OFFLOAD = 0x00004000;
-pub const SO_NO_DDP = 0x00008000;
-pub const SO_REUSEPORT_LB = 0x00010000;
-
-pub const SO_SNDBUF = 0x1001;
-pub const SO_RCVBUF = 0x1002;
-pub const SO_SNDLOWAT = 0x1003;
-pub const SO_RCVLOWAT = 0x1004;
-pub const SO_SNDTIMEO = 0x1005;
-pub const SO_RCVTIMEO = 0x1006;
-pub const SO_ERROR = 0x1007;
-pub const SO_TYPE = 0x1008;
-pub const SO_LABEL = 0x1009;
-pub const SO_PEERLABEL = 0x1010;
-pub const SO_LISTENQLIMIT = 0x1011;
-pub const SO_LISTENQLEN = 0x1012;
-pub const SO_LISTENINCQLEN = 0x1013;
-pub const SO_SETFIB = 0x1014;
-pub const SO_USER_COOKIE = 0x1015;
-pub const SO_PROTOCOL = 0x1016;
-pub const SO_PROTOTYPE = SO_PROTOCOL;
-pub const SO_TS_CLOCK = 0x1017;
-pub const SO_MAX_PACING_RATE = 0x1018;
-pub const SO_DOMAIN = 0x1019;
-
-pub const SOL_SOCKET = 0xffff;
-
-pub const PF_UNSPEC = AF_UNSPEC;
-pub const PF_LOCAL = AF_LOCAL;
-pub const PF_UNIX = PF_LOCAL;
-pub const PF_INET = AF_INET;
-pub const PF_IMPLINK = AF_IMPLINK;
-pub const PF_PUP = AF_PUP;
-pub const PF_CHAOS = AF_CHAOS;
-pub const PF_NETBIOS = AF_NETBIOS;
-pub const PF_ISO = AF_ISO;
-pub const PF_OSI = AF_ISO;
-pub const PF_ECMA = AF_ECMA;
-pub const PF_DATAKIT = AF_DATAKIT;
-pub const PF_CCITT = AF_CCITT;
-pub const PF_DECnet = AF_DECnet;
-pub const PF_DLI = AF_DLI;
-pub const PF_LAT = AF_LAT;
-pub const PF_HYLINK = AF_HYLINK;
-pub const PF_APPLETALK = AF_APPLETALK;
-pub const PF_ROUTE = AF_ROUTE;
-pub const PF_LINK = AF_LINK;
-pub const PF_XTP = pseudo_AF_XTP;
-pub const PF_COIP = AF_COIP;
-pub const PF_CNT = AF_CNT;
-pub const PF_SIP = AF_SIP;
-pub const PF_IPX = AF_IPX;
-pub const PF_RTIP = pseudo_AF_RTIP;
-pub const PF_PIP = psuedo_AF_PIP;
-pub const PF_ISDN = AF_ISDN;
-pub const PF_KEY = pseudo_AF_KEY;
-pub const PF_INET6 = pseudo_AF_INET6;
-pub const PF_NATM = AF_NATM;
-pub const PF_ATM = AF_ATM;
-pub const PF_NETGRAPH = AF_NETGRAPH;
-pub const PF_SLOW = AF_SLOW;
-pub const PF_SCLUSTER = AF_SCLUSTER;
-pub const PF_ARP = AF_ARP;
-pub const PF_BLUETOOTH = AF_BLUETOOTH;
-pub const PF_IEEE80211 = AF_IEEE80211;
-pub const PF_INET_SDP = AF_INET_SDP;
-pub const PF_INET6_SDP = AF_INET6_SDP;
-pub const PF_MAX = AF_MAX;
-
-pub const AF_UNSPEC = 0;
-pub const AF_UNIX = 1;
-pub const AF_LOCAL = AF_UNIX;
-pub const AF_FILE = AF_LOCAL;
-pub const AF_INET = 2;
-pub const AF_IMPLINK = 3;
-pub const AF_PUP = 4;
-pub const AF_CHAOS = 5;
-pub const AF_NETBIOS = 6;
-pub const AF_ISO = 7;
-pub const AF_OSI = AF_ISO;
-pub const AF_ECMA = 8;
-pub const AF_DATAKIT = 9;
-pub const AF_CCITT = 10;
-pub const AF_SNA = 11;
-pub const AF_DECnet = 12;
-pub const AF_DLI = 13;
-pub const AF_LAT = 14;
-pub const AF_HYLINK = 15;
-pub const AF_APPLETALK = 16;
-pub const AF_ROUTE = 17;
-pub const AF_LINK = 18;
-pub const pseudo_AF_XTP = 19;
-pub const AF_COIP = 20;
-pub const AF_CNT = 21;
-pub const pseudo_AF_RTIP = 22;
-pub const AF_IPX = 23;
-pub const AF_SIP = 24;
-pub const pseudo_AF_PIP = 25;
-pub const AF_ISDN = 26;
-pub const AF_E164 = AF_ISDN;
-pub const pseudo_AF_KEY = 27;
-pub const AF_INET6 = 28;
-pub const AF_NATM = 29;
-pub const AF_ATM = 30;
-pub const pseudo_AF_HDRCMPLT = 31;
-pub const AF_NETGRAPH = 32;
-pub const AF_SLOW = 33;
-pub const AF_SCLUSTER = 34;
-pub const AF_ARP = 35;
-pub const AF_BLUETOOTH = 36;
-pub const AF_IEEE80211 = 37;
-pub const AF_INET_SDP = 40;
-pub const AF_INET6_SDP = 42;
-pub const AF_MAX = 42;
-
-pub const DT_UNKNOWN = 0;
-pub const DT_FIFO = 1;
-pub const DT_CHR = 2;
-pub const DT_DIR = 4;
-pub const DT_BLK = 6;
-pub const DT_REG = 8;
-pub const DT_LNK = 10;
-pub const DT_SOCK = 12;
-pub const DT_WHT = 14;
-
-/// add event to kq (implies enable)
-pub const EV_ADD = 0x0001;
-
-/// delete event from kq
-pub const EV_DELETE = 0x0002;
-
-/// enable event
-pub const EV_ENABLE = 0x0004;
-
-/// disable event (not reported)
-pub const EV_DISABLE = 0x0008;
-
-/// only report one occurrence
-pub const EV_ONESHOT = 0x0010;
-
-/// clear event state after reporting
-pub const EV_CLEAR = 0x0020;
-
-/// error, event data contains errno
-pub const EV_ERROR = 0x4000;
-
-/// force immediate event output
-/// ... with or without EV_ERROR
-/// ... use KEVENT_FLAG_ERROR_EVENTS
-/// on syscalls supporting flags
-pub const EV_RECEIPT = 0x0040;
-
-/// disable event after reporting
-pub const EV_DISPATCH = 0x0080;
-
-pub const EVFILT_READ = -1;
-pub const EVFILT_WRITE = -2;
-
-/// attached to aio requests
-pub const EVFILT_AIO = -3;
-
-/// attached to vnodes
-pub const EVFILT_VNODE = -4;
-
-/// attached to struct proc
-pub const EVFILT_PROC = -5;
-
-/// attached to struct proc
-pub const EVFILT_SIGNAL = -6;
-
-/// timers
-pub const EVFILT_TIMER = -7;
-
-/// Process descriptors
-pub const EVFILT_PROCDESC = -8;
-
-/// Filesystem events
-pub const EVFILT_FS = -9;
-
-pub const EVFILT_LIO = -10;
-
-/// User events
-pub const EVFILT_USER = -11;
-
-/// Sendfile events
-pub const EVFILT_SENDFILE = -12;
-
-pub const EVFILT_EMPTY = -13;
-
-/// On input, NOTE_TRIGGER causes the event to be triggered for output.
-pub const NOTE_TRIGGER = 0x01000000;
-
-/// ignore input fflags
-pub const NOTE_FFNOP = 0x00000000;
-
-/// and fflags
-pub const NOTE_FFAND = 0x40000000;
-
-/// or fflags
-pub const NOTE_FFOR = 0x80000000;
-
-/// copy fflags
-pub const NOTE_FFCOPY = 0xc0000000;
-
-/// mask for operations
-pub const NOTE_FFCTRLMASK = 0xc0000000;
-pub const NOTE_FFLAGSMASK = 0x00ffffff;
-
-/// low water mark
-pub const NOTE_LOWAT = 0x00000001;
-
-/// behave like poll()
-pub const NOTE_FILE_POLL = 0x00000002;
-
-/// vnode was removed
-pub const NOTE_DELETE = 0x00000001;
-
-/// data contents changed
-pub const NOTE_WRITE = 0x00000002;
-
-/// size increased
-pub const NOTE_EXTEND = 0x00000004;
-
-/// attributes changed
-pub const NOTE_ATTRIB = 0x00000008;
-
-/// link count changed
-pub const NOTE_LINK = 0x00000010;
-
-/// vnode was renamed
-pub const NOTE_RENAME = 0x00000020;
-
-/// vnode access was revoked
-pub const NOTE_REVOKE = 0x00000040;
-
-/// vnode was opened
-pub const NOTE_OPEN = 0x00000080;
-
-/// file closed, fd did not allow write
-pub const NOTE_CLOSE = 0x00000100;
-
-/// file closed, fd did allow write
-pub const NOTE_CLOSE_WRITE = 0x00000200;
-
-/// file was read
-pub const NOTE_READ = 0x00000400;
-
-/// process exited
-pub const NOTE_EXIT = 0x80000000;
-
-/// process forked
-pub const NOTE_FORK = 0x40000000;
-
-/// process exec'd
-pub const NOTE_EXEC = 0x20000000;
-
-/// mask for signal & exit status
-pub const NOTE_PDATAMASK = 0x000fffff;
-pub const NOTE_PCTRLMASK = (~NOTE_PDATAMASK);
-
-/// data is seconds
-pub const NOTE_SECONDS = 0x00000001;
-
-/// data is milliseconds
-pub const NOTE_MSECONDS = 0x00000002;
-
-/// data is microseconds
-pub const NOTE_USECONDS = 0x00000004;
-
-/// data is nanoseconds
-pub const NOTE_NSECONDS = 0x00000008;
-
-/// timeout is absolute
-pub const NOTE_ABSTIME = 0x00000010;
-
-pub const TIOCEXCL = 0x2000740d;
-pub const TIOCNXCL = 0x2000740e;
-pub const TIOCSCTTY = 0x20007461;
-pub const TIOCGPGRP = 0x40047477;
-pub const TIOCSPGRP = 0x80047476;
-pub const TIOCOUTQ = 0x40047473;
-pub const TIOCSTI = 0x80017472;
-pub const TIOCGWINSZ = 0x40087468;
-pub const TIOCSWINSZ = 0x80087467;
-pub const TIOCMGET = 0x4004746a;
-pub const TIOCMBIS = 0x8004746c;
-pub const TIOCMBIC = 0x8004746b;
-pub const TIOCMSET = 0x8004746d;
-pub const FIONREAD = 0x4004667f;
-pub const TIOCCONS = 0x80047462;
-pub const TIOCPKT = 0x80047470;
-pub const FIONBIO = 0x8004667e;
-pub const TIOCNOTTY = 0x20007471;
-pub const TIOCSETD = 0x8004741b;
-pub const TIOCGETD = 0x4004741a;
-pub const TIOCSBRK = 0x2000747b;
-pub const TIOCCBRK = 0x2000747a;
-pub const TIOCGSID = 0x40047463;
-pub const TIOCGPTN = 0x4004740f;
-pub const TIOCSIG = 0x2004745f;
-
-pub fn WEXITSTATUS(s: u32) u8 {
- return @intCast(u8, (s & 0xff00) >> 8);
-}
-pub fn WTERMSIG(s: u32) u32 {
- return s & 0x7f;
-}
-pub fn WSTOPSIG(s: u32) u32 {
- return WEXITSTATUS(s);
-}
-pub fn WIFEXITED(s: u32) bool {
- return WTERMSIG(s) == 0;
-}
-pub fn WIFSTOPPED(s: u32) bool {
- return @truncate(u16, (((s & 0xffff) *% 0x10001) >> 8)) > 0x7f00;
-}
-pub fn WIFSIGNALED(s: u32) bool {
- return (s & 0xffff) -% 1 < 0xff;
-}
-
-pub const winsize = extern struct {
- ws_row: u16,
- ws_col: u16,
- ws_xpixel: u16,
- ws_ypixel: u16,
-};
-
-const NSIG = 32;
-
-pub const SIG_DFL = @intToPtr(?Sigaction.sigaction_fn, 0);
-pub const SIG_IGN = @intToPtr(?Sigaction.sigaction_fn, 1);
-pub const SIG_ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize));
-
-/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.
-pub const Sigaction = extern struct {
- pub const handler_fn = fn (c_int) callconv(.C) void;
- pub const sigaction_fn = fn (c_int, *const siginfo_t, ?*const c_void) callconv(.C) void;
-
- /// signal handler
- handler: extern union {
- handler: ?handler_fn,
- sigaction: ?sigaction_fn,
- },
-
- /// see signal options
- flags: c_uint,
-
- /// signal mask to apply
- mask: sigset_t,
-};
-
-pub const siginfo_t = extern struct {
- signo: c_int,
- errno: c_int,
- code: c_int,
- pid: pid_t,
- uid: uid_t,
- status: c_int,
- addr: ?*c_void,
- value: sigval,
- reason: extern union {
- fault: extern struct {
- trapno: c_int,
- },
- timer: extern struct {
- timerid: c_int,
- overrun: c_int,
- },
- mesgq: extern struct {
- mqd: c_int,
- },
- poll: extern struct {
- band: c_long,
- },
- spare: extern struct {
- spare1: c_long,
- spare2: [7]c_int,
- },
- },
-};
-
-pub const sigval = extern union {
- int: c_int,
- ptr: ?*c_void,
-};
-
-pub const _SIG_WORDS = 4;
-pub const _SIG_MAXSIG = 128;
-
-pub inline fn _SIG_IDX(sig: usize) usize {
- return sig - 1;
-}
-pub inline fn _SIG_WORD(sig: usize) usize {
- return_SIG_IDX(sig) >> 5;
-}
-pub inline fn _SIG_BIT(sig: usize) usize {
- return 1 << (_SIG_IDX(sig) & 31);
-}
-pub inline fn _SIG_VALID(sig: usize) usize {
- return sig <= _SIG_MAXSIG and sig > 0;
-}
-
-pub const sigset_t = extern struct {
- __bits: [_SIG_WORDS]u32,
-};
-
-pub const empty_sigset = sigset_t{ .__bits = [_]u32{0} ** _SIG_WORDS };
-
-pub usingnamespace switch (builtin.target.cpu.arch) {
- .x86_64 => struct {
- pub const ucontext_t = extern struct {
- sigmask: sigset_t,
- mcontext: mcontext_t,
- link: ?*ucontext_t,
- stack: stack_t,
- flags: c_int,
- __spare__: [4]c_int,
- };
-
- /// XXX x86_64 specific
- pub const mcontext_t = extern struct {
- onstack: u64,
- rdi: u64,
- rsi: u64,
- rdx: u64,
- rcx: u64,
- r8: u64,
- r9: u64,
- rax: u64,
- rbx: u64,
- rbp: u64,
- r10: u64,
- r11: u64,
- r12: u64,
- r13: u64,
- r14: u64,
- r15: u64,
- trapno: u32,
- fs: u16,
- gs: u16,
- addr: u64,
- flags: u32,
- es: u16,
- ds: u16,
- err: u64,
- rip: u64,
- cs: u64,
- rflags: u64,
- rsp: u64,
- ss: u64,
- };
- },
- else => struct {},
-};
-
-pub const E = enum(u16) {
- /// No error occurred.
- SUCCESS = 0,
-
- PERM = 1, // Operation not permitted
- NOENT = 2, // No such file or directory
- SRCH = 3, // No such process
- INTR = 4, // Interrupted system call
- IO = 5, // Input/output error
- NXIO = 6, // Device not configured
- @"2BIG" = 7, // Argument list too long
- NOEXEC = 8, // Exec format error
- BADF = 9, // Bad file descriptor
- CHILD = 10, // No child processes
- DEADLK = 11, // Resource deadlock avoided
- // 11 was AGAIN
- NOMEM = 12, // Cannot allocate memory
- ACCES = 13, // Permission denied
- FAULT = 14, // Bad address
- NOTBLK = 15, // Block device required
- BUSY = 16, // Device busy
- EXIST = 17, // File exists
- XDEV = 18, // Cross-device link
- NODEV = 19, // Operation not supported by device
- NOTDIR = 20, // Not a directory
- ISDIR = 21, // Is a directory
- INVAL = 22, // Invalid argument
- NFILE = 23, // Too many open files in system
- MFILE = 24, // Too many open files
- NOTTY = 25, // Inappropriate ioctl for device
- TXTBSY = 26, // Text file busy
- FBIG = 27, // File too large
- NOSPC = 28, // No space left on device
- SPIPE = 29, // Illegal seek
- ROFS = 30, // Read-only filesystem
- MLINK = 31, // Too many links
- PIPE = 32, // Broken pipe
-
- // math software
- DOM = 33, // Numerical argument out of domain
- RANGE = 34, // Result too large
-
- // non-blocking and interrupt i/o
-
- /// Resource temporarily unavailable
- /// This code is also used for `WOULDBLOCK`: operation would block.
- AGAIN = 35,
- INPROGRESS = 36, // Operation now in progress
- ALREADY = 37, // Operation already in progress
-
- // ipc/network software -- argument errors
- NOTSOCK = 38, // Socket operation on non-socket
- DESTADDRREQ = 39, // Destination address required
- MSGSIZE = 40, // Message too long
- PROTOTYPE = 41, // Protocol wrong type for socket
- NOPROTOOPT = 42, // Protocol not available
- PROTONOSUPPORT = 43, // Protocol not supported
- SOCKTNOSUPPORT = 44, // Socket type not supported
- /// Operation not supported
- /// This code is also used for `NOTSUP`.
- OPNOTSUPP = 45,
- PFNOSUPPORT = 46, // Protocol family not supported
- AFNOSUPPORT = 47, // Address family not supported by protocol family
- ADDRINUSE = 48, // Address already in use
- ADDRNOTAVAIL = 49, // Can't assign requested address
-
- // ipc/network software -- operational errors
- NETDOWN = 50, // Network is down
- NETUNREACH = 51, // Network is unreachable
- NETRESET = 52, // Network dropped connection on reset
- CONNABORTED = 53, // Software caused connection abort
- CONNRESET = 54, // Connection reset by peer
- NOBUFS = 55, // No buffer space available
- ISCONN = 56, // Socket is already connected
- NOTCONN = 57, // Socket is not connected
- SHUTDOWN = 58, // Can't send after socket shutdown
- TOOMANYREFS = 59, // Too many references: can't splice
- TIMEDOUT = 60, // Operation timed out
- CONNREFUSED = 61, // Connection refused
-
- LOOP = 62, // Too many levels of symbolic links
- NAMETOOLONG = 63, // File name too long
-
- // should be rearranged
- HOSTDOWN = 64, // Host is down
- HOSTUNREACH = 65, // No route to host
- NOTEMPTY = 66, // Directory not empty
-
- // quotas & mush
- PROCLIM = 67, // Too many processes
- USERS = 68, // Too many users
- DQUOT = 69, // Disc quota exceeded
-
- // Network File System
- STALE = 70, // Stale NFS file handle
- REMOTE = 71, // Too many levels of remote in path
- BADRPC = 72, // RPC struct is bad
- RPCMISMATCH = 73, // RPC version wrong
- PROGUNAVAIL = 74, // RPC prog. not avail
- PROGMISMATCH = 75, // Program version wrong
- PROCUNAVAIL = 76, // Bad procedure for program
-
- NOLCK = 77, // No locks available
- NOSYS = 78, // Function not implemented
-
- FTYPE = 79, // Inappropriate file type or format
- AUTH = 80, // Authentication error
- NEEDAUTH = 81, // Need authenticator
- IDRM = 82, // Identifier removed
- NOMSG = 83, // No message of desired type
- OVERFLOW = 84, // Value too large to be stored in data type
- CANCELED = 85, // Operation canceled
- ILSEQ = 86, // Illegal byte sequence
- NOATTR = 87, // Attribute not found
-
- DOOFUS = 88, // Programming error
-
- BADMSG = 89, // Bad message
- MULTIHOP = 90, // Multihop attempted
- NOLINK = 91, // Link has been severed
- PROTO = 92, // Protocol error
-
- NOTCAPABLE = 93, // Capabilities insufficient
- CAPMODE = 94, // Not permitted in capability mode
- NOTRECOVERABLE = 95, // State not recoverable
- OWNERDEAD = 96, // Previous owner died
- _,
-};
-
-pub const MINSIGSTKSZ = switch (builtin.target.cpu.arch) {
- .i386, .x86_64 => 2048,
- .arm, .aarch64 => 4096,
- else => @compileError("MINSIGSTKSZ not defined for this architecture"),
-};
-pub const SIGSTKSZ = MINSIGSTKSZ + 32768;
-
-pub const SS_ONSTACK = 1;
-pub const SS_DISABLE = 4;
-
-pub const stack_t = extern struct {
- ss_sp: [*]u8,
- ss_size: isize,
- ss_flags: i32,
-};
-
-pub const S_IFMT = 0o170000;
-
-pub const S_IFIFO = 0o010000;
-pub const S_IFCHR = 0o020000;
-pub const S_IFDIR = 0o040000;
-pub const S_IFBLK = 0o060000;
-pub const S_IFREG = 0o100000;
-pub const S_IFLNK = 0o120000;
-pub const S_IFSOCK = 0o140000;
-pub const S_IFWHT = 0o160000;
-
-pub const S_ISUID = 0o4000;
-pub const S_ISGID = 0o2000;
-pub const S_ISVTX = 0o1000;
-pub const S_IRWXU = 0o700;
-pub const S_IRUSR = 0o400;
-pub const S_IWUSR = 0o200;
-pub const S_IXUSR = 0o100;
-pub const S_IRWXG = 0o070;
-pub const S_IRGRP = 0o040;
-pub const S_IWGRP = 0o020;
-pub const S_IXGRP = 0o010;
-pub const S_IRWXO = 0o007;
-pub const S_IROTH = 0o004;
-pub const S_IWOTH = 0o002;
-pub const S_IXOTH = 0o001;
-
-pub fn S_ISFIFO(m: u32) bool {
- return m & S_IFMT == S_IFIFO;
-}
-
-pub fn S_ISCHR(m: u32) bool {
- return m & S_IFMT == S_IFCHR;
-}
-
-pub fn S_ISDIR(m: u32) bool {
- return m & S_IFMT == S_IFDIR;
-}
-
-pub fn S_ISBLK(m: u32) bool {
- return m & S_IFMT == S_IFBLK;
-}
-
-pub fn S_ISREG(m: u32) bool {
- return m & S_IFMT == S_IFREG;
-}
-
-pub fn S_ISLNK(m: u32) bool {
- return m & S_IFMT == S_IFLNK;
-}
-
-pub fn S_ISSOCK(m: u32) bool {
- return m & S_IFMT == S_IFSOCK;
-}
-
-pub fn S_IWHT(m: u32) bool {
- return m & S_IFMT == S_IFWHT;
-}
-
-pub const HOST_NAME_MAX = 255;
-
-/// Magic value that specify the use of the current working directory
-/// to determine the target of relative file paths in the openat() and
-/// similar syscalls.
-pub const AT_FDCWD = -100;
-
-/// Check access using effective user and group ID
-pub const AT_EACCESS = 0x0100;
-
-/// Do not follow symbolic links
-pub const AT_SYMLINK_NOFOLLOW = 0x0200;
-
-/// Follow symbolic link
-pub const AT_SYMLINK_FOLLOW = 0x0400;
-
-/// Remove directory instead of file
-pub const AT_REMOVEDIR = 0x0800;
-
-pub const addrinfo = extern struct {
- flags: i32,
- family: i32,
- socktype: i32,
- protocol: i32,
- addrlen: socklen_t,
- canonname: ?[*:0]u8,
- addr: ?*sockaddr,
- next: ?*addrinfo,
-};
-
-/// Fail if not under dirfd
-pub const AT_BENEATH = 0x1000;
-
-/// dummy for IP
-pub const IPPROTO_IP = 0;
-
-/// control message protocol
-pub const IPPROTO_ICMP = 1;
-
-/// tcp
-pub const IPPROTO_TCP = 6;
-
-/// user datagram protocol
-pub const IPPROTO_UDP = 17;
-
-/// IP6 header
-pub const IPPROTO_IPV6 = 41;
-
-/// raw IP packet
-pub const IPPROTO_RAW = 255;
-
-/// IP6 hop-by-hop options
-pub const IPPROTO_HOPOPTS = 0;
-
-/// group mgmt protocol
-pub const IPPROTO_IGMP = 2;
-
-/// gateway^2 (deprecated)
-pub const IPPROTO_GGP = 3;
-
-/// IPv4 encapsulation
-pub const IPPROTO_IPV4 = 4;
-
-/// for compatibility
-pub const IPPROTO_IPIP = IPPROTO_IPV4;
-
-/// Stream protocol II
-pub const IPPROTO_ST = 7;
-
-/// exterior gateway protocol
-pub const IPPROTO_EGP = 8;
-
-/// private interior gateway
-pub const IPPROTO_PIGP = 9;
-
-/// BBN RCC Monitoring
-pub const IPPROTO_RCCMON = 10;
-
-/// network voice protocol
-pub const IPPROTO_NVPII = 11;
-
-/// pup
-pub const IPPROTO_PUP = 12;
-
-/// Argus
-pub const IPPROTO_ARGUS = 13;
-
-/// EMCON
-pub const IPPROTO_EMCON = 14;
-
-/// Cross Net Debugger
-pub const IPPROTO_XNET = 15;
-
-/// Chaos
-pub const IPPROTO_CHAOS = 16;
-
-/// Multiplexing
-pub const IPPROTO_MUX = 18;
-
-/// DCN Measurement Subsystems
-pub const IPPROTO_MEAS = 19;
-
-/// Host Monitoring
-pub const IPPROTO_HMP = 20;
-
-/// Packet Radio Measurement
-pub const IPPROTO_PRM = 21;
-
-/// xns idp
-pub const IPPROTO_IDP = 22;
-
-/// Trunk-1
-pub const IPPROTO_TRUNK1 = 23;
-
-/// Trunk-2
-pub const IPPROTO_TRUNK2 = 24;
-
-/// Leaf-1
-pub const IPPROTO_LEAF1 = 25;
-
-/// Leaf-2
-pub const IPPROTO_LEAF2 = 26;
-
-/// Reliable Data
-pub const IPPROTO_RDP = 27;
-
-/// Reliable Transaction
-pub const IPPROTO_IRTP = 28;
-
-/// tp-4 w/ class negotiation
-pub const IPPROTO_TP = 29;
-
-/// Bulk Data Transfer
-pub const IPPROTO_BLT = 30;
-
-/// Network Services
-pub const IPPROTO_NSP = 31;
-
-/// Merit Internodal
-pub const IPPROTO_INP = 32;
-
-/// Datagram Congestion Control Protocol
-pub const IPPROTO_DCCP = 33;
-
-/// Third Party Connect
-pub const IPPROTO_3PC = 34;
-
-/// InterDomain Policy Routing
-pub const IPPROTO_IDPR = 35;
-
-/// XTP
-pub const IPPROTO_XTP = 36;
-
-/// Datagram Delivery
-pub const IPPROTO_DDP = 37;
-
-/// Control Message Transport
-pub const IPPROTO_CMTP = 38;
-
-/// TP++ Transport
-pub const IPPROTO_TPXX = 39;
-
-/// IL transport protocol
-pub const IPPROTO_IL = 40;
-
-/// Source Demand Routing
-pub const IPPROTO_SDRP = 42;
-
-/// IP6 routing header
-pub const IPPROTO_ROUTING = 43;
-
-/// IP6 fragmentation header
-pub const IPPROTO_FRAGMENT = 44;
-
-/// InterDomain Routing
-pub const IPPROTO_IDRP = 45;
-
-/// resource reservation
-pub const IPPROTO_RSVP = 46;
-
-/// General Routing Encap.
-pub const IPPROTO_GRE = 47;
-
-/// Mobile Host Routing
-pub const IPPROTO_MHRP = 48;
-
-/// BHA
-pub const IPPROTO_BHA = 49;
-
-/// IP6 Encap Sec. Payload
-pub const IPPROTO_ESP = 50;
-
-/// IP6 Auth Header
-pub const IPPROTO_AH = 51;
-
-/// Integ. Net Layer Security
-pub const IPPROTO_INLSP = 52;
-
-/// IP with encryption
-pub const IPPROTO_SWIPE = 53;
-
-/// Next Hop Resolution
-pub const IPPROTO_NHRP = 54;
-
-/// IP Mobility
-pub const IPPROTO_MOBILE = 55;
-
-/// Transport Layer Security
-pub const IPPROTO_TLSP = 56;
-
-/// SKIP
-pub const IPPROTO_SKIP = 57;
-
-/// ICMP6
-pub const IPPROTO_ICMPV6 = 58;
-
-/// IP6 no next header
-pub const IPPROTO_NONE = 59;
-
-/// IP6 destination option
-pub const IPPROTO_DSTOPTS = 60;
-
-/// any host internal protocol
-pub const IPPROTO_AHIP = 61;
-
-/// CFTP
-pub const IPPROTO_CFTP = 62;
-
-/// "hello" routing protocol
-pub const IPPROTO_HELLO = 63;
-
-/// SATNET/Backroom EXPAK
-pub const IPPROTO_SATEXPAK = 64;
-
-/// Kryptolan
-pub const IPPROTO_KRYPTOLAN = 65;
-
-/// Remote Virtual Disk
-pub const IPPROTO_RVD = 66;
-
-/// Pluribus Packet Core
-pub const IPPROTO_IPPC = 67;
-
-/// Any distributed FS
-pub const IPPROTO_ADFS = 68;
-
-/// Satnet Monitoring
-pub const IPPROTO_SATMON = 69;
-
-/// VISA Protocol
-pub const IPPROTO_VISA = 70;
-
-/// Packet Core Utility
-pub const IPPROTO_IPCV = 71;
-
-/// Comp. Prot. Net. Executive
-pub const IPPROTO_CPNX = 72;
-
-/// Comp. Prot. HeartBeat
-pub const IPPROTO_CPHB = 73;
-
-/// Wang Span Network
-pub const IPPROTO_WSN = 74;
-
-/// Packet Video Protocol
-pub const IPPROTO_PVP = 75;
-
-/// BackRoom SATNET Monitoring
-pub const IPPROTO_BRSATMON = 76;
-
-/// Sun net disk proto (temp.)
-pub const IPPROTO_ND = 77;
-
-/// WIDEBAND Monitoring
-pub const IPPROTO_WBMON = 78;
-
-/// WIDEBAND EXPAK
-pub const IPPROTO_WBEXPAK = 79;
-
-/// ISO cnlp
-pub const IPPROTO_EON = 80;
-
-/// VMTP
-pub const IPPROTO_VMTP = 81;
-
-/// Secure VMTP
-pub const IPPROTO_SVMTP = 82;
-
-/// Banyon VINES
-pub const IPPROTO_VINES = 83;
-
-/// TTP
-pub const IPPROTO_TTP = 84;
-
-/// NSFNET-IGP
-pub const IPPROTO_IGP = 85;
-
-/// dissimilar gateway prot.
-pub const IPPROTO_DGP = 86;
-
-/// TCF
-pub const IPPROTO_TCF = 87;
-
-/// Cisco/GXS IGRP
-pub const IPPROTO_IGRP = 88;
-
-/// OSPFIGP
-pub const IPPROTO_OSPFIGP = 89;
-
-/// Strite RPC protocol
-pub const IPPROTO_SRPC = 90;
-
-/// Locus Address Resoloution
-pub const IPPROTO_LARP = 91;
-
-/// Multicast Transport
-pub const IPPROTO_MTP = 92;
-
-/// AX.25 Frames
-pub const IPPROTO_AX25 = 93;
-
-/// IP encapsulated in IP
-pub const IPPROTO_IPEIP = 94;
-
-/// Mobile Int.ing control
-pub const IPPROTO_MICP = 95;
-
-/// Semaphore Comm. security
-pub const IPPROTO_SCCSP = 96;
-
-/// Ethernet IP encapsulation
-pub const IPPROTO_ETHERIP = 97;
-
-/// encapsulation header
-pub const IPPROTO_ENCAP = 98;
-
-/// any private encr. scheme
-pub const IPPROTO_APES = 99;
-
-/// GMTP
-pub const IPPROTO_GMTP = 100;
-
-/// payload compression (IPComp)
-pub const IPPROTO_IPCOMP = 108;
-
-/// SCTP
-pub const IPPROTO_SCTP = 132;
-
-/// IPv6 Mobility Header
-pub const IPPROTO_MH = 135;
-
-/// UDP-Lite
-pub const IPPROTO_UDPLITE = 136;
-
-/// IP6 Host Identity Protocol
-pub const IPPROTO_HIP = 139;
-
-/// IP6 Shim6 Protocol
-pub const IPPROTO_SHIM6 = 140;
-
-/// Protocol Independent Mcast
-pub const IPPROTO_PIM = 103;
-
-/// CARP
-pub const IPPROTO_CARP = 112;
-
-/// PGM
-pub const IPPROTO_PGM = 113;
-
-/// MPLS-in-IP
-pub const IPPROTO_MPLS = 137;
-
-/// PFSYNC
-pub const IPPROTO_PFSYNC = 240;
-
-/// Reserved
-pub const IPPROTO_RESERVED_253 = 253;
-
-/// Reserved
-pub const IPPROTO_RESERVED_254 = 254;
-
-pub const rlimit_resource = enum(c_int) {
- CPU = 0,
- FSIZE = 1,
- DATA = 2,
- STACK = 3,
- CORE = 4,
- RSS = 5,
- MEMLOCK = 6,
- NPROC = 7,
- NOFILE = 8,
- SBSIZE = 9,
- VMEM = 10,
- NPTS = 11,
- SWAP = 12,
- KQUEUES = 13,
- UMTXP = 14,
- _,
-
- pub const AS: rlimit_resource = .VMEM;
-};
-
-pub const rlim_t = i64;
-
-/// No limit
-pub const RLIM_INFINITY: rlim_t = (1 << 63) - 1;
-
-pub const RLIM_SAVED_MAX = RLIM_INFINITY;
-pub const RLIM_SAVED_CUR = RLIM_INFINITY;
-
-pub const rlimit = extern struct {
- /// Soft limit
- cur: rlim_t,
- /// Hard limit
- max: rlim_t,
-};
-
-pub const SHUT_RD = 0;
-pub const SHUT_WR = 1;
-pub const SHUT_RDWR = 2;
-
-pub const nfds_t = u32;
-
-pub const pollfd = extern struct {
- fd: fd_t,
- events: i16,
- revents: i16,
-};
-
-/// any readable data available.
-pub const POLLIN = 0x0001;
-/// OOB/Urgent readable data.
-pub const POLLPRI = 0x0002;
-/// file descriptor is writeable.
-pub const POLLOUT = 0x0004;
-/// non-OOB/URG data available.
-pub const POLLRDNORM = 0x0040;
-/// no write type differentiation.
-pub const POLLWRNORM = POLLOUT;
-/// OOB/Urgent readable data.
-pub const POLLRDBAND = 0x0080;
-/// OOB/Urgent data can be written.
-pub const POLLWRBAND = 0x0100;
-/// like POLLIN, except ignore EOF.
-pub const POLLINIGNEOF = 0x2000;
-/// some poll error occurred.
-pub const POLLERR = 0x0008;
-/// file descriptor was "hung up".
-pub const POLLHUP = 0x0010;
-/// requested events "invalid".
-pub const POLLNVAL = 0x0020;
-
-pub const POLLSTANDARD = POLLIN | POLLPRI | POLLOUT | POLLRDNORM | POLLRDBAND |
- POLLWRBAND | POLLERR | POLLHUP | POLLNVAL;
diff --git a/lib/std/os/bits/haiku.zig b/lib/std/os/bits/haiku.zig
deleted file mode 100644
index 620bf2341404..000000000000
--- a/lib/std/os/bits/haiku.zig
+++ /dev/null
@@ -1,1375 +0,0 @@
-const std = @import("../../std.zig");
-const maxInt = std.math.maxInt;
-
-pub usingnamespace @import("posix.zig");
-
-pub const fd_t = c_int;
-pub const pid_t = c_int;
-pub const uid_t = u32;
-pub const gid_t = u32;
-pub const mode_t = c_uint;
-
-pub const socklen_t = u32;
-
-/// Renamed from `kevent` to `Kevent` to avoid conflict with function name.
-pub const Kevent = extern struct {
- ident: usize,
- filter: i16,
- flags: u16,
- fflags: u32,
- data: i64,
- udata: usize,
- // TODO ext
-};
-
-// Modes and flags for dlopen()
-// include/dlfcn.h
-
-pub const POLLIN = 0x0001;
-pub const POLLERR = 0x0004;
-pub const POLLNVAL = 0x1000;
-pub const POLLHUP = 0x0080;
-
-/// Bind function calls lazily.
-pub const RTLD_LAZY = 1;
-
-/// Bind function calls immediately.
-pub const RTLD_NOW = 2;
-
-pub const RTLD_MODEMASK = 0x3;
-
-/// Make symbols globally available.
-pub const RTLD_GLOBAL = 0x100;
-
-/// Opposite of RTLD_GLOBAL, and the default.
-pub const RTLD_LOCAL = 0;
-
-/// Trace loaded objects and exit.
-pub const RTLD_TRACE = 0x200;
-
-/// Do not remove members.
-pub const RTLD_NODELETE = 0x01000;
-
-/// Do not load if not already loaded.
-pub const RTLD_NOLOAD = 0x02000;
-
-pub const dl_phdr_info = extern struct {
- dlpi_addr: usize,
- dlpi_name: ?[*:0]const u8,
- dlpi_phdr: [*]std.elf.Phdr,
- dlpi_phnum: u16,
-};
-
-pub const Flock = extern struct {
- l_start: off_t,
- l_len: off_t,
- l_pid: pid_t,
- l_type: i16,
- l_whence: i16,
- l_sysid: i32,
- __unused: [4]u8,
-};
-
-pub const msghdr = extern struct {
- /// optional address
- msg_name: ?*sockaddr,
-
- /// size of address
- msg_namelen: socklen_t,
-
- /// scatter/gather array
- msg_iov: [*]iovec,
-
- /// # elements in msg_iov
- msg_iovlen: i32,
-
- /// ancillary data
- msg_control: ?*c_void,
-
- /// ancillary data buffer len
- msg_controllen: socklen_t,
-
- /// flags on received message
- msg_flags: i32,
-};
-
-pub const msghdr_const = extern struct {
- /// optional address
- msg_name: ?*const sockaddr,
-
- /// size of address
- msg_namelen: socklen_t,
-
- /// scatter/gather array
- msg_iov: [*]iovec_const,
-
- /// # elements in msg_iov
- msg_iovlen: i32,
-
- /// ancillary data
- msg_control: ?*c_void,
-
- /// ancillary data buffer len
- msg_controllen: socklen_t,
-
- /// flags on received message
- msg_flags: i32,
-};
-
-pub const off_t = i64;
-pub const ino_t = u64;
-
-pub const nfds_t = u32;
-
-pub const pollfd = extern struct {
- fd: i32,
- events: i16,
- revents: i16,
-};
-
-pub const libc_stat = extern struct {
- dev: i32,
- ino: u64,
- mode: u32,
- nlink: i32,
- uid: i32,
- gid: i32,
- size: i64,
- rdev: i32,
- blksize: i32,
- atim: timespec,
- mtim: timespec,
- ctim: timespec,
- crtim: timespec,
- st_type: u32,
- blocks: i64,
-
- pub fn atime(self: @This()) timespec {
- return self.atim;
- }
- pub fn mtime(self: @This()) timespec {
- return self.mtim;
- }
- pub fn ctime(self: @This()) timespec {
- return self.ctim;
- }
- pub fn crtime(self: @This()) timespec {
- return self.crtim;
- }
-};
-
-pub const timespec = extern struct {
- tv_sec: isize,
- tv_nsec: isize,
-};
-
-pub const dirent = extern struct {
- d_dev: i32,
- d_pdev: i32,
- d_ino: i64,
- d_pino: i64,
- d_reclen: u16,
- d_name: [256]u8,
-
- pub fn reclen(self: dirent) u16 {
- return self.d_reclen;
- }
-};
-
-pub const image_info = extern struct {
- id: u32,
- type: u32,
- sequence: i32,
- init_order: i32,
- init_routine: *c_void,
- term_routine: *c_void,
- device: i32,
- node: i32,
- name: [1024]u8,
- text: *c_void,
- data: *c_void,
- text_size: i32,
- data_size: i32,
- api_version: i32,
- abi: i32,
-};
-
-pub const system_info = extern struct {
- boot_time: i64,
- cpu_count: u32,
- max_pages: u64,
- used_pages: u64,
- cached_pages: u64,
- block_cache_pages: u64,
- ignored_pages: u64,
- needed_memory: u64,
- free_memory: u64,
- max_swap_pages: u64,
- free_swap_pages: u64,
- page_faults: u32,
- max_sems: u32,
- used_sems: u32,
- max_ports: u32,
- used_ports: u32,
- max_threads: u32,
- used_threads: u32,
- max_teams: u32,
- used_teams: u32,
- kernel_name: [256]u8,
- kernel_build_date: [32]u8,
- kernel_build_time: [32]u8,
- kernel_version: i64,
- abi: u32,
-};
-
-pub const in_port_t = u16;
-pub const sa_family_t = u8;
-
-pub const sockaddr = extern struct {
- /// total length
- len: u8,
-
- /// address family
- family: sa_family_t,
-
- /// actually longer; address value
- data: [14]u8,
-};
-
-pub const sockaddr_storage = std.x.os.Socket.Address.Native.Storage;
-
-pub const sockaddr_in = extern struct {
- len: u8 = @sizeOf(sockaddr_in),
- family: sa_family_t = AF_INET,
- port: in_port_t,
- addr: u32,
- zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },
-};
-
-pub const sockaddr_in6 = extern struct {
- len: u8 = @sizeOf(sockaddr_in6),
- family: sa_family_t = AF_INET6,
- port: in_port_t,
- flowinfo: u32,
- addr: [16]u8,
- scope_id: u32,
-};
-
-pub const sockaddr_un = extern struct {
- len: u8 = @sizeOf(sockaddr_un),
- family: sa_family_t = AF_UNIX,
- path: [104]u8,
-};
-
-pub const CTL_KERN = 1;
-pub const CTL_DEBUG = 5;
-
-pub const KERN_PROC = 14; // struct: process entries
-pub const KERN_PROC_PATHNAME = 12; // path to executable
-
-pub const PATH_MAX = 1024;
-
-pub const STDIN_FILENO = 0;
-pub const STDOUT_FILENO = 1;
-pub const STDERR_FILENO = 2;
-
-pub const PROT_NONE = 0;
-pub const PROT_READ = 1;
-pub const PROT_WRITE = 2;
-pub const PROT_EXEC = 4;
-
-pub const CLOCK_MONOTONIC = 0;
-pub const CLOCK_REALTIME = -1;
-pub const CLOCK_PROCESS_CPUTIME_ID = -2;
-pub const CLOCK_THREAD_CPUTIME_ID = -3;
-
-pub const MAP_FAILED = @intToPtr(*c_void, maxInt(usize));
-pub const MAP_SHARED = 0x0001;
-pub const MAP_PRIVATE = 0x0002;
-pub const MAP_FIXED = 0x0010;
-pub const MAP_STACK = 0x0400;
-pub const MAP_NOSYNC = 0x0800;
-pub const MAP_ANON = 0x1000;
-pub const MAP_ANONYMOUS = MAP_ANON;
-pub const MAP_FILE = 0;
-
-pub const MAP_GUARD = 0x00002000;
-pub const MAP_EXCL = 0x00004000;
-pub const MAP_NOCORE = 0x00020000;
-pub const MAP_PREFAULT_READ = 0x00040000;
-pub const MAP_32BIT = 0x00080000;
-
-pub const WNOHANG = 0x1;
-pub const WUNTRACED = 0x2;
-pub const WSTOPPED = 0x10;
-pub const WCONTINUED = 0x4;
-pub const WNOWAIT = 0x20;
-pub const WEXITED = 0x08;
-
-pub const SA_ONSTACK = 0x20;
-pub const SA_RESTART = 0x10;
-pub const SA_RESETHAND = 0x04;
-pub const SA_NOCLDSTOP = 0x01;
-pub const SA_NODEFER = 0x08;
-pub const SA_NOCLDWAIT = 0x02;
-pub const SA_SIGINFO = 0x40;
-pub const SA_NOMASK = SA_NODEFER;
-pub const SA_STACK = SA_ONSTACK;
-pub const SA_ONESHOT = SA_RESETHAND;
-
-pub const SIGHUP = 1;
-pub const SIGINT = 2;
-pub const SIGQUIT = 3;
-pub const SIGILL = 4;
-pub const SIGCHLD = 5;
-pub const SIGABRT = 6;
-pub const SIGIOT = SIGABRT;
-pub const SIGPIPE = 7;
-pub const SIGFPE = 8;
-pub const SIGKILL = 9;
-pub const SIGSTOP = 10;
-pub const SIGSEGV = 11;
-pub const SIGCONT = 12;
-pub const SIGTSTP = 13;
-pub const SIGALRM = 14;
-pub const SIGTERM = 15;
-pub const SIGTTIN = 16;
-pub const SIGTTOU = 17;
-pub const SIGUSR1 = 18;
-pub const SIGUSR2 = 19;
-pub const SIGWINCH = 20;
-pub const SIGKILLTHR = 21;
-pub const SIGTRAP = 22;
-pub const SIGPOLL = 23;
-pub const SIGPROF = 24;
-pub const SIGSYS = 25;
-pub const SIGURG = 26;
-pub const SIGVTALRM = 27;
-pub const SIGXCPU = 28;
-pub const SIGXFSZ = 29;
-pub const SIGBUS = 30;
-pub const SIGRESERVED1 = 31;
-pub const SIGRESERVED2 = 32;
-
-// TODO: check
-pub const SIGRTMIN = 65;
-pub const SIGRTMAX = 126;
-
-// access function
-pub const F_OK = 0; // test for existence of file
-pub const X_OK = 1; // test for execute or search permission
-pub const W_OK = 2; // test for write permission
-pub const R_OK = 4; // test for read permission
-
-pub const O_RDONLY = 0x0000;
-pub const O_WRONLY = 0x0001;
-pub const O_RDWR = 0x0002;
-pub const O_ACCMODE = 0x0003;
-
-pub const O_SHLOCK = 0x0010;
-pub const O_EXLOCK = 0x0020;
-
-pub const O_CREAT = 0x0200;
-pub const O_EXCL = 0x0800;
-pub const O_NOCTTY = 0x8000;
-pub const O_TRUNC = 0x0400;
-pub const O_APPEND = 0x0008;
-pub const O_NONBLOCK = 0x0004;
-pub const O_DSYNC = 0o10000;
-pub const O_SYNC = 0x0080;
-pub const O_RSYNC = 0o4010000;
-pub const O_DIRECTORY = 0x20000;
-pub const O_NOFOLLOW = 0x0100;
-pub const O_CLOEXEC = 0x00100000;
-
-pub const O_ASYNC = 0x0040;
-pub const O_DIRECT = 0x00010000;
-pub const O_NOATIME = 0o1000000;
-pub const O_PATH = 0o10000000;
-pub const O_TMPFILE = 0o20200000;
-pub const O_NDELAY = O_NONBLOCK;
-
-pub const F_DUPFD = 0;
-pub const F_GETFD = 1;
-pub const F_SETFD = 2;
-pub const F_GETFL = 3;
-pub const F_SETFL = 4;
-
-pub const F_GETOWN = 5;
-pub const F_SETOWN = 6;
-
-pub const F_GETLK = 11;
-pub const F_SETLK = 12;
-pub const F_SETLKW = 13;
-
-pub const F_RDLCK = 1;
-pub const F_WRLCK = 3;
-pub const F_UNLCK = 2;
-
-pub const LOCK_SH = 1;
-pub const LOCK_EX = 2;
-pub const LOCK_UN = 8;
-pub const LOCK_NB = 4;
-
-pub const F_SETOWN_EX = 15;
-pub const F_GETOWN_EX = 16;
-
-pub const F_GETOWNER_UIDS = 17;
-
-pub const FD_CLOEXEC = 1;
-
-pub const SEEK_SET = 0;
-pub const SEEK_CUR = 1;
-pub const SEEK_END = 2;
-
-pub const SIG_BLOCK = 1;
-pub const SIG_UNBLOCK = 2;
-pub const SIG_SETMASK = 3;
-
-pub const SOCK_STREAM = 1;
-pub const SOCK_DGRAM = 2;
-pub const SOCK_RAW = 3;
-pub const SOCK_RDM = 4;
-pub const SOCK_SEQPACKET = 5;
-
-pub const SOCK_CLOEXEC = 0x10000000;
-pub const SOCK_NONBLOCK = 0x20000000;
-
-pub const SO_DEBUG = 0x00000001;
-pub const SO_ACCEPTCONN = 0x00000002;
-pub const SO_REUSEADDR = 0x00000004;
-pub const SO_KEEPALIVE = 0x00000008;
-pub const SO_DONTROUTE = 0x00000010;
-pub const SO_BROADCAST = 0x00000020;
-pub const SO_USELOOPBACK = 0x00000040;
-pub const SO_LINGER = 0x00000080;
-pub const SO_OOBINLINE = 0x00000100;
-pub const SO_REUSEPORT = 0x00000200;
-pub const SO_TIMESTAMP = 0x00000400;
-pub const SO_NOSIGPIPE = 0x00000800;
-pub const SO_ACCEPTFILTER = 0x00001000;
-pub const SO_BINTIME = 0x00002000;
-pub const SO_NO_OFFLOAD = 0x00004000;
-pub const SO_NO_DDP = 0x00008000;
-pub const SO_REUSEPORT_LB = 0x00010000;
-
-pub const SO_SNDBUF = 0x1001;
-pub const SO_RCVBUF = 0x1002;
-pub const SO_SNDLOWAT = 0x1003;
-pub const SO_RCVLOWAT = 0x1004;
-pub const SO_SNDTIMEO = 0x1005;
-pub const SO_RCVTIMEO = 0x1006;
-pub const SO_ERROR = 0x1007;
-pub const SO_TYPE = 0x1008;
-pub const SO_LABEL = 0x1009;
-pub const SO_PEERLABEL = 0x1010;
-pub const SO_LISTENQLIMIT = 0x1011;
-pub const SO_LISTENQLEN = 0x1012;
-pub const SO_LISTENINCQLEN = 0x1013;
-pub const SO_SETFIB = 0x1014;
-pub const SO_USER_COOKIE = 0x1015;
-pub const SO_PROTOCOL = 0x1016;
-pub const SO_PROTOTYPE = SO_PROTOCOL;
-pub const SO_TS_CLOCK = 0x1017;
-pub const SO_MAX_PACING_RATE = 0x1018;
-pub const SO_DOMAIN = 0x1019;
-
-pub const SOL_SOCKET = 0xffff;
-
-pub const PF_UNSPEC = AF_UNSPEC;
-pub const PF_LOCAL = AF_LOCAL;
-pub const PF_UNIX = PF_LOCAL;
-pub const PF_INET = AF_INET;
-pub const PF_IMPLINK = AF_IMPLINK;
-pub const PF_PUP = AF_PUP;
-pub const PF_CHAOS = AF_CHAOS;
-pub const PF_NETBIOS = AF_NETBIOS;
-pub const PF_ISO = AF_ISO;
-pub const PF_OSI = AF_ISO;
-pub const PF_ECMA = AF_ECMA;
-pub const PF_DATAKIT = AF_DATAKIT;
-pub const PF_CCITT = AF_CCITT;
-pub const PF_DECnet = AF_DECnet;
-pub const PF_DLI = AF_DLI;
-pub const PF_LAT = AF_LAT;
-pub const PF_HYLINK = AF_HYLINK;
-pub const PF_APPLETALK = AF_APPLETALK;
-pub const PF_ROUTE = AF_ROUTE;
-pub const PF_LINK = AF_LINK;
-pub const PF_XTP = pseudo_AF_XTP;
-pub const PF_COIP = AF_COIP;
-pub const PF_CNT = AF_CNT;
-pub const PF_SIP = AF_SIP;
-pub const PF_IPX = AF_IPX;
-pub const PF_RTIP = pseudo_AF_RTIP;
-pub const PF_PIP = psuedo_AF_PIP;
-pub const PF_ISDN = AF_ISDN;
-pub const PF_KEY = pseudo_AF_KEY;
-pub const PF_INET6 = pseudo_AF_INET6;
-pub const PF_NATM = AF_NATM;
-pub const PF_ATM = AF_ATM;
-pub const PF_NETGRAPH = AF_NETGRAPH;
-pub const PF_SLOW = AF_SLOW;
-pub const PF_SCLUSTER = AF_SCLUSTER;
-pub const PF_ARP = AF_ARP;
-pub const PF_BLUETOOTH = AF_BLUETOOTH;
-pub const PF_IEEE80211 = AF_IEEE80211;
-pub const PF_INET_SDP = AF_INET_SDP;
-pub const PF_INET6_SDP = AF_INET6_SDP;
-pub const PF_MAX = AF_MAX;
-
-pub const AF_UNSPEC = 0;
-pub const AF_UNIX = 1;
-pub const AF_LOCAL = AF_UNIX;
-pub const AF_FILE = AF_LOCAL;
-pub const AF_INET = 2;
-pub const AF_IMPLINK = 3;
-pub const AF_PUP = 4;
-pub const AF_CHAOS = 5;
-pub const AF_NETBIOS = 6;
-pub const AF_ISO = 7;
-pub const AF_OSI = AF_ISO;
-pub const AF_ECMA = 8;
-pub const AF_DATAKIT = 9;
-pub const AF_CCITT = 10;
-pub const AF_SNA = 11;
-pub const AF_DECnet = 12;
-pub const AF_DLI = 13;
-pub const AF_LAT = 14;
-pub const AF_HYLINK = 15;
-pub const AF_APPLETALK = 16;
-pub const AF_ROUTE = 17;
-pub const AF_LINK = 18;
-pub const pseudo_AF_XTP = 19;
-pub const AF_COIP = 20;
-pub const AF_CNT = 21;
-pub const pseudo_AF_RTIP = 22;
-pub const AF_IPX = 23;
-pub const AF_SIP = 24;
-pub const pseudo_AF_PIP = 25;
-pub const AF_ISDN = 26;
-pub const AF_E164 = AF_ISDN;
-pub const pseudo_AF_KEY = 27;
-pub const AF_INET6 = 28;
-pub const AF_NATM = 29;
-pub const AF_ATM = 30;
-pub const pseudo_AF_HDRCMPLT = 31;
-pub const AF_NETGRAPH = 32;
-pub const AF_SLOW = 33;
-pub const AF_SCLUSTER = 34;
-pub const AF_ARP = 35;
-pub const AF_BLUETOOTH = 36;
-pub const AF_IEEE80211 = 37;
-pub const AF_INET_SDP = 40;
-pub const AF_INET6_SDP = 42;
-pub const AF_MAX = 42;
-
-pub const DT_UNKNOWN = 0;
-pub const DT_FIFO = 1;
-pub const DT_CHR = 2;
-pub const DT_DIR = 4;
-pub const DT_BLK = 6;
-pub const DT_REG = 8;
-pub const DT_LNK = 10;
-pub const DT_SOCK = 12;
-pub const DT_WHT = 14;
-
-/// add event to kq (implies enable)
-pub const EV_ADD = 0x0001;
-
-/// delete event from kq
-pub const EV_DELETE = 0x0002;
-
-/// enable event
-pub const EV_ENABLE = 0x0004;
-
-/// disable event (not reported)
-pub const EV_DISABLE = 0x0008;
-
-/// only report one occurrence
-pub const EV_ONESHOT = 0x0010;
-
-/// clear event state after reporting
-pub const EV_CLEAR = 0x0020;
-
-/// force immediate event output
-/// ... with or without EV_ERROR
-/// ... use KEVENT_FLAG_ERROR_EVENTS
-/// on syscalls supporting flags
-pub const EV_RECEIPT = 0x0040;
-
-/// disable event after reporting
-pub const EV_DISPATCH = 0x0080;
-
-pub const EVFILT_READ = -1;
-pub const EVFILT_WRITE = -2;
-
-/// attached to aio requests
-pub const EVFILT_AIO = -3;
-
-/// attached to vnodes
-pub const EVFILT_VNODE = -4;
-
-/// attached to struct proc
-pub const EVFILT_PROC = -5;
-
-/// attached to struct proc
-pub const EVFILT_SIGNAL = -6;
-
-/// timers
-pub const EVFILT_TIMER = -7;
-
-/// Process descriptors
-pub const EVFILT_PROCDESC = -8;
-
-/// Filesystem events
-pub const EVFILT_FS = -9;
-
-pub const EVFILT_LIO = -10;
-
-/// User events
-pub const EVFILT_USER = -11;
-
-/// Sendfile events
-pub const EVFILT_SENDFILE = -12;
-
-pub const EVFILT_EMPTY = -13;
-
-pub const TCGETA = 0x8000;
-pub const TCSETA = 0x8001;
-pub const TCSETAW = 0x8004;
-pub const TCSETAF = 0x8003;
-pub const TCSBRK = 08005;
-pub const TCXONC = 0x8007;
-pub const TCFLSH = 0x8006;
-
-pub const TIOCSCTTY = 0x8017;
-pub const TIOCGPGRP = 0x8015;
-pub const TIOCSPGRP = 0x8016;
-pub const TIOCGWINSZ = 0x8012;
-pub const TIOCSWINSZ = 0x8013;
-pub const TIOCMGET = 0x8018;
-pub const TIOCMBIS = 0x8022;
-pub const TIOCMBIC = 0x8023;
-pub const TIOCMSET = 0x8019;
-pub const FIONREAD = 0xbe000001;
-pub const FIONBIO = 0xbe000000;
-pub const TIOCSBRK = 0x8020;
-pub const TIOCCBRK = 0x8021;
-pub const TIOCGSID = 0x8024;
-
-pub fn WEXITSTATUS(s: u32) u8 {
- return @intCast(u8, s & 0xff);
-}
-
-pub fn WTERMSIG(s: u32) u32 {
- return (s >> 8) & 0xff;
-}
-
-pub fn WSTOPSIG(s: u32) u32 {
- return WEXITSTATUS(s);
-}
-
-pub fn WIFEXITED(s: u32) bool {
- return WTERMSIG(s) == 0;
-}
-
-pub fn WIFSTOPPED(s: u32) bool {
- return ((s >> 16) & 0xff) != 0;
-}
-
-pub fn WIFSIGNALED(s: u32) bool {
- return ((s >> 8) & 0xff) != 0;
-}
-
-pub const winsize = extern struct {
- ws_row: u16,
- ws_col: u16,
- ws_xpixel: u16,
- ws_ypixel: u16,
-};
-
-const NSIG = 32;
-
-pub const SIG_ERR = @intToPtr(fn (i32) callconv(.C) void, maxInt(usize));
-pub const SIG_DFL = @intToPtr(fn (i32) callconv(.C) void, 0);
-pub const SIG_IGN = @intToPtr(fn (i32) callconv(.C) void, 1);
-
-/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.
-pub const Sigaction = extern struct {
- /// signal handler
- __sigaction_u: extern union {
- __sa_handler: fn (i32) callconv(.C) void,
- __sa_sigaction: fn (i32, *__siginfo, usize) callconv(.C) void,
- },
-
- /// see signal options
- sa_flags: u32,
-
- /// signal mask to apply
- sa_mask: sigset_t,
-};
-
-pub const _SIG_WORDS = 4;
-pub const _SIG_MAXSIG = 128;
-pub inline fn _SIG_IDX(sig: usize) usize {
- return sig - 1;
-}
-pub inline fn _SIG_WORD(sig: usize) usize {
- return_SIG_IDX(sig) >> 5;
-}
-pub inline fn _SIG_BIT(sig: usize) usize {
- return 1 << (_SIG_IDX(sig) & 31);
-}
-pub inline fn _SIG_VALID(sig: usize) usize {
- return sig <= _SIG_MAXSIG and sig > 0;
-}
-
-pub const sigset_t = extern struct {
- __bits: [_SIG_WORDS]u32,
-};
-
-pub const E = enum(i32) {
- /// No error occurred.
- SUCCESS = 0,
- PERM = -0x7ffffff1, // Operation not permitted
- NOENT = -0x7fff9ffd, // No such file or directory
- SRCH = -0x7fff8ff3, // No such process
- INTR = -0x7ffffff6, // Interrupted system call
- IO = -0x7fffffff, // Input/output error
- NXIO = -0x7fff8ff5, // Device not configured
- @"2BIG" = -0x7fff8fff, // Argument list too long
- NOEXEC = -0x7fffecfe, // Exec format error
- CHILD = -0x7fff8ffe, // No child processes
- DEADLK = -0x7fff8ffd, // Resource deadlock avoided
- NOMEM = -0x80000000, // Cannot allocate memory
- ACCES = -0x7ffffffe, // Permission denied
- FAULT = -0x7fffecff, // Bad address
- BUSY = -0x7ffffff2, // Device busy
- EXIST = -0x7fff9ffe, // File exists
- XDEV = -0x7fff9ff5, // Cross-device link
- NODEV = -0x7fff8ff9, // Operation not supported by device
- NOTDIR = -0x7fff9ffb, // Not a directory
- ISDIR = -0x7fff9ff7, // Is a directory
- INVAL = -0x7ffffffb, // Invalid argument
- NFILE = -0x7fff8ffa, // Too many open files in system
- MFILE = -0x7fff9ff6, // Too many open files
- NOTTY = -0x7fff8ff6, // Inappropriate ioctl for device
- TXTBSY = -0x7fff8fc5, // Text file busy
- FBIG = -0x7fff8ffc, // File too large
- NOSPC = -0x7fff9ff9, // No space left on device
- SPIPE = -0x7fff8ff4, // Illegal seek
- ROFS = -0x7fff9ff8, // Read-only filesystem
- MLINK = -0x7fff8ffb, // Too many links
- PIPE = -0x7fff9ff3, // Broken pipe
- BADF = -0x7fffa000, // Bad file descriptor
-
- // math software
- DOM = 33, // Numerical argument out of domain
- RANGE = 34, // Result too large
-
- // non-blocking and interrupt i/o
-
- /// Also used for `WOULDBLOCK`.
- AGAIN = -0x7ffffff5,
- INPROGRESS = -0x7fff8fdc,
- ALREADY = -0x7fff8fdb,
-
- // ipc/network software -- argument errors
- NOTSOCK = 38, // Socket operation on non-socket
- DESTADDRREQ = 39, // Destination address required
- MSGSIZE = 40, // Message too long
- PROTOTYPE = 41, // Protocol wrong type for socket
- NOPROTOOPT = 42, // Protocol not available
- PROTONOSUPPORT = 43, // Protocol not supported
- SOCKTNOSUPPORT = 44, // Socket type not supported
- /// Also used for `NOTSUP`.
- OPNOTSUPP = 45, // Operation not supported
- PFNOSUPPORT = 46, // Protocol family not supported
- AFNOSUPPORT = 47, // Address family not supported by protocol family
- ADDRINUSE = 48, // Address already in use
- ADDRNOTAVAIL = 49, // Can't assign requested address
-
- // ipc/network software -- operational errors
- NETDOWN = 50, // Network is down
- NETUNREACH = 51, // Network is unreachable
- NETRESET = 52, // Network dropped connection on reset
- CONNABORTED = 53, // Software caused connection abort
- CONNRESET = 54, // Connection reset by peer
- NOBUFS = 55, // No buffer space available
- ISCONN = 56, // Socket is already connected
- NOTCONN = 57, // Socket is not connected
- SHUTDOWN = 58, // Can't send after socket shutdown
- TOOMANYREFS = 59, // Too many references: can't splice
- TIMEDOUT = 60, // Operation timed out
- CONNREFUSED = 61, // Connection refused
-
- LOOP = 62, // Too many levels of symbolic links
- NAMETOOLONG = 63, // File name too long
-
- // should be rearranged
- HOSTDOWN = 64, // Host is down
- HOSTUNREACH = 65, // No route to host
- NOTEMPTY = 66, // Directory not empty
-
- // quotas & mush
- PROCLIM = 67, // Too many processes
- USERS = 68, // Too many users
- DQUOT = 69, // Disc quota exceeded
-
- // Network File System
- STALE = 70, // Stale NFS file handle
- REMOTE = 71, // Too many levels of remote in path
- BADRPC = 72, // RPC struct is bad
- RPCMISMATCH = 73, // RPC version wrong
- PROGUNAVAIL = 74, // RPC prog. not avail
- PROGMISMATCH = 75, // Program version wrong
- PROCUNAVAIL = 76, // Bad procedure for program
-
- NOLCK = 77, // No locks available
- NOSYS = 78, // Function not implemented
-
- FTYPE = 79, // Inappropriate file type or format
- AUTH = 80, // Authentication error
- NEEDAUTH = 81, // Need authenticator
- IDRM = 82, // Identifier removed
- NOMSG = 83, // No message of desired type
- OVERFLOW = 84, // Value too large to be stored in data type
- CANCELED = 85, // Operation canceled
- ILSEQ = 86, // Illegal byte sequence
- NOATTR = 87, // Attribute not found
-
- DOOFUS = 88, // Programming error
-
- BADMSG = 89, // Bad message
- MULTIHOP = 90, // Multihop attempted
- NOLINK = 91, // Link has been severed
- PROTO = 92, // Protocol error
-
- NOTCAPABLE = 93, // Capabilities insufficient
- CAPMODE = 94, // Not permitted in capability mode
- NOTRECOVERABLE = 95, // State not recoverable
- OWNERDEAD = 96, // Previous owner died
-
- _,
-};
-
-pub const MINSIGSTKSZ = switch (builtin.cpu.arch) {
- .i386, .x86_64 => 2048,
- .arm, .aarch64 => 4096,
- else => @compileError("MINSIGSTKSZ not defined for this architecture"),
-};
-pub const SIGSTKSZ = MINSIGSTKSZ + 32768;
-
-pub const SS_ONSTACK = 1;
-pub const SS_DISABLE = 4;
-
-pub const stack_t = extern struct {
- ss_sp: [*]u8,
- ss_size: isize,
- ss_flags: i32,
-};
-
-pub const S_IFMT = 0o170000;
-
-pub const S_IFIFO = 0o010000;
-pub const S_IFCHR = 0o020000;
-pub const S_IFDIR = 0o040000;
-pub const S_IFBLK = 0o060000;
-pub const S_IFREG = 0o100000;
-pub const S_IFLNK = 0o120000;
-pub const S_IFSOCK = 0o140000;
-pub const S_IFWHT = 0o160000;
-
-pub const S_ISUID = 0o4000;
-pub const S_ISGID = 0o2000;
-pub const S_ISVTX = 0o1000;
-pub const S_IRWXU = 0o700;
-pub const S_IRUSR = 0o400;
-pub const S_IWUSR = 0o200;
-pub const S_IXUSR = 0o100;
-pub const S_IRWXG = 0o070;
-pub const S_IRGRP = 0o040;
-pub const S_IWGRP = 0o020;
-pub const S_IXGRP = 0o010;
-pub const S_IRWXO = 0o007;
-pub const S_IROTH = 0o004;
-pub const S_IWOTH = 0o002;
-pub const S_IXOTH = 0o001;
-
-pub fn S_ISFIFO(m: u32) bool {
- return m & S_IFMT == S_IFIFO;
-}
-
-pub fn S_ISCHR(m: u32) bool {
- return m & S_IFMT == S_IFCHR;
-}
-
-pub fn S_ISDIR(m: u32) bool {
- return m & S_IFMT == S_IFDIR;
-}
-
-pub fn S_ISBLK(m: u32) bool {
- return m & S_IFMT == S_IFBLK;
-}
-
-pub fn S_ISREG(m: u32) bool {
- return m & S_IFMT == S_IFREG;
-}
-
-pub fn S_ISLNK(m: u32) bool {
- return m & S_IFMT == S_IFLNK;
-}
-
-pub fn S_ISSOCK(m: u32) bool {
- return m & S_IFMT == S_IFSOCK;
-}
-
-pub fn S_IWHT(m: u32) bool {
- return m & S_IFMT == S_IFWHT;
-}
-
-pub const HOST_NAME_MAX = 255;
-
-/// Magic value that specify the use of the current working directory
-/// to determine the target of relative file paths in the openat() and
-/// similar syscalls.
-pub const AT_FDCWD = -100;
-
-/// Check access using effective user and group ID
-pub const AT_EACCESS = 0x0100;
-
-/// Do not follow symbolic links
-pub const AT_SYMLINK_NOFOLLOW = 0x0200;
-
-/// Follow symbolic link
-pub const AT_SYMLINK_FOLLOW = 0x0400;
-
-/// Remove directory instead of file
-pub const AT_REMOVEDIR = 0x0800;
-
-pub const addrinfo = extern struct {
- flags: i32,
- family: i32,
- socktype: i32,
- protocol: i32,
- addrlen: socklen_t,
- canonname: ?[*:0]u8,
- addr: ?*sockaddr,
- next: ?*addrinfo,
-};
-
-/// Fail if not under dirfd
-pub const AT_BENEATH = 0x1000;
-
-/// dummy for IP
-pub const IPPROTO_IP = 0;
-
-/// control message protocol
-pub const IPPROTO_ICMP = 1;
-
-/// tcp
-pub const IPPROTO_TCP = 6;
-
-/// user datagram protocol
-pub const IPPROTO_UDP = 17;
-
-/// IP6 header
-pub const IPPROTO_IPV6 = 41;
-
-/// raw IP packet
-pub const IPPROTO_RAW = 255;
-
-/// IP6 hop-by-hop options
-pub const IPPROTO_HOPOPTS = 0;
-
-/// group mgmt protocol
-pub const IPPROTO_IGMP = 2;
-
-/// gateway^2 (deprecated)
-pub const IPPROTO_GGP = 3;
-
-/// IPv4 encapsulation
-pub const IPPROTO_IPV4 = 4;
-
-/// for compatibility
-pub const IPPROTO_IPIP = IPPROTO_IPV4;
-
-/// Stream protocol II
-pub const IPPROTO_ST = 7;
-
-/// exterior gateway protocol
-pub const IPPROTO_EGP = 8;
-
-/// private interior gateway
-pub const IPPROTO_PIGP = 9;
-
-/// BBN RCC Monitoring
-pub const IPPROTO_RCCMON = 10;
-
-/// network voice protocol
-pub const IPPROTO_NVPII = 11;
-
-/// pup
-pub const IPPROTO_PUP = 12;
-
-/// Argus
-pub const IPPROTO_ARGUS = 13;
-
-/// EMCON
-pub const IPPROTO_EMCON = 14;
-
-/// Cross Net Debugger
-pub const IPPROTO_XNET = 15;
-
-/// Chaos
-pub const IPPROTO_CHAOS = 16;
-
-/// Multiplexing
-pub const IPPROTO_MUX = 18;
-
-/// DCN Measurement Subsystems
-pub const IPPROTO_MEAS = 19;
-
-/// Host Monitoring
-pub const IPPROTO_HMP = 20;
-
-/// Packet Radio Measurement
-pub const IPPROTO_PRM = 21;
-
-/// xns idp
-pub const IPPROTO_IDP = 22;
-
-/// Trunk-1
-pub const IPPROTO_TRUNK1 = 23;
-
-/// Trunk-2
-pub const IPPROTO_TRUNK2 = 24;
-
-/// Leaf-1
-pub const IPPROTO_LEAF1 = 25;
-
-/// Leaf-2
-pub const IPPROTO_LEAF2 = 26;
-
-/// Reliable Data
-pub const IPPROTO_RDP = 27;
-
-/// Reliable Transaction
-pub const IPPROTO_IRTP = 28;
-
-/// tp-4 w/ class negotiation
-pub const IPPROTO_TP = 29;
-
-/// Bulk Data Transfer
-pub const IPPROTO_BLT = 30;
-
-/// Network Services
-pub const IPPROTO_NSP = 31;
-
-/// Merit Internodal
-pub const IPPROTO_INP = 32;
-
-/// Datagram Congestion Control Protocol
-pub const IPPROTO_DCCP = 33;
-
-/// Third Party Connect
-pub const IPPROTO_3PC = 34;
-
-/// InterDomain Policy Routing
-pub const IPPROTO_IDPR = 35;
-
-/// XTP
-pub const IPPROTO_XTP = 36;
-
-/// Datagram Delivery
-pub const IPPROTO_DDP = 37;
-
-/// Control Message Transport
-pub const IPPROTO_CMTP = 38;
-
-/// TP++ Transport
-pub const IPPROTO_TPXX = 39;
-
-/// IL transport protocol
-pub const IPPROTO_IL = 40;
-
-/// Source Demand Routing
-pub const IPPROTO_SDRP = 42;
-
-/// IP6 routing header
-pub const IPPROTO_ROUTING = 43;
-
-/// IP6 fragmentation header
-pub const IPPROTO_FRAGMENT = 44;
-
-/// InterDomain Routing
-pub const IPPROTO_IDRP = 45;
-
-/// resource reservation
-pub const IPPROTO_RSVP = 46;
-
-/// General Routing Encap.
-pub const IPPROTO_GRE = 47;
-
-/// Mobile Host Routing
-pub const IPPROTO_MHRP = 48;
-
-/// BHA
-pub const IPPROTO_BHA = 49;
-
-/// IP6 Encap Sec. Payload
-pub const IPPROTO_ESP = 50;
-
-/// IP6 Auth Header
-pub const IPPROTO_AH = 51;
-
-/// Integ. Net Layer Security
-pub const IPPROTO_INLSP = 52;
-
-/// IP with encryption
-pub const IPPROTO_SWIPE = 53;
-
-/// Next Hop Resolution
-pub const IPPROTO_NHRP = 54;
-
-/// IP Mobility
-pub const IPPROTO_MOBILE = 55;
-
-/// Transport Layer Security
-pub const IPPROTO_TLSP = 56;
-
-/// SKIP
-pub const IPPROTO_SKIP = 57;
-
-/// ICMP6
-pub const IPPROTO_ICMPV6 = 58;
-
-/// IP6 no next header
-pub const IPPROTO_NONE = 59;
-
-/// IP6 destination option
-pub const IPPROTO_DSTOPTS = 60;
-
-/// any host internal protocol
-pub const IPPROTO_AHIP = 61;
-
-/// CFTP
-pub const IPPROTO_CFTP = 62;
-
-/// "hello" routing protocol
-pub const IPPROTO_HELLO = 63;
-
-/// SATNET/Backroom EXPAK
-pub const IPPROTO_SATEXPAK = 64;
-
-/// Kryptolan
-pub const IPPROTO_KRYPTOLAN = 65;
-
-/// Remote Virtual Disk
-pub const IPPROTO_RVD = 66;
-
-/// Pluribus Packet Core
-pub const IPPROTO_IPPC = 67;
-
-/// Any distributed FS
-pub const IPPROTO_ADFS = 68;
-
-/// Satnet Monitoring
-pub const IPPROTO_SATMON = 69;
-
-/// VISA Protocol
-pub const IPPROTO_VISA = 70;
-
-/// Packet Core Utility
-pub const IPPROTO_IPCV = 71;
-
-/// Comp. Prot. Net. Executive
-pub const IPPROTO_CPNX = 72;
-
-/// Comp. Prot. HeartBeat
-pub const IPPROTO_CPHB = 73;
-
-/// Wang Span Network
-pub const IPPROTO_WSN = 74;
-
-/// Packet Video Protocol
-pub const IPPROTO_PVP = 75;
-
-/// BackRoom SATNET Monitoring
-pub const IPPROTO_BRSATMON = 76;
-
-/// Sun net disk proto (temp.)
-pub const IPPROTO_ND = 77;
-
-/// WIDEBAND Monitoring
-pub const IPPROTO_WBMON = 78;
-
-/// WIDEBAND EXPAK
-pub const IPPROTO_WBEXPAK = 79;
-
-/// ISO cnlp
-pub const IPPROTO_EON = 80;
-
-/// VMTP
-pub const IPPROTO_VMTP = 81;
-
-/// Secure VMTP
-pub const IPPROTO_SVMTP = 82;
-
-/// Banyon VINES
-pub const IPPROTO_VINES = 83;
-
-/// TTP
-pub const IPPROTO_TTP = 84;
-
-/// NSFNET-IGP
-pub const IPPROTO_IGP = 85;
-
-/// dissimilar gateway prot.
-pub const IPPROTO_DGP = 86;
-
-/// TCF
-pub const IPPROTO_TCF = 87;
-
-/// Cisco/GXS IGRP
-pub const IPPROTO_IGRP = 88;
-
-/// OSPFIGP
-pub const IPPROTO_OSPFIGP = 89;
-
-/// Strite RPC protocol
-pub const IPPROTO_SRPC = 90;
-
-/// Locus Address Resoloution
-pub const IPPROTO_LARP = 91;
-
-/// Multicast Transport
-pub const IPPROTO_MTP = 92;
-
-/// AX.25 Frames
-pub const IPPROTO_AX25 = 93;
-
-/// IP encapsulated in IP
-pub const IPPROTO_IPEIP = 94;
-
-/// Mobile Int.ing control
-pub const IPPROTO_MICP = 95;
-
-/// Semaphore Comm. security
-pub const IPPROTO_SCCSP = 96;
-
-/// Ethernet IP encapsulation
-pub const IPPROTO_ETHERIP = 97;
-
-/// encapsulation header
-pub const IPPROTO_ENCAP = 98;
-
-/// any private encr. scheme
-pub const IPPROTO_APES = 99;
-
-/// GMTP
-pub const IPPROTO_GMTP = 100;
-
-/// payload compression (IPComp)
-pub const IPPROTO_IPCOMP = 108;
-
-/// SCTP
-pub const IPPROTO_SCTP = 132;
-
-/// IPv6 Mobility Header
-pub const IPPROTO_MH = 135;
-
-/// UDP-Lite
-pub const IPPROTO_UDPLITE = 136;
-
-/// IP6 Host Identity Protocol
-pub const IPPROTO_HIP = 139;
-
-/// IP6 Shim6 Protocol
-pub const IPPROTO_SHIM6 = 140;
-
-/// Protocol Independent Mcast
-pub const IPPROTO_PIM = 103;
-
-/// CARP
-pub const IPPROTO_CARP = 112;
-
-/// PGM
-pub const IPPROTO_PGM = 113;
-
-/// MPLS-in-IP
-pub const IPPROTO_MPLS = 137;
-
-/// PFSYNC
-pub const IPPROTO_PFSYNC = 240;
-
-/// Reserved
-pub const IPPROTO_RESERVED_253 = 253;
-
-/// Reserved
-pub const IPPROTO_RESERVED_254 = 254;
-
-pub const rlimit_resource = enum(c_int) {
- CPU = 0,
- FSIZE = 1,
- DATA = 2,
- STACK = 3,
- CORE = 4,
- RSS = 5,
- MEMLOCK = 6,
- NPROC = 7,
- NOFILE = 8,
- SBSIZE = 9,
- VMEM = 10,
- NPTS = 11,
- SWAP = 12,
- KQUEUES = 13,
- UMTXP = 14,
- _,
-
- pub const AS: rlimit_resource = .VMEM;
-};
-
-pub const rlim_t = i64;
-
-/// No limit
-pub const RLIM_INFINITY: rlim_t = (1 << 63) - 1;
-
-pub const RLIM_SAVED_MAX = RLIM_INFINITY;
-pub const RLIM_SAVED_CUR = RLIM_INFINITY;
-
-pub const rlimit = extern struct {
- /// Soft limit
- cur: rlim_t,
- /// Hard limit
- max: rlim_t,
-};
-
-pub const SHUT_RD = 0;
-pub const SHUT_WR = 1;
-pub const SHUT_RDWR = 2;
-
-// TODO fill out if needed
-pub const directory_which = enum(c_int) {
- B_USER_SETTINGS_DIRECTORY = 0xbbe,
-
- _,
-};
-
-pub const cc_t = u8;
-pub const speed_t = u8;
-pub const tcflag_t = u32;
-
-pub const NCCS = 32;
-
-pub const termios = extern struct {
- c_iflag: tcflag_t,
- c_oflag: tcflag_t,
- c_cflag: tcflag_t,
- c_lflag: tcflag_t,
- c_line: cc_t,
- c_ispeed: speed_t,
- c_ospeed: speed_t,
- cc_t: [NCCS]cc_t,
-};
diff --git a/lib/std/os/bits/linux.zig b/lib/std/os/bits/linux.zig
deleted file mode 100644
index dfc2b5065c11..000000000000
--- a/lib/std/os/bits/linux.zig
+++ /dev/null
@@ -1,2455 +0,0 @@
-const std = @import("../../std.zig");
-const maxInt = std.math.maxInt;
-const arch = @import("builtin").target.cpu.arch;
-pub usingnamespace @import("posix.zig");
-
-pub const E = switch (arch) {
- .mips, .mipsel => @import("linux/errno/mips.zig").E,
- .sparc, .sparcel, .sparcv9 => @import("linux/errno/sparc.zig").E,
- else => @import("linux/errno/generic.zig").E,
-};
-
-pub usingnamespace switch (arch) {
- .i386 => @import("linux/i386.zig"),
- .x86_64 => @import("linux/x86_64.zig"),
- .aarch64 => @import("linux/arm64.zig"),
- .arm, .thumb => @import("linux/arm-eabi.zig"),
- .riscv64 => @import("linux/riscv64.zig"),
- .sparcv9 => @import("linux/sparc64.zig"),
- .mips, .mipsel => @import("linux/mips.zig"),
- .powerpc => @import("linux/powerpc.zig"),
- .powerpc64, .powerpc64le => @import("linux/powerpc64.zig"),
- else => struct {},
-};
-
-pub usingnamespace @import("linux/netlink.zig");
-pub usingnamespace @import("linux/prctl.zig");
-pub usingnamespace @import("linux/securebits.zig");
-pub usingnamespace @import("linux/xdp.zig");
-
-const is_mips = arch.isMIPS();
-const is_ppc = arch.isPPC();
-const is_ppc64 = arch.isPPC64();
-const is_sparc = arch.isSPARC();
-
-pub const pid_t = i32;
-pub const fd_t = i32;
-pub const uid_t = u32;
-pub const gid_t = u32;
-pub const clock_t = isize;
-
-pub const NAME_MAX = 255;
-pub const PATH_MAX = 4096;
-pub const IOV_MAX = 1024;
-
-/// Largest hardware address length
-/// e.g. a mac address is a type of hardware address
-pub const MAX_ADDR_LEN = 32;
-
-pub const STDIN_FILENO = 0;
-pub const STDOUT_FILENO = 1;
-pub const STDERR_FILENO = 2;
-
-/// Special value used to indicate openat should use the current working directory
-pub const AT_FDCWD = -100;
-
-/// Do not follow symbolic links
-pub const AT_SYMLINK_NOFOLLOW = 0x100;
-
-/// Remove directory instead of unlinking file
-pub const AT_REMOVEDIR = 0x200;
-
-/// Follow symbolic links.
-pub const AT_SYMLINK_FOLLOW = 0x400;
-
-/// Suppress terminal automount traversal
-pub const AT_NO_AUTOMOUNT = 0x800;
-
-/// Allow empty relative pathname
-pub const AT_EMPTY_PATH = 0x1000;
-
-/// Type of synchronisation required from statx()
-pub const AT_STATX_SYNC_TYPE = 0x6000;
-
-/// - Do whatever stat() does
-pub const AT_STATX_SYNC_AS_STAT = 0x0000;
-
-/// - Force the attributes to be sync'd with the server
-pub const AT_STATX_FORCE_SYNC = 0x2000;
-
-/// - Don't sync attributes with the server
-pub const AT_STATX_DONT_SYNC = 0x4000;
-
-/// Apply to the entire subtree
-pub const AT_RECURSIVE = 0x8000;
-
-/// Default is extend size
-pub const FALLOC_FL_KEEP_SIZE = 0x01;
-
-/// De-allocates range
-pub const FALLOC_FL_PUNCH_HOLE = 0x02;
-
-/// Reserved codepoint
-pub const FALLOC_FL_NO_HIDE_STALE = 0x04;
-
-/// Removes a range of a file without leaving a hole in the file
-pub const FALLOC_FL_COLLAPSE_RANGE = 0x08;
-
-/// Converts a range of file to zeros preferably without issuing data IO
-pub const FALLOC_FL_ZERO_RANGE = 0x10;
-
-/// Inserts space within the file size without overwriting any existing data
-pub const FALLOC_FL_INSERT_RANGE = 0x20;
-
-/// Unshares shared blocks within the file size without overwriting any existing data
-pub const FALLOC_FL_UNSHARE_RANGE = 0x40;
-
-pub const FUTEX_WAIT = 0;
-pub const FUTEX_WAKE = 1;
-pub const FUTEX_FD = 2;
-pub const FUTEX_REQUEUE = 3;
-pub const FUTEX_CMP_REQUEUE = 4;
-pub const FUTEX_WAKE_OP = 5;
-pub const FUTEX_LOCK_PI = 6;
-pub const FUTEX_UNLOCK_PI = 7;
-pub const FUTEX_TRYLOCK_PI = 8;
-pub const FUTEX_WAIT_BITSET = 9;
-pub const FUTEX_WAKE_BITSET = 10;
-pub const FUTEX_WAIT_REQUEUE_PI = 11;
-pub const FUTEX_CMP_REQUEUE_PI = 12;
-
-pub const FUTEX_PRIVATE_FLAG = 128;
-
-pub const FUTEX_CLOCK_REALTIME = 256;
-
-/// page can not be accessed
-pub const PROT_NONE = 0x0;
-
-/// page can be read
-pub const PROT_READ = 0x1;
-
-/// page can be written
-pub const PROT_WRITE = 0x2;
-
-/// page can be executed
-pub const PROT_EXEC = 0x4;
-
-/// page may be used for atomic ops
-pub const PROT_SEM = switch (arch) {
- // TODO: also xtensa
- .mips, .mipsel, .mips64, .mips64el => 0x10,
- else => 0x8,
-};
-
-/// mprotect flag: extend change to start of growsdown vma
-pub const PROT_GROWSDOWN = 0x01000000;
-
-/// mprotect flag: extend change to end of growsup vma
-pub const PROT_GROWSUP = 0x02000000;
-
-/// Share changes
-pub const MAP_SHARED = 0x01;
-
-/// Changes are private
-pub const MAP_PRIVATE = 0x02;
-
-/// share + validate extension flags
-pub const MAP_SHARED_VALIDATE = 0x03;
-
-/// Mask for type of mapping
-pub const MAP_TYPE = 0x0f;
-
-/// Interpret addr exactly
-pub const MAP_FIXED = 0x10;
-
-/// don't use a file
-pub const MAP_ANONYMOUS = if (is_mips) 0x800 else 0x20;
-
-// MAP_ 0x0100 - 0x4000 flags are per architecture
-
-/// populate (prefault) pagetables
-pub const MAP_POPULATE = if (is_mips) 0x10000 else 0x8000;
-
-/// do not block on IO
-pub const MAP_NONBLOCK = if (is_mips) 0x20000 else 0x10000;
-
-/// give out an address that is best suited for process/thread stacks
-pub const MAP_STACK = if (is_mips) 0x40000 else 0x20000;
-
-/// create a huge page mapping
-pub const MAP_HUGETLB = if (is_mips) 0x80000 else 0x40000;
-
-/// perform synchronous page faults for the mapping
-pub const MAP_SYNC = 0x80000;
-
-/// MAP_FIXED which doesn't unmap underlying mapping
-pub const MAP_FIXED_NOREPLACE = 0x100000;
-
-/// For anonymous mmap, memory could be uninitialized
-pub const MAP_UNINITIALIZED = 0x4000000;
-
-pub const FD_CLOEXEC = 1;
-
-pub const F_OK = 0;
-pub const X_OK = 1;
-pub const W_OK = 2;
-pub const R_OK = 4;
-
-pub const WNOHANG = 1;
-pub const WUNTRACED = 2;
-pub const WSTOPPED = 2;
-pub const WEXITED = 4;
-pub const WCONTINUED = 8;
-pub const WNOWAIT = 0x1000000;
-
-// waitid id types
-pub const P = enum(c_uint) {
- ALL = 0,
- PID = 1,
- PGID = 2,
- PIDFD = 3,
- _,
-};
-
-pub usingnamespace if (is_mips)
- struct {
- pub const SA_NOCLDSTOP = 1;
- pub const SA_NOCLDWAIT = 0x10000;
- pub const SA_SIGINFO = 8;
- pub const SA_RESTART = 0x10000000;
- pub const SA_RESETHAND = 0x80000000;
- pub const SA_ONSTACK = 0x08000000;
- pub const SA_NODEFER = 0x40000000;
- pub const SA_RESTORER = 0x04000000;
-
- pub const SIG_BLOCK = 1;
- pub const SIG_UNBLOCK = 2;
- pub const SIG_SETMASK = 3;
- }
-else if (is_sparc)
- struct {
- pub const SA_NOCLDSTOP = 0x8;
- pub const SA_NOCLDWAIT = 0x100;
- pub const SA_SIGINFO = 0x200;
- pub const SA_RESTART = 0x2;
- pub const SA_RESETHAND = 0x4;
- pub const SA_ONSTACK = 0x1;
- pub const SA_NODEFER = 0x20;
- pub const SA_RESTORER = 0x04000000;
-
- pub const SIG_BLOCK = 1;
- pub const SIG_UNBLOCK = 2;
- pub const SIG_SETMASK = 4;
- }
-else
- struct {
- pub const SA_NOCLDSTOP = 1;
- pub const SA_NOCLDWAIT = 2;
- pub const SA_SIGINFO = 4;
- pub const SA_RESTART = 0x10000000;
- pub const SA_RESETHAND = 0x80000000;
- pub const SA_ONSTACK = 0x08000000;
- pub const SA_NODEFER = 0x40000000;
- pub const SA_RESTORER = 0x04000000;
-
- pub const SIG_BLOCK = 0;
- pub const SIG_UNBLOCK = 1;
- pub const SIG_SETMASK = 2;
- };
-
-pub usingnamespace if (is_sparc) struct {
- pub const SIGHUP = 1;
- pub const SIGINT = 2;
- pub const SIGQUIT = 3;
- pub const SIGILL = 4;
- pub const SIGTRAP = 5;
- pub const SIGABRT = 6;
- pub const SIGEMT = 7;
- pub const SIGFPE = 8;
- pub const SIGKILL = 9;
- pub const SIGBUS = 10;
- pub const SIGSEGV = 11;
- pub const SIGSYS = 12;
- pub const SIGPIPE = 13;
- pub const SIGALRM = 14;
- pub const SIGTERM = 15;
- pub const SIGURG = 16;
- pub const SIGSTOP = 17;
- pub const SIGTSTP = 18;
- pub const SIGCONT = 19;
- pub const SIGCHLD = 20;
- pub const SIGTTIN = 21;
- pub const SIGTTOU = 22;
- pub const SIGPOLL = 23;
- pub const SIGXCPU = 24;
- pub const SIGXFSZ = 25;
- pub const SIGVTALRM = 26;
- pub const SIGPROF = 27;
- pub const SIGWINCH = 28;
- pub const SIGLOST = 29;
- pub const SIGUSR1 = 30;
- pub const SIGUSR2 = 31;
- pub const SIGIOT = SIGABRT;
- pub const SIGCLD = SIGCHLD;
- pub const SIGPWR = SIGLOST;
- pub const SIGIO = SIGPOLL;
-} else struct {
- pub const SIGHUP = 1;
- pub const SIGINT = 2;
- pub const SIGQUIT = 3;
- pub const SIGILL = 4;
- pub const SIGTRAP = 5;
- pub const SIGABRT = 6;
- pub const SIGIOT = SIGABRT;
- pub const SIGBUS = 7;
- pub const SIGFPE = 8;
- pub const SIGKILL = 9;
- pub const SIGUSR1 = 10;
- pub const SIGSEGV = 11;
- pub const SIGUSR2 = 12;
- pub const SIGPIPE = 13;
- pub const SIGALRM = 14;
- pub const SIGTERM = 15;
- pub const SIGSTKFLT = 16;
- pub const SIGCHLD = 17;
- pub const SIGCONT = 18;
- pub const SIGSTOP = 19;
- pub const SIGTSTP = 20;
- pub const SIGTTIN = 21;
- pub const SIGTTOU = 22;
- pub const SIGURG = 23;
- pub const SIGXCPU = 24;
- pub const SIGXFSZ = 25;
- pub const SIGVTALRM = 26;
- pub const SIGPROF = 27;
- pub const SIGWINCH = 28;
- pub const SIGIO = 29;
- pub const SIGPOLL = 29;
- pub const SIGPWR = 30;
- pub const SIGSYS = 31;
- pub const SIGUNUSED = SIGSYS;
-};
-
-pub const O_RDONLY = 0o0;
-pub const O_WRONLY = 0o1;
-pub const O_RDWR = 0o2;
-
-pub const kernel_rwf = u32;
-
-/// high priority request, poll if possible
-pub const RWF_HIPRI: kernel_rwf = 0x00000001;
-
-/// per-IO O_DSYNC
-pub const RWF_DSYNC: kernel_rwf = 0x00000002;
-
-/// per-IO O_SYNC
-pub const RWF_SYNC: kernel_rwf = 0x00000004;
-
-/// per-IO, return -EAGAIN if operation would block
-pub const RWF_NOWAIT: kernel_rwf = 0x00000008;
-
-/// per-IO O_APPEND
-pub const RWF_APPEND: kernel_rwf = 0x00000010;
-
-pub const SEEK_SET = 0;
-pub const SEEK_CUR = 1;
-pub const SEEK_END = 2;
-
-pub const SHUT_RD = 0;
-pub const SHUT_WR = 1;
-pub const SHUT_RDWR = 2;
-
-pub const SOCK_STREAM = if (is_mips) 2 else 1;
-pub const SOCK_DGRAM = if (is_mips) 1 else 2;
-pub const SOCK_RAW = 3;
-pub const SOCK_RDM = 4;
-pub const SOCK_SEQPACKET = 5;
-pub const SOCK_DCCP = 6;
-pub const SOCK_PACKET = 10;
-pub const SOCK_CLOEXEC = 0o2000000;
-pub const SOCK_NONBLOCK = if (is_mips) 0o200 else 0o4000;
-
-pub const PF_UNSPEC = 0;
-pub const PF_LOCAL = 1;
-pub const PF_UNIX = PF_LOCAL;
-pub const PF_FILE = PF_LOCAL;
-pub const PF_INET = 2;
-pub const PF_AX25 = 3;
-pub const PF_IPX = 4;
-pub const PF_APPLETALK = 5;
-pub const PF_NETROM = 6;
-pub const PF_BRIDGE = 7;
-pub const PF_ATMPVC = 8;
-pub const PF_X25 = 9;
-pub const PF_INET6 = 10;
-pub const PF_ROSE = 11;
-pub const PF_DECnet = 12;
-pub const PF_NETBEUI = 13;
-pub const PF_SECURITY = 14;
-pub const PF_KEY = 15;
-pub const PF_NETLINK = 16;
-pub const PF_ROUTE = PF_NETLINK;
-pub const PF_PACKET = 17;
-pub const PF_ASH = 18;
-pub const PF_ECONET = 19;
-pub const PF_ATMSVC = 20;
-pub const PF_RDS = 21;
-pub const PF_SNA = 22;
-pub const PF_IRDA = 23;
-pub const PF_PPPOX = 24;
-pub const PF_WANPIPE = 25;
-pub const PF_LLC = 26;
-pub const PF_IB = 27;
-pub const PF_MPLS = 28;
-pub const PF_CAN = 29;
-pub const PF_TIPC = 30;
-pub const PF_BLUETOOTH = 31;
-pub const PF_IUCV = 32;
-pub const PF_RXRPC = 33;
-pub const PF_ISDN = 34;
-pub const PF_PHONET = 35;
-pub const PF_IEEE802154 = 36;
-pub const PF_CAIF = 37;
-pub const PF_ALG = 38;
-pub const PF_NFC = 39;
-pub const PF_VSOCK = 40;
-pub const PF_KCM = 41;
-pub const PF_QIPCRTR = 42;
-pub const PF_SMC = 43;
-pub const PF_XDP = 44;
-pub const PF_MAX = 45;
-
-pub const AF_UNSPEC = PF_UNSPEC;
-pub const AF_LOCAL = PF_LOCAL;
-pub const AF_UNIX = AF_LOCAL;
-pub const AF_FILE = AF_LOCAL;
-pub const AF_INET = PF_INET;
-pub const AF_AX25 = PF_AX25;
-pub const AF_IPX = PF_IPX;
-pub const AF_APPLETALK = PF_APPLETALK;
-pub const AF_NETROM = PF_NETROM;
-pub const AF_BRIDGE = PF_BRIDGE;
-pub const AF_ATMPVC = PF_ATMPVC;
-pub const AF_X25 = PF_X25;
-pub const AF_INET6 = PF_INET6;
-pub const AF_ROSE = PF_ROSE;
-pub const AF_DECnet = PF_DECnet;
-pub const AF_NETBEUI = PF_NETBEUI;
-pub const AF_SECURITY = PF_SECURITY;
-pub const AF_KEY = PF_KEY;
-pub const AF_NETLINK = PF_NETLINK;
-pub const AF_ROUTE = PF_ROUTE;
-pub const AF_PACKET = PF_PACKET;
-pub const AF_ASH = PF_ASH;
-pub const AF_ECONET = PF_ECONET;
-pub const AF_ATMSVC = PF_ATMSVC;
-pub const AF_RDS = PF_RDS;
-pub const AF_SNA = PF_SNA;
-pub const AF_IRDA = PF_IRDA;
-pub const AF_PPPOX = PF_PPPOX;
-pub const AF_WANPIPE = PF_WANPIPE;
-pub const AF_LLC = PF_LLC;
-pub const AF_IB = PF_IB;
-pub const AF_MPLS = PF_MPLS;
-pub const AF_CAN = PF_CAN;
-pub const AF_TIPC = PF_TIPC;
-pub const AF_BLUETOOTH = PF_BLUETOOTH;
-pub const AF_IUCV = PF_IUCV;
-pub const AF_RXRPC = PF_RXRPC;
-pub const AF_ISDN = PF_ISDN;
-pub const AF_PHONET = PF_PHONET;
-pub const AF_IEEE802154 = PF_IEEE802154;
-pub const AF_CAIF = PF_CAIF;
-pub const AF_ALG = PF_ALG;
-pub const AF_NFC = PF_NFC;
-pub const AF_VSOCK = PF_VSOCK;
-pub const AF_KCM = PF_KCM;
-pub const AF_QIPCRTR = PF_QIPCRTR;
-pub const AF_SMC = PF_SMC;
-pub const AF_XDP = PF_XDP;
-pub const AF_MAX = PF_MAX;
-
-pub usingnamespace if (is_mips)
- struct {}
-else if (is_ppc or is_ppc64)
- struct {
- pub const SO_DEBUG = 1;
- pub const SO_REUSEADDR = 2;
- pub const SO_TYPE = 3;
- pub const SO_ERROR = 4;
- pub const SO_DONTROUTE = 5;
- pub const SO_BROADCAST = 6;
- pub const SO_SNDBUF = 7;
- pub const SO_RCVBUF = 8;
- pub const SO_KEEPALIVE = 9;
- pub const SO_OOBINLINE = 10;
- pub const SO_NO_CHECK = 11;
- pub const SO_PRIORITY = 12;
- pub const SO_LINGER = 13;
- pub const SO_BSDCOMPAT = 14;
- pub const SO_REUSEPORT = 15;
- pub const SO_RCVLOWAT = 16;
- pub const SO_SNDLOWAT = 17;
- pub const SO_RCVTIMEO = 18;
- pub const SO_SNDTIMEO = 19;
- pub const SO_PASSCRED = 20;
- pub const SO_PEERCRED = 21;
- pub const SO_ACCEPTCONN = 30;
- pub const SO_PEERSEC = 31;
- pub const SO_SNDBUFFORCE = 32;
- pub const SO_RCVBUFFORCE = 33;
- pub const SO_PROTOCOL = 38;
- pub const SO_DOMAIN = 39;
- }
-else
- struct {
- pub const SO_DEBUG = 1;
- pub const SO_REUSEADDR = 2;
- pub const SO_TYPE = 3;
- pub const SO_ERROR = 4;
- pub const SO_DONTROUTE = 5;
- pub const SO_BROADCAST = 6;
- pub const SO_SNDBUF = 7;
- pub const SO_RCVBUF = 8;
- pub const SO_KEEPALIVE = 9;
- pub const SO_OOBINLINE = 10;
- pub const SO_NO_CHECK = 11;
- pub const SO_PRIORITY = 12;
- pub const SO_LINGER = 13;
- pub const SO_BSDCOMPAT = 14;
- pub const SO_REUSEPORT = 15;
- pub const SO_PASSCRED = 16;
- pub const SO_PEERCRED = 17;
- pub const SO_RCVLOWAT = 18;
- pub const SO_SNDLOWAT = 19;
- pub const SO_RCVTIMEO = 20;
- pub const SO_SNDTIMEO = 21;
- pub const SO_ACCEPTCONN = 30;
- pub const SO_PEERSEC = 31;
- pub const SO_SNDBUFFORCE = 32;
- pub const SO_RCVBUFFORCE = 33;
- pub const SO_PROTOCOL = 38;
- pub const SO_DOMAIN = 39;
- };
-
-pub const SO_SECURITY_AUTHENTICATION = 22;
-pub const SO_SECURITY_ENCRYPTION_TRANSPORT = 23;
-pub const SO_SECURITY_ENCRYPTION_NETWORK = 24;
-
-pub const SO_BINDTODEVICE = 25;
-
-pub const SO_ATTACH_FILTER = 26;
-pub const SO_DETACH_FILTER = 27;
-pub const SO_GET_FILTER = SO_ATTACH_FILTER;
-
-pub const SO_PEERNAME = 28;
-pub const SO_TIMESTAMP_OLD = 29;
-pub const SO_PASSSEC = 34;
-pub const SO_TIMESTAMPNS_OLD = 35;
-pub const SO_MARK = 36;
-pub const SO_TIMESTAMPING_OLD = 37;
-
-pub const SO_RXQ_OVFL = 40;
-pub const SO_WIFI_STATUS = 41;
-pub const SCM_WIFI_STATUS = SO_WIFI_STATUS;
-pub const SO_PEEK_OFF = 42;
-pub const SO_NOFCS = 43;
-pub const SO_LOCK_FILTER = 44;
-pub const SO_SELECT_ERR_QUEUE = 45;
-pub const SO_BUSY_POLL = 46;
-pub const SO_MAX_PACING_RATE = 47;
-pub const SO_BPF_EXTENSIONS = 48;
-pub const SO_INCOMING_CPU = 49;
-pub const SO_ATTACH_BPF = 50;
-pub const SO_DETACH_BPF = SO_DETACH_FILTER;
-pub const SO_ATTACH_REUSEPORT_CBPF = 51;
-pub const SO_ATTACH_REUSEPORT_EBPF = 52;
-pub const SO_CNX_ADVICE = 53;
-pub const SCM_TIMESTAMPING_OPT_STATS = 54;
-pub const SO_MEMINFO = 55;
-pub const SO_INCOMING_NAPI_ID = 56;
-pub const SO_COOKIE = 57;
-pub const SCM_TIMESTAMPING_PKTINFO = 58;
-pub const SO_PEERGROUPS = 59;
-pub const SO_ZEROCOPY = 60;
-pub const SO_TXTIME = 61;
-pub const SCM_TXTIME = SO_TXTIME;
-pub const SO_BINDTOIFINDEX = 62;
-pub const SO_TIMESTAMP_NEW = 63;
-pub const SO_TIMESTAMPNS_NEW = 64;
-pub const SO_TIMESTAMPING_NEW = 65;
-pub const SO_RCVTIMEO_NEW = 66;
-pub const SO_SNDTIMEO_NEW = 67;
-pub const SO_DETACH_REUSEPORT_BPF = 68;
-
-pub const SOL_SOCKET = if (is_mips) 65535 else 1;
-
-pub const SOL_IP = 0;
-pub const SOL_IPV6 = 41;
-pub const SOL_ICMPV6 = 58;
-
-pub const SOL_RAW = 255;
-pub const SOL_DECNET = 261;
-pub const SOL_X25 = 262;
-pub const SOL_PACKET = 263;
-pub const SOL_ATM = 264;
-pub const SOL_AAL = 265;
-pub const SOL_IRDA = 266;
-pub const SOL_NETBEUI = 267;
-pub const SOL_LLC = 268;
-pub const SOL_DCCP = 269;
-pub const SOL_NETLINK = 270;
-pub const SOL_TIPC = 271;
-pub const SOL_RXRPC = 272;
-pub const SOL_PPPOL2TP = 273;
-pub const SOL_BLUETOOTH = 274;
-pub const SOL_PNPIPE = 275;
-pub const SOL_RDS = 276;
-pub const SOL_IUCV = 277;
-pub const SOL_CAIF = 278;
-pub const SOL_ALG = 279;
-pub const SOL_NFC = 280;
-pub const SOL_KCM = 281;
-pub const SOL_TLS = 282;
-pub const SOL_XDP = 283;
-
-pub const SOMAXCONN = 128;
-
-pub const IP_TOS = 1;
-pub const IP_TTL = 2;
-pub const IP_HDRINCL = 3;
-pub const IP_OPTIONS = 4;
-pub const IP_ROUTER_ALERT = 5;
-pub const IP_RECVOPTS = 6;
-pub const IP_RETOPTS = 7;
-pub const IP_PKTINFO = 8;
-pub const IP_PKTOPTIONS = 9;
-pub const IP_PMTUDISC = 10;
-pub const IP_MTU_DISCOVER = 10;
-pub const IP_RECVERR = 11;
-pub const IP_RECVTTL = 12;
-pub const IP_RECVTOS = 13;
-pub const IP_MTU = 14;
-pub const IP_FREEBIND = 15;
-pub const IP_IPSEC_POLICY = 16;
-pub const IP_XFRM_POLICY = 17;
-pub const IP_PASSSEC = 18;
-pub const IP_TRANSPARENT = 19;
-pub const IP_ORIGDSTADDR = 20;
-pub const IP_RECVORIGDSTADDR = IP_ORIGDSTADDR;
-pub const IP_MINTTL = 21;
-pub const IP_NODEFRAG = 22;
-pub const IP_CHECKSUM = 23;
-pub const IP_BIND_ADDRESS_NO_PORT = 24;
-pub const IP_RECVFRAGSIZE = 25;
-pub const IP_MULTICAST_IF = 32;
-pub const IP_MULTICAST_TTL = 33;
-pub const IP_MULTICAST_LOOP = 34;
-pub const IP_ADD_MEMBERSHIP = 35;
-pub const IP_DROP_MEMBERSHIP = 36;
-pub const IP_UNBLOCK_SOURCE = 37;
-pub const IP_BLOCK_SOURCE = 38;
-pub const IP_ADD_SOURCE_MEMBERSHIP = 39;
-pub const IP_DROP_SOURCE_MEMBERSHIP = 40;
-pub const IP_MSFILTER = 41;
-pub const IP_MULTICAST_ALL = 49;
-pub const IP_UNICAST_IF = 50;
-
-pub const IP_RECVRETOPTS = IP_RETOPTS;
-
-pub const IP_PMTUDISC_DONT = 0;
-pub const IP_PMTUDISC_WANT = 1;
-pub const IP_PMTUDISC_DO = 2;
-pub const IP_PMTUDISC_PROBE = 3;
-pub const IP_PMTUDISC_INTERFACE = 4;
-pub const IP_PMTUDISC_OMIT = 5;
-
-pub const IP_DEFAULT_MULTICAST_TTL = 1;
-pub const IP_DEFAULT_MULTICAST_LOOP = 1;
-pub const IP_MAX_MEMBERSHIPS = 20;
-
-// IPv6 socket options
-
-pub const IPV6_ADDRFORM = 1;
-pub const IPV6_2292PKTINFO = 2;
-pub const IPV6_2292HOPOPTS = 3;
-pub const IPV6_2292DSTOPTS = 4;
-pub const IPV6_2292RTHDR = 5;
-pub const IPV6_2292PKTOPTIONS = 6;
-pub const IPV6_CHECKSUM = 7;
-pub const IPV6_2292HOPLIMIT = 8;
-pub const IPV6_NEXTHOP = 9;
-pub const IPV6_AUTHHDR = 10;
-pub const IPV6_FLOWINFO = 11;
-
-pub const IPV6_UNICAST_HOPS = 16;
-pub const IPV6_MULTICAST_IF = 17;
-pub const IPV6_MULTICAST_HOPS = 18;
-pub const IPV6_MULTICAST_LOOP = 19;
-pub const IPV6_ADD_MEMBERSHIP = 20;
-pub const IPV6_DROP_MEMBERSHIP = 21;
-pub const IPV6_ROUTER_ALERT = 22;
-pub const IPV6_MTU_DISCOVER = 23;
-pub const IPV6_MTU = 24;
-pub const IPV6_RECVERR = 25;
-pub const IPV6_V6ONLY = 26;
-pub const IPV6_JOIN_ANYCAST = 27;
-pub const IPV6_LEAVE_ANYCAST = 28;
-
-// IPV6_MTU_DISCOVER values
-pub const IPV6_PMTUDISC_DONT = 0;
-pub const IPV6_PMTUDISC_WANT = 1;
-pub const IPV6_PMTUDISC_DO = 2;
-pub const IPV6_PMTUDISC_PROBE = 3;
-pub const IPV6_PMTUDISC_INTERFACE = 4;
-pub const IPV6_PMTUDISC_OMIT = 5;
-
-// Flowlabel
-pub const IPV6_FLOWLABEL_MGR = 32;
-pub const IPV6_FLOWINFO_SEND = 33;
-pub const IPV6_IPSEC_POLICY = 34;
-pub const IPV6_XFRM_POLICY = 35;
-pub const IPV6_HDRINCL = 36;
-
-// Advanced API (RFC3542) (1)
-pub const IPV6_RECVPKTINFO = 49;
-pub const IPV6_PKTINFO = 50;
-pub const IPV6_RECVHOPLIMIT = 51;
-pub const IPV6_HOPLIMIT = 52;
-pub const IPV6_RECVHOPOPTS = 53;
-pub const IPV6_HOPOPTS = 54;
-pub const IPV6_RTHDRDSTOPTS = 55;
-pub const IPV6_RECVRTHDR = 56;
-pub const IPV6_RTHDR = 57;
-pub const IPV6_RECVDSTOPTS = 58;
-pub const IPV6_DSTOPTS = 59;
-pub const IPV6_RECVPATHMTU = 60;
-pub const IPV6_PATHMTU = 61;
-pub const IPV6_DONTFRAG = 62;
-
-// Advanced API (RFC3542) (2)
-pub const IPV6_RECVTCLASS = 66;
-pub const IPV6_TCLASS = 67;
-
-pub const IPV6_AUTOFLOWLABEL = 70;
-
-// RFC5014: Source address selection
-pub const IPV6_ADDR_PREFERENCES = 72;
-
-pub const IPV6_PREFER_SRC_TMP = 0x0001;
-pub const IPV6_PREFER_SRC_PUBLIC = 0x0002;
-pub const IPV6_PREFER_SRC_PUBTMP_DEFAULT = 0x0100;
-pub const IPV6_PREFER_SRC_COA = 0x0004;
-pub const IPV6_PREFER_SRC_HOME = 0x0400;
-pub const IPV6_PREFER_SRC_CGA = 0x0008;
-pub const IPV6_PREFER_SRC_NONCGA = 0x0800;
-
-// RFC5082: Generalized Ttl Security Mechanism
-pub const IPV6_MINHOPCOUNT = 73;
-
-pub const IPV6_ORIGDSTADDR = 74;
-pub const IPV6_RECVORIGDSTADDR = IPV6_ORIGDSTADDR;
-pub const IPV6_TRANSPARENT = 75;
-pub const IPV6_UNICAST_IF = 76;
-pub const IPV6_RECVFRAGSIZE = 77;
-pub const IPV6_FREEBIND = 78;
-
-pub const MSG_OOB = 0x0001;
-pub const MSG_PEEK = 0x0002;
-pub const MSG_DONTROUTE = 0x0004;
-pub const MSG_CTRUNC = 0x0008;
-pub const MSG_PROXY = 0x0010;
-pub const MSG_TRUNC = 0x0020;
-pub const MSG_DONTWAIT = 0x0040;
-pub const MSG_EOR = 0x0080;
-pub const MSG_WAITALL = 0x0100;
-pub const MSG_FIN = 0x0200;
-pub const MSG_SYN = 0x0400;
-pub const MSG_CONFIRM = 0x0800;
-pub const MSG_RST = 0x1000;
-pub const MSG_ERRQUEUE = 0x2000;
-pub const MSG_NOSIGNAL = 0x4000;
-pub const MSG_MORE = 0x8000;
-pub const MSG_WAITFORONE = 0x10000;
-pub const MSG_BATCH = 0x40000;
-pub const MSG_ZEROCOPY = 0x4000000;
-pub const MSG_FASTOPEN = 0x20000000;
-pub const MSG_CMSG_CLOEXEC = 0x40000000;
-
-pub const DT_UNKNOWN = 0;
-pub const DT_FIFO = 1;
-pub const DT_CHR = 2;
-pub const DT_DIR = 4;
-pub const DT_BLK = 6;
-pub const DT_REG = 8;
-pub const DT_LNK = 10;
-pub const DT_SOCK = 12;
-pub const DT_WHT = 14;
-
-pub const TCGETS = if (is_mips) 0x540D else 0x5401;
-pub const TCSETS = 0x5402;
-pub const TCSETSW = 0x5403;
-pub const TCSETSF = 0x5404;
-pub const TCGETA = 0x5405;
-pub const TCSETA = 0x5406;
-pub const TCSETAW = 0x5407;
-pub const TCSETAF = 0x5408;
-pub const TCSBRK = 0x5409;
-pub const TCXONC = 0x540A;
-pub const TCFLSH = 0x540B;
-pub const TIOCEXCL = 0x540C;
-pub const TIOCNXCL = 0x540D;
-pub const TIOCSCTTY = 0x540E;
-pub const TIOCGPGRP = 0x540F;
-pub const TIOCSPGRP = 0x5410;
-pub const TIOCOUTQ = if (is_mips) 0x7472 else 0x5411;
-pub const TIOCSTI = 0x5412;
-pub const TIOCGWINSZ = if (is_mips or is_ppc64) 0x40087468 else 0x5413;
-pub const TIOCSWINSZ = if (is_mips or is_ppc64) 0x80087467 else 0x5414;
-pub const TIOCMGET = 0x5415;
-pub const TIOCMBIS = 0x5416;
-pub const TIOCMBIC = 0x5417;
-pub const TIOCMSET = 0x5418;
-pub const TIOCGSOFTCAR = 0x5419;
-pub const TIOCSSOFTCAR = 0x541A;
-pub const FIONREAD = if (is_mips) 0x467F else 0x541B;
-pub const TIOCINQ = FIONREAD;
-pub const TIOCLINUX = 0x541C;
-pub const TIOCCONS = 0x541D;
-pub const TIOCGSERIAL = 0x541E;
-pub const TIOCSSERIAL = 0x541F;
-pub const TIOCPKT = 0x5420;
-pub const FIONBIO = 0x5421;
-pub const TIOCNOTTY = 0x5422;
-pub const TIOCSETD = 0x5423;
-pub const TIOCGETD = 0x5424;
-pub const TCSBRKP = 0x5425;
-pub const TIOCSBRK = 0x5427;
-pub const TIOCCBRK = 0x5428;
-pub const TIOCGSID = 0x5429;
-pub const TIOCGRS485 = 0x542E;
-pub const TIOCSRS485 = 0x542F;
-pub const TIOCGPTN = 0x80045430;
-pub const TIOCSPTLCK = 0x40045431;
-pub const TIOCGDEV = 0x80045432;
-pub const TCGETX = 0x5432;
-pub const TCSETX = 0x5433;
-pub const TCSETXF = 0x5434;
-pub const TCSETXW = 0x5435;
-pub const TIOCSIG = 0x40045436;
-pub const TIOCVHANGUP = 0x5437;
-pub const TIOCGPKT = 0x80045438;
-pub const TIOCGPTLCK = 0x80045439;
-pub const TIOCGEXCL = 0x80045440;
-
-pub const EPOLL_CLOEXEC = O_CLOEXEC;
-
-pub const EPOLL_CTL_ADD = 1;
-pub const EPOLL_CTL_DEL = 2;
-pub const EPOLL_CTL_MOD = 3;
-
-pub const EPOLLIN = 0x001;
-pub const EPOLLPRI = 0x002;
-pub const EPOLLOUT = 0x004;
-pub const EPOLLRDNORM = 0x040;
-pub const EPOLLRDBAND = 0x080;
-pub const EPOLLWRNORM = if (is_mips) 0x004 else 0x100;
-pub const EPOLLWRBAND = if (is_mips) 0x100 else 0x200;
-pub const EPOLLMSG = 0x400;
-pub const EPOLLERR = 0x008;
-pub const EPOLLHUP = 0x010;
-pub const EPOLLRDHUP = 0x2000;
-pub const EPOLLEXCLUSIVE = (@as(u32, 1) << 28);
-pub const EPOLLWAKEUP = (@as(u32, 1) << 29);
-pub const EPOLLONESHOT = (@as(u32, 1) << 30);
-pub const EPOLLET = (@as(u32, 1) << 31);
-
-pub const CLOCK_REALTIME = 0;
-pub const CLOCK_MONOTONIC = 1;
-pub const CLOCK_PROCESS_CPUTIME_ID = 2;
-pub const CLOCK_THREAD_CPUTIME_ID = 3;
-pub const CLOCK_MONOTONIC_RAW = 4;
-pub const CLOCK_REALTIME_COARSE = 5;
-pub const CLOCK_MONOTONIC_COARSE = 6;
-pub const CLOCK_BOOTTIME = 7;
-pub const CLOCK_REALTIME_ALARM = 8;
-pub const CLOCK_BOOTTIME_ALARM = 9;
-pub const CLOCK_SGI_CYCLE = 10;
-pub const CLOCK_TAI = 11;
-
-pub const CSIGNAL = 0x000000ff;
-pub const CLONE_VM = 0x00000100;
-pub const CLONE_FS = 0x00000200;
-pub const CLONE_FILES = 0x00000400;
-pub const CLONE_SIGHAND = 0x00000800;
-pub const CLONE_PIDFD = 0x00001000;
-pub const CLONE_PTRACE = 0x00002000;
-pub const CLONE_VFORK = 0x00004000;
-pub const CLONE_PARENT = 0x00008000;
-pub const CLONE_THREAD = 0x00010000;
-pub const CLONE_NEWNS = 0x00020000;
-pub const CLONE_SYSVSEM = 0x00040000;
-pub const CLONE_SETTLS = 0x00080000;
-pub const CLONE_PARENT_SETTID = 0x00100000;
-pub const CLONE_CHILD_CLEARTID = 0x00200000;
-pub const CLONE_DETACHED = 0x00400000;
-pub const CLONE_UNTRACED = 0x00800000;
-pub const CLONE_CHILD_SETTID = 0x01000000;
-pub const CLONE_NEWCGROUP = 0x02000000;
-pub const CLONE_NEWUTS = 0x04000000;
-pub const CLONE_NEWIPC = 0x08000000;
-pub const CLONE_NEWUSER = 0x10000000;
-pub const CLONE_NEWPID = 0x20000000;
-pub const CLONE_NEWNET = 0x40000000;
-pub const CLONE_IO = 0x80000000;
-
-// Flags for the clone3() syscall.
-
-/// Clear any signal handler and reset to SIG_DFL.
-pub const CLONE_CLEAR_SIGHAND = 0x100000000;
-/// Clone into a specific cgroup given the right permissions.
-pub const CLONE_INTO_CGROUP = 0x200000000;
-
-// cloning flags intersect with CSIGNAL so can be used with unshare and clone3 syscalls only.
-
-/// New time namespace
-pub const CLONE_NEWTIME = 0x00000080;
-
-pub const EFD_SEMAPHORE = 1;
-pub const EFD_CLOEXEC = O_CLOEXEC;
-pub const EFD_NONBLOCK = O_NONBLOCK;
-
-pub const MS_RDONLY = 1;
-pub const MS_NOSUID = 2;
-pub const MS_NODEV = 4;
-pub const MS_NOEXEC = 8;
-pub const MS_SYNCHRONOUS = 16;
-pub const MS_REMOUNT = 32;
-pub const MS_MANDLOCK = 64;
-pub const MS_DIRSYNC = 128;
-pub const MS_NOATIME = 1024;
-pub const MS_NODIRATIME = 2048;
-pub const MS_BIND = 4096;
-pub const MS_MOVE = 8192;
-pub const MS_REC = 16384;
-pub const MS_SILENT = 32768;
-pub const MS_POSIXACL = (1 << 16);
-pub const MS_UNBINDABLE = (1 << 17);
-pub const MS_PRIVATE = (1 << 18);
-pub const MS_SLAVE = (1 << 19);
-pub const MS_SHARED = (1 << 20);
-pub const MS_RELATIME = (1 << 21);
-pub const MS_KERNMOUNT = (1 << 22);
-pub const MS_I_VERSION = (1 << 23);
-pub const MS_STRICTATIME = (1 << 24);
-pub const MS_LAZYTIME = (1 << 25);
-pub const MS_NOREMOTELOCK = (1 << 27);
-pub const MS_NOSEC = (1 << 28);
-pub const MS_BORN = (1 << 29);
-pub const MS_ACTIVE = (1 << 30);
-pub const MS_NOUSER = (1 << 31);
-
-pub const MS_RMT_MASK = (MS_RDONLY | MS_SYNCHRONOUS | MS_MANDLOCK | MS_I_VERSION | MS_LAZYTIME);
-
-pub const MS_MGC_VAL = 0xc0ed0000;
-pub const MS_MGC_MSK = 0xffff0000;
-
-pub const MNT_FORCE = 1;
-pub const MNT_DETACH = 2;
-pub const MNT_EXPIRE = 4;
-pub const UMOUNT_NOFOLLOW = 8;
-
-pub const IN_CLOEXEC = O_CLOEXEC;
-pub const IN_NONBLOCK = O_NONBLOCK;
-
-pub const IN_ACCESS = 0x00000001;
-pub const IN_MODIFY = 0x00000002;
-pub const IN_ATTRIB = 0x00000004;
-pub const IN_CLOSE_WRITE = 0x00000008;
-pub const IN_CLOSE_NOWRITE = 0x00000010;
-pub const IN_CLOSE = IN_CLOSE_WRITE | IN_CLOSE_NOWRITE;
-pub const IN_OPEN = 0x00000020;
-pub const IN_MOVED_FROM = 0x00000040;
-pub const IN_MOVED_TO = 0x00000080;
-pub const IN_MOVE = IN_MOVED_FROM | IN_MOVED_TO;
-pub const IN_CREATE = 0x00000100;
-pub const IN_DELETE = 0x00000200;
-pub const IN_DELETE_SELF = 0x00000400;
-pub const IN_MOVE_SELF = 0x00000800;
-pub const IN_ALL_EVENTS = 0x00000fff;
-
-pub const IN_UNMOUNT = 0x00002000;
-pub const IN_Q_OVERFLOW = 0x00004000;
-pub const IN_IGNORED = 0x00008000;
-
-pub const IN_ONLYDIR = 0x01000000;
-pub const IN_DONT_FOLLOW = 0x02000000;
-pub const IN_EXCL_UNLINK = 0x04000000;
-pub const IN_MASK_ADD = 0x20000000;
-
-pub const IN_ISDIR = 0x40000000;
-pub const IN_ONESHOT = 0x80000000;
-
-pub const S_IFMT = 0o170000;
-
-pub const S_IFDIR = 0o040000;
-pub const S_IFCHR = 0o020000;
-pub const S_IFBLK = 0o060000;
-pub const S_IFREG = 0o100000;
-pub const S_IFIFO = 0o010000;
-pub const S_IFLNK = 0o120000;
-pub const S_IFSOCK = 0o140000;
-
-pub const S_ISUID = 0o4000;
-pub const S_ISGID = 0o2000;
-pub const S_ISVTX = 0o1000;
-pub const S_IRUSR = 0o400;
-pub const S_IWUSR = 0o200;
-pub const S_IXUSR = 0o100;
-pub const S_IRWXU = 0o700;
-pub const S_IRGRP = 0o040;
-pub const S_IWGRP = 0o020;
-pub const S_IXGRP = 0o010;
-pub const S_IRWXG = 0o070;
-pub const S_IROTH = 0o004;
-pub const S_IWOTH = 0o002;
-pub const S_IXOTH = 0o001;
-pub const S_IRWXO = 0o007;
-
-pub fn S_ISREG(m: u32) bool {
- return m & S_IFMT == S_IFREG;
-}
-
-pub fn S_ISDIR(m: u32) bool {
- return m & S_IFMT == S_IFDIR;
-}
-
-pub fn S_ISCHR(m: u32) bool {
- return m & S_IFMT == S_IFCHR;
-}
-
-pub fn S_ISBLK(m: u32) bool {
- return m & S_IFMT == S_IFBLK;
-}
-
-pub fn S_ISFIFO(m: u32) bool {
- return m & S_IFMT == S_IFIFO;
-}
-
-pub fn S_ISLNK(m: u32) bool {
- return m & S_IFMT == S_IFLNK;
-}
-
-pub fn S_ISSOCK(m: u32) bool {
- return m & S_IFMT == S_IFSOCK;
-}
-
-pub const UTIME_NOW = 0x3fffffff;
-pub const UTIME_OMIT = 0x3ffffffe;
-
-pub const TFD_NONBLOCK = O_NONBLOCK;
-pub const TFD_CLOEXEC = O_CLOEXEC;
-
-pub const TFD_TIMER_ABSTIME = 1;
-pub const TFD_TIMER_CANCEL_ON_SET = (1 << 1);
-
-pub fn WEXITSTATUS(s: u32) u8 {
- return @intCast(u8, (s & 0xff00) >> 8);
-}
-pub fn WTERMSIG(s: u32) u32 {
- return s & 0x7f;
-}
-pub fn WSTOPSIG(s: u32) u32 {
- return WEXITSTATUS(s);
-}
-pub fn WIFEXITED(s: u32) bool {
- return WTERMSIG(s) == 0;
-}
-pub fn WIFSTOPPED(s: u32) bool {
- return @truncate(u16, ((s & 0xffff) *% 0x10001) >> 8) > 0x7f00;
-}
-pub fn WIFSIGNALED(s: u32) bool {
- return (s & 0xffff) -% 1 < 0xff;
-}
-
-pub const winsize = extern struct {
- ws_row: u16,
- ws_col: u16,
- ws_xpixel: u16,
- ws_ypixel: u16,
-};
-
-/// NSIG is the total number of signals defined.
-/// As signal numbers are sequential, NSIG is one greater than the largest defined signal number.
-pub const NSIG = if (is_mips) 128 else 65;
-
-pub const sigset_t = [1024 / 32]u32;
-
-pub const all_mask: sigset_t = [_]u32{0xffffffff} ** sigset_t.len;
-pub const app_mask: sigset_t = [2]u32{ 0xfffffffc, 0x7fffffff } ++ [_]u32{0xffffffff} ** 30;
-
-pub const k_sigaction = switch (arch) {
- .mips, .mipsel => extern struct {
- flags: c_uint,
- handler: ?fn (c_int) callconv(.C) void,
- mask: [4]c_ulong,
- restorer: fn () callconv(.C) void,
- },
- .mips64, .mips64el => extern struct {
- flags: c_uint,
- handler: ?fn (c_int) callconv(.C) void,
- mask: [2]c_ulong,
- restorer: fn () callconv(.C) void,
- },
- else => extern struct {
- handler: ?fn (c_int) callconv(.C) void,
- flags: c_ulong,
- restorer: fn () callconv(.C) void,
- mask: [2]c_uint,
- },
-};
-
-/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.
-pub const Sigaction = extern struct {
- pub const handler_fn = fn (c_int) callconv(.C) void;
- pub const sigaction_fn = fn (c_int, *const siginfo_t, ?*const c_void) callconv(.C) void;
-
- handler: extern union {
- handler: ?handler_fn,
- sigaction: ?sigaction_fn,
- },
- mask: sigset_t,
- flags: c_uint,
- restorer: ?fn () callconv(.C) void = null,
-};
-
-pub const SIG_ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize));
-pub const SIG_DFL = @intToPtr(?Sigaction.sigaction_fn, 0);
-pub const SIG_IGN = @intToPtr(?Sigaction.sigaction_fn, 1);
-
-pub const empty_sigset = [_]u32{0} ** @typeInfo(sigset_t).Array.len;
-
-pub const SFD_CLOEXEC = O_CLOEXEC;
-pub const SFD_NONBLOCK = O_NONBLOCK;
-
-pub const signalfd_siginfo = extern struct {
- signo: u32,
- errno: i32,
- code: i32,
- pid: u32,
- uid: uid_t,
- fd: i32,
- tid: u32,
- band: u32,
- overrun: u32,
- trapno: u32,
- status: i32,
- int: i32,
- ptr: u64,
- utime: u64,
- stime: u64,
- addr: u64,
- addr_lsb: u16,
- __pad2: u16,
- syscall: i32,
- call_addr: u64,
- arch: u32,
- __pad: [28]u8,
-};
-
-pub const in_port_t = u16;
-pub const sa_family_t = u16;
-pub const socklen_t = u32;
-
-pub const sockaddr = extern struct {
- family: sa_family_t,
- data: [14]u8,
-};
-
-pub const sockaddr_storage = std.x.os.Socket.Address.Native.Storage;
-
-/// IPv4 socket address
-pub const sockaddr_in = extern struct {
- family: sa_family_t = AF_INET,
- port: in_port_t,
- addr: u32,
- zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },
-};
-
-/// IPv6 socket address
-pub const sockaddr_in6 = extern struct {
- family: sa_family_t = AF_INET6,
- port: in_port_t,
- flowinfo: u32,
- addr: [16]u8,
- scope_id: u32,
-};
-
-/// UNIX domain socket address
-pub const sockaddr_un = extern struct {
- family: sa_family_t = AF_UNIX,
- path: [108]u8,
-};
-
-pub const mmsghdr = extern struct {
- msg_hdr: msghdr,
- msg_len: u32,
-};
-
-pub const mmsghdr_const = extern struct {
- msg_hdr: msghdr_const,
- msg_len: u32,
-};
-
-pub const epoll_data = extern union {
- ptr: usize,
- fd: i32,
- @"u32": u32,
- @"u64": u64,
-};
-
-// On x86_64 the structure is packed so that it matches the definition of its
-// 32bit counterpart
-pub const epoll_event = switch (arch) {
- .x86_64 => packed struct {
- events: u32,
- data: epoll_data,
- },
- else => extern struct {
- events: u32,
- data: epoll_data,
- },
-};
-
-pub const _LINUX_CAPABILITY_VERSION_1 = 0x19980330;
-pub const _LINUX_CAPABILITY_U32S_1 = 1;
-
-pub const _LINUX_CAPABILITY_VERSION_2 = 0x20071026;
-pub const _LINUX_CAPABILITY_U32S_2 = 2;
-
-pub const _LINUX_CAPABILITY_VERSION_3 = 0x20080522;
-pub const _LINUX_CAPABILITY_U32S_3 = 2;
-
-pub const VFS_CAP_REVISION_MASK = 0xFF000000;
-pub const VFS_CAP_REVISION_SHIFT = 24;
-pub const VFS_CAP_FLAGS_MASK = ~VFS_CAP_REVISION_MASK;
-pub const VFS_CAP_FLAGS_EFFECTIVE = 0x000001;
-
-pub const VFS_CAP_REVISION_1 = 0x01000000;
-pub const VFS_CAP_U32_1 = 1;
-pub const XATTR_CAPS_SZ_1 = @sizeOf(u32) * (1 + 2 * VFS_CAP_U32_1);
-
-pub const VFS_CAP_REVISION_2 = 0x02000000;
-pub const VFS_CAP_U32_2 = 2;
-pub const XATTR_CAPS_SZ_2 = @sizeOf(u32) * (1 + 2 * VFS_CAP_U32_2);
-
-pub const XATTR_CAPS_SZ = XATTR_CAPS_SZ_2;
-pub const VFS_CAP_U32 = VFS_CAP_U32_2;
-pub const VFS_CAP_REVISION = VFS_CAP_REVISION_2;
-
-pub const vfs_cap_data = extern struct {
- //all of these are mandated as little endian
- //when on disk.
- const Data = struct {
- permitted: u32,
- inheritable: u32,
- };
-
- magic_etc: u32,
- data: [VFS_CAP_U32]Data,
-};
-
-pub const CAP_CHOWN = 0;
-pub const CAP_DAC_OVERRIDE = 1;
-pub const CAP_DAC_READ_SEARCH = 2;
-pub const CAP_FOWNER = 3;
-pub const CAP_FSETID = 4;
-pub const CAP_KILL = 5;
-pub const CAP_SETGID = 6;
-pub const CAP_SETUID = 7;
-pub const CAP_SETPCAP = 8;
-pub const CAP_LINUX_IMMUTABLE = 9;
-pub const CAP_NET_BIND_SERVICE = 10;
-pub const CAP_NET_BROADCAST = 11;
-pub const CAP_NET_ADMIN = 12;
-pub const CAP_NET_RAW = 13;
-pub const CAP_IPC_LOCK = 14;
-pub const CAP_IPC_OWNER = 15;
-pub const CAP_SYS_MODULE = 16;
-pub const CAP_SYS_RAWIO = 17;
-pub const CAP_SYS_CHROOT = 18;
-pub const CAP_SYS_PTRACE = 19;
-pub const CAP_SYS_PACCT = 20;
-pub const CAP_SYS_ADMIN = 21;
-pub const CAP_SYS_BOOT = 22;
-pub const CAP_SYS_NICE = 23;
-pub const CAP_SYS_RESOURCE = 24;
-pub const CAP_SYS_TIME = 25;
-pub const CAP_SYS_TTY_CONFIG = 26;
-pub const CAP_MKNOD = 27;
-pub const CAP_LEASE = 28;
-pub const CAP_AUDIT_WRITE = 29;
-pub const CAP_AUDIT_CONTROL = 30;
-pub const CAP_SETFCAP = 31;
-pub const CAP_MAC_OVERRIDE = 32;
-pub const CAP_MAC_ADMIN = 33;
-pub const CAP_SYSLOG = 34;
-pub const CAP_WAKE_ALARM = 35;
-pub const CAP_BLOCK_SUSPEND = 36;
-pub const CAP_AUDIT_READ = 37;
-pub const CAP_LAST_CAP = CAP_AUDIT_READ;
-
-pub fn cap_valid(x: u8) bool {
- return x >= 0 and x <= CAP_LAST_CAP;
-}
-
-pub fn CAP_TO_MASK(cap: u8) u32 {
- return @as(u32, 1) << @intCast(u5, cap & 31);
-}
-
-pub fn CAP_TO_INDEX(cap: u8) u8 {
- return cap >> 5;
-}
-
-pub const cap_t = extern struct {
- hdrp: *cap_user_header_t,
- datap: *cap_user_data_t,
-};
-
-pub const cap_user_header_t = extern struct {
- version: u32,
- pid: usize,
-};
-
-pub const cap_user_data_t = extern struct {
- effective: u32,
- permitted: u32,
- inheritable: u32,
-};
-
-pub const inotify_event = extern struct {
- wd: i32,
- mask: u32,
- cookie: u32,
- len: u32,
- //name: [?]u8,
-};
-
-pub const dirent64 = extern struct {
- d_ino: u64,
- d_off: u64,
- d_reclen: u16,
- d_type: u8,
- d_name: u8, // field address is the address of first byte of name https://github.com/ziglang/zig/issues/173
-
- pub fn reclen(self: dirent64) u16 {
- return self.d_reclen;
- }
-};
-
-pub const dl_phdr_info = extern struct {
- dlpi_addr: usize,
- dlpi_name: ?[*:0]const u8,
- dlpi_phdr: [*]std.elf.Phdr,
- dlpi_phnum: u16,
-};
-
-pub const CPU_SETSIZE = 128;
-pub const cpu_set_t = [CPU_SETSIZE / @sizeOf(usize)]usize;
-pub const cpu_count_t = std.meta.Int(.unsigned, std.math.log2(CPU_SETSIZE * 8));
-
-pub fn CPU_COUNT(set: cpu_set_t) cpu_count_t {
- var sum: cpu_count_t = 0;
- for (set) |x| {
- sum += @popCount(usize, x);
- }
- return sum;
-}
-
-// TODO port these over
-//#define CPU_SET(i, set) CPU_SET_S(i,sizeof(cpu_set_t),set)
-//#define CPU_CLR(i, set) CPU_CLR_S(i,sizeof(cpu_set_t),set)
-//#define CPU_ISSET(i, set) CPU_ISSET_S(i,sizeof(cpu_set_t),set)
-//#define CPU_AND(d,s1,s2) CPU_AND_S(sizeof(cpu_set_t),d,s1,s2)
-//#define CPU_OR(d,s1,s2) CPU_OR_S(sizeof(cpu_set_t),d,s1,s2)
-//#define CPU_XOR(d,s1,s2) CPU_XOR_S(sizeof(cpu_set_t),d,s1,s2)
-//#define CPU_COUNT(set) CPU_COUNT_S(sizeof(cpu_set_t),set)
-//#define CPU_ZERO(set) CPU_ZERO_S(sizeof(cpu_set_t),set)
-//#define CPU_EQUAL(s1,s2) CPU_EQUAL_S(sizeof(cpu_set_t),s1,s2)
-
-pub const MINSIGSTKSZ = switch (arch) {
- .i386, .x86_64, .arm, .mipsel => 2048,
- .aarch64 => 5120,
- else => @compileError("MINSIGSTKSZ not defined for this architecture"),
-};
-pub const SIGSTKSZ = switch (arch) {
- .i386, .x86_64, .arm, .mipsel => 8192,
- .aarch64 => 16384,
- else => @compileError("SIGSTKSZ not defined for this architecture"),
-};
-
-pub const SS_ONSTACK = 1;
-pub const SS_DISABLE = 2;
-pub const SS_AUTODISARM = 1 << 31;
-
-pub const stack_t = if (is_mips)
- // IRIX compatible stack_t
- extern struct {
- ss_sp: [*]u8,
- ss_size: usize,
- ss_flags: i32,
- }
-else
- extern struct {
- ss_sp: [*]u8,
- ss_flags: i32,
- ss_size: usize,
- };
-
-pub const sigval = extern union {
- int: i32,
- ptr: *c_void,
-};
-
-const siginfo_fields_union = extern union {
- pad: [128 - 2 * @sizeOf(c_int) - @sizeOf(c_long)]u8,
- common: extern struct {
- first: extern union {
- piduid: extern struct {
- pid: pid_t,
- uid: uid_t,
- },
- timer: extern struct {
- timerid: i32,
- overrun: i32,
- },
- },
- second: extern union {
- value: sigval,
- sigchld: extern struct {
- status: i32,
- utime: clock_t,
- stime: clock_t,
- },
- },
- },
- sigfault: extern struct {
- addr: *c_void,
- addr_lsb: i16,
- first: extern union {
- addr_bnd: extern struct {
- lower: *c_void,
- upper: *c_void,
- },
- pkey: u32,
- },
- },
- sigpoll: extern struct {
- band: isize,
- fd: i32,
- },
- sigsys: extern struct {
- call_addr: *c_void,
- syscall: i32,
- arch: u32,
- },
-};
-
-pub const siginfo_t = if (is_mips)
- extern struct {
- signo: i32,
- code: i32,
- errno: i32,
- fields: siginfo_fields_union,
- }
-else
- extern struct {
- signo: i32,
- errno: i32,
- code: i32,
- fields: siginfo_fields_union,
- };
-
-pub const io_uring_params = extern struct {
- sq_entries: u32,
- cq_entries: u32,
- flags: u32,
- sq_thread_cpu: u32,
- sq_thread_idle: u32,
- features: u32,
- wq_fd: u32,
- resv: [3]u32,
- sq_off: io_sqring_offsets,
- cq_off: io_cqring_offsets,
-};
-
-// io_uring_params.features flags
-
-pub const IORING_FEAT_SINGLE_MMAP = 1 << 0;
-pub const IORING_FEAT_NODROP = 1 << 1;
-pub const IORING_FEAT_SUBMIT_STABLE = 1 << 2;
-pub const IORING_FEAT_RW_CUR_POS = 1 << 3;
-pub const IORING_FEAT_CUR_PERSONALITY = 1 << 4;
-pub const IORING_FEAT_FAST_POLL = 1 << 5;
-pub const IORING_FEAT_POLL_32BITS = 1 << 6;
-
-// io_uring_params.flags
-
-/// io_context is polled
-pub const IORING_SETUP_IOPOLL = 1 << 0;
-
-/// SQ poll thread
-pub const IORING_SETUP_SQPOLL = 1 << 1;
-
-/// sq_thread_cpu is valid
-pub const IORING_SETUP_SQ_AFF = 1 << 2;
-
-/// app defines CQ size
-pub const IORING_SETUP_CQSIZE = 1 << 3;
-
-/// clamp SQ/CQ ring sizes
-pub const IORING_SETUP_CLAMP = 1 << 4;
-
-/// attach to existing wq
-pub const IORING_SETUP_ATTACH_WQ = 1 << 5;
-
-/// start with ring disabled
-pub const IORING_SETUP_R_DISABLED = 1 << 6;
-
-pub const io_sqring_offsets = extern struct {
- /// offset of ring head
- head: u32,
-
- /// offset of ring tail
- tail: u32,
-
- /// ring mask value
- ring_mask: u32,
-
- /// entries in ring
- ring_entries: u32,
-
- /// ring flags
- flags: u32,
-
- /// number of sqes not submitted
- dropped: u32,
-
- /// sqe index array
- array: u32,
-
- resv1: u32,
- resv2: u64,
-};
-
-// io_sqring_offsets.flags
-
-/// needs io_uring_enter wakeup
-pub const IORING_SQ_NEED_WAKEUP = 1 << 0;
-
-/// kernel has cqes waiting beyond the cq ring
-pub const IORING_SQ_CQ_OVERFLOW = 1 << 1;
-
-pub const io_cqring_offsets = extern struct {
- head: u32,
- tail: u32,
- ring_mask: u32,
- ring_entries: u32,
- overflow: u32,
- cqes: u32,
- resv: [2]u64,
-};
-
-pub const io_uring_sqe = extern struct {
- opcode: IORING_OP,
- flags: u8,
- ioprio: u16,
- fd: i32,
- off: u64,
- addr: u64,
- len: u32,
- rw_flags: u32,
- user_data: u64,
- buf_index: u16,
- personality: u16,
- splice_fd_in: i32,
- __pad2: [2]u64,
-};
-
-pub const IOSQE_BIT = enum(u8) {
- FIXED_FILE,
- IO_DRAIN,
- IO_LINK,
- IO_HARDLINK,
- ASYNC,
- BUFFER_SELECT,
-
- _,
-};
-
-// io_uring_sqe.flags
-
-/// use fixed fileset
-pub const IOSQE_FIXED_FILE = 1 << @enumToInt(IOSQE_BIT.FIXED_FILE);
-
-/// issue after inflight IO
-pub const IOSQE_IO_DRAIN = 1 << @enumToInt(IOSQE_BIT.IO_DRAIN);
-
-/// links next sqe
-pub const IOSQE_IO_LINK = 1 << @enumToInt(IOSQE_BIT.IO_LINK);
-
-/// like LINK, but stronger
-pub const IOSQE_IO_HARDLINK = 1 << @enumToInt(IOSQE_BIT.IO_HARDLINK);
-
-/// always go async
-pub const IOSQE_ASYNC = 1 << @enumToInt(IOSQE_BIT.ASYNC);
-
-/// select buffer from buf_group
-pub const IOSQE_BUFFER_SELECT = 1 << @enumToInt(IOSQE_BIT.BUFFER_SELECT);
-
-pub const IORING_OP = enum(u8) {
- NOP,
- READV,
- WRITEV,
- FSYNC,
- READ_FIXED,
- WRITE_FIXED,
- POLL_ADD,
- POLL_REMOVE,
- SYNC_FILE_RANGE,
- SENDMSG,
- RECVMSG,
- TIMEOUT,
- TIMEOUT_REMOVE,
- ACCEPT,
- ASYNC_CANCEL,
- LINK_TIMEOUT,
- CONNECT,
- FALLOCATE,
- OPENAT,
- CLOSE,
- FILES_UPDATE,
- STATX,
- READ,
- WRITE,
- FADVISE,
- MADVISE,
- SEND,
- RECV,
- OPENAT2,
- EPOLL_CTL,
- SPLICE,
- PROVIDE_BUFFERS,
- REMOVE_BUFFERS,
- TEE,
-
- _,
-};
-
-// io_uring_sqe.fsync_flags
-pub const IORING_FSYNC_DATASYNC = 1 << 0;
-
-// io_uring_sqe.timeout_flags
-pub const IORING_TIMEOUT_ABS = 1 << 0;
-
-// IO completion data structure (Completion Queue Entry)
-pub const io_uring_cqe = extern struct {
- /// io_uring_sqe.data submission passed back
- user_data: u64,
-
- /// result code for this event
- res: i32,
- flags: u32,
-
- pub fn err(self: io_uring_cqe) E {
- if (self.res > -4096 and self.res < 0) {
- return @intToEnum(E, -self.res);
- }
- return .SUCCESS;
- }
-};
-
-// io_uring_cqe.flags
-
-/// If set, the upper 16 bits are the buffer ID
-pub const IORING_CQE_F_BUFFER = 1 << 0;
-
-pub const IORING_OFF_SQ_RING = 0;
-pub const IORING_OFF_CQ_RING = 0x8000000;
-pub const IORING_OFF_SQES = 0x10000000;
-
-// io_uring_enter flags
-pub const IORING_ENTER_GETEVENTS = 1 << 0;
-pub const IORING_ENTER_SQ_WAKEUP = 1 << 1;
-
-// io_uring_register opcodes and arguments
-pub const IORING_REGISTER = enum(u8) {
- REGISTER_BUFFERS,
- UNREGISTER_BUFFERS,
- REGISTER_FILES,
- UNREGISTER_FILES,
- REGISTER_EVENTFD,
- UNREGISTER_EVENTFD,
- REGISTER_FILES_UPDATE,
- REGISTER_EVENTFD_ASYNC,
- REGISTER_PROBE,
- REGISTER_PERSONALITY,
- UNREGISTER_PERSONALITY,
- REGISTER_RESTRICTIONS,
- REGISTER_ENABLE_RINGS,
-
- _,
-};
-
-pub const io_uring_files_update = extern struct {
- offset: u32,
- resv: u32,
- fds: u64,
-};
-
-pub const IO_URING_OP_SUPPORTED = 1 << 0;
-
-pub const io_uring_probe_op = extern struct {
- op: IORING_OP,
-
- resv: u8,
-
- /// IO_URING_OP_* flags
- flags: u16,
-
- resv2: u32,
-};
-
-pub const io_uring_probe = extern struct {
- /// last opcode supported
- last_op: IORING_OP,
-
- /// Number of io_uring_probe_op following
- ops_len: u8,
-
- resv: u16,
- resv2: u32[3],
-
- // Followed by up to `ops_len` io_uring_probe_op structures
-};
-
-pub const io_uring_restriction = extern struct {
- opcode: u16,
- arg: extern union {
- /// IORING_RESTRICTION_REGISTER_OP
- register_op: IORING_REGISTER,
-
- /// IORING_RESTRICTION_SQE_OP
- sqe_op: IORING_OP,
-
- /// IORING_RESTRICTION_SQE_FLAGS_*
- sqe_flags: u8,
- },
- resv: u8,
- resv2: u32[3],
-};
-
-/// io_uring_restriction->opcode values
-pub const IORING_RESTRICTION = enum(u8) {
- /// Allow an io_uring_register(2) opcode
- REGISTER_OP = 0,
-
- /// Allow an sqe opcode
- SQE_OP = 1,
-
- /// Allow sqe flags
- SQE_FLAGS_ALLOWED = 2,
-
- /// Require sqe flags (these flags must be set on each submission)
- SQE_FLAGS_REQUIRED = 3,
-
- _,
-};
-
-pub const utsname = extern struct {
- sysname: [64:0]u8,
- nodename: [64:0]u8,
- release: [64:0]u8,
- version: [64:0]u8,
- machine: [64:0]u8,
- domainname: [64:0]u8,
-};
-pub const HOST_NAME_MAX = 64;
-
-pub const STATX_TYPE = 0x0001;
-pub const STATX_MODE = 0x0002;
-pub const STATX_NLINK = 0x0004;
-pub const STATX_UID = 0x0008;
-pub const STATX_GID = 0x0010;
-pub const STATX_ATIME = 0x0020;
-pub const STATX_MTIME = 0x0040;
-pub const STATX_CTIME = 0x0080;
-pub const STATX_INO = 0x0100;
-pub const STATX_SIZE = 0x0200;
-pub const STATX_BLOCKS = 0x0400;
-pub const STATX_BASIC_STATS = 0x07ff;
-
-pub const STATX_BTIME = 0x0800;
-
-pub const STATX_ATTR_COMPRESSED = 0x0004;
-pub const STATX_ATTR_IMMUTABLE = 0x0010;
-pub const STATX_ATTR_APPEND = 0x0020;
-pub const STATX_ATTR_NODUMP = 0x0040;
-pub const STATX_ATTR_ENCRYPTED = 0x0800;
-pub const STATX_ATTR_AUTOMOUNT = 0x1000;
-
-pub const statx_timestamp = extern struct {
- tv_sec: i64,
- tv_nsec: u32,
- __pad1: u32,
-};
-
-/// Renamed to `Statx` to not conflict with the `statx` function.
-pub const Statx = extern struct {
- /// Mask of bits indicating filled fields
- mask: u32,
-
- /// Block size for filesystem I/O
- blksize: u32,
-
- /// Extra file attribute indicators
- attributes: u64,
-
- /// Number of hard links
- nlink: u32,
-
- /// User ID of owner
- uid: uid_t,
-
- /// Group ID of owner
- gid: gid_t,
-
- /// File type and mode
- mode: u16,
- __pad1: u16,
-
- /// Inode number
- ino: u64,
-
- /// Total size in bytes
- size: u64,
-
- /// Number of 512B blocks allocated
- blocks: u64,
-
- /// Mask to show what's supported in `attributes`.
- attributes_mask: u64,
-
- /// Last access file timestamp
- atime: statx_timestamp,
-
- /// Creation file timestamp
- btime: statx_timestamp,
-
- /// Last status change file timestamp
- ctime: statx_timestamp,
-
- /// Last modification file timestamp
- mtime: statx_timestamp,
-
- /// Major ID, if this file represents a device.
- rdev_major: u32,
-
- /// Minor ID, if this file represents a device.
- rdev_minor: u32,
-
- /// Major ID of the device containing the filesystem where this file resides.
- dev_major: u32,
-
- /// Minor ID of the device containing the filesystem where this file resides.
- dev_minor: u32,
-
- __pad2: [14]u64,
-};
-
-pub const addrinfo = extern struct {
- flags: i32,
- family: i32,
- socktype: i32,
- protocol: i32,
- addrlen: socklen_t,
- addr: ?*sockaddr,
- canonname: ?[*:0]u8,
- next: ?*addrinfo,
-};
-
-pub const IPPORT_RESERVED = 1024;
-
-pub const IPPROTO_IP = 0;
-pub const IPPROTO_HOPOPTS = 0;
-pub const IPPROTO_ICMP = 1;
-pub const IPPROTO_IGMP = 2;
-pub const IPPROTO_IPIP = 4;
-pub const IPPROTO_TCP = 6;
-pub const IPPROTO_EGP = 8;
-pub const IPPROTO_PUP = 12;
-pub const IPPROTO_UDP = 17;
-pub const IPPROTO_IDP = 22;
-pub const IPPROTO_TP = 29;
-pub const IPPROTO_DCCP = 33;
-pub const IPPROTO_IPV6 = 41;
-pub const IPPROTO_ROUTING = 43;
-pub const IPPROTO_FRAGMENT = 44;
-pub const IPPROTO_RSVP = 46;
-pub const IPPROTO_GRE = 47;
-pub const IPPROTO_ESP = 50;
-pub const IPPROTO_AH = 51;
-pub const IPPROTO_ICMPV6 = 58;
-pub const IPPROTO_NONE = 59;
-pub const IPPROTO_DSTOPTS = 60;
-pub const IPPROTO_MTP = 92;
-pub const IPPROTO_BEETPH = 94;
-pub const IPPROTO_ENCAP = 98;
-pub const IPPROTO_PIM = 103;
-pub const IPPROTO_COMP = 108;
-pub const IPPROTO_SCTP = 132;
-pub const IPPROTO_MH = 135;
-pub const IPPROTO_UDPLITE = 136;
-pub const IPPROTO_MPLS = 137;
-pub const IPPROTO_RAW = 255;
-pub const IPPROTO_MAX = 256;
-
-pub const RR_A = 1;
-pub const RR_CNAME = 5;
-pub const RR_AAAA = 28;
-
-/// Turn off Nagle's algorithm
-pub const TCP_NODELAY = 1;
-/// Limit MSS
-pub const TCP_MAXSEG = 2;
-/// Never send partially complete segments.
-pub const TCP_CORK = 3;
-/// Start keeplives after this period, in seconds
-pub const TCP_KEEPIDLE = 4;
-/// Interval between keepalives
-pub const TCP_KEEPINTVL = 5;
-/// Number of keepalives before death
-pub const TCP_KEEPCNT = 6;
-/// Number of SYN retransmits
-pub const TCP_SYNCNT = 7;
-/// Life time of orphaned FIN-WAIT-2 state
-pub const TCP_LINGER2 = 8;
-/// Wake up listener only when data arrive
-pub const TCP_DEFER_ACCEPT = 9;
-/// Bound advertised window
-pub const TCP_WINDOW_CLAMP = 10;
-/// Information about this connection.
-pub const TCP_INFO = 11;
-/// Block/reenable quick acks
-pub const TCP_QUICKACK = 12;
-/// Congestion control algorithm
-pub const TCP_CONGESTION = 13;
-/// TCP MD5 Signature (RFC2385)
-pub const TCP_MD5SIG = 14;
-/// Use linear timeouts for thin streams
-pub const TCP_THIN_LINEAR_TIMEOUTS = 16;
-/// Fast retrans. after 1 dupack
-pub const TCP_THIN_DUPACK = 17;
-/// How long for loss retry before timeout
-pub const TCP_USER_TIMEOUT = 18;
-/// TCP sock is under repair right now
-pub const TCP_REPAIR = 19;
-pub const TCP_REPAIR_QUEUE = 20;
-pub const TCP_QUEUE_SEQ = 21;
-pub const TCP_REPAIR_OPTIONS = 22;
-/// Enable FastOpen on listeners
-pub const TCP_FASTOPEN = 23;
-pub const TCP_TIMESTAMP = 24;
-/// limit number of unsent bytes in write queue
-pub const TCP_NOTSENT_LOWAT = 25;
-/// Get Congestion Control (optional) info
-pub const TCP_CC_INFO = 26;
-/// Record SYN headers for new connections
-pub const TCP_SAVE_SYN = 27;
-/// Get SYN headers recorded for connection
-pub const TCP_SAVED_SYN = 28;
-/// Get/set window parameters
-pub const TCP_REPAIR_WINDOW = 29;
-/// Attempt FastOpen with connect
-pub const TCP_FASTOPEN_CONNECT = 30;
-/// Attach a ULP to a TCP connection
-pub const TCP_ULP = 31;
-/// TCP MD5 Signature with extensions
-pub const TCP_MD5SIG_EXT = 32;
-/// Set the key for Fast Open (cookie)
-pub const TCP_FASTOPEN_KEY = 33;
-/// Enable TFO without a TFO cookie
-pub const TCP_FASTOPEN_NO_COOKIE = 34;
-pub const TCP_ZEROCOPY_RECEIVE = 35;
-/// Notify bytes available to read as a cmsg on read
-pub const TCP_INQ = 36;
-pub const TCP_CM_INQ = TCP_INQ;
-/// delay outgoing packets by XX usec
-pub const TCP_TX_DELAY = 37;
-
-pub const TCP_REPAIR_ON = 1;
-pub const TCP_REPAIR_OFF = 0;
-/// Turn off without window probes
-pub const TCP_REPAIR_OFF_NO_WP = -1;
-
-pub const tcp_repair_opt = extern struct {
- opt_code: u32,
- opt_val: u32,
-};
-
-pub const tcp_repair_window = extern struct {
- snd_wl1: u32,
- snd_wnd: u32,
- max_window: u32,
- rcv_wnd: u32,
- rcv_wup: u32,
-};
-
-pub const TcpRepairOption = enum {
- TCP_NO_QUEUE,
- TCP_RECV_QUEUE,
- TCP_SEND_QUEUE,
- TCP_QUEUES_NR,
-};
-
-/// why fastopen failed from client perspective
-pub const tcp_fastopen_client_fail = enum {
- /// catch-all
- TFO_STATUS_UNSPEC,
- /// if not in TFO_CLIENT_NO_COOKIE mode
- TFO_COOKIE_UNAVAILABLE,
- /// SYN-ACK did not ack SYN data
- TFO_DATA_NOT_ACKED,
- /// SYN-ACK did not ack SYN data after timeout
- TFO_SYN_RETRANSMITTED,
-};
-
-/// for TCP_INFO socket option
-pub const TCPI_OPT_TIMESTAMPS = 1;
-pub const TCPI_OPT_SACK = 2;
-pub const TCPI_OPT_WSCALE = 4;
-/// ECN was negociated at TCP session init
-pub const TCPI_OPT_ECN = 8;
-/// we received at least one packet with ECT
-pub const TCPI_OPT_ECN_SEEN = 16;
-/// SYN-ACK acked data in SYN sent or rcvd
-pub const TCPI_OPT_SYN_DATA = 32;
-
-pub const nfds_t = usize;
-pub const pollfd = extern struct {
- fd: fd_t,
- events: i16,
- revents: i16,
-};
-
-pub const POLLIN = 0x001;
-pub const POLLPRI = 0x002;
-pub const POLLOUT = 0x004;
-pub const POLLERR = 0x008;
-pub const POLLHUP = 0x010;
-pub const POLLNVAL = 0x020;
-pub const POLLRDNORM = 0x040;
-pub const POLLRDBAND = 0x080;
-
-pub const MFD_CLOEXEC = 0x0001;
-pub const MFD_ALLOW_SEALING = 0x0002;
-pub const MFD_HUGETLB = 0x0004;
-pub const MFD_ALL_FLAGS = MFD_CLOEXEC | MFD_ALLOW_SEALING | MFD_HUGETLB;
-
-pub const HUGETLB_FLAG_ENCODE_SHIFT = 26;
-pub const HUGETLB_FLAG_ENCODE_MASK = 0x3f;
-pub const HUGETLB_FLAG_ENCODE_64KB = 16 << HUGETLB_FLAG_ENCODE_SHIFT;
-pub const HUGETLB_FLAG_ENCODE_512KB = 19 << HUGETLB_FLAG_ENCODE_SHIFT;
-pub const HUGETLB_FLAG_ENCODE_1MB = 20 << HUGETLB_FLAG_ENCODE_SHIFT;
-pub const HUGETLB_FLAG_ENCODE_2MB = 21 << HUGETLB_FLAG_ENCODE_SHIFT;
-pub const HUGETLB_FLAG_ENCODE_8MB = 23 << HUGETLB_FLAG_ENCODE_SHIFT;
-pub const HUGETLB_FLAG_ENCODE_16MB = 24 << HUGETLB_FLAG_ENCODE_SHIFT;
-pub const HUGETLB_FLAG_ENCODE_32MB = 25 << HUGETLB_FLAG_ENCODE_SHIFT;
-pub const HUGETLB_FLAG_ENCODE_256MB = 28 << HUGETLB_FLAG_ENCODE_SHIFT;
-pub const HUGETLB_FLAG_ENCODE_512MB = 29 << HUGETLB_FLAG_ENCODE_SHIFT;
-pub const HUGETLB_FLAG_ENCODE_1GB = 30 << HUGETLB_FLAG_ENCODE_SHIFT;
-pub const HUGETLB_FLAG_ENCODE_2GB = 31 << HUGETLB_FLAG_ENCODE_SHIFT;
-pub const HUGETLB_FLAG_ENCODE_16GB = 34 << HUGETLB_FLAG_ENCODE_SHIFT;
-
-pub const MFD_HUGE_SHIFT = HUGETLB_FLAG_ENCODE_SHIFT;
-pub const MFD_HUGE_MASK = HUGETLB_FLAG_ENCODE_MASK;
-pub const MFD_HUGE_64KB = HUGETLB_FLAG_ENCODE_64KB;
-pub const MFD_HUGE_512KB = HUGETLB_FLAG_ENCODE_512KB;
-pub const MFD_HUGE_1MB = HUGETLB_FLAG_ENCODE_1MB;
-pub const MFD_HUGE_2MB = HUGETLB_FLAG_ENCODE_2MB;
-pub const MFD_HUGE_8MB = HUGETLB_FLAG_ENCODE_8MB;
-pub const MFD_HUGE_16MB = HUGETLB_FLAG_ENCODE_16MB;
-pub const MFD_HUGE_32MB = HUGETLB_FLAG_ENCODE_32MB;
-pub const MFD_HUGE_256MB = HUGETLB_FLAG_ENCODE_256MB;
-pub const MFD_HUGE_512MB = HUGETLB_FLAG_ENCODE_512MB;
-pub const MFD_HUGE_1GB = HUGETLB_FLAG_ENCODE_1GB;
-pub const MFD_HUGE_2GB = HUGETLB_FLAG_ENCODE_2GB;
-pub const MFD_HUGE_16GB = HUGETLB_FLAG_ENCODE_16GB;
-
-pub const RUSAGE_SELF = 0;
-pub const RUSAGE_CHILDREN = -1;
-pub const RUSAGE_THREAD = 1;
-
-pub const rusage = extern struct {
- utime: timeval,
- stime: timeval,
- maxrss: isize,
- ixrss: isize,
- idrss: isize,
- isrss: isize,
- minflt: isize,
- majflt: isize,
- nswap: isize,
- inblock: isize,
- oublock: isize,
- msgsnd: isize,
- msgrcv: isize,
- nsignals: isize,
- nvcsw: isize,
- nivcsw: isize,
- __reserved: [16]isize = [1]isize{0} ** 16,
-};
-
-pub const cc_t = u8;
-pub const speed_t = u32;
-pub const tcflag_t = u32;
-
-pub const NCCS = 32;
-
-pub const B0 = 0o0000000;
-pub const B50 = 0o0000001;
-pub const B75 = 0o0000002;
-pub const B110 = 0o0000003;
-pub const B134 = 0o0000004;
-pub const B150 = 0o0000005;
-pub const B200 = 0o0000006;
-pub const B300 = 0o0000007;
-pub const B600 = 0o0000010;
-pub const B1200 = 0o0000011;
-pub const B1800 = 0o0000012;
-pub const B2400 = 0o0000013;
-pub const B4800 = 0o0000014;
-pub const B9600 = 0o0000015;
-pub const B19200 = 0o0000016;
-pub const B38400 = 0o0000017;
-pub const BOTHER = 0o0010000;
-pub const B57600 = 0o0010001;
-pub const B115200 = 0o0010002;
-pub const B230400 = 0o0010003;
-pub const B460800 = 0o0010004;
-pub const B500000 = 0o0010005;
-pub const B576000 = 0o0010006;
-pub const B921600 = 0o0010007;
-pub const B1000000 = 0o0010010;
-pub const B1152000 = 0o0010011;
-pub const B1500000 = 0o0010012;
-pub const B2000000 = 0o0010013;
-pub const B2500000 = 0o0010014;
-pub const B3000000 = 0o0010015;
-pub const B3500000 = 0o0010016;
-pub const B4000000 = 0o0010017;
-
-pub usingnamespace switch (arch) {
- .powerpc, .powerpc64, .powerpc64le => struct {
- pub const VINTR = 0;
- pub const VQUIT = 1;
- pub const VERASE = 2;
- pub const VKILL = 3;
- pub const VEOF = 4;
- pub const VMIN = 5;
- pub const VEOL = 6;
- pub const VTIME = 7;
- pub const VEOL2 = 8;
- pub const VSWTC = 9;
- pub const VWERASE = 10;
- pub const VREPRINT = 11;
- pub const VSUSP = 12;
- pub const VSTART = 13;
- pub const VSTOP = 14;
- pub const VLNEXT = 15;
- pub const VDISCARD = 16;
- },
- .sparc, .sparcv9 => struct {
- pub const VINTR = 0;
- pub const VQUIT = 1;
- pub const VERASE = 2;
- pub const VKILL = 3;
- pub const VEOF = 4;
- pub const VEOL = 5;
- pub const VEOL2 = 6;
- pub const VSWTC = 7;
- pub const VSTART = 8;
- pub const VSTOP = 9;
- pub const VSUSP = 10;
- pub const VDSUSP = 11;
- pub const VREPRINT = 12;
- pub const VDISCARD = 13;
- pub const VWERASE = 14;
- pub const VLNEXT = 15;
- pub const VMIN = VEOF;
- pub const VTIME = VEOL;
- },
- .mips, .mipsel, .mips64, .mips64el => struct {
- pub const VINTR = 0;
- pub const VQUIT = 1;
- pub const VERASE = 2;
- pub const VKILL = 3;
- pub const VMIN = 4;
- pub const VTIME = 5;
- pub const VEOL2 = 6;
- pub const VSWTC = 7;
- pub const VSWTCH = 7;
- pub const VSTART = 8;
- pub const VSTOP = 9;
- pub const VSUSP = 10;
- pub const VREPRINT = 12;
- pub const VDISCARD = 13;
- pub const VWERASE = 14;
- pub const VLNEXT = 15;
- pub const VEOF = 16;
- pub const VEOL = 17;
- },
- else => struct {
- pub const VINTR = 0;
- pub const VQUIT = 1;
- pub const VERASE = 2;
- pub const VKILL = 3;
- pub const VEOF = 4;
- pub const VTIME = 5;
- pub const VMIN = 6;
- pub const VSWTC = 7;
- pub const VSTART = 8;
- pub const VSTOP = 9;
- pub const VSUSP = 10;
- pub const VEOL = 11;
- pub const VREPRINT = 12;
- pub const VDISCARD = 13;
- pub const VWERASE = 14;
- pub const VLNEXT = 15;
- pub const VEOL2 = 16;
- },
-};
-
-pub const IGNBRK = 1;
-pub const BRKINT = 2;
-pub const IGNPAR = 4;
-pub const PARMRK = 8;
-pub const INPCK = 16;
-pub const ISTRIP = 32;
-pub const INLCR = 64;
-pub const IGNCR = 128;
-pub const ICRNL = 256;
-pub const IUCLC = 512;
-pub const IXON = 1024;
-pub const IXANY = 2048;
-pub const IXOFF = 4096;
-pub const IMAXBEL = 8192;
-pub const IUTF8 = 16384;
-
-pub const OPOST = 1;
-pub const OLCUC = 2;
-pub const ONLCR = 4;
-pub const OCRNL = 8;
-pub const ONOCR = 16;
-pub const ONLRET = 32;
-pub const OFILL = 64;
-pub const OFDEL = 128;
-pub const VTDLY = 16384;
-pub const VT0 = 0;
-pub const VT1 = 16384;
-
-pub const CSIZE = 48;
-pub const CS5 = 0;
-pub const CS6 = 16;
-pub const CS7 = 32;
-pub const CS8 = 48;
-pub const CSTOPB = 64;
-pub const CREAD = 128;
-pub const PARENB = 256;
-pub const PARODD = 512;
-pub const HUPCL = 1024;
-pub const CLOCAL = 2048;
-
-pub const ISIG = 1;
-pub const ICANON = 2;
-pub const ECHO = 8;
-pub const ECHOE = 16;
-pub const ECHOK = 32;
-pub const ECHONL = 64;
-pub const NOFLSH = 128;
-pub const TOSTOP = 256;
-pub const IEXTEN = 32768;
-
-pub const TCSA = enum(c_uint) {
- NOW,
- DRAIN,
- FLUSH,
- _,
-};
-
-pub const termios = extern struct {
- iflag: tcflag_t,
- oflag: tcflag_t,
- cflag: tcflag_t,
- lflag: tcflag_t,
- line: cc_t,
- cc: [NCCS]cc_t,
- ispeed: speed_t,
- ospeed: speed_t,
-};
-
-pub const SIOCGIFINDEX = 0x8933;
-pub const IFNAMESIZE = 16;
-
-pub const ifmap = extern struct {
- mem_start: u32,
- mem_end: u32,
- base_addr: u16,
- irq: u8,
- dma: u8,
- port: u8,
-};
-
-pub const ifreq = extern struct {
- ifrn: extern union {
- name: [IFNAMESIZE]u8,
- },
- ifru: extern union {
- addr: sockaddr,
- dstaddr: sockaddr,
- broadaddr: sockaddr,
- netmask: sockaddr,
- hwaddr: sockaddr,
- flags: i16,
- ivalue: i32,
- mtu: i32,
- map: ifmap,
- slave: [IFNAMESIZE - 1:0]u8,
- newname: [IFNAMESIZE - 1:0]u8,
- data: ?[*]u8,
- },
-};
-
-// doc comments copied from musl
-pub const rlimit_resource = enum(c_int) {
- /// Per-process CPU limit, in seconds.
- CPU,
-
- /// Largest file that can be created, in bytes.
- FSIZE,
-
- /// Maximum size of data segment, in bytes.
- DATA,
-
- /// Maximum size of stack segment, in bytes.
- STACK,
-
- /// Largest core file that can be created, in bytes.
- CORE,
-
- /// Largest resident set size, in bytes.
- /// This affects swapping; processes that are exceeding their
- /// resident set size will be more likely to have physical memory
- /// taken from them.
- RSS,
-
- /// Number of processes.
- NPROC,
-
- /// Number of open files.
- NOFILE,
-
- /// Locked-in-memory address space.
- MEMLOCK,
-
- /// Address space limit.
- AS,
-
- /// Maximum number of file locks.
- LOCKS,
-
- /// Maximum number of pending signals.
- SIGPENDING,
-
- /// Maximum bytes in POSIX message queues.
- MSGQUEUE,
-
- /// Maximum nice priority allowed to raise to.
- /// Nice levels 19 .. -20 correspond to 0 .. 39
- /// values of this resource limit.
- NICE,
-
- /// Maximum realtime priority allowed for non-priviledged
- /// processes.
- RTPRIO,
-
- /// Maximum CPU time in µs that a process scheduled under a real-time
- /// scheduling policy may consume without making a blocking system
- /// call before being forcibly descheduled.
- RTTIME,
-
- _,
-};
-
-pub const rlim_t = u64;
-
-/// No limit
-pub const RLIM_INFINITY = ~@as(rlim_t, 0);
-
-pub const RLIM_SAVED_MAX = RLIM_INFINITY;
-pub const RLIM_SAVED_CUR = RLIM_INFINITY;
-
-pub const rlimit = extern struct {
- /// Soft limit
- cur: rlim_t,
- /// Hard limit
- max: rlim_t,
-};
-
-pub const MADV_NORMAL = 0;
-pub const MADV_RANDOM = 1;
-pub const MADV_SEQUENTIAL = 2;
-pub const MADV_WILLNEED = 3;
-pub const MADV_DONTNEED = 4;
-pub const MADV_FREE = 8;
-pub const MADV_REMOVE = 9;
-pub const MADV_DONTFORK = 10;
-pub const MADV_DOFORK = 11;
-pub const MADV_MERGEABLE = 12;
-pub const MADV_UNMERGEABLE = 13;
-pub const MADV_HUGEPAGE = 14;
-pub const MADV_NOHUGEPAGE = 15;
-pub const MADV_DONTDUMP = 16;
-pub const MADV_DODUMP = 17;
-pub const MADV_WIPEONFORK = 18;
-pub const MADV_KEEPONFORK = 19;
-pub const MADV_COLD = 20;
-pub const MADV_PAGEOUT = 21;
-pub const MADV_HWPOISON = 100;
-pub const MADV_SOFT_OFFLINE = 101;
-
-pub const POSIX_FADV_NORMAL = 0;
-pub const POSIX_FADV_RANDOM = 1;
-pub const POSIX_FADV_SEQUENTIAL = 2;
-pub const POSIX_FADV_WILLNEED = 3;
-pub usingnamespace switch (arch) {
- .s390x => if (@typeInfo(usize).Int.bits == 64)
- struct {
- pub const POSIX_FADV_DONTNEED = 6;
- pub const POSIX_FADV_NOREUSE = 7;
- }
- else
- struct {
- pub const POSIX_FADV_DONTNEED = 4;
- pub const POSIX_FADV_NOREUSE = 5;
- },
- else => struct {
- pub const POSIX_FADV_DONTNEED = 4;
- pub const POSIX_FADV_NOREUSE = 5;
- },
-};
-
-pub const __kernel_timespec = extern struct {
- tv_sec: i64,
- tv_nsec: i64,
-};
diff --git a/lib/std/os/bits/linux/arm-eabi.zig b/lib/std/os/bits/linux/arm-eabi.zig
deleted file mode 100644
index 91ca2b32d2b4..000000000000
--- a/lib/std/os/bits/linux/arm-eabi.zig
+++ /dev/null
@@ -1,636 +0,0 @@
-// arm-eabi-specific declarations that are intended to be imported into the POSIX namespace.
-const std = @import("../../../std.zig");
-const linux = std.os.linux;
-const socklen_t = linux.socklen_t;
-const iovec = linux.iovec;
-const iovec_const = linux.iovec_const;
-const stack_t = linux.stack_t;
-const sigset_t = linux.sigset_t;
-const uid_t = linux.uid_t;
-const gid_t = linux.gid_t;
-const pid_t = linux.pid_t;
-
-pub const SYS = enum(usize) {
- restart_syscall = 0,
- exit = 1,
- fork = 2,
- read = 3,
- write = 4,
- open = 5,
- close = 6,
- creat = 8,
- link = 9,
- unlink = 10,
- execve = 11,
- chdir = 12,
- mknod = 14,
- chmod = 15,
- lchown = 16,
- lseek = 19,
- getpid = 20,
- mount = 21,
- setuid = 23,
- getuid = 24,
- ptrace = 26,
- pause = 29,
- access = 33,
- nice = 34,
- sync = 36,
- kill = 37,
- rename = 38,
- mkdir = 39,
- rmdir = 40,
- dup = 41,
- pipe = 42,
- times = 43,
- brk = 45,
- setgid = 46,
- getgid = 47,
- geteuid = 49,
- getegid = 50,
- acct = 51,
- umount2 = 52,
- ioctl = 54,
- fcntl = 55,
- setpgid = 57,
- umask = 60,
- chroot = 61,
- ustat = 62,
- dup2 = 63,
- getppid = 64,
- getpgrp = 65,
- setsid = 66,
- sigaction = 67,
- setreuid = 70,
- setregid = 71,
- sigsuspend = 72,
- sigpending = 73,
- sethostname = 74,
- setrlimit = 75,
- getrusage = 77,
- gettimeofday = 78,
- settimeofday = 79,
- getgroups = 80,
- setgroups = 81,
- symlink = 83,
- readlink = 85,
- uselib = 86,
- swapon = 87,
- reboot = 88,
- munmap = 91,
- truncate = 92,
- ftruncate = 93,
- fchmod = 94,
- fchown = 95,
- getpriority = 96,
- setpriority = 97,
- statfs = 99,
- fstatfs = 100,
- syslog = 103,
- setitimer = 104,
- getitimer = 105,
- stat = 106,
- lstat = 107,
- fstat = 108,
- vhangup = 111,
- wait4 = 114,
- swapoff = 115,
- sysinfo = 116,
- fsync = 118,
- sigreturn = 119,
- clone = 120,
- setdomainname = 121,
- uname = 122,
- adjtimex = 124,
- mprotect = 125,
- sigprocmask = 126,
- init_module = 128,
- delete_module = 129,
- quotactl = 131,
- getpgid = 132,
- fchdir = 133,
- bdflush = 134,
- sysfs = 135,
- personality = 136,
- setfsuid = 138,
- setfsgid = 139,
- _llseek = 140,
- getdents = 141,
- _newselect = 142,
- flock = 143,
- msync = 144,
- readv = 145,
- writev = 146,
- getsid = 147,
- fdatasync = 148,
- _sysctl = 149,
- mlock = 150,
- munlock = 151,
- mlockall = 152,
- munlockall = 153,
- sched_setparam = 154,
- sched_getparam = 155,
- sched_setscheduler = 156,
- sched_getscheduler = 157,
- sched_yield = 158,
- sched_get_priority_max = 159,
- sched_get_priority_min = 160,
- sched_rr_get_interval = 161,
- nanosleep = 162,
- mremap = 163,
- setresuid = 164,
- getresuid = 165,
- poll = 168,
- nfsservctl = 169,
- setresgid = 170,
- getresgid = 171,
- prctl = 172,
- rt_sigreturn = 173,
- rt_sigaction = 174,
- rt_sigprocmask = 175,
- rt_sigpending = 176,
- rt_sigtimedwait = 177,
- rt_sigqueueinfo = 178,
- rt_sigsuspend = 179,
- pread64 = 180,
- pwrite64 = 181,
- chown = 182,
- getcwd = 183,
- capget = 184,
- capset = 185,
- sigaltstack = 186,
- sendfile = 187,
- vfork = 190,
- ugetrlimit = 191,
- mmap2 = 192,
- truncate64 = 193,
- ftruncate64 = 194,
- stat64 = 195,
- lstat64 = 196,
- fstat64 = 197,
- lchown32 = 198,
- getuid32 = 199,
- getgid32 = 200,
- geteuid32 = 201,
- getegid32 = 202,
- setreuid32 = 203,
- setregid32 = 204,
- getgroups32 = 205,
- setgroups32 = 206,
- fchown32 = 207,
- setresuid32 = 208,
- getresuid32 = 209,
- setresgid32 = 210,
- getresgid32 = 211,
- chown32 = 212,
- setuid32 = 213,
- setgid32 = 214,
- setfsuid32 = 215,
- setfsgid32 = 216,
- getdents64 = 217,
- pivot_root = 218,
- mincore = 219,
- madvise = 220,
- fcntl64 = 221,
- gettid = 224,
- readahead = 225,
- setxattr = 226,
- lsetxattr = 227,
- fsetxattr = 228,
- getxattr = 229,
- lgetxattr = 230,
- fgetxattr = 231,
- listxattr = 232,
- llistxattr = 233,
- flistxattr = 234,
- removexattr = 235,
- lremovexattr = 236,
- fremovexattr = 237,
- tkill = 238,
- sendfile64 = 239,
- futex = 240,
- sched_setaffinity = 241,
- sched_getaffinity = 242,
- io_setup = 243,
- io_destroy = 244,
- io_getevents = 245,
- io_submit = 246,
- io_cancel = 247,
- exit_group = 248,
- lookup_dcookie = 249,
- epoll_create = 250,
- epoll_ctl = 251,
- epoll_wait = 252,
- remap_file_pages = 253,
- set_tid_address = 256,
- timer_create = 257,
- timer_settime = 258,
- timer_gettime = 259,
- timer_getoverrun = 260,
- timer_delete = 261,
- clock_settime = 262,
- clock_gettime = 263,
- clock_getres = 264,
- clock_nanosleep = 265,
- statfs64 = 266,
- fstatfs64 = 267,
- tgkill = 268,
- utimes = 269,
- fadvise64_64 = 270,
- pciconfig_iobase = 271,
- pciconfig_read = 272,
- pciconfig_write = 273,
- mq_open = 274,
- mq_unlink = 275,
- mq_timedsend = 276,
- mq_timedreceive = 277,
- mq_notify = 278,
- mq_getsetattr = 279,
- waitid = 280,
- socket = 281,
- bind = 282,
- connect = 283,
- listen = 284,
- accept = 285,
- getsockname = 286,
- getpeername = 287,
- socketpair = 288,
- send = 289,
- sendto = 290,
- recv = 291,
- recvfrom = 292,
- shutdown = 293,
- setsockopt = 294,
- getsockopt = 295,
- sendmsg = 296,
- recvmsg = 297,
- semop = 298,
- semget = 299,
- semctl = 300,
- msgsnd = 301,
- msgrcv = 302,
- msgget = 303,
- msgctl = 304,
- shmat = 305,
- shmdt = 306,
- shmget = 307,
- shmctl = 308,
- add_key = 309,
- request_key = 310,
- keyctl = 311,
- semtimedop = 312,
- vserver = 313,
- ioprio_set = 314,
- ioprio_get = 315,
- inotify_init = 316,
- inotify_add_watch = 317,
- inotify_rm_watch = 318,
- mbind = 319,
- get_mempolicy = 320,
- set_mempolicy = 321,
- openat = 322,
- mkdirat = 323,
- mknodat = 324,
- fchownat = 325,
- futimesat = 326,
- fstatat64 = 327,
- unlinkat = 328,
- renameat = 329,
- linkat = 330,
- symlinkat = 331,
- readlinkat = 332,
- fchmodat = 333,
- faccessat = 334,
- pselect6 = 335,
- ppoll = 336,
- unshare = 337,
- set_robust_list = 338,
- get_robust_list = 339,
- splice = 340,
- sync_file_range = 341,
- tee = 342,
- vmsplice = 343,
- move_pages = 344,
- getcpu = 345,
- epoll_pwait = 346,
- kexec_load = 347,
- utimensat = 348,
- signalfd = 349,
- timerfd_create = 350,
- eventfd = 351,
- fallocate = 352,
- timerfd_settime = 353,
- timerfd_gettime = 354,
- signalfd4 = 355,
- eventfd2 = 356,
- epoll_create1 = 357,
- dup3 = 358,
- pipe2 = 359,
- inotify_init1 = 360,
- preadv = 361,
- pwritev = 362,
- rt_tgsigqueueinfo = 363,
- perf_event_open = 364,
- recvmmsg = 365,
- accept4 = 366,
- fanotify_init = 367,
- fanotify_mark = 368,
- prlimit64 = 369,
- name_to_handle_at = 370,
- open_by_handle_at = 371,
- clock_adjtime = 372,
- syncfs = 373,
- sendmmsg = 374,
- setns = 375,
- process_vm_readv = 376,
- process_vm_writev = 377,
- kcmp = 378,
- finit_module = 379,
- sched_setattr = 380,
- sched_getattr = 381,
- renameat2 = 382,
- seccomp = 383,
- getrandom = 384,
- memfd_create = 385,
- bpf = 386,
- execveat = 387,
- userfaultfd = 388,
- membarrier = 389,
- mlock2 = 390,
- copy_file_range = 391,
- preadv2 = 392,
- pwritev2 = 393,
- pkey_mprotect = 394,
- pkey_alloc = 395,
- pkey_free = 396,
- statx = 397,
- rseq = 398,
- io_pgetevents = 399,
- migrate_pages = 400,
- kexec_file_load = 401,
- clock_gettime64 = 403,
- clock_settime64 = 404,
- clock_adjtime64 = 405,
- clock_getres_time64 = 406,
- clock_nanosleep_time64 = 407,
- timer_gettime64 = 408,
- timer_settime64 = 409,
- timerfd_gettime64 = 410,
- timerfd_settime64 = 411,
- utimensat_time64 = 412,
- pselect6_time64 = 413,
- ppoll_time64 = 414,
- io_pgetevents_time64 = 416,
- recvmmsg_time64 = 417,
- mq_timedsend_time64 = 418,
- mq_timedreceive_time64 = 419,
- semtimedop_time64 = 420,
- rt_sigtimedwait_time64 = 421,
- futex_time64 = 422,
- sched_rr_get_interval_time64 = 423,
- pidfd_send_signal = 424,
- io_uring_setup = 425,
- io_uring_enter = 426,
- io_uring_register = 427,
- open_tree = 428,
- move_mount = 429,
- fsopen = 430,
- fsconfig = 431,
- fsmount = 432,
- fspick = 433,
- pidfd_open = 434,
- clone3 = 435,
- close_range = 436,
- openat2 = 437,
- pidfd_getfd = 438,
- faccessat2 = 439,
- process_madvise = 440,
- epoll_pwait2 = 441,
-
- breakpoint = 0x0f0001,
- cacheflush = 0x0f0002,
- usr26 = 0x0f0003,
- usr32 = 0x0f0004,
- set_tls = 0x0f0005,
- get_tls = 0x0f0006,
-
- _,
-};
-
-pub const MMAP2_UNIT = 4096;
-
-pub const O_CREAT = 0o100;
-pub const O_EXCL = 0o200;
-pub const O_NOCTTY = 0o400;
-pub const O_TRUNC = 0o1000;
-pub const O_APPEND = 0o2000;
-pub const O_NONBLOCK = 0o4000;
-pub const O_DSYNC = 0o10000;
-pub const O_SYNC = 0o4010000;
-pub const O_RSYNC = 0o4010000;
-pub const O_DIRECTORY = 0o40000;
-pub const O_NOFOLLOW = 0o100000;
-pub const O_CLOEXEC = 0o2000000;
-
-pub const O_ASYNC = 0o20000;
-pub const O_DIRECT = 0o200000;
-pub const O_LARGEFILE = 0o400000;
-pub const O_NOATIME = 0o1000000;
-pub const O_PATH = 0o10000000;
-pub const O_TMPFILE = 0o20040000;
-pub const O_NDELAY = O_NONBLOCK;
-
-pub const F_DUPFD = 0;
-pub const F_GETFD = 1;
-pub const F_SETFD = 2;
-pub const F_GETFL = 3;
-pub const F_SETFL = 4;
-
-pub const F_SETOWN = 8;
-pub const F_GETOWN = 9;
-pub const F_SETSIG = 10;
-pub const F_GETSIG = 11;
-
-pub const F_GETLK = 12;
-pub const F_SETLK = 13;
-pub const F_SETLKW = 14;
-
-pub const F_RDLCK = 0;
-pub const F_WRLCK = 1;
-pub const F_UNLCK = 2;
-
-pub const F_SETOWN_EX = 15;
-pub const F_GETOWN_EX = 16;
-
-pub const F_GETOWNER_UIDS = 17;
-
-pub const LOCK_SH = 1;
-pub const LOCK_EX = 2;
-pub const LOCK_UN = 8;
-pub const LOCK_NB = 4;
-
-/// stack-like segment
-pub const MAP_GROWSDOWN = 0x0100;
-
-/// ETXTBSY
-pub const MAP_DENYWRITE = 0x0800;
-
-/// mark it as an executable
-pub const MAP_EXECUTABLE = 0x1000;
-
-/// pages are locked
-pub const MAP_LOCKED = 0x2000;
-
-/// don't check for reservations
-pub const MAP_NORESERVE = 0x4000;
-
-pub const VDSO_CGT_SYM = "__vdso_clock_gettime";
-pub const VDSO_CGT_VER = "LINUX_2.6";
-
-pub const HWCAP_SWP = 1 << 0;
-pub const HWCAP_HALF = 1 << 1;
-pub const HWCAP_THUMB = 1 << 2;
-pub const HWCAP_26BIT = 1 << 3;
-pub const HWCAP_FAST_MULT = 1 << 4;
-pub const HWCAP_FPA = 1 << 5;
-pub const HWCAP_VFP = 1 << 6;
-pub const HWCAP_EDSP = 1 << 7;
-pub const HWCAP_JAVA = 1 << 8;
-pub const HWCAP_IWMMXT = 1 << 9;
-pub const HWCAP_CRUNCH = 1 << 10;
-pub const HWCAP_THUMBEE = 1 << 11;
-pub const HWCAP_NEON = 1 << 12;
-pub const HWCAP_VFPv3 = 1 << 13;
-pub const HWCAP_VFPv3D16 = 1 << 14;
-pub const HWCAP_TLS = 1 << 15;
-pub const HWCAP_VFPv4 = 1 << 16;
-pub const HWCAP_IDIVA = 1 << 17;
-pub const HWCAP_IDIVT = 1 << 18;
-pub const HWCAP_VFPD32 = 1 << 19;
-pub const HWCAP_IDIV = HWCAP_IDIVA | HWCAP_IDIVT;
-pub const HWCAP_LPAE = 1 << 20;
-pub const HWCAP_EVTSTRM = 1 << 21;
-
-pub const Flock = extern struct {
- l_type: i16,
- l_whence: i16,
- __pad0: [4]u8,
- l_start: off_t,
- l_len: off_t,
- l_pid: pid_t,
- __unused: [4]u8,
-};
-
-pub const msghdr = extern struct {
- msg_name: ?*sockaddr,
- msg_namelen: socklen_t,
- msg_iov: [*]iovec,
- msg_iovlen: i32,
- msg_control: ?*c_void,
- msg_controllen: socklen_t,
- msg_flags: i32,
-};
-
-pub const msghdr_const = extern struct {
- msg_name: ?*const sockaddr,
- msg_namelen: socklen_t,
- msg_iov: [*]iovec_const,
- msg_iovlen: i32,
- msg_control: ?*c_void,
- msg_controllen: socklen_t,
- msg_flags: i32,
-};
-
-pub const blksize_t = i32;
-pub const nlink_t = u32;
-pub const time_t = isize;
-pub const mode_t = u32;
-pub const off_t = i64;
-pub const ino_t = u64;
-pub const dev_t = u64;
-pub const blkcnt_t = i64;
-
-// The `stat` definition used by the Linux kernel.
-pub const kernel_stat = extern struct {
- dev: dev_t,
- __dev_padding: u32,
- __ino_truncated: u32,
- mode: mode_t,
- nlink: nlink_t,
- uid: uid_t,
- gid: gid_t,
- rdev: dev_t,
- __rdev_padding: u32,
- size: off_t,
- blksize: blksize_t,
- blocks: blkcnt_t,
- atim: timespec,
- mtim: timespec,
- ctim: timespec,
- ino: ino_t,
-
- pub fn atime(self: @This()) timespec {
- return self.atim;
- }
-
- pub fn mtime(self: @This()) timespec {
- return self.mtim;
- }
-
- pub fn ctime(self: @This()) timespec {
- return self.ctim;
- }
-};
-
-// The `stat64` definition used by the libc.
-pub const libc_stat = kernel_stat;
-
-pub const timespec = extern struct {
- tv_sec: i32,
- tv_nsec: i32,
-};
-
-pub const timeval = extern struct {
- tv_sec: i32,
- tv_usec: i32,
-};
-
-pub const timezone = extern struct {
- tz_minuteswest: i32,
- tz_dsttime: i32,
-};
-
-pub const mcontext_t = extern struct {
- trap_no: usize,
- error_code: usize,
- oldmask: usize,
- arm_r0: usize,
- arm_r1: usize,
- arm_r2: usize,
- arm_r3: usize,
- arm_r4: usize,
- arm_r5: usize,
- arm_r6: usize,
- arm_r7: usize,
- arm_r8: usize,
- arm_r9: usize,
- arm_r10: usize,
- arm_fp: usize,
- arm_ip: usize,
- arm_sp: usize,
- arm_lr: usize,
- arm_pc: usize,
- arm_cpsr: usize,
- fault_address: usize,
-};
-
-pub const ucontext_t = extern struct {
- flags: usize,
- link: *ucontext_t,
- stack: stack_t,
- mcontext: mcontext_t,
- sigmask: sigset_t,
- regspace: [64]u64,
-};
-
-pub const Elf_Symndx = u32;
diff --git a/lib/std/os/bits/linux/arm64.zig b/lib/std/os/bits/linux/arm64.zig
deleted file mode 100644
index 67c77ce186cf..000000000000
--- a/lib/std/os/bits/linux/arm64.zig
+++ /dev/null
@@ -1,495 +0,0 @@
-// arm64-specific declarations that are intended to be imported into the POSIX namespace.
-// This does include Linux-only APIs.
-
-const std = @import("../../../std.zig");
-const linux = std.os.linux;
-const socklen_t = linux.socklen_t;
-const sockaddr = linux.sockaddr;
-const iovec = linux.iovec;
-const iovec_const = linux.iovec_const;
-const uid_t = linux.uid_t;
-const gid_t = linux.gid_t;
-const pid_t = linux.pid_t;
-const stack_t = linux.stack_t;
-const sigset_t = linux.sigset_t;
-pub const SYS = enum(usize) {
- io_setup = 0,
- io_destroy = 1,
- io_submit = 2,
- io_cancel = 3,
- io_getevents = 4,
- setxattr = 5,
- lsetxattr = 6,
- fsetxattr = 7,
- getxattr = 8,
- lgetxattr = 9,
- fgetxattr = 10,
- listxattr = 11,
- llistxattr = 12,
- flistxattr = 13,
- removexattr = 14,
- lremovexattr = 15,
- fremovexattr = 16,
- getcwd = 17,
- lookup_dcookie = 18,
- eventfd2 = 19,
- epoll_create1 = 20,
- epoll_ctl = 21,
- epoll_pwait = 22,
- dup = 23,
- dup3 = 24,
- fcntl = 25,
- inotify_init1 = 26,
- inotify_add_watch = 27,
- inotify_rm_watch = 28,
- ioctl = 29,
- ioprio_set = 30,
- ioprio_get = 31,
- flock = 32,
- mknodat = 33,
- mkdirat = 34,
- unlinkat = 35,
- symlinkat = 36,
- linkat = 37,
- renameat = 38,
- umount2 = 39,
- mount = 40,
- pivot_root = 41,
- nfsservctl = 42,
- statfs = 43,
- fstatfs = 44,
- truncate = 45,
- ftruncate = 46,
- fallocate = 47,
- faccessat = 48,
- chdir = 49,
- fchdir = 50,
- chroot = 51,
- fchmod = 52,
- fchmodat = 53,
- fchownat = 54,
- fchown = 55,
- openat = 56,
- close = 57,
- vhangup = 58,
- pipe2 = 59,
- quotactl = 60,
- getdents64 = 61,
- lseek = 62,
- read = 63,
- write = 64,
- readv = 65,
- writev = 66,
- pread64 = 67,
- pwrite64 = 68,
- preadv = 69,
- pwritev = 70,
- sendfile = 71,
- pselect6 = 72,
- ppoll = 73,
- signalfd4 = 74,
- vmsplice = 75,
- splice = 76,
- tee = 77,
- readlinkat = 78,
- fstatat = 79,
- fstat = 80,
- sync = 81,
- fsync = 82,
- fdatasync = 83,
- sync_file_range = 84,
- timerfd_create = 85,
- timerfd_settime = 86,
- timerfd_gettime = 87,
- utimensat = 88,
- acct = 89,
- capget = 90,
- capset = 91,
- personality = 92,
- exit = 93,
- exit_group = 94,
- waitid = 95,
- set_tid_address = 96,
- unshare = 97,
- futex = 98,
- set_robust_list = 99,
- get_robust_list = 100,
- nanosleep = 101,
- getitimer = 102,
- setitimer = 103,
- kexec_load = 104,
- init_module = 105,
- delete_module = 106,
- timer_create = 107,
- timer_gettime = 108,
- timer_getoverrun = 109,
- timer_settime = 110,
- timer_delete = 111,
- clock_settime = 112,
- clock_gettime = 113,
- clock_getres = 114,
- clock_nanosleep = 115,
- syslog = 116,
- ptrace = 117,
- sched_setparam = 118,
- sched_setscheduler = 119,
- sched_getscheduler = 120,
- sched_getparam = 121,
- sched_setaffinity = 122,
- sched_getaffinity = 123,
- sched_yield = 124,
- sched_get_priority_max = 125,
- sched_get_priority_min = 126,
- sched_rr_get_interval = 127,
- restart_syscall = 128,
- kill = 129,
- tkill = 130,
- tgkill = 131,
- sigaltstack = 132,
- rt_sigsuspend = 133,
- rt_sigaction = 134,
- rt_sigprocmask = 135,
- rt_sigpending = 136,
- rt_sigtimedwait = 137,
- rt_sigqueueinfo = 138,
- rt_sigreturn = 139,
- setpriority = 140,
- getpriority = 141,
- reboot = 142,
- setregid = 143,
- setgid = 144,
- setreuid = 145,
- setuid = 146,
- setresuid = 147,
- getresuid = 148,
- setresgid = 149,
- getresgid = 150,
- setfsuid = 151,
- setfsgid = 152,
- times = 153,
- setpgid = 154,
- getpgid = 155,
- getsid = 156,
- setsid = 157,
- getgroups = 158,
- setgroups = 159,
- uname = 160,
- sethostname = 161,
- setdomainname = 162,
- getrlimit = 163,
- setrlimit = 164,
- getrusage = 165,
- umask = 166,
- prctl = 167,
- getcpu = 168,
- gettimeofday = 169,
- settimeofday = 170,
- adjtimex = 171,
- getpid = 172,
- getppid = 173,
- getuid = 174,
- geteuid = 175,
- getgid = 176,
- getegid = 177,
- gettid = 178,
- sysinfo = 179,
- mq_open = 180,
- mq_unlink = 181,
- mq_timedsend = 182,
- mq_timedreceive = 183,
- mq_notify = 184,
- mq_getsetattr = 185,
- msgget = 186,
- msgctl = 187,
- msgrcv = 188,
- msgsnd = 189,
- semget = 190,
- semctl = 191,
- semtimedop = 192,
- semop = 193,
- shmget = 194,
- shmctl = 195,
- shmat = 196,
- shmdt = 197,
- socket = 198,
- socketpair = 199,
- bind = 200,
- listen = 201,
- accept = 202,
- connect = 203,
- getsockname = 204,
- getpeername = 205,
- sendto = 206,
- recvfrom = 207,
- setsockopt = 208,
- getsockopt = 209,
- shutdown = 210,
- sendmsg = 211,
- recvmsg = 212,
- readahead = 213,
- brk = 214,
- munmap = 215,
- mremap = 216,
- add_key = 217,
- request_key = 218,
- keyctl = 219,
- clone = 220,
- execve = 221,
- mmap = 222,
- fadvise64 = 223,
- swapon = 224,
- swapoff = 225,
- mprotect = 226,
- msync = 227,
- mlock = 228,
- munlock = 229,
- mlockall = 230,
- munlockall = 231,
- mincore = 232,
- madvise = 233,
- remap_file_pages = 234,
- mbind = 235,
- get_mempolicy = 236,
- set_mempolicy = 237,
- migrate_pages = 238,
- move_pages = 239,
- rt_tgsigqueueinfo = 240,
- perf_event_open = 241,
- accept4 = 242,
- recvmmsg = 243,
- arch_specific_syscall = 244,
- wait4 = 260,
- prlimit64 = 261,
- fanotify_init = 262,
- fanotify_mark = 263,
- clock_adjtime = 266,
- syncfs = 267,
- setns = 268,
- sendmmsg = 269,
- process_vm_readv = 270,
- process_vm_writev = 271,
- kcmp = 272,
- finit_module = 273,
- sched_setattr = 274,
- sched_getattr = 275,
- renameat2 = 276,
- seccomp = 277,
- getrandom = 278,
- memfd_create = 279,
- bpf = 280,
- execveat = 281,
- userfaultfd = 282,
- membarrier = 283,
- mlock2 = 284,
- copy_file_range = 285,
- preadv2 = 286,
- pwritev2 = 287,
- pkey_mprotect = 288,
- pkey_alloc = 289,
- pkey_free = 290,
- statx = 291,
- io_pgetevents = 292,
- rseq = 293,
- kexec_file_load = 294,
- pidfd_send_signal = 424,
- io_uring_setup = 425,
- io_uring_enter = 426,
- io_uring_register = 427,
- open_tree = 428,
- move_mount = 429,
- fsopen = 430,
- fsconfig = 431,
- fsmount = 432,
- fspick = 433,
- pidfd_open = 434,
- clone3 = 435,
- close_range = 436,
- openat2 = 437,
- pidfd_getfd = 438,
- faccessat2 = 439,
- process_madvise = 440,
- epoll_pwait2 = 441,
-
- _,
-};
-
-pub const O_CREAT = 0o100;
-pub const O_EXCL = 0o200;
-pub const O_NOCTTY = 0o400;
-pub const O_TRUNC = 0o1000;
-pub const O_APPEND = 0o2000;
-pub const O_NONBLOCK = 0o4000;
-pub const O_DSYNC = 0o10000;
-pub const O_SYNC = 0o4010000;
-pub const O_RSYNC = 0o4010000;
-pub const O_DIRECTORY = 0o40000;
-pub const O_NOFOLLOW = 0o100000;
-pub const O_CLOEXEC = 0o2000000;
-
-pub const O_ASYNC = 0o20000;
-pub const O_DIRECT = 0o200000;
-pub const O_LARGEFILE = 0o400000;
-pub const O_NOATIME = 0o1000000;
-pub const O_PATH = 0o10000000;
-pub const O_TMPFILE = 0o20040000;
-pub const O_NDELAY = O_NONBLOCK;
-
-pub const F_DUPFD = 0;
-pub const F_GETFD = 1;
-pub const F_SETFD = 2;
-pub const F_GETFL = 3;
-pub const F_SETFL = 4;
-
-pub const F_SETOWN = 8;
-pub const F_GETOWN = 9;
-pub const F_SETSIG = 10;
-pub const F_GETSIG = 11;
-
-pub const F_GETLK = 5;
-pub const F_SETLK = 6;
-pub const F_SETLKW = 7;
-
-pub const F_RDLCK = 0;
-pub const F_WRLCK = 1;
-pub const F_UNLCK = 2;
-
-pub const LOCK_SH = 1;
-pub const LOCK_EX = 2;
-pub const LOCK_UN = 8;
-pub const LOCK_NB = 4;
-
-pub const F_SETOWN_EX = 15;
-pub const F_GETOWN_EX = 16;
-
-pub const F_GETOWNER_UIDS = 17;
-
-/// stack-like segment
-pub const MAP_GROWSDOWN = 0x0100;
-
-/// ETXTBSY
-pub const MAP_DENYWRITE = 0x0800;
-
-/// mark it as an executable
-pub const MAP_EXECUTABLE = 0x1000;
-
-/// pages are locked
-pub const MAP_LOCKED = 0x2000;
-
-/// don't check for reservations
-pub const MAP_NORESERVE = 0x4000;
-
-pub const VDSO_CGT_SYM = "__kernel_clock_gettime";
-pub const VDSO_CGT_VER = "LINUX_2.6.39";
-
-pub const Flock = extern struct {
- l_type: i16,
- l_whence: i16,
- l_start: off_t,
- l_len: off_t,
- l_pid: pid_t,
- __unused: [4]u8,
-};
-
-pub const msghdr = extern struct {
- msg_name: ?*sockaddr,
- msg_namelen: socklen_t,
- msg_iov: [*]iovec,
- msg_iovlen: i32,
- __pad1: i32 = 0,
- msg_control: ?*c_void,
- msg_controllen: socklen_t,
- __pad2: socklen_t = 0,
- msg_flags: i32,
-};
-
-pub const msghdr_const = extern struct {
- msg_name: ?*const sockaddr,
- msg_namelen: socklen_t,
- msg_iov: [*]iovec_const,
- msg_iovlen: i32,
- __pad1: i32 = 0,
- msg_control: ?*c_void,
- msg_controllen: socklen_t,
- __pad2: socklen_t = 0,
- msg_flags: i32,
-};
-
-pub const blksize_t = i32;
-pub const nlink_t = u32;
-pub const time_t = isize;
-pub const mode_t = u32;
-pub const off_t = isize;
-pub const ino_t = usize;
-pub const dev_t = usize;
-pub const blkcnt_t = isize;
-
-// The `stat` definition used by the Linux kernel.
-pub const kernel_stat = extern struct {
- dev: dev_t,
- ino: ino_t,
- mode: mode_t,
- nlink: nlink_t,
- uid: uid_t,
- gid: gid_t,
- rdev: dev_t,
- __pad: usize,
- size: off_t,
- blksize: blksize_t,
- __pad2: i32,
- blocks: blkcnt_t,
- atim: timespec,
- mtim: timespec,
- ctim: timespec,
- __unused: [2]u32,
-
- pub fn atime(self: @This()) timespec {
- return self.atim;
- }
-
- pub fn mtime(self: @This()) timespec {
- return self.mtim;
- }
-
- pub fn ctime(self: @This()) timespec {
- return self.ctim;
- }
-};
-
-// The `stat64` definition used by the libc.
-pub const libc_stat = kernel_stat;
-
-pub const timespec = extern struct {
- tv_sec: time_t,
- tv_nsec: isize,
-};
-
-pub const timeval = extern struct {
- tv_sec: isize,
- tv_usec: isize,
-};
-
-pub const timezone = extern struct {
- tz_minuteswest: i32,
- tz_dsttime: i32,
-};
-
-pub const mcontext_t = extern struct {
- fault_address: usize,
- regs: [31]usize,
- sp: usize,
- pc: usize,
- pstate: usize,
- // Make sure the field is correctly aligned since this area
- // holds various FP/vector registers
- reserved1: [256 * 16]u8 align(16),
-};
-
-pub const ucontext_t = extern struct {
- flags: usize,
- link: *ucontext_t,
- stack: stack_t,
- sigmask: sigset_t,
- mcontext: mcontext_t,
-};
-
-pub const Elf_Symndx = u32;
diff --git a/lib/std/os/bits/linux/i386.zig b/lib/std/os/bits/linux/i386.zig
deleted file mode 100644
index 12c8fa471373..000000000000
--- a/lib/std/os/bits/linux/i386.zig
+++ /dev/null
@@ -1,670 +0,0 @@
-// i386-specific declarations that are intended to be imported into the POSIX namespace.
-// This does include Linux-only APIs.
-
-const std = @import("../../../std.zig");
-const linux = std.os.linux;
-const socklen_t = linux.socklen_t;
-const iovec = linux.iovec;
-const iovec_const = linux.iovec_const;
-const uid_t = linux.uid_t;
-const gid_t = linux.gid_t;
-const pid_t = linux.pid_t;
-const stack_t = linux.stack_t;
-const sigset_t = linux.sigset_t;
-
-pub const SYS = enum(usize) {
- restart_syscall = 0,
- exit = 1,
- fork = 2,
- read = 3,
- write = 4,
- open = 5,
- close = 6,
- waitpid = 7,
- creat = 8,
- link = 9,
- unlink = 10,
- execve = 11,
- chdir = 12,
- time = 13,
- mknod = 14,
- chmod = 15,
- lchown = 16,
- @"break" = 17,
- oldstat = 18,
- lseek = 19,
- getpid = 20,
- mount = 21,
- umount = 22,
- setuid = 23,
- getuid = 24,
- stime = 25,
- ptrace = 26,
- alarm = 27,
- oldfstat = 28,
- pause = 29,
- utime = 30,
- stty = 31,
- gtty = 32,
- access = 33,
- nice = 34,
- ftime = 35,
- sync = 36,
- kill = 37,
- rename = 38,
- mkdir = 39,
- rmdir = 40,
- dup = 41,
- pipe = 42,
- times = 43,
- prof = 44,
- brk = 45,
- setgid = 46,
- getgid = 47,
- signal = 48,
- geteuid = 49,
- getegid = 50,
- acct = 51,
- umount2 = 52,
- lock = 53,
- ioctl = 54,
- fcntl = 55,
- mpx = 56,
- setpgid = 57,
- ulimit = 58,
- oldolduname = 59,
- umask = 60,
- chroot = 61,
- ustat = 62,
- dup2 = 63,
- getppid = 64,
- getpgrp = 65,
- setsid = 66,
- sigaction = 67,
- sgetmask = 68,
- ssetmask = 69,
- setreuid = 70,
- setregid = 71,
- sigsuspend = 72,
- sigpending = 73,
- sethostname = 74,
- setrlimit = 75,
- getrlimit = 76,
- getrusage = 77,
- gettimeofday = 78,
- settimeofday = 79,
- getgroups = 80,
- setgroups = 81,
- select = 82,
- symlink = 83,
- oldlstat = 84,
- readlink = 85,
- uselib = 86,
- swapon = 87,
- reboot = 88,
- readdir = 89,
- mmap = 90,
- munmap = 91,
- truncate = 92,
- ftruncate = 93,
- fchmod = 94,
- fchown = 95,
- getpriority = 96,
- setpriority = 97,
- profil = 98,
- statfs = 99,
- fstatfs = 100,
- ioperm = 101,
- socketcall = 102,
- syslog = 103,
- setitimer = 104,
- getitimer = 105,
- stat = 106,
- lstat = 107,
- fstat = 108,
- olduname = 109,
- iopl = 110,
- vhangup = 111,
- idle = 112,
- vm86old = 113,
- wait4 = 114,
- swapoff = 115,
- sysinfo = 116,
- ipc = 117,
- fsync = 118,
- sigreturn = 119,
- clone = 120,
- setdomainname = 121,
- uname = 122,
- modify_ldt = 123,
- adjtimex = 124,
- mprotect = 125,
- sigprocmask = 126,
- create_module = 127,
- init_module = 128,
- delete_module = 129,
- get_kernel_syms = 130,
- quotactl = 131,
- getpgid = 132,
- fchdir = 133,
- bdflush = 134,
- sysfs = 135,
- personality = 136,
- afs_syscall = 137,
- setfsuid = 138,
- setfsgid = 139,
- _llseek = 140,
- getdents = 141,
- _newselect = 142,
- flock = 143,
- msync = 144,
- readv = 145,
- writev = 146,
- getsid = 147,
- fdatasync = 148,
- _sysctl = 149,
- mlock = 150,
- munlock = 151,
- mlockall = 152,
- munlockall = 153,
- sched_setparam = 154,
- sched_getparam = 155,
- sched_setscheduler = 156,
- sched_getscheduler = 157,
- sched_yield = 158,
- sched_get_priority_max = 159,
- sched_get_priority_min = 160,
- sched_rr_get_interval = 161,
- nanosleep = 162,
- mremap = 163,
- setresuid = 164,
- getresuid = 165,
- vm86 = 166,
- query_module = 167,
- poll = 168,
- nfsservctl = 169,
- setresgid = 170,
- getresgid = 171,
- prctl = 172,
- rt_sigreturn = 173,
- rt_sigaction = 174,
- rt_sigprocmask = 175,
- rt_sigpending = 176,
- rt_sigtimedwait = 177,
- rt_sigqueueinfo = 178,
- rt_sigsuspend = 179,
- pread64 = 180,
- pwrite64 = 181,
- chown = 182,
- getcwd = 183,
- capget = 184,
- capset = 185,
- sigaltstack = 186,
- sendfile = 187,
- getpmsg = 188,
- putpmsg = 189,
- vfork = 190,
- ugetrlimit = 191,
- mmap2 = 192,
- truncate64 = 193,
- ftruncate64 = 194,
- stat64 = 195,
- lstat64 = 196,
- fstat64 = 197,
- lchown32 = 198,
- getuid32 = 199,
- getgid32 = 200,
- geteuid32 = 201,
- getegid32 = 202,
- setreuid32 = 203,
- setregid32 = 204,
- getgroups32 = 205,
- setgroups32 = 206,
- fchown32 = 207,
- setresuid32 = 208,
- getresuid32 = 209,
- setresgid32 = 210,
- getresgid32 = 211,
- chown32 = 212,
- setuid32 = 213,
- setgid32 = 214,
- setfsuid32 = 215,
- setfsgid32 = 216,
- pivot_root = 217,
- mincore = 218,
- madvise = 219,
- getdents64 = 220,
- fcntl64 = 221,
- gettid = 224,
- readahead = 225,
- setxattr = 226,
- lsetxattr = 227,
- fsetxattr = 228,
- getxattr = 229,
- lgetxattr = 230,
- fgetxattr = 231,
- listxattr = 232,
- llistxattr = 233,
- flistxattr = 234,
- removexattr = 235,
- lremovexattr = 236,
- fremovexattr = 237,
- tkill = 238,
- sendfile64 = 239,
- futex = 240,
- sched_setaffinity = 241,
- sched_getaffinity = 242,
- set_thread_area = 243,
- get_thread_area = 244,
- io_setup = 245,
- io_destroy = 246,
- io_getevents = 247,
- io_submit = 248,
- io_cancel = 249,
- fadvise64 = 250,
- exit_group = 252,
- lookup_dcookie = 253,
- epoll_create = 254,
- epoll_ctl = 255,
- epoll_wait = 256,
- remap_file_pages = 257,
- set_tid_address = 258,
- timer_create = 259,
- timer_settime, // SYS_timer_create + 1
- timer_gettime, // SYS_timer_create + 2
- timer_getoverrun, // SYS_timer_create + 3
- timer_delete, // SYS_timer_create + 4
- clock_settime, // SYS_timer_create + 5
- clock_gettime, // SYS_timer_create + 6
- clock_getres, // SYS_timer_create + 7
- clock_nanosleep, // SYS_timer_create + 8
- statfs64 = 268,
- fstatfs64 = 269,
- tgkill = 270,
- utimes = 271,
- fadvise64_64 = 272,
- vserver = 273,
- mbind = 274,
- get_mempolicy = 275,
- set_mempolicy = 276,
- mq_open = 277,
- mq_unlink, // SYS_mq_open + 1
- mq_timedsend, // SYS_mq_open + 2
- mq_timedreceive, // SYS_mq_open + 3
- mq_notify, // SYS_mq_open + 4
- mq_getsetattr, // SYS_mq_open + 5
- kexec_load = 283,
- waitid = 284,
- add_key = 286,
- request_key = 287,
- keyctl = 288,
- ioprio_set = 289,
- ioprio_get = 290,
- inotify_init = 291,
- inotify_add_watch = 292,
- inotify_rm_watch = 293,
- migrate_pages = 294,
- openat = 295,
- mkdirat = 296,
- mknodat = 297,
- fchownat = 298,
- futimesat = 299,
- fstatat64 = 300,
- unlinkat = 301,
- renameat = 302,
- linkat = 303,
- symlinkat = 304,
- readlinkat = 305,
- fchmodat = 306,
- faccessat = 307,
- pselect6 = 308,
- ppoll = 309,
- unshare = 310,
- set_robust_list = 311,
- get_robust_list = 312,
- splice = 313,
- sync_file_range = 314,
- tee = 315,
- vmsplice = 316,
- move_pages = 317,
- getcpu = 318,
- epoll_pwait = 319,
- utimensat = 320,
- signalfd = 321,
- timerfd_create = 322,
- eventfd = 323,
- fallocate = 324,
- timerfd_settime = 325,
- timerfd_gettime = 326,
- signalfd4 = 327,
- eventfd2 = 328,
- epoll_create1 = 329,
- dup3 = 330,
- pipe2 = 331,
- inotify_init1 = 332,
- preadv = 333,
- pwritev = 334,
- rt_tgsigqueueinfo = 335,
- perf_event_open = 336,
- recvmmsg = 337,
- fanotify_init = 338,
- fanotify_mark = 339,
- prlimit64 = 340,
- name_to_handle_at = 341,
- open_by_handle_at = 342,
- clock_adjtime = 343,
- syncfs = 344,
- sendmmsg = 345,
- setns = 346,
- process_vm_readv = 347,
- process_vm_writev = 348,
- kcmp = 349,
- finit_module = 350,
- sched_setattr = 351,
- sched_getattr = 352,
- renameat2 = 353,
- seccomp = 354,
- getrandom = 355,
- memfd_create = 356,
- bpf = 357,
- execveat = 358,
- socket = 359,
- socketpair = 360,
- bind = 361,
- connect = 362,
- listen = 363,
- accept4 = 364,
- getsockopt = 365,
- setsockopt = 366,
- getsockname = 367,
- getpeername = 368,
- sendto = 369,
- sendmsg = 370,
- recvfrom = 371,
- recvmsg = 372,
- shutdown = 373,
- userfaultfd = 374,
- membarrier = 375,
- mlock2 = 376,
- copy_file_range = 377,
- preadv2 = 378,
- pwritev2 = 379,
- pkey_mprotect = 380,
- pkey_alloc = 381,
- pkey_free = 382,
- statx = 383,
- arch_prctl = 384,
- io_pgetevents = 385,
- rseq = 386,
- semget = 393,
- semctl = 394,
- shmget = 395,
- shmctl = 396,
- shmat = 397,
- shmdt = 398,
- msgget = 399,
- msgsnd = 400,
- msgrcv = 401,
- msgctl = 402,
- clock_gettime64 = 403,
- clock_settime64 = 404,
- clock_adjtime64 = 405,
- clock_getres_time64 = 406,
- clock_nanosleep_time64 = 407,
- timer_gettime64 = 408,
- timer_settime64 = 409,
- timerfd_gettime64 = 410,
- timerfd_settime64 = 411,
- utimensat_time64 = 412,
- pselect6_time64 = 413,
- ppoll_time64 = 414,
- io_pgetevents_time64 = 416,
- recvmmsg_time64 = 417,
- mq_timedsend_time64 = 418,
- mq_timedreceive_time64 = 419,
- semtimedop_time64 = 420,
- rt_sigtimedwait_time64 = 421,
- futex_time64 = 422,
- sched_rr_get_interval_time64 = 423,
- pidfd_send_signal = 424,
- io_uring_setup = 425,
- io_uring_enter = 426,
- io_uring_register = 427,
- open_tree = 428,
- move_mount = 429,
- fsopen = 430,
- fsconfig = 431,
- fsmount = 432,
- fspick = 433,
- pidfd_open = 434,
- clone3 = 435,
- close_range = 436,
- openat2 = 437,
- pidfd_getfd = 438,
- faccessat2 = 439,
- process_madvise = 440,
- epoll_pwait2 = 441,
-
- _,
-};
-
-pub const O_CREAT = 0o100;
-pub const O_EXCL = 0o200;
-pub const O_NOCTTY = 0o400;
-pub const O_TRUNC = 0o1000;
-pub const O_APPEND = 0o2000;
-pub const O_NONBLOCK = 0o4000;
-pub const O_DSYNC = 0o10000;
-pub const O_SYNC = 0o4010000;
-pub const O_RSYNC = 0o4010000;
-pub const O_DIRECTORY = 0o200000;
-pub const O_NOFOLLOW = 0o400000;
-pub const O_CLOEXEC = 0o2000000;
-
-pub const O_ASYNC = 0o20000;
-pub const O_DIRECT = 0o40000;
-pub const O_LARGEFILE = 0o100000;
-pub const O_NOATIME = 0o1000000;
-pub const O_PATH = 0o10000000;
-pub const O_TMPFILE = 0o20200000;
-pub const O_NDELAY = O_NONBLOCK;
-
-pub const F_DUPFD = 0;
-pub const F_GETFD = 1;
-pub const F_SETFD = 2;
-pub const F_GETFL = 3;
-pub const F_SETFL = 4;
-
-pub const F_SETOWN = 8;
-pub const F_GETOWN = 9;
-pub const F_SETSIG = 10;
-pub const F_GETSIG = 11;
-
-pub const F_GETLK = 12;
-pub const F_SETLK = 13;
-pub const F_SETLKW = 14;
-
-pub const F_RDLCK = 0;
-pub const F_WRLCK = 1;
-pub const F_UNLCK = 2;
-
-pub const LOCK_SH = 1;
-pub const LOCK_EX = 2;
-pub const LOCK_UN = 8;
-pub const LOCK_NB = 4;
-
-pub const F_SETOWN_EX = 15;
-pub const F_GETOWN_EX = 16;
-
-pub const F_GETOWNER_UIDS = 17;
-
-pub const MAP_NORESERVE = 0x4000;
-pub const MAP_GROWSDOWN = 0x0100;
-pub const MAP_DENYWRITE = 0x0800;
-pub const MAP_EXECUTABLE = 0x1000;
-pub const MAP_LOCKED = 0x2000;
-pub const MAP_32BIT = 0x40;
-
-pub const MMAP2_UNIT = 4096;
-
-pub const VDSO_CGT_SYM = "__vdso_clock_gettime";
-pub const VDSO_CGT_VER = "LINUX_2.6";
-
-pub const Flock = extern struct {
- l_type: i16,
- l_whence: i16,
- l_start: off_t,
- l_len: off_t,
- l_pid: pid_t,
-};
-
-pub const msghdr = extern struct {
- msg_name: ?*sockaddr,
- msg_namelen: socklen_t,
- msg_iov: [*]iovec,
- msg_iovlen: i32,
- msg_control: ?*c_void,
- msg_controllen: socklen_t,
- msg_flags: i32,
-};
-
-pub const msghdr_const = extern struct {
- msg_name: ?*const sockaddr,
- msg_namelen: socklen_t,
- msg_iov: [*]iovec_const,
- msg_iovlen: i32,
- msg_control: ?*c_void,
- msg_controllen: socklen_t,
- msg_flags: i32,
-};
-
-pub const blksize_t = i32;
-pub const nlink_t = u32;
-pub const time_t = isize;
-pub const mode_t = u32;
-pub const off_t = i64;
-pub const ino_t = u64;
-pub const dev_t = u64;
-pub const blkcnt_t = i64;
-
-// The `stat` definition used by the Linux kernel.
-pub const kernel_stat = extern struct {
- dev: dev_t,
- __dev_padding: u32,
- __ino_truncated: u32,
- mode: mode_t,
- nlink: nlink_t,
- uid: uid_t,
- gid: gid_t,
- rdev: dev_t,
- __rdev_padding: u32,
- size: off_t,
- blksize: blksize_t,
- blocks: blkcnt_t,
- atim: timespec,
- mtim: timespec,
- ctim: timespec,
- ino: ino_t,
-
- pub fn atime(self: @This()) timespec {
- return self.atim;
- }
-
- pub fn mtime(self: @This()) timespec {
- return self.mtim;
- }
-
- pub fn ctime(self: @This()) timespec {
- return self.ctim;
- }
-};
-
-// The `stat64` definition used by the libc.
-pub const libc_stat = kernel_stat;
-
-pub const timespec = extern struct {
- tv_sec: i32,
- tv_nsec: i32,
-};
-
-pub const timeval = extern struct {
- tv_sec: i32,
- tv_usec: i32,
-};
-
-pub const timezone = extern struct {
- tz_minuteswest: i32,
- tz_dsttime: i32,
-};
-
-pub const mcontext_t = extern struct {
- gregs: [19]usize,
- fpregs: [*]u8,
- oldmask: usize,
- cr2: usize,
-};
-
-pub const REG_GS = 0;
-pub const REG_FS = 1;
-pub const REG_ES = 2;
-pub const REG_DS = 3;
-pub const REG_EDI = 4;
-pub const REG_ESI = 5;
-pub const REG_EBP = 6;
-pub const REG_ESP = 7;
-pub const REG_EBX = 8;
-pub const REG_EDX = 9;
-pub const REG_ECX = 10;
-pub const REG_EAX = 11;
-pub const REG_TRAPNO = 12;
-pub const REG_ERR = 13;
-pub const REG_EIP = 14;
-pub const REG_CS = 15;
-pub const REG_EFL = 16;
-pub const REG_UESP = 17;
-pub const REG_SS = 18;
-
-pub const ucontext_t = extern struct {
- flags: usize,
- link: *ucontext_t,
- stack: stack_t,
- mcontext: mcontext_t,
- sigmask: sigset_t,
- regspace: [64]u64,
-};
-
-pub const Elf_Symndx = u32;
-
-pub const user_desc = packed struct {
- entry_number: u32,
- base_addr: u32,
- limit: u32,
- seg_32bit: u1,
- contents: u2,
- read_exec_only: u1,
- limit_in_pages: u1,
- seg_not_present: u1,
- useable: u1,
-};
-
-// socketcall() call numbers
-pub const SC_socket = 1;
-pub const SC_bind = 2;
-pub const SC_connect = 3;
-pub const SC_listen = 4;
-pub const SC_accept = 5;
-pub const SC_getsockname = 6;
-pub const SC_getpeername = 7;
-pub const SC_socketpair = 8;
-pub const SC_send = 9;
-pub const SC_recv = 10;
-pub const SC_sendto = 11;
-pub const SC_recvfrom = 12;
-pub const SC_shutdown = 13;
-pub const SC_setsockopt = 14;
-pub const SC_getsockopt = 15;
-pub const SC_sendmsg = 16;
-pub const SC_recvmsg = 17;
-pub const SC_accept4 = 18;
-pub const SC_recvmmsg = 19;
-pub const SC_sendmmsg = 20;
diff --git a/lib/std/os/bits/linux/mips.zig b/lib/std/os/bits/linux/mips.zig
deleted file mode 100644
index ddf241fb4d38..000000000000
--- a/lib/std/os/bits/linux/mips.zig
+++ /dev/null
@@ -1,622 +0,0 @@
-const std = @import("../../../std.zig");
-const linux = std.os.linux;
-const socklen_t = linux.socklen_t;
-const iovec = linux.iovec;
-const iovec_const = linux.iovec_const;
-const uid_t = linux.uid_t;
-const gid_t = linux.gid_t;
-const pid_t = linux.pid_t;
-
-pub const SYS = enum(usize) {
- pub const Linux = 4000;
-
- syscall = Linux + 0,
- exit = Linux + 1,
- fork = Linux + 2,
- read = Linux + 3,
- write = Linux + 4,
- open = Linux + 5,
- close = Linux + 6,
- waitpid = Linux + 7,
- creat = Linux + 8,
- link = Linux + 9,
- unlink = Linux + 10,
- execve = Linux + 11,
- chdir = Linux + 12,
- time = Linux + 13,
- mknod = Linux + 14,
- chmod = Linux + 15,
- lchown = Linux + 16,
- @"break" = Linux + 17,
- unused18 = Linux + 18,
- lseek = Linux + 19,
- getpid = Linux + 20,
- mount = Linux + 21,
- umount = Linux + 22,
- setuid = Linux + 23,
- getuid = Linux + 24,
- stime = Linux + 25,
- ptrace = Linux + 26,
- alarm = Linux + 27,
- unused28 = Linux + 28,
- pause = Linux + 29,
- utime = Linux + 30,
- stty = Linux + 31,
- gtty = Linux + 32,
- access = Linux + 33,
- nice = Linux + 34,
- ftime = Linux + 35,
- sync = Linux + 36,
- kill = Linux + 37,
- rename = Linux + 38,
- mkdir = Linux + 39,
- rmdir = Linux + 40,
- dup = Linux + 41,
- pipe = Linux + 42,
- times = Linux + 43,
- prof = Linux + 44,
- brk = Linux + 45,
- setgid = Linux + 46,
- getgid = Linux + 47,
- signal = Linux + 48,
- geteuid = Linux + 49,
- getegid = Linux + 50,
- acct = Linux + 51,
- umount2 = Linux + 52,
- lock = Linux + 53,
- ioctl = Linux + 54,
- fcntl = Linux + 55,
- mpx = Linux + 56,
- setpgid = Linux + 57,
- ulimit = Linux + 58,
- unused59 = Linux + 59,
- umask = Linux + 60,
- chroot = Linux + 61,
- ustat = Linux + 62,
- dup2 = Linux + 63,
- getppid = Linux + 64,
- getpgrp = Linux + 65,
- setsid = Linux + 66,
- sigaction = Linux + 67,
- sgetmask = Linux + 68,
- ssetmask = Linux + 69,
- setreuid = Linux + 70,
- setregid = Linux + 71,
- sigsuspend = Linux + 72,
- sigpending = Linux + 73,
- sethostname = Linux + 74,
- setrlimit = Linux + 75,
- getrlimit = Linux + 76,
- getrusage = Linux + 77,
- gettimeofday = Linux + 78,
- settimeofday = Linux + 79,
- getgroups = Linux + 80,
- setgroups = Linux + 81,
- reserved82 = Linux + 82,
- symlink = Linux + 83,
- unused84 = Linux + 84,
- readlink = Linux + 85,
- uselib = Linux + 86,
- swapon = Linux + 87,
- reboot = Linux + 88,
- readdir = Linux + 89,
- mmap = Linux + 90,
- munmap = Linux + 91,
- truncate = Linux + 92,
- ftruncate = Linux + 93,
- fchmod = Linux + 94,
- fchown = Linux + 95,
- getpriority = Linux + 96,
- setpriority = Linux + 97,
- profil = Linux + 98,
- statfs = Linux + 99,
- fstatfs = Linux + 100,
- ioperm = Linux + 101,
- socketcall = Linux + 102,
- syslog = Linux + 103,
- setitimer = Linux + 104,
- getitimer = Linux + 105,
- stat = Linux + 106,
- lstat = Linux + 107,
- fstat = Linux + 108,
- unused109 = Linux + 109,
- iopl = Linux + 110,
- vhangup = Linux + 111,
- idle = Linux + 112,
- vm86 = Linux + 113,
- wait4 = Linux + 114,
- swapoff = Linux + 115,
- sysinfo = Linux + 116,
- ipc = Linux + 117,
- fsync = Linux + 118,
- sigreturn = Linux + 119,
- clone = Linux + 120,
- setdomainname = Linux + 121,
- uname = Linux + 122,
- modify_ldt = Linux + 123,
- adjtimex = Linux + 124,
- mprotect = Linux + 125,
- sigprocmask = Linux + 126,
- create_module = Linux + 127,
- init_module = Linux + 128,
- delete_module = Linux + 129,
- get_kernel_syms = Linux + 130,
- quotactl = Linux + 131,
- getpgid = Linux + 132,
- fchdir = Linux + 133,
- bdflush = Linux + 134,
- sysfs = Linux + 135,
- personality = Linux + 136,
- afs_syscall = Linux + 137,
- setfsuid = Linux + 138,
- setfsgid = Linux + 139,
- _llseek = Linux + 140,
- getdents = Linux + 141,
- _newselect = Linux + 142,
- flock = Linux + 143,
- msync = Linux + 144,
- readv = Linux + 145,
- writev = Linux + 146,
- cacheflush = Linux + 147,
- cachectl = Linux + 148,
- sysmips = Linux + 149,
- unused150 = Linux + 150,
- getsid = Linux + 151,
- fdatasync = Linux + 152,
- _sysctl = Linux + 153,
- mlock = Linux + 154,
- munlock = Linux + 155,
- mlockall = Linux + 156,
- munlockall = Linux + 157,
- sched_setparam = Linux + 158,
- sched_getparam = Linux + 159,
- sched_setscheduler = Linux + 160,
- sched_getscheduler = Linux + 161,
- sched_yield = Linux + 162,
- sched_get_priority_max = Linux + 163,
- sched_get_priority_min = Linux + 164,
- sched_rr_get_interval = Linux + 165,
- nanosleep = Linux + 166,
- mremap = Linux + 167,
- accept = Linux + 168,
- bind = Linux + 169,
- connect = Linux + 170,
- getpeername = Linux + 171,
- getsockname = Linux + 172,
- getsockopt = Linux + 173,
- listen = Linux + 174,
- recv = Linux + 175,
- recvfrom = Linux + 176,
- recvmsg = Linux + 177,
- send = Linux + 178,
- sendmsg = Linux + 179,
- sendto = Linux + 180,
- setsockopt = Linux + 181,
- shutdown = Linux + 182,
- socket = Linux + 183,
- socketpair = Linux + 184,
- setresuid = Linux + 185,
- getresuid = Linux + 186,
- query_module = Linux + 187,
- poll = Linux + 188,
- nfsservctl = Linux + 189,
- setresgid = Linux + 190,
- getresgid = Linux + 191,
- prctl = Linux + 192,
- rt_sigreturn = Linux + 193,
- rt_sigaction = Linux + 194,
- rt_sigprocmask = Linux + 195,
- rt_sigpending = Linux + 196,
- rt_sigtimedwait = Linux + 197,
- rt_sigqueueinfo = Linux + 198,
- rt_sigsuspend = Linux + 199,
- pread64 = Linux + 200,
- pwrite64 = Linux + 201,
- chown = Linux + 202,
- getcwd = Linux + 203,
- capget = Linux + 204,
- capset = Linux + 205,
- sigaltstack = Linux + 206,
- sendfile = Linux + 207,
- getpmsg = Linux + 208,
- putpmsg = Linux + 209,
- mmap2 = Linux + 210,
- truncate64 = Linux + 211,
- ftruncate64 = Linux + 212,
- stat64 = Linux + 213,
- lstat64 = Linux + 214,
- fstat64 = Linux + 215,
- pivot_root = Linux + 216,
- mincore = Linux + 217,
- madvise = Linux + 218,
- getdents64 = Linux + 219,
- fcntl64 = Linux + 220,
- reserved221 = Linux + 221,
- gettid = Linux + 222,
- readahead = Linux + 223,
- setxattr = Linux + 224,
- lsetxattr = Linux + 225,
- fsetxattr = Linux + 226,
- getxattr = Linux + 227,
- lgetxattr = Linux + 228,
- fgetxattr = Linux + 229,
- listxattr = Linux + 230,
- llistxattr = Linux + 231,
- flistxattr = Linux + 232,
- removexattr = Linux + 233,
- lremovexattr = Linux + 234,
- fremovexattr = Linux + 235,
- tkill = Linux + 236,
- sendfile64 = Linux + 237,
- futex = Linux + 238,
- sched_setaffinity = Linux + 239,
- sched_getaffinity = Linux + 240,
- io_setup = Linux + 241,
- io_destroy = Linux + 242,
- io_getevents = Linux + 243,
- io_submit = Linux + 244,
- io_cancel = Linux + 245,
- exit_group = Linux + 246,
- lookup_dcookie = Linux + 247,
- epoll_create = Linux + 248,
- epoll_ctl = Linux + 249,
- epoll_wait = Linux + 250,
- remap_file_pages = Linux + 251,
- set_tid_address = Linux + 252,
- restart_syscall = Linux + 253,
- fadvise64 = Linux + 254,
- statfs64 = Linux + 255,
- fstatfs64 = Linux + 256,
- timer_create = Linux + 257,
- timer_settime = Linux + 258,
- timer_gettime = Linux + 259,
- timer_getoverrun = Linux + 260,
- timer_delete = Linux + 261,
- clock_settime = Linux + 262,
- clock_gettime = Linux + 263,
- clock_getres = Linux + 264,
- clock_nanosleep = Linux + 265,
- tgkill = Linux + 266,
- utimes = Linux + 267,
- mbind = Linux + 268,
- get_mempolicy = Linux + 269,
- set_mempolicy = Linux + 270,
- mq_open = Linux + 271,
- mq_unlink = Linux + 272,
- mq_timedsend = Linux + 273,
- mq_timedreceive = Linux + 274,
- mq_notify = Linux + 275,
- mq_getsetattr = Linux + 276,
- vserver = Linux + 277,
- waitid = Linux + 278,
- add_key = Linux + 280,
- request_key = Linux + 281,
- keyctl = Linux + 282,
- set_thread_area = Linux + 283,
- inotify_init = Linux + 284,
- inotify_add_watch = Linux + 285,
- inotify_rm_watch = Linux + 286,
- migrate_pages = Linux + 287,
- openat = Linux + 288,
- mkdirat = Linux + 289,
- mknodat = Linux + 290,
- fchownat = Linux + 291,
- futimesat = Linux + 292,
- fstatat64 = Linux + 293,
- unlinkat = Linux + 294,
- renameat = Linux + 295,
- linkat = Linux + 296,
- symlinkat = Linux + 297,
- readlinkat = Linux + 298,
- fchmodat = Linux + 299,
- faccessat = Linux + 300,
- pselect6 = Linux + 301,
- ppoll = Linux + 302,
- unshare = Linux + 303,
- splice = Linux + 304,
- sync_file_range = Linux + 305,
- tee = Linux + 306,
- vmsplice = Linux + 307,
- move_pages = Linux + 308,
- set_robust_list = Linux + 309,
- get_robust_list = Linux + 310,
- kexec_load = Linux + 311,
- getcpu = Linux + 312,
- epoll_pwait = Linux + 313,
- ioprio_set = Linux + 314,
- ioprio_get = Linux + 315,
- utimensat = Linux + 316,
- signalfd = Linux + 317,
- timerfd = Linux + 318,
- eventfd = Linux + 319,
- fallocate = Linux + 320,
- timerfd_create = Linux + 321,
- timerfd_gettime = Linux + 322,
- timerfd_settime = Linux + 323,
- signalfd4 = Linux + 324,
- eventfd2 = Linux + 325,
- epoll_create1 = Linux + 326,
- dup3 = Linux + 327,
- pipe2 = Linux + 328,
- inotify_init1 = Linux + 329,
- preadv = Linux + 330,
- pwritev = Linux + 331,
- rt_tgsigqueueinfo = Linux + 332,
- perf_event_open = Linux + 333,
- accept4 = Linux + 334,
- recvmmsg = Linux + 335,
- fanotify_init = Linux + 336,
- fanotify_mark = Linux + 337,
- prlimit64 = Linux + 338,
- name_to_handle_at = Linux + 339,
- open_by_handle_at = Linux + 340,
- clock_adjtime = Linux + 341,
- syncfs = Linux + 342,
- sendmmsg = Linux + 343,
- setns = Linux + 344,
- process_vm_readv = Linux + 345,
- process_vm_writev = Linux + 346,
- kcmp = Linux + 347,
- finit_module = Linux + 348,
- sched_setattr = Linux + 349,
- sched_getattr = Linux + 350,
- renameat2 = Linux + 351,
- seccomp = Linux + 352,
- getrandom = Linux + 353,
- memfd_create = Linux + 354,
- bpf = Linux + 355,
- execveat = Linux + 356,
- userfaultfd = Linux + 357,
- membarrier = Linux + 358,
- mlock2 = Linux + 359,
- copy_file_range = Linux + 360,
- preadv2 = Linux + 361,
- pwritev2 = Linux + 362,
- pkey_mprotect = Linux + 363,
- pkey_alloc = Linux + 364,
- pkey_free = Linux + 365,
- statx = Linux + 366,
- rseq = Linux + 367,
- io_pgetevents = Linux + 368,
- semget = Linux + 393,
- semctl = Linux + 394,
- shmget = Linux + 395,
- shmctl = Linux + 396,
- shmat = Linux + 397,
- shmdt = Linux + 398,
- msgget = Linux + 399,
- msgsnd = Linux + 400,
- msgrcv = Linux + 401,
- msgctl = Linux + 402,
- clock_gettime64 = Linux + 403,
- clock_settime64 = Linux + 404,
- clock_adjtime64 = Linux + 405,
- clock_getres_time64 = Linux + 406,
- clock_nanosleep_time64 = Linux + 407,
- timer_gettime64 = Linux + 408,
- timer_settime64 = Linux + 409,
- timerfd_gettime64 = Linux + 410,
- timerfd_settime64 = Linux + 411,
- utimensat_time64 = Linux + 412,
- pselect6_time64 = Linux + 413,
- ppoll_time64 = Linux + 414,
- io_pgetevents_time64 = Linux + 416,
- recvmmsg_time64 = Linux + 417,
- mq_timedsend_time64 = Linux + 418,
- mq_timedreceive_time64 = Linux + 419,
- semtimedop_time64 = Linux + 420,
- rt_sigtimedwait_time64 = Linux + 421,
- futex_time64 = Linux + 422,
- sched_rr_get_interval_time64 = Linux + 423,
- pidfd_send_signal = Linux + 424,
- io_uring_setup = Linux + 425,
- io_uring_enter = Linux + 426,
- io_uring_register = Linux + 427,
- open_tree = Linux + 428,
- move_mount = Linux + 429,
- fsopen = Linux + 430,
- fsconfig = Linux + 431,
- fsmount = Linux + 432,
- fspick = Linux + 433,
- pidfd_open = Linux + 434,
- clone3 = Linux + 435,
- close_range = Linux + 436,
- openat2 = Linux + 437,
- pidfd_getfd = Linux + 438,
- faccessat2 = Linux + 439,
- process_madvise = Linux + 440,
- epoll_pwait2 = Linux + 441,
-
- _,
-};
-
-pub const O_CREAT = 0o0400;
-pub const O_EXCL = 0o02000;
-pub const O_NOCTTY = 0o04000;
-pub const O_TRUNC = 0o01000;
-pub const O_APPEND = 0o0010;
-pub const O_NONBLOCK = 0o0200;
-pub const O_DSYNC = 0o0020;
-pub const O_SYNC = 0o040020;
-pub const O_RSYNC = 0o040020;
-pub const O_DIRECTORY = 0o0200000;
-pub const O_NOFOLLOW = 0o0400000;
-pub const O_CLOEXEC = 0o02000000;
-
-pub const O_ASYNC = 0o010000;
-pub const O_DIRECT = 0o0100000;
-pub const O_LARGEFILE = 0o020000;
-pub const O_NOATIME = 0o01000000;
-pub const O_PATH = 0o010000000;
-pub const O_TMPFILE = 0o020200000;
-pub const O_NDELAY = O_NONBLOCK;
-
-pub const F_DUPFD = 0;
-pub const F_GETFD = 1;
-pub const F_SETFD = 2;
-pub const F_GETFL = 3;
-pub const F_SETFL = 4;
-
-pub const F_SETOWN = 24;
-pub const F_GETOWN = 23;
-pub const F_SETSIG = 10;
-pub const F_GETSIG = 11;
-
-pub const F_GETLK = 33;
-pub const F_SETLK = 34;
-pub const F_SETLKW = 35;
-
-pub const F_RDLCK = 0;
-pub const F_WRLCK = 1;
-pub const F_UNLCK = 2;
-
-pub const LOCK_SH = 1;
-pub const LOCK_EX = 2;
-pub const LOCK_UN = 8;
-pub const LOCK_NB = 4;
-
-pub const F_SETOWN_EX = 15;
-pub const F_GETOWN_EX = 16;
-
-pub const F_GETOWNER_UIDS = 17;
-
-pub const MMAP2_UNIT = 4096;
-
-pub const MAP_NORESERVE = 0x0400;
-pub const MAP_GROWSDOWN = 0x1000;
-pub const MAP_DENYWRITE = 0x2000;
-pub const MAP_EXECUTABLE = 0x4000;
-pub const MAP_LOCKED = 0x8000;
-pub const MAP_32BIT = 0x40;
-
-pub const SO_DEBUG = 1;
-pub const SO_REUSEADDR = 0x0004;
-pub const SO_KEEPALIVE = 0x0008;
-pub const SO_DONTROUTE = 0x0010;
-pub const SO_BROADCAST = 0x0020;
-pub const SO_LINGER = 0x0080;
-pub const SO_OOBINLINE = 0x0100;
-pub const SO_REUSEPORT = 0x0200;
-pub const SO_SNDBUF = 0x1001;
-pub const SO_RCVBUF = 0x1002;
-pub const SO_SNDLOWAT = 0x1003;
-pub const SO_RCVLOWAT = 0x1004;
-pub const SO_RCVTIMEO = 0x1006;
-pub const SO_SNDTIMEO = 0x1005;
-pub const SO_ERROR = 0x1007;
-pub const SO_TYPE = 0x1008;
-pub const SO_ACCEPTCONN = 0x1009;
-pub const SO_PROTOCOL = 0x1028;
-pub const SO_DOMAIN = 0x1029;
-pub const SO_NO_CHECK = 11;
-pub const SO_PRIORITY = 12;
-pub const SO_BSDCOMPAT = 14;
-pub const SO_PASSCRED = 17;
-pub const SO_PEERCRED = 18;
-pub const SO_PEERSEC = 30;
-pub const SO_SNDBUFFORCE = 31;
-pub const SO_RCVBUFFORCE = 33;
-
-pub const VDSO_CGT_SYM = "__kernel_clock_gettime";
-pub const VDSO_CGT_VER = "LINUX_2.6.39";
-
-pub const Flock = extern struct {
- l_type: i16,
- l_whence: i16,
- __pad0: [4]u8,
- l_start: off_t,
- l_len: off_t,
- l_pid: pid_t,
- __unused: [4]u8,
-};
-
-pub const blksize_t = i32;
-pub const nlink_t = u32;
-pub const time_t = i32;
-pub const mode_t = u32;
-pub const off_t = i64;
-pub const ino_t = u64;
-pub const dev_t = u64;
-pub const blkcnt_t = i64;
-
-// The `stat` definition used by the Linux kernel.
-pub const kernel_stat = extern struct {
- dev: u32,
- __pad0: [3]u32, // Reserved for st_dev expansion
- ino: ino_t,
- mode: mode_t,
- nlink: nlink_t,
- uid: uid_t,
- gid: gid_t,
- rdev: u32,
- __pad1: [3]u32,
- size: off_t,
- atim: timespec,
- mtim: timespec,
- ctim: timespec,
- blksize: blksize_t,
- __pad3: u32,
- blocks: blkcnt_t,
- __pad4: [14]usize,
-
- pub fn atime(self: @This()) timespec {
- return self.atim;
- }
-
- pub fn mtime(self: @This()) timespec {
- return self.mtim;
- }
-
- pub fn ctime(self: @This()) timespec {
- return self.ctim;
- }
-};
-
-pub const libc_stat = extern struct {
- dev: dev_t,
- __pad0: [2]u32,
- ino: ino_t,
- mode: mode_t,
- nlink: nlink_t,
- uid: uid_t,
- gid: gid_t,
- rdev: dev_t,
- __pad1: [2]u32,
- size: off_t,
- atim: timespec,
- mtim: timespec,
- ctim: timespec,
- blksize: blksize_t,
- __pad3: u32,
- blocks: blkcnt_t,
- __pad4: [14]u32,
-
- pub fn atime(self: @This()) timespec {
- return self.atim;
- }
-
- pub fn mtime(self: @This()) timespec {
- return self.mtim;
- }
-
- pub fn ctime(self: @This()) timespec {
- return self.ctim;
- }
-};
-
-pub const timespec = extern struct {
- tv_sec: isize,
- tv_nsec: isize,
-};
-
-pub const timeval = extern struct {
- tv_sec: isize,
- tv_usec: isize,
-};
-
-pub const timezone = extern struct {
- tz_minuteswest: i32,
- tz_dsttime: i32,
-};
-
-pub const Elf_Symndx = u32;
diff --git a/lib/std/os/bits/linux/netlink.zig b/lib/std/os/bits/linux/netlink.zig
deleted file mode 100644
index 9de546fb208e..000000000000
--- a/lib/std/os/bits/linux/netlink.zig
+++ /dev/null
@@ -1,498 +0,0 @@
-usingnamespace @import("../linux.zig");
-
-/// Routing/device hook
-pub const NETLINK_ROUTE = 0;
-
-/// Unused number
-pub const NETLINK_UNUSED = 1;
-
-/// Reserved for user mode socket protocols
-pub const NETLINK_USERSOCK = 2;
-
-/// Unused number, formerly ip_queue
-pub const NETLINK_FIREWALL = 3;
-
-/// socket monitoring
-pub const NETLINK_SOCK_DIAG = 4;
-
-/// netfilter/iptables ULOG
-pub const NETLINK_NFLOG = 5;
-
-/// ipsec
-pub const NETLINK_XFRM = 6;
-
-/// SELinux event notifications
-pub const NETLINK_SELINUX = 7;
-
-/// Open-iSCSI
-pub const NETLINK_ISCSI = 8;
-
-/// auditing
-pub const NETLINK_AUDIT = 9;
-
-pub const NETLINK_FIB_LOOKUP = 10;
-
-pub const NETLINK_CONNECTOR = 11;
-
-/// netfilter subsystem
-pub const NETLINK_NETFILTER = 12;
-
-pub const NETLINK_IP6_FW = 13;
-
-/// DECnet routing messages
-pub const NETLINK_DNRTMSG = 14;
-
-/// Kernel messages to userspace
-pub const NETLINK_KOBJECT_UEVENT = 15;
-
-pub const NETLINK_GENERIC = 16;
-
-// leave room for NETLINK_DM (DM Events)
-
-/// SCSI Transports
-pub const NETLINK_SCSITRANSPORT = 18;
-
-pub const NETLINK_ECRYPTFS = 19;
-
-pub const NETLINK_RDMA = 20;
-
-/// Crypto layer
-pub const NETLINK_CRYPTO = 21;
-
-/// SMC monitoring
-pub const NETLINK_SMC = 22;
-
-// Flags values
-
-/// It is request message.
-pub const NLM_F_REQUEST = 0x01;
-
-/// Multipart message, terminated by NLMSG_DONE
-pub const NLM_F_MULTI = 0x02;
-
-/// Reply with ack, with zero or error code
-pub const NLM_F_ACK = 0x04;
-
-/// Echo this request
-pub const NLM_F_ECHO = 0x08;
-
-/// Dump was inconsistent due to sequence change
-pub const NLM_F_DUMP_INTR = 0x10;
-
-/// Dump was filtered as requested
-pub const NLM_F_DUMP_FILTERED = 0x20;
-
-// Modifiers to GET request
-
-/// specify tree root
-pub const NLM_F_ROOT = 0x100;
-
-/// return all matching
-pub const NLM_F_MATCH = 0x200;
-
-/// atomic GET
-pub const NLM_F_ATOMIC = 0x400;
-pub const NLM_F_DUMP = NLM_F_ROOT | NLM_F_MATCH;
-
-// Modifiers to NEW request
-
-/// Override existing
-pub const NLM_F_REPLACE = 0x100;
-
-/// Do not touch, if it exists
-pub const NLM_F_EXCL = 0x200;
-
-/// Create, if it does not exist
-pub const NLM_F_CREATE = 0x400;
-
-/// Add to end of list
-pub const NLM_F_APPEND = 0x800;
-
-// Modifiers to DELETE request
-
-/// Do not delete recursively
-pub const NLM_F_NONREC = 0x100;
-
-// Flags for ACK message
-
-/// request was capped
-pub const NLM_F_CAPPED = 0x100;
-
-/// extended ACK TVLs were included
-pub const NLM_F_ACK_TLVS = 0x200;
-
-pub const NetlinkMessageType = enum(u16) {
- /// < 0x10: reserved control messages
- pub const MIN_TYPE = 0x10;
-
- /// Nothing.
- NOOP = 0x1,
-
- /// Error
- ERROR = 0x2,
-
- /// End of a dump
- DONE = 0x3,
-
- /// Data lost
- OVERRUN = 0x4,
-
- // rtlink types
-
- RTM_NEWLINK = 16,
- RTM_DELLINK,
- RTM_GETLINK,
- RTM_SETLINK,
-
- RTM_NEWADDR = 20,
- RTM_DELADDR,
- RTM_GETADDR,
-
- RTM_NEWROUTE = 24,
- RTM_DELROUTE,
- RTM_GETROUTE,
-
- RTM_NEWNEIGH = 28,
- RTM_DELNEIGH,
- RTM_GETNEIGH,
-
- RTM_NEWRULE = 32,
- RTM_DELRULE,
- RTM_GETRULE,
-
- RTM_NEWQDISC = 36,
- RTM_DELQDISC,
- RTM_GETQDISC,
-
- RTM_NEWTCLASS = 40,
- RTM_DELTCLASS,
- RTM_GETTCLASS,
-
- RTM_NEWTFILTER = 44,
- RTM_DELTFILTER,
- RTM_GETTFILTER,
-
- RTM_NEWACTION = 48,
- RTM_DELACTION,
- RTM_GETACTION,
-
- RTM_NEWPREFIX = 52,
-
- RTM_GETMULTICAST = 58,
-
- RTM_GETANYCAST = 62,
-
- RTM_NEWNEIGHTBL = 64,
- RTM_GETNEIGHTBL = 66,
- RTM_SETNEIGHTBL,
-
- RTM_NEWNDUSEROPT = 68,
-
- RTM_NEWADDRLABEL = 72,
- RTM_DELADDRLABEL,
- RTM_GETADDRLABEL,
-
- RTM_GETDCB = 78,
- RTM_SETDCB,
-
- RTM_NEWNETCONF = 80,
- RTM_DELNETCONF,
- RTM_GETNETCONF = 82,
-
- RTM_NEWMDB = 84,
- RTM_DELMDB = 85,
- RTM_GETMDB = 86,
-
- RTM_NEWNSID = 88,
- RTM_DELNSID = 89,
- RTM_GETNSID = 90,
-
- RTM_NEWSTATS = 92,
- RTM_GETSTATS = 94,
-
- RTM_NEWCACHEREPORT = 96,
-
- RTM_NEWCHAIN = 100,
- RTM_DELCHAIN,
- RTM_GETCHAIN,
-
- RTM_NEWNEXTHOP = 104,
- RTM_DELNEXTHOP,
- RTM_GETNEXTHOP,
-
- _,
-};
-
-/// Netlink socket address
-pub const sockaddr_nl = extern struct {
- family: sa_family_t = AF_NETLINK,
- __pad1: c_ushort = 0,
-
- /// port ID
- pid: u32,
-
- /// multicast groups mask
- groups: u32,
-};
-
-/// Netlink message header
-/// Specified in RFC 3549 Section 2.3.2
-pub const nlmsghdr = extern struct {
- /// Length of message including header
- len: u32,
-
- /// Message content
- @"type": NetlinkMessageType,
-
- /// Additional flags
- flags: u16,
-
- /// Sequence number
- seq: u32,
-
- /// Sending process port ID
- pid: u32,
-};
-
-pub const ifinfomsg = extern struct {
- family: u8,
- __pad1: u8 = 0,
-
- /// ARPHRD_*
- @"type": c_ushort,
-
- /// Link index
- index: c_int,
-
- /// IFF_* flags
- flags: c_uint,
-
- /// IFF_* change mask
- change: c_uint,
-};
-
-pub const rtattr = extern struct {
- /// Length of option
- len: c_ushort,
-
- /// Type of option
- @"type": IFLA,
-
- pub const ALIGNTO = 4;
-};
-
-pub const IFLA = enum(c_ushort) {
- UNSPEC,
- ADDRESS,
- BROADCAST,
- IFNAME,
- MTU,
- LINK,
- QDISC,
- STATS,
- COST,
- PRIORITY,
- MASTER,
-
- /// Wireless Extension event
- WIRELESS,
-
- /// Protocol specific information for a link
- PROTINFO,
-
- TXQLEN,
- MAP,
- WEIGHT,
- OPERSTATE,
- LINKMODE,
- LINKINFO,
- NET_NS_PID,
- IFALIAS,
-
- /// Number of VFs if device is SR-IOV PF
- NUM_VF,
-
- VFINFO_LIST,
- STATS64,
- VF_PORTS,
- PORT_SELF,
- AF_SPEC,
-
- /// Group the device belongs to
- GROUP,
-
- NET_NS_FD,
-
- /// Extended info mask, VFs, etc
- EXT_MASK,
-
- /// Promiscuity count: > 0 means acts PROMISC
- PROMISCUITY,
-
- NUM_TX_QUEUES,
- NUM_RX_QUEUES,
- CARRIER,
- PHYS_PORT_ID,
- CARRIER_CHANGES,
- PHYS_SWITCH_ID,
- LINK_NETNSID,
- PHYS_PORT_NAME,
- PROTO_DOWN,
- GSO_MAX_SEGS,
- GSO_MAX_SIZE,
- PAD,
- XDP,
- EVENT,
-
- NEW_NETNSID,
- IF_NETNSID,
-
- CARRIER_UP_COUNT,
- CARRIER_DOWN_COUNT,
- NEW_IFINDEX,
- MIN_MTU,
- MAX_MTU,
-
- _,
-
- pub const TARGET_NETNSID: IFLA = .IF_NETNSID;
-};
-
-pub const rtnl_link_ifmap = extern struct {
- mem_start: u64,
- mem_end: u64,
- base_addr: u64,
- irq: u16,
- dma: u8,
- port: u8,
-};
-
-pub const rtnl_link_stats = extern struct {
- /// total packets received
- rx_packets: u32,
-
- /// total packets transmitted
- tx_packets: u32,
-
- /// total bytes received
- rx_bytes: u32,
-
- /// total bytes transmitted
- tx_bytes: u32,
-
- /// bad packets received
- rx_errors: u32,
-
- /// packet transmit problems
- tx_errors: u32,
-
- /// no space in linux buffers
- rx_dropped: u32,
-
- /// no space available in linux
- tx_dropped: u32,
-
- /// multicast packets received
- multicast: u32,
-
- collisions: u32,
-
- // detailed rx_errors
-
- rx_length_errors: u32,
-
- /// receiver ring buff overflow
- rx_over_errors: u32,
-
- /// recved pkt with crc error
- rx_crc_errors: u32,
-
- /// recv'd frame alignment error
- rx_frame_errors: u32,
-
- /// recv'r fifo overrun
- rx_fifo_errors: u32,
-
- /// receiver missed packet
- rx_missed_errors: u32,
-
- // detailed tx_errors
- tx_aborted_errors: u32,
- tx_carrier_errors: u32,
- tx_fifo_errors: u32,
- tx_heartbeat_errors: u32,
- tx_window_errors: u32,
-
- // for cslip etc
-
- rx_compressed: u32,
- tx_compressed: u32,
-
- /// dropped, no handler found
- rx_nohandler: u32,
-};
-
-pub const rtnl_link_stats64 = extern struct {
- /// total packets received
- rx_packets: u64,
-
- /// total packets transmitted
- tx_packets: u64,
-
- /// total bytes received
- rx_bytes: u64,
-
- /// total bytes transmitted
- tx_bytes: u64,
-
- /// bad packets received
- rx_errors: u64,
-
- /// packet transmit problems
- tx_errors: u64,
-
- /// no space in linux buffers
- rx_dropped: u64,
-
- /// no space available in linux
- tx_dropped: u64,
-
- /// multicast packets received
- multicast: u64,
-
- collisions: u64,
-
- // detailed rx_errors
-
- rx_length_errors: u64,
-
- /// receiver ring buff overflow
- rx_over_errors: u64,
-
- /// recved pkt with crc error
- rx_crc_errors: u64,
-
- /// recv'd frame alignment error
- rx_frame_errors: u64,
-
- /// recv'r fifo overrun
- rx_fifo_errors: u64,
-
- /// receiver missed packet
- rx_missed_errors: u64,
-
- // detailed tx_errors
- tx_aborted_errors: u64,
- tx_carrier_errors: u64,
- tx_fifo_errors: u64,
- tx_heartbeat_errors: u64,
- tx_window_errors: u64,
-
- // for cslip etc
-
- rx_compressed: u64,
- tx_compressed: u64,
-
- /// dropped, no handler found
- rx_nohandler: u64,
-};
diff --git a/lib/std/os/bits/linux/powerpc.zig b/lib/std/os/bits/linux/powerpc.zig
deleted file mode 100644
index 06f8e326ba2d..000000000000
--- a/lib/std/os/bits/linux/powerpc.zig
+++ /dev/null
@@ -1,621 +0,0 @@
-const std = @import("../../../std.zig");
-const linux = std.os.linux;
-const socklen_t = linux.socklen_t;
-const iovec = linux.iovec;
-const iovec_const = linux.iovec_const;
-const uid_t = linux.uid_t;
-const gid_t = linux.gid_t;
-const pid_t = linux.pid_t;
-const stack_t = linux.stack_t;
-const sigset_t = linux.sigset_t;
-pub const SYS = enum(usize) {
- restart_syscall = 0,
- exit = 1,
- fork = 2,
- read = 3,
- write = 4,
- open = 5,
- close = 6,
- waitpid = 7,
- creat = 8,
- link = 9,
- unlink = 10,
- execve = 11,
- chdir = 12,
- time = 13,
- mknod = 14,
- chmod = 15,
- lchown = 16,
- @"break" = 17,
- oldstat = 18,
- lseek = 19,
- getpid = 20,
- mount = 21,
- umount = 22,
- setuid = 23,
- getuid = 24,
- stime = 25,
- ptrace = 26,
- alarm = 27,
- oldfstat = 28,
- pause = 29,
- utime = 30,
- stty = 31,
- gtty = 32,
- access = 33,
- nice = 34,
- ftime = 35,
- sync = 36,
- kill = 37,
- rename = 38,
- mkdir = 39,
- rmdir = 40,
- dup = 41,
- pipe = 42,
- times = 43,
- prof = 44,
- brk = 45,
- setgid = 46,
- getgid = 47,
- signal = 48,
- geteuid = 49,
- getegid = 50,
- acct = 51,
- umount2 = 52,
- lock = 53,
- ioctl = 54,
- fcntl = 55,
- mpx = 56,
- setpgid = 57,
- ulimit = 58,
- oldolduname = 59,
- umask = 60,
- chroot = 61,
- ustat = 62,
- dup2 = 63,
- getppid = 64,
- getpgrp = 65,
- setsid = 66,
- sigaction = 67,
- sgetmask = 68,
- ssetmask = 69,
- setreuid = 70,
- setregid = 71,
- sigsuspend = 72,
- sigpending = 73,
- sethostname = 74,
- setrlimit = 75,
- getrlimit = 76,
- getrusage = 77,
- gettimeofday = 78,
- settimeofday = 79,
- getgroups = 80,
- setgroups = 81,
- select = 82,
- symlink = 83,
- oldlstat = 84,
- readlink = 85,
- uselib = 86,
- swapon = 87,
- reboot = 88,
- readdir = 89,
- mmap = 90,
- munmap = 91,
- truncate = 92,
- ftruncate = 93,
- fchmod = 94,
- fchown = 95,
- getpriority = 96,
- setpriority = 97,
- profil = 98,
- statfs = 99,
- fstatfs = 100,
- ioperm = 101,
- socketcall = 102,
- syslog = 103,
- setitimer = 104,
- getitimer = 105,
- stat = 106,
- lstat = 107,
- fstat = 108,
- olduname = 109,
- iopl = 110,
- vhangup = 111,
- idle = 112,
- vm86 = 113,
- wait4 = 114,
- swapoff = 115,
- sysinfo = 116,
- ipc = 117,
- fsync = 118,
- sigreturn = 119,
- clone = 120,
- setdomainname = 121,
- uname = 122,
- modify_ldt = 123,
- adjtimex = 124,
- mprotect = 125,
- sigprocmask = 126,
- create_module = 127,
- init_module = 128,
- delete_module = 129,
- get_kernel_syms = 130,
- quotactl = 131,
- getpgid = 132,
- fchdir = 133,
- bdflush = 134,
- sysfs = 135,
- personality = 136,
- afs_syscall = 137,
- setfsuid = 138,
- setfsgid = 139,
- _llseek = 140,
- getdents = 141,
- _newselect = 142,
- flock = 143,
- msync = 144,
- readv = 145,
- writev = 146,
- getsid = 147,
- fdatasync = 148,
- _sysctl = 149,
- mlock = 150,
- munlock = 151,
- mlockall = 152,
- munlockall = 153,
- sched_setparam = 154,
- sched_getparam = 155,
- sched_setscheduler = 156,
- sched_getscheduler = 157,
- sched_yield = 158,
- sched_get_priority_max = 159,
- sched_get_priority_min = 160,
- sched_rr_get_interval = 161,
- nanosleep = 162,
- mremap = 163,
- setresuid = 164,
- getresuid = 165,
- query_module = 166,
- poll = 167,
- nfsservctl = 168,
- setresgid = 169,
- getresgid = 170,
- prctl = 171,
- rt_sigreturn = 172,
- rt_sigaction = 173,
- rt_sigprocmask = 174,
- rt_sigpending = 175,
- rt_sigtimedwait = 176,
- rt_sigqueueinfo = 177,
- rt_sigsuspend = 178,
- pread64 = 179,
- pwrite64 = 180,
- chown = 181,
- getcwd = 182,
- capget = 183,
- capset = 184,
- sigaltstack = 185,
- sendfile = 186,
- getpmsg = 187,
- putpmsg = 188,
- vfork = 189,
- ugetrlimit = 190,
- readahead = 191,
- mmap2 = 192,
- truncate64 = 193,
- ftruncate64 = 194,
- stat64 = 195,
- lstat64 = 196,
- fstat64 = 197,
- pciconfig_read = 198,
- pciconfig_write = 199,
- pciconfig_iobase = 200,
- multiplexer = 201,
- getdents64 = 202,
- pivot_root = 203,
- fcntl64 = 204,
- madvise = 205,
- mincore = 206,
- gettid = 207,
- tkill = 208,
- setxattr = 209,
- lsetxattr = 210,
- fsetxattr = 211,
- getxattr = 212,
- lgetxattr = 213,
- fgetxattr = 214,
- listxattr = 215,
- llistxattr = 216,
- flistxattr = 217,
- removexattr = 218,
- lremovexattr = 219,
- fremovexattr = 220,
- futex = 221,
- sched_setaffinity = 222,
- sched_getaffinity = 223,
- tuxcall = 225,
- sendfile64 = 226,
- io_setup = 227,
- io_destroy = 228,
- io_getevents = 229,
- io_submit = 230,
- io_cancel = 231,
- set_tid_address = 232,
- fadvise64 = 233,
- exit_group = 234,
- lookup_dcookie = 235,
- epoll_create = 236,
- epoll_ctl = 237,
- epoll_wait = 238,
- remap_file_pages = 239,
- timer_create = 240,
- timer_settime = 241,
- timer_gettime = 242,
- timer_getoverrun = 243,
- timer_delete = 244,
- clock_settime = 245,
- clock_gettime = 246,
- clock_getres = 247,
- clock_nanosleep = 248,
- swapcontext = 249,
- tgkill = 250,
- utimes = 251,
- statfs64 = 252,
- fstatfs64 = 253,
- fadvise64_64 = 254,
- rtas = 255,
- sys_debug_setcontext = 256,
- migrate_pages = 258,
- mbind = 259,
- get_mempolicy = 260,
- set_mempolicy = 261,
- mq_open = 262,
- mq_unlink = 263,
- mq_timedsend = 264,
- mq_timedreceive = 265,
- mq_notify = 266,
- mq_getsetattr = 267,
- kexec_load = 268,
- add_key = 269,
- request_key = 270,
- keyctl = 271,
- waitid = 272,
- ioprio_set = 273,
- ioprio_get = 274,
- inotify_init = 275,
- inotify_add_watch = 276,
- inotify_rm_watch = 277,
- spu_run = 278,
- spu_create = 279,
- pselect6 = 280,
- ppoll = 281,
- unshare = 282,
- splice = 283,
- tee = 284,
- vmsplice = 285,
- openat = 286,
- mkdirat = 287,
- mknodat = 288,
- fchownat = 289,
- futimesat = 290,
- fstatat64 = 291,
- unlinkat = 292,
- renameat = 293,
- linkat = 294,
- symlinkat = 295,
- readlinkat = 296,
- fchmodat = 297,
- faccessat = 298,
- get_robust_list = 299,
- set_robust_list = 300,
- move_pages = 301,
- getcpu = 302,
- epoll_pwait = 303,
- utimensat = 304,
- signalfd = 305,
- timerfd_create = 306,
- eventfd = 307,
- sync_file_range = 308,
- fallocate = 309,
- subpage_prot = 310,
- timerfd_settime = 311,
- timerfd_gettime = 312,
- signalfd4 = 313,
- eventfd2 = 314,
- epoll_create1 = 315,
- dup3 = 316,
- pipe2 = 317,
- inotify_init1 = 318,
- perf_event_open = 319,
- preadv = 320,
- pwritev = 321,
- rt_tgsigqueueinfo = 322,
- fanotify_init = 323,
- fanotify_mark = 324,
- prlimit64 = 325,
- socket = 326,
- bind = 327,
- connect = 328,
- listen = 329,
- accept = 330,
- getsockname = 331,
- getpeername = 332,
- socketpair = 333,
- send = 334,
- sendto = 335,
- recv = 336,
- recvfrom = 337,
- shutdown = 338,
- setsockopt = 339,
- getsockopt = 340,
- sendmsg = 341,
- recvmsg = 342,
- recvmmsg = 343,
- accept4 = 344,
- name_to_handle_at = 345,
- open_by_handle_at = 346,
- clock_adjtime = 347,
- syncfs = 348,
- sendmmsg = 349,
- setns = 350,
- process_vm_readv = 351,
- process_vm_writev = 352,
- finit_module = 353,
- kcmp = 354,
- sched_setattr = 355,
- sched_getattr = 356,
- renameat2 = 357,
- seccomp = 358,
- getrandom = 359,
- memfd_create = 360,
- bpf = 361,
- execveat = 362,
- switch_endian = 363,
- userfaultfd = 364,
- membarrier = 365,
- mlock2 = 378,
- copy_file_range = 379,
- preadv2 = 380,
- pwritev2 = 381,
- kexec_file_load = 382,
- statx = 383,
- pkey_alloc = 384,
- pkey_free = 385,
- pkey_mprotect = 386,
- rseq = 387,
- io_pgetevents = 388,
- semget = 393,
- semctl = 394,
- shmget = 395,
- shmctl = 396,
- shmat = 397,
- shmdt = 398,
- msgget = 399,
- msgsnd = 400,
- msgrcv = 401,
- msgctl = 402,
- clock_gettime64 = 403,
- clock_settime64 = 404,
- clock_adjtime64 = 405,
- clock_getres_time64 = 406,
- clock_nanosleep_time64 = 407,
- timer_gettime64 = 408,
- timer_settime64 = 409,
- timerfd_gettime64 = 410,
- timerfd_settime64 = 411,
- utimensat_time64 = 412,
- pselect6_time64 = 413,
- ppoll_time64 = 414,
- io_pgetevents_time64 = 416,
- recvmmsg_time64 = 417,
- mq_timedsend_time64 = 418,
- mq_timedreceive_time64 = 419,
- semtimedop_time64 = 420,
- rt_sigtimedwait_time64 = 421,
- futex_time64 = 422,
- sched_rr_get_interval_time64 = 423,
- pidfd_send_signal = 424,
- io_uring_setup = 425,
- io_uring_enter = 426,
- io_uring_register = 427,
- open_tree = 428,
- move_mount = 429,
- fsopen = 430,
- fsconfig = 431,
- fsmount = 432,
- fspick = 433,
- pidfd_open = 434,
- clone3 = 435,
- close_range = 436,
- openat2 = 437,
- pidfd_getfd = 438,
- faccessat2 = 439,
- process_madvise = 440,
-};
-
-pub const O_CREAT = 0o100;
-pub const O_EXCL = 0o200;
-pub const O_NOCTTY = 0o400;
-pub const O_TRUNC = 0o1000;
-pub const O_APPEND = 0o2000;
-pub const O_NONBLOCK = 0o4000;
-pub const O_DSYNC = 0o10000;
-pub const O_SYNC = 0o4010000;
-pub const O_RSYNC = 0o4010000;
-pub const O_DIRECTORY = 0o40000;
-pub const O_NOFOLLOW = 0o100000;
-pub const O_CLOEXEC = 0o2000000;
-
-pub const O_ASYNC = 0o20000;
-pub const O_DIRECT = 0o400000;
-pub const O_LARGEFILE = 0o200000;
-pub const O_NOATIME = 0o1000000;
-pub const O_PATH = 0o10000000;
-pub const O_TMPFILE = 0o20040000;
-pub const O_NDELAY = O_NONBLOCK;
-
-pub const F_DUPFD = 0;
-pub const F_GETFD = 1;
-pub const F_SETFD = 2;
-pub const F_GETFL = 3;
-pub const F_SETFL = 4;
-
-pub const F_SETOWN = 8;
-pub const F_GETOWN = 9;
-pub const F_SETSIG = 10;
-pub const F_GETSIG = 11;
-
-pub const F_GETLK = 12;
-pub const F_SETLK = 13;
-pub const F_SETLKW = 14;
-
-pub const F_SETOWN_EX = 15;
-pub const F_GETOWN_EX = 16;
-
-pub const F_GETOWNER_UIDS = 17;
-
-pub const F_RDLCK = 0;
-pub const F_WRLCK = 1;
-pub const F_UNLCK = 2;
-
-pub const LOCK_SH = 1;
-pub const LOCK_EX = 2;
-pub const LOCK_UN = 8;
-pub const LOCK_NB = 4;
-
-/// stack-like segment
-pub const MAP_GROWSDOWN = 0x0100;
-
-/// ETXTBSY
-pub const MAP_DENYWRITE = 0x0800;
-
-/// mark it as an executable
-pub const MAP_EXECUTABLE = 0x1000;
-
-/// pages are locked
-pub const MAP_LOCKED = 0x0080;
-
-/// don't check for reservations
-pub const MAP_NORESERVE = 0x0040;
-
-pub const VDSO_CGT_SYM = "__kernel_clock_gettime";
-pub const VDSO_CGT_VER = "LINUX_2.6.15";
-
-pub const Flock = extern struct {
- l_type: i16,
- l_whence: i16,
- l_start: off_t,
- l_len: off_t,
- l_pid: pid_t,
-};
-
-pub const msghdr = extern struct {
- msg_name: ?*sockaddr,
- msg_namelen: socklen_t,
- msg_iov: [*]iovec,
- msg_iovlen: usize,
- msg_control: ?*c_void,
- msg_controllen: socklen_t,
- msg_flags: i32,
-};
-
-pub const msghdr_const = extern struct {
- msg_name: ?*const sockaddr,
- msg_namelen: socklen_t,
- msg_iov: [*]iovec_const,
- msg_iovlen: usize,
- msg_control: ?*c_void,
- msg_controllen: socklen_t,
- msg_flags: i32,
-};
-
-pub const blksize_t = i32;
-pub const nlink_t = u32;
-pub const time_t = isize;
-pub const mode_t = u32;
-pub const off_t = i64;
-pub const ino_t = u64;
-pub const dev_t = u64;
-pub const blkcnt_t = i64;
-
-// The `stat` definition used by the Linux kernel.
-pub const kernel_stat = extern struct {
- dev: dev_t,
- ino: ino_t,
- mode: mode_t,
- nlink: nlink_t,
- uid: uid_t,
- gid: gid_t,
- rdev: dev_t,
- __rdev_padding: i16,
- size: off_t,
- blksize: blksize_t,
- blocks: blkcnt_t,
- atim: timespec,
- mtim: timespec,
- ctim: timespec,
- __unused: [2]u32,
-
- pub fn atime(self: @This()) timespec {
- return self.atim;
- }
-
- pub fn mtime(self: @This()) timespec {
- return self.mtim;
- }
-
- pub fn ctime(self: @This()) timespec {
- return self.ctim;
- }
-};
-
-// The `stat64` definition used by the libc.
-pub const libc_stat = kernel_stat;
-
-pub const timespec = extern struct {
- tv_sec: time_t,
- tv_nsec: isize,
-};
-
-pub const timeval = extern struct {
- tv_sec: time_t,
- tv_usec: isize,
-};
-
-pub const timezone = extern struct {
- tz_minuteswest: i32,
- tz_dsttime: i32,
-};
-
-pub const greg_t = u32;
-pub const gregset_t = [48]greg_t;
-pub const fpregset_t = [33]f64;
-
-pub const vrregset = extern struct {
- vrregs: [32][4]u32,
- vrsave: u32,
- _pad: [2]u32,
- vscr: u32,
-};
-pub const vrregset_t = vrregset;
-
-pub const mcontext_t = extern struct {
- gp_regs: gregset_t,
- fp_regs: fpregset_t,
- v_regs: vrregset_t align(16),
-};
-
-pub const ucontext_t = extern struct {
- flags: u32,
- link: *ucontext_t,
- stack: stack_t,
- pad: [7]i32,
- regs: *mcontext_t,
- sigmask: sigset_t,
- pad2: [3]i32,
- mcontext: mcontext_t,
-};
-
-pub const Elf_Symndx = u32;
-
-pub const MMAP2_UNIT = 4096;
diff --git a/lib/std/os/bits/linux/powerpc64.zig b/lib/std/os/bits/linux/powerpc64.zig
deleted file mode 100644
index 74c6ad11fc7a..000000000000
--- a/lib/std/os/bits/linux/powerpc64.zig
+++ /dev/null
@@ -1,604 +0,0 @@
-const std = @import("../../../std.zig");
-const linux = std.os.linux;
-const socklen_t = linux.socklen_t;
-const iovec = linux.iovec;
-const iovec_const = linux.iovec_const;
-const uid_t = linux.uid_t;
-const gid_t = linux.gid_t;
-const pid_t = linux.pid_t;
-const stack_t = linux.stack_t;
-const sigset_t = linux.sigset_t;
-pub const SYS = enum(usize) {
- restart_syscall = 0,
- exit = 1,
- fork = 2,
- read = 3,
- write = 4,
- open = 5,
- close = 6,
- waitpid = 7,
- creat = 8,
- link = 9,
- unlink = 10,
- execve = 11,
- chdir = 12,
- time = 13,
- mknod = 14,
- chmod = 15,
- lchown = 16,
- @"break" = 17,
- oldstat = 18,
- lseek = 19,
- getpid = 20,
- mount = 21,
- umount = 22,
- setuid = 23,
- getuid = 24,
- stime = 25,
- ptrace = 26,
- alarm = 27,
- oldfstat = 28,
- pause = 29,
- utime = 30,
- stty = 31,
- gtty = 32,
- access = 33,
- nice = 34,
- ftime = 35,
- sync = 36,
- kill = 37,
- rename = 38,
- mkdir = 39,
- rmdir = 40,
- dup = 41,
- pipe = 42,
- times = 43,
- prof = 44,
- brk = 45,
- setgid = 46,
- getgid = 47,
- signal = 48,
- geteuid = 49,
- getegid = 50,
- acct = 51,
- umount2 = 52,
- lock = 53,
- ioctl = 54,
- fcntl = 55,
- mpx = 56,
- setpgid = 57,
- ulimit = 58,
- oldolduname = 59,
- umask = 60,
- chroot = 61,
- ustat = 62,
- dup2 = 63,
- getppid = 64,
- getpgrp = 65,
- setsid = 66,
- sigaction = 67,
- sgetmask = 68,
- ssetmask = 69,
- setreuid = 70,
- setregid = 71,
- sigsuspend = 72,
- sigpending = 73,
- sethostname = 74,
- setrlimit = 75,
- getrlimit = 76,
- getrusage = 77,
- gettimeofday = 78,
- settimeofday = 79,
- getgroups = 80,
- setgroups = 81,
- select = 82,
- symlink = 83,
- oldlstat = 84,
- readlink = 85,
- uselib = 86,
- swapon = 87,
- reboot = 88,
- readdir = 89,
- mmap = 90,
- munmap = 91,
- truncate = 92,
- ftruncate = 93,
- fchmod = 94,
- fchown = 95,
- getpriority = 96,
- setpriority = 97,
- profil = 98,
- statfs = 99,
- fstatfs = 100,
- ioperm = 101,
- socketcall = 102,
- syslog = 103,
- setitimer = 104,
- getitimer = 105,
- stat = 106,
- lstat = 107,
- fstat = 108,
- olduname = 109,
- iopl = 110,
- vhangup = 111,
- idle = 112,
- vm86 = 113,
- wait4 = 114,
- swapoff = 115,
- sysinfo = 116,
- ipc = 117,
- fsync = 118,
- sigreturn = 119,
- clone = 120,
- setdomainname = 121,
- uname = 122,
- modify_ldt = 123,
- adjtimex = 124,
- mprotect = 125,
- sigprocmask = 126,
- create_module = 127,
- init_module = 128,
- delete_module = 129,
- get_kernel_syms = 130,
- quotactl = 131,
- getpgid = 132,
- fchdir = 133,
- bdflush = 134,
- sysfs = 135,
- personality = 136,
- afs_syscall = 137,
- setfsuid = 138,
- setfsgid = 139,
- _llseek = 140,
- getdents = 141,
- _newselect = 142,
- flock = 143,
- msync = 144,
- readv = 145,
- writev = 146,
- getsid = 147,
- fdatasync = 148,
- _sysctl = 149,
- mlock = 150,
- munlock = 151,
- mlockall = 152,
- munlockall = 153,
- sched_setparam = 154,
- sched_getparam = 155,
- sched_setscheduler = 156,
- sched_getscheduler = 157,
- sched_yield = 158,
- sched_get_priority_max = 159,
- sched_get_priority_min = 160,
- sched_rr_get_interval = 161,
- nanosleep = 162,
- mremap = 163,
- setresuid = 164,
- getresuid = 165,
- query_module = 166,
- poll = 167,
- nfsservctl = 168,
- setresgid = 169,
- getresgid = 170,
- prctl = 171,
- rt_sigreturn = 172,
- rt_sigaction = 173,
- rt_sigprocmask = 174,
- rt_sigpending = 175,
- rt_sigtimedwait = 176,
- rt_sigqueueinfo = 177,
- rt_sigsuspend = 178,
- pread64 = 179,
- pwrite64 = 180,
- chown = 181,
- getcwd = 182,
- capget = 183,
- capset = 184,
- sigaltstack = 185,
- sendfile = 186,
- getpmsg = 187,
- putpmsg = 188,
- vfork = 189,
- ugetrlimit = 190,
- readahead = 191,
- pciconfig_read = 198,
- pciconfig_write = 199,
- pciconfig_iobase = 200,
- multiplexer = 201,
- getdents64 = 202,
- pivot_root = 203,
- madvise = 205,
- mincore = 206,
- gettid = 207,
- tkill = 208,
- setxattr = 209,
- lsetxattr = 210,
- fsetxattr = 211,
- getxattr = 212,
- lgetxattr = 213,
- fgetxattr = 214,
- listxattr = 215,
- llistxattr = 216,
- flistxattr = 217,
- removexattr = 218,
- lremovexattr = 219,
- fremovexattr = 220,
- futex = 221,
- sched_setaffinity = 222,
- sched_getaffinity = 223,
- tuxcall = 225,
- io_setup = 227,
- io_destroy = 228,
- io_getevents = 229,
- io_submit = 230,
- io_cancel = 231,
- set_tid_address = 232,
- fadvise64 = 233,
- exit_group = 234,
- lookup_dcookie = 235,
- epoll_create = 236,
- epoll_ctl = 237,
- epoll_wait = 238,
- remap_file_pages = 239,
- timer_create = 240,
- timer_settime = 241,
- timer_gettime = 242,
- timer_getoverrun = 243,
- timer_delete = 244,
- clock_settime = 245,
- clock_gettime = 246,
- clock_getres = 247,
- clock_nanosleep = 248,
- swapcontext = 249,
- tgkill = 250,
- utimes = 251,
- statfs64 = 252,
- fstatfs64 = 253,
- rtas = 255,
- sys_debug_setcontext = 256,
- migrate_pages = 258,
- mbind = 259,
- get_mempolicy = 260,
- set_mempolicy = 261,
- mq_open = 262,
- mq_unlink = 263,
- mq_timedsend = 264,
- mq_timedreceive = 265,
- mq_notify = 266,
- mq_getsetattr = 267,
- kexec_load = 268,
- add_key = 269,
- request_key = 270,
- keyctl = 271,
- waitid = 272,
- ioprio_set = 273,
- ioprio_get = 274,
- inotify_init = 275,
- inotify_add_watch = 276,
- inotify_rm_watch = 277,
- spu_run = 278,
- spu_create = 279,
- pselect6 = 280,
- ppoll = 281,
- unshare = 282,
- splice = 283,
- tee = 284,
- vmsplice = 285,
- openat = 286,
- mkdirat = 287,
- mknodat = 288,
- fchownat = 289,
- futimesat = 290,
- fstatat = 291,
- unlinkat = 292,
- renameat = 293,
- linkat = 294,
- symlinkat = 295,
- readlinkat = 296,
- fchmodat = 297,
- faccessat = 298,
- get_robust_list = 299,
- set_robust_list = 300,
- move_pages = 301,
- getcpu = 302,
- epoll_pwait = 303,
- utimensat = 304,
- signalfd = 305,
- timerfd_create = 306,
- eventfd = 307,
- sync_file_range = 308,
- fallocate = 309,
- subpage_prot = 310,
- timerfd_settime = 311,
- timerfd_gettime = 312,
- signalfd4 = 313,
- eventfd2 = 314,
- epoll_create1 = 315,
- dup3 = 316,
- pipe2 = 317,
- inotify_init1 = 318,
- perf_event_open = 319,
- preadv = 320,
- pwritev = 321,
- rt_tgsigqueueinfo = 322,
- fanotify_init = 323,
- fanotify_mark = 324,
- prlimit64 = 325,
- socket = 326,
- bind = 327,
- connect = 328,
- listen = 329,
- accept = 330,
- getsockname = 331,
- getpeername = 332,
- socketpair = 333,
- send = 334,
- sendto = 335,
- recv = 336,
- recvfrom = 337,
- shutdown = 338,
- setsockopt = 339,
- getsockopt = 340,
- sendmsg = 341,
- recvmsg = 342,
- recvmmsg = 343,
- accept4 = 344,
- name_to_handle_at = 345,
- open_by_handle_at = 346,
- clock_adjtime = 347,
- syncfs = 348,
- sendmmsg = 349,
- setns = 350,
- process_vm_readv = 351,
- process_vm_writev = 352,
- finit_module = 353,
- kcmp = 354,
- sched_setattr = 355,
- sched_getattr = 356,
- renameat2 = 357,
- seccomp = 358,
- getrandom = 359,
- memfd_create = 360,
- bpf = 361,
- execveat = 362,
- switch_endian = 363,
- userfaultfd = 364,
- membarrier = 365,
- mlock2 = 378,
- copy_file_range = 379,
- preadv2 = 380,
- pwritev2 = 381,
- kexec_file_load = 382,
- statx = 383,
- pkey_alloc = 384,
- pkey_free = 385,
- pkey_mprotect = 386,
- rseq = 387,
- io_pgetevents = 388,
- semtimedop = 392,
- semget = 393,
- semctl = 394,
- shmget = 395,
- shmctl = 396,
- shmat = 397,
- shmdt = 398,
- msgget = 399,
- msgsnd = 400,
- msgrcv = 401,
- msgctl = 402,
- pidfd_send_signal = 424,
- io_uring_setup = 425,
- io_uring_enter = 426,
- io_uring_register = 427,
- open_tree = 428,
- move_mount = 429,
- fsopen = 430,
- fsconfig = 431,
- fsmount = 432,
- fspick = 433,
- pidfd_open = 434,
- clone3 = 435,
- close_range = 436,
- openat2 = 437,
- pidfd_getfd = 438,
- faccessat2 = 439,
- process_madvise = 440,
- epoll_pwait2 = 441,
-
- _,
-};
-
-pub const O_CREAT = 0o100;
-pub const O_EXCL = 0o200;
-pub const O_NOCTTY = 0o400;
-pub const O_TRUNC = 0o1000;
-pub const O_APPEND = 0o2000;
-pub const O_NONBLOCK = 0o4000;
-pub const O_DSYNC = 0o10000;
-pub const O_SYNC = 0o4010000;
-pub const O_RSYNC = 0o4010000;
-pub const O_DIRECTORY = 0o40000;
-pub const O_NOFOLLOW = 0o100000;
-pub const O_CLOEXEC = 0o2000000;
-
-pub const O_ASYNC = 0o20000;
-pub const O_DIRECT = 0o400000;
-pub const O_LARGEFILE = 0o200000;
-pub const O_NOATIME = 0o1000000;
-pub const O_PATH = 0o10000000;
-pub const O_TMPFILE = 0o20200000;
-pub const O_NDELAY = O_NONBLOCK;
-
-pub const F_DUPFD = 0;
-pub const F_GETFD = 1;
-pub const F_SETFD = 2;
-pub const F_GETFL = 3;
-pub const F_SETFL = 4;
-
-pub const F_SETOWN = 8;
-pub const F_GETOWN = 9;
-pub const F_SETSIG = 10;
-pub const F_GETSIG = 11;
-
-pub const F_GETLK = 5;
-pub const F_SETLK = 6;
-pub const F_SETLKW = 7;
-
-pub const F_RDLCK = 0;
-pub const F_WRLCK = 1;
-pub const F_UNLCK = 2;
-
-pub const LOCK_SH = 1;
-pub const LOCK_EX = 2;
-pub const LOCK_UN = 8;
-pub const LOCK_NB = 4;
-
-pub const F_SETOWN_EX = 15;
-pub const F_GETOWN_EX = 16;
-
-pub const F_GETOWNER_UIDS = 17;
-
-/// stack-like segment
-pub const MAP_GROWSDOWN = 0x0100;
-
-/// ETXTBSY
-pub const MAP_DENYWRITE = 0x0800;
-
-/// mark it as an executable
-pub const MAP_EXECUTABLE = 0x1000;
-
-/// pages are locked
-pub const MAP_LOCKED = 0x0080;
-
-/// don't check for reservations
-pub const MAP_NORESERVE = 0x0040;
-
-pub const VDSO_CGT_SYM = "__kernel_clock_gettime";
-pub const VDSO_CGT_VER = "LINUX_2.6.15";
-
-pub const Flock = extern struct {
- l_type: i16,
- l_whence: i16,
- l_start: off_t,
- l_len: off_t,
- l_pid: pid_t,
- __unused: [4]u8,
-};
-
-pub const msghdr = extern struct {
- msg_name: ?*sockaddr,
- msg_namelen: socklen_t,
- msg_iov: [*]iovec,
- msg_iovlen: usize,
- msg_control: ?*c_void,
- msg_controllen: usize,
- msg_flags: i32,
-};
-
-pub const msghdr_const = extern struct {
- msg_name: ?*const sockaddr,
- msg_namelen: socklen_t,
- msg_iov: [*]iovec_const,
- msg_iovlen: usize,
- msg_control: ?*c_void,
- msg_controllen: usize,
- msg_flags: i32,
-};
-
-pub const blksize_t = i64;
-pub const nlink_t = u64;
-pub const time_t = i64;
-pub const mode_t = u32;
-pub const off_t = i64;
-pub const ino_t = u64;
-pub const dev_t = u64;
-pub const blkcnt_t = i64;
-
-// The `stat` definition used by the Linux kernel.
-pub const kernel_stat = extern struct {
- dev: dev_t,
- ino: ino_t,
- nlink: nlink_t,
- mode: mode_t,
- uid: uid_t,
- gid: gid_t,
- rdev: dev_t,
- size: off_t,
- blksize: blksize_t,
- blocks: blkcnt_t,
- atim: timespec,
- mtim: timespec,
- ctim: timespec,
- __unused: [3]u64,
-
- pub fn atime(self: @This()) timespec {
- return self.atim;
- }
-
- pub fn mtime(self: @This()) timespec {
- return self.mtim;
- }
-
- pub fn ctime(self: @This()) timespec {
- return self.ctim;
- }
-};
-
-// The `stat64` definition used by the libc.
-pub const libc_stat = kernel_stat;
-
-pub const timespec = extern struct {
- tv_sec: time_t,
- tv_nsec: isize,
-};
-
-pub const timeval = extern struct {
- tv_sec: isize,
- tv_usec: isize,
-};
-
-pub const timezone = extern struct {
- tz_minuteswest: i32,
- tz_dsttime: i32,
-};
-
-pub const greg_t = u64;
-pub const gregset_t = [48]greg_t;
-pub const fpregset_t = [33]f64;
-
-/// The position of the vscr register depends on endianness.
-/// On C, macros are used to change vscr_word's offset to
-/// account for this. Here we'll just define vscr_word_le
-/// and vscr_word_be. Code must take care to use the correct one.
-pub const vrregset = extern struct {
- vrregs: [32][4]u32 align(16),
- vscr_word_le: u32,
- _pad1: [2]u32,
- vscr_word_be: u32,
- vrsave: u32,
- _pad2: [3]u32,
-};
-pub const vrregset_t = vrregset;
-
-pub const mcontext_t = extern struct {
- __unused: [4]u64,
- signal: i32,
- _pad0: i32,
- handler: u64,
- oldmask: u64,
- regs: ?*c_void,
- gp_regs: gregset_t,
- fp_regs: fpregset_t,
- v_regs: *vrregset_t,
- vmx_reserve: [34 + 34 + 32 + 1]i64,
-};
-
-pub const ucontext_t = extern struct {
- flags: u32,
- link: *ucontext_t,
- stack: stack_t,
- sigmask: sigset_t,
- mcontext: mcontext_t,
-};
-
-pub const Elf_Symndx = u32;
diff --git a/lib/std/os/bits/linux/prctl.zig b/lib/std/os/bits/linux/prctl.zig
deleted file mode 100644
index d29b6021b606..000000000000
--- a/lib/std/os/bits/linux/prctl.zig
+++ /dev/null
@@ -1,234 +0,0 @@
-pub const PR = enum(i32) {
- SET_PDEATHSIG = 1,
- GET_PDEATHSIG = 2,
-
- GET_DUMPABLE = 3,
- SET_DUMPABLE = 4,
-
- GET_UNALIGN = 5,
- SET_UNALIGN = 6,
-
- GET_KEEPCAPS = 7,
- SET_KEEPCAPS = 8,
-
- GET_FPEMU = 9,
- SET_FPEMU = 10,
-
- GET_FPEXC = 11,
- SET_FPEXC = 12,
-
- GET_TIMING = 13,
- SET_TIMING = 14,
-
- SET_NAME = 15,
- GET_NAME = 16,
-
- GET_ENDIAN = 19,
- SET_ENDIAN = 20,
-
- GET_SECCOMP = 21,
- SET_SECCOMP = 22,
-
- CAPBSET_READ = 23,
- CAPBSET_DROP = 24,
-
- GET_TSC = 25,
- SET_TSC = 26,
-
- GET_SECUREBITS = 27,
- SET_SECUREBITS = 28,
-
- SET_TIMERSLACK = 29,
- GET_TIMERSLACK = 30,
-
- TASK_PERF_EVENTS_DISABLE = 31,
- TASK_PERF_EVENTS_ENABLE = 32,
-
- MCE_KILL = 33,
-
- MCE_KILL_GET = 34,
-
- SET_MM = 35,
-
- SET_PTRACER = 0x59616d61,
-
- SET_CHILD_SUBREAPER = 36,
- GET_CHILD_SUBREAPER = 37,
-
- SET_NO_NEW_PRIVS = 38,
- GET_NO_NEW_PRIVS = 39,
-
- GET_TID_ADDRESS = 40,
-
- SET_THP_DISABLE = 41,
- GET_THP_DISABLE = 42,
-
- MPX_ENABLE_MANAGEMENT = 43,
- MPX_DISABLE_MANAGEMENT = 44,
-
- SET_FP_MODE = 45,
- GET_FP_MODE = 46,
-
- CAP_AMBIENT = 47,
-
- SVE_SET_VL = 50,
- SVE_GET_VL = 51,
-
- GET_SPECULATION_CTRL = 52,
- SET_SPECULATION_CTRL = 53,
-
- _,
-};
-
-pub const PR_SET_PDEATHSIG = @enumToInt(PR.SET_PDEATHSIG);
-pub const PR_GET_PDEATHSIG = @enumToInt(PR.GET_PDEATHSIG);
-
-pub const PR_GET_DUMPABLE = @enumToInt(PR.GET_DUMPABLE);
-pub const PR_SET_DUMPABLE = @enumToInt(PR.SET_DUMPABLE);
-
-pub const PR_GET_UNALIGN = @enumToInt(PR.GET_UNALIGN);
-pub const PR_SET_UNALIGN = @enumToInt(PR.SET_UNALIGN);
-pub const PR_UNALIGN_NOPRINT = 1;
-pub const PR_UNALIGN_SIGBUS = 2;
-
-pub const PR_GET_KEEPCAPS = @enumToInt(PR.GET_KEEPCAPS);
-pub const PR_SET_KEEPCAPS = @enumToInt(PR.SET_KEEPCAPS);
-
-pub const PR_GET_FPEMU = @enumToInt(PR.GET_FPEMU);
-pub const PR_SET_FPEMU = @enumToInt(PR.SET_FPEMU);
-pub const PR_FPEMU_NOPRINT = 1;
-pub const PR_FPEMU_SIGFPE = 2;
-
-pub const PR_GET_FPEXC = @enumToInt(PR.GET_FPEXC);
-pub const PR_SET_FPEXC = @enumToInt(PR.SET_FPEXC);
-pub const PR_FP_EXC_SW_ENABLE = 0x80;
-pub const PR_FP_EXC_DIV = 0x010000;
-pub const PR_FP_EXC_OVF = 0x020000;
-pub const PR_FP_EXC_UND = 0x040000;
-pub const PR_FP_EXC_RES = 0x080000;
-pub const PR_FP_EXC_INV = 0x100000;
-pub const PR_FP_EXC_DISABLED = 0;
-pub const PR_FP_EXC_NONRECOV = 1;
-pub const PR_FP_EXC_ASYNC = 2;
-pub const PR_FP_EXC_PRECISE = 3;
-
-pub const PR_GET_TIMING = @enumToInt(PR.GET_TIMING);
-pub const PR_SET_TIMING = @enumToInt(PR.SET_TIMING);
-pub const PR_TIMING_STATISTICAL = 0;
-pub const PR_TIMING_TIMESTAMP = 1;
-
-pub const PR_SET_NAME = @enumToInt(PR.SET_NAME);
-pub const PR_GET_NAME = @enumToInt(PR.GET_NAME);
-
-pub const PR_GET_ENDIAN = @enumToInt(PR.GET_ENDIAN);
-pub const PR_SET_ENDIAN = @enumToInt(PR.SET_ENDIAN);
-pub const PR_ENDIAN_BIG = 0;
-pub const PR_ENDIAN_LITTLE = 1;
-pub const PR_ENDIAN_PPC_LITTLE = 2;
-
-pub const PR_GET_SECCOMP = @enumToInt(PR.GET_SECCOMP);
-pub const PR_SET_SECCOMP = @enumToInt(PR.SET_SECCOMP);
-
-pub const PR_CAPBSET_READ = @enumToInt(PR.CAPBSET_READ);
-pub const PR_CAPBSET_DROP = @enumToInt(PR.CAPBSET_DROP);
-
-pub const PR_GET_TSC = @enumToInt(PR.GET_TSC);
-pub const PR_SET_TSC = @enumToInt(PR.SET_TSC);
-pub const PR_TSC_ENABLE = 1;
-pub const PR_TSC_SIGSEGV = 2;
-
-pub const PR_GET_SECUREBITS = @enumToInt(PR.GET_SECUREBITS);
-pub const PR_SET_SECUREBITS = @enumToInt(PR.SET_SECUREBITS);
-
-pub const PR_SET_TIMERSLACK = @enumToInt(PR.SET_TIMERSLACK);
-pub const PR_GET_TIMERSLACK = @enumToInt(PR.GET_TIMERSLACK);
-
-pub const PR_TASK_PERF_EVENTS_DISABLE = @enumToInt(PR.TASK_PERF_EVENTS_DISABLE);
-pub const PR_TASK_PERF_EVENTS_ENABLE = @enumToInt(PR.TASK_PERF_EVENTS_ENABLE);
-
-pub const PR_MCE_KILL = @enumToInt(PR.MCE_KILL);
-pub const PR_MCE_KILL_CLEAR = 0;
-pub const PR_MCE_KILL_SET = 1;
-
-pub const PR_MCE_KILL_LATE = 0;
-pub const PR_MCE_KILL_EARLY = 1;
-pub const PR_MCE_KILL_DEFAULT = 2;
-
-pub const PR_MCE_KILL_GET = @enumToInt(PR.MCE_KILL_GET);
-
-pub const PR_SET_MM = @enumToInt(PR.SET_MM);
-pub const PR_SET_MM_START_CODE = 1;
-pub const PR_SET_MM_END_CODE = 2;
-pub const PR_SET_MM_START_DATA = 3;
-pub const PR_SET_MM_END_DATA = 4;
-pub const PR_SET_MM_START_STACK = 5;
-pub const PR_SET_MM_START_BRK = 6;
-pub const PR_SET_MM_BRK = 7;
-pub const PR_SET_MM_ARG_START = 8;
-pub const PR_SET_MM_ARG_END = 9;
-pub const PR_SET_MM_ENV_START = 10;
-pub const PR_SET_MM_ENV_END = 11;
-pub const PR_SET_MM_AUXV = 12;
-pub const PR_SET_MM_EXE_FILE = 13;
-pub const PR_SET_MM_MAP = 14;
-pub const PR_SET_MM_MAP_SIZE = 15;
-
-pub const prctl_mm_map = extern struct {
- start_code: u64,
- end_code: u64,
- start_data: u64,
- end_data: u64,
- start_brk: u64,
- brk: u64,
- start_stack: u64,
- arg_start: u64,
- arg_end: u64,
- env_start: u64,
- env_end: u64,
- auxv: *u64,
- auxv_size: u32,
- exe_fd: u32,
-};
-
-pub const PR_SET_PTRACER = @enumToInt(PR.SET_PTRACER);
-pub const PR_SET_PTRACER_ANY = std.math.maxInt(c_ulong);
-
-pub const PR_SET_CHILD_SUBREAPER = @enumToInt(PR.SET_CHILD_SUBREAPER);
-pub const PR_GET_CHILD_SUBREAPER = @enumToInt(PR.GET_CHILD_SUBREAPER);
-
-pub const PR_SET_NO_NEW_PRIVS = @enumToInt(PR.SET_NO_NEW_PRIVS);
-pub const PR_GET_NO_NEW_PRIVS = @enumToInt(PR.GET_NO_NEW_PRIVS);
-
-pub const PR_GET_TID_ADDRESS = @enumToInt(PR.GET_TID_ADDRESS);
-
-pub const PR_SET_THP_DISABLE = @enumToInt(PR.SET_THP_DISABLE);
-pub const PR_GET_THP_DISABLE = @enumToInt(PR.GET_THP_DISABLE);
-
-pub const PR_MPX_ENABLE_MANAGEMENT = @enumToInt(PR.MPX_ENABLE_MANAGEMENT);
-pub const PR_MPX_DISABLE_MANAGEMENT = @enumToInt(PR.MPX_DISABLE_MANAGEMENT);
-
-pub const PR_SET_FP_MODE = @enumToInt(PR.SET_FP_MODE);
-pub const PR_GET_FP_MODE = @enumToInt(PR.GET_FP_MODE);
-pub const PR_FP_MODE_FR = 1 << 0;
-pub const PR_FP_MODE_FRE = 1 << 1;
-
-pub const PR_CAP_AMBIENT = @enumToInt(PR.CAP_AMBIENT);
-pub const PR_CAP_AMBIENT_IS_SET = 1;
-pub const PR_CAP_AMBIENT_RAISE = 2;
-pub const PR_CAP_AMBIENT_LOWER = 3;
-pub const PR_CAP_AMBIENT_CLEAR_ALL = 4;
-
-pub const PR_SVE_SET_VL = @enumToInt(PR.SVE_SET_VL);
-pub const PR_SVE_SET_VL_ONEXEC = 1 << 18;
-pub const PR_SVE_GET_VL = @enumToInt(PR.SVE_GET_VL);
-pub const PR_SVE_VL_LEN_MASK = 0xffff;
-pub const PR_SVE_VL_INHERIT = 1 << 17;
-
-pub const PR_GET_SPECULATION_CTRL = @enumToInt(PR.GET_SPECULATION_CTRL);
-pub const PR_SET_SPECULATION_CTRL = @enumToInt(PR.SET_SPECULATION_CTRL);
-pub const PR_SPEC_STORE_BYPASS = 0;
-pub const PR_SPEC_NOT_AFFECTED = 0;
-pub const PR_SPEC_PRCTL = 1 << 0;
-pub const PR_SPEC_ENABLE = 1 << 1;
-pub const PR_SPEC_DISABLE = 1 << 2;
-pub const PR_SPEC_FORCE_DISABLE = 1 << 3;
diff --git a/lib/std/os/bits/linux/riscv64.zig b/lib/std/os/bits/linux/riscv64.zig
deleted file mode 100644
index 7a0811cc1ab0..000000000000
--- a/lib/std/os/bits/linux/riscv64.zig
+++ /dev/null
@@ -1,423 +0,0 @@
-// riscv64-specific declarations that are intended to be imported into the POSIX namespace.
-const std = @import("../../../std.zig");
-const uid_t = std.os.linux.uid_t;
-const gid_t = std.os.linux.gid_t;
-const pid_t = std.os.linux.pid_t;
-
-pub const SYS = enum(usize) {
- pub const arch_specific_syscall = 244;
-
- io_setup = 0,
- io_destroy = 1,
- io_submit = 2,
- io_cancel = 3,
- io_getevents = 4,
- setxattr = 5,
- lsetxattr = 6,
- fsetxattr = 7,
- getxattr = 8,
- lgetxattr = 9,
- fgetxattr = 10,
- listxattr = 11,
- llistxattr = 12,
- flistxattr = 13,
- removexattr = 14,
- lremovexattr = 15,
- fremovexattr = 16,
- getcwd = 17,
- lookup_dcookie = 18,
- eventfd2 = 19,
- epoll_create1 = 20,
- epoll_ctl = 21,
- epoll_pwait = 22,
- dup = 23,
- dup3 = 24,
- fcntl = 25,
- inotify_init1 = 26,
- inotify_add_watch = 27,
- inotify_rm_watch = 28,
- ioctl = 29,
- ioprio_set = 30,
- ioprio_get = 31,
- flock = 32,
- mknodat = 33,
- mkdirat = 34,
- unlinkat = 35,
- symlinkat = 36,
- linkat = 37,
- umount2 = 39,
- mount = 40,
- pivot_root = 41,
- nfsservctl = 42,
- statfs = 43,
- fstatfs = 44,
- truncate = 45,
- ftruncate = 46,
- fallocate = 47,
- faccessat = 48,
- chdir = 49,
- fchdir = 50,
- chroot = 51,
- fchmod = 52,
- fchmodat = 53,
- fchownat = 54,
- fchown = 55,
- openat = 56,
- close = 57,
- vhangup = 58,
- pipe2 = 59,
- quotactl = 60,
- getdents64 = 61,
- lseek = 62,
- read = 63,
- write = 64,
- readv = 65,
- writev = 66,
- pread64 = 67,
- pwrite64 = 68,
- preadv = 69,
- pwritev = 70,
- sendfile = 71,
- pselect6 = 72,
- ppoll = 73,
- signalfd4 = 74,
- vmsplice = 75,
- splice = 76,
- tee = 77,
- readlinkat = 78,
- fstatat = 79,
- fstat = 80,
- sync = 81,
- fsync = 82,
- fdatasync = 83,
- sync_file_range = 84,
- timerfd_create = 85,
- timerfd_settime = 86,
- timerfd_gettime = 87,
- utimensat = 88,
- acct = 89,
- capget = 90,
- capset = 91,
- personality = 92,
- exit = 93,
- exit_group = 94,
- waitid = 95,
- set_tid_address = 96,
- unshare = 97,
- futex = 98,
- set_robust_list = 99,
- get_robust_list = 100,
- nanosleep = 101,
- getitimer = 102,
- setitimer = 103,
- kexec_load = 104,
- init_module = 105,
- delete_module = 106,
- timer_create = 107,
- timer_gettime = 108,
- timer_getoverrun = 109,
- timer_settime = 110,
- timer_delete = 111,
- clock_settime = 112,
- clock_gettime = 113,
- clock_getres = 114,
- clock_nanosleep = 115,
- syslog = 116,
- ptrace = 117,
- sched_setparam = 118,
- sched_setscheduler = 119,
- sched_getscheduler = 120,
- sched_getparam = 121,
- sched_setaffinity = 122,
- sched_getaffinity = 123,
- sched_yield = 124,
- sched_get_priority_max = 125,
- sched_get_priority_min = 126,
- sched_rr_get_interval = 127,
- restart_syscall = 128,
- kill = 129,
- tkill = 130,
- tgkill = 131,
- sigaltstack = 132,
- rt_sigsuspend = 133,
- rt_sigaction = 134,
- rt_sigprocmask = 135,
- rt_sigpending = 136,
- rt_sigtimedwait = 137,
- rt_sigqueueinfo = 138,
- rt_sigreturn = 139,
- setpriority = 140,
- getpriority = 141,
- reboot = 142,
- setregid = 143,
- setgid = 144,
- setreuid = 145,
- setuid = 146,
- setresuid = 147,
- getresuid = 148,
- setresgid = 149,
- getresgid = 150,
- setfsuid = 151,
- setfsgid = 152,
- times = 153,
- setpgid = 154,
- getpgid = 155,
- getsid = 156,
- setsid = 157,
- getgroups = 158,
- setgroups = 159,
- uname = 160,
- sethostname = 161,
- setdomainname = 162,
- getrlimit = 163,
- setrlimit = 164,
- getrusage = 165,
- umask = 166,
- prctl = 167,
- getcpu = 168,
- gettimeofday = 169,
- settimeofday = 170,
- adjtimex = 171,
- getpid = 172,
- getppid = 173,
- getuid = 174,
- geteuid = 175,
- getgid = 176,
- getegid = 177,
- gettid = 178,
- sysinfo = 179,
- mq_open = 180,
- mq_unlink = 181,
- mq_timedsend = 182,
- mq_timedreceive = 183,
- mq_notify = 184,
- mq_getsetattr = 185,
- msgget = 186,
- msgctl = 187,
- msgrcv = 188,
- msgsnd = 189,
- semget = 190,
- semctl = 191,
- semtimedop = 192,
- semop = 193,
- shmget = 194,
- shmctl = 195,
- shmat = 196,
- shmdt = 197,
- socket = 198,
- socketpair = 199,
- bind = 200,
- listen = 201,
- accept = 202,
- connect = 203,
- getsockname = 204,
- getpeername = 205,
- sendto = 206,
- recvfrom = 207,
- setsockopt = 208,
- getsockopt = 209,
- shutdown = 210,
- sendmsg = 211,
- recvmsg = 212,
- readahead = 213,
- brk = 214,
- munmap = 215,
- mremap = 216,
- add_key = 217,
- request_key = 218,
- keyctl = 219,
- clone = 220,
- execve = 221,
- mmap = 222,
- fadvise64 = 223,
- swapon = 224,
- swapoff = 225,
- mprotect = 226,
- msync = 227,
- mlock = 228,
- munlock = 229,
- mlockall = 230,
- munlockall = 231,
- mincore = 232,
- madvise = 233,
- remap_file_pages = 234,
- mbind = 235,
- get_mempolicy = 236,
- set_mempolicy = 237,
- migrate_pages = 238,
- move_pages = 239,
- rt_tgsigqueueinfo = 240,
- perf_event_open = 241,
- accept4 = 242,
- recvmmsg = 243,
-
- riscv_flush_icache = arch_specific_syscall + 15,
-
- wait4 = 260,
- prlimit64 = 261,
- fanotify_init = 262,
- fanotify_mark = 263,
- name_to_handle_at = 264,
- open_by_handle_at = 265,
- clock_adjtime = 266,
- syncfs = 267,
- setns = 268,
- sendmmsg = 269,
- process_vm_readv = 270,
- process_vm_writev = 271,
- kcmp = 272,
- finit_module = 273,
- sched_setattr = 274,
- sched_getattr = 275,
- renameat2 = 276,
- seccomp = 277,
- getrandom = 278,
- memfd_create = 279,
- bpf = 280,
- execveat = 281,
- userfaultfd = 282,
- membarrier = 283,
- mlock2 = 284,
- copy_file_range = 285,
- preadv2 = 286,
- pwritev2 = 287,
- pkey_mprotect = 288,
- pkey_alloc = 289,
- pkey_free = 290,
- statx = 291,
- io_pgetevents = 292,
- rseq = 293,
- kexec_file_load = 294,
- pidfd_send_signal = 424,
- io_uring_setup = 425,
- io_uring_enter = 426,
- io_uring_register = 427,
- open_tree = 428,
- move_mount = 429,
- fsopen = 430,
- fsconfig = 431,
- fsmount = 432,
- fspick = 433,
- pidfd_open = 434,
- clone3 = 435,
- close_range = 436,
- openat2 = 437,
- pidfd_getfd = 438,
- faccessat2 = 439,
- process_madvise = 440,
- epoll_pwait2 = 441,
-
- _,
-};
-
-pub const O_CREAT = 0o100;
-pub const O_EXCL = 0o200;
-pub const O_NOCTTY = 0o400;
-pub const O_TRUNC = 0o1000;
-pub const O_APPEND = 0o2000;
-pub const O_NONBLOCK = 0o4000;
-pub const O_DSYNC = 0o10000;
-pub const O_SYNC = 0o4010000;
-pub const O_RSYNC = 0o4010000;
-pub const O_DIRECTORY = 0o200000;
-pub const O_NOFOLLOW = 0o400000;
-pub const O_CLOEXEC = 0o2000000;
-
-pub const O_ASYNC = 0o20000;
-pub const O_DIRECT = 0o40000;
-pub const O_LARGEFILE = 0o100000;
-pub const O_NOATIME = 0o1000000;
-pub const O_PATH = 0o10000000;
-pub const O_TMPFILE = 0o20200000;
-pub const O_NDELAY = O_NONBLOCK;
-
-pub const F_DUPFD = 0;
-pub const F_GETFD = 1;
-pub const F_SETFD = 2;
-pub const F_GETFL = 3;
-pub const F_SETFL = 4;
-pub const F_GETLK = 5;
-pub const F_SETLK = 6;
-pub const F_SETLKW = 7;
-pub const F_SETOWN = 8;
-pub const F_GETOWN = 9;
-pub const F_SETSIG = 10;
-pub const F_GETSIG = 11;
-
-pub const F_RDLCK = 0;
-pub const F_WRLCK = 1;
-pub const F_UNLCK = 2;
-
-pub const LOCK_SH = 1;
-pub const LOCK_EX = 2;
-pub const LOCK_UN = 8;
-pub const LOCK_NB = 4;
-
-pub const F_SETOWN_EX = 15;
-pub const F_GETOWN_EX = 16;
-
-pub const F_GETOWNER_UIDS = 17;
-
-pub const blksize_t = i32;
-pub const nlink_t = u32;
-pub const time_t = isize;
-pub const mode_t = u32;
-pub const off_t = isize;
-pub const ino_t = usize;
-pub const dev_t = usize;
-pub const blkcnt_t = isize;
-pub const timespec = extern struct {
- tv_sec: time_t,
- tv_nsec: isize,
-};
-
-pub const timeval = extern struct {
- tv_sec: time_t,
- tv_usec: i64,
-};
-
-pub const Flock = extern struct {
- l_type: i16,
- l_whence: i16,
- l_start: off_t,
- l_len: off_t,
- l_pid: pid_t,
- __unused: [4]u8,
-};
-
-// The `stat` definition used by the Linux kernel.
-pub const kernel_stat = extern struct {
- dev: dev_t,
- ino: ino_t,
- mode: mode_t,
- nlink: nlink_t,
- uid: uid_t,
- gid: gid_t,
- rdev: dev_t,
- __pad: usize,
- size: off_t,
- blksize: blksize_t,
- __pad2: i32,
- blocks: blkcnt_t,
- atim: timespec,
- mtim: timespec,
- ctim: timespec,
- __unused: [2]u32,
-
- pub fn atime(self: @This()) timespec {
- return self.atim;
- }
-
- pub fn mtime(self: @This()) timespec {
- return self.mtim;
- }
-
- pub fn ctime(self: @This()) timespec {
- return self.ctim;
- }
-};
-
-// The `stat64` definition used by the libc.
-pub const libc_stat = kernel_stat;
-
-pub const Elf_Symndx = u32;
diff --git a/lib/std/os/bits/linux/securebits.zig b/lib/std/os/bits/linux/securebits.zig
deleted file mode 100644
index a23ced3cf2ec..000000000000
--- a/lib/std/os/bits/linux/securebits.zig
+++ /dev/null
@@ -1,35 +0,0 @@
-fn issecure_mask(comptime x: comptime_int) comptime_int {
- return 1 << x;
-}
-
-pub const SECUREBITS_DEFAULT = 0x00000000;
-
-pub const SECURE_NOROOT = 0;
-pub const SECURE_NOROOT_LOCKED = 1;
-
-pub const SECBIT_NOROOT = issecure_mask(SECURE_NOROOT);
-pub const SECBIT_NOROOT_LOCKED = issecure_mask(SECURE_NOROOT_LOCKED);
-
-pub const SECURE_NO_SETUID_FIXUP = 2;
-pub const SECURE_NO_SETUID_FIXUP_LOCKED = 3;
-
-pub const SECBIT_NO_SETUID_FIXUP = issecure_mask(SECURE_NO_SETUID_FIXUP);
-pub const SECBIT_NO_SETUID_FIXUP_LOCKED = issecure_mask(SECURE_NO_SETUID_FIXUP_LOCKED);
-
-pub const SECURE_KEEP_CAPS = 4;
-pub const SECURE_KEEP_CAPS_LOCKED = 5;
-
-pub const SECBIT_KEEP_CAPS = issecure_mask(SECURE_KEEP_CAPS);
-pub const SECBIT_KEEP_CAPS_LOCKED = issecure_mask(SECURE_KEEP_CAPS_LOCKED);
-
-pub const SECURE_NO_CAP_AMBIENT_RAISE = 6;
-pub const SECURE_NO_CAP_AMBIENT_RAISE_LOCKED = 7;
-
-pub const SECBIT_NO_CAP_AMBIENT_RAISE = issecure_mask(SECURE_NO_CAP_AMBIENT_RAISE);
-pub const SECBIT_NO_CAP_AMBIENT_RAISE_LOCKED = issecure_mask(SECURE_NO_CAP_AMBIENT_RAISE_LOCKED);
-
-pub const SECURE_ALL_BITS = issecure_mask(SECURE_NOROOT) |
- issecure_mask(SECURE_NO_SETUID_FIXUP) |
- issecure_mask(SECURE_KEEP_CAPS) |
- issecure_mask(SECURE_NO_CAP_AMBIENT_RAISE);
-pub const SECURE_ALL_LOCKS = SECURE_ALL_BITS << 1;
diff --git a/lib/std/os/bits/linux/sparc64.zig b/lib/std/os/bits/linux/sparc64.zig
deleted file mode 100644
index 5c67b745f003..000000000000
--- a/lib/std/os/bits/linux/sparc64.zig
+++ /dev/null
@@ -1,675 +0,0 @@
-// sparc64-specific declarations that are intended to be imported into the POSIX namespace.
-const std = @import("../../../std.zig");
-const pid_t = linux.pid_t;
-const uid_t = linux.uid_t;
-const clock_t = linux.clock_t;
-const stack_t = linux.stack_t;
-const sigset_t = linux.sigset_t;
-
-const linux = std.os.linux;
-const sockaddr = linux.sockaddr;
-const socklen_t = linux.socklen_t;
-const iovec = linux.iovec;
-const iovec_const = linux.iovec_const;
-
-pub const SYS = enum(usize) {
- restart_syscall = 0,
- exit = 1,
- fork = 2,
- read = 3,
- write = 4,
- open = 5,
- close = 6,
- wait4 = 7,
- creat = 8,
- link = 9,
- unlink = 10,
- execv = 11,
- chdir = 12,
- chown = 13,
- mknod = 14,
- chmod = 15,
- lchown = 16,
- brk = 17,
- perfctr = 18,
- lseek = 19,
- getpid = 20,
- capget = 21,
- capset = 22,
- setuid = 23,
- getuid = 24,
- vmsplice = 25,
- ptrace = 26,
- alarm = 27,
- sigaltstack = 28,
- pause = 29,
- utime = 30,
- access = 33,
- nice = 34,
- sync = 36,
- kill = 37,
- stat = 38,
- sendfile = 39,
- lstat = 40,
- dup = 41,
- pipe = 42,
- times = 43,
- umount2 = 45,
- setgid = 46,
- getgid = 47,
- signal = 48,
- geteuid = 49,
- getegid = 50,
- acct = 51,
- memory_ordering = 52,
- ioctl = 54,
- reboot = 55,
- symlink = 57,
- readlink = 58,
- execve = 59,
- umask = 60,
- chroot = 61,
- fstat = 62,
- fstat64 = 63,
- getpagesize = 64,
- msync = 65,
- vfork = 66,
- pread64 = 67,
- pwrite64 = 68,
- mmap = 71,
- munmap = 73,
- mprotect = 74,
- madvise = 75,
- vhangup = 76,
- mincore = 78,
- getgroups = 79,
- setgroups = 80,
- getpgrp = 81,
- setitimer = 83,
- swapon = 85,
- getitimer = 86,
- sethostname = 88,
- dup2 = 90,
- fcntl = 92,
- select = 93,
- fsync = 95,
- setpriority = 96,
- socket = 97,
- connect = 98,
- accept = 99,
- getpriority = 100,
- rt_sigreturn = 101,
- rt_sigaction = 102,
- rt_sigprocmask = 103,
- rt_sigpending = 104,
- rt_sigtimedwait = 105,
- rt_sigqueueinfo = 106,
- rt_sigsuspend = 107,
- setresuid = 108,
- getresuid = 109,
- setresgid = 110,
- getresgid = 111,
- recvmsg = 113,
- sendmsg = 114,
- gettimeofday = 116,
- getrusage = 117,
- getsockopt = 118,
- getcwd = 119,
- readv = 120,
- writev = 121,
- settimeofday = 122,
- fchown = 123,
- fchmod = 124,
- recvfrom = 125,
- setreuid = 126,
- setregid = 127,
- rename = 128,
- truncate = 129,
- ftruncate = 130,
- flock = 131,
- lstat64 = 132,
- sendto = 133,
- shutdown = 134,
- socketpair = 135,
- mkdir = 136,
- rmdir = 137,
- utimes = 138,
- stat64 = 139,
- sendfile64 = 140,
- getpeername = 141,
- futex = 142,
- gettid = 143,
- getrlimit = 144,
- setrlimit = 145,
- pivot_root = 146,
- prctl = 147,
- pciconfig_read = 148,
- pciconfig_write = 149,
- getsockname = 150,
- inotify_init = 151,
- inotify_add_watch = 152,
- poll = 153,
- getdents64 = 154,
- inotify_rm_watch = 156,
- statfs = 157,
- fstatfs = 158,
- umount = 159,
- sched_set_affinity = 160,
- sched_get_affinity = 161,
- getdomainname = 162,
- setdomainname = 163,
- utrap_install = 164,
- quotactl = 165,
- set_tid_address = 166,
- mount = 167,
- ustat = 168,
- setxattr = 169,
- lsetxattr = 170,
- fsetxattr = 171,
- getxattr = 172,
- lgetxattr = 173,
- getdents = 174,
- setsid = 175,
- fchdir = 176,
- fgetxattr = 177,
- listxattr = 178,
- llistxattr = 179,
- flistxattr = 180,
- removexattr = 181,
- lremovexattr = 182,
- sigpending = 183,
- query_module = 184,
- setpgid = 185,
- fremovexattr = 186,
- tkill = 187,
- exit_group = 188,
- uname = 189,
- init_module = 190,
- personality = 191,
- remap_file_pages = 192,
- epoll_create = 193,
- epoll_ctl = 194,
- epoll_wait = 195,
- ioprio_set = 196,
- getppid = 197,
- sigaction = 198,
- sgetmask = 199,
- ssetmask = 200,
- sigsuspend = 201,
- oldlstat = 202,
- uselib = 203,
- readdir = 204,
- readahead = 205,
- socketcall = 206,
- syslog = 207,
- lookup_dcookie = 208,
- fadvise64 = 209,
- fadvise64_64 = 210,
- tgkill = 211,
- waitpid = 212,
- swapoff = 213,
- sysinfo = 214,
- ipc = 215,
- sigreturn = 216,
- clone = 217,
- ioprio_get = 218,
- adjtimex = 219,
- sigprocmask = 220,
- create_module = 221,
- delete_module = 222,
- get_kernel_syms = 223,
- getpgid = 224,
- bdflush = 225,
- sysfs = 226,
- afs_syscall = 227,
- setfsuid = 228,
- setfsgid = 229,
- _newselect = 230,
- splice = 232,
- stime = 233,
- statfs64 = 234,
- fstatfs64 = 235,
- _llseek = 236,
- mlock = 237,
- munlock = 238,
- mlockall = 239,
- munlockall = 240,
- sched_setparam = 241,
- sched_getparam = 242,
- sched_setscheduler = 243,
- sched_getscheduler = 244,
- sched_yield = 245,
- sched_get_priority_max = 246,
- sched_get_priority_min = 247,
- sched_rr_get_interval = 248,
- nanosleep = 249,
- mremap = 250,
- _sysctl = 251,
- getsid = 252,
- fdatasync = 253,
- nfsservctl = 254,
- sync_file_range = 255,
- clock_settime = 256,
- clock_gettime = 257,
- clock_getres = 258,
- clock_nanosleep = 259,
- sched_getaffinity = 260,
- sched_setaffinity = 261,
- timer_settime = 262,
- timer_gettime = 263,
- timer_getoverrun = 264,
- timer_delete = 265,
- timer_create = 266,
- vserver = 267,
- io_setup = 268,
- io_destroy = 269,
- io_submit = 270,
- io_cancel = 271,
- io_getevents = 272,
- mq_open = 273,
- mq_unlink = 274,
- mq_timedsend = 275,
- mq_timedreceive = 276,
- mq_notify = 277,
- mq_getsetattr = 278,
- waitid = 279,
- tee = 280,
- add_key = 281,
- request_key = 282,
- keyctl = 283,
- openat = 284,
- mkdirat = 285,
- mknodat = 286,
- fchownat = 287,
- futimesat = 288,
- fstatat64 = 289,
- unlinkat = 290,
- renameat = 291,
- linkat = 292,
- symlinkat = 293,
- readlinkat = 294,
- fchmodat = 295,
- faccessat = 296,
- pselect6 = 297,
- ppoll = 298,
- unshare = 299,
- set_robust_list = 300,
- get_robust_list = 301,
- migrate_pages = 302,
- mbind = 303,
- get_mempolicy = 304,
- set_mempolicy = 305,
- kexec_load = 306,
- move_pages = 307,
- getcpu = 308,
- epoll_pwait = 309,
- utimensat = 310,
- signalfd = 311,
- timerfd_create = 312,
- eventfd = 313,
- fallocate = 314,
- timerfd_settime = 315,
- timerfd_gettime = 316,
- signalfd4 = 317,
- eventfd2 = 318,
- epoll_create1 = 319,
- dup3 = 320,
- pipe2 = 321,
- inotify_init1 = 322,
- accept4 = 323,
- preadv = 324,
- pwritev = 325,
- rt_tgsigqueueinfo = 326,
- perf_event_open = 327,
- recvmmsg = 328,
- fanotify_init = 329,
- fanotify_mark = 330,
- prlimit64 = 331,
- name_to_handle_at = 332,
- open_by_handle_at = 333,
- clock_adjtime = 334,
- syncfs = 335,
- sendmmsg = 336,
- setns = 337,
- process_vm_readv = 338,
- process_vm_writev = 339,
- kern_features = 340,
- kcmp = 341,
- finit_module = 342,
- sched_setattr = 343,
- sched_getattr = 344,
- renameat2 = 345,
- seccomp = 346,
- getrandom = 347,
- memfd_create = 348,
- bpf = 349,
- execveat = 350,
- membarrier = 351,
- userfaultfd = 352,
- bind = 353,
- listen = 354,
- setsockopt = 355,
- mlock2 = 356,
- copy_file_range = 357,
- preadv2 = 358,
- pwritev2 = 359,
- statx = 360,
- io_pgetevents = 361,
- pkey_mprotect = 362,
- pkey_alloc = 363,
- pkey_free = 364,
- rseq = 365,
- semtimedop = 392,
- semget = 393,
- semctl = 394,
- shmget = 395,
- shmctl = 396,
- shmat = 397,
- shmdt = 398,
- msgget = 399,
- msgsnd = 400,
- msgrcv = 401,
- msgctl = 402,
- pidfd_send_signal = 424,
- io_uring_setup = 425,
- io_uring_enter = 426,
- io_uring_register = 427,
- open_tree = 428,
- move_mount = 429,
- fsopen = 430,
- fsconfig = 431,
- fsmount = 432,
- fspick = 433,
- pidfd_open = 434,
- clone3 = 435,
- close_range = 436,
- openat2 = 437,
- pidfd_getfd = 438,
- faccessat2 = 439,
- process_madvise = 440,
- epoll_pwait2 = 441,
-
- _,
-};
-
-pub const O_CREAT = 0x200;
-pub const O_EXCL = 0x800;
-pub const O_NOCTTY = 0x8000;
-pub const O_TRUNC = 0x400;
-pub const O_APPEND = 0x8;
-pub const O_NONBLOCK = 0x4000;
-pub const O_SYNC = 0x802000;
-pub const O_DSYNC = 0x2000;
-pub const O_RSYNC = O_SYNC;
-pub const O_DIRECTORY = 0x10000;
-pub const O_NOFOLLOW = 0x20000;
-pub const O_CLOEXEC = 0x400000;
-
-pub const O_ASYNC = 0x40;
-pub const O_DIRECT = 0x100000;
-pub const O_LARGEFILE = 0;
-pub const O_NOATIME = 0x200000;
-pub const O_PATH = 0x1000000;
-pub const O_TMPFILE = 0x2010000;
-pub const O_NDELAY = O_NONBLOCK | 0x4;
-
-pub const F_DUPFD = 0;
-pub const F_GETFD = 1;
-pub const F_SETFD = 2;
-pub const F_GETFL = 3;
-pub const F_SETFL = 4;
-
-pub const F_SETOWN = 5;
-pub const F_GETOWN = 6;
-pub const F_GETLK = 7;
-pub const F_SETLK = 8;
-pub const F_SETLKW = 9;
-
-pub const F_RDLCK = 1;
-pub const F_WRLCK = 2;
-pub const F_UNLCK = 3;
-
-pub const F_SETOWN_EX = 15;
-pub const F_GETOWN_EX = 16;
-
-pub const F_GETOWNER_UIDS = 17;
-
-pub const LOCK_SH = 1;
-pub const LOCK_EX = 2;
-pub const LOCK_NB = 4;
-pub const LOCK_UN = 8;
-
-/// stack-like segment
-pub const MAP_GROWSDOWN = 0x0200;
-
-/// ETXTBSY
-pub const MAP_DENYWRITE = 0x0800;
-
-/// mark it as an executable
-pub const MAP_EXECUTABLE = 0x1000;
-
-/// pages are locked
-pub const MAP_LOCKED = 0x0100;
-
-/// don't check for reservations
-pub const MAP_NORESERVE = 0x0040;
-
-pub const VDSO_CGT_SYM = "__vdso_clock_gettime";
-pub const VDSO_CGT_VER = "LINUX_2.6";
-
-pub const Flock = extern struct {
- l_type: i16,
- l_whence: i16,
- l_start: off_t,
- l_len: off_t,
- l_pid: pid_t,
-};
-
-pub const msghdr = extern struct {
- msg_name: ?*sockaddr,
- msg_namelen: socklen_t,
- msg_iov: [*]iovec,
- msg_iovlen: u64,
- msg_control: ?*c_void,
- msg_controllen: u64,
- msg_flags: i32,
-};
-
-pub const msghdr_const = extern struct {
- msg_name: ?*const sockaddr,
- msg_namelen: socklen_t,
- msg_iov: [*]iovec_const,
- msg_iovlen: u64,
- msg_control: ?*c_void,
- msg_controllen: u64,
- msg_flags: i32,
-};
-
-pub const off_t = i64;
-pub const ino_t = u64;
-pub const mode_t = u32;
-
-// The `stat64` definition used by the libc.
-pub const libc_stat = extern struct {
- dev: u64,
- ino: ino_t,
- mode: u32,
- nlink: usize,
-
- uid: u32,
- gid: u32,
- rdev: u64,
- __pad0: u32,
-
- size: off_t,
- blksize: isize,
- blocks: i64,
-
- atim: timespec,
- mtim: timespec,
- ctim: timespec,
- __unused: [2]isize,
-
- pub fn atime(self: libc_stat) timespec {
- return self.atim;
- }
-
- pub fn mtime(self: libc_stat) timespec {
- return self.mtim;
- }
-
- pub fn ctime(self: libc_stat) timespec {
- return self.ctim;
- }
-};
-
-// The `stat64` definition used by the kernel.
-pub const kernel_stat = extern struct {
- dev: u64,
- ino: u64,
- nlink: u64,
-
- mode: u32,
- uid: u32,
- gid: u32,
- __pad0: u32,
-
- rdev: u64,
- size: i64,
- blksize: i64,
- blocks: i64,
-
- atim: timespec,
- mtim: timespec,
- ctim: timespec,
- __unused: [3]u64,
-
- pub fn atime(self: @This()) timespec {
- return self.atim;
- }
-
- pub fn mtime(self: @This()) timespec {
- return self.mtim;
- }
-
- pub fn ctime(self: @This()) timespec {
- return self.ctim;
- }
-};
-
-pub const timespec = extern struct {
- tv_sec: isize,
- tv_nsec: isize,
-};
-
-pub const timeval = extern struct {
- tv_sec: isize,
- tv_usec: isize,
-};
-
-pub const timezone = extern struct {
- tz_minuteswest: i32,
- tz_dsttime: i32,
-};
-
-// TODO I'm not sure if the code below is correct, need someone with more
-// knowledge about sparc64 linux internals to look into.
-
-pub const Elf_Symndx = u32;
-
-pub const fpstate = extern struct {
- regs: [32]u64,
- fsr: u64,
- gsr: u64,
- fprs: u64,
-};
-
-pub const __fpq = extern struct {
- fpq_addr: *u32,
- fpq_instr: u32,
-};
-
-pub const __fq = extern struct {
- FQu: extern union {
- whole: f64,
- fpq: __fpq,
- },
-};
-
-pub const fpregset_t = extern struct {
- fpu_fr: extern union {
- fpu_regs: [32]u32,
- fpu_dregs: [32]f64,
- fpu_qregs: [16]c_longdouble,
- },
- fpu_q: *__fq,
- fpu_fsr: u64,
- fpu_qcnt: u8,
- fpu_q_entrysize: u8,
- fpu_en: u8,
-};
-
-pub const siginfo_fpu_t = extern struct {
- float_regs: [64]u32,
- fsr: u64,
- gsr: u64,
- fprs: u64,
-};
-
-pub const sigcontext = extern struct {
- info: [128]i8,
- regs: extern struct {
- u_regs: [16]u64,
- tstate: u64,
- tpc: u64,
- tnpc: u64,
- y: u64,
- fprs: u64,
- },
- fpu_save: *siginfo_fpu_t,
- stack: extern struct {
- sp: usize,
- flags: i32,
- size: u64,
- },
- mask: u64,
-};
-
-pub const greg_t = u64;
-pub const gregset_t = [19]greg_t;
-
-pub const fq = extern struct {
- addr: *u64,
- insn: u32,
-};
-
-pub const fpu_t = extern struct {
- fregs: extern union {
- sregs: [32]u32,
- dregs: [32]u64,
- qregs: [16]c_longdouble,
- },
- fsr: u64,
- fprs: u64,
- gsr: u64,
- fq: *fq,
- qcnt: u8,
- qentsz: u8,
- enab: u8,
-};
-
-pub const mcontext_t = extern struct {
- gregs: gregset_t,
- fp: greg_t,
- @"i7": greg_t,
- fpregs: fpu_t,
-};
-
-pub const ucontext_t = extern struct {
- link: *ucontext_t,
- flags: u64,
- sigmask: u64,
- mcontext: mcontext_t,
- stack: stack_t,
- sigmask: sigset_t,
-};
diff --git a/lib/std/os/bits/linux/x86_64.zig b/lib/std/os/bits/linux/x86_64.zig
deleted file mode 100644
index 69beac9d878f..000000000000
--- a/lib/std/os/bits/linux/x86_64.zig
+++ /dev/null
@@ -1,638 +0,0 @@
-// x86-64-specific declarations that are intended to be imported into the POSIX namespace.
-const std = @import("../../../std.zig");
-const pid_t = linux.pid_t;
-const uid_t = linux.uid_t;
-const gid_t = linux.gid_t;
-const clock_t = linux.clock_t;
-const stack_t = linux.stack_t;
-const sigset_t = linux.sigset_t;
-
-const linux = std.os.linux;
-const sockaddr = linux.sockaddr;
-const socklen_t = linux.socklen_t;
-const iovec = linux.iovec;
-const iovec_const = linux.iovec_const;
-
-pub const mode_t = usize;
-pub const time_t = isize;
-
-pub const SYS = enum(usize) {
- read = 0,
- write = 1,
- open = 2,
- close = 3,
- stat = 4,
- fstat = 5,
- lstat = 6,
- poll = 7,
- lseek = 8,
- mmap = 9,
- mprotect = 10,
- munmap = 11,
- brk = 12,
- rt_sigaction = 13,
- rt_sigprocmask = 14,
- rt_sigreturn = 15,
- ioctl = 16,
- pread = 17,
- pwrite = 18,
- readv = 19,
- writev = 20,
- access = 21,
- pipe = 22,
- select = 23,
- sched_yield = 24,
- mremap = 25,
- msync = 26,
- mincore = 27,
- madvise = 28,
- shmget = 29,
- shmat = 30,
- shmctl = 31,
- dup = 32,
- dup2 = 33,
- pause = 34,
- nanosleep = 35,
- getitimer = 36,
- alarm = 37,
- setitimer = 38,
- getpid = 39,
- sendfile = 40,
- socket = 41,
- connect = 42,
- accept = 43,
- sendto = 44,
- recvfrom = 45,
- sendmsg = 46,
- recvmsg = 47,
- shutdown = 48,
- bind = 49,
- listen = 50,
- getsockname = 51,
- getpeername = 52,
- socketpair = 53,
- setsockopt = 54,
- getsockopt = 55,
- clone = 56,
- fork = 57,
- vfork = 58,
- execve = 59,
- exit = 60,
- wait4 = 61,
- kill = 62,
- uname = 63,
- semget = 64,
- semop = 65,
- semctl = 66,
- shmdt = 67,
- msgget = 68,
- msgsnd = 69,
- msgrcv = 70,
- msgctl = 71,
- fcntl = 72,
- flock = 73,
- fsync = 74,
- fdatasync = 75,
- truncate = 76,
- ftruncate = 77,
- getdents = 78,
- getcwd = 79,
- chdir = 80,
- fchdir = 81,
- rename = 82,
- mkdir = 83,
- rmdir = 84,
- creat = 85,
- link = 86,
- unlink = 87,
- symlink = 88,
- readlink = 89,
- chmod = 90,
- fchmod = 91,
- chown = 92,
- fchown = 93,
- lchown = 94,
- umask = 95,
- gettimeofday = 96,
- getrlimit = 97,
- getrusage = 98,
- sysinfo = 99,
- times = 100,
- ptrace = 101,
- getuid = 102,
- syslog = 103,
- getgid = 104,
- setuid = 105,
- setgid = 106,
- geteuid = 107,
- getegid = 108,
- setpgid = 109,
- getppid = 110,
- getpgrp = 111,
- setsid = 112,
- setreuid = 113,
- setregid = 114,
- getgroups = 115,
- setgroups = 116,
- setresuid = 117,
- getresuid = 118,
- setresgid = 119,
- getresgid = 120,
- getpgid = 121,
- setfsuid = 122,
- setfsgid = 123,
- getsid = 124,
- capget = 125,
- capset = 126,
- rt_sigpending = 127,
- rt_sigtimedwait = 128,
- rt_sigqueueinfo = 129,
- rt_sigsuspend = 130,
- sigaltstack = 131,
- utime = 132,
- mknod = 133,
- uselib = 134,
- personality = 135,
- ustat = 136,
- statfs = 137,
- fstatfs = 138,
- sysfs = 139,
- getpriority = 140,
- setpriority = 141,
- sched_setparam = 142,
- sched_getparam = 143,
- sched_setscheduler = 144,
- sched_getscheduler = 145,
- sched_get_priority_max = 146,
- sched_get_priority_min = 147,
- sched_rr_get_interval = 148,
- mlock = 149,
- munlock = 150,
- mlockall = 151,
- munlockall = 152,
- vhangup = 153,
- modify_ldt = 154,
- pivot_root = 155,
- _sysctl = 156,
- prctl = 157,
- arch_prctl = 158,
- adjtimex = 159,
- setrlimit = 160,
- chroot = 161,
- sync = 162,
- acct = 163,
- settimeofday = 164,
- mount = 165,
- umount2 = 166,
- swapon = 167,
- swapoff = 168,
- reboot = 169,
- sethostname = 170,
- setdomainname = 171,
- iopl = 172,
- ioperm = 173,
- create_module = 174,
- init_module = 175,
- delete_module = 176,
- get_kernel_syms = 177,
- query_module = 178,
- quotactl = 179,
- nfsservctl = 180,
- getpmsg = 181,
- putpmsg = 182,
- afs_syscall = 183,
- tuxcall = 184,
- security = 185,
- gettid = 186,
- readahead = 187,
- setxattr = 188,
- lsetxattr = 189,
- fsetxattr = 190,
- getxattr = 191,
- lgetxattr = 192,
- fgetxattr = 193,
- listxattr = 194,
- llistxattr = 195,
- flistxattr = 196,
- removexattr = 197,
- lremovexattr = 198,
- fremovexattr = 199,
- tkill = 200,
- time = 201,
- futex = 202,
- sched_setaffinity = 203,
- sched_getaffinity = 204,
- set_thread_area = 205,
- io_setup = 206,
- io_destroy = 207,
- io_getevents = 208,
- io_submit = 209,
- io_cancel = 210,
- get_thread_area = 211,
- lookup_dcookie = 212,
- epoll_create = 213,
- epoll_ctl_old = 214,
- epoll_wait_old = 215,
- remap_file_pages = 216,
- getdents64 = 217,
- set_tid_address = 218,
- restart_syscall = 219,
- semtimedop = 220,
- fadvise64 = 221,
- timer_create = 222,
- timer_settime = 223,
- timer_gettime = 224,
- timer_getoverrun = 225,
- timer_delete = 226,
- clock_settime = 227,
- clock_gettime = 228,
- clock_getres = 229,
- clock_nanosleep = 230,
- exit_group = 231,
- epoll_wait = 232,
- epoll_ctl = 233,
- tgkill = 234,
- utimes = 235,
- vserver = 236,
- mbind = 237,
- set_mempolicy = 238,
- get_mempolicy = 239,
- mq_open = 240,
- mq_unlink = 241,
- mq_timedsend = 242,
- mq_timedreceive = 243,
- mq_notify = 244,
- mq_getsetattr = 245,
- kexec_load = 246,
- waitid = 247,
- add_key = 248,
- request_key = 249,
- keyctl = 250,
- ioprio_set = 251,
- ioprio_get = 252,
- inotify_init = 253,
- inotify_add_watch = 254,
- inotify_rm_watch = 255,
- migrate_pages = 256,
- openat = 257,
- mkdirat = 258,
- mknodat = 259,
- fchownat = 260,
- futimesat = 261,
- fstatat = 262,
- unlinkat = 263,
- renameat = 264,
- linkat = 265,
- symlinkat = 266,
- readlinkat = 267,
- fchmodat = 268,
- faccessat = 269,
- pselect6 = 270,
- ppoll = 271,
- unshare = 272,
- set_robust_list = 273,
- get_robust_list = 274,
- splice = 275,
- tee = 276,
- sync_file_range = 277,
- vmsplice = 278,
- move_pages = 279,
- utimensat = 280,
- epoll_pwait = 281,
- signalfd = 282,
- timerfd_create = 283,
- eventfd = 284,
- fallocate = 285,
- timerfd_settime = 286,
- timerfd_gettime = 287,
- accept4 = 288,
- signalfd4 = 289,
- eventfd2 = 290,
- epoll_create1 = 291,
- dup3 = 292,
- pipe2 = 293,
- inotify_init1 = 294,
- preadv = 295,
- pwritev = 296,
- rt_tgsigqueueinfo = 297,
- perf_event_open = 298,
- recvmmsg = 299,
- fanotify_init = 300,
- fanotify_mark = 301,
- prlimit64 = 302,
- name_to_handle_at = 303,
- open_by_handle_at = 304,
- clock_adjtime = 305,
- syncfs = 306,
- sendmmsg = 307,
- setns = 308,
- getcpu = 309,
- process_vm_readv = 310,
- process_vm_writev = 311,
- kcmp = 312,
- finit_module = 313,
- sched_setattr = 314,
- sched_getattr = 315,
- renameat2 = 316,
- seccomp = 317,
- getrandom = 318,
- memfd_create = 319,
- kexec_file_load = 320,
- bpf = 321,
- execveat = 322,
- userfaultfd = 323,
- membarrier = 324,
- mlock2 = 325,
- copy_file_range = 326,
- preadv2 = 327,
- pwritev2 = 328,
- pkey_mprotect = 329,
- pkey_alloc = 330,
- pkey_free = 331,
- statx = 332,
- io_pgetevents = 333,
- rseq = 334,
- pidfd_send_signal = 424,
- io_uring_setup = 425,
- io_uring_enter = 426,
- io_uring_register = 427,
- open_tree = 428,
- move_mount = 429,
- fsopen = 430,
- fsconfig = 431,
- fsmount = 432,
- fspick = 433,
- pidfd_open = 434,
- clone3 = 435,
- close_range = 436,
- openat2 = 437,
- pidfd_getfd = 438,
- faccessat2 = 439,
- process_madvise = 440,
- epoll_pwait2 = 441,
-
- _,
-};
-
-pub const O_CREAT = 0o100;
-pub const O_EXCL = 0o200;
-pub const O_NOCTTY = 0o400;
-pub const O_TRUNC = 0o1000;
-pub const O_APPEND = 0o2000;
-pub const O_NONBLOCK = 0o4000;
-pub const O_DSYNC = 0o10000;
-pub const O_SYNC = 0o4010000;
-pub const O_RSYNC = 0o4010000;
-pub const O_DIRECTORY = 0o200000;
-pub const O_NOFOLLOW = 0o400000;
-pub const O_CLOEXEC = 0o2000000;
-
-pub const O_ASYNC = 0o20000;
-pub const O_DIRECT = 0o40000;
-pub const O_LARGEFILE = 0;
-pub const O_NOATIME = 0o1000000;
-pub const O_PATH = 0o10000000;
-pub const O_TMPFILE = 0o20200000;
-pub const O_NDELAY = O_NONBLOCK;
-
-pub const F_DUPFD = 0;
-pub const F_GETFD = 1;
-pub const F_SETFD = 2;
-pub const F_GETFL = 3;
-pub const F_SETFL = 4;
-
-pub const F_SETOWN = 8;
-pub const F_GETOWN = 9;
-pub const F_SETSIG = 10;
-pub const F_GETSIG = 11;
-
-pub const F_GETLK = 5;
-pub const F_SETLK = 6;
-pub const F_SETLKW = 7;
-
-pub const F_SETOWN_EX = 15;
-pub const F_GETOWN_EX = 16;
-
-pub const F_GETOWNER_UIDS = 17;
-
-/// only give out 32bit addresses
-pub const MAP_32BIT = 0x40;
-
-/// stack-like segment
-pub const MAP_GROWSDOWN = 0x0100;
-
-/// ETXTBSY
-pub const MAP_DENYWRITE = 0x0800;
-
-/// mark it as an executable
-pub const MAP_EXECUTABLE = 0x1000;
-
-/// pages are locked
-pub const MAP_LOCKED = 0x2000;
-
-/// don't check for reservations
-pub const MAP_NORESERVE = 0x4000;
-
-pub const VDSO_CGT_SYM = "__vdso_clock_gettime";
-pub const VDSO_CGT_VER = "LINUX_2.6";
-pub const VDSO_GETCPU_SYM = "__vdso_getcpu";
-pub const VDSO_GETCPU_VER = "LINUX_2.6";
-
-pub const ARCH_SET_GS = 0x1001;
-pub const ARCH_SET_FS = 0x1002;
-pub const ARCH_GET_FS = 0x1003;
-pub const ARCH_GET_GS = 0x1004;
-
-pub const REG_R8 = 0;
-pub const REG_R9 = 1;
-pub const REG_R10 = 2;
-pub const REG_R11 = 3;
-pub const REG_R12 = 4;
-pub const REG_R13 = 5;
-pub const REG_R14 = 6;
-pub const REG_R15 = 7;
-pub const REG_RDI = 8;
-pub const REG_RSI = 9;
-pub const REG_RBP = 10;
-pub const REG_RBX = 11;
-pub const REG_RDX = 12;
-pub const REG_RAX = 13;
-pub const REG_RCX = 14;
-pub const REG_RSP = 15;
-pub const REG_RIP = 16;
-pub const REG_EFL = 17;
-pub const REG_CSGSFS = 18;
-pub const REG_ERR = 19;
-pub const REG_TRAPNO = 20;
-pub const REG_OLDMASK = 21;
-pub const REG_CR2 = 22;
-
-pub const LOCK_SH = 1;
-pub const LOCK_EX = 2;
-pub const LOCK_UN = 8;
-pub const LOCK_NB = 4;
-
-pub const F_RDLCK = 0;
-pub const F_WRLCK = 1;
-pub const F_UNLCK = 2;
-
-pub const Flock = extern struct {
- l_type: i16,
- l_whence: i16,
- l_start: off_t,
- l_len: off_t,
- l_pid: pid_t,
-};
-
-pub const msghdr = extern struct {
- msg_name: ?*sockaddr,
- msg_namelen: socklen_t,
- msg_iov: [*]iovec,
- msg_iovlen: i32,
- __pad1: i32 = 0,
- msg_control: ?*c_void,
- msg_controllen: socklen_t,
- __pad2: socklen_t = 0,
- msg_flags: i32,
-};
-
-pub const msghdr_const = extern struct {
- msg_name: ?*const sockaddr,
- msg_namelen: socklen_t,
- msg_iov: [*]iovec_const,
- msg_iovlen: i32,
- __pad1: i32 = 0,
- msg_control: ?*c_void,
- msg_controllen: socklen_t,
- __pad2: socklen_t = 0,
- msg_flags: i32,
-};
-
-pub const off_t = i64;
-pub const ino_t = u64;
-pub const dev_t = u64;
-
-// The `stat` definition used by the Linux kernel.
-pub const kernel_stat = extern struct {
- dev: dev_t,
- ino: ino_t,
- nlink: usize,
-
- mode: u32,
- uid: uid_t,
- gid: gid_t,
- __pad0: u32,
- rdev: dev_t,
- size: off_t,
- blksize: isize,
- blocks: i64,
-
- atim: timespec,
- mtim: timespec,
- ctim: timespec,
- __unused: [3]isize,
-
- pub fn atime(self: @This()) timespec {
- return self.atim;
- }
-
- pub fn mtime(self: @This()) timespec {
- return self.mtim;
- }
-
- pub fn ctime(self: @This()) timespec {
- return self.ctim;
- }
-};
-
-// The `stat64` definition used by the libc.
-pub const libc_stat = kernel_stat;
-
-pub const timespec = extern struct {
- tv_sec: isize,
- tv_nsec: isize,
-};
-
-pub const timeval = extern struct {
- tv_sec: isize,
- tv_usec: isize,
-};
-
-pub const timezone = extern struct {
- tz_minuteswest: i32,
- tz_dsttime: i32,
-};
-
-pub const Elf_Symndx = u32;
-
-pub const greg_t = usize;
-pub const gregset_t = [23]greg_t;
-pub const fpstate = extern struct {
- cwd: u16,
- swd: u16,
- ftw: u16,
- fop: u16,
- rip: usize,
- rdp: usize,
- mxcsr: u32,
- mxcr_mask: u32,
- st: [8]extern struct {
- significand: [4]u16,
- exponent: u16,
- padding: [3]u16 = undefined,
- },
- xmm: [16]extern struct {
- element: [4]u32,
- },
- padding: [24]u32 = undefined,
-};
-pub const fpregset_t = *fpstate;
-pub const sigcontext = extern struct {
- r8: usize,
- r9: usize,
- r10: usize,
- r11: usize,
- r12: usize,
- r13: usize,
- r14: usize,
- r15: usize,
-
- rdi: usize,
- rsi: usize,
- rbp: usize,
- rbx: usize,
- rdx: usize,
- rax: usize,
- rcx: usize,
- rsp: usize,
- rip: usize,
- eflags: usize,
-
- cs: u16,
- gs: u16,
- fs: u16,
- pad0: u16 = undefined,
-
- err: usize,
- trapno: usize,
- oldmask: usize,
- cr2: usize,
-
- fpstate: *fpstate,
- reserved1: [8]usize = undefined,
-};
-
-pub const mcontext_t = extern struct {
- gregs: gregset_t,
- fpregs: fpregset_t,
- reserved1: [8]usize = undefined,
-};
-
-pub const ucontext_t = extern struct {
- flags: usize,
- link: *ucontext_t,
- stack: stack_t,
- mcontext: mcontext_t,
- sigmask: sigset_t,
- fpregs_mem: [64]usize,
-};
diff --git a/lib/std/os/bits/linux/xdp.zig b/lib/std/os/bits/linux/xdp.zig
deleted file mode 100644
index 88fa9918a356..000000000000
--- a/lib/std/os/bits/linux/xdp.zig
+++ /dev/null
@@ -1,77 +0,0 @@
-usingnamespace @import("../linux.zig");
-
-pub const XDP_SHARED_UMEM = (1 << 0);
-pub const XDP_COPY = (1 << 1);
-pub const XDP_ZEROCOPY = (1 << 2);
-
-pub const XDP_UMEM_UNALIGNED_CHUNK_FLAG = (1 << 0);
-
-pub const sockaddr_xdp = extern struct {
- family: u16 = AF_XDP,
- flags: u16,
- ifindex: u32,
- queue_id: u32,
- shared_umem_fd: u32,
-};
-
-pub const XDP_USE_NEED_WAKEUP = (1 << 3);
-
-pub const xdp_ring_offset = extern struct {
- producer: u64,
- consumer: u64,
- desc: u64,
- flags: u64,
-};
-
-pub const xdp_mmap_offsets = extern struct {
- rx: xdp_ring_offset,
- tx: xdp_ring_offset,
- fr: xdp_ring_offset,
- cr: xdp_ring_offset,
-};
-
-pub const XDP_MMAP_OFFSETS = 1;
-pub const XDP_RX_RING = 2;
-pub const XDP_TX_RING = 3;
-pub const XDP_UMEM_REG = 4;
-pub const XDP_UMEM_FILL_RING = 5;
-pub const XDP_UMEM_COMPLETION_RING = 6;
-pub const XDP_STATISTICS = 7;
-pub const XDP_OPTIONS = 8;
-
-pub const xdp_umem_reg = extern struct {
- addr: u64,
- len: u64,
- chunk_size: u32,
- headroom: u32,
- flags: u32,
-};
-
-pub const xdp_statistics = extern struct {
- rx_dropped: u64,
- rx_invalid_descs: u64,
- tx_invalid_descs: u64,
- rx_ring_full: u64,
- rx_fill_ring_empty_descs: u64,
- tx_ring_empty_descs: u64,
-};
-
-pub const xdp_options = extern struct {
- flags: u32,
-};
-
-pub const XDP_OPTIONS_ZEROCOPY = (1 << 0);
-
-pub const XDP_PGOFF_RX_RING = 0;
-pub const XDP_PGOFF_TX_RING = 0x80000000;
-pub const XDP_UMEM_PGOFF_FILL_RING = 0x100000000;
-pub const XDP_UMEM_PGOFF_COMPLETION_RING = 0x180000000;
-
-pub const XSK_UNALIGNED_BUF_OFFSET_SHIFT = 48;
-pub const XSK_UNALIGNED_BUF_ADDR_MASK = (1 << XSK_UNALIGNED_BUF_OFFSET_SHIFT) - 1;
-
-pub const xdp_desc = extern struct {
- addr: u64,
- len: u32,
- options: u32,
-};
diff --git a/lib/std/os/bits/netbsd.zig b/lib/std/os/bits/netbsd.zig
deleted file mode 100644
index be35889042c4..000000000000
--- a/lib/std/os/bits/netbsd.zig
+++ /dev/null
@@ -1,1328 +0,0 @@
-const std = @import("../../std.zig");
-const builtin = std.builtin;
-const maxInt = std.math.maxInt;
-
-pub usingnamespace @import("posix.zig");
-
-pub const blkcnt_t = i64;
-pub const blksize_t = i32;
-pub const clock_t = u32;
-pub const dev_t = u64;
-pub const fd_t = i32;
-pub const gid_t = u32;
-pub const ino_t = u64;
-pub const mode_t = u32;
-pub const nlink_t = u32;
-pub const off_t = i64;
-pub const pid_t = i32;
-pub const socklen_t = u32;
-pub const time_t = i64;
-pub const uid_t = u32;
-pub const lwpid_t = i32;
-pub const suseconds_t = c_int;
-
-/// Renamed from `kevent` to `Kevent` to avoid conflict with function name.
-pub const Kevent = extern struct {
- ident: usize,
- filter: i32,
- flags: u32,
- fflags: u32,
- data: i64,
- udata: usize,
-};
-
-pub const RTLD_LAZY = 1;
-pub const RTLD_NOW = 2;
-pub const RTLD_GLOBAL = 0x100;
-pub const RTLD_LOCAL = 0x200;
-pub const RTLD_NODELETE = 0x01000;
-pub const RTLD_NOLOAD = 0x02000;
-
-pub const RTLD_NEXT = @intToPtr(*c_void, @bitCast(usize, @as(isize, -1)));
-pub const RTLD_DEFAULT = @intToPtr(*c_void, @bitCast(usize, @as(isize, -2)));
-pub const RTLD_SELF = @intToPtr(*c_void, @bitCast(usize, @as(isize, -3)));
-
-pub const dl_phdr_info = extern struct {
- dlpi_addr: usize,
- dlpi_name: ?[*:0]const u8,
- dlpi_phdr: [*]std.elf.Phdr,
- dlpi_phnum: u16,
-};
-
-pub const Flock = extern struct {
- l_start: off_t,
- l_len: off_t,
- l_pid: pid_t,
- l_type: i16,
- l_whence: i16,
-};
-
-pub const addrinfo = extern struct {
- flags: i32,
- family: i32,
- socktype: i32,
- protocol: i32,
- addrlen: socklen_t,
- canonname: ?[*:0]u8,
- addr: ?*sockaddr,
- next: ?*addrinfo,
-};
-
-pub const EAI = enum(c_int) {
- /// address family for hostname not supported
- ADDRFAMILY = 1,
-
- /// name could not be resolved at this time
- AGAIN = 2,
-
- /// flags parameter had an invalid value
- BADFLAGS = 3,
-
- /// non-recoverable failure in name resolution
- FAIL = 4,
-
- /// address family not recognized
- FAMILY = 5,
-
- /// memory allocation failure
- MEMORY = 6,
-
- /// no address associated with hostname
- NODATA = 7,
-
- /// name does not resolve
- NONAME = 8,
-
- /// service not recognized for socket type
- SERVICE = 9,
-
- /// intended socket type was not recognized
- SOCKTYPE = 10,
-
- /// system error returned in errno
- SYSTEM = 11,
-
- /// invalid value for hints
- BADHINTS = 12,
-
- /// resolved protocol is unknown
- PROTOCOL = 13,
-
- /// argument buffer overflow
- OVERFLOW = 14,
-
- _,
-};
-
-pub const EAI_MAX = 15;
-
-pub const msghdr = extern struct {
- /// optional address
- msg_name: ?*sockaddr,
-
- /// size of address
- msg_namelen: socklen_t,
-
- /// scatter/gather array
- msg_iov: [*]iovec,
-
- /// # elements in msg_iov
- msg_iovlen: i32,
-
- /// ancillary data
- msg_control: ?*c_void,
-
- /// ancillary data buffer len
- msg_controllen: socklen_t,
-
- /// flags on received message
- msg_flags: i32,
-};
-
-pub const msghdr_const = extern struct {
- /// optional address
- msg_name: ?*const sockaddr,
-
- /// size of address
- msg_namelen: socklen_t,
-
- /// scatter/gather array
- msg_iov: [*]iovec_const,
-
- /// # elements in msg_iov
- msg_iovlen: i32,
-
- /// ancillary data
- msg_control: ?*c_void,
-
- /// ancillary data buffer len
- msg_controllen: socklen_t,
-
- /// flags on received message
- msg_flags: i32,
-};
-
-pub const libc_stat = extern struct {
- dev: dev_t,
- mode: mode_t,
- ino: ino_t,
- nlink: nlink_t,
- uid: uid_t,
- gid: gid_t,
- rdev: dev_t,
- atim: timespec,
- mtim: timespec,
- ctim: timespec,
- birthtim: timespec,
- size: off_t,
- blocks: blkcnt_t,
- blksize: blksize_t,
- flags: u32,
- gen: u32,
- __spare: [2]u32,
-
- pub fn atime(self: @This()) timespec {
- return self.atim;
- }
-
- pub fn mtime(self: @This()) timespec {
- return self.mtim;
- }
-
- pub fn ctime(self: @This()) timespec {
- return self.ctim;
- }
-};
-
-pub const timespec = extern struct {
- tv_sec: i64,
- tv_nsec: isize,
-};
-
-pub const timeval = extern struct {
- /// seconds
- tv_sec: time_t,
- /// microseconds
- tv_usec: suseconds_t,
-};
-
-pub const MAXNAMLEN = 511;
-
-pub const dirent = extern struct {
- d_fileno: ino_t,
- d_reclen: u16,
- d_namlen: u16,
- d_type: u8,
- d_name: [MAXNAMLEN:0]u8,
-
- pub fn reclen(self: dirent) u16 {
- return self.d_reclen;
- }
-};
-
-pub const SOCK_STREAM = 1;
-pub const SOCK_DGRAM = 2;
-pub const SOCK_RAW = 3;
-pub const SOCK_RDM = 4;
-pub const SOCK_SEQPACKET = 5;
-pub const SOCK_CONN_DGRAM = 6;
-pub const SOCK_DCCP = SOCK_CONN_DGRAM;
-
-pub const SOCK_CLOEXEC = 0x10000000;
-pub const SOCK_NONBLOCK = 0x20000000;
-pub const SOCK_NOSIGPIPE = 0x40000000;
-pub const SOCK_FLAGS_MASK = 0xf0000000;
-
-pub const SO_DEBUG = 0x0001;
-pub const SO_ACCEPTCONN = 0x0002;
-pub const SO_REUSEADDR = 0x0004;
-pub const SO_KEEPALIVE = 0x0008;
-pub const SO_DONTROUTE = 0x0010;
-pub const SO_BROADCAST = 0x0020;
-pub const SO_USELOOPBACK = 0x0040;
-pub const SO_LINGER = 0x0080;
-pub const SO_OOBINLINE = 0x0100;
-pub const SO_REUSEPORT = 0x0200;
-pub const SO_NOSIGPIPE = 0x0800;
-pub const SO_ACCEPTFILTER = 0x1000;
-pub const SO_TIMESTAMP = 0x2000;
-pub const SO_RERROR = 0x4000;
-
-pub const SO_SNDBUF = 0x1001;
-pub const SO_RCVBUF = 0x1002;
-pub const SO_SNDLOWAT = 0x1003;
-pub const SO_RCVLOWAT = 0x1004;
-pub const SO_ERROR = 0x1007;
-pub const SO_TYPE = 0x1008;
-pub const SO_OVERFLOWED = 0x1009;
-
-pub const SO_NOHEADER = 0x100a;
-pub const SO_SNDTIMEO = 0x100b;
-pub const SO_RCVTIMEO = 0x100c;
-
-pub const SOL_SOCKET = 0xffff;
-
-pub const PF_UNSPEC = AF_UNSPEC;
-pub const PF_LOCAL = AF_LOCAL;
-pub const PF_UNIX = PF_LOCAL;
-pub const PF_INET = AF_INET;
-pub const PF_IMPLINK = AF_IMPLINK;
-pub const PF_PUP = AF_PUP;
-pub const PF_CHAOS = AF_CHAOS;
-pub const PF_NS = AF_NS;
-pub const PF_ISO = AF_ISO;
-pub const PF_OSI = AF_ISO;
-pub const PF_ECMA = AF_ECMA;
-pub const PF_DATAKIT = AF_DATAKIT;
-pub const PF_CCITT = AF_CCITT;
-pub const PF_SNA = AF_SNA;
-pub const PF_DECnet = AF_DECnet;
-pub const PF_DLI = AF_DLI;
-pub const PF_LAT = AF_LAT;
-pub const PF_HYLINK = AF_HYLINK;
-pub const PF_APPLETALK = AF_APPLETALK;
-pub const PF_OROUTE = AF_OROUTE;
-pub const PF_LINK = AF_LINK;
-pub const PF_COIP = AF_COIP;
-pub const PF_CNT = AF_CNT;
-pub const PF_INET6 = AF_INET6;
-pub const PF_IPX = AF_IPX;
-pub const PF_ISDN = AF_ISDN;
-pub const PF_E164 = AF_E164;
-pub const PF_NATM = AF_NATM;
-pub const PF_ARP = AF_ARP;
-pub const PF_BLUETOOTH = AF_BLUETOOTH;
-pub const PF_MPLS = AF_MPLS;
-pub const PF_ROUTE = AF_ROUTE;
-pub const PF_CAN = AF_CAN;
-pub const PF_ETHER = AF_ETHER;
-pub const PF_MAX = AF_MAX;
-
-pub const AF_UNSPEC = 0;
-pub const AF_LOCAL = 1;
-pub const AF_UNIX = AF_LOCAL;
-pub const AF_INET = 2;
-pub const AF_IMPLINK = 3;
-pub const AF_PUP = 4;
-pub const AF_CHAOS = 5;
-pub const AF_NS = 6;
-pub const AF_ISO = 7;
-pub const AF_OSI = AF_ISO;
-pub const AF_ECMA = 8;
-pub const AF_DATAKIT = 9;
-pub const AF_CCITT = 10;
-pub const AF_SNA = 11;
-pub const AF_DECnet = 12;
-pub const AF_DLI = 13;
-pub const AF_LAT = 14;
-pub const AF_HYLINK = 15;
-pub const AF_APPLETALK = 16;
-pub const AF_OROUTE = 17;
-pub const AF_LINK = 18;
-pub const AF_COIP = 20;
-pub const AF_CNT = 21;
-pub const AF_IPX = 23;
-pub const AF_INET6 = 24;
-pub const AF_ISDN = 26;
-pub const AF_E164 = AF_ISDN;
-pub const AF_NATM = 27;
-pub const AF_ARP = 28;
-pub const AF_BLUETOOTH = 31;
-pub const AF_IEEE80211 = 32;
-pub const AF_MPLS = 33;
-pub const AF_ROUTE = 34;
-pub const AF_CAN = 35;
-pub const AF_ETHER = 36;
-pub const AF_MAX = 37;
-
-pub const in_port_t = u16;
-pub const sa_family_t = u8;
-
-pub const sockaddr = extern struct {
- /// total length
- len: u8,
-
- /// address family
- family: sa_family_t,
-
- /// actually longer; address value
- data: [14]u8,
-};
-
-pub const sockaddr_storage = std.x.os.Socket.Address.Native.Storage;
-
-pub const sockaddr_in = extern struct {
- len: u8 = @sizeOf(sockaddr_in),
- family: sa_family_t = AF_INET,
- port: in_port_t,
- addr: u32,
- zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },
-};
-
-pub const sockaddr_in6 = extern struct {
- len: u8 = @sizeOf(sockaddr_in6),
- family: sa_family_t = AF_INET6,
- port: in_port_t,
- flowinfo: u32,
- addr: [16]u8,
- scope_id: u32,
-};
-
-/// Definitions for UNIX IPC domain.
-pub const sockaddr_un = extern struct {
- /// total sockaddr length
- len: u8 = @sizeOf(sockaddr_un),
-
- /// AF_LOCAL
- family: sa_family_t = AF_LOCAL,
-
- /// path name
- path: [104]u8,
-};
-
-/// get address to use bind()
-pub const AI_PASSIVE = 0x00000001;
-
-/// fill ai_canonname
-pub const AI_CANONNAME = 0x00000002;
-
-/// prevent host name resolution
-pub const AI_NUMERICHOST = 0x00000004;
-
-/// prevent service name resolution
-pub const AI_NUMERICSERV = 0x00000008;
-
-/// only if any address is assigned
-pub const AI_ADDRCONFIG = 0x00000400;
-
-pub const CTL_KERN = 1;
-pub const CTL_DEBUG = 5;
-
-pub const KERN_PROC_ARGS = 48; // struct: process argv/env
-pub const KERN_PROC_PATHNAME = 5; // path to executable
-pub const KERN_IOV_MAX = 38;
-
-pub const PATH_MAX = 1024;
-pub const IOV_MAX = KERN_IOV_MAX;
-
-pub const STDIN_FILENO = 0;
-pub const STDOUT_FILENO = 1;
-pub const STDERR_FILENO = 2;
-
-pub const PROT_NONE = 0;
-pub const PROT_READ = 1;
-pub const PROT_WRITE = 2;
-pub const PROT_EXEC = 4;
-
-pub const CLOCK_REALTIME = 0;
-pub const CLOCK_VIRTUAL = 1;
-pub const CLOCK_PROF = 2;
-pub const CLOCK_MONOTONIC = 3;
-pub const CLOCK_THREAD_CPUTIME_ID = 0x20000000;
-pub const CLOCK_PROCESS_CPUTIME_ID = 0x40000000;
-
-pub const MAP_FAILED = @intToPtr(*c_void, maxInt(usize));
-pub const MAP_SHARED = 0x0001;
-pub const MAP_PRIVATE = 0x0002;
-pub const MAP_REMAPDUP = 0x0004;
-pub const MAP_FIXED = 0x0010;
-pub const MAP_RENAME = 0x0020;
-pub const MAP_NORESERVE = 0x0040;
-pub const MAP_INHERIT = 0x0080;
-pub const MAP_HASSEMAPHORE = 0x0200;
-pub const MAP_TRYFIXED = 0x0400;
-pub const MAP_WIRED = 0x0800;
-
-pub const MAP_FILE = 0x0000;
-pub const MAP_NOSYNC = 0x0800;
-pub const MAP_ANON = 0x1000;
-pub const MAP_ANONYMOUS = MAP_ANON;
-pub const MAP_STACK = 0x2000;
-
-pub const WNOHANG = 0x00000001;
-pub const WUNTRACED = 0x00000002;
-pub const WSTOPPED = WUNTRACED;
-pub const WCONTINUED = 0x00000010;
-pub const WNOWAIT = 0x00010000;
-pub const WEXITED = 0x00000020;
-pub const WTRAPPED = 0x00000040;
-
-pub const SA_ONSTACK = 0x0001;
-pub const SA_RESTART = 0x0002;
-pub const SA_RESETHAND = 0x0004;
-pub const SA_NOCLDSTOP = 0x0008;
-pub const SA_NODEFER = 0x0010;
-pub const SA_NOCLDWAIT = 0x0020;
-pub const SA_SIGINFO = 0x0040;
-
-pub const SIGHUP = 1;
-pub const SIGINT = 2;
-pub const SIGQUIT = 3;
-pub const SIGILL = 4;
-pub const SIGTRAP = 5;
-pub const SIGABRT = 6;
-pub const SIGIOT = SIGABRT;
-pub const SIGEMT = 7;
-pub const SIGFPE = 8;
-pub const SIGKILL = 9;
-pub const SIGBUS = 10;
-pub const SIGSEGV = 11;
-pub const SIGSYS = 12;
-pub const SIGPIPE = 13;
-pub const SIGALRM = 14;
-pub const SIGTERM = 15;
-pub const SIGURG = 16;
-pub const SIGSTOP = 17;
-pub const SIGTSTP = 18;
-pub const SIGCONT = 19;
-pub const SIGCHLD = 20;
-pub const SIGTTIN = 21;
-pub const SIGTTOU = 22;
-pub const SIGIO = 23;
-pub const SIGXCPU = 24;
-pub const SIGXFSZ = 25;
-pub const SIGVTALRM = 26;
-pub const SIGPROF = 27;
-pub const SIGWINCH = 28;
-pub const SIGINFO = 29;
-pub const SIGUSR1 = 30;
-pub const SIGUSR2 = 31;
-pub const SIGPWR = 32;
-
-pub const SIGRTMIN = 33;
-pub const SIGRTMAX = 63;
-
-// access function
-pub const F_OK = 0; // test for existence of file
-pub const X_OK = 1; // test for execute or search permission
-pub const W_OK = 2; // test for write permission
-pub const R_OK = 4; // test for read permission
-
-/// open for reading only
-pub const O_RDONLY = 0x00000000;
-
-/// open for writing only
-pub const O_WRONLY = 0x00000001;
-
-/// open for reading and writing
-pub const O_RDWR = 0x00000002;
-
-/// mask for above modes
-pub const O_ACCMODE = 0x00000003;
-
-/// no delay
-pub const O_NONBLOCK = 0x00000004;
-
-/// set append mode
-pub const O_APPEND = 0x00000008;
-
-/// open with shared file lock
-pub const O_SHLOCK = 0x00000010;
-
-/// open with exclusive file lock
-pub const O_EXLOCK = 0x00000020;
-
-/// signal pgrp when data ready
-pub const O_ASYNC = 0x00000040;
-
-/// synchronous writes
-pub const O_SYNC = 0x00000080;
-
-/// don't follow symlinks on the last
-pub const O_NOFOLLOW = 0x00000100;
-
-/// create if nonexistent
-pub const O_CREAT = 0x00000200;
-
-/// truncate to zero length
-pub const O_TRUNC = 0x00000400;
-
-/// error if already exists
-pub const O_EXCL = 0x00000800;
-
-/// don't assign controlling terminal
-pub const O_NOCTTY = 0x00008000;
-
-/// write: I/O data completion
-pub const O_DSYNC = 0x00010000;
-
-/// read: I/O completion as for write
-pub const O_RSYNC = 0x00020000;
-
-/// use alternate i/o semantics
-pub const O_ALT_IO = 0x00040000;
-
-/// direct I/O hint
-pub const O_DIRECT = 0x00080000;
-
-/// fail if not a directory
-pub const O_DIRECTORY = 0x00200000;
-
-/// set close on exec
-pub const O_CLOEXEC = 0x00400000;
-
-/// skip search permission checks
-pub const O_SEARCH = 0x00800000;
-
-pub const F_DUPFD = 0;
-pub const F_GETFD = 1;
-pub const F_SETFD = 2;
-pub const F_GETFL = 3;
-pub const F_SETFL = 4;
-
-pub const F_GETOWN = 5;
-pub const F_SETOWN = 6;
-
-pub const F_GETLK = 7;
-pub const F_SETLK = 8;
-pub const F_SETLKW = 9;
-
-pub const F_RDLCK = 1;
-pub const F_WRLCK = 3;
-pub const F_UNLCK = 2;
-
-pub const LOCK_SH = 1;
-pub const LOCK_EX = 2;
-pub const LOCK_UN = 8;
-pub const LOCK_NB = 4;
-
-pub const FD_CLOEXEC = 1;
-
-pub const SEEK_SET = 0;
-pub const SEEK_CUR = 1;
-pub const SEEK_END = 2;
-
-pub const SIG_BLOCK = 1;
-pub const SIG_UNBLOCK = 2;
-pub const SIG_SETMASK = 3;
-
-pub const DT_UNKNOWN = 0;
-pub const DT_FIFO = 1;
-pub const DT_CHR = 2;
-pub const DT_DIR = 4;
-pub const DT_BLK = 6;
-pub const DT_REG = 8;
-pub const DT_LNK = 10;
-pub const DT_SOCK = 12;
-pub const DT_WHT = 14;
-
-/// add event to kq (implies enable)
-pub const EV_ADD = 0x0001;
-
-/// delete event from kq
-pub const EV_DELETE = 0x0002;
-
-/// enable event
-pub const EV_ENABLE = 0x0004;
-
-/// disable event (not reported)
-pub const EV_DISABLE = 0x0008;
-
-/// only report one occurrence
-pub const EV_ONESHOT = 0x0010;
-
-/// clear event state after reporting
-pub const EV_CLEAR = 0x0020;
-
-/// force immediate event output
-/// ... with or without EV_ERROR
-/// ... use KEVENT_FLAG_ERROR_EVENTS
-/// on syscalls supporting flags
-pub const EV_RECEIPT = 0x0040;
-
-/// disable event after reporting
-pub const EV_DISPATCH = 0x0080;
-
-pub const EVFILT_READ = 0;
-pub const EVFILT_WRITE = 1;
-
-/// attached to aio requests
-pub const EVFILT_AIO = 2;
-
-/// attached to vnodes
-pub const EVFILT_VNODE = 3;
-
-/// attached to struct proc
-pub const EVFILT_PROC = 4;
-
-/// attached to struct proc
-pub const EVFILT_SIGNAL = 5;
-
-/// timers
-pub const EVFILT_TIMER = 6;
-
-/// Filesystem events
-pub const EVFILT_FS = 7;
-
-/// On input, NOTE_TRIGGER causes the event to be triggered for output.
-pub const NOTE_TRIGGER = 0x08000000;
-
-/// low water mark
-pub const NOTE_LOWAT = 0x00000001;
-
-/// vnode was removed
-pub const NOTE_DELETE = 0x00000001;
-
-/// data contents changed
-pub const NOTE_WRITE = 0x00000002;
-
-/// size increased
-pub const NOTE_EXTEND = 0x00000004;
-
-/// attributes changed
-pub const NOTE_ATTRIB = 0x00000008;
-
-/// link count changed
-pub const NOTE_LINK = 0x00000010;
-
-/// vnode was renamed
-pub const NOTE_RENAME = 0x00000020;
-
-/// vnode access was revoked
-pub const NOTE_REVOKE = 0x00000040;
-
-/// process exited
-pub const NOTE_EXIT = 0x80000000;
-
-/// process forked
-pub const NOTE_FORK = 0x40000000;
-
-/// process exec'd
-pub const NOTE_EXEC = 0x20000000;
-
-/// mask for signal & exit status
-pub const NOTE_PDATAMASK = 0x000fffff;
-pub const NOTE_PCTRLMASK = 0xf0000000;
-
-pub const TIOCCBRK = 0x2000747a;
-pub const TIOCCDTR = 0x20007478;
-pub const TIOCCONS = 0x80047462;
-pub const TIOCDCDTIMESTAMP = 0x40107458;
-pub const TIOCDRAIN = 0x2000745e;
-pub const TIOCEXCL = 0x2000740d;
-pub const TIOCEXT = 0x80047460;
-pub const TIOCFLAG_CDTRCTS = 0x10;
-pub const TIOCFLAG_CLOCAL = 0x2;
-pub const TIOCFLAG_CRTSCTS = 0x4;
-pub const TIOCFLAG_MDMBUF = 0x8;
-pub const TIOCFLAG_SOFTCAR = 0x1;
-pub const TIOCFLUSH = 0x80047410;
-pub const TIOCGETA = 0x402c7413;
-pub const TIOCGETD = 0x4004741a;
-pub const TIOCGFLAGS = 0x4004745d;
-pub const TIOCGLINED = 0x40207442;
-pub const TIOCGPGRP = 0x40047477;
-pub const TIOCGQSIZE = 0x40047481;
-pub const TIOCGRANTPT = 0x20007447;
-pub const TIOCGSID = 0x40047463;
-pub const TIOCGSIZE = 0x40087468;
-pub const TIOCGWINSZ = 0x40087468;
-pub const TIOCMBIC = 0x8004746b;
-pub const TIOCMBIS = 0x8004746c;
-pub const TIOCMGET = 0x4004746a;
-pub const TIOCMSET = 0x8004746d;
-pub const TIOCM_CAR = 0x40;
-pub const TIOCM_CD = 0x40;
-pub const TIOCM_CTS = 0x20;
-pub const TIOCM_DSR = 0x100;
-pub const TIOCM_DTR = 0x2;
-pub const TIOCM_LE = 0x1;
-pub const TIOCM_RI = 0x80;
-pub const TIOCM_RNG = 0x80;
-pub const TIOCM_RTS = 0x4;
-pub const TIOCM_SR = 0x10;
-pub const TIOCM_ST = 0x8;
-pub const TIOCNOTTY = 0x20007471;
-pub const TIOCNXCL = 0x2000740e;
-pub const TIOCOUTQ = 0x40047473;
-pub const TIOCPKT = 0x80047470;
-pub const TIOCPKT_DATA = 0x0;
-pub const TIOCPKT_DOSTOP = 0x20;
-pub const TIOCPKT_FLUSHREAD = 0x1;
-pub const TIOCPKT_FLUSHWRITE = 0x2;
-pub const TIOCPKT_IOCTL = 0x40;
-pub const TIOCPKT_NOSTOP = 0x10;
-pub const TIOCPKT_START = 0x8;
-pub const TIOCPKT_STOP = 0x4;
-pub const TIOCPTMGET = 0x40287446;
-pub const TIOCPTSNAME = 0x40287448;
-pub const TIOCRCVFRAME = 0x80087445;
-pub const TIOCREMOTE = 0x80047469;
-pub const TIOCSBRK = 0x2000747b;
-pub const TIOCSCTTY = 0x20007461;
-pub const TIOCSDTR = 0x20007479;
-pub const TIOCSETA = 0x802c7414;
-pub const TIOCSETAF = 0x802c7416;
-pub const TIOCSETAW = 0x802c7415;
-pub const TIOCSETD = 0x8004741b;
-pub const TIOCSFLAGS = 0x8004745c;
-pub const TIOCSIG = 0x2000745f;
-pub const TIOCSLINED = 0x80207443;
-pub const TIOCSPGRP = 0x80047476;
-pub const TIOCSQSIZE = 0x80047480;
-pub const TIOCSSIZE = 0x80087467;
-pub const TIOCSTART = 0x2000746e;
-pub const TIOCSTAT = 0x80047465;
-pub const TIOCSTI = 0x80017472;
-pub const TIOCSTOP = 0x2000746f;
-pub const TIOCSWINSZ = 0x80087467;
-pub const TIOCUCNTL = 0x80047466;
-pub const TIOCXMTFRAME = 0x80087444;
-
-pub fn WEXITSTATUS(s: u32) u8 {
- return @intCast(u8, (s >> 8) & 0xff);
-}
-pub fn WTERMSIG(s: u32) u32 {
- return s & 0x7f;
-}
-pub fn WSTOPSIG(s: u32) u32 {
- return WEXITSTATUS(s);
-}
-pub fn WIFEXITED(s: u32) bool {
- return WTERMSIG(s) == 0;
-}
-
-pub fn WIFCONTINUED(s: u32) bool {
- return ((s & 0x7f) == 0xffff);
-}
-
-pub fn WIFSTOPPED(s: u32) bool {
- return ((s & 0x7f != 0x7f) and !WIFCONTINUED(s));
-}
-
-pub fn WIFSIGNALED(s: u32) bool {
- return !WIFSTOPPED(s) and !WIFCONTINUED(s) and !WIFEXITED(s);
-}
-
-pub const winsize = extern struct {
- ws_row: u16,
- ws_col: u16,
- ws_xpixel: u16,
- ws_ypixel: u16,
-};
-
-const NSIG = 32;
-
-pub const SIG_DFL = @intToPtr(?Sigaction.sigaction_fn, 0);
-pub const SIG_IGN = @intToPtr(?Sigaction.sigaction_fn, 1);
-pub const SIG_ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize));
-
-/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.
-pub const Sigaction = extern struct {
- pub const handler_fn = fn (c_int) callconv(.C) void;
- pub const sigaction_fn = fn (c_int, *const siginfo_t, ?*const c_void) callconv(.C) void;
-
- /// signal handler
- handler: extern union {
- handler: ?handler_fn,
- sigaction: ?sigaction_fn,
- },
- /// signal mask to apply
- mask: sigset_t,
- /// signal options
- flags: c_uint,
-};
-
-pub const sigval_t = extern union {
- int: i32,
- ptr: ?*c_void,
-};
-
-pub const siginfo_t = extern union {
- pad: [128]u8,
- info: _ksiginfo,
-};
-
-pub const _ksiginfo = extern struct {
- signo: i32,
- code: i32,
- errno: i32,
- // 64bit architectures insert 4bytes of padding here, this is done by
- // correctly aligning the reason field
- reason: extern union {
- rt: extern struct {
- pid: pid_t,
- uid: uid_t,
- value: sigval_t,
- },
- child: extern struct {
- pid: pid_t,
- uid: uid_t,
- status: i32,
- utime: clock_t,
- stime: clock_t,
- },
- fault: extern struct {
- addr: ?*c_void,
- trap: i32,
- trap2: i32,
- trap3: i32,
- },
- poll: extern struct {
- band: i32,
- fd: i32,
- },
- syscall: extern struct {
- sysnum: i32,
- retval: [2]i32,
- @"error": i32,
- args: [8]u64,
- },
- ptrace_state: extern struct {
- pe_report_event: i32,
- option: extern union {
- pe_other_pid: pid_t,
- pe_lwp: lwpid_t,
- },
- },
- } align(@sizeOf(usize)),
-};
-
-pub const _SIG_WORDS = 4;
-pub const _SIG_MAXSIG = 128;
-
-pub inline fn _SIG_IDX(sig: usize) usize {
- return sig - 1;
-}
-pub inline fn _SIG_WORD(sig: usize) usize {
- return_SIG_IDX(sig) >> 5;
-}
-pub inline fn _SIG_BIT(sig: usize) usize {
- return 1 << (_SIG_IDX(sig) & 31);
-}
-pub inline fn _SIG_VALID(sig: usize) usize {
- return sig <= _SIG_MAXSIG and sig > 0;
-}
-
-pub const sigset_t = extern struct {
- __bits: [_SIG_WORDS]u32,
-};
-
-pub const empty_sigset = sigset_t{ .__bits = [_]u32{0} ** _SIG_WORDS };
-
-// XXX x86_64 specific
-pub const mcontext_t = extern struct {
- gregs: [26]u64,
- mc_tlsbase: u64,
- fpregs: [512]u8 align(8),
-};
-
-pub const REG_RBP = 12;
-pub const REG_RIP = 21;
-pub const REG_RSP = 24;
-
-pub const ucontext_t = extern struct {
- flags: u32,
- link: ?*ucontext_t,
- sigmask: sigset_t,
- stack: stack_t,
- mcontext: mcontext_t,
- __pad: [
- switch (builtin.cpu.arch) {
- .i386 => 4,
- .mips, .mipsel, .mips64, .mips64el => 14,
- .arm, .armeb, .thumb, .thumbeb => 1,
- .sparc, .sparcel, .sparcv9 => if (@sizeOf(usize) == 4) 43 else 8,
- else => 0,
- }
- ]u32,
-};
-
-pub const E = enum(u16) {
- /// No error occurred.
- SUCCESS = 0,
- PERM = 1, // Operation not permitted
- NOENT = 2, // No such file or directory
- SRCH = 3, // No such process
- INTR = 4, // Interrupted system call
- IO = 5, // Input/output error
- NXIO = 6, // Device not configured
- @"2BIG" = 7, // Argument list too long
- NOEXEC = 8, // Exec format error
- BADF = 9, // Bad file descriptor
- CHILD = 10, // No child processes
- DEADLK = 11, // Resource deadlock avoided
- // 11 was AGAIN
- NOMEM = 12, // Cannot allocate memory
- ACCES = 13, // Permission denied
- FAULT = 14, // Bad address
- NOTBLK = 15, // Block device required
- BUSY = 16, // Device busy
- EXIST = 17, // File exists
- XDEV = 18, // Cross-device link
- NODEV = 19, // Operation not supported by device
- NOTDIR = 20, // Not a directory
- ISDIR = 21, // Is a directory
- INVAL = 22, // Invalid argument
- NFILE = 23, // Too many open files in system
- MFILE = 24, // Too many open files
- NOTTY = 25, // Inappropriate ioctl for device
- TXTBSY = 26, // Text file busy
- FBIG = 27, // File too large
- NOSPC = 28, // No space left on device
- SPIPE = 29, // Illegal seek
- ROFS = 30, // Read-only file system
- MLINK = 31, // Too many links
- PIPE = 32, // Broken pipe
-
- // math software
- DOM = 33, // Numerical argument out of domain
- RANGE = 34, // Result too large or too small
-
- // non-blocking and interrupt i/o
- // also: WOULDBLOCK: operation would block
- AGAIN = 35, // Resource temporarily unavailable
- INPROGRESS = 36, // Operation now in progress
- ALREADY = 37, // Operation already in progress
-
- // ipc/network software -- argument errors
- NOTSOCK = 38, // Socket operation on non-socket
- DESTADDRREQ = 39, // Destination address required
- MSGSIZE = 40, // Message too long
- PROTOTYPE = 41, // Protocol wrong type for socket
- NOPROTOOPT = 42, // Protocol option not available
- PROTONOSUPPORT = 43, // Protocol not supported
- SOCKTNOSUPPORT = 44, // Socket type not supported
- OPNOTSUPP = 45, // Operation not supported
- PFNOSUPPORT = 46, // Protocol family not supported
- AFNOSUPPORT = 47, // Address family not supported by protocol family
- ADDRINUSE = 48, // Address already in use
- ADDRNOTAVAIL = 49, // Can't assign requested address
-
- // ipc/network software -- operational errors
- NETDOWN = 50, // Network is down
- NETUNREACH = 51, // Network is unreachable
- NETRESET = 52, // Network dropped connection on reset
- CONNABORTED = 53, // Software caused connection abort
- CONNRESET = 54, // Connection reset by peer
- NOBUFS = 55, // No buffer space available
- ISCONN = 56, // Socket is already connected
- NOTCONN = 57, // Socket is not connected
- SHUTDOWN = 58, // Can't send after socket shutdown
- TOOMANYREFS = 59, // Too many references: can't splice
- TIMEDOUT = 60, // Operation timed out
- CONNREFUSED = 61, // Connection refused
-
- LOOP = 62, // Too many levels of symbolic links
- NAMETOOLONG = 63, // File name too long
-
- // should be rearranged
- HOSTDOWN = 64, // Host is down
- HOSTUNREACH = 65, // No route to host
- NOTEMPTY = 66, // Directory not empty
-
- // quotas & mush
- PROCLIM = 67, // Too many processes
- USERS = 68, // Too many users
- DQUOT = 69, // Disc quota exceeded
-
- // Network File System
- STALE = 70, // Stale NFS file handle
- REMOTE = 71, // Too many levels of remote in path
- BADRPC = 72, // RPC struct is bad
- RPCMISMATCH = 73, // RPC version wrong
- PROGUNAVAIL = 74, // RPC prog. not avail
- PROGMISMATCH = 75, // Program version wrong
- PROCUNAVAIL = 76, // Bad procedure for program
-
- NOLCK = 77, // No locks available
- NOSYS = 78, // Function not implemented
-
- FTYPE = 79, // Inappropriate file type or format
- AUTH = 80, // Authentication error
- NEEDAUTH = 81, // Need authenticator
-
- // SystemV IPC
- IDRM = 82, // Identifier removed
- NOMSG = 83, // No message of desired type
- OVERFLOW = 84, // Value too large to be stored in data type
-
- // Wide/multibyte-character handling, ISO/IEC 9899/AMD1:1995
- ILSEQ = 85, // Illegal byte sequence
-
- // From IEEE Std 1003.1-2001
- // Base, Realtime, Threads or Thread Priority Scheduling option errors
- NOTSUP = 86, // Not supported
-
- // Realtime option errors
- CANCELED = 87, // Operation canceled
-
- // Realtime, XSI STREAMS option errors
- BADMSG = 88, // Bad or Corrupt message
-
- // XSI STREAMS option errors
- NODATA = 89, // No message available
- NOSR = 90, // No STREAM resources
- NOSTR = 91, // Not a STREAM
- TIME = 92, // STREAM ioctl timeout
-
- // File system extended attribute errors
- NOATTR = 93, // Attribute not found
-
- // Realtime, XSI STREAMS option errors
- MULTIHOP = 94, // Multihop attempted
- NOLINK = 95, // Link has been severed
- PROTO = 96, // Protocol error
-
- _,
-};
-
-pub const MINSIGSTKSZ = 8192;
-pub const SIGSTKSZ = MINSIGSTKSZ + 32768;
-
-pub const SS_ONSTACK = 1;
-pub const SS_DISABLE = 4;
-
-pub const stack_t = extern struct {
- ss_sp: [*]u8,
- ss_size: isize,
- ss_flags: i32,
-};
-
-pub const S_IFMT = 0o170000;
-
-pub const S_IFIFO = 0o010000;
-pub const S_IFCHR = 0o020000;
-pub const S_IFDIR = 0o040000;
-pub const S_IFBLK = 0o060000;
-pub const S_IFREG = 0o100000;
-pub const S_IFLNK = 0o120000;
-pub const S_IFSOCK = 0o140000;
-pub const S_IFWHT = 0o160000;
-
-pub const S_ISUID = 0o4000;
-pub const S_ISGID = 0o2000;
-pub const S_ISVTX = 0o1000;
-pub const S_IRWXU = 0o700;
-pub const S_IRUSR = 0o400;
-pub const S_IWUSR = 0o200;
-pub const S_IXUSR = 0o100;
-pub const S_IRWXG = 0o070;
-pub const S_IRGRP = 0o040;
-pub const S_IWGRP = 0o020;
-pub const S_IXGRP = 0o010;
-pub const S_IRWXO = 0o007;
-pub const S_IROTH = 0o004;
-pub const S_IWOTH = 0o002;
-pub const S_IXOTH = 0o001;
-
-pub fn S_ISFIFO(m: u32) bool {
- return m & S_IFMT == S_IFIFO;
-}
-
-pub fn S_ISCHR(m: u32) bool {
- return m & S_IFMT == S_IFCHR;
-}
-
-pub fn S_ISDIR(m: u32) bool {
- return m & S_IFMT == S_IFDIR;
-}
-
-pub fn S_ISBLK(m: u32) bool {
- return m & S_IFMT == S_IFBLK;
-}
-
-pub fn S_ISREG(m: u32) bool {
- return m & S_IFMT == S_IFREG;
-}
-
-pub fn S_ISLNK(m: u32) bool {
- return m & S_IFMT == S_IFLNK;
-}
-
-pub fn S_ISSOCK(m: u32) bool {
- return m & S_IFMT == S_IFSOCK;
-}
-
-pub fn S_IWHT(m: u32) bool {
- return m & S_IFMT == S_IFWHT;
-}
-
-/// Magic value that specify the use of the current working directory
-/// to determine the target of relative file paths in the openat() and
-/// similar syscalls.
-pub const AT_FDCWD = -100;
-
-/// Check access using effective user and group ID
-pub const AT_EACCESS = 0x0100;
-
-/// Do not follow symbolic links
-pub const AT_SYMLINK_NOFOLLOW = 0x0200;
-
-/// Follow symbolic link
-pub const AT_SYMLINK_FOLLOW = 0x0400;
-
-/// Remove directory instead of file
-pub const AT_REMOVEDIR = 0x0800;
-
-pub const HOST_NAME_MAX = 255;
-
-/// dummy for IP
-pub const IPPROTO_IP = 0;
-
-/// IP6 hop-by-hop options
-pub const IPPROTO_HOPOPTS = 0;
-
-/// control message protocol
-pub const IPPROTO_ICMP = 1;
-
-/// group mgmt protocol
-pub const IPPROTO_IGMP = 2;
-
-/// gateway^2 (deprecated)
-pub const IPPROTO_GGP = 3;
-
-/// IP header
-pub const IPPROTO_IPV4 = 4;
-
-/// IP inside IP
-pub const IPPROTO_IPIP = 4;
-
-/// tcp
-pub const IPPROTO_TCP = 6;
-
-/// exterior gateway protocol
-pub const IPPROTO_EGP = 8;
-
-/// pup
-pub const IPPROTO_PUP = 12;
-
-/// user datagram protocol
-pub const IPPROTO_UDP = 17;
-
-/// xns idp
-pub const IPPROTO_IDP = 22;
-
-/// tp-4 w/ class negotiation
-pub const IPPROTO_TP = 29;
-
-/// DCCP
-pub const IPPROTO_DCCP = 33;
-
-/// IP6 header
-pub const IPPROTO_IPV6 = 41;
-
-/// IP6 routing header
-pub const IPPROTO_ROUTING = 43;
-
-/// IP6 fragmentation header
-pub const IPPROTO_FRAGMENT = 44;
-
-/// resource reservation
-pub const IPPROTO_RSVP = 46;
-
-/// GRE encaps RFC 1701
-pub const IPPROTO_GRE = 47;
-
-/// encap. security payload
-pub const IPPROTO_ESP = 50;
-
-/// authentication header
-pub const IPPROTO_AH = 51;
-
-/// IP Mobility RFC 2004
-pub const IPPROTO_MOBILE = 55;
-
-/// IPv6 ICMP
-pub const IPPROTO_IPV6_ICMP = 58;
-
-/// ICMP6
-pub const IPPROTO_ICMPV6 = 58;
-
-/// IP6 no next header
-pub const IPPROTO_NONE = 59;
-
-/// IP6 destination option
-pub const IPPROTO_DSTOPTS = 60;
-
-/// ISO cnlp
-pub const IPPROTO_EON = 80;
-
-/// Ethernet-in-IP
-pub const IPPROTO_ETHERIP = 97;
-
-/// encapsulation header
-pub const IPPROTO_ENCAP = 98;
-
-/// Protocol indep. multicast
-pub const IPPROTO_PIM = 103;
-
-/// IP Payload Comp. Protocol
-pub const IPPROTO_IPCOMP = 108;
-
-/// VRRP RFC 2338
-pub const IPPROTO_VRRP = 112;
-
-/// Common Address Resolution Protocol
-pub const IPPROTO_CARP = 112;
-
-/// L2TPv3
-pub const IPPROTO_L2TP = 115;
-
-/// SCTP
-pub const IPPROTO_SCTP = 132;
-
-/// PFSYNC
-pub const IPPROTO_PFSYNC = 240;
-
-/// raw IP packet
-pub const IPPROTO_RAW = 255;
-
-pub const rlimit_resource = enum(c_int) {
- CPU = 0,
- FSIZE = 1,
- DATA = 2,
- STACK = 3,
- CORE = 4,
- RSS = 5,
- MEMLOCK = 6,
- NPROC = 7,
- NOFILE = 8,
- SBSIZE = 9,
- VMEM = 10,
- NTHR = 11,
- _,
-
- pub const AS: rlimit_resource = .VMEM;
-};
-
-pub const rlim_t = u64;
-
-/// No limit
-pub const RLIM_INFINITY: rlim_t = (1 << 63) - 1;
-
-pub const RLIM_SAVED_MAX = RLIM_INFINITY;
-pub const RLIM_SAVED_CUR = RLIM_INFINITY;
-
-pub const rlimit = extern struct {
- /// Soft limit
- cur: rlim_t,
- /// Hard limit
- max: rlim_t,
-};
-
-pub const SHUT_RD = 0;
-pub const SHUT_WR = 1;
-pub const SHUT_RDWR = 2;
-
-pub const nfds_t = u32;
-
-pub const pollfd = extern struct {
- fd: fd_t,
- events: i16,
- revents: i16,
-};
-
-/// Testable events (may be specified in events field).
-pub const POLLIN = 0x0001;
-pub const POLLPRI = 0x0002;
-pub const POLLOUT = 0x0004;
-pub const POLLRDNORM = 0x0040;
-pub const POLLWRNORM = POLLOUT;
-pub const POLLRDBAND = 0x0080;
-pub const POLLWRBAND = 0x0100;
-
-/// Non-testable events (may not be specified in events field).
-pub const POLLERR = 0x0008;
-pub const POLLHUP = 0x0010;
-pub const POLLNVAL = 0x0020;
diff --git a/lib/std/os/bits/openbsd.zig b/lib/std/os/bits/openbsd.zig
deleted file mode 100644
index c7d1c0583bc6..000000000000
--- a/lib/std/os/bits/openbsd.zig
+++ /dev/null
@@ -1,1330 +0,0 @@
-const std = @import("../../std.zig");
-const builtin = std.builtin;
-const maxInt = std.math.maxInt;
-
-pub usingnamespace @import("posix.zig");
-
-pub const blkcnt_t = i64;
-pub const blksize_t = i32;
-pub const clock_t = i64;
-pub const dev_t = i32;
-pub const fd_t = c_int;
-pub const gid_t = u32;
-pub const ino_t = u64;
-pub const mode_t = u32;
-pub const nlink_t = u32;
-pub const off_t = i64;
-pub const pid_t = i32;
-pub const socklen_t = u32;
-pub const time_t = i64;
-pub const uid_t = u32;
-
-/// Renamed from `kevent` to `Kevent` to avoid conflict with function name.
-pub const Kevent = extern struct {
- ident: usize,
- filter: c_short,
- flags: u16,
- fflags: c_uint,
- data: i64,
- udata: usize,
-};
-
-// Modes and flags for dlopen()
-// include/dlfcn.h
-
-/// Bind function calls lazily.
-pub const RTLD_LAZY = 1;
-
-/// Bind function calls immediately.
-pub const RTLD_NOW = 2;
-
-/// Make symbols globally available.
-pub const RTLD_GLOBAL = 0x100;
-
-/// Opposite of RTLD_GLOBAL, and the default.
-pub const RTLD_LOCAL = 0x000;
-
-/// Trace loaded objects and exit.
-pub const RTLD_TRACE = 0x200;
-
-pub const dl_phdr_info = extern struct {
- dlpi_addr: std.elf.Addr,
- dlpi_name: ?[*:0]const u8,
- dlpi_phdr: [*]std.elf.Phdr,
- dlpi_phnum: std.elf.Half,
-};
-
-pub const Flock = extern struct {
- l_start: off_t,
- l_len: off_t,
- l_pid: pid_t,
- l_type: c_short,
- l_whence: c_short,
-};
-
-pub const addrinfo = extern struct {
- flags: c_int,
- family: c_int,
- socktype: c_int,
- protocol: c_int,
- addrlen: socklen_t,
- addr: ?*sockaddr,
- canonname: ?[*:0]u8,
- next: ?*addrinfo,
-};
-
-pub const EAI = enum(c_int) {
- /// address family for hostname not supported
- ADDRFAMILY = -9,
-
- /// name could not be resolved at this time
- AGAIN = -3,
-
- /// flags parameter had an invalid value
- BADFLAGS = -1,
-
- /// non-recoverable failure in name resolution
- FAIL = -4,
-
- /// address family not recognized
- FAMILY = -6,
-
- /// memory allocation failure
- MEMORY = -10,
-
- /// no address associated with hostname
- NODATA = -5,
-
- /// name does not resolve
- NONAME = -2,
-
- /// service not recognized for socket type
- SERVICE = -8,
-
- /// intended socket type was not recognized
- SOCKTYPE = -7,
-
- /// system error returned in errno
- SYSTEM = -11,
-
- /// invalid value for hints
- BADHINTS = -12,
-
- /// resolved protocol is unknown
- PROTOCOL = -13,
-
- /// argument buffer overflow
- OVERFLOW = -14,
-
- _,
-};
-
-pub const EAI_MAX = 15;
-
-pub const msghdr = extern struct {
- /// optional address
- msg_name: ?*sockaddr,
-
- /// size of address
- msg_namelen: socklen_t,
-
- /// scatter/gather array
- msg_iov: [*]iovec,
-
- /// # elements in msg_iov
- msg_iovlen: c_uint,
-
- /// ancillary data
- msg_control: ?*c_void,
-
- /// ancillary data buffer len
- msg_controllen: socklen_t,
-
- /// flags on received message
- msg_flags: c_int,
-};
-
-pub const msghdr_const = extern struct {
- /// optional address
- msg_name: ?*const sockaddr,
-
- /// size of address
- msg_namelen: socklen_t,
-
- /// scatter/gather array
- msg_iov: [*]iovec_const,
-
- /// # elements in msg_iov
- msg_iovlen: c_uint,
-
- /// ancillary data
- msg_control: ?*c_void,
-
- /// ancillary data buffer len
- msg_controllen: socklen_t,
-
- /// flags on received message
- msg_flags: c_int,
-};
-
-pub const libc_stat = extern struct {
- mode: mode_t,
- dev: dev_t,
- ino: ino_t,
- nlink: nlink_t,
- uid: uid_t,
- gid: gid_t,
- rdev: dev_t,
- atim: timespec,
- mtim: timespec,
- ctim: timespec,
- size: off_t,
- blocks: blkcnt_t,
- blksize: blksize_t,
- flags: u32,
- gen: u32,
- birthtim: timespec,
-
- pub fn atime(self: @This()) timespec {
- return self.atim;
- }
-
- pub fn mtime(self: @This()) timespec {
- return self.mtim;
- }
-
- pub fn ctime(self: @This()) timespec {
- return self.ctim;
- }
-};
-
-pub const timespec = extern struct {
- tv_sec: time_t,
- tv_nsec: c_long,
-};
-
-pub const timeval = extern struct {
- tv_sec: time_t,
- tv_usec: c_long,
-};
-
-pub const timezone = extern struct {
- tz_minuteswest: c_int,
- tz_dsttime: c_int,
-};
-
-pub const MAXNAMLEN = 255;
-
-pub const dirent = extern struct {
- d_fileno: ino_t,
- d_off: off_t,
- d_reclen: u16,
- d_type: u8,
- d_namlen: u8,
- __d_padding: [4]u8,
- d_name: [MAXNAMLEN + 1]u8,
-
- pub fn reclen(self: dirent) u16 {
- return self.d_reclen;
- }
-};
-
-pub const in_port_t = u16;
-pub const sa_family_t = u8;
-
-pub const sockaddr = extern struct {
- /// total length
- len: u8,
-
- /// address family
- family: sa_family_t,
-
- /// actually longer; address value
- data: [14]u8,
-};
-
-pub const sockaddr_storage = std.x.os.Socket.Address.Native.Storage;
-
-pub const sockaddr_in = extern struct {
- len: u8 = @sizeOf(sockaddr_in),
- family: sa_family_t = AF_INET,
- port: in_port_t,
- addr: u32,
- zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },
-};
-
-pub const sockaddr_in6 = extern struct {
- len: u8 = @sizeOf(sockaddr_in6),
- family: sa_family_t = AF_INET6,
- port: in_port_t,
- flowinfo: u32,
- addr: [16]u8,
- scope_id: u32,
-};
-
-/// Definitions for UNIX IPC domain.
-pub const sockaddr_un = extern struct {
- /// total sockaddr length
- len: u8 = @sizeOf(sockaddr_un),
-
- /// AF_LOCAL
- family: sa_family_t = AF_LOCAL,
-
- /// path name
- path: [104]u8,
-};
-
-/// get address to use bind()
-pub const AI_PASSIVE = 1;
-
-/// fill ai_canonname
-pub const AI_CANONNAME = 2;
-
-/// prevent host name resolution
-pub const AI_NUMERICHOST = 4;
-
-/// prevent service name resolution
-pub const AI_NUMERICSERV = 16;
-
-/// only if any address is assigned
-pub const AI_ADDRCONFIG = 64;
-
-pub const PATH_MAX = 1024;
-pub const IOV_MAX = 1024;
-
-pub const STDIN_FILENO = 0;
-pub const STDOUT_FILENO = 1;
-pub const STDERR_FILENO = 2;
-
-pub const PROT_NONE = 0;
-pub const PROT_READ = 1;
-pub const PROT_WRITE = 2;
-pub const PROT_EXEC = 4;
-
-pub const CLOCK_REALTIME = 0;
-pub const CLOCK_PROCESS_CPUTIME_ID = 2;
-pub const CLOCK_MONOTONIC = 3;
-pub const CLOCK_THREAD_CPUTIME_ID = 4;
-
-pub const MAP_FAILED = @intToPtr(*c_void, maxInt(usize));
-pub const MAP_SHARED = 0x0001;
-pub const MAP_PRIVATE = 0x0002;
-pub const MAP_FIXED = 0x0010;
-pub const MAP_RENAME = 0;
-pub const MAP_NORESERVE = 0;
-pub const MAP_INHERIT = 0;
-pub const MAP_HASSEMAPHORE = 0;
-pub const MAP_TRYFIXED = 0;
-
-pub const MAP_FILE = 0;
-pub const MAP_ANON = 0x1000;
-pub const MAP_ANONYMOUS = MAP_ANON;
-pub const MAP_STACK = 0x4000;
-pub const MAP_CONCEAL = 0x8000;
-
-pub const WNOHANG = 1;
-pub const WUNTRACED = 2;
-pub const WCONTINUED = 8;
-
-pub const SA_ONSTACK = 0x0001;
-pub const SA_RESTART = 0x0002;
-pub const SA_RESETHAND = 0x0004;
-pub const SA_NOCLDSTOP = 0x0008;
-pub const SA_NODEFER = 0x0010;
-pub const SA_NOCLDWAIT = 0x0020;
-pub const SA_SIGINFO = 0x0040;
-
-pub const SIGHUP = 1;
-pub const SIGINT = 2;
-pub const SIGQUIT = 3;
-pub const SIGILL = 4;
-pub const SIGTRAP = 5;
-pub const SIGABRT = 6;
-pub const SIGIOT = SIGABRT;
-pub const SIGEMT = 7;
-pub const SIGFPE = 8;
-pub const SIGKILL = 9;
-pub const SIGBUS = 10;
-pub const SIGSEGV = 11;
-pub const SIGSYS = 12;
-pub const SIGPIPE = 13;
-pub const SIGALRM = 14;
-pub const SIGTERM = 15;
-pub const SIGURG = 16;
-pub const SIGSTOP = 17;
-pub const SIGTSTP = 18;
-pub const SIGCONT = 19;
-pub const SIGCHLD = 20;
-pub const SIGTTIN = 21;
-pub const SIGTTOU = 22;
-pub const SIGIO = 23;
-pub const SIGXCPU = 24;
-pub const SIGXFSZ = 25;
-pub const SIGVTALRM = 26;
-pub const SIGPROF = 27;
-pub const SIGWINCH = 28;
-pub const SIGINFO = 29;
-pub const SIGUSR1 = 30;
-pub const SIGUSR2 = 31;
-pub const SIGPWR = 32;
-
-// access function
-pub const F_OK = 0; // test for existence of file
-pub const X_OK = 1; // test for execute or search permission
-pub const W_OK = 2; // test for write permission
-pub const R_OK = 4; // test for read permission
-
-/// open for reading only
-pub const O_RDONLY = 0x00000000;
-
-/// open for writing only
-pub const O_WRONLY = 0x00000001;
-
-/// open for reading and writing
-pub const O_RDWR = 0x00000002;
-
-/// mask for above modes
-pub const O_ACCMODE = 0x00000003;
-
-/// no delay
-pub const O_NONBLOCK = 0x00000004;
-
-/// set append mode
-pub const O_APPEND = 0x00000008;
-
-/// open with shared file lock
-pub const O_SHLOCK = 0x00000010;
-
-/// open with exclusive file lock
-pub const O_EXLOCK = 0x00000020;
-
-/// signal pgrp when data ready
-pub const O_ASYNC = 0x00000040;
-
-/// synchronous writes
-pub const O_SYNC = 0x00000080;
-
-/// don't follow symlinks on the last
-pub const O_NOFOLLOW = 0x00000100;
-
-/// create if nonexistent
-pub const O_CREAT = 0x00000200;
-
-/// truncate to zero length
-pub const O_TRUNC = 0x00000400;
-
-/// error if already exists
-pub const O_EXCL = 0x00000800;
-
-/// don't assign controlling terminal
-pub const O_NOCTTY = 0x00008000;
-
-/// write: I/O data completion
-pub const O_DSYNC = O_SYNC;
-
-/// read: I/O completion as for write
-pub const O_RSYNC = O_SYNC;
-
-/// fail if not a directory
-pub const O_DIRECTORY = 0x20000;
-
-/// set close on exec
-pub const O_CLOEXEC = 0x10000;
-
-pub const F_DUPFD = 0;
-pub const F_GETFD = 1;
-pub const F_SETFD = 2;
-pub const F_GETFL = 3;
-pub const F_SETFL = 4;
-
-pub const F_GETOWN = 5;
-pub const F_SETOWN = 6;
-
-pub const F_GETLK = 7;
-pub const F_SETLK = 8;
-pub const F_SETLKW = 9;
-
-pub const F_RDLCK = 1;
-pub const F_UNLCK = 2;
-pub const F_WRLCK = 3;
-
-pub const LOCK_SH = 0x01;
-pub const LOCK_EX = 0x02;
-pub const LOCK_NB = 0x04;
-pub const LOCK_UN = 0x08;
-
-pub const FD_CLOEXEC = 1;
-
-pub const SEEK_SET = 0;
-pub const SEEK_CUR = 1;
-pub const SEEK_END = 2;
-
-pub const SIG_BLOCK = 1;
-pub const SIG_UNBLOCK = 2;
-pub const SIG_SETMASK = 3;
-
-pub const SOCK_STREAM = 1;
-pub const SOCK_DGRAM = 2;
-pub const SOCK_RAW = 3;
-pub const SOCK_RDM = 4;
-pub const SOCK_SEQPACKET = 5;
-
-pub const SOCK_CLOEXEC = 0x8000;
-pub const SOCK_NONBLOCK = 0x4000;
-
-pub const SO_DEBUG = 0x0001;
-pub const SO_ACCEPTCONN = 0x0002;
-pub const SO_REUSEADDR = 0x0004;
-pub const SO_KEEPALIVE = 0x0008;
-pub const SO_DONTROUTE = 0x0010;
-pub const SO_BROADCAST = 0x0020;
-pub const SO_USELOOPBACK = 0x0040;
-pub const SO_LINGER = 0x0080;
-pub const SO_OOBINLINE = 0x0100;
-pub const SO_REUSEPORT = 0x0200;
-pub const SO_TIMESTAMP = 0x0800;
-pub const SO_BINDANY = 0x1000;
-pub const SO_ZEROIZE = 0x2000;
-pub const SO_SNDBUF = 0x1001;
-pub const SO_RCVBUF = 0x1002;
-pub const SO_SNDLOWAT = 0x1003;
-pub const SO_RCVLOWAT = 0x1004;
-pub const SO_SNDTIMEO = 0x1005;
-pub const SO_RCVTIMEO = 0x1006;
-pub const SO_ERROR = 0x1007;
-pub const SO_TYPE = 0x1008;
-pub const SO_NETPROC = 0x1020;
-pub const SO_RTABLE = 0x1021;
-pub const SO_PEERCRED = 0x1022;
-pub const SO_SPLICE = 0x1023;
-pub const SO_DOMAIN = 0x1024;
-pub const SO_PROTOCOL = 0x1025;
-
-pub const SOL_SOCKET = 0xffff;
-
-pub const PF_UNSPEC = AF_UNSPEC;
-pub const PF_LOCAL = AF_LOCAL;
-pub const PF_UNIX = AF_UNIX;
-pub const PF_INET = AF_INET;
-pub const PF_APPLETALK = AF_APPLETALK;
-pub const PF_INET6 = AF_INET6;
-pub const PF_DECnet = AF_DECnet;
-pub const PF_KEY = AF_KEY;
-pub const PF_ROUTE = AF_ROUTE;
-pub const PF_SNA = AF_SNA;
-pub const PF_MPLS = AF_MPLS;
-pub const PF_BLUETOOTH = AF_BLUETOOTH;
-pub const PF_ISDN = AF_ISDN;
-pub const PF_MAX = AF_MAX;
-
-pub const AF_UNSPEC = 0;
-pub const AF_UNIX = 1;
-pub const AF_LOCAL = AF_UNIX;
-pub const AF_INET = 2;
-pub const AF_APPLETALK = 16;
-pub const AF_INET6 = 24;
-pub const AF_KEY = 30;
-pub const AF_ROUTE = 17;
-pub const AF_SNA = 11;
-pub const AF_MPLS = 33;
-pub const AF_BLUETOOTH = 32;
-pub const AF_ISDN = 26;
-pub const AF_MAX = 36;
-
-pub const DT_UNKNOWN = 0;
-pub const DT_FIFO = 1;
-pub const DT_CHR = 2;
-pub const DT_DIR = 4;
-pub const DT_BLK = 6;
-pub const DT_REG = 8;
-pub const DT_LNK = 10;
-pub const DT_SOCK = 12;
-pub const DT_WHT = 14; // XXX
-
-pub const EV_ADD = 0x0001;
-pub const EV_DELETE = 0x0002;
-pub const EV_ENABLE = 0x0004;
-pub const EV_DISABLE = 0x0008;
-pub const EV_ONESHOT = 0x0010;
-pub const EV_CLEAR = 0x0020;
-pub const EV_RECEIPT = 0x0040;
-pub const EV_DISPATCH = 0x0080;
-pub const EV_FLAG1 = 0x2000;
-pub const EV_ERROR = 0x4000;
-pub const EV_EOF = 0x8000;
-
-pub const EVFILT_READ = -1;
-pub const EVFILT_WRITE = -2;
-pub const EVFILT_AIO = -3;
-pub const EVFILT_VNODE = -4;
-pub const EVFILT_PROC = -5;
-pub const EVFILT_SIGNAL = -6;
-pub const EVFILT_TIMER = -7;
-pub const EVFILT_EXCEPT = -9;
-
-// data/hint flags for EVFILT_{READ|WRITE}
-pub const NOTE_LOWAT = 0x0001;
-pub const NOTE_EOF = 0x0002;
-
-// data/hint flags for EVFILT_EXCEPT and EVFILT_{READ|WRITE}
-pub const NOTE_OOB = 0x0004;
-
-// data/hint flags for EVFILT_VNODE
-pub const NOTE_DELETE = 0x0001;
-pub const NOTE_WRITE = 0x0002;
-pub const NOTE_EXTEND = 0x0004;
-pub const NOTE_ATTRIB = 0x0008;
-pub const NOTE_LINK = 0x0010;
-pub const NOTE_RENAME = 0x0020;
-pub const NOTE_REVOKE = 0x0040;
-pub const NOTE_TRUNCATE = 0x0080;
-
-// data/hint flags for EVFILT_PROC
-pub const NOTE_EXIT = 0x80000000;
-pub const NOTE_FORK = 0x40000000;
-pub const NOTE_EXEC = 0x20000000;
-pub const NOTE_PDATAMASK = 0x000fffff;
-pub const NOTE_PCTRLMASK = 0xf0000000;
-pub const NOTE_TRACK = 0x00000001;
-pub const NOTE_TRACKERR = 0x00000002;
-pub const NOTE_CHILD = 0x00000004;
-
-// data/hint flags for EVFILT_DEVICE
-pub const NOTE_CHANGE = 0x00000001;
-
-pub const TIOCCBRK = 0x2000747a;
-pub const TIOCCDTR = 0x20007478;
-pub const TIOCCONS = 0x80047462;
-pub const TIOCDCDTIMESTAMP = 0x40107458;
-pub const TIOCDRAIN = 0x2000745e;
-pub const TIOCEXCL = 0x2000740d;
-pub const TIOCEXT = 0x80047460;
-pub const TIOCFLAG_CDTRCTS = 0x10;
-pub const TIOCFLAG_CLOCAL = 0x2;
-pub const TIOCFLAG_CRTSCTS = 0x4;
-pub const TIOCFLAG_MDMBUF = 0x8;
-pub const TIOCFLAG_SOFTCAR = 0x1;
-pub const TIOCFLUSH = 0x80047410;
-pub const TIOCGETA = 0x402c7413;
-pub const TIOCGETD = 0x4004741a;
-pub const TIOCGFLAGS = 0x4004745d;
-pub const TIOCGLINED = 0x40207442;
-pub const TIOCGPGRP = 0x40047477;
-pub const TIOCGQSIZE = 0x40047481;
-pub const TIOCGRANTPT = 0x20007447;
-pub const TIOCGSID = 0x40047463;
-pub const TIOCGSIZE = 0x40087468;
-pub const TIOCGWINSZ = 0x40087468;
-pub const TIOCMBIC = 0x8004746b;
-pub const TIOCMBIS = 0x8004746c;
-pub const TIOCMGET = 0x4004746a;
-pub const TIOCMSET = 0x8004746d;
-pub const TIOCM_CAR = 0x40;
-pub const TIOCM_CD = 0x40;
-pub const TIOCM_CTS = 0x20;
-pub const TIOCM_DSR = 0x100;
-pub const TIOCM_DTR = 0x2;
-pub const TIOCM_LE = 0x1;
-pub const TIOCM_RI = 0x80;
-pub const TIOCM_RNG = 0x80;
-pub const TIOCM_RTS = 0x4;
-pub const TIOCM_SR = 0x10;
-pub const TIOCM_ST = 0x8;
-pub const TIOCNOTTY = 0x20007471;
-pub const TIOCNXCL = 0x2000740e;
-pub const TIOCOUTQ = 0x40047473;
-pub const TIOCPKT = 0x80047470;
-pub const TIOCPKT_DATA = 0x0;
-pub const TIOCPKT_DOSTOP = 0x20;
-pub const TIOCPKT_FLUSHREAD = 0x1;
-pub const TIOCPKT_FLUSHWRITE = 0x2;
-pub const TIOCPKT_IOCTL = 0x40;
-pub const TIOCPKT_NOSTOP = 0x10;
-pub const TIOCPKT_START = 0x8;
-pub const TIOCPKT_STOP = 0x4;
-pub const TIOCPTMGET = 0x40287446;
-pub const TIOCPTSNAME = 0x40287448;
-pub const TIOCRCVFRAME = 0x80087445;
-pub const TIOCREMOTE = 0x80047469;
-pub const TIOCSBRK = 0x2000747b;
-pub const TIOCSCTTY = 0x20007461;
-pub const TIOCSDTR = 0x20007479;
-pub const TIOCSETA = 0x802c7414;
-pub const TIOCSETAF = 0x802c7416;
-pub const TIOCSETAW = 0x802c7415;
-pub const TIOCSETD = 0x8004741b;
-pub const TIOCSFLAGS = 0x8004745c;
-pub const TIOCSIG = 0x2000745f;
-pub const TIOCSLINED = 0x80207443;
-pub const TIOCSPGRP = 0x80047476;
-pub const TIOCSQSIZE = 0x80047480;
-pub const TIOCSSIZE = 0x80087467;
-pub const TIOCSTART = 0x2000746e;
-pub const TIOCSTAT = 0x80047465;
-pub const TIOCSTI = 0x80017472;
-pub const TIOCSTOP = 0x2000746f;
-pub const TIOCSWINSZ = 0x80087467;
-pub const TIOCUCNTL = 0x80047466;
-pub const TIOCXMTFRAME = 0x80087444;
-
-pub fn WEXITSTATUS(s: u32) u8 {
- return @intCast(u8, (s >> 8) & 0xff);
-}
-pub fn WTERMSIG(s: u32) u32 {
- return (s & 0x7f);
-}
-pub fn WSTOPSIG(s: u32) u32 {
- return WEXITSTATUS(s);
-}
-pub fn WIFEXITED(s: u32) bool {
- return WTERMSIG(s) == 0;
-}
-
-pub fn WIFCONTINUED(s: u32) bool {
- return ((s & 0o177777) == 0o177777);
-}
-
-pub fn WIFSTOPPED(s: u32) bool {
- return (s & 0xff == 0o177);
-}
-
-pub fn WIFSIGNALED(s: u32) bool {
- return (((s) & 0o177) != 0o177) and (((s) & 0o177) != 0);
-}
-
-pub const winsize = extern struct {
- ws_row: c_ushort,
- ws_col: c_ushort,
- ws_xpixel: c_ushort,
- ws_ypixel: c_ushort,
-};
-
-const NSIG = 33;
-
-pub const SIG_DFL = @intToPtr(?Sigaction.sigaction_fn, 0);
-pub const SIG_IGN = @intToPtr(?Sigaction.sigaction_fn, 1);
-pub const SIG_ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize));
-pub const SIG_CATCH = @intToPtr(?Sigaction.sigaction_fn, 2);
-pub const SIG_HOLD = @intToPtr(?Sigaction.sigaction_fn, 3);
-
-/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.
-pub const Sigaction = extern struct {
- pub const handler_fn = fn (c_int) callconv(.C) void;
- pub const sigaction_fn = fn (c_int, *const siginfo_t, ?*const c_void) callconv(.C) void;
-
- /// signal handler
- handler: extern union {
- handler: ?handler_fn,
- sigaction: ?sigaction_fn,
- },
- /// signal mask to apply
- mask: sigset_t,
- /// signal options
- flags: c_uint,
-};
-
-pub const sigval = extern union {
- int: c_int,
- ptr: ?*c_void,
-};
-
-pub const siginfo_t = extern struct {
- signo: c_int,
- code: c_int,
- errno: c_int,
- data: extern union {
- proc: extern struct {
- pid: pid_t,
- pdata: extern union {
- kill: extern struct {
- uid: uid_t,
- value: sigval,
- },
- cld: extern struct {
- utime: clock_t,
- stime: clock_t,
- status: c_int,
- },
- },
- },
- fault: extern struct {
- addr: ?*c_void,
- trapno: c_int,
- },
- __pad: [128 - 3 * @sizeOf(c_int)]u8,
- },
-};
-
-comptime {
- if (@sizeOf(usize) == 4)
- std.debug.assert(@sizeOf(siginfo_t) == 128)
- else
- // Take into account the padding between errno and data fields.
- std.debug.assert(@sizeOf(siginfo_t) == 136);
-}
-
-pub usingnamespace switch (builtin.target.cpu.arch) {
- .x86_64 => struct {
- pub const ucontext_t = extern struct {
- sc_rdi: c_long,
- sc_rsi: c_long,
- sc_rdx: c_long,
- sc_rcx: c_long,
- sc_r8: c_long,
- sc_r9: c_long,
- sc_r10: c_long,
- sc_r11: c_long,
- sc_r12: c_long,
- sc_r13: c_long,
- sc_r14: c_long,
- sc_r15: c_long,
- sc_rbp: c_long,
- sc_rbx: c_long,
- sc_rax: c_long,
- sc_gs: c_long,
- sc_fs: c_long,
- sc_es: c_long,
- sc_ds: c_long,
- sc_trapno: c_long,
- sc_err: c_long,
- sc_rip: c_long,
- sc_cs: c_long,
- sc_rflags: c_long,
- sc_rsp: c_long,
- sc_ss: c_long,
-
- sc_fpstate: fxsave64,
- __sc_unused: c_int,
- sc_mask: c_int,
- sc_cookie: c_long,
- };
-
- pub const fxsave64 = packed struct {
- fx_fcw: u16,
- fx_fsw: u16,
- fx_ftw: u8,
- fx_unused1: u8,
- fx_fop: u16,
- fx_rip: u64,
- fx_rdp: u64,
- fx_mxcsr: u32,
- fx_mxcsr_mask: u32,
- fx_st: [8][2]u64,
- fx_xmm: [16][2]u64,
- fx_unused3: [96]u8,
- };
- },
- else => struct {},
-};
-
-pub const sigset_t = c_uint;
-pub const empty_sigset: sigset_t = 0;
-
-pub const E = enum(u16) {
- /// No error occurred.
- SUCCESS = 0,
- PERM = 1, // Operation not permitted
- NOENT = 2, // No such file or directory
- SRCH = 3, // No such process
- INTR = 4, // Interrupted system call
- IO = 5, // Input/output error
- NXIO = 6, // Device not configured
- @"2BIG" = 7, // Argument list too long
- NOEXEC = 8, // Exec format error
- BADF = 9, // Bad file descriptor
- CHILD = 10, // No child processes
- DEADLK = 11, // Resource deadlock avoided
- // 11 was AGAIN
- NOMEM = 12, // Cannot allocate memory
- ACCES = 13, // Permission denied
- FAULT = 14, // Bad address
- NOTBLK = 15, // Block device required
- BUSY = 16, // Device busy
- EXIST = 17, // File exists
- XDEV = 18, // Cross-device link
- NODEV = 19, // Operation not supported by device
- NOTDIR = 20, // Not a directory
- ISDIR = 21, // Is a directory
- INVAL = 22, // Invalid argument
- NFILE = 23, // Too many open files in system
- MFILE = 24, // Too many open files
- NOTTY = 25, // Inappropriate ioctl for device
- TXTBSY = 26, // Text file busy
- FBIG = 27, // File too large
- NOSPC = 28, // No space left on device
- SPIPE = 29, // Illegal seek
- ROFS = 30, // Read-only file system
- MLINK = 31, // Too many links
- PIPE = 32, // Broken pipe
-
- // math software
- DOM = 33, // Numerical argument out of domain
- RANGE = 34, // Result too large or too small
-
- // non-blocking and interrupt i/o
- // also: WOULDBLOCK: operation would block
- AGAIN = 35, // Resource temporarily unavailable
- INPROGRESS = 36, // Operation now in progress
- ALREADY = 37, // Operation already in progress
-
- // ipc/network software -- argument errors
- NOTSOCK = 38, // Socket operation on non-socket
- DESTADDRREQ = 39, // Destination address required
- MSGSIZE = 40, // Message too long
- PROTOTYPE = 41, // Protocol wrong type for socket
- NOPROTOOPT = 42, // Protocol option not available
- PROTONOSUPPORT = 43, // Protocol not supported
- SOCKTNOSUPPORT = 44, // Socket type not supported
- OPNOTSUPP = 45, // Operation not supported
- PFNOSUPPORT = 46, // Protocol family not supported
- AFNOSUPPORT = 47, // Address family not supported by protocol family
- ADDRINUSE = 48, // Address already in use
- ADDRNOTAVAIL = 49, // Can't assign requested address
-
- // ipc/network software -- operational errors
- NETDOWN = 50, // Network is down
- NETUNREACH = 51, // Network is unreachable
- NETRESET = 52, // Network dropped connection on reset
- CONNABORTED = 53, // Software caused connection abort
- CONNRESET = 54, // Connection reset by peer
- NOBUFS = 55, // No buffer space available
- ISCONN = 56, // Socket is already connected
- NOTCONN = 57, // Socket is not connected
- SHUTDOWN = 58, // Can't send after socket shutdown
- TOOMANYREFS = 59, // Too many references: can't splice
- TIMEDOUT = 60, // Operation timed out
- CONNREFUSED = 61, // Connection refused
-
- LOOP = 62, // Too many levels of symbolic links
- NAMETOOLONG = 63, // File name too long
-
- // should be rearranged
- HOSTDOWN = 64, // Host is down
- HOSTUNREACH = 65, // No route to host
- NOTEMPTY = 66, // Directory not empty
-
- // quotas & mush
- PROCLIM = 67, // Too many processes
- USERS = 68, // Too many users
- DQUOT = 69, // Disc quota exceeded
-
- // Network File System
- STALE = 70, // Stale NFS file handle
- REMOTE = 71, // Too many levels of remote in path
- BADRPC = 72, // RPC struct is bad
- RPCMISMATCH = 73, // RPC version wrong
- PROGUNAVAIL = 74, // RPC prog. not avail
- PROGMISMATCH = 75, // Program version wrong
- PROCUNAVAIL = 76, // Bad procedure for program
-
- NOLCK = 77, // No locks available
- NOSYS = 78, // Function not implemented
-
- FTYPE = 79, // Inappropriate file type or format
- AUTH = 80, // Authentication error
- NEEDAUTH = 81, // Need authenticator
- IPSEC = 82, // IPsec processing failure
- NOATTR = 83, // Attribute not found
-
- // Wide/multibyte-character handling, ISO/IEC 9899/AMD1:1995
- ILSEQ = 84, // Illegal byte sequence
-
- NOMEDIUM = 85, // No medium found
- MEDIUMTYPE = 86, // Wrong medium type
- OVERFLOW = 87, // Value too large to be stored in data type
- CANCELED = 88, // Operation canceled
- IDRM = 89, // Identifier removed
- NOMSG = 90, // No message of desired type
- NOTSUP = 91, // Not supported
- BADMSG = 92, // Bad or Corrupt message
- NOTRECOVERABLE = 93, // State not recoverable
- OWNERDEAD = 94, // Previous owner died
- PROTO = 95, // Protocol error
-
- _,
-};
-
-const _MAX_PAGE_SHIFT = switch (builtin.target.cpu.arch) {
- .i386 => 12,
- .sparcv9 => 13,
-};
-pub const MINSIGSTKSZ = 1 << _MAX_PAGE_SHIFT;
-pub const SIGSTKSZ = MINSIGSTKSZ + (1 << _MAX_PAGE_SHIFT) * 4;
-
-pub const SS_ONSTACK = 0x0001;
-pub const SS_DISABLE = 0x0004;
-
-pub const stack_t = extern struct {
- ss_sp: [*]u8,
- ss_size: usize,
- ss_flags: c_int,
-};
-
-pub const S_IFMT = 0o170000;
-
-pub const S_IFIFO = 0o010000;
-pub const S_IFCHR = 0o020000;
-pub const S_IFDIR = 0o040000;
-pub const S_IFBLK = 0o060000;
-pub const S_IFREG = 0o100000;
-pub const S_IFLNK = 0o120000;
-pub const S_IFSOCK = 0o140000;
-
-pub const S_ISUID = 0o4000;
-pub const S_ISGID = 0o2000;
-pub const S_ISVTX = 0o1000;
-pub const S_IRWXU = 0o700;
-pub const S_IRUSR = 0o400;
-pub const S_IWUSR = 0o200;
-pub const S_IXUSR = 0o100;
-pub const S_IRWXG = 0o070;
-pub const S_IRGRP = 0o040;
-pub const S_IWGRP = 0o020;
-pub const S_IXGRP = 0o010;
-pub const S_IRWXO = 0o007;
-pub const S_IROTH = 0o004;
-pub const S_IWOTH = 0o002;
-pub const S_IXOTH = 0o001;
-
-pub fn S_ISFIFO(m: u32) bool {
- return m & S_IFMT == S_IFIFO;
-}
-
-pub fn S_ISCHR(m: u32) bool {
- return m & S_IFMT == S_IFCHR;
-}
-
-pub fn S_ISDIR(m: u32) bool {
- return m & S_IFMT == S_IFDIR;
-}
-
-pub fn S_ISBLK(m: u32) bool {
- return m & S_IFMT == S_IFBLK;
-}
-
-pub fn S_ISREG(m: u32) bool {
- return m & S_IFMT == S_IFREG;
-}
-
-pub fn S_ISLNK(m: u32) bool {
- return m & S_IFMT == S_IFLNK;
-}
-
-pub fn S_ISSOCK(m: u32) bool {
- return m & S_IFMT == S_IFSOCK;
-}
-
-/// Magic value that specify the use of the current working directory
-/// to determine the target of relative file paths in the openat() and
-/// similar syscalls.
-pub const AT_FDCWD = -100;
-
-/// Check access using effective user and group ID
-pub const AT_EACCESS = 0x01;
-
-/// Do not follow symbolic links
-pub const AT_SYMLINK_NOFOLLOW = 0x02;
-
-/// Follow symbolic link
-pub const AT_SYMLINK_FOLLOW = 0x04;
-
-/// Remove directory instead of file
-pub const AT_REMOVEDIR = 0x08;
-
-pub const HOST_NAME_MAX = 255;
-
-/// dummy for IP
-pub const IPPROTO_IP = 0;
-
-/// IP6 hop-by-hop options
-pub const IPPROTO_HOPOPTS = IPPROTO_IP;
-
-/// control message protocol
-pub const IPPROTO_ICMP = 1;
-
-/// group mgmt protocol
-pub const IPPROTO_IGMP = 2;
-
-/// gateway^2 (deprecated)
-pub const IPPROTO_GGP = 3;
-
-/// IP header
-pub const IPPROTO_IPV4 = IPPROTO_IPIP;
-
-/// IP inside IP
-pub const IPPROTO_IPIP = 4;
-
-/// tcp
-pub const IPPROTO_TCP = 6;
-
-/// exterior gateway protocol
-pub const IPPROTO_EGP = 8;
-
-/// pup
-pub const IPPROTO_PUP = 12;
-
-/// user datagram protocol
-pub const IPPROTO_UDP = 17;
-
-/// xns idp
-pub const IPPROTO_IDP = 22;
-
-/// tp-4 w/ class negotiation
-pub const IPPROTO_TP = 29;
-
-/// IP6 header
-pub const IPPROTO_IPV6 = 41;
-
-/// IP6 routing header
-pub const IPPROTO_ROUTING = 43;
-
-/// IP6 fragmentation header
-pub const IPPROTO_FRAGMENT = 44;
-
-/// resource reservation
-pub const IPPROTO_RSVP = 46;
-
-/// GRE encaps RFC 1701
-pub const IPPROTO_GRE = 47;
-
-/// encap. security payload
-pub const IPPROTO_ESP = 50;
-
-/// authentication header
-pub const IPPROTO_AH = 51;
-
-/// IP Mobility RFC 2004
-pub const IPPROTO_MOBILE = 55;
-
-/// IPv6 ICMP
-pub const IPPROTO_IPV6_ICMP = 58;
-
-/// ICMP6
-pub const IPPROTO_ICMPV6 = 58;
-
-/// IP6 no next header
-pub const IPPROTO_NONE = 59;
-
-/// IP6 destination option
-pub const IPPROTO_DSTOPTS = 60;
-
-/// ISO cnlp
-pub const IPPROTO_EON = 80;
-
-/// Ethernet-in-IP
-pub const IPPROTO_ETHERIP = 97;
-
-/// encapsulation header
-pub const IPPROTO_ENCAP = 98;
-
-/// Protocol indep. multicast
-pub const IPPROTO_PIM = 103;
-
-/// IP Payload Comp. Protocol
-pub const IPPROTO_IPCOMP = 108;
-
-/// VRRP RFC 2338
-pub const IPPROTO_VRRP = 112;
-
-/// Common Address Resolution Protocol
-pub const IPPROTO_CARP = 112;
-
-/// PFSYNC
-pub const IPPROTO_PFSYNC = 240;
-
-/// raw IP packet
-pub const IPPROTO_RAW = 255;
-
-pub const rlimit_resource = enum(c_int) {
- CPU,
- FSIZE,
- DATA,
- STACK,
- CORE,
- RSS,
- MEMLOCK,
- NPROC,
- NOFILE,
-
- _,
-};
-
-pub const rlim_t = u64;
-
-/// No limit
-pub const RLIM_INFINITY: rlim_t = (1 << 63) - 1;
-
-pub const RLIM_SAVED_MAX = RLIM_INFINITY;
-pub const RLIM_SAVED_CUR = RLIM_INFINITY;
-
-pub const rlimit = extern struct {
- /// Soft limit
- cur: rlim_t,
- /// Hard limit
- max: rlim_t,
-};
-
-pub const SHUT_RD = 0;
-pub const SHUT_WR = 1;
-pub const SHUT_RDWR = 2;
-
-pub const nfds_t = c_uint;
-
-pub const pollfd = extern struct {
- fd: fd_t,
- events: c_short,
- revents: c_short,
-};
-
-pub const POLLIN = 0x0001;
-pub const POLLPRI = 0x0002;
-pub const POLLOUT = 0x0004;
-pub const POLLERR = 0x0008;
-pub const POLLHUP = 0x0010;
-pub const POLLNVAL = 0x0020;
-pub const POLLRDNORM = 0x0040;
-pub const POLLNORM = POLLRDNORM;
-pub const POLLWRNORM = POLLOUT;
-pub const POLLRDBAND = 0x0080;
-pub const POLLWRBAND = 0x0100;
-
-// sysctl mib
-pub const CTL_UNSPEC = 0;
-pub const CTL_KERN = 1;
-pub const CTL_VM = 2;
-pub const CTL_FS = 3;
-pub const CTL_NET = 4;
-pub const CTL_DEBUG = 5;
-pub const CTL_HW = 6;
-pub const CTL_MACHDEP = 7;
-
-pub const CTL_DDB = 9;
-pub const CTL_VFS = 10;
-
-pub const KERN_OSTYPE = 1;
-pub const KERN_OSRELEASE = 2;
-pub const KERN_OSREV = 3;
-pub const KERN_VERSION = 4;
-pub const KERN_MAXVNODES = 5;
-pub const KERN_MAXPROC = 6;
-pub const KERN_MAXFILES = 7;
-pub const KERN_ARGMAX = 8;
-pub const KERN_SECURELVL = 9;
-pub const KERN_HOSTNAME = 10;
-pub const KERN_HOSTID = 11;
-pub const KERN_CLOCKRATE = 12;
-
-pub const KERN_PROF = 16;
-pub const KERN_POSIX1 = 17;
-pub const KERN_NGROUPS = 18;
-pub const KERN_JOB_CONTROL = 19;
-pub const KERN_SAVED_IDS = 20;
-pub const KERN_BOOTTIME = 21;
-pub const KERN_DOMAINNAME = 22;
-pub const KERN_MAXPARTITIONS = 23;
-pub const KERN_RAWPARTITION = 24;
-pub const KERN_MAXTHREAD = 25;
-pub const KERN_NTHREADS = 26;
-pub const KERN_OSVERSION = 27;
-pub const KERN_SOMAXCONN = 28;
-pub const KERN_SOMINCONN = 29;
-
-pub const KERN_NOSUIDCOREDUMP = 32;
-pub const KERN_FSYNC = 33;
-pub const KERN_SYSVMSG = 34;
-pub const KERN_SYSVSEM = 35;
-pub const KERN_SYSVSHM = 36;
-
-pub const KERN_MSGBUFSIZE = 38;
-pub const KERN_MALLOCSTATS = 39;
-pub const KERN_CPTIME = 40;
-pub const KERN_NCHSTATS = 41;
-pub const KERN_FORKSTAT = 42;
-pub const KERN_NSELCOLL = 43;
-pub const KERN_TTY = 44;
-pub const KERN_CCPU = 45;
-pub const KERN_FSCALE = 46;
-pub const KERN_NPROCS = 47;
-pub const KERN_MSGBUF = 48;
-pub const KERN_POOL = 49;
-pub const KERN_STACKGAPRANDOM = 50;
-pub const KERN_SYSVIPC_INFO = 51;
-pub const KERN_ALLOWKMEM = 52;
-pub const KERN_WITNESSWATCH = 53;
-pub const KERN_SPLASSERT = 54;
-pub const KERN_PROC_ARGS = 55;
-pub const KERN_NFILES = 56;
-pub const KERN_TTYCOUNT = 57;
-pub const KERN_NUMVNODES = 58;
-pub const KERN_MBSTAT = 59;
-pub const KERN_WITNESS = 60;
-pub const KERN_SEMINFO = 61;
-pub const KERN_SHMINFO = 62;
-pub const KERN_INTRCNT = 63;
-pub const KERN_WATCHDOG = 64;
-pub const KERN_ALLOWDT = 65;
-pub const KERN_PROC = 66;
-pub const KERN_MAXCLUSTERS = 67;
-pub const KERN_EVCOUNT = 68;
-pub const KERN_TIMECOUNTER = 69;
-pub const KERN_MAXLOCKSPERUID = 70;
-pub const KERN_CPTIME2 = 71;
-pub const KERN_CACHEPCT = 72;
-pub const KERN_FILE = 73;
-pub const KERN_WXABORT = 74;
-pub const KERN_CONSDEV = 75;
-pub const KERN_NETLIVELOCKS = 76;
-pub const KERN_POOL_DEBUG = 77;
-pub const KERN_PROC_CWD = 78;
-pub const KERN_PROC_NOBROADCASTKILL = 79;
-pub const KERN_PROC_VMMAP = 80;
-pub const KERN_GLOBAL_PTRACE = 81;
-pub const KERN_CONSBUFSIZE = 82;
-pub const KERN_CONSBUF = 83;
-pub const KERN_AUDIO = 84;
-pub const KERN_CPUSTATS = 85;
-pub const KERN_PFSTATUS = 86;
-pub const KERN_TIMEOUT_STATS = 87;
-pub const KERN_UTC_OFFSET = 88;
-pub const KERN_VIDEO = 89;
-
-pub const HW_MACHINE = 1;
-pub const HW_MODEL = 2;
-pub const HW_NCPU = 3;
-pub const HW_BYTEORDER = 4;
-pub const HW_PHYSMEM = 5;
-pub const HW_USERMEM = 6;
-pub const HW_PAGESIZE = 7;
-pub const HW_DISKNAMES = 8;
-pub const HW_DISKSTATS = 9;
-pub const HW_DISKCOUNT = 10;
-pub const HW_SENSORS = 11;
-pub const HW_CPUSPEED = 12;
-pub const HW_SETPERF = 13;
-pub const HW_VENDOR = 14;
-pub const HW_PRODUCT = 15;
-pub const HW_VERSION = 16;
-pub const HW_SERIALNO = 17;
-pub const HW_UUID = 18;
-pub const HW_PHYSMEM64 = 19;
-pub const HW_USERMEM64 = 20;
-pub const HW_NCPUFOUND = 21;
-pub const HW_ALLOWPOWERDOWN = 22;
-pub const HW_PERFPOLICY = 23;
-pub const HW_SMT = 24;
-pub const HW_NCPUONLINE = 25;
-
-pub const KERN_PROC_ALL = 0;
-pub const KERN_PROC_PID = 1;
-pub const KERN_PROC_PGRP = 2;
-pub const KERN_PROC_SESSION = 3;
-pub const KERN_PROC_TTY = 4;
-pub const KERN_PROC_UID = 5;
-pub const KERN_PROC_RUID = 6;
-pub const KERN_PROC_KTHREAD = 7;
-pub const KERN_PROC_SHOW_THREADS = 0x40000000;
-
-pub const KERN_PROC_ARGV = 1;
-pub const KERN_PROC_NARGV = 2;
-pub const KERN_PROC_ENV = 3;
-pub const KERN_PROC_NENV = 4;
diff --git a/lib/std/os/bits/posix.zig b/lib/std/os/bits/posix.zig
deleted file mode 100644
index 6ffd2dcf6a06..000000000000
--- a/lib/std/os/bits/posix.zig
+++ /dev/null
@@ -1,28 +0,0 @@
-pub const iovec = extern struct {
- iov_base: [*]u8,
- iov_len: usize,
-};
-
-pub const iovec_const = extern struct {
- iov_base: [*]const u8,
- iov_len: usize,
-};
-
-// syslog
-
-/// system is unusable
-pub const LOG_EMERG = 0;
-/// action must be taken immediately
-pub const LOG_ALERT = 1;
-/// critical conditions
-pub const LOG_CRIT = 2;
-/// error conditions
-pub const LOG_ERR = 3;
-/// warning conditions
-pub const LOG_WARNING = 4;
-/// normal but significant condition
-pub const LOG_NOTICE = 5;
-/// informational
-pub const LOG_INFO = 6;
-/// debug-level messages
-pub const LOG_DEBUG = 7;
diff --git a/lib/std/os/bits/wasi.zig b/lib/std/os/bits/wasi.zig
deleted file mode 100644
index 567d74961ef8..000000000000
--- a/lib/std/os/bits/wasi.zig
+++ /dev/null
@@ -1,490 +0,0 @@
-// Convenience types and consts used by std.os module
-const builtin = @import("builtin");
-const posix = @import("posix.zig");
-pub const iovec = posix.iovec;
-pub const iovec_const = posix.iovec_const;
-
-pub const STDIN_FILENO = 0;
-pub const STDOUT_FILENO = 1;
-pub const STDERR_FILENO = 2;
-
-pub const mode_t = u32;
-
-pub const time_t = i64; // match https://github.com/CraneStation/wasi-libc
-
-pub const timespec = struct {
- tv_sec: time_t,
- tv_nsec: isize,
-
- pub fn fromTimestamp(tm: timestamp_t) timespec {
- const tv_sec: timestamp_t = tm / 1_000_000_000;
- const tv_nsec = tm - tv_sec * 1_000_000_000;
- return timespec{
- .tv_sec = @intCast(time_t, tv_sec),
- .tv_nsec = @intCast(isize, tv_nsec),
- };
- }
-
- pub fn toTimestamp(ts: timespec) timestamp_t {
- const tm = @intCast(timestamp_t, ts.tv_sec * 1_000_000_000) + @intCast(timestamp_t, ts.tv_nsec);
- return tm;
- }
-};
-
-pub const kernel_stat = struct {
- dev: device_t,
- ino: inode_t,
- mode: mode_t,
- filetype: filetype_t,
- nlink: linkcount_t,
- size: filesize_t,
- atim: timespec,
- mtim: timespec,
- ctim: timespec,
-
- const Self = @This();
-
- pub fn fromFilestat(stat: filestat_t) Self {
- return Self{
- .dev = stat.dev,
- .ino = stat.ino,
- .mode = 0,
- .filetype = stat.filetype,
- .nlink = stat.nlink,
- .size = stat.size,
- .atim = stat.atime(),
- .mtim = stat.mtime(),
- .ctim = stat.ctime(),
- };
- }
-
- pub fn atime(self: Self) timespec {
- return self.atim;
- }
-
- pub fn mtime(self: Self) timespec {
- return self.mtim;
- }
-
- pub fn ctime(self: Self) timespec {
- return self.ctim;
- }
-};
-
-pub const IOV_MAX = 1024;
-
-pub const AT_REMOVEDIR: u32 = 0x4;
-pub const AT_FDCWD: fd_t = -2;
-
-// As defined in the wasi_snapshot_preview1 spec file:
-// https://github.com/WebAssembly/WASI/blob/master/phases/snapshot/witx/typenames.witx
-pub const advice_t = u8;
-pub const ADVICE_NORMAL: advice_t = 0;
-pub const ADVICE_SEQUENTIAL: advice_t = 1;
-pub const ADVICE_RANDOM: advice_t = 2;
-pub const ADVICE_WILLNEED: advice_t = 3;
-pub const ADVICE_DONTNEED: advice_t = 4;
-pub const ADVICE_NOREUSE: advice_t = 5;
-
-pub const clockid_t = u32;
-pub const CLOCK_REALTIME: clockid_t = 0;
-pub const CLOCK_MONOTONIC: clockid_t = 1;
-pub const CLOCK_PROCESS_CPUTIME_ID: clockid_t = 2;
-pub const CLOCK_THREAD_CPUTIME_ID: clockid_t = 3;
-
-pub const device_t = u64;
-
-pub const dircookie_t = u64;
-pub const DIRCOOKIE_START: dircookie_t = 0;
-
-pub const dirnamlen_t = u32;
-
-pub const dirent_t = extern struct {
- d_next: dircookie_t,
- d_ino: inode_t,
- d_namlen: dirnamlen_t,
- d_type: filetype_t,
-};
-
-pub const errno_t = enum(u16) {
- SUCCESS = 0,
- @"2BIG" = 1,
- ACCES = 2,
- ADDRINUSE = 3,
- ADDRNOTAVAIL = 4,
- AFNOSUPPORT = 5,
- /// This is also the error code used for `WOULDBLOCK`.
- AGAIN = 6,
- ALREADY = 7,
- BADF = 8,
- BADMSG = 9,
- BUSY = 10,
- CANCELED = 11,
- CHILD = 12,
- CONNABORTED = 13,
- CONNREFUSED = 14,
- CONNRESET = 15,
- DEADLK = 16,
- DESTADDRREQ = 17,
- DOM = 18,
- DQUOT = 19,
- EXIST = 20,
- FAULT = 21,
- FBIG = 22,
- HOSTUNREACH = 23,
- IDRM = 24,
- ILSEQ = 25,
- INPROGRESS = 26,
- INTR = 27,
- INVAL = 28,
- IO = 29,
- ISCONN = 30,
- ISDIR = 31,
- LOOP = 32,
- MFILE = 33,
- MLINK = 34,
- MSGSIZE = 35,
- MULTIHOP = 36,
- NAMETOOLONG = 37,
- NETDOWN = 38,
- NETRESET = 39,
- NETUNREACH = 40,
- NFILE = 41,
- NOBUFS = 42,
- NODEV = 43,
- NOENT = 44,
- NOEXEC = 45,
- NOLCK = 46,
- NOLINK = 47,
- NOMEM = 48,
- NOMSG = 49,
- NOPROTOOPT = 50,
- NOSPC = 51,
- NOSYS = 52,
- NOTCONN = 53,
- NOTDIR = 54,
- NOTEMPTY = 55,
- NOTRECOVERABLE = 56,
- NOTSOCK = 57,
- /// This is also the code used for `NOTSUP`.
- OPNOTSUPP = 58,
- NOTTY = 59,
- NXIO = 60,
- OVERFLOW = 61,
- OWNERDEAD = 62,
- PERM = 63,
- PIPE = 64,
- PROTO = 65,
- PROTONOSUPPORT = 66,
- PROTOTYPE = 67,
- RANGE = 68,
- ROFS = 69,
- SPIPE = 70,
- SRCH = 71,
- STALE = 72,
- TIMEDOUT = 73,
- TXTBSY = 74,
- XDEV = 75,
- NOTCAPABLE = 76,
- _,
-};
-pub const E = errno_t;
-
-pub const event_t = extern struct {
- userdata: userdata_t,
- @"error": errno_t,
- @"type": eventtype_t,
- fd_readwrite: eventfdreadwrite_t,
-};
-
-pub const eventfdreadwrite_t = extern struct {
- nbytes: filesize_t,
- flags: eventrwflags_t,
-};
-
-pub const eventrwflags_t = u16;
-pub const EVENT_FD_READWRITE_HANGUP: eventrwflags_t = 0x0001;
-
-pub const eventtype_t = u8;
-pub const EVENTTYPE_CLOCK: eventtype_t = 0;
-pub const EVENTTYPE_FD_READ: eventtype_t = 1;
-pub const EVENTTYPE_FD_WRITE: eventtype_t = 2;
-
-pub const exitcode_t = u32;
-
-pub const fd_t = if (builtin.link_libc) c_int else u32;
-
-pub const fdflags_t = u16;
-pub const FDFLAG_APPEND: fdflags_t = 0x0001;
-pub const FDFLAG_DSYNC: fdflags_t = 0x0002;
-pub const FDFLAG_NONBLOCK: fdflags_t = 0x0004;
-pub const FDFLAG_RSYNC: fdflags_t = 0x0008;
-pub const FDFLAG_SYNC: fdflags_t = 0x0010;
-
-pub const fdstat_t = extern struct {
- fs_filetype: filetype_t,
- fs_flags: fdflags_t,
- fs_rights_base: rights_t,
- fs_rights_inheriting: rights_t,
-};
-
-pub const filedelta_t = i64;
-
-pub const filesize_t = u64;
-
-pub const filestat_t = extern struct {
- dev: device_t,
- ino: inode_t,
- filetype: filetype_t,
- nlink: linkcount_t,
- size: filesize_t,
- atim: timestamp_t,
- mtim: timestamp_t,
- ctim: timestamp_t,
-
- pub fn atime(self: filestat_t) timespec {
- return timespec.fromTimestamp(self.atim);
- }
-
- pub fn mtime(self: filestat_t) timespec {
- return timespec.fromTimestamp(self.mtim);
- }
-
- pub fn ctime(self: filestat_t) timespec {
- return timespec.fromTimestamp(self.ctim);
- }
-};
-
-pub const filetype_t = u8;
-pub const FILETYPE_UNKNOWN: filetype_t = 0;
-pub const FILETYPE_BLOCK_DEVICE: filetype_t = 1;
-pub const FILETYPE_CHARACTER_DEVICE: filetype_t = 2;
-pub const FILETYPE_DIRECTORY: filetype_t = 3;
-pub const FILETYPE_REGULAR_FILE: filetype_t = 4;
-pub const FILETYPE_SOCKET_DGRAM: filetype_t = 5;
-pub const FILETYPE_SOCKET_STREAM: filetype_t = 6;
-pub const FILETYPE_SYMBOLIC_LINK: filetype_t = 7;
-
-pub const fstflags_t = u16;
-pub const FILESTAT_SET_ATIM: fstflags_t = 0x0001;
-pub const FILESTAT_SET_ATIM_NOW: fstflags_t = 0x0002;
-pub const FILESTAT_SET_MTIM: fstflags_t = 0x0004;
-pub const FILESTAT_SET_MTIM_NOW: fstflags_t = 0x0008;
-
-pub const inode_t = u64;
-pub const ino_t = inode_t;
-
-pub const linkcount_t = u64;
-
-pub const lookupflags_t = u32;
-pub const LOOKUP_SYMLINK_FOLLOW: lookupflags_t = 0x00000001;
-
-pub usingnamespace if (builtin.link_libc) struct {
- // Derived from https://github.com/WebAssembly/wasi-libc/blob/main/expected/wasm32-wasi/predefined-macros.txt
- pub const O_ACCMODE = (O_EXEC | O_RDWR | O_SEARCH);
- pub const O_APPEND = FDFLAG_APPEND;
- pub const O_CLOEXEC = (0);
- pub const O_CREAT = ((1 << 0) << 12); // = __WASI_OFLAGS_CREAT << 12
- pub const O_DIRECTORY = ((1 << 1) << 12); // = __WASI_OFLAGS_DIRECTORY << 12
- pub const O_DSYNC = FDFLAG_DSYNC;
- pub const O_EXCL = ((1 << 2) << 12); // = __WASI_OFLAGS_EXCL << 12
- pub const O_EXEC = (0x02000000);
- pub const O_NOCTTY = (0);
- pub const O_NOFOLLOW = (0x01000000);
- pub const O_NONBLOCK = (1 << FDFLAG_NONBLOCK);
- pub const O_RDONLY = (0x04000000);
- pub const O_RDWR = (O_RDONLY | O_WRONLY);
- pub const O_RSYNC = (1 << FDFLAG_RSYNC);
- pub const O_SEARCH = (0x08000000);
- pub const O_SYNC = (1 << FDFLAG_SYNC);
- pub const O_TRUNC = ((1 << 3) << 12); // = __WASI_OFLAGS_TRUNC << 12
- pub const O_TTY_INIT = (0);
- pub const O_WRONLY = (0x10000000);
-} else struct {
- pub const oflags_t = u16;
- pub const O_CREAT: oflags_t = 0x0001;
- pub const O_DIRECTORY: oflags_t = 0x0002;
- pub const O_EXCL: oflags_t = 0x0004;
- pub const O_TRUNC: oflags_t = 0x0008;
-};
-
-pub const preopentype_t = u8;
-pub const PREOPENTYPE_DIR: preopentype_t = 0;
-
-pub const prestat_t = extern struct {
- pr_type: preopentype_t,
- u: prestat_u_t,
-};
-
-pub const prestat_dir_t = extern struct {
- pr_name_len: usize,
-};
-
-pub const prestat_u_t = extern union {
- dir: prestat_dir_t,
-};
-
-pub const riflags_t = u16;
-pub const SOCK_RECV_PEEK: riflags_t = 0x0001;
-pub const SOCK_RECV_WAITALL: riflags_t = 0x0002;
-
-pub const rights_t = u64;
-pub const RIGHT_FD_DATASYNC: rights_t = 0x0000000000000001;
-pub const RIGHT_FD_READ: rights_t = 0x0000000000000002;
-pub const RIGHT_FD_SEEK: rights_t = 0x0000000000000004;
-pub const RIGHT_FD_FDSTAT_SET_FLAGS: rights_t = 0x0000000000000008;
-pub const RIGHT_FD_SYNC: rights_t = 0x0000000000000010;
-pub const RIGHT_FD_TELL: rights_t = 0x0000000000000020;
-pub const RIGHT_FD_WRITE: rights_t = 0x0000000000000040;
-pub const RIGHT_FD_ADVISE: rights_t = 0x0000000000000080;
-pub const RIGHT_FD_ALLOCATE: rights_t = 0x0000000000000100;
-pub const RIGHT_PATH_CREATE_DIRECTORY: rights_t = 0x0000000000000200;
-pub const RIGHT_PATH_CREATE_FILE: rights_t = 0x0000000000000400;
-pub const RIGHT_PATH_LINK_SOURCE: rights_t = 0x0000000000000800;
-pub const RIGHT_PATH_LINK_TARGET: rights_t = 0x0000000000001000;
-pub const RIGHT_PATH_OPEN: rights_t = 0x0000000000002000;
-pub const RIGHT_FD_READDIR: rights_t = 0x0000000000004000;
-pub const RIGHT_PATH_READLINK: rights_t = 0x0000000000008000;
-pub const RIGHT_PATH_RENAME_SOURCE: rights_t = 0x0000000000010000;
-pub const RIGHT_PATH_RENAME_TARGET: rights_t = 0x0000000000020000;
-pub const RIGHT_PATH_FILESTAT_GET: rights_t = 0x0000000000040000;
-pub const RIGHT_PATH_FILESTAT_SET_SIZE: rights_t = 0x0000000000080000;
-pub const RIGHT_PATH_FILESTAT_SET_TIMES: rights_t = 0x0000000000100000;
-pub const RIGHT_FD_FILESTAT_GET: rights_t = 0x0000000000200000;
-pub const RIGHT_FD_FILESTAT_SET_SIZE: rights_t = 0x0000000000400000;
-pub const RIGHT_FD_FILESTAT_SET_TIMES: rights_t = 0x0000000000800000;
-pub const RIGHT_PATH_SYMLINK: rights_t = 0x0000000001000000;
-pub const RIGHT_PATH_REMOVE_DIRECTORY: rights_t = 0x0000000002000000;
-pub const RIGHT_PATH_UNLINK_FILE: rights_t = 0x0000000004000000;
-pub const RIGHT_POLL_FD_READWRITE: rights_t = 0x0000000008000000;
-pub const RIGHT_SOCK_SHUTDOWN: rights_t = 0x0000000010000000;
-pub const RIGHT_ALL: rights_t = RIGHT_FD_DATASYNC |
- RIGHT_FD_READ |
- RIGHT_FD_SEEK |
- RIGHT_FD_FDSTAT_SET_FLAGS |
- RIGHT_FD_SYNC |
- RIGHT_FD_TELL |
- RIGHT_FD_WRITE |
- RIGHT_FD_ADVISE |
- RIGHT_FD_ALLOCATE |
- RIGHT_PATH_CREATE_DIRECTORY |
- RIGHT_PATH_CREATE_FILE |
- RIGHT_PATH_LINK_SOURCE |
- RIGHT_PATH_LINK_TARGET |
- RIGHT_PATH_OPEN |
- RIGHT_FD_READDIR |
- RIGHT_PATH_READLINK |
- RIGHT_PATH_RENAME_SOURCE |
- RIGHT_PATH_RENAME_TARGET |
- RIGHT_PATH_FILESTAT_GET |
- RIGHT_PATH_FILESTAT_SET_SIZE |
- RIGHT_PATH_FILESTAT_SET_TIMES |
- RIGHT_FD_FILESTAT_GET |
- RIGHT_FD_FILESTAT_SET_SIZE |
- RIGHT_FD_FILESTAT_SET_TIMES |
- RIGHT_PATH_SYMLINK |
- RIGHT_PATH_REMOVE_DIRECTORY |
- RIGHT_PATH_UNLINK_FILE |
- RIGHT_POLL_FD_READWRITE |
- RIGHT_SOCK_SHUTDOWN;
-
-pub const roflags_t = u16;
-pub const SOCK_RECV_DATA_TRUNCATED: roflags_t = 0x0001;
-
-pub const sdflags_t = u8;
-pub const SHUT_RD: sdflags_t = 0x01;
-pub const SHUT_WR: sdflags_t = 0x02;
-
-pub const siflags_t = u16;
-
-pub const signal_t = u8;
-pub const SIGNONE: signal_t = 0;
-pub const SIGHUP: signal_t = 1;
-pub const SIGINT: signal_t = 2;
-pub const SIGQUIT: signal_t = 3;
-pub const SIGILL: signal_t = 4;
-pub const SIGTRAP: signal_t = 5;
-pub const SIGABRT: signal_t = 6;
-pub const SIGBUS: signal_t = 7;
-pub const SIGFPE: signal_t = 8;
-pub const SIGKILL: signal_t = 9;
-pub const SIGUSR1: signal_t = 10;
-pub const SIGSEGV: signal_t = 11;
-pub const SIGUSR2: signal_t = 12;
-pub const SIGPIPE: signal_t = 13;
-pub const SIGALRM: signal_t = 14;
-pub const SIGTERM: signal_t = 15;
-pub const SIGCHLD: signal_t = 16;
-pub const SIGCONT: signal_t = 17;
-pub const SIGSTOP: signal_t = 18;
-pub const SIGTSTP: signal_t = 19;
-pub const SIGTTIN: signal_t = 20;
-pub const SIGTTOU: signal_t = 21;
-pub const SIGURG: signal_t = 22;
-pub const SIGXCPU: signal_t = 23;
-pub const SIGXFSZ: signal_t = 24;
-pub const SIGVTALRM: signal_t = 25;
-pub const SIGPROF: signal_t = 26;
-pub const SIGWINCH: signal_t = 27;
-pub const SIGPOLL: signal_t = 28;
-pub const SIGPWR: signal_t = 29;
-pub const SIGSYS: signal_t = 30;
-
-pub const subclockflags_t = u16;
-pub const SUBSCRIPTION_CLOCK_ABSTIME: subclockflags_t = 0x0001;
-
-pub const subscription_t = extern struct {
- userdata: userdata_t,
- u: subscription_u_t,
-};
-
-pub const subscription_clock_t = extern struct {
- id: clockid_t,
- timeout: timestamp_t,
- precision: timestamp_t,
- flags: subclockflags_t,
-};
-
-pub const subscription_fd_readwrite_t = extern struct {
- fd: fd_t,
-};
-
-pub const subscription_u_t = extern struct {
- tag: eventtype_t,
- u: subscription_u_u_t,
-};
-
-pub const subscription_u_u_t = extern union {
- clock: subscription_clock_t,
- fd_read: subscription_fd_readwrite_t,
- fd_write: subscription_fd_readwrite_t,
-};
-
-pub const timestamp_t = u64;
-
-pub const userdata_t = u64;
-
-pub const whence_t = u8;
-pub const WHENCE_SET: whence_t = 0;
-pub const WHENCE_CUR: whence_t = 1;
-pub const WHENCE_END: whence_t = 2;
-
-pub const S_IEXEC = S_IXUSR;
-pub const S_IFBLK = 0x6000;
-pub const S_IFCHR = 0x2000;
-pub const S_IFDIR = 0x4000;
-pub const S_IFIFO = 0xc000;
-pub const S_IFLNK = 0xa000;
-pub const S_IFMT = S_IFBLK | S_IFCHR | S_IFDIR | S_IFIFO | S_IFLNK | S_IFREG | S_IFSOCK;
-pub const S_IFREG = 0x8000;
-// There's no concept of UNIX domain socket but we define this value here in order to line with other OSes.
-pub const S_IFSOCK = 0x1;
-
-pub const SEEK_SET = WHENCE_SET;
-pub const SEEK_CUR = WHENCE_CUR;
-pub const SEEK_END = WHENCE_END;
-
-pub const LOCK_SH = 0x1;
-pub const LOCK_EX = 0x2;
-pub const LOCK_NB = 0x4;
-pub const LOCK_UN = 0x8;
diff --git a/lib/std/os/bits/windows.zig b/lib/std/os/bits/windows.zig
deleted file mode 100644
index bb57a13ffebe..000000000000
--- a/lib/std/os/bits/windows.zig
+++ /dev/null
@@ -1,329 +0,0 @@
-// The reference for these types and values is Microsoft Windows's ucrt (Universal C RunTime).
-
-usingnamespace @import("../windows/bits.zig");
-const ws2_32 = @import("../windows/ws2_32.zig");
-
-// TODO: Stop using os.iovec in std.fs et al on Windows in the future
-const posix = @import("posix.zig");
-pub const iovec = posix.iovec;
-pub const iovec_const = posix.iovec_const;
-
-pub const fd_t = HANDLE;
-pub const ino_t = LARGE_INTEGER;
-pub const pid_t = HANDLE;
-pub const mode_t = u0;
-
-pub const PATH_MAX = 260;
-
-pub const time_t = c_longlong;
-
-pub const timespec = extern struct {
- tv_sec: time_t,
- tv_nsec: c_long,
-};
-
-pub const timeval = extern struct {
- tv_sec: c_long,
- tv_usec: c_long,
-};
-
-pub const sig_atomic_t = c_int;
-
-/// maximum signal number + 1
-pub const NSIG = 23;
-
-// Signal types
-
-/// interrupt
-pub const SIGINT = 2;
-
-/// illegal instruction - invalid function image
-pub const SIGILL = 4;
-
-/// floating point exception
-pub const SIGFPE = 8;
-
-/// segment violation
-pub const SIGSEGV = 11;
-
-/// Software termination signal from kill
-pub const SIGTERM = 15;
-
-/// Ctrl-Break sequence
-pub const SIGBREAK = 21;
-
-/// abnormal termination triggered by abort call
-pub const SIGABRT = 22;
-
-/// SIGABRT compatible with other platforms, same as SIGABRT
-pub const SIGABRT_COMPAT = 6;
-
-// Signal action codes
-
-/// default signal action
-pub const SIG_DFL = 0;
-
-/// ignore signal
-pub const SIG_IGN = 1;
-
-/// return current value
-pub const SIG_GET = 2;
-
-/// signal gets error
-pub const SIG_SGE = 3;
-
-/// acknowledge
-pub const SIG_ACK = 4;
-
-/// Signal error value (returned by signal call on error)
-pub const SIG_ERR = -1;
-
-pub const SEEK_SET = 0;
-pub const SEEK_CUR = 1;
-pub const SEEK_END = 2;
-
-pub const E = enum(u16) {
- /// No error occurred.
- SUCCESS = 0,
- PERM = 1,
- NOENT = 2,
- SRCH = 3,
- INTR = 4,
- IO = 5,
- NXIO = 6,
- @"2BIG" = 7,
- NOEXEC = 8,
- BADF = 9,
- CHILD = 10,
- AGAIN = 11,
- NOMEM = 12,
- ACCES = 13,
- FAULT = 14,
- BUSY = 16,
- EXIST = 17,
- XDEV = 18,
- NODEV = 19,
- NOTDIR = 20,
- ISDIR = 21,
- NFILE = 23,
- MFILE = 24,
- NOTTY = 25,
- FBIG = 27,
- NOSPC = 28,
- SPIPE = 29,
- ROFS = 30,
- MLINK = 31,
- PIPE = 32,
- DOM = 33,
- /// Also means `DEADLOCK`.
- DEADLK = 36,
- NAMETOOLONG = 38,
- NOLCK = 39,
- NOSYS = 40,
- NOTEMPTY = 41,
-
- INVAL = 22,
- RANGE = 34,
- ILSEQ = 42,
-
- // POSIX Supplement
- ADDRINUSE = 100,
- ADDRNOTAVAIL = 101,
- AFNOSUPPORT = 102,
- ALREADY = 103,
- BADMSG = 104,
- CANCELED = 105,
- CONNABORTED = 106,
- CONNREFUSED = 107,
- CONNRESET = 108,
- DESTADDRREQ = 109,
- HOSTUNREACH = 110,
- IDRM = 111,
- INPROGRESS = 112,
- ISCONN = 113,
- LOOP = 114,
- MSGSIZE = 115,
- NETDOWN = 116,
- NETRESET = 117,
- NETUNREACH = 118,
- NOBUFS = 119,
- NODATA = 120,
- NOLINK = 121,
- NOMSG = 122,
- NOPROTOOPT = 123,
- NOSR = 124,
- NOSTR = 125,
- NOTCONN = 126,
- NOTRECOVERABLE = 127,
- NOTSOCK = 128,
- NOTSUP = 129,
- OPNOTSUPP = 130,
- OTHER = 131,
- OVERFLOW = 132,
- OWNERDEAD = 133,
- PROTO = 134,
- PROTONOSUPPORT = 135,
- PROTOTYPE = 136,
- TIME = 137,
- TIMEDOUT = 138,
- TXTBSY = 139,
- WOULDBLOCK = 140,
- DQUOT = 10069,
- _,
-};
-
-pub const STRUNCATE = 80;
-
-pub const F_OK = 0;
-
-/// Remove directory instead of unlinking file
-pub const AT_REMOVEDIR = 0x200;
-
-pub const in_port_t = u16;
-pub const sa_family_t = ws2_32.ADDRESS_FAMILY;
-pub const socklen_t = ws2_32.socklen_t;
-
-pub const sockaddr = ws2_32.sockaddr;
-pub const sockaddr_in = ws2_32.sockaddr_in;
-pub const sockaddr_in6 = ws2_32.sockaddr_in6;
-pub const sockaddr_un = ws2_32.sockaddr_un;
-
-pub const in6_addr = [16]u8;
-pub const in_addr = u32;
-
-pub const addrinfo = ws2_32.addrinfo;
-
-pub const AF_UNSPEC = ws2_32.AF_UNSPEC;
-pub const AF_UNIX = ws2_32.AF_UNIX;
-pub const AF_INET = ws2_32.AF_INET;
-pub const AF_IMPLINK = ws2_32.AF_IMPLINK;
-pub const AF_PUP = ws2_32.AF_PUP;
-pub const AF_CHAOS = ws2_32.AF_CHAOS;
-pub const AF_NS = ws2_32.AF_NS;
-pub const AF_IPX = ws2_32.AF_IPX;
-pub const AF_ISO = ws2_32.AF_ISO;
-pub const AF_OSI = ws2_32.AF_OSI;
-pub const AF_ECMA = ws2_32.AF_ECMA;
-pub const AF_DATAKIT = ws2_32.AF_DATAKIT;
-pub const AF_CCITT = ws2_32.AF_CCITT;
-pub const AF_SNA = ws2_32.AF_SNA;
-pub const AF_DECnet = ws2_32.AF_DECnet;
-pub const AF_DLI = ws2_32.AF_DLI;
-pub const AF_LAT = ws2_32.AF_LAT;
-pub const AF_HYLINK = ws2_32.AF_HYLINK;
-pub const AF_APPLETALK = ws2_32.AF_APPLETALK;
-pub const AF_NETBIOS = ws2_32.AF_NETBIOS;
-pub const AF_VOICEVIEW = ws2_32.AF_VOICEVIEW;
-pub const AF_FIREFOX = ws2_32.AF_FIREFOX;
-pub const AF_UNKNOWN1 = ws2_32.AF_UNKNOWN1;
-pub const AF_BAN = ws2_32.AF_BAN;
-pub const AF_ATM = ws2_32.AF_ATM;
-pub const AF_INET6 = ws2_32.AF_INET6;
-pub const AF_CLUSTER = ws2_32.AF_CLUSTER;
-pub const AF_12844 = ws2_32.AF_12844;
-pub const AF_IRDA = ws2_32.AF_IRDA;
-pub const AF_NETDES = ws2_32.AF_NETDES;
-pub const AF_TCNPROCESS = ws2_32.AF_TCNPROCESS;
-pub const AF_TCNMESSAGE = ws2_32.AF_TCNMESSAGE;
-pub const AF_ICLFXBM = ws2_32.AF_ICLFXBM;
-pub const AF_BTH = ws2_32.AF_BTH;
-pub const AF_MAX = ws2_32.AF_MAX;
-
-pub const SOCK_STREAM = ws2_32.SOCK_STREAM;
-pub const SOCK_DGRAM = ws2_32.SOCK_DGRAM;
-pub const SOCK_RAW = ws2_32.SOCK_RAW;
-pub const SOCK_RDM = ws2_32.SOCK_RDM;
-pub const SOCK_SEQPACKET = ws2_32.SOCK_SEQPACKET;
-
-/// WARNING: this flag is not supported by windows socket functions directly,
-/// it is only supported by std.os.socket. Be sure that this value does
-/// not share any bits with any of the SOCK_* values.
-pub const SOCK_CLOEXEC = 0x10000;
-/// WARNING: this flag is not supported by windows socket functions directly,
-/// it is only supported by std.os.socket. Be sure that this value does
-/// not share any bits with any of the SOCK_* values.
-pub const SOCK_NONBLOCK = 0x20000;
-
-pub const IPPROTO_ICMP = ws2_32.IPPROTO_ICMP;
-pub const IPPROTO_IGMP = ws2_32.IPPROTO_IGMP;
-pub const BTHPROTO_RFCOMM = ws2_32.BTHPROTO_RFCOMM;
-pub const IPPROTO_TCP = ws2_32.IPPROTO_TCP;
-pub const IPPROTO_UDP = ws2_32.IPPROTO_UDP;
-pub const IPPROTO_ICMPV6 = ws2_32.IPPROTO_ICMPV6;
-pub const IPPROTO_RM = ws2_32.IPPROTO_RM;
-
-pub const nfds_t = c_ulong;
-pub const pollfd = ws2_32.pollfd;
-
-pub const POLLRDNORM = ws2_32.POLLRDNORM;
-pub const POLLRDBAND = ws2_32.POLLRDBAND;
-pub const POLLIN = ws2_32.POLLIN;
-pub const POLLPRI = ws2_32.POLLPRI;
-pub const POLLWRNORM = ws2_32.POLLWRNORM;
-pub const POLLOUT = ws2_32.POLLOUT;
-pub const POLLWRBAND = ws2_32.POLLWRBAND;
-pub const POLLERR = ws2_32.POLLERR;
-pub const POLLHUP = ws2_32.POLLHUP;
-pub const POLLNVAL = ws2_32.POLLNVAL;
-
-pub const SOL_SOCKET = ws2_32.SOL_SOCKET;
-
-pub const SO_DEBUG = ws2_32.SO_DEBUG;
-pub const SO_ACCEPTCONN = ws2_32.SO_ACCEPTCONN;
-pub const SO_REUSEADDR = ws2_32.SO_REUSEADDR;
-pub const SO_KEEPALIVE = ws2_32.SO_KEEPALIVE;
-pub const SO_DONTROUTE = ws2_32.SO_DONTROUTE;
-pub const SO_BROADCAST = ws2_32.SO_BROADCAST;
-pub const SO_USELOOPBACK = ws2_32.SO_USELOOPBACK;
-pub const SO_LINGER = ws2_32.SO_LINGER;
-pub const SO_OOBINLINE = ws2_32.SO_OOBINLINE;
-
-pub const SO_DONTLINGER = ws2_32.SO_DONTLINGER;
-pub const SO_EXCLUSIVEADDRUSE = ws2_32.SO_EXCLUSIVEADDRUSE;
-
-pub const SO_SNDBUF = ws2_32.SO_SNDBUF;
-pub const SO_RCVBUF = ws2_32.SO_RCVBUF;
-pub const SO_SNDLOWAT = ws2_32.SO_SNDLOWAT;
-pub const SO_RCVLOWAT = ws2_32.SO_RCVLOWAT;
-pub const SO_SNDTIMEO = ws2_32.SO_SNDTIMEO;
-pub const SO_RCVTIMEO = ws2_32.SO_RCVTIMEO;
-pub const SO_ERROR = ws2_32.SO_ERROR;
-pub const SO_TYPE = ws2_32.SO_TYPE;
-
-pub const SO_GROUP_ID = ws2_32.SO_GROUP_ID;
-pub const SO_GROUP_PRIORITY = ws2_32.SO_GROUP_PRIORITY;
-pub const SO_MAX_MSG_SIZE = ws2_32.SO_MAX_MSG_SIZE;
-pub const SO_PROTOCOL_INFOA = ws2_32.SO_PROTOCOL_INFOA;
-pub const SO_PROTOCOL_INFOW = ws2_32.SO_PROTOCOL_INFOW;
-
-pub const PVD_CONFIG = ws2_32.PVD_CONFIG;
-pub const SO_CONDITIONAL_ACCEPT = ws2_32.SO_CONDITIONAL_ACCEPT;
-
-pub const TCP_NODELAY = ws2_32.TCP_NODELAY;
-
-pub const O_RDONLY = 0o0;
-pub const O_WRONLY = 0o1;
-pub const O_RDWR = 0o2;
-
-pub const O_CREAT = 0o100;
-pub const O_EXCL = 0o200;
-pub const O_NOCTTY = 0o400;
-pub const O_TRUNC = 0o1000;
-pub const O_APPEND = 0o2000;
-pub const O_NONBLOCK = 0o4000;
-pub const O_DSYNC = 0o10000;
-pub const O_SYNC = 0o4010000;
-pub const O_RSYNC = 0o4010000;
-pub const O_DIRECTORY = 0o200000;
-pub const O_NOFOLLOW = 0o400000;
-pub const O_CLOEXEC = 0o2000000;
-
-pub const O_ASYNC = 0o20000;
-pub const O_DIRECT = 0o40000;
-pub const O_LARGEFILE = 0;
-pub const O_NOATIME = 0o1000000;
-pub const O_PATH = 0o10000000;
-pub const O_TMPFILE = 0o20200000;
-pub const O_NDELAY = O_NONBLOCK;
-
-pub const IFNAMESIZE = 30;
diff --git a/lib/std/os/darwin.zig b/lib/std/os/darwin.zig
deleted file mode 100644
index 5f9684b96de9..000000000000
--- a/lib/std/os/darwin.zig
+++ /dev/null
@@ -1,3 +0,0 @@
-const std = @import("../std.zig");
-pub usingnamespace std.c;
-pub usingnamespace @import("bits.zig");
diff --git a/lib/std/os/dragonfly.zig b/lib/std/os/dragonfly.zig
deleted file mode 100644
index 5f9684b96de9..000000000000
--- a/lib/std/os/dragonfly.zig
+++ /dev/null
@@ -1,3 +0,0 @@
-const std = @import("../std.zig");
-pub usingnamespace std.c;
-pub usingnamespace @import("bits.zig");
diff --git a/lib/std/os/freebsd.zig b/lib/std/os/freebsd.zig
deleted file mode 100644
index 5f9684b96de9..000000000000
--- a/lib/std/os/freebsd.zig
+++ /dev/null
@@ -1,3 +0,0 @@
-const std = @import("../std.zig");
-pub usingnamespace std.c;
-pub usingnamespace @import("bits.zig");
diff --git a/lib/std/os/haiku.zig b/lib/std/os/haiku.zig
deleted file mode 100644
index 5f9684b96de9..000000000000
--- a/lib/std/os/haiku.zig
+++ /dev/null
@@ -1,3 +0,0 @@
-const std = @import("../std.zig");
-pub usingnamespace std.c;
-pub usingnamespace @import("bits.zig");
diff --git a/lib/std/os/linux.zig b/lib/std/os/linux.zig
index 369fae8f5325..a5f49cda1c30 100644
--- a/lib/std/os/linux.zig
+++ b/lib/std/os/linux.zig
@@ -1,10 +1,10 @@
-// This file provides the system interface functions for Linux matching those
-// that are provided by libc, whether or not libc is linked. The following
-// abstractions are made:
-// * Work around kernel bugs and limitations. For example, see sendmmsg.
-// * Implement all the syscalls in the same way that libc functions will
-// provide `rename` when only the `renameat` syscall exists.
-// * Does not support POSIX thread cancellation.
+//! This file provides the system interface functions for Linux matching those
+//! that are provided by libc, whether or not libc is linked. The following
+//! abstractions are made:
+//! * Work around kernel bugs and limitations. For example, see sendmmsg.
+//! * Implement all the syscalls in the same way that libc functions will
+//! provide `rename` when only the `renameat` syscall exists.
+//! * Does not support POSIX thread cancellation.
const std = @import("../std.zig");
const assert = std.debug.assert;
const maxInt = std.math.maxInt;
@@ -13,13 +13,29 @@ const vdso = @import("linux/vdso.zig");
const dl = @import("../dynamic_library.zig");
const native_arch = std.Target.current.cpu.arch;
const native_endian = native_arch.endian();
+const is_mips = native_arch.isMIPS();
+const is_ppc = native_arch.isPPC();
+const is_ppc64 = native_arch.isPPC64();
+const is_sparc = native_arch.isSPARC();
+const iovec = std.os.iovec;
+const iovec_const = std.os.iovec_const;
-pub usingnamespace switch (native_arch) {
+test {
+ if (std.Target.current.os.tag == .linux) {
+ _ = @import("linux/test.zig");
+ }
+}
+
+const syscall_bits = switch (native_arch) {
+ .thumb => @import("linux/thumb.zig"),
+ else => arch_bits,
+};
+
+const arch_bits = switch (native_arch) {
.i386 => @import("linux/i386.zig"),
.x86_64 => @import("linux/x86_64.zig"),
.aarch64 => @import("linux/arm64.zig"),
- .arm => @import("linux/arm-eabi.zig"),
- .thumb => @import("linux/thumb.zig"),
+ .arm, .thumb => @import("linux/arm-eabi.zig"),
.riscv64 => @import("linux/riscv64.zig"),
.sparcv9 => @import("linux/sparc64.zig"),
.mips, .mipsel => @import("linux/mips.zig"),
@@ -27,10 +43,93 @@ pub usingnamespace switch (native_arch) {
.powerpc64, .powerpc64le => @import("linux/powerpc64.zig"),
else => struct {},
};
-pub usingnamespace @import("bits.zig");
+pub const syscall0 = syscall_bits.syscall0;
+pub const syscall1 = syscall_bits.syscall1;
+pub const syscall2 = syscall_bits.syscall2;
+pub const syscall3 = syscall_bits.syscall3;
+pub const syscall4 = syscall_bits.syscall4;
+pub const syscall5 = syscall_bits.syscall5;
+pub const syscall6 = syscall_bits.syscall6;
+pub const syscall7 = syscall_bits.syscall7;
+pub const restore = syscall_bits.restore;
+pub const restore_rt = syscall_bits.restore_rt;
+pub const socketcall = syscall_bits.socketcall;
+pub const syscall_pipe = syscall_bits.syscall_pipe;
+pub const syscall_fork = syscall_bits.syscall_fork;
+
+pub const ARCH = arch_bits.ARCH;
+pub const Elf_Symndx = arch_bits.Elf_Symndx;
+pub const F = arch_bits.F;
+pub const Flock = arch_bits.Flock;
+pub const HWCAP = arch_bits.HWCAP;
+pub const LOCK = arch_bits.LOCK;
+pub const MMAP2_UNIT = arch_bits.MMAP2_UNIT;
+pub const REG = arch_bits.REG;
+pub const SC = arch_bits.SC;
+pub const SYS = arch_bits.SYS;
+pub const Stat = arch_bits.Stat;
+pub const VDSO = arch_bits.VDSO;
+pub const blkcnt_t = arch_bits.blkcnt_t;
+pub const blksize_t = arch_bits.blksize_t;
+pub const clone = arch_bits.clone;
+pub const dev_t = arch_bits.dev_t;
+pub const ino_t = arch_bits.ino_t;
+pub const mcontext_t = arch_bits.mcontext_t;
+pub const mode_t = arch_bits.mode_t;
+pub const msghdr = arch_bits.msghdr;
+pub const msghdr_const = arch_bits.msghdr_const;
+pub const nlink_t = arch_bits.nlink_t;
+pub const off_t = arch_bits.off_t;
+pub const time_t = arch_bits.time_t;
+pub const timeval = arch_bits.timeval;
+pub const timezone = arch_bits.timezone;
+pub const ucontext_t = arch_bits.ucontext_t;
+pub const user_desc = arch_bits.user_desc;
+
pub const tls = @import("linux/tls.zig");
pub const pie = @import("linux/start_pie.zig");
pub const BPF = @import("linux/bpf.zig");
+
+pub const MAP = struct {
+ pub usingnamespace arch_bits.MAP;
+
+ /// Share changes
+ pub const SHARED = 0x01;
+ /// Changes are private
+ pub const PRIVATE = 0x02;
+ /// share + validate extension flags
+ pub const SHARED_VALIDATE = 0x03;
+ /// Mask for type of mapping
+ pub const TYPE = 0x0f;
+ /// Interpret addr exactly
+ pub const FIXED = 0x10;
+ /// don't use a file
+ pub const ANONYMOUS = if (is_mips) 0x800 else 0x20;
+ // MAP_ 0x0100 - 0x4000 flags are per architecture
+ /// populate (prefault) pagetables
+ pub const POPULATE = if (is_mips) 0x10000 else 0x8000;
+ /// do not block on IO
+ pub const NONBLOCK = if (is_mips) 0x20000 else 0x10000;
+ /// give out an address that is best suited for process/thread stacks
+ pub const STACK = if (is_mips) 0x40000 else 0x20000;
+ /// create a huge page mapping
+ pub const HUGETLB = if (is_mips) 0x80000 else 0x40000;
+ /// perform synchronous page faults for the mapping
+ pub const SYNC = 0x80000;
+ /// MAP_FIXED which doesn't unmap underlying mapping
+ pub const FIXED_NOREPLACE = 0x100000;
+ /// For anonymous mmap, memory could be uninitialized
+ pub const UNINITIALIZED = 0x4000000;
+};
+
+pub const O = struct {
+ pub usingnamespace arch_bits.O;
+
+ pub const RDONLY = 0o0;
+ pub const WRONLY = 0o1;
+ pub const RDWR = 0o2;
+};
+
pub usingnamespace @import("linux/io_uring.zig");
/// Set by startup code, used by `getauxval`.
@@ -102,7 +201,7 @@ pub fn dup2(old: i32, new: i32) usize {
} else {
if (old == new) {
if (std.debug.runtime_safety) {
- const rc = syscall2(.fcntl, @bitCast(usize, @as(isize, old)), F_GETFD);
+ const rc = syscall2(.fcntl, @bitCast(usize, @as(isize, old)), F.GETFD);
if (@bitCast(isize, rc) < 0) return rc;
}
return @intCast(usize, old);
@@ -138,7 +237,7 @@ pub fn fork() usize {
} else if (@hasField(SYS, "fork")) {
return syscall0(.fork);
} else {
- return syscall2(.clone, SIGCHLD, 0);
+ return syscall2(.clone, SIG.CHLD, 0);
}
}
@@ -229,7 +328,7 @@ pub fn readlink(noalias path: [*:0]const u8, noalias buf_ptr: [*]u8, buf_len: us
if (@hasField(SYS, "readlink")) {
return syscall3(.readlink, @ptrToInt(path), @ptrToInt(buf_ptr), buf_len);
} else {
- return syscall4(.readlinkat, @bitCast(usize, @as(isize, AT_FDCWD)), @ptrToInt(path), @ptrToInt(buf_ptr), buf_len);
+ return syscall4(.readlinkat, @bitCast(usize, @as(isize, AT.FDCWD)), @ptrToInt(path), @ptrToInt(buf_ptr), buf_len);
}
}
@@ -241,7 +340,7 @@ pub fn mkdir(path: [*:0]const u8, mode: u32) usize {
if (@hasField(SYS, "mkdir")) {
return syscall2(.mkdir, @ptrToInt(path), mode);
} else {
- return syscall3(.mkdirat, @bitCast(usize, @as(isize, AT_FDCWD)), @ptrToInt(path), mode);
+ return syscall3(.mkdirat, @bitCast(usize, @as(isize, AT.FDCWD)), @ptrToInt(path), mode);
}
}
@@ -253,7 +352,7 @@ pub fn mknod(path: [*:0]const u8, mode: u32, dev: u32) usize {
if (@hasField(SYS, "mknod")) {
return syscall3(.mknod, @ptrToInt(path), mode, dev);
} else {
- return mknodat(AT_FDCWD, path, mode, dev);
+ return mknodat(AT.FDCWD, path, mode, dev);
}
}
@@ -400,7 +499,7 @@ pub fn rmdir(path: [*:0]const u8) usize {
if (@hasField(SYS, "rmdir")) {
return syscall1(.rmdir, @ptrToInt(path));
} else {
- return syscall3(.unlinkat, @bitCast(usize, @as(isize, AT_FDCWD)), @ptrToInt(path), AT_REMOVEDIR);
+ return syscall3(.unlinkat, @bitCast(usize, @as(isize, AT.FDCWD)), @ptrToInt(path), AT.REMOVEDIR);
}
}
@@ -408,7 +507,7 @@ pub fn symlink(existing: [*:0]const u8, new: [*:0]const u8) usize {
if (@hasField(SYS, "symlink")) {
return syscall2(.symlink, @ptrToInt(existing), @ptrToInt(new));
} else {
- return syscall3(.symlinkat, @ptrToInt(existing), @bitCast(usize, @as(isize, AT_FDCWD)), @ptrToInt(new));
+ return syscall3(.symlinkat, @ptrToInt(existing), @bitCast(usize, @as(isize, AT.FDCWD)), @ptrToInt(new));
}
}
@@ -441,9 +540,12 @@ pub fn pread(fd: i32, buf: [*]u8, count: usize, offset: i64) usize {
}
} else {
// Some architectures (eg. 64bit SPARC) pread is called pread64.
- const S = if (!@hasField(SYS, "pread") and @hasField(SYS, "pread64")) .pread64 else .pread;
+ const syscall_number = if (!@hasField(SYS, "pread") and @hasField(SYS, "pread64"))
+ .pread64
+ else
+ .pread;
return syscall4(
- S,
+ syscall_number,
@bitCast(usize, @as(isize, fd)),
@ptrToInt(buf),
count,
@@ -456,7 +558,7 @@ pub fn access(path: [*:0]const u8, mode: u32) usize {
if (@hasField(SYS, "access")) {
return syscall2(.access, @ptrToInt(path), mode);
} else {
- return syscall4(.faccessat, @bitCast(usize, @as(isize, AT_FDCWD)), @ptrToInt(path), mode, 0);
+ return syscall4(.faccessat, @bitCast(usize, @as(isize, AT.FDCWD)), @ptrToInt(path), mode, 0);
}
}
@@ -536,9 +638,12 @@ pub fn pwrite(fd: i32, buf: [*]const u8, count: usize, offset: i64) usize {
}
} else {
// Some architectures (eg. 64bit SPARC) pwrite is called pwrite64.
- const S = if (!@hasField(SYS, "pwrite") and @hasField(SYS, "pwrite64")) .pwrite64 else .pwrite;
+ const syscall_number = if (!@hasField(SYS, "pwrite") and @hasField(SYS, "pwrite64"))
+ .pwrite64
+ else
+ .pwrite;
return syscall4(
- S,
+ syscall_number,
@bitCast(usize, @as(isize, fd)),
@ptrToInt(buf),
count,
@@ -551,9 +656,9 @@ pub fn rename(old: [*:0]const u8, new: [*:0]const u8) usize {
if (@hasField(SYS, "rename")) {
return syscall2(.rename, @ptrToInt(old), @ptrToInt(new));
} else if (@hasField(SYS, "renameat")) {
- return syscall4(.renameat, @bitCast(usize, @as(isize, AT_FDCWD)), @ptrToInt(old), @bitCast(usize, @as(isize, AT_FDCWD)), @ptrToInt(new));
+ return syscall4(.renameat, @bitCast(usize, @as(isize, AT.FDCWD)), @ptrToInt(old), @bitCast(usize, @as(isize, AT.FDCWD)), @ptrToInt(new));
} else {
- return syscall5(.renameat2, @bitCast(usize, @as(isize, AT_FDCWD)), @ptrToInt(old), @bitCast(usize, @as(isize, AT_FDCWD)), @ptrToInt(new), 0);
+ return syscall5(.renameat2, @bitCast(usize, @as(isize, AT.FDCWD)), @ptrToInt(old), @bitCast(usize, @as(isize, AT.FDCWD)), @ptrToInt(new), 0);
}
}
@@ -595,7 +700,7 @@ pub fn open(path: [*:0]const u8, flags: u32, perm: mode_t) usize {
} else {
return syscall4(
.openat,
- @bitCast(usize, @as(isize, AT_FDCWD)),
+ @bitCast(usize, @as(isize, AT.FDCWD)),
@ptrToInt(path),
flags,
perm,
@@ -608,7 +713,7 @@ pub fn create(path: [*:0]const u8, perm: mode_t) usize {
}
pub fn openat(dirfd: i32, path: [*:0]const u8, flags: u32, mode: mode_t) usize {
- // dirfd could be negative, for example AT_FDCWD is -100
+ // dirfd could be negative, for example AT.FDCWD is -100
return syscall4(.openat, @bitCast(usize, @as(isize, dirfd)), @ptrToInt(path), flags, mode);
}
@@ -682,9 +787,9 @@ pub fn link(oldpath: [*:0]const u8, newpath: [*:0]const u8, flags: i32) usize {
} else {
return syscall5(
.linkat,
- @bitCast(usize, @as(isize, AT_FDCWD)),
+ @bitCast(usize, @as(isize, AT.FDCWD)),
@ptrToInt(oldpath),
- @bitCast(usize, @as(isize, AT_FDCWD)),
+ @bitCast(usize, @as(isize, AT.FDCWD)),
@ptrToInt(newpath),
@bitCast(usize, @as(isize, flags)),
);
@@ -706,7 +811,7 @@ pub fn unlink(path: [*:0]const u8) usize {
if (@hasField(SYS, "unlink")) {
return syscall1(.unlink, @ptrToInt(path));
} else {
- return syscall3(.unlinkat, @bitCast(usize, @as(isize, AT_FDCWD)), @ptrToInt(path), 0);
+ return syscall3(.unlinkat, @bitCast(usize, @as(isize, AT.FDCWD)), @ptrToInt(path), 0);
}
}
@@ -736,7 +841,7 @@ var vdso_clock_gettime = @ptrCast(?*const c_void, init_vdso_clock_gettime);
const vdso_clock_gettime_ty = fn (i32, *timespec) callconv(.C) usize;
pub fn clock_gettime(clk_id: i32, tp: *timespec) usize {
- if (@hasDecl(@This(), "VDSO_CGT_SYM")) {
+ if (@hasDecl(VDSO, "CGT_SYM")) {
const ptr = @atomicLoad(?*const c_void, &vdso_clock_gettime, .Unordered);
if (ptr) |fn_ptr| {
const f = @ptrCast(vdso_clock_gettime_ty, fn_ptr);
@@ -751,7 +856,7 @@ pub fn clock_gettime(clk_id: i32, tp: *timespec) usize {
}
fn init_vdso_clock_gettime(clk: i32, ts: *timespec) callconv(.C) usize {
- const ptr = @intToPtr(?*const c_void, vdso.lookup(VDSO_CGT_VER, VDSO_CGT_SYM));
+ const ptr = @intToPtr(?*const c_void, vdso.lookup(VDSO.CGT_VER, VDSO.CGT_SYM));
// Note that we may not have a VDSO at all, update the stub address anyway
// so that clock_gettime will fall back on the good old (and slow) syscall
@atomicStore(?*const c_void, &vdso_clock_gettime, ptr, .Monotonic);
@@ -931,18 +1036,18 @@ pub fn sigprocmask(flags: u32, noalias set: ?*const sigset_t, noalias oldset: ?*
pub fn sigaction(sig: u6, noalias act: ?*const Sigaction, noalias oact: ?*Sigaction) usize {
assert(sig >= 1);
- assert(sig != SIGKILL);
- assert(sig != SIGSTOP);
+ assert(sig != SIG.KILL);
+ assert(sig != SIG.STOP);
var ksa: k_sigaction = undefined;
var oldksa: k_sigaction = undefined;
const mask_size = @sizeOf(@TypeOf(ksa.mask));
if (act) |new| {
- const restorer_fn = if ((new.flags & SA_SIGINFO) != 0) restore_rt else restore;
+ const restorer_fn = if ((new.flags & SA.SIGINFO) != 0) restore_rt else restore;
ksa = k_sigaction{
.handler = new.handler.handler,
- .flags = new.flags | SA_RESTORER,
+ .flags = new.flags | SA.RESTORER,
.mask = undefined,
.restorer = @ptrCast(fn () callconv(.C) void, restorer_fn),
};
@@ -985,42 +1090,42 @@ pub fn sigismember(set: *const sigset_t, sig: u6) bool {
pub fn getsockname(fd: i32, noalias addr: *sockaddr, noalias len: *socklen_t) usize {
if (native_arch == .i386) {
- return socketcall(SC_getsockname, &[3]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len) });
+ return socketcall(SC.getsockname, &[3]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len) });
}
return syscall3(.getsockname, @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len));
}
pub fn getpeername(fd: i32, noalias addr: *sockaddr, noalias len: *socklen_t) usize {
if (native_arch == .i386) {
- return socketcall(SC_getpeername, &[3]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len) });
+ return socketcall(SC.getpeername, &[3]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len) });
}
return syscall3(.getpeername, @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len));
}
pub fn socket(domain: u32, socket_type: u32, protocol: u32) usize {
if (native_arch == .i386) {
- return socketcall(SC_socket, &[3]usize{ domain, socket_type, protocol });
+ return socketcall(SC.socket, &[3]usize{ domain, socket_type, protocol });
}
return syscall3(.socket, domain, socket_type, protocol);
}
pub fn setsockopt(fd: i32, level: u32, optname: u32, optval: [*]const u8, optlen: socklen_t) usize {
if (native_arch == .i386) {
- return socketcall(SC_setsockopt, &[5]usize{ @bitCast(usize, @as(isize, fd)), level, optname, @ptrToInt(optval), @intCast(usize, optlen) });
+ return socketcall(SC.setsockopt, &[5]usize{ @bitCast(usize, @as(isize, fd)), level, optname, @ptrToInt(optval), @intCast(usize, optlen) });
}
return syscall5(.setsockopt, @bitCast(usize, @as(isize, fd)), level, optname, @ptrToInt(optval), @intCast(usize, optlen));
}
pub fn getsockopt(fd: i32, level: u32, optname: u32, noalias optval: [*]u8, noalias optlen: *socklen_t) usize {
if (native_arch == .i386) {
- return socketcall(SC_getsockopt, &[5]usize{ @bitCast(usize, @as(isize, fd)), level, optname, @ptrToInt(optval), @ptrToInt(optlen) });
+ return socketcall(SC.getsockopt, &[5]usize{ @bitCast(usize, @as(isize, fd)), level, optname, @ptrToInt(optval), @ptrToInt(optlen) });
}
return syscall5(.getsockopt, @bitCast(usize, @as(isize, fd)), level, optname, @ptrToInt(optval), @ptrToInt(optlen));
}
pub fn sendmsg(fd: i32, msg: *const std.x.os.Socket.Message, flags: c_int) usize {
if (native_arch == .i386) {
- return socketcall(SC_sendmsg, &[3]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(msg), @bitCast(usize, @as(isize, flags)) });
+ return socketcall(SC.sendmsg, &[3]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(msg), @bitCast(usize, @as(isize, flags)) });
}
return syscall3(.sendmsg, @bitCast(usize, @as(isize, fd)), @ptrToInt(msg), @bitCast(usize, @as(isize, flags)));
}
@@ -1054,7 +1159,7 @@ pub fn sendmmsg(fd: i32, msgvec: [*]mmsghdr_const, vlen: u32, flags: u32) usize
}
}
}
- if (next_unsent < kvlen or next_unsent == 0) { // want to make sure at least one syscall occurs (e.g. to trigger MSG_EOR)
+ if (next_unsent < kvlen or next_unsent == 0) { // want to make sure at least one syscall occurs (e.g. to trigger MSG.EOR)
const batch_size = kvlen - next_unsent;
const r = syscall4(.sendmmsg, @bitCast(usize, @as(isize, fd)), @ptrToInt(&msgvec[next_unsent]), batch_size, flags);
if (getErrno(r) != 0) return r;
@@ -1067,49 +1172,49 @@ pub fn sendmmsg(fd: i32, msgvec: [*]mmsghdr_const, vlen: u32, flags: u32) usize
pub fn connect(fd: i32, addr: *const c_void, len: socklen_t) usize {
if (native_arch == .i386) {
- return socketcall(SC_connect, &[3]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), len });
+ return socketcall(SC.connect, &[3]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), len });
}
return syscall3(.connect, @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), len);
}
pub fn recvmsg(fd: i32, msg: *std.x.os.Socket.Message, flags: c_int) usize {
if (native_arch == .i386) {
- return socketcall(SC_recvmsg, &[3]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(msg), @bitCast(usize, @as(isize, flags)) });
+ return socketcall(SC.recvmsg, &[3]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(msg), @bitCast(usize, @as(isize, flags)) });
}
return syscall3(.recvmsg, @bitCast(usize, @as(isize, fd)), @ptrToInt(msg), @bitCast(usize, @as(isize, flags)));
}
pub fn recvfrom(fd: i32, noalias buf: [*]u8, len: usize, flags: u32, noalias addr: ?*sockaddr, noalias alen: ?*socklen_t) usize {
if (native_arch == .i386) {
- return socketcall(SC_recvfrom, &[6]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(buf), len, flags, @ptrToInt(addr), @ptrToInt(alen) });
+ return socketcall(SC.recvfrom, &[6]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(buf), len, flags, @ptrToInt(addr), @ptrToInt(alen) });
}
return syscall6(.recvfrom, @bitCast(usize, @as(isize, fd)), @ptrToInt(buf), len, flags, @ptrToInt(addr), @ptrToInt(alen));
}
pub fn shutdown(fd: i32, how: i32) usize {
if (native_arch == .i386) {
- return socketcall(SC_shutdown, &[2]usize{ @bitCast(usize, @as(isize, fd)), @bitCast(usize, @as(isize, how)) });
+ return socketcall(SC.shutdown, &[2]usize{ @bitCast(usize, @as(isize, fd)), @bitCast(usize, @as(isize, how)) });
}
return syscall2(.shutdown, @bitCast(usize, @as(isize, fd)), @bitCast(usize, @as(isize, how)));
}
pub fn bind(fd: i32, addr: *const sockaddr, len: socklen_t) usize {
if (native_arch == .i386) {
- return socketcall(SC_bind, &[3]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @intCast(usize, len) });
+ return socketcall(SC.bind, &[3]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @intCast(usize, len) });
}
return syscall3(.bind, @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @intCast(usize, len));
}
pub fn listen(fd: i32, backlog: u32) usize {
if (native_arch == .i386) {
- return socketcall(SC_listen, &[2]usize{ @bitCast(usize, @as(isize, fd)), backlog });
+ return socketcall(SC.listen, &[2]usize{ @bitCast(usize, @as(isize, fd)), backlog });
}
return syscall2(.listen, @bitCast(usize, @as(isize, fd)), backlog);
}
pub fn sendto(fd: i32, buf: [*]const u8, len: usize, flags: u32, addr: ?*const sockaddr, alen: socklen_t) usize {
if (native_arch == .i386) {
- return socketcall(SC_sendto, &[6]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(buf), len, flags, @ptrToInt(addr), @intCast(usize, alen) });
+ return socketcall(SC.sendto, &[6]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(buf), len, flags, @ptrToInt(addr), @intCast(usize, alen) });
}
return syscall6(.sendto, @bitCast(usize, @as(isize, fd)), @ptrToInt(buf), len, flags, @ptrToInt(addr), @intCast(usize, alen));
}
@@ -1136,26 +1241,26 @@ pub fn sendfile(outfd: i32, infd: i32, offset: ?*i64, count: usize) usize {
pub fn socketpair(domain: i32, socket_type: i32, protocol: i32, fd: [2]i32) usize {
if (native_arch == .i386) {
- return socketcall(SC_socketpair, &[4]usize{ @intCast(usize, domain), @intCast(usize, socket_type), @intCast(usize, protocol), @ptrToInt(&fd[0]) });
+ return socketcall(SC.socketpair, &[4]usize{ @intCast(usize, domain), @intCast(usize, socket_type), @intCast(usize, protocol), @ptrToInt(&fd[0]) });
}
return syscall4(.socketpair, @intCast(usize, domain), @intCast(usize, socket_type), @intCast(usize, protocol), @ptrToInt(&fd[0]));
}
pub fn accept(fd: i32, noalias addr: ?*sockaddr, noalias len: ?*socklen_t) usize {
if (native_arch == .i386) {
- return socketcall(SC_accept, &[4]usize{ fd, addr, len, 0 });
+ return socketcall(SC.accept, &[4]usize{ fd, addr, len, 0 });
}
return accept4(fd, addr, len, 0);
}
pub fn accept4(fd: i32, noalias addr: ?*sockaddr, noalias len: ?*socklen_t, flags: u32) usize {
if (native_arch == .i386) {
- return socketcall(SC_accept4, &[4]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len), flags });
+ return socketcall(SC.accept4, &[4]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len), flags });
}
return syscall4(.accept4, @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len), flags);
}
-pub fn fstat(fd: i32, stat_buf: *kernel_stat) usize {
+pub fn fstat(fd: i32, stat_buf: *Stat) usize {
if (@hasField(SYS, "fstat64")) {
return syscall2(.fstat64, @bitCast(usize, @as(isize, fd)), @ptrToInt(stat_buf));
} else {
@@ -1163,7 +1268,7 @@ pub fn fstat(fd: i32, stat_buf: *kernel_stat) usize {
}
}
-pub fn stat(pathname: [*:0]const u8, statbuf: *kernel_stat) usize {
+pub fn stat(pathname: [*:0]const u8, statbuf: *Stat) usize {
if (@hasField(SYS, "stat64")) {
return syscall2(.stat64, @ptrToInt(pathname), @ptrToInt(statbuf));
} else {
@@ -1171,7 +1276,7 @@ pub fn stat(pathname: [*:0]const u8, statbuf: *kernel_stat) usize {
}
}
-pub fn lstat(pathname: [*:0]const u8, statbuf: *kernel_stat) usize {
+pub fn lstat(pathname: [*:0]const u8, statbuf: *Stat) usize {
if (@hasField(SYS, "lstat64")) {
return syscall2(.lstat64, @ptrToInt(pathname), @ptrToInt(statbuf));
} else {
@@ -1179,7 +1284,7 @@ pub fn lstat(pathname: [*:0]const u8, statbuf: *kernel_stat) usize {
}
}
-pub fn fstatat(dirfd: i32, path: [*:0]const u8, stat_buf: *kernel_stat, flags: u32) usize {
+pub fn fstatat(dirfd: i32, path: [*:0]const u8, stat_buf: *Stat, flags: u32) usize {
if (@hasField(SYS, "fstatat64")) {
return syscall4(.fstatat64, @bitCast(usize, @as(isize, dirfd)), @ptrToInt(path), @ptrToInt(stat_buf), flags);
} else {
@@ -1350,11 +1455,11 @@ pub fn getrusage(who: i32, usage: *rusage) usize {
}
pub fn tcgetattr(fd: fd_t, termios_p: *termios) usize {
- return syscall3(.ioctl, @bitCast(usize, @as(isize, fd)), TCGETS, @ptrToInt(termios_p));
+ return syscall3(.ioctl, @bitCast(usize, @as(isize, fd)), T.CGETS, @ptrToInt(termios_p));
}
pub fn tcsetattr(fd: fd_t, optional_action: TCSA, termios_p: *const termios) usize {
- return syscall3(.ioctl, @bitCast(usize, @as(isize, fd)), TCSETS + @enumToInt(optional_action), @ptrToInt(termios_p));
+ return syscall3(.ioctl, @bitCast(usize, @as(isize, fd)), T.CSETS + @enumToInt(optional_action), @ptrToInt(termios_p));
}
pub fn ioctl(fd: fd_t, request: u32, arg: usize) usize {
@@ -1531,8 +1636,3287 @@ pub fn fadvise(fd: fd_t, offset: i64, len: i64, advice: usize) usize {
}
}
-test {
- if (std.Target.current.os.tag == .linux) {
- _ = @import("linux/test.zig");
+pub const E = switch (native_arch) {
+ .mips, .mipsel => @import("linux/errno/mips.zig").E,
+ .sparc, .sparcel, .sparcv9 => @import("linux/errno/sparc.zig").E,
+ else => @import("linux/errno/generic.zig").E,
+};
+
+pub const pid_t = i32;
+pub const fd_t = i32;
+pub const uid_t = u32;
+pub const gid_t = u32;
+pub const clock_t = isize;
+
+pub const NAME_MAX = 255;
+pub const PATH_MAX = 4096;
+pub const IOV_MAX = 1024;
+
+/// Largest hardware address length
+/// e.g. a mac address is a type of hardware address
+pub const MAX_ADDR_LEN = 32;
+
+pub const STDIN_FILENO = 0;
+pub const STDOUT_FILENO = 1;
+pub const STDERR_FILENO = 2;
+
+pub const AT = struct {
+ /// Special value used to indicate openat should use the current working directory
+ pub const FDCWD = -100;
+
+ /// Do not follow symbolic links
+ pub const SYMLINK_NOFOLLOW = 0x100;
+
+ /// Remove directory instead of unlinking file
+ pub const REMOVEDIR = 0x200;
+
+ /// Follow symbolic links.
+ pub const SYMLINK_FOLLOW = 0x400;
+
+ /// Suppress terminal automount traversal
+ pub const NO_AUTOMOUNT = 0x800;
+
+ /// Allow empty relative pathname
+ pub const EMPTY_PATH = 0x1000;
+
+ /// Type of synchronisation required from statx()
+ pub const STATX_SYNC_TYPE = 0x6000;
+
+ /// - Do whatever stat() does
+ pub const STATX_SYNC_AS_STAT = 0x0000;
+
+ /// - Force the attributes to be sync'd with the server
+ pub const STATX_FORCE_SYNC = 0x2000;
+
+ /// - Don't sync attributes with the server
+ pub const STATX_DONT_SYNC = 0x4000;
+
+ /// Apply to the entire subtree
+ pub const RECURSIVE = 0x8000;
+};
+
+pub const FALLOC = struct {
+ /// Default is extend size
+ pub const FL_KEEP_SIZE = 0x01;
+
+ /// De-allocates range
+ pub const FL_PUNCH_HOLE = 0x02;
+
+ /// Reserved codepoint
+ pub const FL_NO_HIDE_STALE = 0x04;
+
+ /// Removes a range of a file without leaving a hole in the file
+ pub const FL_COLLAPSE_RANGE = 0x08;
+
+ /// Converts a range of file to zeros preferably without issuing data IO
+ pub const FL_ZERO_RANGE = 0x10;
+
+ /// Inserts space within the file size without overwriting any existing data
+ pub const FL_INSERT_RANGE = 0x20;
+
+ /// Unshares shared blocks within the file size without overwriting any existing data
+ pub const FL_UNSHARE_RANGE = 0x40;
+};
+
+pub const FUTEX = struct {
+ pub const WAIT = 0;
+ pub const WAKE = 1;
+ pub const FD = 2;
+ pub const REQUEUE = 3;
+ pub const CMP_REQUEUE = 4;
+ pub const WAKE_OP = 5;
+ pub const LOCK_PI = 6;
+ pub const UNLOCK_PI = 7;
+ pub const TRYLOCK_PI = 8;
+ pub const WAIT_BITSET = 9;
+ pub const WAKE_BITSET = 10;
+ pub const WAIT_REQUEUE_PI = 11;
+ pub const CMP_REQUEUE_PI = 12;
+
+ pub const PRIVATE_FLAG = 128;
+
+ pub const CLOCK_REALTIME = 256;
+};
+
+pub const PROT = struct {
+ /// page can not be accessed
+ pub const NONE = 0x0;
+ /// page can be read
+ pub const READ = 0x1;
+ /// page can be written
+ pub const WRITE = 0x2;
+ /// page can be executed
+ pub const EXEC = 0x4;
+ /// page may be used for atomic ops
+ pub const SEM = switch (native_arch) {
+ // TODO: also xtensa
+ .mips, .mipsel, .mips64, .mips64el => 0x10,
+ else => 0x8,
+ };
+ /// mprotect flag: extend change to start of growsdown vma
+ pub const GROWSDOWN = 0x01000000;
+ /// mprotect flag: extend change to end of growsup vma
+ pub const GROWSUP = 0x02000000;
+};
+
+pub const FD_CLOEXEC = 1;
+
+pub const F_OK = 0;
+pub const X_OK = 1;
+pub const W_OK = 2;
+pub const R_OK = 4;
+
+pub const W = struct {
+ pub const NOHANG = 1;
+ pub const UNTRACED = 2;
+ pub const STOPPED = 2;
+ pub const EXITED = 4;
+ pub const CONTINUED = 8;
+ pub const NOWAIT = 0x1000000;
+
+ pub fn EXITSTATUS(s: u32) u8 {
+ return @intCast(u8, (s & 0xff00) >> 8);
+ }
+ pub fn TERMSIG(s: u32) u32 {
+ return s & 0x7f;
+ }
+ pub fn STOPSIG(s: u32) u32 {
+ return EXITSTATUS(s);
+ }
+ pub fn IFEXITED(s: u32) bool {
+ return TERMSIG(s) == 0;
+ }
+ pub fn IFSTOPPED(s: u32) bool {
+ return @truncate(u16, ((s & 0xffff) *% 0x10001) >> 8) > 0x7f00;
+ }
+ pub fn IFSIGNALED(s: u32) bool {
+ return (s & 0xffff) -% 1 < 0xff;
+ }
+};
+
+// waitid id types
+pub const P = enum(c_uint) {
+ ALL = 0,
+ PID = 1,
+ PGID = 2,
+ PIDFD = 3,
+ _,
+};
+
+pub const SA = if (is_mips) struct {
+ pub const NOCLDSTOP = 1;
+ pub const NOCLDWAIT = 0x10000;
+ pub const SIGINFO = 8;
+ pub const RESTART = 0x10000000;
+ pub const RESETHAND = 0x80000000;
+ pub const ONSTACK = 0x08000000;
+ pub const NODEFER = 0x40000000;
+ pub const RESTORER = 0x04000000;
+} else if (is_sparc) struct {
+ pub const NOCLDSTOP = 0x8;
+ pub const NOCLDWAIT = 0x100;
+ pub const SIGINFO = 0x200;
+ pub const RESTART = 0x2;
+ pub const RESETHAND = 0x4;
+ pub const ONSTACK = 0x1;
+ pub const NODEFER = 0x20;
+ pub const RESTORER = 0x04000000;
+} else struct {
+ pub const NOCLDSTOP = 1;
+ pub const NOCLDWAIT = 2;
+ pub const SIGINFO = 4;
+ pub const RESTART = 0x10000000;
+ pub const RESETHAND = 0x80000000;
+ pub const ONSTACK = 0x08000000;
+ pub const NODEFER = 0x40000000;
+ pub const RESTORER = 0x04000000;
+};
+
+pub const SIG = if (is_mips) struct {
+ pub const BLOCK = 1;
+ pub const UNBLOCK = 2;
+ pub const SETMASK = 3;
+
+ pub const HUP = 1;
+ pub const INT = 2;
+ pub const QUIT = 3;
+ pub const ILL = 4;
+ pub const TRAP = 5;
+ pub const ABRT = 6;
+ pub const IOT = ABRT;
+ pub const BUS = 7;
+ pub const FPE = 8;
+ pub const KILL = 9;
+ pub const USR1 = 10;
+ pub const SEGV = 11;
+ pub const USR2 = 12;
+ pub const PIPE = 13;
+ pub const ALRM = 14;
+ pub const TERM = 15;
+ pub const STKFLT = 16;
+ pub const CHLD = 17;
+ pub const CONT = 18;
+ pub const STOP = 19;
+ pub const TSTP = 20;
+ pub const TTIN = 21;
+ pub const TTOU = 22;
+ pub const URG = 23;
+ pub const XCPU = 24;
+ pub const XFSZ = 25;
+ pub const VTALRM = 26;
+ pub const PROF = 27;
+ pub const WINCH = 28;
+ pub const IO = 29;
+ pub const POLL = 29;
+ pub const PWR = 30;
+ pub const SYS = 31;
+ pub const UNUSED = SIG.SYS;
+
+ pub const ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize));
+ pub const DFL = @intToPtr(?Sigaction.sigaction_fn, 0);
+ pub const IGN = @intToPtr(?Sigaction.sigaction_fn, 1);
+} else if (is_sparc) struct {
+ pub const BLOCK = 1;
+ pub const UNBLOCK = 2;
+ pub const SETMASK = 4;
+
+ pub const HUP = 1;
+ pub const INT = 2;
+ pub const QUIT = 3;
+ pub const ILL = 4;
+ pub const TRAP = 5;
+ pub const ABRT = 6;
+ pub const EMT = 7;
+ pub const FPE = 8;
+ pub const KILL = 9;
+ pub const BUS = 10;
+ pub const SEGV = 11;
+ pub const SYS = 12;
+ pub const PIPE = 13;
+ pub const ALRM = 14;
+ pub const TERM = 15;
+ pub const URG = 16;
+ pub const STOP = 17;
+ pub const TSTP = 18;
+ pub const CONT = 19;
+ pub const CHLD = 20;
+ pub const TTIN = 21;
+ pub const TTOU = 22;
+ pub const POLL = 23;
+ pub const XCPU = 24;
+ pub const XFSZ = 25;
+ pub const VTALRM = 26;
+ pub const PROF = 27;
+ pub const WINCH = 28;
+ pub const LOST = 29;
+ pub const USR1 = 30;
+ pub const USR2 = 31;
+ pub const IOT = ABRT;
+ pub const CLD = CHLD;
+ pub const PWR = LOST;
+ pub const IO = SIG.POLL;
+
+ pub const ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize));
+ pub const DFL = @intToPtr(?Sigaction.sigaction_fn, 0);
+ pub const IGN = @intToPtr(?Sigaction.sigaction_fn, 1);
+} else struct {
+ pub const BLOCK = 0;
+ pub const UNBLOCK = 1;
+ pub const SETMASK = 2;
+
+ pub const HUP = 1;
+ pub const INT = 2;
+ pub const QUIT = 3;
+ pub const ILL = 4;
+ pub const TRAP = 5;
+ pub const ABRT = 6;
+ pub const IOT = ABRT;
+ pub const BUS = 7;
+ pub const FPE = 8;
+ pub const KILL = 9;
+ pub const USR1 = 10;
+ pub const SEGV = 11;
+ pub const USR2 = 12;
+ pub const PIPE = 13;
+ pub const ALRM = 14;
+ pub const TERM = 15;
+ pub const STKFLT = 16;
+ pub const CHLD = 17;
+ pub const CONT = 18;
+ pub const STOP = 19;
+ pub const TSTP = 20;
+ pub const TTIN = 21;
+ pub const TTOU = 22;
+ pub const URG = 23;
+ pub const XCPU = 24;
+ pub const XFSZ = 25;
+ pub const VTALRM = 26;
+ pub const PROF = 27;
+ pub const WINCH = 28;
+ pub const IO = 29;
+ pub const POLL = 29;
+ pub const PWR = 30;
+ pub const SYS = 31;
+ pub const UNUSED = SIG.SYS;
+
+ pub const ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize));
+ pub const DFL = @intToPtr(?Sigaction.sigaction_fn, 0);
+ pub const IGN = @intToPtr(?Sigaction.sigaction_fn, 1);
+};
+
+pub const kernel_rwf = u32;
+
+pub const RWF = struct {
+ /// high priority request, poll if possible
+ pub const HIPRI: kernel_rwf = 0x00000001;
+
+ /// per-IO O.DSYNC
+ pub const DSYNC: kernel_rwf = 0x00000002;
+
+ /// per-IO O.SYNC
+ pub const SYNC: kernel_rwf = 0x00000004;
+
+ /// per-IO, return -EAGAIN if operation would block
+ pub const NOWAIT: kernel_rwf = 0x00000008;
+
+ /// per-IO O.APPEND
+ pub const APPEND: kernel_rwf = 0x00000010;
+};
+
+pub const SEEK = struct {
+ pub const SET = 0;
+ pub const CUR = 1;
+ pub const END = 2;
+};
+
+pub const SHUT = struct {
+ pub const RD = 0;
+ pub const WR = 1;
+ pub const RDWR = 2;
+};
+
+pub const SOCK = struct {
+ pub const STREAM = if (is_mips) 2 else 1;
+ pub const DGRAM = if (is_mips) 1 else 2;
+ pub const RAW = 3;
+ pub const RDM = 4;
+ pub const SEQPACKET = 5;
+ pub const DCCP = 6;
+ pub const PACKET = 10;
+ pub const CLOEXEC = 0o2000000;
+ pub const NONBLOCK = if (is_mips) 0o200 else 0o4000;
+};
+
+pub const PF = struct {
+ pub const UNSPEC = 0;
+ pub const LOCAL = 1;
+ pub const UNIX = LOCAL;
+ pub const FILE = LOCAL;
+ pub const INET = 2;
+ pub const AX25 = 3;
+ pub const IPX = 4;
+ pub const APPLETALK = 5;
+ pub const NETROM = 6;
+ pub const BRIDGE = 7;
+ pub const ATMPVC = 8;
+ pub const X25 = 9;
+ pub const INET6 = 10;
+ pub const ROSE = 11;
+ pub const DECnet = 12;
+ pub const NETBEUI = 13;
+ pub const SECURITY = 14;
+ pub const KEY = 15;
+ pub const NETLINK = 16;
+ pub const ROUTE = PF.NETLINK;
+ pub const PACKET = 17;
+ pub const ASH = 18;
+ pub const ECONET = 19;
+ pub const ATMSVC = 20;
+ pub const RDS = 21;
+ pub const SNA = 22;
+ pub const IRDA = 23;
+ pub const PPPOX = 24;
+ pub const WANPIPE = 25;
+ pub const LLC = 26;
+ pub const IB = 27;
+ pub const MPLS = 28;
+ pub const CAN = 29;
+ pub const TIPC = 30;
+ pub const BLUETOOTH = 31;
+ pub const IUCV = 32;
+ pub const RXRPC = 33;
+ pub const ISDN = 34;
+ pub const PHONET = 35;
+ pub const IEEE802154 = 36;
+ pub const CAIF = 37;
+ pub const ALG = 38;
+ pub const NFC = 39;
+ pub const VSOCK = 40;
+ pub const KCM = 41;
+ pub const QIPCRTR = 42;
+ pub const SMC = 43;
+ pub const XDP = 44;
+ pub const MAX = 45;
+};
+
+pub const AF = struct {
+ pub const UNSPEC = PF.UNSPEC;
+ pub const LOCAL = PF.LOCAL;
+ pub const UNIX = AF.LOCAL;
+ pub const FILE = AF.LOCAL;
+ pub const INET = PF.INET;
+ pub const AX25 = PF.AX25;
+ pub const IPX = PF.IPX;
+ pub const APPLETALK = PF.APPLETALK;
+ pub const NETROM = PF.NETROM;
+ pub const BRIDGE = PF.BRIDGE;
+ pub const ATMPVC = PF.ATMPVC;
+ pub const X25 = PF.X25;
+ pub const INET6 = PF.INET6;
+ pub const ROSE = PF.ROSE;
+ pub const DECnet = PF.DECnet;
+ pub const NETBEUI = PF.NETBEUI;
+ pub const SECURITY = PF.SECURITY;
+ pub const KEY = PF.KEY;
+ pub const NETLINK = PF.NETLINK;
+ pub const ROUTE = PF.ROUTE;
+ pub const PACKET = PF.PACKET;
+ pub const ASH = PF.ASH;
+ pub const ECONET = PF.ECONET;
+ pub const ATMSVC = PF.ATMSVC;
+ pub const RDS = PF.RDS;
+ pub const SNA = PF.SNA;
+ pub const IRDA = PF.IRDA;
+ pub const PPPOX = PF.PPPOX;
+ pub const WANPIPE = PF.WANPIPE;
+ pub const LLC = PF.LLC;
+ pub const IB = PF.IB;
+ pub const MPLS = PF.MPLS;
+ pub const CAN = PF.CAN;
+ pub const TIPC = PF.TIPC;
+ pub const BLUETOOTH = PF.BLUETOOTH;
+ pub const IUCV = PF.IUCV;
+ pub const RXRPC = PF.RXRPC;
+ pub const ISDN = PF.ISDN;
+ pub const PHONET = PF.PHONET;
+ pub const IEEE802154 = PF.IEEE802154;
+ pub const CAIF = PF.CAIF;
+ pub const ALG = PF.ALG;
+ pub const NFC = PF.NFC;
+ pub const VSOCK = PF.VSOCK;
+ pub const KCM = PF.KCM;
+ pub const QIPCRTR = PF.QIPCRTR;
+ pub const SMC = PF.SMC;
+ pub const XDP = PF.XDP;
+ pub const MAX = PF.MAX;
+};
+
+pub const SO = struct {
+ pub usingnamespace if (is_mips) struct {
+ pub const DEBUG = 1;
+ pub const REUSEADDR = 0x0004;
+ pub const KEEPALIVE = 0x0008;
+ pub const DONTROUTE = 0x0010;
+ pub const BROADCAST = 0x0020;
+ pub const LINGER = 0x0080;
+ pub const OOBINLINE = 0x0100;
+ pub const REUSEPORT = 0x0200;
+ pub const SNDBUF = 0x1001;
+ pub const RCVBUF = 0x1002;
+ pub const SNDLOWAT = 0x1003;
+ pub const RCVLOWAT = 0x1004;
+ pub const RCVTIMEO = 0x1006;
+ pub const SNDTIMEO = 0x1005;
+ pub const ERROR = 0x1007;
+ pub const TYPE = 0x1008;
+ pub const ACCEPTCONN = 0x1009;
+ pub const PROTOCOL = 0x1028;
+ pub const DOMAIN = 0x1029;
+ pub const NO_CHECK = 11;
+ pub const PRIORITY = 12;
+ pub const BSDCOMPAT = 14;
+ pub const PASSCRED = 17;
+ pub const PEERCRED = 18;
+ pub const PEERSEC = 30;
+ pub const SNDBUFFORCE = 31;
+ pub const RCVBUFFORCE = 33;
+ } else if (is_ppc or is_ppc64) struct {
+ pub const DEBUG = 1;
+ pub const REUSEADDR = 2;
+ pub const TYPE = 3;
+ pub const ERROR = 4;
+ pub const DONTROUTE = 5;
+ pub const BROADCAST = 6;
+ pub const SNDBUF = 7;
+ pub const RCVBUF = 8;
+ pub const KEEPALIVE = 9;
+ pub const OOBINLINE = 10;
+ pub const NO_CHECK = 11;
+ pub const PRIORITY = 12;
+ pub const LINGER = 13;
+ pub const BSDCOMPAT = 14;
+ pub const REUSEPORT = 15;
+ pub const RCVLOWAT = 16;
+ pub const SNDLOWAT = 17;
+ pub const RCVTIMEO = 18;
+ pub const SNDTIMEO = 19;
+ pub const PASSCRED = 20;
+ pub const PEERCRED = 21;
+ pub const ACCEPTCONN = 30;
+ pub const PEERSEC = 31;
+ pub const SNDBUFFORCE = 32;
+ pub const RCVBUFFORCE = 33;
+ pub const PROTOCOL = 38;
+ pub const DOMAIN = 39;
+ } else struct {
+ pub const DEBUG = 1;
+ pub const REUSEADDR = 2;
+ pub const TYPE = 3;
+ pub const ERROR = 4;
+ pub const DONTROUTE = 5;
+ pub const BROADCAST = 6;
+ pub const SNDBUF = 7;
+ pub const RCVBUF = 8;
+ pub const KEEPALIVE = 9;
+ pub const OOBINLINE = 10;
+ pub const NO_CHECK = 11;
+ pub const PRIORITY = 12;
+ pub const LINGER = 13;
+ pub const BSDCOMPAT = 14;
+ pub const REUSEPORT = 15;
+ pub const PASSCRED = 16;
+ pub const PEERCRED = 17;
+ pub const RCVLOWAT = 18;
+ pub const SNDLOWAT = 19;
+ pub const RCVTIMEO = 20;
+ pub const SNDTIMEO = 21;
+ pub const ACCEPTCONN = 30;
+ pub const PEERSEC = 31;
+ pub const SNDBUFFORCE = 32;
+ pub const RCVBUFFORCE = 33;
+ pub const PROTOCOL = 38;
+ pub const DOMAIN = 39;
+ };
+
+ pub const SECURITY_AUTHENTICATION = 22;
+ pub const SECURITY_ENCRYPTION_TRANSPORT = 23;
+ pub const SECURITY_ENCRYPTION_NETWORK = 24;
+
+ pub const BINDTODEVICE = 25;
+
+ pub const ATTACH_FILTER = 26;
+ pub const DETACH_FILTER = 27;
+ pub const GET_FILTER = ATTACH_FILTER;
+
+ pub const PEERNAME = 28;
+ pub const TIMESTAMP_OLD = 29;
+ pub const PASSSEC = 34;
+ pub const TIMESTAMPNS_OLD = 35;
+ pub const MARK = 36;
+ pub const TIMESTAMPING_OLD = 37;
+
+ pub const RXQ_OVFL = 40;
+ pub const WIFI_STATUS = 41;
+ pub const PEEK_OFF = 42;
+ pub const NOFCS = 43;
+ pub const LOCK_FILTER = 44;
+ pub const SELECT_ERR_QUEUE = 45;
+ pub const BUSY_POLL = 46;
+ pub const MAX_PACING_RATE = 47;
+ pub const BPF_EXTENSIONS = 48;
+ pub const INCOMING_CPU = 49;
+ pub const ATTACH_BPF = 50;
+ pub const DETACH_BPF = DETACH_FILTER;
+ pub const ATTACH_REUSEPORT_CBPF = 51;
+ pub const ATTACH_REUSEPORT_EBPF = 52;
+ pub const CNX_ADVICE = 53;
+ pub const MEMINFO = 55;
+ pub const INCOMING_NAPI_ID = 56;
+ pub const COOKIE = 57;
+ pub const PEERGROUPS = 59;
+ pub const ZEROCOPY = 60;
+ pub const TXTIME = 61;
+ pub const BINDTOIFINDEX = 62;
+ pub const TIMESTAMP_NEW = 63;
+ pub const TIMESTAMPNS_NEW = 64;
+ pub const TIMESTAMPING_NEW = 65;
+ pub const RCVTIMEO_NEW = 66;
+ pub const SNDTIMEO_NEW = 67;
+ pub const DETACH_REUSEPORT_BPF = 68;
+};
+
+pub const SCM = struct {
+ pub const WIFI_STATUS = SO.WIFI_STATUS;
+ pub const TIMESTAMPING_OPT_STATS = 54;
+ pub const TIMESTAMPING_PKTINFO = 58;
+ pub const TXTIME = SO.TXTIME;
+};
+
+pub const SOL = struct {
+ pub const SOCKET = if (is_mips) 65535 else 1;
+
+ pub const IP = 0;
+ pub const IPV6 = 41;
+ pub const ICMPV6 = 58;
+
+ pub const RAW = 255;
+ pub const DECNET = 261;
+ pub const X25 = 262;
+ pub const PACKET = 263;
+ pub const ATM = 264;
+ pub const AAL = 265;
+ pub const IRDA = 266;
+ pub const NETBEUI = 267;
+ pub const LLC = 268;
+ pub const DCCP = 269;
+ pub const NETLINK = 270;
+ pub const TIPC = 271;
+ pub const RXRPC = 272;
+ pub const PPPOL2TP = 273;
+ pub const BLUETOOTH = 274;
+ pub const PNPIPE = 275;
+ pub const RDS = 276;
+ pub const IUCV = 277;
+ pub const CAIF = 278;
+ pub const ALG = 279;
+ pub const NFC = 280;
+ pub const KCM = 281;
+ pub const TLS = 282;
+ pub const XDP = 283;
+};
+
+pub const SOMAXCONN = 128;
+
+pub const IP = struct {
+ pub const TOS = 1;
+ pub const TTL = 2;
+ pub const HDRINCL = 3;
+ pub const OPTIONS = 4;
+ pub const ROUTER_ALERT = 5;
+ pub const RECVOPTS = 6;
+ pub const RETOPTS = 7;
+ pub const PKTINFO = 8;
+ pub const PKTOPTIONS = 9;
+ pub const PMTUDISC = 10;
+ pub const MTU_DISCOVER = 10;
+ pub const RECVERR = 11;
+ pub const RECVTTL = 12;
+ pub const RECVTOS = 13;
+ pub const MTU = 14;
+ pub const FREEBIND = 15;
+ pub const IPSEC_POLICY = 16;
+ pub const XFRM_POLICY = 17;
+ pub const PASSSEC = 18;
+ pub const TRANSPARENT = 19;
+ pub const ORIGDSTADDR = 20;
+ pub const RECVORIGDSTADDR = IP.ORIGDSTADDR;
+ pub const MINTTL = 21;
+ pub const NODEFRAG = 22;
+ pub const CHECKSUM = 23;
+ pub const BIND_ADDRESS_NO_PORT = 24;
+ pub const RECVFRAGSIZE = 25;
+ pub const MULTICAST_IF = 32;
+ pub const MULTICAST_TTL = 33;
+ pub const MULTICAST_LOOP = 34;
+ pub const ADD_MEMBERSHIP = 35;
+ pub const DROP_MEMBERSHIP = 36;
+ pub const UNBLOCK_SOURCE = 37;
+ pub const BLOCK_SOURCE = 38;
+ pub const ADD_SOURCE_MEMBERSHIP = 39;
+ pub const DROP_SOURCE_MEMBERSHIP = 40;
+ pub const MSFILTER = 41;
+ pub const MULTICAST_ALL = 49;
+ pub const UNICAST_IF = 50;
+
+ pub const RECVRETOPTS = IP.RETOPTS;
+
+ pub const PMTUDISC_DONT = 0;
+ pub const PMTUDISC_WANT = 1;
+ pub const PMTUDISC_DO = 2;
+ pub const PMTUDISC_PROBE = 3;
+ pub const PMTUDISC_INTERFACE = 4;
+ pub const PMTUDISC_OMIT = 5;
+
+ pub const DEFAULT_MULTICAST_TTL = 1;
+ pub const DEFAULT_MULTICAST_LOOP = 1;
+ pub const MAX_MEMBERSHIPS = 20;
+};
+
+/// IPv6 socket options
+pub const IPV6 = struct {
+ pub const ADDRFORM = 1;
+ pub const @"2292PKTINFO" = 2;
+ pub const @"2292HOPOPTS" = 3;
+ pub const @"2292DSTOPTS" = 4;
+ pub const @"2292RTHDR" = 5;
+ pub const @"2292PKTOPTIONS" = 6;
+ pub const CHECKSUM = 7;
+ pub const @"2292HOPLIMIT" = 8;
+ pub const NEXTHOP = 9;
+ pub const AUTHHDR = 10;
+ pub const FLOWINFO = 11;
+
+ pub const UNICAST_HOPS = 16;
+ pub const MULTICAST_IF = 17;
+ pub const MULTICAST_HOPS = 18;
+ pub const MULTICAST_LOOP = 19;
+ pub const ADD_MEMBERSHIP = 20;
+ pub const DROP_MEMBERSHIP = 21;
+ pub const ROUTER_ALERT = 22;
+ pub const MTU_DISCOVER = 23;
+ pub const MTU = 24;
+ pub const RECVERR = 25;
+ pub const V6ONLY = 26;
+ pub const JOIN_ANYCAST = 27;
+ pub const LEAVE_ANYCAST = 28;
+
+ // IPV6.MTU_DISCOVER values
+ pub const PMTUDISC_DONT = 0;
+ pub const PMTUDISC_WANT = 1;
+ pub const PMTUDISC_DO = 2;
+ pub const PMTUDISC_PROBE = 3;
+ pub const PMTUDISC_INTERFACE = 4;
+ pub const PMTUDISC_OMIT = 5;
+
+ // Flowlabel
+ pub const FLOWLABEL_MGR = 32;
+ pub const FLOWINFO_SEND = 33;
+ pub const IPSEC_POLICY = 34;
+ pub const XFRM_POLICY = 35;
+ pub const HDRINCL = 36;
+
+ // Advanced API (RFC3542) (1)
+ pub const RECVPKTINFO = 49;
+ pub const PKTINFO = 50;
+ pub const RECVHOPLIMIT = 51;
+ pub const HOPLIMIT = 52;
+ pub const RECVHOPOPTS = 53;
+ pub const HOPOPTS = 54;
+ pub const RTHDRDSTOPTS = 55;
+ pub const RECVRTHDR = 56;
+ pub const RTHDR = 57;
+ pub const RECVDSTOPTS = 58;
+ pub const DSTOPTS = 59;
+ pub const RECVPATHMTU = 60;
+ pub const PATHMTU = 61;
+ pub const DONTFRAG = 62;
+
+ // Advanced API (RFC3542) (2)
+ pub const RECVTCLASS = 66;
+ pub const TCLASS = 67;
+
+ pub const AUTOFLOWLABEL = 70;
+
+ // RFC5014: Source address selection
+ pub const ADDR_PREFERENCES = 72;
+
+ pub const PREFER_SRC_TMP = 0x0001;
+ pub const PREFER_SRC_PUBLIC = 0x0002;
+ pub const PREFER_SRC_PUBTMP_DEFAULT = 0x0100;
+ pub const PREFER_SRC_COA = 0x0004;
+ pub const PREFER_SRC_HOME = 0x0400;
+ pub const PREFER_SRC_CGA = 0x0008;
+ pub const PREFER_SRC_NONCGA = 0x0800;
+
+ // RFC5082: Generalized Ttl Security Mechanism
+ pub const MINHOPCOUNT = 73;
+
+ pub const ORIGDSTADDR = 74;
+ pub const RECVORIGDSTADDR = IPV6.ORIGDSTADDR;
+ pub const TRANSPARENT = 75;
+ pub const UNICAST_IF = 76;
+ pub const RECVFRAGSIZE = 77;
+ pub const FREEBIND = 78;
+};
+
+pub const MSG = struct {
+ pub const OOB = 0x0001;
+ pub const PEEK = 0x0002;
+ pub const DONTROUTE = 0x0004;
+ pub const CTRUNC = 0x0008;
+ pub const PROXY = 0x0010;
+ pub const TRUNC = 0x0020;
+ pub const DONTWAIT = 0x0040;
+ pub const EOR = 0x0080;
+ pub const WAITALL = 0x0100;
+ pub const FIN = 0x0200;
+ pub const SYN = 0x0400;
+ pub const CONFIRM = 0x0800;
+ pub const RST = 0x1000;
+ pub const ERRQUEUE = 0x2000;
+ pub const NOSIGNAL = 0x4000;
+ pub const MORE = 0x8000;
+ pub const WAITFORONE = 0x10000;
+ pub const BATCH = 0x40000;
+ pub const ZEROCOPY = 0x4000000;
+ pub const FASTOPEN = 0x20000000;
+ pub const CMSG_CLOEXEC = 0x40000000;
+};
+
+pub const DT = struct {
+ pub const UNKNOWN = 0;
+ pub const FIFO = 1;
+ pub const CHR = 2;
+ pub const DIR = 4;
+ pub const BLK = 6;
+ pub const REG = 8;
+ pub const LNK = 10;
+ pub const SOCK = 12;
+ pub const WHT = 14;
+};
+
+pub const T = struct {
+ pub const CGETS = if (is_mips) 0x540D else 0x5401;
+ pub const CSETS = 0x5402;
+ pub const CSETSW = 0x5403;
+ pub const CSETSF = 0x5404;
+ pub const CGETA = 0x5405;
+ pub const CSETA = 0x5406;
+ pub const CSETAW = 0x5407;
+ pub const CSETAF = 0x5408;
+ pub const CSBRK = 0x5409;
+ pub const CXONC = 0x540A;
+ pub const CFLSH = 0x540B;
+ pub const IOCEXCL = 0x540C;
+ pub const IOCNXCL = 0x540D;
+ pub const IOCSCTTY = 0x540E;
+ pub const IOCGPGRP = 0x540F;
+ pub const IOCSPGRP = 0x5410;
+ pub const IOCOUTQ = if (is_mips) 0x7472 else 0x5411;
+ pub const IOCSTI = 0x5412;
+ pub const IOCGWINSZ = if (is_mips or is_ppc64) 0x40087468 else 0x5413;
+ pub const IOCSWINSZ = if (is_mips or is_ppc64) 0x80087467 else 0x5414;
+ pub const IOCMGET = 0x5415;
+ pub const IOCMBIS = 0x5416;
+ pub const IOCMBIC = 0x5417;
+ pub const IOCMSET = 0x5418;
+ pub const IOCGSOFTCAR = 0x5419;
+ pub const IOCSSOFTCAR = 0x541A;
+ pub const FIONREAD = if (is_mips) 0x467F else 0x541B;
+ pub const IOCINQ = FIONREAD;
+ pub const IOCLINUX = 0x541C;
+ pub const IOCCONS = 0x541D;
+ pub const IOCGSERIAL = 0x541E;
+ pub const IOCSSERIAL = 0x541F;
+ pub const IOCPKT = 0x5420;
+ pub const FIONBIO = 0x5421;
+ pub const IOCNOTTY = 0x5422;
+ pub const IOCSETD = 0x5423;
+ pub const IOCGETD = 0x5424;
+ pub const CSBRKP = 0x5425;
+ pub const IOCSBRK = 0x5427;
+ pub const IOCCBRK = 0x5428;
+ pub const IOCGSID = 0x5429;
+ pub const IOCGRS485 = 0x542E;
+ pub const IOCSRS485 = 0x542F;
+ pub const IOCGPTN = 0x80045430;
+ pub const IOCSPTLCK = 0x40045431;
+ pub const IOCGDEV = 0x80045432;
+ pub const CGETX = 0x5432;
+ pub const CSETX = 0x5433;
+ pub const CSETXF = 0x5434;
+ pub const CSETXW = 0x5435;
+ pub const IOCSIG = 0x40045436;
+ pub const IOCVHANGUP = 0x5437;
+ pub const IOCGPKT = 0x80045438;
+ pub const IOCGPTLCK = 0x80045439;
+ pub const IOCGEXCL = 0x80045440;
+};
+
+pub const EPOLL = struct {
+ pub const CLOEXEC = O.CLOEXEC;
+
+ pub const CTL_ADD = 1;
+ pub const CTL_DEL = 2;
+ pub const CTL_MOD = 3;
+
+ pub const IN = 0x001;
+ pub const PRI = 0x002;
+ pub const OUT = 0x004;
+ pub const RDNORM = 0x040;
+ pub const RDBAND = 0x080;
+ pub const WRNORM = if (is_mips) 0x004 else 0x100;
+ pub const WRBAND = if (is_mips) 0x100 else 0x200;
+ pub const MSG = 0x400;
+ pub const ERR = 0x008;
+ pub const HUP = 0x010;
+ pub const RDHUP = 0x2000;
+ pub const EXCLUSIVE = (@as(u32, 1) << 28);
+ pub const WAKEUP = (@as(u32, 1) << 29);
+ pub const ONESHOT = (@as(u32, 1) << 30);
+ pub const ET = (@as(u32, 1) << 31);
+};
+
+pub const CLOCK = struct {
+ pub const REALTIME = 0;
+ pub const MONOTONIC = 1;
+ pub const PROCESS_CPUTIME_ID = 2;
+ pub const THREAD_CPUTIME_ID = 3;
+ pub const MONOTONIC_RAW = 4;
+ pub const REALTIME_COARSE = 5;
+ pub const MONOTONIC_COARSE = 6;
+ pub const BOOTTIME = 7;
+ pub const REALTIME_ALARM = 8;
+ pub const BOOTTIME_ALARM = 9;
+ pub const SGI_CYCLE = 10;
+ pub const TAI = 11;
+};
+
+pub const CSIGNAL = 0x000000ff;
+
+pub const CLONE = struct {
+ pub const VM = 0x00000100;
+ pub const FS = 0x00000200;
+ pub const FILES = 0x00000400;
+ pub const SIGHAND = 0x00000800;
+ pub const PIDFD = 0x00001000;
+ pub const PTRACE = 0x00002000;
+ pub const VFORK = 0x00004000;
+ pub const PARENT = 0x00008000;
+ pub const THREAD = 0x00010000;
+ pub const NEWNS = 0x00020000;
+ pub const SYSVSEM = 0x00040000;
+ pub const SETTLS = 0x00080000;
+ pub const PARENT_SETTID = 0x00100000;
+ pub const CHILD_CLEARTID = 0x00200000;
+ pub const DETACHED = 0x00400000;
+ pub const UNTRACED = 0x00800000;
+ pub const CHILD_SETTID = 0x01000000;
+ pub const NEWCGROUP = 0x02000000;
+ pub const NEWUTS = 0x04000000;
+ pub const NEWIPC = 0x08000000;
+ pub const NEWUSER = 0x10000000;
+ pub const NEWPID = 0x20000000;
+ pub const NEWNET = 0x40000000;
+ pub const IO = 0x80000000;
+
+ // Flags for the clone3() syscall.
+
+ /// Clear any signal handler and reset to SIG_DFL.
+ pub const CLEAR_SIGHAND = 0x100000000;
+ /// Clone into a specific cgroup given the right permissions.
+ pub const INTO_CGROUP = 0x200000000;
+
+ // cloning flags intersect with CSIGNAL so can be used with unshare and clone3 syscalls only.
+
+ /// New time namespace
+ pub const NEWTIME = 0x00000080;
+};
+
+pub const EFD = struct {
+ pub const SEMAPHORE = 1;
+ pub const CLOEXEC = O.CLOEXEC;
+ pub const NONBLOCK = O.NONBLOCK;
+};
+
+pub const MS = struct {
+ pub const RDONLY = 1;
+ pub const NOSUID = 2;
+ pub const NODEV = 4;
+ pub const NOEXEC = 8;
+ pub const SYNCHRONOUS = 16;
+ pub const REMOUNT = 32;
+ pub const MANDLOCK = 64;
+ pub const DIRSYNC = 128;
+ pub const NOATIME = 1024;
+ pub const NODIRATIME = 2048;
+ pub const BIND = 4096;
+ pub const MOVE = 8192;
+ pub const REC = 16384;
+ pub const SILENT = 32768;
+ pub const POSIXACL = (1 << 16);
+ pub const UNBINDABLE = (1 << 17);
+ pub const PRIVATE = (1 << 18);
+ pub const SLAVE = (1 << 19);
+ pub const SHARED = (1 << 20);
+ pub const RELATIME = (1 << 21);
+ pub const KERNMOUNT = (1 << 22);
+ pub const I_VERSION = (1 << 23);
+ pub const STRICTATIME = (1 << 24);
+ pub const LAZYTIME = (1 << 25);
+ pub const NOREMOTELOCK = (1 << 27);
+ pub const NOSEC = (1 << 28);
+ pub const BORN = (1 << 29);
+ pub const ACTIVE = (1 << 30);
+ pub const NOUSER = (1 << 31);
+
+ pub const RMT_MASK = (RDONLY | SYNCHRONOUS | MANDLOCK | I_VERSION | LAZYTIME);
+
+ pub const MGC_VAL = 0xc0ed0000;
+ pub const MGC_MSK = 0xffff0000;
+};
+
+pub const MNT = struct {
+ pub const FORCE = 1;
+ pub const DETACH = 2;
+ pub const EXPIRE = 4;
+};
+
+pub const UMOUNT_NOFOLLOW = 8;
+
+pub const IN = struct {
+ pub const CLOEXEC = O.CLOEXEC;
+ pub const NONBLOCK = O.NONBLOCK;
+
+ pub const ACCESS = 0x00000001;
+ pub const MODIFY = 0x00000002;
+ pub const ATTRIB = 0x00000004;
+ pub const CLOSE_WRITE = 0x00000008;
+ pub const CLOSE_NOWRITE = 0x00000010;
+ pub const CLOSE = CLOSE_WRITE | CLOSE_NOWRITE;
+ pub const OPEN = 0x00000020;
+ pub const MOVED_FROM = 0x00000040;
+ pub const MOVED_TO = 0x00000080;
+ pub const MOVE = MOVED_FROM | MOVED_TO;
+ pub const CREATE = 0x00000100;
+ pub const DELETE = 0x00000200;
+ pub const DELETE_SELF = 0x00000400;
+ pub const MOVE_SELF = 0x00000800;
+ pub const ALL_EVENTS = 0x00000fff;
+
+ pub const UNMOUNT = 0x00002000;
+ pub const Q_OVERFLOW = 0x00004000;
+ pub const IGNORED = 0x00008000;
+
+ pub const ONLYDIR = 0x01000000;
+ pub const DONT_FOLLOW = 0x02000000;
+ pub const EXCL_UNLINK = 0x04000000;
+ pub const MASK_ADD = 0x20000000;
+
+ pub const ISDIR = 0x40000000;
+ pub const ONESHOT = 0x80000000;
+};
+
+pub const S = struct {
+ pub const IFMT = 0o170000;
+
+ pub const IFDIR = 0o040000;
+ pub const IFCHR = 0o020000;
+ pub const IFBLK = 0o060000;
+ pub const IFREG = 0o100000;
+ pub const IFIFO = 0o010000;
+ pub const IFLNK = 0o120000;
+ pub const IFSOCK = 0o140000;
+
+ pub const ISUID = 0o4000;
+ pub const ISGID = 0o2000;
+ pub const ISVTX = 0o1000;
+ pub const IRUSR = 0o400;
+ pub const IWUSR = 0o200;
+ pub const IXUSR = 0o100;
+ pub const IRWXU = 0o700;
+ pub const IRGRP = 0o040;
+ pub const IWGRP = 0o020;
+ pub const IXGRP = 0o010;
+ pub const IRWXG = 0o070;
+ pub const IROTH = 0o004;
+ pub const IWOTH = 0o002;
+ pub const IXOTH = 0o001;
+ pub const IRWXO = 0o007;
+
+ pub fn ISREG(m: u32) bool {
+ return m & IFMT == IFREG;
+ }
+
+ pub fn ISDIR(m: u32) bool {
+ return m & IFMT == IFDIR;
+ }
+
+ pub fn ISCHR(m: u32) bool {
+ return m & IFMT == IFCHR;
+ }
+
+ pub fn ISBLK(m: u32) bool {
+ return m & IFMT == IFBLK;
+ }
+
+ pub fn ISFIFO(m: u32) bool {
+ return m & IFMT == IFIFO;
+ }
+
+ pub fn ISLNK(m: u32) bool {
+ return m & IFMT == IFLNK;
+ }
+
+ pub fn ISSOCK(m: u32) bool {
+ return m & IFMT == IFSOCK;
+ }
+};
+
+pub const UTIME = struct {
+ pub const NOW = 0x3fffffff;
+ pub const OMIT = 0x3ffffffe;
+};
+
+pub const TFD = struct {
+ pub const NONBLOCK = O.NONBLOCK;
+ pub const CLOEXEC = O.CLOEXEC;
+
+ pub const TIMER_ABSTIME = 1;
+ pub const TIMER_CANCEL_ON_SET = (1 << 1);
+};
+
+pub const winsize = extern struct {
+ ws_row: u16,
+ ws_col: u16,
+ ws_xpixel: u16,
+ ws_ypixel: u16,
+};
+
+/// NSIG is the total number of signals defined.
+/// As signal numbers are sequential, NSIG is one greater than the largest defined signal number.
+pub const NSIG = if (is_mips) 128 else 65;
+
+pub const sigset_t = [1024 / 32]u32;
+
+pub const all_mask: sigset_t = [_]u32{0xffffffff} ** sigset_t.len;
+pub const app_mask: sigset_t = [2]u32{ 0xfffffffc, 0x7fffffff } ++ [_]u32{0xffffffff} ** 30;
+
+pub const k_sigaction = switch (native_arch) {
+ .mips, .mipsel => extern struct {
+ flags: c_uint,
+ handler: ?fn (c_int) callconv(.C) void,
+ mask: [4]c_ulong,
+ restorer: fn () callconv(.C) void,
+ },
+ .mips64, .mips64el => extern struct {
+ flags: c_uint,
+ handler: ?fn (c_int) callconv(.C) void,
+ mask: [2]c_ulong,
+ restorer: fn () callconv(.C) void,
+ },
+ else => extern struct {
+ handler: ?fn (c_int) callconv(.C) void,
+ flags: c_ulong,
+ restorer: fn () callconv(.C) void,
+ mask: [2]c_uint,
+ },
+};
+
+/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.
+pub const Sigaction = extern struct {
+ pub const handler_fn = fn (c_int) callconv(.C) void;
+ pub const sigaction_fn = fn (c_int, *const siginfo_t, ?*const c_void) callconv(.C) void;
+
+ handler: extern union {
+ handler: ?handler_fn,
+ sigaction: ?sigaction_fn,
+ },
+ mask: sigset_t,
+ flags: c_uint,
+ restorer: ?fn () callconv(.C) void = null,
+};
+
+pub const empty_sigset = [_]u32{0} ** @typeInfo(sigset_t).Array.len;
+
+pub const SFD = struct {
+ pub const CLOEXEC = O.CLOEXEC;
+ pub const NONBLOCK = O.NONBLOCK;
+};
+
+pub const signalfd_siginfo = extern struct {
+ signo: u32,
+ errno: i32,
+ code: i32,
+ pid: u32,
+ uid: uid_t,
+ fd: i32,
+ tid: u32,
+ band: u32,
+ overrun: u32,
+ trapno: u32,
+ status: i32,
+ int: i32,
+ ptr: u64,
+ utime: u64,
+ stime: u64,
+ addr: u64,
+ addr_lsb: u16,
+ __pad2: u16,
+ syscall: i32,
+ call_addr: u64,
+ native_arch: u32,
+ __pad: [28]u8,
+};
+
+pub const in_port_t = u16;
+pub const sa_family_t = u16;
+pub const socklen_t = u32;
+
+pub const sockaddr = extern struct {
+ family: sa_family_t,
+ data: [14]u8,
+
+ pub const storage = std.x.os.Socket.Address.Native.Storage;
+
+ /// IPv4 socket address
+ pub const in = extern struct {
+ family: sa_family_t = AF.INET,
+ port: in_port_t,
+ addr: u32,
+ zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },
+ };
+
+ /// IPv6 socket address
+ pub const in6 = extern struct {
+ family: sa_family_t = AF.INET6,
+ port: in_port_t,
+ flowinfo: u32,
+ addr: [16]u8,
+ scope_id: u32,
+ };
+
+ /// UNIX domain socket address
+ pub const un = extern struct {
+ family: sa_family_t = AF.UNIX,
+ path: [108]u8,
+ };
+
+ /// Netlink socket address
+ pub const nl = extern struct {
+ family: sa_family_t = AF.NETLINK,
+ __pad1: c_ushort = 0,
+
+ /// port ID
+ pid: u32,
+
+ /// multicast groups mask
+ groups: u32,
+ };
+
+ pub const xdp = extern struct {
+ family: u16 = AF.XDP,
+ flags: u16,
+ ifindex: u32,
+ queue_id: u32,
+ shared_umem_fd: u32,
+ };
+};
+
+pub const mmsghdr = extern struct {
+ msg_hdr: msghdr,
+ msg_len: u32,
+};
+
+pub const mmsghdr_const = extern struct {
+ msg_hdr: msghdr_const,
+ msg_len: u32,
+};
+
+pub const epoll_data = extern union {
+ ptr: usize,
+ fd: i32,
+ @"u32": u32,
+ @"u64": u64,
+};
+
+// On x86_64 the structure is packed so that it matches the definition of its
+// 32bit counterpart
+pub const epoll_event = switch (native_arch) {
+ .x86_64 => packed struct {
+ events: u32,
+ data: epoll_data,
+ },
+ else => extern struct {
+ events: u32,
+ data: epoll_data,
+ },
+};
+
+pub const VFS_CAP_REVISION_MASK = 0xFF000000;
+pub const VFS_CAP_REVISION_SHIFT = 24;
+pub const VFS_CAP_FLAGS_MASK = ~VFS_CAP_REVISION_MASK;
+pub const VFS_CAP_FLAGS_EFFECTIVE = 0x000001;
+
+pub const VFS_CAP_REVISION_1 = 0x01000000;
+pub const VFS_CAP_U32_1 = 1;
+pub const XATTR_CAPS_SZ_1 = @sizeOf(u32) * (1 + 2 * VFS_CAP_U32_1);
+
+pub const VFS_CAP_REVISION_2 = 0x02000000;
+pub const VFS_CAP_U32_2 = 2;
+pub const XATTR_CAPS_SZ_2 = @sizeOf(u32) * (1 + 2 * VFS_CAP_U32_2);
+
+pub const XATTR_CAPS_SZ = XATTR_CAPS_SZ_2;
+pub const VFS_CAP_U32 = VFS_CAP_U32_2;
+pub const VFS_CAP_REVISION = VFS_CAP_REVISION_2;
+
+pub const vfs_cap_data = extern struct {
+ //all of these are mandated as little endian
+ //when on disk.
+ const Data = struct {
+ permitted: u32,
+ inheritable: u32,
+ };
+
+ magic_etc: u32,
+ data: [VFS_CAP_U32]Data,
+};
+
+pub const CAP = struct {
+ pub const CHOWN = 0;
+ pub const DAC_OVERRIDE = 1;
+ pub const DAC_READ_SEARCH = 2;
+ pub const FOWNER = 3;
+ pub const FSETID = 4;
+ pub const KILL = 5;
+ pub const SETGID = 6;
+ pub const SETUID = 7;
+ pub const SETPCAP = 8;
+ pub const LINUX_IMMUTABLE = 9;
+ pub const NET_BIND_SERVICE = 10;
+ pub const NET_BROADCAST = 11;
+ pub const NET_ADMIN = 12;
+ pub const NET_RAW = 13;
+ pub const IPC_LOCK = 14;
+ pub const IPC_OWNER = 15;
+ pub const SYS_MODULE = 16;
+ pub const SYS_RAWIO = 17;
+ pub const SYS_CHROOT = 18;
+ pub const SYS_PTRACE = 19;
+ pub const SYS_PACCT = 20;
+ pub const SYS_ADMIN = 21;
+ pub const SYS_BOOT = 22;
+ pub const SYS_NICE = 23;
+ pub const SYS_RESOURCE = 24;
+ pub const SYS_TIME = 25;
+ pub const SYS_TTY_CONFIG = 26;
+ pub const MKNOD = 27;
+ pub const LEASE = 28;
+ pub const AUDIT_WRITE = 29;
+ pub const AUDIT_CONTROL = 30;
+ pub const SETFCAP = 31;
+ pub const MAC_OVERRIDE = 32;
+ pub const MAC_ADMIN = 33;
+ pub const SYSLOG = 34;
+ pub const WAKE_ALARM = 35;
+ pub const BLOCK_SUSPEND = 36;
+ pub const AUDIT_READ = 37;
+ pub const LAST_CAP = AUDIT_READ;
+
+ pub fn valid(x: u8) bool {
+ return x >= 0 and x <= LAST_CAP;
+ }
+
+ pub fn TO_MASK(cap: u8) u32 {
+ return @as(u32, 1) << @intCast(u5, cap & 31);
+ }
+
+ pub fn TO_INDEX(cap: u8) u8 {
+ return cap >> 5;
+ }
+};
+
+pub const cap_t = extern struct {
+ hdrp: *cap_user_header_t,
+ datap: *cap_user_data_t,
+};
+
+pub const cap_user_header_t = extern struct {
+ version: u32,
+ pid: usize,
+};
+
+pub const cap_user_data_t = extern struct {
+ effective: u32,
+ permitted: u32,
+ inheritable: u32,
+};
+
+pub const inotify_event = extern struct {
+ wd: i32,
+ mask: u32,
+ cookie: u32,
+ len: u32,
+ //name: [?]u8,
+};
+
+pub const dirent64 = extern struct {
+ d_ino: u64,
+ d_off: u64,
+ d_reclen: u16,
+ d_type: u8,
+ d_name: u8, // field address is the address of first byte of name https://github.com/ziglang/zig/issues/173
+
+ pub fn reclen(self: dirent64) u16 {
+ return self.d_reclen;
}
+};
+
+pub const dl_phdr_info = extern struct {
+ dlpi_addr: usize,
+ dlpi_name: ?[*:0]const u8,
+ dlpi_phdr: [*]std.elf.Phdr,
+ dlpi_phnum: u16,
+};
+
+pub const CPU_SETSIZE = 128;
+pub const cpu_set_t = [CPU_SETSIZE / @sizeOf(usize)]usize;
+pub const cpu_count_t = std.meta.Int(.unsigned, std.math.log2(CPU_SETSIZE * 8));
+
+pub fn CPU_COUNT(set: cpu_set_t) cpu_count_t {
+ var sum: cpu_count_t = 0;
+ for (set) |x| {
+ sum += @popCount(usize, x);
+ }
+ return sum;
}
+
+pub const MINSIGSTKSZ = switch (native_arch) {
+ .i386, .x86_64, .arm, .mipsel => 2048,
+ .aarch64 => 5120,
+ else => @compileError("MINSIGSTKSZ not defined for this architecture"),
+};
+pub const SIGSTKSZ = switch (native_arch) {
+ .i386, .x86_64, .arm, .mipsel => 8192,
+ .aarch64 => 16384,
+ else => @compileError("SIGSTKSZ not defined for this architecture"),
+};
+
+pub const SS_ONSTACK = 1;
+pub const SS_DISABLE = 2;
+pub const SS_AUTODISARM = 1 << 31;
+
+pub const stack_t = if (is_mips)
+ // IRIX compatible stack_t
+ extern struct {
+ sp: [*]u8,
+ size: usize,
+ flags: i32,
+ }
+else
+ extern struct {
+ sp: [*]u8,
+ flags: i32,
+ size: usize,
+ };
+
+pub const sigval = extern union {
+ int: i32,
+ ptr: *c_void,
+};
+
+const siginfo_fields_union = extern union {
+ pad: [128 - 2 * @sizeOf(c_int) - @sizeOf(c_long)]u8,
+ common: extern struct {
+ first: extern union {
+ piduid: extern struct {
+ pid: pid_t,
+ uid: uid_t,
+ },
+ timer: extern struct {
+ timerid: i32,
+ overrun: i32,
+ },
+ },
+ second: extern union {
+ value: sigval,
+ sigchld: extern struct {
+ status: i32,
+ utime: clock_t,
+ stime: clock_t,
+ },
+ },
+ },
+ sigfault: extern struct {
+ addr: *c_void,
+ addr_lsb: i16,
+ first: extern union {
+ addr_bnd: extern struct {
+ lower: *c_void,
+ upper: *c_void,
+ },
+ pkey: u32,
+ },
+ },
+ sigpoll: extern struct {
+ band: isize,
+ fd: i32,
+ },
+ sigsys: extern struct {
+ call_addr: *c_void,
+ syscall: i32,
+ native_arch: u32,
+ },
+};
+
+pub const siginfo_t = if (is_mips)
+ extern struct {
+ signo: i32,
+ code: i32,
+ errno: i32,
+ fields: siginfo_fields_union,
+ }
+else
+ extern struct {
+ signo: i32,
+ errno: i32,
+ code: i32,
+ fields: siginfo_fields_union,
+ };
+
+pub const io_uring_params = extern struct {
+ sq_entries: u32,
+ cq_entries: u32,
+ flags: u32,
+ sq_thread_cpu: u32,
+ sq_thread_idle: u32,
+ features: u32,
+ wq_fd: u32,
+ resv: [3]u32,
+ sq_off: io_sqring_offsets,
+ cq_off: io_cqring_offsets,
+};
+
+// io_uring_params.features flags
+
+pub const IORING_FEAT_SINGLE_MMAP = 1 << 0;
+pub const IORING_FEAT_NODROP = 1 << 1;
+pub const IORING_FEAT_SUBMIT_STABLE = 1 << 2;
+pub const IORING_FEAT_RW_CUR_POS = 1 << 3;
+pub const IORING_FEAT_CUR_PERSONALITY = 1 << 4;
+pub const IORING_FEAT_FAST_POLL = 1 << 5;
+pub const IORING_FEAT_POLL_32BITS = 1 << 6;
+
+// io_uring_params.flags
+
+/// io_context is polled
+pub const IORING_SETUP_IOPOLL = 1 << 0;
+
+/// SQ poll thread
+pub const IORING_SETUP_SQPOLL = 1 << 1;
+
+/// sq_thread_cpu is valid
+pub const IORING_SETUP_SQ_AFF = 1 << 2;
+
+/// app defines CQ size
+pub const IORING_SETUP_CQSIZE = 1 << 3;
+
+/// clamp SQ/CQ ring sizes
+pub const IORING_SETUP_CLAMP = 1 << 4;
+
+/// attach to existing wq
+pub const IORING_SETUP_ATTACH_WQ = 1 << 5;
+
+/// start with ring disabled
+pub const IORING_SETUP_R_DISABLED = 1 << 6;
+
+pub const io_sqring_offsets = extern struct {
+ /// offset of ring head
+ head: u32,
+
+ /// offset of ring tail
+ tail: u32,
+
+ /// ring mask value
+ ring_mask: u32,
+
+ /// entries in ring
+ ring_entries: u32,
+
+ /// ring flags
+ flags: u32,
+
+ /// number of sqes not submitted
+ dropped: u32,
+
+ /// sqe index array
+ array: u32,
+
+ resv1: u32,
+ resv2: u64,
+};
+
+// io_sqring_offsets.flags
+
+/// needs io_uring_enter wakeup
+pub const IORING_SQ_NEED_WAKEUP = 1 << 0;
+
+/// kernel has cqes waiting beyond the cq ring
+pub const IORING_SQ_CQ_OVERFLOW = 1 << 1;
+
+pub const io_cqring_offsets = extern struct {
+ head: u32,
+ tail: u32,
+ ring_mask: u32,
+ ring_entries: u32,
+ overflow: u32,
+ cqes: u32,
+ resv: [2]u64,
+};
+
+pub const io_uring_sqe = extern struct {
+ opcode: IORING_OP,
+ flags: u8,
+ ioprio: u16,
+ fd: i32,
+ off: u64,
+ addr: u64,
+ len: u32,
+ rw_flags: u32,
+ user_data: u64,
+ buf_index: u16,
+ personality: u16,
+ splice_fd_in: i32,
+ __pad2: [2]u64,
+};
+
+pub const IOSQE_BIT = enum(u8) {
+ FIXED_FILE,
+ IO_DRAIN,
+ IO_LINK,
+ IO_HARDLINK,
+ ASYNC,
+ BUFFER_SELECT,
+
+ _,
+};
+
+// io_uring_sqe.flags
+
+/// use fixed fileset
+pub const IOSQE_FIXED_FILE = 1 << @enumToInt(IOSQE_BIT.FIXED_FILE);
+
+/// issue after inflight IO
+pub const IOSQE_IO_DRAIN = 1 << @enumToInt(IOSQE_BIT.IO_DRAIN);
+
+/// links next sqe
+pub const IOSQE_IO_LINK = 1 << @enumToInt(IOSQE_BIT.IO_LINK);
+
+/// like LINK, but stronger
+pub const IOSQE_IO_HARDLINK = 1 << @enumToInt(IOSQE_BIT.IO_HARDLINK);
+
+/// always go async
+pub const IOSQE_ASYNC = 1 << @enumToInt(IOSQE_BIT.ASYNC);
+
+/// select buffer from buf_group
+pub const IOSQE_BUFFER_SELECT = 1 << @enumToInt(IOSQE_BIT.BUFFER_SELECT);
+
+pub const IORING_OP = enum(u8) {
+ NOP,
+ READV,
+ WRITEV,
+ FSYNC,
+ READ_FIXED,
+ WRITE_FIXED,
+ POLL_ADD,
+ POLL_REMOVE,
+ SYNC_FILE_RANGE,
+ SENDMSG,
+ RECVMSG,
+ TIMEOUT,
+ TIMEOUT_REMOVE,
+ ACCEPT,
+ ASYNC_CANCEL,
+ LINK_TIMEOUT,
+ CONNECT,
+ FALLOCATE,
+ OPENAT,
+ CLOSE,
+ FILES_UPDATE,
+ STATX,
+ READ,
+ WRITE,
+ FADVISE,
+ MADVISE,
+ SEND,
+ RECV,
+ OPENAT2,
+ EPOLL_CTL,
+ SPLICE,
+ PROVIDE_BUFFERS,
+ REMOVE_BUFFERS,
+ TEE,
+
+ _,
+};
+
+// io_uring_sqe.fsync_flags
+pub const IORING_FSYNC_DATASYNC = 1 << 0;
+
+// io_uring_sqe.timeout_flags
+pub const IORING_TIMEOUT_ABS = 1 << 0;
+
+// IO completion data structure (Completion Queue Entry)
+pub const io_uring_cqe = extern struct {
+ /// io_uring_sqe.data submission passed back
+ user_data: u64,
+
+ /// result code for this event
+ res: i32,
+ flags: u32,
+
+ pub fn err(self: io_uring_cqe) E {
+ if (self.res > -4096 and self.res < 0) {
+ return @intToEnum(E, -self.res);
+ }
+ return .SUCCESS;
+ }
+};
+
+// io_uring_cqe.flags
+
+/// If set, the upper 16 bits are the buffer ID
+pub const IORING_CQE_F_BUFFER = 1 << 0;
+
+pub const IORING_OFF_SQ_RING = 0;
+pub const IORING_OFF_CQ_RING = 0x8000000;
+pub const IORING_OFF_SQES = 0x10000000;
+
+// io_uring_enter flags
+pub const IORING_ENTER_GETEVENTS = 1 << 0;
+pub const IORING_ENTER_SQ_WAKEUP = 1 << 1;
+
+// io_uring_register opcodes and arguments
+pub const IORING_REGISTER = enum(u8) {
+ REGISTER_BUFFERS,
+ UNREGISTER_BUFFERS,
+ REGISTER_FILES,
+ UNREGISTER_FILES,
+ REGISTER_EVENTFD,
+ UNREGISTER_EVENTFD,
+ REGISTER_FILES_UPDATE,
+ REGISTER_EVENTFD_ASYNC,
+ REGISTER_PROBE,
+ REGISTER_PERSONALITY,
+ UNREGISTER_PERSONALITY,
+ REGISTER_RESTRICTIONS,
+ REGISTER_ENABLE_RINGS,
+
+ _,
+};
+
+pub const io_uring_files_update = extern struct {
+ offset: u32,
+ resv: u32,
+ fds: u64,
+};
+
+pub const IO_URING_OP_SUPPORTED = 1 << 0;
+
+pub const io_uring_probe_op = extern struct {
+ op: IORING_OP,
+
+ resv: u8,
+
+ /// IO_URING_OP_* flags
+ flags: u16,
+
+ resv2: u32,
+};
+
+pub const io_uring_probe = extern struct {
+ /// last opcode supported
+ last_op: IORING_OP,
+
+ /// Number of io_uring_probe_op following
+ ops_len: u8,
+
+ resv: u16,
+ resv2: u32[3],
+
+ // Followed by up to `ops_len` io_uring_probe_op structures
+};
+
+pub const io_uring_restriction = extern struct {
+ opcode: u16,
+ arg: extern union {
+ /// IORING_RESTRICTION_REGISTER_OP
+ register_op: IORING_REGISTER,
+
+ /// IORING_RESTRICTION_SQE_OP
+ sqe_op: IORING_OP,
+
+ /// IORING_RESTRICTION_SQE_FLAGS_*
+ sqe_flags: u8,
+ },
+ resv: u8,
+ resv2: u32[3],
+};
+
+/// io_uring_restriction->opcode values
+pub const IORING_RESTRICTION = enum(u8) {
+ /// Allow an io_uring_register(2) opcode
+ REGISTER_OP = 0,
+
+ /// Allow an sqe opcode
+ SQE_OP = 1,
+
+ /// Allow sqe flags
+ SQE_FLAGS_ALLOWED = 2,
+
+ /// Require sqe flags (these flags must be set on each submission)
+ SQE_FLAGS_REQUIRED = 3,
+
+ _,
+};
+
+pub const utsname = extern struct {
+ sysname: [64:0]u8,
+ nodename: [64:0]u8,
+ release: [64:0]u8,
+ version: [64:0]u8,
+ machine: [64:0]u8,
+ domainname: [64:0]u8,
+};
+pub const HOST_NAME_MAX = 64;
+
+pub const STATX_TYPE = 0x0001;
+pub const STATX_MODE = 0x0002;
+pub const STATX_NLINK = 0x0004;
+pub const STATX_UID = 0x0008;
+pub const STATX_GID = 0x0010;
+pub const STATX_ATIME = 0x0020;
+pub const STATX_MTIME = 0x0040;
+pub const STATX_CTIME = 0x0080;
+pub const STATX_INO = 0x0100;
+pub const STATX_SIZE = 0x0200;
+pub const STATX_BLOCKS = 0x0400;
+pub const STATX_BASIC_STATS = 0x07ff;
+
+pub const STATX_BTIME = 0x0800;
+
+pub const STATX_ATTR_COMPRESSED = 0x0004;
+pub const STATX_ATTR_IMMUTABLE = 0x0010;
+pub const STATX_ATTR_APPEND = 0x0020;
+pub const STATX_ATTR_NODUMP = 0x0040;
+pub const STATX_ATTR_ENCRYPTED = 0x0800;
+pub const STATX_ATTR_AUTOMOUNT = 0x1000;
+
+pub const statx_timestamp = extern struct {
+ tv_sec: i64,
+ tv_nsec: u32,
+ __pad1: u32,
+};
+
+/// Renamed to `Statx` to not conflict with the `statx` function.
+pub const Statx = extern struct {
+ /// Mask of bits indicating filled fields
+ mask: u32,
+
+ /// Block size for filesystem I/O
+ blksize: u32,
+
+ /// Extra file attribute indicators
+ attributes: u64,
+
+ /// Number of hard links
+ nlink: u32,
+
+ /// User ID of owner
+ uid: uid_t,
+
+ /// Group ID of owner
+ gid: gid_t,
+
+ /// File type and mode
+ mode: u16,
+ __pad1: u16,
+
+ /// Inode number
+ ino: u64,
+
+ /// Total size in bytes
+ size: u64,
+
+ /// Number of 512B blocks allocated
+ blocks: u64,
+
+ /// Mask to show what's supported in `attributes`.
+ attributes_mask: u64,
+
+ /// Last access file timestamp
+ atime: statx_timestamp,
+
+ /// Creation file timestamp
+ btime: statx_timestamp,
+
+ /// Last status change file timestamp
+ ctime: statx_timestamp,
+
+ /// Last modification file timestamp
+ mtime: statx_timestamp,
+
+ /// Major ID, if this file represents a device.
+ rdev_major: u32,
+
+ /// Minor ID, if this file represents a device.
+ rdev_minor: u32,
+
+ /// Major ID of the device containing the filesystem where this file resides.
+ dev_major: u32,
+
+ /// Minor ID of the device containing the filesystem where this file resides.
+ dev_minor: u32,
+
+ __pad2: [14]u64,
+};
+
+pub const addrinfo = extern struct {
+ flags: i32,
+ family: i32,
+ socktype: i32,
+ protocol: i32,
+ addrlen: socklen_t,
+ addr: ?*sockaddr,
+ canonname: ?[*:0]u8,
+ next: ?*addrinfo,
+};
+
+pub const IPPORT_RESERVED = 1024;
+
+pub const IPPROTO = struct {
+ pub const IP = 0;
+ pub const HOPOPTS = 0;
+ pub const ICMP = 1;
+ pub const IGMP = 2;
+ pub const IPIP = 4;
+ pub const TCP = 6;
+ pub const EGP = 8;
+ pub const PUP = 12;
+ pub const UDP = 17;
+ pub const IDP = 22;
+ pub const TP = 29;
+ pub const DCCP = 33;
+ pub const IPV6 = 41;
+ pub const ROUTING = 43;
+ pub const FRAGMENT = 44;
+ pub const RSVP = 46;
+ pub const GRE = 47;
+ pub const ESP = 50;
+ pub const AH = 51;
+ pub const ICMPV6 = 58;
+ pub const NONE = 59;
+ pub const DSTOPTS = 60;
+ pub const MTP = 92;
+ pub const BEETPH = 94;
+ pub const ENCAP = 98;
+ pub const PIM = 103;
+ pub const COMP = 108;
+ pub const SCTP = 132;
+ pub const MH = 135;
+ pub const UDPLITE = 136;
+ pub const MPLS = 137;
+ pub const RAW = 255;
+ pub const MAX = 256;
+};
+
+pub const RR = struct {
+ pub const A = 1;
+ pub const CNAME = 5;
+ pub const AAAA = 28;
+};
+
+/// Turn off Nagle's algorithm
+pub const TCP_NODELAY = 1;
+/// Limit MSS
+pub const TCP_MAXSEG = 2;
+/// Never send partially complete segments.
+pub const TCP_CORK = 3;
+/// Start keeplives after this period, in seconds
+pub const TCP_KEEPIDLE = 4;
+/// Interval between keepalives
+pub const TCP_KEEPINTVL = 5;
+/// Number of keepalives before death
+pub const TCP_KEEPCNT = 6;
+/// Number of SYN retransmits
+pub const TCP_SYNCNT = 7;
+/// Life time of orphaned FIN-WAIT-2 state
+pub const TCP_LINGER2 = 8;
+/// Wake up listener only when data arrive
+pub const TCP_DEFER_ACCEPT = 9;
+/// Bound advertised window
+pub const TCP_WINDOW_CLAMP = 10;
+/// Information about this connection.
+pub const TCP_INFO = 11;
+/// Block/reenable quick acks
+pub const TCP_QUICKACK = 12;
+/// Congestion control algorithm
+pub const TCP_CONGESTION = 13;
+/// TCP MD5 Signature (RFC2385)
+pub const TCP_MD5SIG = 14;
+/// Use linear timeouts for thin streams
+pub const TCP_THIN_LINEAR_TIMEOUTS = 16;
+/// Fast retrans. after 1 dupack
+pub const TCP_THIN_DUPACK = 17;
+/// How long for loss retry before timeout
+pub const TCP_USER_TIMEOUT = 18;
+/// TCP sock is under repair right now
+pub const TCP_REPAIR = 19;
+pub const TCP_REPAIR_QUEUE = 20;
+pub const TCP_QUEUE_SEQ = 21;
+pub const TCP_REPAIR_OPTIONS = 22;
+/// Enable FastOpen on listeners
+pub const TCP_FASTOPEN = 23;
+pub const TCP_TIMESTAMP = 24;
+/// limit number of unsent bytes in write queue
+pub const TCP_NOTSENT_LOWAT = 25;
+/// Get Congestion Control (optional) info
+pub const TCP_CC_INFO = 26;
+/// Record SYN headers for new connections
+pub const TCP_SAVE_SYN = 27;
+/// Get SYN headers recorded for connection
+pub const TCP_SAVED_SYN = 28;
+/// Get/set window parameters
+pub const TCP_REPAIR_WINDOW = 29;
+/// Attempt FastOpen with connect
+pub const TCP_FASTOPEN_CONNECT = 30;
+/// Attach a ULP to a TCP connection
+pub const TCP_ULP = 31;
+/// TCP MD5 Signature with extensions
+pub const TCP_MD5SIG_EXT = 32;
+/// Set the key for Fast Open (cookie)
+pub const TCP_FASTOPEN_KEY = 33;
+/// Enable TFO without a TFO cookie
+pub const TCP_FASTOPEN_NO_COOKIE = 34;
+pub const TCP_ZEROCOPY_RECEIVE = 35;
+/// Notify bytes available to read as a cmsg on read
+pub const TCP_INQ = 36;
+pub const TCP_CM_INQ = TCP_INQ;
+/// delay outgoing packets by XX usec
+pub const TCP_TX_DELAY = 37;
+
+pub const TCP_REPAIR_ON = 1;
+pub const TCP_REPAIR_OFF = 0;
+/// Turn off without window probes
+pub const TCP_REPAIR_OFF_NO_WP = -1;
+
+pub const tcp_repair_opt = extern struct {
+ opt_code: u32,
+ opt_val: u32,
+};
+
+pub const tcp_repair_window = extern struct {
+ snd_wl1: u32,
+ snd_wnd: u32,
+ max_window: u32,
+ rcv_wnd: u32,
+ rcv_wup: u32,
+};
+
+pub const TcpRepairOption = enum {
+ TCP_NO_QUEUE,
+ TCP_RECV_QUEUE,
+ TCP_SEND_QUEUE,
+ TCP_QUEUES_NR,
+};
+
+/// why fastopen failed from client perspective
+pub const tcp_fastopen_client_fail = enum {
+ /// catch-all
+ TFO_STATUS_UNSPEC,
+ /// if not in TFO_CLIENT_NO_COOKIE mode
+ TFO_COOKIE_UNAVAILABLE,
+ /// SYN-ACK did not ack SYN data
+ TFO_DATA_NOT_ACKED,
+ /// SYN-ACK did not ack SYN data after timeout
+ TFO_SYN_RETRANSMITTED,
+};
+
+/// for TCP_INFO socket option
+pub const TCPI_OPT_TIMESTAMPS = 1;
+pub const TCPI_OPT_SACK = 2;
+pub const TCPI_OPT_WSCALE = 4;
+/// ECN was negociated at TCP session init
+pub const TCPI_OPT_ECN = 8;
+/// we received at least one packet with ECT
+pub const TCPI_OPT_ECN_SEEN = 16;
+/// SYN-ACK acked data in SYN sent or rcvd
+pub const TCPI_OPT_SYN_DATA = 32;
+
+pub const nfds_t = usize;
+pub const pollfd = extern struct {
+ fd: fd_t,
+ events: i16,
+ revents: i16,
+};
+
+pub const POLL = struct {
+ pub const IN = 0x001;
+ pub const PRI = 0x002;
+ pub const OUT = 0x004;
+ pub const ERR = 0x008;
+ pub const HUP = 0x010;
+ pub const NVAL = 0x020;
+ pub const RDNORM = 0x040;
+ pub const RDBAND = 0x080;
+};
+
+pub const MFD_CLOEXEC = 0x0001;
+pub const MFD_ALLOW_SEALING = 0x0002;
+pub const MFD_HUGETLB = 0x0004;
+pub const MFD_ALL_FLAGS = MFD_CLOEXEC | MFD_ALLOW_SEALING | MFD_HUGETLB;
+
+pub const HUGETLB_FLAG_ENCODE_SHIFT = 26;
+pub const HUGETLB_FLAG_ENCODE_MASK = 0x3f;
+pub const HUGETLB_FLAG_ENCODE_64KB = 16 << HUGETLB_FLAG_ENCODE_SHIFT;
+pub const HUGETLB_FLAG_ENCODE_512KB = 19 << HUGETLB_FLAG_ENCODE_SHIFT;
+pub const HUGETLB_FLAG_ENCODE_1MB = 20 << HUGETLB_FLAG_ENCODE_SHIFT;
+pub const HUGETLB_FLAG_ENCODE_2MB = 21 << HUGETLB_FLAG_ENCODE_SHIFT;
+pub const HUGETLB_FLAG_ENCODE_8MB = 23 << HUGETLB_FLAG_ENCODE_SHIFT;
+pub const HUGETLB_FLAG_ENCODE_16MB = 24 << HUGETLB_FLAG_ENCODE_SHIFT;
+pub const HUGETLB_FLAG_ENCODE_32MB = 25 << HUGETLB_FLAG_ENCODE_SHIFT;
+pub const HUGETLB_FLAG_ENCODE_256MB = 28 << HUGETLB_FLAG_ENCODE_SHIFT;
+pub const HUGETLB_FLAG_ENCODE_512MB = 29 << HUGETLB_FLAG_ENCODE_SHIFT;
+pub const HUGETLB_FLAG_ENCODE_1GB = 30 << HUGETLB_FLAG_ENCODE_SHIFT;
+pub const HUGETLB_FLAG_ENCODE_2GB = 31 << HUGETLB_FLAG_ENCODE_SHIFT;
+pub const HUGETLB_FLAG_ENCODE_16GB = 34 << HUGETLB_FLAG_ENCODE_SHIFT;
+
+pub const MFD_HUGE_SHIFT = HUGETLB_FLAG_ENCODE_SHIFT;
+pub const MFD_HUGE_MASK = HUGETLB_FLAG_ENCODE_MASK;
+pub const MFD_HUGE_64KB = HUGETLB_FLAG_ENCODE_64KB;
+pub const MFD_HUGE_512KB = HUGETLB_FLAG_ENCODE_512KB;
+pub const MFD_HUGE_1MB = HUGETLB_FLAG_ENCODE_1MB;
+pub const MFD_HUGE_2MB = HUGETLB_FLAG_ENCODE_2MB;
+pub const MFD_HUGE_8MB = HUGETLB_FLAG_ENCODE_8MB;
+pub const MFD_HUGE_16MB = HUGETLB_FLAG_ENCODE_16MB;
+pub const MFD_HUGE_32MB = HUGETLB_FLAG_ENCODE_32MB;
+pub const MFD_HUGE_256MB = HUGETLB_FLAG_ENCODE_256MB;
+pub const MFD_HUGE_512MB = HUGETLB_FLAG_ENCODE_512MB;
+pub const MFD_HUGE_1GB = HUGETLB_FLAG_ENCODE_1GB;
+pub const MFD_HUGE_2GB = HUGETLB_FLAG_ENCODE_2GB;
+pub const MFD_HUGE_16GB = HUGETLB_FLAG_ENCODE_16GB;
+
+pub const RUSAGE_SELF = 0;
+pub const RUSAGE_CHILDREN = -1;
+pub const RUSAGE_THREAD = 1;
+
+pub const rusage = extern struct {
+ utime: timeval,
+ stime: timeval,
+ maxrss: isize,
+ ixrss: isize,
+ idrss: isize,
+ isrss: isize,
+ minflt: isize,
+ majflt: isize,
+ nswap: isize,
+ inblock: isize,
+ oublock: isize,
+ msgsnd: isize,
+ msgrcv: isize,
+ nsignals: isize,
+ nvcsw: isize,
+ nivcsw: isize,
+ __reserved: [16]isize = [1]isize{0} ** 16,
+};
+
+pub const cc_t = u8;
+pub const speed_t = u32;
+pub const tcflag_t = u32;
+
+pub const NCCS = 32;
+
+pub const B0 = 0o0000000;
+pub const B50 = 0o0000001;
+pub const B75 = 0o0000002;
+pub const B110 = 0o0000003;
+pub const B134 = 0o0000004;
+pub const B150 = 0o0000005;
+pub const B200 = 0o0000006;
+pub const B300 = 0o0000007;
+pub const B600 = 0o0000010;
+pub const B1200 = 0o0000011;
+pub const B1800 = 0o0000012;
+pub const B2400 = 0o0000013;
+pub const B4800 = 0o0000014;
+pub const B9600 = 0o0000015;
+pub const B19200 = 0o0000016;
+pub const B38400 = 0o0000017;
+pub const BOTHER = 0o0010000;
+pub const B57600 = 0o0010001;
+pub const B115200 = 0o0010002;
+pub const B230400 = 0o0010003;
+pub const B460800 = 0o0010004;
+pub const B500000 = 0o0010005;
+pub const B576000 = 0o0010006;
+pub const B921600 = 0o0010007;
+pub const B1000000 = 0o0010010;
+pub const B1152000 = 0o0010011;
+pub const B1500000 = 0o0010012;
+pub const B2000000 = 0o0010013;
+pub const B2500000 = 0o0010014;
+pub const B3000000 = 0o0010015;
+pub const B3500000 = 0o0010016;
+pub const B4000000 = 0o0010017;
+
+pub const V = switch (native_arch) {
+ .powerpc, .powerpc64, .powerpc64le => struct {
+ pub const INTR = 0;
+ pub const QUIT = 1;
+ pub const ERASE = 2;
+ pub const KILL = 3;
+ pub const EOF = 4;
+ pub const MIN = 5;
+ pub const EOL = 6;
+ pub const TIME = 7;
+ pub const EOL2 = 8;
+ pub const SWTC = 9;
+ pub const WERASE = 10;
+ pub const REPRINT = 11;
+ pub const SUSP = 12;
+ pub const START = 13;
+ pub const STOP = 14;
+ pub const LNEXT = 15;
+ pub const DISCARD = 16;
+ },
+ .sparc, .sparcv9 => struct {
+ pub const INTR = 0;
+ pub const QUIT = 1;
+ pub const ERASE = 2;
+ pub const KILL = 3;
+ pub const EOF = 4;
+ pub const EOL = 5;
+ pub const EOL2 = 6;
+ pub const SWTC = 7;
+ pub const START = 8;
+ pub const STOP = 9;
+ pub const SUSP = 10;
+ pub const DSUSP = 11;
+ pub const REPRINT = 12;
+ pub const DISCARD = 13;
+ pub const WERASE = 14;
+ pub const LNEXT = 15;
+ pub const MIN = EOF;
+ pub const TIME = EOL;
+ },
+ .mips, .mipsel, .mips64, .mips64el => struct {
+ pub const INTR = 0;
+ pub const QUIT = 1;
+ pub const ERASE = 2;
+ pub const KILL = 3;
+ pub const MIN = 4;
+ pub const TIME = 5;
+ pub const EOL2 = 6;
+ pub const SWTC = 7;
+ pub const SWTCH = 7;
+ pub const START = 8;
+ pub const STOP = 9;
+ pub const SUSP = 10;
+ pub const REPRINT = 12;
+ pub const DISCARD = 13;
+ pub const WERASE = 14;
+ pub const LNEXT = 15;
+ pub const EOF = 16;
+ pub const EOL = 17;
+ },
+ else => struct {
+ pub const INTR = 0;
+ pub const QUIT = 1;
+ pub const ERASE = 2;
+ pub const KILL = 3;
+ pub const EOF = 4;
+ pub const TIME = 5;
+ pub const MIN = 6;
+ pub const SWTC = 7;
+ pub const START = 8;
+ pub const STOP = 9;
+ pub const SUSP = 10;
+ pub const EOL = 11;
+ pub const REPRINT = 12;
+ pub const DISCARD = 13;
+ pub const WERASE = 14;
+ pub const LNEXT = 15;
+ pub const EOL2 = 16;
+ },
+};
+
+pub const IGNBRK = 1;
+pub const BRKINT = 2;
+pub const IGNPAR = 4;
+pub const PARMRK = 8;
+pub const INPCK = 16;
+pub const ISTRIP = 32;
+pub const INLCR = 64;
+pub const IGNCR = 128;
+pub const ICRNL = 256;
+pub const IUCLC = 512;
+pub const IXON = 1024;
+pub const IXANY = 2048;
+pub const IXOFF = 4096;
+pub const IMAXBEL = 8192;
+pub const IUTF8 = 16384;
+
+pub const OPOST = 1;
+pub const OLCUC = 2;
+pub const ONLCR = 4;
+pub const OCRNL = 8;
+pub const ONOCR = 16;
+pub const ONLRET = 32;
+pub const OFILL = 64;
+pub const OFDEL = 128;
+pub const VTDLY = 16384;
+pub const VT0 = 0;
+pub const VT1 = 16384;
+
+pub const CSIZE = 48;
+pub const CS5 = 0;
+pub const CS6 = 16;
+pub const CS7 = 32;
+pub const CS8 = 48;
+pub const CSTOPB = 64;
+pub const CREAD = 128;
+pub const PARENB = 256;
+pub const PARODD = 512;
+pub const HUPCL = 1024;
+pub const CLOCAL = 2048;
+
+pub const ISIG = 1;
+pub const ICANON = 2;
+pub const ECHO = 8;
+pub const ECHOE = 16;
+pub const ECHOK = 32;
+pub const ECHONL = 64;
+pub const NOFLSH = 128;
+pub const TOSTOP = 256;
+pub const IEXTEN = 32768;
+
+pub const TCSA = enum(c_uint) {
+ NOW,
+ DRAIN,
+ FLUSH,
+ _,
+};
+
+pub const termios = extern struct {
+ iflag: tcflag_t,
+ oflag: tcflag_t,
+ cflag: tcflag_t,
+ lflag: tcflag_t,
+ line: cc_t,
+ cc: [NCCS]cc_t,
+ ispeed: speed_t,
+ ospeed: speed_t,
+};
+
+pub const SIOCGIFINDEX = 0x8933;
+pub const IFNAMESIZE = 16;
+
+pub const ifmap = extern struct {
+ mem_start: u32,
+ mem_end: u32,
+ base_addr: u16,
+ irq: u8,
+ dma: u8,
+ port: u8,
+};
+
+pub const ifreq = extern struct {
+ ifrn: extern union {
+ name: [IFNAMESIZE]u8,
+ },
+ ifru: extern union {
+ addr: sockaddr,
+ dstaddr: sockaddr,
+ broadaddr: sockaddr,
+ netmask: sockaddr,
+ hwaddr: sockaddr,
+ flags: i16,
+ ivalue: i32,
+ mtu: i32,
+ map: ifmap,
+ slave: [IFNAMESIZE - 1:0]u8,
+ newname: [IFNAMESIZE - 1:0]u8,
+ data: ?[*]u8,
+ },
+};
+
+// doc comments copied from musl
+pub const rlimit_resource = enum(c_int) {
+ /// Per-process CPU limit, in seconds.
+ CPU,
+
+ /// Largest file that can be created, in bytes.
+ FSIZE,
+
+ /// Maximum size of data segment, in bytes.
+ DATA,
+
+ /// Maximum size of stack segment, in bytes.
+ STACK,
+
+ /// Largest core file that can be created, in bytes.
+ CORE,
+
+ /// Largest resident set size, in bytes.
+ /// This affects swapping; processes that are exceeding their
+ /// resident set size will be more likely to have physical memory
+ /// taken from them.
+ RSS,
+
+ /// Number of processes.
+ NPROC,
+
+ /// Number of open files.
+ NOFILE,
+
+ /// Locked-in-memory address space.
+ MEMLOCK,
+
+ /// Address space limit.
+ AS,
+
+ /// Maximum number of file locks.
+ LOCKS,
+
+ /// Maximum number of pending signals.
+ SIGPENDING,
+
+ /// Maximum bytes in POSIX message queues.
+ MSGQUEUE,
+
+ /// Maximum nice priority allowed to raise to.
+ /// Nice levels 19 .. -20 correspond to 0 .. 39
+ /// values of this resource limit.
+ NICE,
+
+ /// Maximum realtime priority allowed for non-priviledged
+ /// processes.
+ RTPRIO,
+
+ /// Maximum CPU time in µs that a process scheduled under a real-time
+ /// scheduling policy may consume without making a blocking system
+ /// call before being forcibly descheduled.
+ RTTIME,
+
+ _,
+};
+
+pub const rlim_t = u64;
+
+pub const RLIM = struct {
+ /// No limit
+ pub const INFINITY = ~@as(rlim_t, 0);
+
+ pub const SAVED_MAX = INFINITY;
+ pub const SAVED_CUR = INFINITY;
+};
+
+pub const rlimit = extern struct {
+ /// Soft limit
+ cur: rlim_t,
+ /// Hard limit
+ max: rlim_t,
+};
+
+pub const MADV = struct {
+ pub const NORMAL = 0;
+ pub const RANDOM = 1;
+ pub const SEQUENTIAL = 2;
+ pub const WILLNEED = 3;
+ pub const DONTNEED = 4;
+ pub const FREE = 8;
+ pub const REMOVE = 9;
+ pub const DONTFORK = 10;
+ pub const DOFORK = 11;
+ pub const MERGEABLE = 12;
+ pub const UNMERGEABLE = 13;
+ pub const HUGEPAGE = 14;
+ pub const NOHUGEPAGE = 15;
+ pub const DONTDUMP = 16;
+ pub const DODUMP = 17;
+ pub const WIPEONFORK = 18;
+ pub const KEEPONFORK = 19;
+ pub const COLD = 20;
+ pub const PAGEOUT = 21;
+ pub const HWPOISON = 100;
+ pub const SOFT_OFFLINE = 101;
+};
+
+pub const POSIX_FADV = switch (native_arch) {
+ .s390x => if (@typeInfo(usize).Int.bits == 64) struct {
+ pub const NORMAL = 0;
+ pub const RANDOM = 1;
+ pub const SEQUENTIAL = 2;
+ pub const WILLNEED = 3;
+ pub const DONTNEED = 6;
+ pub const NOREUSE = 7;
+ } else struct {
+ pub const NORMAL = 0;
+ pub const RANDOM = 1;
+ pub const SEQUENTIAL = 2;
+ pub const WILLNEED = 3;
+ pub const DONTNEED = 4;
+ pub const NOREUSE = 5;
+ },
+ else => struct {
+ pub const NORMAL = 0;
+ pub const RANDOM = 1;
+ pub const SEQUENTIAL = 2;
+ pub const WILLNEED = 3;
+ pub const DONTNEED = 4;
+ pub const NOREUSE = 5;
+ },
+};
+
+/// The timespec struct used by the kernel.
+pub const kernel_timespec = if (@sizeOf(usize) >= 8) timespec else extern struct {
+ tv_sec: i64,
+ tv_nsec: i64,
+};
+
+pub const timespec = extern struct {
+ tv_sec: isize,
+ tv_nsec: isize,
+};
+
+pub const XDP = struct {
+ pub const SHARED_UMEM = (1 << 0);
+ pub const COPY = (1 << 1);
+ pub const ZEROCOPY = (1 << 2);
+ pub const UMEM_UNALIGNED_CHUNK_FLAG = (1 << 0);
+ pub const USE_NEED_WAKEUP = (1 << 3);
+
+ pub const MMAP_OFFSETS = 1;
+ pub const RX_RING = 2;
+ pub const TX_RING = 3;
+ pub const UMEM_REG = 4;
+ pub const UMEM_FILL_RING = 5;
+ pub const UMEM_COMPLETION_RING = 6;
+ pub const STATISTICS = 7;
+ pub const OPTIONS = 8;
+
+ pub const OPTIONS_ZEROCOPY = (1 << 0);
+
+ pub const PGOFF_RX_RING = 0;
+ pub const PGOFF_TX_RING = 0x80000000;
+ pub const UMEM_PGOFF_FILL_RING = 0x100000000;
+ pub const UMEM_PGOFF_COMPLETION_RING = 0x180000000;
+};
+
+pub const xdp_ring_offset = extern struct {
+ producer: u64,
+ consumer: u64,
+ desc: u64,
+ flags: u64,
+};
+
+pub const xdp_mmap_offsets = extern struct {
+ rx: xdp_ring_offset,
+ tx: xdp_ring_offset,
+ fr: xdp_ring_offset,
+ cr: xdp_ring_offset,
+};
+
+pub const xdp_umem_reg = extern struct {
+ addr: u64,
+ len: u64,
+ chunk_size: u32,
+ headroom: u32,
+ flags: u32,
+};
+
+pub const xdp_statistics = extern struct {
+ rx_dropped: u64,
+ rx_invalid_descs: u64,
+ tx_invalid_descs: u64,
+ rx_ring_full: u64,
+ rx_fill_ring_empty_descs: u64,
+ tx_ring_empty_descs: u64,
+};
+
+pub const xdp_options = extern struct {
+ flags: u32,
+};
+
+pub const XSK_UNALIGNED_BUF_OFFSET_SHIFT = 48;
+pub const XSK_UNALIGNED_BUF_ADDR_MASK = (1 << XSK_UNALIGNED_BUF_OFFSET_SHIFT) - 1;
+
+pub const xdp_desc = extern struct {
+ addr: u64,
+ len: u32,
+ options: u32,
+};
+
+fn issecure_mask(comptime x: comptime_int) comptime_int {
+ return 1 << x;
+}
+
+pub const SECUREBITS_DEFAULT = 0x00000000;
+
+pub const SECURE_NOROOT = 0;
+pub const SECURE_NOROOT_LOCKED = 1;
+
+pub const SECBIT_NOROOT = issecure_mask(SECURE_NOROOT);
+pub const SECBIT_NOROOT_LOCKED = issecure_mask(SECURE_NOROOT_LOCKED);
+
+pub const SECURE_NO_SETUID_FIXUP = 2;
+pub const SECURE_NO_SETUID_FIXUP_LOCKED = 3;
+
+pub const SECBIT_NO_SETUID_FIXUP = issecure_mask(SECURE_NO_SETUID_FIXUP);
+pub const SECBIT_NO_SETUID_FIXUP_LOCKED = issecure_mask(SECURE_NO_SETUID_FIXUP_LOCKED);
+
+pub const SECURE_KEEP_CAPS = 4;
+pub const SECURE_KEEP_CAPS_LOCKED = 5;
+
+pub const SECBIT_KEEP_CAPS = issecure_mask(SECURE_KEEP_CAPS);
+pub const SECBIT_KEEP_CAPS_LOCKED = issecure_mask(SECURE_KEEP_CAPS_LOCKED);
+
+pub const SECURE_NO_CAP_AMBIENT_RAISE = 6;
+pub const SECURE_NO_CAP_AMBIENT_RAISE_LOCKED = 7;
+
+pub const SECBIT_NO_CAP_AMBIENT_RAISE = issecure_mask(SECURE_NO_CAP_AMBIENT_RAISE);
+pub const SECBIT_NO_CAP_AMBIENT_RAISE_LOCKED = issecure_mask(SECURE_NO_CAP_AMBIENT_RAISE_LOCKED);
+
+pub const SECURE_ALL_BITS = issecure_mask(SECURE_NOROOT) |
+ issecure_mask(SECURE_NO_SETUID_FIXUP) |
+ issecure_mask(SECURE_KEEP_CAPS) |
+ issecure_mask(SECURE_NO_CAP_AMBIENT_RAISE);
+pub const SECURE_ALL_LOCKS = SECURE_ALL_BITS << 1;
+
+pub const PR = enum(i32) {
+ SET_PDEATHSIG = 1,
+ GET_PDEATHSIG = 2,
+
+ GET_DUMPABLE = 3,
+ SET_DUMPABLE = 4,
+
+ GET_UNALIGN = 5,
+ SET_UNALIGN = 6,
+
+ GET_KEEPCAPS = 7,
+ SET_KEEPCAPS = 8,
+
+ GET_FPEMU = 9,
+ SET_FPEMU = 10,
+
+ GET_FPEXC = 11,
+ SET_FPEXC = 12,
+
+ GET_TIMING = 13,
+ SET_TIMING = 14,
+
+ SET_NAME = 15,
+ GET_NAME = 16,
+
+ GET_ENDIAN = 19,
+ SET_ENDIAN = 20,
+
+ GET_SECCOMP = 21,
+ SET_SECCOMP = 22,
+
+ CAPBSET_READ = 23,
+ CAPBSET_DROP = 24,
+
+ GET_TSC = 25,
+ SET_TSC = 26,
+
+ GET_SECUREBITS = 27,
+ SET_SECUREBITS = 28,
+
+ SET_TIMERSLACK = 29,
+ GET_TIMERSLACK = 30,
+
+ TASK_PERF_EVENTS_DISABLE = 31,
+ TASK_PERF_EVENTS_ENABLE = 32,
+
+ MCE_KILL = 33,
+
+ MCE_KILL_GET = 34,
+
+ SET_MM = 35,
+
+ SET_PTRACER = 0x59616d61,
+
+ SET_CHILD_SUBREAPER = 36,
+ GET_CHILD_SUBREAPER = 37,
+
+ SET_NO_NEW_PRIVS = 38,
+ GET_NO_NEW_PRIVS = 39,
+
+ GET_TID_ADDRESS = 40,
+
+ SET_THP_DISABLE = 41,
+ GET_THP_DISABLE = 42,
+
+ MPX_ENABLE_MANAGEMENT = 43,
+ MPX_DISABLE_MANAGEMENT = 44,
+
+ SET_FP_MODE = 45,
+ GET_FP_MODE = 46,
+
+ CAP_AMBIENT = 47,
+
+ SVE_SET_VL = 50,
+ SVE_GET_VL = 51,
+
+ GET_SPECULATION_CTRL = 52,
+ SET_SPECULATION_CTRL = 53,
+
+ _,
+
+ pub const UNALIGN_NOPRINT = 1;
+ pub const UNALIGN_SIGBUS = 2;
+
+ pub const FPEMU_NOPRINT = 1;
+ pub const FPEMU_SIGFPE = 2;
+
+ pub const FP_EXC_SW_ENABLE = 0x80;
+ pub const FP_EXC_DIV = 0x010000;
+ pub const FP_EXC_OVF = 0x020000;
+ pub const FP_EXC_UND = 0x040000;
+ pub const FP_EXC_RES = 0x080000;
+ pub const FP_EXC_INV = 0x100000;
+ pub const FP_EXC_DISABLED = 0;
+ pub const FP_EXC_NONRECOV = 1;
+ pub const FP_EXC_ASYNC = 2;
+ pub const FP_EXC_PRECISE = 3;
+
+ pub const TIMING_STATISTICAL = 0;
+ pub const TIMING_TIMESTAMP = 1;
+
+ pub const ENDIAN_BIG = 0;
+ pub const ENDIAN_LITTLE = 1;
+ pub const ENDIAN_PPC_LITTLE = 2;
+
+ pub const TSC_ENABLE = 1;
+ pub const TSC_SIGSEGV = 2;
+
+ pub const MCE_KILL_CLEAR = 0;
+ pub const MCE_KILL_SET = 1;
+
+ pub const MCE_KILL_LATE = 0;
+ pub const MCE_KILL_EARLY = 1;
+ pub const MCE_KILL_DEFAULT = 2;
+
+ pub const SET_MM_START_CODE = 1;
+ pub const SET_MM_END_CODE = 2;
+ pub const SET_MM_START_DATA = 3;
+ pub const SET_MM_END_DATA = 4;
+ pub const SET_MM_START_STACK = 5;
+ pub const SET_MM_START_BRK = 6;
+ pub const SET_MM_BRK = 7;
+ pub const SET_MM_ARG_START = 8;
+ pub const SET_MM_ARG_END = 9;
+ pub const SET_MM_ENV_START = 10;
+ pub const SET_MM_ENV_END = 11;
+ pub const SET_MM_AUXV = 12;
+ pub const SET_MM_EXE_FILE = 13;
+ pub const SET_MM_MAP = 14;
+ pub const SET_MM_MAP_SIZE = 15;
+
+ pub const SET_PTRACER_ANY = std.math.maxInt(c_ulong);
+
+ pub const FP_MODE_FR = 1 << 0;
+ pub const FP_MODE_FRE = 1 << 1;
+
+ pub const CAP_AMBIENT_IS_SET = 1;
+ pub const CAP_AMBIENT_RAISE = 2;
+ pub const CAP_AMBIENT_LOWER = 3;
+ pub const CAP_AMBIENT_CLEAR_ALL = 4;
+
+ pub const SVE_SET_VL_ONEXEC = 1 << 18;
+ pub const SVE_VL_LEN_MASK = 0xffff;
+ pub const SVE_VL_INHERIT = 1 << 17;
+
+ pub const SPEC_STORE_BYPASS = 0;
+ pub const SPEC_NOT_AFFECTED = 0;
+ pub const SPEC_PRCTL = 1 << 0;
+ pub const SPEC_ENABLE = 1 << 1;
+ pub const SPEC_DISABLE = 1 << 2;
+ pub const SPEC_FORCE_DISABLE = 1 << 3;
+};
+
+pub const prctl_mm_map = extern struct {
+ start_code: u64,
+ end_code: u64,
+ start_data: u64,
+ end_data: u64,
+ start_brk: u64,
+ brk: u64,
+ start_stack: u64,
+ arg_start: u64,
+ arg_end: u64,
+ env_start: u64,
+ env_end: u64,
+ auxv: *u64,
+ auxv_size: u32,
+ exe_fd: u32,
+};
+
+pub const NETLINK = struct {
+
+ /// Routing/device hook
+ pub const ROUTE = 0;
+
+ /// Unused number
+ pub const UNUSED = 1;
+
+ /// Reserved for user mode socket protocols
+ pub const USERSOCK = 2;
+
+ /// Unused number, formerly ip_queue
+ pub const FIREWALL = 3;
+
+ /// socket monitoring
+ pub const SOCK_DIAG = 4;
+
+ /// netfilter/iptables ULOG
+ pub const NFLOG = 5;
+
+ /// ipsec
+ pub const XFRM = 6;
+
+ /// SELinux event notifications
+ pub const SELINUX = 7;
+
+ /// Open-iSCSI
+ pub const ISCSI = 8;
+
+ /// auditing
+ pub const AUDIT = 9;
+
+ pub const FIB_LOOKUP = 10;
+
+ pub const CONNECTOR = 11;
+
+ /// netfilter subsystem
+ pub const NETFILTER = 12;
+
+ pub const IP6_FW = 13;
+
+ /// DECnet routing messages
+ pub const DNRTMSG = 14;
+
+ /// Kernel messages to userspace
+ pub const KOBJECT_UEVENT = 15;
+
+ pub const GENERIC = 16;
+
+ // leave room for NETLINK_DM (DM Events)
+
+ /// SCSI Transports
+ pub const SCSITRANSPORT = 18;
+
+ pub const ECRYPTFS = 19;
+
+ pub const RDMA = 20;
+
+ /// Crypto layer
+ pub const CRYPTO = 21;
+
+ /// SMC monitoring
+ pub const SMC = 22;
+};
+
+// Flags values
+
+/// It is request message.
+pub const NLM_F_REQUEST = 0x01;
+
+/// Multipart message, terminated by NLMSG_DONE
+pub const NLM_F_MULTI = 0x02;
+
+/// Reply with ack, with zero or error code
+pub const NLM_F_ACK = 0x04;
+
+/// Echo this request
+pub const NLM_F_ECHO = 0x08;
+
+/// Dump was inconsistent due to sequence change
+pub const NLM_F_DUMP_INTR = 0x10;
+
+/// Dump was filtered as requested
+pub const NLM_F_DUMP_FILTERED = 0x20;
+
+// Modifiers to GET request
+
+/// specify tree root
+pub const NLM_F_ROOT = 0x100;
+
+/// return all matching
+pub const NLM_F_MATCH = 0x200;
+
+/// atomic GET
+pub const NLM_F_ATOMIC = 0x400;
+pub const NLM_F_DUMP = NLM_F_ROOT | NLM_F_MATCH;
+
+// Modifiers to NEW request
+
+/// Override existing
+pub const NLM_F_REPLACE = 0x100;
+
+/// Do not touch, if it exists
+pub const NLM_F_EXCL = 0x200;
+
+/// Create, if it does not exist
+pub const NLM_F_CREATE = 0x400;
+
+/// Add to end of list
+pub const NLM_F_APPEND = 0x800;
+
+// Modifiers to DELETE request
+
+/// Do not delete recursively
+pub const NLM_F_NONREC = 0x100;
+
+// Flags for ACK message
+
+/// request was capped
+pub const NLM_F_CAPPED = 0x100;
+
+/// extended ACK TVLs were included
+pub const NLM_F_ACK_TLVS = 0x200;
+
+pub const NetlinkMessageType = enum(u16) {
+ /// < 0x10: reserved control messages
+ pub const MIN_TYPE = 0x10;
+
+ /// Nothing.
+ NOOP = 0x1,
+
+ /// Error
+ ERROR = 0x2,
+
+ /// End of a dump
+ DONE = 0x3,
+
+ /// Data lost
+ OVERRUN = 0x4,
+
+ // rtlink types
+
+ RTM_NEWLINK = 16,
+ RTM_DELLINK,
+ RTM_GETLINK,
+ RTM_SETLINK,
+
+ RTM_NEWADDR = 20,
+ RTM_DELADDR,
+ RTM_GETADDR,
+
+ RTM_NEWROUTE = 24,
+ RTM_DELROUTE,
+ RTM_GETROUTE,
+
+ RTM_NEWNEIGH = 28,
+ RTM_DELNEIGH,
+ RTM_GETNEIGH,
+
+ RTM_NEWRULE = 32,
+ RTM_DELRULE,
+ RTM_GETRULE,
+
+ RTM_NEWQDISC = 36,
+ RTM_DELQDISC,
+ RTM_GETQDISC,
+
+ RTM_NEWTCLASS = 40,
+ RTM_DELTCLASS,
+ RTM_GETTCLASS,
+
+ RTM_NEWTFILTER = 44,
+ RTM_DELTFILTER,
+ RTM_GETTFILTER,
+
+ RTM_NEWACTION = 48,
+ RTM_DELACTION,
+ RTM_GETACTION,
+
+ RTM_NEWPREFIX = 52,
+
+ RTM_GETMULTICAST = 58,
+
+ RTM_GETANYCAST = 62,
+
+ RTM_NEWNEIGHTBL = 64,
+ RTM_GETNEIGHTBL = 66,
+ RTM_SETNEIGHTBL,
+
+ RTM_NEWNDUSEROPT = 68,
+
+ RTM_NEWADDRLABEL = 72,
+ RTM_DELADDRLABEL,
+ RTM_GETADDRLABEL,
+
+ RTM_GETDCB = 78,
+ RTM_SETDCB,
+
+ RTM_NEWNETCONF = 80,
+ RTM_DELNETCONF,
+ RTM_GETNETCONF = 82,
+
+ RTM_NEWMDB = 84,
+ RTM_DELMDB = 85,
+ RTM_GETMDB = 86,
+
+ RTM_NEWNSID = 88,
+ RTM_DELNSID = 89,
+ RTM_GETNSID = 90,
+
+ RTM_NEWSTATS = 92,
+ RTM_GETSTATS = 94,
+
+ RTM_NEWCACHEREPORT = 96,
+
+ RTM_NEWCHAIN = 100,
+ RTM_DELCHAIN,
+ RTM_GETCHAIN,
+
+ RTM_NEWNEXTHOP = 104,
+ RTM_DELNEXTHOP,
+ RTM_GETNEXTHOP,
+
+ _,
+};
+
+/// Netlink message header
+/// Specified in RFC 3549 Section 2.3.2
+pub const nlmsghdr = extern struct {
+ /// Length of message including header
+ len: u32,
+
+ /// Message content
+ @"type": NetlinkMessageType,
+
+ /// Additional flags
+ flags: u16,
+
+ /// Sequence number
+ seq: u32,
+
+ /// Sending process port ID
+ pid: u32,
+};
+
+pub const ifinfomsg = extern struct {
+ family: u8,
+ __pad1: u8 = 0,
+
+ /// ARPHRD_*
+ @"type": c_ushort,
+
+ /// Link index
+ index: c_int,
+
+ /// IFF_* flags
+ flags: c_uint,
+
+ /// IFF_* change mask
+ change: c_uint,
+};
+
+pub const rtattr = extern struct {
+ /// Length of option
+ len: c_ushort,
+
+ /// Type of option
+ @"type": IFLA,
+
+ pub const ALIGNTO = 4;
+};
+
+pub const IFLA = enum(c_ushort) {
+ UNSPEC,
+ ADDRESS,
+ BROADCAST,
+ IFNAME,
+ MTU,
+ LINK,
+ QDISC,
+ STATS,
+ COST,
+ PRIORITY,
+ MASTER,
+
+ /// Wireless Extension event
+ WIRELESS,
+
+ /// Protocol specific information for a link
+ PROTINFO,
+
+ TXQLEN,
+ MAP,
+ WEIGHT,
+ OPERSTATE,
+ LINKMODE,
+ LINKINFO,
+ NET_NS_PID,
+ IFALIAS,
+
+ /// Number of VFs if device is SR-IOV PF
+ NUM_VF,
+
+ VFINFO_LIST,
+ STATS64,
+ VF_PORTS,
+ PORT_SELF,
+ AF_SPEC,
+
+ /// Group the device belongs to
+ GROUP,
+
+ NET_NS_FD,
+
+ /// Extended info mask, VFs, etc
+ EXT_MASK,
+
+ /// Promiscuity count: > 0 means acts PROMISC
+ PROMISCUITY,
+
+ NUM_TX_QUEUES,
+ NUM_RX_QUEUES,
+ CARRIER,
+ PHYS_PORT_ID,
+ CARRIER_CHANGES,
+ PHYS_SWITCH_ID,
+ LINK_NETNSID,
+ PHYS_PORT_NAME,
+ PROTO_DOWN,
+ GSO_MAX_SEGS,
+ GSO_MAX_SIZE,
+ PAD,
+ XDP,
+ EVENT,
+
+ NEW_NETNSID,
+ IF_NETNSID,
+
+ CARRIER_UP_COUNT,
+ CARRIER_DOWN_COUNT,
+ NEW_IFINDEX,
+ MIN_MTU,
+ MAX_MTU,
+
+ _,
+
+ pub const TARGET_NETNSID: IFLA = .IF_NETNSID;
+};
+
+pub const rtnl_link_ifmap = extern struct {
+ mem_start: u64,
+ mem_end: u64,
+ base_addr: u64,
+ irq: u16,
+ dma: u8,
+ port: u8,
+};
+
+pub const rtnl_link_stats = extern struct {
+ /// total packets received
+ rx_packets: u32,
+
+ /// total packets transmitted
+ tx_packets: u32,
+
+ /// total bytes received
+ rx_bytes: u32,
+
+ /// total bytes transmitted
+ tx_bytes: u32,
+
+ /// bad packets received
+ rx_errors: u32,
+
+ /// packet transmit problems
+ tx_errors: u32,
+
+ /// no space in linux buffers
+ rx_dropped: u32,
+
+ /// no space available in linux
+ tx_dropped: u32,
+
+ /// multicast packets received
+ multicast: u32,
+
+ collisions: u32,
+
+ // detailed rx_errors
+
+ rx_length_errors: u32,
+
+ /// receiver ring buff overflow
+ rx_over_errors: u32,
+
+ /// recved pkt with crc error
+ rx_crc_errors: u32,
+
+ /// recv'd frame alignment error
+ rx_frame_errors: u32,
+
+ /// recv'r fifo overrun
+ rx_fifo_errors: u32,
+
+ /// receiver missed packet
+ rx_missed_errors: u32,
+
+ // detailed tx_errors
+ tx_aborted_errors: u32,
+ tx_carrier_errors: u32,
+ tx_fifo_errors: u32,
+ tx_heartbeat_errors: u32,
+ tx_window_errors: u32,
+
+ // for cslip etc
+
+ rx_compressed: u32,
+ tx_compressed: u32,
+
+ /// dropped, no handler found
+ rx_nohandler: u32,
+};
+
+pub const rtnl_link_stats64 = extern struct {
+ /// total packets received
+ rx_packets: u64,
+
+ /// total packets transmitted
+ tx_packets: u64,
+
+ /// total bytes received
+ rx_bytes: u64,
+
+ /// total bytes transmitted
+ tx_bytes: u64,
+
+ /// bad packets received
+ rx_errors: u64,
+
+ /// packet transmit problems
+ tx_errors: u64,
+
+ /// no space in linux buffers
+ rx_dropped: u64,
+
+ /// no space available in linux
+ tx_dropped: u64,
+
+ /// multicast packets received
+ multicast: u64,
+
+ collisions: u64,
+
+ // detailed rx_errors
+
+ rx_length_errors: u64,
+
+ /// receiver ring buff overflow
+ rx_over_errors: u64,
+
+ /// recved pkt with crc error
+ rx_crc_errors: u64,
+
+ /// recv'd frame alignment error
+ rx_frame_errors: u64,
+
+ /// recv'r fifo overrun
+ rx_fifo_errors: u64,
+
+ /// receiver missed packet
+ rx_missed_errors: u64,
+
+ // detailed tx_errors
+ tx_aborted_errors: u64,
+ tx_carrier_errors: u64,
+ tx_fifo_errors: u64,
+ tx_heartbeat_errors: u64,
+ tx_window_errors: u64,
+
+ // for cslip etc
+
+ rx_compressed: u64,
+ tx_compressed: u64,
+
+ /// dropped, no handler found
+ rx_nohandler: u64,
+};
diff --git a/lib/std/os/linux/arm-eabi.zig b/lib/std/os/linux/arm-eabi.zig
index 415cfd42f2ad..4bb60a000561 100644
--- a/lib/std/os/linux/arm-eabi.zig
+++ b/lib/std/os/linux/arm-eabi.zig
@@ -1,4 +1,16 @@
-usingnamespace @import("../bits/linux.zig");
+const std = @import("../../std.zig");
+const maxInt = std.math.maxInt;
+const linux = std.os.linux;
+const iovec = std.os.iovec;
+const iovec_const = std.os.iovec_const;
+const socklen_t = linux.socklen_t;
+const stack_t = linux.stack_t;
+const sigset_t = linux.sigset_t;
+const uid_t = linux.uid_t;
+const gid_t = linux.gid_t;
+const pid_t = linux.pid_t;
+const sockaddr = linux.sockaddr;
+const timespec = linux.timespec;
pub fn syscall0(number: SYS) usize {
return asm volatile ("svc #0"
@@ -86,7 +98,15 @@ pub fn syscall6(
}
/// This matches the libc clone function.
-pub extern fn clone(func: fn (arg: usize) callconv(.C) u8, stack: usize, flags: u32, arg: usize, ptid: *i32, tls: usize, ctid: *i32) usize;
+pub extern fn clone(
+ func: fn (arg: usize) callconv(.C) u8,
+ stack: usize,
+ flags: u32,
+ arg: usize,
+ ptid: *i32,
+ tls: usize,
+ ctid: *i32,
+) usize;
pub fn restore() callconv(.Naked) void {
return asm volatile ("svc #0"
@@ -103,3 +123,628 @@ pub fn restore_rt() callconv(.Naked) void {
: "memory"
);
}
+
+pub const SYS = enum(usize) {
+ restart_syscall = 0,
+ exit = 1,
+ fork = 2,
+ read = 3,
+ write = 4,
+ open = 5,
+ close = 6,
+ creat = 8,
+ link = 9,
+ unlink = 10,
+ execve = 11,
+ chdir = 12,
+ mknod = 14,
+ chmod = 15,
+ lchown = 16,
+ lseek = 19,
+ getpid = 20,
+ mount = 21,
+ setuid = 23,
+ getuid = 24,
+ ptrace = 26,
+ pause = 29,
+ access = 33,
+ nice = 34,
+ sync = 36,
+ kill = 37,
+ rename = 38,
+ mkdir = 39,
+ rmdir = 40,
+ dup = 41,
+ pipe = 42,
+ times = 43,
+ brk = 45,
+ setgid = 46,
+ getgid = 47,
+ geteuid = 49,
+ getegid = 50,
+ acct = 51,
+ umount2 = 52,
+ ioctl = 54,
+ fcntl = 55,
+ setpgid = 57,
+ umask = 60,
+ chroot = 61,
+ ustat = 62,
+ dup2 = 63,
+ getppid = 64,
+ getpgrp = 65,
+ setsid = 66,
+ sigaction = 67,
+ setreuid = 70,
+ setregid = 71,
+ sigsuspend = 72,
+ sigpending = 73,
+ sethostname = 74,
+ setrlimit = 75,
+ getrusage = 77,
+ gettimeofday = 78,
+ settimeofday = 79,
+ getgroups = 80,
+ setgroups = 81,
+ symlink = 83,
+ readlink = 85,
+ uselib = 86,
+ swapon = 87,
+ reboot = 88,
+ munmap = 91,
+ truncate = 92,
+ ftruncate = 93,
+ fchmod = 94,
+ fchown = 95,
+ getpriority = 96,
+ setpriority = 97,
+ statfs = 99,
+ fstatfs = 100,
+ syslog = 103,
+ setitimer = 104,
+ getitimer = 105,
+ stat = 106,
+ lstat = 107,
+ fstat = 108,
+ vhangup = 111,
+ wait4 = 114,
+ swapoff = 115,
+ sysinfo = 116,
+ fsync = 118,
+ sigreturn = 119,
+ clone = 120,
+ setdomainname = 121,
+ uname = 122,
+ adjtimex = 124,
+ mprotect = 125,
+ sigprocmask = 126,
+ init_module = 128,
+ delete_module = 129,
+ quotactl = 131,
+ getpgid = 132,
+ fchdir = 133,
+ bdflush = 134,
+ sysfs = 135,
+ personality = 136,
+ setfsuid = 138,
+ setfsgid = 139,
+ _llseek = 140,
+ getdents = 141,
+ _newselect = 142,
+ flock = 143,
+ msync = 144,
+ readv = 145,
+ writev = 146,
+ getsid = 147,
+ fdatasync = 148,
+ _sysctl = 149,
+ mlock = 150,
+ munlock = 151,
+ mlockall = 152,
+ munlockall = 153,
+ sched_setparam = 154,
+ sched_getparam = 155,
+ sched_setscheduler = 156,
+ sched_getscheduler = 157,
+ sched_yield = 158,
+ sched_get_priority_max = 159,
+ sched_get_priority_min = 160,
+ sched_rr_get_interval = 161,
+ nanosleep = 162,
+ mremap = 163,
+ setresuid = 164,
+ getresuid = 165,
+ poll = 168,
+ nfsservctl = 169,
+ setresgid = 170,
+ getresgid = 171,
+ prctl = 172,
+ rt_sigreturn = 173,
+ rt_sigaction = 174,
+ rt_sigprocmask = 175,
+ rt_sigpending = 176,
+ rt_sigtimedwait = 177,
+ rt_sigqueueinfo = 178,
+ rt_sigsuspend = 179,
+ pread64 = 180,
+ pwrite64 = 181,
+ chown = 182,
+ getcwd = 183,
+ capget = 184,
+ capset = 185,
+ sigaltstack = 186,
+ sendfile = 187,
+ vfork = 190,
+ ugetrlimit = 191,
+ mmap2 = 192,
+ truncate64 = 193,
+ ftruncate64 = 194,
+ stat64 = 195,
+ lstat64 = 196,
+ fstat64 = 197,
+ lchown32 = 198,
+ getuid32 = 199,
+ getgid32 = 200,
+ geteuid32 = 201,
+ getegid32 = 202,
+ setreuid32 = 203,
+ setregid32 = 204,
+ getgroups32 = 205,
+ setgroups32 = 206,
+ fchown32 = 207,
+ setresuid32 = 208,
+ getresuid32 = 209,
+ setresgid32 = 210,
+ getresgid32 = 211,
+ chown32 = 212,
+ setuid32 = 213,
+ setgid32 = 214,
+ setfsuid32 = 215,
+ setfsgid32 = 216,
+ getdents64 = 217,
+ pivot_root = 218,
+ mincore = 219,
+ madvise = 220,
+ fcntl64 = 221,
+ gettid = 224,
+ readahead = 225,
+ setxattr = 226,
+ lsetxattr = 227,
+ fsetxattr = 228,
+ getxattr = 229,
+ lgetxattr = 230,
+ fgetxattr = 231,
+ listxattr = 232,
+ llistxattr = 233,
+ flistxattr = 234,
+ removexattr = 235,
+ lremovexattr = 236,
+ fremovexattr = 237,
+ tkill = 238,
+ sendfile64 = 239,
+ futex = 240,
+ sched_setaffinity = 241,
+ sched_getaffinity = 242,
+ io_setup = 243,
+ io_destroy = 244,
+ io_getevents = 245,
+ io_submit = 246,
+ io_cancel = 247,
+ exit_group = 248,
+ lookup_dcookie = 249,
+ epoll_create = 250,
+ epoll_ctl = 251,
+ epoll_wait = 252,
+ remap_file_pages = 253,
+ set_tid_address = 256,
+ timer_create = 257,
+ timer_settime = 258,
+ timer_gettime = 259,
+ timer_getoverrun = 260,
+ timer_delete = 261,
+ clock_settime = 262,
+ clock_gettime = 263,
+ clock_getres = 264,
+ clock_nanosleep = 265,
+ statfs64 = 266,
+ fstatfs64 = 267,
+ tgkill = 268,
+ utimes = 269,
+ fadvise64_64 = 270,
+ pciconfig_iobase = 271,
+ pciconfig_read = 272,
+ pciconfig_write = 273,
+ mq_open = 274,
+ mq_unlink = 275,
+ mq_timedsend = 276,
+ mq_timedreceive = 277,
+ mq_notify = 278,
+ mq_getsetattr = 279,
+ waitid = 280,
+ socket = 281,
+ bind = 282,
+ connect = 283,
+ listen = 284,
+ accept = 285,
+ getsockname = 286,
+ getpeername = 287,
+ socketpair = 288,
+ send = 289,
+ sendto = 290,
+ recv = 291,
+ recvfrom = 292,
+ shutdown = 293,
+ setsockopt = 294,
+ getsockopt = 295,
+ sendmsg = 296,
+ recvmsg = 297,
+ semop = 298,
+ semget = 299,
+ semctl = 300,
+ msgsnd = 301,
+ msgrcv = 302,
+ msgget = 303,
+ msgctl = 304,
+ shmat = 305,
+ shmdt = 306,
+ shmget = 307,
+ shmctl = 308,
+ add_key = 309,
+ request_key = 310,
+ keyctl = 311,
+ semtimedop = 312,
+ vserver = 313,
+ ioprio_set = 314,
+ ioprio_get = 315,
+ inotify_init = 316,
+ inotify_add_watch = 317,
+ inotify_rm_watch = 318,
+ mbind = 319,
+ get_mempolicy = 320,
+ set_mempolicy = 321,
+ openat = 322,
+ mkdirat = 323,
+ mknodat = 324,
+ fchownat = 325,
+ futimesat = 326,
+ fstatat64 = 327,
+ unlinkat = 328,
+ renameat = 329,
+ linkat = 330,
+ symlinkat = 331,
+ readlinkat = 332,
+ fchmodat = 333,
+ faccessat = 334,
+ pselect6 = 335,
+ ppoll = 336,
+ unshare = 337,
+ set_robust_list = 338,
+ get_robust_list = 339,
+ splice = 340,
+ sync_file_range = 341,
+ tee = 342,
+ vmsplice = 343,
+ move_pages = 344,
+ getcpu = 345,
+ epoll_pwait = 346,
+ kexec_load = 347,
+ utimensat = 348,
+ signalfd = 349,
+ timerfd_create = 350,
+ eventfd = 351,
+ fallocate = 352,
+ timerfd_settime = 353,
+ timerfd_gettime = 354,
+ signalfd4 = 355,
+ eventfd2 = 356,
+ epoll_create1 = 357,
+ dup3 = 358,
+ pipe2 = 359,
+ inotify_init1 = 360,
+ preadv = 361,
+ pwritev = 362,
+ rt_tgsigqueueinfo = 363,
+ perf_event_open = 364,
+ recvmmsg = 365,
+ accept4 = 366,
+ fanotify_init = 367,
+ fanotify_mark = 368,
+ prlimit64 = 369,
+ name_to_handle_at = 370,
+ open_by_handle_at = 371,
+ clock_adjtime = 372,
+ syncfs = 373,
+ sendmmsg = 374,
+ setns = 375,
+ process_vm_readv = 376,
+ process_vm_writev = 377,
+ kcmp = 378,
+ finit_module = 379,
+ sched_setattr = 380,
+ sched_getattr = 381,
+ renameat2 = 382,
+ seccomp = 383,
+ getrandom = 384,
+ memfd_create = 385,
+ bpf = 386,
+ execveat = 387,
+ userfaultfd = 388,
+ membarrier = 389,
+ mlock2 = 390,
+ copy_file_range = 391,
+ preadv2 = 392,
+ pwritev2 = 393,
+ pkey_mprotect = 394,
+ pkey_alloc = 395,
+ pkey_free = 396,
+ statx = 397,
+ rseq = 398,
+ io_pgetevents = 399,
+ migrate_pages = 400,
+ kexec_file_load = 401,
+ clock_gettime64 = 403,
+ clock_settime64 = 404,
+ clock_adjtime64 = 405,
+ clock_getres_time64 = 406,
+ clock_nanosleep_time64 = 407,
+ timer_gettime64 = 408,
+ timer_settime64 = 409,
+ timerfd_gettime64 = 410,
+ timerfd_settime64 = 411,
+ utimensat_time64 = 412,
+ pselect6_time64 = 413,
+ ppoll_time64 = 414,
+ io_pgetevents_time64 = 416,
+ recvmmsg_time64 = 417,
+ mq_timedsend_time64 = 418,
+ mq_timedreceive_time64 = 419,
+ semtimedop_time64 = 420,
+ rt_sigtimedwait_time64 = 421,
+ futex_time64 = 422,
+ sched_rr_get_interval_time64 = 423,
+ pidfd_send_signal = 424,
+ io_uring_setup = 425,
+ io_uring_enter = 426,
+ io_uring_register = 427,
+ open_tree = 428,
+ move_mount = 429,
+ fsopen = 430,
+ fsconfig = 431,
+ fsmount = 432,
+ fspick = 433,
+ pidfd_open = 434,
+ clone3 = 435,
+ close_range = 436,
+ openat2 = 437,
+ pidfd_getfd = 438,
+ faccessat2 = 439,
+ process_madvise = 440,
+ epoll_pwait2 = 441,
+
+ breakpoint = 0x0f0001,
+ cacheflush = 0x0f0002,
+ usr26 = 0x0f0003,
+ usr32 = 0x0f0004,
+ set_tls = 0x0f0005,
+ get_tls = 0x0f0006,
+
+ _,
+};
+
+pub const MMAP2_UNIT = 4096;
+
+pub const O = struct {
+ pub const CREAT = 0o100;
+ pub const EXCL = 0o200;
+ pub const NOCTTY = 0o400;
+ pub const TRUNC = 0o1000;
+ pub const APPEND = 0o2000;
+ pub const NONBLOCK = 0o4000;
+ pub const DSYNC = 0o10000;
+ pub const SYNC = 0o4010000;
+ pub const RSYNC = 0o4010000;
+ pub const DIRECTORY = 0o40000;
+ pub const NOFOLLOW = 0o100000;
+ pub const CLOEXEC = 0o2000000;
+
+ pub const ASYNC = 0o20000;
+ pub const DIRECT = 0o200000;
+ pub const LARGEFILE = 0o400000;
+ pub const NOATIME = 0o1000000;
+ pub const PATH = 0o10000000;
+ pub const TMPFILE = 0o20040000;
+ pub const NDELAY = NONBLOCK;
+};
+
+pub const F = struct {
+ pub const DUPFD = 0;
+ pub const GETFD = 1;
+ pub const SETFD = 2;
+ pub const GETFL = 3;
+ pub const SETFL = 4;
+
+ pub const SETOWN = 8;
+ pub const GETOWN = 9;
+ pub const SETSIG = 10;
+ pub const GETSIG = 11;
+
+ pub const GETLK = 12;
+ pub const SETLK = 13;
+ pub const SETLKW = 14;
+
+ pub const RDLCK = 0;
+ pub const WRLCK = 1;
+ pub const UNLCK = 2;
+
+ pub const SETOWN_EX = 15;
+ pub const GETOWN_EX = 16;
+
+ pub const GETOWNER_UIDS = 17;
+};
+
+pub const LOCK = struct {
+ pub const SH = 1;
+ pub const EX = 2;
+ pub const UN = 8;
+ pub const NB = 4;
+};
+
+pub const MAP = struct {
+ /// stack-like segment
+ pub const GROWSDOWN = 0x0100;
+ /// ETXTBSY
+ pub const DENYWRITE = 0x0800;
+ /// mark it as an executable
+ pub const EXECUTABLE = 0x1000;
+ /// pages are locked
+ pub const LOCKED = 0x2000;
+ /// don't check for reservations
+ pub const NORESERVE = 0x4000;
+};
+
+pub const VDSO = struct {
+ pub const CGT_SYM = "__vdso_clock_gettime";
+ pub const CGT_VER = "LINUX_2.6";
+};
+
+pub const HWCAP = struct {
+ pub const SWP = 1 << 0;
+ pub const HALF = 1 << 1;
+ pub const THUMB = 1 << 2;
+ pub const @"26BIT" = 1 << 3;
+ pub const FAST_MULT = 1 << 4;
+ pub const FPA = 1 << 5;
+ pub const VFP = 1 << 6;
+ pub const EDSP = 1 << 7;
+ pub const JAVA = 1 << 8;
+ pub const IWMMXT = 1 << 9;
+ pub const CRUNCH = 1 << 10;
+ pub const THUMBEE = 1 << 11;
+ pub const NEON = 1 << 12;
+ pub const VFPv3 = 1 << 13;
+ pub const VFPv3D16 = 1 << 14;
+ pub const TLS = 1 << 15;
+ pub const VFPv4 = 1 << 16;
+ pub const IDIVA = 1 << 17;
+ pub const IDIVT = 1 << 18;
+ pub const VFPD32 = 1 << 19;
+ pub const IDIV = IDIVA | IDIVT;
+ pub const LPAE = 1 << 20;
+ pub const EVTSTRM = 1 << 21;
+};
+
+pub const Flock = extern struct {
+ l_type: i16,
+ l_whence: i16,
+ __pad0: [4]u8,
+ l_start: off_t,
+ l_len: off_t,
+ l_pid: pid_t,
+ __unused: [4]u8,
+};
+
+pub const msghdr = extern struct {
+ msg_name: ?*sockaddr,
+ msg_namelen: socklen_t,
+ msg_iov: [*]iovec,
+ msg_iovlen: i32,
+ msg_control: ?*c_void,
+ msg_controllen: socklen_t,
+ msg_flags: i32,
+};
+
+pub const msghdr_const = extern struct {
+ msg_name: ?*const sockaddr,
+ msg_namelen: socklen_t,
+ msg_iov: [*]iovec_const,
+ msg_iovlen: i32,
+ msg_control: ?*c_void,
+ msg_controllen: socklen_t,
+ msg_flags: i32,
+};
+
+pub const blksize_t = i32;
+pub const nlink_t = u32;
+pub const time_t = isize;
+pub const mode_t = u32;
+pub const off_t = i64;
+pub const ino_t = u64;
+pub const dev_t = u64;
+pub const blkcnt_t = i64;
+
+// The `stat` definition used by the Linux kernel.
+pub const Stat = extern struct {
+ dev: dev_t,
+ __dev_padding: u32,
+ __ino_truncated: u32,
+ mode: mode_t,
+ nlink: nlink_t,
+ uid: uid_t,
+ gid: gid_t,
+ rdev: dev_t,
+ __rdev_padding: u32,
+ size: off_t,
+ blksize: blksize_t,
+ blocks: blkcnt_t,
+ atim: timespec,
+ mtim: timespec,
+ ctim: timespec,
+ ino: ino_t,
+
+ pub fn atime(self: @This()) timespec {
+ return self.atim;
+ }
+
+ pub fn mtime(self: @This()) timespec {
+ return self.mtim;
+ }
+
+ pub fn ctime(self: @This()) timespec {
+ return self.ctim;
+ }
+};
+
+pub const timeval = extern struct {
+ tv_sec: i32,
+ tv_usec: i32,
+};
+
+pub const timezone = extern struct {
+ tz_minuteswest: i32,
+ tz_dsttime: i32,
+};
+
+pub const mcontext_t = extern struct {
+ trap_no: usize,
+ error_code: usize,
+ oldmask: usize,
+ arm_r0: usize,
+ arm_r1: usize,
+ arm_r2: usize,
+ arm_r3: usize,
+ arm_r4: usize,
+ arm_r5: usize,
+ arm_r6: usize,
+ arm_r7: usize,
+ arm_r8: usize,
+ arm_r9: usize,
+ arm_r10: usize,
+ arm_fp: usize,
+ arm_ip: usize,
+ arm_sp: usize,
+ arm_lr: usize,
+ arm_pc: usize,
+ arm_cpsr: usize,
+ fault_address: usize,
+};
+
+pub const ucontext_t = extern struct {
+ flags: usize,
+ link: *ucontext_t,
+ stack: stack_t,
+ mcontext: mcontext_t,
+ sigmask: sigset_t,
+ regspace: [64]u64,
+};
+
+pub const Elf_Symndx = u32;
diff --git a/lib/std/os/linux/arm64.zig b/lib/std/os/linux/arm64.zig
index 3a619c5f45a1..58895843e081 100644
--- a/lib/std/os/linux/arm64.zig
+++ b/lib/std/os/linux/arm64.zig
@@ -1,4 +1,16 @@
-usingnamespace @import("../bits/linux.zig");
+const std = @import("../../std.zig");
+const maxInt = std.math.maxInt;
+const linux = std.os.linux;
+const socklen_t = linux.socklen_t;
+const sockaddr = linux.sockaddr;
+const iovec = linux.iovec;
+const iovec_const = linux.iovec_const;
+const uid_t = linux.uid_t;
+const gid_t = linux.gid_t;
+const pid_t = linux.pid_t;
+const stack_t = linux.stack_t;
+const sigset_t = linux.sigset_t;
+const timespec = std.os.linux.timespec;
pub fn syscall0(number: SYS) usize {
return asm volatile ("svc #0"
@@ -97,3 +109,483 @@ pub fn restore_rt() callconv(.Naked) void {
: "memory", "cc"
);
}
+
+pub const SYS = enum(usize) {
+ io_setup = 0,
+ io_destroy = 1,
+ io_submit = 2,
+ io_cancel = 3,
+ io_getevents = 4,
+ setxattr = 5,
+ lsetxattr = 6,
+ fsetxattr = 7,
+ getxattr = 8,
+ lgetxattr = 9,
+ fgetxattr = 10,
+ listxattr = 11,
+ llistxattr = 12,
+ flistxattr = 13,
+ removexattr = 14,
+ lremovexattr = 15,
+ fremovexattr = 16,
+ getcwd = 17,
+ lookup_dcookie = 18,
+ eventfd2 = 19,
+ epoll_create1 = 20,
+ epoll_ctl = 21,
+ epoll_pwait = 22,
+ dup = 23,
+ dup3 = 24,
+ fcntl = 25,
+ inotify_init1 = 26,
+ inotify_add_watch = 27,
+ inotify_rm_watch = 28,
+ ioctl = 29,
+ ioprio_set = 30,
+ ioprio_get = 31,
+ flock = 32,
+ mknodat = 33,
+ mkdirat = 34,
+ unlinkat = 35,
+ symlinkat = 36,
+ linkat = 37,
+ renameat = 38,
+ umount2 = 39,
+ mount = 40,
+ pivot_root = 41,
+ nfsservctl = 42,
+ statfs = 43,
+ fstatfs = 44,
+ truncate = 45,
+ ftruncate = 46,
+ fallocate = 47,
+ faccessat = 48,
+ chdir = 49,
+ fchdir = 50,
+ chroot = 51,
+ fchmod = 52,
+ fchmodat = 53,
+ fchownat = 54,
+ fchown = 55,
+ openat = 56,
+ close = 57,
+ vhangup = 58,
+ pipe2 = 59,
+ quotactl = 60,
+ getdents64 = 61,
+ lseek = 62,
+ read = 63,
+ write = 64,
+ readv = 65,
+ writev = 66,
+ pread64 = 67,
+ pwrite64 = 68,
+ preadv = 69,
+ pwritev = 70,
+ sendfile = 71,
+ pselect6 = 72,
+ ppoll = 73,
+ signalfd4 = 74,
+ vmsplice = 75,
+ splice = 76,
+ tee = 77,
+ readlinkat = 78,
+ fstatat = 79,
+ fstat = 80,
+ sync = 81,
+ fsync = 82,
+ fdatasync = 83,
+ sync_file_range = 84,
+ timerfd_create = 85,
+ timerfd_settime = 86,
+ timerfd_gettime = 87,
+ utimensat = 88,
+ acct = 89,
+ capget = 90,
+ capset = 91,
+ personality = 92,
+ exit = 93,
+ exit_group = 94,
+ waitid = 95,
+ set_tid_address = 96,
+ unshare = 97,
+ futex = 98,
+ set_robust_list = 99,
+ get_robust_list = 100,
+ nanosleep = 101,
+ getitimer = 102,
+ setitimer = 103,
+ kexec_load = 104,
+ init_module = 105,
+ delete_module = 106,
+ timer_create = 107,
+ timer_gettime = 108,
+ timer_getoverrun = 109,
+ timer_settime = 110,
+ timer_delete = 111,
+ clock_settime = 112,
+ clock_gettime = 113,
+ clock_getres = 114,
+ clock_nanosleep = 115,
+ syslog = 116,
+ ptrace = 117,
+ sched_setparam = 118,
+ sched_setscheduler = 119,
+ sched_getscheduler = 120,
+ sched_getparam = 121,
+ sched_setaffinity = 122,
+ sched_getaffinity = 123,
+ sched_yield = 124,
+ sched_get_priority_max = 125,
+ sched_get_priority_min = 126,
+ sched_rr_get_interval = 127,
+ restart_syscall = 128,
+ kill = 129,
+ tkill = 130,
+ tgkill = 131,
+ sigaltstack = 132,
+ rt_sigsuspend = 133,
+ rt_sigaction = 134,
+ rt_sigprocmask = 135,
+ rt_sigpending = 136,
+ rt_sigtimedwait = 137,
+ rt_sigqueueinfo = 138,
+ rt_sigreturn = 139,
+ setpriority = 140,
+ getpriority = 141,
+ reboot = 142,
+ setregid = 143,
+ setgid = 144,
+ setreuid = 145,
+ setuid = 146,
+ setresuid = 147,
+ getresuid = 148,
+ setresgid = 149,
+ getresgid = 150,
+ setfsuid = 151,
+ setfsgid = 152,
+ times = 153,
+ setpgid = 154,
+ getpgid = 155,
+ getsid = 156,
+ setsid = 157,
+ getgroups = 158,
+ setgroups = 159,
+ uname = 160,
+ sethostname = 161,
+ setdomainname = 162,
+ getrlimit = 163,
+ setrlimit = 164,
+ getrusage = 165,
+ umask = 166,
+ prctl = 167,
+ getcpu = 168,
+ gettimeofday = 169,
+ settimeofday = 170,
+ adjtimex = 171,
+ getpid = 172,
+ getppid = 173,
+ getuid = 174,
+ geteuid = 175,
+ getgid = 176,
+ getegid = 177,
+ gettid = 178,
+ sysinfo = 179,
+ mq_open = 180,
+ mq_unlink = 181,
+ mq_timedsend = 182,
+ mq_timedreceive = 183,
+ mq_notify = 184,
+ mq_getsetattr = 185,
+ msgget = 186,
+ msgctl = 187,
+ msgrcv = 188,
+ msgsnd = 189,
+ semget = 190,
+ semctl = 191,
+ semtimedop = 192,
+ semop = 193,
+ shmget = 194,
+ shmctl = 195,
+ shmat = 196,
+ shmdt = 197,
+ socket = 198,
+ socketpair = 199,
+ bind = 200,
+ listen = 201,
+ accept = 202,
+ connect = 203,
+ getsockname = 204,
+ getpeername = 205,
+ sendto = 206,
+ recvfrom = 207,
+ setsockopt = 208,
+ getsockopt = 209,
+ shutdown = 210,
+ sendmsg = 211,
+ recvmsg = 212,
+ readahead = 213,
+ brk = 214,
+ munmap = 215,
+ mremap = 216,
+ add_key = 217,
+ request_key = 218,
+ keyctl = 219,
+ clone = 220,
+ execve = 221,
+ mmap = 222,
+ fadvise64 = 223,
+ swapon = 224,
+ swapoff = 225,
+ mprotect = 226,
+ msync = 227,
+ mlock = 228,
+ munlock = 229,
+ mlockall = 230,
+ munlockall = 231,
+ mincore = 232,
+ madvise = 233,
+ remap_file_pages = 234,
+ mbind = 235,
+ get_mempolicy = 236,
+ set_mempolicy = 237,
+ migrate_pages = 238,
+ move_pages = 239,
+ rt_tgsigqueueinfo = 240,
+ perf_event_open = 241,
+ accept4 = 242,
+ recvmmsg = 243,
+ arch_specific_syscall = 244,
+ wait4 = 260,
+ prlimit64 = 261,
+ fanotify_init = 262,
+ fanotify_mark = 263,
+ clock_adjtime = 266,
+ syncfs = 267,
+ setns = 268,
+ sendmmsg = 269,
+ process_vm_readv = 270,
+ process_vm_writev = 271,
+ kcmp = 272,
+ finit_module = 273,
+ sched_setattr = 274,
+ sched_getattr = 275,
+ renameat2 = 276,
+ seccomp = 277,
+ getrandom = 278,
+ memfd_create = 279,
+ bpf = 280,
+ execveat = 281,
+ userfaultfd = 282,
+ membarrier = 283,
+ mlock2 = 284,
+ copy_file_range = 285,
+ preadv2 = 286,
+ pwritev2 = 287,
+ pkey_mprotect = 288,
+ pkey_alloc = 289,
+ pkey_free = 290,
+ statx = 291,
+ io_pgetevents = 292,
+ rseq = 293,
+ kexec_file_load = 294,
+ pidfd_send_signal = 424,
+ io_uring_setup = 425,
+ io_uring_enter = 426,
+ io_uring_register = 427,
+ open_tree = 428,
+ move_mount = 429,
+ fsopen = 430,
+ fsconfig = 431,
+ fsmount = 432,
+ fspick = 433,
+ pidfd_open = 434,
+ clone3 = 435,
+ close_range = 436,
+ openat2 = 437,
+ pidfd_getfd = 438,
+ faccessat2 = 439,
+ process_madvise = 440,
+ epoll_pwait2 = 441,
+
+ _,
+};
+
+pub const O = struct {
+ pub const CREAT = 0o100;
+ pub const EXCL = 0o200;
+ pub const NOCTTY = 0o400;
+ pub const TRUNC = 0o1000;
+ pub const APPEND = 0o2000;
+ pub const NONBLOCK = 0o4000;
+ pub const DSYNC = 0o10000;
+ pub const SYNC = 0o4010000;
+ pub const RSYNC = 0o4010000;
+ pub const DIRECTORY = 0o40000;
+ pub const NOFOLLOW = 0o100000;
+ pub const CLOEXEC = 0o2000000;
+
+ pub const ASYNC = 0o20000;
+ pub const DIRECT = 0o200000;
+ pub const LARGEFILE = 0o400000;
+ pub const NOATIME = 0o1000000;
+ pub const PATH = 0o10000000;
+ pub const TMPFILE = 0o20040000;
+ pub const NDELAY = NONBLOCK;
+};
+
+pub const F = struct {
+ pub const DUPFD = 0;
+ pub const GETFD = 1;
+ pub const SETFD = 2;
+ pub const GETFL = 3;
+ pub const SETFL = 4;
+
+ pub const SETOWN = 8;
+ pub const GETOWN = 9;
+ pub const SETSIG = 10;
+ pub const GETSIG = 11;
+
+ pub const GETLK = 5;
+ pub const SETLK = 6;
+ pub const SETLKW = 7;
+
+ pub const RDLCK = 0;
+ pub const WRLCK = 1;
+ pub const UNLCK = 2;
+
+ pub const SETOWN_EX = 15;
+ pub const GETOWN_EX = 16;
+
+ pub const GETOWNER_UIDS = 17;
+};
+
+pub const LOCK = struct {
+ pub const SH = 1;
+ pub const EX = 2;
+ pub const UN = 8;
+ pub const NB = 4;
+};
+
+pub const MAP = struct {
+ /// stack-like segment
+ pub const GROWSDOWN = 0x0100;
+ /// ETXTBSY
+ pub const DENYWRITE = 0x0800;
+ /// mark it as an executable
+ pub const EXECUTABLE = 0x1000;
+ /// pages are locked
+ pub const LOCKED = 0x2000;
+ /// don't check for reservations
+ pub const NORESERVE = 0x4000;
+};
+
+pub const VDSO = struct {
+ pub const CGT_SYM = "__kernel_clock_gettime";
+ pub const CGT_VER = "LINUX_2.6.39";
+};
+
+pub const Flock = extern struct {
+ l_type: i16,
+ l_whence: i16,
+ l_start: off_t,
+ l_len: off_t,
+ l_pid: pid_t,
+ __unused: [4]u8,
+};
+
+pub const msghdr = extern struct {
+ msg_name: ?*sockaddr,
+ msg_namelen: socklen_t,
+ msg_iov: [*]iovec,
+ msg_iovlen: i32,
+ __pad1: i32 = 0,
+ msg_control: ?*c_void,
+ msg_controllen: socklen_t,
+ __pad2: socklen_t = 0,
+ msg_flags: i32,
+};
+
+pub const msghdr_const = extern struct {
+ msg_name: ?*const sockaddr,
+ msg_namelen: socklen_t,
+ msg_iov: [*]iovec_const,
+ msg_iovlen: i32,
+ __pad1: i32 = 0,
+ msg_control: ?*c_void,
+ msg_controllen: socklen_t,
+ __pad2: socklen_t = 0,
+ msg_flags: i32,
+};
+
+pub const blksize_t = i32;
+pub const nlink_t = u32;
+pub const time_t = isize;
+pub const mode_t = u32;
+pub const off_t = isize;
+pub const ino_t = usize;
+pub const dev_t = usize;
+pub const blkcnt_t = isize;
+
+// The `stat` definition used by the Linux kernel.
+pub const Stat = extern struct {
+ dev: dev_t,
+ ino: ino_t,
+ mode: mode_t,
+ nlink: nlink_t,
+ uid: uid_t,
+ gid: gid_t,
+ rdev: dev_t,
+ __pad: usize,
+ size: off_t,
+ blksize: blksize_t,
+ __pad2: i32,
+ blocks: blkcnt_t,
+ atim: timespec,
+ mtim: timespec,
+ ctim: timespec,
+ __unused: [2]u32,
+
+ pub fn atime(self: @This()) timespec {
+ return self.atim;
+ }
+
+ pub fn mtime(self: @This()) timespec {
+ return self.mtim;
+ }
+
+ pub fn ctime(self: @This()) timespec {
+ return self.ctim;
+ }
+};
+
+pub const timeval = extern struct {
+ tv_sec: isize,
+ tv_usec: isize,
+};
+
+pub const timezone = extern struct {
+ tz_minuteswest: i32,
+ tz_dsttime: i32,
+};
+
+pub const mcontext_t = extern struct {
+ fault_address: usize,
+ regs: [31]usize,
+ sp: usize,
+ pc: usize,
+ pstate: usize,
+ // Make sure the field is correctly aligned since this area
+ // holds various FP/vector registers
+ reserved1: [256 * 16]u8 align(16),
+};
+
+pub const ucontext_t = extern struct {
+ flags: usize,
+ link: *ucontext_t,
+ stack: stack_t,
+ sigmask: sigset_t,
+ mcontext: mcontext_t,
+};
+
+pub const Elf_Symndx = u32;
diff --git a/lib/std/os/linux/bpf.zig b/lib/std/os/linux/bpf.zig
index cff4acaeee6a..4cb9dbf5c539 100644
--- a/lib/std/os/linux/bpf.zig
+++ b/lib/std/os/linux/bpf.zig
@@ -1,4 +1,3 @@
-usingnamespace std.os.linux;
const std = @import("../../std.zig");
const errno = getErrno;
const unexpectedErrno = std.os.unexpectedErrno;
@@ -6,6 +5,11 @@ const expectEqual = std.testing.expectEqual;
const expectError = std.testing.expectError;
const expect = std.testing.expect;
+const linux = std.os.linux;
+const fd_t = linux.fd_t;
+const pid_t = linux.pid_t;
+const getErrno = linux.getErrno;
+
pub const btf = @import("bpf/btf.zig");
pub const kern = @import("bpf/kern.zig");
@@ -1502,7 +1506,7 @@ pub fn map_create(map_type: MapType, key_size: u32, value_size: u32, max_entries
attr.map_create.value_size = value_size;
attr.map_create.max_entries = max_entries;
- const rc = bpf(.map_create, &attr, @sizeOf(MapCreateAttr));
+ const rc = linux.bpf(.map_create, &attr, @sizeOf(MapCreateAttr));
switch (errno(rc)) {
.SUCCESS => return @intCast(fd_t, rc),
.INVAL => return error.MapTypeOrAttrInvalid,
@@ -1526,7 +1530,7 @@ pub fn map_lookup_elem(fd: fd_t, key: []const u8, value: []u8) !void {
attr.map_elem.key = @ptrToInt(key.ptr);
attr.map_elem.result.value = @ptrToInt(value.ptr);
- const rc = bpf(.map_lookup_elem, &attr, @sizeOf(MapElemAttr));
+ const rc = linux.bpf(.map_lookup_elem, &attr, @sizeOf(MapElemAttr));
switch (errno(rc)) {
.SUCCESS => return,
.BADF => return error.BadFd,
@@ -1548,7 +1552,7 @@ pub fn map_update_elem(fd: fd_t, key: []const u8, value: []const u8, flags: u64)
attr.map_elem.result = .{ .value = @ptrToInt(value.ptr) };
attr.map_elem.flags = flags;
- const rc = bpf(.map_update_elem, &attr, @sizeOf(MapElemAttr));
+ const rc = linux.bpf(.map_update_elem, &attr, @sizeOf(MapElemAttr));
switch (errno(rc)) {
.SUCCESS => return,
.@"2BIG" => return error.ReachedMaxEntries,
@@ -1569,7 +1573,7 @@ pub fn map_delete_elem(fd: fd_t, key: []const u8) !void {
attr.map_elem.map_fd = fd;
attr.map_elem.key = @ptrToInt(key.ptr);
- const rc = bpf(.map_delete_elem, &attr, @sizeOf(MapElemAttr));
+ const rc = linux.bpf(.map_delete_elem, &attr, @sizeOf(MapElemAttr));
switch (errno(rc)) {
.SUCCESS => return,
.BADF => return error.BadFd,
@@ -1632,7 +1636,7 @@ pub fn prog_load(
attr.prog_load.log_level = l.level;
}
- const rc = bpf(.prog_load, &attr, @sizeOf(ProgLoadAttr));
+ const rc = linux.bpf(.prog_load, &attr, @sizeOf(ProgLoadAttr));
return switch (errno(rc)) {
.SUCCESS => @intCast(fd_t, rc),
.ACCES => error.UnsafeProgram,
diff --git a/lib/std/os/linux/bpf/btf.zig b/lib/std/os/linux/bpf/btf.zig
index 35eaf1056106..8da3bbbe4c14 100644
--- a/lib/std/os/linux/bpf/btf.zig
+++ b/lib/std/os/linux/bpf/btf.zig
@@ -1,3 +1,5 @@
+const std = @import("../../../std.zig");
+
const magic = 0xeb9f;
const version = 1;
diff --git a/lib/std/os/linux/bpf/helpers.zig b/lib/std/os/linux/bpf/helpers.zig
index 86c86c1ec5a6..3b0df9673c83 100644
--- a/lib/std/os/linux/bpf/helpers.zig
+++ b/lib/std/os/linux/bpf/helpers.zig
@@ -1,5 +1,10 @@
+const std = @import("../../../std.zig");
const kern = @import("kern.zig");
+const PtRegs = @compileError("TODO missing os bits: PtRegs");
+const TcpHdr = @compileError("TODO missing os bits: TcpHdr");
+const SkFullSock = @compileError("TODO missing os bits: SkFullSock");
+
// in BPF, all the helper calls
// TODO: when https://github.com/ziglang/zig/issues/1717 is here, make a nice
// function that uses the Helper enum
diff --git a/lib/std/os/bits/linux/errno/generic.zig b/lib/std/os/linux/errno/generic.zig
similarity index 100%
rename from lib/std/os/bits/linux/errno/generic.zig
rename to lib/std/os/linux/errno/generic.zig
diff --git a/lib/std/os/bits/linux/errno/mips.zig b/lib/std/os/linux/errno/mips.zig
similarity index 100%
rename from lib/std/os/bits/linux/errno/mips.zig
rename to lib/std/os/linux/errno/mips.zig
diff --git a/lib/std/os/bits/linux/errno/sparc.zig b/lib/std/os/linux/errno/sparc.zig
similarity index 100%
rename from lib/std/os/bits/linux/errno/sparc.zig
rename to lib/std/os/linux/errno/sparc.zig
diff --git a/lib/std/os/linux/i386.zig b/lib/std/os/linux/i386.zig
index 04a67da762b6..4d1af88e0a7e 100644
--- a/lib/std/os/linux/i386.zig
+++ b/lib/std/os/linux/i386.zig
@@ -1,4 +1,16 @@
-usingnamespace @import("../bits/linux.zig");
+const std = @import("../../std.zig");
+const maxInt = std.math.maxInt;
+const linux = std.os.linux;
+const socklen_t = linux.socklen_t;
+const iovec = linux.iovec;
+const iovec_const = linux.iovec_const;
+const uid_t = linux.uid_t;
+const gid_t = linux.gid_t;
+const pid_t = linux.pid_t;
+const stack_t = linux.stack_t;
+const sigset_t = linux.sigset_t;
+const sockaddr = linux.sockaddr;
+const timespec = linux.timespec;
pub fn syscall0(number: SYS) usize {
return asm volatile ("int $0x80"
@@ -123,3 +135,664 @@ pub fn restore_rt() callconv(.Naked) void {
: "memory"
);
}
+
+pub const SYS = enum(usize) {
+ restart_syscall = 0,
+ exit = 1,
+ fork = 2,
+ read = 3,
+ write = 4,
+ open = 5,
+ close = 6,
+ waitpid = 7,
+ creat = 8,
+ link = 9,
+ unlink = 10,
+ execve = 11,
+ chdir = 12,
+ time = 13,
+ mknod = 14,
+ chmod = 15,
+ lchown = 16,
+ @"break" = 17,
+ oldstat = 18,
+ lseek = 19,
+ getpid = 20,
+ mount = 21,
+ umount = 22,
+ setuid = 23,
+ getuid = 24,
+ stime = 25,
+ ptrace = 26,
+ alarm = 27,
+ oldfstat = 28,
+ pause = 29,
+ utime = 30,
+ stty = 31,
+ gtty = 32,
+ access = 33,
+ nice = 34,
+ ftime = 35,
+ sync = 36,
+ kill = 37,
+ rename = 38,
+ mkdir = 39,
+ rmdir = 40,
+ dup = 41,
+ pipe = 42,
+ times = 43,
+ prof = 44,
+ brk = 45,
+ setgid = 46,
+ getgid = 47,
+ signal = 48,
+ geteuid = 49,
+ getegid = 50,
+ acct = 51,
+ umount2 = 52,
+ lock = 53,
+ ioctl = 54,
+ fcntl = 55,
+ mpx = 56,
+ setpgid = 57,
+ ulimit = 58,
+ oldolduname = 59,
+ umask = 60,
+ chroot = 61,
+ ustat = 62,
+ dup2 = 63,
+ getppid = 64,
+ getpgrp = 65,
+ setsid = 66,
+ sigaction = 67,
+ sgetmask = 68,
+ ssetmask = 69,
+ setreuid = 70,
+ setregid = 71,
+ sigsuspend = 72,
+ sigpending = 73,
+ sethostname = 74,
+ setrlimit = 75,
+ getrlimit = 76,
+ getrusage = 77,
+ gettimeofday = 78,
+ settimeofday = 79,
+ getgroups = 80,
+ setgroups = 81,
+ select = 82,
+ symlink = 83,
+ oldlstat = 84,
+ readlink = 85,
+ uselib = 86,
+ swapon = 87,
+ reboot = 88,
+ readdir = 89,
+ mmap = 90,
+ munmap = 91,
+ truncate = 92,
+ ftruncate = 93,
+ fchmod = 94,
+ fchown = 95,
+ getpriority = 96,
+ setpriority = 97,
+ profil = 98,
+ statfs = 99,
+ fstatfs = 100,
+ ioperm = 101,
+ socketcall = 102,
+ syslog = 103,
+ setitimer = 104,
+ getitimer = 105,
+ stat = 106,
+ lstat = 107,
+ fstat = 108,
+ olduname = 109,
+ iopl = 110,
+ vhangup = 111,
+ idle = 112,
+ vm86old = 113,
+ wait4 = 114,
+ swapoff = 115,
+ sysinfo = 116,
+ ipc = 117,
+ fsync = 118,
+ sigreturn = 119,
+ clone = 120,
+ setdomainname = 121,
+ uname = 122,
+ modify_ldt = 123,
+ adjtimex = 124,
+ mprotect = 125,
+ sigprocmask = 126,
+ create_module = 127,
+ init_module = 128,
+ delete_module = 129,
+ get_kernel_syms = 130,
+ quotactl = 131,
+ getpgid = 132,
+ fchdir = 133,
+ bdflush = 134,
+ sysfs = 135,
+ personality = 136,
+ afs_syscall = 137,
+ setfsuid = 138,
+ setfsgid = 139,
+ _llseek = 140,
+ getdents = 141,
+ _newselect = 142,
+ flock = 143,
+ msync = 144,
+ readv = 145,
+ writev = 146,
+ getsid = 147,
+ fdatasync = 148,
+ _sysctl = 149,
+ mlock = 150,
+ munlock = 151,
+ mlockall = 152,
+ munlockall = 153,
+ sched_setparam = 154,
+ sched_getparam = 155,
+ sched_setscheduler = 156,
+ sched_getscheduler = 157,
+ sched_yield = 158,
+ sched_get_priority_max = 159,
+ sched_get_priority_min = 160,
+ sched_rr_get_interval = 161,
+ nanosleep = 162,
+ mremap = 163,
+ setresuid = 164,
+ getresuid = 165,
+ vm86 = 166,
+ query_module = 167,
+ poll = 168,
+ nfsservctl = 169,
+ setresgid = 170,
+ getresgid = 171,
+ prctl = 172,
+ rt_sigreturn = 173,
+ rt_sigaction = 174,
+ rt_sigprocmask = 175,
+ rt_sigpending = 176,
+ rt_sigtimedwait = 177,
+ rt_sigqueueinfo = 178,
+ rt_sigsuspend = 179,
+ pread64 = 180,
+ pwrite64 = 181,
+ chown = 182,
+ getcwd = 183,
+ capget = 184,
+ capset = 185,
+ sigaltstack = 186,
+ sendfile = 187,
+ getpmsg = 188,
+ putpmsg = 189,
+ vfork = 190,
+ ugetrlimit = 191,
+ mmap2 = 192,
+ truncate64 = 193,
+ ftruncate64 = 194,
+ stat64 = 195,
+ lstat64 = 196,
+ fstat64 = 197,
+ lchown32 = 198,
+ getuid32 = 199,
+ getgid32 = 200,
+ geteuid32 = 201,
+ getegid32 = 202,
+ setreuid32 = 203,
+ setregid32 = 204,
+ getgroups32 = 205,
+ setgroups32 = 206,
+ fchown32 = 207,
+ setresuid32 = 208,
+ getresuid32 = 209,
+ setresgid32 = 210,
+ getresgid32 = 211,
+ chown32 = 212,
+ setuid32 = 213,
+ setgid32 = 214,
+ setfsuid32 = 215,
+ setfsgid32 = 216,
+ pivot_root = 217,
+ mincore = 218,
+ madvise = 219,
+ getdents64 = 220,
+ fcntl64 = 221,
+ gettid = 224,
+ readahead = 225,
+ setxattr = 226,
+ lsetxattr = 227,
+ fsetxattr = 228,
+ getxattr = 229,
+ lgetxattr = 230,
+ fgetxattr = 231,
+ listxattr = 232,
+ llistxattr = 233,
+ flistxattr = 234,
+ removexattr = 235,
+ lremovexattr = 236,
+ fremovexattr = 237,
+ tkill = 238,
+ sendfile64 = 239,
+ futex = 240,
+ sched_setaffinity = 241,
+ sched_getaffinity = 242,
+ set_thread_area = 243,
+ get_thread_area = 244,
+ io_setup = 245,
+ io_destroy = 246,
+ io_getevents = 247,
+ io_submit = 248,
+ io_cancel = 249,
+ fadvise64 = 250,
+ exit_group = 252,
+ lookup_dcookie = 253,
+ epoll_create = 254,
+ epoll_ctl = 255,
+ epoll_wait = 256,
+ remap_file_pages = 257,
+ set_tid_address = 258,
+ timer_create = 259,
+ timer_settime, // SYS_timer_create + 1
+ timer_gettime, // SYS_timer_create + 2
+ timer_getoverrun, // SYS_timer_create + 3
+ timer_delete, // SYS_timer_create + 4
+ clock_settime, // SYS_timer_create + 5
+ clock_gettime, // SYS_timer_create + 6
+ clock_getres, // SYS_timer_create + 7
+ clock_nanosleep, // SYS_timer_create + 8
+ statfs64 = 268,
+ fstatfs64 = 269,
+ tgkill = 270,
+ utimes = 271,
+ fadvise64_64 = 272,
+ vserver = 273,
+ mbind = 274,
+ get_mempolicy = 275,
+ set_mempolicy = 276,
+ mq_open = 277,
+ mq_unlink, // SYS_mq_open + 1
+ mq_timedsend, // SYS_mq_open + 2
+ mq_timedreceive, // SYS_mq_open + 3
+ mq_notify, // SYS_mq_open + 4
+ mq_getsetattr, // SYS_mq_open + 5
+ kexec_load = 283,
+ waitid = 284,
+ add_key = 286,
+ request_key = 287,
+ keyctl = 288,
+ ioprio_set = 289,
+ ioprio_get = 290,
+ inotify_init = 291,
+ inotify_add_watch = 292,
+ inotify_rm_watch = 293,
+ migrate_pages = 294,
+ openat = 295,
+ mkdirat = 296,
+ mknodat = 297,
+ fchownat = 298,
+ futimesat = 299,
+ fstatat64 = 300,
+ unlinkat = 301,
+ renameat = 302,
+ linkat = 303,
+ symlinkat = 304,
+ readlinkat = 305,
+ fchmodat = 306,
+ faccessat = 307,
+ pselect6 = 308,
+ ppoll = 309,
+ unshare = 310,
+ set_robust_list = 311,
+ get_robust_list = 312,
+ splice = 313,
+ sync_file_range = 314,
+ tee = 315,
+ vmsplice = 316,
+ move_pages = 317,
+ getcpu = 318,
+ epoll_pwait = 319,
+ utimensat = 320,
+ signalfd = 321,
+ timerfd_create = 322,
+ eventfd = 323,
+ fallocate = 324,
+ timerfd_settime = 325,
+ timerfd_gettime = 326,
+ signalfd4 = 327,
+ eventfd2 = 328,
+ epoll_create1 = 329,
+ dup3 = 330,
+ pipe2 = 331,
+ inotify_init1 = 332,
+ preadv = 333,
+ pwritev = 334,
+ rt_tgsigqueueinfo = 335,
+ perf_event_open = 336,
+ recvmmsg = 337,
+ fanotify_init = 338,
+ fanotify_mark = 339,
+ prlimit64 = 340,
+ name_to_handle_at = 341,
+ open_by_handle_at = 342,
+ clock_adjtime = 343,
+ syncfs = 344,
+ sendmmsg = 345,
+ setns = 346,
+ process_vm_readv = 347,
+ process_vm_writev = 348,
+ kcmp = 349,
+ finit_module = 350,
+ sched_setattr = 351,
+ sched_getattr = 352,
+ renameat2 = 353,
+ seccomp = 354,
+ getrandom = 355,
+ memfd_create = 356,
+ bpf = 357,
+ execveat = 358,
+ socket = 359,
+ socketpair = 360,
+ bind = 361,
+ connect = 362,
+ listen = 363,
+ accept4 = 364,
+ getsockopt = 365,
+ setsockopt = 366,
+ getsockname = 367,
+ getpeername = 368,
+ sendto = 369,
+ sendmsg = 370,
+ recvfrom = 371,
+ recvmsg = 372,
+ shutdown = 373,
+ userfaultfd = 374,
+ membarrier = 375,
+ mlock2 = 376,
+ copy_file_range = 377,
+ preadv2 = 378,
+ pwritev2 = 379,
+ pkey_mprotect = 380,
+ pkey_alloc = 381,
+ pkey_free = 382,
+ statx = 383,
+ arch_prctl = 384,
+ io_pgetevents = 385,
+ rseq = 386,
+ semget = 393,
+ semctl = 394,
+ shmget = 395,
+ shmctl = 396,
+ shmat = 397,
+ shmdt = 398,
+ msgget = 399,
+ msgsnd = 400,
+ msgrcv = 401,
+ msgctl = 402,
+ clock_gettime64 = 403,
+ clock_settime64 = 404,
+ clock_adjtime64 = 405,
+ clock_getres_time64 = 406,
+ clock_nanosleep_time64 = 407,
+ timer_gettime64 = 408,
+ timer_settime64 = 409,
+ timerfd_gettime64 = 410,
+ timerfd_settime64 = 411,
+ utimensat_time64 = 412,
+ pselect6_time64 = 413,
+ ppoll_time64 = 414,
+ io_pgetevents_time64 = 416,
+ recvmmsg_time64 = 417,
+ mq_timedsend_time64 = 418,
+ mq_timedreceive_time64 = 419,
+ semtimedop_time64 = 420,
+ rt_sigtimedwait_time64 = 421,
+ futex_time64 = 422,
+ sched_rr_get_interval_time64 = 423,
+ pidfd_send_signal = 424,
+ io_uring_setup = 425,
+ io_uring_enter = 426,
+ io_uring_register = 427,
+ open_tree = 428,
+ move_mount = 429,
+ fsopen = 430,
+ fsconfig = 431,
+ fsmount = 432,
+ fspick = 433,
+ pidfd_open = 434,
+ clone3 = 435,
+ close_range = 436,
+ openat2 = 437,
+ pidfd_getfd = 438,
+ faccessat2 = 439,
+ process_madvise = 440,
+ epoll_pwait2 = 441,
+
+ _,
+};
+
+pub const O = struct {
+ pub const CREAT = 0o100;
+ pub const EXCL = 0o200;
+ pub const NOCTTY = 0o400;
+ pub const TRUNC = 0o1000;
+ pub const APPEND = 0o2000;
+ pub const NONBLOCK = 0o4000;
+ pub const DSYNC = 0o10000;
+ pub const SYNC = 0o4010000;
+ pub const RSYNC = 0o4010000;
+ pub const DIRECTORY = 0o200000;
+ pub const NOFOLLOW = 0o400000;
+ pub const CLOEXEC = 0o2000000;
+
+ pub const ASYNC = 0o20000;
+ pub const DIRECT = 0o40000;
+ pub const LARGEFILE = 0o100000;
+ pub const NOATIME = 0o1000000;
+ pub const PATH = 0o10000000;
+ pub const TMPFILE = 0o20200000;
+ pub const NDELAY = NONBLOCK;
+};
+
+pub const F = struct {
+ pub const DUPFD = 0;
+ pub const GETFD = 1;
+ pub const SETFD = 2;
+ pub const GETFL = 3;
+ pub const SETFL = 4;
+ pub const SETOWN = 8;
+ pub const GETOWN = 9;
+ pub const SETSIG = 10;
+ pub const GETSIG = 11;
+ pub const GETLK = 12;
+ pub const SETLK = 13;
+ pub const SETLKW = 14;
+ pub const SETOWN_EX = 15;
+ pub const GETOWN_EX = 16;
+ pub const GETOWNER_UIDS = 17;
+
+ pub const RDLCK = 0;
+ pub const WRLCK = 1;
+ pub const UNLCK = 2;
+};
+
+pub const LOCK = struct {
+ pub const SH = 1;
+ pub const EX = 2;
+ pub const NB = 4;
+ pub const UN = 8;
+};
+
+pub const MAP = struct {
+ pub const NORESERVE = 0x4000;
+ pub const GROWSDOWN = 0x0100;
+ pub const DENYWRITE = 0x0800;
+ pub const EXECUTABLE = 0x1000;
+ pub const LOCKED = 0x2000;
+ pub const @"32BIT" = 0x40;
+};
+
+pub const MMAP2_UNIT = 4096;
+
+pub const VDSO = struct {
+ pub const CGT_SYM = "__vdso_clock_gettime";
+ pub const CGT_VER = "LINUX_2.6";
+};
+
+pub const ARCH = struct {};
+
+pub const Flock = extern struct {
+ type: i16,
+ whence: i16,
+ start: off_t,
+ len: off_t,
+ pid: pid_t,
+};
+
+pub const msghdr = extern struct {
+ name: ?*sockaddr,
+ namelen: socklen_t,
+ iov: [*]iovec,
+ iovlen: i32,
+ control: ?*c_void,
+ controllen: socklen_t,
+ flags: i32,
+};
+
+pub const msghdr_const = extern struct {
+ name: ?*const sockaddr,
+ namelen: socklen_t,
+ iov: [*]iovec_const,
+ iovlen: i32,
+ control: ?*c_void,
+ controllen: socklen_t,
+ flags: i32,
+};
+
+pub const blksize_t = i32;
+pub const nlink_t = u32;
+pub const time_t = isize;
+pub const mode_t = u32;
+pub const off_t = i64;
+pub const ino_t = u64;
+pub const dev_t = u64;
+pub const blkcnt_t = i64;
+
+// The `stat` definition used by the Linux kernel.
+pub const Stat = extern struct {
+ dev: dev_t,
+ __dev_padding: u32,
+ __ino_truncated: u32,
+ mode: mode_t,
+ nlink: nlink_t,
+ uid: uid_t,
+ gid: gid_t,
+ rdev: dev_t,
+ __rdev_padding: u32,
+ size: off_t,
+ blksize: blksize_t,
+ blocks: blkcnt_t,
+ atim: timespec,
+ mtim: timespec,
+ ctim: timespec,
+ ino: ino_t,
+
+ pub fn atime(self: @This()) timespec {
+ return self.atim;
+ }
+
+ pub fn mtime(self: @This()) timespec {
+ return self.mtim;
+ }
+
+ pub fn ctime(self: @This()) timespec {
+ return self.ctim;
+ }
+};
+
+pub const timeval = extern struct {
+ tv_sec: i32,
+ tv_usec: i32,
+};
+
+pub const timezone = extern struct {
+ tz_minuteswest: i32,
+ tz_dsttime: i32,
+};
+
+pub const mcontext_t = extern struct {
+ gregs: [19]usize,
+ fpregs: [*]u8,
+ oldmask: usize,
+ cr2: usize,
+};
+
+pub const REG = struct {
+ pub const GS = 0;
+ pub const FS = 1;
+ pub const ES = 2;
+ pub const DS = 3;
+ pub const EDI = 4;
+ pub const ESI = 5;
+ pub const EBP = 6;
+ pub const ESP = 7;
+ pub const EBX = 8;
+ pub const EDX = 9;
+ pub const ECX = 10;
+ pub const EAX = 11;
+ pub const TRAPNO = 12;
+ pub const ERR = 13;
+ pub const EIP = 14;
+ pub const CS = 15;
+ pub const EFL = 16;
+ pub const UESP = 17;
+ pub const SS = 18;
+};
+
+pub const ucontext_t = extern struct {
+ flags: usize,
+ link: *ucontext_t,
+ stack: stack_t,
+ mcontext: mcontext_t,
+ sigmask: sigset_t,
+ regspace: [64]u64,
+};
+
+pub const Elf_Symndx = u32;
+
+pub const user_desc = packed struct {
+ entry_number: u32,
+ base_addr: u32,
+ limit: u32,
+ seg_32bit: u1,
+ contents: u2,
+ read_exec_only: u1,
+ limit_in_pages: u1,
+ seg_not_present: u1,
+ useable: u1,
+};
+
+/// socketcall() call numbers
+pub const SC = struct {
+ pub const socket = 1;
+ pub const bind = 2;
+ pub const connect = 3;
+ pub const listen = 4;
+ pub const accept = 5;
+ pub const getsockname = 6;
+ pub const getpeername = 7;
+ pub const socketpair = 8;
+ pub const send = 9;
+ pub const recv = 10;
+ pub const sendto = 11;
+ pub const recvfrom = 12;
+ pub const shutdown = 13;
+ pub const setsockopt = 14;
+ pub const getsockopt = 15;
+ pub const sendmsg = 16;
+ pub const recvmsg = 17;
+ pub const accept4 = 18;
+ pub const recvmmsg = 19;
+ pub const sendmmsg = 20;
+};
diff --git a/lib/std/os/linux/io_uring.zig b/lib/std/os/linux/io_uring.zig
index b74a7da3dd0d..a98ce009a962 100644
--- a/lib/std/os/linux/io_uring.zig
+++ b/lib/std/os/linux/io_uring.zig
@@ -535,11 +535,11 @@ pub const IO_Uring = struct {
/// `0` if the timeout completed after the specified number of events, or `-ECANCELED` if the
/// timeout was removed before it expired.
///
- /// io_uring timeouts use the `CLOCK_MONOTONIC` clock source.
+ /// io_uring timeouts use the `CLOCK.MONOTONIC` clock source.
pub fn timeout(
self: *IO_Uring,
user_data: u64,
- ts: *const os.__kernel_timespec,
+ ts: *const os.linux.kernel_timespec,
count: u32,
flags: u32,
) !*io_uring_sqe {
@@ -736,8 +736,8 @@ pub const SubmissionQueue = struct {
const mmap = try os.mmap(
null,
size,
- os.PROT_READ | os.PROT_WRITE,
- os.MAP_SHARED | os.MAP_POPULATE,
+ os.PROT.READ | os.PROT.WRITE,
+ os.MAP.SHARED | os.MAP.POPULATE,
fd,
linux.IORING_OFF_SQ_RING,
);
@@ -750,8 +750,8 @@ pub const SubmissionQueue = struct {
const mmap_sqes = try os.mmap(
null,
size_sqes,
- os.PROT_READ | os.PROT_WRITE,
- os.MAP_SHARED | os.MAP_POPULATE,
+ os.PROT.READ | os.PROT.WRITE,
+ os.MAP.SHARED | os.MAP.POPULATE,
fd,
linux.IORING_OFF_SQES,
);
@@ -979,7 +979,7 @@ pub fn io_uring_prep_close(sqe: *io_uring_sqe, fd: os.fd_t) void {
pub fn io_uring_prep_timeout(
sqe: *io_uring_sqe,
- ts: *const os.__kernel_timespec,
+ ts: *const os.linux.kernel_timespec,
count: u32,
flags: u32,
) void {
@@ -1136,7 +1136,7 @@ test "readv" {
};
defer ring.deinit();
- const fd = try os.openZ("/dev/zero", os.O_RDONLY | os.O_CLOEXEC, 0);
+ const fd = try os.openZ("/dev/zero", os.O.RDONLY | os.O.CLOEXEC, 0);
defer os.close(fd);
// Linux Kernel 5.4 supports IORING_REGISTER_FILES but not sparse fd sets (i.e. an fd of -1).
@@ -1295,14 +1295,14 @@ test "openat" {
const path = "test_io_uring_openat";
defer std.fs.cwd().deleteFile(path) catch {};
- const flags: u32 = os.O_CLOEXEC | os.O_RDWR | os.O_CREAT;
+ const flags: u32 = os.O.CLOEXEC | os.O.RDWR | os.O.CREAT;
const mode: os.mode_t = 0o666;
- const sqe_openat = try ring.openat(0x33333333, linux.AT_FDCWD, path, flags, mode);
+ const sqe_openat = try ring.openat(0x33333333, linux.AT.FDCWD, path, flags, mode);
try testing.expectEqual(io_uring_sqe{
.opcode = .OPENAT,
.flags = 0,
.ioprio = 0,
- .fd = linux.AT_FDCWD,
+ .fd = linux.AT.FDCWD,
.off = 0,
.addr = @ptrToInt(path),
.len = mode,
@@ -1318,7 +1318,7 @@ test "openat" {
const cqe_openat = try ring.copy_cqe();
try testing.expectEqual(@as(u64, 0x33333333), cqe_openat.user_data);
if (cqe_openat.err() == .INVAL) return error.SkipZigTest;
- // AT_FDCWD is not fully supported before kernel 5.6:
+ // AT.FDCWD is not fully supported before kernel 5.6:
// See https://lore.kernel.org/io-uring/20200207155039.12819-1-axboe@kernel.dk/T/
// We use IORING_FEAT_RW_CUR_POS to know if we are pre-5.6 since that feature was added in 5.6.
if (cqe_openat.err() == .BADF and (ring.features & linux.IORING_FEAT_RW_CUR_POS) == 0) {
@@ -1372,9 +1372,9 @@ test "accept/connect/send/recv" {
const address = try net.Address.parseIp4("127.0.0.1", 3131);
const kernel_backlog = 1;
- const server = try os.socket(address.any.family, os.SOCK_STREAM | os.SOCK_CLOEXEC, 0);
+ const server = try os.socket(address.any.family, os.SOCK.STREAM | os.SOCK.CLOEXEC, 0);
defer os.close(server);
- try os.setsockopt(server, os.SOL_SOCKET, os.SO_REUSEADDR, &mem.toBytes(@as(c_int, 1)));
+ try os.setsockopt(server, os.SOL.SOCKET, os.SO.REUSEADDR, &mem.toBytes(@as(c_int, 1)));
try os.bind(server, &address.any, address.getOsSockLen());
try os.listen(server, kernel_backlog);
@@ -1386,7 +1386,7 @@ test "accept/connect/send/recv" {
_ = try ring.accept(0xaaaaaaaa, server, &accept_addr, &accept_addr_len, 0);
try testing.expectEqual(@as(u32, 1), try ring.submit());
- const client = try os.socket(address.any.family, os.SOCK_STREAM | os.SOCK_CLOEXEC, 0);
+ const client = try os.socket(address.any.family, os.SOCK.STREAM | os.SOCK.CLOEXEC, 0);
defer os.close(client);
_ = try ring.connect(0xcccccccc, client, &address.any, address.getOsSockLen());
try testing.expectEqual(@as(u32, 1), try ring.submit());
@@ -1450,7 +1450,7 @@ test "timeout (after a relative time)" {
const ms = 10;
const margin = 5;
- const ts = os.__kernel_timespec{ .tv_sec = 0, .tv_nsec = ms * 1000000 };
+ const ts = os.linux.kernel_timespec{ .tv_sec = 0, .tv_nsec = ms * 1000000 };
const started = std.time.milliTimestamp();
const sqe = try ring.timeout(0x55555555, &ts, 0, 0);
@@ -1479,7 +1479,7 @@ test "timeout (after a number of completions)" {
};
defer ring.deinit();
- const ts = os.__kernel_timespec{ .tv_sec = 3, .tv_nsec = 0 };
+ const ts = os.linux.kernel_timespec{ .tv_sec = 3, .tv_nsec = 0 };
const count_completions: u64 = 1;
const sqe_timeout = try ring.timeout(0x66666666, &ts, count_completions, 0);
try testing.expectEqual(linux.IORING_OP.TIMEOUT, sqe_timeout.opcode);
@@ -1512,7 +1512,7 @@ test "timeout_remove" {
};
defer ring.deinit();
- const ts = os.__kernel_timespec{ .tv_sec = 3, .tv_nsec = 0 };
+ const ts = os.linux.kernel_timespec{ .tv_sec = 3, .tv_nsec = 0 };
const sqe_timeout = try ring.timeout(0x88888888, &ts, 0, 0);
try testing.expectEqual(linux.IORING_OP.TIMEOUT, sqe_timeout.opcode);
try testing.expectEqual(@as(u64, 0x88888888), sqe_timeout.user_data);
diff --git a/lib/std/os/linux/mips.zig b/lib/std/os/linux/mips.zig
index f59f04b13053..b3697405f7b9 100644
--- a/lib/std/os/linux/mips.zig
+++ b/lib/std/os/linux/mips.zig
@@ -1,4 +1,13 @@
-usingnamespace @import("../bits/linux.zig");
+const std = @import("../../std.zig");
+const maxInt = std.math.maxInt;
+const linux = std.os.linux;
+const socklen_t = linux.socklen_t;
+const iovec = linux.iovec;
+const iovec_const = linux.iovec_const;
+const uid_t = linux.uid_t;
+const gid_t = linux.gid_t;
+const pid_t = linux.pid_t;
+const timespec = linux.timespec;
pub fn syscall0(number: SYS) usize {
return asm volatile (
@@ -197,3 +206,562 @@ pub fn restore_rt() callconv(.Naked) void {
: "memory", "cc", "$7"
);
}
+
+pub const SYS = enum(usize) {
+ pub const Linux = 4000;
+
+ syscall = Linux + 0,
+ exit = Linux + 1,
+ fork = Linux + 2,
+ read = Linux + 3,
+ write = Linux + 4,
+ open = Linux + 5,
+ close = Linux + 6,
+ waitpid = Linux + 7,
+ creat = Linux + 8,
+ link = Linux + 9,
+ unlink = Linux + 10,
+ execve = Linux + 11,
+ chdir = Linux + 12,
+ time = Linux + 13,
+ mknod = Linux + 14,
+ chmod = Linux + 15,
+ lchown = Linux + 16,
+ @"break" = Linux + 17,
+ unused18 = Linux + 18,
+ lseek = Linux + 19,
+ getpid = Linux + 20,
+ mount = Linux + 21,
+ umount = Linux + 22,
+ setuid = Linux + 23,
+ getuid = Linux + 24,
+ stime = Linux + 25,
+ ptrace = Linux + 26,
+ alarm = Linux + 27,
+ unused28 = Linux + 28,
+ pause = Linux + 29,
+ utime = Linux + 30,
+ stty = Linux + 31,
+ gtty = Linux + 32,
+ access = Linux + 33,
+ nice = Linux + 34,
+ ftime = Linux + 35,
+ sync = Linux + 36,
+ kill = Linux + 37,
+ rename = Linux + 38,
+ mkdir = Linux + 39,
+ rmdir = Linux + 40,
+ dup = Linux + 41,
+ pipe = Linux + 42,
+ times = Linux + 43,
+ prof = Linux + 44,
+ brk = Linux + 45,
+ setgid = Linux + 46,
+ getgid = Linux + 47,
+ signal = Linux + 48,
+ geteuid = Linux + 49,
+ getegid = Linux + 50,
+ acct = Linux + 51,
+ umount2 = Linux + 52,
+ lock = Linux + 53,
+ ioctl = Linux + 54,
+ fcntl = Linux + 55,
+ mpx = Linux + 56,
+ setpgid = Linux + 57,
+ ulimit = Linux + 58,
+ unused59 = Linux + 59,
+ umask = Linux + 60,
+ chroot = Linux + 61,
+ ustat = Linux + 62,
+ dup2 = Linux + 63,
+ getppid = Linux + 64,
+ getpgrp = Linux + 65,
+ setsid = Linux + 66,
+ sigaction = Linux + 67,
+ sgetmask = Linux + 68,
+ ssetmask = Linux + 69,
+ setreuid = Linux + 70,
+ setregid = Linux + 71,
+ sigsuspend = Linux + 72,
+ sigpending = Linux + 73,
+ sethostname = Linux + 74,
+ setrlimit = Linux + 75,
+ getrlimit = Linux + 76,
+ getrusage = Linux + 77,
+ gettimeofday = Linux + 78,
+ settimeofday = Linux + 79,
+ getgroups = Linux + 80,
+ setgroups = Linux + 81,
+ reserved82 = Linux + 82,
+ symlink = Linux + 83,
+ unused84 = Linux + 84,
+ readlink = Linux + 85,
+ uselib = Linux + 86,
+ swapon = Linux + 87,
+ reboot = Linux + 88,
+ readdir = Linux + 89,
+ mmap = Linux + 90,
+ munmap = Linux + 91,
+ truncate = Linux + 92,
+ ftruncate = Linux + 93,
+ fchmod = Linux + 94,
+ fchown = Linux + 95,
+ getpriority = Linux + 96,
+ setpriority = Linux + 97,
+ profil = Linux + 98,
+ statfs = Linux + 99,
+ fstatfs = Linux + 100,
+ ioperm = Linux + 101,
+ socketcall = Linux + 102,
+ syslog = Linux + 103,
+ setitimer = Linux + 104,
+ getitimer = Linux + 105,
+ stat = Linux + 106,
+ lstat = Linux + 107,
+ fstat = Linux + 108,
+ unused109 = Linux + 109,
+ iopl = Linux + 110,
+ vhangup = Linux + 111,
+ idle = Linux + 112,
+ vm86 = Linux + 113,
+ wait4 = Linux + 114,
+ swapoff = Linux + 115,
+ sysinfo = Linux + 116,
+ ipc = Linux + 117,
+ fsync = Linux + 118,
+ sigreturn = Linux + 119,
+ clone = Linux + 120,
+ setdomainname = Linux + 121,
+ uname = Linux + 122,
+ modify_ldt = Linux + 123,
+ adjtimex = Linux + 124,
+ mprotect = Linux + 125,
+ sigprocmask = Linux + 126,
+ create_module = Linux + 127,
+ init_module = Linux + 128,
+ delete_module = Linux + 129,
+ get_kernel_syms = Linux + 130,
+ quotactl = Linux + 131,
+ getpgid = Linux + 132,
+ fchdir = Linux + 133,
+ bdflush = Linux + 134,
+ sysfs = Linux + 135,
+ personality = Linux + 136,
+ afs_syscall = Linux + 137,
+ setfsuid = Linux + 138,
+ setfsgid = Linux + 139,
+ _llseek = Linux + 140,
+ getdents = Linux + 141,
+ _newselect = Linux + 142,
+ flock = Linux + 143,
+ msync = Linux + 144,
+ readv = Linux + 145,
+ writev = Linux + 146,
+ cacheflush = Linux + 147,
+ cachectl = Linux + 148,
+ sysmips = Linux + 149,
+ unused150 = Linux + 150,
+ getsid = Linux + 151,
+ fdatasync = Linux + 152,
+ _sysctl = Linux + 153,
+ mlock = Linux + 154,
+ munlock = Linux + 155,
+ mlockall = Linux + 156,
+ munlockall = Linux + 157,
+ sched_setparam = Linux + 158,
+ sched_getparam = Linux + 159,
+ sched_setscheduler = Linux + 160,
+ sched_getscheduler = Linux + 161,
+ sched_yield = Linux + 162,
+ sched_get_priority_max = Linux + 163,
+ sched_get_priority_min = Linux + 164,
+ sched_rr_get_interval = Linux + 165,
+ nanosleep = Linux + 166,
+ mremap = Linux + 167,
+ accept = Linux + 168,
+ bind = Linux + 169,
+ connect = Linux + 170,
+ getpeername = Linux + 171,
+ getsockname = Linux + 172,
+ getsockopt = Linux + 173,
+ listen = Linux + 174,
+ recv = Linux + 175,
+ recvfrom = Linux + 176,
+ recvmsg = Linux + 177,
+ send = Linux + 178,
+ sendmsg = Linux + 179,
+ sendto = Linux + 180,
+ setsockopt = Linux + 181,
+ shutdown = Linux + 182,
+ socket = Linux + 183,
+ socketpair = Linux + 184,
+ setresuid = Linux + 185,
+ getresuid = Linux + 186,
+ query_module = Linux + 187,
+ poll = Linux + 188,
+ nfsservctl = Linux + 189,
+ setresgid = Linux + 190,
+ getresgid = Linux + 191,
+ prctl = Linux + 192,
+ rt_sigreturn = Linux + 193,
+ rt_sigaction = Linux + 194,
+ rt_sigprocmask = Linux + 195,
+ rt_sigpending = Linux + 196,
+ rt_sigtimedwait = Linux + 197,
+ rt_sigqueueinfo = Linux + 198,
+ rt_sigsuspend = Linux + 199,
+ pread64 = Linux + 200,
+ pwrite64 = Linux + 201,
+ chown = Linux + 202,
+ getcwd = Linux + 203,
+ capget = Linux + 204,
+ capset = Linux + 205,
+ sigaltstack = Linux + 206,
+ sendfile = Linux + 207,
+ getpmsg = Linux + 208,
+ putpmsg = Linux + 209,
+ mmap2 = Linux + 210,
+ truncate64 = Linux + 211,
+ ftruncate64 = Linux + 212,
+ stat64 = Linux + 213,
+ lstat64 = Linux + 214,
+ fstat64 = Linux + 215,
+ pivot_root = Linux + 216,
+ mincore = Linux + 217,
+ madvise = Linux + 218,
+ getdents64 = Linux + 219,
+ fcntl64 = Linux + 220,
+ reserved221 = Linux + 221,
+ gettid = Linux + 222,
+ readahead = Linux + 223,
+ setxattr = Linux + 224,
+ lsetxattr = Linux + 225,
+ fsetxattr = Linux + 226,
+ getxattr = Linux + 227,
+ lgetxattr = Linux + 228,
+ fgetxattr = Linux + 229,
+ listxattr = Linux + 230,
+ llistxattr = Linux + 231,
+ flistxattr = Linux + 232,
+ removexattr = Linux + 233,
+ lremovexattr = Linux + 234,
+ fremovexattr = Linux + 235,
+ tkill = Linux + 236,
+ sendfile64 = Linux + 237,
+ futex = Linux + 238,
+ sched_setaffinity = Linux + 239,
+ sched_getaffinity = Linux + 240,
+ io_setup = Linux + 241,
+ io_destroy = Linux + 242,
+ io_getevents = Linux + 243,
+ io_submit = Linux + 244,
+ io_cancel = Linux + 245,
+ exit_group = Linux + 246,
+ lookup_dcookie = Linux + 247,
+ epoll_create = Linux + 248,
+ epoll_ctl = Linux + 249,
+ epoll_wait = Linux + 250,
+ remap_file_pages = Linux + 251,
+ set_tid_address = Linux + 252,
+ restart_syscall = Linux + 253,
+ fadvise64 = Linux + 254,
+ statfs64 = Linux + 255,
+ fstatfs64 = Linux + 256,
+ timer_create = Linux + 257,
+ timer_settime = Linux + 258,
+ timer_gettime = Linux + 259,
+ timer_getoverrun = Linux + 260,
+ timer_delete = Linux + 261,
+ clock_settime = Linux + 262,
+ clock_gettime = Linux + 263,
+ clock_getres = Linux + 264,
+ clock_nanosleep = Linux + 265,
+ tgkill = Linux + 266,
+ utimes = Linux + 267,
+ mbind = Linux + 268,
+ get_mempolicy = Linux + 269,
+ set_mempolicy = Linux + 270,
+ mq_open = Linux + 271,
+ mq_unlink = Linux + 272,
+ mq_timedsend = Linux + 273,
+ mq_timedreceive = Linux + 274,
+ mq_notify = Linux + 275,
+ mq_getsetattr = Linux + 276,
+ vserver = Linux + 277,
+ waitid = Linux + 278,
+ add_key = Linux + 280,
+ request_key = Linux + 281,
+ keyctl = Linux + 282,
+ set_thread_area = Linux + 283,
+ inotify_init = Linux + 284,
+ inotify_add_watch = Linux + 285,
+ inotify_rm_watch = Linux + 286,
+ migrate_pages = Linux + 287,
+ openat = Linux + 288,
+ mkdirat = Linux + 289,
+ mknodat = Linux + 290,
+ fchownat = Linux + 291,
+ futimesat = Linux + 292,
+ fstatat64 = Linux + 293,
+ unlinkat = Linux + 294,
+ renameat = Linux + 295,
+ linkat = Linux + 296,
+ symlinkat = Linux + 297,
+ readlinkat = Linux + 298,
+ fchmodat = Linux + 299,
+ faccessat = Linux + 300,
+ pselect6 = Linux + 301,
+ ppoll = Linux + 302,
+ unshare = Linux + 303,
+ splice = Linux + 304,
+ sync_file_range = Linux + 305,
+ tee = Linux + 306,
+ vmsplice = Linux + 307,
+ move_pages = Linux + 308,
+ set_robust_list = Linux + 309,
+ get_robust_list = Linux + 310,
+ kexec_load = Linux + 311,
+ getcpu = Linux + 312,
+ epoll_pwait = Linux + 313,
+ ioprio_set = Linux + 314,
+ ioprio_get = Linux + 315,
+ utimensat = Linux + 316,
+ signalfd = Linux + 317,
+ timerfd = Linux + 318,
+ eventfd = Linux + 319,
+ fallocate = Linux + 320,
+ timerfd_create = Linux + 321,
+ timerfd_gettime = Linux + 322,
+ timerfd_settime = Linux + 323,
+ signalfd4 = Linux + 324,
+ eventfd2 = Linux + 325,
+ epoll_create1 = Linux + 326,
+ dup3 = Linux + 327,
+ pipe2 = Linux + 328,
+ inotify_init1 = Linux + 329,
+ preadv = Linux + 330,
+ pwritev = Linux + 331,
+ rt_tgsigqueueinfo = Linux + 332,
+ perf_event_open = Linux + 333,
+ accept4 = Linux + 334,
+ recvmmsg = Linux + 335,
+ fanotify_init = Linux + 336,
+ fanotify_mark = Linux + 337,
+ prlimit64 = Linux + 338,
+ name_to_handle_at = Linux + 339,
+ open_by_handle_at = Linux + 340,
+ clock_adjtime = Linux + 341,
+ syncfs = Linux + 342,
+ sendmmsg = Linux + 343,
+ setns = Linux + 344,
+ process_vm_readv = Linux + 345,
+ process_vm_writev = Linux + 346,
+ kcmp = Linux + 347,
+ finit_module = Linux + 348,
+ sched_setattr = Linux + 349,
+ sched_getattr = Linux + 350,
+ renameat2 = Linux + 351,
+ seccomp = Linux + 352,
+ getrandom = Linux + 353,
+ memfd_create = Linux + 354,
+ bpf = Linux + 355,
+ execveat = Linux + 356,
+ userfaultfd = Linux + 357,
+ membarrier = Linux + 358,
+ mlock2 = Linux + 359,
+ copy_file_range = Linux + 360,
+ preadv2 = Linux + 361,
+ pwritev2 = Linux + 362,
+ pkey_mprotect = Linux + 363,
+ pkey_alloc = Linux + 364,
+ pkey_free = Linux + 365,
+ statx = Linux + 366,
+ rseq = Linux + 367,
+ io_pgetevents = Linux + 368,
+ semget = Linux + 393,
+ semctl = Linux + 394,
+ shmget = Linux + 395,
+ shmctl = Linux + 396,
+ shmat = Linux + 397,
+ shmdt = Linux + 398,
+ msgget = Linux + 399,
+ msgsnd = Linux + 400,
+ msgrcv = Linux + 401,
+ msgctl = Linux + 402,
+ clock_gettime64 = Linux + 403,
+ clock_settime64 = Linux + 404,
+ clock_adjtime64 = Linux + 405,
+ clock_getres_time64 = Linux + 406,
+ clock_nanosleep_time64 = Linux + 407,
+ timer_gettime64 = Linux + 408,
+ timer_settime64 = Linux + 409,
+ timerfd_gettime64 = Linux + 410,
+ timerfd_settime64 = Linux + 411,
+ utimensat_time64 = Linux + 412,
+ pselect6_time64 = Linux + 413,
+ ppoll_time64 = Linux + 414,
+ io_pgetevents_time64 = Linux + 416,
+ recvmmsg_time64 = Linux + 417,
+ mq_timedsend_time64 = Linux + 418,
+ mq_timedreceive_time64 = Linux + 419,
+ semtimedop_time64 = Linux + 420,
+ rt_sigtimedwait_time64 = Linux + 421,
+ futex_time64 = Linux + 422,
+ sched_rr_get_interval_time64 = Linux + 423,
+ pidfd_send_signal = Linux + 424,
+ io_uring_setup = Linux + 425,
+ io_uring_enter = Linux + 426,
+ io_uring_register = Linux + 427,
+ open_tree = Linux + 428,
+ move_mount = Linux + 429,
+ fsopen = Linux + 430,
+ fsconfig = Linux + 431,
+ fsmount = Linux + 432,
+ fspick = Linux + 433,
+ pidfd_open = Linux + 434,
+ clone3 = Linux + 435,
+ close_range = Linux + 436,
+ openat2 = Linux + 437,
+ pidfd_getfd = Linux + 438,
+ faccessat2 = Linux + 439,
+ process_madvise = Linux + 440,
+ epoll_pwait2 = Linux + 441,
+
+ _,
+};
+
+pub const O = struct {
+ pub const CREAT = 0o0400;
+ pub const EXCL = 0o02000;
+ pub const NOCTTY = 0o04000;
+ pub const TRUNC = 0o01000;
+ pub const APPEND = 0o0010;
+ pub const NONBLOCK = 0o0200;
+ pub const DSYNC = 0o0020;
+ pub const SYNC = 0o040020;
+ pub const RSYNC = 0o040020;
+ pub const DIRECTORY = 0o0200000;
+ pub const NOFOLLOW = 0o0400000;
+ pub const CLOEXEC = 0o02000000;
+
+ pub const ASYNC = 0o010000;
+ pub const DIRECT = 0o0100000;
+ pub const LARGEFILE = 0o020000;
+ pub const NOATIME = 0o01000000;
+ pub const PATH = 0o010000000;
+ pub const TMPFILE = 0o020200000;
+ pub const NDELAY = NONBLOCK;
+};
+
+pub const F = struct {
+ pub const DUPFD = 0;
+ pub const GETFD = 1;
+ pub const SETFD = 2;
+ pub const GETFL = 3;
+ pub const SETFL = 4;
+
+ pub const SETOWN = 24;
+ pub const GETOWN = 23;
+ pub const SETSIG = 10;
+ pub const GETSIG = 11;
+
+ pub const GETLK = 33;
+ pub const SETLK = 34;
+ pub const SETLKW = 35;
+
+ pub const RDLCK = 0;
+ pub const WRLCK = 1;
+ pub const UNLCK = 2;
+
+ pub const SETOWN_EX = 15;
+ pub const GETOWN_EX = 16;
+
+ pub const GETOWNER_UIDS = 17;
+};
+
+pub const LOCK = struct {
+ pub const SH = 1;
+ pub const EX = 2;
+ pub const UN = 8;
+ pub const NB = 4;
+};
+
+pub const MMAP2_UNIT = 4096;
+
+pub const MAP = struct {
+ pub const NORESERVE = 0x0400;
+ pub const GROWSDOWN = 0x1000;
+ pub const DENYWRITE = 0x2000;
+ pub const EXECUTABLE = 0x4000;
+ pub const LOCKED = 0x8000;
+ pub const @"32BIT" = 0x40;
+};
+
+pub const VDSO = struct {
+ pub const CGT_SYM = "__kernel_clock_gettime";
+ pub const CGT_VER = "LINUX_2.6.39";
+};
+
+pub const Flock = extern struct {
+ l_type: i16,
+ l_whence: i16,
+ __pad0: [4]u8,
+ l_start: off_t,
+ l_len: off_t,
+ l_pid: pid_t,
+ __unused: [4]u8,
+};
+
+pub const blksize_t = i32;
+pub const nlink_t = u32;
+pub const time_t = i32;
+pub const mode_t = u32;
+pub const off_t = i64;
+pub const ino_t = u64;
+pub const dev_t = u64;
+pub const blkcnt_t = i64;
+
+// The `stat` definition used by the Linux kernel.
+pub const Stat = extern struct {
+ dev: u32,
+ __pad0: [3]u32, // Reserved for st_dev expansion
+ ino: ino_t,
+ mode: mode_t,
+ nlink: nlink_t,
+ uid: uid_t,
+ gid: gid_t,
+ rdev: u32,
+ __pad1: [3]u32,
+ size: off_t,
+ atim: timespec,
+ mtim: timespec,
+ ctim: timespec,
+ blksize: blksize_t,
+ __pad3: u32,
+ blocks: blkcnt_t,
+ __pad4: [14]usize,
+
+ pub fn atime(self: @This()) timespec {
+ return self.atim;
+ }
+
+ pub fn mtime(self: @This()) timespec {
+ return self.mtim;
+ }
+
+ pub fn ctime(self: @This()) timespec {
+ return self.ctim;
+ }
+};
+
+pub const timeval = extern struct {
+ tv_sec: isize,
+ tv_usec: isize,
+};
+
+pub const timezone = extern struct {
+ tz_minuteswest: i32,
+ tz_dsttime: i32,
+};
+
+pub const Elf_Symndx = u32;
diff --git a/lib/std/os/linux/powerpc.zig b/lib/std/os/linux/powerpc.zig
index 760655b5fa5e..30001c48c68d 100644
--- a/lib/std/os/linux/powerpc.zig
+++ b/lib/std/os/linux/powerpc.zig
@@ -1,4 +1,16 @@
-usingnamespace @import("../bits/linux.zig");
+const std = @import("../../std.zig");
+const maxInt = std.math.maxInt;
+const linux = std.os.linux;
+const socklen_t = linux.socklen_t;
+const iovec = linux.iovec;
+const iovec_const = linux.iovec_const;
+const uid_t = linux.uid_t;
+const gid_t = linux.gid_t;
+const pid_t = linux.pid_t;
+const stack_t = linux.stack_t;
+const sigset_t = linux.sigset_t;
+const sockaddr = linux.sockaddr;
+const timespec = linux.timespec;
pub fn syscall0(number: SYS) usize {
return asm volatile (
@@ -125,3 +137,613 @@ pub fn restore_rt() callconv(.Naked) void {
: "memory", "cr0", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12"
);
}
+
+pub const SYS = enum(usize) {
+ restart_syscall = 0,
+ exit = 1,
+ fork = 2,
+ read = 3,
+ write = 4,
+ open = 5,
+ close = 6,
+ waitpid = 7,
+ creat = 8,
+ link = 9,
+ unlink = 10,
+ execve = 11,
+ chdir = 12,
+ time = 13,
+ mknod = 14,
+ chmod = 15,
+ lchown = 16,
+ @"break" = 17,
+ oldstat = 18,
+ lseek = 19,
+ getpid = 20,
+ mount = 21,
+ umount = 22,
+ setuid = 23,
+ getuid = 24,
+ stime = 25,
+ ptrace = 26,
+ alarm = 27,
+ oldfstat = 28,
+ pause = 29,
+ utime = 30,
+ stty = 31,
+ gtty = 32,
+ access = 33,
+ nice = 34,
+ ftime = 35,
+ sync = 36,
+ kill = 37,
+ rename = 38,
+ mkdir = 39,
+ rmdir = 40,
+ dup = 41,
+ pipe = 42,
+ times = 43,
+ prof = 44,
+ brk = 45,
+ setgid = 46,
+ getgid = 47,
+ signal = 48,
+ geteuid = 49,
+ getegid = 50,
+ acct = 51,
+ umount2 = 52,
+ lock = 53,
+ ioctl = 54,
+ fcntl = 55,
+ mpx = 56,
+ setpgid = 57,
+ ulimit = 58,
+ oldolduname = 59,
+ umask = 60,
+ chroot = 61,
+ ustat = 62,
+ dup2 = 63,
+ getppid = 64,
+ getpgrp = 65,
+ setsid = 66,
+ sigaction = 67,
+ sgetmask = 68,
+ ssetmask = 69,
+ setreuid = 70,
+ setregid = 71,
+ sigsuspend = 72,
+ sigpending = 73,
+ sethostname = 74,
+ setrlimit = 75,
+ getrlimit = 76,
+ getrusage = 77,
+ gettimeofday = 78,
+ settimeofday = 79,
+ getgroups = 80,
+ setgroups = 81,
+ select = 82,
+ symlink = 83,
+ oldlstat = 84,
+ readlink = 85,
+ uselib = 86,
+ swapon = 87,
+ reboot = 88,
+ readdir = 89,
+ mmap = 90,
+ munmap = 91,
+ truncate = 92,
+ ftruncate = 93,
+ fchmod = 94,
+ fchown = 95,
+ getpriority = 96,
+ setpriority = 97,
+ profil = 98,
+ statfs = 99,
+ fstatfs = 100,
+ ioperm = 101,
+ socketcall = 102,
+ syslog = 103,
+ setitimer = 104,
+ getitimer = 105,
+ stat = 106,
+ lstat = 107,
+ fstat = 108,
+ olduname = 109,
+ iopl = 110,
+ vhangup = 111,
+ idle = 112,
+ vm86 = 113,
+ wait4 = 114,
+ swapoff = 115,
+ sysinfo = 116,
+ ipc = 117,
+ fsync = 118,
+ sigreturn = 119,
+ clone = 120,
+ setdomainname = 121,
+ uname = 122,
+ modify_ldt = 123,
+ adjtimex = 124,
+ mprotect = 125,
+ sigprocmask = 126,
+ create_module = 127,
+ init_module = 128,
+ delete_module = 129,
+ get_kernel_syms = 130,
+ quotactl = 131,
+ getpgid = 132,
+ fchdir = 133,
+ bdflush = 134,
+ sysfs = 135,
+ personality = 136,
+ afs_syscall = 137,
+ setfsuid = 138,
+ setfsgid = 139,
+ _llseek = 140,
+ getdents = 141,
+ _newselect = 142,
+ flock = 143,
+ msync = 144,
+ readv = 145,
+ writev = 146,
+ getsid = 147,
+ fdatasync = 148,
+ _sysctl = 149,
+ mlock = 150,
+ munlock = 151,
+ mlockall = 152,
+ munlockall = 153,
+ sched_setparam = 154,
+ sched_getparam = 155,
+ sched_setscheduler = 156,
+ sched_getscheduler = 157,
+ sched_yield = 158,
+ sched_get_priority_max = 159,
+ sched_get_priority_min = 160,
+ sched_rr_get_interval = 161,
+ nanosleep = 162,
+ mremap = 163,
+ setresuid = 164,
+ getresuid = 165,
+ query_module = 166,
+ poll = 167,
+ nfsservctl = 168,
+ setresgid = 169,
+ getresgid = 170,
+ prctl = 171,
+ rt_sigreturn = 172,
+ rt_sigaction = 173,
+ rt_sigprocmask = 174,
+ rt_sigpending = 175,
+ rt_sigtimedwait = 176,
+ rt_sigqueueinfo = 177,
+ rt_sigsuspend = 178,
+ pread64 = 179,
+ pwrite64 = 180,
+ chown = 181,
+ getcwd = 182,
+ capget = 183,
+ capset = 184,
+ sigaltstack = 185,
+ sendfile = 186,
+ getpmsg = 187,
+ putpmsg = 188,
+ vfork = 189,
+ ugetrlimit = 190,
+ readahead = 191,
+ mmap2 = 192,
+ truncate64 = 193,
+ ftruncate64 = 194,
+ stat64 = 195,
+ lstat64 = 196,
+ fstat64 = 197,
+ pciconfig_read = 198,
+ pciconfig_write = 199,
+ pciconfig_iobase = 200,
+ multiplexer = 201,
+ getdents64 = 202,
+ pivot_root = 203,
+ fcntl64 = 204,
+ madvise = 205,
+ mincore = 206,
+ gettid = 207,
+ tkill = 208,
+ setxattr = 209,
+ lsetxattr = 210,
+ fsetxattr = 211,
+ getxattr = 212,
+ lgetxattr = 213,
+ fgetxattr = 214,
+ listxattr = 215,
+ llistxattr = 216,
+ flistxattr = 217,
+ removexattr = 218,
+ lremovexattr = 219,
+ fremovexattr = 220,
+ futex = 221,
+ sched_setaffinity = 222,
+ sched_getaffinity = 223,
+ tuxcall = 225,
+ sendfile64 = 226,
+ io_setup = 227,
+ io_destroy = 228,
+ io_getevents = 229,
+ io_submit = 230,
+ io_cancel = 231,
+ set_tid_address = 232,
+ fadvise64 = 233,
+ exit_group = 234,
+ lookup_dcookie = 235,
+ epoll_create = 236,
+ epoll_ctl = 237,
+ epoll_wait = 238,
+ remap_file_pages = 239,
+ timer_create = 240,
+ timer_settime = 241,
+ timer_gettime = 242,
+ timer_getoverrun = 243,
+ timer_delete = 244,
+ clock_settime = 245,
+ clock_gettime = 246,
+ clock_getres = 247,
+ clock_nanosleep = 248,
+ swapcontext = 249,
+ tgkill = 250,
+ utimes = 251,
+ statfs64 = 252,
+ fstatfs64 = 253,
+ fadvise64_64 = 254,
+ rtas = 255,
+ sys_debug_setcontext = 256,
+ migrate_pages = 258,
+ mbind = 259,
+ get_mempolicy = 260,
+ set_mempolicy = 261,
+ mq_open = 262,
+ mq_unlink = 263,
+ mq_timedsend = 264,
+ mq_timedreceive = 265,
+ mq_notify = 266,
+ mq_getsetattr = 267,
+ kexec_load = 268,
+ add_key = 269,
+ request_key = 270,
+ keyctl = 271,
+ waitid = 272,
+ ioprio_set = 273,
+ ioprio_get = 274,
+ inotify_init = 275,
+ inotify_add_watch = 276,
+ inotify_rm_watch = 277,
+ spu_run = 278,
+ spu_create = 279,
+ pselect6 = 280,
+ ppoll = 281,
+ unshare = 282,
+ splice = 283,
+ tee = 284,
+ vmsplice = 285,
+ openat = 286,
+ mkdirat = 287,
+ mknodat = 288,
+ fchownat = 289,
+ futimesat = 290,
+ fstatat64 = 291,
+ unlinkat = 292,
+ renameat = 293,
+ linkat = 294,
+ symlinkat = 295,
+ readlinkat = 296,
+ fchmodat = 297,
+ faccessat = 298,
+ get_robust_list = 299,
+ set_robust_list = 300,
+ move_pages = 301,
+ getcpu = 302,
+ epoll_pwait = 303,
+ utimensat = 304,
+ signalfd = 305,
+ timerfd_create = 306,
+ eventfd = 307,
+ sync_file_range = 308,
+ fallocate = 309,
+ subpage_prot = 310,
+ timerfd_settime = 311,
+ timerfd_gettime = 312,
+ signalfd4 = 313,
+ eventfd2 = 314,
+ epoll_create1 = 315,
+ dup3 = 316,
+ pipe2 = 317,
+ inotify_init1 = 318,
+ perf_event_open = 319,
+ preadv = 320,
+ pwritev = 321,
+ rt_tgsigqueueinfo = 322,
+ fanotify_init = 323,
+ fanotify_mark = 324,
+ prlimit64 = 325,
+ socket = 326,
+ bind = 327,
+ connect = 328,
+ listen = 329,
+ accept = 330,
+ getsockname = 331,
+ getpeername = 332,
+ socketpair = 333,
+ send = 334,
+ sendto = 335,
+ recv = 336,
+ recvfrom = 337,
+ shutdown = 338,
+ setsockopt = 339,
+ getsockopt = 340,
+ sendmsg = 341,
+ recvmsg = 342,
+ recvmmsg = 343,
+ accept4 = 344,
+ name_to_handle_at = 345,
+ open_by_handle_at = 346,
+ clock_adjtime = 347,
+ syncfs = 348,
+ sendmmsg = 349,
+ setns = 350,
+ process_vm_readv = 351,
+ process_vm_writev = 352,
+ finit_module = 353,
+ kcmp = 354,
+ sched_setattr = 355,
+ sched_getattr = 356,
+ renameat2 = 357,
+ seccomp = 358,
+ getrandom = 359,
+ memfd_create = 360,
+ bpf = 361,
+ execveat = 362,
+ switch_endian = 363,
+ userfaultfd = 364,
+ membarrier = 365,
+ mlock2 = 378,
+ copy_file_range = 379,
+ preadv2 = 380,
+ pwritev2 = 381,
+ kexec_file_load = 382,
+ statx = 383,
+ pkey_alloc = 384,
+ pkey_free = 385,
+ pkey_mprotect = 386,
+ rseq = 387,
+ io_pgetevents = 388,
+ semget = 393,
+ semctl = 394,
+ shmget = 395,
+ shmctl = 396,
+ shmat = 397,
+ shmdt = 398,
+ msgget = 399,
+ msgsnd = 400,
+ msgrcv = 401,
+ msgctl = 402,
+ clock_gettime64 = 403,
+ clock_settime64 = 404,
+ clock_adjtime64 = 405,
+ clock_getres_time64 = 406,
+ clock_nanosleep_time64 = 407,
+ timer_gettime64 = 408,
+ timer_settime64 = 409,
+ timerfd_gettime64 = 410,
+ timerfd_settime64 = 411,
+ utimensat_time64 = 412,
+ pselect6_time64 = 413,
+ ppoll_time64 = 414,
+ io_pgetevents_time64 = 416,
+ recvmmsg_time64 = 417,
+ mq_timedsend_time64 = 418,
+ mq_timedreceive_time64 = 419,
+ semtimedop_time64 = 420,
+ rt_sigtimedwait_time64 = 421,
+ futex_time64 = 422,
+ sched_rr_get_interval_time64 = 423,
+ pidfd_send_signal = 424,
+ io_uring_setup = 425,
+ io_uring_enter = 426,
+ io_uring_register = 427,
+ open_tree = 428,
+ move_mount = 429,
+ fsopen = 430,
+ fsconfig = 431,
+ fsmount = 432,
+ fspick = 433,
+ pidfd_open = 434,
+ clone3 = 435,
+ close_range = 436,
+ openat2 = 437,
+ pidfd_getfd = 438,
+ faccessat2 = 439,
+ process_madvise = 440,
+};
+
+pub const O = struct {
+ pub const CREAT = 0o100;
+ pub const EXCL = 0o200;
+ pub const NOCTTY = 0o400;
+ pub const TRUNC = 0o1000;
+ pub const APPEND = 0o2000;
+ pub const NONBLOCK = 0o4000;
+ pub const DSYNC = 0o10000;
+ pub const SYNC = 0o4010000;
+ pub const RSYNC = 0o4010000;
+ pub const DIRECTORY = 0o40000;
+ pub const NOFOLLOW = 0o100000;
+ pub const CLOEXEC = 0o2000000;
+
+ pub const ASYNC = 0o20000;
+ pub const DIRECT = 0o400000;
+ pub const LARGEFILE = 0o200000;
+ pub const NOATIME = 0o1000000;
+ pub const PATH = 0o10000000;
+ pub const TMPFILE = 0o20040000;
+ pub const NDELAY = NONBLOCK;
+};
+
+pub const F = struct {
+ pub const DUPFD = 0;
+ pub const GETFD = 1;
+ pub const SETFD = 2;
+ pub const GETFL = 3;
+ pub const SETFL = 4;
+
+ pub const SETOWN = 8;
+ pub const GETOWN = 9;
+ pub const SETSIG = 10;
+ pub const GETSIG = 11;
+
+ pub const GETLK = 12;
+ pub const SETLK = 13;
+ pub const SETLKW = 14;
+
+ pub const SETOWN_EX = 15;
+ pub const GETOWN_EX = 16;
+
+ pub const GETOWNER_UIDS = 17;
+
+ pub const RDLCK = 0;
+ pub const WRLCK = 1;
+ pub const UNLCK = 2;
+};
+
+pub const LOCK = struct {
+ pub const SH = 1;
+ pub const EX = 2;
+ pub const UN = 8;
+ pub const NB = 4;
+};
+
+pub const MAP = struct {
+ /// stack-like segment
+ pub const GROWSDOWN = 0x0100;
+ /// ETXTBSY
+ pub const DENYWRITE = 0x0800;
+ /// mark it as an executable
+ pub const EXECUTABLE = 0x1000;
+ /// pages are locked
+ pub const LOCKED = 0x0080;
+ /// don't check for reservations
+ pub const NORESERVE = 0x0040;
+};
+
+pub const VDSO = struct {
+ pub const CGT_SYM = "__kernel_clock_gettime";
+ pub const CGT_VER = "LINUX_2.6.15";
+};
+
+pub const Flock = extern struct {
+ l_type: i16,
+ l_whence: i16,
+ l_start: off_t,
+ l_len: off_t,
+ l_pid: pid_t,
+};
+
+pub const msghdr = extern struct {
+ msg_name: ?*sockaddr,
+ msg_namelen: socklen_t,
+ msg_iov: [*]iovec,
+ msg_iovlen: usize,
+ msg_control: ?*c_void,
+ msg_controllen: socklen_t,
+ msg_flags: i32,
+};
+
+pub const msghdr_const = extern struct {
+ msg_name: ?*const sockaddr,
+ msg_namelen: socklen_t,
+ msg_iov: [*]iovec_const,
+ msg_iovlen: usize,
+ msg_control: ?*c_void,
+ msg_controllen: socklen_t,
+ msg_flags: i32,
+};
+
+pub const blksize_t = i32;
+pub const nlink_t = u32;
+pub const time_t = isize;
+pub const mode_t = u32;
+pub const off_t = i64;
+pub const ino_t = u64;
+pub const dev_t = u64;
+pub const blkcnt_t = i64;
+
+// The `stat` definition used by the Linux kernel.
+pub const Stat = extern struct {
+ dev: dev_t,
+ ino: ino_t,
+ mode: mode_t,
+ nlink: nlink_t,
+ uid: uid_t,
+ gid: gid_t,
+ rdev: dev_t,
+ __rdev_padding: i16,
+ size: off_t,
+ blksize: blksize_t,
+ blocks: blkcnt_t,
+ atim: timespec,
+ mtim: timespec,
+ ctim: timespec,
+ __unused: [2]u32,
+
+ pub fn atime(self: @This()) timespec {
+ return self.atim;
+ }
+
+ pub fn mtime(self: @This()) timespec {
+ return self.mtim;
+ }
+
+ pub fn ctime(self: @This()) timespec {
+ return self.ctim;
+ }
+};
+
+pub const timeval = extern struct {
+ tv_sec: time_t,
+ tv_usec: isize,
+};
+
+pub const timezone = extern struct {
+ tz_minuteswest: i32,
+ tz_dsttime: i32,
+};
+
+pub const greg_t = u32;
+pub const gregset_t = [48]greg_t;
+pub const fpregset_t = [33]f64;
+
+pub const vrregset = extern struct {
+ vrregs: [32][4]u32,
+ vrsave: u32,
+ _pad: [2]u32,
+ vscr: u32,
+};
+pub const vrregset_t = vrregset;
+
+pub const mcontext_t = extern struct {
+ gp_regs: gregset_t,
+ fp_regs: fpregset_t,
+ v_regs: vrregset_t align(16),
+};
+
+pub const ucontext_t = extern struct {
+ flags: u32,
+ link: *ucontext_t,
+ stack: stack_t,
+ pad: [7]i32,
+ regs: *mcontext_t,
+ sigmask: sigset_t,
+ pad2: [3]i32,
+ mcontext: mcontext_t,
+};
+
+pub const Elf_Symndx = u32;
+
+pub const MMAP2_UNIT = 4096;
diff --git a/lib/std/os/linux/powerpc64.zig b/lib/std/os/linux/powerpc64.zig
index 760655b5fa5e..2903df15ef70 100644
--- a/lib/std/os/linux/powerpc64.zig
+++ b/lib/std/os/linux/powerpc64.zig
@@ -1,4 +1,16 @@
-usingnamespace @import("../bits/linux.zig");
+const std = @import("../../std.zig");
+const maxInt = std.math.maxInt;
+const linux = std.os.linux;
+const socklen_t = linux.socklen_t;
+const iovec = linux.iovec;
+const iovec_const = linux.iovec_const;
+const uid_t = linux.uid_t;
+const gid_t = linux.gid_t;
+const pid_t = linux.pid_t;
+const stack_t = linux.stack_t;
+const sigset_t = linux.sigset_t;
+const sockaddr = linux.sockaddr;
+const timespec = linux.timespec;
pub fn syscall0(number: SYS) usize {
return asm volatile (
@@ -125,3 +137,596 @@ pub fn restore_rt() callconv(.Naked) void {
: "memory", "cr0", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12"
);
}
+
+pub const SYS = enum(usize) {
+ restart_syscall = 0,
+ exit = 1,
+ fork = 2,
+ read = 3,
+ write = 4,
+ open = 5,
+ close = 6,
+ waitpid = 7,
+ creat = 8,
+ link = 9,
+ unlink = 10,
+ execve = 11,
+ chdir = 12,
+ time = 13,
+ mknod = 14,
+ chmod = 15,
+ lchown = 16,
+ @"break" = 17,
+ oldstat = 18,
+ lseek = 19,
+ getpid = 20,
+ mount = 21,
+ umount = 22,
+ setuid = 23,
+ getuid = 24,
+ stime = 25,
+ ptrace = 26,
+ alarm = 27,
+ oldfstat = 28,
+ pause = 29,
+ utime = 30,
+ stty = 31,
+ gtty = 32,
+ access = 33,
+ nice = 34,
+ ftime = 35,
+ sync = 36,
+ kill = 37,
+ rename = 38,
+ mkdir = 39,
+ rmdir = 40,
+ dup = 41,
+ pipe = 42,
+ times = 43,
+ prof = 44,
+ brk = 45,
+ setgid = 46,
+ getgid = 47,
+ signal = 48,
+ geteuid = 49,
+ getegid = 50,
+ acct = 51,
+ umount2 = 52,
+ lock = 53,
+ ioctl = 54,
+ fcntl = 55,
+ mpx = 56,
+ setpgid = 57,
+ ulimit = 58,
+ oldolduname = 59,
+ umask = 60,
+ chroot = 61,
+ ustat = 62,
+ dup2 = 63,
+ getppid = 64,
+ getpgrp = 65,
+ setsid = 66,
+ sigaction = 67,
+ sgetmask = 68,
+ ssetmask = 69,
+ setreuid = 70,
+ setregid = 71,
+ sigsuspend = 72,
+ sigpending = 73,
+ sethostname = 74,
+ setrlimit = 75,
+ getrlimit = 76,
+ getrusage = 77,
+ gettimeofday = 78,
+ settimeofday = 79,
+ getgroups = 80,
+ setgroups = 81,
+ select = 82,
+ symlink = 83,
+ oldlstat = 84,
+ readlink = 85,
+ uselib = 86,
+ swapon = 87,
+ reboot = 88,
+ readdir = 89,
+ mmap = 90,
+ munmap = 91,
+ truncate = 92,
+ ftruncate = 93,
+ fchmod = 94,
+ fchown = 95,
+ getpriority = 96,
+ setpriority = 97,
+ profil = 98,
+ statfs = 99,
+ fstatfs = 100,
+ ioperm = 101,
+ socketcall = 102,
+ syslog = 103,
+ setitimer = 104,
+ getitimer = 105,
+ stat = 106,
+ lstat = 107,
+ fstat = 108,
+ olduname = 109,
+ iopl = 110,
+ vhangup = 111,
+ idle = 112,
+ vm86 = 113,
+ wait4 = 114,
+ swapoff = 115,
+ sysinfo = 116,
+ ipc = 117,
+ fsync = 118,
+ sigreturn = 119,
+ clone = 120,
+ setdomainname = 121,
+ uname = 122,
+ modify_ldt = 123,
+ adjtimex = 124,
+ mprotect = 125,
+ sigprocmask = 126,
+ create_module = 127,
+ init_module = 128,
+ delete_module = 129,
+ get_kernel_syms = 130,
+ quotactl = 131,
+ getpgid = 132,
+ fchdir = 133,
+ bdflush = 134,
+ sysfs = 135,
+ personality = 136,
+ afs_syscall = 137,
+ setfsuid = 138,
+ setfsgid = 139,
+ _llseek = 140,
+ getdents = 141,
+ _newselect = 142,
+ flock = 143,
+ msync = 144,
+ readv = 145,
+ writev = 146,
+ getsid = 147,
+ fdatasync = 148,
+ _sysctl = 149,
+ mlock = 150,
+ munlock = 151,
+ mlockall = 152,
+ munlockall = 153,
+ sched_setparam = 154,
+ sched_getparam = 155,
+ sched_setscheduler = 156,
+ sched_getscheduler = 157,
+ sched_yield = 158,
+ sched_get_priority_max = 159,
+ sched_get_priority_min = 160,
+ sched_rr_get_interval = 161,
+ nanosleep = 162,
+ mremap = 163,
+ setresuid = 164,
+ getresuid = 165,
+ query_module = 166,
+ poll = 167,
+ nfsservctl = 168,
+ setresgid = 169,
+ getresgid = 170,
+ prctl = 171,
+ rt_sigreturn = 172,
+ rt_sigaction = 173,
+ rt_sigprocmask = 174,
+ rt_sigpending = 175,
+ rt_sigtimedwait = 176,
+ rt_sigqueueinfo = 177,
+ rt_sigsuspend = 178,
+ pread64 = 179,
+ pwrite64 = 180,
+ chown = 181,
+ getcwd = 182,
+ capget = 183,
+ capset = 184,
+ sigaltstack = 185,
+ sendfile = 186,
+ getpmsg = 187,
+ putpmsg = 188,
+ vfork = 189,
+ ugetrlimit = 190,
+ readahead = 191,
+ pciconfig_read = 198,
+ pciconfig_write = 199,
+ pciconfig_iobase = 200,
+ multiplexer = 201,
+ getdents64 = 202,
+ pivot_root = 203,
+ madvise = 205,
+ mincore = 206,
+ gettid = 207,
+ tkill = 208,
+ setxattr = 209,
+ lsetxattr = 210,
+ fsetxattr = 211,
+ getxattr = 212,
+ lgetxattr = 213,
+ fgetxattr = 214,
+ listxattr = 215,
+ llistxattr = 216,
+ flistxattr = 217,
+ removexattr = 218,
+ lremovexattr = 219,
+ fremovexattr = 220,
+ futex = 221,
+ sched_setaffinity = 222,
+ sched_getaffinity = 223,
+ tuxcall = 225,
+ io_setup = 227,
+ io_destroy = 228,
+ io_getevents = 229,
+ io_submit = 230,
+ io_cancel = 231,
+ set_tid_address = 232,
+ fadvise64 = 233,
+ exit_group = 234,
+ lookup_dcookie = 235,
+ epoll_create = 236,
+ epoll_ctl = 237,
+ epoll_wait = 238,
+ remap_file_pages = 239,
+ timer_create = 240,
+ timer_settime = 241,
+ timer_gettime = 242,
+ timer_getoverrun = 243,
+ timer_delete = 244,
+ clock_settime = 245,
+ clock_gettime = 246,
+ clock_getres = 247,
+ clock_nanosleep = 248,
+ swapcontext = 249,
+ tgkill = 250,
+ utimes = 251,
+ statfs64 = 252,
+ fstatfs64 = 253,
+ rtas = 255,
+ sys_debug_setcontext = 256,
+ migrate_pages = 258,
+ mbind = 259,
+ get_mempolicy = 260,
+ set_mempolicy = 261,
+ mq_open = 262,
+ mq_unlink = 263,
+ mq_timedsend = 264,
+ mq_timedreceive = 265,
+ mq_notify = 266,
+ mq_getsetattr = 267,
+ kexec_load = 268,
+ add_key = 269,
+ request_key = 270,
+ keyctl = 271,
+ waitid = 272,
+ ioprio_set = 273,
+ ioprio_get = 274,
+ inotify_init = 275,
+ inotify_add_watch = 276,
+ inotify_rm_watch = 277,
+ spu_run = 278,
+ spu_create = 279,
+ pselect6 = 280,
+ ppoll = 281,
+ unshare = 282,
+ splice = 283,
+ tee = 284,
+ vmsplice = 285,
+ openat = 286,
+ mkdirat = 287,
+ mknodat = 288,
+ fchownat = 289,
+ futimesat = 290,
+ fstatat = 291,
+ unlinkat = 292,
+ renameat = 293,
+ linkat = 294,
+ symlinkat = 295,
+ readlinkat = 296,
+ fchmodat = 297,
+ faccessat = 298,
+ get_robust_list = 299,
+ set_robust_list = 300,
+ move_pages = 301,
+ getcpu = 302,
+ epoll_pwait = 303,
+ utimensat = 304,
+ signalfd = 305,
+ timerfd_create = 306,
+ eventfd = 307,
+ sync_file_range = 308,
+ fallocate = 309,
+ subpage_prot = 310,
+ timerfd_settime = 311,
+ timerfd_gettime = 312,
+ signalfd4 = 313,
+ eventfd2 = 314,
+ epoll_create1 = 315,
+ dup3 = 316,
+ pipe2 = 317,
+ inotify_init1 = 318,
+ perf_event_open = 319,
+ preadv = 320,
+ pwritev = 321,
+ rt_tgsigqueueinfo = 322,
+ fanotify_init = 323,
+ fanotify_mark = 324,
+ prlimit64 = 325,
+ socket = 326,
+ bind = 327,
+ connect = 328,
+ listen = 329,
+ accept = 330,
+ getsockname = 331,
+ getpeername = 332,
+ socketpair = 333,
+ send = 334,
+ sendto = 335,
+ recv = 336,
+ recvfrom = 337,
+ shutdown = 338,
+ setsockopt = 339,
+ getsockopt = 340,
+ sendmsg = 341,
+ recvmsg = 342,
+ recvmmsg = 343,
+ accept4 = 344,
+ name_to_handle_at = 345,
+ open_by_handle_at = 346,
+ clock_adjtime = 347,
+ syncfs = 348,
+ sendmmsg = 349,
+ setns = 350,
+ process_vm_readv = 351,
+ process_vm_writev = 352,
+ finit_module = 353,
+ kcmp = 354,
+ sched_setattr = 355,
+ sched_getattr = 356,
+ renameat2 = 357,
+ seccomp = 358,
+ getrandom = 359,
+ memfd_create = 360,
+ bpf = 361,
+ execveat = 362,
+ switch_endian = 363,
+ userfaultfd = 364,
+ membarrier = 365,
+ mlock2 = 378,
+ copy_file_range = 379,
+ preadv2 = 380,
+ pwritev2 = 381,
+ kexec_file_load = 382,
+ statx = 383,
+ pkey_alloc = 384,
+ pkey_free = 385,
+ pkey_mprotect = 386,
+ rseq = 387,
+ io_pgetevents = 388,
+ semtimedop = 392,
+ semget = 393,
+ semctl = 394,
+ shmget = 395,
+ shmctl = 396,
+ shmat = 397,
+ shmdt = 398,
+ msgget = 399,
+ msgsnd = 400,
+ msgrcv = 401,
+ msgctl = 402,
+ pidfd_send_signal = 424,
+ io_uring_setup = 425,
+ io_uring_enter = 426,
+ io_uring_register = 427,
+ open_tree = 428,
+ move_mount = 429,
+ fsopen = 430,
+ fsconfig = 431,
+ fsmount = 432,
+ fspick = 433,
+ pidfd_open = 434,
+ clone3 = 435,
+ close_range = 436,
+ openat2 = 437,
+ pidfd_getfd = 438,
+ faccessat2 = 439,
+ process_madvise = 440,
+ epoll_pwait2 = 441,
+
+ _,
+};
+
+pub const O = struct {
+ pub const CREAT = 0o100;
+ pub const EXCL = 0o200;
+ pub const NOCTTY = 0o400;
+ pub const TRUNC = 0o1000;
+ pub const APPEND = 0o2000;
+ pub const NONBLOCK = 0o4000;
+ pub const DSYNC = 0o10000;
+ pub const SYNC = 0o4010000;
+ pub const RSYNC = 0o4010000;
+ pub const DIRECTORY = 0o40000;
+ pub const NOFOLLOW = 0o100000;
+ pub const CLOEXEC = 0o2000000;
+
+ pub const ASYNC = 0o20000;
+ pub const DIRECT = 0o400000;
+ pub const LARGEFILE = 0o200000;
+ pub const NOATIME = 0o1000000;
+ pub const PATH = 0o10000000;
+ pub const TMPFILE = 0o20200000;
+ pub const NDELAY = NONBLOCK;
+};
+
+pub const F = struct {
+ pub const DUPFD = 0;
+ pub const GETFD = 1;
+ pub const SETFD = 2;
+ pub const GETFL = 3;
+ pub const SETFL = 4;
+
+ pub const SETOWN = 8;
+ pub const GETOWN = 9;
+ pub const SETSIG = 10;
+ pub const GETSIG = 11;
+
+ pub const GETLK = 5;
+ pub const SETLK = 6;
+ pub const SETLKW = 7;
+
+ pub const RDLCK = 0;
+ pub const WRLCK = 1;
+ pub const UNLCK = 2;
+
+ pub const SETOWN_EX = 15;
+ pub const GETOWN_EX = 16;
+
+ pub const GETOWNER_UIDS = 17;
+};
+
+pub const LOCK = struct {
+ pub const SH = 1;
+ pub const EX = 2;
+ pub const UN = 8;
+ pub const NB = 4;
+};
+
+pub const MAP = struct {
+ /// stack-like segment
+ pub const GROWSDOWN = 0x0100;
+ /// ETXTBSY
+ pub const DENYWRITE = 0x0800;
+ /// mark it as an executable
+ pub const EXECUTABLE = 0x1000;
+ /// pages are locked
+ pub const LOCKED = 0x0080;
+ /// don't check for reservations
+ pub const NORESERVE = 0x0040;
+};
+
+pub const VDSO = struct {
+ pub const CGT_SYM = "__kernel_clock_gettime";
+ pub const CGT_VER = "LINUX_2.6.15";
+};
+
+pub const Flock = extern struct {
+ l_type: i16,
+ l_whence: i16,
+ l_start: off_t,
+ l_len: off_t,
+ l_pid: pid_t,
+ __unused: [4]u8,
+};
+
+pub const msghdr = extern struct {
+ msg_name: ?*sockaddr,
+ msg_namelen: socklen_t,
+ msg_iov: [*]iovec,
+ msg_iovlen: usize,
+ msg_control: ?*c_void,
+ msg_controllen: usize,
+ msg_flags: i32,
+};
+
+pub const msghdr_const = extern struct {
+ msg_name: ?*const sockaddr,
+ msg_namelen: socklen_t,
+ msg_iov: [*]iovec_const,
+ msg_iovlen: usize,
+ msg_control: ?*c_void,
+ msg_controllen: usize,
+ msg_flags: i32,
+};
+
+pub const blksize_t = i64;
+pub const nlink_t = u64;
+pub const time_t = i64;
+pub const mode_t = u32;
+pub const off_t = i64;
+pub const ino_t = u64;
+pub const dev_t = u64;
+pub const blkcnt_t = i64;
+
+// The `stat` definition used by the Linux kernel.
+pub const Stat = extern struct {
+ dev: dev_t,
+ ino: ino_t,
+ nlink: nlink_t,
+ mode: mode_t,
+ uid: uid_t,
+ gid: gid_t,
+ rdev: dev_t,
+ size: off_t,
+ blksize: blksize_t,
+ blocks: blkcnt_t,
+ atim: timespec,
+ mtim: timespec,
+ ctim: timespec,
+ __unused: [3]u64,
+
+ pub fn atime(self: @This()) timespec {
+ return self.atim;
+ }
+
+ pub fn mtime(self: @This()) timespec {
+ return self.mtim;
+ }
+
+ pub fn ctime(self: @This()) timespec {
+ return self.ctim;
+ }
+};
+
+pub const timeval = extern struct {
+ tv_sec: isize,
+ tv_usec: isize,
+};
+
+pub const timezone = extern struct {
+ tz_minuteswest: i32,
+ tz_dsttime: i32,
+};
+
+pub const greg_t = u64;
+pub const gregset_t = [48]greg_t;
+pub const fpregset_t = [33]f64;
+
+/// The position of the vscr register depends on endianness.
+/// On C, macros are used to change vscr_word's offset to
+/// account for this. Here we'll just define vscr_word_le
+/// and vscr_word_be. Code must take care to use the correct one.
+pub const vrregset = extern struct {
+ vrregs: [32][4]u32 align(16),
+ vscr_word_le: u32,
+ _pad1: [2]u32,
+ vscr_word_be: u32,
+ vrsave: u32,
+ _pad2: [3]u32,
+};
+pub const vrregset_t = vrregset;
+
+pub const mcontext_t = extern struct {
+ __unused: [4]u64,
+ signal: i32,
+ _pad0: i32,
+ handler: u64,
+ oldmask: u64,
+ regs: ?*c_void,
+ gp_regs: gregset_t,
+ fp_regs: fpregset_t,
+ v_regs: *vrregset_t,
+ vmx_reserve: [34 + 34 + 32 + 1]i64,
+};
+
+pub const ucontext_t = extern struct {
+ flags: u32,
+ link: *ucontext_t,
+ stack: stack_t,
+ sigmask: sigset_t,
+ mcontext: mcontext_t,
+};
+
+pub const Elf_Symndx = u32;
diff --git a/lib/std/os/linux/riscv64.zig b/lib/std/os/linux/riscv64.zig
index 1448bfe3d39b..be78a1bf4e3d 100644
--- a/lib/std/os/linux/riscv64.zig
+++ b/lib/std/os/linux/riscv64.zig
@@ -1,4 +1,8 @@
-usingnamespace @import("../bits/linux.zig");
+const std = @import("../../std.zig");
+const uid_t = std.os.linux.uid_t;
+const gid_t = std.os.linux.gid_t;
+const pid_t = std.os.linux.pid_t;
+const timespec = std.os.linux.timespec;
pub fn syscall0(number: SYS) usize {
return asm volatile ("ecall"
@@ -96,3 +100,423 @@ pub fn restore_rt() callconv(.Naked) void {
: "memory"
);
}
+
+pub const SYS = enum(usize) {
+ pub const arch_specific_syscall = 244;
+
+ io_setup = 0,
+ io_destroy = 1,
+ io_submit = 2,
+ io_cancel = 3,
+ io_getevents = 4,
+ setxattr = 5,
+ lsetxattr = 6,
+ fsetxattr = 7,
+ getxattr = 8,
+ lgetxattr = 9,
+ fgetxattr = 10,
+ listxattr = 11,
+ llistxattr = 12,
+ flistxattr = 13,
+ removexattr = 14,
+ lremovexattr = 15,
+ fremovexattr = 16,
+ getcwd = 17,
+ lookup_dcookie = 18,
+ eventfd2 = 19,
+ epoll_create1 = 20,
+ epoll_ctl = 21,
+ epoll_pwait = 22,
+ dup = 23,
+ dup3 = 24,
+ fcntl = 25,
+ inotify_init1 = 26,
+ inotify_add_watch = 27,
+ inotify_rm_watch = 28,
+ ioctl = 29,
+ ioprio_set = 30,
+ ioprio_get = 31,
+ flock = 32,
+ mknodat = 33,
+ mkdirat = 34,
+ unlinkat = 35,
+ symlinkat = 36,
+ linkat = 37,
+ umount2 = 39,
+ mount = 40,
+ pivot_root = 41,
+ nfsservctl = 42,
+ statfs = 43,
+ fstatfs = 44,
+ truncate = 45,
+ ftruncate = 46,
+ fallocate = 47,
+ faccessat = 48,
+ chdir = 49,
+ fchdir = 50,
+ chroot = 51,
+ fchmod = 52,
+ fchmodat = 53,
+ fchownat = 54,
+ fchown = 55,
+ openat = 56,
+ close = 57,
+ vhangup = 58,
+ pipe2 = 59,
+ quotactl = 60,
+ getdents64 = 61,
+ lseek = 62,
+ read = 63,
+ write = 64,
+ readv = 65,
+ writev = 66,
+ pread64 = 67,
+ pwrite64 = 68,
+ preadv = 69,
+ pwritev = 70,
+ sendfile = 71,
+ pselect6 = 72,
+ ppoll = 73,
+ signalfd4 = 74,
+ vmsplice = 75,
+ splice = 76,
+ tee = 77,
+ readlinkat = 78,
+ fstatat = 79,
+ fstat = 80,
+ sync = 81,
+ fsync = 82,
+ fdatasync = 83,
+ sync_file_range = 84,
+ timerfd_create = 85,
+ timerfd_settime = 86,
+ timerfd_gettime = 87,
+ utimensat = 88,
+ acct = 89,
+ capget = 90,
+ capset = 91,
+ personality = 92,
+ exit = 93,
+ exit_group = 94,
+ waitid = 95,
+ set_tid_address = 96,
+ unshare = 97,
+ futex = 98,
+ set_robust_list = 99,
+ get_robust_list = 100,
+ nanosleep = 101,
+ getitimer = 102,
+ setitimer = 103,
+ kexec_load = 104,
+ init_module = 105,
+ delete_module = 106,
+ timer_create = 107,
+ timer_gettime = 108,
+ timer_getoverrun = 109,
+ timer_settime = 110,
+ timer_delete = 111,
+ clock_settime = 112,
+ clock_gettime = 113,
+ clock_getres = 114,
+ clock_nanosleep = 115,
+ syslog = 116,
+ ptrace = 117,
+ sched_setparam = 118,
+ sched_setscheduler = 119,
+ sched_getscheduler = 120,
+ sched_getparam = 121,
+ sched_setaffinity = 122,
+ sched_getaffinity = 123,
+ sched_yield = 124,
+ sched_get_priority_max = 125,
+ sched_get_priority_min = 126,
+ sched_rr_get_interval = 127,
+ restart_syscall = 128,
+ kill = 129,
+ tkill = 130,
+ tgkill = 131,
+ sigaltstack = 132,
+ rt_sigsuspend = 133,
+ rt_sigaction = 134,
+ rt_sigprocmask = 135,
+ rt_sigpending = 136,
+ rt_sigtimedwait = 137,
+ rt_sigqueueinfo = 138,
+ rt_sigreturn = 139,
+ setpriority = 140,
+ getpriority = 141,
+ reboot = 142,
+ setregid = 143,
+ setgid = 144,
+ setreuid = 145,
+ setuid = 146,
+ setresuid = 147,
+ getresuid = 148,
+ setresgid = 149,
+ getresgid = 150,
+ setfsuid = 151,
+ setfsgid = 152,
+ times = 153,
+ setpgid = 154,
+ getpgid = 155,
+ getsid = 156,
+ setsid = 157,
+ getgroups = 158,
+ setgroups = 159,
+ uname = 160,
+ sethostname = 161,
+ setdomainname = 162,
+ getrlimit = 163,
+ setrlimit = 164,
+ getrusage = 165,
+ umask = 166,
+ prctl = 167,
+ getcpu = 168,
+ gettimeofday = 169,
+ settimeofday = 170,
+ adjtimex = 171,
+ getpid = 172,
+ getppid = 173,
+ getuid = 174,
+ geteuid = 175,
+ getgid = 176,
+ getegid = 177,
+ gettid = 178,
+ sysinfo = 179,
+ mq_open = 180,
+ mq_unlink = 181,
+ mq_timedsend = 182,
+ mq_timedreceive = 183,
+ mq_notify = 184,
+ mq_getsetattr = 185,
+ msgget = 186,
+ msgctl = 187,
+ msgrcv = 188,
+ msgsnd = 189,
+ semget = 190,
+ semctl = 191,
+ semtimedop = 192,
+ semop = 193,
+ shmget = 194,
+ shmctl = 195,
+ shmat = 196,
+ shmdt = 197,
+ socket = 198,
+ socketpair = 199,
+ bind = 200,
+ listen = 201,
+ accept = 202,
+ connect = 203,
+ getsockname = 204,
+ getpeername = 205,
+ sendto = 206,
+ recvfrom = 207,
+ setsockopt = 208,
+ getsockopt = 209,
+ shutdown = 210,
+ sendmsg = 211,
+ recvmsg = 212,
+ readahead = 213,
+ brk = 214,
+ munmap = 215,
+ mremap = 216,
+ add_key = 217,
+ request_key = 218,
+ keyctl = 219,
+ clone = 220,
+ execve = 221,
+ mmap = 222,
+ fadvise64 = 223,
+ swapon = 224,
+ swapoff = 225,
+ mprotect = 226,
+ msync = 227,
+ mlock = 228,
+ munlock = 229,
+ mlockall = 230,
+ munlockall = 231,
+ mincore = 232,
+ madvise = 233,
+ remap_file_pages = 234,
+ mbind = 235,
+ get_mempolicy = 236,
+ set_mempolicy = 237,
+ migrate_pages = 238,
+ move_pages = 239,
+ rt_tgsigqueueinfo = 240,
+ perf_event_open = 241,
+ accept4 = 242,
+ recvmmsg = 243,
+
+ riscv_flush_icache = arch_specific_syscall + 15,
+
+ wait4 = 260,
+ prlimit64 = 261,
+ fanotify_init = 262,
+ fanotify_mark = 263,
+ name_to_handle_at = 264,
+ open_by_handle_at = 265,
+ clock_adjtime = 266,
+ syncfs = 267,
+ setns = 268,
+ sendmmsg = 269,
+ process_vm_readv = 270,
+ process_vm_writev = 271,
+ kcmp = 272,
+ finit_module = 273,
+ sched_setattr = 274,
+ sched_getattr = 275,
+ renameat2 = 276,
+ seccomp = 277,
+ getrandom = 278,
+ memfd_create = 279,
+ bpf = 280,
+ execveat = 281,
+ userfaultfd = 282,
+ membarrier = 283,
+ mlock2 = 284,
+ copy_file_range = 285,
+ preadv2 = 286,
+ pwritev2 = 287,
+ pkey_mprotect = 288,
+ pkey_alloc = 289,
+ pkey_free = 290,
+ statx = 291,
+ io_pgetevents = 292,
+ rseq = 293,
+ kexec_file_load = 294,
+ pidfd_send_signal = 424,
+ io_uring_setup = 425,
+ io_uring_enter = 426,
+ io_uring_register = 427,
+ open_tree = 428,
+ move_mount = 429,
+ fsopen = 430,
+ fsconfig = 431,
+ fsmount = 432,
+ fspick = 433,
+ pidfd_open = 434,
+ clone3 = 435,
+ close_range = 436,
+ openat2 = 437,
+ pidfd_getfd = 438,
+ faccessat2 = 439,
+ process_madvise = 440,
+ epoll_pwait2 = 441,
+
+ _,
+};
+
+pub const O = struct {
+ pub const CREAT = 0o100;
+ pub const EXCL = 0o200;
+ pub const NOCTTY = 0o400;
+ pub const TRUNC = 0o1000;
+ pub const APPEND = 0o2000;
+ pub const NONBLOCK = 0o4000;
+ pub const DSYNC = 0o10000;
+ pub const SYNC = 0o4010000;
+ pub const RSYNC = 0o4010000;
+ pub const DIRECTORY = 0o200000;
+ pub const NOFOLLOW = 0o400000;
+ pub const CLOEXEC = 0o2000000;
+
+ pub const ASYNC = 0o20000;
+ pub const DIRECT = 0o40000;
+ pub const LARGEFILE = 0o100000;
+ pub const NOATIME = 0o1000000;
+ pub const PATH = 0o10000000;
+ pub const TMPFILE = 0o20200000;
+ pub const NDELAY = NONBLOCK;
+};
+
+pub const F = struct {
+ pub const DUPFD = 0;
+ pub const GETFD = 1;
+ pub const SETFD = 2;
+ pub const GETFL = 3;
+ pub const SETFL = 4;
+ pub const GETLK = 5;
+ pub const SETLK = 6;
+ pub const SETLKW = 7;
+ pub const SETOWN = 8;
+ pub const GETOWN = 9;
+ pub const SETSIG = 10;
+ pub const GETSIG = 11;
+
+ pub const RDLCK = 0;
+ pub const WRLCK = 1;
+ pub const UNLCK = 2;
+
+ pub const SETOWN_EX = 15;
+ pub const GETOWN_EX = 16;
+
+ pub const GETOWNER_UIDS = 17;
+};
+
+pub const LOCK = struct {
+ pub const SH = 1;
+ pub const EX = 2;
+ pub const UN = 8;
+ pub const NB = 4;
+};
+
+pub const blksize_t = i32;
+pub const nlink_t = u32;
+pub const time_t = isize;
+pub const mode_t = u32;
+pub const off_t = isize;
+pub const ino_t = usize;
+pub const dev_t = usize;
+pub const blkcnt_t = isize;
+
+pub const timeval = extern struct {
+ tv_sec: time_t,
+ tv_usec: i64,
+};
+
+pub const Flock = extern struct {
+ l_type: i16,
+ l_whence: i16,
+ l_start: off_t,
+ l_len: off_t,
+ l_pid: pid_t,
+ __unused: [4]u8,
+};
+
+// The `stat` definition used by the Linux kernel.
+pub const Stat = extern struct {
+ dev: dev_t,
+ ino: ino_t,
+ mode: mode_t,
+ nlink: nlink_t,
+ uid: uid_t,
+ gid: gid_t,
+ rdev: dev_t,
+ __pad: usize,
+ size: off_t,
+ blksize: blksize_t,
+ __pad2: i32,
+ blocks: blkcnt_t,
+ atim: timespec,
+ mtim: timespec,
+ ctim: timespec,
+ __unused: [2]u32,
+
+ pub fn atime(self: @This()) timespec {
+ return self.atim;
+ }
+
+ pub fn mtime(self: @This()) timespec {
+ return self.mtim;
+ }
+
+ pub fn ctime(self: @This()) timespec {
+ return self.ctim;
+ }
+};
+
+pub const Elf_Symndx = u32;
+
+pub const VDSO = struct {};
+pub const MAP = struct {};
diff --git a/lib/std/os/linux/sparc64.zig b/lib/std/os/linux/sparc64.zig
index ce41af40d6c0..3ae490f5e97a 100644
--- a/lib/std/os/linux/sparc64.zig
+++ b/lib/std/os/linux/sparc64.zig
@@ -1,4 +1,17 @@
-usingnamespace @import("../bits/linux.zig");
+const std = @import("../../std.zig");
+const maxInt = std.math.maxInt;
+const pid_t = linux.pid_t;
+const uid_t = linux.uid_t;
+const clock_t = linux.clock_t;
+const stack_t = linux.stack_t;
+const sigset_t = linux.sigset_t;
+
+const linux = std.os.linux;
+const sockaddr = linux.sockaddr;
+const socklen_t = linux.socklen_t;
+const iovec = linux.iovec;
+const iovec_const = linux.iovec_const;
+const timespec = linux.timespec;
pub fn syscall_pipe(fd: *[2]i32) usize {
return asm volatile (
@@ -178,3 +191,632 @@ pub fn restore_rt() callconv(.C) void {
: "memory", "xcc", "o0", "o1", "o2", "o3", "o4", "o5", "o7"
);
}
+
+pub const SYS = enum(usize) {
+ restart_syscall = 0,
+ exit = 1,
+ fork = 2,
+ read = 3,
+ write = 4,
+ open = 5,
+ close = 6,
+ wait4 = 7,
+ creat = 8,
+ link = 9,
+ unlink = 10,
+ execv = 11,
+ chdir = 12,
+ chown = 13,
+ mknod = 14,
+ chmod = 15,
+ lchown = 16,
+ brk = 17,
+ perfctr = 18,
+ lseek = 19,
+ getpid = 20,
+ capget = 21,
+ capset = 22,
+ setuid = 23,
+ getuid = 24,
+ vmsplice = 25,
+ ptrace = 26,
+ alarm = 27,
+ sigaltstack = 28,
+ pause = 29,
+ utime = 30,
+ access = 33,
+ nice = 34,
+ sync = 36,
+ kill = 37,
+ stat = 38,
+ sendfile = 39,
+ lstat = 40,
+ dup = 41,
+ pipe = 42,
+ times = 43,
+ umount2 = 45,
+ setgid = 46,
+ getgid = 47,
+ signal = 48,
+ geteuid = 49,
+ getegid = 50,
+ acct = 51,
+ memory_ordering = 52,
+ ioctl = 54,
+ reboot = 55,
+ symlink = 57,
+ readlink = 58,
+ execve = 59,
+ umask = 60,
+ chroot = 61,
+ fstat = 62,
+ fstat64 = 63,
+ getpagesize = 64,
+ msync = 65,
+ vfork = 66,
+ pread64 = 67,
+ pwrite64 = 68,
+ mmap = 71,
+ munmap = 73,
+ mprotect = 74,
+ madvise = 75,
+ vhangup = 76,
+ mincore = 78,
+ getgroups = 79,
+ setgroups = 80,
+ getpgrp = 81,
+ setitimer = 83,
+ swapon = 85,
+ getitimer = 86,
+ sethostname = 88,
+ dup2 = 90,
+ fcntl = 92,
+ select = 93,
+ fsync = 95,
+ setpriority = 96,
+ socket = 97,
+ connect = 98,
+ accept = 99,
+ getpriority = 100,
+ rt_sigreturn = 101,
+ rt_sigaction = 102,
+ rt_sigprocmask = 103,
+ rt_sigpending = 104,
+ rt_sigtimedwait = 105,
+ rt_sigqueueinfo = 106,
+ rt_sigsuspend = 107,
+ setresuid = 108,
+ getresuid = 109,
+ setresgid = 110,
+ getresgid = 111,
+ recvmsg = 113,
+ sendmsg = 114,
+ gettimeofday = 116,
+ getrusage = 117,
+ getsockopt = 118,
+ getcwd = 119,
+ readv = 120,
+ writev = 121,
+ settimeofday = 122,
+ fchown = 123,
+ fchmod = 124,
+ recvfrom = 125,
+ setreuid = 126,
+ setregid = 127,
+ rename = 128,
+ truncate = 129,
+ ftruncate = 130,
+ flock = 131,
+ lstat64 = 132,
+ sendto = 133,
+ shutdown = 134,
+ socketpair = 135,
+ mkdir = 136,
+ rmdir = 137,
+ utimes = 138,
+ stat64 = 139,
+ sendfile64 = 140,
+ getpeername = 141,
+ futex = 142,
+ gettid = 143,
+ getrlimit = 144,
+ setrlimit = 145,
+ pivot_root = 146,
+ prctl = 147,
+ pciconfig_read = 148,
+ pciconfig_write = 149,
+ getsockname = 150,
+ inotify_init = 151,
+ inotify_add_watch = 152,
+ poll = 153,
+ getdents64 = 154,
+ inotify_rm_watch = 156,
+ statfs = 157,
+ fstatfs = 158,
+ umount = 159,
+ sched_set_affinity = 160,
+ sched_get_affinity = 161,
+ getdomainname = 162,
+ setdomainname = 163,
+ utrap_install = 164,
+ quotactl = 165,
+ set_tid_address = 166,
+ mount = 167,
+ ustat = 168,
+ setxattr = 169,
+ lsetxattr = 170,
+ fsetxattr = 171,
+ getxattr = 172,
+ lgetxattr = 173,
+ getdents = 174,
+ setsid = 175,
+ fchdir = 176,
+ fgetxattr = 177,
+ listxattr = 178,
+ llistxattr = 179,
+ flistxattr = 180,
+ removexattr = 181,
+ lremovexattr = 182,
+ sigpending = 183,
+ query_module = 184,
+ setpgid = 185,
+ fremovexattr = 186,
+ tkill = 187,
+ exit_group = 188,
+ uname = 189,
+ init_module = 190,
+ personality = 191,
+ remap_file_pages = 192,
+ epoll_create = 193,
+ epoll_ctl = 194,
+ epoll_wait = 195,
+ ioprio_set = 196,
+ getppid = 197,
+ sigaction = 198,
+ sgetmask = 199,
+ ssetmask = 200,
+ sigsuspend = 201,
+ oldlstat = 202,
+ uselib = 203,
+ readdir = 204,
+ readahead = 205,
+ socketcall = 206,
+ syslog = 207,
+ lookup_dcookie = 208,
+ fadvise64 = 209,
+ fadvise64_64 = 210,
+ tgkill = 211,
+ waitpid = 212,
+ swapoff = 213,
+ sysinfo = 214,
+ ipc = 215,
+ sigreturn = 216,
+ clone = 217,
+ ioprio_get = 218,
+ adjtimex = 219,
+ sigprocmask = 220,
+ create_module = 221,
+ delete_module = 222,
+ get_kernel_syms = 223,
+ getpgid = 224,
+ bdflush = 225,
+ sysfs = 226,
+ afs_syscall = 227,
+ setfsuid = 228,
+ setfsgid = 229,
+ _newselect = 230,
+ splice = 232,
+ stime = 233,
+ statfs64 = 234,
+ fstatfs64 = 235,
+ _llseek = 236,
+ mlock = 237,
+ munlock = 238,
+ mlockall = 239,
+ munlockall = 240,
+ sched_setparam = 241,
+ sched_getparam = 242,
+ sched_setscheduler = 243,
+ sched_getscheduler = 244,
+ sched_yield = 245,
+ sched_get_priority_max = 246,
+ sched_get_priority_min = 247,
+ sched_rr_get_interval = 248,
+ nanosleep = 249,
+ mremap = 250,
+ _sysctl = 251,
+ getsid = 252,
+ fdatasync = 253,
+ nfsservctl = 254,
+ sync_file_range = 255,
+ clock_settime = 256,
+ clock_gettime = 257,
+ clock_getres = 258,
+ clock_nanosleep = 259,
+ sched_getaffinity = 260,
+ sched_setaffinity = 261,
+ timer_settime = 262,
+ timer_gettime = 263,
+ timer_getoverrun = 264,
+ timer_delete = 265,
+ timer_create = 266,
+ vserver = 267,
+ io_setup = 268,
+ io_destroy = 269,
+ io_submit = 270,
+ io_cancel = 271,
+ io_getevents = 272,
+ mq_open = 273,
+ mq_unlink = 274,
+ mq_timedsend = 275,
+ mq_timedreceive = 276,
+ mq_notify = 277,
+ mq_getsetattr = 278,
+ waitid = 279,
+ tee = 280,
+ add_key = 281,
+ request_key = 282,
+ keyctl = 283,
+ openat = 284,
+ mkdirat = 285,
+ mknodat = 286,
+ fchownat = 287,
+ futimesat = 288,
+ fstatat64 = 289,
+ unlinkat = 290,
+ renameat = 291,
+ linkat = 292,
+ symlinkat = 293,
+ readlinkat = 294,
+ fchmodat = 295,
+ faccessat = 296,
+ pselect6 = 297,
+ ppoll = 298,
+ unshare = 299,
+ set_robust_list = 300,
+ get_robust_list = 301,
+ migrate_pages = 302,
+ mbind = 303,
+ get_mempolicy = 304,
+ set_mempolicy = 305,
+ kexec_load = 306,
+ move_pages = 307,
+ getcpu = 308,
+ epoll_pwait = 309,
+ utimensat = 310,
+ signalfd = 311,
+ timerfd_create = 312,
+ eventfd = 313,
+ fallocate = 314,
+ timerfd_settime = 315,
+ timerfd_gettime = 316,
+ signalfd4 = 317,
+ eventfd2 = 318,
+ epoll_create1 = 319,
+ dup3 = 320,
+ pipe2 = 321,
+ inotify_init1 = 322,
+ accept4 = 323,
+ preadv = 324,
+ pwritev = 325,
+ rt_tgsigqueueinfo = 326,
+ perf_event_open = 327,
+ recvmmsg = 328,
+ fanotify_init = 329,
+ fanotify_mark = 330,
+ prlimit64 = 331,
+ name_to_handle_at = 332,
+ open_by_handle_at = 333,
+ clock_adjtime = 334,
+ syncfs = 335,
+ sendmmsg = 336,
+ setns = 337,
+ process_vm_readv = 338,
+ process_vm_writev = 339,
+ kern_features = 340,
+ kcmp = 341,
+ finit_module = 342,
+ sched_setattr = 343,
+ sched_getattr = 344,
+ renameat2 = 345,
+ seccomp = 346,
+ getrandom = 347,
+ memfd_create = 348,
+ bpf = 349,
+ execveat = 350,
+ membarrier = 351,
+ userfaultfd = 352,
+ bind = 353,
+ listen = 354,
+ setsockopt = 355,
+ mlock2 = 356,
+ copy_file_range = 357,
+ preadv2 = 358,
+ pwritev2 = 359,
+ statx = 360,
+ io_pgetevents = 361,
+ pkey_mprotect = 362,
+ pkey_alloc = 363,
+ pkey_free = 364,
+ rseq = 365,
+ semtimedop = 392,
+ semget = 393,
+ semctl = 394,
+ shmget = 395,
+ shmctl = 396,
+ shmat = 397,
+ shmdt = 398,
+ msgget = 399,
+ msgsnd = 400,
+ msgrcv = 401,
+ msgctl = 402,
+ pidfd_send_signal = 424,
+ io_uring_setup = 425,
+ io_uring_enter = 426,
+ io_uring_register = 427,
+ open_tree = 428,
+ move_mount = 429,
+ fsopen = 430,
+ fsconfig = 431,
+ fsmount = 432,
+ fspick = 433,
+ pidfd_open = 434,
+ clone3 = 435,
+ close_range = 436,
+ openat2 = 437,
+ pidfd_getfd = 438,
+ faccessat2 = 439,
+ process_madvise = 440,
+ epoll_pwait2 = 441,
+
+ _,
+};
+
+pub const O = struct {
+ pub const CREAT = 0x200;
+ pub const EXCL = 0x800;
+ pub const NOCTTY = 0x8000;
+ pub const TRUNC = 0x400;
+ pub const APPEND = 0x8;
+ pub const NONBLOCK = 0x4000;
+ pub const SYNC = 0x802000;
+ pub const DSYNC = 0x2000;
+ pub const RSYNC = SYNC;
+ pub const DIRECTORY = 0x10000;
+ pub const NOFOLLOW = 0x20000;
+ pub const CLOEXEC = 0x400000;
+
+ pub const ASYNC = 0x40;
+ pub const DIRECT = 0x100000;
+ pub const LARGEFILE = 0;
+ pub const NOATIME = 0x200000;
+ pub const PATH = 0x1000000;
+ pub const TMPFILE = 0x2010000;
+ pub const NDELAY = NONBLOCK | 0x4;
+};
+
+pub const F = struct {
+ pub const DUPFD = 0;
+ pub const GETFD = 1;
+ pub const SETFD = 2;
+ pub const GETFL = 3;
+ pub const SETFL = 4;
+
+ pub const SETOWN = 5;
+ pub const GETOWN = 6;
+ pub const GETLK = 7;
+ pub const SETLK = 8;
+ pub const SETLKW = 9;
+
+ pub const RDLCK = 1;
+ pub const WRLCK = 2;
+ pub const UNLCK = 3;
+
+ pub const SETOWN_EX = 15;
+ pub const GETOWN_EX = 16;
+
+ pub const GETOWNER_UIDS = 17;
+};
+
+pub const LOCK = struct {
+ pub const SH = 1;
+ pub const EX = 2;
+ pub const NB = 4;
+ pub const UN = 8;
+};
+
+pub const MAP = struct {
+ /// stack-like segment
+ pub const GROWSDOWN = 0x0200;
+ /// ETXTBSY
+ pub const DENYWRITE = 0x0800;
+ /// mark it as an executable
+ pub const EXECUTABLE = 0x1000;
+ /// pages are locked
+ pub const LOCKED = 0x0100;
+ /// don't check for reservations
+ pub const NORESERVE = 0x0040;
+};
+
+pub const VDSO = struct {
+ pub const CGT_SYM = "__vdso_clock_gettime";
+ pub const CGT_VER = "LINUX_2.6";
+};
+
+pub const Flock = extern struct {
+ l_type: i16,
+ l_whence: i16,
+ l_start: off_t,
+ l_len: off_t,
+ l_pid: pid_t,
+};
+
+pub const msghdr = extern struct {
+ msg_name: ?*sockaddr,
+ msg_namelen: socklen_t,
+ msg_iov: [*]iovec,
+ msg_iovlen: u64,
+ msg_control: ?*c_void,
+ msg_controllen: u64,
+ msg_flags: i32,
+};
+
+pub const msghdr_const = extern struct {
+ msg_name: ?*const sockaddr,
+ msg_namelen: socklen_t,
+ msg_iov: [*]iovec_const,
+ msg_iovlen: u64,
+ msg_control: ?*c_void,
+ msg_controllen: u64,
+ msg_flags: i32,
+};
+
+pub const off_t = i64;
+pub const ino_t = u64;
+pub const mode_t = u32;
+
+// The `stat64` definition used by the kernel.
+pub const Stat = extern struct {
+ dev: u64,
+ ino: u64,
+ nlink: u64,
+
+ mode: u32,
+ uid: u32,
+ gid: u32,
+ __pad0: u32,
+
+ rdev: u64,
+ size: i64,
+ blksize: i64,
+ blocks: i64,
+
+ atim: timespec,
+ mtim: timespec,
+ ctim: timespec,
+ __unused: [3]u64,
+
+ pub fn atime(self: @This()) timespec {
+ return self.atim;
+ }
+
+ pub fn mtime(self: @This()) timespec {
+ return self.mtim;
+ }
+
+ pub fn ctime(self: @This()) timespec {
+ return self.ctim;
+ }
+};
+
+pub const timeval = extern struct {
+ tv_sec: isize,
+ tv_usec: isize,
+};
+
+pub const timezone = extern struct {
+ tz_minuteswest: i32,
+ tz_dsttime: i32,
+};
+
+// TODO I'm not sure if the code below is correct, need someone with more
+// knowledge about sparc64 linux internals to look into.
+
+pub const Elf_Symndx = u32;
+
+pub const fpstate = extern struct {
+ regs: [32]u64,
+ fsr: u64,
+ gsr: u64,
+ fprs: u64,
+};
+
+pub const __fpq = extern struct {
+ fpq_addr: *u32,
+ fpq_instr: u32,
+};
+
+pub const __fq = extern struct {
+ FQu: extern union {
+ whole: f64,
+ fpq: __fpq,
+ },
+};
+
+pub const fpregset_t = extern struct {
+ fpu_fr: extern union {
+ fpu_regs: [32]u32,
+ fpu_dregs: [32]f64,
+ fpu_qregs: [16]c_longdouble,
+ },
+ fpu_q: *__fq,
+ fpu_fsr: u64,
+ fpu_qcnt: u8,
+ fpu_q_entrysize: u8,
+ fpu_en: u8,
+};
+
+pub const siginfo_fpu_t = extern struct {
+ float_regs: [64]u32,
+ fsr: u64,
+ gsr: u64,
+ fprs: u64,
+};
+
+pub const sigcontext = extern struct {
+ info: [128]i8,
+ regs: extern struct {
+ u_regs: [16]u64,
+ tstate: u64,
+ tpc: u64,
+ tnpc: u64,
+ y: u64,
+ fprs: u64,
+ },
+ fpu_save: *siginfo_fpu_t,
+ stack: extern struct {
+ sp: usize,
+ flags: i32,
+ size: u64,
+ },
+ mask: u64,
+};
+
+pub const greg_t = u64;
+pub const gregset_t = [19]greg_t;
+
+pub const fq = extern struct {
+ addr: *u64,
+ insn: u32,
+};
+
+pub const fpu_t = extern struct {
+ fregs: extern union {
+ sregs: [32]u32,
+ dregs: [32]u64,
+ qregs: [16]c_longdouble,
+ },
+ fsr: u64,
+ fprs: u64,
+ gsr: u64,
+ fq: *fq,
+ qcnt: u8,
+ qentsz: u8,
+ enab: u8,
+};
+
+pub const mcontext_t = extern struct {
+ gregs: gregset_t,
+ fp: greg_t,
+ @"i7": greg_t,
+ fpregs: fpu_t,
+};
+
+pub const ucontext_t = extern struct {
+ link: *ucontext_t,
+ flags: u64,
+ sigmask: u64,
+ mcontext: mcontext_t,
+ stack: stack_t,
+ sigmask: sigset_t,
+};
diff --git a/lib/std/os/linux/test.zig b/lib/std/os/linux/test.zig
index e45c9dbb9937..14ff8ea38db7 100644
--- a/lib/std/os/linux/test.zig
+++ b/lib/std/os/linux/test.zig
@@ -35,7 +35,7 @@ test "timer" {
var err: linux.E = linux.getErrno(epoll_fd);
try expect(err == .SUCCESS);
- const timer_fd = linux.timerfd_create(linux.CLOCK_MONOTONIC, 0);
+ const timer_fd = linux.timerfd_create(linux.CLOCK.MONOTONIC, 0);
try expect(linux.getErrno(timer_fd) == .SUCCESS);
const time_interval = linux.timespec{
@@ -52,11 +52,11 @@ test "timer" {
try expect(err == .SUCCESS);
var event = linux.epoll_event{
- .events = linux.EPOLLIN | linux.EPOLLOUT | linux.EPOLLET,
+ .events = linux.EPOLL.IN | linux.EPOLL.OUT | linux.EPOLL.ET,
.data = linux.epoll_data{ .ptr = 0 },
};
- err = linux.getErrno(linux.epoll_ctl(@intCast(i32, epoll_fd), linux.EPOLL_CTL_ADD, @intCast(i32, timer_fd), &event));
+ err = linux.getErrno(linux.epoll_ctl(@intCast(i32, epoll_fd), linux.EPOLL.CTL_ADD, @intCast(i32, timer_fd), &event));
try expect(err == .SUCCESS);
const events_one: linux.epoll_event = undefined;
@@ -75,15 +75,15 @@ test "statx" {
}
var statx_buf: linux.Statx = undefined;
- switch (linux.getErrno(linux.statx(file.handle, "", linux.AT_EMPTY_PATH, linux.STATX_BASIC_STATS, &statx_buf))) {
+ switch (linux.getErrno(linux.statx(file.handle, "", linux.AT.EMPTY_PATH, linux.STATX_BASIC_STATS, &statx_buf))) {
.SUCCESS => {},
// The statx syscall was only introduced in linux 4.11
.NOSYS => return error.SkipZigTest,
else => unreachable,
}
- var stat_buf: linux.kernel_stat = undefined;
- switch (linux.getErrno(linux.fstatat(file.handle, "", &stat_buf, linux.AT_EMPTY_PATH))) {
+ var stat_buf: linux.Stat = undefined;
+ switch (linux.getErrno(linux.fstatat(file.handle, "", &stat_buf, linux.AT.EMPTY_PATH))) {
.SUCCESS => {},
else => unreachable,
}
@@ -119,7 +119,7 @@ test "fadvise" {
file.handle,
0,
0,
- linux.POSIX_FADV_SEQUENTIAL,
+ linux.POSIX_FADV.SEQUENTIAL,
);
try expectEqual(@as(usize, 0), ret);
}
diff --git a/lib/std/os/linux/thumb.zig b/lib/std/os/linux/thumb.zig
index e5d185b8c146..6ac51afb7880 100644
--- a/lib/std/os/linux/thumb.zig
+++ b/lib/std/os/linux/thumb.zig
@@ -1,10 +1,11 @@
-usingnamespace @import("../bits/linux.zig");
-
-// The syscall interface is identical to the ARM one but we're facing an extra
-// challenge: r7, the register where the syscall number is stored, may be
-// reserved for the frame pointer.
-// Save and restore r7 around the syscall without touching the stack pointer not
-// to break the frame chain.
+//! The syscall interface is identical to the ARM one but we're facing an extra
+//! challenge: r7, the register where the syscall number is stored, may be
+//! reserved for the frame pointer.
+//! Save and restore r7 around the syscall without touching the stack pointer not
+//! to break the frame chain.
+const std = @import("../../std.zig");
+const linux = std.os.linux;
+const SYS = linux.SYS;
pub fn syscall0(number: SYS) usize {
@setRuntimeSafety(false);
@@ -140,9 +141,6 @@ pub fn syscall6(
);
}
-/// This matches the libc clone function.
-pub extern fn clone(func: fn (arg: usize) callconv(.C) u8, stack: usize, flags: u32, arg: usize, ptid: *i32, tls: usize, ctid: *i32) usize;
-
pub fn restore() callconv(.Naked) void {
return asm volatile (
\\ mov r7, %[number]
diff --git a/lib/std/os/linux/tls.zig b/lib/std/os/linux/tls.zig
index d04bf24b5fad..de9c475083b4 100644
--- a/lib/std/os/linux/tls.zig
+++ b/lib/std/os/linux/tls.zig
@@ -135,7 +135,7 @@ pub fn setThreadPointer(addr: usize) void {
);
},
.x86_64 => {
- const rc = std.os.linux.syscall2(.arch_prctl, std.os.linux.ARCH_SET_FS, addr);
+ const rc = std.os.linux.syscall2(.arch_prctl, std.os.linux.ARCH.SET_FS, addr);
assert(rc == 0);
},
.aarch64 => {
@@ -319,8 +319,8 @@ pub fn initStaticTLS(phdrs: []elf.Phdr) void {
const alloc_tls_area = os.mmap(
null,
tls_image.alloc_size + tls_image.alloc_align - 1,
- os.PROT_READ | os.PROT_WRITE,
- os.MAP_PRIVATE | os.MAP_ANONYMOUS,
+ os.PROT.READ | os.PROT.WRITE,
+ os.MAP.PRIVATE | os.MAP.ANONYMOUS,
-1,
0,
) catch os.abort();
diff --git a/lib/std/os/linux/x86_64.zig b/lib/std/os/linux/x86_64.zig
index 7398c3afb6d1..b6a2d2763f73 100644
--- a/lib/std/os/linux/x86_64.zig
+++ b/lib/std/os/linux/x86_64.zig
@@ -1,4 +1,18 @@
-usingnamespace @import("../bits/linux.zig");
+const std = @import("../../std.zig");
+const maxInt = std.math.maxInt;
+const linux = std.os.linux;
+const iovec = std.os.iovec;
+const iovec_const = std.os.iovec_const;
+
+const pid_t = linux.pid_t;
+const uid_t = linux.uid_t;
+const gid_t = linux.gid_t;
+const clock_t = linux.clock_t;
+const stack_t = linux.stack_t;
+const sigset_t = linux.sigset_t;
+const sockaddr = linux.sockaddr;
+const socklen_t = linux.socklen_t;
+const timespec = linux.timespec;
pub fn syscall0(number: SYS) usize {
return asm volatile ("syscall"
@@ -97,3 +111,629 @@ pub fn restore_rt() callconv(.Naked) void {
: "rcx", "r11", "memory"
);
}
+
+pub const mode_t = usize;
+pub const time_t = isize;
+pub const nlink_t = usize;
+pub const blksize_t = isize;
+pub const blkcnt_t = isize;
+
+pub const SYS = enum(usize) {
+ read = 0,
+ write = 1,
+ open = 2,
+ close = 3,
+ stat = 4,
+ fstat = 5,
+ lstat = 6,
+ poll = 7,
+ lseek = 8,
+ mmap = 9,
+ mprotect = 10,
+ munmap = 11,
+ brk = 12,
+ rt_sigaction = 13,
+ rt_sigprocmask = 14,
+ rt_sigreturn = 15,
+ ioctl = 16,
+ pread = 17,
+ pwrite = 18,
+ readv = 19,
+ writev = 20,
+ access = 21,
+ pipe = 22,
+ select = 23,
+ sched_yield = 24,
+ mremap = 25,
+ msync = 26,
+ mincore = 27,
+ madvise = 28,
+ shmget = 29,
+ shmat = 30,
+ shmctl = 31,
+ dup = 32,
+ dup2 = 33,
+ pause = 34,
+ nanosleep = 35,
+ getitimer = 36,
+ alarm = 37,
+ setitimer = 38,
+ getpid = 39,
+ sendfile = 40,
+ socket = 41,
+ connect = 42,
+ accept = 43,
+ sendto = 44,
+ recvfrom = 45,
+ sendmsg = 46,
+ recvmsg = 47,
+ shutdown = 48,
+ bind = 49,
+ listen = 50,
+ getsockname = 51,
+ getpeername = 52,
+ socketpair = 53,
+ setsockopt = 54,
+ getsockopt = 55,
+ clone = 56,
+ fork = 57,
+ vfork = 58,
+ execve = 59,
+ exit = 60,
+ wait4 = 61,
+ kill = 62,
+ uname = 63,
+ semget = 64,
+ semop = 65,
+ semctl = 66,
+ shmdt = 67,
+ msgget = 68,
+ msgsnd = 69,
+ msgrcv = 70,
+ msgctl = 71,
+ fcntl = 72,
+ flock = 73,
+ fsync = 74,
+ fdatasync = 75,
+ truncate = 76,
+ ftruncate = 77,
+ getdents = 78,
+ getcwd = 79,
+ chdir = 80,
+ fchdir = 81,
+ rename = 82,
+ mkdir = 83,
+ rmdir = 84,
+ creat = 85,
+ link = 86,
+ unlink = 87,
+ symlink = 88,
+ readlink = 89,
+ chmod = 90,
+ fchmod = 91,
+ chown = 92,
+ fchown = 93,
+ lchown = 94,
+ umask = 95,
+ gettimeofday = 96,
+ getrlimit = 97,
+ getrusage = 98,
+ sysinfo = 99,
+ times = 100,
+ ptrace = 101,
+ getuid = 102,
+ syslog = 103,
+ getgid = 104,
+ setuid = 105,
+ setgid = 106,
+ geteuid = 107,
+ getegid = 108,
+ setpgid = 109,
+ getppid = 110,
+ getpgrp = 111,
+ setsid = 112,
+ setreuid = 113,
+ setregid = 114,
+ getgroups = 115,
+ setgroups = 116,
+ setresuid = 117,
+ getresuid = 118,
+ setresgid = 119,
+ getresgid = 120,
+ getpgid = 121,
+ setfsuid = 122,
+ setfsgid = 123,
+ getsid = 124,
+ capget = 125,
+ capset = 126,
+ rt_sigpending = 127,
+ rt_sigtimedwait = 128,
+ rt_sigqueueinfo = 129,
+ rt_sigsuspend = 130,
+ sigaltstack = 131,
+ utime = 132,
+ mknod = 133,
+ uselib = 134,
+ personality = 135,
+ ustat = 136,
+ statfs = 137,
+ fstatfs = 138,
+ sysfs = 139,
+ getpriority = 140,
+ setpriority = 141,
+ sched_setparam = 142,
+ sched_getparam = 143,
+ sched_setscheduler = 144,
+ sched_getscheduler = 145,
+ sched_get_priority_max = 146,
+ sched_get_priority_min = 147,
+ sched_rr_get_interval = 148,
+ mlock = 149,
+ munlock = 150,
+ mlockall = 151,
+ munlockall = 152,
+ vhangup = 153,
+ modify_ldt = 154,
+ pivot_root = 155,
+ _sysctl = 156,
+ prctl = 157,
+ arch_prctl = 158,
+ adjtimex = 159,
+ setrlimit = 160,
+ chroot = 161,
+ sync = 162,
+ acct = 163,
+ settimeofday = 164,
+ mount = 165,
+ umount2 = 166,
+ swapon = 167,
+ swapoff = 168,
+ reboot = 169,
+ sethostname = 170,
+ setdomainname = 171,
+ iopl = 172,
+ ioperm = 173,
+ create_module = 174,
+ init_module = 175,
+ delete_module = 176,
+ get_kernel_syms = 177,
+ query_module = 178,
+ quotactl = 179,
+ nfsservctl = 180,
+ getpmsg = 181,
+ putpmsg = 182,
+ afs_syscall = 183,
+ tuxcall = 184,
+ security = 185,
+ gettid = 186,
+ readahead = 187,
+ setxattr = 188,
+ lsetxattr = 189,
+ fsetxattr = 190,
+ getxattr = 191,
+ lgetxattr = 192,
+ fgetxattr = 193,
+ listxattr = 194,
+ llistxattr = 195,
+ flistxattr = 196,
+ removexattr = 197,
+ lremovexattr = 198,
+ fremovexattr = 199,
+ tkill = 200,
+ time = 201,
+ futex = 202,
+ sched_setaffinity = 203,
+ sched_getaffinity = 204,
+ set_thread_area = 205,
+ io_setup = 206,
+ io_destroy = 207,
+ io_getevents = 208,
+ io_submit = 209,
+ io_cancel = 210,
+ get_thread_area = 211,
+ lookup_dcookie = 212,
+ epoll_create = 213,
+ epoll_ctl_old = 214,
+ epoll_wait_old = 215,
+ remap_file_pages = 216,
+ getdents64 = 217,
+ set_tid_address = 218,
+ restart_syscall = 219,
+ semtimedop = 220,
+ fadvise64 = 221,
+ timer_create = 222,
+ timer_settime = 223,
+ timer_gettime = 224,
+ timer_getoverrun = 225,
+ timer_delete = 226,
+ clock_settime = 227,
+ clock_gettime = 228,
+ clock_getres = 229,
+ clock_nanosleep = 230,
+ exit_group = 231,
+ epoll_wait = 232,
+ epoll_ctl = 233,
+ tgkill = 234,
+ utimes = 235,
+ vserver = 236,
+ mbind = 237,
+ set_mempolicy = 238,
+ get_mempolicy = 239,
+ mq_open = 240,
+ mq_unlink = 241,
+ mq_timedsend = 242,
+ mq_timedreceive = 243,
+ mq_notify = 244,
+ mq_getsetattr = 245,
+ kexec_load = 246,
+ waitid = 247,
+ add_key = 248,
+ request_key = 249,
+ keyctl = 250,
+ ioprio_set = 251,
+ ioprio_get = 252,
+ inotify_init = 253,
+ inotify_add_watch = 254,
+ inotify_rm_watch = 255,
+ migrate_pages = 256,
+ openat = 257,
+ mkdirat = 258,
+ mknodat = 259,
+ fchownat = 260,
+ futimesat = 261,
+ fstatat = 262,
+ unlinkat = 263,
+ renameat = 264,
+ linkat = 265,
+ symlinkat = 266,
+ readlinkat = 267,
+ fchmodat = 268,
+ faccessat = 269,
+ pselect6 = 270,
+ ppoll = 271,
+ unshare = 272,
+ set_robust_list = 273,
+ get_robust_list = 274,
+ splice = 275,
+ tee = 276,
+ sync_file_range = 277,
+ vmsplice = 278,
+ move_pages = 279,
+ utimensat = 280,
+ epoll_pwait = 281,
+ signalfd = 282,
+ timerfd_create = 283,
+ eventfd = 284,
+ fallocate = 285,
+ timerfd_settime = 286,
+ timerfd_gettime = 287,
+ accept4 = 288,
+ signalfd4 = 289,
+ eventfd2 = 290,
+ epoll_create1 = 291,
+ dup3 = 292,
+ pipe2 = 293,
+ inotify_init1 = 294,
+ preadv = 295,
+ pwritev = 296,
+ rt_tgsigqueueinfo = 297,
+ perf_event_open = 298,
+ recvmmsg = 299,
+ fanotify_init = 300,
+ fanotify_mark = 301,
+ prlimit64 = 302,
+ name_to_handle_at = 303,
+ open_by_handle_at = 304,
+ clock_adjtime = 305,
+ syncfs = 306,
+ sendmmsg = 307,
+ setns = 308,
+ getcpu = 309,
+ process_vm_readv = 310,
+ process_vm_writev = 311,
+ kcmp = 312,
+ finit_module = 313,
+ sched_setattr = 314,
+ sched_getattr = 315,
+ renameat2 = 316,
+ seccomp = 317,
+ getrandom = 318,
+ memfd_create = 319,
+ kexec_file_load = 320,
+ bpf = 321,
+ execveat = 322,
+ userfaultfd = 323,
+ membarrier = 324,
+ mlock2 = 325,
+ copy_file_range = 326,
+ preadv2 = 327,
+ pwritev2 = 328,
+ pkey_mprotect = 329,
+ pkey_alloc = 330,
+ pkey_free = 331,
+ statx = 332,
+ io_pgetevents = 333,
+ rseq = 334,
+ pidfd_send_signal = 424,
+ io_uring_setup = 425,
+ io_uring_enter = 426,
+ io_uring_register = 427,
+ open_tree = 428,
+ move_mount = 429,
+ fsopen = 430,
+ fsconfig = 431,
+ fsmount = 432,
+ fspick = 433,
+ pidfd_open = 434,
+ clone3 = 435,
+ close_range = 436,
+ openat2 = 437,
+ pidfd_getfd = 438,
+ faccessat2 = 439,
+ process_madvise = 440,
+ epoll_pwait2 = 441,
+
+ _,
+};
+
+pub const O = struct {
+ pub const CREAT = 0o100;
+ pub const EXCL = 0o200;
+ pub const NOCTTY = 0o400;
+ pub const TRUNC = 0o1000;
+ pub const APPEND = 0o2000;
+ pub const NONBLOCK = 0o4000;
+ pub const DSYNC = 0o10000;
+ pub const SYNC = 0o4010000;
+ pub const RSYNC = 0o4010000;
+ pub const DIRECTORY = 0o200000;
+ pub const NOFOLLOW = 0o400000;
+ pub const CLOEXEC = 0o2000000;
+
+ pub const ASYNC = 0o20000;
+ pub const DIRECT = 0o40000;
+ pub const LARGEFILE = 0;
+ pub const NOATIME = 0o1000000;
+ pub const PATH = 0o10000000;
+ pub const TMPFILE = 0o20200000;
+ pub const NDELAY = NONBLOCK;
+};
+
+pub const F = struct {
+ pub const DUPFD = 0;
+ pub const GETFD = 1;
+ pub const SETFD = 2;
+ pub const GETFL = 3;
+ pub const SETFL = 4;
+ pub const GETLK = 5;
+ pub const SETLK = 6;
+ pub const SETLKW = 7;
+ pub const SETOWN = 8;
+ pub const GETOWN = 9;
+ pub const SETSIG = 10;
+ pub const GETSIG = 11;
+
+ pub const SETOWN_EX = 15;
+ pub const GETOWN_EX = 16;
+ pub const GETOWNER_UIDS = 17;
+
+ pub const RDLCK = 0;
+ pub const WRLCK = 1;
+ pub const UNLCK = 2;
+};
+
+pub const MAP = struct {
+ /// only give out 32bit addresses
+ pub const @"32BIT" = 0x40;
+ /// stack-like segment
+ pub const GROWSDOWN = 0x0100;
+ /// ETXTBSY
+ pub const DENYWRITE = 0x0800;
+ /// mark it as an executable
+ pub const EXECUTABLE = 0x1000;
+ /// pages are locked
+ pub const LOCKED = 0x2000;
+ /// don't check for reservations
+ pub const NORESERVE = 0x4000;
+};
+
+pub const VDSO = struct {
+ pub const CGT_SYM = "__vdso_clock_gettime";
+ pub const CGT_VER = "LINUX_2.6";
+
+ pub const GETCPU_SYM = "__vdso_getcpu";
+ pub const GETCPU_VER = "LINUX_2.6";
+};
+
+pub const ARCH = struct {
+ pub const SET_GS = 0x1001;
+ pub const SET_FS = 0x1002;
+ pub const GET_FS = 0x1003;
+ pub const GET_GS = 0x1004;
+};
+
+pub const REG = struct {
+ pub const R8 = 0;
+ pub const R9 = 1;
+ pub const R10 = 2;
+ pub const R11 = 3;
+ pub const R12 = 4;
+ pub const R13 = 5;
+ pub const R14 = 6;
+ pub const R15 = 7;
+ pub const RDI = 8;
+ pub const RSI = 9;
+ pub const RBP = 10;
+ pub const RBX = 11;
+ pub const RDX = 12;
+ pub const RAX = 13;
+ pub const RCX = 14;
+ pub const RSP = 15;
+ pub const RIP = 16;
+ pub const EFL = 17;
+ pub const CSGSFS = 18;
+ pub const ERR = 19;
+ pub const TRAPNO = 20;
+ pub const OLDMASK = 21;
+ pub const CR2 = 22;
+};
+
+pub const LOCK = struct {
+ pub const SH = 1;
+ pub const EX = 2;
+ pub const NB = 4;
+ pub const UN = 8;
+};
+
+pub const Flock = extern struct {
+ type: i16,
+ whence: i16,
+ start: off_t,
+ len: off_t,
+ pid: pid_t,
+};
+
+pub const msghdr = extern struct {
+ name: ?*sockaddr,
+ namelen: socklen_t,
+ iov: [*]iovec,
+ iovlen: i32,
+ __pad1: i32 = 0,
+ control: ?*c_void,
+ controllen: socklen_t,
+ __pad2: socklen_t = 0,
+ flags: i32,
+};
+
+pub const msghdr_const = extern struct {
+ name: ?*const sockaddr,
+ namelen: socklen_t,
+ iov: [*]iovec_const,
+ iovlen: i32,
+ __pad1: i32 = 0,
+ control: ?*c_void,
+ controllen: socklen_t,
+ __pad2: socklen_t = 0,
+ flags: i32,
+};
+
+pub const off_t = i64;
+pub const ino_t = u64;
+pub const dev_t = u64;
+
+// The `stat` definition used by the Linux kernel.
+pub const Stat = extern struct {
+ dev: dev_t,
+ ino: ino_t,
+ nlink: usize,
+
+ mode: u32,
+ uid: uid_t,
+ gid: gid_t,
+ __pad0: u32,
+ rdev: dev_t,
+ size: off_t,
+ blksize: isize,
+ blocks: i64,
+
+ atim: timespec,
+ mtim: timespec,
+ ctim: timespec,
+ __unused: [3]isize,
+
+ pub fn atime(self: @This()) timespec {
+ return self.atim;
+ }
+
+ pub fn mtime(self: @This()) timespec {
+ return self.mtim;
+ }
+
+ pub fn ctime(self: @This()) timespec {
+ return self.ctim;
+ }
+};
+
+pub const timeval = extern struct {
+ tv_sec: isize,
+ tv_usec: isize,
+};
+
+pub const timezone = extern struct {
+ tz_minuteswest: i32,
+ tz_dsttime: i32,
+};
+
+pub const Elf_Symndx = u32;
+
+pub const greg_t = usize;
+pub const gregset_t = [23]greg_t;
+pub const fpstate = extern struct {
+ cwd: u16,
+ swd: u16,
+ ftw: u16,
+ fop: u16,
+ rip: usize,
+ rdp: usize,
+ mxcsr: u32,
+ mxcr_mask: u32,
+ st: [8]extern struct {
+ significand: [4]u16,
+ exponent: u16,
+ padding: [3]u16 = undefined,
+ },
+ xmm: [16]extern struct {
+ element: [4]u32,
+ },
+ padding: [24]u32 = undefined,
+};
+pub const fpregset_t = *fpstate;
+pub const sigcontext = extern struct {
+ r8: usize,
+ r9: usize,
+ r10: usize,
+ r11: usize,
+ r12: usize,
+ r13: usize,
+ r14: usize,
+ r15: usize,
+
+ rdi: usize,
+ rsi: usize,
+ rbp: usize,
+ rbx: usize,
+ rdx: usize,
+ rax: usize,
+ rcx: usize,
+ rsp: usize,
+ rip: usize,
+ eflags: usize,
+
+ cs: u16,
+ gs: u16,
+ fs: u16,
+ pad0: u16 = undefined,
+
+ err: usize,
+ trapno: usize,
+ oldmask: usize,
+ cr2: usize,
+
+ fpstate: *fpstate,
+ reserved1: [8]usize = undefined,
+};
+
+pub const mcontext_t = extern struct {
+ gregs: gregset_t,
+ fpregs: fpregset_t,
+ reserved1: [8]usize = undefined,
+};
+
+pub const ucontext_t = extern struct {
+ flags: usize,
+ link: *ucontext_t,
+ stack: stack_t,
+ mcontext: mcontext_t,
+ sigmask: sigset_t,
+ fpregs_mem: [64]usize,
+};
diff --git a/lib/std/os/netbsd.zig b/lib/std/os/netbsd.zig
deleted file mode 100644
index 5f9684b96de9..000000000000
--- a/lib/std/os/netbsd.zig
+++ /dev/null
@@ -1,3 +0,0 @@
-const std = @import("../std.zig");
-pub usingnamespace std.c;
-pub usingnamespace @import("bits.zig");
diff --git a/lib/std/os/openbsd.zig b/lib/std/os/openbsd.zig
deleted file mode 100644
index 5f9684b96de9..000000000000
--- a/lib/std/os/openbsd.zig
+++ /dev/null
@@ -1,3 +0,0 @@
-const std = @import("../std.zig");
-pub usingnamespace std.c;
-pub usingnamespace @import("bits.zig");
diff --git a/lib/std/os/test.zig b/lib/std/os/test.zig
index 53a040294e9b..3a0187f735d6 100644
--- a/lib/std/os/test.zig
+++ b/lib/std/os/test.zig
@@ -70,21 +70,21 @@ test "open smoke test" {
// Create some file using `open`.
file_path = try fs.path.join(&arena.allocator, &[_][]const u8{ base_path, "some_file" });
- fd = try os.open(file_path, os.O_RDWR | os.O_CREAT | os.O_EXCL, mode);
+ fd = try os.open(file_path, os.O.RDWR | os.O.CREAT | os.O.EXCL, mode);
os.close(fd);
// Try this again with the same flags. This op should fail with error.PathAlreadyExists.
file_path = try fs.path.join(&arena.allocator, &[_][]const u8{ base_path, "some_file" });
- try expectError(error.PathAlreadyExists, os.open(file_path, os.O_RDWR | os.O_CREAT | os.O_EXCL, mode));
+ try expectError(error.PathAlreadyExists, os.open(file_path, os.O.RDWR | os.O.CREAT | os.O.EXCL, mode));
- // Try opening without `O_EXCL` flag.
+ // Try opening without `O.EXCL` flag.
file_path = try fs.path.join(&arena.allocator, &[_][]const u8{ base_path, "some_file" });
- fd = try os.open(file_path, os.O_RDWR | os.O_CREAT, mode);
+ fd = try os.open(file_path, os.O.RDWR | os.O.CREAT, mode);
os.close(fd);
// Try opening as a directory which should fail.
file_path = try fs.path.join(&arena.allocator, &[_][]const u8{ base_path, "some_file" });
- try expectError(error.NotDir, os.open(file_path, os.O_RDWR | os.O_DIRECTORY, mode));
+ try expectError(error.NotDir, os.open(file_path, os.O.RDWR | os.O.DIRECTORY, mode));
// Create some directory
file_path = try fs.path.join(&arena.allocator, &[_][]const u8{ base_path, "some_dir" });
@@ -92,12 +92,12 @@ test "open smoke test" {
// Open dir using `open`
file_path = try fs.path.join(&arena.allocator, &[_][]const u8{ base_path, "some_dir" });
- fd = try os.open(file_path, os.O_RDONLY | os.O_DIRECTORY, mode);
+ fd = try os.open(file_path, os.O.RDONLY | os.O.DIRECTORY, mode);
os.close(fd);
// Try opening as file which should fail.
file_path = try fs.path.join(&arena.allocator, &[_][]const u8{ base_path, "some_dir" });
- try expectError(error.IsDir, os.open(file_path, os.O_RDWR, mode));
+ try expectError(error.IsDir, os.open(file_path, os.O.RDWR, mode));
}
test "openat smoke test" {
@@ -112,28 +112,28 @@ test "openat smoke test" {
const mode: os.mode_t = if (native_os == .windows) 0 else 0o666;
// Create some file using `openat`.
- fd = try os.openat(tmp.dir.fd, "some_file", os.O_RDWR | os.O_CREAT | os.O_EXCL, mode);
+ fd = try os.openat(tmp.dir.fd, "some_file", os.O.RDWR | os.O.CREAT | os.O.EXCL, mode);
os.close(fd);
// Try this again with the same flags. This op should fail with error.PathAlreadyExists.
- try expectError(error.PathAlreadyExists, os.openat(tmp.dir.fd, "some_file", os.O_RDWR | os.O_CREAT | os.O_EXCL, mode));
+ try expectError(error.PathAlreadyExists, os.openat(tmp.dir.fd, "some_file", os.O.RDWR | os.O.CREAT | os.O.EXCL, mode));
- // Try opening without `O_EXCL` flag.
- fd = try os.openat(tmp.dir.fd, "some_file", os.O_RDWR | os.O_CREAT, mode);
+ // Try opening without `O.EXCL` flag.
+ fd = try os.openat(tmp.dir.fd, "some_file", os.O.RDWR | os.O.CREAT, mode);
os.close(fd);
// Try opening as a directory which should fail.
- try expectError(error.NotDir, os.openat(tmp.dir.fd, "some_file", os.O_RDWR | os.O_DIRECTORY, mode));
+ try expectError(error.NotDir, os.openat(tmp.dir.fd, "some_file", os.O.RDWR | os.O.DIRECTORY, mode));
// Create some directory
try os.mkdirat(tmp.dir.fd, "some_dir", mode);
// Open dir using `open`
- fd = try os.openat(tmp.dir.fd, "some_dir", os.O_RDONLY | os.O_DIRECTORY, mode);
+ fd = try os.openat(tmp.dir.fd, "some_dir", os.O.RDONLY | os.O.DIRECTORY, mode);
os.close(fd);
// Try opening as file which should fail.
- try expectError(error.IsDir, os.openat(tmp.dir.fd, "some_dir", os.O_RDWR, mode));
+ try expectError(error.IsDir, os.openat(tmp.dir.fd, "some_dir", os.O.RDWR, mode));
}
test "symlink with relative paths" {
@@ -273,7 +273,7 @@ test "fstatat" {
defer file.close();
// now repeat but using `fstatat` instead
- const flags = if (native_os == .wasi) 0x0 else os.AT_SYMLINK_NOFOLLOW;
+ const flags = if (native_os == .wasi) 0x0 else os.AT.SYMLINK_NOFOLLOW;
const statat = try os.fstatat(tmp.dir.fd, "file.txt", flags);
try expectEqual(stat, statat);
}
@@ -394,14 +394,14 @@ test "sigaltstack" {
var st: os.stack_t = undefined;
try os.sigaltstack(null, &st);
// Setting a stack size less than MINSIGSTKSZ returns ENOMEM
- st.ss_flags = 0;
- st.ss_size = 1;
+ st.flags = 0;
+ st.size = 1;
try testing.expectError(error.SizeTooSmall, os.sigaltstack(&st, null));
}
// If the type is not available use void to avoid erroring out when `iter_fn` is
// analyzed
-const dl_phdr_info = if (@hasDecl(os, "dl_phdr_info")) os.dl_phdr_info else c_void;
+const dl_phdr_info = if (@hasDecl(os.system, "dl_phdr_info")) os.dl_phdr_info else c_void;
const IterFnError = error{
MissingPtLoadSegment,
@@ -508,8 +508,8 @@ test "mmap" {
const data = try os.mmap(
null,
1234,
- os.PROT_READ | os.PROT_WRITE,
- os.MAP_ANONYMOUS | os.MAP_PRIVATE,
+ os.PROT.READ | os.PROT.WRITE,
+ os.MAP.ANONYMOUS | os.MAP.PRIVATE,
-1,
0,
);
@@ -550,8 +550,8 @@ test "mmap" {
const data = try os.mmap(
null,
alloc_size,
- os.PROT_READ,
- os.MAP_PRIVATE,
+ os.PROT.READ,
+ os.MAP.PRIVATE,
file.handle,
0,
);
@@ -574,8 +574,8 @@ test "mmap" {
const data = try os.mmap(
null,
alloc_size / 2,
- os.PROT_READ,
- os.MAP_PRIVATE,
+ os.PROT.READ,
+ os.MAP.PRIVATE,
file.handle,
alloc_size / 2,
);
@@ -616,19 +616,19 @@ test "fcntl" {
tmp.dir.deleteFile(test_out_file) catch {};
}
- // Note: The test assumes createFile opens the file with O_CLOEXEC
+ // Note: The test assumes createFile opens the file with O.CLOEXEC
{
- const flags = try os.fcntl(file.handle, os.F_GETFD, 0);
+ const flags = try os.fcntl(file.handle, os.F.GETFD, 0);
try expect((flags & os.FD_CLOEXEC) != 0);
}
{
- _ = try os.fcntl(file.handle, os.F_SETFD, 0);
- const flags = try os.fcntl(file.handle, os.F_GETFD, 0);
+ _ = try os.fcntl(file.handle, os.F.SETFD, 0);
+ const flags = try os.fcntl(file.handle, os.F.GETFD, 0);
try expect((flags & os.FD_CLOEXEC) == 0);
}
{
- _ = try os.fcntl(file.handle, os.F_SETFD, os.FD_CLOEXEC);
- const flags = try os.fcntl(file.handle, os.F_GETFD, 0);
+ _ = try os.fcntl(file.handle, os.F.SETFD, os.FD_CLOEXEC);
+ const flags = try os.fcntl(file.handle, os.F.GETFD, 0);
try expect((flags & os.FD_CLOEXEC) != 0);
}
}
@@ -676,7 +676,7 @@ test "fsync" {
}
test "getrlimit and setrlimit" {
- if (!@hasDecl(os, "rlimit")) {
+ if (!@hasDecl(os.system, "rlimit")) {
return error.SkipZigTest;
}
@@ -698,7 +698,7 @@ test "shutdown socket" {
std.os.windows.WSACleanup() catch unreachable;
}
}
- const sock = try os.socket(os.AF_INET, os.SOCK_STREAM, 0);
+ const sock = try os.socket(os.AF.INET, os.SOCK.STREAM, 0);
os.shutdown(sock, .both) catch |err| switch (err) {
error.SocketNotConnected => {},
else => |e| return e,
@@ -722,11 +722,11 @@ test "sigaction" {
// Check that we received the correct signal.
switch (native_os) {
.netbsd => {
- if (sig == os.SIGUSR1 and sig == info.info.signo)
+ if (sig == os.SIG.USR1 and sig == info.info.signo)
signal_test_failed = false;
},
else => {
- if (sig == os.SIGUSR1 and sig == info.signo)
+ if (sig == os.SIG.USR1 and sig == info.signo)
signal_test_failed = false;
},
}
@@ -736,21 +736,21 @@ test "sigaction" {
var sa = os.Sigaction{
.handler = .{ .sigaction = S.handler },
.mask = os.empty_sigset,
- .flags = os.SA_SIGINFO | os.SA_RESETHAND,
+ .flags = os.SA.SIGINFO | os.SA.RESETHAND,
};
var old_sa: os.Sigaction = undefined;
// Install the new signal handler.
- os.sigaction(os.SIGUSR1, &sa, null);
+ os.sigaction(os.SIG.USR1, &sa, null);
// Check that we can read it back correctly.
- os.sigaction(os.SIGUSR1, null, &old_sa);
+ os.sigaction(os.SIG.USR1, null, &old_sa);
try testing.expectEqual(S.handler, old_sa.handler.sigaction.?);
- try testing.expect((old_sa.flags & os.SA_SIGINFO) != 0);
+ try testing.expect((old_sa.flags & os.SA.SIGINFO) != 0);
// Invoke the handler.
- try os.raise(os.SIGUSR1);
+ try os.raise(os.SIG.USR1);
try testing.expect(signal_test_failed == false);
// Check if the handler has been correctly reset to SIG_DFL
- os.sigaction(os.SIGUSR1, null, &old_sa);
- try testing.expectEqual(os.SIG_DFL, old_sa.handler.sigaction);
+ os.sigaction(os.SIG.USR1, null, &old_sa);
+ try testing.expectEqual(os.SIG.DFL, old_sa.handler.sigaction);
}
test "dup & dup2" {
diff --git a/lib/std/os/wasi.zig b/lib/std/os/wasi.zig
index 708f445ee42b..029deca3fda6 100644
--- a/lib/std/os/wasi.zig
+++ b/lib/std/os/wasi.zig
@@ -4,8 +4,6 @@
const std = @import("std");
const assert = std.debug.assert;
-pub usingnamespace @import("bits.zig");
-
comptime {
assert(@alignOf(i8) == 1);
assert(@alignOf(u8) == 1);
@@ -17,8 +15,8 @@ comptime {
// assert(@alignOf(u64) == 8);
}
-pub const iovec_t = iovec;
-pub const ciovec_t = iovec_const;
+pub const iovec_t = std.os.iovec;
+pub const ciovec_t = std.os.iovec_const;
pub extern "wasi_snapshot_preview1" fn args_get(argv: [*][*:0]u8, argv_buf: [*]u8) errno_t;
pub extern "wasi_snapshot_preview1" fn args_sizes_get(argc: *usize, argv_buf_size: *usize) errno_t;
@@ -81,3 +79,481 @@ pub extern "wasi_snapshot_preview1" fn sock_shutdown(sock: fd_t, how: sdflags_t)
pub fn getErrno(r: errno_t) errno_t {
return r;
}
+
+pub const STDIN_FILENO = 0;
+pub const STDOUT_FILENO = 1;
+pub const STDERR_FILENO = 2;
+
+pub const mode_t = u32;
+
+pub const time_t = i64; // match https://github.com/CraneStation/wasi-libc
+
+pub const timespec = struct {
+ tv_sec: time_t,
+ tv_nsec: isize,
+
+ pub fn fromTimestamp(tm: timestamp_t) timespec {
+ const tv_sec: timestamp_t = tm / 1_000_000_000;
+ const tv_nsec = tm - tv_sec * 1_000_000_000;
+ return timespec{
+ .tv_sec = @intCast(time_t, tv_sec),
+ .tv_nsec = @intCast(isize, tv_nsec),
+ };
+ }
+
+ pub fn toTimestamp(ts: timespec) timestamp_t {
+ const tm = @intCast(timestamp_t, ts.tv_sec * 1_000_000_000) + @intCast(timestamp_t, ts.tv_nsec);
+ return tm;
+ }
+};
+
+pub const Stat = struct {
+ dev: device_t,
+ ino: inode_t,
+ mode: mode_t,
+ filetype: filetype_t,
+ nlink: linkcount_t,
+ size: filesize_t,
+ atim: timespec,
+ mtim: timespec,
+ ctim: timespec,
+
+ const Self = @This();
+
+ pub fn fromFilestat(stat: filestat_t) Self {
+ return Self{
+ .dev = stat.dev,
+ .ino = stat.ino,
+ .mode = 0,
+ .filetype = stat.filetype,
+ .nlink = stat.nlink,
+ .size = stat.size,
+ .atim = stat.atime(),
+ .mtim = stat.mtime(),
+ .ctim = stat.ctime(),
+ };
+ }
+
+ pub fn atime(self: Self) timespec {
+ return self.atim;
+ }
+
+ pub fn mtime(self: Self) timespec {
+ return self.mtim;
+ }
+
+ pub fn ctime(self: Self) timespec {
+ return self.ctim;
+ }
+};
+
+pub const IOV_MAX = 1024;
+
+pub const AT = struct {
+ pub const REMOVEDIR: u32 = 0x4;
+ pub const FDCWD: fd_t = -2;
+};
+
+// As defined in the wasi_snapshot_preview1 spec file:
+// https://github.com/WebAssembly/WASI/blob/master/phases/snapshot/witx/typenames.witx
+pub const advice_t = u8;
+pub const ADVICE_NORMAL: advice_t = 0;
+pub const ADVICE_SEQUENTIAL: advice_t = 1;
+pub const ADVICE_RANDOM: advice_t = 2;
+pub const ADVICE_WILLNEED: advice_t = 3;
+pub const ADVICE_DONTNEED: advice_t = 4;
+pub const ADVICE_NOREUSE: advice_t = 5;
+
+pub const clockid_t = u32;
+pub const CLOCK = struct {
+ pub const REALTIME: clockid_t = 0;
+ pub const MONOTONIC: clockid_t = 1;
+ pub const PROCESS_CPUTIME_ID: clockid_t = 2;
+ pub const THREAD_CPUTIME_ID: clockid_t = 3;
+};
+
+pub const device_t = u64;
+
+pub const dircookie_t = u64;
+pub const DIRCOOKIE_START: dircookie_t = 0;
+
+pub const dirnamlen_t = u32;
+
+pub const dirent_t = extern struct {
+ d_next: dircookie_t,
+ d_ino: inode_t,
+ d_namlen: dirnamlen_t,
+ d_type: filetype_t,
+};
+
+pub const errno_t = enum(u16) {
+ SUCCESS = 0,
+ @"2BIG" = 1,
+ ACCES = 2,
+ ADDRINUSE = 3,
+ ADDRNOTAVAIL = 4,
+ AFNOSUPPORT = 5,
+ /// This is also the error code used for `WOULDBLOCK`.
+ AGAIN = 6,
+ ALREADY = 7,
+ BADF = 8,
+ BADMSG = 9,
+ BUSY = 10,
+ CANCELED = 11,
+ CHILD = 12,
+ CONNABORTED = 13,
+ CONNREFUSED = 14,
+ CONNRESET = 15,
+ DEADLK = 16,
+ DESTADDRREQ = 17,
+ DOM = 18,
+ DQUOT = 19,
+ EXIST = 20,
+ FAULT = 21,
+ FBIG = 22,
+ HOSTUNREACH = 23,
+ IDRM = 24,
+ ILSEQ = 25,
+ INPROGRESS = 26,
+ INTR = 27,
+ INVAL = 28,
+ IO = 29,
+ ISCONN = 30,
+ ISDIR = 31,
+ LOOP = 32,
+ MFILE = 33,
+ MLINK = 34,
+ MSGSIZE = 35,
+ MULTIHOP = 36,
+ NAMETOOLONG = 37,
+ NETDOWN = 38,
+ NETRESET = 39,
+ NETUNREACH = 40,
+ NFILE = 41,
+ NOBUFS = 42,
+ NODEV = 43,
+ NOENT = 44,
+ NOEXEC = 45,
+ NOLCK = 46,
+ NOLINK = 47,
+ NOMEM = 48,
+ NOMSG = 49,
+ NOPROTOOPT = 50,
+ NOSPC = 51,
+ NOSYS = 52,
+ NOTCONN = 53,
+ NOTDIR = 54,
+ NOTEMPTY = 55,
+ NOTRECOVERABLE = 56,
+ NOTSOCK = 57,
+ /// This is also the code used for `NOTSUP`.
+ OPNOTSUPP = 58,
+ NOTTY = 59,
+ NXIO = 60,
+ OVERFLOW = 61,
+ OWNERDEAD = 62,
+ PERM = 63,
+ PIPE = 64,
+ PROTO = 65,
+ PROTONOSUPPORT = 66,
+ PROTOTYPE = 67,
+ RANGE = 68,
+ ROFS = 69,
+ SPIPE = 70,
+ SRCH = 71,
+ STALE = 72,
+ TIMEDOUT = 73,
+ TXTBSY = 74,
+ XDEV = 75,
+ NOTCAPABLE = 76,
+ _,
+};
+pub const E = errno_t;
+
+pub const event_t = extern struct {
+ userdata: userdata_t,
+ @"error": errno_t,
+ @"type": eventtype_t,
+ fd_readwrite: eventfdreadwrite_t,
+};
+
+pub const eventfdreadwrite_t = extern struct {
+ nbytes: filesize_t,
+ flags: eventrwflags_t,
+};
+
+pub const eventrwflags_t = u16;
+pub const EVENT_FD_READWRITE_HANGUP: eventrwflags_t = 0x0001;
+
+pub const eventtype_t = u8;
+pub const EVENTTYPE_CLOCK: eventtype_t = 0;
+pub const EVENTTYPE_FD_READ: eventtype_t = 1;
+pub const EVENTTYPE_FD_WRITE: eventtype_t = 2;
+
+pub const exitcode_t = u32;
+
+pub const fd_t = i32;
+
+pub const fdflags_t = u16;
+pub const FDFLAG = struct {
+ pub const APPEND: fdflags_t = 0x0001;
+ pub const DSYNC: fdflags_t = 0x0002;
+ pub const NONBLOCK: fdflags_t = 0x0004;
+ pub const RSYNC: fdflags_t = 0x0008;
+ pub const SYNC: fdflags_t = 0x0010;
+};
+
+pub const fdstat_t = extern struct {
+ fs_filetype: filetype_t,
+ fs_flags: fdflags_t,
+ fs_rights_base: rights_t,
+ fs_rights_inheriting: rights_t,
+};
+
+pub const filedelta_t = i64;
+
+pub const filesize_t = u64;
+
+pub const filestat_t = extern struct {
+ dev: device_t,
+ ino: inode_t,
+ filetype: filetype_t,
+ nlink: linkcount_t,
+ size: filesize_t,
+ atim: timestamp_t,
+ mtim: timestamp_t,
+ ctim: timestamp_t,
+
+ pub fn atime(self: filestat_t) timespec {
+ return timespec.fromTimestamp(self.atim);
+ }
+
+ pub fn mtime(self: filestat_t) timespec {
+ return timespec.fromTimestamp(self.mtim);
+ }
+
+ pub fn ctime(self: filestat_t) timespec {
+ return timespec.fromTimestamp(self.ctim);
+ }
+};
+
+/// Also known as `FILETYPE`.
+pub const filetype_t = enum(u8) {
+ UNKNOWN,
+ BLOCK_DEVICE,
+ CHARACTER_DEVICE,
+ DIRECTORY,
+ REGULAR_FILE,
+ SOCKET_DGRAM,
+ SOCKET_STREAM,
+ SYMBOLIC_LINK,
+ _,
+};
+
+pub const fstflags_t = u16;
+pub const FILESTAT_SET_ATIM: fstflags_t = 0x0001;
+pub const FILESTAT_SET_ATIM_NOW: fstflags_t = 0x0002;
+pub const FILESTAT_SET_MTIM: fstflags_t = 0x0004;
+pub const FILESTAT_SET_MTIM_NOW: fstflags_t = 0x0008;
+
+pub const inode_t = u64;
+pub const ino_t = inode_t;
+
+pub const linkcount_t = u64;
+
+pub const lookupflags_t = u32;
+pub const LOOKUP_SYMLINK_FOLLOW: lookupflags_t = 0x00000001;
+
+pub const oflags_t = u16;
+pub const O = struct {
+ pub const CREAT: oflags_t = 0x0001;
+ pub const DIRECTORY: oflags_t = 0x0002;
+ pub const EXCL: oflags_t = 0x0004;
+ pub const TRUNC: oflags_t = 0x0008;
+};
+
+pub const preopentype_t = u8;
+pub const PREOPENTYPE_DIR: preopentype_t = 0;
+
+pub const prestat_t = extern struct {
+ pr_type: preopentype_t,
+ u: prestat_u_t,
+};
+
+pub const prestat_dir_t = extern struct {
+ pr_name_len: usize,
+};
+
+pub const prestat_u_t = extern union {
+ dir: prestat_dir_t,
+};
+
+pub const riflags_t = u16;
+pub const roflags_t = u16;
+
+pub const SOCK = struct {
+ pub const RECV_PEEK: riflags_t = 0x0001;
+ pub const RECV_WAITALL: riflags_t = 0x0002;
+
+ pub const RECV_DATA_TRUNCATED: roflags_t = 0x0001;
+};
+
+pub const rights_t = u64;
+pub const RIGHT = struct {
+ pub const FD_DATASYNC: rights_t = 0x0000000000000001;
+ pub const FD_READ: rights_t = 0x0000000000000002;
+ pub const FD_SEEK: rights_t = 0x0000000000000004;
+ pub const FD_FDSTAT_SET_FLAGS: rights_t = 0x0000000000000008;
+ pub const FD_SYNC: rights_t = 0x0000000000000010;
+ pub const FD_TELL: rights_t = 0x0000000000000020;
+ pub const FD_WRITE: rights_t = 0x0000000000000040;
+ pub const FD_ADVISE: rights_t = 0x0000000000000080;
+ pub const FD_ALLOCATE: rights_t = 0x0000000000000100;
+ pub const PATH_CREATE_DIRECTORY: rights_t = 0x0000000000000200;
+ pub const PATH_CREATE_FILE: rights_t = 0x0000000000000400;
+ pub const PATH_LINK_SOURCE: rights_t = 0x0000000000000800;
+ pub const PATH_LINK_TARGET: rights_t = 0x0000000000001000;
+ pub const PATH_OPEN: rights_t = 0x0000000000002000;
+ pub const FD_READDIR: rights_t = 0x0000000000004000;
+ pub const PATH_READLINK: rights_t = 0x0000000000008000;
+ pub const PATH_RENAME_SOURCE: rights_t = 0x0000000000010000;
+ pub const PATH_RENAME_TARGET: rights_t = 0x0000000000020000;
+ pub const PATH_FILESTAT_GET: rights_t = 0x0000000000040000;
+ pub const PATH_FILESTAT_SET_SIZE: rights_t = 0x0000000000080000;
+ pub const PATH_FILESTAT_SET_TIMES: rights_t = 0x0000000000100000;
+ pub const FD_FILESTAT_GET: rights_t = 0x0000000000200000;
+ pub const FD_FILESTAT_SET_SIZE: rights_t = 0x0000000000400000;
+ pub const FD_FILESTAT_SET_TIMES: rights_t = 0x0000000000800000;
+ pub const PATH_SYMLINK: rights_t = 0x0000000001000000;
+ pub const PATH_REMOVE_DIRECTORY: rights_t = 0x0000000002000000;
+ pub const PATH_UNLINK_FILE: rights_t = 0x0000000004000000;
+ pub const POLL_FD_READWRITE: rights_t = 0x0000000008000000;
+ pub const SOCK_SHUTDOWN: rights_t = 0x0000000010000000;
+ pub const ALL: rights_t = FD_DATASYNC |
+ FD_READ |
+ FD_SEEK |
+ FD_FDSTAT_SET_FLAGS |
+ FD_SYNC |
+ FD_TELL |
+ FD_WRITE |
+ FD_ADVISE |
+ FD_ALLOCATE |
+ PATH_CREATE_DIRECTORY |
+ PATH_CREATE_FILE |
+ PATH_LINK_SOURCE |
+ PATH_LINK_TARGET |
+ PATH_OPEN |
+ FD_READDIR |
+ PATH_READLINK |
+ PATH_RENAME_SOURCE |
+ PATH_RENAME_TARGET |
+ PATH_FILESTAT_GET |
+ PATH_FILESTAT_SET_SIZE |
+ PATH_FILESTAT_SET_TIMES |
+ FD_FILESTAT_GET |
+ FD_FILESTAT_SET_SIZE |
+ FD_FILESTAT_SET_TIMES |
+ PATH_SYMLINK |
+ PATH_REMOVE_DIRECTORY |
+ PATH_UNLINK_FILE |
+ POLL_FD_READWRITE |
+ SOCK_SHUTDOWN;
+};
+
+pub const sdflags_t = u8;
+pub const SHUT = struct {
+ pub const RD: sdflags_t = 0x01;
+ pub const WR: sdflags_t = 0x02;
+};
+
+pub const siflags_t = u16;
+
+pub const signal_t = u8;
+pub const SIGNONE: signal_t = 0;
+pub const SIGHUP: signal_t = 1;
+pub const SIGINT: signal_t = 2;
+pub const SIGQUIT: signal_t = 3;
+pub const SIGILL: signal_t = 4;
+pub const SIGTRAP: signal_t = 5;
+pub const SIGABRT: signal_t = 6;
+pub const SIGBUS: signal_t = 7;
+pub const SIGFPE: signal_t = 8;
+pub const SIGKILL: signal_t = 9;
+pub const SIGUSR1: signal_t = 10;
+pub const SIGSEGV: signal_t = 11;
+pub const SIGUSR2: signal_t = 12;
+pub const SIGPIPE: signal_t = 13;
+pub const SIGALRM: signal_t = 14;
+pub const SIGTERM: signal_t = 15;
+pub const SIGCHLD: signal_t = 16;
+pub const SIGCONT: signal_t = 17;
+pub const SIGSTOP: signal_t = 18;
+pub const SIGTSTP: signal_t = 19;
+pub const SIGTTIN: signal_t = 20;
+pub const SIGTTOU: signal_t = 21;
+pub const SIGURG: signal_t = 22;
+pub const SIGXCPU: signal_t = 23;
+pub const SIGXFSZ: signal_t = 24;
+pub const SIGVTALRM: signal_t = 25;
+pub const SIGPROF: signal_t = 26;
+pub const SIGWINCH: signal_t = 27;
+pub const SIGPOLL: signal_t = 28;
+pub const SIGPWR: signal_t = 29;
+pub const SIGSYS: signal_t = 30;
+
+pub const subclockflags_t = u16;
+pub const SUBSCRIPTION_CLOCK_ABSTIME: subclockflags_t = 0x0001;
+
+pub const subscription_t = extern struct {
+ userdata: userdata_t,
+ u: subscription_u_t,
+};
+
+pub const subscription_clock_t = extern struct {
+ id: clockid_t,
+ timeout: timestamp_t,
+ precision: timestamp_t,
+ flags: subclockflags_t,
+};
+
+pub const subscription_fd_readwrite_t = extern struct {
+ fd: fd_t,
+};
+
+pub const subscription_u_t = extern struct {
+ tag: eventtype_t,
+ u: subscription_u_u_t,
+};
+
+pub const subscription_u_u_t = extern union {
+ clock: subscription_clock_t,
+ fd_read: subscription_fd_readwrite_t,
+ fd_write: subscription_fd_readwrite_t,
+};
+
+pub const timestamp_t = u64;
+
+pub const userdata_t = u64;
+
+/// Also known as `WHENCE`.
+pub const whence_t = enum(u8) { SET, CUR, END };
+
+pub const S = struct {
+ pub const IEXEC = @compileError("TODO audit this");
+ pub const IFBLK = 0x6000;
+ pub const IFCHR = 0x2000;
+ pub const IFDIR = 0x4000;
+ pub const IFIFO = 0xc000;
+ pub const IFLNK = 0xa000;
+ pub const IFMT = IFBLK | IFCHR | IFDIR | IFIFO | IFLNK | IFREG | IFSOCK;
+ pub const IFREG = 0x8000;
+ // There's no concept of UNIX domain socket but we define this value here in order to line with other OSes.
+ pub const IFSOCK = 0x1;
+};
+
+pub const LOCK = struct {
+ pub const SH = 0x1;
+ pub const EX = 0x2;
+ pub const NB = 0x4;
+ pub const UN = 0x8;
+};
diff --git a/lib/std/os/windows.zig b/lib/std/os/windows.zig
index cef4628eddd3..3b1394202fc9 100644
--- a/lib/std/os/windows.zig
+++ b/lib/std/os/windows.zig
@@ -1,8 +1,8 @@
-// This file contains thin wrappers around Windows-specific APIs, with these
-// specific goals in mind:
-// * Convert "errno"-style error codes into Zig errors.
-// * When null-terminated or UTF16LE byte buffers are required, provide APIs which accept
-// slices as well as APIs which accept null-terminated UTF16LE byte buffers.
+//! This file contains thin wrappers around Windows-specific APIs, with these
+//! specific goals in mind:
+//! * Convert "errno"-style error codes into Zig errors.
+//! * When null-terminated or UTF16LE byte buffers are required, provide APIs which accept
+//! slices as well as APIs which accept null-terminated UTF16LE byte buffers.
const builtin = @import("builtin");
const std = @import("../std.zig");
@@ -10,6 +10,13 @@ const mem = std.mem;
const assert = std.debug.assert;
const math = std.math;
const maxInt = std.math.maxInt;
+const native_arch = builtin.cpu.arch;
+
+test {
+ if (builtin.os.tag == .windows) {
+ _ = @import("windows/test.zig");
+ }
+}
pub const advapi32 = @import("windows/advapi32.zig");
pub const kernel32 = @import("windows/kernel32.zig");
@@ -22,8 +29,6 @@ pub const ws2_32 = @import("windows/ws2_32.zig");
pub const gdi32 = @import("windows/gdi32.zig");
pub const winmm = @import("windows/winmm.zig");
-pub usingnamespace @import("windows/bits.zig");
-
pub const self_process_handle = @intToPtr(HANDLE, maxInt(usize));
pub const OpenError = error{
@@ -1017,7 +1022,7 @@ pub fn QueryObjectName(
}
}
test "QueryObjectName" {
- if (comptime builtin.target.os.tag != .windows)
+ if (builtin.os.tag != .windows)
return;
//any file will do; canonicalization works on NTFS junctions and symlinks, hardlinks remain separate paths.
@@ -1171,7 +1176,7 @@ pub fn GetFinalPathNameByHandle(
}
test "GetFinalPathNameByHandle" {
- if (comptime builtin.target.os.tag != .windows)
+ if (builtin.os.tag != .windows)
return;
//any file will do
@@ -1720,7 +1725,7 @@ pub fn UnlockFile(
}
pub fn teb() *TEB {
- return switch (builtin.target.cpu.arch) {
+ return switch (native_arch) {
.i386 => asm volatile (
\\ movl %%fs:0x18, %[ptr]
: [ptr] "=r" (-> *TEB),
@@ -2025,8 +2030,1633 @@ pub fn GetThreadDescription(hThread: HANDLE, ppszThreadDescription: *LPWSTR) !vo
}
}
-test "" {
- if (builtin.os.tag == .windows) {
- _ = @import("windows/test.zig");
- }
+pub const Win32Error = @import("windows/win32error.zig").Win32Error;
+pub const NTSTATUS = @import("windows/ntstatus.zig").NTSTATUS;
+pub const LANG = @import("windows/lang.zig");
+pub const SUBLANG = @import("windows/sublang.zig");
+
+/// The standard input device. Initially, this is the console input buffer, CONIN$.
+pub const STD_INPUT_HANDLE = maxInt(DWORD) - 10 + 1;
+
+/// The standard output device. Initially, this is the active console screen buffer, CONOUT$.
+pub const STD_OUTPUT_HANDLE = maxInt(DWORD) - 11 + 1;
+
+/// The standard error device. Initially, this is the active console screen buffer, CONOUT$.
+pub const STD_ERROR_HANDLE = maxInt(DWORD) - 12 + 1;
+
+pub const WINAPI: std.builtin.CallingConvention = if (native_arch == .i386)
+ .Stdcall
+else
+ .C;
+
+pub const BOOL = c_int;
+pub const BOOLEAN = BYTE;
+pub const BYTE = u8;
+pub const CHAR = u8;
+pub const UCHAR = u8;
+pub const FLOAT = f32;
+pub const HANDLE = *c_void;
+pub const HCRYPTPROV = ULONG_PTR;
+pub const ATOM = u16;
+pub const HBRUSH = *opaque {};
+pub const HCURSOR = *opaque {};
+pub const HICON = *opaque {};
+pub const HINSTANCE = *opaque {};
+pub const HMENU = *opaque {};
+pub const HMODULE = *opaque {};
+pub const HWND = *opaque {};
+pub const HDC = *opaque {};
+pub const HGLRC = *opaque {};
+pub const FARPROC = *opaque {};
+pub const INT = c_int;
+pub const LPCSTR = [*:0]const CHAR;
+pub const LPCVOID = *const c_void;
+pub const LPSTR = [*:0]CHAR;
+pub const LPVOID = *c_void;
+pub const LPWSTR = [*:0]WCHAR;
+pub const LPCWSTR = [*:0]const WCHAR;
+pub const PVOID = *c_void;
+pub const PWSTR = [*:0]WCHAR;
+pub const SIZE_T = usize;
+pub const UINT = c_uint;
+pub const ULONG_PTR = usize;
+pub const LONG_PTR = isize;
+pub const DWORD_PTR = ULONG_PTR;
+pub const WCHAR = u16;
+pub const WORD = u16;
+pub const DWORD = u32;
+pub const DWORD64 = u64;
+pub const LARGE_INTEGER = i64;
+pub const ULARGE_INTEGER = u64;
+pub const USHORT = u16;
+pub const SHORT = i16;
+pub const ULONG = u32;
+pub const LONG = i32;
+pub const ULONGLONG = u64;
+pub const LONGLONG = i64;
+pub const HLOCAL = HANDLE;
+pub const LANGID = c_ushort;
+
+pub const WPARAM = usize;
+pub const LPARAM = LONG_PTR;
+pub const LRESULT = LONG_PTR;
+
+pub const va_list = *opaque {};
+
+pub const TRUE = 1;
+pub const FALSE = 0;
+
+pub const DEVICE_TYPE = ULONG;
+pub const FILE_DEVICE_BEEP: DEVICE_TYPE = 0x0001;
+pub const FILE_DEVICE_CD_ROM: DEVICE_TYPE = 0x0002;
+pub const FILE_DEVICE_CD_ROM_FILE_SYSTEM: DEVICE_TYPE = 0x0003;
+pub const FILE_DEVICE_CONTROLLER: DEVICE_TYPE = 0x0004;
+pub const FILE_DEVICE_DATALINK: DEVICE_TYPE = 0x0005;
+pub const FILE_DEVICE_DFS: DEVICE_TYPE = 0x0006;
+pub const FILE_DEVICE_DISK: DEVICE_TYPE = 0x0007;
+pub const FILE_DEVICE_DISK_FILE_SYSTEM: DEVICE_TYPE = 0x0008;
+pub const FILE_DEVICE_FILE_SYSTEM: DEVICE_TYPE = 0x0009;
+pub const FILE_DEVICE_INPORT_PORT: DEVICE_TYPE = 0x000a;
+pub const FILE_DEVICE_KEYBOARD: DEVICE_TYPE = 0x000b;
+pub const FILE_DEVICE_MAILSLOT: DEVICE_TYPE = 0x000c;
+pub const FILE_DEVICE_MIDI_IN: DEVICE_TYPE = 0x000d;
+pub const FILE_DEVICE_MIDI_OUT: DEVICE_TYPE = 0x000e;
+pub const FILE_DEVICE_MOUSE: DEVICE_TYPE = 0x000f;
+pub const FILE_DEVICE_MULTI_UNC_PROVIDER: DEVICE_TYPE = 0x0010;
+pub const FILE_DEVICE_NAMED_PIPE: DEVICE_TYPE = 0x0011;
+pub const FILE_DEVICE_NETWORK: DEVICE_TYPE = 0x0012;
+pub const FILE_DEVICE_NETWORK_BROWSER: DEVICE_TYPE = 0x0013;
+pub const FILE_DEVICE_NETWORK_FILE_SYSTEM: DEVICE_TYPE = 0x0014;
+pub const FILE_DEVICE_NULL: DEVICE_TYPE = 0x0015;
+pub const FILE_DEVICE_PARALLEL_PORT: DEVICE_TYPE = 0x0016;
+pub const FILE_DEVICE_PHYSICAL_NETCARD: DEVICE_TYPE = 0x0017;
+pub const FILE_DEVICE_PRINTER: DEVICE_TYPE = 0x0018;
+pub const FILE_DEVICE_SCANNER: DEVICE_TYPE = 0x0019;
+pub const FILE_DEVICE_SERIAL_MOUSE_PORT: DEVICE_TYPE = 0x001a;
+pub const FILE_DEVICE_SERIAL_PORT: DEVICE_TYPE = 0x001b;
+pub const FILE_DEVICE_SCREEN: DEVICE_TYPE = 0x001c;
+pub const FILE_DEVICE_SOUND: DEVICE_TYPE = 0x001d;
+pub const FILE_DEVICE_STREAMS: DEVICE_TYPE = 0x001e;
+pub const FILE_DEVICE_TAPE: DEVICE_TYPE = 0x001f;
+pub const FILE_DEVICE_TAPE_FILE_SYSTEM: DEVICE_TYPE = 0x0020;
+pub const FILE_DEVICE_TRANSPORT: DEVICE_TYPE = 0x0021;
+pub const FILE_DEVICE_UNKNOWN: DEVICE_TYPE = 0x0022;
+pub const FILE_DEVICE_VIDEO: DEVICE_TYPE = 0x0023;
+pub const FILE_DEVICE_VIRTUAL_DISK: DEVICE_TYPE = 0x0024;
+pub const FILE_DEVICE_WAVE_IN: DEVICE_TYPE = 0x0025;
+pub const FILE_DEVICE_WAVE_OUT: DEVICE_TYPE = 0x0026;
+pub const FILE_DEVICE_8042_PORT: DEVICE_TYPE = 0x0027;
+pub const FILE_DEVICE_NETWORK_REDIRECTOR: DEVICE_TYPE = 0x0028;
+pub const FILE_DEVICE_BATTERY: DEVICE_TYPE = 0x0029;
+pub const FILE_DEVICE_BUS_EXTENDER: DEVICE_TYPE = 0x002a;
+pub const FILE_DEVICE_MODEM: DEVICE_TYPE = 0x002b;
+pub const FILE_DEVICE_VDM: DEVICE_TYPE = 0x002c;
+pub const FILE_DEVICE_MASS_STORAGE: DEVICE_TYPE = 0x002d;
+pub const FILE_DEVICE_SMB: DEVICE_TYPE = 0x002e;
+pub const FILE_DEVICE_KS: DEVICE_TYPE = 0x002f;
+pub const FILE_DEVICE_CHANGER: DEVICE_TYPE = 0x0030;
+pub const FILE_DEVICE_SMARTCARD: DEVICE_TYPE = 0x0031;
+pub const FILE_DEVICE_ACPI: DEVICE_TYPE = 0x0032;
+pub const FILE_DEVICE_DVD: DEVICE_TYPE = 0x0033;
+pub const FILE_DEVICE_FULLSCREEN_VIDEO: DEVICE_TYPE = 0x0034;
+pub const FILE_DEVICE_DFS_FILE_SYSTEM: DEVICE_TYPE = 0x0035;
+pub const FILE_DEVICE_DFS_VOLUME: DEVICE_TYPE = 0x0036;
+pub const FILE_DEVICE_SERENUM: DEVICE_TYPE = 0x0037;
+pub const FILE_DEVICE_TERMSRV: DEVICE_TYPE = 0x0038;
+pub const FILE_DEVICE_KSEC: DEVICE_TYPE = 0x0039;
+pub const FILE_DEVICE_FIPS: DEVICE_TYPE = 0x003a;
+pub const FILE_DEVICE_INFINIBAND: DEVICE_TYPE = 0x003b;
+// TODO: missing values?
+pub const FILE_DEVICE_VMBUS: DEVICE_TYPE = 0x003e;
+pub const FILE_DEVICE_CRYPT_PROVIDER: DEVICE_TYPE = 0x003f;
+pub const FILE_DEVICE_WPD: DEVICE_TYPE = 0x0040;
+pub const FILE_DEVICE_BLUETOOTH: DEVICE_TYPE = 0x0041;
+pub const FILE_DEVICE_MT_COMPOSITE: DEVICE_TYPE = 0x0042;
+pub const FILE_DEVICE_MT_TRANSPORT: DEVICE_TYPE = 0x0043;
+pub const FILE_DEVICE_BIOMETRIC: DEVICE_TYPE = 0x0044;
+pub const FILE_DEVICE_PMI: DEVICE_TYPE = 0x0045;
+pub const FILE_DEVICE_EHSTOR: DEVICE_TYPE = 0x0046;
+pub const FILE_DEVICE_DEVAPI: DEVICE_TYPE = 0x0047;
+pub const FILE_DEVICE_GPIO: DEVICE_TYPE = 0x0048;
+pub const FILE_DEVICE_USBEX: DEVICE_TYPE = 0x0049;
+pub const FILE_DEVICE_CONSOLE: DEVICE_TYPE = 0x0050;
+pub const FILE_DEVICE_NFP: DEVICE_TYPE = 0x0051;
+pub const FILE_DEVICE_SYSENV: DEVICE_TYPE = 0x0052;
+pub const FILE_DEVICE_VIRTUAL_BLOCK: DEVICE_TYPE = 0x0053;
+pub const FILE_DEVICE_POINT_OF_SERVICE: DEVICE_TYPE = 0x0054;
+pub const FILE_DEVICE_STORAGE_REPLICATION: DEVICE_TYPE = 0x0055;
+pub const FILE_DEVICE_TRUST_ENV: DEVICE_TYPE = 0x0056;
+pub const FILE_DEVICE_UCM: DEVICE_TYPE = 0x0057;
+pub const FILE_DEVICE_UCMTCPCI: DEVICE_TYPE = 0x0058;
+pub const FILE_DEVICE_PERSISTENT_MEMORY: DEVICE_TYPE = 0x0059;
+pub const FILE_DEVICE_NVDIMM: DEVICE_TYPE = 0x005a;
+pub const FILE_DEVICE_HOLOGRAPHIC: DEVICE_TYPE = 0x005b;
+pub const FILE_DEVICE_SDFXHCI: DEVICE_TYPE = 0x005c;
+
+/// https://docs.microsoft.com/en-us/windows-hardware/drivers/kernel/buffer-descriptions-for-i-o-control-codes
+pub const TransferType = enum(u2) {
+ METHOD_BUFFERED = 0,
+ METHOD_IN_DIRECT = 1,
+ METHOD_OUT_DIRECT = 2,
+ METHOD_NEITHER = 3,
+};
+
+pub const FILE_ANY_ACCESS = 0;
+pub const FILE_READ_ACCESS = 1;
+pub const FILE_WRITE_ACCESS = 2;
+
+/// https://docs.microsoft.com/en-us/windows-hardware/drivers/kernel/defining-i-o-control-codes
+pub fn CTL_CODE(deviceType: u16, function: u12, method: TransferType, access: u2) DWORD {
+ return (@as(DWORD, deviceType) << 16) |
+ (@as(DWORD, access) << 14) |
+ (@as(DWORD, function) << 2) |
+ @enumToInt(method);
}
+
+pub const INVALID_HANDLE_VALUE = @intToPtr(HANDLE, maxInt(usize));
+
+pub const INVALID_FILE_ATTRIBUTES = @as(DWORD, maxInt(DWORD));
+
+pub const FILE_ALL_INFORMATION = extern struct {
+ BasicInformation: FILE_BASIC_INFORMATION,
+ StandardInformation: FILE_STANDARD_INFORMATION,
+ InternalInformation: FILE_INTERNAL_INFORMATION,
+ EaInformation: FILE_EA_INFORMATION,
+ AccessInformation: FILE_ACCESS_INFORMATION,
+ PositionInformation: FILE_POSITION_INFORMATION,
+ ModeInformation: FILE_MODE_INFORMATION,
+ AlignmentInformation: FILE_ALIGNMENT_INFORMATION,
+ NameInformation: FILE_NAME_INFORMATION,
+};
+
+pub const FILE_BASIC_INFORMATION = extern struct {
+ CreationTime: LARGE_INTEGER,
+ LastAccessTime: LARGE_INTEGER,
+ LastWriteTime: LARGE_INTEGER,
+ ChangeTime: LARGE_INTEGER,
+ FileAttributes: ULONG,
+};
+
+pub const FILE_STANDARD_INFORMATION = extern struct {
+ AllocationSize: LARGE_INTEGER,
+ EndOfFile: LARGE_INTEGER,
+ NumberOfLinks: ULONG,
+ DeletePending: BOOLEAN,
+ Directory: BOOLEAN,
+};
+
+pub const FILE_INTERNAL_INFORMATION = extern struct {
+ IndexNumber: LARGE_INTEGER,
+};
+
+pub const FILE_EA_INFORMATION = extern struct {
+ EaSize: ULONG,
+};
+
+pub const FILE_ACCESS_INFORMATION = extern struct {
+ AccessFlags: ACCESS_MASK,
+};
+
+pub const FILE_POSITION_INFORMATION = extern struct {
+ CurrentByteOffset: LARGE_INTEGER,
+};
+
+pub const FILE_END_OF_FILE_INFORMATION = extern struct {
+ EndOfFile: LARGE_INTEGER,
+};
+
+pub const FILE_MODE_INFORMATION = extern struct {
+ Mode: ULONG,
+};
+
+pub const FILE_ALIGNMENT_INFORMATION = extern struct {
+ AlignmentRequirement: ULONG,
+};
+
+pub const FILE_NAME_INFORMATION = extern struct {
+ FileNameLength: ULONG,
+ FileName: [1]WCHAR,
+};
+
+pub const FILE_RENAME_INFORMATION = extern struct {
+ ReplaceIfExists: BOOLEAN,
+ RootDirectory: ?HANDLE,
+ FileNameLength: ULONG,
+ FileName: [1]WCHAR,
+};
+
+pub const IO_STATUS_BLOCK = extern struct {
+ // "DUMMYUNIONNAME" expands to "u"
+ u: extern union {
+ Status: NTSTATUS,
+ Pointer: ?*c_void,
+ },
+ Information: ULONG_PTR,
+};
+
+pub const FILE_INFORMATION_CLASS = enum(c_int) {
+ FileDirectoryInformation = 1,
+ FileFullDirectoryInformation,
+ FileBothDirectoryInformation,
+ FileBasicInformation,
+ FileStandardInformation,
+ FileInternalInformation,
+ FileEaInformation,
+ FileAccessInformation,
+ FileNameInformation,
+ FileRenameInformation,
+ FileLinkInformation,
+ FileNamesInformation,
+ FileDispositionInformation,
+ FilePositionInformation,
+ FileFullEaInformation,
+ FileModeInformation,
+ FileAlignmentInformation,
+ FileAllInformation,
+ FileAllocationInformation,
+ FileEndOfFileInformation,
+ FileAlternateNameInformation,
+ FileStreamInformation,
+ FilePipeInformation,
+ FilePipeLocalInformation,
+ FilePipeRemoteInformation,
+ FileMailslotQueryInformation,
+ FileMailslotSetInformation,
+ FileCompressionInformation,
+ FileObjectIdInformation,
+ FileCompletionInformation,
+ FileMoveClusterInformation,
+ FileQuotaInformation,
+ FileReparsePointInformation,
+ FileNetworkOpenInformation,
+ FileAttributeTagInformation,
+ FileTrackingInformation,
+ FileIdBothDirectoryInformation,
+ FileIdFullDirectoryInformation,
+ FileValidDataLengthInformation,
+ FileShortNameInformation,
+ FileIoCompletionNotificationInformation,
+ FileIoStatusBlockRangeInformation,
+ FileIoPriorityHintInformation,
+ FileSfioReserveInformation,
+ FileSfioVolumeInformation,
+ FileHardLinkInformation,
+ FileProcessIdsUsingFileInformation,
+ FileNormalizedNameInformation,
+ FileNetworkPhysicalNameInformation,
+ FileIdGlobalTxDirectoryInformation,
+ FileIsRemoteDeviceInformation,
+ FileUnusedInformation,
+ FileNumaNodeInformation,
+ FileStandardLinkInformation,
+ FileRemoteProtocolInformation,
+ FileRenameInformationBypassAccessCheck,
+ FileLinkInformationBypassAccessCheck,
+ FileVolumeNameInformation,
+ FileIdInformation,
+ FileIdExtdDirectoryInformation,
+ FileReplaceCompletionInformation,
+ FileHardLinkFullIdInformation,
+ FileIdExtdBothDirectoryInformation,
+ FileDispositionInformationEx,
+ FileRenameInformationEx,
+ FileRenameInformationExBypassAccessCheck,
+ FileDesiredStorageClassInformation,
+ FileStatInformation,
+ FileMemoryPartitionInformation,
+ FileStatLxInformation,
+ FileCaseSensitiveInformation,
+ FileLinkInformationEx,
+ FileLinkInformationExBypassAccessCheck,
+ FileStorageReserveIdInformation,
+ FileCaseSensitiveInformationForceAccessCheck,
+ FileMaximumInformation,
+};
+
+pub const OVERLAPPED = extern struct {
+ Internal: ULONG_PTR,
+ InternalHigh: ULONG_PTR,
+ DUMMYUNIONNAME: extern union {
+ DUMMYSTRUCTNAME: extern struct {
+ Offset: DWORD,
+ OffsetHigh: DWORD,
+ },
+ Pointer: ?PVOID,
+ },
+ hEvent: ?HANDLE,
+};
+
+pub const OVERLAPPED_ENTRY = extern struct {
+ lpCompletionKey: ULONG_PTR,
+ lpOverlapped: *OVERLAPPED,
+ Internal: ULONG_PTR,
+ dwNumberOfBytesTransferred: DWORD,
+};
+
+pub const MAX_PATH = 260;
+
+// TODO issue #305
+pub const FILE_INFO_BY_HANDLE_CLASS = u32;
+pub const FileBasicInfo = 0;
+pub const FileStandardInfo = 1;
+pub const FileNameInfo = 2;
+pub const FileRenameInfo = 3;
+pub const FileDispositionInfo = 4;
+pub const FileAllocationInfo = 5;
+pub const FileEndOfFileInfo = 6;
+pub const FileStreamInfo = 7;
+pub const FileCompressionInfo = 8;
+pub const FileAttributeTagInfo = 9;
+pub const FileIdBothDirectoryInfo = 10;
+pub const FileIdBothDirectoryRestartInfo = 11;
+pub const FileIoPriorityHintInfo = 12;
+pub const FileRemoteProtocolInfo = 13;
+pub const FileFullDirectoryInfo = 14;
+pub const FileFullDirectoryRestartInfo = 15;
+pub const FileStorageInfo = 16;
+pub const FileAlignmentInfo = 17;
+pub const FileIdInfo = 18;
+pub const FileIdExtdDirectoryInfo = 19;
+pub const FileIdExtdDirectoryRestartInfo = 20;
+
+pub const BY_HANDLE_FILE_INFORMATION = extern struct {
+ dwFileAttributes: DWORD,
+ ftCreationTime: FILETIME,
+ ftLastAccessTime: FILETIME,
+ ftLastWriteTime: FILETIME,
+ dwVolumeSerialNumber: DWORD,
+ nFileSizeHigh: DWORD,
+ nFileSizeLow: DWORD,
+ nNumberOfLinks: DWORD,
+ nFileIndexHigh: DWORD,
+ nFileIndexLow: DWORD,
+};
+
+pub const FILE_NAME_INFO = extern struct {
+ FileNameLength: DWORD,
+ FileName: [1]WCHAR,
+};
+
+/// Return the normalized drive name. This is the default.
+pub const FILE_NAME_NORMALIZED = 0x0;
+
+/// Return the opened file name (not normalized).
+pub const FILE_NAME_OPENED = 0x8;
+
+/// Return the path with the drive letter. This is the default.
+pub const VOLUME_NAME_DOS = 0x0;
+
+/// Return the path with a volume GUID path instead of the drive name.
+pub const VOLUME_NAME_GUID = 0x1;
+
+/// Return the path with no drive information.
+pub const VOLUME_NAME_NONE = 0x4;
+
+/// Return the path with the volume device path.
+pub const VOLUME_NAME_NT = 0x2;
+
+pub const SECURITY_ATTRIBUTES = extern struct {
+ nLength: DWORD,
+ lpSecurityDescriptor: ?*c_void,
+ bInheritHandle: BOOL,
+};
+
+pub const PIPE_ACCESS_INBOUND = 0x00000001;
+pub const PIPE_ACCESS_OUTBOUND = 0x00000002;
+pub const PIPE_ACCESS_DUPLEX = 0x00000003;
+
+pub const PIPE_TYPE_BYTE = 0x00000000;
+pub const PIPE_TYPE_MESSAGE = 0x00000004;
+
+pub const PIPE_READMODE_BYTE = 0x00000000;
+pub const PIPE_READMODE_MESSAGE = 0x00000002;
+
+pub const PIPE_WAIT = 0x00000000;
+pub const PIPE_NOWAIT = 0x00000001;
+
+pub const GENERIC_READ = 0x80000000;
+pub const GENERIC_WRITE = 0x40000000;
+pub const GENERIC_EXECUTE = 0x20000000;
+pub const GENERIC_ALL = 0x10000000;
+
+pub const FILE_SHARE_DELETE = 0x00000004;
+pub const FILE_SHARE_READ = 0x00000001;
+pub const FILE_SHARE_WRITE = 0x00000002;
+
+pub const DELETE = 0x00010000;
+pub const READ_CONTROL = 0x00020000;
+pub const WRITE_DAC = 0x00040000;
+pub const WRITE_OWNER = 0x00080000;
+pub const SYNCHRONIZE = 0x00100000;
+pub const STANDARD_RIGHTS_READ = READ_CONTROL;
+pub const STANDARD_RIGHTS_WRITE = READ_CONTROL;
+pub const STANDARD_RIGHTS_EXECUTE = READ_CONTROL;
+pub const STANDARD_RIGHTS_REQUIRED = DELETE | READ_CONTROL | WRITE_DAC | WRITE_OWNER;
+
+// disposition for NtCreateFile
+pub const FILE_SUPERSEDE = 0;
+pub const FILE_OPEN = 1;
+pub const FILE_CREATE = 2;
+pub const FILE_OPEN_IF = 3;
+pub const FILE_OVERWRITE = 4;
+pub const FILE_OVERWRITE_IF = 5;
+pub const FILE_MAXIMUM_DISPOSITION = 5;
+
+// flags for NtCreateFile and NtOpenFile
+pub const FILE_READ_DATA = 0x00000001;
+pub const FILE_LIST_DIRECTORY = 0x00000001;
+pub const FILE_WRITE_DATA = 0x00000002;
+pub const FILE_ADD_FILE = 0x00000002;
+pub const FILE_APPEND_DATA = 0x00000004;
+pub const FILE_ADD_SUBDIRECTORY = 0x00000004;
+pub const FILE_CREATE_PIPE_INSTANCE = 0x00000004;
+pub const FILE_READ_EA = 0x00000008;
+pub const FILE_WRITE_EA = 0x00000010;
+pub const FILE_EXECUTE = 0x00000020;
+pub const FILE_TRAVERSE = 0x00000020;
+pub const FILE_DELETE_CHILD = 0x00000040;
+pub const FILE_READ_ATTRIBUTES = 0x00000080;
+pub const FILE_WRITE_ATTRIBUTES = 0x00000100;
+
+pub const FILE_DIRECTORY_FILE = 0x00000001;
+pub const FILE_WRITE_THROUGH = 0x00000002;
+pub const FILE_SEQUENTIAL_ONLY = 0x00000004;
+pub const FILE_NO_INTERMEDIATE_BUFFERING = 0x00000008;
+pub const FILE_SYNCHRONOUS_IO_ALERT = 0x00000010;
+pub const FILE_SYNCHRONOUS_IO_NONALERT = 0x00000020;
+pub const FILE_NON_DIRECTORY_FILE = 0x00000040;
+pub const FILE_CREATE_TREE_CONNECTION = 0x00000080;
+pub const FILE_COMPLETE_IF_OPLOCKED = 0x00000100;
+pub const FILE_NO_EA_KNOWLEDGE = 0x00000200;
+pub const FILE_OPEN_FOR_RECOVERY = 0x00000400;
+pub const FILE_RANDOM_ACCESS = 0x00000800;
+pub const FILE_DELETE_ON_CLOSE = 0x00001000;
+pub const FILE_OPEN_BY_FILE_ID = 0x00002000;
+pub const FILE_OPEN_FOR_BACKUP_INTENT = 0x00004000;
+pub const FILE_NO_COMPRESSION = 0x00008000;
+pub const FILE_RESERVE_OPFILTER = 0x00100000;
+pub const FILE_OPEN_REPARSE_POINT = 0x00200000;
+pub const FILE_OPEN_OFFLINE_FILE = 0x00400000;
+pub const FILE_OPEN_FOR_FREE_SPACE_QUERY = 0x00800000;
+
+pub const CREATE_ALWAYS = 2;
+pub const CREATE_NEW = 1;
+pub const OPEN_ALWAYS = 4;
+pub const OPEN_EXISTING = 3;
+pub const TRUNCATE_EXISTING = 5;
+
+pub const FILE_ATTRIBUTE_ARCHIVE = 0x20;
+pub const FILE_ATTRIBUTE_COMPRESSED = 0x800;
+pub const FILE_ATTRIBUTE_DEVICE = 0x40;
+pub const FILE_ATTRIBUTE_DIRECTORY = 0x10;
+pub const FILE_ATTRIBUTE_ENCRYPTED = 0x4000;
+pub const FILE_ATTRIBUTE_HIDDEN = 0x2;
+pub const FILE_ATTRIBUTE_INTEGRITY_STREAM = 0x8000;
+pub const FILE_ATTRIBUTE_NORMAL = 0x80;
+pub const FILE_ATTRIBUTE_NOT_CONTENT_INDEXED = 0x2000;
+pub const FILE_ATTRIBUTE_NO_SCRUB_DATA = 0x20000;
+pub const FILE_ATTRIBUTE_OFFLINE = 0x1000;
+pub const FILE_ATTRIBUTE_READONLY = 0x1;
+pub const FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS = 0x400000;
+pub const FILE_ATTRIBUTE_RECALL_ON_OPEN = 0x40000;
+pub const FILE_ATTRIBUTE_REPARSE_POINT = 0x400;
+pub const FILE_ATTRIBUTE_SPARSE_FILE = 0x200;
+pub const FILE_ATTRIBUTE_SYSTEM = 0x4;
+pub const FILE_ATTRIBUTE_TEMPORARY = 0x100;
+pub const FILE_ATTRIBUTE_VIRTUAL = 0x10000;
+
+// flags for CreateEvent
+pub const CREATE_EVENT_INITIAL_SET = 0x00000002;
+pub const CREATE_EVENT_MANUAL_RESET = 0x00000001;
+
+pub const EVENT_ALL_ACCESS = 0x1F0003;
+pub const EVENT_MODIFY_STATE = 0x0002;
+
+pub const PROCESS_INFORMATION = extern struct {
+ hProcess: HANDLE,
+ hThread: HANDLE,
+ dwProcessId: DWORD,
+ dwThreadId: DWORD,
+};
+
+pub const STARTUPINFOW = extern struct {
+ cb: DWORD,
+ lpReserved: ?LPWSTR,
+ lpDesktop: ?LPWSTR,
+ lpTitle: ?LPWSTR,
+ dwX: DWORD,
+ dwY: DWORD,
+ dwXSize: DWORD,
+ dwYSize: DWORD,
+ dwXCountChars: DWORD,
+ dwYCountChars: DWORD,
+ dwFillAttribute: DWORD,
+ dwFlags: DWORD,
+ wShowWindow: WORD,
+ cbReserved2: WORD,
+ lpReserved2: ?*BYTE,
+ hStdInput: ?HANDLE,
+ hStdOutput: ?HANDLE,
+ hStdError: ?HANDLE,
+};
+
+pub const STARTF_FORCEONFEEDBACK = 0x00000040;
+pub const STARTF_FORCEOFFFEEDBACK = 0x00000080;
+pub const STARTF_PREVENTPINNING = 0x00002000;
+pub const STARTF_RUNFULLSCREEN = 0x00000020;
+pub const STARTF_TITLEISAPPID = 0x00001000;
+pub const STARTF_TITLEISLINKNAME = 0x00000800;
+pub const STARTF_UNTRUSTEDSOURCE = 0x00008000;
+pub const STARTF_USECOUNTCHARS = 0x00000008;
+pub const STARTF_USEFILLATTRIBUTE = 0x00000010;
+pub const STARTF_USEHOTKEY = 0x00000200;
+pub const STARTF_USEPOSITION = 0x00000004;
+pub const STARTF_USESHOWWINDOW = 0x00000001;
+pub const STARTF_USESIZE = 0x00000002;
+pub const STARTF_USESTDHANDLES = 0x00000100;
+
+pub const INFINITE = 4294967295;
+
+pub const MAXIMUM_WAIT_OBJECTS = 64;
+
+pub const WAIT_ABANDONED = 0x00000080;
+pub const WAIT_ABANDONED_0 = WAIT_ABANDONED + 0;
+pub const WAIT_OBJECT_0 = 0x00000000;
+pub const WAIT_TIMEOUT = 0x00000102;
+pub const WAIT_FAILED = 0xFFFFFFFF;
+
+pub const HANDLE_FLAG_INHERIT = 0x00000001;
+pub const HANDLE_FLAG_PROTECT_FROM_CLOSE = 0x00000002;
+
+pub const MOVEFILE_COPY_ALLOWED = 2;
+pub const MOVEFILE_CREATE_HARDLINK = 16;
+pub const MOVEFILE_DELAY_UNTIL_REBOOT = 4;
+pub const MOVEFILE_FAIL_IF_NOT_TRACKABLE = 32;
+pub const MOVEFILE_REPLACE_EXISTING = 1;
+pub const MOVEFILE_WRITE_THROUGH = 8;
+
+pub const FILE_BEGIN = 0;
+pub const FILE_CURRENT = 1;
+pub const FILE_END = 2;
+
+pub const HEAP_CREATE_ENABLE_EXECUTE = 0x00040000;
+pub const HEAP_REALLOC_IN_PLACE_ONLY = 0x00000010;
+pub const HEAP_GENERATE_EXCEPTIONS = 0x00000004;
+pub const HEAP_NO_SERIALIZE = 0x00000001;
+
+// AllocationType values
+pub const MEM_COMMIT = 0x1000;
+pub const MEM_RESERVE = 0x2000;
+pub const MEM_RESET = 0x80000;
+pub const MEM_RESET_UNDO = 0x1000000;
+pub const MEM_LARGE_PAGES = 0x20000000;
+pub const MEM_PHYSICAL = 0x400000;
+pub const MEM_TOP_DOWN = 0x100000;
+pub const MEM_WRITE_WATCH = 0x200000;
+
+// Protect values
+pub const PAGE_EXECUTE = 0x10;
+pub const PAGE_EXECUTE_READ = 0x20;
+pub const PAGE_EXECUTE_READWRITE = 0x40;
+pub const PAGE_EXECUTE_WRITECOPY = 0x80;
+pub const PAGE_NOACCESS = 0x01;
+pub const PAGE_READONLY = 0x02;
+pub const PAGE_READWRITE = 0x04;
+pub const PAGE_WRITECOPY = 0x08;
+pub const PAGE_TARGETS_INVALID = 0x40000000;
+pub const PAGE_TARGETS_NO_UPDATE = 0x40000000; // Same as PAGE_TARGETS_INVALID
+pub const PAGE_GUARD = 0x100;
+pub const PAGE_NOCACHE = 0x200;
+pub const PAGE_WRITECOMBINE = 0x400;
+
+// FreeType values
+pub const MEM_COALESCE_PLACEHOLDERS = 0x1;
+pub const MEM_RESERVE_PLACEHOLDERS = 0x2;
+pub const MEM_DECOMMIT = 0x4000;
+pub const MEM_RELEASE = 0x8000;
+
+pub const PTHREAD_START_ROUTINE = fn (LPVOID) callconv(.C) DWORD;
+pub const LPTHREAD_START_ROUTINE = PTHREAD_START_ROUTINE;
+
+pub const WIN32_FIND_DATAW = extern struct {
+ dwFileAttributes: DWORD,
+ ftCreationTime: FILETIME,
+ ftLastAccessTime: FILETIME,
+ ftLastWriteTime: FILETIME,
+ nFileSizeHigh: DWORD,
+ nFileSizeLow: DWORD,
+ dwReserved0: DWORD,
+ dwReserved1: DWORD,
+ cFileName: [260]u16,
+ cAlternateFileName: [14]u16,
+};
+
+pub const FILETIME = extern struct {
+ dwLowDateTime: DWORD,
+ dwHighDateTime: DWORD,
+};
+
+pub const SYSTEM_INFO = extern struct {
+ anon1: extern union {
+ dwOemId: DWORD,
+ anon2: extern struct {
+ wProcessorArchitecture: WORD,
+ wReserved: WORD,
+ },
+ },
+ dwPageSize: DWORD,
+ lpMinimumApplicationAddress: LPVOID,
+ lpMaximumApplicationAddress: LPVOID,
+ dwActiveProcessorMask: DWORD_PTR,
+ dwNumberOfProcessors: DWORD,
+ dwProcessorType: DWORD,
+ dwAllocationGranularity: DWORD,
+ wProcessorLevel: WORD,
+ wProcessorRevision: WORD,
+};
+
+pub const HRESULT = c_long;
+
+pub const KNOWNFOLDERID = GUID;
+pub const GUID = extern struct {
+ Data1: c_ulong,
+ Data2: c_ushort,
+ Data3: c_ushort,
+ Data4: [8]u8,
+
+ pub fn parse(str: []const u8) GUID {
+ var guid: GUID = undefined;
+ var index: usize = 0;
+ assert(str[index] == '{');
+ index += 1;
+
+ guid.Data1 = std.fmt.parseUnsigned(c_ulong, str[index .. index + 8], 16) catch unreachable;
+ index += 8;
+
+ assert(str[index] == '-');
+ index += 1;
+
+ guid.Data2 = std.fmt.parseUnsigned(c_ushort, str[index .. index + 4], 16) catch unreachable;
+ index += 4;
+
+ assert(str[index] == '-');
+ index += 1;
+
+ guid.Data3 = std.fmt.parseUnsigned(c_ushort, str[index .. index + 4], 16) catch unreachable;
+ index += 4;
+
+ assert(str[index] == '-');
+ index += 1;
+
+ guid.Data4[0] = std.fmt.parseUnsigned(u8, str[index .. index + 2], 16) catch unreachable;
+ index += 2;
+ guid.Data4[1] = std.fmt.parseUnsigned(u8, str[index .. index + 2], 16) catch unreachable;
+ index += 2;
+
+ assert(str[index] == '-');
+ index += 1;
+
+ var i: usize = 2;
+ while (i < guid.Data4.len) : (i += 1) {
+ guid.Data4[i] = std.fmt.parseUnsigned(u8, str[index .. index + 2], 16) catch unreachable;
+ index += 2;
+ }
+
+ assert(str[index] == '}');
+ index += 1;
+ return guid;
+ }
+};
+
+pub const FOLDERID_LocalAppData = GUID.parse("{F1B32785-6FBA-4FCF-9D55-7B8E7F157091}");
+
+pub const KF_FLAG_DEFAULT = 0;
+pub const KF_FLAG_NO_APPCONTAINER_REDIRECTION = 65536;
+pub const KF_FLAG_CREATE = 32768;
+pub const KF_FLAG_DONT_VERIFY = 16384;
+pub const KF_FLAG_DONT_UNEXPAND = 8192;
+pub const KF_FLAG_NO_ALIAS = 4096;
+pub const KF_FLAG_INIT = 2048;
+pub const KF_FLAG_DEFAULT_PATH = 1024;
+pub const KF_FLAG_NOT_PARENT_RELATIVE = 512;
+pub const KF_FLAG_SIMPLE_IDLIST = 256;
+pub const KF_FLAG_ALIAS_ONLY = -2147483648;
+
+pub const S_OK = 0;
+pub const E_NOTIMPL = @bitCast(c_long, @as(c_ulong, 0x80004001));
+pub const E_NOINTERFACE = @bitCast(c_long, @as(c_ulong, 0x80004002));
+pub const E_POINTER = @bitCast(c_long, @as(c_ulong, 0x80004003));
+pub const E_ABORT = @bitCast(c_long, @as(c_ulong, 0x80004004));
+pub const E_FAIL = @bitCast(c_long, @as(c_ulong, 0x80004005));
+pub const E_UNEXPECTED = @bitCast(c_long, @as(c_ulong, 0x8000FFFF));
+pub const E_ACCESSDENIED = @bitCast(c_long, @as(c_ulong, 0x80070005));
+pub const E_HANDLE = @bitCast(c_long, @as(c_ulong, 0x80070006));
+pub const E_OUTOFMEMORY = @bitCast(c_long, @as(c_ulong, 0x8007000E));
+pub const E_INVALIDARG = @bitCast(c_long, @as(c_ulong, 0x80070057));
+
+pub const FILE_FLAG_BACKUP_SEMANTICS = 0x02000000;
+pub const FILE_FLAG_DELETE_ON_CLOSE = 0x04000000;
+pub const FILE_FLAG_NO_BUFFERING = 0x20000000;
+pub const FILE_FLAG_OPEN_NO_RECALL = 0x00100000;
+pub const FILE_FLAG_OPEN_REPARSE_POINT = 0x00200000;
+pub const FILE_FLAG_OVERLAPPED = 0x40000000;
+pub const FILE_FLAG_POSIX_SEMANTICS = 0x0100000;
+pub const FILE_FLAG_RANDOM_ACCESS = 0x10000000;
+pub const FILE_FLAG_SESSION_AWARE = 0x00800000;
+pub const FILE_FLAG_SEQUENTIAL_SCAN = 0x08000000;
+pub const FILE_FLAG_WRITE_THROUGH = 0x80000000;
+
+pub const RECT = extern struct {
+ left: LONG,
+ top: LONG,
+ right: LONG,
+ bottom: LONG,
+};
+
+pub const SMALL_RECT = extern struct {
+ Left: SHORT,
+ Top: SHORT,
+ Right: SHORT,
+ Bottom: SHORT,
+};
+
+pub const POINT = extern struct {
+ x: LONG,
+ y: LONG,
+};
+
+pub const COORD = extern struct {
+ X: SHORT,
+ Y: SHORT,
+};
+
+pub const CREATE_UNICODE_ENVIRONMENT = 1024;
+
+pub const TLS_OUT_OF_INDEXES = 4294967295;
+pub const IMAGE_TLS_DIRECTORY = extern struct {
+ StartAddressOfRawData: usize,
+ EndAddressOfRawData: usize,
+ AddressOfIndex: usize,
+ AddressOfCallBacks: usize,
+ SizeOfZeroFill: u32,
+ Characteristics: u32,
+};
+pub const IMAGE_TLS_DIRECTORY64 = IMAGE_TLS_DIRECTORY;
+pub const IMAGE_TLS_DIRECTORY32 = IMAGE_TLS_DIRECTORY;
+
+pub const PIMAGE_TLS_CALLBACK = ?fn (PVOID, DWORD, PVOID) callconv(.C) void;
+
+pub const PROV_RSA_FULL = 1;
+
+pub const REGSAM = ACCESS_MASK;
+pub const ACCESS_MASK = DWORD;
+pub const HKEY = *HKEY__;
+pub const HKEY__ = extern struct {
+ unused: c_int,
+};
+pub const LSTATUS = LONG;
+
+pub const FILE_NOTIFY_INFORMATION = extern struct {
+ NextEntryOffset: DWORD,
+ Action: DWORD,
+ FileNameLength: DWORD,
+ // Flexible array member
+ // FileName: [1]WCHAR,
+};
+
+pub const FILE_ACTION_ADDED = 0x00000001;
+pub const FILE_ACTION_REMOVED = 0x00000002;
+pub const FILE_ACTION_MODIFIED = 0x00000003;
+pub const FILE_ACTION_RENAMED_OLD_NAME = 0x00000004;
+pub const FILE_ACTION_RENAMED_NEW_NAME = 0x00000005;
+
+pub const LPOVERLAPPED_COMPLETION_ROUTINE = ?fn (DWORD, DWORD, *OVERLAPPED) callconv(.C) void;
+
+pub const FILE_NOTIFY_CHANGE_CREATION = 64;
+pub const FILE_NOTIFY_CHANGE_SIZE = 8;
+pub const FILE_NOTIFY_CHANGE_SECURITY = 256;
+pub const FILE_NOTIFY_CHANGE_LAST_ACCESS = 32;
+pub const FILE_NOTIFY_CHANGE_LAST_WRITE = 16;
+pub const FILE_NOTIFY_CHANGE_DIR_NAME = 2;
+pub const FILE_NOTIFY_CHANGE_FILE_NAME = 1;
+pub const FILE_NOTIFY_CHANGE_ATTRIBUTES = 4;
+
+pub const CONSOLE_SCREEN_BUFFER_INFO = extern struct {
+ dwSize: COORD,
+ dwCursorPosition: COORD,
+ wAttributes: WORD,
+ srWindow: SMALL_RECT,
+ dwMaximumWindowSize: COORD,
+};
+
+pub const FOREGROUND_BLUE = 1;
+pub const FOREGROUND_GREEN = 2;
+pub const FOREGROUND_RED = 4;
+pub const FOREGROUND_INTENSITY = 8;
+
+pub const LIST_ENTRY = extern struct {
+ Flink: *LIST_ENTRY,
+ Blink: *LIST_ENTRY,
+};
+
+pub const RTL_CRITICAL_SECTION_DEBUG = extern struct {
+ Type: WORD,
+ CreatorBackTraceIndex: WORD,
+ CriticalSection: *RTL_CRITICAL_SECTION,
+ ProcessLocksList: LIST_ENTRY,
+ EntryCount: DWORD,
+ ContentionCount: DWORD,
+ Flags: DWORD,
+ CreatorBackTraceIndexHigh: WORD,
+ SpareWORD: WORD,
+};
+
+pub const RTL_CRITICAL_SECTION = extern struct {
+ DebugInfo: *RTL_CRITICAL_SECTION_DEBUG,
+ LockCount: LONG,
+ RecursionCount: LONG,
+ OwningThread: HANDLE,
+ LockSemaphore: HANDLE,
+ SpinCount: ULONG_PTR,
+};
+
+pub const CRITICAL_SECTION = RTL_CRITICAL_SECTION;
+pub const INIT_ONCE = RTL_RUN_ONCE;
+pub const INIT_ONCE_STATIC_INIT = RTL_RUN_ONCE_INIT;
+pub const INIT_ONCE_FN = fn (InitOnce: *INIT_ONCE, Parameter: ?*c_void, Context: ?*c_void) callconv(.C) BOOL;
+
+pub const RTL_RUN_ONCE = extern struct {
+ Ptr: ?*c_void,
+};
+
+pub const RTL_RUN_ONCE_INIT = RTL_RUN_ONCE{ .Ptr = null };
+
+pub const COINIT_APARTMENTTHREADED = COINIT.COINIT_APARTMENTTHREADED;
+pub const COINIT_MULTITHREADED = COINIT.COINIT_MULTITHREADED;
+pub const COINIT_DISABLE_OLE1DDE = COINIT.COINIT_DISABLE_OLE1DDE;
+pub const COINIT_SPEED_OVER_MEMORY = COINIT.COINIT_SPEED_OVER_MEMORY;
+pub const COINIT = enum(c_int) {
+ COINIT_APARTMENTTHREADED = 2,
+ COINIT_MULTITHREADED = 0,
+ COINIT_DISABLE_OLE1DDE = 4,
+ COINIT_SPEED_OVER_MEMORY = 8,
+};
+
+/// > The maximum path of 32,767 characters is approximate, because the "\\?\"
+/// > prefix may be expanded to a longer string by the system at run time, and
+/// > this expansion applies to the total length.
+/// from https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file#maximum-path-length-limitation
+pub const PATH_MAX_WIDE = 32767;
+
+pub const FORMAT_MESSAGE_ALLOCATE_BUFFER = 0x00000100;
+pub const FORMAT_MESSAGE_ARGUMENT_ARRAY = 0x00002000;
+pub const FORMAT_MESSAGE_FROM_HMODULE = 0x00000800;
+pub const FORMAT_MESSAGE_FROM_STRING = 0x00000400;
+pub const FORMAT_MESSAGE_FROM_SYSTEM = 0x00001000;
+pub const FORMAT_MESSAGE_IGNORE_INSERTS = 0x00000200;
+pub const FORMAT_MESSAGE_MAX_WIDTH_MASK = 0x000000FF;
+
+pub const EXCEPTION_DATATYPE_MISALIGNMENT = 0x80000002;
+pub const EXCEPTION_ACCESS_VIOLATION = 0xc0000005;
+pub const EXCEPTION_ILLEGAL_INSTRUCTION = 0xc000001d;
+pub const EXCEPTION_STACK_OVERFLOW = 0xc00000fd;
+pub const EXCEPTION_CONTINUE_SEARCH = 0;
+
+pub const EXCEPTION_RECORD = extern struct {
+ ExceptionCode: u32,
+ ExceptionFlags: u32,
+ ExceptionRecord: *EXCEPTION_RECORD,
+ ExceptionAddress: *c_void,
+ NumberParameters: u32,
+ ExceptionInformation: [15]usize,
+};
+
+pub usingnamespace switch (native_arch) {
+ .i386 => struct {
+ pub const FLOATING_SAVE_AREA = extern struct {
+ ControlWord: DWORD,
+ StatusWord: DWORD,
+ TagWord: DWORD,
+ ErrorOffset: DWORD,
+ ErrorSelector: DWORD,
+ DataOffset: DWORD,
+ DataSelector: DWORD,
+ RegisterArea: [80]BYTE,
+ Cr0NpxState: DWORD,
+ };
+
+ pub const CONTEXT = extern struct {
+ ContextFlags: DWORD,
+ Dr0: DWORD,
+ Dr1: DWORD,
+ Dr2: DWORD,
+ Dr3: DWORD,
+ Dr6: DWORD,
+ Dr7: DWORD,
+ FloatSave: FLOATING_SAVE_AREA,
+ SegGs: DWORD,
+ SegFs: DWORD,
+ SegEs: DWORD,
+ SegDs: DWORD,
+ Edi: DWORD,
+ Esi: DWORD,
+ Ebx: DWORD,
+ Edx: DWORD,
+ Ecx: DWORD,
+ Eax: DWORD,
+ Ebp: DWORD,
+ Eip: DWORD,
+ SegCs: DWORD,
+ EFlags: DWORD,
+ Esp: DWORD,
+ SegSs: DWORD,
+ ExtendedRegisters: [512]BYTE,
+
+ pub fn getRegs(ctx: *const CONTEXT) struct { bp: usize, ip: usize } {
+ return .{ .bp = ctx.Ebp, .ip = ctx.Eip };
+ }
+ };
+ },
+ .x86_64 => struct {
+ pub const M128A = extern struct {
+ Low: ULONGLONG,
+ High: LONGLONG,
+ };
+
+ pub const XMM_SAVE_AREA32 = extern struct {
+ ControlWord: WORD,
+ StatusWord: WORD,
+ TagWord: BYTE,
+ Reserved1: BYTE,
+ ErrorOpcode: WORD,
+ ErrorOffset: DWORD,
+ ErrorSelector: WORD,
+ Reserved2: WORD,
+ DataOffset: DWORD,
+ DataSelector: WORD,
+ Reserved3: WORD,
+ MxCsr: DWORD,
+ MxCsr_Mask: DWORD,
+ FloatRegisters: [8]M128A,
+ XmmRegisters: [16]M128A,
+ Reserved4: [96]BYTE,
+ };
+
+ pub const CONTEXT = extern struct {
+ P1Home: DWORD64,
+ P2Home: DWORD64,
+ P3Home: DWORD64,
+ P4Home: DWORD64,
+ P5Home: DWORD64,
+ P6Home: DWORD64,
+ ContextFlags: DWORD,
+ MxCsr: DWORD,
+ SegCs: WORD,
+ SegDs: WORD,
+ SegEs: WORD,
+ SegFs: WORD,
+ SegGs: WORD,
+ SegSs: WORD,
+ EFlags: DWORD,
+ Dr0: DWORD64,
+ Dr1: DWORD64,
+ Dr2: DWORD64,
+ Dr3: DWORD64,
+ Dr6: DWORD64,
+ Dr7: DWORD64,
+ Rax: DWORD64,
+ Rcx: DWORD64,
+ Rdx: DWORD64,
+ Rbx: DWORD64,
+ Rsp: DWORD64,
+ Rbp: DWORD64,
+ Rsi: DWORD64,
+ Rdi: DWORD64,
+ R8: DWORD64,
+ R9: DWORD64,
+ R10: DWORD64,
+ R11: DWORD64,
+ R12: DWORD64,
+ R13: DWORD64,
+ R14: DWORD64,
+ R15: DWORD64,
+ Rip: DWORD64,
+ DUMMYUNIONNAME: extern union {
+ FltSave: XMM_SAVE_AREA32,
+ FloatSave: XMM_SAVE_AREA32,
+ DUMMYSTRUCTNAME: extern struct {
+ Header: [2]M128A,
+ Legacy: [8]M128A,
+ Xmm0: M128A,
+ Xmm1: M128A,
+ Xmm2: M128A,
+ Xmm3: M128A,
+ Xmm4: M128A,
+ Xmm5: M128A,
+ Xmm6: M128A,
+ Xmm7: M128A,
+ Xmm8: M128A,
+ Xmm9: M128A,
+ Xmm10: M128A,
+ Xmm11: M128A,
+ Xmm12: M128A,
+ Xmm13: M128A,
+ Xmm14: M128A,
+ Xmm15: M128A,
+ },
+ },
+ VectorRegister: [26]M128A,
+ VectorControl: DWORD64,
+ DebugControl: DWORD64,
+ LastBranchToRip: DWORD64,
+ LastBranchFromRip: DWORD64,
+ LastExceptionToRip: DWORD64,
+ LastExceptionFromRip: DWORD64,
+
+ pub fn getRegs(ctx: *const CONTEXT) struct { bp: usize, ip: usize } {
+ return .{ .bp = ctx.Rbp, .ip = ctx.Rip };
+ }
+ };
+ },
+ .aarch64 => struct {
+ pub const NEON128 = extern union {
+ DUMMYSTRUCTNAME: extern struct {
+ Low: ULONGLONG,
+ High: LONGLONG,
+ },
+ D: [2]f64,
+ S: [4]f32,
+ H: [8]WORD,
+ B: [16]BYTE,
+ };
+
+ pub const CONTEXT = extern struct {
+ ContextFlags: ULONG,
+ Cpsr: ULONG,
+ DUMMYUNIONNAME: extern union {
+ DUMMYSTRUCTNAME: extern struct {
+ X0: DWORD64,
+ X1: DWORD64,
+ X2: DWORD64,
+ X3: DWORD64,
+ X4: DWORD64,
+ X5: DWORD64,
+ X6: DWORD64,
+ X7: DWORD64,
+ X8: DWORD64,
+ X9: DWORD64,
+ X10: DWORD64,
+ X11: DWORD64,
+ X12: DWORD64,
+ X13: DWORD64,
+ X14: DWORD64,
+ X15: DWORD64,
+ X16: DWORD64,
+ X17: DWORD64,
+ X18: DWORD64,
+ X19: DWORD64,
+ X20: DWORD64,
+ X21: DWORD64,
+ X22: DWORD64,
+ X23: DWORD64,
+ X24: DWORD64,
+ X25: DWORD64,
+ X26: DWORD64,
+ X27: DWORD64,
+ X28: DWORD64,
+ Fp: DWORD64,
+ Lr: DWORD64,
+ },
+ X: [31]DWORD64,
+ },
+ Sp: DWORD64,
+ Pc: DWORD64,
+ V: [32]NEON128,
+ Fpcr: DWORD,
+ Fpsr: DWORD,
+ Bcr: [8]DWORD,
+ Bvr: [8]DWORD64,
+ Wcr: [2]DWORD,
+ Wvr: [2]DWORD64,
+
+ pub fn getRegs(ctx: *const CONTEXT) struct { bp: usize, ip: usize } {
+ return .{
+ .bp = ctx.DUMMYUNIONNAME.DUMMYSTRUCTNAME.Fp,
+ .ip = ctx.Pc,
+ };
+ }
+ };
+ },
+ else => struct {},
+};
+
+pub const EXCEPTION_POINTERS = extern struct {
+ ExceptionRecord: *EXCEPTION_RECORD,
+ ContextRecord: *std.os.windows.CONTEXT,
+};
+
+pub const VECTORED_EXCEPTION_HANDLER = fn (ExceptionInfo: *EXCEPTION_POINTERS) callconv(WINAPI) c_long;
+
+pub const OBJECT_ATTRIBUTES = extern struct {
+ Length: ULONG,
+ RootDirectory: ?HANDLE,
+ ObjectName: *UNICODE_STRING,
+ Attributes: ULONG,
+ SecurityDescriptor: ?*c_void,
+ SecurityQualityOfService: ?*c_void,
+};
+
+pub const OBJ_INHERIT = 0x00000002;
+pub const OBJ_PERMANENT = 0x00000010;
+pub const OBJ_EXCLUSIVE = 0x00000020;
+pub const OBJ_CASE_INSENSITIVE = 0x00000040;
+pub const OBJ_OPENIF = 0x00000080;
+pub const OBJ_OPENLINK = 0x00000100;
+pub const OBJ_KERNEL_HANDLE = 0x00000200;
+pub const OBJ_VALID_ATTRIBUTES = 0x000003F2;
+
+pub const UNICODE_STRING = extern struct {
+ Length: c_ushort,
+ MaximumLength: c_ushort,
+ Buffer: [*]WCHAR,
+};
+
+pub const ACTIVATION_CONTEXT_DATA = opaque {};
+pub const ASSEMBLY_STORAGE_MAP = opaque {};
+pub const FLS_CALLBACK_INFO = opaque {};
+pub const RTL_BITMAP = opaque {};
+pub const KAFFINITY = usize;
+
+pub const TEB = extern struct {
+ Reserved1: [12]PVOID,
+ ProcessEnvironmentBlock: *PEB,
+ Reserved2: [399]PVOID,
+ Reserved3: [1952]u8,
+ TlsSlots: [64]PVOID,
+ Reserved4: [8]u8,
+ Reserved5: [26]PVOID,
+ ReservedForOle: PVOID,
+ Reserved6: [4]PVOID,
+ TlsExpansionSlots: PVOID,
+};
+
+/// Process Environment Block
+/// Microsoft documentation of this is incomplete, the fields here are taken from various resources including:
+/// - https://github.com/wine-mirror/wine/blob/1aff1e6a370ee8c0213a0fd4b220d121da8527aa/include/winternl.h#L269
+/// - https://www.geoffchappell.com/studies/windows/win32/ntdll/structs/peb/index.htm
+pub const PEB = extern struct {
+ // Versions: All
+ InheritedAddressSpace: BOOLEAN,
+
+ // Versions: 3.51+
+ ReadImageFileExecOptions: BOOLEAN,
+ BeingDebugged: BOOLEAN,
+
+ // Versions: 5.2+ (previously was padding)
+ BitField: UCHAR,
+
+ // Versions: all
+ Mutant: HANDLE,
+ ImageBaseAddress: HMODULE,
+ Ldr: *PEB_LDR_DATA,
+ ProcessParameters: *RTL_USER_PROCESS_PARAMETERS,
+ SubSystemData: PVOID,
+ ProcessHeap: HANDLE,
+
+ // Versions: 5.1+
+ FastPebLock: *RTL_CRITICAL_SECTION,
+
+ // Versions: 5.2+
+ AtlThunkSListPtr: PVOID,
+ IFEOKey: PVOID,
+
+ // Versions: 6.0+
+
+ /// https://www.geoffchappell.com/studies/windows/win32/ntdll/structs/peb/crossprocessflags.htm
+ CrossProcessFlags: ULONG,
+
+ // Versions: 6.0+
+ union1: extern union {
+ KernelCallbackTable: PVOID,
+ UserSharedInfoPtr: PVOID,
+ },
+
+ // Versions: 5.1+
+ SystemReserved: ULONG,
+
+ // Versions: 5.1, (not 5.2, not 6.0), 6.1+
+ AtlThunkSListPtr32: ULONG,
+
+ // Versions: 6.1+
+ ApiSetMap: PVOID,
+
+ // Versions: all
+ TlsExpansionCounter: ULONG,
+ // note: there is padding here on 64 bit
+ TlsBitmap: *RTL_BITMAP,
+ TlsBitmapBits: [2]ULONG,
+ ReadOnlySharedMemoryBase: PVOID,
+
+ // Versions: 1703+
+ SharedData: PVOID,
+
+ // Versions: all
+ ReadOnlyStaticServerData: *PVOID,
+ AnsiCodePageData: PVOID,
+ OemCodePageData: PVOID,
+ UnicodeCaseTableData: PVOID,
+
+ // Versions: 3.51+
+ NumberOfProcessors: ULONG,
+ NtGlobalFlag: ULONG,
+
+ // Versions: all
+ CriticalSectionTimeout: LARGE_INTEGER,
+
+ // End of Original PEB size
+
+ // Fields appended in 3.51:
+ HeapSegmentReserve: ULONG_PTR,
+ HeapSegmentCommit: ULONG_PTR,
+ HeapDeCommitTotalFreeThreshold: ULONG_PTR,
+ HeapDeCommitFreeBlockThreshold: ULONG_PTR,
+ NumberOfHeaps: ULONG,
+ MaximumNumberOfHeaps: ULONG,
+ ProcessHeaps: *PVOID,
+
+ // Fields appended in 4.0:
+ GdiSharedHandleTable: PVOID,
+ ProcessStarterHelper: PVOID,
+ GdiDCAttributeList: ULONG,
+ // note: there is padding here on 64 bit
+ LoaderLock: *RTL_CRITICAL_SECTION,
+ OSMajorVersion: ULONG,
+ OSMinorVersion: ULONG,
+ OSBuildNumber: USHORT,
+ OSCSDVersion: USHORT,
+ OSPlatformId: ULONG,
+ ImageSubSystem: ULONG,
+ ImageSubSystemMajorVersion: ULONG,
+ ImageSubSystemMinorVersion: ULONG,
+ // note: there is padding here on 64 bit
+ ActiveProcessAffinityMask: KAFFINITY,
+ GdiHandleBuffer: [
+ switch (@sizeOf(usize)) {
+ 4 => 0x22,
+ 8 => 0x3C,
+ else => unreachable,
+ }
+ ]ULONG,
+
+ // Fields appended in 5.0 (Windows 2000):
+ PostProcessInitRoutine: PVOID,
+ TlsExpansionBitmap: *RTL_BITMAP,
+ TlsExpansionBitmapBits: [32]ULONG,
+ SessionId: ULONG,
+ // note: there is padding here on 64 bit
+ // Versions: 5.1+
+ AppCompatFlags: ULARGE_INTEGER,
+ AppCompatFlagsUser: ULARGE_INTEGER,
+ ShimData: PVOID,
+ // Versions: 5.0+
+ AppCompatInfo: PVOID,
+ CSDVersion: UNICODE_STRING,
+
+ // Fields appended in 5.1 (Windows XP):
+ ActivationContextData: *const ACTIVATION_CONTEXT_DATA,
+ ProcessAssemblyStorageMap: *ASSEMBLY_STORAGE_MAP,
+ SystemDefaultActivationData: *const ACTIVATION_CONTEXT_DATA,
+ SystemAssemblyStorageMap: *ASSEMBLY_STORAGE_MAP,
+ MinimumStackCommit: ULONG_PTR,
+
+ // Fields appended in 5.2 (Windows Server 2003):
+ FlsCallback: *FLS_CALLBACK_INFO,
+ FlsListHead: LIST_ENTRY,
+ FlsBitmap: *RTL_BITMAP,
+ FlsBitmapBits: [4]ULONG,
+ FlsHighIndex: ULONG,
+
+ // Fields appended in 6.0 (Windows Vista):
+ WerRegistrationData: PVOID,
+ WerShipAssertPtr: PVOID,
+
+ // Fields appended in 6.1 (Windows 7):
+ pUnused: PVOID, // previously pContextData
+ pImageHeaderHash: PVOID,
+
+ /// TODO: https://www.geoffchappell.com/studies/windows/win32/ntdll/structs/peb/tracingflags.htm
+ TracingFlags: ULONG,
+
+ // Fields appended in 6.2 (Windows 8):
+ CsrServerReadOnlySharedMemoryBase: ULONGLONG,
+
+ // Fields appended in 1511:
+ TppWorkerpListLock: ULONG,
+ TppWorkerpList: LIST_ENTRY,
+ WaitOnAddressHashTable: [0x80]PVOID,
+
+ // Fields appended in 1709:
+ TelemetryCoverageHeader: PVOID,
+ CloudFileFlags: ULONG,
+};
+
+/// The `PEB_LDR_DATA` structure is the main record of what modules are loaded in a process.
+/// It is essentially the head of three double-linked lists of `LDR_DATA_TABLE_ENTRY` structures which each represent one loaded module.
+///
+/// Microsoft documentation of this is incomplete, the fields here are taken from various resources including:
+/// - https://www.geoffchappell.com/studies/windows/win32/ntdll/structs/peb_ldr_data.htm
+pub const PEB_LDR_DATA = extern struct {
+ // Versions: 3.51 and higher
+ /// The size in bytes of the structure
+ Length: ULONG,
+
+ /// TRUE if the structure is prepared.
+ Initialized: BOOLEAN,
+
+ SsHandle: PVOID,
+ InLoadOrderModuleList: LIST_ENTRY,
+ InMemoryOrderModuleList: LIST_ENTRY,
+ InInitializationOrderModuleList: LIST_ENTRY,
+
+ // Versions: 5.1 and higher
+
+ /// No known use of this field is known in Windows 8 and higher.
+ EntryInProgress: PVOID,
+
+ // Versions: 6.0 from Windows Vista SP1, and higher
+ ShutdownInProgress: BOOLEAN,
+
+ /// Though ShutdownThreadId is declared as a HANDLE,
+ /// it is indeed the thread ID as suggested by its name.
+ /// It is picked up from the UniqueThread member of the CLIENT_ID in the
+ /// TEB of the thread that asks to terminate the process.
+ ShutdownThreadId: HANDLE,
+};
+
+pub const RTL_USER_PROCESS_PARAMETERS = extern struct {
+ AllocationSize: ULONG,
+ Size: ULONG,
+ Flags: ULONG,
+ DebugFlags: ULONG,
+ ConsoleHandle: HANDLE,
+ ConsoleFlags: ULONG,
+ hStdInput: HANDLE,
+ hStdOutput: HANDLE,
+ hStdError: HANDLE,
+ CurrentDirectory: CURDIR,
+ DllPath: UNICODE_STRING,
+ ImagePathName: UNICODE_STRING,
+ CommandLine: UNICODE_STRING,
+ Environment: [*:0]WCHAR,
+ dwX: ULONG,
+ dwY: ULONG,
+ dwXSize: ULONG,
+ dwYSize: ULONG,
+ dwXCountChars: ULONG,
+ dwYCountChars: ULONG,
+ dwFillAttribute: ULONG,
+ dwFlags: ULONG,
+ dwShowWindow: ULONG,
+ WindowTitle: UNICODE_STRING,
+ Desktop: UNICODE_STRING,
+ ShellInfo: UNICODE_STRING,
+ RuntimeInfo: UNICODE_STRING,
+ DLCurrentDirectory: [0x20]RTL_DRIVE_LETTER_CURDIR,
+};
+
+pub const RTL_DRIVE_LETTER_CURDIR = extern struct {
+ Flags: c_ushort,
+ Length: c_ushort,
+ TimeStamp: ULONG,
+ DosPath: UNICODE_STRING,
+};
+
+pub const PPS_POST_PROCESS_INIT_ROUTINE = ?fn () callconv(.C) void;
+
+pub const FILE_BOTH_DIR_INFORMATION = extern struct {
+ NextEntryOffset: ULONG,
+ FileIndex: ULONG,
+ CreationTime: LARGE_INTEGER,
+ LastAccessTime: LARGE_INTEGER,
+ LastWriteTime: LARGE_INTEGER,
+ ChangeTime: LARGE_INTEGER,
+ EndOfFile: LARGE_INTEGER,
+ AllocationSize: LARGE_INTEGER,
+ FileAttributes: ULONG,
+ FileNameLength: ULONG,
+ EaSize: ULONG,
+ ShortNameLength: CHAR,
+ ShortName: [12]WCHAR,
+ FileName: [1]WCHAR,
+};
+pub const FILE_BOTH_DIRECTORY_INFORMATION = FILE_BOTH_DIR_INFORMATION;
+
+pub const IO_APC_ROUTINE = fn (PVOID, *IO_STATUS_BLOCK, ULONG) callconv(.C) void;
+
+pub const CURDIR = extern struct {
+ DosPath: UNICODE_STRING,
+ Handle: HANDLE,
+};
+
+pub const DUPLICATE_SAME_ACCESS = 2;
+
+pub const MODULEINFO = extern struct {
+ lpBaseOfDll: LPVOID,
+ SizeOfImage: DWORD,
+ EntryPoint: LPVOID,
+};
+
+pub const PSAPI_WS_WATCH_INFORMATION = extern struct {
+ FaultingPc: LPVOID,
+ FaultingVa: LPVOID,
+};
+
+pub const PROCESS_MEMORY_COUNTERS = extern struct {
+ cb: DWORD,
+ PageFaultCount: DWORD,
+ PeakWorkingSetSize: SIZE_T,
+ WorkingSetSize: SIZE_T,
+ QuotaPeakPagedPoolUsage: SIZE_T,
+ QuotaPagedPoolUsage: SIZE_T,
+ QuotaPeakNonPagedPoolUsage: SIZE_T,
+ QuotaNonPagedPoolUsage: SIZE_T,
+ PagefileUsage: SIZE_T,
+ PeakPagefileUsage: SIZE_T,
+};
+
+pub const PROCESS_MEMORY_COUNTERS_EX = extern struct {
+ cb: DWORD,
+ PageFaultCount: DWORD,
+ PeakWorkingSetSize: SIZE_T,
+ WorkingSetSize: SIZE_T,
+ QuotaPeakPagedPoolUsage: SIZE_T,
+ QuotaPagedPoolUsage: SIZE_T,
+ QuotaPeakNonPagedPoolUsage: SIZE_T,
+ QuotaNonPagedPoolUsage: SIZE_T,
+ PagefileUsage: SIZE_T,
+ PeakPagefileUsage: SIZE_T,
+ PrivateUsage: SIZE_T,
+};
+
+pub const PERFORMANCE_INFORMATION = extern struct {
+ cb: DWORD,
+ CommitTotal: SIZE_T,
+ CommitLimit: SIZE_T,
+ CommitPeak: SIZE_T,
+ PhysicalTotal: SIZE_T,
+ PhysicalAvailable: SIZE_T,
+ SystemCache: SIZE_T,
+ KernelTotal: SIZE_T,
+ KernelPaged: SIZE_T,
+ KernelNonpaged: SIZE_T,
+ PageSize: SIZE_T,
+ HandleCount: DWORD,
+ ProcessCount: DWORD,
+ ThreadCount: DWORD,
+};
+
+pub const ENUM_PAGE_FILE_INFORMATION = extern struct {
+ cb: DWORD,
+ Reserved: DWORD,
+ TotalSize: SIZE_T,
+ TotalInUse: SIZE_T,
+ PeakUsage: SIZE_T,
+};
+
+pub const PENUM_PAGE_FILE_CALLBACKW = ?fn (?LPVOID, *ENUM_PAGE_FILE_INFORMATION, LPCWSTR) callconv(.C) BOOL;
+pub const PENUM_PAGE_FILE_CALLBACKA = ?fn (?LPVOID, *ENUM_PAGE_FILE_INFORMATION, LPCSTR) callconv(.C) BOOL;
+
+pub const PSAPI_WS_WATCH_INFORMATION_EX = extern struct {
+ BasicInfo: PSAPI_WS_WATCH_INFORMATION,
+ FaultingThreadId: ULONG_PTR,
+ Flags: ULONG_PTR,
+};
+
+pub const OSVERSIONINFOW = extern struct {
+ dwOSVersionInfoSize: ULONG,
+ dwMajorVersion: ULONG,
+ dwMinorVersion: ULONG,
+ dwBuildNumber: ULONG,
+ dwPlatformId: ULONG,
+ szCSDVersion: [128]WCHAR,
+};
+pub const RTL_OSVERSIONINFOW = OSVERSIONINFOW;
+
+pub const REPARSE_DATA_BUFFER = extern struct {
+ ReparseTag: ULONG,
+ ReparseDataLength: USHORT,
+ Reserved: USHORT,
+ DataBuffer: [1]UCHAR,
+};
+pub const SYMBOLIC_LINK_REPARSE_BUFFER = extern struct {
+ SubstituteNameOffset: USHORT,
+ SubstituteNameLength: USHORT,
+ PrintNameOffset: USHORT,
+ PrintNameLength: USHORT,
+ Flags: ULONG,
+ PathBuffer: [1]WCHAR,
+};
+pub const MOUNT_POINT_REPARSE_BUFFER = extern struct {
+ SubstituteNameOffset: USHORT,
+ SubstituteNameLength: USHORT,
+ PrintNameOffset: USHORT,
+ PrintNameLength: USHORT,
+ PathBuffer: [1]WCHAR,
+};
+pub const MAXIMUM_REPARSE_DATA_BUFFER_SIZE: ULONG = 16 * 1024;
+pub const FSCTL_SET_REPARSE_POINT: DWORD = 0x900a4;
+pub const FSCTL_GET_REPARSE_POINT: DWORD = 0x900a8;
+pub const IO_REPARSE_TAG_SYMLINK: ULONG = 0xa000000c;
+pub const IO_REPARSE_TAG_MOUNT_POINT: ULONG = 0xa0000003;
+pub const SYMLINK_FLAG_RELATIVE: ULONG = 0x1;
+
+pub const SYMBOLIC_LINK_FLAG_DIRECTORY: DWORD = 0x1;
+pub const SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE: DWORD = 0x2;
+
+pub const MOUNTMGR_MOUNT_POINT = extern struct {
+ SymbolicLinkNameOffset: ULONG,
+ SymbolicLinkNameLength: USHORT,
+ Reserved1: USHORT,
+ UniqueIdOffset: ULONG,
+ UniqueIdLength: USHORT,
+ Reserved2: USHORT,
+ DeviceNameOffset: ULONG,
+ DeviceNameLength: USHORT,
+ Reserved3: USHORT,
+};
+pub const MOUNTMGR_MOUNT_POINTS = extern struct {
+ Size: ULONG,
+ NumberOfMountPoints: ULONG,
+ MountPoints: [1]MOUNTMGR_MOUNT_POINT,
+};
+pub const IOCTL_MOUNTMGR_QUERY_POINTS: ULONG = 0x6d0008;
+
+pub const OBJECT_INFORMATION_CLASS = enum(c_int) {
+ ObjectBasicInformation = 0,
+ ObjectNameInformation = 1,
+ ObjectTypeInformation = 2,
+ ObjectTypesInformation = 3,
+ ObjectHandleFlagInformation = 4,
+ ObjectSessionInformation = 5,
+ MaxObjectInfoClass,
+};
+
+pub const OBJECT_NAME_INFORMATION = extern struct {
+ Name: UNICODE_STRING,
+};
+
+pub const SRWLOCK = usize;
+pub const SRWLOCK_INIT: SRWLOCK = 0;
+pub const CONDITION_VARIABLE = usize;
+pub const CONDITION_VARIABLE_INIT: CONDITION_VARIABLE = 0;
+
+pub const FILE_SKIP_COMPLETION_PORT_ON_SUCCESS = 0x1;
+pub const FILE_SKIP_SET_EVENT_ON_HANDLE = 0x2;
+
+pub const CTRL_C_EVENT: DWORD = 0;
+pub const CTRL_BREAK_EVENT: DWORD = 1;
+pub const CTRL_CLOSE_EVENT: DWORD = 2;
+pub const CTRL_LOGOFF_EVENT: DWORD = 5;
+pub const CTRL_SHUTDOWN_EVENT: DWORD = 6;
+
+pub const HANDLER_ROUTINE = fn (dwCtrlType: DWORD) callconv(.C) BOOL;
diff --git a/lib/std/os/windows/advapi32.zig b/lib/std/os/windows/advapi32.zig
index db77c4b7e976..6d7ea3f8e0d2 100644
--- a/lib/std/os/windows/advapi32.zig
+++ b/lib/std/os/windows/advapi32.zig
@@ -1,4 +1,14 @@
-usingnamespace @import("bits.zig");
+const std = @import("../../std.zig");
+const windows = std.os.windows;
+const BOOL = windows.BOOL;
+const DWORD = windows.DWORD;
+const HKEY = windows.HKEY;
+const BYTE = windows.BYTE;
+const LPCWSTR = windows.LPCWSTR;
+const LSTATUS = windows.LSTATUS;
+const REGSAM = windows.REGSAM;
+const ULONG = windows.ULONG;
+const WINAPI = windows.WINAPI;
pub extern "advapi32" fn RegOpenKeyExW(
hKey: HKEY,
@@ -11,10 +21,10 @@ pub extern "advapi32" fn RegOpenKeyExW(
pub extern "advapi32" fn RegQueryValueExW(
hKey: HKEY,
lpValueName: LPCWSTR,
- lpReserved: LPDWORD,
- lpType: LPDWORD,
- lpData: LPBYTE,
- lpcbData: LPDWORD,
+ lpReserved: *DWORD,
+ lpType: *DWORD,
+ lpData: *BYTE,
+ lpcbData: *DWORD,
) callconv(WINAPI) LSTATUS;
// RtlGenRandom is known as SystemFunction036 under advapi32
diff --git a/lib/std/os/windows/bits.zig b/lib/std/os/windows/bits.zig
deleted file mode 100644
index 7bc0e131ea12..000000000000
--- a/lib/std/os/windows/bits.zig
+++ /dev/null
@@ -1,1668 +0,0 @@
-// Platform-dependent types and values that are used along with OS-specific APIs.
-
-const std = @import("../../std.zig");
-const assert = std.debug.assert;
-const maxInt = std.math.maxInt;
-const arch = std.Target.current.cpu.arch;
-
-pub usingnamespace @import("win32error.zig");
-pub usingnamespace @import("ntstatus.zig");
-pub const LANG = @import("lang.zig");
-pub const SUBLANG = @import("sublang.zig");
-
-/// The standard input device. Initially, this is the console input buffer, CONIN$.
-pub const STD_INPUT_HANDLE = maxInt(DWORD) - 10 + 1;
-
-/// The standard output device. Initially, this is the active console screen buffer, CONOUT$.
-pub const STD_OUTPUT_HANDLE = maxInt(DWORD) - 11 + 1;
-
-/// The standard error device. Initially, this is the active console screen buffer, CONOUT$.
-pub const STD_ERROR_HANDLE = maxInt(DWORD) - 12 + 1;
-
-pub const WINAPI: std.builtin.CallingConvention = if (arch == .i386)
- .Stdcall
-else
- .C;
-
-pub const BOOL = c_int;
-pub const BOOLEAN = BYTE;
-pub const BYTE = u8;
-pub const CHAR = u8;
-pub const UCHAR = u8;
-pub const FLOAT = f32;
-pub const HANDLE = *c_void;
-pub const HCRYPTPROV = ULONG_PTR;
-pub const ATOM = u16;
-pub const HBRUSH = *opaque {};
-pub const HCURSOR = *opaque {};
-pub const HICON = *opaque {};
-pub const HINSTANCE = *opaque {};
-pub const HMENU = *opaque {};
-pub const HMODULE = *opaque {};
-pub const HWND = *opaque {};
-pub const HDC = *opaque {};
-pub const HGLRC = *opaque {};
-pub const FARPROC = *opaque {};
-pub const INT = c_int;
-pub const LPBYTE = *BYTE;
-pub const LPCH = *CHAR;
-pub const LPCSTR = [*:0]const CHAR;
-pub const LPCVOID = *const c_void;
-pub const LPDWORD = *DWORD;
-pub const LPSTR = [*:0]CHAR;
-pub const LPVOID = *c_void;
-pub const LPWSTR = [*:0]WCHAR;
-pub const LPCWSTR = [*:0]const WCHAR;
-pub const PVOID = *c_void;
-pub const PWSTR = [*:0]WCHAR;
-pub const SIZE_T = usize;
-pub const UINT = c_uint;
-pub const ULONG_PTR = usize;
-pub const LONG_PTR = isize;
-pub const DWORD_PTR = ULONG_PTR;
-pub const WCHAR = u16;
-pub const WORD = u16;
-pub const DWORD = u32;
-pub const DWORD64 = u64;
-pub const LARGE_INTEGER = i64;
-pub const ULARGE_INTEGER = u64;
-pub const USHORT = u16;
-pub const SHORT = i16;
-pub const ULONG = u32;
-pub const LONG = i32;
-pub const ULONGLONG = u64;
-pub const LONGLONG = i64;
-pub const HLOCAL = HANDLE;
-pub const LANGID = c_ushort;
-
-pub const WPARAM = usize;
-pub const LPARAM = LONG_PTR;
-pub const LRESULT = LONG_PTR;
-
-pub const va_list = *opaque {};
-
-pub const TRUE = 1;
-pub const FALSE = 0;
-
-pub const DEVICE_TYPE = ULONG;
-pub const FILE_DEVICE_BEEP: DEVICE_TYPE = 0x0001;
-pub const FILE_DEVICE_CD_ROM: DEVICE_TYPE = 0x0002;
-pub const FILE_DEVICE_CD_ROM_FILE_SYSTEM: DEVICE_TYPE = 0x0003;
-pub const FILE_DEVICE_CONTROLLER: DEVICE_TYPE = 0x0004;
-pub const FILE_DEVICE_DATALINK: DEVICE_TYPE = 0x0005;
-pub const FILE_DEVICE_DFS: DEVICE_TYPE = 0x0006;
-pub const FILE_DEVICE_DISK: DEVICE_TYPE = 0x0007;
-pub const FILE_DEVICE_DISK_FILE_SYSTEM: DEVICE_TYPE = 0x0008;
-pub const FILE_DEVICE_FILE_SYSTEM: DEVICE_TYPE = 0x0009;
-pub const FILE_DEVICE_INPORT_PORT: DEVICE_TYPE = 0x000a;
-pub const FILE_DEVICE_KEYBOARD: DEVICE_TYPE = 0x000b;
-pub const FILE_DEVICE_MAILSLOT: DEVICE_TYPE = 0x000c;
-pub const FILE_DEVICE_MIDI_IN: DEVICE_TYPE = 0x000d;
-pub const FILE_DEVICE_MIDI_OUT: DEVICE_TYPE = 0x000e;
-pub const FILE_DEVICE_MOUSE: DEVICE_TYPE = 0x000f;
-pub const FILE_DEVICE_MULTI_UNC_PROVIDER: DEVICE_TYPE = 0x0010;
-pub const FILE_DEVICE_NAMED_PIPE: DEVICE_TYPE = 0x0011;
-pub const FILE_DEVICE_NETWORK: DEVICE_TYPE = 0x0012;
-pub const FILE_DEVICE_NETWORK_BROWSER: DEVICE_TYPE = 0x0013;
-pub const FILE_DEVICE_NETWORK_FILE_SYSTEM: DEVICE_TYPE = 0x0014;
-pub const FILE_DEVICE_NULL: DEVICE_TYPE = 0x0015;
-pub const FILE_DEVICE_PARALLEL_PORT: DEVICE_TYPE = 0x0016;
-pub const FILE_DEVICE_PHYSICAL_NETCARD: DEVICE_TYPE = 0x0017;
-pub const FILE_DEVICE_PRINTER: DEVICE_TYPE = 0x0018;
-pub const FILE_DEVICE_SCANNER: DEVICE_TYPE = 0x0019;
-pub const FILE_DEVICE_SERIAL_MOUSE_PORT: DEVICE_TYPE = 0x001a;
-pub const FILE_DEVICE_SERIAL_PORT: DEVICE_TYPE = 0x001b;
-pub const FILE_DEVICE_SCREEN: DEVICE_TYPE = 0x001c;
-pub const FILE_DEVICE_SOUND: DEVICE_TYPE = 0x001d;
-pub const FILE_DEVICE_STREAMS: DEVICE_TYPE = 0x001e;
-pub const FILE_DEVICE_TAPE: DEVICE_TYPE = 0x001f;
-pub const FILE_DEVICE_TAPE_FILE_SYSTEM: DEVICE_TYPE = 0x0020;
-pub const FILE_DEVICE_TRANSPORT: DEVICE_TYPE = 0x0021;
-pub const FILE_DEVICE_UNKNOWN: DEVICE_TYPE = 0x0022;
-pub const FILE_DEVICE_VIDEO: DEVICE_TYPE = 0x0023;
-pub const FILE_DEVICE_VIRTUAL_DISK: DEVICE_TYPE = 0x0024;
-pub const FILE_DEVICE_WAVE_IN: DEVICE_TYPE = 0x0025;
-pub const FILE_DEVICE_WAVE_OUT: DEVICE_TYPE = 0x0026;
-pub const FILE_DEVICE_8042_PORT: DEVICE_TYPE = 0x0027;
-pub const FILE_DEVICE_NETWORK_REDIRECTOR: DEVICE_TYPE = 0x0028;
-pub const FILE_DEVICE_BATTERY: DEVICE_TYPE = 0x0029;
-pub const FILE_DEVICE_BUS_EXTENDER: DEVICE_TYPE = 0x002a;
-pub const FILE_DEVICE_MODEM: DEVICE_TYPE = 0x002b;
-pub const FILE_DEVICE_VDM: DEVICE_TYPE = 0x002c;
-pub const FILE_DEVICE_MASS_STORAGE: DEVICE_TYPE = 0x002d;
-pub const FILE_DEVICE_SMB: DEVICE_TYPE = 0x002e;
-pub const FILE_DEVICE_KS: DEVICE_TYPE = 0x002f;
-pub const FILE_DEVICE_CHANGER: DEVICE_TYPE = 0x0030;
-pub const FILE_DEVICE_SMARTCARD: DEVICE_TYPE = 0x0031;
-pub const FILE_DEVICE_ACPI: DEVICE_TYPE = 0x0032;
-pub const FILE_DEVICE_DVD: DEVICE_TYPE = 0x0033;
-pub const FILE_DEVICE_FULLSCREEN_VIDEO: DEVICE_TYPE = 0x0034;
-pub const FILE_DEVICE_DFS_FILE_SYSTEM: DEVICE_TYPE = 0x0035;
-pub const FILE_DEVICE_DFS_VOLUME: DEVICE_TYPE = 0x0036;
-pub const FILE_DEVICE_SERENUM: DEVICE_TYPE = 0x0037;
-pub const FILE_DEVICE_TERMSRV: DEVICE_TYPE = 0x0038;
-pub const FILE_DEVICE_KSEC: DEVICE_TYPE = 0x0039;
-pub const FILE_DEVICE_FIPS: DEVICE_TYPE = 0x003a;
-pub const FILE_DEVICE_INFINIBAND: DEVICE_TYPE = 0x003b;
-// TODO: missing values?
-pub const FILE_DEVICE_VMBUS: DEVICE_TYPE = 0x003e;
-pub const FILE_DEVICE_CRYPT_PROVIDER: DEVICE_TYPE = 0x003f;
-pub const FILE_DEVICE_WPD: DEVICE_TYPE = 0x0040;
-pub const FILE_DEVICE_BLUETOOTH: DEVICE_TYPE = 0x0041;
-pub const FILE_DEVICE_MT_COMPOSITE: DEVICE_TYPE = 0x0042;
-pub const FILE_DEVICE_MT_TRANSPORT: DEVICE_TYPE = 0x0043;
-pub const FILE_DEVICE_BIOMETRIC: DEVICE_TYPE = 0x0044;
-pub const FILE_DEVICE_PMI: DEVICE_TYPE = 0x0045;
-pub const FILE_DEVICE_EHSTOR: DEVICE_TYPE = 0x0046;
-pub const FILE_DEVICE_DEVAPI: DEVICE_TYPE = 0x0047;
-pub const FILE_DEVICE_GPIO: DEVICE_TYPE = 0x0048;
-pub const FILE_DEVICE_USBEX: DEVICE_TYPE = 0x0049;
-pub const FILE_DEVICE_CONSOLE: DEVICE_TYPE = 0x0050;
-pub const FILE_DEVICE_NFP: DEVICE_TYPE = 0x0051;
-pub const FILE_DEVICE_SYSENV: DEVICE_TYPE = 0x0052;
-pub const FILE_DEVICE_VIRTUAL_BLOCK: DEVICE_TYPE = 0x0053;
-pub const FILE_DEVICE_POINT_OF_SERVICE: DEVICE_TYPE = 0x0054;
-pub const FILE_DEVICE_STORAGE_REPLICATION: DEVICE_TYPE = 0x0055;
-pub const FILE_DEVICE_TRUST_ENV: DEVICE_TYPE = 0x0056;
-pub const FILE_DEVICE_UCM: DEVICE_TYPE = 0x0057;
-pub const FILE_DEVICE_UCMTCPCI: DEVICE_TYPE = 0x0058;
-pub const FILE_DEVICE_PERSISTENT_MEMORY: DEVICE_TYPE = 0x0059;
-pub const FILE_DEVICE_NVDIMM: DEVICE_TYPE = 0x005a;
-pub const FILE_DEVICE_HOLOGRAPHIC: DEVICE_TYPE = 0x005b;
-pub const FILE_DEVICE_SDFXHCI: DEVICE_TYPE = 0x005c;
-
-/// https://docs.microsoft.com/en-us/windows-hardware/drivers/kernel/buffer-descriptions-for-i-o-control-codes
-pub const TransferType = enum(u2) {
- METHOD_BUFFERED = 0,
- METHOD_IN_DIRECT = 1,
- METHOD_OUT_DIRECT = 2,
- METHOD_NEITHER = 3,
-};
-
-pub const FILE_ANY_ACCESS = 0;
-pub const FILE_READ_ACCESS = 1;
-pub const FILE_WRITE_ACCESS = 2;
-
-/// https://docs.microsoft.com/en-us/windows-hardware/drivers/kernel/defining-i-o-control-codes
-pub fn CTL_CODE(deviceType: u16, function: u12, method: TransferType, access: u2) DWORD {
- return (@as(DWORD, deviceType) << 16) |
- (@as(DWORD, access) << 14) |
- (@as(DWORD, function) << 2) |
- @enumToInt(method);
-}
-
-pub const INVALID_HANDLE_VALUE = @intToPtr(HANDLE, maxInt(usize));
-
-pub const INVALID_FILE_ATTRIBUTES = @as(DWORD, maxInt(DWORD));
-
-pub const FILE_ALL_INFORMATION = extern struct {
- BasicInformation: FILE_BASIC_INFORMATION,
- StandardInformation: FILE_STANDARD_INFORMATION,
- InternalInformation: FILE_INTERNAL_INFORMATION,
- EaInformation: FILE_EA_INFORMATION,
- AccessInformation: FILE_ACCESS_INFORMATION,
- PositionInformation: FILE_POSITION_INFORMATION,
- ModeInformation: FILE_MODE_INFORMATION,
- AlignmentInformation: FILE_ALIGNMENT_INFORMATION,
- NameInformation: FILE_NAME_INFORMATION,
-};
-
-pub const FILE_BASIC_INFORMATION = extern struct {
- CreationTime: LARGE_INTEGER,
- LastAccessTime: LARGE_INTEGER,
- LastWriteTime: LARGE_INTEGER,
- ChangeTime: LARGE_INTEGER,
- FileAttributes: ULONG,
-};
-
-pub const FILE_STANDARD_INFORMATION = extern struct {
- AllocationSize: LARGE_INTEGER,
- EndOfFile: LARGE_INTEGER,
- NumberOfLinks: ULONG,
- DeletePending: BOOLEAN,
- Directory: BOOLEAN,
-};
-
-pub const FILE_INTERNAL_INFORMATION = extern struct {
- IndexNumber: LARGE_INTEGER,
-};
-
-pub const FILE_EA_INFORMATION = extern struct {
- EaSize: ULONG,
-};
-
-pub const FILE_ACCESS_INFORMATION = extern struct {
- AccessFlags: ACCESS_MASK,
-};
-
-pub const FILE_POSITION_INFORMATION = extern struct {
- CurrentByteOffset: LARGE_INTEGER,
-};
-
-pub const FILE_END_OF_FILE_INFORMATION = extern struct {
- EndOfFile: LARGE_INTEGER,
-};
-
-pub const FILE_MODE_INFORMATION = extern struct {
- Mode: ULONG,
-};
-
-pub const FILE_ALIGNMENT_INFORMATION = extern struct {
- AlignmentRequirement: ULONG,
-};
-
-pub const FILE_NAME_INFORMATION = extern struct {
- FileNameLength: ULONG,
- FileName: [1]WCHAR,
-};
-
-pub const FILE_RENAME_INFORMATION = extern struct {
- ReplaceIfExists: BOOLEAN,
- RootDirectory: ?HANDLE,
- FileNameLength: ULONG,
- FileName: [1]WCHAR,
-};
-
-pub const IO_STATUS_BLOCK = extern struct {
- // "DUMMYUNIONNAME" expands to "u"
- u: extern union {
- Status: NTSTATUS,
- Pointer: ?*c_void,
- },
- Information: ULONG_PTR,
-};
-
-pub const FILE_INFORMATION_CLASS = enum(c_int) {
- FileDirectoryInformation = 1,
- FileFullDirectoryInformation,
- FileBothDirectoryInformation,
- FileBasicInformation,
- FileStandardInformation,
- FileInternalInformation,
- FileEaInformation,
- FileAccessInformation,
- FileNameInformation,
- FileRenameInformation,
- FileLinkInformation,
- FileNamesInformation,
- FileDispositionInformation,
- FilePositionInformation,
- FileFullEaInformation,
- FileModeInformation,
- FileAlignmentInformation,
- FileAllInformation,
- FileAllocationInformation,
- FileEndOfFileInformation,
- FileAlternateNameInformation,
- FileStreamInformation,
- FilePipeInformation,
- FilePipeLocalInformation,
- FilePipeRemoteInformation,
- FileMailslotQueryInformation,
- FileMailslotSetInformation,
- FileCompressionInformation,
- FileObjectIdInformation,
- FileCompletionInformation,
- FileMoveClusterInformation,
- FileQuotaInformation,
- FileReparsePointInformation,
- FileNetworkOpenInformation,
- FileAttributeTagInformation,
- FileTrackingInformation,
- FileIdBothDirectoryInformation,
- FileIdFullDirectoryInformation,
- FileValidDataLengthInformation,
- FileShortNameInformation,
- FileIoCompletionNotificationInformation,
- FileIoStatusBlockRangeInformation,
- FileIoPriorityHintInformation,
- FileSfioReserveInformation,
- FileSfioVolumeInformation,
- FileHardLinkInformation,
- FileProcessIdsUsingFileInformation,
- FileNormalizedNameInformation,
- FileNetworkPhysicalNameInformation,
- FileIdGlobalTxDirectoryInformation,
- FileIsRemoteDeviceInformation,
- FileUnusedInformation,
- FileNumaNodeInformation,
- FileStandardLinkInformation,
- FileRemoteProtocolInformation,
- FileRenameInformationBypassAccessCheck,
- FileLinkInformationBypassAccessCheck,
- FileVolumeNameInformation,
- FileIdInformation,
- FileIdExtdDirectoryInformation,
- FileReplaceCompletionInformation,
- FileHardLinkFullIdInformation,
- FileIdExtdBothDirectoryInformation,
- FileDispositionInformationEx,
- FileRenameInformationEx,
- FileRenameInformationExBypassAccessCheck,
- FileDesiredStorageClassInformation,
- FileStatInformation,
- FileMemoryPartitionInformation,
- FileStatLxInformation,
- FileCaseSensitiveInformation,
- FileLinkInformationEx,
- FileLinkInformationExBypassAccessCheck,
- FileStorageReserveIdInformation,
- FileCaseSensitiveInformationForceAccessCheck,
- FileMaximumInformation,
-};
-
-pub const OVERLAPPED = extern struct {
- Internal: ULONG_PTR,
- InternalHigh: ULONG_PTR,
- DUMMYUNIONNAME: extern union {
- DUMMYSTRUCTNAME: extern struct {
- Offset: DWORD,
- OffsetHigh: DWORD,
- },
- Pointer: ?PVOID,
- },
- hEvent: ?HANDLE,
-};
-pub const LPOVERLAPPED = *OVERLAPPED;
-
-pub const OVERLAPPED_ENTRY = extern struct {
- lpCompletionKey: ULONG_PTR,
- lpOverlapped: LPOVERLAPPED,
- Internal: ULONG_PTR,
- dwNumberOfBytesTransferred: DWORD,
-};
-pub const LPOVERLAPPED_ENTRY = *OVERLAPPED_ENTRY;
-
-pub const MAX_PATH = 260;
-
-// TODO issue #305
-pub const FILE_INFO_BY_HANDLE_CLASS = u32;
-pub const FileBasicInfo = 0;
-pub const FileStandardInfo = 1;
-pub const FileNameInfo = 2;
-pub const FileRenameInfo = 3;
-pub const FileDispositionInfo = 4;
-pub const FileAllocationInfo = 5;
-pub const FileEndOfFileInfo = 6;
-pub const FileStreamInfo = 7;
-pub const FileCompressionInfo = 8;
-pub const FileAttributeTagInfo = 9;
-pub const FileIdBothDirectoryInfo = 10;
-pub const FileIdBothDirectoryRestartInfo = 11;
-pub const FileIoPriorityHintInfo = 12;
-pub const FileRemoteProtocolInfo = 13;
-pub const FileFullDirectoryInfo = 14;
-pub const FileFullDirectoryRestartInfo = 15;
-pub const FileStorageInfo = 16;
-pub const FileAlignmentInfo = 17;
-pub const FileIdInfo = 18;
-pub const FileIdExtdDirectoryInfo = 19;
-pub const FileIdExtdDirectoryRestartInfo = 20;
-
-pub const BY_HANDLE_FILE_INFORMATION = extern struct {
- dwFileAttributes: DWORD,
- ftCreationTime: FILETIME,
- ftLastAccessTime: FILETIME,
- ftLastWriteTime: FILETIME,
- dwVolumeSerialNumber: DWORD,
- nFileSizeHigh: DWORD,
- nFileSizeLow: DWORD,
- nNumberOfLinks: DWORD,
- nFileIndexHigh: DWORD,
- nFileIndexLow: DWORD,
-};
-
-pub const FILE_NAME_INFO = extern struct {
- FileNameLength: DWORD,
- FileName: [1]WCHAR,
-};
-
-/// Return the normalized drive name. This is the default.
-pub const FILE_NAME_NORMALIZED = 0x0;
-
-/// Return the opened file name (not normalized).
-pub const FILE_NAME_OPENED = 0x8;
-
-/// Return the path with the drive letter. This is the default.
-pub const VOLUME_NAME_DOS = 0x0;
-
-/// Return the path with a volume GUID path instead of the drive name.
-pub const VOLUME_NAME_GUID = 0x1;
-
-/// Return the path with no drive information.
-pub const VOLUME_NAME_NONE = 0x4;
-
-/// Return the path with the volume device path.
-pub const VOLUME_NAME_NT = 0x2;
-
-pub const SECURITY_ATTRIBUTES = extern struct {
- nLength: DWORD,
- lpSecurityDescriptor: ?*c_void,
- bInheritHandle: BOOL,
-};
-pub const PSECURITY_ATTRIBUTES = *SECURITY_ATTRIBUTES;
-pub const LPSECURITY_ATTRIBUTES = *SECURITY_ATTRIBUTES;
-
-pub const PIPE_ACCESS_INBOUND = 0x00000001;
-pub const PIPE_ACCESS_OUTBOUND = 0x00000002;
-pub const PIPE_ACCESS_DUPLEX = 0x00000003;
-
-pub const PIPE_TYPE_BYTE = 0x00000000;
-pub const PIPE_TYPE_MESSAGE = 0x00000004;
-
-pub const PIPE_READMODE_BYTE = 0x00000000;
-pub const PIPE_READMODE_MESSAGE = 0x00000002;
-
-pub const PIPE_WAIT = 0x00000000;
-pub const PIPE_NOWAIT = 0x00000001;
-
-pub const GENERIC_READ = 0x80000000;
-pub const GENERIC_WRITE = 0x40000000;
-pub const GENERIC_EXECUTE = 0x20000000;
-pub const GENERIC_ALL = 0x10000000;
-
-pub const FILE_SHARE_DELETE = 0x00000004;
-pub const FILE_SHARE_READ = 0x00000001;
-pub const FILE_SHARE_WRITE = 0x00000002;
-
-pub const DELETE = 0x00010000;
-pub const READ_CONTROL = 0x00020000;
-pub const WRITE_DAC = 0x00040000;
-pub const WRITE_OWNER = 0x00080000;
-pub const SYNCHRONIZE = 0x00100000;
-pub const STANDARD_RIGHTS_READ = READ_CONTROL;
-pub const STANDARD_RIGHTS_WRITE = READ_CONTROL;
-pub const STANDARD_RIGHTS_EXECUTE = READ_CONTROL;
-pub const STANDARD_RIGHTS_REQUIRED = DELETE | READ_CONTROL | WRITE_DAC | WRITE_OWNER;
-
-// disposition for NtCreateFile
-pub const FILE_SUPERSEDE = 0;
-pub const FILE_OPEN = 1;
-pub const FILE_CREATE = 2;
-pub const FILE_OPEN_IF = 3;
-pub const FILE_OVERWRITE = 4;
-pub const FILE_OVERWRITE_IF = 5;
-pub const FILE_MAXIMUM_DISPOSITION = 5;
-
-// flags for NtCreateFile and NtOpenFile
-pub const FILE_READ_DATA = 0x00000001;
-pub const FILE_LIST_DIRECTORY = 0x00000001;
-pub const FILE_WRITE_DATA = 0x00000002;
-pub const FILE_ADD_FILE = 0x00000002;
-pub const FILE_APPEND_DATA = 0x00000004;
-pub const FILE_ADD_SUBDIRECTORY = 0x00000004;
-pub const FILE_CREATE_PIPE_INSTANCE = 0x00000004;
-pub const FILE_READ_EA = 0x00000008;
-pub const FILE_WRITE_EA = 0x00000010;
-pub const FILE_EXECUTE = 0x00000020;
-pub const FILE_TRAVERSE = 0x00000020;
-pub const FILE_DELETE_CHILD = 0x00000040;
-pub const FILE_READ_ATTRIBUTES = 0x00000080;
-pub const FILE_WRITE_ATTRIBUTES = 0x00000100;
-
-pub const FILE_DIRECTORY_FILE = 0x00000001;
-pub const FILE_WRITE_THROUGH = 0x00000002;
-pub const FILE_SEQUENTIAL_ONLY = 0x00000004;
-pub const FILE_NO_INTERMEDIATE_BUFFERING = 0x00000008;
-pub const FILE_SYNCHRONOUS_IO_ALERT = 0x00000010;
-pub const FILE_SYNCHRONOUS_IO_NONALERT = 0x00000020;
-pub const FILE_NON_DIRECTORY_FILE = 0x00000040;
-pub const FILE_CREATE_TREE_CONNECTION = 0x00000080;
-pub const FILE_COMPLETE_IF_OPLOCKED = 0x00000100;
-pub const FILE_NO_EA_KNOWLEDGE = 0x00000200;
-pub const FILE_OPEN_FOR_RECOVERY = 0x00000400;
-pub const FILE_RANDOM_ACCESS = 0x00000800;
-pub const FILE_DELETE_ON_CLOSE = 0x00001000;
-pub const FILE_OPEN_BY_FILE_ID = 0x00002000;
-pub const FILE_OPEN_FOR_BACKUP_INTENT = 0x00004000;
-pub const FILE_NO_COMPRESSION = 0x00008000;
-pub const FILE_RESERVE_OPFILTER = 0x00100000;
-pub const FILE_OPEN_REPARSE_POINT = 0x00200000;
-pub const FILE_OPEN_OFFLINE_FILE = 0x00400000;
-pub const FILE_OPEN_FOR_FREE_SPACE_QUERY = 0x00800000;
-
-pub const CREATE_ALWAYS = 2;
-pub const CREATE_NEW = 1;
-pub const OPEN_ALWAYS = 4;
-pub const OPEN_EXISTING = 3;
-pub const TRUNCATE_EXISTING = 5;
-
-pub const FILE_ATTRIBUTE_ARCHIVE = 0x20;
-pub const FILE_ATTRIBUTE_COMPRESSED = 0x800;
-pub const FILE_ATTRIBUTE_DEVICE = 0x40;
-pub const FILE_ATTRIBUTE_DIRECTORY = 0x10;
-pub const FILE_ATTRIBUTE_ENCRYPTED = 0x4000;
-pub const FILE_ATTRIBUTE_HIDDEN = 0x2;
-pub const FILE_ATTRIBUTE_INTEGRITY_STREAM = 0x8000;
-pub const FILE_ATTRIBUTE_NORMAL = 0x80;
-pub const FILE_ATTRIBUTE_NOT_CONTENT_INDEXED = 0x2000;
-pub const FILE_ATTRIBUTE_NO_SCRUB_DATA = 0x20000;
-pub const FILE_ATTRIBUTE_OFFLINE = 0x1000;
-pub const FILE_ATTRIBUTE_READONLY = 0x1;
-pub const FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS = 0x400000;
-pub const FILE_ATTRIBUTE_RECALL_ON_OPEN = 0x40000;
-pub const FILE_ATTRIBUTE_REPARSE_POINT = 0x400;
-pub const FILE_ATTRIBUTE_SPARSE_FILE = 0x200;
-pub const FILE_ATTRIBUTE_SYSTEM = 0x4;
-pub const FILE_ATTRIBUTE_TEMPORARY = 0x100;
-pub const FILE_ATTRIBUTE_VIRTUAL = 0x10000;
-
-// flags for CreateEvent
-pub const CREATE_EVENT_INITIAL_SET = 0x00000002;
-pub const CREATE_EVENT_MANUAL_RESET = 0x00000001;
-
-pub const EVENT_ALL_ACCESS = 0x1F0003;
-pub const EVENT_MODIFY_STATE = 0x0002;
-
-pub const PROCESS_INFORMATION = extern struct {
- hProcess: HANDLE,
- hThread: HANDLE,
- dwProcessId: DWORD,
- dwThreadId: DWORD,
-};
-
-pub const STARTUPINFOW = extern struct {
- cb: DWORD,
- lpReserved: ?LPWSTR,
- lpDesktop: ?LPWSTR,
- lpTitle: ?LPWSTR,
- dwX: DWORD,
- dwY: DWORD,
- dwXSize: DWORD,
- dwYSize: DWORD,
- dwXCountChars: DWORD,
- dwYCountChars: DWORD,
- dwFillAttribute: DWORD,
- dwFlags: DWORD,
- wShowWindow: WORD,
- cbReserved2: WORD,
- lpReserved2: ?LPBYTE,
- hStdInput: ?HANDLE,
- hStdOutput: ?HANDLE,
- hStdError: ?HANDLE,
-};
-
-pub const STARTF_FORCEONFEEDBACK = 0x00000040;
-pub const STARTF_FORCEOFFFEEDBACK = 0x00000080;
-pub const STARTF_PREVENTPINNING = 0x00002000;
-pub const STARTF_RUNFULLSCREEN = 0x00000020;
-pub const STARTF_TITLEISAPPID = 0x00001000;
-pub const STARTF_TITLEISLINKNAME = 0x00000800;
-pub const STARTF_UNTRUSTEDSOURCE = 0x00008000;
-pub const STARTF_USECOUNTCHARS = 0x00000008;
-pub const STARTF_USEFILLATTRIBUTE = 0x00000010;
-pub const STARTF_USEHOTKEY = 0x00000200;
-pub const STARTF_USEPOSITION = 0x00000004;
-pub const STARTF_USESHOWWINDOW = 0x00000001;
-pub const STARTF_USESIZE = 0x00000002;
-pub const STARTF_USESTDHANDLES = 0x00000100;
-
-pub const INFINITE = 4294967295;
-
-pub const MAXIMUM_WAIT_OBJECTS = 64;
-
-pub const WAIT_ABANDONED = 0x00000080;
-pub const WAIT_ABANDONED_0 = WAIT_ABANDONED + 0;
-pub const WAIT_OBJECT_0 = 0x00000000;
-pub const WAIT_TIMEOUT = 0x00000102;
-pub const WAIT_FAILED = 0xFFFFFFFF;
-
-pub const HANDLE_FLAG_INHERIT = 0x00000001;
-pub const HANDLE_FLAG_PROTECT_FROM_CLOSE = 0x00000002;
-
-pub const MOVEFILE_COPY_ALLOWED = 2;
-pub const MOVEFILE_CREATE_HARDLINK = 16;
-pub const MOVEFILE_DELAY_UNTIL_REBOOT = 4;
-pub const MOVEFILE_FAIL_IF_NOT_TRACKABLE = 32;
-pub const MOVEFILE_REPLACE_EXISTING = 1;
-pub const MOVEFILE_WRITE_THROUGH = 8;
-
-pub const FILE_BEGIN = 0;
-pub const FILE_CURRENT = 1;
-pub const FILE_END = 2;
-
-pub const HEAP_CREATE_ENABLE_EXECUTE = 0x00040000;
-pub const HEAP_REALLOC_IN_PLACE_ONLY = 0x00000010;
-pub const HEAP_GENERATE_EXCEPTIONS = 0x00000004;
-pub const HEAP_NO_SERIALIZE = 0x00000001;
-
-// AllocationType values
-pub const MEM_COMMIT = 0x1000;
-pub const MEM_RESERVE = 0x2000;
-pub const MEM_RESET = 0x80000;
-pub const MEM_RESET_UNDO = 0x1000000;
-pub const MEM_LARGE_PAGES = 0x20000000;
-pub const MEM_PHYSICAL = 0x400000;
-pub const MEM_TOP_DOWN = 0x100000;
-pub const MEM_WRITE_WATCH = 0x200000;
-
-// Protect values
-pub const PAGE_EXECUTE = 0x10;
-pub const PAGE_EXECUTE_READ = 0x20;
-pub const PAGE_EXECUTE_READWRITE = 0x40;
-pub const PAGE_EXECUTE_WRITECOPY = 0x80;
-pub const PAGE_NOACCESS = 0x01;
-pub const PAGE_READONLY = 0x02;
-pub const PAGE_READWRITE = 0x04;
-pub const PAGE_WRITECOPY = 0x08;
-pub const PAGE_TARGETS_INVALID = 0x40000000;
-pub const PAGE_TARGETS_NO_UPDATE = 0x40000000; // Same as PAGE_TARGETS_INVALID
-pub const PAGE_GUARD = 0x100;
-pub const PAGE_NOCACHE = 0x200;
-pub const PAGE_WRITECOMBINE = 0x400;
-
-// FreeType values
-pub const MEM_COALESCE_PLACEHOLDERS = 0x1;
-pub const MEM_RESERVE_PLACEHOLDERS = 0x2;
-pub const MEM_DECOMMIT = 0x4000;
-pub const MEM_RELEASE = 0x8000;
-
-pub const PTHREAD_START_ROUTINE = fn (LPVOID) callconv(.C) DWORD;
-pub const LPTHREAD_START_ROUTINE = PTHREAD_START_ROUTINE;
-
-pub const WIN32_FIND_DATAW = extern struct {
- dwFileAttributes: DWORD,
- ftCreationTime: FILETIME,
- ftLastAccessTime: FILETIME,
- ftLastWriteTime: FILETIME,
- nFileSizeHigh: DWORD,
- nFileSizeLow: DWORD,
- dwReserved0: DWORD,
- dwReserved1: DWORD,
- cFileName: [260]u16,
- cAlternateFileName: [14]u16,
-};
-
-pub const FILETIME = extern struct {
- dwLowDateTime: DWORD,
- dwHighDateTime: DWORD,
-};
-
-pub const SYSTEM_INFO = extern struct {
- anon1: extern union {
- dwOemId: DWORD,
- anon2: extern struct {
- wProcessorArchitecture: WORD,
- wReserved: WORD,
- },
- },
- dwPageSize: DWORD,
- lpMinimumApplicationAddress: LPVOID,
- lpMaximumApplicationAddress: LPVOID,
- dwActiveProcessorMask: DWORD_PTR,
- dwNumberOfProcessors: DWORD,
- dwProcessorType: DWORD,
- dwAllocationGranularity: DWORD,
- wProcessorLevel: WORD,
- wProcessorRevision: WORD,
-};
-
-pub const HRESULT = c_long;
-
-pub const KNOWNFOLDERID = GUID;
-pub const GUID = extern struct {
- Data1: c_ulong,
- Data2: c_ushort,
- Data3: c_ushort,
- Data4: [8]u8,
-
- pub fn parse(str: []const u8) GUID {
- var guid: GUID = undefined;
- var index: usize = 0;
- assert(str[index] == '{');
- index += 1;
-
- guid.Data1 = std.fmt.parseUnsigned(c_ulong, str[index .. index + 8], 16) catch unreachable;
- index += 8;
-
- assert(str[index] == '-');
- index += 1;
-
- guid.Data2 = std.fmt.parseUnsigned(c_ushort, str[index .. index + 4], 16) catch unreachable;
- index += 4;
-
- assert(str[index] == '-');
- index += 1;
-
- guid.Data3 = std.fmt.parseUnsigned(c_ushort, str[index .. index + 4], 16) catch unreachable;
- index += 4;
-
- assert(str[index] == '-');
- index += 1;
-
- guid.Data4[0] = std.fmt.parseUnsigned(u8, str[index .. index + 2], 16) catch unreachable;
- index += 2;
- guid.Data4[1] = std.fmt.parseUnsigned(u8, str[index .. index + 2], 16) catch unreachable;
- index += 2;
-
- assert(str[index] == '-');
- index += 1;
-
- var i: usize = 2;
- while (i < guid.Data4.len) : (i += 1) {
- guid.Data4[i] = std.fmt.parseUnsigned(u8, str[index .. index + 2], 16) catch unreachable;
- index += 2;
- }
-
- assert(str[index] == '}');
- index += 1;
- return guid;
- }
-};
-
-pub const FOLDERID_LocalAppData = GUID.parse("{F1B32785-6FBA-4FCF-9D55-7B8E7F157091}");
-
-pub const KF_FLAG_DEFAULT = 0;
-pub const KF_FLAG_NO_APPCONTAINER_REDIRECTION = 65536;
-pub const KF_FLAG_CREATE = 32768;
-pub const KF_FLAG_DONT_VERIFY = 16384;
-pub const KF_FLAG_DONT_UNEXPAND = 8192;
-pub const KF_FLAG_NO_ALIAS = 4096;
-pub const KF_FLAG_INIT = 2048;
-pub const KF_FLAG_DEFAULT_PATH = 1024;
-pub const KF_FLAG_NOT_PARENT_RELATIVE = 512;
-pub const KF_FLAG_SIMPLE_IDLIST = 256;
-pub const KF_FLAG_ALIAS_ONLY = -2147483648;
-
-pub const S_OK = 0;
-pub const E_NOTIMPL = @bitCast(c_long, @as(c_ulong, 0x80004001));
-pub const E_NOINTERFACE = @bitCast(c_long, @as(c_ulong, 0x80004002));
-pub const E_POINTER = @bitCast(c_long, @as(c_ulong, 0x80004003));
-pub const E_ABORT = @bitCast(c_long, @as(c_ulong, 0x80004004));
-pub const E_FAIL = @bitCast(c_long, @as(c_ulong, 0x80004005));
-pub const E_UNEXPECTED = @bitCast(c_long, @as(c_ulong, 0x8000FFFF));
-pub const E_ACCESSDENIED = @bitCast(c_long, @as(c_ulong, 0x80070005));
-pub const E_HANDLE = @bitCast(c_long, @as(c_ulong, 0x80070006));
-pub const E_OUTOFMEMORY = @bitCast(c_long, @as(c_ulong, 0x8007000E));
-pub const E_INVALIDARG = @bitCast(c_long, @as(c_ulong, 0x80070057));
-
-pub const FILE_FLAG_BACKUP_SEMANTICS = 0x02000000;
-pub const FILE_FLAG_DELETE_ON_CLOSE = 0x04000000;
-pub const FILE_FLAG_NO_BUFFERING = 0x20000000;
-pub const FILE_FLAG_OPEN_NO_RECALL = 0x00100000;
-pub const FILE_FLAG_OPEN_REPARSE_POINT = 0x00200000;
-pub const FILE_FLAG_OVERLAPPED = 0x40000000;
-pub const FILE_FLAG_POSIX_SEMANTICS = 0x0100000;
-pub const FILE_FLAG_RANDOM_ACCESS = 0x10000000;
-pub const FILE_FLAG_SESSION_AWARE = 0x00800000;
-pub const FILE_FLAG_SEQUENTIAL_SCAN = 0x08000000;
-pub const FILE_FLAG_WRITE_THROUGH = 0x80000000;
-
-pub const RECT = extern struct {
- left: LONG,
- top: LONG,
- right: LONG,
- bottom: LONG,
-};
-
-pub const SMALL_RECT = extern struct {
- Left: SHORT,
- Top: SHORT,
- Right: SHORT,
- Bottom: SHORT,
-};
-
-pub const POINT = extern struct {
- x: LONG,
- y: LONG,
-};
-
-pub const COORD = extern struct {
- X: SHORT,
- Y: SHORT,
-};
-
-pub const CREATE_UNICODE_ENVIRONMENT = 1024;
-
-pub const TLS_OUT_OF_INDEXES = 4294967295;
-pub const IMAGE_TLS_DIRECTORY = extern struct {
- StartAddressOfRawData: usize,
- EndAddressOfRawData: usize,
- AddressOfIndex: usize,
- AddressOfCallBacks: usize,
- SizeOfZeroFill: u32,
- Characteristics: u32,
-};
-pub const IMAGE_TLS_DIRECTORY64 = IMAGE_TLS_DIRECTORY;
-pub const IMAGE_TLS_DIRECTORY32 = IMAGE_TLS_DIRECTORY;
-
-pub const PIMAGE_TLS_CALLBACK = ?fn (PVOID, DWORD, PVOID) callconv(.C) void;
-
-pub const PROV_RSA_FULL = 1;
-
-pub const REGSAM = ACCESS_MASK;
-pub const ACCESS_MASK = DWORD;
-pub const PHKEY = *HKEY;
-pub const HKEY = *HKEY__;
-pub const HKEY__ = extern struct {
- unused: c_int,
-};
-pub const LSTATUS = LONG;
-
-pub const FILE_NOTIFY_INFORMATION = extern struct {
- NextEntryOffset: DWORD,
- Action: DWORD,
- FileNameLength: DWORD,
- // Flexible array member
- // FileName: [1]WCHAR,
-};
-
-pub const FILE_ACTION_ADDED = 0x00000001;
-pub const FILE_ACTION_REMOVED = 0x00000002;
-pub const FILE_ACTION_MODIFIED = 0x00000003;
-pub const FILE_ACTION_RENAMED_OLD_NAME = 0x00000004;
-pub const FILE_ACTION_RENAMED_NEW_NAME = 0x00000005;
-
-pub const LPOVERLAPPED_COMPLETION_ROUTINE = ?fn (DWORD, DWORD, *OVERLAPPED) callconv(.C) void;
-
-pub const FILE_NOTIFY_CHANGE_CREATION = 64;
-pub const FILE_NOTIFY_CHANGE_SIZE = 8;
-pub const FILE_NOTIFY_CHANGE_SECURITY = 256;
-pub const FILE_NOTIFY_CHANGE_LAST_ACCESS = 32;
-pub const FILE_NOTIFY_CHANGE_LAST_WRITE = 16;
-pub const FILE_NOTIFY_CHANGE_DIR_NAME = 2;
-pub const FILE_NOTIFY_CHANGE_FILE_NAME = 1;
-pub const FILE_NOTIFY_CHANGE_ATTRIBUTES = 4;
-
-pub const CONSOLE_SCREEN_BUFFER_INFO = extern struct {
- dwSize: COORD,
- dwCursorPosition: COORD,
- wAttributes: WORD,
- srWindow: SMALL_RECT,
- dwMaximumWindowSize: COORD,
-};
-
-pub const FOREGROUND_BLUE = 1;
-pub const FOREGROUND_GREEN = 2;
-pub const FOREGROUND_RED = 4;
-pub const FOREGROUND_INTENSITY = 8;
-
-pub const LIST_ENTRY = extern struct {
- Flink: *LIST_ENTRY,
- Blink: *LIST_ENTRY,
-};
-
-pub const RTL_CRITICAL_SECTION_DEBUG = extern struct {
- Type: WORD,
- CreatorBackTraceIndex: WORD,
- CriticalSection: *RTL_CRITICAL_SECTION,
- ProcessLocksList: LIST_ENTRY,
- EntryCount: DWORD,
- ContentionCount: DWORD,
- Flags: DWORD,
- CreatorBackTraceIndexHigh: WORD,
- SpareWORD: WORD,
-};
-
-pub const RTL_CRITICAL_SECTION = extern struct {
- DebugInfo: *RTL_CRITICAL_SECTION_DEBUG,
- LockCount: LONG,
- RecursionCount: LONG,
- OwningThread: HANDLE,
- LockSemaphore: HANDLE,
- SpinCount: ULONG_PTR,
-};
-
-pub const CRITICAL_SECTION = RTL_CRITICAL_SECTION;
-pub const INIT_ONCE = RTL_RUN_ONCE;
-pub const INIT_ONCE_STATIC_INIT = RTL_RUN_ONCE_INIT;
-pub const INIT_ONCE_FN = fn (InitOnce: *INIT_ONCE, Parameter: ?*c_void, Context: ?*c_void) callconv(.C) BOOL;
-
-pub const RTL_RUN_ONCE = extern struct {
- Ptr: ?*c_void,
-};
-
-pub const RTL_RUN_ONCE_INIT = RTL_RUN_ONCE{ .Ptr = null };
-
-pub const COINIT_APARTMENTTHREADED = COINIT.COINIT_APARTMENTTHREADED;
-pub const COINIT_MULTITHREADED = COINIT.COINIT_MULTITHREADED;
-pub const COINIT_DISABLE_OLE1DDE = COINIT.COINIT_DISABLE_OLE1DDE;
-pub const COINIT_SPEED_OVER_MEMORY = COINIT.COINIT_SPEED_OVER_MEMORY;
-pub const COINIT = enum(c_int) {
- COINIT_APARTMENTTHREADED = 2,
- COINIT_MULTITHREADED = 0,
- COINIT_DISABLE_OLE1DDE = 4,
- COINIT_SPEED_OVER_MEMORY = 8,
-};
-
-/// > The maximum path of 32,767 characters is approximate, because the "\\?\"
-/// > prefix may be expanded to a longer string by the system at run time, and
-/// > this expansion applies to the total length.
-/// from https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file#maximum-path-length-limitation
-pub const PATH_MAX_WIDE = 32767;
-
-pub const FORMAT_MESSAGE_ALLOCATE_BUFFER = 0x00000100;
-pub const FORMAT_MESSAGE_ARGUMENT_ARRAY = 0x00002000;
-pub const FORMAT_MESSAGE_FROM_HMODULE = 0x00000800;
-pub const FORMAT_MESSAGE_FROM_STRING = 0x00000400;
-pub const FORMAT_MESSAGE_FROM_SYSTEM = 0x00001000;
-pub const FORMAT_MESSAGE_IGNORE_INSERTS = 0x00000200;
-pub const FORMAT_MESSAGE_MAX_WIDTH_MASK = 0x000000FF;
-
-pub const EXCEPTION_DATATYPE_MISALIGNMENT = 0x80000002;
-pub const EXCEPTION_ACCESS_VIOLATION = 0xc0000005;
-pub const EXCEPTION_ILLEGAL_INSTRUCTION = 0xc000001d;
-pub const EXCEPTION_STACK_OVERFLOW = 0xc00000fd;
-pub const EXCEPTION_CONTINUE_SEARCH = 0;
-
-pub const EXCEPTION_RECORD = extern struct {
- ExceptionCode: u32,
- ExceptionFlags: u32,
- ExceptionRecord: *EXCEPTION_RECORD,
- ExceptionAddress: *c_void,
- NumberParameters: u32,
- ExceptionInformation: [15]usize,
-};
-
-pub usingnamespace switch (arch) {
- .i386 => struct {
- pub const FLOATING_SAVE_AREA = extern struct {
- ControlWord: DWORD,
- StatusWord: DWORD,
- TagWord: DWORD,
- ErrorOffset: DWORD,
- ErrorSelector: DWORD,
- DataOffset: DWORD,
- DataSelector: DWORD,
- RegisterArea: [80]BYTE,
- Cr0NpxState: DWORD,
- };
-
- pub const CONTEXT = extern struct {
- ContextFlags: DWORD,
- Dr0: DWORD,
- Dr1: DWORD,
- Dr2: DWORD,
- Dr3: DWORD,
- Dr6: DWORD,
- Dr7: DWORD,
- FloatSave: FLOATING_SAVE_AREA,
- SegGs: DWORD,
- SegFs: DWORD,
- SegEs: DWORD,
- SegDs: DWORD,
- Edi: DWORD,
- Esi: DWORD,
- Ebx: DWORD,
- Edx: DWORD,
- Ecx: DWORD,
- Eax: DWORD,
- Ebp: DWORD,
- Eip: DWORD,
- SegCs: DWORD,
- EFlags: DWORD,
- Esp: DWORD,
- SegSs: DWORD,
- ExtendedRegisters: [512]BYTE,
-
- pub fn getRegs(ctx: *const CONTEXT) struct { bp: usize, ip: usize } {
- return .{ .bp = ctx.Ebp, .ip = ctx.Eip };
- }
- };
-
- pub const PCONTEXT = *CONTEXT;
- },
- .x86_64 => struct {
- pub const M128A = extern struct {
- Low: ULONGLONG,
- High: LONGLONG,
- };
-
- pub const XMM_SAVE_AREA32 = extern struct {
- ControlWord: WORD,
- StatusWord: WORD,
- TagWord: BYTE,
- Reserved1: BYTE,
- ErrorOpcode: WORD,
- ErrorOffset: DWORD,
- ErrorSelector: WORD,
- Reserved2: WORD,
- DataOffset: DWORD,
- DataSelector: WORD,
- Reserved3: WORD,
- MxCsr: DWORD,
- MxCsr_Mask: DWORD,
- FloatRegisters: [8]M128A,
- XmmRegisters: [16]M128A,
- Reserved4: [96]BYTE,
- };
-
- pub const CONTEXT = extern struct {
- P1Home: DWORD64,
- P2Home: DWORD64,
- P3Home: DWORD64,
- P4Home: DWORD64,
- P5Home: DWORD64,
- P6Home: DWORD64,
- ContextFlags: DWORD,
- MxCsr: DWORD,
- SegCs: WORD,
- SegDs: WORD,
- SegEs: WORD,
- SegFs: WORD,
- SegGs: WORD,
- SegSs: WORD,
- EFlags: DWORD,
- Dr0: DWORD64,
- Dr1: DWORD64,
- Dr2: DWORD64,
- Dr3: DWORD64,
- Dr6: DWORD64,
- Dr7: DWORD64,
- Rax: DWORD64,
- Rcx: DWORD64,
- Rdx: DWORD64,
- Rbx: DWORD64,
- Rsp: DWORD64,
- Rbp: DWORD64,
- Rsi: DWORD64,
- Rdi: DWORD64,
- R8: DWORD64,
- R9: DWORD64,
- R10: DWORD64,
- R11: DWORD64,
- R12: DWORD64,
- R13: DWORD64,
- R14: DWORD64,
- R15: DWORD64,
- Rip: DWORD64,
- DUMMYUNIONNAME: extern union {
- FltSave: XMM_SAVE_AREA32,
- FloatSave: XMM_SAVE_AREA32,
- DUMMYSTRUCTNAME: extern struct {
- Header: [2]M128A,
- Legacy: [8]M128A,
- Xmm0: M128A,
- Xmm1: M128A,
- Xmm2: M128A,
- Xmm3: M128A,
- Xmm4: M128A,
- Xmm5: M128A,
- Xmm6: M128A,
- Xmm7: M128A,
- Xmm8: M128A,
- Xmm9: M128A,
- Xmm10: M128A,
- Xmm11: M128A,
- Xmm12: M128A,
- Xmm13: M128A,
- Xmm14: M128A,
- Xmm15: M128A,
- },
- },
- VectorRegister: [26]M128A,
- VectorControl: DWORD64,
- DebugControl: DWORD64,
- LastBranchToRip: DWORD64,
- LastBranchFromRip: DWORD64,
- LastExceptionToRip: DWORD64,
- LastExceptionFromRip: DWORD64,
-
- pub fn getRegs(ctx: *const CONTEXT) struct { bp: usize, ip: usize } {
- return .{ .bp = ctx.Rbp, .ip = ctx.Rip };
- }
- };
-
- pub const PCONTEXT = *CONTEXT;
- },
- .aarch64 => struct {
- pub const NEON128 = extern union {
- DUMMYSTRUCTNAME: extern struct {
- Low: ULONGLONG,
- High: LONGLONG,
- },
- D: [2]f64,
- S: [4]f32,
- H: [8]WORD,
- B: [16]BYTE,
- };
-
- pub const CONTEXT = extern struct {
- ContextFlags: ULONG,
- Cpsr: ULONG,
- DUMMYUNIONNAME: extern union {
- DUMMYSTRUCTNAME: extern struct {
- X0: DWORD64,
- X1: DWORD64,
- X2: DWORD64,
- X3: DWORD64,
- X4: DWORD64,
- X5: DWORD64,
- X6: DWORD64,
- X7: DWORD64,
- X8: DWORD64,
- X9: DWORD64,
- X10: DWORD64,
- X11: DWORD64,
- X12: DWORD64,
- X13: DWORD64,
- X14: DWORD64,
- X15: DWORD64,
- X16: DWORD64,
- X17: DWORD64,
- X18: DWORD64,
- X19: DWORD64,
- X20: DWORD64,
- X21: DWORD64,
- X22: DWORD64,
- X23: DWORD64,
- X24: DWORD64,
- X25: DWORD64,
- X26: DWORD64,
- X27: DWORD64,
- X28: DWORD64,
- Fp: DWORD64,
- Lr: DWORD64,
- },
- X: [31]DWORD64,
- },
- Sp: DWORD64,
- Pc: DWORD64,
- V: [32]NEON128,
- Fpcr: DWORD,
- Fpsr: DWORD,
- Bcr: [8]DWORD,
- Bvr: [8]DWORD64,
- Wcr: [2]DWORD,
- Wvr: [2]DWORD64,
-
- pub fn getRegs(ctx: *const CONTEXT) struct { bp: usize, ip: usize } {
- return .{
- .bp = ctx.DUMMYUNIONNAME.DUMMYSTRUCTNAME.Fp,
- .ip = ctx.Pc,
- };
- }
- };
-
- pub const PCONTEXT = *CONTEXT;
- },
- else => struct {
- pub const PCONTEXT = *c_void;
- },
-};
-
-pub const EXCEPTION_POINTERS = extern struct {
- ExceptionRecord: *EXCEPTION_RECORD,
- ContextRecord: PCONTEXT,
-};
-
-pub const VECTORED_EXCEPTION_HANDLER = fn (ExceptionInfo: *EXCEPTION_POINTERS) callconv(WINAPI) c_long;
-
-pub const OBJECT_ATTRIBUTES = extern struct {
- Length: ULONG,
- RootDirectory: ?HANDLE,
- ObjectName: *UNICODE_STRING,
- Attributes: ULONG,
- SecurityDescriptor: ?*c_void,
- SecurityQualityOfService: ?*c_void,
-};
-
-pub const OBJ_INHERIT = 0x00000002;
-pub const OBJ_PERMANENT = 0x00000010;
-pub const OBJ_EXCLUSIVE = 0x00000020;
-pub const OBJ_CASE_INSENSITIVE = 0x00000040;
-pub const OBJ_OPENIF = 0x00000080;
-pub const OBJ_OPENLINK = 0x00000100;
-pub const OBJ_KERNEL_HANDLE = 0x00000200;
-pub const OBJ_VALID_ATTRIBUTES = 0x000003F2;
-
-pub const UNICODE_STRING = extern struct {
- Length: c_ushort,
- MaximumLength: c_ushort,
- Buffer: [*]WCHAR,
-};
-
-const ACTIVATION_CONTEXT_DATA = opaque {};
-const ASSEMBLY_STORAGE_MAP = opaque {};
-const FLS_CALLBACK_INFO = opaque {};
-const RTL_BITMAP = opaque {};
-pub const PRTL_BITMAP = *RTL_BITMAP;
-const KAFFINITY = usize;
-
-pub const TEB = extern struct {
- Reserved1: [12]PVOID,
- ProcessEnvironmentBlock: *PEB,
- Reserved2: [399]PVOID,
- Reserved3: [1952]u8,
- TlsSlots: [64]PVOID,
- Reserved4: [8]u8,
- Reserved5: [26]PVOID,
- ReservedForOle: PVOID,
- Reserved6: [4]PVOID,
- TlsExpansionSlots: PVOID,
-};
-
-/// Process Environment Block
-/// Microsoft documentation of this is incomplete, the fields here are taken from various resources including:
-/// - https://github.com/wine-mirror/wine/blob/1aff1e6a370ee8c0213a0fd4b220d121da8527aa/include/winternl.h#L269
-/// - https://www.geoffchappell.com/studies/windows/win32/ntdll/structs/peb/index.htm
-pub const PEB = extern struct {
- // Versions: All
- InheritedAddressSpace: BOOLEAN,
-
- // Versions: 3.51+
- ReadImageFileExecOptions: BOOLEAN,
- BeingDebugged: BOOLEAN,
-
- // Versions: 5.2+ (previously was padding)
- BitField: UCHAR,
-
- // Versions: all
- Mutant: HANDLE,
- ImageBaseAddress: HMODULE,
- Ldr: *PEB_LDR_DATA,
- ProcessParameters: *RTL_USER_PROCESS_PARAMETERS,
- SubSystemData: PVOID,
- ProcessHeap: HANDLE,
-
- // Versions: 5.1+
- FastPebLock: *RTL_CRITICAL_SECTION,
-
- // Versions: 5.2+
- AtlThunkSListPtr: PVOID,
- IFEOKey: PVOID,
-
- // Versions: 6.0+
-
- /// https://www.geoffchappell.com/studies/windows/win32/ntdll/structs/peb/crossprocessflags.htm
- CrossProcessFlags: ULONG,
-
- // Versions: 6.0+
- union1: extern union {
- KernelCallbackTable: PVOID,
- UserSharedInfoPtr: PVOID,
- },
-
- // Versions: 5.1+
- SystemReserved: ULONG,
-
- // Versions: 5.1, (not 5.2, not 6.0), 6.1+
- AtlThunkSListPtr32: ULONG,
-
- // Versions: 6.1+
- ApiSetMap: PVOID,
-
- // Versions: all
- TlsExpansionCounter: ULONG,
- // note: there is padding here on 64 bit
- TlsBitmap: PRTL_BITMAP,
- TlsBitmapBits: [2]ULONG,
- ReadOnlySharedMemoryBase: PVOID,
-
- // Versions: 1703+
- SharedData: PVOID,
-
- // Versions: all
- ReadOnlyStaticServerData: *PVOID,
- AnsiCodePageData: PVOID,
- OemCodePageData: PVOID,
- UnicodeCaseTableData: PVOID,
-
- // Versions: 3.51+
- NumberOfProcessors: ULONG,
- NtGlobalFlag: ULONG,
-
- // Versions: all
- CriticalSectionTimeout: LARGE_INTEGER,
-
- // End of Original PEB size
-
- // Fields appended in 3.51:
- HeapSegmentReserve: ULONG_PTR,
- HeapSegmentCommit: ULONG_PTR,
- HeapDeCommitTotalFreeThreshold: ULONG_PTR,
- HeapDeCommitFreeBlockThreshold: ULONG_PTR,
- NumberOfHeaps: ULONG,
- MaximumNumberOfHeaps: ULONG,
- ProcessHeaps: *PVOID,
-
- // Fields appended in 4.0:
- GdiSharedHandleTable: PVOID,
- ProcessStarterHelper: PVOID,
- GdiDCAttributeList: ULONG,
- // note: there is padding here on 64 bit
- LoaderLock: *RTL_CRITICAL_SECTION,
- OSMajorVersion: ULONG,
- OSMinorVersion: ULONG,
- OSBuildNumber: USHORT,
- OSCSDVersion: USHORT,
- OSPlatformId: ULONG,
- ImageSubSystem: ULONG,
- ImageSubSystemMajorVersion: ULONG,
- ImageSubSystemMinorVersion: ULONG,
- // note: there is padding here on 64 bit
- ActiveProcessAffinityMask: KAFFINITY,
- GdiHandleBuffer: [
- switch (@sizeOf(usize)) {
- 4 => 0x22,
- 8 => 0x3C,
- else => unreachable,
- }
- ]ULONG,
-
- // Fields appended in 5.0 (Windows 2000):
- PostProcessInitRoutine: PVOID,
- TlsExpansionBitmap: PRTL_BITMAP,
- TlsExpansionBitmapBits: [32]ULONG,
- SessionId: ULONG,
- // note: there is padding here on 64 bit
- // Versions: 5.1+
- AppCompatFlags: ULARGE_INTEGER,
- AppCompatFlagsUser: ULARGE_INTEGER,
- ShimData: PVOID,
- // Versions: 5.0+
- AppCompatInfo: PVOID,
- CSDVersion: UNICODE_STRING,
-
- // Fields appended in 5.1 (Windows XP):
- ActivationContextData: *const ACTIVATION_CONTEXT_DATA,
- ProcessAssemblyStorageMap: *ASSEMBLY_STORAGE_MAP,
- SystemDefaultActivationData: *const ACTIVATION_CONTEXT_DATA,
- SystemAssemblyStorageMap: *ASSEMBLY_STORAGE_MAP,
- MinimumStackCommit: ULONG_PTR,
-
- // Fields appended in 5.2 (Windows Server 2003):
- FlsCallback: *FLS_CALLBACK_INFO,
- FlsListHead: LIST_ENTRY,
- FlsBitmap: PRTL_BITMAP,
- FlsBitmapBits: [4]ULONG,
- FlsHighIndex: ULONG,
-
- // Fields appended in 6.0 (Windows Vista):
- WerRegistrationData: PVOID,
- WerShipAssertPtr: PVOID,
-
- // Fields appended in 6.1 (Windows 7):
- pUnused: PVOID, // previously pContextData
- pImageHeaderHash: PVOID,
-
- /// TODO: https://www.geoffchappell.com/studies/windows/win32/ntdll/structs/peb/tracingflags.htm
- TracingFlags: ULONG,
-
- // Fields appended in 6.2 (Windows 8):
- CsrServerReadOnlySharedMemoryBase: ULONGLONG,
-
- // Fields appended in 1511:
- TppWorkerpListLock: ULONG,
- TppWorkerpList: LIST_ENTRY,
- WaitOnAddressHashTable: [0x80]PVOID,
-
- // Fields appended in 1709:
- TelemetryCoverageHeader: PVOID,
- CloudFileFlags: ULONG,
-};
-
-/// The `PEB_LDR_DATA` structure is the main record of what modules are loaded in a process.
-/// It is essentially the head of three double-linked lists of `LDR_DATA_TABLE_ENTRY` structures which each represent one loaded module.
-///
-/// Microsoft documentation of this is incomplete, the fields here are taken from various resources including:
-/// - https://www.geoffchappell.com/studies/windows/win32/ntdll/structs/peb_ldr_data.htm
-pub const PEB_LDR_DATA = extern struct {
- // Versions: 3.51 and higher
- /// The size in bytes of the structure
- Length: ULONG,
-
- /// TRUE if the structure is prepared.
- Initialized: BOOLEAN,
-
- SsHandle: PVOID,
- InLoadOrderModuleList: LIST_ENTRY,
- InMemoryOrderModuleList: LIST_ENTRY,
- InInitializationOrderModuleList: LIST_ENTRY,
-
- // Versions: 5.1 and higher
-
- /// No known use of this field is known in Windows 8 and higher.
- EntryInProgress: PVOID,
-
- // Versions: 6.0 from Windows Vista SP1, and higher
- ShutdownInProgress: BOOLEAN,
-
- /// Though ShutdownThreadId is declared as a HANDLE,
- /// it is indeed the thread ID as suggested by its name.
- /// It is picked up from the UniqueThread member of the CLIENT_ID in the
- /// TEB of the thread that asks to terminate the process.
- ShutdownThreadId: HANDLE,
-};
-
-pub const RTL_USER_PROCESS_PARAMETERS = extern struct {
- AllocationSize: ULONG,
- Size: ULONG,
- Flags: ULONG,
- DebugFlags: ULONG,
- ConsoleHandle: HANDLE,
- ConsoleFlags: ULONG,
- hStdInput: HANDLE,
- hStdOutput: HANDLE,
- hStdError: HANDLE,
- CurrentDirectory: CURDIR,
- DllPath: UNICODE_STRING,
- ImagePathName: UNICODE_STRING,
- CommandLine: UNICODE_STRING,
- Environment: [*:0]WCHAR,
- dwX: ULONG,
- dwY: ULONG,
- dwXSize: ULONG,
- dwYSize: ULONG,
- dwXCountChars: ULONG,
- dwYCountChars: ULONG,
- dwFillAttribute: ULONG,
- dwFlags: ULONG,
- dwShowWindow: ULONG,
- WindowTitle: UNICODE_STRING,
- Desktop: UNICODE_STRING,
- ShellInfo: UNICODE_STRING,
- RuntimeInfo: UNICODE_STRING,
- DLCurrentDirectory: [0x20]RTL_DRIVE_LETTER_CURDIR,
-};
-
-pub const RTL_DRIVE_LETTER_CURDIR = extern struct {
- Flags: c_ushort,
- Length: c_ushort,
- TimeStamp: ULONG,
- DosPath: UNICODE_STRING,
-};
-
-pub const PPS_POST_PROCESS_INIT_ROUTINE = ?fn () callconv(.C) void;
-
-pub const FILE_BOTH_DIR_INFORMATION = extern struct {
- NextEntryOffset: ULONG,
- FileIndex: ULONG,
- CreationTime: LARGE_INTEGER,
- LastAccessTime: LARGE_INTEGER,
- LastWriteTime: LARGE_INTEGER,
- ChangeTime: LARGE_INTEGER,
- EndOfFile: LARGE_INTEGER,
- AllocationSize: LARGE_INTEGER,
- FileAttributes: ULONG,
- FileNameLength: ULONG,
- EaSize: ULONG,
- ShortNameLength: CHAR,
- ShortName: [12]WCHAR,
- FileName: [1]WCHAR,
-};
-pub const FILE_BOTH_DIRECTORY_INFORMATION = FILE_BOTH_DIR_INFORMATION;
-
-pub const IO_APC_ROUTINE = fn (PVOID, *IO_STATUS_BLOCK, ULONG) callconv(.C) void;
-
-pub const CURDIR = extern struct {
- DosPath: UNICODE_STRING,
- Handle: HANDLE,
-};
-
-pub const DUPLICATE_SAME_ACCESS = 2;
-
-pub const MODULEINFO = extern struct {
- lpBaseOfDll: LPVOID,
- SizeOfImage: DWORD,
- EntryPoint: LPVOID,
-};
-pub const LPMODULEINFO = *MODULEINFO;
-
-pub const PSAPI_WS_WATCH_INFORMATION = extern struct {
- FaultingPc: LPVOID,
- FaultingVa: LPVOID,
-};
-pub const PPSAPI_WS_WATCH_INFORMATION = *PSAPI_WS_WATCH_INFORMATION;
-
-pub const PROCESS_MEMORY_COUNTERS = extern struct {
- cb: DWORD,
- PageFaultCount: DWORD,
- PeakWorkingSetSize: SIZE_T,
- WorkingSetSize: SIZE_T,
- QuotaPeakPagedPoolUsage: SIZE_T,
- QuotaPagedPoolUsage: SIZE_T,
- QuotaPeakNonPagedPoolUsage: SIZE_T,
- QuotaNonPagedPoolUsage: SIZE_T,
- PagefileUsage: SIZE_T,
- PeakPagefileUsage: SIZE_T,
-};
-pub const PPROCESS_MEMORY_COUNTERS = *PROCESS_MEMORY_COUNTERS;
-
-pub const PROCESS_MEMORY_COUNTERS_EX = extern struct {
- cb: DWORD,
- PageFaultCount: DWORD,
- PeakWorkingSetSize: SIZE_T,
- WorkingSetSize: SIZE_T,
- QuotaPeakPagedPoolUsage: SIZE_T,
- QuotaPagedPoolUsage: SIZE_T,
- QuotaPeakNonPagedPoolUsage: SIZE_T,
- QuotaNonPagedPoolUsage: SIZE_T,
- PagefileUsage: SIZE_T,
- PeakPagefileUsage: SIZE_T,
- PrivateUsage: SIZE_T,
-};
-pub const PPROCESS_MEMORY_COUNTERS_EX = *PROCESS_MEMORY_COUNTERS_EX;
-
-pub const PERFORMANCE_INFORMATION = extern struct {
- cb: DWORD,
- CommitTotal: SIZE_T,
- CommitLimit: SIZE_T,
- CommitPeak: SIZE_T,
- PhysicalTotal: SIZE_T,
- PhysicalAvailable: SIZE_T,
- SystemCache: SIZE_T,
- KernelTotal: SIZE_T,
- KernelPaged: SIZE_T,
- KernelNonpaged: SIZE_T,
- PageSize: SIZE_T,
- HandleCount: DWORD,
- ProcessCount: DWORD,
- ThreadCount: DWORD,
-};
-pub const PPERFORMANCE_INFORMATION = *PERFORMANCE_INFORMATION;
-
-pub const PERFORMACE_INFORMATION = PERFORMANCE_INFORMATION;
-pub const PPERFORMACE_INFORMATION = *PERFORMANCE_INFORMATION;
-
-pub const ENUM_PAGE_FILE_INFORMATION = extern struct {
- cb: DWORD,
- Reserved: DWORD,
- TotalSize: SIZE_T,
- TotalInUse: SIZE_T,
- PeakUsage: SIZE_T,
-};
-pub const PENUM_PAGE_FILE_INFORMATION = *ENUM_PAGE_FILE_INFORMATION;
-
-pub const PENUM_PAGE_FILE_CALLBACKW = ?fn (?LPVOID, PENUM_PAGE_FILE_INFORMATION, LPCWSTR) callconv(.C) BOOL;
-pub const PENUM_PAGE_FILE_CALLBACKA = ?fn (?LPVOID, PENUM_PAGE_FILE_INFORMATION, LPCSTR) callconv(.C) BOOL;
-
-pub const PSAPI_WS_WATCH_INFORMATION_EX = extern struct {
- BasicInfo: PSAPI_WS_WATCH_INFORMATION,
- FaultingThreadId: ULONG_PTR,
- Flags: ULONG_PTR,
-};
-pub const PPSAPI_WS_WATCH_INFORMATION_EX = *PSAPI_WS_WATCH_INFORMATION_EX;
-
-pub const OSVERSIONINFOW = extern struct {
- dwOSVersionInfoSize: ULONG,
- dwMajorVersion: ULONG,
- dwMinorVersion: ULONG,
- dwBuildNumber: ULONG,
- dwPlatformId: ULONG,
- szCSDVersion: [128]WCHAR,
-};
-pub const POSVERSIONINFOW = *OSVERSIONINFOW;
-pub const LPOSVERSIONINFOW = *OSVERSIONINFOW;
-pub const RTL_OSVERSIONINFOW = OSVERSIONINFOW;
-pub const PRTL_OSVERSIONINFOW = *RTL_OSVERSIONINFOW;
-
-pub const REPARSE_DATA_BUFFER = extern struct {
- ReparseTag: ULONG,
- ReparseDataLength: USHORT,
- Reserved: USHORT,
- DataBuffer: [1]UCHAR,
-};
-pub const SYMBOLIC_LINK_REPARSE_BUFFER = extern struct {
- SubstituteNameOffset: USHORT,
- SubstituteNameLength: USHORT,
- PrintNameOffset: USHORT,
- PrintNameLength: USHORT,
- Flags: ULONG,
- PathBuffer: [1]WCHAR,
-};
-pub const MOUNT_POINT_REPARSE_BUFFER = extern struct {
- SubstituteNameOffset: USHORT,
- SubstituteNameLength: USHORT,
- PrintNameOffset: USHORT,
- PrintNameLength: USHORT,
- PathBuffer: [1]WCHAR,
-};
-pub const MAXIMUM_REPARSE_DATA_BUFFER_SIZE: ULONG = 16 * 1024;
-pub const FSCTL_SET_REPARSE_POINT: DWORD = 0x900a4;
-pub const FSCTL_GET_REPARSE_POINT: DWORD = 0x900a8;
-pub const IO_REPARSE_TAG_SYMLINK: ULONG = 0xa000000c;
-pub const IO_REPARSE_TAG_MOUNT_POINT: ULONG = 0xa0000003;
-pub const SYMLINK_FLAG_RELATIVE: ULONG = 0x1;
-
-pub const SYMBOLIC_LINK_FLAG_DIRECTORY: DWORD = 0x1;
-pub const SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE: DWORD = 0x2;
-
-pub const MOUNTMGR_MOUNT_POINT = extern struct {
- SymbolicLinkNameOffset: ULONG,
- SymbolicLinkNameLength: USHORT,
- Reserved1: USHORT,
- UniqueIdOffset: ULONG,
- UniqueIdLength: USHORT,
- Reserved2: USHORT,
- DeviceNameOffset: ULONG,
- DeviceNameLength: USHORT,
- Reserved3: USHORT,
-};
-pub const MOUNTMGR_MOUNT_POINTS = extern struct {
- Size: ULONG,
- NumberOfMountPoints: ULONG,
- MountPoints: [1]MOUNTMGR_MOUNT_POINT,
-};
-pub const IOCTL_MOUNTMGR_QUERY_POINTS: ULONG = 0x6d0008;
-
-pub const OBJECT_INFORMATION_CLASS = enum(c_int) {
- ObjectBasicInformation = 0,
- ObjectNameInformation = 1,
- ObjectTypeInformation = 2,
- ObjectTypesInformation = 3,
- ObjectHandleFlagInformation = 4,
- ObjectSessionInformation = 5,
- MaxObjectInfoClass,
-};
-
-pub const OBJECT_NAME_INFORMATION = extern struct {
- Name: UNICODE_STRING,
-};
-pub const POBJECT_NAME_INFORMATION = *OBJECT_NAME_INFORMATION;
-
-pub const SRWLOCK = usize;
-pub const SRWLOCK_INIT: SRWLOCK = 0;
-pub const CONDITION_VARIABLE = usize;
-pub const CONDITION_VARIABLE_INIT: CONDITION_VARIABLE = 0;
-
-pub const FILE_SKIP_COMPLETION_PORT_ON_SUCCESS = 0x1;
-pub const FILE_SKIP_SET_EVENT_ON_HANDLE = 0x2;
-
-pub const CTRL_C_EVENT: DWORD = 0;
-pub const CTRL_BREAK_EVENT: DWORD = 1;
-pub const CTRL_CLOSE_EVENT: DWORD = 2;
-pub const CTRL_LOGOFF_EVENT: DWORD = 5;
-pub const CTRL_SHUTDOWN_EVENT: DWORD = 6;
-
-pub const HANDLER_ROUTINE = fn (dwCtrlType: DWORD) callconv(.C) BOOL;
diff --git a/lib/std/os/windows/gdi32.zig b/lib/std/os/windows/gdi32.zig
index 132fd80a34a8..f7860c2ca196 100644
--- a/lib/std/os/windows/gdi32.zig
+++ b/lib/std/os/windows/gdi32.zig
@@ -1,4 +1,12 @@
-usingnamespace @import("bits.zig");
+const std = @import("../../std.zig");
+const windows = std.os.windows;
+const BOOL = windows.BOOL;
+const DWORD = windows.DWORD;
+const WINAPI = windows.WINAPI;
+const HDC = windows.HDC;
+const HGLRC = windows.HGLRC;
+const WORD = windows.WORD;
+const BYTE = windows.BYTE;
pub const PIXELFORMATDESCRIPTOR = extern struct {
nSize: WORD = @sizeOf(PIXELFORMATDESCRIPTOR),
diff --git a/lib/std/os/windows/kernel32.zig b/lib/std/os/windows/kernel32.zig
index 6996ad9991ac..89a00ed892bb 100644
--- a/lib/std/os/windows/kernel32.zig
+++ b/lib/std/os/windows/kernel32.zig
@@ -1,10 +1,67 @@
-usingnamespace @import("bits.zig");
+const std = @import("../../std.zig");
+const windows = std.os.windows;
+
+const BOOL = windows.BOOL;
+const BOOLEAN = windows.BOOLEAN;
+const CONDITION_VARIABLE = windows.CONDITION_VARIABLE;
+const CONSOLE_SCREEN_BUFFER_INFO = windows.CONSOLE_SCREEN_BUFFER_INFO;
+const COORD = windows.COORD;
+const DWORD = windows.DWORD;
+const FILE_INFO_BY_HANDLE_CLASS = windows.FILE_INFO_BY_HANDLE_CLASS;
+const HANDLE = windows.HANDLE;
+const HMODULE = windows.HMODULE;
+const HRESULT = windows.HRESULT;
+const LARGE_INTEGER = windows.LARGE_INTEGER;
+const LPCWSTR = windows.LPCWSTR;
+const LPTHREAD_START_ROUTINE = windows.LPTHREAD_START_ROUTINE;
+const LPVOID = windows.LPVOID;
+const LPWSTR = windows.LPWSTR;
+const MODULEINFO = windows.MODULEINFO;
+const OVERLAPPED = windows.OVERLAPPED;
+const PERFORMANCE_INFORMATION = windows.PERFORMANCE_INFORMATION;
+const PROCESS_MEMORY_COUNTERS = windows.PROCESS_MEMORY_COUNTERS;
+const PSAPI_WS_WATCH_INFORMATION = windows.PSAPI_WS_WATCH_INFORMATION;
+const PSAPI_WS_WATCH_INFORMATION_EX = windows.PSAPI_WS_WATCH_INFORMATION_EX;
+const SECURITY_ATTRIBUTES = windows.SECURITY_ATTRIBUTES;
+const SIZE_T = windows.SIZE_T;
+const SRWLOCK = windows.SRWLOCK;
+const UINT = windows.UINT;
+const VECTORED_EXCEPTION_HANDLER = windows.VECTORED_EXCEPTION_HANDLER;
+const WCHAR = windows.WCHAR;
+const WINAPI = windows.WINAPI;
+const WORD = windows.WORD;
+const Win32Error = windows.Win32Error;
+const va_list = windows.va_list;
+const HLOCAL = windows.HLOCAL;
+const FILETIME = windows.FILETIME;
+const STARTUPINFOW = windows.STARTUPINFOW;
+const PROCESS_INFORMATION = windows.PROCESS_INFORMATION;
+const OVERLAPPED_ENTRY = windows.OVERLAPPED_ENTRY;
+const LPHEAP_SUMMARY = windows.LPHEAP_SUMMARY;
+const ULONG_PTR = windows.ULONG_PTR;
+const FILE_NOTIFY_INFORMATION = windows.FILE_NOTIFY_INFORMATION;
+const HANDLER_ROUTINE = windows.HANDLER_ROUTINE;
+const ULONG = windows.ULONG;
+const PVOID = windows.PVOID;
+const LPSTR = windows.LPSTR;
+const PENUM_PAGE_FILE_CALLBACKA = windows.PENUM_PAGE_FILE_CALLBACKA;
+const PENUM_PAGE_FILE_CALLBACKW = windows.PENUM_PAGE_FILE_CALLBACKW;
+const INIT_ONCE = windows.INIT_ONCE;
+const CRITICAL_SECTION = windows.CRITICAL_SECTION;
+const WIN32_FIND_DATAW = windows.WIN32_FIND_DATAW;
+const CHAR = windows.CHAR;
+const BY_HANDLE_FILE_INFORMATION = windows.BY_HANDLE_FILE_INFORMATION;
+const SYSTEM_INFO = windows.SYSTEM_INFO;
+const LPOVERLAPPED_COMPLETION_ROUTINE = windows.LPOVERLAPPED_COMPLETION_ROUTINE;
+const UCHAR = windows.UCHAR;
+const FARPROC = windows.FARPROC;
+const INIT_ONCE_FN = windows.INIT_ONCE_FN;
pub extern "kernel32" fn AddVectoredExceptionHandler(First: c_ulong, Handler: ?VECTORED_EXCEPTION_HANDLER) callconv(WINAPI) ?*c_void;
pub extern "kernel32" fn RemoveVectoredExceptionHandler(Handle: HANDLE) callconv(WINAPI) c_ulong;
pub extern "kernel32" fn CancelIo(hFile: HANDLE) callconv(WINAPI) BOOL;
-pub extern "kernel32" fn CancelIoEx(hFile: HANDLE, lpOverlapped: ?LPOVERLAPPED) callconv(WINAPI) BOOL;
+pub extern "kernel32" fn CancelIoEx(hFile: HANDLE, lpOverlapped: ?*OVERLAPPED) callconv(WINAPI) BOOL;
pub extern "kernel32" fn CloseHandle(hObject: HANDLE) callconv(WINAPI) BOOL;
@@ -22,7 +79,7 @@ pub extern "kernel32" fn CreateFileW(
lpFileName: [*:0]const u16,
dwDesiredAccess: DWORD,
dwShareMode: DWORD,
- lpSecurityAttributes: ?LPSECURITY_ATTRIBUTES,
+ lpSecurityAttributes: ?*SECURITY_ATTRIBUTES,
dwCreationDisposition: DWORD,
dwFlagsAndAttributes: DWORD,
hTemplateFile: ?HANDLE,
@@ -63,7 +120,7 @@ pub extern "kernel32" fn CreateSymbolicLinkW(lpSymlinkFileName: [*:0]const u16,
pub extern "kernel32" fn CreateIoCompletionPort(FileHandle: HANDLE, ExistingCompletionPort: ?HANDLE, CompletionKey: ULONG_PTR, NumberOfConcurrentThreads: DWORD) callconv(WINAPI) ?HANDLE;
-pub extern "kernel32" fn CreateThread(lpThreadAttributes: ?LPSECURITY_ATTRIBUTES, dwStackSize: SIZE_T, lpStartAddress: LPTHREAD_START_ROUTINE, lpParameter: ?LPVOID, dwCreationFlags: DWORD, lpThreadId: ?LPDWORD) callconv(WINAPI) ?HANDLE;
+pub extern "kernel32" fn CreateThread(lpThreadAttributes: ?*SECURITY_ATTRIBUTES, dwStackSize: SIZE_T, lpStartAddress: LPTHREAD_START_ROUTINE, lpParameter: ?LPVOID, dwCreationFlags: DWORD, lpThreadId: ?*DWORD) callconv(WINAPI) ?HANDLE;
pub extern "kernel32" fn DeviceIoControl(
h: HANDLE,
@@ -96,9 +153,9 @@ pub extern "kernel32" fn GetCommandLineW() callconv(WINAPI) LPWSTR;
pub extern "kernel32" fn GetConsoleMode(in_hConsoleHandle: HANDLE, out_lpMode: *DWORD) callconv(WINAPI) BOOL;
pub extern "kernel32" fn GetConsoleScreenBufferInfo(hConsoleOutput: HANDLE, lpConsoleScreenBufferInfo: *CONSOLE_SCREEN_BUFFER_INFO) callconv(WINAPI) BOOL;
-pub extern "kernel32" fn FillConsoleOutputCharacterA(hConsoleOutput: HANDLE, cCharacter: CHAR, nLength: DWORD, dwWriteCoord: COORD, lpNumberOfCharsWritten: LPDWORD) callconv(WINAPI) BOOL;
-pub extern "kernel32" fn FillConsoleOutputCharacterW(hConsoleOutput: HANDLE, cCharacter: WCHAR, nLength: DWORD, dwWriteCoord: COORD, lpNumberOfCharsWritten: LPDWORD) callconv(WINAPI) BOOL;
-pub extern "kernel32" fn FillConsoleOutputAttribute(hConsoleOutput: HANDLE, wAttribute: WORD, nLength: DWORD, dwWriteCoord: COORD, lpNumberOfAttrsWritten: LPDWORD) callconv(WINAPI) BOOL;
+pub extern "kernel32" fn FillConsoleOutputCharacterA(hConsoleOutput: HANDLE, cCharacter: CHAR, nLength: DWORD, dwWriteCoord: COORD, lpNumberOfCharsWritten: *DWORD) callconv(WINAPI) BOOL;
+pub extern "kernel32" fn FillConsoleOutputCharacterW(hConsoleOutput: HANDLE, cCharacter: WCHAR, nLength: DWORD, dwWriteCoord: COORD, lpNumberOfCharsWritten: *DWORD) callconv(WINAPI) BOOL;
+pub extern "kernel32" fn FillConsoleOutputAttribute(hConsoleOutput: HANDLE, wAttribute: WORD, nLength: DWORD, dwWriteCoord: COORD, lpNumberOfAttrsWritten: *DWORD) callconv(WINAPI) BOOL;
pub extern "kernel32" fn SetConsoleCursorPosition(hConsoleOutput: HANDLE, dwCursorPosition: COORD) callconv(WINAPI) BOOL;
pub extern "kernel32" fn GetCurrentDirectoryW(nBufferLength: DWORD, lpBuffer: ?[*]WCHAR) callconv(WINAPI) DWORD;
@@ -156,7 +213,7 @@ pub extern "kernel32" fn GetFullPathNameW(
pub extern "kernel32" fn GetOverlappedResult(hFile: HANDLE, lpOverlapped: *OVERLAPPED, lpNumberOfBytesTransferred: *DWORD, bWait: BOOL) callconv(WINAPI) BOOL;
pub extern "kernel32" fn GetProcessHeap() callconv(WINAPI) ?HANDLE;
-pub extern "kernel32" fn GetQueuedCompletionStatus(CompletionPort: HANDLE, lpNumberOfBytesTransferred: LPDWORD, lpCompletionKey: *ULONG_PTR, lpOverlapped: *?*OVERLAPPED, dwMilliseconds: DWORD) callconv(WINAPI) BOOL;
+pub extern "kernel32" fn GetQueuedCompletionStatus(CompletionPort: HANDLE, lpNumberOfBytesTransferred: *DWORD, lpCompletionKey: *ULONG_PTR, lpOverlapped: *?*OVERLAPPED, dwMilliseconds: DWORD) callconv(WINAPI) BOOL;
pub extern "kernel32" fn GetQueuedCompletionStatusEx(
CompletionPort: HANDLE,
lpCompletionPortEntries: [*]OVERLAPPED_ENTRY,
@@ -282,7 +339,7 @@ pub extern "kernel32" fn WriteFile(
in_out_lpOverlapped: ?*OVERLAPPED,
) callconv(WINAPI) BOOL;
-pub extern "kernel32" fn WriteFileEx(hFile: HANDLE, lpBuffer: [*]const u8, nNumberOfBytesToWrite: DWORD, lpOverlapped: LPOVERLAPPED, lpCompletionRoutine: LPOVERLAPPED_COMPLETION_ROUTINE) callconv(WINAPI) BOOL;
+pub extern "kernel32" fn WriteFileEx(hFile: HANDLE, lpBuffer: [*]const u8, nNumberOfBytesToWrite: DWORD, lpOverlapped: *OVERLAPPED, lpCompletionRoutine: LPOVERLAPPED_COMPLETION_ROUTINE) callconv(WINAPI) BOOL;
pub extern "kernel32" fn LoadLibraryW(lpLibFileName: [*:0]const u16) callconv(WINAPI) ?HMODULE;
@@ -298,12 +355,12 @@ pub extern "kernel32" fn DeleteCriticalSection(lpCriticalSection: *CRITICAL_SECT
pub extern "kernel32" fn InitOnceExecuteOnce(InitOnce: *INIT_ONCE, InitFn: INIT_ONCE_FN, Parameter: ?*c_void, Context: ?*c_void) callconv(WINAPI) BOOL;
pub extern "kernel32" fn K32EmptyWorkingSet(hProcess: HANDLE) callconv(WINAPI) BOOL;
-pub extern "kernel32" fn K32EnumDeviceDrivers(lpImageBase: [*]LPVOID, cb: DWORD, lpcbNeeded: LPDWORD) callconv(WINAPI) BOOL;
+pub extern "kernel32" fn K32EnumDeviceDrivers(lpImageBase: [*]LPVOID, cb: DWORD, lpcbNeeded: *DWORD) callconv(WINAPI) BOOL;
pub extern "kernel32" fn K32EnumPageFilesA(pCallBackRoutine: PENUM_PAGE_FILE_CALLBACKA, pContext: LPVOID) callconv(WINAPI) BOOL;
pub extern "kernel32" fn K32EnumPageFilesW(pCallBackRoutine: PENUM_PAGE_FILE_CALLBACKW, pContext: LPVOID) callconv(WINAPI) BOOL;
-pub extern "kernel32" fn K32EnumProcessModules(hProcess: HANDLE, lphModule: [*]HMODULE, cb: DWORD, lpcbNeeded: LPDWORD) callconv(WINAPI) BOOL;
-pub extern "kernel32" fn K32EnumProcessModulesEx(hProcess: HANDLE, lphModule: [*]HMODULE, cb: DWORD, lpcbNeeded: LPDWORD, dwFilterFlag: DWORD) callconv(WINAPI) BOOL;
-pub extern "kernel32" fn K32EnumProcesses(lpidProcess: [*]DWORD, cb: DWORD, cbNeeded: LPDWORD) callconv(WINAPI) BOOL;
+pub extern "kernel32" fn K32EnumProcessModules(hProcess: HANDLE, lphModule: [*]HMODULE, cb: DWORD, lpcbNeeded: *DWORD) callconv(WINAPI) BOOL;
+pub extern "kernel32" fn K32EnumProcessModulesEx(hProcess: HANDLE, lphModule: [*]HMODULE, cb: DWORD, lpcbNeeded: *DWORD, dwFilterFlag: DWORD) callconv(WINAPI) BOOL;
+pub extern "kernel32" fn K32EnumProcesses(lpidProcess: [*]DWORD, cb: DWORD, cbNeeded: *DWORD) callconv(WINAPI) BOOL;
pub extern "kernel32" fn K32GetDeviceDriverBaseNameA(ImageBase: LPVOID, lpBaseName: LPSTR, nSize: DWORD) callconv(WINAPI) DWORD;
pub extern "kernel32" fn K32GetDeviceDriverBaseNameW(ImageBase: LPVOID, lpBaseName: LPWSTR, nSize: DWORD) callconv(WINAPI) DWORD;
pub extern "kernel32" fn K32GetDeviceDriverFileNameA(ImageBase: LPVOID, lpFilename: LPSTR, nSize: DWORD) callconv(WINAPI) DWORD;
@@ -314,13 +371,13 @@ pub extern "kernel32" fn K32GetModuleBaseNameA(hProcess: HANDLE, hModule: ?HMODU
pub extern "kernel32" fn K32GetModuleBaseNameW(hProcess: HANDLE, hModule: ?HMODULE, lpBaseName: LPWSTR, nSize: DWORD) callconv(WINAPI) DWORD;
pub extern "kernel32" fn K32GetModuleFileNameExA(hProcess: HANDLE, hModule: ?HMODULE, lpFilename: LPSTR, nSize: DWORD) callconv(WINAPI) DWORD;
pub extern "kernel32" fn K32GetModuleFileNameExW(hProcess: HANDLE, hModule: ?HMODULE, lpFilename: LPWSTR, nSize: DWORD) callconv(WINAPI) DWORD;
-pub extern "kernel32" fn K32GetModuleInformation(hProcess: HANDLE, hModule: HMODULE, lpmodinfo: LPMODULEINFO, cb: DWORD) callconv(WINAPI) BOOL;
-pub extern "kernel32" fn K32GetPerformanceInfo(pPerformanceInformation: PPERFORMACE_INFORMATION, cb: DWORD) callconv(WINAPI) BOOL;
+pub extern "kernel32" fn K32GetModuleInformation(hProcess: HANDLE, hModule: HMODULE, lpmodinfo: *MODULEINFO, cb: DWORD) callconv(WINAPI) BOOL;
+pub extern "kernel32" fn K32GetPerformanceInfo(pPerformanceInformation: *PERFORMANCE_INFORMATION, cb: DWORD) callconv(WINAPI) BOOL;
pub extern "kernel32" fn K32GetProcessImageFileNameA(hProcess: HANDLE, lpImageFileName: LPSTR, nSize: DWORD) callconv(WINAPI) DWORD;
pub extern "kernel32" fn K32GetProcessImageFileNameW(hProcess: HANDLE, lpImageFileName: LPWSTR, nSize: DWORD) callconv(WINAPI) DWORD;
-pub extern "kernel32" fn K32GetProcessMemoryInfo(Process: HANDLE, ppsmemCounters: PPROCESS_MEMORY_COUNTERS, cb: DWORD) callconv(WINAPI) BOOL;
-pub extern "kernel32" fn K32GetWsChanges(hProcess: HANDLE, lpWatchInfo: PPSAPI_WS_WATCH_INFORMATION, cb: DWORD) callconv(WINAPI) BOOL;
-pub extern "kernel32" fn K32GetWsChangesEx(hProcess: HANDLE, lpWatchInfoEx: PPSAPI_WS_WATCH_INFORMATION_EX, cb: DWORD) callconv(WINAPI) BOOL;
+pub extern "kernel32" fn K32GetProcessMemoryInfo(Process: HANDLE, ppsmemCounters: *PROCESS_MEMORY_COUNTERS, cb: DWORD) callconv(WINAPI) BOOL;
+pub extern "kernel32" fn K32GetWsChanges(hProcess: HANDLE, lpWatchInfo: *PSAPI_WS_WATCH_INFORMATION, cb: DWORD) callconv(WINAPI) BOOL;
+pub extern "kernel32" fn K32GetWsChangesEx(hProcess: HANDLE, lpWatchInfoEx: *PSAPI_WS_WATCH_INFORMATION_EX, cb: DWORD) callconv(WINAPI) BOOL;
pub extern "kernel32" fn K32InitializeProcessForWsWatch(hProcess: HANDLE) callconv(WINAPI) BOOL;
pub extern "kernel32" fn K32QueryWorkingSet(hProcess: HANDLE, pv: PVOID, cb: DWORD) callconv(WINAPI) BOOL;
pub extern "kernel32" fn K32QueryWorkingSetEx(hProcess: HANDLE, pv: PVOID, cb: DWORD) callconv(WINAPI) BOOL;
diff --git a/lib/std/os/windows/ntdll.zig b/lib/std/os/windows/ntdll.zig
index 5a0154db6f8c..228cf09ead75 100644
--- a/lib/std/os/windows/ntdll.zig
+++ b/lib/std/os/windows/ntdll.zig
@@ -1,7 +1,30 @@
-usingnamespace @import("bits.zig");
+const std = @import("../../std.zig");
+const windows = std.os.windows;
+
+const BOOL = windows.BOOL;
+const DWORD = windows.DWORD;
+const ULONG = windows.ULONG;
+const WINAPI = windows.WINAPI;
+const NTSTATUS = windows.NTSTATUS;
+const WORD = windows.WORD;
+const HANDLE = windows.HANDLE;
+const ACCESS_MASK = windows.ACCESS_MASK;
+const IO_APC_ROUTINE = windows.IO_APC_ROUTINE;
+const BOOLEAN = windows.BOOLEAN;
+const OBJECT_ATTRIBUTES = windows.OBJECT_ATTRIBUTES;
+const PVOID = windows.PVOID;
+const IO_STATUS_BLOCK = windows.IO_STATUS_BLOCK;
+const LARGE_INTEGER = windows.LARGE_INTEGER;
+const OBJECT_INFORMATION_CLASS = windows.OBJECT_INFORMATION_CLASS;
+const FILE_INFORMATION_CLASS = windows.FILE_INFORMATION_CLASS;
+const UNICODE_STRING = windows.UNICODE_STRING;
+const RTL_OSVERSIONINFOW = windows.RTL_OSVERSIONINFOW;
+const FILE_BASIC_INFORMATION = windows.FILE_BASIC_INFORMATION;
+const SIZE_T = windows.SIZE_T;
+const CURDIR = windows.CURDIR;
pub extern "NtDll" fn RtlGetVersion(
- lpVersionInformation: PRTL_OSVERSIONINFOW,
+ lpVersionInformation: *RTL_OSVERSIONINFOW,
) callconv(WINAPI) NTSTATUS;
pub extern "NtDll" fn RtlCaptureStackBackTrace(
FramesToSkip: DWORD,
diff --git a/lib/std/os/windows/ole32.zig b/lib/std/os/windows/ole32.zig
index e4e043265933..a7abb715ef48 100644
--- a/lib/std/os/windows/ole32.zig
+++ b/lib/std/os/windows/ole32.zig
@@ -1,4 +1,9 @@
-usingnamespace @import("bits.zig");
+const std = @import("../../std.zig");
+const windows = std.os.windows;
+const WINAPI = windows.WINAPI;
+const LPVOID = windows.LPVOID;
+const DWORD = windows.DWORD;
+const HRESULT = windows.HRESULT;
pub extern "ole32" fn CoTaskMemFree(pv: LPVOID) callconv(WINAPI) void;
pub extern "ole32" fn CoUninitialize() callconv(WINAPI) void;
diff --git a/lib/std/os/windows/psapi.zig b/lib/std/os/windows/psapi.zig
index cebe03d3aa1f..0ef7429232e8 100644
--- a/lib/std/os/windows/psapi.zig
+++ b/lib/std/os/windows/psapi.zig
@@ -1,12 +1,58 @@
-usingnamespace @import("bits.zig");
+const std = @import("../../std.zig");
+const windows = std.os.windows;
+const WINAPI = windows.WINAPI;
+const DWORD = windows.DWORD;
+const HANDLE = windows.HANDLE;
+const PENUM_PAGE_FILE_CALLBACKW = windows.PENUM_PAGE_FILE_CALLBACKW;
+const HMODULE = windows.HMODULE;
+const BOOL = windows.BOOL;
+const BOOLEAN = windows.BOOLEAN;
+const CONDITION_VARIABLE = windows.CONDITION_VARIABLE;
+const CONSOLE_SCREEN_BUFFER_INFO = windows.CONSOLE_SCREEN_BUFFER_INFO;
+const COORD = windows.COORD;
+const FILE_INFO_BY_HANDLE_CLASS = windows.FILE_INFO_BY_HANDLE_CLASS;
+const HRESULT = windows.HRESULT;
+const LARGE_INTEGER = windows.LARGE_INTEGER;
+const LPCWSTR = windows.LPCWSTR;
+const LPTHREAD_START_ROUTINE = windows.LPTHREAD_START_ROUTINE;
+const LPVOID = windows.LPVOID;
+const LPWSTR = windows.LPWSTR;
+const MODULEINFO = windows.MODULEINFO;
+const OVERLAPPED = windows.OVERLAPPED;
+const PERFORMANCE_INFORMATION = windows.PERFORMANCE_INFORMATION;
+const PROCESS_MEMORY_COUNTERS = windows.PROCESS_MEMORY_COUNTERS;
+const PSAPI_WS_WATCH_INFORMATION = windows.PSAPI_WS_WATCH_INFORMATION;
+const PSAPI_WS_WATCH_INFORMATION_EX = windows.PSAPI_WS_WATCH_INFORMATION_EX;
+const SECURITY_ATTRIBUTES = windows.SECURITY_ATTRIBUTES;
+const SIZE_T = windows.SIZE_T;
+const SRWLOCK = windows.SRWLOCK;
+const UINT = windows.UINT;
+const VECTORED_EXCEPTION_HANDLER = windows.VECTORED_EXCEPTION_HANDLER;
+const WCHAR = windows.WCHAR;
+const WORD = windows.WORD;
+const Win32Error = windows.Win32Error;
+const va_list = windows.va_list;
+const HLOCAL = windows.HLOCAL;
+const FILETIME = windows.FILETIME;
+const STARTUPINFOW = windows.STARTUPINFOW;
+const PROCESS_INFORMATION = windows.PROCESS_INFORMATION;
+const OVERLAPPED_ENTRY = windows.OVERLAPPED_ENTRY;
+const LPHEAP_SUMMARY = windows.LPHEAP_SUMMARY;
+const ULONG_PTR = windows.ULONG_PTR;
+const FILE_NOTIFY_INFORMATION = windows.FILE_NOTIFY_INFORMATION;
+const HANDLER_ROUTINE = windows.HANDLER_ROUTINE;
+const ULONG = windows.ULONG;
+const PVOID = windows.PVOID;
+const LPSTR = windows.LPSTR;
+const PENUM_PAGE_FILE_CALLBACKA = windows.PENUM_PAGE_FILE_CALLBACKA;
pub extern "psapi" fn EmptyWorkingSet(hProcess: HANDLE) callconv(WINAPI) BOOL;
-pub extern "psapi" fn EnumDeviceDrivers(lpImageBase: [*]LPVOID, cb: DWORD, lpcbNeeded: LPDWORD) callconv(WINAPI) BOOL;
+pub extern "psapi" fn EnumDeviceDrivers(lpImageBase: [*]LPVOID, cb: DWORD, lpcbNeeded: *DWORD) callconv(WINAPI) BOOL;
pub extern "psapi" fn EnumPageFilesA(pCallBackRoutine: PENUM_PAGE_FILE_CALLBACKA, pContext: LPVOID) callconv(WINAPI) BOOL;
pub extern "psapi" fn EnumPageFilesW(pCallBackRoutine: PENUM_PAGE_FILE_CALLBACKW, pContext: LPVOID) callconv(WINAPI) BOOL;
-pub extern "psapi" fn EnumProcessModules(hProcess: HANDLE, lphModule: [*]HMODULE, cb: DWORD, lpcbNeeded: LPDWORD) callconv(WINAPI) BOOL;
-pub extern "psapi" fn EnumProcessModulesEx(hProcess: HANDLE, lphModule: [*]HMODULE, cb: DWORD, lpcbNeeded: LPDWORD, dwFilterFlag: DWORD) callconv(WINAPI) BOOL;
-pub extern "psapi" fn EnumProcesses(lpidProcess: [*]DWORD, cb: DWORD, cbNeeded: LPDWORD) callconv(WINAPI) BOOL;
+pub extern "psapi" fn EnumProcessModules(hProcess: HANDLE, lphModule: [*]HMODULE, cb: DWORD, lpcbNeeded: *DWORD) callconv(WINAPI) BOOL;
+pub extern "psapi" fn EnumProcessModulesEx(hProcess: HANDLE, lphModule: [*]HMODULE, cb: DWORD, lpcbNeeded: *DWORD, dwFilterFlag: DWORD) callconv(WINAPI) BOOL;
+pub extern "psapi" fn EnumProcesses(lpidProcess: [*]DWORD, cb: DWORD, cbNeeded: *DWORD) callconv(WINAPI) BOOL;
pub extern "psapi" fn GetDeviceDriverBaseNameA(ImageBase: LPVOID, lpBaseName: LPSTR, nSize: DWORD) callconv(WINAPI) DWORD;
pub extern "psapi" fn GetDeviceDriverBaseNameW(ImageBase: LPVOID, lpBaseName: LPWSTR, nSize: DWORD) callconv(WINAPI) DWORD;
pub extern "psapi" fn GetDeviceDriverFileNameA(ImageBase: LPVOID, lpFilename: LPSTR, nSize: DWORD) callconv(WINAPI) DWORD;
@@ -17,13 +63,13 @@ pub extern "psapi" fn GetModuleBaseNameA(hProcess: HANDLE, hModule: ?HMODULE, lp
pub extern "psapi" fn GetModuleBaseNameW(hProcess: HANDLE, hModule: ?HMODULE, lpBaseName: LPWSTR, nSize: DWORD) callconv(WINAPI) DWORD;
pub extern "psapi" fn GetModuleFileNameExA(hProcess: HANDLE, hModule: ?HMODULE, lpFilename: LPSTR, nSize: DWORD) callconv(WINAPI) DWORD;
pub extern "psapi" fn GetModuleFileNameExW(hProcess: HANDLE, hModule: ?HMODULE, lpFilename: LPWSTR, nSize: DWORD) callconv(WINAPI) DWORD;
-pub extern "psapi" fn GetModuleInformation(hProcess: HANDLE, hModule: HMODULE, lpmodinfo: LPMODULEINFO, cb: DWORD) callconv(WINAPI) BOOL;
-pub extern "psapi" fn GetPerformanceInfo(pPerformanceInformation: PPERFORMACE_INFORMATION, cb: DWORD) callconv(WINAPI) BOOL;
+pub extern "psapi" fn GetModuleInformation(hProcess: HANDLE, hModule: HMODULE, lpmodinfo: *MODULEINFO, cb: DWORD) callconv(WINAPI) BOOL;
+pub extern "psapi" fn GetPerformanceInfo(pPerformanceInformation: *PERFORMANCE_INFORMATION, cb: DWORD) callconv(WINAPI) BOOL;
pub extern "psapi" fn GetProcessImageFileNameA(hProcess: HANDLE, lpImageFileName: LPSTR, nSize: DWORD) callconv(WINAPI) DWORD;
pub extern "psapi" fn GetProcessImageFileNameW(hProcess: HANDLE, lpImageFileName: LPWSTR, nSize: DWORD) callconv(WINAPI) DWORD;
-pub extern "psapi" fn GetProcessMemoryInfo(Process: HANDLE, ppsmemCounters: PPROCESS_MEMORY_COUNTERS, cb: DWORD) callconv(WINAPI) BOOL;
-pub extern "psapi" fn GetWsChanges(hProcess: HANDLE, lpWatchInfo: PPSAPI_WS_WATCH_INFORMATION, cb: DWORD) callconv(WINAPI) BOOL;
-pub extern "psapi" fn GetWsChangesEx(hProcess: HANDLE, lpWatchInfoEx: PPSAPI_WS_WATCH_INFORMATION_EX, cb: DWORD) callconv(WINAPI) BOOL;
+pub extern "psapi" fn GetProcessMemoryInfo(Process: HANDLE, ppsmemCounters: *PROCESS_MEMORY_COUNTERS, cb: DWORD) callconv(WINAPI) BOOL;
+pub extern "psapi" fn GetWsChanges(hProcess: HANDLE, lpWatchInfo: *PSAPI_WS_WATCH_INFORMATION, cb: DWORD) callconv(WINAPI) BOOL;
+pub extern "psapi" fn GetWsChangesEx(hProcess: HANDLE, lpWatchInfoEx: *PSAPI_WS_WATCH_INFORMATION_EX, cb: DWORD) callconv(WINAPI) BOOL;
pub extern "psapi" fn InitializeProcessForWsWatch(hProcess: HANDLE) callconv(WINAPI) BOOL;
pub extern "psapi" fn QueryWorkingSet(hProcess: HANDLE, pv: PVOID, cb: DWORD) callconv(WINAPI) BOOL;
pub extern "psapi" fn QueryWorkingSetEx(hProcess: HANDLE, pv: PVOID, cb: DWORD) callconv(WINAPI) BOOL;
diff --git a/lib/std/os/windows/shell32.zig b/lib/std/os/windows/shell32.zig
index 8739f9301e67..befc5793f965 100644
--- a/lib/std/os/windows/shell32.zig
+++ b/lib/std/os/windows/shell32.zig
@@ -1,3 +1,15 @@
-usingnamespace @import("bits.zig");
+const std = @import("../../std.zig");
+const windows = std.os.windows;
+const WINAPI = windows.WINAPI;
+const KNOWNFOLDERID = windows.KNOWNFOLDERID;
+const DWORD = windows.DWORD;
+const HANDLE = windows.HANDLE;
+const WCHAR = windows.WCHAR;
+const HRESULT = windows.HRESULT;
-pub extern "shell32" fn SHGetKnownFolderPath(rfid: *const KNOWNFOLDERID, dwFlags: DWORD, hToken: ?HANDLE, ppszPath: *[*:0]WCHAR) callconv(WINAPI) HRESULT;
+pub extern "shell32" fn SHGetKnownFolderPath(
+ rfid: *const KNOWNFOLDERID,
+ dwFlags: DWORD,
+ hToken: ?HANDLE,
+ ppszPath: *[*:0]WCHAR,
+) callconv(WINAPI) HRESULT;
diff --git a/lib/std/os/windows/user32.zig b/lib/std/os/windows/user32.zig
index e4511b62d3ab..5224b9f0cb8c 100644
--- a/lib/std/os/windows/user32.zig
+++ b/lib/std/os/windows/user32.zig
@@ -1,11 +1,31 @@
-usingnamespace @import("bits.zig");
-const std = @import("std");
-const builtin = std.builtin;
+const std = @import("../../std.zig");
const assert = std.debug.assert;
-const windows = @import("../windows.zig");
-const unexpectedError = windows.unexpectedError;
+
+const windows = std.os.windows;
const GetLastError = windows.kernel32.GetLastError;
const SetLastError = windows.kernel32.SetLastError;
+const unexpectedError = windows.unexpectedError;
+const HWND = windows.HWND;
+const UINT = windows.UINT;
+const HDC = windows.HDC;
+const LONG = windows.LONG;
+const LONG_PTR = windows.LONG_PTR;
+const WINAPI = windows.WINAPI;
+const RECT = windows.RECT;
+const DWORD = windows.DWORD;
+const BOOL = windows.BOOL;
+const TRUE = windows.TRUE;
+const HMENU = windows.HMENU;
+const HINSTANCE = windows.HINSTANCE;
+const LPVOID = windows.LPVOID;
+const ATOM = windows.ATOM;
+const WPARAM = windows.WPARAM;
+const LRESULT = windows.LRESULT;
+const HICON = windows.HICON;
+const LPARAM = windows.LPARAM;
+const POINT = windows.POINT;
+const HCURSOR = windows.HCURSOR;
+const HBRUSH = windows.HBRUSH;
fn selectSymbol(comptime function_static: anytype, function_dynamic: @TypeOf(function_static), comptime os: std.Target.Os.WindowsVersion) @TypeOf(function_static) {
comptime {
@@ -1318,7 +1338,7 @@ pub fn showWindow(hWnd: HWND, nCmdShow: i32) bool {
pub extern "user32" fn UpdateWindow(hWnd: HWND) callconv(WINAPI) BOOL;
pub fn updateWindow(hWnd: HWND) !void {
- if (ShowWindow(hWnd, nCmdShow) == 0) {
+ if (UpdateWindow(hWnd) == 0) {
switch (GetLastError()) {
.INVALID_WINDOW_HANDLE => unreachable,
.INVALID_PARAMETER => unreachable,
diff --git a/lib/std/os/windows/win32error.zig b/lib/std/os/windows/win32error.zig
index 008316ca1371..72ff68f57115 100644
--- a/lib/std/os/windows/win32error.zig
+++ b/lib/std/os/windows/win32error.zig
@@ -1,3696 +1,2507 @@
-// Codes are from https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-erref/18d8fbe8-a967-4f1c-ae50-99ca8e491d2d
+/// Codes are from https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-erref/18d8fbe8-a967-4f1c-ae50-99ca8e491d2d
pub const Win32Error = enum(u16) {
/// The operation completed successfully.
SUCCESS = 0,
-
/// Incorrect function.
INVALID_FUNCTION = 1,
-
/// The system cannot find the file specified.
FILE_NOT_FOUND = 2,
-
/// The system cannot find the path specified.
PATH_NOT_FOUND = 3,
-
/// The system cannot open the file.
TOO_MANY_OPEN_FILES = 4,
-
/// Access is denied.
ACCESS_DENIED = 5,
-
/// The handle is invalid.
INVALID_HANDLE = 6,
-
/// The storage control blocks were destroyed.
ARENA_TRASHED = 7,
-
/// Not enough storage is available to process this command.
NOT_ENOUGH_MEMORY = 8,
-
/// The storage control block address is invalid.
INVALID_BLOCK = 9,
-
/// The environment is incorrect.
BAD_ENVIRONMENT = 10,
-
/// An attempt was made to load a program with an incorrect format.
BAD_FORMAT = 11,
-
/// The access code is invalid.
INVALID_ACCESS = 12,
-
/// The data is invalid.
INVALID_DATA = 13,
-
/// Not enough storage is available to complete this operation.
OUTOFMEMORY = 14,
-
/// The system cannot find the drive specified.
INVALID_DRIVE = 15,
-
/// The directory cannot be removed.
CURRENT_DIRECTORY = 16,
-
/// The system cannot move the file to a different disk drive.
NOT_SAME_DEVICE = 17,
-
/// There are no more files.
NO_MORE_FILES = 18,
-
/// The media is write protected.
WRITE_PROTECT = 19,
-
/// The system cannot find the device specified.
BAD_UNIT = 20,
-
/// The device is not ready.
NOT_READY = 21,
-
/// The device does not recognize the command.
BAD_COMMAND = 22,
-
/// Data error (cyclic redundancy check).
CRC = 23,
-
/// The program issued a command but the command length is incorrect.
BAD_LENGTH = 24,
-
/// The drive cannot locate a specific area or track on the disk.
SEEK = 25,
-
/// The specified disk or diskette cannot be accessed.
NOT_DOS_DISK = 26,
-
/// The drive cannot find the sector requested.
SECTOR_NOT_FOUND = 27,
-
/// The printer is out of paper.
OUT_OF_PAPER = 28,
-
/// The system cannot write to the specified device.
WRITE_FAULT = 29,
-
/// The system cannot read from the specified device.
READ_FAULT = 30,
-
/// A device attached to the system is not functioning.
GEN_FAILURE = 31,
-
/// The process cannot access the file because it is being used by another process.
SHARING_VIOLATION = 32,
-
/// The process cannot access the file because another process has locked a portion of the file.
LOCK_VIOLATION = 33,
-
/// The wrong diskette is in the drive.
/// Insert %2 (Volume Serial Number: %3) into drive %1.
WRONG_DISK = 34,
-
/// Too many files opened for sharing.
SHARING_BUFFER_EXCEEDED = 36,
-
/// Reached the end of the file.
HANDLE_EOF = 38,
-
/// The disk is full.
HANDLE_DISK_FULL = 39,
-
/// The request is not supported.
NOT_SUPPORTED = 50,
-
/// Windows cannot find the network path.
/// Verify that the network path is correct and the destination computer is not busy or turned off.
/// If Windows still cannot find the network path, contact your network administrator.
REM_NOT_LIST = 51,
-
/// You were not connected because a duplicate name exists on the network.
/// If joining a domain, go to System in Control Panel to change the computer name and try again.
/// If joining a workgroup, choose another workgroup name.
DUP_NAME = 52,
-
/// The network path was not found.
BAD_NETPATH = 53,
-
/// The network is busy.
NETWORK_BUSY = 54,
-
/// The specified network resource or device is no longer available.
DEV_NOT_EXIST = 55,
-
/// The network BIOS command limit has been reached.
TOO_MANY_CMDS = 56,
-
/// A network adapter hardware error occurred.
ADAP_HDW_ERR = 57,
-
/// The specified server cannot perform the requested operation.
BAD_NET_RESP = 58,
-
/// An unexpected network error occurred.
UNEXP_NET_ERR = 59,
-
/// The remote adapter is not compatible.
BAD_REM_ADAP = 60,
-
/// The printer queue is full.
PRINTQ_FULL = 61,
-
/// Space to store the file waiting to be printed is not available on the server.
NO_SPOOL_SPACE = 62,
-
/// Your file waiting to be printed was deleted.
PRINT_CANCELLED = 63,
-
/// The specified network name is no longer available.
NETNAME_DELETED = 64,
-
/// Network access is denied.
NETWORK_ACCESS_DENIED = 65,
-
/// The network resource type is not correct.
BAD_DEV_TYPE = 66,
-
/// The network name cannot be found.
BAD_NET_NAME = 67,
-
/// The name limit for the local computer network adapter card was exceeded.
TOO_MANY_NAMES = 68,
-
/// The network BIOS session limit was exceeded.
TOO_MANY_SESS = 69,
-
/// The remote server has been paused or is in the process of being started.
SHARING_PAUSED = 70,
-
/// No more connections can be made to this remote computer at this time because there are already as many connections as the computer can accept.
REQ_NOT_ACCEP = 71,
-
/// The specified printer or disk device has been paused.
REDIR_PAUSED = 72,
-
/// The file exists.
FILE_EXISTS = 80,
-
/// The directory or file cannot be created.
CANNOT_MAKE = 82,
-
/// Fail on INT 24.
FAIL_I24 = 83,
-
/// Storage to process this request is not available.
OUT_OF_STRUCTURES = 84,
-
/// The local device name is already in use.
ALREADY_ASSIGNED = 85,
-
/// The specified network password is not correct.
INVALID_PASSWORD = 86,
-
/// The parameter is incorrect.
INVALID_PARAMETER = 87,
-
/// A write fault occurred on the network.
NET_WRITE_FAULT = 88,
-
/// The system cannot start another process at this time.
NO_PROC_SLOTS = 89,
-
/// Cannot create another system semaphore.
TOO_MANY_SEMAPHORES = 100,
-
/// The exclusive semaphore is owned by another process.
EXCL_SEM_ALREADY_OWNED = 101,
-
/// The semaphore is set and cannot be closed.
SEM_IS_SET = 102,
-
/// The semaphore cannot be set again.
TOO_MANY_SEM_REQUESTS = 103,
-
/// Cannot request exclusive semaphores at interrupt time.
INVALID_AT_INTERRUPT_TIME = 104,
-
/// The previous ownership of this semaphore has ended.
SEM_OWNER_DIED = 105,
-
/// Insert the diskette for drive %1.
SEM_USER_LIMIT = 106,
-
/// The program stopped because an alternate diskette was not inserted.
DISK_CHANGE = 107,
-
/// The disk is in use or locked by another process.
DRIVE_LOCKED = 108,
-
/// The pipe has been ended.
BROKEN_PIPE = 109,
-
/// The system cannot open the device or file specified.
OPEN_FAILED = 110,
-
/// The file name is too long.
BUFFER_OVERFLOW = 111,
-
/// There is not enough space on the disk.
DISK_FULL = 112,
-
/// No more internal file identifiers available.
NO_MORE_SEARCH_HANDLES = 113,
-
/// The target internal file identifier is incorrect.
INVALID_TARGET_HANDLE = 114,
-
/// The IOCTL call made by the application program is not correct.
INVALID_CATEGORY = 117,
-
/// The verify-on-write switch parameter value is not correct.
INVALID_VERIFY_SWITCH = 118,
-
/// The system does not support the command requested.
BAD_DRIVER_LEVEL = 119,
-
/// This function is not supported on this system.
CALL_NOT_IMPLEMENTED = 120,
-
/// The semaphore timeout period has expired.
SEM_TIMEOUT = 121,
-
/// The data area passed to a system call is too small.
INSUFFICIENT_BUFFER = 122,
-
/// The filename, directory name, or volume label syntax is incorrect.
INVALID_NAME = 123,
-
/// The system call level is not correct.
INVALID_LEVEL = 124,
-
/// The disk has no volume label.
NO_VOLUME_LABEL = 125,
-
/// The specified module could not be found.
MOD_NOT_FOUND = 126,
-
/// The specified procedure could not be found.
PROC_NOT_FOUND = 127,
-
/// There are no child processes to wait for.
WAIT_NO_CHILDREN = 128,
-
/// The %1 application cannot be run in Win32 mode.
CHILD_NOT_COMPLETE = 129,
-
/// Attempt to use a file handle to an open disk partition for an operation other than raw disk I/O.
DIRECT_ACCESS_HANDLE = 130,
-
/// An attempt was made to move the file pointer before the beginning of the file.
NEGATIVE_SEEK = 131,
-
/// The file pointer cannot be set on the specified device or file.
SEEK_ON_DEVICE = 132,
-
/// A JOIN or SUBST command cannot be used for a drive that contains previously joined drives.
IS_JOIN_TARGET = 133,
-
/// An attempt was made to use a JOIN or SUBST command on a drive that has already been joined.
IS_JOINED = 134,
-
/// An attempt was made to use a JOIN or SUBST command on a drive that has already been substituted.
IS_SUBSTED = 135,
-
/// The system tried to delete the JOIN of a drive that is not joined.
NOT_JOINED = 136,
-
/// The system tried to delete the substitution of a drive that is not substituted.
NOT_SUBSTED = 137,
-
/// The system tried to join a drive to a directory on a joined drive.
JOIN_TO_JOIN = 138,
-
/// The system tried to substitute a drive to a directory on a substituted drive.
SUBST_TO_SUBST = 139,
-
/// The system tried to join a drive to a directory on a substituted drive.
JOIN_TO_SUBST = 140,
-
/// The system tried to SUBST a drive to a directory on a joined drive.
SUBST_TO_JOIN = 141,
-
/// The system cannot perform a JOIN or SUBST at this time.
BUSY_DRIVE = 142,
-
/// The system cannot join or substitute a drive to or for a directory on the same drive.
SAME_DRIVE = 143,
-
/// The directory is not a subdirectory of the root directory.
DIR_NOT_ROOT = 144,
-
/// The directory is not empty.
DIR_NOT_EMPTY = 145,
-
/// The path specified is being used in a substitute.
IS_SUBST_PATH = 146,
-
/// Not enough resources are available to process this command.
IS_JOIN_PATH = 147,
-
/// The path specified cannot be used at this time.
PATH_BUSY = 148,
-
/// An attempt was made to join or substitute a drive for which a directory on the drive is the target of a previous substitute.
IS_SUBST_TARGET = 149,
-
/// System trace information was not specified in your CONFIG.SYS file, or tracing is disallowed.
SYSTEM_TRACE = 150,
-
/// The number of specified semaphore events for DosMuxSemWait is not correct.
INVALID_EVENT_COUNT = 151,
-
/// DosMuxSemWait did not execute; too many semaphores are already set.
TOO_MANY_MUXWAITERS = 152,
-
/// The DosMuxSemWait list is not correct.
INVALID_LIST_FORMAT = 153,
-
/// The volume label you entered exceeds the label character limit of the target file system.
LABEL_TOO_LONG = 154,
-
/// Cannot create another thread.
TOO_MANY_TCBS = 155,
-
/// The recipient process has refused the signal.
SIGNAL_REFUSED = 156,
-
/// The segment is already discarded and cannot be locked.
DISCARDED = 157,
-
/// The segment is already unlocked.
NOT_LOCKED = 158,
-
/// The address for the thread ID is not correct.
BAD_THREADID_ADDR = 159,
-
/// One or more arguments are not correct.
BAD_ARGUMENTS = 160,
-
/// The specified path is invalid.
BAD_PATHNAME = 161,
-
/// A signal is already pending.
SIGNAL_PENDING = 162,
-
/// No more threads can be created in the system.
MAX_THRDS_REACHED = 164,
-
/// Unable to lock a region of a file.
LOCK_FAILED = 167,
-
/// The requested resource is in use.
BUSY = 170,
-
/// Device's command support detection is in progress.
DEVICE_SUPPORT_IN_PROGRESS = 171,
-
/// A lock request was not outstanding for the supplied cancel region.
CANCEL_VIOLATION = 173,
-
/// The file system does not support atomic changes to the lock type.
ATOMIC_LOCKS_NOT_SUPPORTED = 174,
-
/// The system detected a segment number that was not correct.
INVALID_SEGMENT_NUMBER = 180,
-
/// The operating system cannot run %1.
INVALID_ORDINAL = 182,
-
/// Cannot create a file when that file already exists.
ALREADY_EXISTS = 183,
-
/// The flag passed is not correct.
INVALID_FLAG_NUMBER = 186,
-
/// The specified system semaphore name was not found.
SEM_NOT_FOUND = 187,
-
/// The operating system cannot run %1.
INVALID_STARTING_CODESEG = 188,
-
/// The operating system cannot run %1.
INVALID_STACKSEG = 189,
-
/// The operating system cannot run %1.
INVALID_MODULETYPE = 190,
-
/// Cannot run %1 in Win32 mode.
INVALID_EXE_SIGNATURE = 191,
-
/// The operating system cannot run %1.
EXE_MARKED_INVALID = 192,
-
/// %1 is not a valid Win32 application.
BAD_EXE_FORMAT = 193,
-
/// The operating system cannot run %1.
ITERATED_DATA_EXCEEDS_64k = 194,
-
/// The operating system cannot run %1.
INVALID_MINALLOCSIZE = 195,
-
/// The operating system cannot run this application program.
DYNLINK_FROM_INVALID_RING = 196,
-
/// The operating system is not presently configured to run this application.
IOPL_NOT_ENABLED = 197,
-
/// The operating system cannot run %1.
INVALID_SEGDPL = 198,
-
/// The operating system cannot run this application program.
AUTODATASEG_EXCEEDS_64k = 199,
-
/// The code segment cannot be greater than or equal to 64K.
RING2SEG_MUST_BE_MOVABLE = 200,
-
/// The operating system cannot run %1.
RELOC_CHAIN_XEEDS_SEGLIM = 201,
-
/// The operating system cannot run %1.
INFLOOP_IN_RELOC_CHAIN = 202,
-
/// The system could not find the environment option that was entered.
ENVVAR_NOT_FOUND = 203,
-
/// No process in the command subtree has a signal handler.
NO_SIGNAL_SENT = 205,
-
/// The filename or extension is too long.
FILENAME_EXCED_RANGE = 206,
-
/// The ring 2 stack is in use.
RING2_STACK_IN_USE = 207,
-
/// The global filename characters, * or ?, are entered incorrectly or too many global filename characters are specified.
META_EXPANSION_TOO_LONG = 208,
-
/// The signal being posted is not correct.
INVALID_SIGNAL_NUMBER = 209,
-
/// The signal handler cannot be set.
THREAD_1_INACTIVE = 210,
-
/// The segment is locked and cannot be reallocated.
LOCKED = 212,
-
/// Too many dynamic-link modules are attached to this program or dynamic-link module.
TOO_MANY_MODULES = 214,
-
/// Cannot nest calls to LoadModule.
NESTING_NOT_ALLOWED = 215,
-
/// This version of %1 is not compatible with the version of Windows you're running.
/// Check your computer's system information and then contact the software publisher.
EXE_MACHINE_TYPE_MISMATCH = 216,
-
/// The image file %1 is signed, unable to modify.
EXE_CANNOT_MODIFY_SIGNED_BINARY = 217,
-
/// The image file %1 is strong signed, unable to modify.
EXE_CANNOT_MODIFY_STRONG_SIGNED_BINARY = 218,
-
/// This file is checked out or locked for editing by another user.
FILE_CHECKED_OUT = 220,
-
/// The file must be checked out before saving changes.
CHECKOUT_REQUIRED = 221,
-
/// The file type being saved or retrieved has been blocked.
BAD_FILE_TYPE = 222,
-
/// The file size exceeds the limit allowed and cannot be saved.
FILE_TOO_LARGE = 223,
-
/// Access Denied. Before opening files in this location, you must first add the web site to your trusted sites list, browse to the web site, and select the option to login automatically.
FORMS_AUTH_REQUIRED = 224,
-
/// Operation did not complete successfully because the file contains a virus or potentially unwanted software.
VIRUS_INFECTED = 225,
-
/// This file contains a virus or potentially unwanted software and cannot be opened.
/// Due to the nature of this virus or potentially unwanted software, the file has been removed from this location.
VIRUS_DELETED = 226,
-
/// The pipe is local.
PIPE_LOCAL = 229,
-
/// The pipe state is invalid.
BAD_PIPE = 230,
-
/// All pipe instances are busy.
PIPE_BUSY = 231,
-
/// The pipe is being closed.
NO_DATA = 232,
-
/// No process is on the other end of the pipe.
PIPE_NOT_CONNECTED = 233,
-
/// More data is available.
MORE_DATA = 234,
-
/// The session was canceled.
VC_DISCONNECTED = 240,
-
/// The specified extended attribute name was invalid.
INVALID_EA_NAME = 254,
-
/// The extended attributes are inconsistent.
EA_LIST_INCONSISTENT = 255,
-
/// The wait operation timed out.
IMEOUT = 258,
-
/// No more data is available.
NO_MORE_ITEMS = 259,
-
/// The copy functions cannot be used.
CANNOT_COPY = 266,
-
/// The directory name is invalid.
DIRECTORY = 267,
-
/// The extended attributes did not fit in the buffer.
EAS_DIDNT_FIT = 275,
-
/// The extended attribute file on the mounted file system is corrupt.
EA_FILE_CORRUPT = 276,
-
/// The extended attribute table file is full.
EA_TABLE_FULL = 277,
-
/// The specified extended attribute handle is invalid.
INVALID_EA_HANDLE = 278,
-
/// The mounted file system does not support extended attributes.
EAS_NOT_SUPPORTED = 282,
-
/// Attempt to release mutex not owned by caller.
NOT_OWNER = 288,
-
/// Too many posts were made to a semaphore.
TOO_MANY_POSTS = 298,
-
/// Only part of a ReadProcessMemory or WriteProcessMemory request was completed.
PARTIAL_COPY = 299,
-
/// The oplock request is denied.
OPLOCK_NOT_GRANTED = 300,
-
/// An invalid oplock acknowledgment was received by the system.
INVALID_OPLOCK_PROTOCOL = 301,
-
/// The volume is too fragmented to complete this operation.
DISK_TOO_FRAGMENTED = 302,
-
/// The file cannot be opened because it is in the process of being deleted.
DELETE_PENDING = 303,
-
/// Short name settings may not be changed on this volume due to the global registry setting.
INCOMPATIBLE_WITH_GLOBAL_SHORT_NAME_REGISTRY_SETTING = 304,
-
/// Short names are not enabled on this volume.
SHORT_NAMES_NOT_ENABLED_ON_VOLUME = 305,
-
/// The security stream for the given volume is in an inconsistent state. Please run CHKDSK on the volume.
SECURITY_STREAM_IS_INCONSISTENT = 306,
-
/// A requested file lock operation cannot be processed due to an invalid byte range.
INVALID_LOCK_RANGE = 307,
-
/// The subsystem needed to support the image type is not present.
IMAGE_SUBSYSTEM_NOT_PRESENT = 308,
-
/// The specified file already has a notification GUID associated with it.
NOTIFICATION_GUID_ALREADY_DEFINED = 309,
-
/// An invalid exception handler routine has been detected.
INVALID_EXCEPTION_HANDLER = 310,
-
/// Duplicate privileges were specified for the token.
DUPLICATE_PRIVILEGES = 311,
-
/// No ranges for the specified operation were able to be processed.
NO_RANGES_PROCESSED = 312,
-
/// Operation is not allowed on a file system internal file.
NOT_ALLOWED_ON_SYSTEM_FILE = 313,
-
/// The physical resources of this disk have been exhausted.
DISK_RESOURCES_EXHAUSTED = 314,
-
/// The token representing the data is invalid.
INVALID_TOKEN = 315,
-
/// The device does not support the command feature.
DEVICE_FEATURE_NOT_SUPPORTED = 316,
-
/// The system cannot find message text for message number 0x%1 in the message file for %2.
MR_MID_NOT_FOUND = 317,
-
/// The scope specified was not found.
SCOPE_NOT_FOUND = 318,
-
/// The Central Access Policy specified is not defined on the target machine.
UNDEFINED_SCOPE = 319,
-
/// The Central Access Policy obtained from Active Directory is invalid.
INVALID_CAP = 320,
-
/// The device is unreachable.
DEVICE_UNREACHABLE = 321,
-
/// The target device has insufficient resources to complete the operation.
DEVICE_NO_RESOURCES = 322,
-
/// A data integrity checksum error occurred. Data in the file stream is corrupt.
DATA_CHECKSUM_ERROR = 323,
-
/// An attempt was made to modify both a KERNEL and normal Extended Attribute (EA) in the same operation.
INTERMIXED_KERNEL_EA_OPERATION = 324,
-
/// Device does not support file-level TRIM.
FILE_LEVEL_TRIM_NOT_SUPPORTED = 326,
-
/// The command specified a data offset that does not align to the device's granularity/alignment.
OFFSET_ALIGNMENT_VIOLATION = 327,
-
/// The command specified an invalid field in its parameter list.
INVALID_FIELD_IN_PARAMETER_LIST = 328,
-
/// An operation is currently in progress with the device.
OPERATION_IN_PROGRESS = 329,
-
/// An attempt was made to send down the command via an invalid path to the target device.
BAD_DEVICE_PATH = 330,
-
/// The command specified a number of descriptors that exceeded the maximum supported by the device.
TOO_MANY_DESCRIPTORS = 331,
-
/// Scrub is disabled on the specified file.
SCRUB_DATA_DISABLED = 332,
-
/// The storage device does not provide redundancy.
NOT_REDUNDANT_STORAGE = 333,
-
/// An operation is not supported on a resident file.
RESIDENT_FILE_NOT_SUPPORTED = 334,
-
/// An operation is not supported on a compressed file.
COMPRESSED_FILE_NOT_SUPPORTED = 335,
-
/// An operation is not supported on a directory.
DIRECTORY_NOT_SUPPORTED = 336,
-
/// The specified copy of the requested data could not be read.
NOT_READ_FROM_COPY = 337,
-
/// No action was taken as a system reboot is required.
FAIL_NOACTION_REBOOT = 350,
-
/// The shutdown operation failed.
FAIL_SHUTDOWN = 351,
-
/// The restart operation failed.
FAIL_RESTART = 352,
-
/// The maximum number of sessions has been reached.
MAX_SESSIONS_REACHED = 353,
-
/// The thread is already in background processing mode.
THREAD_MODE_ALREADY_BACKGROUND = 400,
-
/// The thread is not in background processing mode.
THREAD_MODE_NOT_BACKGROUND = 401,
-
/// The process is already in background processing mode.
PROCESS_MODE_ALREADY_BACKGROUND = 402,
-
/// The process is not in background processing mode.
PROCESS_MODE_NOT_BACKGROUND = 403,
-
/// Attempt to access invalid address.
INVALID_ADDRESS = 487,
-
/// User profile cannot be loaded.
USER_PROFILE_LOAD = 500,
-
/// Arithmetic result exceeded 32 bits.
ARITHMETIC_OVERFLOW = 534,
-
/// There is a process on other end of the pipe.
PIPE_CONNECTED = 535,
-
/// Waiting for a process to open the other end of the pipe.
PIPE_LISTENING = 536,
-
/// Application verifier has found an error in the current process.
VERIFIER_STOP = 537,
-
/// An error occurred in the ABIOS subsystem.
ABIOS_ERROR = 538,
-
/// A warning occurred in the WX86 subsystem.
WX86_WARNING = 539,
-
/// An error occurred in the WX86 subsystem.
WX86_ERROR = 540,
-
/// An attempt was made to cancel or set a timer that has an associated APC and the subject thread is not the thread that originally set the timer with an associated APC routine.
TIMER_NOT_CANCELED = 541,
-
/// Unwind exception code.
UNWIND = 542,
-
/// An invalid or unaligned stack was encountered during an unwind operation.
BAD_STACK = 543,
-
/// An invalid unwind target was encountered during an unwind operation.
INVALID_UNWIND_TARGET = 544,
-
/// Invalid Object Attributes specified to NtCreatePort or invalid Port Attributes specified to NtConnectPort
INVALID_PORT_ATTRIBUTES = 545,
-
/// Length of message passed to NtRequestPort or NtRequestWaitReplyPort was longer than the maximum message allowed by the port.
PORT_MESSAGE_TOO_LONG = 546,
-
/// An attempt was made to lower a quota limit below the current usage.
INVALID_QUOTA_LOWER = 547,
-
/// An attempt was made to attach to a device that was already attached to another device.
DEVICE_ALREADY_ATTACHED = 548,
-
/// An attempt was made to execute an instruction at an unaligned address and the host system does not support unaligned instruction references.
INSTRUCTION_MISALIGNMENT = 549,
-
/// Profiling not started.
PROFILING_NOT_STARTED = 550,
-
/// Profiling not stopped.
PROFILING_NOT_STOPPED = 551,
-
/// The passed ACL did not contain the minimum required information.
COULD_NOT_INTERPRET = 552,
-
/// The number of active profiling objects is at the maximum and no more may be started.
PROFILING_AT_LIMIT = 553,
-
/// Used to indicate that an operation cannot continue without blocking for I/O.
CANT_WAIT = 554,
-
/// Indicates that a thread attempted to terminate itself by default (called NtTerminateThread with NULL) and it was the last thread in the current process.
CANT_TERMINATE_SELF = 555,
-
/// If an MM error is returned which is not defined in the standard FsRtl filter, it is converted to one of the following errors which is guaranteed to be in the filter.
/// In this case information is lost, however, the filter correctly handles the exception.
UNEXPECTED_MM_CREATE_ERR = 556,
-
/// If an MM error is returned which is not defined in the standard FsRtl filter, it is converted to one of the following errors which is guaranteed to be in the filter.
/// In this case information is lost, however, the filter correctly handles the exception.
UNEXPECTED_MM_MAP_ERROR = 557,
-
/// If an MM error is returned which is not defined in the standard FsRtl filter, it is converted to one of the following errors which is guaranteed to be in the filter.
/// In this case information is lost, however, the filter correctly handles the exception.
UNEXPECTED_MM_EXTEND_ERR = 558,
-
/// A malformed function table was encountered during an unwind operation.
BAD_FUNCTION_TABLE = 559,
-
/// Indicates that an attempt was made to assign protection to a file system file or directory and one of the SIDs in the security descriptor could not be translated into a GUID that could be stored by the file system.
/// This causes the protection attempt to fail, which may cause a file creation attempt to fail.
NO_GUID_TRANSLATION = 560,
-
/// Indicates that an attempt was made to grow an LDT by setting its size, or that the size was not an even number of selectors.
INVALID_LDT_SIZE = 561,
-
/// Indicates that the starting value for the LDT information was not an integral multiple of the selector size.
INVALID_LDT_OFFSET = 563,
-
/// Indicates that the user supplied an invalid descriptor when trying to set up Ldt descriptors.
INVALID_LDT_DESCRIPTOR = 564,
-
/// Indicates a process has too many threads to perform the requested action.
/// For example, assignment of a primary token may only be performed when a process has zero or one threads.
TOO_MANY_THREADS = 565,
-
/// An attempt was made to operate on a thread within a specific process, but the thread specified is not in the process specified.
THREAD_NOT_IN_PROCESS = 566,
-
/// Page file quota was exceeded.
PAGEFILE_QUOTA_EXCEEDED = 567,
-
/// The Netlogon service cannot start because another Netlogon service running in the domain conflicts with the specified role.
LOGON_SERVER_CONFLICT = 568,
-
/// The SAM database on a Windows Server is significantly out of synchronization with the copy on the Domain Controller. A complete synchronization is required.
SYNCHRONIZATION_REQUIRED = 569,
-
/// The NtCreateFile API failed. This error should never be returned to an application, it is a place holder for the Windows Lan Manager Redirector to use in its internal error mapping routines.
NET_OPEN_FAILED = 570,
-
/// {Privilege Failed} The I/O permissions for the process could not be changed.
IO_PRIVILEGE_FAILED = 571,
-
/// {Application Exit by CTRL+C} The application terminated as a result of a CTRL+C.
CONTROL_C_EXIT = 572,
-
/// {Missing System File} The required system file %hs is bad or missing.
MISSING_SYSTEMFILE = 573,
-
/// {Application Error} The exception %s (0x%08lx) occurred in the application at location 0x%08lx.
UNHANDLED_EXCEPTION = 574,
-
/// {Application Error} The application was unable to start correctly (0x%lx). Click OK to close the application.
APP_INIT_FAILURE = 575,
-
/// {Unable to Create Paging File} The creation of the paging file %hs failed (%lx). The requested size was %ld.
PAGEFILE_CREATE_FAILED = 576,
-
/// Windows cannot verify the digital signature for this file.
/// A recent hardware or software change might have installed a file that is signed incorrectly or damaged, or that might be malicious software from an unknown source.
INVALID_IMAGE_HASH = 577,
-
/// {No Paging File Specified} No paging file was specified in the system configuration.
NO_PAGEFILE = 578,
-
/// {EXCEPTION} A real-mode application issued a floating-point instruction and floating-point hardware is not present.
ILLEGAL_FLOAT_CONTEXT = 579,
-
/// An event pair synchronization operation was performed using the thread specific client/server event pair object, but no event pair object was associated with the thread.
NO_EVENT_PAIR = 580,
-
/// A Windows Server has an incorrect configuration.
DOMAIN_CTRLR_CONFIG_ERROR = 581,
-
/// An illegal character was encountered.
/// For a multi-byte character set this includes a lead byte without a succeeding trail byte.
/// For the Unicode character set this includes the characters 0xFFFF and 0xFFFE.
ILLEGAL_CHARACTER = 582,
-
/// The Unicode character is not defined in the Unicode character set installed on the system.
UNDEFINED_CHARACTER = 583,
-
/// The paging file cannot be created on a floppy diskette.
FLOPPY_VOLUME = 584,
-
/// The system BIOS failed to connect a system interrupt to the device or bus for which the device is connected.
BIOS_FAILED_TO_CONNECT_INTERRUPT = 585,
-
/// This operation is only allowed for the Primary Domain Controller of the domain.
BACKUP_CONTROLLER = 586,
-
/// An attempt was made to acquire a mutant such that its maximum count would have been exceeded.
MUTANT_LIMIT_EXCEEDED = 587,
-
/// A volume has been accessed for which a file system driver is required that has not yet been loaded.
FS_DRIVER_REQUIRED = 588,
-
/// {Registry File Failure} The registry cannot load the hive (file): %hs or its log or alternate. It is corrupt, absent, or not writable.
CANNOT_LOAD_REGISTRY_FILE = 589,
-
/// {Unexpected Failure in DebugActiveProcess} An unexpected failure occurred while processing a DebugActiveProcess API request.
/// You may choose OK to terminate the process, or Cancel to ignore the error.
DEBUG_ATTACH_FAILED = 590,
-
/// {Fatal System Error} The %hs system process terminated unexpectedly with a status of 0x%08x (0x%08x 0x%08x). The system has been shut down.
SYSTEM_PROCESS_TERMINATED = 591,
-
/// {Data Not Accepted} The TDI client could not handle the data received during an indication.
DATA_NOT_ACCEPTED = 592,
-
/// NTVDM encountered a hard error.
VDM_HARD_ERROR = 593,
-
/// {Cancel Timeout} The driver %hs failed to complete a cancelled I/O request in the allotted time.
DRIVER_CANCEL_TIMEOUT = 594,
-
/// {Reply Message Mismatch} An attempt was made to reply to an LPC message, but the thread specified by the client ID in the message was not waiting on that message.
REPLY_MESSAGE_MISMATCH = 595,
-
/// {Delayed Write Failed} Windows was unable to save all the data for the file %hs. The data has been lost.
/// This error may be caused by a failure of your computer hardware or network connection. Please try to save this file elsewhere.
LOST_WRITEBEHIND_DATA = 596,
-
/// The parameter(s) passed to the server in the client/server shared memory window were invalid.
/// Too much data may have been put in the shared memory window.
CLIENT_SERVER_PARAMETERS_INVALID = 597,
-
/// The stream is not a tiny stream.
NOT_TINY_STREAM = 598,
-
/// The request must be handled by the stack overflow code.
STACK_OVERFLOW_READ = 599,
-
/// Internal OFS status codes indicating how an allocation operation is handled.
/// Either it is retried after the containing onode is moved or the extent stream is converted to a large stream.
CONVERT_TO_LARGE = 600,
-
/// The attempt to find the object found an object matching by ID on the volume but it is out of the scope of the handle used for the operation.
FOUND_OUT_OF_SCOPE = 601,
-
/// The bucket array must be grown. Retry transaction after doing so.
ALLOCATE_BUCKET = 602,
-
/// The user/kernel marshalling buffer has overflowed.
MARSHALL_OVERFLOW = 603,
-
/// The supplied variant structure contains invalid data.
INVALID_VARIANT = 604,
-
/// The specified buffer contains ill-formed data.
BAD_COMPRESSION_BUFFER = 605,
-
/// {Audit Failed} An attempt to generate a security audit failed.
AUDIT_FAILED = 606,
-
/// The timer resolution was not previously set by the current process.
TIMER_RESOLUTION_NOT_SET = 607,
-
/// There is insufficient account information to log you on.
INSUFFICIENT_LOGON_INFO = 608,
-
/// {Invalid DLL Entrypoint} The dynamic link library %hs is not written correctly.
/// The stack pointer has been left in an inconsistent state.
/// The entrypoint should be declared as WINAPI or STDCALL.
/// Select YES to fail the DLL load. Select NO to continue execution.
/// Selecting NO may cause the application to operate incorrectly.
BAD_DLL_ENTRYPOINT = 609,
-
/// {Invalid Service Callback Entrypoint} The %hs service is not written correctly.
/// The stack pointer has been left in an inconsistent state.
/// The callback entrypoint should be declared as WINAPI or STDCALL.
/// Selecting OK will cause the service to continue operation.
/// However, the service process may operate incorrectly.
BAD_SERVICE_ENTRYPOINT = 610,
-
/// There is an IP address conflict with another system on the network.
IP_ADDRESS_CONFLICT1 = 611,
-
/// There is an IP address conflict with another system on the network.
IP_ADDRESS_CONFLICT2 = 612,
-
/// {Low On Registry Space} The system has reached the maximum size allowed for the system part of the registry. Additional storage requests will be ignored.
REGISTRY_QUOTA_LIMIT = 613,
-
/// A callback return system service cannot be executed when no callback is active.
NO_CALLBACK_ACTIVE = 614,
-
/// The password provided is too short to meet the policy of your user account. Please choose a longer password.
PWD_TOO_SHORT = 615,
-
/// The policy of your user account does not allow you to change passwords too frequently.
/// This is done to prevent users from changing back to a familiar, but potentially discovered, password.
/// If you feel your password has been compromised then please contact your administrator immediately to have a new one assigned.
PWD_TOO_RECENT = 616,
-
/// You have attempted to change your password to one that you have used in the past.
/// The policy of your user account does not allow this.
/// Please select a password that you have not previously used.
PWD_HISTORY_CONFLICT = 617,
-
/// The specified compression format is unsupported.
UNSUPPORTED_COMPRESSION = 618,
-
/// The specified hardware profile configuration is invalid.
INVALID_HW_PROFILE = 619,
-
/// The specified Plug and Play registry device path is invalid.
INVALID_PLUGPLAY_DEVICE_PATH = 620,
-
/// The specified quota list is internally inconsistent with its descriptor.
QUOTA_LIST_INCONSISTENT = 621,
-
/// {Windows Evaluation Notification} The evaluation period for this installation of Windows has expired. This system will shutdown in 1 hour.
/// To restore access to this installation of Windows, please upgrade this installation using a licensed distribution of this product.
EVALUATION_EXPIRATION = 622,
-
/// {Illegal System DLL Relocation} The system DLL %hs was relocated in memory. The application will not run properly.
/// The relocation occurred because the DLL %hs occupied an address range reserved for Windows system DLLs.
/// The vendor supplying the DLL should be contacted for a new DLL.
ILLEGAL_DLL_RELOCATION = 623,
-
/// {DLL Initialization Failed} The application failed to initialize because the window station is shutting down.
DLL_INIT_FAILED_LOGOFF = 624,
-
/// The validation process needs to continue on to the next step.
VALIDATE_CONTINUE = 625,
-
/// There are no more matches for the current index enumeration.
NO_MORE_MATCHES = 626,
-
/// The range could not be added to the range list because of a conflict.
RANGE_LIST_CONFLICT = 627,
-
/// The server process is running under a SID different than that required by client.
SERVER_SID_MISMATCH = 628,
-
/// A group marked use for deny only cannot be enabled.
CANT_ENABLE_DENY_ONLY = 629,
-
/// {EXCEPTION} Multiple floating point faults.
FLOAT_MULTIPLE_FAULTS = 630,
-
/// {EXCEPTION} Multiple floating point traps.
FLOAT_MULTIPLE_TRAPS = 631,
-
/// The requested interface is not supported.
NOINTERFACE = 632,
-
/// {System Standby Failed} The driver %hs does not support standby mode.
/// Updating this driver may allow the system to go to standby mode.
DRIVER_FAILED_SLEEP = 633,
-
/// The system file %1 has become corrupt and has been replaced.
CORRUPT_SYSTEM_FILE = 634,
-
/// {Virtual Memory Minimum Too Low} Your system is low on virtual memory.
/// Windows is increasing the size of your virtual memory paging file.
/// During this process, memory requests for some applications may be denied. For more information, see Help.
COMMITMENT_MINIMUM = 635,
-
/// A device was removed so enumeration must be restarted.
PNP_RESTART_ENUMERATION = 636,
-
/// {Fatal System Error} The system image %s is not properly signed.
/// The file has been replaced with the signed file. The system has been shut down.
SYSTEM_IMAGE_BAD_SIGNATURE = 637,
-
/// Device will not start without a reboot.
PNP_REBOOT_REQUIRED = 638,
-
/// There is not enough power to complete the requested operation.
INSUFFICIENT_POWER = 639,
-
/// ERROR_MULTIPLE_FAULT_VIOLATION
MULTIPLE_FAULT_VIOLATION = 640,
-
/// The system is in the process of shutting down.
SYSTEM_SHUTDOWN = 641,
-
/// An attempt to remove a processes DebugPort was made, but a port was not already associated with the process.
PORT_NOT_SET = 642,
-
/// This version of Windows is not compatible with the behavior version of directory forest, domain or domain controller.
DS_VERSION_CHECK_FAILURE = 643,
-
/// The specified range could not be found in the range list.
RANGE_NOT_FOUND = 644,
-
/// The driver was not loaded because the system is booting into safe mode.
NOT_SAFE_MODE_DRIVER = 646,
-
/// The driver was not loaded because it failed its initialization call.
FAILED_DRIVER_ENTRY = 647,
-
/// The "%hs" encountered an error while applying power or reading the device configuration.
/// This may be caused by a failure of your hardware or by a poor connection.
DEVICE_ENUMERATION_ERROR = 648,
-
/// The create operation failed because the name contained at least one mount point which resolves to a volume to which the specified device object is not attached.
MOUNT_POINT_NOT_RESOLVED = 649,
-
/// The device object parameter is either not a valid device object or is not attached to the volume specified by the file name.
INVALID_DEVICE_OBJECT_PARAMETER = 650,
-
/// A Machine Check Error has occurred.
/// Please check the system eventlog for additional information.
MCA_OCCURED = 651,
-
/// There was error [%2] processing the driver database.
DRIVER_DATABASE_ERROR = 652,
-
/// System hive size has exceeded its limit.
SYSTEM_HIVE_TOO_LARGE = 653,
-
/// The driver could not be loaded because a previous version of the driver is still in memory.
DRIVER_FAILED_PRIOR_UNLOAD = 654,
-
/// {Volume Shadow Copy Service} Please wait while the Volume Shadow Copy Service prepares volume %hs for hibernation.
VOLSNAP_PREPARE_HIBERNATE = 655,
-
/// The system has failed to hibernate (The error code is %hs).
/// Hibernation will be disabled until the system is restarted.
HIBERNATION_FAILURE = 656,
-
/// The password provided is too long to meet the policy of your user account. Please choose a shorter password.
PWD_TOO_LONG = 657,
-
/// The requested operation could not be completed due to a file system limitation.
FILE_SYSTEM_LIMITATION = 665,
-
/// An assertion failure has occurred.
ASSERTION_FAILURE = 668,
-
/// An error occurred in the ACPI subsystem.
ACPI_ERROR = 669,
-
/// WOW Assertion Error.
WOW_ASSERTION = 670,
-
/// A device is missing in the system BIOS MPS table. This device will not be used.
/// Please contact your system vendor for system BIOS update.
PNP_BAD_MPS_TABLE = 671,
-
/// A translator failed to translate resources.
PNP_TRANSLATION_FAILED = 672,
-
/// A IRQ translator failed to translate resources.
PNP_IRQ_TRANSLATION_FAILED = 673,
-
/// Driver %2 returned invalid ID for a child device (%3).
PNP_INVALID_ID = 674,
-
/// {Kernel Debugger Awakened} the system debugger was awakened by an interrupt.
WAKE_SYSTEM_DEBUGGER = 675,
-
/// {Handles Closed} Handles to objects have been automatically closed as a result of the requested operation.
HANDLES_CLOSED = 676,
-
/// {Too Much Information} The specified access control list (ACL) contained more information than was expected.
EXTRANEOUS_INFORMATION = 677,
-
/// This warning level status indicates that the transaction state already exists for the registry sub-tree, but that a transaction commit was previously aborted.
/// The commit has NOT been completed, but has not been rolled back either (so it may still be committed if desired).
RXACT_COMMIT_NECESSARY = 678,
-
/// {Media Changed} The media may have changed.
MEDIA_CHECK = 679,
-
/// {GUID Substitution} During the translation of a global identifier (GUID) to a Windows security ID (SID), no administratively-defined GUID prefix was found.
/// A substitute prefix was used, which will not compromise system security.
/// However, this may provide a more restrictive access than intended.
GUID_SUBSTITUTION_MADE = 680,
-
/// The create operation stopped after reaching a symbolic link.
STOPPED_ON_SYMLINK = 681,
-
/// A long jump has been executed.
LONGJUMP = 682,
-
/// The Plug and Play query operation was not successful.
PLUGPLAY_QUERY_VETOED = 683,
-
/// A frame consolidation has been executed.
UNWIND_CONSOLIDATE = 684,
-
/// {Registry Hive Recovered} Registry hive (file): %hs was corrupted and it has been recovered. Some data might have been lost.
REGISTRY_HIVE_RECOVERED = 685,
-
/// The application is attempting to run executable code from the module %hs. This may be insecure.
/// An alternative, %hs, is available. Should the application use the secure module %hs?
DLL_MIGHT_BE_INSECURE = 686,
-
/// The application is loading executable code from the module %hs.
/// This is secure, but may be incompatible with previous releases of the operating system.
/// An alternative, %hs, is available. Should the application use the secure module %hs?
DLL_MIGHT_BE_INCOMPATIBLE = 687,
-
/// Debugger did not handle the exception.
DBG_EXCEPTION_NOT_HANDLED = 688,
-
/// Debugger will reply later.
DBG_REPLY_LATER = 689,
-
/// Debugger cannot provide handle.
DBG_UNABLE_TO_PROVIDE_HANDLE = 690,
-
/// Debugger terminated thread.
DBG_TERMINATE_THREAD = 691,
-
/// Debugger terminated process.
DBG_TERMINATE_PROCESS = 692,
-
/// Debugger got control C.
DBG_CONTROL_C = 693,
-
/// Debugger printed exception on control C.
DBG_PRINTEXCEPTION_C = 694,
-
/// Debugger received RIP exception.
DBG_RIPEXCEPTION = 695,
-
/// Debugger received control break.
DBG_CONTROL_BREAK = 696,
-
/// Debugger command communication exception.
DBG_COMMAND_EXCEPTION = 697,
-
/// {Object Exists} An attempt was made to create an object and the object name already existed.
OBJECT_NAME_EXISTS = 698,
-
/// {Thread Suspended} A thread termination occurred while the thread was suspended.
/// The thread was resumed, and termination proceeded.
THREAD_WAS_SUSPENDED = 699,
-
/// {Image Relocated} An image file could not be mapped at the address specified in the image file. Local fixups must be performed on this image.
IMAGE_NOT_AT_BASE = 700,
-
/// This informational level status indicates that a specified registry sub-tree transaction state did not yet exist and had to be created.
RXACT_STATE_CREATED = 701,
-
/// {Segment Load} A virtual DOS machine (VDM) is loading, unloading, or moving an MS-DOS or Win16 program segment image.
/// An exception is raised so a debugger can load, unload or track symbols and breakpoints within these 16-bit segments.
SEGMENT_NOTIFICATION = 702,
-
/// {Invalid Current Directory} The process cannot switch to the startup current directory %hs.
/// Select OK to set current directory to %hs, or select CANCEL to exit.
BAD_CURRENT_DIRECTORY = 703,
-
/// {Redundant Read} To satisfy a read request, the NT fault-tolerant file system successfully read the requested data from a redundant copy.
/// This was done because the file system encountered a failure on a member of the fault-tolerant volume, but was unable to reassign the failing area of the device.
FT_READ_RECOVERY_FROM_BACKUP = 704,
-
/// {Redundant Write} To satisfy a write request, the NT fault-tolerant file system successfully wrote a redundant copy of the information.
/// This was done because the file system encountered a failure on a member of the fault-tolerant volume, but was not able to reassign the failing area of the device.
FT_WRITE_RECOVERY = 705,
-
/// {Machine Type Mismatch} The image file %hs is valid, but is for a machine type other than the current machine.
/// Select OK to continue, or CANCEL to fail the DLL load.
IMAGE_MACHINE_TYPE_MISMATCH = 706,
-
/// {Partial Data Received} The network transport returned partial data to its client. The remaining data will be sent later.
RECEIVE_PARTIAL = 707,
-
/// {Expedited Data Received} The network transport returned data to its client that was marked as expedited by the remote system.
RECEIVE_EXPEDITED = 708,
-
/// {Partial Expedited Data Received} The network transport returned partial data to its client and this data was marked as expedited by the remote system. The remaining data will be sent later.
RECEIVE_PARTIAL_EXPEDITED = 709,
-
/// {TDI Event Done} The TDI indication has completed successfully.
EVENT_DONE = 710,
-
/// {TDI Event Pending} The TDI indication has entered the pending state.
EVENT_PENDING = 711,
-
/// Checking file system on %wZ.
CHECKING_FILE_SYSTEM = 712,
-
/// {Fatal Application Exit} %hs.
FATAL_APP_EXIT = 713,
-
/// The specified registry key is referenced by a predefined handle.
PREDEFINED_HANDLE = 714,
-
/// {Page Unlocked} The page protection of a locked page was changed to 'No Access' and the page was unlocked from memory and from the process.
WAS_UNLOCKED = 715,
-
/// %hs
SERVICE_NOTIFICATION = 716,
-
/// {Page Locked} One of the pages to lock was already locked.
WAS_LOCKED = 717,
-
/// Application popup: %1 : %2
LOG_HARD_ERROR = 718,
-
/// ERROR_ALREADY_WIN32
ALREADY_WIN32 = 719,
-
/// {Machine Type Mismatch} The image file %hs is valid, but is for a machine type other than the current machine.
IMAGE_MACHINE_TYPE_MISMATCH_EXE = 720,
-
/// A yield execution was performed and no thread was available to run.
NO_YIELD_PERFORMED = 721,
-
/// The resumable flag to a timer API was ignored.
TIMER_RESUME_IGNORED = 722,
-
/// The arbiter has deferred arbitration of these resources to its parent.
ARBITRATION_UNHANDLED = 723,
-
/// The inserted CardBus device cannot be started because of a configuration error on "%hs".
CARDBUS_NOT_SUPPORTED = 724,
-
/// The CPUs in this multiprocessor system are not all the same revision level.
/// To use all processors the operating system restricts itself to the features of the least capable processor in the system.
/// Should problems occur with this system, contact the CPU manufacturer to see if this mix of processors is supported.
MP_PROCESSOR_MISMATCH = 725,
-
/// The system was put into hibernation.
HIBERNATED = 726,
-
/// The system was resumed from hibernation.
RESUME_HIBERNATION = 727,
-
/// Windows has detected that the system firmware (BIOS) was updated [previous firmware date = %2, current firmware date %3].
FIRMWARE_UPDATED = 728,
-
/// A device driver is leaking locked I/O pages causing system degradation.
/// The system has automatically enabled tracking code in order to try and catch the culprit.
DRIVERS_LEAKING_LOCKED_PAGES = 729,
-
/// The system has awoken.
WAKE_SYSTEM = 730,
-
/// ERROR_WAIT_1
WAIT_1 = 731,
-
/// ERROR_WAIT_2
WAIT_2 = 732,
-
/// ERROR_WAIT_3
WAIT_3 = 733,
-
/// ERROR_WAIT_63
WAIT_63 = 734,
-
/// ERROR_ABANDONED_WAIT_0
ABANDONED_WAIT_0 = 735,
-
/// ERROR_ABANDONED_WAIT_63
ABANDONED_WAIT_63 = 736,
-
/// ERROR_USER_APC
USER_APC = 737,
-
/// ERROR_KERNEL_APC
KERNEL_APC = 738,
-
/// ERROR_ALERTED
ALERTED = 739,
-
/// The requested operation requires elevation.
ELEVATION_REQUIRED = 740,
-
/// A reparse should be performed by the Object Manager since the name of the file resulted in a symbolic link.
REPARSE = 741,
-
/// An open/create operation completed while an oplock break is underway.
OPLOCK_BREAK_IN_PROGRESS = 742,
-
/// A new volume has been mounted by a file system.
VOLUME_MOUNTED = 743,
-
/// This success level status indicates that the transaction state already exists for the registry sub-tree, but that a transaction commit was previously aborted. The commit has now been completed.
RXACT_COMMITTED = 744,
-
/// This indicates that a notify change request has been completed due to closing the handle which made the notify change request.
NOTIFY_CLEANUP = 745,
-
/// {Connect Failure on Primary Transport} An attempt was made to connect to the remote server %hs on the primary transport, but the connection failed.
/// The computer WAS able to connect on a secondary transport.
PRIMARY_TRANSPORT_CONNECT_FAILED = 746,
-
/// Page fault was a transition fault.
PAGE_FAULT_TRANSITION = 747,
-
/// Page fault was a demand zero fault.
PAGE_FAULT_DEMAND_ZERO = 748,
-
/// Page fault was a demand zero fault.
PAGE_FAULT_COPY_ON_WRITE = 749,
-
/// Page fault was a demand zero fault.
PAGE_FAULT_GUARD_PAGE = 750,
-
/// Page fault was satisfied by reading from a secondary storage device.
PAGE_FAULT_PAGING_FILE = 751,
-
/// Cached page was locked during operation.
CACHE_PAGE_LOCKED = 752,
-
/// Crash dump exists in paging file.
CRASH_DUMP = 753,
-
/// Specified buffer contains all zeros.
BUFFER_ALL_ZEROS = 754,
-
/// A reparse should be performed by the Object Manager since the name of the file resulted in a symbolic link.
REPARSE_OBJECT = 755,
-
/// The device has succeeded a query-stop and its resource requirements have changed.
RESOURCE_REQUIREMENTS_CHANGED = 756,
-
/// The translator has translated these resources into the global space and no further translations should be performed.
TRANSLATION_COMPLETE = 757,
-
/// A process being terminated has no threads to terminate.
NOTHING_TO_TERMINATE = 758,
-
/// The specified process is not part of a job.
PROCESS_NOT_IN_JOB = 759,
-
/// The specified process is part of a job.
PROCESS_IN_JOB = 760,
-
/// {Volume Shadow Copy Service} The system is now ready for hibernation.
VOLSNAP_HIBERNATE_READY = 761,
-
/// A file system or file system filter driver has successfully completed an FsFilter operation.
FSFILTER_OP_COMPLETED_SUCCESSFULLY = 762,
-
/// The specified interrupt vector was already connected.
INTERRUPT_VECTOR_ALREADY_CONNECTED = 763,
-
/// The specified interrupt vector is still connected.
INTERRUPT_STILL_CONNECTED = 764,
-
/// An operation is blocked waiting for an oplock.
WAIT_FOR_OPLOCK = 765,
-
/// Debugger handled exception.
DBG_EXCEPTION_HANDLED = 766,
-
/// Debugger continued.
DBG_CONTINUE = 767,
-
/// An exception occurred in a user mode callback and the kernel callback frame should be removed.
CALLBACK_POP_STACK = 768,
-
/// Compression is disabled for this volume.
COMPRESSION_DISABLED = 769,
-
/// The data provider cannot fetch backwards through a result set.
CANTFETCHBACKWARDS = 770,
-
/// The data provider cannot scroll backwards through a result set.
CANTSCROLLBACKWARDS = 771,
-
/// The data provider requires that previously fetched data is released before asking for more data.
ROWSNOTRELEASED = 772,
-
/// The data provider was not able to interpret the flags set for a column binding in an accessor.
BAD_ACCESSOR_FLAGS = 773,
-
/// One or more errors occurred while processing the request.
ERRORS_ENCOUNTERED = 774,
-
/// The implementation is not capable of performing the request.
NOT_CAPABLE = 775,
-
/// The client of a component requested an operation which is not valid given the state of the component instance.
REQUEST_OUT_OF_SEQUENCE = 776,
-
/// A version number could not be parsed.
VERSION_PARSE_ERROR = 777,
-
/// The iterator's start position is invalid.
BADSTARTPOSITION = 778,
-
/// The hardware has reported an uncorrectable memory error.
MEMORY_HARDWARE = 779,
-
/// The attempted operation required self healing to be enabled.
DISK_REPAIR_DISABLED = 780,
-
/// The Desktop heap encountered an error while allocating session memory.
/// There is more information in the system event log.
INSUFFICIENT_RESOURCE_FOR_SPECIFIED_SHARED_SECTION_SIZE = 781,
-
/// The system power state is transitioning from %2 to %3.
SYSTEM_POWERSTATE_TRANSITION = 782,
-
/// The system power state is transitioning from %2 to %3 but could enter %4.
SYSTEM_POWERSTATE_COMPLEX_TRANSITION = 783,
-
/// A thread is getting dispatched with MCA EXCEPTION because of MCA.
MCA_EXCEPTION = 784,
-
/// Access to %1 is monitored by policy rule %2.
ACCESS_AUDIT_BY_POLICY = 785,
-
/// Access to %1 has been restricted by your Administrator by policy rule %2.
ACCESS_DISABLED_NO_SAFER_UI_BY_POLICY = 786,
-
/// A valid hibernation file has been invalidated and should be abandoned.
ABANDON_HIBERFILE = 787,
-
/// {Delayed Write Failed} Windows was unable to save all the data for the file %hs; the data has been lost.
/// This error may be caused by network connectivity issues. Please try to save this file elsewhere.
LOST_WRITEBEHIND_DATA_NETWORK_DISCONNECTED = 788,
-
/// {Delayed Write Failed} Windows was unable to save all the data for the file %hs; the data has been lost.
/// This error was returned by the server on which the file exists. Please try to save this file elsewhere.
LOST_WRITEBEHIND_DATA_NETWORK_SERVER_ERROR = 789,
-
/// {Delayed Write Failed} Windows was unable to save all the data for the file %hs; the data has been lost.
/// This error may be caused if the device has been removed or the media is write-protected.
LOST_WRITEBEHIND_DATA_LOCAL_DISK_ERROR = 790,
-
/// The resources required for this device conflict with the MCFG table.
BAD_MCFG_TABLE = 791,
-
/// The volume repair could not be performed while it is online.
/// Please schedule to take the volume offline so that it can be repaired.
DISK_REPAIR_REDIRECTED = 792,
-
/// The volume repair was not successful.
DISK_REPAIR_UNSUCCESSFUL = 793,
-
/// One of the volume corruption logs is full.
/// Further corruptions that may be detected won't be logged.
CORRUPT_LOG_OVERFULL = 794,
-
/// One of the volume corruption logs is internally corrupted and needs to be recreated.
/// The volume may contain undetected corruptions and must be scanned.
CORRUPT_LOG_CORRUPTED = 795,
-
/// One of the volume corruption logs is unavailable for being operated on.
CORRUPT_LOG_UNAVAILABLE = 796,
-
/// One of the volume corruption logs was deleted while still having corruption records in them.
/// The volume contains detected corruptions and must be scanned.
CORRUPT_LOG_DELETED_FULL = 797,
-
/// One of the volume corruption logs was cleared by chkdsk and no longer contains real corruptions.
CORRUPT_LOG_CLEARED = 798,
-
/// Orphaned files exist on the volume but could not be recovered because no more new names could be created in the recovery directory. Files must be moved from the recovery directory.
ORPHAN_NAME_EXHAUSTED = 799,
-
/// The oplock that was associated with this handle is now associated with a different handle.
OPLOCK_SWITCHED_TO_NEW_HANDLE = 800,
-
/// An oplock of the requested level cannot be granted. An oplock of a lower level may be available.
CANNOT_GRANT_REQUESTED_OPLOCK = 801,
-
/// The operation did not complete successfully because it would cause an oplock to be broken.
/// The caller has requested that existing oplocks not be broken.
CANNOT_BREAK_OPLOCK = 802,
-
/// The handle with which this oplock was associated has been closed. The oplock is now broken.
OPLOCK_HANDLE_CLOSED = 803,
-
/// The specified access control entry (ACE) does not contain a condition.
NO_ACE_CONDITION = 804,
-
/// The specified access control entry (ACE) contains an invalid condition.
INVALID_ACE_CONDITION = 805,
-
/// Access to the specified file handle has been revoked.
FILE_HANDLE_REVOKED = 806,
-
/// An image file was mapped at a different address from the one specified in the image file but fixups will still be automatically performed on the image.
IMAGE_AT_DIFFERENT_BASE = 807,
-
/// Access to the extended attribute was denied.
EA_ACCESS_DENIED = 994,
-
/// The I/O operation has been aborted because of either a thread exit or an application request.
OPERATION_ABORTED = 995,
-
/// Overlapped I/O event is not in a signaled state.
IO_INCOMPLETE = 996,
-
/// Overlapped I/O operation is in progress.
IO_PENDING = 997,
-
/// Invalid access to memory location.
NOACCESS = 998,
-
/// Error performing inpage operation.
SWAPERROR = 999,
-
/// Recursion too deep; the stack overflowed.
STACK_OVERFLOW = 1001,
-
/// The window cannot act on the sent message.
INVALID_MESSAGE = 1002,
-
/// Cannot complete this function.
CAN_NOT_COMPLETE = 1003,
-
/// Invalid flags.
INVALID_FLAGS = 1004,
-
/// The volume does not contain a recognized file system.
/// Please make sure that all required file system drivers are loaded and that the volume is not corrupted.
UNRECOGNIZED_VOLUME = 1005,
-
/// The volume for a file has been externally altered so that the opened file is no longer valid.
FILE_INVALID = 1006,
-
/// The requested operation cannot be performed in full-screen mode.
FULLSCREEN_MODE = 1007,
-
/// An attempt was made to reference a token that does not exist.
NO_TOKEN = 1008,
-
/// The configuration registry database is corrupt.
BADDB = 1009,
-
/// The configuration registry key is invalid.
BADKEY = 1010,
-
/// The configuration registry key could not be opened.
CANTOPEN = 1011,
-
/// The configuration registry key could not be read.
CANTREAD = 1012,
-
/// The configuration registry key could not be written.
CANTWRITE = 1013,
-
/// One of the files in the registry database had to be recovered by use of a log or alternate copy. The recovery was successful.
REGISTRY_RECOVERED = 1014,
-
/// The registry is corrupted. The structure of one of the files containing registry data is corrupted, or the system's memory image of the file is corrupted, or the file could not be recovered because the alternate copy or log was absent or corrupted.
REGISTRY_CORRUPT = 1015,
-
/// An I/O operation initiated by the registry failed unrecoverably.
/// The registry could not read in, or write out, or flush, one of the files that contain the system's image of the registry.
REGISTRY_IO_FAILED = 1016,
-
/// The system has attempted to load or restore a file into the registry, but the specified file is not in a registry file format.
NOT_REGISTRY_FILE = 1017,
-
/// Illegal operation attempted on a registry key that has been marked for deletion.
KEY_DELETED = 1018,
-
/// System could not allocate the required space in a registry log.
NO_LOG_SPACE = 1019,
-
/// Cannot create a symbolic link in a registry key that already has subkeys or values.
KEY_HAS_CHILDREN = 1020,
-
/// Cannot create a stable subkey under a volatile parent key.
CHILD_MUST_BE_VOLATILE = 1021,
-
/// A notify change request is being completed and the information is not being returned in the caller's buffer.
/// The caller now needs to enumerate the files to find the changes.
NOTIFY_ENUM_DIR = 1022,
-
/// A stop control has been sent to a service that other running services are dependent on.
DEPENDENT_SERVICES_RUNNING = 1051,
-
/// The requested control is not valid for this service.
INVALID_SERVICE_CONTROL = 1052,
-
/// The service did not respond to the start or control request in a timely fashion.
SERVICE_REQUEST_TIMEOUT = 1053,
-
/// A thread could not be created for the service.
SERVICE_NO_THREAD = 1054,
-
/// The service database is locked.
SERVICE_DATABASE_LOCKED = 1055,
-
/// An instance of the service is already running.
SERVICE_ALREADY_RUNNING = 1056,
-
/// The account name is invalid or does not exist, or the password is invalid for the account name specified.
INVALID_SERVICE_ACCOUNT = 1057,
-
/// The service cannot be started, either because it is disabled or because it has no enabled devices associated with it.
SERVICE_DISABLED = 1058,
-
/// Circular service dependency was specified.
CIRCULAR_DEPENDENCY = 1059,
-
/// The specified service does not exist as an installed service.
SERVICE_DOES_NOT_EXIST = 1060,
-
/// The service cannot accept control messages at this time.
SERVICE_CANNOT_ACCEPT_CTRL = 1061,
-
/// The service has not been started.
SERVICE_NOT_ACTIVE = 1062,
-
/// The service process could not connect to the service controller.
FAILED_SERVICE_CONTROLLER_CONNECT = 1063,
-
/// An exception occurred in the service when handling the control request.
EXCEPTION_IN_SERVICE = 1064,
-
/// The database specified does not exist.
DATABASE_DOES_NOT_EXIST = 1065,
-
/// The service has returned a service-specific error code.
SERVICE_SPECIFIC_ERROR = 1066,
-
/// The process terminated unexpectedly.
PROCESS_ABORTED = 1067,
-
/// The dependency service or group failed to start.
SERVICE_DEPENDENCY_FAIL = 1068,
-
/// The service did not start due to a logon failure.
SERVICE_LOGON_FAILED = 1069,
-
/// After starting, the service hung in a start-pending state.
SERVICE_START_HANG = 1070,
-
/// The specified service database lock is invalid.
INVALID_SERVICE_LOCK = 1071,
-
/// The specified service has been marked for deletion.
SERVICE_MARKED_FOR_DELETE = 1072,
-
/// The specified service already exists.
SERVICE_EXISTS = 1073,
-
/// The system is currently running with the last-known-good configuration.
ALREADY_RUNNING_LKG = 1074,
-
/// The dependency service does not exist or has been marked for deletion.
SERVICE_DEPENDENCY_DELETED = 1075,
-
/// The current boot has already been accepted for use as the last-known-good control set.
BOOT_ALREADY_ACCEPTED = 1076,
-
/// No attempts to start the service have been made since the last boot.
SERVICE_NEVER_STARTED = 1077,
-
/// The name is already in use as either a service name or a service display name.
DUPLICATE_SERVICE_NAME = 1078,
-
/// The account specified for this service is different from the account specified for other services running in the same process.
DIFFERENT_SERVICE_ACCOUNT = 1079,
-
/// Failure actions can only be set for Win32 services, not for drivers.
CANNOT_DETECT_DRIVER_FAILURE = 1080,
-
/// This service runs in the same process as the service control manager.
/// Therefore, the service control manager cannot take action if this service's process terminates unexpectedly.
CANNOT_DETECT_PROCESS_ABORT = 1081,
-
/// No recovery program has been configured for this service.
NO_RECOVERY_PROGRAM = 1082,
-
/// The executable program that this service is configured to run in does not implement the service.
SERVICE_NOT_IN_EXE = 1083,
-
/// This service cannot be started in Safe Mode.
NOT_SAFEBOOT_SERVICE = 1084,
-
/// The physical end of the tape has been reached.
END_OF_MEDIA = 1100,
-
/// A tape access reached a filemark.
FILEMARK_DETECTED = 1101,
-
/// The beginning of the tape or a partition was encountered.
BEGINNING_OF_MEDIA = 1102,
-
/// A tape access reached the end of a set of files.
SETMARK_DETECTED = 1103,
-
/// No more data is on the tape.
NO_DATA_DETECTED = 1104,
-
/// Tape could not be partitioned.
PARTITION_FAILURE = 1105,
-
/// When accessing a new tape of a multivolume partition, the current block size is incorrect.
INVALID_BLOCK_LENGTH = 1106,
-
/// Tape partition information could not be found when loading a tape.
DEVICE_NOT_PARTITIONED = 1107,
-
/// Unable to lock the media eject mechanism.
UNABLE_TO_LOCK_MEDIA = 1108,
-
/// Unable to unload the media.
UNABLE_TO_UNLOAD_MEDIA = 1109,
-
/// The media in the drive may have changed.
MEDIA_CHANGED = 1110,
-
/// The I/O bus was reset.
BUS_RESET = 1111,
-
/// No media in drive.
NO_MEDIA_IN_DRIVE = 1112,
-
/// No mapping for the Unicode character exists in the target multi-byte code page.
NO_UNICODE_TRANSLATION = 1113,
-
/// A dynamic link library (DLL) initialization routine failed.
DLL_INIT_FAILED = 1114,
-
/// A system shutdown is in progress.
SHUTDOWN_IN_PROGRESS = 1115,
-
/// Unable to abort the system shutdown because no shutdown was in progress.
NO_SHUTDOWN_IN_PROGRESS = 1116,
-
/// The request could not be performed because of an I/O device error.
IO_DEVICE = 1117,
-
/// No serial device was successfully initialized. The serial driver will unload.
SERIAL_NO_DEVICE = 1118,
-
/// Unable to open a device that was sharing an interrupt request (IRQ) with other devices.
/// At least one other device that uses that IRQ was already opened.
IRQ_BUSY = 1119,
-
/// A serial I/O operation was completed by another write to the serial port. The IOCTL_SERIAL_XOFF_COUNTER reached zero.)
MORE_WRITES = 1120,
-
/// A serial I/O operation completed because the timeout period expired.
/// The IOCTL_SERIAL_XOFF_COUNTER did not reach zero.)
COUNTER_TIMEOUT = 1121,
-
/// No ID address mark was found on the floppy disk.
FLOPPY_ID_MARK_NOT_FOUND = 1122,
-
/// Mismatch between the floppy disk sector ID field and the floppy disk controller track address.
FLOPPY_WRONG_CYLINDER = 1123,
-
/// The floppy disk controller reported an error that is not recognized by the floppy disk driver.
FLOPPY_UNKNOWN_ERROR = 1124,
-
/// The floppy disk controller returned inconsistent results in its registers.
FLOPPY_BAD_REGISTERS = 1125,
-
/// While accessing the hard disk, a recalibrate operation failed, even after retries.
DISK_RECALIBRATE_FAILED = 1126,
-
/// While accessing the hard disk, a disk operation failed even after retries.
DISK_OPERATION_FAILED = 1127,
-
/// While accessing the hard disk, a disk controller reset was needed, but even that failed.
DISK_RESET_FAILED = 1128,
-
/// Physical end of tape encountered.
EOM_OVERFLOW = 1129,
-
/// Not enough server storage is available to process this command.
NOT_ENOUGH_SERVER_MEMORY = 1130,
-
/// A potential deadlock condition has been detected.
POSSIBLE_DEADLOCK = 1131,
-
/// The base address or the file offset specified does not have the proper alignment.
MAPPED_ALIGNMENT = 1132,
-
/// An attempt to change the system power state was vetoed by another application or driver.
SET_POWER_STATE_VETOED = 1140,
-
/// The system BIOS failed an attempt to change the system power state.
SET_POWER_STATE_FAILED = 1141,
-
/// An attempt was made to create more links on a file than the file system supports.
TOO_MANY_LINKS = 1142,
-
/// The specified program requires a newer version of Windows.
OLD_WIN_VERSION = 1150,
-
/// The specified program is not a Windows or MS-DOS program.
APP_WRONG_OS = 1151,
-
/// Cannot start more than one instance of the specified program.
SINGLE_INSTANCE_APP = 1152,
-
/// The specified program was written for an earlier version of Windows.
RMODE_APP = 1153,
-
/// One of the library files needed to run this application is damaged.
INVALID_DLL = 1154,
-
/// No application is associated with the specified file for this operation.
NO_ASSOCIATION = 1155,
-
/// An error occurred in sending the command to the application.
DDE_FAIL = 1156,
-
/// One of the library files needed to run this application cannot be found.
DLL_NOT_FOUND = 1157,
-
/// The current process has used all of its system allowance of handles for Window Manager objects.
NO_MORE_USER_HANDLES = 1158,
-
/// The message can be used only with synchronous operations.
MESSAGE_SYNC_ONLY = 1159,
-
/// The indicated source element has no media.
SOURCE_ELEMENT_EMPTY = 1160,
-
/// The indicated destination element already contains media.
DESTINATION_ELEMENT_FULL = 1161,
-
/// The indicated element does not exist.
ILLEGAL_ELEMENT_ADDRESS = 1162,
-
/// The indicated element is part of a magazine that is not present.
MAGAZINE_NOT_PRESENT = 1163,
-
/// The indicated device requires reinitialization due to hardware errors.
DEVICE_REINITIALIZATION_NEEDED = 1164,
-
/// The device has indicated that cleaning is required before further operations are attempted.
DEVICE_REQUIRES_CLEANING = 1165,
-
/// The device has indicated that its door is open.
DEVICE_DOOR_OPEN = 1166,
-
/// The device is not connected.
DEVICE_NOT_CONNECTED = 1167,
-
/// Element not found.
NOT_FOUND = 1168,
-
/// There was no match for the specified key in the index.
NO_MATCH = 1169,
-
/// The property set specified does not exist on the object.
SET_NOT_FOUND = 1170,
-
/// The point passed to GetMouseMovePoints is not in the buffer.
POINT_NOT_FOUND = 1171,
-
/// The tracking (workstation) service is not running.
NO_TRACKING_SERVICE = 1172,
-
/// The Volume ID could not be found.
NO_VOLUME_ID = 1173,
-
/// Unable to remove the file to be replaced.
UNABLE_TO_REMOVE_REPLACED = 1175,
-
/// Unable to move the replacement file to the file to be replaced.
/// The file to be replaced has retained its original name.
UNABLE_TO_MOVE_REPLACEMENT = 1176,
-
/// Unable to move the replacement file to the file to be replaced.
/// The file to be replaced has been renamed using the backup name.
UNABLE_TO_MOVE_REPLACEMENT_2 = 1177,
-
/// The volume change journal is being deleted.
JOURNAL_DELETE_IN_PROGRESS = 1178,
-
/// The volume change journal is not active.
JOURNAL_NOT_ACTIVE = 1179,
-
/// A file was found, but it may not be the correct file.
POTENTIAL_FILE_FOUND = 1180,
-
/// The journal entry has been deleted from the journal.
JOURNAL_ENTRY_DELETED = 1181,
-
/// A system shutdown has already been scheduled.
SHUTDOWN_IS_SCHEDULED = 1190,
-
/// The system shutdown cannot be initiated because there are other users logged on to the computer.
SHUTDOWN_USERS_LOGGED_ON = 1191,
-
/// The specified device name is invalid.
BAD_DEVICE = 1200,
-
/// The device is not currently connected but it is a remembered connection.
CONNECTION_UNAVAIL = 1201,
-
/// The local device name has a remembered connection to another network resource.
DEVICE_ALREADY_REMEMBERED = 1202,
-
/// The network path was either typed incorrectly, does not exist, or the network provider is not currently available.
/// Please try retyping the path or contact your network administrator.
NO_NET_OR_BAD_PATH = 1203,
-
/// The specified network provider name is invalid.
BAD_PROVIDER = 1204,
-
/// Unable to open the network connection profile.
CANNOT_OPEN_PROFILE = 1205,
-
/// The network connection profile is corrupted.
BAD_PROFILE = 1206,
-
/// Cannot enumerate a noncontainer.
NOT_CONTAINER = 1207,
-
/// An extended error has occurred.
EXTENDED_ERROR = 1208,
-
/// The format of the specified group name is invalid.
INVALID_GROUPNAME = 1209,
-
/// The format of the specified computer name is invalid.
INVALID_COMPUTERNAME = 1210,
-
/// The format of the specified event name is invalid.
INVALID_EVENTNAME = 1211,
-
/// The format of the specified domain name is invalid.
INVALID_DOMAINNAME = 1212,
-
/// The format of the specified service name is invalid.
INVALID_SERVICENAME = 1213,
-
/// The format of the specified network name is invalid.
INVALID_NETNAME = 1214,
-
/// The format of the specified share name is invalid.
INVALID_SHARENAME = 1215,
-
/// The format of the specified password is invalid.
INVALID_PASSWORDNAME = 1216,
-
/// The format of the specified message name is invalid.
INVALID_MESSAGENAME = 1217,
-
/// The format of the specified message destination is invalid.
INVALID_MESSAGEDEST = 1218,
-
/// Multiple connections to a server or shared resource by the same user, using more than one user name, are not allowed.
/// Disconnect all previous connections to the server or shared resource and try again.
SESSION_CREDENTIAL_CONFLICT = 1219,
-
/// An attempt was made to establish a session to a network server, but there are already too many sessions established to that server.
REMOTE_SESSION_LIMIT_EXCEEDED = 1220,
-
/// The workgroup or domain name is already in use by another computer on the network.
DUP_DOMAINNAME = 1221,
-
/// The network is not present or not started.
NO_NETWORK = 1222,
-
/// The operation was canceled by the user.
CANCELLED = 1223,
-
/// The requested operation cannot be performed on a file with a user-mapped section open.
USER_MAPPED_FILE = 1224,
-
/// The remote computer refused the network connection.
CONNECTION_REFUSED = 1225,
-
/// The network connection was gracefully closed.
GRACEFUL_DISCONNECT = 1226,
-
/// The network transport endpoint already has an address associated with it.
ADDRESS_ALREADY_ASSOCIATED = 1227,
-
/// An address has not yet been associated with the network endpoint.
ADDRESS_NOT_ASSOCIATED = 1228,
-
/// An operation was attempted on a nonexistent network connection.
CONNECTION_INVALID = 1229,
-
/// An invalid operation was attempted on an active network connection.
CONNECTION_ACTIVE = 1230,
-
/// The network location cannot be reached.
/// For information about network troubleshooting, see Windows Help.
NETWORK_UNREACHABLE = 1231,
-
/// The network location cannot be reached.
/// For information about network troubleshooting, see Windows Help.
HOST_UNREACHABLE = 1232,
-
/// The network location cannot be reached.
/// For information about network troubleshooting, see Windows Help.
PROTOCOL_UNREACHABLE = 1233,
-
/// No service is operating at the destination network endpoint on the remote system.
PORT_UNREACHABLE = 1234,
-
/// The request was aborted.
REQUEST_ABORTED = 1235,
-
/// The network connection was aborted by the local system.
CONNECTION_ABORTED = 1236,
-
/// The operation could not be completed. A retry should be performed.
RETRY = 1237,
-
/// A connection to the server could not be made because the limit on the number of concurrent connections for this account has been reached.
CONNECTION_COUNT_LIMIT = 1238,
-
/// Attempting to log in during an unauthorized time of day for this account.
LOGIN_TIME_RESTRICTION = 1239,
-
/// The account is not authorized to log in from this station.
LOGIN_WKSTA_RESTRICTION = 1240,
-
/// The network address could not be used for the operation requested.
INCORRECT_ADDRESS = 1241,
-
/// The service is already registered.
ALREADY_REGISTERED = 1242,
-
/// The specified service does not exist.
SERVICE_NOT_FOUND = 1243,
-
/// The operation being requested was not performed because the user has not been authenticated.
NOT_AUTHENTICATED = 1244,
-
/// The operation being requested was not performed because the user has not logged on to the network. The specified service does not exist.
NOT_LOGGED_ON = 1245,
-
/// Continue with work in progress.
CONTINUE = 1246,
-
/// An attempt was made to perform an initialization operation when initialization has already been completed.
ALREADY_INITIALIZED = 1247,
-
/// No more local devices.
NO_MORE_DEVICES = 1248,
-
/// The specified site does not exist.
NO_SUCH_SITE = 1249,
-
/// A domain controller with the specified name already exists.
DOMAIN_CONTROLLER_EXISTS = 1250,
-
/// This operation is supported only when you are connected to the server.
ONLY_IF_CONNECTED = 1251,
-
/// The group policy framework should call the extension even if there are no changes.
OVERRIDE_NOCHANGES = 1252,
-
/// The specified user does not have a valid profile.
BAD_USER_PROFILE = 1253,
-
/// This operation is not supported on a computer running Windows Server 2003 for Small Business Server.
NOT_SUPPORTED_ON_SBS = 1254,
-
/// The server machine is shutting down.
SERVER_SHUTDOWN_IN_PROGRESS = 1255,
-
/// The remote system is not available.
/// For information about network troubleshooting, see Windows Help.
HOST_DOWN = 1256,
-
/// The security identifier provided is not from an account domain.
NON_ACCOUNT_SID = 1257,
-
/// The security identifier provided does not have a domain component.
NON_DOMAIN_SID = 1258,
-
/// AppHelp dialog canceled thus preventing the application from starting.
APPHELP_BLOCK = 1259,
-
/// This program is blocked by group policy.
/// For more information, contact your system administrator.
ACCESS_DISABLED_BY_POLICY = 1260,
-
/// A program attempt to use an invalid register value.
/// Normally caused by an uninitialized register. This error is Itanium specific.
REG_NAT_CONSUMPTION = 1261,
-
/// The share is currently offline or does not exist.
CSCSHARE_OFFLINE = 1262,
-
/// The Kerberos protocol encountered an error while validating the KDC certificate during smartcard logon.
/// There is more information in the system event log.
PKINIT_FAILURE = 1263,
-
/// The Kerberos protocol encountered an error while attempting to utilize the smartcard subsystem.
SMARTCARD_SUBSYSTEM_FAILURE = 1264,
-
/// The system cannot contact a domain controller to service the authentication request. Please try again later.
DOWNGRADE_DETECTED = 1265,
-
/// The machine is locked and cannot be shut down without the force option.
MACHINE_LOCKED = 1271,
-
/// An application-defined callback gave invalid data when called.
CALLBACK_SUPPLIED_INVALID_DATA = 1273,
-
/// The group policy framework should call the extension in the synchronous foreground policy refresh.
SYNC_FOREGROUND_REFRESH_REQUIRED = 1274,
-
/// This driver has been blocked from loading.
DRIVER_BLOCKED = 1275,
-
/// A dynamic link library (DLL) referenced a module that was neither a DLL nor the process's executable image.
INVALID_IMPORT_OF_NON_DLL = 1276,
-
/// Windows cannot open this program since it has been disabled.
ACCESS_DISABLED_WEBBLADE = 1277,
-
/// Windows cannot open this program because the license enforcement system has been tampered with or become corrupted.
ACCESS_DISABLED_WEBBLADE_TAMPER = 1278,
-
/// A transaction recover failed.
RECOVERY_FAILURE = 1279,
-
/// The current thread has already been converted to a fiber.
ALREADY_FIBER = 1280,
-
/// The current thread has already been converted from a fiber.
ALREADY_THREAD = 1281,
-
/// The system detected an overrun of a stack-based buffer in this application.
/// This overrun could potentially allow a malicious user to gain control of this application.
STACK_BUFFER_OVERRUN = 1282,
-
/// Data present in one of the parameters is more than the function can operate on.
PARAMETER_QUOTA_EXCEEDED = 1283,
-
/// An attempt to do an operation on a debug object failed because the object is in the process of being deleted.
DEBUGGER_INACTIVE = 1284,
-
/// An attempt to delay-load a .dll or get a function address in a delay-loaded .dll failed.
DELAY_LOAD_FAILED = 1285,
-
/// %1 is a 16-bit application. You do not have permissions to execute 16-bit applications.
/// Check your permissions with your system administrator.
VDM_DISALLOWED = 1286,
-
/// Insufficient information exists to identify the cause of failure.
UNIDENTIFIED_ERROR = 1287,
-
/// The parameter passed to a C runtime function is incorrect.
INVALID_CRUNTIME_PARAMETER = 1288,
-
/// The operation occurred beyond the valid data length of the file.
BEYOND_VDL = 1289,
-
/// The service start failed since one or more services in the same process have an incompatible service SID type setting.
/// A service with restricted service SID type can only coexist in the same process with other services with a restricted SID type.
/// If the service SID type for this service was just configured, the hosting process must be restarted in order to start this service.
/// On Windows Server 2003 and Windows XP, an unrestricted service cannot coexist in the same process with other services.
/// The service with the unrestricted service SID type must be moved to an owned process in order to start this service.
INCOMPATIBLE_SERVICE_SID_TYPE = 1290,
-
/// The process hosting the driver for this device has been terminated.
DRIVER_PROCESS_TERMINATED = 1291,
-
/// An operation attempted to exceed an implementation-defined limit.
IMPLEMENTATION_LIMIT = 1292,
-
/// Either the target process, or the target thread's containing process, is a protected process.
PROCESS_IS_PROTECTED = 1293,
-
/// The service notification client is lagging too far behind the current state of services in the machine.
SERVICE_NOTIFY_CLIENT_LAGGING = 1294,
-
/// The requested file operation failed because the storage quota was exceeded.
/// To free up disk space, move files to a different location or delete unnecessary files.
/// For more information, contact your system administrator.
DISK_QUOTA_EXCEEDED = 1295,
-
/// The requested file operation failed because the storage policy blocks that type of file.
/// For more information, contact your system administrator.
CONTENT_BLOCKED = 1296,
-
/// A privilege that the service requires to function properly does not exist in the service account configuration.
/// You may use the Services Microsoft Management Console (MMC) snap-in (services.msc) and the Local Security Settings MMC snap-in (secpol.msc) to view the service configuration and the account configuration.
INCOMPATIBLE_SERVICE_PRIVILEGE = 1297,
-
/// A thread involved in this operation appears to be unresponsive.
APP_HANG = 1298,
-
/// Indicates a particular Security ID may not be assigned as the label of an object.
INVALID_LABEL = 1299,
-
/// Not all privileges or groups referenced are assigned to the caller.
NOT_ALL_ASSIGNED = 1300,
-
/// Some mapping between account names and security IDs was not done.
SOME_NOT_MAPPED = 1301,
-
/// No system quota limits are specifically set for this account.
NO_QUOTAS_FOR_ACCOUNT = 1302,
-
/// No encryption key is available. A well-known encryption key was returned.
LOCAL_USER_SESSION_KEY = 1303,
-
/// The password is too complex to be converted to a LAN Manager password.
/// The LAN Manager password returned is a NULL string.
NULL_LM_PASSWORD = 1304,
-
/// The revision level is unknown.
UNKNOWN_REVISION = 1305,
-
/// Indicates two revision levels are incompatible.
REVISION_MISMATCH = 1306,
-
/// This security ID may not be assigned as the owner of this object.
INVALID_OWNER = 1307,
-
/// This security ID may not be assigned as the primary group of an object.
INVALID_PRIMARY_GROUP = 1308,
-
/// An attempt has been made to operate on an impersonation token by a thread that is not currently impersonating a client.
NO_IMPERSONATION_TOKEN = 1309,
-
/// The group may not be disabled.
CANT_DISABLE_MANDATORY = 1310,
-
/// There are currently no logon servers available to service the logon request.
NO_LOGON_SERVERS = 1311,
-
/// A specified logon session does not exist. It may already have been terminated.
NO_SUCH_LOGON_SESSION = 1312,
-
/// A specified privilege does not exist.
NO_SUCH_PRIVILEGE = 1313,
-
/// A required privilege is not held by the client.
PRIVILEGE_NOT_HELD = 1314,
-
/// The name provided is not a properly formed account name.
INVALID_ACCOUNT_NAME = 1315,
-
/// The specified account already exists.
USER_EXISTS = 1316,
-
/// The specified account does not exist.
NO_SUCH_USER = 1317,
-
/// The specified group already exists.
GROUP_EXISTS = 1318,
-
/// The specified group does not exist.
NO_SUCH_GROUP = 1319,
-
/// Either the specified user account is already a member of the specified group, or the specified group cannot be deleted because it contains a member.
MEMBER_IN_GROUP = 1320,
-
/// The specified user account is not a member of the specified group account.
MEMBER_NOT_IN_GROUP = 1321,
-
/// This operation is disallowed as it could result in an administration account being disabled, deleted or unable to log on.
LAST_ADMIN = 1322,
-
/// Unable to update the password. The value provided as the current password is incorrect.
WRONG_PASSWORD = 1323,
-
/// Unable to update the password. The value provided for the new password contains values that are not allowed in passwords.
ILL_FORMED_PASSWORD = 1324,
-
/// Unable to update the password. The value provided for the new password does not meet the length, complexity, or history requirements of the domain.
PASSWORD_RESTRICTION = 1325,
-
/// The user name or password is incorrect.
LOGON_FAILURE = 1326,
-
/// Account restrictions are preventing this user from signing in.
/// For example: blank passwords aren't allowed, sign-in times are limited, or a policy restriction has been enforced.
ACCOUNT_RESTRICTION = 1327,
-
/// Your account has time restrictions that keep you from signing in right now.
INVALID_LOGON_HOURS = 1328,
-
/// This user isn't allowed to sign in to this computer.
INVALID_WORKSTATION = 1329,
-
/// The password for this account has expired.
PASSWORD_EXPIRED = 1330,
-
/// This user can't sign in because this account is currently disabled.
ACCOUNT_DISABLED = 1331,
-
/// No mapping between account names and security IDs was done.
NONE_MAPPED = 1332,
-
/// Too many local user identifiers (LUIDs) were requested at one time.
TOO_MANY_LUIDS_REQUESTED = 1333,
-
/// No more local user identifiers (LUIDs) are available.
LUIDS_EXHAUSTED = 1334,
-
/// The subauthority part of a security ID is invalid for this particular use.
INVALID_SUB_AUTHORITY = 1335,
-
/// The access control list (ACL) structure is invalid.
INVALID_ACL = 1336,
-
/// The security ID structure is invalid.
INVALID_SID = 1337,
-
/// The security descriptor structure is invalid.
INVALID_SECURITY_DESCR = 1338,
-
/// The inherited access control list (ACL) or access control entry (ACE) could not be built.
BAD_INHERITANCE_ACL = 1340,
-
/// The server is currently disabled.
SERVER_DISABLED = 1341,
-
/// The server is currently enabled.
SERVER_NOT_DISABLED = 1342,
-
/// The value provided was an invalid value for an identifier authority.
INVALID_ID_AUTHORITY = 1343,
-
/// No more memory is available for security information updates.
ALLOTTED_SPACE_EXCEEDED = 1344,
-
/// The specified attributes are invalid, or incompatible with the attributes for the group as a whole.
INVALID_GROUP_ATTRIBUTES = 1345,
-
/// Either a required impersonation level was not provided, or the provided impersonation level is invalid.
BAD_IMPERSONATION_LEVEL = 1346,
-
/// Cannot open an anonymous level security token.
CANT_OPEN_ANONYMOUS = 1347,
-
/// The validation information class requested was invalid.
BAD_VALIDATION_CLASS = 1348,
-
/// The type of the token is inappropriate for its attempted use.
BAD_TOKEN_TYPE = 1349,
-
/// Unable to perform a security operation on an object that has no associated security.
NO_SECURITY_ON_OBJECT = 1350,
-
/// Configuration information could not be read from the domain controller, either because the machine is unavailable, or access has been denied.
CANT_ACCESS_DOMAIN_INFO = 1351,
-
/// The security account manager (SAM) or local security authority (LSA) server was in the wrong state to perform the security operation.
INVALID_SERVER_STATE = 1352,
-
/// The domain was in the wrong state to perform the security operation.
INVALID_DOMAIN_STATE = 1353,
-
/// This operation is only allowed for the Primary Domain Controller of the domain.
INVALID_DOMAIN_ROLE = 1354,
-
/// The specified domain either does not exist or could not be contacted.
NO_SUCH_DOMAIN = 1355,
-
/// The specified domain already exists.
DOMAIN_EXISTS = 1356,
-
/// An attempt was made to exceed the limit on the number of domains per server.
DOMAIN_LIMIT_EXCEEDED = 1357,
-
/// Unable to complete the requested operation because of either a catastrophic media failure or a data structure corruption on the disk.
INTERNAL_DB_CORRUPTION = 1358,
-
/// An internal error occurred.
INTERNAL_ERROR = 1359,
-
/// Generic access types were contained in an access mask which should already be mapped to nongeneric types.
GENERIC_NOT_MAPPED = 1360,
-
/// A security descriptor is not in the right format (absolute or self-relative).
BAD_DESCRIPTOR_FORMAT = 1361,
-
/// The requested action is restricted for use by logon processes only.
/// The calling process has not registered as a logon process.
NOT_LOGON_PROCESS = 1362,
-
/// Cannot start a new logon session with an ID that is already in use.
LOGON_SESSION_EXISTS = 1363,
-
/// A specified authentication package is unknown.
NO_SUCH_PACKAGE = 1364,
-
/// The logon session is not in a state that is consistent with the requested operation.
BAD_LOGON_SESSION_STATE = 1365,
-
/// The logon session ID is already in use.
LOGON_SESSION_COLLISION = 1366,
-
/// A logon request contained an invalid logon type value.
INVALID_LOGON_TYPE = 1367,
-
/// Unable to impersonate using a named pipe until data has been read from that pipe.
CANNOT_IMPERSONATE = 1368,
-
/// The transaction state of a registry subtree is incompatible with the requested operation.
RXACT_INVALID_STATE = 1369,
-
/// An internal security database corruption has been encountered.
RXACT_COMMIT_FAILURE = 1370,
-
/// Cannot perform this operation on built-in accounts.
SPECIAL_ACCOUNT = 1371,
-
/// Cannot perform this operation on this built-in special group.
SPECIAL_GROUP = 1372,
-
/// Cannot perform this operation on this built-in special user.
SPECIAL_USER = 1373,
-
/// The user cannot be removed from a group because the group is currently the user's primary group.
MEMBERS_PRIMARY_GROUP = 1374,
-
/// The token is already in use as a primary token.
TOKEN_ALREADY_IN_USE = 1375,
-
/// The specified local group does not exist.
NO_SUCH_ALIAS = 1376,
-
/// The specified account name is not a member of the group.
MEMBER_NOT_IN_ALIAS = 1377,
-
/// The specified account name is already a member of the group.
MEMBER_IN_ALIAS = 1378,
-
/// The specified local group already exists.
ALIAS_EXISTS = 1379,
-
/// Logon failure: the user has not been granted the requested logon type at this computer.
LOGON_NOT_GRANTED = 1380,
-
/// The maximum number of secrets that may be stored in a single system has been exceeded.
TOO_MANY_SECRETS = 1381,
-
/// The length of a secret exceeds the maximum length allowed.
SECRET_TOO_LONG = 1382,
-
/// The local security authority database contains an internal inconsistency.
INTERNAL_DB_ERROR = 1383,
-
/// During a logon attempt, the user's security context accumulated too many security IDs.
TOO_MANY_CONTEXT_IDS = 1384,
-
/// Logon failure: the user has not been granted the requested logon type at this computer.
LOGON_TYPE_NOT_GRANTED = 1385,
-
/// A cross-encrypted password is necessary to change a user password.
NT_CROSS_ENCRYPTION_REQUIRED = 1386,
-
/// A member could not be added to or removed from the local group because the member does not exist.
NO_SUCH_MEMBER = 1387,
-
/// A new member could not be added to a local group because the member has the wrong account type.
INVALID_MEMBER = 1388,
-
/// Too many security IDs have been specified.
TOO_MANY_SIDS = 1389,
-
/// A cross-encrypted password is necessary to change this user password.
LM_CROSS_ENCRYPTION_REQUIRED = 1390,
-
/// Indicates an ACL contains no inheritable components.
NO_INHERITANCE = 1391,
-
/// The file or directory is corrupted and unreadable.
FILE_CORRUPT = 1392,
-
/// The disk structure is corrupted and unreadable.
DISK_CORRUPT = 1393,
-
/// There is no user session key for the specified logon session.
NO_USER_SESSION_KEY = 1394,
-
/// The service being accessed is licensed for a particular number of connections.
/// No more connections can be made to the service at this time because there are already as many connections as the service can accept.
LICENSE_QUOTA_EXCEEDED = 1395,
-
/// The target account name is incorrect.
WRONG_TARGET_NAME = 1396,
-
/// Mutual Authentication failed. The server's password is out of date at the domain controller.
MUTUAL_AUTH_FAILED = 1397,
-
/// There is a time and/or date difference between the client and server.
TIME_SKEW = 1398,
-
/// This operation cannot be performed on the current domain.
CURRENT_DOMAIN_NOT_ALLOWED = 1399,
-
/// Invalid window handle.
INVALID_WINDOW_HANDLE = 1400,
-
/// Invalid menu handle.
INVALID_MENU_HANDLE = 1401,
-
/// Invalid cursor handle.
INVALID_CURSOR_HANDLE = 1402,
-
/// Invalid accelerator table handle.
INVALID_ACCEL_HANDLE = 1403,
-
/// Invalid hook handle.
INVALID_HOOK_HANDLE = 1404,
-
/// Invalid handle to a multiple-window position structure.
INVALID_DWP_HANDLE = 1405,
-
/// Cannot create a top-level child window.
TLW_WITH_WSCHILD = 1406,
-
/// Cannot find window class.
CANNOT_FIND_WND_CLASS = 1407,
-
/// Invalid window; it belongs to other thread.
WINDOW_OF_OTHER_THREAD = 1408,
-
/// Hot key is already registered.
HOTKEY_ALREADY_REGISTERED = 1409,
-
/// Class already exists.
CLASS_ALREADY_EXISTS = 1410,
-
/// Class does not exist.
CLASS_DOES_NOT_EXIST = 1411,
-
/// Class still has open windows.
CLASS_HAS_WINDOWS = 1412,
-
/// Invalid index.
INVALID_INDEX = 1413,
-
/// Invalid icon handle.
INVALID_ICON_HANDLE = 1414,
-
/// Using private DIALOG window words.
PRIVATE_DIALOG_INDEX = 1415,
-
/// The list box identifier was not found.
LISTBOX_ID_NOT_FOUND = 1416,
-
/// No wildcards were found.
NO_WILDCARD_CHARACTERS = 1417,
-
/// Thread does not have a clipboard open.
CLIPBOARD_NOT_OPEN = 1418,
-
/// Hot key is not registered.
HOTKEY_NOT_REGISTERED = 1419,
-
/// The window is not a valid dialog window.
WINDOW_NOT_DIALOG = 1420,
-
/// Control ID not found.
CONTROL_ID_NOT_FOUND = 1421,
-
/// Invalid message for a combo box because it does not have an edit control.
INVALID_COMBOBOX_MESSAGE = 1422,
-
/// The window is not a combo box.
WINDOW_NOT_COMBOBOX = 1423,
-
/// Height must be less than 256.
INVALID_EDIT_HEIGHT = 1424,
-
/// Invalid device context (DC) handle.
DC_NOT_FOUND = 1425,
-
/// Invalid hook procedure type.
INVALID_HOOK_FILTER = 1426,
-
/// Invalid hook procedure.
INVALID_FILTER_PROC = 1427,
-
/// Cannot set nonlocal hook without a module handle.
HOOK_NEEDS_HMOD = 1428,
-
/// This hook procedure can only be set globally.
GLOBAL_ONLY_HOOK = 1429,
-
/// The journal hook procedure is already installed.
JOURNAL_HOOK_SET = 1430,
-
/// The hook procedure is not installed.
HOOK_NOT_INSTALLED = 1431,
-
/// Invalid message for single-selection list box.
INVALID_LB_MESSAGE = 1432,
-
/// LB_SETCOUNT sent to non-lazy list box.
SETCOUNT_ON_BAD_LB = 1433,
-
/// This list box does not support tab stops.
LB_WITHOUT_TABSTOPS = 1434,
-
/// Cannot destroy object created by another thread.
DESTROY_OBJECT_OF_OTHER_THREAD = 1435,
-
/// Child windows cannot have menus.
CHILD_WINDOW_MENU = 1436,
-
/// The window does not have a system menu.
NO_SYSTEM_MENU = 1437,
-
/// Invalid message box style.
INVALID_MSGBOX_STYLE = 1438,
-
/// Invalid system-wide (SPI_*) parameter.
INVALID_SPI_VALUE = 1439,
-
/// Screen already locked.
SCREEN_ALREADY_LOCKED = 1440,
-
/// All handles to windows in a multiple-window position structure must have the same parent.
HWNDS_HAVE_DIFF_PARENT = 1441,
-
/// The window is not a child window.
NOT_CHILD_WINDOW = 1442,
-
/// Invalid GW_* command.
INVALID_GW_COMMAND = 1443,
-
/// Invalid thread identifier.
INVALID_THREAD_ID = 1444,
-
/// Cannot process a message from a window that is not a multiple document interface (MDI) window.
NON_MDICHILD_WINDOW = 1445,
-
/// Popup menu already active.
POPUP_ALREADY_ACTIVE = 1446,
-
/// The window does not have scroll bars.
NO_SCROLLBARS = 1447,
-
/// Scroll bar range cannot be greater than MAXLONG.
INVALID_SCROLLBAR_RANGE = 1448,
-
/// Cannot show or remove the window in the way specified.
INVALID_SHOWWIN_COMMAND = 1449,
-
/// Insufficient system resources exist to complete the requested service.
NO_SYSTEM_RESOURCES = 1450,
-
/// Insufficient system resources exist to complete the requested service.
NONPAGED_SYSTEM_RESOURCES = 1451,
-
/// Insufficient system resources exist to complete the requested service.
PAGED_SYSTEM_RESOURCES = 1452,
-
/// Insufficient quota to complete the requested service.
WORKING_SET_QUOTA = 1453,
-
/// Insufficient quota to complete the requested service.
PAGEFILE_QUOTA = 1454,
-
/// The paging file is too small for this operation to complete.
COMMITMENT_LIMIT = 1455,
-
/// A menu item was not found.
MENU_ITEM_NOT_FOUND = 1456,
-
/// Invalid keyboard layout handle.
INVALID_KEYBOARD_HANDLE = 1457,
-
/// Hook type not allowed.
HOOK_TYPE_NOT_ALLOWED = 1458,
-
/// This operation requires an interactive window station.
REQUIRES_INTERACTIVE_WINDOWSTATION = 1459,
-
/// This operation returned because the timeout period expired.
TIMEOUT = 1460,
-
/// Invalid monitor handle.
INVALID_MONITOR_HANDLE = 1461,
-
/// Incorrect size argument.
INCORRECT_SIZE = 1462,
-
/// The symbolic link cannot be followed because its type is disabled.
SYMLINK_CLASS_DISABLED = 1463,
-
/// This application does not support the current operation on symbolic links.
SYMLINK_NOT_SUPPORTED = 1464,
-
/// Windows was unable to parse the requested XML data.
XML_PARSE_ERROR = 1465,
-
/// An error was encountered while processing an XML digital signature.
XMLDSIG_ERROR = 1466,
-
/// This application must be restarted.
RESTART_APPLICATION = 1467,
-
/// The caller made the connection request in the wrong routing compartment.
WRONG_COMPARTMENT = 1468,
-
/// There was an AuthIP failure when attempting to connect to the remote host.
AUTHIP_FAILURE = 1469,
-
/// Insufficient NVRAM resources exist to complete the requested service. A reboot might be required.
NO_NVRAM_RESOURCES = 1470,
-
/// Unable to finish the requested operation because the specified process is not a GUI process.
NOT_GUI_PROCESS = 1471,
-
/// The event log file is corrupted.
EVENTLOG_FILE_CORRUPT = 1500,
-
/// No event log file could be opened, so the event logging service did not start.
EVENTLOG_CANT_START = 1501,
-
/// The event log file is full.
LOG_FILE_FULL = 1502,
-
/// The event log file has changed between read operations.
EVENTLOG_FILE_CHANGED = 1503,
-
/// The specified task name is invalid.
INVALID_TASK_NAME = 1550,
-
/// The specified task index is invalid.
INVALID_TASK_INDEX = 1551,
-
/// The specified thread is already joining a task.
THREAD_ALREADY_IN_TASK = 1552,
-
/// The Windows Installer Service could not be accessed.
/// This can occur if the Windows Installer is not correctly installed. Contact your support personnel for assistance.
INSTALL_SERVICE_FAILURE = 1601,
-
/// User cancelled installation.
INSTALL_USEREXIT = 1602,
-
/// Fatal error during installation.
INSTALL_FAILURE = 1603,
-
/// Installation suspended, incomplete.
INSTALL_SUSPEND = 1604,
-
/// This action is only valid for products that are currently installed.
UNKNOWN_PRODUCT = 1605,
-
/// Feature ID not registered.
UNKNOWN_FEATURE = 1606,
-
/// Component ID not registered.
UNKNOWN_COMPONENT = 1607,
-
/// Unknown property.
UNKNOWN_PROPERTY = 1608,
-
/// Handle is in an invalid state.
INVALID_HANDLE_STATE = 1609,
-
/// The configuration data for this product is corrupt. Contact your support personnel.
BAD_CONFIGURATION = 1610,
-
/// Component qualifier not present.
INDEX_ABSENT = 1611,
-
/// The installation source for this product is not available.
/// Verify that the source exists and that you can access it.
INSTALL_SOURCE_ABSENT = 1612,
-
/// This installation package cannot be installed by the Windows Installer service.
/// You must install a Windows service pack that contains a newer version of the Windows Installer service.
INSTALL_PACKAGE_VERSION = 1613,
-
/// Product is uninstalled.
PRODUCT_UNINSTALLED = 1614,
-
/// SQL query syntax invalid or unsupported.
BAD_QUERY_SYNTAX = 1615,
-
/// Record field does not exist.
INVALID_FIELD = 1616,
-
/// The device has been removed.
DEVICE_REMOVED = 1617,
-
/// Another installation is already in progress.
/// Complete that installation before proceeding with this install.
INSTALL_ALREADY_RUNNING = 1618,
-
/// This installation package could not be opened.
/// Verify that the package exists and that you can access it, or contact the application vendor to verify that this is a valid Windows Installer package.
INSTALL_PACKAGE_OPEN_FAILED = 1619,
-
/// This installation package could not be opened.
/// Contact the application vendor to verify that this is a valid Windows Installer package.
INSTALL_PACKAGE_INVALID = 1620,
-
/// There was an error starting the Windows Installer service user interface. Contact your support personnel.
INSTALL_UI_FAILURE = 1621,
-
/// Error opening installation log file.
/// Verify that the specified log file location exists and that you can write to it.
INSTALL_LOG_FAILURE = 1622,
-
/// The language of this installation package is not supported by your system.
INSTALL_LANGUAGE_UNSUPPORTED = 1623,
-
/// Error applying transforms. Verify that the specified transform paths are valid.
INSTALL_TRANSFORM_FAILURE = 1624,
-
/// This installation is forbidden by system policy. Contact your system administrator.
INSTALL_PACKAGE_REJECTED = 1625,
-
/// Function could not be executed.
FUNCTION_NOT_CALLED = 1626,
-
/// Function failed during execution.
FUNCTION_FAILED = 1627,
-
/// Invalid or unknown table specified.
INVALID_TABLE = 1628,
-
/// Data supplied is of wrong type.
DATATYPE_MISMATCH = 1629,
-
/// Data of this type is not supported.
UNSUPPORTED_TYPE = 1630,
-
/// The Windows Installer service failed to start. Contact your support personnel.
CREATE_FAILED = 1631,
-
/// The Temp folder is on a drive that is full or is inaccessible.
/// Free up space on the drive or verify that you have write permission on the Temp folder.
INSTALL_TEMP_UNWRITABLE = 1632,
-
/// This installation package is not supported by this processor type. Contact your product vendor.
INSTALL_PLATFORM_UNSUPPORTED = 1633,
-
/// Component not used on this computer.
INSTALL_NOTUSED = 1634,
-
/// This update package could not be opened.
/// Verify that the update package exists and that you can access it, or contact the application vendor to verify that this is a valid Windows Installer update package.
PATCH_PACKAGE_OPEN_FAILED = 1635,
-
/// This update package could not be opened.
/// Contact the application vendor to verify that this is a valid Windows Installer update package.
PATCH_PACKAGE_INVALID = 1636,
-
/// This update package cannot be processed by the Windows Installer service.
/// You must install a Windows service pack that contains a newer version of the Windows Installer service.
PATCH_PACKAGE_UNSUPPORTED = 1637,
-
/// Another version of this product is already installed. Installation of this version cannot continue.
/// To configure or remove the existing version of this product, use Add/Remove Programs on the Control Panel.
PRODUCT_VERSION = 1638,
-
/// Invalid command line argument. Consult the Windows Installer SDK for detailed command line help.
INVALID_COMMAND_LINE = 1639,
-
/// Only administrators have permission to add, remove, or configure server software during a Terminal services remote session.
/// If you want to install or configure software on the server, contact your network administrator.
INSTALL_REMOTE_DISALLOWED = 1640,
-
/// The requested operation completed successfully.
/// The system will be restarted so the changes can take effect.
SUCCESS_REBOOT_INITIATED = 1641,
-
/// The upgrade cannot be installed by the Windows Installer service because the program to be upgraded may be missing, or the upgrade may update a different version of the program.
/// Verify that the program to be upgraded exists on your computer and that you have the correct upgrade.
PATCH_TARGET_NOT_FOUND = 1642,
-
/// The update package is not permitted by software restriction policy.
PATCH_PACKAGE_REJECTED = 1643,
-
/// One or more customizations are not permitted by software restriction policy.
INSTALL_TRANSFORM_REJECTED = 1644,
-
/// The Windows Installer does not permit installation from a Remote Desktop Connection.
INSTALL_REMOTE_PROHIBITED = 1645,
-
/// Uninstallation of the update package is not supported.
PATCH_REMOVAL_UNSUPPORTED = 1646,
-
/// The update is not applied to this product.
UNKNOWN_PATCH = 1647,
-
/// No valid sequence could be found for the set of updates.
PATCH_NO_SEQUENCE = 1648,
-
/// Update removal was disallowed by policy.
PATCH_REMOVAL_DISALLOWED = 1649,
-
/// The XML update data is invalid.
INVALID_PATCH_XML = 1650,
-
/// Windows Installer does not permit updating of managed advertised products.
/// At least one feature of the product must be installed before applying the update.
PATCH_MANAGED_ADVERTISED_PRODUCT = 1651,
-
/// The Windows Installer service is not accessible in Safe Mode.
/// Please try again when your computer is not in Safe Mode or you can use System Restore to return your machine to a previous good state.
INSTALL_SERVICE_SAFEBOOT = 1652,
-
/// A fail fast exception occurred.
/// Exception handlers will not be invoked and the process will be terminated immediately.
FAIL_FAST_EXCEPTION = 1653,
-
/// The app that you are trying to run is not supported on this version of Windows.
INSTALL_REJECTED = 1654,
-
/// The string binding is invalid.
RPC_S_INVALID_STRING_BINDING = 1700,
-
/// The binding handle is not the correct type.
RPC_S_WRONG_KIND_OF_BINDING = 1701,
-
/// The binding handle is invalid.
RPC_S_INVALID_BINDING = 1702,
-
/// The RPC protocol sequence is not supported.
RPC_S_PROTSEQ_NOT_SUPPORTED = 1703,
-
/// The RPC protocol sequence is invalid.
RPC_S_INVALID_RPC_PROTSEQ = 1704,
-
/// The string universal unique identifier (UUID) is invalid.
RPC_S_INVALID_STRING_UUID = 1705,
-
/// The endpoint format is invalid.
RPC_S_INVALID_ENDPOINT_FORMAT = 1706,
-
/// The network address is invalid.
RPC_S_INVALID_NET_ADDR = 1707,
-
/// No endpoint was found.
RPC_S_NO_ENDPOINT_FOUND = 1708,
-
/// The timeout value is invalid.
RPC_S_INVALID_TIMEOUT = 1709,
-
/// The object universal unique identifier (UUID) was not found.
RPC_S_OBJECT_NOT_FOUND = 1710,
-
/// The object universal unique identifier (UUID) has already been registered.
RPC_S_ALREADY_REGISTERED = 1711,
-
/// The type universal unique identifier (UUID) has already been registered.
RPC_S_TYPE_ALREADY_REGISTERED = 1712,
-
/// The RPC server is already listening.
RPC_S_ALREADY_LISTENING = 1713,
-
/// No protocol sequences have been registered.
RPC_S_NO_PROTSEQS_REGISTERED = 1714,
-
/// The RPC server is not listening.
RPC_S_NOT_LISTENING = 1715,
-
/// The manager type is unknown.
RPC_S_UNKNOWN_MGR_TYPE = 1716,
-
/// The interface is unknown.
RPC_S_UNKNOWN_IF = 1717,
-
/// There are no bindings.
RPC_S_NO_BINDINGS = 1718,
-
/// There are no protocol sequences.
RPC_S_NO_PROTSEQS = 1719,
-
/// The endpoint cannot be created.
RPC_S_CANT_CREATE_ENDPOINT = 1720,
-
/// Not enough resources are available to complete this operation.
RPC_S_OUT_OF_RESOURCES = 1721,
-
/// The RPC server is unavailable.
RPC_S_SERVER_UNAVAILABLE = 1722,
-
/// The RPC server is too busy to complete this operation.
RPC_S_SERVER_TOO_BUSY = 1723,
-
/// The network options are invalid.
RPC_S_INVALID_NETWORK_OPTIONS = 1724,
-
/// There are no remote procedure calls active on this thread.
RPC_S_NO_CALL_ACTIVE = 1725,
-
/// The remote procedure call failed.
RPC_S_CALL_FAILED = 1726,
-
/// The remote procedure call failed and did not execute.
RPC_S_CALL_FAILED_DNE = 1727,
-
/// A remote procedure call (RPC) protocol error occurred.
RPC_S_PROTOCOL_ERROR = 1728,
-
/// Access to the HTTP proxy is denied.
RPC_S_PROXY_ACCESS_DENIED = 1729,
-
/// The transfer syntax is not supported by the RPC server.
RPC_S_UNSUPPORTED_TRANS_SYN = 1730,
-
/// The universal unique identifier (UUID) type is not supported.
RPC_S_UNSUPPORTED_TYPE = 1732,
-
/// The tag is invalid.
RPC_S_INVALID_TAG = 1733,
-
/// The array bounds are invalid.
RPC_S_INVALID_BOUND = 1734,
-
/// The binding does not contain an entry name.
RPC_S_NO_ENTRY_NAME = 1735,
-
/// The name syntax is invalid.
RPC_S_INVALID_NAME_SYNTAX = 1736,
-
/// The name syntax is not supported.
RPC_S_UNSUPPORTED_NAME_SYNTAX = 1737,
-
/// No network address is available to use to construct a universal unique identifier (UUID).
RPC_S_UUID_NO_ADDRESS = 1739,
-
/// The endpoint is a duplicate.
RPC_S_DUPLICATE_ENDPOINT = 1740,
-
/// The authentication type is unknown.
RPC_S_UNKNOWN_AUTHN_TYPE = 1741,
-
/// The maximum number of calls is too small.
RPC_S_MAX_CALLS_TOO_SMALL = 1742,
-
/// The string is too long.
RPC_S_STRING_TOO_LONG = 1743,
-
/// The RPC protocol sequence was not found.
RPC_S_PROTSEQ_NOT_FOUND = 1744,
-
/// The procedure number is out of range.
RPC_S_PROCNUM_OUT_OF_RANGE = 1745,
-
/// The binding does not contain any authentication information.
RPC_S_BINDING_HAS_NO_AUTH = 1746,
-
/// The authentication service is unknown.
RPC_S_UNKNOWN_AUTHN_SERVICE = 1747,
-
/// The authentication level is unknown.
RPC_S_UNKNOWN_AUTHN_LEVEL = 1748,
-
/// The security context is invalid.
RPC_S_INVALID_AUTH_IDENTITY = 1749,
-
/// The authorization service is unknown.
RPC_S_UNKNOWN_AUTHZ_SERVICE = 1750,
-
/// The entry is invalid.
EPT_S_INVALID_ENTRY = 1751,
-
/// The server endpoint cannot perform the operation.
EPT_S_CANT_PERFORM_OP = 1752,
-
/// There are no more endpoints available from the endpoint mapper.
EPT_S_NOT_REGISTERED = 1753,
-
/// No interfaces have been exported.
RPC_S_NOTHING_TO_EXPORT = 1754,
-
/// The entry name is incomplete.
RPC_S_INCOMPLETE_NAME = 1755,
-
/// The version option is invalid.
RPC_S_INVALID_VERS_OPTION = 1756,
-
/// There are no more members.
RPC_S_NO_MORE_MEMBERS = 1757,
-
/// There is nothing to unexport.
RPC_S_NOT_ALL_OBJS_UNEXPORTED = 1758,
-
/// The interface was not found.
RPC_S_INTERFACE_NOT_FOUND = 1759,
-
/// The entry already exists.
RPC_S_ENTRY_ALREADY_EXISTS = 1760,
-
/// The entry is not found.
RPC_S_ENTRY_NOT_FOUND = 1761,
-
/// The name service is unavailable.
RPC_S_NAME_SERVICE_UNAVAILABLE = 1762,
-
/// The network address family is invalid.
RPC_S_INVALID_NAF_ID = 1763,
-
/// The requested operation is not supported.
RPC_S_CANNOT_SUPPORT = 1764,
-
/// No security context is available to allow impersonation.
RPC_S_NO_CONTEXT_AVAILABLE = 1765,
-
/// An internal error occurred in a remote procedure call (RPC).
RPC_S_INTERNAL_ERROR = 1766,
-
/// The RPC server attempted an integer division by zero.
RPC_S_ZERO_DIVIDE = 1767,
-
/// An addressing error occurred in the RPC server.
RPC_S_ADDRESS_ERROR = 1768,
-
/// A floating-point operation at the RPC server caused a division by zero.
RPC_S_FP_DIV_ZERO = 1769,
-
/// A floating-point underflow occurred at the RPC server.
RPC_S_FP_UNDERFLOW = 1770,
-
/// A floating-point overflow occurred at the RPC server.
RPC_S_FP_OVERFLOW = 1771,
-
/// The list of RPC servers available for the binding of auto handles has been exhausted.
RPC_X_NO_MORE_ENTRIES = 1772,
-
/// Unable to open the character translation table file.
RPC_X_SS_CHAR_TRANS_OPEN_FAIL = 1773,
-
/// The file containing the character translation table has fewer than 512 bytes.
RPC_X_SS_CHAR_TRANS_SHORT_FILE = 1774,
-
/// A null context handle was passed from the client to the host during a remote procedure call.
RPC_X_SS_IN_NULL_CONTEXT = 1775,
-
/// The context handle changed during a remote procedure call.
RPC_X_SS_CONTEXT_DAMAGED = 1777,
-
/// The binding handles passed to a remote procedure call do not match.
RPC_X_SS_HANDLES_MISMATCH = 1778,
-
/// The stub is unable to get the remote procedure call handle.
RPC_X_SS_CANNOT_GET_CALL_HANDLE = 1779,
-
/// A null reference pointer was passed to the stub.
RPC_X_NULL_REF_POINTER = 1780,
-
/// The enumeration value is out of range.
RPC_X_ENUM_VALUE_OUT_OF_RANGE = 1781,
-
/// The byte count is too small.
RPC_X_BYTE_COUNT_TOO_SMALL = 1782,
-
/// The stub received bad data.
RPC_X_BAD_STUB_DATA = 1783,
-
/// The supplied user buffer is not valid for the requested operation.
INVALID_USER_BUFFER = 1784,
-
/// The disk media is not recognized. It may not be formatted.
UNRECOGNIZED_MEDIA = 1785,
-
/// The workstation does not have a trust secret.
NO_TRUST_LSA_SECRET = 1786,
-
/// The security database on the server does not have a computer account for this workstation trust relationship.
NO_TRUST_SAM_ACCOUNT = 1787,
-
/// The trust relationship between the primary domain and the trusted domain failed.
TRUSTED_DOMAIN_FAILURE = 1788,
-
/// The trust relationship between this workstation and the primary domain failed.
TRUSTED_RELATIONSHIP_FAILURE = 1789,
-
/// The network logon failed.
TRUST_FAILURE = 1790,
-
/// A remote procedure call is already in progress for this thread.
RPC_S_CALL_IN_PROGRESS = 1791,
-
/// An attempt was made to logon, but the network logon service was not started.
NETLOGON_NOT_STARTED = 1792,
-
/// The user's account has expired.
ACCOUNT_EXPIRED = 1793,
-
/// The redirector is in use and cannot be unloaded.
REDIRECTOR_HAS_OPEN_HANDLES = 1794,
-
/// The specified printer driver is already installed.
PRINTER_DRIVER_ALREADY_INSTALLED = 1795,
-
/// The specified port is unknown.
UNKNOWN_PORT = 1796,
-
/// The printer driver is unknown.
UNKNOWN_PRINTER_DRIVER = 1797,
-
/// The print processor is unknown.
UNKNOWN_PRINTPROCESSOR = 1798,
-
/// The specified separator file is invalid.
INVALID_SEPARATOR_FILE = 1799,
-
/// The specified priority is invalid.
INVALID_PRIORITY = 1800,
-
/// The printer name is invalid.
INVALID_PRINTER_NAME = 1801,
-
/// The printer already exists.
PRINTER_ALREADY_EXISTS = 1802,
-
/// The printer command is invalid.
INVALID_PRINTER_COMMAND = 1803,
-
/// The specified datatype is invalid.
INVALID_DATATYPE = 1804,
-
/// The environment specified is invalid.
INVALID_ENVIRONMENT = 1805,
-
/// There are no more bindings.
RPC_S_NO_MORE_BINDINGS = 1806,
-
/// The account used is an interdomain trust account.
/// Use your global user account or local user account to access this server.
NOLOGON_INTERDOMAIN_TRUST_ACCOUNT = 1807,
-
/// The account used is a computer account.
/// Use your global user account or local user account to access this server.
NOLOGON_WORKSTATION_TRUST_ACCOUNT = 1808,
-
/// The account used is a server trust account.
/// Use your global user account or local user account to access this server.
NOLOGON_SERVER_TRUST_ACCOUNT = 1809,
-
/// The name or security ID (SID) of the domain specified is inconsistent with the trust information for that domain.
DOMAIN_TRUST_INCONSISTENT = 1810,
-
/// The server is in use and cannot be unloaded.
SERVER_HAS_OPEN_HANDLES = 1811,
-
/// The specified image file did not contain a resource section.
RESOURCE_DATA_NOT_FOUND = 1812,
-
/// The specified resource type cannot be found in the image file.
RESOURCE_TYPE_NOT_FOUND = 1813,
-
/// The specified resource name cannot be found in the image file.
RESOURCE_NAME_NOT_FOUND = 1814,
-
/// The specified resource language ID cannot be found in the image file.
RESOURCE_LANG_NOT_FOUND = 1815,
-
/// Not enough quota is available to process this command.
NOT_ENOUGH_QUOTA = 1816,
-
/// No interfaces have been registered.
RPC_S_NO_INTERFACES = 1817,
-
/// The remote procedure call was cancelled.
RPC_S_CALL_CANCELLED = 1818,
-
/// The binding handle does not contain all required information.
RPC_S_BINDING_INCOMPLETE = 1819,
-
/// A communications failure occurred during a remote procedure call.
RPC_S_COMM_FAILURE = 1820,
-
/// The requested authentication level is not supported.
RPC_S_UNSUPPORTED_AUTHN_LEVEL = 1821,
-
/// No principal name registered.
RPC_S_NO_PRINC_NAME = 1822,
-
/// The error specified is not a valid Windows RPC error code.
RPC_S_NOT_RPC_ERROR = 1823,
-
/// A UUID that is valid only on this computer has been allocated.
RPC_S_UUID_LOCAL_ONLY = 1824,
-
/// A security package specific error occurred.
RPC_S_SEC_PKG_ERROR = 1825,
-
/// Thread is not canceled.
RPC_S_NOT_CANCELLED = 1826,
-
/// Invalid operation on the encoding/decoding handle.
RPC_X_INVALID_ES_ACTION = 1827,
-
/// Incompatible version of the serializing package.
RPC_X_WRONG_ES_VERSION = 1828,
-
/// Incompatible version of the RPC stub.
RPC_X_WRONG_STUB_VERSION = 1829,
-
/// The RPC pipe object is invalid or corrupted.
RPC_X_INVALID_PIPE_OBJECT = 1830,
-
/// An invalid operation was attempted on an RPC pipe object.
RPC_X_WRONG_PIPE_ORDER = 1831,
-
/// Unsupported RPC pipe version.
RPC_X_WRONG_PIPE_VERSION = 1832,
-
/// HTTP proxy server rejected the connection because the cookie authentication failed.
RPC_S_COOKIE_AUTH_FAILED = 1833,
-
/// The group member was not found.
RPC_S_GROUP_MEMBER_NOT_FOUND = 1898,
-
/// The endpoint mapper database entry could not be created.
EPT_S_CANT_CREATE = 1899,
-
/// The object universal unique identifier (UUID) is the nil UUID.
RPC_S_INVALID_OBJECT = 1900,
-
/// The specified time is invalid.
INVALID_TIME = 1901,
-
/// The specified form name is invalid.
INVALID_FORM_NAME = 1902,
-
/// The specified form size is invalid.
INVALID_FORM_SIZE = 1903,
-
/// The specified printer handle is already being waited on.
ALREADY_WAITING = 1904,
-
/// The specified printer has been deleted.
PRINTER_DELETED = 1905,
-
/// The state of the printer is invalid.
INVALID_PRINTER_STATE = 1906,
-
/// The user's password must be changed before signing in.
PASSWORD_MUST_CHANGE = 1907,
-
/// Could not find the domain controller for this domain.
DOMAIN_CONTROLLER_NOT_FOUND = 1908,
-
/// The referenced account is currently locked out and may not be logged on to.
ACCOUNT_LOCKED_OUT = 1909,
-
/// The object exporter specified was not found.
OR_INVALID_OXID = 1910,
-
/// The object specified was not found.
OR_INVALID_OID = 1911,
-
/// The object resolver set specified was not found.
OR_INVALID_SET = 1912,
-
/// Some data remains to be sent in the request buffer.
RPC_S_SEND_INCOMPLETE = 1913,
-
/// Invalid asynchronous remote procedure call handle.
RPC_S_INVALID_ASYNC_HANDLE = 1914,
-
/// Invalid asynchronous RPC call handle for this operation.
RPC_S_INVALID_ASYNC_CALL = 1915,
-
/// The RPC pipe object has already been closed.
RPC_X_PIPE_CLOSED = 1916,
-
/// The RPC call completed before all pipes were processed.
RPC_X_PIPE_DISCIPLINE_ERROR = 1917,
-
/// No more data is available from the RPC pipe.
RPC_X_PIPE_EMPTY = 1918,
-
/// No site name is available for this machine.
NO_SITENAME = 1919,
-
/// The file cannot be accessed by the system.
CANT_ACCESS_FILE = 1920,
-
/// The name of the file cannot be resolved by the system.
CANT_RESOLVE_FILENAME = 1921,
-
/// The entry is not of the expected type.
RPC_S_ENTRY_TYPE_MISMATCH = 1922,
-
/// Not all object UUIDs could be exported to the specified entry.
RPC_S_NOT_ALL_OBJS_EXPORTED = 1923,
-
/// Interface could not be exported to the specified entry.
RPC_S_INTERFACE_NOT_EXPORTED = 1924,
-
/// The specified profile entry could not be added.
RPC_S_PROFILE_NOT_ADDED = 1925,
-
/// The specified profile element could not be added.
RPC_S_PRF_ELT_NOT_ADDED = 1926,
-
/// The specified profile element could not be removed.
RPC_S_PRF_ELT_NOT_REMOVED = 1927,
-
/// The group element could not be added.
RPC_S_GRP_ELT_NOT_ADDED = 1928,
-
/// The group element could not be removed.
RPC_S_GRP_ELT_NOT_REMOVED = 1929,
-
/// The printer driver is not compatible with a policy enabled on your computer that blocks NT 4.0 drivers.
KM_DRIVER_BLOCKED = 1930,
-
/// The context has expired and can no longer be used.
CONTEXT_EXPIRED = 1931,
-
/// The current user's delegated trust creation quota has been exceeded.
PER_USER_TRUST_QUOTA_EXCEEDED = 1932,
-
/// The total delegated trust creation quota has been exceeded.
ALL_USER_TRUST_QUOTA_EXCEEDED = 1933,
-
/// The current user's delegated trust deletion quota has been exceeded.
USER_DELETE_TRUST_QUOTA_EXCEEDED = 1934,
-
/// The computer you are signing into is protected by an authentication firewall.
/// The specified account is not allowed to authenticate to the computer.
AUTHENTICATION_FIREWALL_FAILED = 1935,
-
/// Remote connections to the Print Spooler are blocked by a policy set on your machine.
REMOTE_PRINT_CONNECTIONS_BLOCKED = 1936,
-
/// Authentication failed because NTLM authentication has been disabled.
NTLM_BLOCKED = 1937,
-
/// Logon Failure: EAS policy requires that the user change their password before this operation can be performed.
PASSWORD_CHANGE_REQUIRED = 1938,
-
/// The pixel format is invalid.
INVALID_PIXEL_FORMAT = 2000,
-
/// The specified driver is invalid.
BAD_DRIVER = 2001,
-
/// The window style or class attribute is invalid for this operation.
INVALID_WINDOW_STYLE = 2002,
-
/// The requested metafile operation is not supported.
METAFILE_NOT_SUPPORTED = 2003,
-
/// The requested transformation operation is not supported.
TRANSFORM_NOT_SUPPORTED = 2004,
-
/// The requested clipping operation is not supported.
CLIPPING_NOT_SUPPORTED = 2005,
-
/// The specified color management module is invalid.
INVALID_CMM = 2010,
-
/// The specified color profile is invalid.
INVALID_PROFILE = 2011,
-
/// The specified tag was not found.
TAG_NOT_FOUND = 2012,
-
/// A required tag is not present.
TAG_NOT_PRESENT = 2013,
-
/// The specified tag is already present.
DUPLICATE_TAG = 2014,
-
/// The specified color profile is not associated with the specified device.
PROFILE_NOT_ASSOCIATED_WITH_DEVICE = 2015,
-
/// The specified color profile was not found.
PROFILE_NOT_FOUND = 2016,
-
/// The specified color space is invalid.
INVALID_COLORSPACE = 2017,
-
/// Image Color Management is not enabled.
ICM_NOT_ENABLED = 2018,
-
/// There was an error while deleting the color transform.
DELETING_ICM_XFORM = 2019,
-
/// The specified color transform is invalid.
INVALID_TRANSFORM = 2020,
-
/// The specified transform does not match the bitmap's color space.
COLORSPACE_MISMATCH = 2021,
-
/// The specified named color index is not present in the profile.
INVALID_COLORINDEX = 2022,
-
/// The specified profile is intended for a device of a different type than the specified device.
PROFILE_DOES_NOT_MATCH_DEVICE = 2023,
-
/// The network connection was made successfully, but the user had to be prompted for a password other than the one originally specified.
CONNECTED_OTHER_PASSWORD = 2108,
-
/// The network connection was made successfully using default credentials.
CONNECTED_OTHER_PASSWORD_DEFAULT = 2109,
-
/// The specified username is invalid.
BAD_USERNAME = 2202,
-
/// This network connection does not exist.
NOT_CONNECTED = 2250,
-
/// This network connection has files open or requests pending.
OPEN_FILES = 2401,
-
/// Active connections still exist.
ACTIVE_CONNECTIONS = 2402,
-
/// The device is in use by an active process and cannot be disconnected.
DEVICE_IN_USE = 2404,
-
/// The specified print monitor is unknown.
UNKNOWN_PRINT_MONITOR = 3000,
-
/// The specified printer driver is currently in use.
PRINTER_DRIVER_IN_USE = 3001,
-
/// The spool file was not found.
SPOOL_FILE_NOT_FOUND = 3002,
-
/// A StartDocPrinter call was not issued.
SPL_NO_STARTDOC = 3003,
-
/// An AddJob call was not issued.
SPL_NO_ADDJOB = 3004,
-
/// The specified print processor has already been installed.
PRINT_PROCESSOR_ALREADY_INSTALLED = 3005,
-
/// The specified print monitor has already been installed.
PRINT_MONITOR_ALREADY_INSTALLED = 3006,
-
/// The specified print monitor does not have the required functions.
INVALID_PRINT_MONITOR = 3007,
-
/// The specified print monitor is currently in use.
PRINT_MONITOR_IN_USE = 3008,
-
/// The requested operation is not allowed when there are jobs queued to the printer.
PRINTER_HAS_JOBS_QUEUED = 3009,
-
/// The requested operation is successful.
/// Changes will not be effective until the system is rebooted.
SUCCESS_REBOOT_REQUIRED = 3010,
-
/// The requested operation is successful.
/// Changes will not be effective until the service is restarted.
SUCCESS_RESTART_REQUIRED = 3011,
-
/// No printers were found.
PRINTER_NOT_FOUND = 3012,
-
/// The printer driver is known to be unreliable.
PRINTER_DRIVER_WARNED = 3013,
-
/// The printer driver is known to harm the system.
PRINTER_DRIVER_BLOCKED = 3014,
-
/// The specified printer driver package is currently in use.
PRINTER_DRIVER_PACKAGE_IN_USE = 3015,
-
/// Unable to find a core driver package that is required by the printer driver package.
CORE_DRIVER_PACKAGE_NOT_FOUND = 3016,
-
/// The requested operation failed.
/// A system reboot is required to roll back changes made.
FAIL_REBOOT_REQUIRED = 3017,
-
/// The requested operation failed.
/// A system reboot has been initiated to roll back changes made.
FAIL_REBOOT_INITIATED = 3018,
-
/// The specified printer driver was not found on the system and needs to be downloaded.
PRINTER_DRIVER_DOWNLOAD_NEEDED = 3019,
-
/// The requested print job has failed to print.
/// A print system update requires the job to be resubmitted.
PRINT_JOB_RESTART_REQUIRED = 3020,
-
/// The printer driver does not contain a valid manifest, or contains too many manifests.
INVALID_PRINTER_DRIVER_MANIFEST = 3021,
-
/// The specified printer cannot be shared.
PRINTER_NOT_SHAREABLE = 3022,
-
/// The operation was paused.
REQUEST_PAUSED = 3050,
-
/// Reissue the given operation as a cached IO operation.
IO_REISSUE_AS_CACHED = 3950,
-
_,
};
diff --git a/lib/std/os/windows/winmm.zig b/lib/std/os/windows/winmm.zig
index 925905fb46a1..f21d4226e74a 100644
--- a/lib/std/os/windows/winmm.zig
+++ b/lib/std/os/windows/winmm.zig
@@ -1,4 +1,9 @@
-usingnamespace @import("bits.zig");
+const std = @import("../../std.zig");
+const windows = std.os.windows;
+const WINAPI = windows.WINAPI;
+const UINT = windows.UINT;
+const BYTE = windows.BYTE;
+const DWORD = windows.DWORD;
pub const MMRESULT = UINT;
pub const MMSYSERR_BASE = 0;
diff --git a/lib/std/os/windows/ws2_32.zig b/lib/std/os/windows/ws2_32.zig
index be5596691769..247ae20deba4 100644
--- a/lib/std/os/windows/ws2_32.zig
+++ b/lib/std/os/windows/ws2_32.zig
@@ -1,5 +1,23 @@
const std = @import("../../std.zig");
-usingnamespace @import("bits.zig");
+const windows = std.os.windows;
+
+const WINAPI = windows.WINAPI;
+const OVERLAPPED = windows.OVERLAPPED;
+const WORD = windows.WORD;
+const DWORD = windows.DWORD;
+const GUID = windows.GUID;
+const USHORT = windows.USHORT;
+const WCHAR = windows.WCHAR;
+const BOOL = windows.BOOL;
+const HANDLE = windows.HANDLE;
+const timeval = windows.timeval;
+const HWND = windows.HWND;
+const INT = windows.INT;
+const SHORT = windows.SHORT;
+const CHAR = windows.CHAR;
+const ULONG = windows.ULONG;
+const LPARAM = windows.LPARAM;
+const FARPROC = windows.FARPROC;
pub const SOCKET = *opaque {};
pub const INVALID_SOCKET = @intToPtr(SOCKET, ~@as(usize, 0));
@@ -179,7 +197,6 @@ pub const RIO_CORRUPT_CQ = 4294967295;
pub const WINDOWS_AF_IRDA = 26;
pub const WCE_AF_IRDA = 22;
pub const IRDA_PROTO_SOCK_STREAM = 1;
-pub const SOL_IRLMP = 255;
pub const IRLMP_ENUMDEVICES = 16;
pub const IRLMP_IAS_SET = 17;
pub const IRLMP_IAS_QUERY = 18;
@@ -238,7 +255,6 @@ pub const IPX_MAX_ADAPTER_NUM = 16397;
pub const IPX_RERIPNETNUMBER = 16398;
pub const IPX_RECEIVE_BROADCAST = 16399;
pub const IPX_IMMEDIATESPXACK = 16400;
-pub const IPPROTO_RM = 113;
pub const MAX_MCAST_TTL = 255;
pub const RM_OPTIONSBASE = 1000;
pub const RM_RATE_WINDOW_SIZE = 1001;
@@ -450,75 +466,117 @@ pub const TCP_ICMP_ERROR_INFO = 19;
pub const UDP_SEND_MSG_SIZE = 2;
pub const UDP_RECV_MAX_COALESCED_SIZE = 3;
pub const UDP_COALESCED_INFO = 3;
-pub const AF_UNSPEC = 0;
-pub const AF_UNIX = 1;
-pub const AF_INET = 2;
-pub const AF_IMPLINK = 3;
-pub const AF_PUP = 4;
-pub const AF_CHAOS = 5;
-pub const AF_NS = 6;
-pub const AF_ISO = 7;
-pub const AF_ECMA = 8;
-pub const AF_DATAKIT = 9;
-pub const AF_CCITT = 10;
-pub const AF_SNA = 11;
-pub const AF_DECnet = 12;
-pub const AF_DLI = 13;
-pub const AF_LAT = 14;
-pub const AF_HYLINK = 15;
-pub const AF_APPLETALK = 16;
-pub const AF_NETBIOS = 17;
-pub const AF_VOICEVIEW = 18;
-pub const AF_FIREFOX = 19;
-pub const AF_UNKNOWN1 = 20;
-pub const AF_BAN = 21;
-pub const AF_ATM = 22;
-pub const AF_INET6 = 23;
-pub const AF_CLUSTER = 24;
-pub const AF_12844 = 25;
-pub const AF_IRDA = 26;
-pub const AF_NETDES = 28;
-pub const AF_MAX = 29;
-pub const AF_TCNPROCESS = 29;
-pub const AF_TCNMESSAGE = 30;
-pub const AF_ICLFXBM = 31;
-pub const AF_LINK = 33;
-pub const AF_HYPERV = 34;
-pub const SOCK_STREAM = 1;
-pub const SOCK_DGRAM = 2;
-pub const SOCK_RAW = 3;
-pub const SOCK_RDM = 4;
-pub const SOCK_SEQPACKET = 5;
-pub const SOL_SOCKET = 65535;
-pub const SO_DEBUG = 1;
-pub const SO_ACCEPTCONN = 2;
-pub const SO_REUSEADDR = 4;
-pub const SO_KEEPALIVE = 8;
-pub const SO_DONTROUTE = 16;
-pub const SO_BROADCAST = 32;
-pub const SO_USELOOPBACK = 64;
-pub const SO_LINGER = 128;
-pub const SO_OOBINLINE = 256;
-pub const SO_SNDBUF = 4097;
-pub const SO_RCVBUF = 4098;
-pub const SO_SNDLOWAT = 4099;
-pub const SO_RCVLOWAT = 4100;
-pub const SO_SNDTIMEO = 4101;
-pub const SO_RCVTIMEO = 4102;
-pub const SO_ERROR = 4103;
-pub const SO_TYPE = 4104;
-pub const SO_BSP_STATE = 4105;
-pub const SO_GROUP_ID = 8193;
-pub const SO_GROUP_PRIORITY = 8194;
-pub const SO_MAX_MSG_SIZE = 8195;
-pub const SO_CONDITIONAL_ACCEPT = 12290;
-pub const SO_PAUSE_ACCEPT = 12291;
-pub const SO_COMPARTMENT_ID = 12292;
-pub const SO_RANDOMIZE_PORT = 12293;
-pub const SO_PORT_SCALABILITY = 12294;
-pub const SO_REUSE_UNICASTPORT = 12295;
-pub const SO_REUSE_MULTICASTPORT = 12296;
-pub const SO_ORIGINAL_DST = 12303;
+
+pub const AF = struct {
+ pub const UNSPEC = 0;
+ pub const UNIX = 1;
+ pub const INET = 2;
+ pub const IMPLINK = 3;
+ pub const PUP = 4;
+ pub const CHAOS = 5;
+ pub const NS = 6;
+ pub const IPX = 6;
+ pub const ISO = 7;
+ pub const ECMA = 8;
+ pub const DATAKIT = 9;
+ pub const CCITT = 10;
+ pub const SNA = 11;
+ pub const DECnet = 12;
+ pub const DLI = 13;
+ pub const LAT = 14;
+ pub const HYLINK = 15;
+ pub const APPLETALK = 16;
+ pub const NETBIOS = 17;
+ pub const VOICEVIEW = 18;
+ pub const FIREFOX = 19;
+ pub const UNKNOWN1 = 20;
+ pub const BAN = 21;
+ pub const ATM = 22;
+ pub const INET6 = 23;
+ pub const CLUSTER = 24;
+ pub const @"12844" = 25;
+ pub const IRDA = 26;
+ pub const NETDES = 28;
+ pub const MAX = 29;
+ pub const TCNPROCESS = 29;
+ pub const TCNMESSAGE = 30;
+ pub const ICLFXBM = 31;
+ pub const LINK = 33;
+ pub const HYPERV = 34;
+};
+
+pub const SOCK = struct {
+ pub const STREAM = 1;
+ pub const DGRAM = 2;
+ pub const RAW = 3;
+ pub const RDM = 4;
+ pub const SEQPACKET = 5;
+
+ /// WARNING: this flag is not supported by windows socket functions directly,
+ /// it is only supported by std.os.socket. Be sure that this value does
+ /// not share any bits with any of the `SOCK` values.
+ pub const CLOEXEC = 0x10000;
+ /// WARNING: this flag is not supported by windows socket functions directly,
+ /// it is only supported by std.os.socket. Be sure that this value does
+ /// not share any bits with any of the `SOCK` values.
+ pub const NONBLOCK = 0x20000;
+};
+
+pub const SOL = struct {
+ pub const IRLMP = 255;
+ pub const SOCKET = 65535;
+};
+
+pub const SO = struct {
+ pub const DEBUG = 1;
+ pub const ACCEPTCONN = 2;
+ pub const REUSEADDR = 4;
+ pub const KEEPALIVE = 8;
+ pub const DONTROUTE = 16;
+ pub const BROADCAST = 32;
+ pub const USELOOPBACK = 64;
+ pub const LINGER = 128;
+ pub const OOBINLINE = 256;
+ pub const SNDBUF = 4097;
+ pub const RCVBUF = 4098;
+ pub const SNDLOWAT = 4099;
+ pub const RCVLOWAT = 4100;
+ pub const SNDTIMEO = 4101;
+ pub const RCVTIMEO = 4102;
+ pub const ERROR = 4103;
+ pub const TYPE = 4104;
+ pub const BSP_STATE = 4105;
+ pub const GROUP_ID = 8193;
+ pub const GROUP_PRIORITY = 8194;
+ pub const MAX_MSG_SIZE = 8195;
+ pub const CONDITIONAL_ACCEPT = 12290;
+ pub const PAUSE_ACCEPT = 12291;
+ pub const COMPARTMENT_ID = 12292;
+ pub const RANDOMIZE_PORT = 12293;
+ pub const PORT_SCALABILITY = 12294;
+ pub const REUSE_UNICASTPORT = 12295;
+ pub const REUSE_MULTICASTPORT = 12296;
+ pub const ORIGINAL_DST = 12303;
+ pub const PROTOCOL_INFOA = 8196;
+ pub const PROTOCOL_INFOW = 8197;
+ pub const CONNDATA = 28672;
+ pub const CONNOPT = 28673;
+ pub const DISCDATA = 28674;
+ pub const DISCOPT = 28675;
+ pub const CONNDATALEN = 28676;
+ pub const CONNOPTLEN = 28677;
+ pub const DISCDATALEN = 28678;
+ pub const DISCOPTLEN = 28679;
+ pub const OPENTYPE = 28680;
+ pub const SYNCHRONOUS_ALERT = 16;
+ pub const SYNCHRONOUS_NONALERT = 32;
+ pub const MAXDG = 28681;
+ pub const MAXPATHDG = 28682;
+ pub const UPDATE_ACCEPT_CONTEXT = 28683;
+ pub const CONNECT_TIME = 28684;
+ pub const UPDATE_CONNECT_CONTEXT = 28688;
+};
+
pub const WSK_SO_BASE = 16384;
pub const TCP_NODELAY = 1;
pub const IOC_UNIX = 0;
@@ -530,7 +588,6 @@ pub const SIO_BSP_HANDLE = IOC_OUT | IOC_WS2 | 27;
pub const SIO_BSP_HANDLE_SELECT = IOC_OUT | IOC_WS2 | 28;
pub const SIO_BSP_HANDLE_POLL = IOC_OUT | IOC_WS2 | 29;
pub const SIO_BASE_HANDLE = IOC_OUT | IOC_WS2 | 34;
-pub const IPPROTO_IP = 0;
pub const IPPORT_TCPMUX = 1;
pub const IPPORT_ECHO = 7;
pub const IPPORT_DISCARD = 9;
@@ -597,27 +654,41 @@ pub const IOCPARM_MASK = 127;
pub const IOC_VOID = 536870912;
pub const IOC_OUT = 1073741824;
pub const IOC_IN = 2147483648;
-pub const MSG_TRUNC = 256;
-pub const MSG_CTRUNC = 512;
-pub const MSG_BCAST = 1024;
-pub const MSG_MCAST = 2048;
-pub const MSG_ERRQUEUE = 4096;
-pub const AI_PASSIVE = 1;
-pub const AI_CANONNAME = 2;
-pub const AI_NUMERICHOST = 4;
-pub const AI_NUMERICSERV = 8;
-pub const AI_DNS_ONLY = 16;
-pub const AI_ALL = 256;
-pub const AI_ADDRCONFIG = 1024;
-pub const AI_V4MAPPED = 2048;
-pub const AI_NON_AUTHORITATIVE = 16384;
-pub const AI_SECURE = 32768;
-pub const AI_RETURN_PREFERRED_NAMES = 65536;
-pub const AI_FQDN = 131072;
-pub const AI_FILESERVER = 262144;
-pub const AI_DISABLE_IDN_ENCODING = 524288;
-pub const AI_EXTENDED = 2147483648;
-pub const AI_RESOLUTION_HANDLE = 1073741824;
+
+pub const MSG = struct {
+ pub const TRUNC = 256;
+ pub const CTRUNC = 512;
+ pub const BCAST = 1024;
+ pub const MCAST = 2048;
+ pub const ERRQUEUE = 4096;
+
+ pub const PEEK = 2;
+ pub const WAITALL = 8;
+ pub const PUSH_IMMEDIATE = 32;
+ pub const PARTIAL = 32768;
+ pub const INTERRUPT = 16;
+ pub const MAXIOVLEN = 16;
+};
+
+pub const AI = struct {
+ pub const PASSIVE = 1;
+ pub const CANONNAME = 2;
+ pub const NUMERICHOST = 4;
+ pub const NUMERICSERV = 8;
+ pub const DNS_ONLY = 16;
+ pub const ALL = 256;
+ pub const ADDRCONFIG = 1024;
+ pub const V4MAPPED = 2048;
+ pub const NON_AUTHORITATIVE = 16384;
+ pub const SECURE = 32768;
+ pub const RETURN_PREFERRED_NAMES = 65536;
+ pub const FQDN = 131072;
+ pub const FILESERVER = 262144;
+ pub const DISABLE_IDN_ENCODING = 524288;
+ pub const EXTENDED = 2147483648;
+ pub const RESOLUTION_HANDLE = 1073741824;
+};
+
pub const FIONBIO = -2147195266;
pub const ADDRINFOEX_VERSION_2 = 2;
pub const ADDRINFOEX_VERSION_3 = 3;
@@ -661,16 +732,8 @@ pub const WSADESCRIPTION_LEN = 256;
pub const WSASYS_STATUS_LEN = 128;
pub const SOCKET_ERROR = -1;
pub const FROM_PROTOCOL_INFO = -1;
-pub const SO_PROTOCOL_INFOA = 8196;
-pub const SO_PROTOCOL_INFOW = 8197;
pub const PVD_CONFIG = 12289;
pub const SOMAXCONN = 2147483647;
-pub const MSG_PEEK = 2;
-pub const MSG_WAITALL = 8;
-pub const MSG_PUSH_IMMEDIATE = 32;
-pub const MSG_PARTIAL = 32768;
-pub const MSG_INTERRUPT = 16;
-pub const MSG_MAXIOVLEN = 16;
pub const MAXGETHOSTSTRUCT = 1024;
pub const FD_READ_BIT = 0;
pub const FD_WRITE_BIT = 1;
@@ -771,30 +834,18 @@ pub const RESULT_IS_ALIAS = 1;
pub const RESULT_IS_ADDED = 16;
pub const RESULT_IS_CHANGED = 32;
pub const RESULT_IS_DELETED = 64;
-pub const POLLRDNORM = 256;
-pub const POLLRDBAND = 512;
-pub const POLLPRI = 1024;
-pub const POLLWRNORM = 16;
-pub const POLLWRBAND = 32;
-pub const POLLERR = 1;
-pub const POLLHUP = 2;
-pub const POLLNVAL = 4;
-pub const SO_CONNDATA = 28672;
-pub const SO_CONNOPT = 28673;
-pub const SO_DISCDATA = 28674;
-pub const SO_DISCOPT = 28675;
-pub const SO_CONNDATALEN = 28676;
-pub const SO_CONNOPTLEN = 28677;
-pub const SO_DISCDATALEN = 28678;
-pub const SO_DISCOPTLEN = 28679;
-pub const SO_OPENTYPE = 28680;
-pub const SO_SYNCHRONOUS_ALERT = 16;
-pub const SO_SYNCHRONOUS_NONALERT = 32;
-pub const SO_MAXDG = 28681;
-pub const SO_MAXPATHDG = 28682;
-pub const SO_UPDATE_ACCEPT_CONTEXT = 28683;
-pub const SO_CONNECT_TIME = 28684;
-pub const SO_UPDATE_CONNECT_CONTEXT = 28688;
+
+pub const POLL = struct {
+ pub const RDNORM = 256;
+ pub const RDBAND = 512;
+ pub const PRI = 1024;
+ pub const WRNORM = 16;
+ pub const WRBAND = 32;
+ pub const ERR = 1;
+ pub const HUP = 2;
+ pub const NVAL = 4;
+};
+
pub const TCP_BSDURGENT = 28672;
pub const TF_DISCONNECT = 1;
pub const TF_REUSE_SOCKET = 2;
@@ -818,20 +869,25 @@ pub const LSP_INBOUND_MODIFY = 16;
pub const LSP_OUTBOUND_MODIFY = 32;
pub const LSP_CRYPTO_COMPRESS = 64;
pub const LSP_LOCAL_CACHE = 128;
-pub const IPPROTO_ICMP = 1;
-pub const IPPROTO_IGMP = 2;
-pub const IPPROTO_GGP = 3;
-pub const IPPROTO_TCP = 6;
-pub const IPPROTO_PUP = 12;
-pub const IPPROTO_UDP = 17;
-pub const IPPROTO_IDP = 22;
-pub const IPPROTO_ND = 77;
-pub const IPPROTO_RAW = 255;
-pub const IPPROTO_MAX = 256;
+
+pub const IPPROTO = struct {
+ pub const IP = 0;
+ pub const ICMP = 1;
+ pub const IGMP = 2;
+ pub const GGP = 3;
+ pub const TCP = 6;
+ pub const PUP = 12;
+ pub const UDP = 17;
+ pub const IDP = 22;
+ pub const ND = 77;
+ pub const RM = 113;
+ pub const RAW = 255;
+ pub const MAX = 256;
+};
+
pub const IP_DEFAULT_MULTICAST_TTL = 1;
pub const IP_DEFAULT_MULTICAST_LOOP = 1;
pub const IP_MAX_MEMBERSHIPS = 20;
-pub const AF_IPX = 6;
pub const FD_READ = 1;
pub const FD_WRITE = 2;
pub const FD_OOB = 4;
@@ -1052,31 +1108,31 @@ pub const addrinfoexA = extern struct {
pub const sockaddr = extern struct {
family: ADDRESS_FAMILY,
data: [14]u8,
-};
-pub const sockaddr_storage = std.x.os.Socket.Address.Native.Storage;
+ pub const storage = std.x.os.Socket.Address.Native.Storage;
-/// IPv4 socket address
-pub const sockaddr_in = extern struct {
- family: ADDRESS_FAMILY = AF_INET,
- port: USHORT,
- addr: u32,
- zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },
-};
+ /// IPv4 socket address
+ pub const in = extern struct {
+ family: ADDRESS_FAMILY = AF.INET,
+ port: USHORT,
+ addr: u32,
+ zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },
+ };
-/// IPv6 socket address
-pub const sockaddr_in6 = extern struct {
- family: ADDRESS_FAMILY = AF_INET6,
- port: USHORT,
- flowinfo: u32,
- addr: [16]u8,
- scope_id: u32,
-};
+ /// IPv6 socket address
+ pub const in6 = extern struct {
+ family: ADDRESS_FAMILY = AF.INET6,
+ port: USHORT,
+ flowinfo: u32,
+ addr: [16]u8,
+ scope_id: u32,
+ };
-/// UNIX domain socket address
-pub const sockaddr_un = extern struct {
- family: ADDRESS_FAMILY = AF_UNIX,
- path: [108]u8,
+ /// UNIX domain socket address
+ pub const un = extern struct {
+ family: ADDRESS_FAMILY = AF.UNIX,
+ path: [108]u8,
+ };
};
pub const WSABUF = extern struct {
@@ -1238,9 +1294,9 @@ pub const WinsockError = enum(u16) {
/// Permission denied.
/// An attempt was made to access a socket in a way forbidden by its access permissions.
- /// An example is using a broadcast address for sendto without broadcast permission being set using setsockopt(SO_BROADCAST).
+ /// An example is using a broadcast address for sendto without broadcast permission being set using setsockopt(SO.BROADCAST).
/// Another possible reason for the WSAEACCES error is that when the bind function is called (on Windows NT 4.0 with SP4 and later), another application, service, or kernel mode driver is bound to the same address with exclusive access.
- /// Such exclusive access is a new feature of Windows NT 4.0 with SP4 and later, and is implemented by using the SO_EXCLUSIVEADDRUSE option.
+ /// Such exclusive access is a new feature of Windows NT 4.0 with SP4 and later, and is implemented by using the SO.EXCLUSIVEADDRUSE option.
WSAEACCES = 10013,
/// Bad address.
@@ -1261,7 +1317,7 @@ pub const WinsockError = enum(u16) {
/// Resource temporarily unavailable.
/// This error is returned from operations on nonblocking sockets that cannot be completed immediately, for example recv when no data is queued to be read from the socket.
/// It is a nonfatal error, and the operation should be retried later.
- /// It is normal for WSAEWOULDBLOCK to be reported as the result from calling connect on a nonblocking SOCK_STREAM socket, since some time must elapse for the connection to be established.
+ /// It is normal for WSAEWOULDBLOCK to be reported as the result from calling connect on a nonblocking SOCK.STREAM socket, since some time must elapse for the connection to be established.
WSAEWOULDBLOCK = 10035,
/// Operation now in progress.
@@ -1289,7 +1345,7 @@ pub const WinsockError = enum(u16) {
/// Protocol wrong type for socket.
/// A protocol was specified in the socket function call that does not support the semantics of the socket type requested.
- /// For example, the ARPA Internet UDP protocol cannot be specified with a socket type of SOCK_STREAM.
+ /// For example, the ARPA Internet UDP protocol cannot be specified with a socket type of SOCK.STREAM.
WSAEPROTOTYPE = 10041,
/// Bad protocol option.
@@ -1298,12 +1354,12 @@ pub const WinsockError = enum(u16) {
/// Protocol not supported.
/// The requested protocol has not been configured into the system, or no implementation for it exists.
- /// For example, a socket call requests a SOCK_DGRAM socket, but specifies a stream protocol.
+ /// For example, a socket call requests a SOCK.DGRAM socket, but specifies a stream protocol.
WSAEPROTONOSUPPORT = 10043,
/// Socket type not supported.
/// The support for the specified socket type does not exist in this address family.
- /// For example, the optional type SOCK_RAW might be selected in a socket call, and the implementation does not support SOCK_RAW sockets at all.
+ /// For example, the optional type SOCK.RAW might be selected in a socket call, and the implementation does not support SOCK.RAW sockets at all.
WSAESOCKTNOSUPPORT = 10044,
/// Operation not supported.
@@ -1319,14 +1375,14 @@ pub const WinsockError = enum(u16) {
/// Address family not supported by protocol family.
/// An address incompatible with the requested protocol was used.
- /// All sockets are created with an associated address family (that is, AF_INET for Internet Protocols) and a generic protocol type (that is, SOCK_STREAM).
+ /// All sockets are created with an associated address family (that is, AF.INET for Internet Protocols) and a generic protocol type (that is, SOCK.STREAM).
/// This error is returned if an incorrect protocol is explicitly requested in the socket call, or if an address of the wrong family is used for a socket, for example, in sendto.
WSAEAFNOSUPPORT = 10047,
/// Address already in use.
/// Typically, only one usage of each socket address (protocol/IP address/port) is permitted.
/// This error occurs if an application attempts to bind a socket to an IP address/port that has already been used for an existing socket, or a socket that was not closed properly, or one that is still in the process of closing.
- /// For server applications that need to bind multiple sockets to the same port number, consider using setsockopt (SO_REUSEADDR).
+ /// For server applications that need to bind multiple sockets to the same port number, consider using setsockopt (SO.REUSEADDR).
/// Client applications usually need not call bind at all—connect chooses an unused port automatically.
/// When bind is called with a wildcard address (involving ADDR_ANY), a WSAEADDRINUSE error could be delayed until the specific address is committed.
/// This could happen with a call to another function later, including connect, listen, WSAConnect, or WSAJoinLeaf.
@@ -1350,7 +1406,7 @@ pub const WinsockError = enum(u16) {
/// Network dropped connection on reset.
/// The connection has been broken due to keep-alive activity detecting a failure while the operation was in progress.
- /// It can also be returned by setsockopt if an attempt is made to set SO_KEEPALIVE on a connection that has already failed.
+ /// It can also be returned by setsockopt if an attempt is made to set SO.KEEPALIVE on a connection that has already failed.
WSAENETRESET = 10052,
/// Software caused connection abort.
@@ -1359,7 +1415,7 @@ pub const WinsockError = enum(u16) {
/// Connection reset by peer.
/// An existing connection was forcibly closed by the remote host.
- /// This normally results if the peer application on the remote host is suddenly stopped, the host is rebooted, the host or remote network interface is disabled, or the remote host uses a hard close (see setsockopt for more information on the SO_LINGER option on the remote socket).
+ /// This normally results if the peer application on the remote host is suddenly stopped, the host is rebooted, the host or remote network interface is disabled, or the remote host uses a hard close (see setsockopt for more information on the SO.LINGER option on the remote socket).
/// This error may also result if a connection was broken due to keep-alive activity detecting a failure while one or more operations are in progress.
/// Operations that were in progress fail with WSAENETRESET. Subsequent operations fail with WSAECONNRESET.
WSAECONNRESET = 10054,
@@ -1370,12 +1426,12 @@ pub const WinsockError = enum(u16) {
/// Socket is already connected.
/// A connect request was made on an already-connected socket.
- /// Some implementations also return this error if sendto is called on a connected SOCK_DGRAM socket (for SOCK_STREAM sockets, the to parameter in sendto is ignored) although other implementations treat this as a legal occurrence.
+ /// Some implementations also return this error if sendto is called on a connected SOCK.DGRAM socket (for SOCK.STREAM sockets, the to parameter in sendto is ignored) although other implementations treat this as a legal occurrence.
WSAEISCONN = 10056,
/// Socket is not connected.
/// A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using sendto) no address was supplied.
- /// Any other type of operation might also return this error—for example, setsockopt setting SO_KEEPALIVE if the connection has been reset.
+ /// Any other type of operation might also return this error—for example, setsockopt setting SO.KEEPALIVE if the connection has been reset.
WSAENOTCONN = 10057,
/// Cannot send after socket shutdown.
diff --git a/lib/std/special/compiler_rt/addXf3.zig b/lib/std/special/compiler_rt/addXf3.zig
index 59e9393ad6c7..4c741103108c 100644
--- a/lib/std/special/compiler_rt/addXf3.zig
+++ b/lib/std/special/compiler_rt/addXf3.zig
@@ -225,6 +225,6 @@ fn addXf3(comptime T: type, a: T, b: T) T {
return @bitCast(T, result);
}
-test "import addXf3" {
+test {
_ = @import("addXf3_test.zig");
}
diff --git a/lib/std/special/compiler_rt/divdf3.zig b/lib/std/special/compiler_rt/divdf3.zig
index b39e428d9688..ebb139f32406 100644
--- a/lib/std/special/compiler_rt/divdf3.zig
+++ b/lib/std/special/compiler_rt/divdf3.zig
@@ -327,6 +327,6 @@ pub fn __aeabi_ddiv(a: f64, b: f64) callconv(.AAPCS) f64 {
return @call(.{ .modifier = .always_inline }, __divdf3, .{ a, b });
}
-test "import divdf3" {
+test {
_ = @import("divdf3_test.zig");
}
diff --git a/lib/std/special/compiler_rt/divsf3.zig b/lib/std/special/compiler_rt/divsf3.zig
index b44f19506d35..af4cfaaa868e 100644
--- a/lib/std/special/compiler_rt/divsf3.zig
+++ b/lib/std/special/compiler_rt/divsf3.zig
@@ -200,6 +200,6 @@ pub fn __aeabi_fdiv(a: f32, b: f32) callconv(.AAPCS) f32 {
return @call(.{ .modifier = .always_inline }, __divsf3, .{ a, b });
}
-test "import divsf3" {
+test {
_ = @import("divsf3_test.zig");
}
diff --git a/lib/std/special/compiler_rt/divtf3.zig b/lib/std/special/compiler_rt/divtf3.zig
index ea71c7502f91..4dce86087dcf 100644
--- a/lib/std/special/compiler_rt/divtf3.zig
+++ b/lib/std/special/compiler_rt/divtf3.zig
@@ -221,6 +221,6 @@ pub fn __divtf3(a: f128, b: f128) callconv(.C) f128 {
}
}
-test "import divtf3" {
+test {
_ = @import("divtf3_test.zig");
}
diff --git a/lib/std/special/compiler_rt/divti3.zig b/lib/std/special/compiler_rt/divti3.zig
index 1fb7947e6f61..41286c34141d 100644
--- a/lib/std/special/compiler_rt/divti3.zig
+++ b/lib/std/special/compiler_rt/divti3.zig
@@ -23,6 +23,6 @@ pub fn __divti3_windows_x86_64(a: v128, b: v128) callconv(.C) v128 {
}));
}
-test "import divti3" {
+test {
_ = @import("divti3_test.zig");
}
diff --git a/lib/std/special/compiler_rt/extendXfYf2.zig b/lib/std/special/compiler_rt/extendXfYf2.zig
index 1c95fd68c1c1..5571bd9ed3ca 100644
--- a/lib/std/special/compiler_rt/extendXfYf2.zig
+++ b/lib/std/special/compiler_rt/extendXfYf2.zig
@@ -104,6 +104,6 @@ fn extendXfYf2(comptime dst_t: type, comptime src_t: type, a: std.meta.Int(.unsi
return @bitCast(dst_t, result);
}
-test "import extendXfYf2" {
+test {
_ = @import("extendXfYf2_test.zig");
}
diff --git a/lib/std/special/compiler_rt/fixdfdi.zig b/lib/std/special/compiler_rt/fixdfdi.zig
index 11b50091294e..6c69f10e090e 100644
--- a/lib/std/special/compiler_rt/fixdfdi.zig
+++ b/lib/std/special/compiler_rt/fixdfdi.zig
@@ -11,6 +11,6 @@ pub fn __aeabi_d2lz(arg: f64) callconv(.AAPCS) i64 {
return @call(.{ .modifier = .always_inline }, __fixdfdi, .{arg});
}
-test "import fixdfdi" {
+test {
_ = @import("fixdfdi_test.zig");
}
diff --git a/lib/std/special/compiler_rt/fixdfsi.zig b/lib/std/special/compiler_rt/fixdfsi.zig
index 8a6d8da34203..5842d99cd307 100644
--- a/lib/std/special/compiler_rt/fixdfsi.zig
+++ b/lib/std/special/compiler_rt/fixdfsi.zig
@@ -11,6 +11,6 @@ pub fn __aeabi_d2iz(a: f64) callconv(.AAPCS) i32 {
return @call(.{ .modifier = .always_inline }, __fixdfsi, .{a});
}
-test "import fixdfsi" {
+test {
_ = @import("fixdfsi_test.zig");
}
diff --git a/lib/std/special/compiler_rt/fixdfti.zig b/lib/std/special/compiler_rt/fixdfti.zig
index 0e21f0ba1921..e8af6a2daf09 100644
--- a/lib/std/special/compiler_rt/fixdfti.zig
+++ b/lib/std/special/compiler_rt/fixdfti.zig
@@ -6,6 +6,6 @@ pub fn __fixdfti(a: f64) callconv(.C) i128 {
return fixint(f64, i128, a);
}
-test "import fixdfti" {
+test {
_ = @import("fixdfti_test.zig");
}
diff --git a/lib/std/special/compiler_rt/fixint.zig b/lib/std/special/compiler_rt/fixint.zig
index 6ef647410580..ff0577c11512 100644
--- a/lib/std/special/compiler_rt/fixint.zig
+++ b/lib/std/special/compiler_rt/fixint.zig
@@ -70,6 +70,6 @@ pub fn fixint(comptime fp_t: type, comptime fixint_t: type, a: fp_t) fixint_t {
}
}
-test "import fixint" {
+test {
_ = @import("fixint_test.zig");
}
diff --git a/lib/std/special/compiler_rt/fixsfdi.zig b/lib/std/special/compiler_rt/fixsfdi.zig
index d0d958cdd6b3..64961075d05b 100644
--- a/lib/std/special/compiler_rt/fixsfdi.zig
+++ b/lib/std/special/compiler_rt/fixsfdi.zig
@@ -11,6 +11,6 @@ pub fn __aeabi_f2lz(arg: f32) callconv(.AAPCS) i64 {
return @call(.{ .modifier = .always_inline }, __fixsfdi, .{arg});
}
-test "import fixsfdi" {
+test {
_ = @import("fixsfdi_test.zig");
}
diff --git a/lib/std/special/compiler_rt/fixsfsi.zig b/lib/std/special/compiler_rt/fixsfsi.zig
index 84395d0fa67a..932a6e1a4fc3 100644
--- a/lib/std/special/compiler_rt/fixsfsi.zig
+++ b/lib/std/special/compiler_rt/fixsfsi.zig
@@ -11,6 +11,6 @@ pub fn __aeabi_f2iz(a: f32) callconv(.AAPCS) i32 {
return @call(.{ .modifier = .always_inline }, __fixsfsi, .{a});
}
-test "import fixsfsi" {
+test {
_ = @import("fixsfsi_test.zig");
}
diff --git a/lib/std/special/compiler_rt/fixsfti.zig b/lib/std/special/compiler_rt/fixsfti.zig
index d7ce4b3a602d..e67bbabbd747 100644
--- a/lib/std/special/compiler_rt/fixsfti.zig
+++ b/lib/std/special/compiler_rt/fixsfti.zig
@@ -6,6 +6,6 @@ pub fn __fixsfti(a: f32) callconv(.C) i128 {
return fixint(f32, i128, a);
}
-test "import fixsfti" {
+test {
_ = @import("fixsfti_test.zig");
}
diff --git a/lib/std/special/compiler_rt/fixtfdi.zig b/lib/std/special/compiler_rt/fixtfdi.zig
index 0ef3aa225937..6087d7e7206f 100644
--- a/lib/std/special/compiler_rt/fixtfdi.zig
+++ b/lib/std/special/compiler_rt/fixtfdi.zig
@@ -6,6 +6,6 @@ pub fn __fixtfdi(a: f128) callconv(.C) i64 {
return fixint(f128, i64, a);
}
-test "import fixtfdi" {
+test {
_ = @import("fixtfdi_test.zig");
}
diff --git a/lib/std/special/compiler_rt/fixtfsi.zig b/lib/std/special/compiler_rt/fixtfsi.zig
index 15e89a11b0b0..b5fea97c5ca0 100644
--- a/lib/std/special/compiler_rt/fixtfsi.zig
+++ b/lib/std/special/compiler_rt/fixtfsi.zig
@@ -6,6 +6,6 @@ pub fn __fixtfsi(a: f128) callconv(.C) i32 {
return fixint(f128, i32, a);
}
-test "import fixtfsi" {
+test {
_ = @import("fixtfsi_test.zig");
}
diff --git a/lib/std/special/compiler_rt/fixtfti.zig b/lib/std/special/compiler_rt/fixtfti.zig
index 733fa1eed1b0..5a001d0b69f0 100644
--- a/lib/std/special/compiler_rt/fixtfti.zig
+++ b/lib/std/special/compiler_rt/fixtfti.zig
@@ -6,6 +6,6 @@ pub fn __fixtfti(a: f128) callconv(.C) i128 {
return fixint(f128, i128, a);
}
-test "import fixtfti" {
+test {
_ = @import("fixtfti_test.zig");
}
diff --git a/lib/std/special/compiler_rt/fixunsdfdi.zig b/lib/std/special/compiler_rt/fixunsdfdi.zig
index 800c9b1148ad..c864f0f6c2e6 100644
--- a/lib/std/special/compiler_rt/fixunsdfdi.zig
+++ b/lib/std/special/compiler_rt/fixunsdfdi.zig
@@ -11,6 +11,6 @@ pub fn __aeabi_d2ulz(a: f64) callconv(.AAPCS) u64 {
return @call(.{ .modifier = .always_inline }, __fixunsdfdi, .{a});
}
-test "import fixunsdfdi" {
+test {
_ = @import("fixunsdfdi_test.zig");
}
diff --git a/lib/std/special/compiler_rt/fixunsdfsi.zig b/lib/std/special/compiler_rt/fixunsdfsi.zig
index 156c21a887b1..c1f517366142 100644
--- a/lib/std/special/compiler_rt/fixunsdfsi.zig
+++ b/lib/std/special/compiler_rt/fixunsdfsi.zig
@@ -11,6 +11,6 @@ pub fn __aeabi_d2uiz(arg: f64) callconv(.AAPCS) u32 {
return @call(.{ .modifier = .always_inline }, __fixunsdfsi, .{arg});
}
-test "import fixunsdfsi" {
+test {
_ = @import("fixunsdfsi_test.zig");
}
diff --git a/lib/std/special/compiler_rt/fixunsdfti.zig b/lib/std/special/compiler_rt/fixunsdfti.zig
index 3dcec6bf8987..3c9871a4df9e 100644
--- a/lib/std/special/compiler_rt/fixunsdfti.zig
+++ b/lib/std/special/compiler_rt/fixunsdfti.zig
@@ -6,6 +6,6 @@ pub fn __fixunsdfti(a: f64) callconv(.C) u128 {
return fixuint(f64, u128, a);
}
-test "import fixunsdfti" {
+test {
_ = @import("fixunsdfti_test.zig");
}
diff --git a/lib/std/special/compiler_rt/fixunssfdi.zig b/lib/std/special/compiler_rt/fixunssfdi.zig
index ec00a7ee35c5..edad20e8bf19 100644
--- a/lib/std/special/compiler_rt/fixunssfdi.zig
+++ b/lib/std/special/compiler_rt/fixunssfdi.zig
@@ -11,6 +11,6 @@ pub fn __aeabi_f2ulz(a: f32) callconv(.AAPCS) u64 {
return @call(.{ .modifier = .always_inline }, __fixunssfdi, .{a});
}
-test "import fixunssfdi" {
+test {
_ = @import("fixunssfdi_test.zig");
}
diff --git a/lib/std/special/compiler_rt/fixunssfsi.zig b/lib/std/special/compiler_rt/fixunssfsi.zig
index a4e5a323f592..96722a2a3648 100644
--- a/lib/std/special/compiler_rt/fixunssfsi.zig
+++ b/lib/std/special/compiler_rt/fixunssfsi.zig
@@ -11,6 +11,6 @@ pub fn __aeabi_f2uiz(a: f32) callconv(.AAPCS) u32 {
return @call(.{ .modifier = .always_inline }, __fixunssfsi, .{a});
}
-test "import fixunssfsi" {
+test {
_ = @import("fixunssfsi_test.zig");
}
diff --git a/lib/std/special/compiler_rt/fixunssfti.zig b/lib/std/special/compiler_rt/fixunssfti.zig
index dff9eb74980f..4967202e6917 100644
--- a/lib/std/special/compiler_rt/fixunssfti.zig
+++ b/lib/std/special/compiler_rt/fixunssfti.zig
@@ -6,6 +6,6 @@ pub fn __fixunssfti(a: f32) callconv(.C) u128 {
return fixuint(f32, u128, a);
}
-test "import fixunssfti" {
+test {
_ = @import("fixunssfti_test.zig");
}
diff --git a/lib/std/special/compiler_rt/fixunstfdi.zig b/lib/std/special/compiler_rt/fixunstfdi.zig
index 907116c1650e..0db4987a08d3 100644
--- a/lib/std/special/compiler_rt/fixunstfdi.zig
+++ b/lib/std/special/compiler_rt/fixunstfdi.zig
@@ -6,6 +6,6 @@ pub fn __fixunstfdi(a: f128) callconv(.C) u64 {
return fixuint(f128, u64, a);
}
-test "import fixunstfdi" {
+test {
_ = @import("fixunstfdi_test.zig");
}
diff --git a/lib/std/special/compiler_rt/fixunstfsi.zig b/lib/std/special/compiler_rt/fixunstfsi.zig
index c66a3f18b492..8cedc07a3513 100644
--- a/lib/std/special/compiler_rt/fixunstfsi.zig
+++ b/lib/std/special/compiler_rt/fixunstfsi.zig
@@ -6,6 +6,6 @@ pub fn __fixunstfsi(a: f128) callconv(.C) u32 {
return fixuint(f128, u32, a);
}
-test "import fixunstfsi" {
+test {
_ = @import("fixunstfsi_test.zig");
}
diff --git a/lib/std/special/compiler_rt/fixunstfti.zig b/lib/std/special/compiler_rt/fixunstfti.zig
index 1867c69234ba..035932702706 100644
--- a/lib/std/special/compiler_rt/fixunstfti.zig
+++ b/lib/std/special/compiler_rt/fixunstfti.zig
@@ -6,6 +6,6 @@ pub fn __fixunstfti(a: f128) callconv(.C) u128 {
return fixuint(f128, u128, a);
}
-test "import fixunstfti" {
+test {
_ = @import("fixunstfti_test.zig");
}
diff --git a/lib/std/special/compiler_rt/floatXisf.zig b/lib/std/special/compiler_rt/floatXisf.zig
index b02ff5f622e1..9fc4c711001b 100644
--- a/lib/std/special/compiler_rt/floatXisf.zig
+++ b/lib/std/special/compiler_rt/floatXisf.zig
@@ -85,9 +85,9 @@ pub fn __aeabi_l2f(arg: i64) callconv(.AAPCS) f32 {
return @call(.{ .modifier = .always_inline }, __floatdisf, .{arg});
}
-test "import floattisf" {
+test {
_ = @import("floattisf_test.zig");
}
-test "import floatdisf" {
+test {
_ = @import("floattisf_test.zig");
}
diff --git a/lib/std/special/compiler_rt/floatdidf.zig b/lib/std/special/compiler_rt/floatdidf.zig
index afe9e906fd81..16a514b615c5 100644
--- a/lib/std/special/compiler_rt/floatdidf.zig
+++ b/lib/std/special/compiler_rt/floatdidf.zig
@@ -22,6 +22,6 @@ pub fn __aeabi_l2d(arg: i64) callconv(.AAPCS) f64 {
return @call(.{ .modifier = .always_inline }, __floatdidf, .{arg});
}
-test "import floatdidf" {
+test {
_ = @import("floatdidf_test.zig");
}
diff --git a/lib/std/special/compiler_rt/floatditf.zig b/lib/std/special/compiler_rt/floatditf.zig
index 581a0e0532bc..fef696e6fbea 100644
--- a/lib/std/special/compiler_rt/floatditf.zig
+++ b/lib/std/special/compiler_rt/floatditf.zig
@@ -33,6 +33,6 @@ pub fn __floatditf(arg: i64) callconv(.C) f128 {
return @bitCast(f128, result | sign);
}
-test "import floatditf" {
+test {
_ = @import("floatditf_test.zig");
}
diff --git a/lib/std/special/compiler_rt/floattidf.zig b/lib/std/special/compiler_rt/floattidf.zig
index 6b5013287b9e..85f84a23d644 100644
--- a/lib/std/special/compiler_rt/floattidf.zig
+++ b/lib/std/special/compiler_rt/floattidf.zig
@@ -66,6 +66,6 @@ pub fn __floattidf(arg: i128) callconv(.C) f64 {
return @bitCast(f64, low | (high << 32));
}
-test "import floattidf" {
+test {
_ = @import("floattidf_test.zig");
}
diff --git a/lib/std/special/compiler_rt/floattitf.zig b/lib/std/special/compiler_rt/floattitf.zig
index 90bc241306fe..aa83f6686eba 100644
--- a/lib/std/special/compiler_rt/floattitf.zig
+++ b/lib/std/special/compiler_rt/floattitf.zig
@@ -66,6 +66,6 @@ pub fn __floattitf(arg: i128) callconv(.C) f128 {
return @bitCast(f128, low | (high << 64));
}
-test "import floattitf" {
+test {
_ = @import("floattitf_test.zig");
}
diff --git a/lib/std/special/compiler_rt/floatundidf.zig b/lib/std/special/compiler_rt/floatundidf.zig
index 1efe55da4062..14e74344907e 100644
--- a/lib/std/special/compiler_rt/floatundidf.zig
+++ b/lib/std/special/compiler_rt/floatundidf.zig
@@ -24,6 +24,6 @@ pub fn __aeabi_ul2d(arg: u64) callconv(.AAPCS) f64 {
return @call(.{ .modifier = .always_inline }, __floatundidf, .{arg});
}
-test "import floatundidf" {
+test {
_ = @import("floatundidf_test.zig");
}
diff --git a/lib/std/special/compiler_rt/floatunditf.zig b/lib/std/special/compiler_rt/floatunditf.zig
index dda5dd6ea523..b304c8cdbae0 100644
--- a/lib/std/special/compiler_rt/floatunditf.zig
+++ b/lib/std/special/compiler_rt/floatunditf.zig
@@ -23,6 +23,6 @@ pub fn __floatunditf(a: u64) callconv(.C) f128 {
return @bitCast(f128, result);
}
-test "import floatunditf" {
+test {
_ = @import("floatunditf_test.zig");
}
diff --git a/lib/std/special/compiler_rt/floatunsitf.zig b/lib/std/special/compiler_rt/floatunsitf.zig
index a430471f3a7a..8774d486ea51 100644
--- a/lib/std/special/compiler_rt/floatunsitf.zig
+++ b/lib/std/special/compiler_rt/floatunsitf.zig
@@ -24,6 +24,6 @@ pub fn __floatunsitf(a: u32) callconv(.C) f128 {
return @bitCast(f128, result);
}
-test "import floatunsitf" {
+test {
_ = @import("floatunsitf_test.zig");
}
diff --git a/lib/std/special/compiler_rt/floatuntidf.zig b/lib/std/special/compiler_rt/floatuntidf.zig
index 5b5adc04910a..2c4729a9d853 100644
--- a/lib/std/special/compiler_rt/floatuntidf.zig
+++ b/lib/std/special/compiler_rt/floatuntidf.zig
@@ -57,6 +57,6 @@ pub fn __floatuntidf(arg: u128) callconv(.C) f64 {
return @bitCast(f64, low | (high << 32));
}
-test "import floatuntidf" {
+test {
_ = @import("floatuntidf_test.zig");
}
diff --git a/lib/std/special/compiler_rt/floatuntisf.zig b/lib/std/special/compiler_rt/floatuntisf.zig
index 33e6e41a84fc..2a54c2e0f3c7 100644
--- a/lib/std/special/compiler_rt/floatuntisf.zig
+++ b/lib/std/special/compiler_rt/floatuntisf.zig
@@ -56,6 +56,6 @@ pub fn __floatuntisf(arg: u128) callconv(.C) f32 {
return @bitCast(f32, high | low);
}
-test "import floatuntisf" {
+test {
_ = @import("floatuntisf_test.zig");
}
diff --git a/lib/std/special/compiler_rt/floatuntitf.zig b/lib/std/special/compiler_rt/floatuntitf.zig
index 0b96076206db..c35b4dcf7469 100644
--- a/lib/std/special/compiler_rt/floatuntitf.zig
+++ b/lib/std/special/compiler_rt/floatuntitf.zig
@@ -57,6 +57,6 @@ pub fn __floatuntitf(arg: u128) callconv(.C) f128 {
return @bitCast(f128, low | (high << 64));
}
-test "import floatuntitf" {
+test {
_ = @import("floatuntitf_test.zig");
}
diff --git a/lib/std/special/compiler_rt/modti3.zig b/lib/std/special/compiler_rt/modti3.zig
index 915b2b95668c..42cbda9627ab 100644
--- a/lib/std/special/compiler_rt/modti3.zig
+++ b/lib/std/special/compiler_rt/modti3.zig
@@ -28,6 +28,6 @@ pub fn __modti3_windows_x86_64(a: v128, b: v128) callconv(.C) v128 {
}));
}
-test "import modti3" {
+test {
_ = @import("modti3_test.zig");
}
diff --git a/lib/std/special/compiler_rt/mulXf3.zig b/lib/std/special/compiler_rt/mulXf3.zig
index f050cb1711bb..1e9171c8cb79 100644
--- a/lib/std/special/compiler_rt/mulXf3.zig
+++ b/lib/std/special/compiler_rt/mulXf3.zig
@@ -294,6 +294,6 @@ fn wideRightShiftWithSticky(comptime Z: type, hi: *Z, lo: *Z, count: u32) void {
}
}
-test "import mulXf3" {
+test {
_ = @import("mulXf3_test.zig");
}
diff --git a/lib/std/special/compiler_rt/muldi3.zig b/lib/std/special/compiler_rt/muldi3.zig
index 359484da09aa..3d426bd48e7b 100644
--- a/lib/std/special/compiler_rt/muldi3.zig
+++ b/lib/std/special/compiler_rt/muldi3.zig
@@ -51,6 +51,6 @@ pub fn __muldi3(a: i64, b: i64) callconv(.C) i64 {
return r.all;
}
-test "import muldi3" {
+test {
_ = @import("muldi3_test.zig");
}
diff --git a/lib/std/special/compiler_rt/mulodi4.zig b/lib/std/special/compiler_rt/mulodi4.zig
index 94ed6752cc08..d58cfbfe11a0 100644
--- a/lib/std/special/compiler_rt/mulodi4.zig
+++ b/lib/std/special/compiler_rt/mulodi4.zig
@@ -1,7 +1,5 @@
const builtin = @import("builtin");
const compiler_rt = @import("../compiler_rt.zig");
-const maxInt = std.math.maxInt;
-const minInt = std.math.minInt;
pub fn __mulodi4(a: i64, b: i64, overflow: *c_int) callconv(.C) i64 {
@setRuntimeSafety(builtin.is_test);
@@ -39,6 +37,6 @@ pub fn __mulodi4(a: i64, b: i64, overflow: *c_int) callconv(.C) i64 {
return result;
}
-test "import mulodi4" {
+test {
_ = @import("mulodi4_test.zig");
}
diff --git a/lib/std/special/compiler_rt/muloti4.zig b/lib/std/special/compiler_rt/muloti4.zig
index b36a32666a50..7e3497ed7bab 100644
--- a/lib/std/special/compiler_rt/muloti4.zig
+++ b/lib/std/special/compiler_rt/muloti4.zig
@@ -44,6 +44,6 @@ pub fn __muloti4(a: i128, b: i128, overflow: *c_int) callconv(.C) i128 {
return r;
}
-test "import muloti4" {
+test {
_ = @import("muloti4_test.zig");
}
diff --git a/lib/std/special/compiler_rt/multi3.zig b/lib/std/special/compiler_rt/multi3.zig
index 47343613300e..d1c4a3b05d2c 100644
--- a/lib/std/special/compiler_rt/multi3.zig
+++ b/lib/std/special/compiler_rt/multi3.zig
@@ -59,6 +59,6 @@ const twords = extern union {
};
};
-test "import multi3" {
+test {
_ = @import("multi3_test.zig");
}
diff --git a/lib/std/special/compiler_rt/popcountdi2.zig b/lib/std/special/compiler_rt/popcountdi2.zig
index b7e7220c7b8c..9835e60fbc7f 100644
--- a/lib/std/special/compiler_rt/popcountdi2.zig
+++ b/lib/std/special/compiler_rt/popcountdi2.zig
@@ -19,6 +19,6 @@ pub fn __popcountdi2(a: i64) callconv(.C) i32 {
return @bitCast(i32, (x + (x >> 8)) & 0x0000007F); // (7 significant bits)
}
-test "import popcountdi2" {
+test {
_ = @import("popcountdi2_test.zig");
}
diff --git a/lib/std/special/compiler_rt/truncXfYf2.zig b/lib/std/special/compiler_rt/truncXfYf2.zig
index 737d0e330f8c..1d0394197cc3 100644
--- a/lib/std/special/compiler_rt/truncXfYf2.zig
+++ b/lib/std/special/compiler_rt/truncXfYf2.zig
@@ -138,6 +138,6 @@ fn truncXfYf2(comptime dst_t: type, comptime src_t: type, a: src_t) dst_t {
return @bitCast(dst_t, result);
}
-test "import truncXfYf2" {
+test {
_ = @import("truncXfYf2_test.zig");
}
diff --git a/lib/std/special/compiler_rt/udivmodti4.zig b/lib/std/special/compiler_rt/udivmodti4.zig
index cc1141dbbca1..be9ed8237bd2 100644
--- a/lib/std/special/compiler_rt/udivmodti4.zig
+++ b/lib/std/special/compiler_rt/udivmodti4.zig
@@ -13,6 +13,6 @@ pub fn __udivmodti4_windows_x86_64(a: v128, b: v128, maybe_rem: ?*u128) callconv
return @bitCast(v128, udivmod(u128, @bitCast(u128, a), @bitCast(u128, b), maybe_rem));
}
-test "import udivmodti4" {
+test {
_ = @import("udivmodti4_test.zig");
}
diff --git a/lib/std/special/ssp.zig b/lib/std/special/ssp.zig
index 7bc5cef81396..94a66768388d 100644
--- a/lib/std/special/ssp.zig
+++ b/lib/std/special/ssp.zig
@@ -25,9 +25,7 @@ pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn
_ = msg;
_ = error_return_trace;
@setCold(true);
- if (@hasDecl(std.os, "abort"))
- std.os.abort();
- while (true) {}
+ std.os.abort();
}
export fn __stack_chk_fail() callconv(.C) noreturn {
diff --git a/lib/std/start.zig b/lib/std/start.zig
index f16a5aba1e83..ac592e26edc1 100644
--- a/lib/std/start.zig
+++ b/lib/std/start.zig
@@ -345,7 +345,7 @@ fn posixCallMainAndExit() noreturn {
// FIXME: Elide the check for targets >= ARMv7 when the target feature API
// becomes less verbose (and more usable).
if (comptime native_arch.isARM()) {
- if (at_hwcap & std.os.linux.HWCAP_TLS == 0) {
+ if (at_hwcap & std.os.linux.HWCAP.TLS == 0) {
// FIXME: Make __aeabi_read_tp call the kernel helper kuser_get_tls
// For the time being use a simple abort instead of a @panic call to
// keep the binary bloat under control.
diff --git a/lib/std/time.zig b/lib/std/time.zig
index 23065307533f..eb398f1a4a52 100644
--- a/lib/std/time.zig
+++ b/lib/std/time.zig
@@ -24,7 +24,7 @@ pub fn sleep(nanoseconds: u64) void {
const w = std.os.wasi;
const userdata: w.userdata_t = 0x0123_45678;
const clock = w.subscription_clock_t{
- .id = w.CLOCK_MONOTONIC,
+ .id = w.CLOCK.MONOTONIC,
.timeout = nanoseconds,
.precision = 0,
.flags = 0,
@@ -86,12 +86,12 @@ pub fn nanoTimestamp() i128 {
}
if (builtin.os.tag == .wasi and !builtin.link_libc) {
var ns: os.wasi.timestamp_t = undefined;
- const err = os.wasi.clock_time_get(os.wasi.CLOCK_REALTIME, 1, &ns);
+ const err = os.wasi.clock_time_get(os.wasi.CLOCK.REALTIME, 1, &ns);
assert(err == .SUCCESS);
return ns;
}
var ts: os.timespec = undefined;
- os.clock_gettime(os.CLOCK_REALTIME, &ts) catch |err| switch (err) {
+ os.clock_gettime(os.CLOCK.REALTIME, &ts) catch |err| switch (err) {
error.UnsupportedClock, error.Unexpected => return 0, // "Precision of timing depends on hardware and OS".
};
return (@as(i128, ts.tv_sec) * ns_per_s) + ts.tv_nsec;
@@ -152,7 +152,7 @@ pub const Timer = struct {
/// At some point we may change our minds on RAW, but for now we're
/// sticking with posix standard MONOTONIC. For more information, see:
/// https://github.com/ziglang/zig/pull/933
- const monotonic_clock_id = os.CLOCK_MONOTONIC;
+ const monotonic_clock_id = os.CLOCK.MONOTONIC;
/// Initialize the timer structure.
/// Can only fail when running in a hostile environment that intentionally injects
@@ -161,7 +161,7 @@ pub const Timer = struct {
pub fn start() Error!Timer {
// This gives us an opportunity to grab the counter frequency in windows.
// On Windows: QueryPerformanceCounter will succeed on anything >= XP/2000.
- // On Posix: CLOCK_MONOTONIC will only fail if the monotonic counter is not
+ // On Posix: CLOCK.MONOTONIC will only fail if the monotonic counter is not
// supported, or if the timespec pointer is out of bounds, which should be
// impossible here barring cosmic rays or other such occurrences of
// incredibly bad luck.
@@ -200,8 +200,6 @@ pub const Timer = struct {
.frequency = {},
};
}
-
- return self;
}
/// Reads the timer value since start or the last reset in nanoseconds
diff --git a/lib/std/x/net/tcp.zig b/lib/std/x/net/tcp.zig
index 5e02b68e9c92..4fbd07e00c8e 100644
--- a/lib/std/x/net/tcp.zig
+++ b/lib/std/x/net/tcp.zig
@@ -46,8 +46,8 @@ pub const Connection = struct {
/// Possible domains that a TCP client/listener may operate over.
pub const Domain = enum(u16) {
- ip = os.AF_INET,
- ipv6 = os.AF_INET6,
+ ip = os.AF.INET,
+ ipv6 = os.AF.INET6,
};
/// A TCP client.
@@ -81,8 +81,8 @@ pub const Client = struct {
return Client{
.socket = try Socket.init(
@enumToInt(domain),
- os.SOCK_STREAM,
- os.IPPROTO_TCP,
+ os.SOCK.STREAM,
+ os.IPPROTO.TCP,
flags,
),
};
@@ -193,9 +193,9 @@ pub const Client = struct {
/// Disable Nagle's algorithm on a TCP socket. It returns `error.UnsupportedSocketOption` if
/// the host does not support sockets disabling Nagle's algorithm.
pub fn setNoDelay(self: Client, enabled: bool) !void {
- if (comptime @hasDecl(os, "TCP_NODELAY")) {
+ if (@hasDecl(os.TCP, "NODELAY")) {
const bytes = mem.asBytes(&@as(usize, @boolToInt(enabled)));
- return self.socket.setOption(os.IPPROTO_TCP, os.TCP_NODELAY, bytes);
+ return self.socket.setOption(os.IPPROTO.TCP, os.TCP_NODELAY, bytes);
}
return error.UnsupportedSocketOption;
}
@@ -203,8 +203,8 @@ pub const Client = struct {
/// Enables TCP Quick ACK on a TCP socket to immediately send rather than delay ACKs when necessary. It returns
/// `error.UnsupportedSocketOption` if the host does not support TCP Quick ACK.
pub fn setQuickACK(self: Client, enabled: bool) !void {
- if (comptime @hasDecl(os, "TCP_QUICKACK")) {
- return self.socket.setOption(os.IPPROTO_TCP, os.TCP_QUICKACK, mem.asBytes(&@as(u32, @boolToInt(enabled))));
+ if (@hasDecl(os.TCP, "QUICKACK")) {
+ return self.socket.setOption(os.IPPROTO.TCP, os.TCP_QUICKACK, mem.asBytes(&@as(u32, @boolToInt(enabled))));
}
return error.UnsupportedSocketOption;
}
@@ -244,8 +244,8 @@ pub const Listener = struct {
return Listener{
.socket = try Socket.init(
@enumToInt(domain),
- os.SOCK_STREAM,
- os.IPPROTO_TCP,
+ os.SOCK.STREAM,
+ os.IPPROTO.TCP,
flags,
),
};
@@ -304,8 +304,8 @@ pub const Listener = struct {
/// Enables TCP Fast Open (RFC 7413) on a TCP socket. It returns `error.UnsupportedSocketOption` if the host does not
/// support TCP Fast Open.
pub fn setFastOpen(self: Listener, enabled: bool) !void {
- if (comptime @hasDecl(os, "TCP_FASTOPEN")) {
- return self.socket.setOption(os.IPPROTO_TCP, os.TCP_FASTOPEN, mem.asBytes(&@as(u32, @boolToInt(enabled))));
+ if (@hasDecl(os.TCP, "FASTOPEN")) {
+ return self.socket.setOption(os.IPPROTO.TCP, os.TCP_FASTOPEN, mem.asBytes(&@as(u32, @boolToInt(enabled))));
}
return error.UnsupportedSocketOption;
}
diff --git a/lib/std/x/os/io.zig b/lib/std/x/os/io.zig
index b0df3f947e86..c2d9b27f671f 100644
--- a/lib/std/x/os/io.zig
+++ b/lib/std/x/os/io.zig
@@ -4,6 +4,7 @@ const os = std.os;
const mem = std.mem;
const testing = std.testing;
const native_os = std.Target.current.os;
+const linux = std.os.linux;
/// POSIX `iovec`, or Windows `WSABUF`. The difference between the two are the ordering
/// of fields, alongside the length being represented as either a ULONG or a size_t.
@@ -67,7 +68,7 @@ pub const Reactor = struct {
pub fn init(flags: std.enums.EnumFieldStruct(Reactor.InitFlags, bool, false)) !Reactor {
var raw_flags: u32 = 0;
const set = std.EnumSet(Reactor.InitFlags).init(flags);
- if (set.contains(.close_on_exec)) raw_flags |= os.EPOLL_CLOEXEC;
+ if (set.contains(.close_on_exec)) raw_flags |= linux.EPOLL.CLOEXEC;
return Reactor{ .fd = try os.epoll_create1(raw_flags) };
}
@@ -77,31 +78,31 @@ pub const Reactor = struct {
pub fn update(self: Reactor, fd: os.fd_t, identifier: usize, interest: Reactor.Interest) !void {
var flags: u32 = 0;
- flags |= if (interest.oneshot) os.EPOLLONESHOT else os.EPOLLET;
- if (interest.hup) flags |= os.EPOLLRDHUP;
- if (interest.readable) flags |= os.EPOLLIN;
- if (interest.writable) flags |= os.EPOLLOUT;
+ flags |= if (interest.oneshot) linux.EPOLL.ONESHOT else linux.EPOLL.ET;
+ if (interest.hup) flags |= linux.EPOLL.RDHUP;
+ if (interest.readable) flags |= linux.EPOLL.IN;
+ if (interest.writable) flags |= linux.EPOLL.OUT;
- const event = &os.epoll_event{
+ const event = &linux.epoll_event{
.events = flags,
.data = .{ .ptr = identifier },
};
- os.epoll_ctl(self.fd, os.EPOLL_CTL_MOD, fd, event) catch |err| switch (err) {
- error.FileDescriptorNotRegistered => try os.epoll_ctl(self.fd, os.EPOLL_CTL_ADD, fd, event),
+ os.epoll_ctl(self.fd, linux.EPOLL.CTL_MOD, fd, event) catch |err| switch (err) {
+ error.FileDescriptorNotRegistered => try os.epoll_ctl(self.fd, linux.EPOLL.CTL_ADD, fd, event),
else => return err,
};
}
pub fn poll(self: Reactor, comptime max_num_events: comptime_int, closure: anytype, timeout_milliseconds: ?u64) !void {
- var events: [max_num_events]os.epoll_event = undefined;
+ var events: [max_num_events]linux.epoll_event = undefined;
const num_events = os.epoll_wait(self.fd, &events, if (timeout_milliseconds) |ms| @intCast(i32, ms) else -1);
for (events[0..num_events]) |ev| {
- const is_error = ev.events & os.EPOLLERR != 0;
- const is_hup = ev.events & (os.EPOLLHUP | os.EPOLLRDHUP) != 0;
- const is_readable = ev.events & os.EPOLLIN != 0;
- const is_writable = ev.events & os.EPOLLOUT != 0;
+ const is_error = ev.events & linux.EPOLL.ERR != 0;
+ const is_hup = ev.events & (linux.EPOLL.HUP | linux.EPOLL.RDHUP) != 0;
+ const is_readable = ev.events & linux.EPOLL.IN != 0;
+ const is_writable = ev.events & linux.EPOLL.OUT != 0;
try closure.call(Reactor.Event{
.data = ev.data.ptr,
diff --git a/lib/std/x/os/net.zig b/lib/std/x/os/net.zig
index cca9bc0ffa66..08ecede3e5c1 100644
--- a/lib/std/x/os/net.zig
+++ b/lib/std/x/os/net.zig
@@ -6,12 +6,13 @@ const mem = std.mem;
const math = std.math;
const testing = std.testing;
const native_os = std.Target.current.os;
+const have_ifnamesize = @hasDecl(os.system, "IFNAMESIZE");
/// Resolves a network interface name into a scope/zone ID. It returns
/// an error if either resolution fails, or if the interface name is
/// too long.
pub fn resolveScopeID(name: []const u8) !u32 {
- if (@hasDecl(os, "IFNAMESIZE")) {
+ if (have_ifnamesize) {
if (name.len >= os.IFNAMESIZE - 1) return error.NameTooLong;
if (native_os.tag == .windows) {
@@ -22,7 +23,7 @@ pub fn resolveScopeID(name: []const u8) !u32 {
return os.windows.ws2_32.if_nametoindex(@ptrCast([*:0]const u8, &interface_name));
}
- const fd = try os.socket(os.AF_UNIX, os.SOCK_DGRAM, 0);
+ const fd = try os.socket(os.AF.UNIX, os.SOCK.DGRAM, 0);
defer os.closeSocket(fd);
var f: os.ifreq = undefined;
@@ -556,7 +557,7 @@ test "ipv6: parse & format" {
}
test "ipv6: parse & format addresses with scope ids" {
- if (!@hasDecl(os, "IFNAMESIZE")) return error.SkipZigTest;
+ if (!have_ifnamesize) return error.SkipZigTest;
const inputs = [_][]const u8{
"FF01::FB%lo",
diff --git a/lib/std/x/os/socket.zig b/lib/std/x/os/socket.zig
index 33fc4971d752..5930b8cb9a7c 100644
--- a/lib/std/x/os/socket.zig
+++ b/lib/std/x/os/socket.zig
@@ -35,7 +35,7 @@ pub const Socket = struct {
pub const Family = if (requires_prepended_length) u8 else c_ushort;
- /// POSIX `sockaddr_storage`. The expected size and alignment is specified in IETF RFC 2553.
+ /// POSIX `sockaddr.storage`. The expected size and alignment is specified in IETF RFC 2553.
pub const Storage = extern struct {
pub const expected_size = 128;
pub const expected_alignment = 8;
@@ -71,14 +71,14 @@ pub const Socket = struct {
/// Parses a `sockaddr` into a generic socket address.
pub fn fromNative(address: *align(4) const os.sockaddr) Socket.Address {
switch (address.family) {
- os.AF_INET => {
- const info = @ptrCast(*const os.sockaddr_in, address);
+ os.AF.INET => {
+ const info = @ptrCast(*const os.sockaddr.in, address);
const host = net.IPv4{ .octets = @bitCast([4]u8, info.addr) };
const port = mem.bigToNative(u16, info.port);
return Socket.Address.initIPv4(host, port);
},
- os.AF_INET6 => {
- const info = @ptrCast(*const os.sockaddr_in6, address);
+ os.AF.INET6 => {
+ const info = @ptrCast(*const os.sockaddr.in6, address);
const host = net.IPv6{ .octets = info.addr, .scope_id = info.scope_id };
const port = mem.bigToNative(u16, info.port);
return Socket.Address.initIPv6(host, port);
@@ -90,8 +90,8 @@ pub const Socket = struct {
/// Encodes a generic socket address into an extern union that may be reliably
/// casted into a `sockaddr` which may be passed into socket syscalls.
pub fn toNative(self: Socket.Address) extern union {
- ipv4: os.sockaddr_in,
- ipv6: os.sockaddr_in6,
+ ipv4: os.sockaddr.in,
+ ipv6: os.sockaddr.in6,
} {
return switch (self) {
.ipv4 => |address| .{
@@ -114,8 +114,8 @@ pub const Socket = struct {
/// Returns the number of bytes that make up the `sockaddr` equivalent to the address.
pub fn getNativeSize(self: Socket.Address) u32 {
return switch (self) {
- .ipv4 => @sizeOf(os.sockaddr_in),
- .ipv6 => @sizeOf(os.sockaddr_in6),
+ .ipv4 => @sizeOf(os.sockaddr.in),
+ .ipv6 => @sizeOf(os.sockaddr.in6),
};
}
diff --git a/lib/std/x/os/socket_posix.zig b/lib/std/x/os/socket_posix.zig
index 895d4c80017a..3d8346db1790 100644
--- a/lib/std/x/os/socket_posix.zig
+++ b/lib/std/x/os/socket_posix.zig
@@ -10,8 +10,8 @@ pub fn Mixin(comptime Socket: type) type {
pub fn init(domain: u32, socket_type: u32, protocol: u32, flags: std.enums.EnumFieldStruct(Socket.InitFlags, bool, false)) !Socket {
var raw_flags: u32 = socket_type;
const set = std.EnumSet(Socket.InitFlags).init(flags);
- if (set.contains(.close_on_exec)) raw_flags |= os.SOCK_CLOEXEC;
- if (set.contains(.nonblocking)) raw_flags |= os.SOCK_NONBLOCK;
+ if (set.contains(.close_on_exec)) raw_flags |= os.SOCK.CLOEXEC;
+ if (set.contains(.nonblocking)) raw_flags |= os.SOCK.NONBLOCK;
return Socket{ .fd = try os.socket(domain, raw_flags, protocol) };
}
@@ -48,8 +48,8 @@ pub fn Mixin(comptime Socket: type) type {
var raw_flags: u32 = 0;
const set = std.EnumSet(Socket.InitFlags).init(flags);
- if (set.contains(.close_on_exec)) raw_flags |= os.SOCK_CLOEXEC;
- if (set.contains(.nonblocking)) raw_flags |= os.SOCK_NONBLOCK;
+ if (set.contains(.close_on_exec)) raw_flags |= os.SOCK.CLOEXEC;
+ if (set.contains(.nonblocking)) raw_flags |= os.SOCK.NONBLOCK;
const socket = Socket{ .fd = try os.accept(self.fd, @ptrCast(*os.sockaddr, &address), &address_len, raw_flags) };
const socket_address = Socket.Address.fromNative(@ptrCast(*os.sockaddr, &address));
@@ -156,7 +156,7 @@ pub fn Mixin(comptime Socket: type) type {
var value: u32 = undefined;
var value_len: u32 = @sizeOf(u32);
- const rc = os.system.getsockopt(self.fd, os.SOL_SOCKET, os.SO_RCVBUF, mem.asBytes(&value), &value_len);
+ const rc = os.system.getsockopt(self.fd, os.SOL.SOCKET, os.SO.RCVBUF, mem.asBytes(&value), &value_len);
return switch (os.errno(rc)) {
.SUCCESS => value,
.BADF => error.BadFileDescriptor,
@@ -173,7 +173,7 @@ pub fn Mixin(comptime Socket: type) type {
var value: u32 = undefined;
var value_len: u32 = @sizeOf(u32);
- const rc = os.system.getsockopt(self.fd, os.SOL_SOCKET, os.SO_SNDBUF, mem.asBytes(&value), &value_len);
+ const rc = os.system.getsockopt(self.fd, os.SOL.SOCKET, os.SO.SNDBUF, mem.asBytes(&value), &value_len);
return switch (os.errno(rc)) {
.SUCCESS => value,
.BADF => error.BadFileDescriptor,
@@ -195,9 +195,9 @@ pub fn Mixin(comptime Socket: type) type {
/// if the host does not support the option for a socket to linger around up until a timeout specified in
/// seconds.
pub fn setLinger(self: Socket, timeout_seconds: ?u16) !void {
- if (comptime @hasDecl(os, "SO_LINGER")) {
+ if (@hasDecl(os.SO, "LINGER")) {
const settings = Socket.Linger.init(timeout_seconds);
- return self.setOption(os.SOL_SOCKET, os.SO_LINGER, mem.asBytes(&settings));
+ return self.setOption(os.SOL.SOCKET, os.SO.LINGER, mem.asBytes(&settings));
}
return error.UnsupportedSocketOption;
@@ -207,8 +207,8 @@ pub fn Mixin(comptime Socket: type) type {
/// messages are sent are dependant on operating system settings. It returns `error.UnsupportedSocketOption` if
/// the host does not support periodically sending keep-alive messages on connection-oriented sockets.
pub fn setKeepAlive(self: Socket, enabled: bool) !void {
- if (comptime @hasDecl(os, "SO_KEEPALIVE")) {
- return self.setOption(os.SOL_SOCKET, os.SO_KEEPALIVE, mem.asBytes(&@as(u32, @boolToInt(enabled))));
+ if (@hasDecl(os.SO, "KEEPALIVE")) {
+ return self.setOption(os.SOL.SOCKET, os.SO.KEEPALIVE, mem.asBytes(&@as(u32, @boolToInt(enabled))));
}
return error.UnsupportedSocketOption;
}
@@ -216,8 +216,8 @@ pub fn Mixin(comptime Socket: type) type {
/// Allow multiple sockets on the same host to listen on the same address. It returns `error.UnsupportedSocketOption` if
/// the host does not support sockets listening the same address.
pub fn setReuseAddress(self: Socket, enabled: bool) !void {
- if (comptime @hasDecl(os, "SO_REUSEADDR")) {
- return self.setOption(os.SOL_SOCKET, os.SO_REUSEADDR, mem.asBytes(&@as(u32, @boolToInt(enabled))));
+ if (@hasDecl(os.SO, "REUSEADDR")) {
+ return self.setOption(os.SOL.SOCKET, os.SO.REUSEADDR, mem.asBytes(&@as(u32, @boolToInt(enabled))));
}
return error.UnsupportedSocketOption;
}
@@ -225,20 +225,20 @@ pub fn Mixin(comptime Socket: type) type {
/// Allow multiple sockets on the same host to listen on the same port. It returns `error.UnsupportedSocketOption` if
/// the host does not supports sockets listening on the same port.
pub fn setReusePort(self: Socket, enabled: bool) !void {
- if (comptime @hasDecl(os, "SO_REUSEPORT")) {
- return self.setOption(os.SOL_SOCKET, os.SO_REUSEPORT, mem.asBytes(&@as(u32, @boolToInt(enabled))));
+ if (@hasDecl(os.SO, "REUSEPORT")) {
+ return self.setOption(os.SOL.SOCKET, os.SO.REUSEPORT, mem.asBytes(&@as(u32, @boolToInt(enabled))));
}
return error.UnsupportedSocketOption;
}
/// Set the write buffer size of the socket.
pub fn setWriteBufferSize(self: Socket, size: u32) !void {
- return self.setOption(os.SOL_SOCKET, os.SO_SNDBUF, mem.asBytes(&size));
+ return self.setOption(os.SOL.SOCKET, os.SO.SNDBUF, mem.asBytes(&size));
}
/// Set the read buffer size of the socket.
pub fn setReadBufferSize(self: Socket, size: u32) !void {
- return self.setOption(os.SOL_SOCKET, os.SO_RCVBUF, mem.asBytes(&size));
+ return self.setOption(os.SOL.SOCKET, os.SO.RCVBUF, mem.asBytes(&size));
}
/// WARNING: Timeouts only affect blocking sockets. It is undefined behavior if a timeout is
@@ -253,7 +253,7 @@ pub fn Mixin(comptime Socket: type) type {
.tv_usec = @intCast(i32, (milliseconds % time.ms_per_s) * time.us_per_ms),
};
- return self.setOption(os.SOL_SOCKET, os.SO_SNDTIMEO, mem.asBytes(&timeout));
+ return self.setOption(os.SOL.SOCKET, os.SO.SNDTIMEO, mem.asBytes(&timeout));
}
/// WARNING: Timeouts only affect blocking sockets. It is undefined behavior if a timeout is
@@ -269,7 +269,7 @@ pub fn Mixin(comptime Socket: type) type {
.tv_usec = @intCast(i32, (milliseconds % time.ms_per_s) * time.us_per_ms),
};
- return self.setOption(os.SOL_SOCKET, os.SO_RCVTIMEO, mem.asBytes(&timeout));
+ return self.setOption(os.SOL.SOCKET, os.SO.RCVTIMEO, mem.asBytes(&timeout));
}
};
}
diff --git a/lib/std/x/os/socket_windows.zig b/lib/std/x/os/socket_windows.zig
index bcc722fcfe9c..178109dade12 100644
--- a/lib/std/x/os/socket_windows.zig
+++ b/lib/std/x/os/socket_windows.zig
@@ -399,39 +399,39 @@ pub fn Mixin(comptime Socket: type) type {
/// seconds.
pub fn setLinger(self: Socket, timeout_seconds: ?u16) !void {
const settings = Socket.Linger.init(timeout_seconds);
- return self.setOption(ws2_32.SOL_SOCKET, ws2_32.SO_LINGER, mem.asBytes(&settings));
+ return self.setOption(ws2_32.SOL.SOCKET, ws2_32.SO.LINGER, mem.asBytes(&settings));
}
/// On connection-oriented sockets, have keep-alive messages be sent periodically. The timing in which keep-alive
/// messages are sent are dependant on operating system settings. It returns `error.UnsupportedSocketOption` if
/// the host does not support periodically sending keep-alive messages on connection-oriented sockets.
pub fn setKeepAlive(self: Socket, enabled: bool) !void {
- return self.setOption(ws2_32.SOL_SOCKET, ws2_32.SO_KEEPALIVE, mem.asBytes(&@as(u32, @boolToInt(enabled))));
+ return self.setOption(ws2_32.SOL.SOCKET, ws2_32.SO.KEEPALIVE, mem.asBytes(&@as(u32, @boolToInt(enabled))));
}
/// Allow multiple sockets on the same host to listen on the same address. It returns `error.UnsupportedSocketOption` if
/// the host does not support sockets listening the same address.
pub fn setReuseAddress(self: Socket, enabled: bool) !void {
- return self.setOption(ws2_32.SOL_SOCKET, ws2_32.SO_REUSEADDR, mem.asBytes(&@as(u32, @boolToInt(enabled))));
+ return self.setOption(ws2_32.SOL.SOCKET, ws2_32.SO.REUSEADDR, mem.asBytes(&@as(u32, @boolToInt(enabled))));
}
/// Allow multiple sockets on the same host to listen on the same port. It returns `error.UnsupportedSocketOption` if
/// the host does not supports sockets listening on the same port.
///
- /// TODO: verify if this truly mimicks SO_REUSEPORT behavior, or if SO_REUSE_UNICASTPORT provides the correct behavior
+ /// TODO: verify if this truly mimicks SO.REUSEPORT behavior, or if SO.REUSE_UNICASTPORT provides the correct behavior
pub fn setReusePort(self: Socket, enabled: bool) !void {
- try self.setOption(ws2_32.SOL_SOCKET, ws2_32.SO_BROADCAST, mem.asBytes(&@as(u32, @boolToInt(enabled))));
+ try self.setOption(ws2_32.SOL.SOCKET, ws2_32.SO.BROADCAST, mem.asBytes(&@as(u32, @boolToInt(enabled))));
try self.setReuseAddress(enabled);
}
/// Set the write buffer size of the socket.
pub fn setWriteBufferSize(self: Socket, size: u32) !void {
- return self.setOption(ws2_32.SOL_SOCKET, ws2_32.SO_SNDBUF, mem.asBytes(&size));
+ return self.setOption(ws2_32.SOL.SOCKET, ws2_32.SO.SNDBUF, mem.asBytes(&size));
}
/// Set the read buffer size of the socket.
pub fn setReadBufferSize(self: Socket, size: u32) !void {
- return self.setOption(ws2_32.SOL_SOCKET, ws2_32.SO_RCVBUF, mem.asBytes(&size));
+ return self.setOption(ws2_32.SOL.SOCKET, ws2_32.SO.RCVBUF, mem.asBytes(&size));
}
/// WARNING: Timeouts only affect blocking sockets. It is undefined behavior if a timeout is
@@ -441,7 +441,7 @@ pub fn Mixin(comptime Socket: type) type {
/// to its bound destination after a specified number of milliseconds. A subsequent write
/// to the socket will thereafter return `error.WouldBlock` should the timeout be exceeded.
pub fn setWriteTimeout(self: Socket, milliseconds: u32) !void {
- return self.setOption(ws2_32.SOL_SOCKET, ws2_32.SO_SNDTIMEO, mem.asBytes(&milliseconds));
+ return self.setOption(ws2_32.SOL.SOCKET, ws2_32.SO.SNDTIMEO, mem.asBytes(&milliseconds));
}
/// WARNING: Timeouts only affect blocking sockets. It is undefined behavior if a timeout is
@@ -452,7 +452,7 @@ pub fn Mixin(comptime Socket: type) type {
/// read from the socket will thereafter return `error.WouldBlock` should the timeout be
/// exceeded.
pub fn setReadTimeout(self: Socket, milliseconds: u32) !void {
- return self.setOption(ws2_32.SOL_SOCKET, ws2_32.SO_RCVTIMEO, mem.asBytes(&milliseconds));
+ return self.setOption(ws2_32.SOL.SOCKET, ws2_32.SO.RCVTIMEO, mem.asBytes(&milliseconds));
}
};
}
diff --git a/lib/std/zig.zig b/lib/std/zig.zig
index 85ad4d2c81f3..8d51cd56f9a3 100644
--- a/lib/std/zig.zig
+++ b/lib/std/zig.zig
@@ -10,7 +10,7 @@ pub const fmtEscapes = fmt.fmtEscapes;
pub const isValidId = fmt.isValidId;
pub const parse = @import("zig/parse.zig").parse;
pub const string_literal = @import("zig/string_literal.zig");
-pub const ast = @import("zig/ast.zig");
+pub const Ast = @import("zig/Ast.zig");
pub const system = @import("zig/system.zig");
pub const CrossTarget = @import("zig/cross_target.zig").CrossTarget;
@@ -157,7 +157,6 @@ pub fn binNameAlloc(allocator: *std.mem.Allocator, options: BinNameOptions) erro
}
},
}
- return std.fmt.allocPrint(allocator, "{s}{s}{s}", .{ target.libPrefix(), root_name, suffix });
},
.Obj => return std.fmt.allocPrint(allocator, "{s}.o", .{root_name}),
},
diff --git a/lib/std/zig/Ast.zig b/lib/std/zig/Ast.zig
new file mode 100644
index 000000000000..35e75f4db28e
--- /dev/null
+++ b/lib/std/zig/Ast.zig
@@ -0,0 +1,2979 @@
+//! Abstract Syntax Tree for Zig source code.
+
+/// Reference to externally-owned data.
+source: [:0]const u8,
+
+tokens: TokenList.Slice,
+/// The root AST node is assumed to be index 0. Since there can be no
+/// references to the root node, this means 0 is available to indicate null.
+nodes: NodeList.Slice,
+extra_data: []Node.Index,
+
+errors: []const Error,
+
+const std = @import("../std.zig");
+const assert = std.debug.assert;
+const testing = std.testing;
+const mem = std.mem;
+const Token = std.zig.Token;
+const Tree = @This();
+
+pub const TokenIndex = u32;
+pub const ByteOffset = u32;
+
+pub const TokenList = std.MultiArrayList(struct {
+ tag: Token.Tag,
+ start: ByteOffset,
+});
+pub const NodeList = std.MultiArrayList(Node);
+
+pub const Location = struct {
+ line: usize,
+ column: usize,
+ line_start: usize,
+ line_end: usize,
+};
+
+pub fn deinit(tree: *Tree, gpa: *mem.Allocator) void {
+ tree.tokens.deinit(gpa);
+ tree.nodes.deinit(gpa);
+ gpa.free(tree.extra_data);
+ gpa.free(tree.errors);
+ tree.* = undefined;
+}
+
+pub const RenderError = error{
+ /// Ran out of memory allocating call stack frames to complete rendering, or
+ /// ran out of memory allocating space in the output buffer.
+ OutOfMemory,
+};
+
+/// `gpa` is used for allocating the resulting formatted source code, as well as
+/// for allocating extra stack memory if needed, because this function utilizes recursion.
+/// Note: that's not actually true yet, see https://github.com/ziglang/zig/issues/1006.
+/// Caller owns the returned slice of bytes, allocated with `gpa`.
+pub fn render(tree: Tree, gpa: *mem.Allocator) RenderError![]u8 {
+ var buffer = std.ArrayList(u8).init(gpa);
+ defer buffer.deinit();
+
+ try tree.renderToArrayList(&buffer);
+ return buffer.toOwnedSlice();
+}
+
+pub fn renderToArrayList(tree: Tree, buffer: *std.ArrayList(u8)) RenderError!void {
+ return @import("./render.zig").renderTree(buffer, tree);
+}
+
+pub fn tokenLocation(self: Tree, start_offset: ByteOffset, token_index: TokenIndex) Location {
+ var loc = Location{
+ .line = 0,
+ .column = 0,
+ .line_start = start_offset,
+ .line_end = self.source.len,
+ };
+ const token_start = self.tokens.items(.start)[token_index];
+ for (self.source[start_offset..]) |c, i| {
+ if (i + start_offset == token_start) {
+ loc.line_end = i + start_offset;
+ while (loc.line_end < self.source.len and self.source[loc.line_end] != '\n') {
+ loc.line_end += 1;
+ }
+ return loc;
+ }
+ if (c == '\n') {
+ loc.line += 1;
+ loc.column = 0;
+ loc.line_start = i + 1;
+ } else {
+ loc.column += 1;
+ }
+ }
+ return loc;
+}
+
+pub fn tokenSlice(tree: Tree, token_index: TokenIndex) []const u8 {
+ const token_starts = tree.tokens.items(.start);
+ const token_tags = tree.tokens.items(.tag);
+ const token_tag = token_tags[token_index];
+
+ // Many tokens can be determined entirely by their tag.
+ if (token_tag.lexeme()) |lexeme| {
+ return lexeme;
+ }
+
+ // For some tokens, re-tokenization is needed to find the end.
+ var tokenizer: std.zig.Tokenizer = .{
+ .buffer = tree.source,
+ .index = token_starts[token_index],
+ .pending_invalid_token = null,
+ };
+ const token = tokenizer.next();
+ assert(token.tag == token_tag);
+ return tree.source[token.loc.start..token.loc.end];
+}
+
+pub fn extraData(tree: Tree, index: usize, comptime T: type) T {
+ const fields = std.meta.fields(T);
+ var result: T = undefined;
+ inline for (fields) |field, i| {
+ comptime assert(field.field_type == Node.Index);
+ @field(result, field.name) = tree.extra_data[index + i];
+ }
+ return result;
+}
+
+pub fn rootDecls(tree: Tree) []const Node.Index {
+ // Root is always index 0.
+ const nodes_data = tree.nodes.items(.data);
+ return tree.extra_data[nodes_data[0].lhs..nodes_data[0].rhs];
+}
+
+pub fn renderError(tree: Tree, parse_error: Error, stream: anytype) !void {
+ const token_tags = tree.tokens.items(.tag);
+ switch (parse_error.tag) {
+ .asterisk_after_ptr_deref => {
+ // Note that the token will point at the `.*` but ideally the source
+ // location would point to the `*` after the `.*`.
+ return stream.writeAll("'.*' cannot be followed by '*'. Are you missing a space?");
+ },
+ .decl_between_fields => {
+ return stream.writeAll("declarations are not allowed between container fields");
+ },
+ .expected_block => {
+ return stream.print("expected block or field, found '{s}'", .{
+ token_tags[parse_error.token].symbol(),
+ });
+ },
+ .expected_block_or_assignment => {
+ return stream.print("expected block or assignment, found '{s}'", .{
+ token_tags[parse_error.token].symbol(),
+ });
+ },
+ .expected_block_or_expr => {
+ return stream.print("expected block or expression, found '{s}'", .{
+ token_tags[parse_error.token].symbol(),
+ });
+ },
+ .expected_block_or_field => {
+ return stream.print("expected block or field, found '{s}'", .{
+ token_tags[parse_error.token].symbol(),
+ });
+ },
+ .expected_container_members => {
+ return stream.print("expected test, comptime, var decl, or container field, found '{s}'", .{
+ token_tags[parse_error.token].symbol(),
+ });
+ },
+ .expected_expr => {
+ return stream.print("expected expression, found '{s}'", .{
+ token_tags[parse_error.token].symbol(),
+ });
+ },
+ .expected_expr_or_assignment => {
+ return stream.print("expected expression or assignment, found '{s}'", .{
+ token_tags[parse_error.token].symbol(),
+ });
+ },
+ .expected_fn => {
+ return stream.print("expected function, found '{s}'", .{
+ token_tags[parse_error.token].symbol(),
+ });
+ },
+ .expected_inlinable => {
+ return stream.print("expected 'while' or 'for', found '{s}'", .{
+ token_tags[parse_error.token].symbol(),
+ });
+ },
+ .expected_labelable => {
+ return stream.print("expected 'while', 'for', 'inline', 'suspend', or '{{', found '{s}'", .{
+ token_tags[parse_error.token].symbol(),
+ });
+ },
+ .expected_param_list => {
+ return stream.print("expected parameter list, found '{s}'", .{
+ token_tags[parse_error.token].symbol(),
+ });
+ },
+ .expected_prefix_expr => {
+ return stream.print("expected prefix expression, found '{s}'", .{
+ token_tags[parse_error.token].symbol(),
+ });
+ },
+ .expected_primary_type_expr => {
+ return stream.print("expected primary type expression, found '{s}'", .{
+ token_tags[parse_error.token].symbol(),
+ });
+ },
+ .expected_pub_item => {
+ return stream.writeAll("expected function or variable declaration after pub");
+ },
+ .expected_return_type => {
+ return stream.print("expected return type expression, found '{s}'", .{
+ token_tags[parse_error.token].symbol(),
+ });
+ },
+ .expected_semi_or_else => {
+ return stream.print("expected ';' or 'else', found '{s}'", .{
+ token_tags[parse_error.token].symbol(),
+ });
+ },
+ .expected_semi_or_lbrace => {
+ return stream.print("expected ';' or '{{', found '{s}'", .{
+ token_tags[parse_error.token].symbol(),
+ });
+ },
+ .expected_statement => {
+ return stream.print("expected statement, found '{s}'", .{
+ token_tags[parse_error.token].symbol(),
+ });
+ },
+ .expected_string_literal => {
+ return stream.print("expected string literal, found '{s}'", .{
+ token_tags[parse_error.token].symbol(),
+ });
+ },
+ .expected_suffix_op => {
+ return stream.print("expected pointer dereference, optional unwrap, or field access, found '{s}'", .{
+ token_tags[parse_error.token].symbol(),
+ });
+ },
+ .expected_type_expr => {
+ return stream.print("expected type expression, found '{s}'", .{
+ token_tags[parse_error.token].symbol(),
+ });
+ },
+ .expected_var_decl => {
+ return stream.print("expected variable declaration, found '{s}'", .{
+ token_tags[parse_error.token].symbol(),
+ });
+ },
+ .expected_var_decl_or_fn => {
+ return stream.print("expected variable declaration or function, found '{s}'", .{
+ token_tags[parse_error.token].symbol(),
+ });
+ },
+ .expected_loop_payload => {
+ return stream.print("expected loop payload, found '{s}'", .{
+ token_tags[parse_error.token].symbol(),
+ });
+ },
+ .expected_container => {
+ return stream.print("expected a struct, enum or union, found '{s}'", .{
+ token_tags[parse_error.token].symbol(),
+ });
+ },
+ .extra_align_qualifier => {
+ return stream.writeAll("extra align qualifier");
+ },
+ .extra_allowzero_qualifier => {
+ return stream.writeAll("extra allowzero qualifier");
+ },
+ .extra_const_qualifier => {
+ return stream.writeAll("extra const qualifier");
+ },
+ .extra_volatile_qualifier => {
+ return stream.writeAll("extra volatile qualifier");
+ },
+ .ptr_mod_on_array_child_type => {
+ return stream.print("pointer modifier '{s}' not allowed on array child type", .{
+ token_tags[parse_error.token].symbol(),
+ });
+ },
+ .invalid_bit_range => {
+ return stream.writeAll("bit range not allowed on slices and arrays");
+ },
+ .invalid_token => {
+ return stream.print("invalid token: '{s}'", .{
+ token_tags[parse_error.token].symbol(),
+ });
+ },
+ .same_line_doc_comment => {
+ return stream.writeAll("same line documentation comment");
+ },
+ .unattached_doc_comment => {
+ return stream.writeAll("unattached documentation comment");
+ },
+ .varargs_nonfinal => {
+ return stream.writeAll("function prototype has parameter after varargs");
+ },
+
+ .expected_token => {
+ const found_tag = token_tags[parse_error.token];
+ const expected_symbol = parse_error.extra.expected_tag.symbol();
+ switch (found_tag) {
+ .invalid => return stream.print("expected '{s}', found invalid bytes", .{
+ expected_symbol,
+ }),
+ else => return stream.print("expected '{s}', found '{s}'", .{
+ expected_symbol, found_tag.symbol(),
+ }),
+ }
+ },
+ }
+}
+
+pub fn firstToken(tree: Tree, node: Node.Index) TokenIndex {
+ const tags = tree.nodes.items(.tag);
+ const datas = tree.nodes.items(.data);
+ const main_tokens = tree.nodes.items(.main_token);
+ const token_tags = tree.tokens.items(.tag);
+ var end_offset: TokenIndex = 0;
+ var n = node;
+ while (true) switch (tags[n]) {
+ .root => return 0,
+
+ .test_decl,
+ .@"errdefer",
+ .@"defer",
+ .bool_not,
+ .negation,
+ .bit_not,
+ .negation_wrap,
+ .address_of,
+ .@"try",
+ .@"await",
+ .optional_type,
+ .@"switch",
+ .switch_comma,
+ .if_simple,
+ .@"if",
+ .@"suspend",
+ .@"resume",
+ .@"continue",
+ .@"break",
+ .@"return",
+ .anyframe_type,
+ .identifier,
+ .anyframe_literal,
+ .char_literal,
+ .integer_literal,
+ .float_literal,
+ .unreachable_literal,
+ .string_literal,
+ .multiline_string_literal,
+ .grouped_expression,
+ .builtin_call_two,
+ .builtin_call_two_comma,
+ .builtin_call,
+ .builtin_call_comma,
+ .error_set_decl,
+ .@"anytype",
+ .@"comptime",
+ .@"nosuspend",
+ .asm_simple,
+ .@"asm",
+ .array_type,
+ .array_type_sentinel,
+ .error_value,
+ => return main_tokens[n] - end_offset,
+
+ .array_init_dot,
+ .array_init_dot_comma,
+ .array_init_dot_two,
+ .array_init_dot_two_comma,
+ .struct_init_dot,
+ .struct_init_dot_comma,
+ .struct_init_dot_two,
+ .struct_init_dot_two_comma,
+ .enum_literal,
+ => return main_tokens[n] - 1 - end_offset,
+
+ .@"catch",
+ .field_access,
+ .unwrap_optional,
+ .equal_equal,
+ .bang_equal,
+ .less_than,
+ .greater_than,
+ .less_or_equal,
+ .greater_or_equal,
+ .assign_mul,
+ .assign_div,
+ .assign_mod,
+ .assign_add,
+ .assign_sub,
+ .assign_bit_shift_left,
+ .assign_bit_shift_right,
+ .assign_bit_and,
+ .assign_bit_xor,
+ .assign_bit_or,
+ .assign_mul_wrap,
+ .assign_add_wrap,
+ .assign_sub_wrap,
+ .assign,
+ .merge_error_sets,
+ .mul,
+ .div,
+ .mod,
+ .array_mult,
+ .mul_wrap,
+ .add,
+ .sub,
+ .array_cat,
+ .add_wrap,
+ .sub_wrap,
+ .bit_shift_left,
+ .bit_shift_right,
+ .bit_and,
+ .bit_xor,
+ .bit_or,
+ .@"orelse",
+ .bool_and,
+ .bool_or,
+ .slice_open,
+ .slice,
+ .slice_sentinel,
+ .deref,
+ .array_access,
+ .array_init_one,
+ .array_init_one_comma,
+ .array_init,
+ .array_init_comma,
+ .struct_init_one,
+ .struct_init_one_comma,
+ .struct_init,
+ .struct_init_comma,
+ .call_one,
+ .call_one_comma,
+ .call,
+ .call_comma,
+ .switch_range,
+ .error_union,
+ => n = datas[n].lhs,
+
+ .fn_decl,
+ .fn_proto_simple,
+ .fn_proto_multi,
+ .fn_proto_one,
+ .fn_proto,
+ => {
+ var i = main_tokens[n]; // fn token
+ while (i > 0) {
+ i -= 1;
+ switch (token_tags[i]) {
+ .keyword_extern,
+ .keyword_export,
+ .keyword_pub,
+ .keyword_inline,
+ .keyword_noinline,
+ .string_literal,
+ => continue,
+
+ else => return i + 1 - end_offset,
+ }
+ }
+ return i - end_offset;
+ },
+
+ .@"usingnamespace" => {
+ const main_token = main_tokens[n];
+ if (main_token > 0 and token_tags[main_token - 1] == .keyword_pub) {
+ end_offset += 1;
+ }
+ return main_token - end_offset;
+ },
+
+ .async_call_one,
+ .async_call_one_comma,
+ .async_call,
+ .async_call_comma,
+ => {
+ end_offset += 1; // async token
+ n = datas[n].lhs;
+ },
+
+ .container_field_init,
+ .container_field_align,
+ .container_field,
+ => {
+ const name_token = main_tokens[n];
+ if (name_token > 0 and token_tags[name_token - 1] == .keyword_comptime) {
+ end_offset += 1;
+ }
+ return name_token - end_offset;
+ },
+
+ .global_var_decl,
+ .local_var_decl,
+ .simple_var_decl,
+ .aligned_var_decl,
+ => {
+ var i = main_tokens[n]; // mut token
+ while (i > 0) {
+ i -= 1;
+ switch (token_tags[i]) {
+ .keyword_extern,
+ .keyword_export,
+ .keyword_comptime,
+ .keyword_pub,
+ .keyword_threadlocal,
+ .string_literal,
+ => continue,
+
+ else => return i + 1 - end_offset,
+ }
+ }
+ return i - end_offset;
+ },
+
+ .block,
+ .block_semicolon,
+ .block_two,
+ .block_two_semicolon,
+ => {
+ // Look for a label.
+ const lbrace = main_tokens[n];
+ if (token_tags[lbrace - 1] == .colon and
+ token_tags[lbrace - 2] == .identifier)
+ {
+ end_offset += 2;
+ }
+ return lbrace - end_offset;
+ },
+
+ .container_decl,
+ .container_decl_trailing,
+ .container_decl_two,
+ .container_decl_two_trailing,
+ .container_decl_arg,
+ .container_decl_arg_trailing,
+ .tagged_union,
+ .tagged_union_trailing,
+ .tagged_union_two,
+ .tagged_union_two_trailing,
+ .tagged_union_enum_tag,
+ .tagged_union_enum_tag_trailing,
+ => {
+ const main_token = main_tokens[n];
+ switch (token_tags[main_token - 1]) {
+ .keyword_packed, .keyword_extern => end_offset += 1,
+ else => {},
+ }
+ return main_token - end_offset;
+ },
+
+ .ptr_type_aligned,
+ .ptr_type_sentinel,
+ .ptr_type,
+ .ptr_type_bit_range,
+ => {
+ const main_token = main_tokens[n];
+ return switch (token_tags[main_token]) {
+ .asterisk,
+ .asterisk_asterisk,
+ => switch (token_tags[main_token - 1]) {
+ .l_bracket => main_token - 1,
+ else => main_token,
+ },
+ .l_bracket => main_token,
+ else => unreachable,
+ } - end_offset;
+ },
+
+ .switch_case_one => {
+ if (datas[n].lhs == 0) {
+ return main_tokens[n] - 1 - end_offset; // else token
+ } else {
+ n = datas[n].lhs;
+ }
+ },
+ .switch_case => {
+ const extra = tree.extraData(datas[n].lhs, Node.SubRange);
+ assert(extra.end - extra.start > 0);
+ n = tree.extra_data[extra.start];
+ },
+
+ .asm_output, .asm_input => {
+ assert(token_tags[main_tokens[n] - 1] == .l_bracket);
+ return main_tokens[n] - 1 - end_offset;
+ },
+
+ .while_simple,
+ .while_cont,
+ .@"while",
+ .for_simple,
+ .@"for",
+ => {
+ // Look for a label and inline.
+ const main_token = main_tokens[n];
+ var result = main_token;
+ if (token_tags[result - 1] == .keyword_inline) {
+ result -= 1;
+ }
+ if (token_tags[result - 1] == .colon) {
+ result -= 2;
+ }
+ return result - end_offset;
+ },
+ };
+}
+
+pub fn lastToken(tree: Tree, node: Node.Index) TokenIndex {
+ const tags = tree.nodes.items(.tag);
+ const datas = tree.nodes.items(.data);
+ const main_tokens = tree.nodes.items(.main_token);
+ const token_starts = tree.tokens.items(.start);
+ const token_tags = tree.tokens.items(.tag);
+ var n = node;
+ var end_offset: TokenIndex = 0;
+ while (true) switch (tags[n]) {
+ .root => return @intCast(TokenIndex, tree.tokens.len - 1),
+
+ .@"usingnamespace",
+ .bool_not,
+ .negation,
+ .bit_not,
+ .negation_wrap,
+ .address_of,
+ .@"try",
+ .@"await",
+ .optional_type,
+ .@"resume",
+ .@"nosuspend",
+ .@"comptime",
+ => n = datas[n].lhs,
+
+ .test_decl,
+ .@"errdefer",
+ .@"defer",
+ .@"catch",
+ .equal_equal,
+ .bang_equal,
+ .less_than,
+ .greater_than,
+ .less_or_equal,
+ .greater_or_equal,
+ .assign_mul,
+ .assign_div,
+ .assign_mod,
+ .assign_add,
+ .assign_sub,
+ .assign_bit_shift_left,
+ .assign_bit_shift_right,
+ .assign_bit_and,
+ .assign_bit_xor,
+ .assign_bit_or,
+ .assign_mul_wrap,
+ .assign_add_wrap,
+ .assign_sub_wrap,
+ .assign,
+ .merge_error_sets,
+ .mul,
+ .div,
+ .mod,
+ .array_mult,
+ .mul_wrap,
+ .add,
+ .sub,
+ .array_cat,
+ .add_wrap,
+ .sub_wrap,
+ .bit_shift_left,
+ .bit_shift_right,
+ .bit_and,
+ .bit_xor,
+ .bit_or,
+ .@"orelse",
+ .bool_and,
+ .bool_or,
+ .anyframe_type,
+ .error_union,
+ .if_simple,
+ .while_simple,
+ .for_simple,
+ .fn_proto_simple,
+ .fn_proto_multi,
+ .ptr_type_aligned,
+ .ptr_type_sentinel,
+ .ptr_type,
+ .ptr_type_bit_range,
+ .array_type,
+ .switch_case_one,
+ .switch_case,
+ .switch_range,
+ => n = datas[n].rhs,
+
+ .field_access,
+ .unwrap_optional,
+ .grouped_expression,
+ .multiline_string_literal,
+ .error_set_decl,
+ .asm_simple,
+ .asm_output,
+ .asm_input,
+ .error_value,
+ => return datas[n].rhs + end_offset,
+
+ .@"anytype",
+ .anyframe_literal,
+ .char_literal,
+ .integer_literal,
+ .float_literal,
+ .unreachable_literal,
+ .identifier,
+ .deref,
+ .enum_literal,
+ .string_literal,
+ => return main_tokens[n] + end_offset,
+
+ .@"return" => if (datas[n].lhs != 0) {
+ n = datas[n].lhs;
+ } else {
+ return main_tokens[n] + end_offset;
+ },
+
+ .call, .async_call => {
+ end_offset += 1; // for the rparen
+ const params = tree.extraData(datas[n].rhs, Node.SubRange);
+ if (params.end - params.start == 0) {
+ return main_tokens[n] + end_offset;
+ }
+ n = tree.extra_data[params.end - 1]; // last parameter
+ },
+ .tagged_union_enum_tag => {
+ const members = tree.extraData(datas[n].rhs, Node.SubRange);
+ if (members.end - members.start == 0) {
+ end_offset += 4; // for the rparen + rparen + lbrace + rbrace
+ n = datas[n].lhs;
+ } else {
+ end_offset += 1; // for the rbrace
+ n = tree.extra_data[members.end - 1]; // last parameter
+ }
+ },
+ .call_comma,
+ .async_call_comma,
+ .tagged_union_enum_tag_trailing,
+ => {
+ end_offset += 2; // for the comma/semicolon + rparen/rbrace
+ const params = tree.extraData(datas[n].rhs, Node.SubRange);
+ assert(params.end > params.start);
+ n = tree.extra_data[params.end - 1]; // last parameter
+ },
+ .@"switch" => {
+ const cases = tree.extraData(datas[n].rhs, Node.SubRange);
+ if (cases.end - cases.start == 0) {
+ end_offset += 3; // rparen, lbrace, rbrace
+ n = datas[n].lhs; // condition expression
+ } else {
+ end_offset += 1; // for the rbrace
+ n = tree.extra_data[cases.end - 1]; // last case
+ }
+ },
+ .container_decl_arg => {
+ const members = tree.extraData(datas[n].rhs, Node.SubRange);
+ if (members.end - members.start == 0) {
+ end_offset += 3; // for the rparen + lbrace + rbrace
+ n = datas[n].lhs;
+ } else {
+ end_offset += 1; // for the rbrace
+ n = tree.extra_data[members.end - 1]; // last parameter
+ }
+ },
+ .@"asm" => {
+ const extra = tree.extraData(datas[n].rhs, Node.Asm);
+ return extra.rparen + end_offset;
+ },
+ .array_init,
+ .struct_init,
+ => {
+ const elements = tree.extraData(datas[n].rhs, Node.SubRange);
+ assert(elements.end - elements.start > 0);
+ end_offset += 1; // for the rbrace
+ n = tree.extra_data[elements.end - 1]; // last element
+ },
+ .array_init_comma,
+ .struct_init_comma,
+ .container_decl_arg_trailing,
+ .switch_comma,
+ => {
+ const members = tree.extraData(datas[n].rhs, Node.SubRange);
+ assert(members.end - members.start > 0);
+ end_offset += 2; // for the comma + rbrace
+ n = tree.extra_data[members.end - 1]; // last parameter
+ },
+ .array_init_dot,
+ .struct_init_dot,
+ .block,
+ .container_decl,
+ .tagged_union,
+ .builtin_call,
+ => {
+ assert(datas[n].rhs - datas[n].lhs > 0);
+ end_offset += 1; // for the rbrace
+ n = tree.extra_data[datas[n].rhs - 1]; // last statement
+ },
+ .array_init_dot_comma,
+ .struct_init_dot_comma,
+ .block_semicolon,
+ .container_decl_trailing,
+ .tagged_union_trailing,
+ .builtin_call_comma,
+ => {
+ assert(datas[n].rhs - datas[n].lhs > 0);
+ end_offset += 2; // for the comma/semicolon + rbrace/rparen
+ n = tree.extra_data[datas[n].rhs - 1]; // last member
+ },
+ .call_one,
+ .async_call_one,
+ .array_access,
+ => {
+ end_offset += 1; // for the rparen/rbracket
+ if (datas[n].rhs == 0) {
+ return main_tokens[n] + end_offset;
+ }
+ n = datas[n].rhs;
+ },
+ .array_init_dot_two,
+ .block_two,
+ .builtin_call_two,
+ .struct_init_dot_two,
+ .container_decl_two,
+ .tagged_union_two,
+ => {
+ if (datas[n].rhs != 0) {
+ end_offset += 1; // for the rparen/rbrace
+ n = datas[n].rhs;
+ } else if (datas[n].lhs != 0) {
+ end_offset += 1; // for the rparen/rbrace
+ n = datas[n].lhs;
+ } else {
+ switch (tags[n]) {
+ .array_init_dot_two,
+ .block_two,
+ .struct_init_dot_two,
+ => end_offset += 1, // rbrace
+ .builtin_call_two => end_offset += 2, // lparen/lbrace + rparen/rbrace
+ .container_decl_two => {
+ var i: u32 = 2; // lbrace + rbrace
+ while (token_tags[main_tokens[n] + i] == .container_doc_comment) i += 1;
+ end_offset += i;
+ },
+ .tagged_union_two => {
+ var i: u32 = 5; // (enum) {}
+ while (token_tags[main_tokens[n] + i] == .container_doc_comment) i += 1;
+ end_offset += i;
+ },
+ else => unreachable,
+ }
+ return main_tokens[n] + end_offset;
+ }
+ },
+ .array_init_dot_two_comma,
+ .builtin_call_two_comma,
+ .block_two_semicolon,
+ .struct_init_dot_two_comma,
+ .container_decl_two_trailing,
+ .tagged_union_two_trailing,
+ => {
+ end_offset += 2; // for the comma/semicolon + rbrace/rparen
+ if (datas[n].rhs != 0) {
+ n = datas[n].rhs;
+ } else if (datas[n].lhs != 0) {
+ n = datas[n].lhs;
+ } else {
+ unreachable;
+ }
+ },
+ .simple_var_decl => {
+ if (datas[n].rhs != 0) {
+ n = datas[n].rhs;
+ } else if (datas[n].lhs != 0) {
+ n = datas[n].lhs;
+ } else {
+ end_offset += 1; // from mut token to name
+ return main_tokens[n] + end_offset;
+ }
+ },
+ .aligned_var_decl => {
+ if (datas[n].rhs != 0) {
+ n = datas[n].rhs;
+ } else if (datas[n].lhs != 0) {
+ end_offset += 1; // for the rparen
+ n = datas[n].lhs;
+ } else {
+ end_offset += 1; // from mut token to name
+ return main_tokens[n] + end_offset;
+ }
+ },
+ .global_var_decl => {
+ if (datas[n].rhs != 0) {
+ n = datas[n].rhs;
+ } else {
+ const extra = tree.extraData(datas[n].lhs, Node.GlobalVarDecl);
+ if (extra.section_node != 0) {
+ end_offset += 1; // for the rparen
+ n = extra.section_node;
+ } else if (extra.align_node != 0) {
+ end_offset += 1; // for the rparen
+ n = extra.align_node;
+ } else if (extra.type_node != 0) {
+ n = extra.type_node;
+ } else {
+ end_offset += 1; // from mut token to name
+ return main_tokens[n] + end_offset;
+ }
+ }
+ },
+ .local_var_decl => {
+ if (datas[n].rhs != 0) {
+ n = datas[n].rhs;
+ } else {
+ const extra = tree.extraData(datas[n].lhs, Node.LocalVarDecl);
+ if (extra.align_node != 0) {
+ end_offset += 1; // for the rparen
+ n = extra.align_node;
+ } else if (extra.type_node != 0) {
+ n = extra.type_node;
+ } else {
+ end_offset += 1; // from mut token to name
+ return main_tokens[n] + end_offset;
+ }
+ }
+ },
+ .container_field_init => {
+ if (datas[n].rhs != 0) {
+ n = datas[n].rhs;
+ } else if (datas[n].lhs != 0) {
+ n = datas[n].lhs;
+ } else {
+ return main_tokens[n] + end_offset;
+ }
+ },
+ .container_field_align => {
+ if (datas[n].rhs != 0) {
+ end_offset += 1; // for the rparen
+ n = datas[n].rhs;
+ } else if (datas[n].lhs != 0) {
+ n = datas[n].lhs;
+ } else {
+ return main_tokens[n] + end_offset;
+ }
+ },
+ .container_field => {
+ const extra = tree.extraData(datas[n].rhs, Node.ContainerField);
+ if (extra.value_expr != 0) {
+ n = extra.value_expr;
+ } else if (extra.align_expr != 0) {
+ end_offset += 1; // for the rparen
+ n = extra.align_expr;
+ } else if (datas[n].lhs != 0) {
+ n = datas[n].lhs;
+ } else {
+ return main_tokens[n] + end_offset;
+ }
+ },
+
+ .array_init_one,
+ .struct_init_one,
+ => {
+ end_offset += 1; // rbrace
+ if (datas[n].rhs == 0) {
+ return main_tokens[n] + end_offset;
+ } else {
+ n = datas[n].rhs;
+ }
+ },
+ .slice_open,
+ .call_one_comma,
+ .async_call_one_comma,
+ .array_init_one_comma,
+ .struct_init_one_comma,
+ => {
+ end_offset += 2; // ellipsis2 + rbracket, or comma + rparen
+ n = datas[n].rhs;
+ assert(n != 0);
+ },
+ .slice => {
+ const extra = tree.extraData(datas[n].rhs, Node.Slice);
+ assert(extra.end != 0); // should have used slice_open
+ end_offset += 1; // rbracket
+ n = extra.end;
+ },
+ .slice_sentinel => {
+ const extra = tree.extraData(datas[n].rhs, Node.SliceSentinel);
+ assert(extra.sentinel != 0); // should have used slice
+ end_offset += 1; // rbracket
+ n = extra.sentinel;
+ },
+
+ .@"continue" => {
+ if (datas[n].lhs != 0) {
+ return datas[n].lhs + end_offset;
+ } else {
+ return main_tokens[n] + end_offset;
+ }
+ },
+ .@"break" => {
+ if (datas[n].rhs != 0) {
+ n = datas[n].rhs;
+ } else if (datas[n].lhs != 0) {
+ return datas[n].lhs + end_offset;
+ } else {
+ return main_tokens[n] + end_offset;
+ }
+ },
+ .fn_decl => {
+ if (datas[n].rhs != 0) {
+ n = datas[n].rhs;
+ } else {
+ n = datas[n].lhs;
+ }
+ },
+ .fn_proto_one => {
+ const extra = tree.extraData(datas[n].lhs, Node.FnProtoOne);
+ // linksection, callconv, align can appear in any order, so we
+ // find the last one here.
+ var max_node: Node.Index = datas[n].rhs;
+ var max_start = token_starts[main_tokens[max_node]];
+ var max_offset: TokenIndex = 0;
+ if (extra.align_expr != 0) {
+ const start = token_starts[main_tokens[extra.align_expr]];
+ if (start > max_start) {
+ max_node = extra.align_expr;
+ max_start = start;
+ max_offset = 1; // for the rparen
+ }
+ }
+ if (extra.section_expr != 0) {
+ const start = token_starts[main_tokens[extra.section_expr]];
+ if (start > max_start) {
+ max_node = extra.section_expr;
+ max_start = start;
+ max_offset = 1; // for the rparen
+ }
+ }
+ if (extra.callconv_expr != 0) {
+ const start = token_starts[main_tokens[extra.callconv_expr]];
+ if (start > max_start) {
+ max_node = extra.callconv_expr;
+ max_start = start;
+ max_offset = 1; // for the rparen
+ }
+ }
+ n = max_node;
+ end_offset += max_offset;
+ },
+ .fn_proto => {
+ const extra = tree.extraData(datas[n].lhs, Node.FnProto);
+ // linksection, callconv, align can appear in any order, so we
+ // find the last one here.
+ var max_node: Node.Index = datas[n].rhs;
+ var max_start = token_starts[main_tokens[max_node]];
+ var max_offset: TokenIndex = 0;
+ if (extra.align_expr != 0) {
+ const start = token_starts[main_tokens[extra.align_expr]];
+ if (start > max_start) {
+ max_node = extra.align_expr;
+ max_start = start;
+ max_offset = 1; // for the rparen
+ }
+ }
+ if (extra.section_expr != 0) {
+ const start = token_starts[main_tokens[extra.section_expr]];
+ if (start > max_start) {
+ max_node = extra.section_expr;
+ max_start = start;
+ max_offset = 1; // for the rparen
+ }
+ }
+ if (extra.callconv_expr != 0) {
+ const start = token_starts[main_tokens[extra.callconv_expr]];
+ if (start > max_start) {
+ max_node = extra.callconv_expr;
+ max_start = start;
+ max_offset = 1; // for the rparen
+ }
+ }
+ n = max_node;
+ end_offset += max_offset;
+ },
+ .while_cont => {
+ const extra = tree.extraData(datas[n].rhs, Node.WhileCont);
+ assert(extra.then_expr != 0);
+ n = extra.then_expr;
+ },
+ .@"while" => {
+ const extra = tree.extraData(datas[n].rhs, Node.While);
+ assert(extra.else_expr != 0);
+ n = extra.else_expr;
+ },
+ .@"if", .@"for" => {
+ const extra = tree.extraData(datas[n].rhs, Node.If);
+ assert(extra.else_expr != 0);
+ n = extra.else_expr;
+ },
+ .@"suspend" => {
+ if (datas[n].lhs != 0) {
+ n = datas[n].lhs;
+ } else {
+ return main_tokens[n] + end_offset;
+ }
+ },
+ .array_type_sentinel => {
+ const extra = tree.extraData(datas[n].rhs, Node.ArrayTypeSentinel);
+ n = extra.elem_type;
+ },
+ };
+}
+
+pub fn tokensOnSameLine(tree: Tree, token1: TokenIndex, token2: TokenIndex) bool {
+ const token_starts = tree.tokens.items(.start);
+ const source = tree.source[token_starts[token1]..token_starts[token2]];
+ return mem.indexOfScalar(u8, source, '\n') == null;
+}
+
+pub fn getNodeSource(tree: Tree, node: Node.Index) []const u8 {
+ const token_starts = tree.tokens.items(.start);
+ const first_token = tree.firstToken(node);
+ const last_token = tree.lastToken(node);
+ const start = token_starts[first_token];
+ const end = token_starts[last_token] + tree.tokenSlice(last_token).len;
+ return tree.source[start..end];
+}
+
+pub fn globalVarDecl(tree: Tree, node: Node.Index) full.VarDecl {
+ assert(tree.nodes.items(.tag)[node] == .global_var_decl);
+ const data = tree.nodes.items(.data)[node];
+ const extra = tree.extraData(data.lhs, Node.GlobalVarDecl);
+ return tree.fullVarDecl(.{
+ .type_node = extra.type_node,
+ .align_node = extra.align_node,
+ .section_node = extra.section_node,
+ .init_node = data.rhs,
+ .mut_token = tree.nodes.items(.main_token)[node],
+ });
+}
+
+pub fn localVarDecl(tree: Tree, node: Node.Index) full.VarDecl {
+ assert(tree.nodes.items(.tag)[node] == .local_var_decl);
+ const data = tree.nodes.items(.data)[node];
+ const extra = tree.extraData(data.lhs, Node.LocalVarDecl);
+ return tree.fullVarDecl(.{
+ .type_node = extra.type_node,
+ .align_node = extra.align_node,
+ .section_node = 0,
+ .init_node = data.rhs,
+ .mut_token = tree.nodes.items(.main_token)[node],
+ });
+}
+
+pub fn simpleVarDecl(tree: Tree, node: Node.Index) full.VarDecl {
+ assert(tree.nodes.items(.tag)[node] == .simple_var_decl);
+ const data = tree.nodes.items(.data)[node];
+ return tree.fullVarDecl(.{
+ .type_node = data.lhs,
+ .align_node = 0,
+ .section_node = 0,
+ .init_node = data.rhs,
+ .mut_token = tree.nodes.items(.main_token)[node],
+ });
+}
+
+pub fn alignedVarDecl(tree: Tree, node: Node.Index) full.VarDecl {
+ assert(tree.nodes.items(.tag)[node] == .aligned_var_decl);
+ const data = tree.nodes.items(.data)[node];
+ return tree.fullVarDecl(.{
+ .type_node = 0,
+ .align_node = data.lhs,
+ .section_node = 0,
+ .init_node = data.rhs,
+ .mut_token = tree.nodes.items(.main_token)[node],
+ });
+}
+
+pub fn ifSimple(tree: Tree, node: Node.Index) full.If {
+ assert(tree.nodes.items(.tag)[node] == .if_simple);
+ const data = tree.nodes.items(.data)[node];
+ return tree.fullIf(.{
+ .cond_expr = data.lhs,
+ .then_expr = data.rhs,
+ .else_expr = 0,
+ .if_token = tree.nodes.items(.main_token)[node],
+ });
+}
+
+pub fn ifFull(tree: Tree, node: Node.Index) full.If {
+ assert(tree.nodes.items(.tag)[node] == .@"if");
+ const data = tree.nodes.items(.data)[node];
+ const extra = tree.extraData(data.rhs, Node.If);
+ return tree.fullIf(.{
+ .cond_expr = data.lhs,
+ .then_expr = extra.then_expr,
+ .else_expr = extra.else_expr,
+ .if_token = tree.nodes.items(.main_token)[node],
+ });
+}
+
+pub fn containerField(tree: Tree, node: Node.Index) full.ContainerField {
+ assert(tree.nodes.items(.tag)[node] == .container_field);
+ const data = tree.nodes.items(.data)[node];
+ const extra = tree.extraData(data.rhs, Node.ContainerField);
+ return tree.fullContainerField(.{
+ .name_token = tree.nodes.items(.main_token)[node],
+ .type_expr = data.lhs,
+ .value_expr = extra.value_expr,
+ .align_expr = extra.align_expr,
+ });
+}
+
+pub fn containerFieldInit(tree: Tree, node: Node.Index) full.ContainerField {
+ assert(tree.nodes.items(.tag)[node] == .container_field_init);
+ const data = tree.nodes.items(.data)[node];
+ return tree.fullContainerField(.{
+ .name_token = tree.nodes.items(.main_token)[node],
+ .type_expr = data.lhs,
+ .value_expr = data.rhs,
+ .align_expr = 0,
+ });
+}
+
+pub fn containerFieldAlign(tree: Tree, node: Node.Index) full.ContainerField {
+ assert(tree.nodes.items(.tag)[node] == .container_field_align);
+ const data = tree.nodes.items(.data)[node];
+ return tree.fullContainerField(.{
+ .name_token = tree.nodes.items(.main_token)[node],
+ .type_expr = data.lhs,
+ .value_expr = 0,
+ .align_expr = data.rhs,
+ });
+}
+
+pub fn fnProtoSimple(tree: Tree, buffer: *[1]Node.Index, node: Node.Index) full.FnProto {
+ assert(tree.nodes.items(.tag)[node] == .fn_proto_simple);
+ const data = tree.nodes.items(.data)[node];
+ buffer[0] = data.lhs;
+ const params = if (data.lhs == 0) buffer[0..0] else buffer[0..1];
+ return tree.fullFnProto(.{
+ .proto_node = node,
+ .fn_token = tree.nodes.items(.main_token)[node],
+ .return_type = data.rhs,
+ .params = params,
+ .align_expr = 0,
+ .section_expr = 0,
+ .callconv_expr = 0,
+ });
+}
+
+pub fn fnProtoMulti(tree: Tree, node: Node.Index) full.FnProto {
+ assert(tree.nodes.items(.tag)[node] == .fn_proto_multi);
+ const data = tree.nodes.items(.data)[node];
+ const params_range = tree.extraData(data.lhs, Node.SubRange);
+ const params = tree.extra_data[params_range.start..params_range.end];
+ return tree.fullFnProto(.{
+ .proto_node = node,
+ .fn_token = tree.nodes.items(.main_token)[node],
+ .return_type = data.rhs,
+ .params = params,
+ .align_expr = 0,
+ .section_expr = 0,
+ .callconv_expr = 0,
+ });
+}
+
+pub fn fnProtoOne(tree: Tree, buffer: *[1]Node.Index, node: Node.Index) full.FnProto {
+ assert(tree.nodes.items(.tag)[node] == .fn_proto_one);
+ const data = tree.nodes.items(.data)[node];
+ const extra = tree.extraData(data.lhs, Node.FnProtoOne);
+ buffer[0] = extra.param;
+ const params = if (extra.param == 0) buffer[0..0] else buffer[0..1];
+ return tree.fullFnProto(.{
+ .proto_node = node,
+ .fn_token = tree.nodes.items(.main_token)[node],
+ .return_type = data.rhs,
+ .params = params,
+ .align_expr = extra.align_expr,
+ .section_expr = extra.section_expr,
+ .callconv_expr = extra.callconv_expr,
+ });
+}
+
+pub fn fnProto(tree: Tree, node: Node.Index) full.FnProto {
+ assert(tree.nodes.items(.tag)[node] == .fn_proto);
+ const data = tree.nodes.items(.data)[node];
+ const extra = tree.extraData(data.lhs, Node.FnProto);
+ const params = tree.extra_data[extra.params_start..extra.params_end];
+ return tree.fullFnProto(.{
+ .proto_node = node,
+ .fn_token = tree.nodes.items(.main_token)[node],
+ .return_type = data.rhs,
+ .params = params,
+ .align_expr = extra.align_expr,
+ .section_expr = extra.section_expr,
+ .callconv_expr = extra.callconv_expr,
+ });
+}
+
+pub fn structInitOne(tree: Tree, buffer: *[1]Node.Index, node: Node.Index) full.StructInit {
+ assert(tree.nodes.items(.tag)[node] == .struct_init_one or
+ tree.nodes.items(.tag)[node] == .struct_init_one_comma);
+ const data = tree.nodes.items(.data)[node];
+ buffer[0] = data.rhs;
+ const fields = if (data.rhs == 0) buffer[0..0] else buffer[0..1];
+ return tree.fullStructInit(.{
+ .lbrace = tree.nodes.items(.main_token)[node],
+ .fields = fields,
+ .type_expr = data.lhs,
+ });
+}
+
+pub fn structInitDotTwo(tree: Tree, buffer: *[2]Node.Index, node: Node.Index) full.StructInit {
+ assert(tree.nodes.items(.tag)[node] == .struct_init_dot_two or
+ tree.nodes.items(.tag)[node] == .struct_init_dot_two_comma);
+ const data = tree.nodes.items(.data)[node];
+ buffer.* = .{ data.lhs, data.rhs };
+ const fields = if (data.rhs != 0)
+ buffer[0..2]
+ else if (data.lhs != 0)
+ buffer[0..1]
+ else
+ buffer[0..0];
+ return tree.fullStructInit(.{
+ .lbrace = tree.nodes.items(.main_token)[node],
+ .fields = fields,
+ .type_expr = 0,
+ });
+}
+
+pub fn structInitDot(tree: Tree, node: Node.Index) full.StructInit {
+ assert(tree.nodes.items(.tag)[node] == .struct_init_dot or
+ tree.nodes.items(.tag)[node] == .struct_init_dot_comma);
+ const data = tree.nodes.items(.data)[node];
+ return tree.fullStructInit(.{
+ .lbrace = tree.nodes.items(.main_token)[node],
+ .fields = tree.extra_data[data.lhs..data.rhs],
+ .type_expr = 0,
+ });
+}
+
+pub fn structInit(tree: Tree, node: Node.Index) full.StructInit {
+ assert(tree.nodes.items(.tag)[node] == .struct_init or
+ tree.nodes.items(.tag)[node] == .struct_init_comma);
+ const data = tree.nodes.items(.data)[node];
+ const fields_range = tree.extraData(data.rhs, Node.SubRange);
+ return tree.fullStructInit(.{
+ .lbrace = tree.nodes.items(.main_token)[node],
+ .fields = tree.extra_data[fields_range.start..fields_range.end],
+ .type_expr = data.lhs,
+ });
+}
+
+pub fn arrayInitOne(tree: Tree, buffer: *[1]Node.Index, node: Node.Index) full.ArrayInit {
+ assert(tree.nodes.items(.tag)[node] == .array_init_one or
+ tree.nodes.items(.tag)[node] == .array_init_one_comma);
+ const data = tree.nodes.items(.data)[node];
+ buffer[0] = data.rhs;
+ const elements = if (data.rhs == 0) buffer[0..0] else buffer[0..1];
+ return .{
+ .ast = .{
+ .lbrace = tree.nodes.items(.main_token)[node],
+ .elements = elements,
+ .type_expr = data.lhs,
+ },
+ };
+}
+
+pub fn arrayInitDotTwo(tree: Tree, buffer: *[2]Node.Index, node: Node.Index) full.ArrayInit {
+ assert(tree.nodes.items(.tag)[node] == .array_init_dot_two or
+ tree.nodes.items(.tag)[node] == .array_init_dot_two_comma);
+ const data = tree.nodes.items(.data)[node];
+ buffer.* = .{ data.lhs, data.rhs };
+ const elements = if (data.rhs != 0)
+ buffer[0..2]
+ else if (data.lhs != 0)
+ buffer[0..1]
+ else
+ buffer[0..0];
+ return .{
+ .ast = .{
+ .lbrace = tree.nodes.items(.main_token)[node],
+ .elements = elements,
+ .type_expr = 0,
+ },
+ };
+}
+
+pub fn arrayInitDot(tree: Tree, node: Node.Index) full.ArrayInit {
+ assert(tree.nodes.items(.tag)[node] == .array_init_dot or
+ tree.nodes.items(.tag)[node] == .array_init_dot_comma);
+ const data = tree.nodes.items(.data)[node];
+ return .{
+ .ast = .{
+ .lbrace = tree.nodes.items(.main_token)[node],
+ .elements = tree.extra_data[data.lhs..data.rhs],
+ .type_expr = 0,
+ },
+ };
+}
+
+pub fn arrayInit(tree: Tree, node: Node.Index) full.ArrayInit {
+ assert(tree.nodes.items(.tag)[node] == .array_init or
+ tree.nodes.items(.tag)[node] == .array_init_comma);
+ const data = tree.nodes.items(.data)[node];
+ const elem_range = tree.extraData(data.rhs, Node.SubRange);
+ return .{
+ .ast = .{
+ .lbrace = tree.nodes.items(.main_token)[node],
+ .elements = tree.extra_data[elem_range.start..elem_range.end],
+ .type_expr = data.lhs,
+ },
+ };
+}
+
+pub fn arrayType(tree: Tree, node: Node.Index) full.ArrayType {
+ assert(tree.nodes.items(.tag)[node] == .array_type);
+ const data = tree.nodes.items(.data)[node];
+ return .{
+ .ast = .{
+ .lbracket = tree.nodes.items(.main_token)[node],
+ .elem_count = data.lhs,
+ .sentinel = 0,
+ .elem_type = data.rhs,
+ },
+ };
+}
+
+pub fn arrayTypeSentinel(tree: Tree, node: Node.Index) full.ArrayType {
+ assert(tree.nodes.items(.tag)[node] == .array_type_sentinel);
+ const data = tree.nodes.items(.data)[node];
+ const extra = tree.extraData(data.rhs, Node.ArrayTypeSentinel);
+ assert(extra.sentinel != 0);
+ return .{
+ .ast = .{
+ .lbracket = tree.nodes.items(.main_token)[node],
+ .elem_count = data.lhs,
+ .sentinel = extra.sentinel,
+ .elem_type = extra.elem_type,
+ },
+ };
+}
+
+pub fn ptrTypeAligned(tree: Tree, node: Node.Index) full.PtrType {
+ assert(tree.nodes.items(.tag)[node] == .ptr_type_aligned);
+ const data = tree.nodes.items(.data)[node];
+ return tree.fullPtrType(.{
+ .main_token = tree.nodes.items(.main_token)[node],
+ .align_node = data.lhs,
+ .sentinel = 0,
+ .bit_range_start = 0,
+ .bit_range_end = 0,
+ .child_type = data.rhs,
+ });
+}
+
+pub fn ptrTypeSentinel(tree: Tree, node: Node.Index) full.PtrType {
+ assert(tree.nodes.items(.tag)[node] == .ptr_type_sentinel);
+ const data = tree.nodes.items(.data)[node];
+ return tree.fullPtrType(.{
+ .main_token = tree.nodes.items(.main_token)[node],
+ .align_node = 0,
+ .sentinel = data.lhs,
+ .bit_range_start = 0,
+ .bit_range_end = 0,
+ .child_type = data.rhs,
+ });
+}
+
+pub fn ptrType(tree: Tree, node: Node.Index) full.PtrType {
+ assert(tree.nodes.items(.tag)[node] == .ptr_type);
+ const data = tree.nodes.items(.data)[node];
+ const extra = tree.extraData(data.lhs, Node.PtrType);
+ return tree.fullPtrType(.{
+ .main_token = tree.nodes.items(.main_token)[node],
+ .align_node = extra.align_node,
+ .sentinel = extra.sentinel,
+ .bit_range_start = 0,
+ .bit_range_end = 0,
+ .child_type = data.rhs,
+ });
+}
+
+pub fn ptrTypeBitRange(tree: Tree, node: Node.Index) full.PtrType {
+ assert(tree.nodes.items(.tag)[node] == .ptr_type_bit_range);
+ const data = tree.nodes.items(.data)[node];
+ const extra = tree.extraData(data.lhs, Node.PtrTypeBitRange);
+ return tree.fullPtrType(.{
+ .main_token = tree.nodes.items(.main_token)[node],
+ .align_node = extra.align_node,
+ .sentinel = extra.sentinel,
+ .bit_range_start = extra.bit_range_start,
+ .bit_range_end = extra.bit_range_end,
+ .child_type = data.rhs,
+ });
+}
+
+pub fn sliceOpen(tree: Tree, node: Node.Index) full.Slice {
+ assert(tree.nodes.items(.tag)[node] == .slice_open);
+ const data = tree.nodes.items(.data)[node];
+ return .{
+ .ast = .{
+ .sliced = data.lhs,
+ .lbracket = tree.nodes.items(.main_token)[node],
+ .start = data.rhs,
+ .end = 0,
+ .sentinel = 0,
+ },
+ };
+}
+
+pub fn slice(tree: Tree, node: Node.Index) full.Slice {
+ assert(tree.nodes.items(.tag)[node] == .slice);
+ const data = tree.nodes.items(.data)[node];
+ const extra = tree.extraData(data.rhs, Node.Slice);
+ return .{
+ .ast = .{
+ .sliced = data.lhs,
+ .lbracket = tree.nodes.items(.main_token)[node],
+ .start = extra.start,
+ .end = extra.end,
+ .sentinel = 0,
+ },
+ };
+}
+
+pub fn sliceSentinel(tree: Tree, node: Node.Index) full.Slice {
+ assert(tree.nodes.items(.tag)[node] == .slice_sentinel);
+ const data = tree.nodes.items(.data)[node];
+ const extra = tree.extraData(data.rhs, Node.SliceSentinel);
+ return .{
+ .ast = .{
+ .sliced = data.lhs,
+ .lbracket = tree.nodes.items(.main_token)[node],
+ .start = extra.start,
+ .end = extra.end,
+ .sentinel = extra.sentinel,
+ },
+ };
+}
+
+pub fn containerDeclTwo(tree: Tree, buffer: *[2]Node.Index, node: Node.Index) full.ContainerDecl {
+ assert(tree.nodes.items(.tag)[node] == .container_decl_two or
+ tree.nodes.items(.tag)[node] == .container_decl_two_trailing);
+ const data = tree.nodes.items(.data)[node];
+ buffer.* = .{ data.lhs, data.rhs };
+ const members = if (data.rhs != 0)
+ buffer[0..2]
+ else if (data.lhs != 0)
+ buffer[0..1]
+ else
+ buffer[0..0];
+ return tree.fullContainerDecl(.{
+ .main_token = tree.nodes.items(.main_token)[node],
+ .enum_token = null,
+ .members = members,
+ .arg = 0,
+ });
+}
+
+pub fn containerDecl(tree: Tree, node: Node.Index) full.ContainerDecl {
+ assert(tree.nodes.items(.tag)[node] == .container_decl or
+ tree.nodes.items(.tag)[node] == .container_decl_trailing);
+ const data = tree.nodes.items(.data)[node];
+ return tree.fullContainerDecl(.{
+ .main_token = tree.nodes.items(.main_token)[node],
+ .enum_token = null,
+ .members = tree.extra_data[data.lhs..data.rhs],
+ .arg = 0,
+ });
+}
+
+pub fn containerDeclArg(tree: Tree, node: Node.Index) full.ContainerDecl {
+ assert(tree.nodes.items(.tag)[node] == .container_decl_arg or
+ tree.nodes.items(.tag)[node] == .container_decl_arg_trailing);
+ const data = tree.nodes.items(.data)[node];
+ const members_range = tree.extraData(data.rhs, Node.SubRange);
+ return tree.fullContainerDecl(.{
+ .main_token = tree.nodes.items(.main_token)[node],
+ .enum_token = null,
+ .members = tree.extra_data[members_range.start..members_range.end],
+ .arg = data.lhs,
+ });
+}
+
+pub fn taggedUnionTwo(tree: Tree, buffer: *[2]Node.Index, node: Node.Index) full.ContainerDecl {
+ assert(tree.nodes.items(.tag)[node] == .tagged_union_two or
+ tree.nodes.items(.tag)[node] == .tagged_union_two_trailing);
+ const data = tree.nodes.items(.data)[node];
+ buffer.* = .{ data.lhs, data.rhs };
+ const members = if (data.rhs != 0)
+ buffer[0..2]
+ else if (data.lhs != 0)
+ buffer[0..1]
+ else
+ buffer[0..0];
+ const main_token = tree.nodes.items(.main_token)[node];
+ return tree.fullContainerDecl(.{
+ .main_token = main_token,
+ .enum_token = main_token + 2, // union lparen enum
+ .members = members,
+ .arg = 0,
+ });
+}
+
+pub fn taggedUnion(tree: Tree, node: Node.Index) full.ContainerDecl {
+ assert(tree.nodes.items(.tag)[node] == .tagged_union or
+ tree.nodes.items(.tag)[node] == .tagged_union_trailing);
+ const data = tree.nodes.items(.data)[node];
+ const main_token = tree.nodes.items(.main_token)[node];
+ return tree.fullContainerDecl(.{
+ .main_token = main_token,
+ .enum_token = main_token + 2, // union lparen enum
+ .members = tree.extra_data[data.lhs..data.rhs],
+ .arg = 0,
+ });
+}
+
+pub fn taggedUnionEnumTag(tree: Tree, node: Node.Index) full.ContainerDecl {
+ assert(tree.nodes.items(.tag)[node] == .tagged_union_enum_tag or
+ tree.nodes.items(.tag)[node] == .tagged_union_enum_tag_trailing);
+ const data = tree.nodes.items(.data)[node];
+ const members_range = tree.extraData(data.rhs, Node.SubRange);
+ const main_token = tree.nodes.items(.main_token)[node];
+ return tree.fullContainerDecl(.{
+ .main_token = main_token,
+ .enum_token = main_token + 2, // union lparen enum
+ .members = tree.extra_data[members_range.start..members_range.end],
+ .arg = data.lhs,
+ });
+}
+
+pub fn switchCaseOne(tree: Tree, node: Node.Index) full.SwitchCase {
+ const data = &tree.nodes.items(.data)[node];
+ const values: *[1]Node.Index = &data.lhs;
+ return tree.fullSwitchCase(.{
+ .values = if (data.lhs == 0) values[0..0] else values[0..1],
+ .arrow_token = tree.nodes.items(.main_token)[node],
+ .target_expr = data.rhs,
+ });
+}
+
+pub fn switchCase(tree: Tree, node: Node.Index) full.SwitchCase {
+ const data = tree.nodes.items(.data)[node];
+ const extra = tree.extraData(data.lhs, Node.SubRange);
+ return tree.fullSwitchCase(.{
+ .values = tree.extra_data[extra.start..extra.end],
+ .arrow_token = tree.nodes.items(.main_token)[node],
+ .target_expr = data.rhs,
+ });
+}
+
+pub fn asmSimple(tree: Tree, node: Node.Index) full.Asm {
+ const data = tree.nodes.items(.data)[node];
+ return tree.fullAsm(.{
+ .asm_token = tree.nodes.items(.main_token)[node],
+ .template = data.lhs,
+ .items = &.{},
+ .rparen = data.rhs,
+ });
+}
+
+pub fn asmFull(tree: Tree, node: Node.Index) full.Asm {
+ const data = tree.nodes.items(.data)[node];
+ const extra = tree.extraData(data.rhs, Node.Asm);
+ return tree.fullAsm(.{
+ .asm_token = tree.nodes.items(.main_token)[node],
+ .template = data.lhs,
+ .items = tree.extra_data[extra.items_start..extra.items_end],
+ .rparen = extra.rparen,
+ });
+}
+
+pub fn whileSimple(tree: Tree, node: Node.Index) full.While {
+ const data = tree.nodes.items(.data)[node];
+ return tree.fullWhile(.{
+ .while_token = tree.nodes.items(.main_token)[node],
+ .cond_expr = data.lhs,
+ .cont_expr = 0,
+ .then_expr = data.rhs,
+ .else_expr = 0,
+ });
+}
+
+pub fn whileCont(tree: Tree, node: Node.Index) full.While {
+ const data = tree.nodes.items(.data)[node];
+ const extra = tree.extraData(data.rhs, Node.WhileCont);
+ return tree.fullWhile(.{
+ .while_token = tree.nodes.items(.main_token)[node],
+ .cond_expr = data.lhs,
+ .cont_expr = extra.cont_expr,
+ .then_expr = extra.then_expr,
+ .else_expr = 0,
+ });
+}
+
+pub fn whileFull(tree: Tree, node: Node.Index) full.While {
+ const data = tree.nodes.items(.data)[node];
+ const extra = tree.extraData(data.rhs, Node.While);
+ return tree.fullWhile(.{
+ .while_token = tree.nodes.items(.main_token)[node],
+ .cond_expr = data.lhs,
+ .cont_expr = extra.cont_expr,
+ .then_expr = extra.then_expr,
+ .else_expr = extra.else_expr,
+ });
+}
+
+pub fn forSimple(tree: Tree, node: Node.Index) full.While {
+ const data = tree.nodes.items(.data)[node];
+ return tree.fullWhile(.{
+ .while_token = tree.nodes.items(.main_token)[node],
+ .cond_expr = data.lhs,
+ .cont_expr = 0,
+ .then_expr = data.rhs,
+ .else_expr = 0,
+ });
+}
+
+pub fn forFull(tree: Tree, node: Node.Index) full.While {
+ const data = tree.nodes.items(.data)[node];
+ const extra = tree.extraData(data.rhs, Node.If);
+ return tree.fullWhile(.{
+ .while_token = tree.nodes.items(.main_token)[node],
+ .cond_expr = data.lhs,
+ .cont_expr = 0,
+ .then_expr = extra.then_expr,
+ .else_expr = extra.else_expr,
+ });
+}
+
+pub fn callOne(tree: Tree, buffer: *[1]Node.Index, node: Node.Index) full.Call {
+ const data = tree.nodes.items(.data)[node];
+ buffer.* = .{data.rhs};
+ const params = if (data.rhs != 0) buffer[0..1] else buffer[0..0];
+ return tree.fullCall(.{
+ .lparen = tree.nodes.items(.main_token)[node],
+ .fn_expr = data.lhs,
+ .params = params,
+ });
+}
+
+pub fn callFull(tree: Tree, node: Node.Index) full.Call {
+ const data = tree.nodes.items(.data)[node];
+ const extra = tree.extraData(data.rhs, Node.SubRange);
+ return tree.fullCall(.{
+ .lparen = tree.nodes.items(.main_token)[node],
+ .fn_expr = data.lhs,
+ .params = tree.extra_data[extra.start..extra.end],
+ });
+}
+
+fn fullVarDecl(tree: Tree, info: full.VarDecl.Components) full.VarDecl {
+ const token_tags = tree.tokens.items(.tag);
+ var result: full.VarDecl = .{
+ .ast = info,
+ .visib_token = null,
+ .extern_export_token = null,
+ .lib_name = null,
+ .threadlocal_token = null,
+ .comptime_token = null,
+ };
+ var i = info.mut_token;
+ while (i > 0) {
+ i -= 1;
+ switch (token_tags[i]) {
+ .keyword_extern, .keyword_export => result.extern_export_token = i,
+ .keyword_comptime => result.comptime_token = i,
+ .keyword_pub => result.visib_token = i,
+ .keyword_threadlocal => result.threadlocal_token = i,
+ .string_literal => result.lib_name = i,
+ else => break,
+ }
+ }
+ return result;
+}
+
+fn fullIf(tree: Tree, info: full.If.Components) full.If {
+ const token_tags = tree.tokens.items(.tag);
+ var result: full.If = .{
+ .ast = info,
+ .payload_token = null,
+ .error_token = null,
+ .else_token = undefined,
+ };
+ // if (cond_expr) |x|
+ // ^ ^
+ const payload_pipe = tree.lastToken(info.cond_expr) + 2;
+ if (token_tags[payload_pipe] == .pipe) {
+ result.payload_token = payload_pipe + 1;
+ }
+ if (info.else_expr != 0) {
+ // then_expr else |x|
+ // ^ ^
+ result.else_token = tree.lastToken(info.then_expr) + 1;
+ if (token_tags[result.else_token + 1] == .pipe) {
+ result.error_token = result.else_token + 2;
+ }
+ }
+ return result;
+}
+
+fn fullContainerField(tree: Tree, info: full.ContainerField.Components) full.ContainerField {
+ const token_tags = tree.tokens.items(.tag);
+ var result: full.ContainerField = .{
+ .ast = info,
+ .comptime_token = null,
+ };
+ // comptime name: type = init,
+ // ^
+ if (info.name_token > 0 and token_tags[info.name_token - 1] == .keyword_comptime) {
+ result.comptime_token = info.name_token - 1;
+ }
+ return result;
+}
+
+fn fullFnProto(tree: Tree, info: full.FnProto.Components) full.FnProto {
+ const token_tags = tree.tokens.items(.tag);
+ var result: full.FnProto = .{
+ .ast = info,
+ .visib_token = null,
+ .extern_export_inline_token = null,
+ .lib_name = null,
+ .name_token = null,
+ .lparen = undefined,
+ };
+ var i = info.fn_token;
+ while (i > 0) {
+ i -= 1;
+ switch (token_tags[i]) {
+ .keyword_extern,
+ .keyword_export,
+ .keyword_inline,
+ .keyword_noinline,
+ => result.extern_export_inline_token = i,
+ .keyword_pub => result.visib_token = i,
+ .string_literal => result.lib_name = i,
+ else => break,
+ }
+ }
+ const after_fn_token = info.fn_token + 1;
+ if (token_tags[after_fn_token] == .identifier) {
+ result.name_token = after_fn_token;
+ result.lparen = after_fn_token + 1;
+ } else {
+ result.lparen = after_fn_token;
+ }
+ assert(token_tags[result.lparen] == .l_paren);
+
+ return result;
+}
+
+fn fullStructInit(tree: Tree, info: full.StructInit.Components) full.StructInit {
+ _ = tree;
+ var result: full.StructInit = .{
+ .ast = info,
+ };
+ return result;
+}
+
+fn fullPtrType(tree: Tree, info: full.PtrType.Components) full.PtrType {
+ const token_tags = tree.tokens.items(.tag);
+ // TODO: looks like stage1 isn't quite smart enough to handle enum
+ // literals in some places here
+ const Size = std.builtin.TypeInfo.Pointer.Size;
+ const size: Size = switch (token_tags[info.main_token]) {
+ .asterisk,
+ .asterisk_asterisk,
+ => switch (token_tags[info.main_token + 1]) {
+ .r_bracket, .colon => .Many,
+ .identifier => if (token_tags[info.main_token - 1] == .l_bracket) Size.C else .One,
+ else => .One,
+ },
+ .l_bracket => Size.Slice,
+ else => unreachable,
+ };
+ var result: full.PtrType = .{
+ .size = size,
+ .allowzero_token = null,
+ .const_token = null,
+ .volatile_token = null,
+ .ast = info,
+ };
+ // We need to be careful that we don't iterate over any sub-expressions
+ // here while looking for modifiers as that could result in false
+ // positives. Therefore, start after a sentinel if there is one and
+ // skip over any align node and bit range nodes.
+ var i = if (info.sentinel != 0) tree.lastToken(info.sentinel) + 1 else info.main_token;
+ const end = tree.firstToken(info.child_type);
+ while (i < end) : (i += 1) {
+ switch (token_tags[i]) {
+ .keyword_allowzero => result.allowzero_token = i,
+ .keyword_const => result.const_token = i,
+ .keyword_volatile => result.volatile_token = i,
+ .keyword_align => {
+ assert(info.align_node != 0);
+ if (info.bit_range_end != 0) {
+ assert(info.bit_range_start != 0);
+ i = tree.lastToken(info.bit_range_end) + 1;
+ } else {
+ i = tree.lastToken(info.align_node) + 1;
+ }
+ },
+ else => {},
+ }
+ }
+ return result;
+}
+
+fn fullContainerDecl(tree: Tree, info: full.ContainerDecl.Components) full.ContainerDecl {
+ const token_tags = tree.tokens.items(.tag);
+ var result: full.ContainerDecl = .{
+ .ast = info,
+ .layout_token = null,
+ };
+ switch (token_tags[info.main_token - 1]) {
+ .keyword_extern, .keyword_packed => result.layout_token = info.main_token - 1,
+ else => {},
+ }
+ return result;
+}
+
+fn fullSwitchCase(tree: Tree, info: full.SwitchCase.Components) full.SwitchCase {
+ const token_tags = tree.tokens.items(.tag);
+ var result: full.SwitchCase = .{
+ .ast = info,
+ .payload_token = null,
+ };
+ if (token_tags[info.arrow_token + 1] == .pipe) {
+ result.payload_token = info.arrow_token + 2;
+ }
+ return result;
+}
+
+fn fullAsm(tree: Tree, info: full.Asm.Components) full.Asm {
+ const token_tags = tree.tokens.items(.tag);
+ const node_tags = tree.nodes.items(.tag);
+ var result: full.Asm = .{
+ .ast = info,
+ .volatile_token = null,
+ .inputs = &.{},
+ .outputs = &.{},
+ .first_clobber = null,
+ };
+ if (token_tags[info.asm_token + 1] == .keyword_volatile) {
+ result.volatile_token = info.asm_token + 1;
+ }
+ const outputs_end: usize = for (info.items) |item, i| {
+ switch (node_tags[item]) {
+ .asm_output => continue,
+ else => break i,
+ }
+ } else info.items.len;
+
+ result.outputs = info.items[0..outputs_end];
+ result.inputs = info.items[outputs_end..];
+
+ if (info.items.len == 0) {
+ // asm ("foo" ::: "a", "b");
+ const template_token = tree.lastToken(info.template);
+ if (token_tags[template_token + 1] == .colon and
+ token_tags[template_token + 2] == .colon and
+ token_tags[template_token + 3] == .colon and
+ token_tags[template_token + 4] == .string_literal)
+ {
+ result.first_clobber = template_token + 4;
+ }
+ } else if (result.inputs.len != 0) {
+ // asm ("foo" :: [_] "" (y) : "a", "b");
+ const last_input = result.inputs[result.inputs.len - 1];
+ const rparen = tree.lastToken(last_input);
+ var i = rparen + 1;
+ // Allow a (useless) comma right after the closing parenthesis.
+ if (token_tags[i] == .comma) i += 1;
+ if (token_tags[i] == .colon and
+ token_tags[i + 1] == .string_literal)
+ {
+ result.first_clobber = i + 1;
+ }
+ } else {
+ // asm ("foo" : [_] "" (x) :: "a", "b");
+ const last_output = result.outputs[result.outputs.len - 1];
+ const rparen = tree.lastToken(last_output);
+ var i = rparen + 1;
+ // Allow a (useless) comma right after the closing parenthesis.
+ if (token_tags[i] == .comma) i += 1;
+ if (token_tags[i] == .colon and
+ token_tags[i + 1] == .colon and
+ token_tags[i + 2] == .string_literal)
+ {
+ result.first_clobber = i + 2;
+ }
+ }
+
+ return result;
+}
+
+fn fullWhile(tree: Tree, info: full.While.Components) full.While {
+ const token_tags = tree.tokens.items(.tag);
+ var result: full.While = .{
+ .ast = info,
+ .inline_token = null,
+ .label_token = null,
+ .payload_token = null,
+ .else_token = undefined,
+ .error_token = null,
+ };
+ var tok_i = info.while_token - 1;
+ if (token_tags[tok_i] == .keyword_inline) {
+ result.inline_token = tok_i;
+ tok_i -= 1;
+ }
+ if (token_tags[tok_i] == .colon and
+ token_tags[tok_i - 1] == .identifier)
+ {
+ result.label_token = tok_i - 1;
+ }
+ const last_cond_token = tree.lastToken(info.cond_expr);
+ if (token_tags[last_cond_token + 2] == .pipe) {
+ result.payload_token = last_cond_token + 3;
+ }
+ if (info.else_expr != 0) {
+ // then_expr else |x|
+ // ^ ^
+ result.else_token = tree.lastToken(info.then_expr) + 1;
+ if (token_tags[result.else_token + 1] == .pipe) {
+ result.error_token = result.else_token + 2;
+ }
+ }
+ return result;
+}
+
+fn fullCall(tree: Tree, info: full.Call.Components) full.Call {
+ const token_tags = tree.tokens.items(.tag);
+ var result: full.Call = .{
+ .ast = info,
+ .async_token = null,
+ };
+ const maybe_async_token = tree.firstToken(info.fn_expr) - 1;
+ if (token_tags[maybe_async_token] == .keyword_async) {
+ result.async_token = maybe_async_token;
+ }
+ return result;
+}
+
+/// Fully assembled AST node information.
+pub const full = struct {
+ pub const VarDecl = struct {
+ visib_token: ?TokenIndex,
+ extern_export_token: ?TokenIndex,
+ lib_name: ?TokenIndex,
+ threadlocal_token: ?TokenIndex,
+ comptime_token: ?TokenIndex,
+ ast: Components,
+
+ pub const Components = struct {
+ mut_token: TokenIndex,
+ type_node: Node.Index,
+ align_node: Node.Index,
+ section_node: Node.Index,
+ init_node: Node.Index,
+ };
+ };
+
+ pub const If = struct {
+ /// Points to the first token after the `|`. Will either be an identifier or
+ /// a `*` (with an identifier immediately after it).
+ payload_token: ?TokenIndex,
+ /// Points to the identifier after the `|`.
+ error_token: ?TokenIndex,
+ /// Populated only if else_expr != 0.
+ else_token: TokenIndex,
+ ast: Components,
+
+ pub const Components = struct {
+ if_token: TokenIndex,
+ cond_expr: Node.Index,
+ then_expr: Node.Index,
+ else_expr: Node.Index,
+ };
+ };
+
+ pub const While = struct {
+ ast: Components,
+ inline_token: ?TokenIndex,
+ label_token: ?TokenIndex,
+ payload_token: ?TokenIndex,
+ error_token: ?TokenIndex,
+ /// Populated only if else_expr != 0.
+ else_token: TokenIndex,
+
+ pub const Components = struct {
+ while_token: TokenIndex,
+ cond_expr: Node.Index,
+ cont_expr: Node.Index,
+ then_expr: Node.Index,
+ else_expr: Node.Index,
+ };
+ };
+
+ pub const ContainerField = struct {
+ comptime_token: ?TokenIndex,
+ ast: Components,
+
+ pub const Components = struct {
+ name_token: TokenIndex,
+ type_expr: Node.Index,
+ value_expr: Node.Index,
+ align_expr: Node.Index,
+ };
+ };
+
+ pub const FnProto = struct {
+ visib_token: ?TokenIndex,
+ extern_export_inline_token: ?TokenIndex,
+ lib_name: ?TokenIndex,
+ name_token: ?TokenIndex,
+ lparen: TokenIndex,
+ ast: Components,
+
+ pub const Components = struct {
+ proto_node: Node.Index,
+ fn_token: TokenIndex,
+ return_type: Node.Index,
+ params: []const Node.Index,
+ align_expr: Node.Index,
+ section_expr: Node.Index,
+ callconv_expr: Node.Index,
+ };
+
+ pub const Param = struct {
+ first_doc_comment: ?TokenIndex,
+ name_token: ?TokenIndex,
+ comptime_noalias: ?TokenIndex,
+ anytype_ellipsis3: ?TokenIndex,
+ type_expr: Node.Index,
+ };
+
+ /// Abstracts over the fact that anytype and ... are not included
+ /// in the params slice, since they are simple identifiers and
+ /// not sub-expressions.
+ pub const Iterator = struct {
+ tree: *const Tree,
+ fn_proto: *const FnProto,
+ param_i: usize,
+ tok_i: TokenIndex,
+ tok_flag: bool,
+
+ pub fn next(it: *Iterator) ?Param {
+ const token_tags = it.tree.tokens.items(.tag);
+ while (true) {
+ var first_doc_comment: ?TokenIndex = null;
+ var comptime_noalias: ?TokenIndex = null;
+ var name_token: ?TokenIndex = null;
+ if (!it.tok_flag) {
+ if (it.param_i >= it.fn_proto.ast.params.len) {
+ return null;
+ }
+ const param_type = it.fn_proto.ast.params[it.param_i];
+ var tok_i = it.tree.firstToken(param_type) - 1;
+ while (true) : (tok_i -= 1) switch (token_tags[tok_i]) {
+ .colon => continue,
+ .identifier => name_token = tok_i,
+ .doc_comment => first_doc_comment = tok_i,
+ .keyword_comptime, .keyword_noalias => comptime_noalias = tok_i,
+ else => break,
+ };
+ it.param_i += 1;
+ it.tok_i = it.tree.lastToken(param_type) + 1;
+ // Look for anytype and ... params afterwards.
+ if (token_tags[it.tok_i] == .comma) {
+ it.tok_i += 1;
+ }
+ it.tok_flag = true;
+ return Param{
+ .first_doc_comment = first_doc_comment,
+ .comptime_noalias = comptime_noalias,
+ .name_token = name_token,
+ .anytype_ellipsis3 = null,
+ .type_expr = param_type,
+ };
+ }
+ if (token_tags[it.tok_i] == .comma) {
+ it.tok_i += 1;
+ }
+ if (token_tags[it.tok_i] == .r_paren) {
+ return null;
+ }
+ if (token_tags[it.tok_i] == .doc_comment) {
+ first_doc_comment = it.tok_i;
+ while (token_tags[it.tok_i] == .doc_comment) {
+ it.tok_i += 1;
+ }
+ }
+ switch (token_tags[it.tok_i]) {
+ .ellipsis3 => {
+ it.tok_flag = false; // Next iteration should return null.
+ return Param{
+ .first_doc_comment = first_doc_comment,
+ .comptime_noalias = null,
+ .name_token = null,
+ .anytype_ellipsis3 = it.tok_i,
+ .type_expr = 0,
+ };
+ },
+ .keyword_noalias, .keyword_comptime => {
+ comptime_noalias = it.tok_i;
+ it.tok_i += 1;
+ },
+ else => {},
+ }
+ if (token_tags[it.tok_i] == .identifier and
+ token_tags[it.tok_i + 1] == .colon)
+ {
+ name_token = it.tok_i;
+ it.tok_i += 2;
+ }
+ if (token_tags[it.tok_i] == .keyword_anytype) {
+ it.tok_i += 1;
+ return Param{
+ .first_doc_comment = first_doc_comment,
+ .comptime_noalias = comptime_noalias,
+ .name_token = name_token,
+ .anytype_ellipsis3 = it.tok_i - 1,
+ .type_expr = 0,
+ };
+ }
+ it.tok_flag = false;
+ }
+ }
+ };
+
+ pub fn iterate(fn_proto: FnProto, tree: Tree) Iterator {
+ return .{
+ .tree = &tree,
+ .fn_proto = &fn_proto,
+ .param_i = 0,
+ .tok_i = fn_proto.lparen + 1,
+ .tok_flag = true,
+ };
+ }
+ };
+
+ pub const StructInit = struct {
+ ast: Components,
+
+ pub const Components = struct {
+ lbrace: TokenIndex,
+ fields: []const Node.Index,
+ type_expr: Node.Index,
+ };
+ };
+
+ pub const ArrayInit = struct {
+ ast: Components,
+
+ pub const Components = struct {
+ lbrace: TokenIndex,
+ elements: []const Node.Index,
+ type_expr: Node.Index,
+ };
+ };
+
+ pub const ArrayType = struct {
+ ast: Components,
+
+ pub const Components = struct {
+ lbracket: TokenIndex,
+ elem_count: Node.Index,
+ sentinel: Node.Index,
+ elem_type: Node.Index,
+ };
+ };
+
+ pub const PtrType = struct {
+ size: std.builtin.TypeInfo.Pointer.Size,
+ allowzero_token: ?TokenIndex,
+ const_token: ?TokenIndex,
+ volatile_token: ?TokenIndex,
+ ast: Components,
+
+ pub const Components = struct {
+ main_token: TokenIndex,
+ align_node: Node.Index,
+ sentinel: Node.Index,
+ bit_range_start: Node.Index,
+ bit_range_end: Node.Index,
+ child_type: Node.Index,
+ };
+ };
+
+ pub const Slice = struct {
+ ast: Components,
+
+ pub const Components = struct {
+ sliced: Node.Index,
+ lbracket: TokenIndex,
+ start: Node.Index,
+ end: Node.Index,
+ sentinel: Node.Index,
+ };
+ };
+
+ pub const ContainerDecl = struct {
+ layout_token: ?TokenIndex,
+ ast: Components,
+
+ pub const Components = struct {
+ main_token: TokenIndex,
+ /// Populated when main_token is Keyword_union.
+ enum_token: ?TokenIndex,
+ members: []const Node.Index,
+ arg: Node.Index,
+ };
+ };
+
+ pub const SwitchCase = struct {
+ /// Points to the first token after the `|`. Will either be an identifier or
+ /// a `*` (with an identifier immediately after it).
+ payload_token: ?TokenIndex,
+ ast: Components,
+
+ pub const Components = struct {
+ /// If empty, this is an else case
+ values: []const Node.Index,
+ arrow_token: TokenIndex,
+ target_expr: Node.Index,
+ };
+ };
+
+ pub const Asm = struct {
+ ast: Components,
+ volatile_token: ?TokenIndex,
+ first_clobber: ?TokenIndex,
+ outputs: []const Node.Index,
+ inputs: []const Node.Index,
+
+ pub const Components = struct {
+ asm_token: TokenIndex,
+ template: Node.Index,
+ items: []const Node.Index,
+ rparen: TokenIndex,
+ };
+ };
+
+ pub const Call = struct {
+ ast: Components,
+ async_token: ?TokenIndex,
+
+ pub const Components = struct {
+ lparen: TokenIndex,
+ fn_expr: Node.Index,
+ params: []const Node.Index,
+ };
+ };
+};
+
+pub const Error = struct {
+ tag: Tag,
+ token: TokenIndex,
+ extra: union {
+ none: void,
+ expected_tag: Token.Tag,
+ } = .{ .none = {} },
+
+ pub const Tag = enum {
+ asterisk_after_ptr_deref,
+ decl_between_fields,
+ expected_block,
+ expected_block_or_assignment,
+ expected_block_or_expr,
+ expected_block_or_field,
+ expected_container_members,
+ expected_expr,
+ expected_expr_or_assignment,
+ expected_fn,
+ expected_inlinable,
+ expected_labelable,
+ expected_param_list,
+ expected_prefix_expr,
+ expected_primary_type_expr,
+ expected_pub_item,
+ expected_return_type,
+ expected_semi_or_else,
+ expected_semi_or_lbrace,
+ expected_statement,
+ expected_string_literal,
+ expected_suffix_op,
+ expected_type_expr,
+ expected_var_decl,
+ expected_var_decl_or_fn,
+ expected_loop_payload,
+ expected_container,
+ extra_align_qualifier,
+ extra_allowzero_qualifier,
+ extra_const_qualifier,
+ extra_volatile_qualifier,
+ ptr_mod_on_array_child_type,
+ invalid_bit_range,
+ invalid_token,
+ same_line_doc_comment,
+ unattached_doc_comment,
+ varargs_nonfinal,
+
+ /// `expected_tag` is populated.
+ expected_token,
+ };
+};
+
+pub const Node = struct {
+ tag: Tag,
+ main_token: TokenIndex,
+ data: Data,
+
+ pub const Index = u32;
+
+ comptime {
+ // Goal is to keep this under one byte for efficiency.
+ assert(@sizeOf(Tag) == 1);
+ }
+
+ /// Note: The FooComma/FooSemicolon variants exist to ease the implementation of
+ /// Tree.lastToken()
+ pub const Tag = enum {
+ /// sub_list[lhs...rhs]
+ root,
+ /// `usingnamespace lhs;`. rhs unused. main_token is `usingnamespace`.
+ @"usingnamespace",
+ /// lhs is test name token (must be string literal), if any.
+ /// rhs is the body node.
+ test_decl,
+ /// lhs is the index into extra_data.
+ /// rhs is the initialization expression, if any.
+ /// main_token is `var` or `const`.
+ global_var_decl,
+ /// `var a: x align(y) = rhs`
+ /// lhs is the index into extra_data.
+ /// main_token is `var` or `const`.
+ local_var_decl,
+ /// `var a: lhs = rhs`. lhs and rhs may be unused.
+ /// Can be local or global.
+ /// main_token is `var` or `const`.
+ simple_var_decl,
+ /// `var a align(lhs) = rhs`. lhs and rhs may be unused.
+ /// Can be local or global.
+ /// main_token is `var` or `const`.
+ aligned_var_decl,
+ /// lhs is the identifier token payload if any,
+ /// rhs is the deferred expression.
+ @"errdefer",
+ /// lhs is unused.
+ /// rhs is the deferred expression.
+ @"defer",
+ /// lhs catch rhs
+ /// lhs catch |err| rhs
+ /// main_token is the `catch` keyword.
+ /// payload is determined by looking at the next token after the `catch` keyword.
+ @"catch",
+ /// `lhs.a`. main_token is the dot. rhs is the identifier token index.
+ field_access,
+ /// `lhs.?`. main_token is the dot. rhs is the `?` token index.
+ unwrap_optional,
+ /// `lhs == rhs`. main_token is op.
+ equal_equal,
+ /// `lhs != rhs`. main_token is op.
+ bang_equal,
+ /// `lhs < rhs`. main_token is op.
+ less_than,
+ /// `lhs > rhs`. main_token is op.
+ greater_than,
+ /// `lhs <= rhs`. main_token is op.
+ less_or_equal,
+ /// `lhs >= rhs`. main_token is op.
+ greater_or_equal,
+ /// `lhs *= rhs`. main_token is op.
+ assign_mul,
+ /// `lhs /= rhs`. main_token is op.
+ assign_div,
+ /// `lhs *= rhs`. main_token is op.
+ assign_mod,
+ /// `lhs += rhs`. main_token is op.
+ assign_add,
+ /// `lhs -= rhs`. main_token is op.
+ assign_sub,
+ /// `lhs <<= rhs`. main_token is op.
+ assign_bit_shift_left,
+ /// `lhs >>= rhs`. main_token is op.
+ assign_bit_shift_right,
+ /// `lhs &= rhs`. main_token is op.
+ assign_bit_and,
+ /// `lhs ^= rhs`. main_token is op.
+ assign_bit_xor,
+ /// `lhs |= rhs`. main_token is op.
+ assign_bit_or,
+ /// `lhs *%= rhs`. main_token is op.
+ assign_mul_wrap,
+ /// `lhs +%= rhs`. main_token is op.
+ assign_add_wrap,
+ /// `lhs -%= rhs`. main_token is op.
+ assign_sub_wrap,
+ /// `lhs = rhs`. main_token is op.
+ assign,
+ /// `lhs || rhs`. main_token is the `||`.
+ merge_error_sets,
+ /// `lhs * rhs`. main_token is the `*`.
+ mul,
+ /// `lhs / rhs`. main_token is the `/`.
+ div,
+ /// `lhs % rhs`. main_token is the `%`.
+ mod,
+ /// `lhs ** rhs`. main_token is the `**`.
+ array_mult,
+ /// `lhs *% rhs`. main_token is the `*%`.
+ mul_wrap,
+ /// `lhs + rhs`. main_token is the `+`.
+ add,
+ /// `lhs - rhs`. main_token is the `-`.
+ sub,
+ /// `lhs ++ rhs`. main_token is the `++`.
+ array_cat,
+ /// `lhs +% rhs`. main_token is the `+%`.
+ add_wrap,
+ /// `lhs -% rhs`. main_token is the `-%`.
+ sub_wrap,
+ /// `lhs << rhs`. main_token is the `<<`.
+ bit_shift_left,
+ /// `lhs >> rhs`. main_token is the `>>`.
+ bit_shift_right,
+ /// `lhs & rhs`. main_token is the `&`.
+ bit_and,
+ /// `lhs ^ rhs`. main_token is the `^`.
+ bit_xor,
+ /// `lhs | rhs`. main_token is the `|`.
+ bit_or,
+ /// `lhs orelse rhs`. main_token is the `orelse`.
+ @"orelse",
+ /// `lhs and rhs`. main_token is the `and`.
+ bool_and,
+ /// `lhs or rhs`. main_token is the `or`.
+ bool_or,
+ /// `op lhs`. rhs unused. main_token is op.
+ bool_not,
+ /// `op lhs`. rhs unused. main_token is op.
+ negation,
+ /// `op lhs`. rhs unused. main_token is op.
+ bit_not,
+ /// `op lhs`. rhs unused. main_token is op.
+ negation_wrap,
+ /// `op lhs`. rhs unused. main_token is op.
+ address_of,
+ /// `op lhs`. rhs unused. main_token is op.
+ @"try",
+ /// `op lhs`. rhs unused. main_token is op.
+ @"await",
+ /// `?lhs`. rhs unused. main_token is the `?`.
+ optional_type,
+ /// `[lhs]rhs`.
+ array_type,
+ /// `[lhs:a]b`. `ArrayTypeSentinel[rhs]`.
+ array_type_sentinel,
+ /// `[*]align(lhs) rhs`. lhs can be omitted.
+ /// `*align(lhs) rhs`. lhs can be omitted.
+ /// `[]rhs`.
+ /// main_token is the asterisk if a pointer or the lbracket if a slice
+ /// main_token might be a ** token, which is shared with a parent/child
+ /// pointer type and may require special handling.
+ ptr_type_aligned,
+ /// `[*:lhs]rhs`. lhs can be omitted.
+ /// `*rhs`.
+ /// `[:lhs]rhs`.
+ /// main_token is the asterisk if a pointer or the lbracket if a slice
+ /// main_token might be a ** token, which is shared with a parent/child
+ /// pointer type and may require special handling.
+ ptr_type_sentinel,
+ /// lhs is index into ptr_type. rhs is the element type expression.
+ /// main_token is the asterisk if a pointer or the lbracket if a slice
+ /// main_token might be a ** token, which is shared with a parent/child
+ /// pointer type and may require special handling.
+ ptr_type,
+ /// lhs is index into ptr_type_bit_range. rhs is the element type expression.
+ /// main_token is the asterisk if a pointer or the lbracket if a slice
+ /// main_token might be a ** token, which is shared with a parent/child
+ /// pointer type and may require special handling.
+ ptr_type_bit_range,
+ /// `lhs[rhs..]`
+ /// main_token is the lbracket.
+ slice_open,
+ /// `lhs[b..c]`. rhs is index into Slice
+ /// main_token is the lbracket.
+ slice,
+ /// `lhs[b..c :d]`. rhs is index into SliceSentinel
+ /// main_token is the lbracket.
+ slice_sentinel,
+ /// `lhs.*`. rhs is unused.
+ deref,
+ /// `lhs[rhs]`.
+ array_access,
+ /// `lhs{rhs}`. rhs can be omitted.
+ array_init_one,
+ /// `lhs{rhs,}`. rhs can *not* be omitted
+ array_init_one_comma,
+ /// `.{lhs, rhs}`. lhs and rhs can be omitted.
+ array_init_dot_two,
+ /// Same as `array_init_dot_two` except there is known to be a trailing comma
+ /// before the final rbrace.
+ array_init_dot_two_comma,
+ /// `.{a, b}`. `sub_list[lhs..rhs]`.
+ array_init_dot,
+ /// Same as `array_init_dot` except there is known to be a trailing comma
+ /// before the final rbrace.
+ array_init_dot_comma,
+ /// `lhs{a, b}`. `sub_range_list[rhs]`. lhs can be omitted which means `.{a, b}`.
+ array_init,
+ /// Same as `array_init` except there is known to be a trailing comma
+ /// before the final rbrace.
+ array_init_comma,
+ /// `lhs{.a = rhs}`. rhs can be omitted making it empty.
+ /// main_token is the lbrace.
+ struct_init_one,
+ /// `lhs{.a = rhs,}`. rhs can *not* be omitted.
+ /// main_token is the lbrace.
+ struct_init_one_comma,
+ /// `.{.a = lhs, .b = rhs}`. lhs and rhs can be omitted.
+ /// main_token is the lbrace.
+ /// No trailing comma before the rbrace.
+ struct_init_dot_two,
+ /// Same as `struct_init_dot_two` except there is known to be a trailing comma
+ /// before the final rbrace.
+ struct_init_dot_two_comma,
+ /// `.{.a = b, .c = d}`. `sub_list[lhs..rhs]`.
+ /// main_token is the lbrace.
+ struct_init_dot,
+ /// Same as `struct_init_dot` except there is known to be a trailing comma
+ /// before the final rbrace.
+ struct_init_dot_comma,
+ /// `lhs{.a = b, .c = d}`. `sub_range_list[rhs]`.
+ /// lhs can be omitted which means `.{.a = b, .c = d}`.
+ /// main_token is the lbrace.
+ struct_init,
+ /// Same as `struct_init` except there is known to be a trailing comma
+ /// before the final rbrace.
+ struct_init_comma,
+ /// `lhs(rhs)`. rhs can be omitted.
+ /// main_token is the lparen.
+ call_one,
+ /// `lhs(rhs,)`. rhs can be omitted.
+ /// main_token is the lparen.
+ call_one_comma,
+ /// `async lhs(rhs)`. rhs can be omitted.
+ async_call_one,
+ /// `async lhs(rhs,)`.
+ async_call_one_comma,
+ /// `lhs(a, b, c)`. `SubRange[rhs]`.
+ /// main_token is the `(`.
+ call,
+ /// `lhs(a, b, c,)`. `SubRange[rhs]`.
+ /// main_token is the `(`.
+ call_comma,
+ /// `async lhs(a, b, c)`. `SubRange[rhs]`.
+ /// main_token is the `(`.
+ async_call,
+ /// `async lhs(a, b, c,)`. `SubRange[rhs]`.
+ /// main_token is the `(`.
+ async_call_comma,
+ /// `switch(lhs) {}`. `SubRange[rhs]`.
+ @"switch",
+ /// Same as switch except there is known to be a trailing comma
+ /// before the final rbrace
+ switch_comma,
+ /// `lhs => rhs`. If lhs is omitted it means `else`.
+ /// main_token is the `=>`
+ switch_case_one,
+ /// `a, b, c => rhs`. `SubRange[lhs]`.
+ /// main_token is the `=>`
+ switch_case,
+ /// `lhs...rhs`.
+ switch_range,
+ /// `while (lhs) rhs`.
+ /// `while (lhs) |x| rhs`.
+ while_simple,
+ /// `while (lhs) : (a) b`. `WhileCont[rhs]`.
+ /// `while (lhs) : (a) b`. `WhileCont[rhs]`.
+ while_cont,
+ /// `while (lhs) : (a) b else c`. `While[rhs]`.
+ /// `while (lhs) |x| : (a) b else c`. `While[rhs]`.
+ /// `while (lhs) |x| : (a) b else |y| c`. `While[rhs]`.
+ @"while",
+ /// `for (lhs) rhs`.
+ for_simple,
+ /// `for (lhs) a else b`. `if_list[rhs]`.
+ @"for",
+ /// `if (lhs) rhs`.
+ /// `if (lhs) |a| rhs`.
+ if_simple,
+ /// `if (lhs) a else b`. `If[rhs]`.
+ /// `if (lhs) |x| a else b`. `If[rhs]`.
+ /// `if (lhs) |x| a else |y| b`. `If[rhs]`.
+ @"if",
+ /// `suspend lhs`. lhs can be omitted. rhs is unused.
+ @"suspend",
+ /// `resume lhs`. rhs is unused.
+ @"resume",
+ /// `continue`. lhs is token index of label if any. rhs is unused.
+ @"continue",
+ /// `break :lhs rhs`
+ /// both lhs and rhs may be omitted.
+ @"break",
+ /// `return lhs`. lhs can be omitted. rhs is unused.
+ @"return",
+ /// `fn(a: lhs) rhs`. lhs can be omitted.
+ /// anytype and ... parameters are omitted from the AST tree.
+ /// main_token is the `fn` keyword.
+ /// extern function declarations use this tag.
+ fn_proto_simple,
+ /// `fn(a: b, c: d) rhs`. `sub_range_list[lhs]`.
+ /// anytype and ... parameters are omitted from the AST tree.
+ /// main_token is the `fn` keyword.
+ /// extern function declarations use this tag.
+ fn_proto_multi,
+ /// `fn(a: b) rhs linksection(e) callconv(f)`. `FnProtoOne[lhs]`.
+ /// zero or one parameters.
+ /// anytype and ... parameters are omitted from the AST tree.
+ /// main_token is the `fn` keyword.
+ /// extern function declarations use this tag.
+ fn_proto_one,
+ /// `fn(a: b, c: d) rhs linksection(e) callconv(f)`. `FnProto[lhs]`.
+ /// anytype and ... parameters are omitted from the AST tree.
+ /// main_token is the `fn` keyword.
+ /// extern function declarations use this tag.
+ fn_proto,
+ /// lhs is the fn_proto.
+ /// rhs is the function body block.
+ /// Note that extern function declarations use the fn_proto tags rather
+ /// than this one.
+ fn_decl,
+ /// `anyframe->rhs`. main_token is `anyframe`. `lhs` is arrow token index.
+ anyframe_type,
+ /// Both lhs and rhs unused.
+ anyframe_literal,
+ /// Both lhs and rhs unused.
+ char_literal,
+ /// Both lhs and rhs unused.
+ integer_literal,
+ /// Both lhs and rhs unused.
+ float_literal,
+ /// Both lhs and rhs unused.
+ unreachable_literal,
+ /// Both lhs and rhs unused.
+ /// Most identifiers will not have explicit AST nodes, however for expressions
+ /// which could be one of many different kinds of AST nodes, there will be an
+ /// identifier AST node for it.
+ identifier,
+ /// lhs is the dot token index, rhs unused, main_token is the identifier.
+ enum_literal,
+ /// main_token is the string literal token
+ /// Both lhs and rhs unused.
+ string_literal,
+ /// main_token is the first token index (redundant with lhs)
+ /// lhs is the first token index; rhs is the last token index.
+ /// Could be a series of multiline_string_literal_line tokens, or a single
+ /// string_literal token.
+ multiline_string_literal,
+ /// `(lhs)`. main_token is the `(`; rhs is the token index of the `)`.
+ grouped_expression,
+ /// `@a(lhs, rhs)`. lhs and rhs may be omitted.
+ /// main_token is the builtin token.
+ builtin_call_two,
+ /// Same as builtin_call_two but there is known to be a trailing comma before the rparen.
+ builtin_call_two_comma,
+ /// `@a(b, c)`. `sub_list[lhs..rhs]`.
+ /// main_token is the builtin token.
+ builtin_call,
+ /// Same as builtin_call but there is known to be a trailing comma before the rparen.
+ builtin_call_comma,
+ /// `error{a, b}`.
+ /// rhs is the rbrace, lhs is unused.
+ error_set_decl,
+ /// `struct {}`, `union {}`, `opaque {}`, `enum {}`. `extra_data[lhs..rhs]`.
+ /// main_token is `struct`, `union`, `opaque`, `enum` keyword.
+ container_decl,
+ /// Same as ContainerDecl but there is known to be a trailing comma
+ /// or semicolon before the rbrace.
+ container_decl_trailing,
+ /// `struct {lhs, rhs}`, `union {lhs, rhs}`, `opaque {lhs, rhs}`, `enum {lhs, rhs}`.
+ /// lhs or rhs can be omitted.
+ /// main_token is `struct`, `union`, `opaque`, `enum` keyword.
+ container_decl_two,
+ /// Same as ContainerDeclTwo except there is known to be a trailing comma
+ /// or semicolon before the rbrace.
+ container_decl_two_trailing,
+ /// `union(lhs)` / `enum(lhs)`. `SubRange[rhs]`.
+ container_decl_arg,
+ /// Same as container_decl_arg but there is known to be a trailing
+ /// comma or semicolon before the rbrace.
+ container_decl_arg_trailing,
+ /// `union(enum) {}`. `sub_list[lhs..rhs]`.
+ /// Note that tagged unions with explicitly provided enums are represented
+ /// by `container_decl_arg`.
+ tagged_union,
+ /// Same as tagged_union but there is known to be a trailing comma
+ /// or semicolon before the rbrace.
+ tagged_union_trailing,
+ /// `union(enum) {lhs, rhs}`. lhs or rhs may be omitted.
+ /// Note that tagged unions with explicitly provided enums are represented
+ /// by `container_decl_arg`.
+ tagged_union_two,
+ /// Same as tagged_union_two but there is known to be a trailing comma
+ /// or semicolon before the rbrace.
+ tagged_union_two_trailing,
+ /// `union(enum(lhs)) {}`. `SubRange[rhs]`.
+ tagged_union_enum_tag,
+ /// Same as tagged_union_enum_tag but there is known to be a trailing comma
+ /// or semicolon before the rbrace.
+ tagged_union_enum_tag_trailing,
+ /// `a: lhs = rhs,`. lhs and rhs can be omitted.
+ /// main_token is the field name identifier.
+ /// lastToken() does not include the possible trailing comma.
+ container_field_init,
+ /// `a: lhs align(rhs),`. rhs can be omitted.
+ /// main_token is the field name identifier.
+ /// lastToken() does not include the possible trailing comma.
+ container_field_align,
+ /// `a: lhs align(c) = d,`. `container_field_list[rhs]`.
+ /// main_token is the field name identifier.
+ /// lastToken() does not include the possible trailing comma.
+ container_field,
+ /// `anytype`. both lhs and rhs unused.
+ /// Used by `ContainerField`.
+ @"anytype",
+ /// `comptime lhs`. rhs unused.
+ @"comptime",
+ /// `nosuspend lhs`. rhs unused.
+ @"nosuspend",
+ /// `{lhs rhs}`. rhs or lhs can be omitted.
+ /// main_token points at the lbrace.
+ block_two,
+ /// Same as block_two but there is known to be a semicolon before the rbrace.
+ block_two_semicolon,
+ /// `{}`. `sub_list[lhs..rhs]`.
+ /// main_token points at the lbrace.
+ block,
+ /// Same as block but there is known to be a semicolon before the rbrace.
+ block_semicolon,
+ /// `asm(lhs)`. rhs is the token index of the rparen.
+ asm_simple,
+ /// `asm(lhs, a)`. `Asm[rhs]`.
+ @"asm",
+ /// `[a] "b" (c)`. lhs is 0, rhs is token index of the rparen.
+ /// `[a] "b" (-> lhs)`. rhs is token index of the rparen.
+ /// main_token is `a`.
+ asm_output,
+ /// `[a] "b" (lhs)`. rhs is token index of the rparen.
+ /// main_token is `a`.
+ asm_input,
+ /// `error.a`. lhs is token index of `.`. rhs is token index of `a`.
+ error_value,
+ /// `lhs!rhs`. main_token is the `!`.
+ error_union,
+
+ pub fn isContainerField(tag: Tag) bool {
+ return switch (tag) {
+ .container_field_init,
+ .container_field_align,
+ .container_field,
+ => true,
+
+ else => false,
+ };
+ }
+ };
+
+ pub const Data = struct {
+ lhs: Index,
+ rhs: Index,
+ };
+
+ pub const LocalVarDecl = struct {
+ type_node: Index,
+ align_node: Index,
+ };
+
+ pub const ArrayTypeSentinel = struct {
+ elem_type: Index,
+ sentinel: Index,
+ };
+
+ pub const PtrType = struct {
+ sentinel: Index,
+ align_node: Index,
+ };
+
+ pub const PtrTypeBitRange = struct {
+ sentinel: Index,
+ align_node: Index,
+ bit_range_start: Index,
+ bit_range_end: Index,
+ };
+
+ pub const SubRange = struct {
+ /// Index into sub_list.
+ start: Index,
+ /// Index into sub_list.
+ end: Index,
+ };
+
+ pub const If = struct {
+ then_expr: Index,
+ else_expr: Index,
+ };
+
+ pub const ContainerField = struct {
+ value_expr: Index,
+ align_expr: Index,
+ };
+
+ pub const GlobalVarDecl = struct {
+ type_node: Index,
+ align_node: Index,
+ section_node: Index,
+ };
+
+ pub const Slice = struct {
+ start: Index,
+ end: Index,
+ };
+
+ pub const SliceSentinel = struct {
+ start: Index,
+ /// May be 0 if the slice is "open"
+ end: Index,
+ sentinel: Index,
+ };
+
+ pub const While = struct {
+ cont_expr: Index,
+ then_expr: Index,
+ else_expr: Index,
+ };
+
+ pub const WhileCont = struct {
+ cont_expr: Index,
+ then_expr: Index,
+ };
+
+ pub const FnProtoOne = struct {
+ /// Populated if there is exactly 1 parameter. Otherwise there are 0 parameters.
+ param: Index,
+ /// Populated if align(A) is present.
+ align_expr: Index,
+ /// Populated if linksection(A) is present.
+ section_expr: Index,
+ /// Populated if callconv(A) is present.
+ callconv_expr: Index,
+ };
+
+ pub const FnProto = struct {
+ params_start: Index,
+ params_end: Index,
+ /// Populated if align(A) is present.
+ align_expr: Index,
+ /// Populated if linksection(A) is present.
+ section_expr: Index,
+ /// Populated if callconv(A) is present.
+ callconv_expr: Index,
+ };
+
+ pub const Asm = struct {
+ items_start: Index,
+ items_end: Index,
+ /// Needed to make lastToken() work.
+ rparen: TokenIndex,
+ };
+};
diff --git a/lib/std/zig/ast.zig b/lib/std/zig/ast.zig
deleted file mode 100644
index 535dc994839e..000000000000
--- a/lib/std/zig/ast.zig
+++ /dev/null
@@ -1,2978 +0,0 @@
-const std = @import("../std.zig");
-const assert = std.debug.assert;
-const testing = std.testing;
-const mem = std.mem;
-const Token = std.zig.Token;
-
-pub const TokenIndex = u32;
-pub const ByteOffset = u32;
-
-pub const TokenList = std.MultiArrayList(struct {
- tag: Token.Tag,
- start: ByteOffset,
-});
-pub const NodeList = std.MultiArrayList(Node);
-
-pub const Tree = struct {
- /// Reference to externally-owned data.
- source: [:0]const u8,
-
- tokens: TokenList.Slice,
- /// The root AST node is assumed to be index 0. Since there can be no
- /// references to the root node, this means 0 is available to indicate null.
- nodes: NodeList.Slice,
- extra_data: []Node.Index,
-
- errors: []const Error,
-
- pub const Location = struct {
- line: usize,
- column: usize,
- line_start: usize,
- line_end: usize,
- };
-
- pub fn deinit(tree: *Tree, gpa: *mem.Allocator) void {
- tree.tokens.deinit(gpa);
- tree.nodes.deinit(gpa);
- gpa.free(tree.extra_data);
- gpa.free(tree.errors);
- tree.* = undefined;
- }
-
- pub const RenderError = error{
- /// Ran out of memory allocating call stack frames to complete rendering, or
- /// ran out of memory allocating space in the output buffer.
- OutOfMemory,
- };
-
- /// `gpa` is used for allocating the resulting formatted source code, as well as
- /// for allocating extra stack memory if needed, because this function utilizes recursion.
- /// Note: that's not actually true yet, see https://github.com/ziglang/zig/issues/1006.
- /// Caller owns the returned slice of bytes, allocated with `gpa`.
- pub fn render(tree: Tree, gpa: *mem.Allocator) RenderError![]u8 {
- var buffer = std.ArrayList(u8).init(gpa);
- defer buffer.deinit();
-
- try tree.renderToArrayList(&buffer);
- return buffer.toOwnedSlice();
- }
-
- pub fn renderToArrayList(tree: Tree, buffer: *std.ArrayList(u8)) RenderError!void {
- return @import("./render.zig").renderTree(buffer, tree);
- }
-
- pub fn tokenLocation(self: Tree, start_offset: ByteOffset, token_index: TokenIndex) Location {
- var loc = Location{
- .line = 0,
- .column = 0,
- .line_start = start_offset,
- .line_end = self.source.len,
- };
- const token_start = self.tokens.items(.start)[token_index];
- for (self.source[start_offset..]) |c, i| {
- if (i + start_offset == token_start) {
- loc.line_end = i + start_offset;
- while (loc.line_end < self.source.len and self.source[loc.line_end] != '\n') {
- loc.line_end += 1;
- }
- return loc;
- }
- if (c == '\n') {
- loc.line += 1;
- loc.column = 0;
- loc.line_start = i + 1;
- } else {
- loc.column += 1;
- }
- }
- return loc;
- }
-
- pub fn tokenSlice(tree: Tree, token_index: TokenIndex) []const u8 {
- const token_starts = tree.tokens.items(.start);
- const token_tags = tree.tokens.items(.tag);
- const token_tag = token_tags[token_index];
-
- // Many tokens can be determined entirely by their tag.
- if (token_tag.lexeme()) |lexeme| {
- return lexeme;
- }
-
- // For some tokens, re-tokenization is needed to find the end.
- var tokenizer: std.zig.Tokenizer = .{
- .buffer = tree.source,
- .index = token_starts[token_index],
- .pending_invalid_token = null,
- };
- const token = tokenizer.next();
- assert(token.tag == token_tag);
- return tree.source[token.loc.start..token.loc.end];
- }
-
- pub fn extraData(tree: Tree, index: usize, comptime T: type) T {
- const fields = std.meta.fields(T);
- var result: T = undefined;
- inline for (fields) |field, i| {
- comptime assert(field.field_type == Node.Index);
- @field(result, field.name) = tree.extra_data[index + i];
- }
- return result;
- }
-
- pub fn rootDecls(tree: Tree) []const Node.Index {
- // Root is always index 0.
- const nodes_data = tree.nodes.items(.data);
- return tree.extra_data[nodes_data[0].lhs..nodes_data[0].rhs];
- }
-
- pub fn renderError(tree: Tree, parse_error: Error, stream: anytype) !void {
- const token_tags = tree.tokens.items(.tag);
- switch (parse_error.tag) {
- .asterisk_after_ptr_deref => {
- // Note that the token will point at the `.*` but ideally the source
- // location would point to the `*` after the `.*`.
- return stream.writeAll("'.*' cannot be followed by '*'. Are you missing a space?");
- },
- .decl_between_fields => {
- return stream.writeAll("declarations are not allowed between container fields");
- },
- .expected_block => {
- return stream.print("expected block or field, found '{s}'", .{
- token_tags[parse_error.token].symbol(),
- });
- },
- .expected_block_or_assignment => {
- return stream.print("expected block or assignment, found '{s}'", .{
- token_tags[parse_error.token].symbol(),
- });
- },
- .expected_block_or_expr => {
- return stream.print("expected block or expression, found '{s}'", .{
- token_tags[parse_error.token].symbol(),
- });
- },
- .expected_block_or_field => {
- return stream.print("expected block or field, found '{s}'", .{
- token_tags[parse_error.token].symbol(),
- });
- },
- .expected_container_members => {
- return stream.print("expected test, comptime, var decl, or container field, found '{s}'", .{
- token_tags[parse_error.token].symbol(),
- });
- },
- .expected_expr => {
- return stream.print("expected expression, found '{s}'", .{
- token_tags[parse_error.token].symbol(),
- });
- },
- .expected_expr_or_assignment => {
- return stream.print("expected expression or assignment, found '{s}'", .{
- token_tags[parse_error.token].symbol(),
- });
- },
- .expected_fn => {
- return stream.print("expected function, found '{s}'", .{
- token_tags[parse_error.token].symbol(),
- });
- },
- .expected_inlinable => {
- return stream.print("expected 'while' or 'for', found '{s}'", .{
- token_tags[parse_error.token].symbol(),
- });
- },
- .expected_labelable => {
- return stream.print("expected 'while', 'for', 'inline', 'suspend', or '{{', found '{s}'", .{
- token_tags[parse_error.token].symbol(),
- });
- },
- .expected_param_list => {
- return stream.print("expected parameter list, found '{s}'", .{
- token_tags[parse_error.token].symbol(),
- });
- },
- .expected_prefix_expr => {
- return stream.print("expected prefix expression, found '{s}'", .{
- token_tags[parse_error.token].symbol(),
- });
- },
- .expected_primary_type_expr => {
- return stream.print("expected primary type expression, found '{s}'", .{
- token_tags[parse_error.token].symbol(),
- });
- },
- .expected_pub_item => {
- return stream.writeAll("expected function or variable declaration after pub");
- },
- .expected_return_type => {
- return stream.print("expected return type expression, found '{s}'", .{
- token_tags[parse_error.token].symbol(),
- });
- },
- .expected_semi_or_else => {
- return stream.print("expected ';' or 'else', found '{s}'", .{
- token_tags[parse_error.token].symbol(),
- });
- },
- .expected_semi_or_lbrace => {
- return stream.print("expected ';' or '{{', found '{s}'", .{
- token_tags[parse_error.token].symbol(),
- });
- },
- .expected_statement => {
- return stream.print("expected statement, found '{s}'", .{
- token_tags[parse_error.token].symbol(),
- });
- },
- .expected_string_literal => {
- return stream.print("expected string literal, found '{s}'", .{
- token_tags[parse_error.token].symbol(),
- });
- },
- .expected_suffix_op => {
- return stream.print("expected pointer dereference, optional unwrap, or field access, found '{s}'", .{
- token_tags[parse_error.token].symbol(),
- });
- },
- .expected_type_expr => {
- return stream.print("expected type expression, found '{s}'", .{
- token_tags[parse_error.token].symbol(),
- });
- },
- .expected_var_decl => {
- return stream.print("expected variable declaration, found '{s}'", .{
- token_tags[parse_error.token].symbol(),
- });
- },
- .expected_var_decl_or_fn => {
- return stream.print("expected variable declaration or function, found '{s}'", .{
- token_tags[parse_error.token].symbol(),
- });
- },
- .expected_loop_payload => {
- return stream.print("expected loop payload, found '{s}'", .{
- token_tags[parse_error.token].symbol(),
- });
- },
- .expected_container => {
- return stream.print("expected a struct, enum or union, found '{s}'", .{
- token_tags[parse_error.token].symbol(),
- });
- },
- .extra_align_qualifier => {
- return stream.writeAll("extra align qualifier");
- },
- .extra_allowzero_qualifier => {
- return stream.writeAll("extra allowzero qualifier");
- },
- .extra_const_qualifier => {
- return stream.writeAll("extra const qualifier");
- },
- .extra_volatile_qualifier => {
- return stream.writeAll("extra volatile qualifier");
- },
- .ptr_mod_on_array_child_type => {
- return stream.print("pointer modifier '{s}' not allowed on array child type", .{
- token_tags[parse_error.token].symbol(),
- });
- },
- .invalid_bit_range => {
- return stream.writeAll("bit range not allowed on slices and arrays");
- },
- .invalid_token => {
- return stream.print("invalid token: '{s}'", .{
- token_tags[parse_error.token].symbol(),
- });
- },
- .same_line_doc_comment => {
- return stream.writeAll("same line documentation comment");
- },
- .unattached_doc_comment => {
- return stream.writeAll("unattached documentation comment");
- },
- .varargs_nonfinal => {
- return stream.writeAll("function prototype has parameter after varargs");
- },
-
- .expected_token => {
- const found_tag = token_tags[parse_error.token];
- const expected_symbol = parse_error.extra.expected_tag.symbol();
- switch (found_tag) {
- .invalid => return stream.print("expected '{s}', found invalid bytes", .{
- expected_symbol,
- }),
- else => return stream.print("expected '{s}', found '{s}'", .{
- expected_symbol, found_tag.symbol(),
- }),
- }
- },
- }
- }
-
- pub fn firstToken(tree: Tree, node: Node.Index) TokenIndex {
- const tags = tree.nodes.items(.tag);
- const datas = tree.nodes.items(.data);
- const main_tokens = tree.nodes.items(.main_token);
- const token_tags = tree.tokens.items(.tag);
- var end_offset: TokenIndex = 0;
- var n = node;
- while (true) switch (tags[n]) {
- .root => return 0,
-
- .test_decl,
- .@"errdefer",
- .@"defer",
- .bool_not,
- .negation,
- .bit_not,
- .negation_wrap,
- .address_of,
- .@"try",
- .@"await",
- .optional_type,
- .@"switch",
- .switch_comma,
- .if_simple,
- .@"if",
- .@"suspend",
- .@"resume",
- .@"continue",
- .@"break",
- .@"return",
- .anyframe_type,
- .identifier,
- .anyframe_literal,
- .char_literal,
- .integer_literal,
- .float_literal,
- .unreachable_literal,
- .string_literal,
- .multiline_string_literal,
- .grouped_expression,
- .builtin_call_two,
- .builtin_call_two_comma,
- .builtin_call,
- .builtin_call_comma,
- .error_set_decl,
- .@"anytype",
- .@"comptime",
- .@"nosuspend",
- .asm_simple,
- .@"asm",
- .array_type,
- .array_type_sentinel,
- .error_value,
- => return main_tokens[n] - end_offset,
-
- .array_init_dot,
- .array_init_dot_comma,
- .array_init_dot_two,
- .array_init_dot_two_comma,
- .struct_init_dot,
- .struct_init_dot_comma,
- .struct_init_dot_two,
- .struct_init_dot_two_comma,
- .enum_literal,
- => return main_tokens[n] - 1 - end_offset,
-
- .@"catch",
- .field_access,
- .unwrap_optional,
- .equal_equal,
- .bang_equal,
- .less_than,
- .greater_than,
- .less_or_equal,
- .greater_or_equal,
- .assign_mul,
- .assign_div,
- .assign_mod,
- .assign_add,
- .assign_sub,
- .assign_bit_shift_left,
- .assign_bit_shift_right,
- .assign_bit_and,
- .assign_bit_xor,
- .assign_bit_or,
- .assign_mul_wrap,
- .assign_add_wrap,
- .assign_sub_wrap,
- .assign,
- .merge_error_sets,
- .mul,
- .div,
- .mod,
- .array_mult,
- .mul_wrap,
- .add,
- .sub,
- .array_cat,
- .add_wrap,
- .sub_wrap,
- .bit_shift_left,
- .bit_shift_right,
- .bit_and,
- .bit_xor,
- .bit_or,
- .@"orelse",
- .bool_and,
- .bool_or,
- .slice_open,
- .slice,
- .slice_sentinel,
- .deref,
- .array_access,
- .array_init_one,
- .array_init_one_comma,
- .array_init,
- .array_init_comma,
- .struct_init_one,
- .struct_init_one_comma,
- .struct_init,
- .struct_init_comma,
- .call_one,
- .call_one_comma,
- .call,
- .call_comma,
- .switch_range,
- .error_union,
- => n = datas[n].lhs,
-
- .fn_decl,
- .fn_proto_simple,
- .fn_proto_multi,
- .fn_proto_one,
- .fn_proto,
- => {
- var i = main_tokens[n]; // fn token
- while (i > 0) {
- i -= 1;
- switch (token_tags[i]) {
- .keyword_extern,
- .keyword_export,
- .keyword_pub,
- .keyword_inline,
- .keyword_noinline,
- .string_literal,
- => continue,
-
- else => return i + 1 - end_offset,
- }
- }
- return i - end_offset;
- },
-
- .@"usingnamespace" => {
- const main_token = main_tokens[n];
- if (main_token > 0 and token_tags[main_token - 1] == .keyword_pub) {
- end_offset += 1;
- }
- return main_token - end_offset;
- },
-
- .async_call_one,
- .async_call_one_comma,
- .async_call,
- .async_call_comma,
- => {
- end_offset += 1; // async token
- n = datas[n].lhs;
- },
-
- .container_field_init,
- .container_field_align,
- .container_field,
- => {
- const name_token = main_tokens[n];
- if (name_token > 0 and token_tags[name_token - 1] == .keyword_comptime) {
- end_offset += 1;
- }
- return name_token - end_offset;
- },
-
- .global_var_decl,
- .local_var_decl,
- .simple_var_decl,
- .aligned_var_decl,
- => {
- var i = main_tokens[n]; // mut token
- while (i > 0) {
- i -= 1;
- switch (token_tags[i]) {
- .keyword_extern,
- .keyword_export,
- .keyword_comptime,
- .keyword_pub,
- .keyword_threadlocal,
- .string_literal,
- => continue,
-
- else => return i + 1 - end_offset,
- }
- }
- return i - end_offset;
- },
-
- .block,
- .block_semicolon,
- .block_two,
- .block_two_semicolon,
- => {
- // Look for a label.
- const lbrace = main_tokens[n];
- if (token_tags[lbrace - 1] == .colon and
- token_tags[lbrace - 2] == .identifier)
- {
- end_offset += 2;
- }
- return lbrace - end_offset;
- },
-
- .container_decl,
- .container_decl_trailing,
- .container_decl_two,
- .container_decl_two_trailing,
- .container_decl_arg,
- .container_decl_arg_trailing,
- .tagged_union,
- .tagged_union_trailing,
- .tagged_union_two,
- .tagged_union_two_trailing,
- .tagged_union_enum_tag,
- .tagged_union_enum_tag_trailing,
- => {
- const main_token = main_tokens[n];
- switch (token_tags[main_token - 1]) {
- .keyword_packed, .keyword_extern => end_offset += 1,
- else => {},
- }
- return main_token - end_offset;
- },
-
- .ptr_type_aligned,
- .ptr_type_sentinel,
- .ptr_type,
- .ptr_type_bit_range,
- => {
- const main_token = main_tokens[n];
- return switch (token_tags[main_token]) {
- .asterisk,
- .asterisk_asterisk,
- => switch (token_tags[main_token - 1]) {
- .l_bracket => main_token - 1,
- else => main_token,
- },
- .l_bracket => main_token,
- else => unreachable,
- } - end_offset;
- },
-
- .switch_case_one => {
- if (datas[n].lhs == 0) {
- return main_tokens[n] - 1 - end_offset; // else token
- } else {
- n = datas[n].lhs;
- }
- },
- .switch_case => {
- const extra = tree.extraData(datas[n].lhs, Node.SubRange);
- assert(extra.end - extra.start > 0);
- n = tree.extra_data[extra.start];
- },
-
- .asm_output, .asm_input => {
- assert(token_tags[main_tokens[n] - 1] == .l_bracket);
- return main_tokens[n] - 1 - end_offset;
- },
-
- .while_simple,
- .while_cont,
- .@"while",
- .for_simple,
- .@"for",
- => {
- // Look for a label and inline.
- const main_token = main_tokens[n];
- var result = main_token;
- if (token_tags[result - 1] == .keyword_inline) {
- result -= 1;
- }
- if (token_tags[result - 1] == .colon) {
- result -= 2;
- }
- return result - end_offset;
- },
- };
- }
-
- pub fn lastToken(tree: Tree, node: Node.Index) TokenIndex {
- const tags = tree.nodes.items(.tag);
- const datas = tree.nodes.items(.data);
- const main_tokens = tree.nodes.items(.main_token);
- const token_starts = tree.tokens.items(.start);
- const token_tags = tree.tokens.items(.tag);
- var n = node;
- var end_offset: TokenIndex = 0;
- while (true) switch (tags[n]) {
- .root => return @intCast(TokenIndex, tree.tokens.len - 1),
-
- .@"usingnamespace",
- .bool_not,
- .negation,
- .bit_not,
- .negation_wrap,
- .address_of,
- .@"try",
- .@"await",
- .optional_type,
- .@"resume",
- .@"nosuspend",
- .@"comptime",
- => n = datas[n].lhs,
-
- .test_decl,
- .@"errdefer",
- .@"defer",
- .@"catch",
- .equal_equal,
- .bang_equal,
- .less_than,
- .greater_than,
- .less_or_equal,
- .greater_or_equal,
- .assign_mul,
- .assign_div,
- .assign_mod,
- .assign_add,
- .assign_sub,
- .assign_bit_shift_left,
- .assign_bit_shift_right,
- .assign_bit_and,
- .assign_bit_xor,
- .assign_bit_or,
- .assign_mul_wrap,
- .assign_add_wrap,
- .assign_sub_wrap,
- .assign,
- .merge_error_sets,
- .mul,
- .div,
- .mod,
- .array_mult,
- .mul_wrap,
- .add,
- .sub,
- .array_cat,
- .add_wrap,
- .sub_wrap,
- .bit_shift_left,
- .bit_shift_right,
- .bit_and,
- .bit_xor,
- .bit_or,
- .@"orelse",
- .bool_and,
- .bool_or,
- .anyframe_type,
- .error_union,
- .if_simple,
- .while_simple,
- .for_simple,
- .fn_proto_simple,
- .fn_proto_multi,
- .ptr_type_aligned,
- .ptr_type_sentinel,
- .ptr_type,
- .ptr_type_bit_range,
- .array_type,
- .switch_case_one,
- .switch_case,
- .switch_range,
- => n = datas[n].rhs,
-
- .field_access,
- .unwrap_optional,
- .grouped_expression,
- .multiline_string_literal,
- .error_set_decl,
- .asm_simple,
- .asm_output,
- .asm_input,
- .error_value,
- => return datas[n].rhs + end_offset,
-
- .@"anytype",
- .anyframe_literal,
- .char_literal,
- .integer_literal,
- .float_literal,
- .unreachable_literal,
- .identifier,
- .deref,
- .enum_literal,
- .string_literal,
- => return main_tokens[n] + end_offset,
-
- .@"return" => if (datas[n].lhs != 0) {
- n = datas[n].lhs;
- } else {
- return main_tokens[n] + end_offset;
- },
-
- .call, .async_call => {
- end_offset += 1; // for the rparen
- const params = tree.extraData(datas[n].rhs, Node.SubRange);
- if (params.end - params.start == 0) {
- return main_tokens[n] + end_offset;
- }
- n = tree.extra_data[params.end - 1]; // last parameter
- },
- .tagged_union_enum_tag => {
- const members = tree.extraData(datas[n].rhs, Node.SubRange);
- if (members.end - members.start == 0) {
- end_offset += 4; // for the rparen + rparen + lbrace + rbrace
- n = datas[n].lhs;
- } else {
- end_offset += 1; // for the rbrace
- n = tree.extra_data[members.end - 1]; // last parameter
- }
- },
- .call_comma,
- .async_call_comma,
- .tagged_union_enum_tag_trailing,
- => {
- end_offset += 2; // for the comma/semicolon + rparen/rbrace
- const params = tree.extraData(datas[n].rhs, Node.SubRange);
- assert(params.end > params.start);
- n = tree.extra_data[params.end - 1]; // last parameter
- },
- .@"switch" => {
- const cases = tree.extraData(datas[n].rhs, Node.SubRange);
- if (cases.end - cases.start == 0) {
- end_offset += 3; // rparen, lbrace, rbrace
- n = datas[n].lhs; // condition expression
- } else {
- end_offset += 1; // for the rbrace
- n = tree.extra_data[cases.end - 1]; // last case
- }
- },
- .container_decl_arg => {
- const members = tree.extraData(datas[n].rhs, Node.SubRange);
- if (members.end - members.start == 0) {
- end_offset += 3; // for the rparen + lbrace + rbrace
- n = datas[n].lhs;
- } else {
- end_offset += 1; // for the rbrace
- n = tree.extra_data[members.end - 1]; // last parameter
- }
- },
- .@"asm" => {
- const extra = tree.extraData(datas[n].rhs, Node.Asm);
- return extra.rparen + end_offset;
- },
- .array_init,
- .struct_init,
- => {
- const elements = tree.extraData(datas[n].rhs, Node.SubRange);
- assert(elements.end - elements.start > 0);
- end_offset += 1; // for the rbrace
- n = tree.extra_data[elements.end - 1]; // last element
- },
- .array_init_comma,
- .struct_init_comma,
- .container_decl_arg_trailing,
- .switch_comma,
- => {
- const members = tree.extraData(datas[n].rhs, Node.SubRange);
- assert(members.end - members.start > 0);
- end_offset += 2; // for the comma + rbrace
- n = tree.extra_data[members.end - 1]; // last parameter
- },
- .array_init_dot,
- .struct_init_dot,
- .block,
- .container_decl,
- .tagged_union,
- .builtin_call,
- => {
- assert(datas[n].rhs - datas[n].lhs > 0);
- end_offset += 1; // for the rbrace
- n = tree.extra_data[datas[n].rhs - 1]; // last statement
- },
- .array_init_dot_comma,
- .struct_init_dot_comma,
- .block_semicolon,
- .container_decl_trailing,
- .tagged_union_trailing,
- .builtin_call_comma,
- => {
- assert(datas[n].rhs - datas[n].lhs > 0);
- end_offset += 2; // for the comma/semicolon + rbrace/rparen
- n = tree.extra_data[datas[n].rhs - 1]; // last member
- },
- .call_one,
- .async_call_one,
- .array_access,
- => {
- end_offset += 1; // for the rparen/rbracket
- if (datas[n].rhs == 0) {
- return main_tokens[n] + end_offset;
- }
- n = datas[n].rhs;
- },
- .array_init_dot_two,
- .block_two,
- .builtin_call_two,
- .struct_init_dot_two,
- .container_decl_two,
- .tagged_union_two,
- => {
- if (datas[n].rhs != 0) {
- end_offset += 1; // for the rparen/rbrace
- n = datas[n].rhs;
- } else if (datas[n].lhs != 0) {
- end_offset += 1; // for the rparen/rbrace
- n = datas[n].lhs;
- } else {
- switch (tags[n]) {
- .array_init_dot_two,
- .block_two,
- .struct_init_dot_two,
- => end_offset += 1, // rbrace
- .builtin_call_two => end_offset += 2, // lparen/lbrace + rparen/rbrace
- .container_decl_two => {
- var i: u32 = 2; // lbrace + rbrace
- while (token_tags[main_tokens[n] + i] == .container_doc_comment) i += 1;
- end_offset += i;
- },
- .tagged_union_two => {
- var i: u32 = 5; // (enum) {}
- while (token_tags[main_tokens[n] + i] == .container_doc_comment) i += 1;
- end_offset += i;
- },
- else => unreachable,
- }
- return main_tokens[n] + end_offset;
- }
- },
- .array_init_dot_two_comma,
- .builtin_call_two_comma,
- .block_two_semicolon,
- .struct_init_dot_two_comma,
- .container_decl_two_trailing,
- .tagged_union_two_trailing,
- => {
- end_offset += 2; // for the comma/semicolon + rbrace/rparen
- if (datas[n].rhs != 0) {
- n = datas[n].rhs;
- } else if (datas[n].lhs != 0) {
- n = datas[n].lhs;
- } else {
- unreachable;
- }
- },
- .simple_var_decl => {
- if (datas[n].rhs != 0) {
- n = datas[n].rhs;
- } else if (datas[n].lhs != 0) {
- n = datas[n].lhs;
- } else {
- end_offset += 1; // from mut token to name
- return main_tokens[n] + end_offset;
- }
- },
- .aligned_var_decl => {
- if (datas[n].rhs != 0) {
- n = datas[n].rhs;
- } else if (datas[n].lhs != 0) {
- end_offset += 1; // for the rparen
- n = datas[n].lhs;
- } else {
- end_offset += 1; // from mut token to name
- return main_tokens[n] + end_offset;
- }
- },
- .global_var_decl => {
- if (datas[n].rhs != 0) {
- n = datas[n].rhs;
- } else {
- const extra = tree.extraData(datas[n].lhs, Node.GlobalVarDecl);
- if (extra.section_node != 0) {
- end_offset += 1; // for the rparen
- n = extra.section_node;
- } else if (extra.align_node != 0) {
- end_offset += 1; // for the rparen
- n = extra.align_node;
- } else if (extra.type_node != 0) {
- n = extra.type_node;
- } else {
- end_offset += 1; // from mut token to name
- return main_tokens[n] + end_offset;
- }
- }
- },
- .local_var_decl => {
- if (datas[n].rhs != 0) {
- n = datas[n].rhs;
- } else {
- const extra = tree.extraData(datas[n].lhs, Node.LocalVarDecl);
- if (extra.align_node != 0) {
- end_offset += 1; // for the rparen
- n = extra.align_node;
- } else if (extra.type_node != 0) {
- n = extra.type_node;
- } else {
- end_offset += 1; // from mut token to name
- return main_tokens[n] + end_offset;
- }
- }
- },
- .container_field_init => {
- if (datas[n].rhs != 0) {
- n = datas[n].rhs;
- } else if (datas[n].lhs != 0) {
- n = datas[n].lhs;
- } else {
- return main_tokens[n] + end_offset;
- }
- },
- .container_field_align => {
- if (datas[n].rhs != 0) {
- end_offset += 1; // for the rparen
- n = datas[n].rhs;
- } else if (datas[n].lhs != 0) {
- n = datas[n].lhs;
- } else {
- return main_tokens[n] + end_offset;
- }
- },
- .container_field => {
- const extra = tree.extraData(datas[n].rhs, Node.ContainerField);
- if (extra.value_expr != 0) {
- n = extra.value_expr;
- } else if (extra.align_expr != 0) {
- end_offset += 1; // for the rparen
- n = extra.align_expr;
- } else if (datas[n].lhs != 0) {
- n = datas[n].lhs;
- } else {
- return main_tokens[n] + end_offset;
- }
- },
-
- .array_init_one,
- .struct_init_one,
- => {
- end_offset += 1; // rbrace
- if (datas[n].rhs == 0) {
- return main_tokens[n] + end_offset;
- } else {
- n = datas[n].rhs;
- }
- },
- .slice_open,
- .call_one_comma,
- .async_call_one_comma,
- .array_init_one_comma,
- .struct_init_one_comma,
- => {
- end_offset += 2; // ellipsis2 + rbracket, or comma + rparen
- n = datas[n].rhs;
- assert(n != 0);
- },
- .slice => {
- const extra = tree.extraData(datas[n].rhs, Node.Slice);
- assert(extra.end != 0); // should have used slice_open
- end_offset += 1; // rbracket
- n = extra.end;
- },
- .slice_sentinel => {
- const extra = tree.extraData(datas[n].rhs, Node.SliceSentinel);
- assert(extra.sentinel != 0); // should have used slice
- end_offset += 1; // rbracket
- n = extra.sentinel;
- },
-
- .@"continue" => {
- if (datas[n].lhs != 0) {
- return datas[n].lhs + end_offset;
- } else {
- return main_tokens[n] + end_offset;
- }
- },
- .@"break" => {
- if (datas[n].rhs != 0) {
- n = datas[n].rhs;
- } else if (datas[n].lhs != 0) {
- return datas[n].lhs + end_offset;
- } else {
- return main_tokens[n] + end_offset;
- }
- },
- .fn_decl => {
- if (datas[n].rhs != 0) {
- n = datas[n].rhs;
- } else {
- n = datas[n].lhs;
- }
- },
- .fn_proto_one => {
- const extra = tree.extraData(datas[n].lhs, Node.FnProtoOne);
- // linksection, callconv, align can appear in any order, so we
- // find the last one here.
- var max_node: Node.Index = datas[n].rhs;
- var max_start = token_starts[main_tokens[max_node]];
- var max_offset: TokenIndex = 0;
- if (extra.align_expr != 0) {
- const start = token_starts[main_tokens[extra.align_expr]];
- if (start > max_start) {
- max_node = extra.align_expr;
- max_start = start;
- max_offset = 1; // for the rparen
- }
- }
- if (extra.section_expr != 0) {
- const start = token_starts[main_tokens[extra.section_expr]];
- if (start > max_start) {
- max_node = extra.section_expr;
- max_start = start;
- max_offset = 1; // for the rparen
- }
- }
- if (extra.callconv_expr != 0) {
- const start = token_starts[main_tokens[extra.callconv_expr]];
- if (start > max_start) {
- max_node = extra.callconv_expr;
- max_start = start;
- max_offset = 1; // for the rparen
- }
- }
- n = max_node;
- end_offset += max_offset;
- },
- .fn_proto => {
- const extra = tree.extraData(datas[n].lhs, Node.FnProto);
- // linksection, callconv, align can appear in any order, so we
- // find the last one here.
- var max_node: Node.Index = datas[n].rhs;
- var max_start = token_starts[main_tokens[max_node]];
- var max_offset: TokenIndex = 0;
- if (extra.align_expr != 0) {
- const start = token_starts[main_tokens[extra.align_expr]];
- if (start > max_start) {
- max_node = extra.align_expr;
- max_start = start;
- max_offset = 1; // for the rparen
- }
- }
- if (extra.section_expr != 0) {
- const start = token_starts[main_tokens[extra.section_expr]];
- if (start > max_start) {
- max_node = extra.section_expr;
- max_start = start;
- max_offset = 1; // for the rparen
- }
- }
- if (extra.callconv_expr != 0) {
- const start = token_starts[main_tokens[extra.callconv_expr]];
- if (start > max_start) {
- max_node = extra.callconv_expr;
- max_start = start;
- max_offset = 1; // for the rparen
- }
- }
- n = max_node;
- end_offset += max_offset;
- },
- .while_cont => {
- const extra = tree.extraData(datas[n].rhs, Node.WhileCont);
- assert(extra.then_expr != 0);
- n = extra.then_expr;
- },
- .@"while" => {
- const extra = tree.extraData(datas[n].rhs, Node.While);
- assert(extra.else_expr != 0);
- n = extra.else_expr;
- },
- .@"if", .@"for" => {
- const extra = tree.extraData(datas[n].rhs, Node.If);
- assert(extra.else_expr != 0);
- n = extra.else_expr;
- },
- .@"suspend" => {
- if (datas[n].lhs != 0) {
- n = datas[n].lhs;
- } else {
- return main_tokens[n] + end_offset;
- }
- },
- .array_type_sentinel => {
- const extra = tree.extraData(datas[n].rhs, Node.ArrayTypeSentinel);
- n = extra.elem_type;
- },
- };
- }
-
- pub fn tokensOnSameLine(tree: Tree, token1: TokenIndex, token2: TokenIndex) bool {
- const token_starts = tree.tokens.items(.start);
- const source = tree.source[token_starts[token1]..token_starts[token2]];
- return mem.indexOfScalar(u8, source, '\n') == null;
- }
-
- pub fn getNodeSource(tree: Tree, node: Node.Index) []const u8 {
- const token_starts = tree.tokens.items(.start);
- const first_token = tree.firstToken(node);
- const last_token = tree.lastToken(node);
- const start = token_starts[first_token];
- const end = token_starts[last_token] + tree.tokenSlice(last_token).len;
- return tree.source[start..end];
- }
-
- pub fn globalVarDecl(tree: Tree, node: Node.Index) full.VarDecl {
- assert(tree.nodes.items(.tag)[node] == .global_var_decl);
- const data = tree.nodes.items(.data)[node];
- const extra = tree.extraData(data.lhs, Node.GlobalVarDecl);
- return tree.fullVarDecl(.{
- .type_node = extra.type_node,
- .align_node = extra.align_node,
- .section_node = extra.section_node,
- .init_node = data.rhs,
- .mut_token = tree.nodes.items(.main_token)[node],
- });
- }
-
- pub fn localVarDecl(tree: Tree, node: Node.Index) full.VarDecl {
- assert(tree.nodes.items(.tag)[node] == .local_var_decl);
- const data = tree.nodes.items(.data)[node];
- const extra = tree.extraData(data.lhs, Node.LocalVarDecl);
- return tree.fullVarDecl(.{
- .type_node = extra.type_node,
- .align_node = extra.align_node,
- .section_node = 0,
- .init_node = data.rhs,
- .mut_token = tree.nodes.items(.main_token)[node],
- });
- }
-
- pub fn simpleVarDecl(tree: Tree, node: Node.Index) full.VarDecl {
- assert(tree.nodes.items(.tag)[node] == .simple_var_decl);
- const data = tree.nodes.items(.data)[node];
- return tree.fullVarDecl(.{
- .type_node = data.lhs,
- .align_node = 0,
- .section_node = 0,
- .init_node = data.rhs,
- .mut_token = tree.nodes.items(.main_token)[node],
- });
- }
-
- pub fn alignedVarDecl(tree: Tree, node: Node.Index) full.VarDecl {
- assert(tree.nodes.items(.tag)[node] == .aligned_var_decl);
- const data = tree.nodes.items(.data)[node];
- return tree.fullVarDecl(.{
- .type_node = 0,
- .align_node = data.lhs,
- .section_node = 0,
- .init_node = data.rhs,
- .mut_token = tree.nodes.items(.main_token)[node],
- });
- }
-
- pub fn ifSimple(tree: Tree, node: Node.Index) full.If {
- assert(tree.nodes.items(.tag)[node] == .if_simple);
- const data = tree.nodes.items(.data)[node];
- return tree.fullIf(.{
- .cond_expr = data.lhs,
- .then_expr = data.rhs,
- .else_expr = 0,
- .if_token = tree.nodes.items(.main_token)[node],
- });
- }
-
- pub fn ifFull(tree: Tree, node: Node.Index) full.If {
- assert(tree.nodes.items(.tag)[node] == .@"if");
- const data = tree.nodes.items(.data)[node];
- const extra = tree.extraData(data.rhs, Node.If);
- return tree.fullIf(.{
- .cond_expr = data.lhs,
- .then_expr = extra.then_expr,
- .else_expr = extra.else_expr,
- .if_token = tree.nodes.items(.main_token)[node],
- });
- }
-
- pub fn containerField(tree: Tree, node: Node.Index) full.ContainerField {
- assert(tree.nodes.items(.tag)[node] == .container_field);
- const data = tree.nodes.items(.data)[node];
- const extra = tree.extraData(data.rhs, Node.ContainerField);
- return tree.fullContainerField(.{
- .name_token = tree.nodes.items(.main_token)[node],
- .type_expr = data.lhs,
- .value_expr = extra.value_expr,
- .align_expr = extra.align_expr,
- });
- }
-
- pub fn containerFieldInit(tree: Tree, node: Node.Index) full.ContainerField {
- assert(tree.nodes.items(.tag)[node] == .container_field_init);
- const data = tree.nodes.items(.data)[node];
- return tree.fullContainerField(.{
- .name_token = tree.nodes.items(.main_token)[node],
- .type_expr = data.lhs,
- .value_expr = data.rhs,
- .align_expr = 0,
- });
- }
-
- pub fn containerFieldAlign(tree: Tree, node: Node.Index) full.ContainerField {
- assert(tree.nodes.items(.tag)[node] == .container_field_align);
- const data = tree.nodes.items(.data)[node];
- return tree.fullContainerField(.{
- .name_token = tree.nodes.items(.main_token)[node],
- .type_expr = data.lhs,
- .value_expr = 0,
- .align_expr = data.rhs,
- });
- }
-
- pub fn fnProtoSimple(tree: Tree, buffer: *[1]Node.Index, node: Node.Index) full.FnProto {
- assert(tree.nodes.items(.tag)[node] == .fn_proto_simple);
- const data = tree.nodes.items(.data)[node];
- buffer[0] = data.lhs;
- const params = if (data.lhs == 0) buffer[0..0] else buffer[0..1];
- return tree.fullFnProto(.{
- .proto_node = node,
- .fn_token = tree.nodes.items(.main_token)[node],
- .return_type = data.rhs,
- .params = params,
- .align_expr = 0,
- .section_expr = 0,
- .callconv_expr = 0,
- });
- }
-
- pub fn fnProtoMulti(tree: Tree, node: Node.Index) full.FnProto {
- assert(tree.nodes.items(.tag)[node] == .fn_proto_multi);
- const data = tree.nodes.items(.data)[node];
- const params_range = tree.extraData(data.lhs, Node.SubRange);
- const params = tree.extra_data[params_range.start..params_range.end];
- return tree.fullFnProto(.{
- .proto_node = node,
- .fn_token = tree.nodes.items(.main_token)[node],
- .return_type = data.rhs,
- .params = params,
- .align_expr = 0,
- .section_expr = 0,
- .callconv_expr = 0,
- });
- }
-
- pub fn fnProtoOne(tree: Tree, buffer: *[1]Node.Index, node: Node.Index) full.FnProto {
- assert(tree.nodes.items(.tag)[node] == .fn_proto_one);
- const data = tree.nodes.items(.data)[node];
- const extra = tree.extraData(data.lhs, Node.FnProtoOne);
- buffer[0] = extra.param;
- const params = if (extra.param == 0) buffer[0..0] else buffer[0..1];
- return tree.fullFnProto(.{
- .proto_node = node,
- .fn_token = tree.nodes.items(.main_token)[node],
- .return_type = data.rhs,
- .params = params,
- .align_expr = extra.align_expr,
- .section_expr = extra.section_expr,
- .callconv_expr = extra.callconv_expr,
- });
- }
-
- pub fn fnProto(tree: Tree, node: Node.Index) full.FnProto {
- assert(tree.nodes.items(.tag)[node] == .fn_proto);
- const data = tree.nodes.items(.data)[node];
- const extra = tree.extraData(data.lhs, Node.FnProto);
- const params = tree.extra_data[extra.params_start..extra.params_end];
- return tree.fullFnProto(.{
- .proto_node = node,
- .fn_token = tree.nodes.items(.main_token)[node],
- .return_type = data.rhs,
- .params = params,
- .align_expr = extra.align_expr,
- .section_expr = extra.section_expr,
- .callconv_expr = extra.callconv_expr,
- });
- }
-
- pub fn structInitOne(tree: Tree, buffer: *[1]Node.Index, node: Node.Index) full.StructInit {
- assert(tree.nodes.items(.tag)[node] == .struct_init_one or
- tree.nodes.items(.tag)[node] == .struct_init_one_comma);
- const data = tree.nodes.items(.data)[node];
- buffer[0] = data.rhs;
- const fields = if (data.rhs == 0) buffer[0..0] else buffer[0..1];
- return tree.fullStructInit(.{
- .lbrace = tree.nodes.items(.main_token)[node],
- .fields = fields,
- .type_expr = data.lhs,
- });
- }
-
- pub fn structInitDotTwo(tree: Tree, buffer: *[2]Node.Index, node: Node.Index) full.StructInit {
- assert(tree.nodes.items(.tag)[node] == .struct_init_dot_two or
- tree.nodes.items(.tag)[node] == .struct_init_dot_two_comma);
- const data = tree.nodes.items(.data)[node];
- buffer.* = .{ data.lhs, data.rhs };
- const fields = if (data.rhs != 0)
- buffer[0..2]
- else if (data.lhs != 0)
- buffer[0..1]
- else
- buffer[0..0];
- return tree.fullStructInit(.{
- .lbrace = tree.nodes.items(.main_token)[node],
- .fields = fields,
- .type_expr = 0,
- });
- }
-
- pub fn structInitDot(tree: Tree, node: Node.Index) full.StructInit {
- assert(tree.nodes.items(.tag)[node] == .struct_init_dot or
- tree.nodes.items(.tag)[node] == .struct_init_dot_comma);
- const data = tree.nodes.items(.data)[node];
- return tree.fullStructInit(.{
- .lbrace = tree.nodes.items(.main_token)[node],
- .fields = tree.extra_data[data.lhs..data.rhs],
- .type_expr = 0,
- });
- }
-
- pub fn structInit(tree: Tree, node: Node.Index) full.StructInit {
- assert(tree.nodes.items(.tag)[node] == .struct_init or
- tree.nodes.items(.tag)[node] == .struct_init_comma);
- const data = tree.nodes.items(.data)[node];
- const fields_range = tree.extraData(data.rhs, Node.SubRange);
- return tree.fullStructInit(.{
- .lbrace = tree.nodes.items(.main_token)[node],
- .fields = tree.extra_data[fields_range.start..fields_range.end],
- .type_expr = data.lhs,
- });
- }
-
- pub fn arrayInitOne(tree: Tree, buffer: *[1]Node.Index, node: Node.Index) full.ArrayInit {
- assert(tree.nodes.items(.tag)[node] == .array_init_one or
- tree.nodes.items(.tag)[node] == .array_init_one_comma);
- const data = tree.nodes.items(.data)[node];
- buffer[0] = data.rhs;
- const elements = if (data.rhs == 0) buffer[0..0] else buffer[0..1];
- return .{
- .ast = .{
- .lbrace = tree.nodes.items(.main_token)[node],
- .elements = elements,
- .type_expr = data.lhs,
- },
- };
- }
-
- pub fn arrayInitDotTwo(tree: Tree, buffer: *[2]Node.Index, node: Node.Index) full.ArrayInit {
- assert(tree.nodes.items(.tag)[node] == .array_init_dot_two or
- tree.nodes.items(.tag)[node] == .array_init_dot_two_comma);
- const data = tree.nodes.items(.data)[node];
- buffer.* = .{ data.lhs, data.rhs };
- const elements = if (data.rhs != 0)
- buffer[0..2]
- else if (data.lhs != 0)
- buffer[0..1]
- else
- buffer[0..0];
- return .{
- .ast = .{
- .lbrace = tree.nodes.items(.main_token)[node],
- .elements = elements,
- .type_expr = 0,
- },
- };
- }
-
- pub fn arrayInitDot(tree: Tree, node: Node.Index) full.ArrayInit {
- assert(tree.nodes.items(.tag)[node] == .array_init_dot or
- tree.nodes.items(.tag)[node] == .array_init_dot_comma);
- const data = tree.nodes.items(.data)[node];
- return .{
- .ast = .{
- .lbrace = tree.nodes.items(.main_token)[node],
- .elements = tree.extra_data[data.lhs..data.rhs],
- .type_expr = 0,
- },
- };
- }
-
- pub fn arrayInit(tree: Tree, node: Node.Index) full.ArrayInit {
- assert(tree.nodes.items(.tag)[node] == .array_init or
- tree.nodes.items(.tag)[node] == .array_init_comma);
- const data = tree.nodes.items(.data)[node];
- const elem_range = tree.extraData(data.rhs, Node.SubRange);
- return .{
- .ast = .{
- .lbrace = tree.nodes.items(.main_token)[node],
- .elements = tree.extra_data[elem_range.start..elem_range.end],
- .type_expr = data.lhs,
- },
- };
- }
-
- pub fn arrayType(tree: Tree, node: Node.Index) full.ArrayType {
- assert(tree.nodes.items(.tag)[node] == .array_type);
- const data = tree.nodes.items(.data)[node];
- return .{
- .ast = .{
- .lbracket = tree.nodes.items(.main_token)[node],
- .elem_count = data.lhs,
- .sentinel = 0,
- .elem_type = data.rhs,
- },
- };
- }
-
- pub fn arrayTypeSentinel(tree: Tree, node: Node.Index) full.ArrayType {
- assert(tree.nodes.items(.tag)[node] == .array_type_sentinel);
- const data = tree.nodes.items(.data)[node];
- const extra = tree.extraData(data.rhs, Node.ArrayTypeSentinel);
- assert(extra.sentinel != 0);
- return .{
- .ast = .{
- .lbracket = tree.nodes.items(.main_token)[node],
- .elem_count = data.lhs,
- .sentinel = extra.sentinel,
- .elem_type = extra.elem_type,
- },
- };
- }
-
- pub fn ptrTypeAligned(tree: Tree, node: Node.Index) full.PtrType {
- assert(tree.nodes.items(.tag)[node] == .ptr_type_aligned);
- const data = tree.nodes.items(.data)[node];
- return tree.fullPtrType(.{
- .main_token = tree.nodes.items(.main_token)[node],
- .align_node = data.lhs,
- .sentinel = 0,
- .bit_range_start = 0,
- .bit_range_end = 0,
- .child_type = data.rhs,
- });
- }
-
- pub fn ptrTypeSentinel(tree: Tree, node: Node.Index) full.PtrType {
- assert(tree.nodes.items(.tag)[node] == .ptr_type_sentinel);
- const data = tree.nodes.items(.data)[node];
- return tree.fullPtrType(.{
- .main_token = tree.nodes.items(.main_token)[node],
- .align_node = 0,
- .sentinel = data.lhs,
- .bit_range_start = 0,
- .bit_range_end = 0,
- .child_type = data.rhs,
- });
- }
-
- pub fn ptrType(tree: Tree, node: Node.Index) full.PtrType {
- assert(tree.nodes.items(.tag)[node] == .ptr_type);
- const data = tree.nodes.items(.data)[node];
- const extra = tree.extraData(data.lhs, Node.PtrType);
- return tree.fullPtrType(.{
- .main_token = tree.nodes.items(.main_token)[node],
- .align_node = extra.align_node,
- .sentinel = extra.sentinel,
- .bit_range_start = 0,
- .bit_range_end = 0,
- .child_type = data.rhs,
- });
- }
-
- pub fn ptrTypeBitRange(tree: Tree, node: Node.Index) full.PtrType {
- assert(tree.nodes.items(.tag)[node] == .ptr_type_bit_range);
- const data = tree.nodes.items(.data)[node];
- const extra = tree.extraData(data.lhs, Node.PtrTypeBitRange);
- return tree.fullPtrType(.{
- .main_token = tree.nodes.items(.main_token)[node],
- .align_node = extra.align_node,
- .sentinel = extra.sentinel,
- .bit_range_start = extra.bit_range_start,
- .bit_range_end = extra.bit_range_end,
- .child_type = data.rhs,
- });
- }
-
- pub fn sliceOpen(tree: Tree, node: Node.Index) full.Slice {
- assert(tree.nodes.items(.tag)[node] == .slice_open);
- const data = tree.nodes.items(.data)[node];
- return .{
- .ast = .{
- .sliced = data.lhs,
- .lbracket = tree.nodes.items(.main_token)[node],
- .start = data.rhs,
- .end = 0,
- .sentinel = 0,
- },
- };
- }
-
- pub fn slice(tree: Tree, node: Node.Index) full.Slice {
- assert(tree.nodes.items(.tag)[node] == .slice);
- const data = tree.nodes.items(.data)[node];
- const extra = tree.extraData(data.rhs, Node.Slice);
- return .{
- .ast = .{
- .sliced = data.lhs,
- .lbracket = tree.nodes.items(.main_token)[node],
- .start = extra.start,
- .end = extra.end,
- .sentinel = 0,
- },
- };
- }
-
- pub fn sliceSentinel(tree: Tree, node: Node.Index) full.Slice {
- assert(tree.nodes.items(.tag)[node] == .slice_sentinel);
- const data = tree.nodes.items(.data)[node];
- const extra = tree.extraData(data.rhs, Node.SliceSentinel);
- return .{
- .ast = .{
- .sliced = data.lhs,
- .lbracket = tree.nodes.items(.main_token)[node],
- .start = extra.start,
- .end = extra.end,
- .sentinel = extra.sentinel,
- },
- };
- }
-
- pub fn containerDeclTwo(tree: Tree, buffer: *[2]Node.Index, node: Node.Index) full.ContainerDecl {
- assert(tree.nodes.items(.tag)[node] == .container_decl_two or
- tree.nodes.items(.tag)[node] == .container_decl_two_trailing);
- const data = tree.nodes.items(.data)[node];
- buffer.* = .{ data.lhs, data.rhs };
- const members = if (data.rhs != 0)
- buffer[0..2]
- else if (data.lhs != 0)
- buffer[0..1]
- else
- buffer[0..0];
- return tree.fullContainerDecl(.{
- .main_token = tree.nodes.items(.main_token)[node],
- .enum_token = null,
- .members = members,
- .arg = 0,
- });
- }
-
- pub fn containerDecl(tree: Tree, node: Node.Index) full.ContainerDecl {
- assert(tree.nodes.items(.tag)[node] == .container_decl or
- tree.nodes.items(.tag)[node] == .container_decl_trailing);
- const data = tree.nodes.items(.data)[node];
- return tree.fullContainerDecl(.{
- .main_token = tree.nodes.items(.main_token)[node],
- .enum_token = null,
- .members = tree.extra_data[data.lhs..data.rhs],
- .arg = 0,
- });
- }
-
- pub fn containerDeclArg(tree: Tree, node: Node.Index) full.ContainerDecl {
- assert(tree.nodes.items(.tag)[node] == .container_decl_arg or
- tree.nodes.items(.tag)[node] == .container_decl_arg_trailing);
- const data = tree.nodes.items(.data)[node];
- const members_range = tree.extraData(data.rhs, Node.SubRange);
- return tree.fullContainerDecl(.{
- .main_token = tree.nodes.items(.main_token)[node],
- .enum_token = null,
- .members = tree.extra_data[members_range.start..members_range.end],
- .arg = data.lhs,
- });
- }
-
- pub fn taggedUnionTwo(tree: Tree, buffer: *[2]Node.Index, node: Node.Index) full.ContainerDecl {
- assert(tree.nodes.items(.tag)[node] == .tagged_union_two or
- tree.nodes.items(.tag)[node] == .tagged_union_two_trailing);
- const data = tree.nodes.items(.data)[node];
- buffer.* = .{ data.lhs, data.rhs };
- const members = if (data.rhs != 0)
- buffer[0..2]
- else if (data.lhs != 0)
- buffer[0..1]
- else
- buffer[0..0];
- const main_token = tree.nodes.items(.main_token)[node];
- return tree.fullContainerDecl(.{
- .main_token = main_token,
- .enum_token = main_token + 2, // union lparen enum
- .members = members,
- .arg = 0,
- });
- }
-
- pub fn taggedUnion(tree: Tree, node: Node.Index) full.ContainerDecl {
- assert(tree.nodes.items(.tag)[node] == .tagged_union or
- tree.nodes.items(.tag)[node] == .tagged_union_trailing);
- const data = tree.nodes.items(.data)[node];
- const main_token = tree.nodes.items(.main_token)[node];
- return tree.fullContainerDecl(.{
- .main_token = main_token,
- .enum_token = main_token + 2, // union lparen enum
- .members = tree.extra_data[data.lhs..data.rhs],
- .arg = 0,
- });
- }
-
- pub fn taggedUnionEnumTag(tree: Tree, node: Node.Index) full.ContainerDecl {
- assert(tree.nodes.items(.tag)[node] == .tagged_union_enum_tag or
- tree.nodes.items(.tag)[node] == .tagged_union_enum_tag_trailing);
- const data = tree.nodes.items(.data)[node];
- const members_range = tree.extraData(data.rhs, Node.SubRange);
- const main_token = tree.nodes.items(.main_token)[node];
- return tree.fullContainerDecl(.{
- .main_token = main_token,
- .enum_token = main_token + 2, // union lparen enum
- .members = tree.extra_data[members_range.start..members_range.end],
- .arg = data.lhs,
- });
- }
-
- pub fn switchCaseOne(tree: Tree, node: Node.Index) full.SwitchCase {
- const data = &tree.nodes.items(.data)[node];
- const values: *[1]Node.Index = &data.lhs;
- return tree.fullSwitchCase(.{
- .values = if (data.lhs == 0) values[0..0] else values[0..1],
- .arrow_token = tree.nodes.items(.main_token)[node],
- .target_expr = data.rhs,
- });
- }
-
- pub fn switchCase(tree: Tree, node: Node.Index) full.SwitchCase {
- const data = tree.nodes.items(.data)[node];
- const extra = tree.extraData(data.lhs, Node.SubRange);
- return tree.fullSwitchCase(.{
- .values = tree.extra_data[extra.start..extra.end],
- .arrow_token = tree.nodes.items(.main_token)[node],
- .target_expr = data.rhs,
- });
- }
-
- pub fn asmSimple(tree: Tree, node: Node.Index) full.Asm {
- const data = tree.nodes.items(.data)[node];
- return tree.fullAsm(.{
- .asm_token = tree.nodes.items(.main_token)[node],
- .template = data.lhs,
- .items = &.{},
- .rparen = data.rhs,
- });
- }
-
- pub fn asmFull(tree: Tree, node: Node.Index) full.Asm {
- const data = tree.nodes.items(.data)[node];
- const extra = tree.extraData(data.rhs, Node.Asm);
- return tree.fullAsm(.{
- .asm_token = tree.nodes.items(.main_token)[node],
- .template = data.lhs,
- .items = tree.extra_data[extra.items_start..extra.items_end],
- .rparen = extra.rparen,
- });
- }
-
- pub fn whileSimple(tree: Tree, node: Node.Index) full.While {
- const data = tree.nodes.items(.data)[node];
- return tree.fullWhile(.{
- .while_token = tree.nodes.items(.main_token)[node],
- .cond_expr = data.lhs,
- .cont_expr = 0,
- .then_expr = data.rhs,
- .else_expr = 0,
- });
- }
-
- pub fn whileCont(tree: Tree, node: Node.Index) full.While {
- const data = tree.nodes.items(.data)[node];
- const extra = tree.extraData(data.rhs, Node.WhileCont);
- return tree.fullWhile(.{
- .while_token = tree.nodes.items(.main_token)[node],
- .cond_expr = data.lhs,
- .cont_expr = extra.cont_expr,
- .then_expr = extra.then_expr,
- .else_expr = 0,
- });
- }
-
- pub fn whileFull(tree: Tree, node: Node.Index) full.While {
- const data = tree.nodes.items(.data)[node];
- const extra = tree.extraData(data.rhs, Node.While);
- return tree.fullWhile(.{
- .while_token = tree.nodes.items(.main_token)[node],
- .cond_expr = data.lhs,
- .cont_expr = extra.cont_expr,
- .then_expr = extra.then_expr,
- .else_expr = extra.else_expr,
- });
- }
-
- pub fn forSimple(tree: Tree, node: Node.Index) full.While {
- const data = tree.nodes.items(.data)[node];
- return tree.fullWhile(.{
- .while_token = tree.nodes.items(.main_token)[node],
- .cond_expr = data.lhs,
- .cont_expr = 0,
- .then_expr = data.rhs,
- .else_expr = 0,
- });
- }
-
- pub fn forFull(tree: Tree, node: Node.Index) full.While {
- const data = tree.nodes.items(.data)[node];
- const extra = tree.extraData(data.rhs, Node.If);
- return tree.fullWhile(.{
- .while_token = tree.nodes.items(.main_token)[node],
- .cond_expr = data.lhs,
- .cont_expr = 0,
- .then_expr = extra.then_expr,
- .else_expr = extra.else_expr,
- });
- }
-
- pub fn callOne(tree: Tree, buffer: *[1]Node.Index, node: Node.Index) full.Call {
- const data = tree.nodes.items(.data)[node];
- buffer.* = .{data.rhs};
- const params = if (data.rhs != 0) buffer[0..1] else buffer[0..0];
- return tree.fullCall(.{
- .lparen = tree.nodes.items(.main_token)[node],
- .fn_expr = data.lhs,
- .params = params,
- });
- }
-
- pub fn callFull(tree: Tree, node: Node.Index) full.Call {
- const data = tree.nodes.items(.data)[node];
- const extra = tree.extraData(data.rhs, Node.SubRange);
- return tree.fullCall(.{
- .lparen = tree.nodes.items(.main_token)[node],
- .fn_expr = data.lhs,
- .params = tree.extra_data[extra.start..extra.end],
- });
- }
-
- fn fullVarDecl(tree: Tree, info: full.VarDecl.Ast) full.VarDecl {
- const token_tags = tree.tokens.items(.tag);
- var result: full.VarDecl = .{
- .ast = info,
- .visib_token = null,
- .extern_export_token = null,
- .lib_name = null,
- .threadlocal_token = null,
- .comptime_token = null,
- };
- var i = info.mut_token;
- while (i > 0) {
- i -= 1;
- switch (token_tags[i]) {
- .keyword_extern, .keyword_export => result.extern_export_token = i,
- .keyword_comptime => result.comptime_token = i,
- .keyword_pub => result.visib_token = i,
- .keyword_threadlocal => result.threadlocal_token = i,
- .string_literal => result.lib_name = i,
- else => break,
- }
- }
- return result;
- }
-
- fn fullIf(tree: Tree, info: full.If.Ast) full.If {
- const token_tags = tree.tokens.items(.tag);
- var result: full.If = .{
- .ast = info,
- .payload_token = null,
- .error_token = null,
- .else_token = undefined,
- };
- // if (cond_expr) |x|
- // ^ ^
- const payload_pipe = tree.lastToken(info.cond_expr) + 2;
- if (token_tags[payload_pipe] == .pipe) {
- result.payload_token = payload_pipe + 1;
- }
- if (info.else_expr != 0) {
- // then_expr else |x|
- // ^ ^
- result.else_token = tree.lastToken(info.then_expr) + 1;
- if (token_tags[result.else_token + 1] == .pipe) {
- result.error_token = result.else_token + 2;
- }
- }
- return result;
- }
-
- fn fullContainerField(tree: Tree, info: full.ContainerField.Ast) full.ContainerField {
- const token_tags = tree.tokens.items(.tag);
- var result: full.ContainerField = .{
- .ast = info,
- .comptime_token = null,
- };
- // comptime name: type = init,
- // ^
- if (info.name_token > 0 and token_tags[info.name_token - 1] == .keyword_comptime) {
- result.comptime_token = info.name_token - 1;
- }
- return result;
- }
-
- fn fullFnProto(tree: Tree, info: full.FnProto.Ast) full.FnProto {
- const token_tags = tree.tokens.items(.tag);
- var result: full.FnProto = .{
- .ast = info,
- .visib_token = null,
- .extern_export_inline_token = null,
- .lib_name = null,
- .name_token = null,
- .lparen = undefined,
- };
- var i = info.fn_token;
- while (i > 0) {
- i -= 1;
- switch (token_tags[i]) {
- .keyword_extern,
- .keyword_export,
- .keyword_inline,
- .keyword_noinline,
- => result.extern_export_inline_token = i,
- .keyword_pub => result.visib_token = i,
- .string_literal => result.lib_name = i,
- else => break,
- }
- }
- const after_fn_token = info.fn_token + 1;
- if (token_tags[after_fn_token] == .identifier) {
- result.name_token = after_fn_token;
- result.lparen = after_fn_token + 1;
- } else {
- result.lparen = after_fn_token;
- }
- assert(token_tags[result.lparen] == .l_paren);
-
- return result;
- }
-
- fn fullStructInit(tree: Tree, info: full.StructInit.Ast) full.StructInit {
- _ = tree;
- var result: full.StructInit = .{
- .ast = info,
- };
- return result;
- }
-
- fn fullPtrType(tree: Tree, info: full.PtrType.Ast) full.PtrType {
- const token_tags = tree.tokens.items(.tag);
- // TODO: looks like stage1 isn't quite smart enough to handle enum
- // literals in some places here
- const Size = std.builtin.TypeInfo.Pointer.Size;
- const size: Size = switch (token_tags[info.main_token]) {
- .asterisk,
- .asterisk_asterisk,
- => switch (token_tags[info.main_token + 1]) {
- .r_bracket, .colon => .Many,
- .identifier => if (token_tags[info.main_token - 1] == .l_bracket) Size.C else .One,
- else => .One,
- },
- .l_bracket => Size.Slice,
- else => unreachable,
- };
- var result: full.PtrType = .{
- .size = size,
- .allowzero_token = null,
- .const_token = null,
- .volatile_token = null,
- .ast = info,
- };
- // We need to be careful that we don't iterate over any sub-expressions
- // here while looking for modifiers as that could result in false
- // positives. Therefore, start after a sentinel if there is one and
- // skip over any align node and bit range nodes.
- var i = if (info.sentinel != 0) tree.lastToken(info.sentinel) + 1 else info.main_token;
- const end = tree.firstToken(info.child_type);
- while (i < end) : (i += 1) {
- switch (token_tags[i]) {
- .keyword_allowzero => result.allowzero_token = i,
- .keyword_const => result.const_token = i,
- .keyword_volatile => result.volatile_token = i,
- .keyword_align => {
- assert(info.align_node != 0);
- if (info.bit_range_end != 0) {
- assert(info.bit_range_start != 0);
- i = tree.lastToken(info.bit_range_end) + 1;
- } else {
- i = tree.lastToken(info.align_node) + 1;
- }
- },
- else => {},
- }
- }
- return result;
- }
-
- fn fullContainerDecl(tree: Tree, info: full.ContainerDecl.Ast) full.ContainerDecl {
- const token_tags = tree.tokens.items(.tag);
- var result: full.ContainerDecl = .{
- .ast = info,
- .layout_token = null,
- };
- switch (token_tags[info.main_token - 1]) {
- .keyword_extern, .keyword_packed => result.layout_token = info.main_token - 1,
- else => {},
- }
- return result;
- }
-
- fn fullSwitchCase(tree: Tree, info: full.SwitchCase.Ast) full.SwitchCase {
- const token_tags = tree.tokens.items(.tag);
- var result: full.SwitchCase = .{
- .ast = info,
- .payload_token = null,
- };
- if (token_tags[info.arrow_token + 1] == .pipe) {
- result.payload_token = info.arrow_token + 2;
- }
- return result;
- }
-
- fn fullAsm(tree: Tree, info: full.Asm.Ast) full.Asm {
- const token_tags = tree.tokens.items(.tag);
- const node_tags = tree.nodes.items(.tag);
- var result: full.Asm = .{
- .ast = info,
- .volatile_token = null,
- .inputs = &.{},
- .outputs = &.{},
- .first_clobber = null,
- };
- if (token_tags[info.asm_token + 1] == .keyword_volatile) {
- result.volatile_token = info.asm_token + 1;
- }
- const outputs_end: usize = for (info.items) |item, i| {
- switch (node_tags[item]) {
- .asm_output => continue,
- else => break i,
- }
- } else info.items.len;
-
- result.outputs = info.items[0..outputs_end];
- result.inputs = info.items[outputs_end..];
-
- if (info.items.len == 0) {
- // asm ("foo" ::: "a", "b");
- const template_token = tree.lastToken(info.template);
- if (token_tags[template_token + 1] == .colon and
- token_tags[template_token + 2] == .colon and
- token_tags[template_token + 3] == .colon and
- token_tags[template_token + 4] == .string_literal)
- {
- result.first_clobber = template_token + 4;
- }
- } else if (result.inputs.len != 0) {
- // asm ("foo" :: [_] "" (y) : "a", "b");
- const last_input = result.inputs[result.inputs.len - 1];
- const rparen = tree.lastToken(last_input);
- var i = rparen + 1;
- // Allow a (useless) comma right after the closing parenthesis.
- if (token_tags[i] == .comma) i += 1;
- if (token_tags[i] == .colon and
- token_tags[i + 1] == .string_literal)
- {
- result.first_clobber = i + 1;
- }
- } else {
- // asm ("foo" : [_] "" (x) :: "a", "b");
- const last_output = result.outputs[result.outputs.len - 1];
- const rparen = tree.lastToken(last_output);
- var i = rparen + 1;
- // Allow a (useless) comma right after the closing parenthesis.
- if (token_tags[i] == .comma) i += 1;
- if (token_tags[i] == .colon and
- token_tags[i + 1] == .colon and
- token_tags[i + 2] == .string_literal)
- {
- result.first_clobber = i + 2;
- }
- }
-
- return result;
- }
-
- fn fullWhile(tree: Tree, info: full.While.Ast) full.While {
- const token_tags = tree.tokens.items(.tag);
- var result: full.While = .{
- .ast = info,
- .inline_token = null,
- .label_token = null,
- .payload_token = null,
- .else_token = undefined,
- .error_token = null,
- };
- var tok_i = info.while_token - 1;
- if (token_tags[tok_i] == .keyword_inline) {
- result.inline_token = tok_i;
- tok_i -= 1;
- }
- if (token_tags[tok_i] == .colon and
- token_tags[tok_i - 1] == .identifier)
- {
- result.label_token = tok_i - 1;
- }
- const last_cond_token = tree.lastToken(info.cond_expr);
- if (token_tags[last_cond_token + 2] == .pipe) {
- result.payload_token = last_cond_token + 3;
- }
- if (info.else_expr != 0) {
- // then_expr else |x|
- // ^ ^
- result.else_token = tree.lastToken(info.then_expr) + 1;
- if (token_tags[result.else_token + 1] == .pipe) {
- result.error_token = result.else_token + 2;
- }
- }
- return result;
- }
-
- fn fullCall(tree: Tree, info: full.Call.Ast) full.Call {
- const token_tags = tree.tokens.items(.tag);
- var result: full.Call = .{
- .ast = info,
- .async_token = null,
- };
- const maybe_async_token = tree.firstToken(info.fn_expr) - 1;
- if (token_tags[maybe_async_token] == .keyword_async) {
- result.async_token = maybe_async_token;
- }
- return result;
- }
-};
-
-/// Fully assembled AST node information.
-pub const full = struct {
- pub const VarDecl = struct {
- visib_token: ?TokenIndex,
- extern_export_token: ?TokenIndex,
- lib_name: ?TokenIndex,
- threadlocal_token: ?TokenIndex,
- comptime_token: ?TokenIndex,
- ast: Ast,
-
- pub const Ast = struct {
- mut_token: TokenIndex,
- type_node: Node.Index,
- align_node: Node.Index,
- section_node: Node.Index,
- init_node: Node.Index,
- };
- };
-
- pub const If = struct {
- /// Points to the first token after the `|`. Will either be an identifier or
- /// a `*` (with an identifier immediately after it).
- payload_token: ?TokenIndex,
- /// Points to the identifier after the `|`.
- error_token: ?TokenIndex,
- /// Populated only if else_expr != 0.
- else_token: TokenIndex,
- ast: Ast,
-
- pub const Ast = struct {
- if_token: TokenIndex,
- cond_expr: Node.Index,
- then_expr: Node.Index,
- else_expr: Node.Index,
- };
- };
-
- pub const While = struct {
- ast: Ast,
- inline_token: ?TokenIndex,
- label_token: ?TokenIndex,
- payload_token: ?TokenIndex,
- error_token: ?TokenIndex,
- /// Populated only if else_expr != 0.
- else_token: TokenIndex,
-
- pub const Ast = struct {
- while_token: TokenIndex,
- cond_expr: Node.Index,
- cont_expr: Node.Index,
- then_expr: Node.Index,
- else_expr: Node.Index,
- };
- };
-
- pub const ContainerField = struct {
- comptime_token: ?TokenIndex,
- ast: Ast,
-
- pub const Ast = struct {
- name_token: TokenIndex,
- type_expr: Node.Index,
- value_expr: Node.Index,
- align_expr: Node.Index,
- };
- };
-
- pub const FnProto = struct {
- visib_token: ?TokenIndex,
- extern_export_inline_token: ?TokenIndex,
- lib_name: ?TokenIndex,
- name_token: ?TokenIndex,
- lparen: TokenIndex,
- ast: Ast,
-
- pub const Ast = struct {
- proto_node: Node.Index,
- fn_token: TokenIndex,
- return_type: Node.Index,
- params: []const Node.Index,
- align_expr: Node.Index,
- section_expr: Node.Index,
- callconv_expr: Node.Index,
- };
-
- pub const Param = struct {
- first_doc_comment: ?TokenIndex,
- name_token: ?TokenIndex,
- comptime_noalias: ?TokenIndex,
- anytype_ellipsis3: ?TokenIndex,
- type_expr: Node.Index,
- };
-
- /// Abstracts over the fact that anytype and ... are not included
- /// in the params slice, since they are simple identifiers and
- /// not sub-expressions.
- pub const Iterator = struct {
- tree: *const Tree,
- fn_proto: *const FnProto,
- param_i: usize,
- tok_i: TokenIndex,
- tok_flag: bool,
-
- pub fn next(it: *Iterator) ?Param {
- const token_tags = it.tree.tokens.items(.tag);
- while (true) {
- var first_doc_comment: ?TokenIndex = null;
- var comptime_noalias: ?TokenIndex = null;
- var name_token: ?TokenIndex = null;
- if (!it.tok_flag) {
- if (it.param_i >= it.fn_proto.ast.params.len) {
- return null;
- }
- const param_type = it.fn_proto.ast.params[it.param_i];
- var tok_i = it.tree.firstToken(param_type) - 1;
- while (true) : (tok_i -= 1) switch (token_tags[tok_i]) {
- .colon => continue,
- .identifier => name_token = tok_i,
- .doc_comment => first_doc_comment = tok_i,
- .keyword_comptime, .keyword_noalias => comptime_noalias = tok_i,
- else => break,
- };
- it.param_i += 1;
- it.tok_i = it.tree.lastToken(param_type) + 1;
- // Look for anytype and ... params afterwards.
- if (token_tags[it.tok_i] == .comma) {
- it.tok_i += 1;
- }
- it.tok_flag = true;
- return Param{
- .first_doc_comment = first_doc_comment,
- .comptime_noalias = comptime_noalias,
- .name_token = name_token,
- .anytype_ellipsis3 = null,
- .type_expr = param_type,
- };
- }
- if (token_tags[it.tok_i] == .comma) {
- it.tok_i += 1;
- }
- if (token_tags[it.tok_i] == .r_paren) {
- return null;
- }
- if (token_tags[it.tok_i] == .doc_comment) {
- first_doc_comment = it.tok_i;
- while (token_tags[it.tok_i] == .doc_comment) {
- it.tok_i += 1;
- }
- }
- switch (token_tags[it.tok_i]) {
- .ellipsis3 => {
- it.tok_flag = false; // Next iteration should return null.
- return Param{
- .first_doc_comment = first_doc_comment,
- .comptime_noalias = null,
- .name_token = null,
- .anytype_ellipsis3 = it.tok_i,
- .type_expr = 0,
- };
- },
- .keyword_noalias, .keyword_comptime => {
- comptime_noalias = it.tok_i;
- it.tok_i += 1;
- },
- else => {},
- }
- if (token_tags[it.tok_i] == .identifier and
- token_tags[it.tok_i + 1] == .colon)
- {
- name_token = it.tok_i;
- it.tok_i += 2;
- }
- if (token_tags[it.tok_i] == .keyword_anytype) {
- it.tok_i += 1;
- return Param{
- .first_doc_comment = first_doc_comment,
- .comptime_noalias = comptime_noalias,
- .name_token = name_token,
- .anytype_ellipsis3 = it.tok_i - 1,
- .type_expr = 0,
- };
- }
- it.tok_flag = false;
- }
- }
- };
-
- pub fn iterate(fn_proto: FnProto, tree: Tree) Iterator {
- return .{
- .tree = &tree,
- .fn_proto = &fn_proto,
- .param_i = 0,
- .tok_i = fn_proto.lparen + 1,
- .tok_flag = true,
- };
- }
- };
-
- pub const StructInit = struct {
- ast: Ast,
-
- pub const Ast = struct {
- lbrace: TokenIndex,
- fields: []const Node.Index,
- type_expr: Node.Index,
- };
- };
-
- pub const ArrayInit = struct {
- ast: Ast,
-
- pub const Ast = struct {
- lbrace: TokenIndex,
- elements: []const Node.Index,
- type_expr: Node.Index,
- };
- };
-
- pub const ArrayType = struct {
- ast: Ast,
-
- pub const Ast = struct {
- lbracket: TokenIndex,
- elem_count: Node.Index,
- sentinel: Node.Index,
- elem_type: Node.Index,
- };
- };
-
- pub const PtrType = struct {
- size: std.builtin.TypeInfo.Pointer.Size,
- allowzero_token: ?TokenIndex,
- const_token: ?TokenIndex,
- volatile_token: ?TokenIndex,
- ast: Ast,
-
- pub const Ast = struct {
- main_token: TokenIndex,
- align_node: Node.Index,
- sentinel: Node.Index,
- bit_range_start: Node.Index,
- bit_range_end: Node.Index,
- child_type: Node.Index,
- };
- };
-
- pub const Slice = struct {
- ast: Ast,
-
- pub const Ast = struct {
- sliced: Node.Index,
- lbracket: TokenIndex,
- start: Node.Index,
- end: Node.Index,
- sentinel: Node.Index,
- };
- };
-
- pub const ContainerDecl = struct {
- layout_token: ?TokenIndex,
- ast: Ast,
-
- pub const Ast = struct {
- main_token: TokenIndex,
- /// Populated when main_token is Keyword_union.
- enum_token: ?TokenIndex,
- members: []const Node.Index,
- arg: Node.Index,
- };
- };
-
- pub const SwitchCase = struct {
- /// Points to the first token after the `|`. Will either be an identifier or
- /// a `*` (with an identifier immediately after it).
- payload_token: ?TokenIndex,
- ast: Ast,
-
- pub const Ast = struct {
- /// If empty, this is an else case
- values: []const Node.Index,
- arrow_token: TokenIndex,
- target_expr: Node.Index,
- };
- };
-
- pub const Asm = struct {
- ast: Ast,
- volatile_token: ?TokenIndex,
- first_clobber: ?TokenIndex,
- outputs: []const Node.Index,
- inputs: []const Node.Index,
-
- pub const Ast = struct {
- asm_token: TokenIndex,
- template: Node.Index,
- items: []const Node.Index,
- rparen: TokenIndex,
- };
- };
-
- pub const Call = struct {
- ast: Ast,
- async_token: ?TokenIndex,
-
- pub const Ast = struct {
- lparen: TokenIndex,
- fn_expr: Node.Index,
- params: []const Node.Index,
- };
- };
-};
-
-pub const Error = struct {
- tag: Tag,
- token: TokenIndex,
- extra: union {
- none: void,
- expected_tag: Token.Tag,
- } = .{ .none = {} },
-
- pub const Tag = enum {
- asterisk_after_ptr_deref,
- decl_between_fields,
- expected_block,
- expected_block_or_assignment,
- expected_block_or_expr,
- expected_block_or_field,
- expected_container_members,
- expected_expr,
- expected_expr_or_assignment,
- expected_fn,
- expected_inlinable,
- expected_labelable,
- expected_param_list,
- expected_prefix_expr,
- expected_primary_type_expr,
- expected_pub_item,
- expected_return_type,
- expected_semi_or_else,
- expected_semi_or_lbrace,
- expected_statement,
- expected_string_literal,
- expected_suffix_op,
- expected_type_expr,
- expected_var_decl,
- expected_var_decl_or_fn,
- expected_loop_payload,
- expected_container,
- extra_align_qualifier,
- extra_allowzero_qualifier,
- extra_const_qualifier,
- extra_volatile_qualifier,
- ptr_mod_on_array_child_type,
- invalid_bit_range,
- invalid_token,
- same_line_doc_comment,
- unattached_doc_comment,
- varargs_nonfinal,
-
- /// `expected_tag` is populated.
- expected_token,
- };
-};
-
-pub const Node = struct {
- tag: Tag,
- main_token: TokenIndex,
- data: Data,
-
- pub const Index = u32;
-
- comptime {
- // Goal is to keep this under one byte for efficiency.
- assert(@sizeOf(Tag) == 1);
- }
-
- /// Note: The FooComma/FooSemicolon variants exist to ease the implementation of
- /// Tree.lastToken()
- pub const Tag = enum {
- /// sub_list[lhs...rhs]
- root,
- /// `usingnamespace lhs;`. rhs unused. main_token is `usingnamespace`.
- @"usingnamespace",
- /// lhs is test name token (must be string literal), if any.
- /// rhs is the body node.
- test_decl,
- /// lhs is the index into extra_data.
- /// rhs is the initialization expression, if any.
- /// main_token is `var` or `const`.
- global_var_decl,
- /// `var a: x align(y) = rhs`
- /// lhs is the index into extra_data.
- /// main_token is `var` or `const`.
- local_var_decl,
- /// `var a: lhs = rhs`. lhs and rhs may be unused.
- /// Can be local or global.
- /// main_token is `var` or `const`.
- simple_var_decl,
- /// `var a align(lhs) = rhs`. lhs and rhs may be unused.
- /// Can be local or global.
- /// main_token is `var` or `const`.
- aligned_var_decl,
- /// lhs is the identifier token payload if any,
- /// rhs is the deferred expression.
- @"errdefer",
- /// lhs is unused.
- /// rhs is the deferred expression.
- @"defer",
- /// lhs catch rhs
- /// lhs catch |err| rhs
- /// main_token is the `catch` keyword.
- /// payload is determined by looking at the next token after the `catch` keyword.
- @"catch",
- /// `lhs.a`. main_token is the dot. rhs is the identifier token index.
- field_access,
- /// `lhs.?`. main_token is the dot. rhs is the `?` token index.
- unwrap_optional,
- /// `lhs == rhs`. main_token is op.
- equal_equal,
- /// `lhs != rhs`. main_token is op.
- bang_equal,
- /// `lhs < rhs`. main_token is op.
- less_than,
- /// `lhs > rhs`. main_token is op.
- greater_than,
- /// `lhs <= rhs`. main_token is op.
- less_or_equal,
- /// `lhs >= rhs`. main_token is op.
- greater_or_equal,
- /// `lhs *= rhs`. main_token is op.
- assign_mul,
- /// `lhs /= rhs`. main_token is op.
- assign_div,
- /// `lhs *= rhs`. main_token is op.
- assign_mod,
- /// `lhs += rhs`. main_token is op.
- assign_add,
- /// `lhs -= rhs`. main_token is op.
- assign_sub,
- /// `lhs <<= rhs`. main_token is op.
- assign_bit_shift_left,
- /// `lhs >>= rhs`. main_token is op.
- assign_bit_shift_right,
- /// `lhs &= rhs`. main_token is op.
- assign_bit_and,
- /// `lhs ^= rhs`. main_token is op.
- assign_bit_xor,
- /// `lhs |= rhs`. main_token is op.
- assign_bit_or,
- /// `lhs *%= rhs`. main_token is op.
- assign_mul_wrap,
- /// `lhs +%= rhs`. main_token is op.
- assign_add_wrap,
- /// `lhs -%= rhs`. main_token is op.
- assign_sub_wrap,
- /// `lhs = rhs`. main_token is op.
- assign,
- /// `lhs || rhs`. main_token is the `||`.
- merge_error_sets,
- /// `lhs * rhs`. main_token is the `*`.
- mul,
- /// `lhs / rhs`. main_token is the `/`.
- div,
- /// `lhs % rhs`. main_token is the `%`.
- mod,
- /// `lhs ** rhs`. main_token is the `**`.
- array_mult,
- /// `lhs *% rhs`. main_token is the `*%`.
- mul_wrap,
- /// `lhs + rhs`. main_token is the `+`.
- add,
- /// `lhs - rhs`. main_token is the `-`.
- sub,
- /// `lhs ++ rhs`. main_token is the `++`.
- array_cat,
- /// `lhs +% rhs`. main_token is the `+%`.
- add_wrap,
- /// `lhs -% rhs`. main_token is the `-%`.
- sub_wrap,
- /// `lhs << rhs`. main_token is the `<<`.
- bit_shift_left,
- /// `lhs >> rhs`. main_token is the `>>`.
- bit_shift_right,
- /// `lhs & rhs`. main_token is the `&`.
- bit_and,
- /// `lhs ^ rhs`. main_token is the `^`.
- bit_xor,
- /// `lhs | rhs`. main_token is the `|`.
- bit_or,
- /// `lhs orelse rhs`. main_token is the `orelse`.
- @"orelse",
- /// `lhs and rhs`. main_token is the `and`.
- bool_and,
- /// `lhs or rhs`. main_token is the `or`.
- bool_or,
- /// `op lhs`. rhs unused. main_token is op.
- bool_not,
- /// `op lhs`. rhs unused. main_token is op.
- negation,
- /// `op lhs`. rhs unused. main_token is op.
- bit_not,
- /// `op lhs`. rhs unused. main_token is op.
- negation_wrap,
- /// `op lhs`. rhs unused. main_token is op.
- address_of,
- /// `op lhs`. rhs unused. main_token is op.
- @"try",
- /// `op lhs`. rhs unused. main_token is op.
- @"await",
- /// `?lhs`. rhs unused. main_token is the `?`.
- optional_type,
- /// `[lhs]rhs`.
- array_type,
- /// `[lhs:a]b`. `ArrayTypeSentinel[rhs]`.
- array_type_sentinel,
- /// `[*]align(lhs) rhs`. lhs can be omitted.
- /// `*align(lhs) rhs`. lhs can be omitted.
- /// `[]rhs`.
- /// main_token is the asterisk if a pointer or the lbracket if a slice
- /// main_token might be a ** token, which is shared with a parent/child
- /// pointer type and may require special handling.
- ptr_type_aligned,
- /// `[*:lhs]rhs`. lhs can be omitted.
- /// `*rhs`.
- /// `[:lhs]rhs`.
- /// main_token is the asterisk if a pointer or the lbracket if a slice
- /// main_token might be a ** token, which is shared with a parent/child
- /// pointer type and may require special handling.
- ptr_type_sentinel,
- /// lhs is index into ptr_type. rhs is the element type expression.
- /// main_token is the asterisk if a pointer or the lbracket if a slice
- /// main_token might be a ** token, which is shared with a parent/child
- /// pointer type and may require special handling.
- ptr_type,
- /// lhs is index into ptr_type_bit_range. rhs is the element type expression.
- /// main_token is the asterisk if a pointer or the lbracket if a slice
- /// main_token might be a ** token, which is shared with a parent/child
- /// pointer type and may require special handling.
- ptr_type_bit_range,
- /// `lhs[rhs..]`
- /// main_token is the lbracket.
- slice_open,
- /// `lhs[b..c]`. rhs is index into Slice
- /// main_token is the lbracket.
- slice,
- /// `lhs[b..c :d]`. rhs is index into SliceSentinel
- /// main_token is the lbracket.
- slice_sentinel,
- /// `lhs.*`. rhs is unused.
- deref,
- /// `lhs[rhs]`.
- array_access,
- /// `lhs{rhs}`. rhs can be omitted.
- array_init_one,
- /// `lhs{rhs,}`. rhs can *not* be omitted
- array_init_one_comma,
- /// `.{lhs, rhs}`. lhs and rhs can be omitted.
- array_init_dot_two,
- /// Same as `array_init_dot_two` except there is known to be a trailing comma
- /// before the final rbrace.
- array_init_dot_two_comma,
- /// `.{a, b}`. `sub_list[lhs..rhs]`.
- array_init_dot,
- /// Same as `array_init_dot` except there is known to be a trailing comma
- /// before the final rbrace.
- array_init_dot_comma,
- /// `lhs{a, b}`. `sub_range_list[rhs]`. lhs can be omitted which means `.{a, b}`.
- array_init,
- /// Same as `array_init` except there is known to be a trailing comma
- /// before the final rbrace.
- array_init_comma,
- /// `lhs{.a = rhs}`. rhs can be omitted making it empty.
- /// main_token is the lbrace.
- struct_init_one,
- /// `lhs{.a = rhs,}`. rhs can *not* be omitted.
- /// main_token is the lbrace.
- struct_init_one_comma,
- /// `.{.a = lhs, .b = rhs}`. lhs and rhs can be omitted.
- /// main_token is the lbrace.
- /// No trailing comma before the rbrace.
- struct_init_dot_two,
- /// Same as `struct_init_dot_two` except there is known to be a trailing comma
- /// before the final rbrace.
- struct_init_dot_two_comma,
- /// `.{.a = b, .c = d}`. `sub_list[lhs..rhs]`.
- /// main_token is the lbrace.
- struct_init_dot,
- /// Same as `struct_init_dot` except there is known to be a trailing comma
- /// before the final rbrace.
- struct_init_dot_comma,
- /// `lhs{.a = b, .c = d}`. `sub_range_list[rhs]`.
- /// lhs can be omitted which means `.{.a = b, .c = d}`.
- /// main_token is the lbrace.
- struct_init,
- /// Same as `struct_init` except there is known to be a trailing comma
- /// before the final rbrace.
- struct_init_comma,
- /// `lhs(rhs)`. rhs can be omitted.
- /// main_token is the lparen.
- call_one,
- /// `lhs(rhs,)`. rhs can be omitted.
- /// main_token is the lparen.
- call_one_comma,
- /// `async lhs(rhs)`. rhs can be omitted.
- async_call_one,
- /// `async lhs(rhs,)`.
- async_call_one_comma,
- /// `lhs(a, b, c)`. `SubRange[rhs]`.
- /// main_token is the `(`.
- call,
- /// `lhs(a, b, c,)`. `SubRange[rhs]`.
- /// main_token is the `(`.
- call_comma,
- /// `async lhs(a, b, c)`. `SubRange[rhs]`.
- /// main_token is the `(`.
- async_call,
- /// `async lhs(a, b, c,)`. `SubRange[rhs]`.
- /// main_token is the `(`.
- async_call_comma,
- /// `switch(lhs) {}`. `SubRange[rhs]`.
- @"switch",
- /// Same as switch except there is known to be a trailing comma
- /// before the final rbrace
- switch_comma,
- /// `lhs => rhs`. If lhs is omitted it means `else`.
- /// main_token is the `=>`
- switch_case_one,
- /// `a, b, c => rhs`. `SubRange[lhs]`.
- /// main_token is the `=>`
- switch_case,
- /// `lhs...rhs`.
- switch_range,
- /// `while (lhs) rhs`.
- /// `while (lhs) |x| rhs`.
- while_simple,
- /// `while (lhs) : (a) b`. `WhileCont[rhs]`.
- /// `while (lhs) : (a) b`. `WhileCont[rhs]`.
- while_cont,
- /// `while (lhs) : (a) b else c`. `While[rhs]`.
- /// `while (lhs) |x| : (a) b else c`. `While[rhs]`.
- /// `while (lhs) |x| : (a) b else |y| c`. `While[rhs]`.
- @"while",
- /// `for (lhs) rhs`.
- for_simple,
- /// `for (lhs) a else b`. `if_list[rhs]`.
- @"for",
- /// `if (lhs) rhs`.
- /// `if (lhs) |a| rhs`.
- if_simple,
- /// `if (lhs) a else b`. `If[rhs]`.
- /// `if (lhs) |x| a else b`. `If[rhs]`.
- /// `if (lhs) |x| a else |y| b`. `If[rhs]`.
- @"if",
- /// `suspend lhs`. lhs can be omitted. rhs is unused.
- @"suspend",
- /// `resume lhs`. rhs is unused.
- @"resume",
- /// `continue`. lhs is token index of label if any. rhs is unused.
- @"continue",
- /// `break :lhs rhs`
- /// both lhs and rhs may be omitted.
- @"break",
- /// `return lhs`. lhs can be omitted. rhs is unused.
- @"return",
- /// `fn(a: lhs) rhs`. lhs can be omitted.
- /// anytype and ... parameters are omitted from the AST tree.
- /// main_token is the `fn` keyword.
- /// extern function declarations use this tag.
- fn_proto_simple,
- /// `fn(a: b, c: d) rhs`. `sub_range_list[lhs]`.
- /// anytype and ... parameters are omitted from the AST tree.
- /// main_token is the `fn` keyword.
- /// extern function declarations use this tag.
- fn_proto_multi,
- /// `fn(a: b) rhs linksection(e) callconv(f)`. `FnProtoOne[lhs]`.
- /// zero or one parameters.
- /// anytype and ... parameters are omitted from the AST tree.
- /// main_token is the `fn` keyword.
- /// extern function declarations use this tag.
- fn_proto_one,
- /// `fn(a: b, c: d) rhs linksection(e) callconv(f)`. `FnProto[lhs]`.
- /// anytype and ... parameters are omitted from the AST tree.
- /// main_token is the `fn` keyword.
- /// extern function declarations use this tag.
- fn_proto,
- /// lhs is the fn_proto.
- /// rhs is the function body block.
- /// Note that extern function declarations use the fn_proto tags rather
- /// than this one.
- fn_decl,
- /// `anyframe->rhs`. main_token is `anyframe`. `lhs` is arrow token index.
- anyframe_type,
- /// Both lhs and rhs unused.
- anyframe_literal,
- /// Both lhs and rhs unused.
- char_literal,
- /// Both lhs and rhs unused.
- integer_literal,
- /// Both lhs and rhs unused.
- float_literal,
- /// Both lhs and rhs unused.
- unreachable_literal,
- /// Both lhs and rhs unused.
- /// Most identifiers will not have explicit AST nodes, however for expressions
- /// which could be one of many different kinds of AST nodes, there will be an
- /// identifier AST node for it.
- identifier,
- /// lhs is the dot token index, rhs unused, main_token is the identifier.
- enum_literal,
- /// main_token is the string literal token
- /// Both lhs and rhs unused.
- string_literal,
- /// main_token is the first token index (redundant with lhs)
- /// lhs is the first token index; rhs is the last token index.
- /// Could be a series of multiline_string_literal_line tokens, or a single
- /// string_literal token.
- multiline_string_literal,
- /// `(lhs)`. main_token is the `(`; rhs is the token index of the `)`.
- grouped_expression,
- /// `@a(lhs, rhs)`. lhs and rhs may be omitted.
- /// main_token is the builtin token.
- builtin_call_two,
- /// Same as builtin_call_two but there is known to be a trailing comma before the rparen.
- builtin_call_two_comma,
- /// `@a(b, c)`. `sub_list[lhs..rhs]`.
- /// main_token is the builtin token.
- builtin_call,
- /// Same as builtin_call but there is known to be a trailing comma before the rparen.
- builtin_call_comma,
- /// `error{a, b}`.
- /// rhs is the rbrace, lhs is unused.
- error_set_decl,
- /// `struct {}`, `union {}`, `opaque {}`, `enum {}`. `extra_data[lhs..rhs]`.
- /// main_token is `struct`, `union`, `opaque`, `enum` keyword.
- container_decl,
- /// Same as ContainerDecl but there is known to be a trailing comma
- /// or semicolon before the rbrace.
- container_decl_trailing,
- /// `struct {lhs, rhs}`, `union {lhs, rhs}`, `opaque {lhs, rhs}`, `enum {lhs, rhs}`.
- /// lhs or rhs can be omitted.
- /// main_token is `struct`, `union`, `opaque`, `enum` keyword.
- container_decl_two,
- /// Same as ContainerDeclTwo except there is known to be a trailing comma
- /// or semicolon before the rbrace.
- container_decl_two_trailing,
- /// `union(lhs)` / `enum(lhs)`. `SubRange[rhs]`.
- container_decl_arg,
- /// Same as container_decl_arg but there is known to be a trailing
- /// comma or semicolon before the rbrace.
- container_decl_arg_trailing,
- /// `union(enum) {}`. `sub_list[lhs..rhs]`.
- /// Note that tagged unions with explicitly provided enums are represented
- /// by `container_decl_arg`.
- tagged_union,
- /// Same as tagged_union but there is known to be a trailing comma
- /// or semicolon before the rbrace.
- tagged_union_trailing,
- /// `union(enum) {lhs, rhs}`. lhs or rhs may be omitted.
- /// Note that tagged unions with explicitly provided enums are represented
- /// by `container_decl_arg`.
- tagged_union_two,
- /// Same as tagged_union_two but there is known to be a trailing comma
- /// or semicolon before the rbrace.
- tagged_union_two_trailing,
- /// `union(enum(lhs)) {}`. `SubRange[rhs]`.
- tagged_union_enum_tag,
- /// Same as tagged_union_enum_tag but there is known to be a trailing comma
- /// or semicolon before the rbrace.
- tagged_union_enum_tag_trailing,
- /// `a: lhs = rhs,`. lhs and rhs can be omitted.
- /// main_token is the field name identifier.
- /// lastToken() does not include the possible trailing comma.
- container_field_init,
- /// `a: lhs align(rhs),`. rhs can be omitted.
- /// main_token is the field name identifier.
- /// lastToken() does not include the possible trailing comma.
- container_field_align,
- /// `a: lhs align(c) = d,`. `container_field_list[rhs]`.
- /// main_token is the field name identifier.
- /// lastToken() does not include the possible trailing comma.
- container_field,
- /// `anytype`. both lhs and rhs unused.
- /// Used by `ContainerField`.
- @"anytype",
- /// `comptime lhs`. rhs unused.
- @"comptime",
- /// `nosuspend lhs`. rhs unused.
- @"nosuspend",
- /// `{lhs rhs}`. rhs or lhs can be omitted.
- /// main_token points at the lbrace.
- block_two,
- /// Same as block_two but there is known to be a semicolon before the rbrace.
- block_two_semicolon,
- /// `{}`. `sub_list[lhs..rhs]`.
- /// main_token points at the lbrace.
- block,
- /// Same as block but there is known to be a semicolon before the rbrace.
- block_semicolon,
- /// `asm(lhs)`. rhs is the token index of the rparen.
- asm_simple,
- /// `asm(lhs, a)`. `Asm[rhs]`.
- @"asm",
- /// `[a] "b" (c)`. lhs is 0, rhs is token index of the rparen.
- /// `[a] "b" (-> lhs)`. rhs is token index of the rparen.
- /// main_token is `a`.
- asm_output,
- /// `[a] "b" (lhs)`. rhs is token index of the rparen.
- /// main_token is `a`.
- asm_input,
- /// `error.a`. lhs is token index of `.`. rhs is token index of `a`.
- error_value,
- /// `lhs!rhs`. main_token is the `!`.
- error_union,
-
- pub fn isContainerField(tag: Tag) bool {
- return switch (tag) {
- .container_field_init,
- .container_field_align,
- .container_field,
- => true,
-
- else => false,
- };
- }
- };
-
- pub const Data = struct {
- lhs: Index,
- rhs: Index,
- };
-
- pub const LocalVarDecl = struct {
- type_node: Index,
- align_node: Index,
- };
-
- pub const ArrayTypeSentinel = struct {
- elem_type: Index,
- sentinel: Index,
- };
-
- pub const PtrType = struct {
- sentinel: Index,
- align_node: Index,
- };
-
- pub const PtrTypeBitRange = struct {
- sentinel: Index,
- align_node: Index,
- bit_range_start: Index,
- bit_range_end: Index,
- };
-
- pub const SubRange = struct {
- /// Index into sub_list.
- start: Index,
- /// Index into sub_list.
- end: Index,
- };
-
- pub const If = struct {
- then_expr: Index,
- else_expr: Index,
- };
-
- pub const ContainerField = struct {
- value_expr: Index,
- align_expr: Index,
- };
-
- pub const GlobalVarDecl = struct {
- type_node: Index,
- align_node: Index,
- section_node: Index,
- };
-
- pub const Slice = struct {
- start: Index,
- end: Index,
- };
-
- pub const SliceSentinel = struct {
- start: Index,
- /// May be 0 if the slice is "open"
- end: Index,
- sentinel: Index,
- };
-
- pub const While = struct {
- cont_expr: Index,
- then_expr: Index,
- else_expr: Index,
- };
-
- pub const WhileCont = struct {
- cont_expr: Index,
- then_expr: Index,
- };
-
- pub const FnProtoOne = struct {
- /// Populated if there is exactly 1 parameter. Otherwise there are 0 parameters.
- param: Index,
- /// Populated if align(A) is present.
- align_expr: Index,
- /// Populated if linksection(A) is present.
- section_expr: Index,
- /// Populated if callconv(A) is present.
- callconv_expr: Index,
- };
-
- pub const FnProto = struct {
- params_start: Index,
- params_end: Index,
- /// Populated if align(A) is present.
- align_expr: Index,
- /// Populated if linksection(A) is present.
- section_expr: Index,
- /// Populated if callconv(A) is present.
- callconv_expr: Index,
- };
-
- pub const Asm = struct {
- items_start: Index,
- items_end: Index,
- /// Needed to make lastToken() work.
- rparen: TokenIndex,
- };
-};
diff --git a/lib/std/zig/parse.zig b/lib/std/zig/parse.zig
index 5904e1816f14..842847a295c4 100644
--- a/lib/std/zig/parse.zig
+++ b/lib/std/zig/parse.zig
@@ -1,19 +1,18 @@
const std = @import("../std.zig");
const assert = std.debug.assert;
const Allocator = std.mem.Allocator;
-const ast = std.zig.ast;
-const Node = ast.Node;
-const Tree = ast.Tree;
-const AstError = ast.Error;
-const TokenIndex = ast.TokenIndex;
+const Ast = std.zig.Ast;
+const Node = Ast.Node;
+const AstError = Ast.Error;
+const TokenIndex = Ast.TokenIndex;
const Token = std.zig.Token;
pub const Error = error{ParseError} || Allocator.Error;
/// Result should be freed with tree.deinit() when there are
/// no more references to any of the tokens or nodes.
-pub fn parse(gpa: *Allocator, source: [:0]const u8) Allocator.Error!Tree {
- var tokens = ast.TokenList{};
+pub fn parse(gpa: *Allocator, source: [:0]const u8) Allocator.Error!Ast {
+ var tokens = Ast.TokenList{};
defer tokens.deinit(gpa);
// Empirically, the zig std lib has an 8:1 ratio of source bytes to token count.
@@ -69,7 +68,7 @@ pub fn parse(gpa: *Allocator, source: [:0]const u8) Allocator.Error!Tree {
};
// TODO experiment with compacting the MultiArrayList slices here
- return Tree{
+ return Ast{
.source = source,
.tokens = tokens.toOwnedSlice(),
.nodes = parser.nodes.toOwnedSlice(),
@@ -80,15 +79,15 @@ pub fn parse(gpa: *Allocator, source: [:0]const u8) Allocator.Error!Tree {
const null_node: Node.Index = 0;
-/// Represents in-progress parsing, will be converted to an ast.Tree after completion.
+/// Represents in-progress parsing, will be converted to an Ast after completion.
const Parser = struct {
gpa: *Allocator,
source: []const u8,
token_tags: []const Token.Tag,
- token_starts: []const ast.ByteOffset,
+ token_starts: []const Ast.ByteOffset,
tok_i: TokenIndex,
errors: std.ArrayListUnmanaged(AstError),
- nodes: ast.NodeList,
+ nodes: Ast.NodeList,
extra_data: std.ArrayListUnmanaged(Node.Index),
scratch: std.ArrayListUnmanaged(Node.Index),
@@ -121,13 +120,13 @@ const Parser = struct {
};
}
- fn addNode(p: *Parser, elem: ast.NodeList.Elem) Allocator.Error!Node.Index {
+ fn addNode(p: *Parser, elem: Ast.NodeList.Elem) Allocator.Error!Node.Index {
const result = @intCast(Node.Index, p.nodes.len);
try p.nodes.append(p.gpa, elem);
return result;
}
- fn setNode(p: *Parser, i: usize, elem: ast.NodeList.Elem) Node.Index {
+ fn setNode(p: *Parser, i: usize, elem: Ast.NodeList.Elem) Node.Index {
p.nodes.set(i, elem);
return @intCast(Node.Index, i);
}
@@ -148,7 +147,7 @@ const Parser = struct {
return result;
}
- fn warn(p: *Parser, tag: ast.Error.Tag) error{OutOfMemory}!void {
+ fn warn(p: *Parser, tag: Ast.Error.Tag) error{OutOfMemory}!void {
@setCold(true);
try p.warnMsg(.{ .tag = tag, .token = p.tok_i });
}
@@ -161,12 +160,12 @@ const Parser = struct {
.extra = .{ .expected_tag = expected_token },
});
}
- fn warnMsg(p: *Parser, msg: ast.Error) error{OutOfMemory}!void {
+ fn warnMsg(p: *Parser, msg: Ast.Error) error{OutOfMemory}!void {
@setCold(true);
try p.errors.append(p.gpa, msg);
}
- fn fail(p: *Parser, tag: ast.Error.Tag) error{ ParseError, OutOfMemory } {
+ fn fail(p: *Parser, tag: Ast.Error.Tag) error{ ParseError, OutOfMemory } {
@setCold(true);
return p.failMsg(.{ .tag = tag, .token = p.tok_i });
}
@@ -180,7 +179,7 @@ const Parser = struct {
});
}
- fn failMsg(p: *Parser, msg: ast.Error) error{ ParseError, OutOfMemory } {
+ fn failMsg(p: *Parser, msg: Ast.Error) error{ ParseError, OutOfMemory } {
@setCold(true);
try p.warnMsg(msg);
return error.ParseError;
diff --git a/lib/std/zig/parser_test.zig b/lib/std/zig/parser_test.zig
index ff6ba8b63a60..24992569b139 100644
--- a/lib/std/zig/parser_test.zig
+++ b/lib/std/zig/parser_test.zig
@@ -4837,6 +4837,77 @@ test "zig fmt: make single-line if no trailing comma" {
);
}
+test "zig fmt: make single-line if no trailing comma" {
+ try testCanonical(
+ \\// Test trailing comma syntax
+ \\// zig fmt: off
+ \\
+ \\extern var a: c_int;
+ \\extern "c" var b: c_int;
+ \\export var c: c_int = 0;
+ \\threadlocal var d: c_int = 0;
+ \\extern threadlocal var e: c_int;
+ \\extern "c" threadlocal var f: c_int;
+ \\export threadlocal var g: c_int = 0;
+ \\
+ \\const struct_trailing_comma = struct { x: i32, y: i32, };
+ \\const struct_no_comma = struct { x: i32, y: i32 };
+ \\const struct_fn_no_comma = struct { fn m() void {} y: i32 };
+ \\
+ \\const enum_no_comma = enum { A, B };
+ \\
+ \\fn container_init() void {
+ \\ const S = struct { x: i32, y: i32 };
+ \\ _ = S { .x = 1, .y = 2 };
+ \\ _ = S { .x = 1, .y = 2, };
+ \\}
+ \\
+ \\fn type_expr_return1() if (true) A {}
+ \\fn type_expr_return2() for (true) |_| A {}
+ \\fn type_expr_return3() while (true) A {}
+ \\
+ \\fn switch_cases(x: i32) void {
+ \\ switch (x) {
+ \\ 1,2,3 => {},
+ \\ 4,5, => {},
+ \\ 6...8, => {},
+ \\ else => {},
+ \\ }
+ \\}
+ \\
+ \\fn switch_prongs(x: i32) void {
+ \\ switch (x) {
+ \\ 0 => {},
+ \\ else => {},
+ \\ }
+ \\ switch (x) {
+ \\ 0 => {},
+ \\ else => {}
+ \\ }
+ \\}
+ \\
+ \\const fn_no_comma = fn(i32, i32)void;
+ \\const fn_trailing_comma = fn(i32, i32,)void;
+ \\
+ \\fn fn_calls() void {
+ \\ fn add(x: i32, y: i32,) i32 { x + y };
+ \\ _ = add(1, 2);
+ \\ _ = add(1, 2,);
+ \\}
+ \\
+ \\fn asm_lists() void {
+ \\ if (false) { // Build AST but don't analyze
+ \\ asm ("not real assembly"
+ \\ :[a] "x" (x),);
+ \\ asm ("not real assembly"
+ \\ :[a] "x" (->i32),:[a] "x" (1),);
+ \\ asm volatile ("still not real assembly"
+ \\ :::"a","b",);
+ \\ }
+ \\}
+ );
+}
+
test "zig fmt: error for invalid bit range" {
try testError(
\\var x: []align(0:0:0)u8 = bar;
@@ -5237,7 +5308,7 @@ fn testCanonical(source: [:0]const u8) !void {
return testTransform(source, source);
}
-const Error = std.zig.ast.Error.Tag;
+const Error = std.zig.Ast.Error.Tag;
fn testError(source: [:0]const u8, expected_errors: []const Error) !void {
var tree = try std.zig.parse(std.testing.allocator, source);
diff --git a/lib/std/zig/render.zig b/lib/std/zig/render.zig
index eecb04b35c2b..bc1dc4285581 100644
--- a/lib/std/zig/render.zig
+++ b/lib/std/zig/render.zig
@@ -3,17 +3,17 @@ const assert = std.debug.assert;
const mem = std.mem;
const Allocator = std.mem.Allocator;
const meta = std.meta;
-const ast = std.zig.ast;
+const Ast = std.zig.Ast;
const Token = std.zig.Token;
const indent_delta = 4;
const asm_indent_delta = 2;
-pub const Error = ast.Tree.RenderError;
+pub const Error = Ast.RenderError;
const Ais = AutoIndentingStream(std.ArrayList(u8).Writer);
-pub fn renderTree(buffer: *std.ArrayList(u8), tree: ast.Tree) Error!void {
+pub fn renderTree(buffer: *std.ArrayList(u8), tree: Ast) Error!void {
assert(tree.errors.len == 0); // Cannot render an invalid tree.
var auto_indenting_stream = Ais{
.indent_delta = indent_delta,
@@ -37,7 +37,7 @@ pub fn renderTree(buffer: *std.ArrayList(u8), tree: ast.Tree) Error!void {
}
/// Render all members in the given slice, keeping empty lines where appropriate
-fn renderMembers(gpa: *Allocator, ais: *Ais, tree: ast.Tree, members: []const ast.Node.Index) Error!void {
+fn renderMembers(gpa: *Allocator, ais: *Ais, tree: Ast, members: []const Ast.Node.Index) Error!void {
if (members.len == 0) return;
try renderMember(gpa, ais, tree, members[0], .newline);
for (members[1..]) |member| {
@@ -46,7 +46,7 @@ fn renderMembers(gpa: *Allocator, ais: *Ais, tree: ast.Tree, members: []const as
}
}
-fn renderMember(gpa: *Allocator, ais: *Ais, tree: ast.Tree, decl: ast.Node.Index, space: Space) Error!void {
+fn renderMember(gpa: *Allocator, ais: *Ais, tree: Ast, decl: Ast.Node.Index, space: Space) Error!void {
const token_tags = tree.tokens.items(.tag);
const main_tokens = tree.nodes.items(.main_token);
const datas = tree.nodes.items(.data);
@@ -83,9 +83,9 @@ fn renderMember(gpa: *Allocator, ais: *Ais, tree: ast.Tree, decl: ast.Node.Index
switch (tree.nodes.items(.tag)[fn_proto]) {
.fn_proto_one, .fn_proto => {
const callconv_expr = if (tree.nodes.items(.tag)[fn_proto] == .fn_proto_one)
- tree.extraData(datas[fn_proto].lhs, ast.Node.FnProtoOne).callconv_expr
+ tree.extraData(datas[fn_proto].lhs, Ast.Node.FnProtoOne).callconv_expr
else
- tree.extraData(datas[fn_proto].lhs, ast.Node.FnProto).callconv_expr;
+ tree.extraData(datas[fn_proto].lhs, Ast.Node.FnProto).callconv_expr;
if (callconv_expr != 0 and tree.nodes.items(.tag)[callconv_expr] == .enum_literal) {
if (mem.eql(u8, "Inline", tree.tokenSlice(main_tokens[callconv_expr]))) {
try ais.writer().writeAll("inline ");
@@ -168,7 +168,7 @@ fn renderMember(gpa: *Allocator, ais: *Ais, tree: ast.Tree, decl: ast.Node.Index
}
/// Render all expressions in the slice, keeping empty lines where appropriate
-fn renderExpressions(gpa: *Allocator, ais: *Ais, tree: ast.Tree, expressions: []const ast.Node.Index, space: Space) Error!void {
+fn renderExpressions(gpa: *Allocator, ais: *Ais, tree: Ast, expressions: []const Ast.Node.Index, space: Space) Error!void {
if (expressions.len == 0) return;
try renderExpression(gpa, ais, tree, expressions[0], space);
for (expressions[1..]) |expression| {
@@ -177,7 +177,7 @@ fn renderExpressions(gpa: *Allocator, ais: *Ais, tree: ast.Tree, expressions: []
}
}
-fn renderExpression(gpa: *Allocator, ais: *Ais, tree: ast.Tree, node: ast.Node.Index, space: Space) Error!void {
+fn renderExpression(gpa: *Allocator, ais: *Ais, tree: Ast, node: Ast.Node.Index, space: Space) Error!void {
const token_tags = tree.tokens.items(.tag);
const main_tokens = tree.nodes.items(.main_token);
const node_tags = tree.nodes.items(.tag);
@@ -220,7 +220,7 @@ fn renderExpression(gpa: *Allocator, ais: *Ais, tree: ast.Tree, node: ast.Node.I
.block_two,
.block_two_semicolon,
=> {
- const statements = [2]ast.Node.Index{ datas[node].lhs, datas[node].rhs };
+ const statements = [2]Ast.Node.Index{ datas[node].lhs, datas[node].rhs };
if (datas[node].lhs == 0) {
return renderBlock(gpa, ais, tree, node, statements[0..0], space);
} else if (datas[node].rhs == 0) {
@@ -413,11 +413,11 @@ fn renderExpression(gpa: *Allocator, ais: *Ais, tree: ast.Tree, node: ast.Node.I
.ptr_type_bit_range => return renderPtrType(gpa, ais, tree, tree.ptrTypeBitRange(node), space),
.array_init_one, .array_init_one_comma => {
- var elements: [1]ast.Node.Index = undefined;
+ var elements: [1]Ast.Node.Index = undefined;
return renderArrayInit(gpa, ais, tree, tree.arrayInitOne(&elements, node), space);
},
.array_init_dot_two, .array_init_dot_two_comma => {
- var elements: [2]ast.Node.Index = undefined;
+ var elements: [2]Ast.Node.Index = undefined;
return renderArrayInit(gpa, ais, tree, tree.arrayInitDotTwo(&elements, node), space);
},
.array_init_dot,
@@ -428,11 +428,11 @@ fn renderExpression(gpa: *Allocator, ais: *Ais, tree: ast.Tree, node: ast.Node.I
=> return renderArrayInit(gpa, ais, tree, tree.arrayInit(node), space),
.struct_init_one, .struct_init_one_comma => {
- var fields: [1]ast.Node.Index = undefined;
+ var fields: [1]Ast.Node.Index = undefined;
return renderStructInit(gpa, ais, tree, node, tree.structInitOne(&fields, node), space);
},
.struct_init_dot_two, .struct_init_dot_two_comma => {
- var fields: [2]ast.Node.Index = undefined;
+ var fields: [2]Ast.Node.Index = undefined;
return renderStructInit(gpa, ais, tree, node, tree.structInitDotTwo(&fields, node), space);
},
.struct_init_dot,
@@ -443,7 +443,7 @@ fn renderExpression(gpa: *Allocator, ais: *Ais, tree: ast.Tree, node: ast.Node.I
=> return renderStructInit(gpa, ais, tree, node, tree.structInit(node), space),
.call_one, .call_one_comma, .async_call_one, .async_call_one_comma => {
- var params: [1]ast.Node.Index = undefined;
+ var params: [1]Ast.Node.Index = undefined;
return renderCall(gpa, ais, tree, tree.callOne(¶ms, node), space);
},
@@ -536,7 +536,7 @@ fn renderExpression(gpa: *Allocator, ais: *Ais, tree: ast.Tree, node: ast.Node.I
=> return renderContainerDecl(gpa, ais, tree, node, tree.containerDecl(node), space),
.container_decl_two, .container_decl_two_trailing => {
- var buffer: [2]ast.Node.Index = undefined;
+ var buffer: [2]Ast.Node.Index = undefined;
return renderContainerDecl(gpa, ais, tree, node, tree.containerDeclTwo(&buffer, node), space);
},
.container_decl_arg,
@@ -548,7 +548,7 @@ fn renderExpression(gpa: *Allocator, ais: *Ais, tree: ast.Tree, node: ast.Node.I
=> return renderContainerDecl(gpa, ais, tree, node, tree.taggedUnion(node), space),
.tagged_union_two, .tagged_union_two_trailing => {
- var buffer: [2]ast.Node.Index = undefined;
+ var buffer: [2]Ast.Node.Index = undefined;
return renderContainerDecl(gpa, ais, tree, node, tree.taggedUnionTwo(&buffer, node), space);
},
.tagged_union_enum_tag,
@@ -619,12 +619,12 @@ fn renderExpression(gpa: *Allocator, ais: *Ais, tree: ast.Tree, node: ast.Node.I
},
.fn_proto_simple => {
- var params: [1]ast.Node.Index = undefined;
+ var params: [1]Ast.Node.Index = undefined;
return renderFnProto(gpa, ais, tree, tree.fnProtoSimple(¶ms, node), space);
},
.fn_proto_multi => return renderFnProto(gpa, ais, tree, tree.fnProtoMulti(node), space),
.fn_proto_one => {
- var params: [1]ast.Node.Index = undefined;
+ var params: [1]Ast.Node.Index = undefined;
return renderFnProto(gpa, ais, tree, tree.fnProtoOne(¶ms, node), space);
},
.fn_proto => return renderFnProto(gpa, ais, tree, tree.fnProto(node), space),
@@ -645,7 +645,7 @@ fn renderExpression(gpa: *Allocator, ais: *Ais, tree: ast.Tree, node: ast.Node.I
=> {
const switch_token = main_tokens[node];
const condition = datas[node].lhs;
- const extra = tree.extraData(datas[node].rhs, ast.Node.SubRange);
+ const extra = tree.extraData(datas[node].rhs, Ast.Node.SubRange);
const cases = tree.extra_data[extra.start..extra.end];
const rparen = tree.lastToken(condition) + 1;
@@ -704,8 +704,8 @@ fn renderExpression(gpa: *Allocator, ais: *Ais, tree: ast.Tree, node: ast.Node.I
fn renderArrayType(
gpa: *Allocator,
ais: *Ais,
- tree: ast.Tree,
- array_type: ast.full.ArrayType,
+ tree: Ast,
+ array_type: Ast.full.ArrayType,
space: Space,
) Error!void {
const rbracket = tree.firstToken(array_type.ast.elem_type) - 1;
@@ -726,8 +726,8 @@ fn renderArrayType(
fn renderPtrType(
gpa: *Allocator,
ais: *Ais,
- tree: ast.Tree,
- ptr_type: ast.full.PtrType,
+ tree: Ast,
+ ptr_type: Ast.full.PtrType,
space: Space,
) Error!void {
switch (ptr_type.size) {
@@ -811,9 +811,9 @@ fn renderPtrType(
fn renderSlice(
gpa: *Allocator,
ais: *Ais,
- tree: ast.Tree,
- slice_node: ast.Node.Index,
- slice: ast.full.Slice,
+ tree: Ast,
+ slice_node: Ast.Node.Index,
+ slice: Ast.full.Slice,
space: Space,
) Error!void {
const node_tags = tree.nodes.items(.tag);
@@ -847,8 +847,8 @@ fn renderSlice(
fn renderAsmOutput(
gpa: *Allocator,
ais: *Ais,
- tree: ast.Tree,
- asm_output: ast.Node.Index,
+ tree: Ast,
+ asm_output: Ast.Node.Index,
space: Space,
) Error!void {
const token_tags = tree.tokens.items(.tag);
@@ -877,8 +877,8 @@ fn renderAsmOutput(
fn renderAsmInput(
gpa: *Allocator,
ais: *Ais,
- tree: ast.Tree,
- asm_input: ast.Node.Index,
+ tree: Ast,
+ asm_input: Ast.Node.Index,
space: Space,
) Error!void {
const node_tags = tree.nodes.items(.tag);
@@ -896,7 +896,7 @@ fn renderAsmInput(
return renderToken(ais, tree, datas[asm_input].rhs, space); // rparen
}
-fn renderVarDecl(gpa: *Allocator, ais: *Ais, tree: ast.Tree, var_decl: ast.full.VarDecl) Error!void {
+fn renderVarDecl(gpa: *Allocator, ais: *Ais, tree: Ast, var_decl: Ast.full.VarDecl) Error!void {
if (var_decl.visib_token) |visib_token| {
try renderToken(ais, tree, visib_token, Space.space); // pub
}
@@ -985,7 +985,7 @@ fn renderVarDecl(gpa: *Allocator, ais: *Ais, tree: ast.Tree, var_decl: ast.full.
return renderToken(ais, tree, var_decl.ast.mut_token + 2, .newline); // ;
}
-fn renderIf(gpa: *Allocator, ais: *Ais, tree: ast.Tree, if_node: ast.full.If, space: Space) Error!void {
+fn renderIf(gpa: *Allocator, ais: *Ais, tree: Ast, if_node: Ast.full.If, space: Space) Error!void {
return renderWhile(gpa, ais, tree, .{
.ast = .{
.while_token = if_node.ast.if_token,
@@ -1004,7 +1004,7 @@ fn renderIf(gpa: *Allocator, ais: *Ais, tree: ast.Tree, if_node: ast.full.If, sp
/// Note that this function is additionally used to render if and for expressions, with
/// respective values set to null.
-fn renderWhile(gpa: *Allocator, ais: *Ais, tree: ast.Tree, while_node: ast.full.While, space: Space) Error!void {
+fn renderWhile(gpa: *Allocator, ais: *Ais, tree: Ast, while_node: Ast.full.While, space: Space) Error!void {
const node_tags = tree.nodes.items(.tag);
const token_tags = tree.tokens.items(.tag);
@@ -1109,8 +1109,8 @@ fn renderWhile(gpa: *Allocator, ais: *Ais, tree: ast.Tree, while_node: ast.full.
fn renderContainerField(
gpa: *Allocator,
ais: *Ais,
- tree: ast.Tree,
- field: ast.full.ContainerField,
+ tree: Ast,
+ field: Ast.full.ContainerField,
space: Space,
) Error!void {
if (field.comptime_token) |t| {
@@ -1183,9 +1183,9 @@ fn renderContainerField(
fn renderBuiltinCall(
gpa: *Allocator,
ais: *Ais,
- tree: ast.Tree,
- builtin_token: ast.TokenIndex,
- params: []const ast.Node.Index,
+ tree: Ast,
+ builtin_token: Ast.TokenIndex,
+ params: []const Ast.Node.Index,
space: Space,
) Error!void {
const token_tags = tree.tokens.items(.tag);
@@ -1238,7 +1238,7 @@ fn renderBuiltinCall(
}
}
-fn renderFnProto(gpa: *Allocator, ais: *Ais, tree: ast.Tree, fn_proto: ast.full.FnProto, space: Space) Error!void {
+fn renderFnProto(gpa: *Allocator, ais: *Ais, tree: Ast, fn_proto: Ast.full.FnProto, space: Space) Error!void {
const token_tags = tree.tokens.items(.tag);
const token_starts = tree.tokens.items(.start);
@@ -1438,8 +1438,8 @@ fn renderFnProto(gpa: *Allocator, ais: *Ais, tree: ast.Tree, fn_proto: ast.full.
fn renderSwitchCase(
gpa: *Allocator,
ais: *Ais,
- tree: ast.Tree,
- switch_case: ast.full.SwitchCase,
+ tree: Ast,
+ switch_case: Ast.full.SwitchCase,
space: Space,
) Error!void {
const node_tags = tree.nodes.items(.tag);
@@ -1491,9 +1491,9 @@ fn renderSwitchCase(
fn renderBlock(
gpa: *Allocator,
ais: *Ais,
- tree: ast.Tree,
- block_node: ast.Node.Index,
- statements: []const ast.Node.Index,
+ tree: Ast,
+ block_node: Ast.Node.Index,
+ statements: []const Ast.Node.Index,
space: Space,
) Error!void {
const token_tags = tree.tokens.items(.tag);
@@ -1531,9 +1531,9 @@ fn renderBlock(
fn renderStructInit(
gpa: *Allocator,
ais: *Ais,
- tree: ast.Tree,
- struct_node: ast.Node.Index,
- struct_init: ast.full.StructInit,
+ tree: Ast,
+ struct_node: Ast.Node.Index,
+ struct_init: Ast.full.StructInit,
space: Space,
) Error!void {
const token_tags = tree.tokens.items(.tag);
@@ -1590,8 +1590,8 @@ fn renderStructInit(
fn renderArrayInit(
gpa: *Allocator,
ais: *Ais,
- tree: ast.Tree,
- array_init: ast.full.ArrayInit,
+ tree: Ast,
+ array_init: Ast.full.ArrayInit,
space: Space,
) Error!void {
const token_tags = tree.tokens.items(.tag);
@@ -1787,9 +1787,9 @@ fn renderArrayInit(
fn renderContainerDecl(
gpa: *Allocator,
ais: *Ais,
- tree: ast.Tree,
- container_decl_node: ast.Node.Index,
- container_decl: ast.full.ContainerDecl,
+ tree: Ast,
+ container_decl_node: Ast.Node.Index,
+ container_decl: Ast.full.ContainerDecl,
space: Space,
) Error!void {
const token_tags = tree.tokens.items(.tag);
@@ -1799,7 +1799,7 @@ fn renderContainerDecl(
try renderToken(ais, tree, layout_token, .space);
}
- var lbrace: ast.TokenIndex = undefined;
+ var lbrace: Ast.TokenIndex = undefined;
if (container_decl.ast.enum_token) |enum_token| {
try renderToken(ais, tree, container_decl.ast.main_token, .none); // union
try renderToken(ais, tree, enum_token - 1, .none); // lparen
@@ -1869,8 +1869,8 @@ fn renderContainerDecl(
fn renderAsm(
gpa: *Allocator,
ais: *Ais,
- tree: ast.Tree,
- asm_node: ast.full.Asm,
+ tree: Ast,
+ asm_node: Ast.full.Asm,
space: Space,
) Error!void {
const token_tags = tree.tokens.items(.tag);
@@ -2018,8 +2018,8 @@ fn renderAsm(
fn renderCall(
gpa: *Allocator,
ais: *Ais,
- tree: ast.Tree,
- call: ast.full.Call,
+ tree: Ast,
+ call: Ast.full.Call,
space: Space,
) Error!void {
const token_tags = tree.tokens.items(.tag);
@@ -2091,7 +2091,7 @@ fn renderCall(
/// Renders the given expression indented, popping the indent before rendering
/// any following line comments
-fn renderExpressionIndented(gpa: *Allocator, ais: *Ais, tree: ast.Tree, node: ast.Node.Index, space: Space) Error!void {
+fn renderExpressionIndented(gpa: *Allocator, ais: *Ais, tree: Ast, node: Ast.Node.Index, space: Space) Error!void {
const token_starts = tree.tokens.items(.start);
const token_tags = tree.tokens.items(.tag);
@@ -2148,7 +2148,7 @@ fn renderExpressionIndented(gpa: *Allocator, ais: *Ais, tree: ast.Tree, node: as
}
/// Render an expression, and the comma that follows it, if it is present in the source.
-fn renderExpressionComma(gpa: *Allocator, ais: *Ais, tree: ast.Tree, node: ast.Node.Index, space: Space) Error!void {
+fn renderExpressionComma(gpa: *Allocator, ais: *Ais, tree: Ast, node: Ast.Node.Index, space: Space) Error!void {
const token_tags = tree.tokens.items(.tag);
const maybe_comma = tree.lastToken(node) + 1;
if (token_tags[maybe_comma] == .comma) {
@@ -2159,7 +2159,7 @@ fn renderExpressionComma(gpa: *Allocator, ais: *Ais, tree: ast.Tree, node: ast.N
}
}
-fn renderTokenComma(ais: *Ais, tree: ast.Tree, token: ast.TokenIndex, space: Space) Error!void {
+fn renderTokenComma(ais: *Ais, tree: Ast, token: Ast.TokenIndex, space: Space) Error!void {
const token_tags = tree.tokens.items(.tag);
const maybe_comma = token + 1;
if (token_tags[maybe_comma] == .comma) {
@@ -2191,7 +2191,7 @@ const Space = enum {
skip,
};
-fn renderToken(ais: *Ais, tree: ast.Tree, token_index: ast.TokenIndex, space: Space) Error!void {
+fn renderToken(ais: *Ais, tree: Ast, token_index: Ast.TokenIndex, space: Space) Error!void {
const token_tags = tree.tokens.items(.tag);
const token_starts = tree.tokens.items(.start);
@@ -2238,7 +2238,7 @@ fn renderToken(ais: *Ais, tree: ast.Tree, token_index: ast.TokenIndex, space: Sp
/// `start_token` to `end_token`. This is used to determine if e.g. a
/// fn_proto should be wrapped and have a trailing comma inserted even if
/// there is none in the source.
-fn hasComment(tree: ast.Tree, start_token: ast.TokenIndex, end_token: ast.TokenIndex) bool {
+fn hasComment(tree: Ast, start_token: Ast.TokenIndex, end_token: Ast.TokenIndex) bool {
const token_starts = tree.tokens.items(.start);
var i = start_token;
@@ -2253,7 +2253,7 @@ fn hasComment(tree: ast.Tree, start_token: ast.TokenIndex, end_token: ast.TokenI
/// Returns true if there exists a multiline string literal between the start
/// of token `start_token` and the start of token `end_token`.
-fn hasMultilineString(tree: ast.Tree, start_token: ast.TokenIndex, end_token: ast.TokenIndex) bool {
+fn hasMultilineString(tree: Ast, start_token: Ast.TokenIndex, end_token: Ast.TokenIndex) bool {
const token_tags = tree.tokens.items(.tag);
for (token_tags[start_token..end_token]) |tag| {
@@ -2268,7 +2268,7 @@ fn hasMultilineString(tree: ast.Tree, start_token: ast.TokenIndex, end_token: as
/// Assumes that start is the first byte past the previous token and
/// that end is the last byte before the next token.
-fn renderComments(ais: *Ais, tree: ast.Tree, start: usize, end: usize) Error!bool {
+fn renderComments(ais: *Ais, tree: Ast, start: usize, end: usize) Error!bool {
var index: usize = start;
while (mem.indexOf(u8, tree.source[index..end], "//")) |offset| {
const comment_start = index + offset;
@@ -2325,12 +2325,12 @@ fn renderComments(ais: *Ais, tree: ast.Tree, start: usize, end: usize) Error!boo
return index != start;
}
-fn renderExtraNewline(ais: *Ais, tree: ast.Tree, node: ast.Node.Index) Error!void {
+fn renderExtraNewline(ais: *Ais, tree: Ast, node: Ast.Node.Index) Error!void {
return renderExtraNewlineToken(ais, tree, tree.firstToken(node));
}
/// Check if there is an empty line immediately before the given token. If so, render it.
-fn renderExtraNewlineToken(ais: *Ais, tree: ast.Tree, token_index: ast.TokenIndex) Error!void {
+fn renderExtraNewlineToken(ais: *Ais, tree: Ast, token_index: Ast.TokenIndex) Error!void {
const token_starts = tree.tokens.items(.start);
const token_start = token_starts[token_index];
if (token_start == 0) return;
@@ -2355,7 +2355,7 @@ fn renderExtraNewlineToken(ais: *Ais, tree: ast.Tree, token_index: ast.TokenInde
/// end_token is the token one past the last doc comment token. This function
/// searches backwards from there.
-fn renderDocComments(ais: *Ais, tree: ast.Tree, end_token: ast.TokenIndex) Error!void {
+fn renderDocComments(ais: *Ais, tree: Ast, end_token: Ast.TokenIndex) Error!void {
// Search backwards for the first doc comment.
const token_tags = tree.tokens.items(.tag);
if (end_token == 0) return;
@@ -2376,7 +2376,7 @@ fn renderDocComments(ais: *Ais, tree: ast.Tree, end_token: ast.TokenIndex) Error
}
/// start_token is first container doc comment token.
-fn renderContainerDocComments(ais: *Ais, tree: ast.Tree, start_token: ast.TokenIndex) Error!void {
+fn renderContainerDocComments(ais: *Ais, tree: Ast, start_token: Ast.TokenIndex) Error!void {
const token_tags = tree.tokens.items(.tag);
var tok = start_token;
while (token_tags[tok] == .container_doc_comment) : (tok += 1) {
@@ -2390,7 +2390,7 @@ fn renderContainerDocComments(ais: *Ais, tree: ast.Tree, start_token: ast.TokenI
}
}
-fn tokenSliceForRender(tree: ast.Tree, token_index: ast.TokenIndex) []const u8 {
+fn tokenSliceForRender(tree: Ast, token_index: Ast.TokenIndex) []const u8 {
var ret = tree.tokenSlice(token_index);
if (tree.tokens.items(.tag)[token_index] == .multiline_string_literal_line) {
assert(ret[ret.len - 1] == '\n');
@@ -2399,7 +2399,7 @@ fn tokenSliceForRender(tree: ast.Tree, token_index: ast.TokenIndex) []const u8 {
return ret;
}
-fn hasSameLineComment(tree: ast.Tree, token_index: ast.TokenIndex) bool {
+fn hasSameLineComment(tree: Ast, token_index: Ast.TokenIndex) bool {
const token_starts = tree.tokens.items(.start);
const between_source = tree.source[token_starts[token_index]..token_starts[token_index + 1]];
for (between_source) |byte| switch (byte) {
@@ -2412,7 +2412,7 @@ fn hasSameLineComment(tree: ast.Tree, token_index: ast.TokenIndex) bool {
/// Returns `true` if and only if there are any tokens or line comments between
/// start_token and end_token.
-fn anythingBetween(tree: ast.Tree, start_token: ast.TokenIndex, end_token: ast.TokenIndex) bool {
+fn anythingBetween(tree: Ast, start_token: Ast.TokenIndex, end_token: Ast.TokenIndex) bool {
if (start_token + 1 != end_token) return true;
const token_starts = tree.tokens.items(.start);
const between_source = tree.source[token_starts[start_token]..token_starts[start_token + 1]];
@@ -2431,7 +2431,7 @@ fn writeFixingWhitespace(writer: std.ArrayList(u8).Writer, slice: []const u8) Er
};
}
-fn nodeIsBlock(tag: ast.Node.Tag) bool {
+fn nodeIsBlock(tag: Ast.Node.Tag) bool {
return switch (tag) {
.block,
.block_semicolon,
@@ -2450,7 +2450,7 @@ fn nodeIsBlock(tag: ast.Node.Tag) bool {
};
}
-fn nodeIsIfForWhileSwitch(tag: ast.Node.Tag) bool {
+fn nodeIsIfForWhileSwitch(tag: Ast.Node.Tag) bool {
return switch (tag) {
.@"if",
.if_simple,
@@ -2466,7 +2466,7 @@ fn nodeIsIfForWhileSwitch(tag: ast.Node.Tag) bool {
};
}
-fn nodeCausesSliceOpSpace(tag: ast.Node.Tag) bool {
+fn nodeCausesSliceOpSpace(tag: Ast.Node.Tag) bool {
return switch (tag) {
.@"catch",
.add,
@@ -2516,7 +2516,7 @@ fn nodeCausesSliceOpSpace(tag: ast.Node.Tag) bool {
}
// Returns the number of nodes in `expr` that are on the same line as `rtoken`.
-fn rowSize(tree: ast.Tree, exprs: []const ast.Node.Index, rtoken: ast.TokenIndex) usize {
+fn rowSize(tree: Ast, exprs: []const Ast.Node.Index, rtoken: Ast.TokenIndex) usize {
const token_tags = tree.tokens.items(.tag);
const first_token = tree.firstToken(exprs[0]);
diff --git a/lib/std/zig/system.zig b/lib/std/zig/system.zig
index a2a92b39df97..da4057d6e174 100644
--- a/lib/std/zig/system.zig
+++ b/lib/std/zig/system.zig
@@ -309,8 +309,8 @@ pub const NativeTargetInfo = struct {
},
.openbsd => {
const mib: [2]c_int = [_]c_int{
- std.os.CTL_KERN,
- std.os.KERN_OSRELEASE,
+ std.os.CTL.KERN,
+ std.os.KERN.OSRELEASE,
};
var buf: [64]u8 = undefined;
var len: usize = buf.len;
diff --git a/lib/std/zig/system/darwin/macos.zig b/lib/std/zig/system/darwin/macos.zig
index 509faaef290b..d374acbc9458 100644
--- a/lib/std/zig/system/darwin/macos.zig
+++ b/lib/std/zig/system/darwin/macos.zig
@@ -404,8 +404,8 @@ fn testVersionEquality(expected: std.builtin.Version, got: std.builtin.Version)
}
pub fn detectNativeCpuAndFeatures() ?Target.Cpu {
- var cpu_family: os.CPUFAMILY = undefined;
- var len: usize = @sizeOf(os.CPUFAMILY);
+ var cpu_family: std.c.CPUFAMILY = undefined;
+ var len: usize = @sizeOf(std.c.CPUFAMILY);
os.sysctlbynameZ("hw.cpufamily", &cpu_family, &len, null, 0) catch |err| switch (err) {
error.NameTooLong => unreachable, // constant, known good value
error.PermissionDenied => unreachable, // only when setting values,
diff --git a/src/AstGen.zig b/src/AstGen.zig
index 245e40c3a1c3..2521984a94f4 100644
--- a/src/AstGen.zig
+++ b/src/AstGen.zig
@@ -2,7 +2,7 @@
const AstGen = @This();
const std = @import("std");
-const ast = std.zig.ast;
+const Ast = std.zig.Ast;
const mem = std.mem;
const Allocator = std.mem.Allocator;
const assert = std.debug.assert;
@@ -13,7 +13,7 @@ const trace = @import("tracy.zig").trace;
const BuiltinFn = @import("BuiltinFn.zig");
gpa: *Allocator,
-tree: *const ast.Tree,
+tree: *const Ast,
instructions: std.MultiArrayList(Zir.Inst) = .{},
extra: ArrayListUnmanaged(u32) = .{},
string_bytes: ArrayListUnmanaged(u8) = .{},
@@ -36,7 +36,7 @@ compile_errors: ArrayListUnmanaged(Zir.Inst.CompileErrors.Item) = .{},
fn_block: ?*GenZir = null,
/// Maps string table indexes to the first `@import` ZIR instruction
/// that uses this string as the operand.
-imports: std.AutoArrayHashMapUnmanaged(u32, ast.TokenIndex) = .{},
+imports: std.AutoArrayHashMapUnmanaged(u32, Ast.TokenIndex) = .{},
const InnerError = error{ OutOfMemory, AnalysisFail };
@@ -70,7 +70,7 @@ fn appendRefsAssumeCapacity(astgen: *AstGen, refs: []const Zir.Inst.Ref) void {
astgen.extra.appendSliceAssumeCapacity(coerced);
}
-pub fn generate(gpa: *Allocator, tree: ast.Tree) Allocator.Error!Zir {
+pub fn generate(gpa: *Allocator, tree: Ast) Allocator.Error!Zir {
var arena = std.heap.ArenaAllocator.init(gpa);
defer arena.deinit();
@@ -106,7 +106,7 @@ pub fn generate(gpa: *Allocator, tree: ast.Tree) Allocator.Error!Zir {
};
defer gen_scope.instructions.deinit(gpa);
- const container_decl: ast.full.ContainerDecl = .{
+ const container_decl: Ast.full.ContainerDecl = .{
.layout_token = null,
.ast = .{
.main_token = undefined,
@@ -265,7 +265,7 @@ pub const bool_rl: ResultLoc = .{ .ty = .bool_type };
pub const type_rl: ResultLoc = .{ .ty = .type_type };
pub const coerced_type_rl: ResultLoc = .{ .coerced_ty = .type_type };
-fn typeExpr(gz: *GenZir, scope: *Scope, type_node: ast.Node.Index) InnerError!Zir.Inst.Ref {
+fn typeExpr(gz: *GenZir, scope: *Scope, type_node: Ast.Node.Index) InnerError!Zir.Inst.Ref {
const prev_force_comptime = gz.force_comptime;
gz.force_comptime = true;
defer gz.force_comptime = prev_force_comptime;
@@ -278,8 +278,8 @@ fn reachableExpr(
gz: *GenZir,
scope: *Scope,
rl: ResultLoc,
- node: ast.Node.Index,
- src_node: ast.Node.Index,
+ node: Ast.Node.Index,
+ src_node: Ast.Node.Index,
) InnerError!Zir.Inst.Ref {
const result_inst = try expr(gz, scope, rl, node);
if (gz.refIsNoReturn(result_inst)) {
@@ -290,7 +290,7 @@ fn reachableExpr(
return result_inst;
}
-fn lvalExpr(gz: *GenZir, scope: *Scope, node: ast.Node.Index) InnerError!Zir.Inst.Ref {
+fn lvalExpr(gz: *GenZir, scope: *Scope, node: Ast.Node.Index) InnerError!Zir.Inst.Ref {
const astgen = gz.astgen;
const tree = astgen.tree;
const node_tags = tree.nodes.items(.tag);
@@ -481,7 +481,7 @@ fn lvalExpr(gz: *GenZir, scope: *Scope, node: ast.Node.Index) InnerError!Zir.Ins
/// When `rl` is discard, ptr, inferred_ptr, or inferred_ptr, the
/// result instruction can be used to inspect whether it is isNoReturn() but that is it,
/// it must otherwise not be used.
-fn expr(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) InnerError!Zir.Inst.Ref {
+fn expr(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: Ast.Node.Index) InnerError!Zir.Inst.Ref {
const astgen = gz.astgen;
const tree = astgen.tree;
const main_tokens = tree.nodes.items(.main_token);
@@ -640,13 +640,13 @@ fn expr(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) InnerEr
.builtin_call_two, .builtin_call_two_comma => {
if (node_datas[node].lhs == 0) {
- const params = [_]ast.Node.Index{};
+ const params = [_]Ast.Node.Index{};
return builtinCall(gz, scope, rl, node, ¶ms);
} else if (node_datas[node].rhs == 0) {
- const params = [_]ast.Node.Index{node_datas[node].lhs};
+ const params = [_]Ast.Node.Index{node_datas[node].lhs};
return builtinCall(gz, scope, rl, node, ¶ms);
} else {
- const params = [_]ast.Node.Index{ node_datas[node].lhs, node_datas[node].rhs };
+ const params = [_]Ast.Node.Index{ node_datas[node].lhs, node_datas[node].rhs };
return builtinCall(gz, scope, rl, node, ¶ms);
}
},
@@ -656,7 +656,7 @@ fn expr(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) InnerEr
},
.call_one, .call_one_comma, .async_call_one, .async_call_one_comma => {
- var params: [1]ast.Node.Index = undefined;
+ var params: [1]Ast.Node.Index = undefined;
return callExpr(gz, scope, rl, node, tree.callOne(¶ms, node));
},
.call, .call_comma, .async_call, .async_call_comma => {
@@ -704,7 +704,7 @@ fn expr(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) InnerEr
},
.slice => {
const lhs = try expr(gz, scope, .ref, node_datas[node].lhs);
- const extra = tree.extraData(node_datas[node].rhs, ast.Node.Slice);
+ const extra = tree.extraData(node_datas[node].rhs, Ast.Node.Slice);
const start = try expr(gz, scope, .{ .ty = .usize_type }, extra.start);
const end = try expr(gz, scope, .{ .ty = .usize_type }, extra.end);
const result = try gz.addPlNode(.slice_end, node, Zir.Inst.SliceEnd{
@@ -722,7 +722,7 @@ fn expr(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) InnerEr
},
.slice_sentinel => {
const lhs = try expr(gz, scope, .ref, node_datas[node].lhs);
- const extra = tree.extraData(node_datas[node].rhs, ast.Node.SliceSentinel);
+ const extra = tree.extraData(node_datas[node].rhs, Ast.Node.SliceSentinel);
const start = try expr(gz, scope, .{ .ty = .usize_type }, extra.start);
const end = if (extra.end != 0) try expr(gz, scope, .{ .ty = .usize_type }, extra.end) else .none;
const sentinel = try expr(gz, scope, .{ .ty = .usize_type }, extra.sentinel);
@@ -773,7 +773,7 @@ fn expr(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) InnerEr
), node),
},
.block_two, .block_two_semicolon => {
- const statements = [2]ast.Node.Index{ node_datas[node].lhs, node_datas[node].rhs };
+ const statements = [2]Ast.Node.Index{ node_datas[node].lhs, node_datas[node].rhs };
if (node_datas[node].lhs == 0) {
return blockExpr(gz, scope, rl, node, statements[0..0]);
} else if (node_datas[node].rhs == 0) {
@@ -796,7 +796,7 @@ fn expr(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) InnerEr
},
.@"catch" => {
const catch_token = main_tokens[node];
- const payload_token: ?ast.TokenIndex = if (token_tags[catch_token + 1] == .pipe)
+ const payload_token: ?Ast.TokenIndex = if (token_tags[catch_token + 1] == .pipe)
catch_token + 2
else
null;
@@ -863,7 +863,7 @@ fn expr(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) InnerEr
.container_decl_trailing,
=> return containerDecl(gz, scope, rl, node, tree.containerDecl(node)),
.container_decl_two, .container_decl_two_trailing => {
- var buffer: [2]ast.Node.Index = undefined;
+ var buffer: [2]Ast.Node.Index = undefined;
return containerDecl(gz, scope, rl, node, tree.containerDeclTwo(&buffer, node));
},
.container_decl_arg,
@@ -874,7 +874,7 @@ fn expr(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) InnerEr
.tagged_union_trailing,
=> return containerDecl(gz, scope, rl, node, tree.taggedUnion(node)),
.tagged_union_two, .tagged_union_two_trailing => {
- var buffer: [2]ast.Node.Index = undefined;
+ var buffer: [2]Ast.Node.Index = undefined;
return containerDecl(gz, scope, rl, node, tree.taggedUnionTwo(&buffer, node));
},
.tagged_union_enum_tag,
@@ -900,11 +900,11 @@ fn expr(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) InnerEr
.@"try" => return tryExpr(gz, scope, rl, node, node_datas[node].lhs),
.array_init_one, .array_init_one_comma => {
- var elements: [1]ast.Node.Index = undefined;
+ var elements: [1]Ast.Node.Index = undefined;
return arrayInitExpr(gz, scope, rl, node, tree.arrayInitOne(&elements, node));
},
.array_init_dot_two, .array_init_dot_two_comma => {
- var elements: [2]ast.Node.Index = undefined;
+ var elements: [2]Ast.Node.Index = undefined;
return arrayInitExpr(gz, scope, rl, node, tree.arrayInitDotTwo(&elements, node));
},
.array_init_dot,
@@ -915,11 +915,11 @@ fn expr(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) InnerEr
=> return arrayInitExpr(gz, scope, rl, node, tree.arrayInit(node)),
.struct_init_one, .struct_init_one_comma => {
- var fields: [1]ast.Node.Index = undefined;
+ var fields: [1]Ast.Node.Index = undefined;
return structInitExpr(gz, scope, rl, node, tree.structInitOne(&fields, node));
},
.struct_init_dot_two, .struct_init_dot_two_comma => {
- var fields: [2]ast.Node.Index = undefined;
+ var fields: [2]Ast.Node.Index = undefined;
return structInitExpr(gz, scope, rl, node, tree.structInitDotTwo(&fields, node));
},
.struct_init_dot,
@@ -930,14 +930,14 @@ fn expr(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) InnerEr
=> return structInitExpr(gz, scope, rl, node, tree.structInit(node)),
.fn_proto_simple => {
- var params: [1]ast.Node.Index = undefined;
+ var params: [1]Ast.Node.Index = undefined;
return fnProtoExpr(gz, scope, rl, tree.fnProtoSimple(¶ms, node));
},
.fn_proto_multi => {
return fnProtoExpr(gz, scope, rl, tree.fnProtoMulti(node));
},
.fn_proto_one => {
- var params: [1]ast.Node.Index = undefined;
+ var params: [1]Ast.Node.Index = undefined;
return fnProtoExpr(gz, scope, rl, tree.fnProtoOne(¶ms, node));
},
.fn_proto => {
@@ -950,7 +950,7 @@ fn nosuspendExpr(
gz: *GenZir,
scope: *Scope,
rl: ResultLoc,
- node: ast.Node.Index,
+ node: Ast.Node.Index,
) InnerError!Zir.Inst.Ref {
const astgen = gz.astgen;
const tree = astgen.tree;
@@ -971,7 +971,7 @@ fn nosuspendExpr(
fn suspendExpr(
gz: *GenZir,
scope: *Scope,
- node: ast.Node.Index,
+ node: Ast.Node.Index,
) InnerError!Zir.Inst.Ref {
const astgen = gz.astgen;
const gpa = astgen.gpa;
@@ -1011,7 +1011,7 @@ fn awaitExpr(
gz: *GenZir,
scope: *Scope,
rl: ResultLoc,
- node: ast.Node.Index,
+ node: Ast.Node.Index,
) InnerError!Zir.Inst.Ref {
const astgen = gz.astgen;
const tree = astgen.tree;
@@ -1033,7 +1033,7 @@ fn resumeExpr(
gz: *GenZir,
scope: *Scope,
rl: ResultLoc,
- node: ast.Node.Index,
+ node: Ast.Node.Index,
) InnerError!Zir.Inst.Ref {
const astgen = gz.astgen;
const tree = astgen.tree;
@@ -1048,7 +1048,7 @@ fn fnProtoExpr(
gz: *GenZir,
scope: *Scope,
rl: ResultLoc,
- fn_proto: ast.full.FnProto,
+ fn_proto: Ast.full.FnProto,
) InnerError!Zir.Inst.Ref {
const astgen = gz.astgen;
const gpa = astgen.gpa;
@@ -1159,8 +1159,8 @@ fn arrayInitExpr(
gz: *GenZir,
scope: *Scope,
rl: ResultLoc,
- node: ast.Node.Index,
- array_init: ast.full.ArrayInit,
+ node: Ast.Node.Index,
+ array_init: Ast.full.ArrayInit,
) InnerError!Zir.Inst.Ref {
const astgen = gz.astgen;
const tree = astgen.tree;
@@ -1179,7 +1179,7 @@ fn arrayInitExpr(
};
infer: {
- const array_type: ast.full.ArrayType = switch (node_tags[array_init.ast.type_expr]) {
+ const array_type: Ast.full.ArrayType = switch (node_tags[array_init.ast.type_expr]) {
.array_type => tree.arrayType(array_init.ast.type_expr),
.array_type_sentinel => tree.arrayTypeSentinel(array_init.ast.type_expr),
else => break :infer,
@@ -1256,8 +1256,8 @@ fn arrayInitExpr(
fn arrayInitExprRlNone(
gz: *GenZir,
scope: *Scope,
- node: ast.Node.Index,
- elements: []const ast.Node.Index,
+ node: Ast.Node.Index,
+ elements: []const Ast.Node.Index,
tag: Zir.Inst.Tag,
) InnerError!Zir.Inst.Ref {
const astgen = gz.astgen;
@@ -1278,8 +1278,8 @@ fn arrayInitExprRlNone(
fn arrayInitExprRlTy(
gz: *GenZir,
scope: *Scope,
- node: ast.Node.Index,
- elements: []const ast.Node.Index,
+ node: Ast.Node.Index,
+ elements: []const Ast.Node.Index,
elem_ty_inst: Zir.Inst.Ref,
tag: Zir.Inst.Tag,
) InnerError!Zir.Inst.Ref {
@@ -1304,8 +1304,8 @@ fn arrayInitExprRlTy(
fn arrayInitExprRlPtr(
gz: *GenZir,
scope: *Scope,
- node: ast.Node.Index,
- elements: []const ast.Node.Index,
+ node: Ast.Node.Index,
+ elements: []const Ast.Node.Index,
result_ptr: Zir.Inst.Ref,
) InnerError!Zir.Inst.Ref {
const astgen = gz.astgen;
@@ -1334,8 +1334,8 @@ fn structInitExpr(
gz: *GenZir,
scope: *Scope,
rl: ResultLoc,
- node: ast.Node.Index,
- struct_init: ast.full.StructInit,
+ node: Ast.Node.Index,
+ struct_init: Ast.full.StructInit,
) InnerError!Zir.Inst.Ref {
const astgen = gz.astgen;
const tree = astgen.tree;
@@ -1347,7 +1347,7 @@ fn structInitExpr(
} else array: {
const node_tags = tree.nodes.items(.tag);
const main_tokens = tree.nodes.items(.main_token);
- const array_type: ast.full.ArrayType = switch (node_tags[struct_init.ast.type_expr]) {
+ const array_type: Ast.full.ArrayType = switch (node_tags[struct_init.ast.type_expr]) {
.array_type => tree.arrayType(struct_init.ast.type_expr),
.array_type_sentinel => tree.arrayTypeSentinel(struct_init.ast.type_expr),
else => break :array,
@@ -1420,8 +1420,8 @@ fn structInitExpr(
fn structInitExprRlNone(
gz: *GenZir,
scope: *Scope,
- node: ast.Node.Index,
- struct_init: ast.full.StructInit,
+ node: Ast.Node.Index,
+ struct_init: Ast.full.StructInit,
tag: Zir.Inst.Tag,
) InnerError!Zir.Inst.Ref {
const astgen = gz.astgen;
@@ -1454,8 +1454,8 @@ fn structInitExprRlNone(
fn structInitExprRlPtr(
gz: *GenZir,
scope: *Scope,
- node: ast.Node.Index,
- struct_init: ast.full.StructInit,
+ node: Ast.Node.Index,
+ struct_init: Ast.full.StructInit,
result_ptr: Zir.Inst.Ref,
) InnerError!Zir.Inst.Ref {
const astgen = gz.astgen;
@@ -1488,8 +1488,8 @@ fn structInitExprRlPtr(
fn structInitExprRlTy(
gz: *GenZir,
scope: *Scope,
- node: ast.Node.Index,
- struct_init: ast.full.StructInit,
+ node: Ast.Node.Index,
+ struct_init: Ast.full.StructInit,
ty_inst: Zir.Inst.Ref,
tag: Zir.Inst.Tag,
) InnerError!Zir.Inst.Ref {
@@ -1530,7 +1530,7 @@ fn comptimeExpr(
gz: *GenZir,
scope: *Scope,
rl: ResultLoc,
- node: ast.Node.Index,
+ node: Ast.Node.Index,
) InnerError!Zir.Inst.Ref {
const prev_force_comptime = gz.force_comptime;
gz.force_comptime = true;
@@ -1546,7 +1546,7 @@ fn comptimeExprAst(
gz: *GenZir,
scope: *Scope,
rl: ResultLoc,
- node: ast.Node.Index,
+ node: Ast.Node.Index,
) InnerError!Zir.Inst.Ref {
const astgen = gz.astgen;
if (gz.force_comptime) {
@@ -1561,7 +1561,7 @@ fn comptimeExprAst(
return result;
}
-fn breakExpr(parent_gz: *GenZir, parent_scope: *Scope, node: ast.Node.Index) InnerError!Zir.Inst.Ref {
+fn breakExpr(parent_gz: *GenZir, parent_scope: *Scope, node: Ast.Node.Index) InnerError!Zir.Inst.Ref {
const astgen = parent_gz.astgen;
const tree = astgen.tree;
const node_datas = tree.nodes.items(.data);
@@ -1636,7 +1636,7 @@ fn breakExpr(parent_gz: *GenZir, parent_scope: *Scope, node: ast.Node.Index) Inn
}
}
-fn continueExpr(parent_gz: *GenZir, parent_scope: *Scope, node: ast.Node.Index) InnerError!Zir.Inst.Ref {
+fn continueExpr(parent_gz: *GenZir, parent_scope: *Scope, node: Ast.Node.Index) InnerError!Zir.Inst.Ref {
const astgen = parent_gz.astgen;
const tree = astgen.tree;
const node_datas = tree.nodes.items(.data);
@@ -1694,8 +1694,8 @@ fn blockExpr(
gz: *GenZir,
scope: *Scope,
rl: ResultLoc,
- block_node: ast.Node.Index,
- statements: []const ast.Node.Index,
+ block_node: Ast.Node.Index,
+ statements: []const Ast.Node.Index,
) InnerError!Zir.Inst.Ref {
const tracy = trace(@src());
defer tracy.end();
@@ -1716,7 +1716,7 @@ fn blockExpr(
return rvalue(gz, rl, .void_value, block_node);
}
-fn checkLabelRedefinition(astgen: *AstGen, parent_scope: *Scope, label: ast.TokenIndex) !void {
+fn checkLabelRedefinition(astgen: *AstGen, parent_scope: *Scope, label: Ast.TokenIndex) !void {
// Look for the label in the scope.
var scope = parent_scope;
while (true) {
@@ -1752,8 +1752,8 @@ fn labeledBlockExpr(
gz: *GenZir,
parent_scope: *Scope,
rl: ResultLoc,
- block_node: ast.Node.Index,
- statements: []const ast.Node.Index,
+ block_node: Ast.Node.Index,
+ statements: []const Ast.Node.Index,
zir_tag: Zir.Inst.Tag,
) InnerError!Zir.Inst.Ref {
const tracy = trace(@src());
@@ -1829,7 +1829,7 @@ fn labeledBlockExpr(
}
}
-fn blockExprStmts(gz: *GenZir, parent_scope: *Scope, statements: []const ast.Node.Index) !void {
+fn blockExprStmts(gz: *GenZir, parent_scope: *Scope, statements: []const Ast.Node.Index) !void {
const astgen = gz.astgen;
const tree = astgen.tree;
const node_tags = tree.nodes.items(.tag);
@@ -1837,7 +1837,7 @@ fn blockExprStmts(gz: *GenZir, parent_scope: *Scope, statements: []const ast.Nod
var block_arena = std.heap.ArenaAllocator.init(gz.astgen.gpa);
defer block_arena.deinit();
- var noreturn_src_node: ast.Node.Index = 0;
+ var noreturn_src_node: Ast.Node.Index = 0;
var scope = parent_scope;
for (statements) |statement| {
if (noreturn_src_node != 0) {
@@ -1892,12 +1892,12 @@ fn blockExprStmts(gz: *GenZir, parent_scope: *Scope, statements: []const ast.Nod
/// Returns AST source node of the thing that is noreturn if the statement is definitely `noreturn`.
/// Otherwise returns 0.
-fn unusedResultExpr(gz: *GenZir, scope: *Scope, statement: ast.Node.Index) InnerError!ast.Node.Index {
+fn unusedResultExpr(gz: *GenZir, scope: *Scope, statement: Ast.Node.Index) InnerError!Ast.Node.Index {
try emitDbgNode(gz, statement);
// We need to emit an error if the result is not `noreturn` or `void`, but
// we want to avoid adding the ZIR instruction if possible for performance.
const maybe_unused_result = try expr(gz, scope, .none, statement);
- var noreturn_src_node: ast.Node.Index = 0;
+ var noreturn_src_node: Ast.Node.Index = 0;
const elide_check = if (refToIndex(maybe_unused_result)) |inst| b: {
// Note that this array becomes invalid after appending more items to it
// in the above while loop.
@@ -2344,7 +2344,7 @@ fn checkUsed(
fn makeDeferScope(
scope: *Scope,
- node: ast.Node.Index,
+ node: Ast.Node.Index,
block_arena: *Allocator,
scope_tag: Scope.Tag,
) InnerError!*Scope {
@@ -2360,9 +2360,9 @@ fn makeDeferScope(
fn varDecl(
gz: *GenZir,
scope: *Scope,
- node: ast.Node.Index,
+ node: Ast.Node.Index,
block_arena: *Allocator,
- var_decl: ast.full.VarDecl,
+ var_decl: Ast.full.VarDecl,
) InnerError!*Scope {
try emitDbgNode(gz, node);
const astgen = gz.astgen;
@@ -2574,7 +2574,7 @@ fn varDecl(
}
}
-fn emitDbgNode(gz: *GenZir, node: ast.Node.Index) !void {
+fn emitDbgNode(gz: *GenZir, node: Ast.Node.Index) !void {
// The instruction emitted here is for debugging runtime code.
// If the current block will be evaluated only during semantic analysis
// then no dbg_stmt ZIR instruction is needed.
@@ -2598,7 +2598,7 @@ fn emitDbgNode(gz: *GenZir, node: ast.Node.Index) !void {
} });
}
-fn assign(gz: *GenZir, scope: *Scope, infix_node: ast.Node.Index) InnerError!void {
+fn assign(gz: *GenZir, scope: *Scope, infix_node: Ast.Node.Index) InnerError!void {
try emitDbgNode(gz, infix_node);
const astgen = gz.astgen;
const tree = astgen.tree;
@@ -2623,7 +2623,7 @@ fn assign(gz: *GenZir, scope: *Scope, infix_node: ast.Node.Index) InnerError!voi
fn assignOp(
gz: *GenZir,
scope: *Scope,
- infix_node: ast.Node.Index,
+ infix_node: Ast.Node.Index,
op_inst_tag: Zir.Inst.Tag,
) InnerError!void {
try emitDbgNode(gz, infix_node);
@@ -2646,7 +2646,7 @@ fn assignOp(
fn assignShift(
gz: *GenZir,
scope: *Scope,
- infix_node: ast.Node.Index,
+ infix_node: Ast.Node.Index,
op_inst_tag: Zir.Inst.Tag,
) InnerError!void {
try emitDbgNode(gz, infix_node);
@@ -2666,7 +2666,7 @@ fn assignShift(
_ = try gz.addBin(.store, lhs_ptr, result);
}
-fn boolNot(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) InnerError!Zir.Inst.Ref {
+fn boolNot(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: Ast.Node.Index) InnerError!Zir.Inst.Ref {
const astgen = gz.astgen;
const tree = astgen.tree;
const node_datas = tree.nodes.items(.data);
@@ -2676,7 +2676,7 @@ fn boolNot(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) Inne
return rvalue(gz, rl, result, node);
}
-fn bitNot(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) InnerError!Zir.Inst.Ref {
+fn bitNot(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: Ast.Node.Index) InnerError!Zir.Inst.Ref {
const astgen = gz.astgen;
const tree = astgen.tree;
const node_datas = tree.nodes.items(.data);
@@ -2690,7 +2690,7 @@ fn negation(
gz: *GenZir,
scope: *Scope,
rl: ResultLoc,
- node: ast.Node.Index,
+ node: Ast.Node.Index,
tag: Zir.Inst.Tag,
) InnerError!Zir.Inst.Ref {
const astgen = gz.astgen;
@@ -2706,8 +2706,8 @@ fn ptrType(
gz: *GenZir,
scope: *Scope,
rl: ResultLoc,
- node: ast.Node.Index,
- ptr_info: ast.full.PtrType,
+ node: Ast.Node.Index,
+ ptr_info: Ast.full.PtrType,
) InnerError!Zir.Inst.Ref {
const elem_type = try typeExpr(gz, scope, ptr_info.ast.child_type);
@@ -2788,7 +2788,7 @@ fn ptrType(
return rvalue(gz, rl, result, node);
}
-fn arrayType(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) !Zir.Inst.Ref {
+fn arrayType(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: Ast.Node.Index) !Zir.Inst.Ref {
const astgen = gz.astgen;
const tree = astgen.tree;
const node_datas = tree.nodes.items(.data);
@@ -2808,13 +2808,13 @@ fn arrayType(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) !Z
return rvalue(gz, rl, result, node);
}
-fn arrayTypeSentinel(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) !Zir.Inst.Ref {
+fn arrayTypeSentinel(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: Ast.Node.Index) !Zir.Inst.Ref {
const astgen = gz.astgen;
const tree = astgen.tree;
const node_datas = tree.nodes.items(.data);
const node_tags = tree.nodes.items(.tag);
const main_tokens = tree.nodes.items(.main_token);
- const extra = tree.extraData(node_datas[node].rhs, ast.Node.ArrayTypeSentinel);
+ const extra = tree.extraData(node_datas[node].rhs, Ast.Node.ArrayTypeSentinel);
const len_node = node_datas[node].lhs;
if (node_tags[len_node] == .identifier and
@@ -2870,9 +2870,9 @@ fn fnDecl(
gz: *GenZir,
scope: *Scope,
wip_decls: *WipDecls,
- decl_node: ast.Node.Index,
- body_node: ast.Node.Index,
- fn_proto: ast.full.FnProto,
+ decl_node: Ast.Node.Index,
+ body_node: Ast.Node.Index,
+ fn_proto: Ast.full.FnProto,
) InnerError!void {
const gpa = astgen.gpa;
const tree = astgen.tree;
@@ -3135,8 +3135,8 @@ fn globalVarDecl(
gz: *GenZir,
scope: *Scope,
wip_decls: *WipDecls,
- node: ast.Node.Index,
- var_decl: ast.full.VarDecl,
+ node: Ast.Node.Index,
+ var_decl: Ast.full.VarDecl,
) InnerError!void {
const gpa = astgen.gpa;
const tree = astgen.tree;
@@ -3279,7 +3279,7 @@ fn comptimeDecl(
gz: *GenZir,
scope: *Scope,
wip_decls: *WipDecls,
- node: ast.Node.Index,
+ node: Ast.Node.Index,
) InnerError!void {
const gpa = astgen.gpa;
const tree = astgen.tree;
@@ -3326,7 +3326,7 @@ fn usingnamespaceDecl(
gz: *GenZir,
scope: *Scope,
wip_decls: *WipDecls,
- node: ast.Node.Index,
+ node: Ast.Node.Index,
) InnerError!void {
const gpa = astgen.gpa;
const tree = astgen.tree;
@@ -3377,7 +3377,7 @@ fn testDecl(
gz: *GenZir,
scope: *Scope,
wip_decls: *WipDecls,
- node: ast.Node.Index,
+ node: Ast.Node.Index,
) InnerError!void {
const gpa = astgen.gpa;
const tree = astgen.tree;
@@ -3468,8 +3468,8 @@ fn testDecl(
fn structDeclInner(
gz: *GenZir,
scope: *Scope,
- node: ast.Node.Index,
- container_decl: ast.full.ContainerDecl,
+ node: Ast.Node.Index,
+ container_decl: Ast.full.ContainerDecl,
layout: std.builtin.TypeInfo.ContainerLayout,
) InnerError!Zir.Inst.Ref {
if (container_decl.ast.members.len == 0) {
@@ -3537,7 +3537,7 @@ fn structDeclInner(
const body = node_datas[member_node].rhs;
switch (node_tags[fn_proto]) {
.fn_proto_simple => {
- var params: [1]ast.Node.Index = undefined;
+ var params: [1]Ast.Node.Index = undefined;
astgen.fnDecl(gz, &namespace.base, &wip_decls, member_node, body, tree.fnProtoSimple(¶ms, fn_proto)) catch |err| switch (err) {
error.OutOfMemory => return error.OutOfMemory,
error.AnalysisFail => {},
@@ -3552,7 +3552,7 @@ fn structDeclInner(
continue;
},
.fn_proto_one => {
- var params: [1]ast.Node.Index = undefined;
+ var params: [1]Ast.Node.Index = undefined;
astgen.fnDecl(gz, &namespace.base, &wip_decls, member_node, body, tree.fnProtoOne(¶ms, fn_proto)) catch |err| switch (err) {
error.OutOfMemory => return error.OutOfMemory,
error.AnalysisFail => {},
@@ -3570,7 +3570,7 @@ fn structDeclInner(
}
},
.fn_proto_simple => {
- var params: [1]ast.Node.Index = undefined;
+ var params: [1]Ast.Node.Index = undefined;
astgen.fnDecl(gz, &namespace.base, &wip_decls, member_node, 0, tree.fnProtoSimple(¶ms, member_node)) catch |err| switch (err) {
error.OutOfMemory => return error.OutOfMemory,
error.AnalysisFail => {},
@@ -3585,7 +3585,7 @@ fn structDeclInner(
continue;
},
.fn_proto_one => {
- var params: [1]ast.Node.Index = undefined;
+ var params: [1]Ast.Node.Index = undefined;
astgen.fnDecl(gz, &namespace.base, &wip_decls, member_node, 0, tree.fnProtoOne(¶ms, member_node)) catch |err| switch (err) {
error.OutOfMemory => return error.OutOfMemory,
error.AnalysisFail => {},
@@ -3750,10 +3750,10 @@ fn structDeclInner(
fn unionDeclInner(
gz: *GenZir,
scope: *Scope,
- node: ast.Node.Index,
- members: []const ast.Node.Index,
+ node: Ast.Node.Index,
+ members: []const Ast.Node.Index,
layout: std.builtin.TypeInfo.ContainerLayout,
- arg_node: ast.Node.Index,
+ arg_node: Ast.Node.Index,
have_auto_enum: bool,
) InnerError!Zir.Inst.Ref {
const astgen = gz.astgen;
@@ -3812,7 +3812,7 @@ fn unionDeclInner(
const body = node_datas[member_node].rhs;
switch (node_tags[fn_proto]) {
.fn_proto_simple => {
- var params: [1]ast.Node.Index = undefined;
+ var params: [1]Ast.Node.Index = undefined;
astgen.fnDecl(gz, &namespace.base, &wip_decls, member_node, body, tree.fnProtoSimple(¶ms, fn_proto)) catch |err| switch (err) {
error.OutOfMemory => return error.OutOfMemory,
error.AnalysisFail => {},
@@ -3827,7 +3827,7 @@ fn unionDeclInner(
continue;
},
.fn_proto_one => {
- var params: [1]ast.Node.Index = undefined;
+ var params: [1]Ast.Node.Index = undefined;
astgen.fnDecl(gz, &namespace.base, &wip_decls, member_node, body, tree.fnProtoOne(¶ms, fn_proto)) catch |err| switch (err) {
error.OutOfMemory => return error.OutOfMemory,
error.AnalysisFail => {},
@@ -3845,7 +3845,7 @@ fn unionDeclInner(
}
},
.fn_proto_simple => {
- var params: [1]ast.Node.Index = undefined;
+ var params: [1]Ast.Node.Index = undefined;
astgen.fnDecl(gz, &namespace.base, &wip_decls, member_node, 0, tree.fnProtoSimple(¶ms, member_node)) catch |err| switch (err) {
error.OutOfMemory => return error.OutOfMemory,
error.AnalysisFail => {},
@@ -3860,7 +3860,7 @@ fn unionDeclInner(
continue;
},
.fn_proto_one => {
- var params: [1]ast.Node.Index = undefined;
+ var params: [1]Ast.Node.Index = undefined;
astgen.fnDecl(gz, &namespace.base, &wip_decls, member_node, 0, tree.fnProtoOne(¶ms, member_node)) catch |err| switch (err) {
error.OutOfMemory => return error.OutOfMemory,
error.AnalysisFail => {},
@@ -4033,8 +4033,8 @@ fn containerDecl(
gz: *GenZir,
scope: *Scope,
rl: ResultLoc,
- node: ast.Node.Index,
- container_decl: ast.full.ContainerDecl,
+ node: Ast.Node.Index,
+ container_decl: Ast.full.ContainerDecl,
) InnerError!Zir.Inst.Ref {
const astgen = gz.astgen;
const gpa = astgen.gpa;
@@ -4084,7 +4084,7 @@ fn containerDecl(
var values: usize = 0;
var total_fields: usize = 0;
var decls: usize = 0;
- var nonexhaustive_node: ast.Node.Index = 0;
+ var nonexhaustive_node: Ast.Node.Index = 0;
for (container_decl.ast.members) |member_node| {
const member = switch (node_tags[member_node]) {
.container_field_init => tree.containerFieldInit(member_node),
@@ -4225,7 +4225,7 @@ fn containerDecl(
const body = node_datas[member_node].rhs;
switch (node_tags[fn_proto]) {
.fn_proto_simple => {
- var params: [1]ast.Node.Index = undefined;
+ var params: [1]Ast.Node.Index = undefined;
astgen.fnDecl(gz, &namespace.base, &wip_decls, member_node, body, tree.fnProtoSimple(¶ms, fn_proto)) catch |err| switch (err) {
error.OutOfMemory => return error.OutOfMemory,
error.AnalysisFail => {},
@@ -4240,7 +4240,7 @@ fn containerDecl(
continue;
},
.fn_proto_one => {
- var params: [1]ast.Node.Index = undefined;
+ var params: [1]Ast.Node.Index = undefined;
astgen.fnDecl(gz, &namespace.base, &wip_decls, member_node, body, tree.fnProtoOne(¶ms, fn_proto)) catch |err| switch (err) {
error.OutOfMemory => return error.OutOfMemory,
error.AnalysisFail => {},
@@ -4258,7 +4258,7 @@ fn containerDecl(
}
},
.fn_proto_simple => {
- var params: [1]ast.Node.Index = undefined;
+ var params: [1]Ast.Node.Index = undefined;
astgen.fnDecl(gz, &namespace.base, &wip_decls, member_node, 0, tree.fnProtoSimple(¶ms, member_node)) catch |err| switch (err) {
error.OutOfMemory => return error.OutOfMemory,
error.AnalysisFail => {},
@@ -4273,7 +4273,7 @@ fn containerDecl(
continue;
},
.fn_proto_one => {
- var params: [1]ast.Node.Index = undefined;
+ var params: [1]Ast.Node.Index = undefined;
astgen.fnDecl(gz, &namespace.base, &wip_decls, member_node, 0, tree.fnProtoOne(¶ms, member_node)) catch |err| switch (err) {
error.OutOfMemory => return error.OutOfMemory,
error.AnalysisFail => {},
@@ -4441,7 +4441,7 @@ fn containerDecl(
const body = node_datas[member_node].rhs;
switch (node_tags[fn_proto]) {
.fn_proto_simple => {
- var params: [1]ast.Node.Index = undefined;
+ var params: [1]Ast.Node.Index = undefined;
astgen.fnDecl(gz, &namespace.base, &wip_decls, member_node, body, tree.fnProtoSimple(¶ms, fn_proto)) catch |err| switch (err) {
error.OutOfMemory => return error.OutOfMemory,
error.AnalysisFail => {},
@@ -4456,7 +4456,7 @@ fn containerDecl(
continue;
},
.fn_proto_one => {
- var params: [1]ast.Node.Index = undefined;
+ var params: [1]Ast.Node.Index = undefined;
astgen.fnDecl(gz, &namespace.base, &wip_decls, member_node, body, tree.fnProtoOne(¶ms, fn_proto)) catch |err| switch (err) {
error.OutOfMemory => return error.OutOfMemory,
error.AnalysisFail => {},
@@ -4474,7 +4474,7 @@ fn containerDecl(
}
},
.fn_proto_simple => {
- var params: [1]ast.Node.Index = undefined;
+ var params: [1]Ast.Node.Index = undefined;
astgen.fnDecl(gz, &namespace.base, &wip_decls, member_node, 0, tree.fnProtoSimple(¶ms, member_node)) catch |err| switch (err) {
error.OutOfMemory => return error.OutOfMemory,
error.AnalysisFail => {},
@@ -4489,7 +4489,7 @@ fn containerDecl(
continue;
},
.fn_proto_one => {
- var params: [1]ast.Node.Index = undefined;
+ var params: [1]Ast.Node.Index = undefined;
astgen.fnDecl(gz, &namespace.base, &wip_decls, member_node, 0, tree.fnProtoOne(¶ms, member_node)) catch |err| switch (err) {
error.OutOfMemory => return error.OutOfMemory,
error.AnalysisFail => {},
@@ -4590,7 +4590,7 @@ fn containerDecl(
}
}
-fn errorSetDecl(gz: *GenZir, rl: ResultLoc, node: ast.Node.Index) InnerError!Zir.Inst.Ref {
+fn errorSetDecl(gz: *GenZir, rl: ResultLoc, node: Ast.Node.Index) InnerError!Zir.Inst.Ref {
const astgen = gz.astgen;
const gpa = astgen.gpa;
const tree = astgen.tree;
@@ -4629,8 +4629,8 @@ fn tryExpr(
parent_gz: *GenZir,
scope: *Scope,
rl: ResultLoc,
- node: ast.Node.Index,
- operand_node: ast.Node.Index,
+ node: Ast.Node.Index,
+ operand_node: Ast.Node.Index,
) InnerError!Zir.Inst.Ref {
const astgen = parent_gz.astgen;
@@ -4705,13 +4705,13 @@ fn orelseCatchExpr(
parent_gz: *GenZir,
scope: *Scope,
rl: ResultLoc,
- node: ast.Node.Index,
- lhs: ast.Node.Index,
+ node: Ast.Node.Index,
+ lhs: Ast.Node.Index,
cond_op: Zir.Inst.Tag,
unwrap_op: Zir.Inst.Tag,
unwrap_code_op: Zir.Inst.Tag,
- rhs: ast.Node.Index,
- payload_token: ?ast.TokenIndex,
+ rhs: Ast.Node.Index,
+ payload_token: ?Ast.TokenIndex,
) InnerError!Zir.Inst.Ref {
const astgen = parent_gz.astgen;
const tree = astgen.tree;
@@ -4796,7 +4796,7 @@ fn orelseCatchExpr(
fn finishThenElseBlock(
parent_gz: *GenZir,
rl: ResultLoc,
- node: ast.Node.Index,
+ node: Ast.Node.Index,
block_scope: *GenZir,
then_scope: *GenZir,
else_scope: *GenZir,
@@ -4852,7 +4852,7 @@ fn finishThenElseBlock(
/// tokens without allocating.
/// OK in theory it could do it without allocating. This implementation
/// allocates when the @"" form is used.
-fn tokenIdentEql(astgen: *AstGen, token1: ast.TokenIndex, token2: ast.TokenIndex) !bool {
+fn tokenIdentEql(astgen: *AstGen, token1: Ast.TokenIndex, token2: Ast.TokenIndex) !bool {
const ident_name_1 = try astgen.identifierTokenString(token1);
const ident_name_2 = try astgen.identifierTokenString(token2);
return mem.eql(u8, ident_name_1, ident_name_2);
@@ -4862,7 +4862,7 @@ fn fieldAccess(
gz: *GenZir,
scope: *Scope,
rl: ResultLoc,
- node: ast.Node.Index,
+ node: Ast.Node.Index,
) InnerError!Zir.Inst.Ref {
const astgen = gz.astgen;
const tree = astgen.tree;
@@ -4889,7 +4889,7 @@ fn arrayAccess(
gz: *GenZir,
scope: *Scope,
rl: ResultLoc,
- node: ast.Node.Index,
+ node: Ast.Node.Index,
) InnerError!Zir.Inst.Ref {
const astgen = gz.astgen;
const tree = astgen.tree;
@@ -4912,7 +4912,7 @@ fn simpleBinOp(
gz: *GenZir,
scope: *Scope,
rl: ResultLoc,
- node: ast.Node.Index,
+ node: Ast.Node.Index,
op_inst_tag: Zir.Inst.Tag,
) InnerError!Zir.Inst.Ref {
const astgen = gz.astgen;
@@ -4929,8 +4929,8 @@ fn simpleBinOp(
fn simpleStrTok(
gz: *GenZir,
rl: ResultLoc,
- ident_token: ast.TokenIndex,
- node: ast.Node.Index,
+ ident_token: Ast.TokenIndex,
+ node: Ast.Node.Index,
op_inst_tag: Zir.Inst.Tag,
) InnerError!Zir.Inst.Ref {
const astgen = gz.astgen;
@@ -4943,7 +4943,7 @@ fn boolBinOp(
gz: *GenZir,
scope: *Scope,
rl: ResultLoc,
- node: ast.Node.Index,
+ node: Ast.Node.Index,
zir_tag: Zir.Inst.Tag,
) InnerError!Zir.Inst.Ref {
const astgen = gz.astgen;
@@ -4969,8 +4969,8 @@ fn ifExpr(
parent_gz: *GenZir,
scope: *Scope,
rl: ResultLoc,
- node: ast.Node.Index,
- if_full: ast.full.If,
+ node: Ast.Node.Index,
+ if_full: Ast.full.If,
) InnerError!Zir.Inst.Ref {
const astgen = parent_gz.astgen;
const tree = astgen.tree;
@@ -5089,7 +5089,7 @@ fn ifExpr(
const else_node = if_full.ast.else_expr;
const else_info: struct {
- src: ast.Node.Index,
+ src: Ast.Node.Index,
result: Zir.Inst.Ref,
} = if (else_node != 0) blk: {
block_scope.break_count += 1;
@@ -5215,8 +5215,8 @@ fn whileExpr(
parent_gz: *GenZir,
scope: *Scope,
rl: ResultLoc,
- node: ast.Node.Index,
- while_full: ast.full.While,
+ node: Ast.Node.Index,
+ while_full: Ast.full.While,
) InnerError!Zir.Inst.Ref {
const astgen = parent_gz.astgen;
const tree = astgen.tree;
@@ -5368,7 +5368,7 @@ fn whileExpr(
const else_node = while_full.ast.else_expr;
const else_info: struct {
- src: ast.Node.Index,
+ src: Ast.Node.Index,
result: Zir.Inst.Ref,
} = if (else_node != 0) blk: {
loop_scope.break_count += 1;
@@ -5435,8 +5435,8 @@ fn forExpr(
parent_gz: *GenZir,
scope: *Scope,
rl: ResultLoc,
- node: ast.Node.Index,
- for_full: ast.full.While,
+ node: Ast.Node.Index,
+ for_full: Ast.full.While,
) InnerError!Zir.Inst.Ref {
const astgen = parent_gz.astgen;
@@ -5577,7 +5577,7 @@ fn forExpr(
const else_node = for_full.ast.else_expr;
const else_info: struct {
- src: ast.Node.Index,
+ src: Ast.Node.Index,
result: Zir.Inst.Ref,
} = if (else_node != 0) blk: {
loop_scope.break_count += 1;
@@ -5618,7 +5618,7 @@ fn switchExpr(
parent_gz: *GenZir,
scope: *Scope,
rl: ResultLoc,
- switch_node: ast.Node.Index,
+ switch_node: Ast.Node.Index,
) InnerError!Zir.Inst.Ref {
const astgen = parent_gz.astgen;
const gpa = astgen.gpa;
@@ -5628,7 +5628,7 @@ fn switchExpr(
const main_tokens = tree.nodes.items(.main_token);
const token_tags = tree.tokens.items(.tag);
const operand_node = node_datas[switch_node].lhs;
- const extra = tree.extraData(node_datas[switch_node].rhs, ast.Node.SubRange);
+ const extra = tree.extraData(node_datas[switch_node].rhs, Ast.Node.SubRange);
const case_nodes = tree.extra_data[extra.start..extra.end];
// We perform two passes over the AST. This first pass is to collect information
@@ -5638,9 +5638,9 @@ fn switchExpr(
var scalar_cases_len: u32 = 0;
var multi_cases_len: u32 = 0;
var special_prong: Zir.SpecialProng = .none;
- var special_node: ast.Node.Index = 0;
- var else_src: ?ast.TokenIndex = null;
- var underscore_src: ?ast.TokenIndex = null;
+ var special_node: Ast.Node.Index = 0;
+ var else_src: ?Ast.TokenIndex = null;
+ var underscore_src: ?Ast.TokenIndex = null;
for (case_nodes) |case_node| {
const case = switch (node_tags[case_node]) {
.switch_case_one => tree.switchCaseOne(case_node),
@@ -6212,7 +6212,7 @@ fn switchExpr(
}
}
-fn ret(gz: *GenZir, scope: *Scope, node: ast.Node.Index) InnerError!Zir.Inst.Ref {
+fn ret(gz: *GenZir, scope: *Scope, node: Ast.Node.Index) InnerError!Zir.Inst.Ref {
const astgen = gz.astgen;
const tree = astgen.tree;
const node_datas = tree.nodes.items(.data);
@@ -6311,7 +6311,7 @@ fn identifier(
gz: *GenZir,
scope: *Scope,
rl: ResultLoc,
- ident: ast.Node.Index,
+ ident: Ast.Node.Index,
) InnerError!Zir.Inst.Ref {
const tracy = trace(@src());
defer tracy.end();
@@ -6363,8 +6363,8 @@ fn identifier(
// Local variables, including function parameters.
const name_str_index = try astgen.identAsString(ident_token);
var s = scope;
- var found_already: ?ast.Node.Index = null; // we have found a decl with the same name already
- var hit_namespace: ast.Node.Index = 0;
+ var found_already: ?Ast.Node.Index = null; // we have found a decl with the same name already
+ var hit_namespace: Ast.Node.Index = 0;
while (true) switch (s.tag) {
.local_val => {
const local_val = s.cast(Scope.LocalVal).?;
@@ -6416,6 +6416,9 @@ fn identifier(
},
.top => break,
};
+ if (found_already == null) {
+ return astgen.failNode(ident, "use of undeclared identifier '{s}'", .{ident_name});
+ }
// Decl references happen by name rather than ZIR index so that when unrelated
// decls are modified, ZIR code containing references to them can be unmodified.
@@ -6431,7 +6434,7 @@ fn identifier(
fn stringLiteral(
gz: *GenZir,
rl: ResultLoc,
- node: ast.Node.Index,
+ node: Ast.Node.Index,
) InnerError!Zir.Inst.Ref {
const astgen = gz.astgen;
const tree = astgen.tree;
@@ -6451,7 +6454,7 @@ fn stringLiteral(
fn multilineStringLiteral(
gz: *GenZir,
rl: ResultLoc,
- node: ast.Node.Index,
+ node: Ast.Node.Index,
) InnerError!Zir.Inst.Ref {
const astgen = gz.astgen;
const str = try astgen.strLitNodeAsString(node);
@@ -6465,7 +6468,7 @@ fn multilineStringLiteral(
return rvalue(gz, rl, result, node);
}
-fn charLiteral(gz: *GenZir, rl: ResultLoc, node: ast.Node.Index) !Zir.Inst.Ref {
+fn charLiteral(gz: *GenZir, rl: ResultLoc, node: Ast.Node.Index) !Zir.Inst.Ref {
const astgen = gz.astgen;
const tree = astgen.tree;
const main_tokens = tree.nodes.items(.main_token);
@@ -6544,7 +6547,7 @@ fn charLiteral(gz: *GenZir, rl: ResultLoc, node: ast.Node.Index) !Zir.Inst.Ref {
}
}
-fn integerLiteral(gz: *GenZir, rl: ResultLoc, node: ast.Node.Index) InnerError!Zir.Inst.Ref {
+fn integerLiteral(gz: *GenZir, rl: ResultLoc, node: Ast.Node.Index) InnerError!Zir.Inst.Ref {
const astgen = gz.astgen;
const tree = astgen.tree;
const main_tokens = tree.nodes.items(.main_token);
@@ -6590,7 +6593,7 @@ fn integerLiteral(gz: *GenZir, rl: ResultLoc, node: ast.Node.Index) InnerError!Z
return rvalue(gz, rl, result, node);
}
-fn floatLiteral(gz: *GenZir, rl: ResultLoc, node: ast.Node.Index) InnerError!Zir.Inst.Ref {
+fn floatLiteral(gz: *GenZir, rl: ResultLoc, node: Ast.Node.Index) InnerError!Zir.Inst.Ref {
const astgen = gz.astgen;
const tree = astgen.tree;
const main_tokens = tree.nodes.items(.main_token);
@@ -6630,8 +6633,8 @@ fn asmExpr(
gz: *GenZir,
scope: *Scope,
rl: ResultLoc,
- node: ast.Node.Index,
- full: ast.full.Asm,
+ node: Ast.Node.Index,
+ full: Ast.full.Asm,
) InnerError!Zir.Inst.Ref {
const astgen = gz.astgen;
const tree = astgen.tree;
@@ -6788,9 +6791,9 @@ fn as(
gz: *GenZir,
scope: *Scope,
rl: ResultLoc,
- node: ast.Node.Index,
- lhs: ast.Node.Index,
- rhs: ast.Node.Index,
+ node: Ast.Node.Index,
+ lhs: Ast.Node.Index,
+ rhs: Ast.Node.Index,
) InnerError!Zir.Inst.Ref {
const dest_type = try typeExpr(gz, scope, lhs);
switch (rl) {
@@ -6811,8 +6814,8 @@ fn unionInit(
gz: *GenZir,
scope: *Scope,
rl: ResultLoc,
- node: ast.Node.Index,
- params: []const ast.Node.Index,
+ node: Ast.Node.Index,
+ params: []const Ast.Node.Index,
) InnerError!Zir.Inst.Ref {
const union_type = try typeExpr(gz, scope, params[0]);
const field_name = try comptimeExpr(gz, scope, .{ .ty = .const_slice_u8_type }, params[1]);
@@ -6837,9 +6840,9 @@ fn unionInit(
fn unionInitRlPtr(
parent_gz: *GenZir,
scope: *Scope,
- node: ast.Node.Index,
+ node: Ast.Node.Index,
result_ptr: Zir.Inst.Ref,
- expr_node: ast.Node.Index,
+ expr_node: Ast.Node.Index,
union_type: Zir.Inst.Ref,
field_name: Zir.Inst.Ref,
) InnerError!Zir.Inst.Ref {
@@ -6856,9 +6859,9 @@ fn asRlPtr(
parent_gz: *GenZir,
scope: *Scope,
rl: ResultLoc,
- src_node: ast.Node.Index,
+ src_node: Ast.Node.Index,
result_ptr: Zir.Inst.Ref,
- operand_node: ast.Node.Index,
+ operand_node: Ast.Node.Index,
dest_type: Zir.Inst.Ref,
) InnerError!Zir.Inst.Ref {
// Detect whether this expr() call goes into rvalue() to store the result into the
@@ -6896,9 +6899,9 @@ fn bitCast(
gz: *GenZir,
scope: *Scope,
rl: ResultLoc,
- node: ast.Node.Index,
- lhs: ast.Node.Index,
- rhs: ast.Node.Index,
+ node: Ast.Node.Index,
+ lhs: Ast.Node.Index,
+ rhs: Ast.Node.Index,
) InnerError!Zir.Inst.Ref {
const astgen = gz.astgen;
const dest_type = try typeExpr(gz, scope, lhs);
@@ -6926,10 +6929,10 @@ fn bitCast(
fn bitCastRlPtr(
gz: *GenZir,
scope: *Scope,
- node: ast.Node.Index,
+ node: Ast.Node.Index,
dest_type: Zir.Inst.Ref,
result_ptr: Zir.Inst.Ref,
- rhs: ast.Node.Index,
+ rhs: Ast.Node.Index,
) InnerError!Zir.Inst.Ref {
const casted_result_ptr = try gz.addPlNode(.bitcast_result_ptr, node, Zir.Inst.Bin{
.lhs = dest_type,
@@ -6942,8 +6945,8 @@ fn typeOf(
gz: *GenZir,
scope: *Scope,
rl: ResultLoc,
- node: ast.Node.Index,
- params: []const ast.Node.Index,
+ node: Ast.Node.Index,
+ params: []const Ast.Node.Index,
) InnerError!Zir.Inst.Ref {
if (params.len < 1) {
return gz.astgen.failNode(node, "expected at least 1 argument, found 0", .{});
@@ -6967,8 +6970,8 @@ fn builtinCall(
gz: *GenZir,
scope: *Scope,
rl: ResultLoc,
- node: ast.Node.Index,
- params: []const ast.Node.Index,
+ node: Ast.Node.Index,
+ params: []const Ast.Node.Index,
) InnerError!Zir.Inst.Ref {
const astgen = gz.astgen;
const tree = astgen.tree;
@@ -7460,7 +7463,7 @@ fn builtinCall(
fn simpleNoOpVoid(
gz: *GenZir,
rl: ResultLoc,
- node: ast.Node.Index,
+ node: Ast.Node.Index,
tag: Zir.Inst.Tag,
) InnerError!Zir.Inst.Ref {
_ = try gz.addNode(tag, node);
@@ -7471,9 +7474,9 @@ fn hasDeclOrField(
gz: *GenZir,
scope: *Scope,
rl: ResultLoc,
- node: ast.Node.Index,
- lhs_node: ast.Node.Index,
- rhs_node: ast.Node.Index,
+ node: Ast.Node.Index,
+ lhs_node: Ast.Node.Index,
+ rhs_node: Ast.Node.Index,
tag: Zir.Inst.Tag,
) InnerError!Zir.Inst.Ref {
const container_type = try typeExpr(gz, scope, lhs_node);
@@ -7489,9 +7492,9 @@ fn typeCast(
gz: *GenZir,
scope: *Scope,
rl: ResultLoc,
- node: ast.Node.Index,
- lhs_node: ast.Node.Index,
- rhs_node: ast.Node.Index,
+ node: Ast.Node.Index,
+ lhs_node: Ast.Node.Index,
+ rhs_node: Ast.Node.Index,
tag: Zir.Inst.Tag,
) InnerError!Zir.Inst.Ref {
const result = try gz.addPlNode(tag, node, Zir.Inst.Bin{
@@ -7505,8 +7508,8 @@ fn simpleUnOpType(
gz: *GenZir,
scope: *Scope,
rl: ResultLoc,
- node: ast.Node.Index,
- operand_node: ast.Node.Index,
+ node: Ast.Node.Index,
+ operand_node: Ast.Node.Index,
tag: Zir.Inst.Tag,
) InnerError!Zir.Inst.Ref {
const operand = try typeExpr(gz, scope, operand_node);
@@ -7518,9 +7521,9 @@ fn simpleUnOp(
gz: *GenZir,
scope: *Scope,
rl: ResultLoc,
- node: ast.Node.Index,
+ node: Ast.Node.Index,
operand_rl: ResultLoc,
- operand_node: ast.Node.Index,
+ operand_node: Ast.Node.Index,
tag: Zir.Inst.Tag,
) InnerError!Zir.Inst.Ref {
const operand = try expr(gz, scope, operand_rl, operand_node);
@@ -7532,8 +7535,8 @@ fn cmpxchg(
gz: *GenZir,
scope: *Scope,
rl: ResultLoc,
- node: ast.Node.Index,
- params: []const ast.Node.Index,
+ node: Ast.Node.Index,
+ params: []const Ast.Node.Index,
tag: Zir.Inst.Tag,
) InnerError!Zir.Inst.Ref {
const int_type = try typeExpr(gz, scope, params[0]);
@@ -7562,9 +7565,9 @@ fn bitBuiltin(
gz: *GenZir,
scope: *Scope,
rl: ResultLoc,
- node: ast.Node.Index,
- int_type_node: ast.Node.Index,
- operand_node: ast.Node.Index,
+ node: Ast.Node.Index,
+ int_type_node: Ast.Node.Index,
+ operand_node: Ast.Node.Index,
tag: Zir.Inst.Tag,
) InnerError!Zir.Inst.Ref {
const int_type = try typeExpr(gz, scope, int_type_node);
@@ -7577,9 +7580,9 @@ fn divBuiltin(
gz: *GenZir,
scope: *Scope,
rl: ResultLoc,
- node: ast.Node.Index,
- lhs_node: ast.Node.Index,
- rhs_node: ast.Node.Index,
+ node: Ast.Node.Index,
+ lhs_node: Ast.Node.Index,
+ rhs_node: Ast.Node.Index,
tag: Zir.Inst.Tag,
) InnerError!Zir.Inst.Ref {
const result = try gz.addPlNode(tag, node, Zir.Inst.Bin{
@@ -7593,8 +7596,8 @@ fn simpleCBuiltin(
gz: *GenZir,
scope: *Scope,
rl: ResultLoc,
- node: ast.Node.Index,
- operand_node: ast.Node.Index,
+ node: Ast.Node.Index,
+ operand_node: Ast.Node.Index,
tag: Zir.Inst.Extended,
) InnerError!Zir.Inst.Ref {
const operand = try comptimeExpr(gz, scope, .{ .ty = .const_slice_u8_type }, operand_node);
@@ -7609,9 +7612,9 @@ fn offsetOf(
gz: *GenZir,
scope: *Scope,
rl: ResultLoc,
- node: ast.Node.Index,
- lhs_node: ast.Node.Index,
- rhs_node: ast.Node.Index,
+ node: Ast.Node.Index,
+ lhs_node: Ast.Node.Index,
+ rhs_node: Ast.Node.Index,
tag: Zir.Inst.Tag,
) InnerError!Zir.Inst.Ref {
const type_inst = try typeExpr(gz, scope, lhs_node);
@@ -7627,9 +7630,9 @@ fn shiftOp(
gz: *GenZir,
scope: *Scope,
rl: ResultLoc,
- node: ast.Node.Index,
- lhs_node: ast.Node.Index,
- rhs_node: ast.Node.Index,
+ node: Ast.Node.Index,
+ lhs_node: Ast.Node.Index,
+ rhs_node: Ast.Node.Index,
tag: Zir.Inst.Tag,
) InnerError!Zir.Inst.Ref {
const lhs = try expr(gz, scope, .none, lhs_node);
@@ -7646,8 +7649,8 @@ fn cImport(
gz: *GenZir,
scope: *Scope,
rl: ResultLoc,
- node: ast.Node.Index,
- body_node: ast.Node.Index,
+ node: Ast.Node.Index,
+ body_node: Ast.Node.Index,
) InnerError!Zir.Inst.Ref {
const astgen = gz.astgen;
const gpa = astgen.gpa;
@@ -7671,8 +7674,8 @@ fn overflowArithmetic(
gz: *GenZir,
scope: *Scope,
rl: ResultLoc,
- node: ast.Node.Index,
- params: []const ast.Node.Index,
+ node: Ast.Node.Index,
+ params: []const Ast.Node.Index,
tag: Zir.Inst.Extended,
) InnerError!Zir.Inst.Ref {
const int_type = try typeExpr(gz, scope, params[0]);
@@ -7701,8 +7704,8 @@ fn saturatingArithmetic(
gz: *GenZir,
scope: *Scope,
rl: ResultLoc,
- node: ast.Node.Index,
- params: []const ast.Node.Index,
+ node: Ast.Node.Index,
+ params: []const Ast.Node.Index,
tag: Zir.Inst.Extended,
) InnerError!Zir.Inst.Ref {
const lhs = try expr(gz, scope, .none, params[0]);
@@ -7719,8 +7722,8 @@ fn callExpr(
gz: *GenZir,
scope: *Scope,
rl: ResultLoc,
- node: ast.Node.Index,
- call: ast.full.Call,
+ node: Ast.Node.Index,
+ call: Ast.full.Call,
) InnerError!Zir.Inst.Ref {
const astgen = gz.astgen;
const lhs = try expr(gz, scope, .none, call.ast.fn_expr);
@@ -7809,7 +7812,7 @@ pub const simple_types = std.ComptimeStringMap(Zir.Inst.Ref, .{
.{ "void", .void_type },
});
-fn nodeMayNeedMemoryLocation(tree: *const ast.Tree, start_node: ast.Node.Index) bool {
+fn nodeMayNeedMemoryLocation(tree: *const Ast, start_node: Ast.Node.Index) bool {
const node_tags = tree.nodes.items(.tag);
const node_datas = tree.nodes.items(.data);
const main_tokens = tree.nodes.items(.main_token);
@@ -8018,7 +8021,7 @@ fn nodeMayNeedMemoryLocation(tree: *const ast.Tree, start_node: ast.Node.Index)
}
}
-fn nodeMayEvalToError(tree: *const ast.Tree, start_node: ast.Node.Index) enum { never, always, maybe } {
+fn nodeMayEvalToError(tree: *const Ast, start_node: Ast.Node.Index) enum { never, always, maybe } {
const node_tags = tree.nodes.items(.tag);
const node_datas = tree.nodes.items(.data);
const main_tokens = tree.nodes.items(.main_token);
@@ -8227,7 +8230,7 @@ fn nodeMayEvalToError(tree: *const ast.Tree, start_node: ast.Node.Index) enum {
}
}
-fn nodeImpliesRuntimeBits(tree: *const ast.Tree, start_node: ast.Node.Index) bool {
+fn nodeImpliesRuntimeBits(tree: *const Ast, start_node: Ast.Node.Index) bool {
const node_tags = tree.nodes.items(.tag);
const node_datas = tree.nodes.items(.data);
@@ -8414,7 +8417,7 @@ fn rvalue(
gz: *GenZir,
rl: ResultLoc,
result: Zir.Inst.Ref,
- src_node: ast.Node.Index,
+ src_node: Ast.Node.Index,
) InnerError!Zir.Inst.Ref {
if (gz.endsWithNoReturn()) return result;
switch (rl) {
@@ -8519,7 +8522,7 @@ fn rvalue(
/// and allocates the result within `astgen.arena`.
/// Otherwise, returns a reference to the source code bytes directly.
/// See also `appendIdentStr` and `parseStrLit`.
-fn identifierTokenString(astgen: *AstGen, token: ast.TokenIndex) InnerError![]const u8 {
+fn identifierTokenString(astgen: *AstGen, token: Ast.TokenIndex) InnerError![]const u8 {
const tree = astgen.tree;
const token_tags = tree.tokens.items(.tag);
assert(token_tags[token] == .identifier);
@@ -8539,7 +8542,7 @@ fn identifierTokenString(astgen: *AstGen, token: ast.TokenIndex) InnerError![]co
/// See also `identifierTokenString` and `parseStrLit`.
fn appendIdentStr(
astgen: *AstGen,
- token: ast.TokenIndex,
+ token: Ast.TokenIndex,
buf: *ArrayListUnmanaged(u8),
) InnerError!void {
const tree = astgen.tree;
@@ -8556,7 +8559,7 @@ fn appendIdentStr(
/// Appends the result to `buf`.
fn parseStrLit(
astgen: *AstGen,
- token: ast.TokenIndex,
+ token: Ast.TokenIndex,
buf: *ArrayListUnmanaged(u8),
bytes: []const u8,
offset: u32,
@@ -8620,7 +8623,7 @@ fn parseStrLit(
fn failNode(
astgen: *AstGen,
- node: ast.Node.Index,
+ node: Ast.Node.Index,
comptime format: []const u8,
args: anytype,
) InnerError {
@@ -8629,7 +8632,7 @@ fn failNode(
fn failNodeNotes(
astgen: *AstGen,
- node: ast.Node.Index,
+ node: Ast.Node.Index,
comptime format: []const u8,
args: anytype,
notes: []const u32,
@@ -8661,7 +8664,7 @@ fn failNodeNotes(
fn failTok(
astgen: *AstGen,
- token: ast.TokenIndex,
+ token: Ast.TokenIndex,
comptime format: []const u8,
args: anytype,
) InnerError {
@@ -8670,7 +8673,7 @@ fn failTok(
fn failTokNotes(
astgen: *AstGen,
- token: ast.TokenIndex,
+ token: Ast.TokenIndex,
comptime format: []const u8,
args: anytype,
notes: []const u32,
@@ -8703,7 +8706,7 @@ fn failTokNotes(
/// Same as `fail`, except given an absolute byte offset.
fn failOff(
astgen: *AstGen,
- token: ast.TokenIndex,
+ token: Ast.TokenIndex,
byte_offset: u32,
comptime format: []const u8,
args: anytype,
@@ -8728,7 +8731,7 @@ fn failOff(
fn errNoteTok(
astgen: *AstGen,
- token: ast.TokenIndex,
+ token: Ast.TokenIndex,
comptime format: []const u8,
args: anytype,
) Allocator.Error!u32 {
@@ -8751,7 +8754,7 @@ fn errNoteTok(
fn errNoteNode(
astgen: *AstGen,
- node: ast.Node.Index,
+ node: Ast.Node.Index,
comptime format: []const u8,
args: anytype,
) Allocator.Error!u32 {
@@ -8772,7 +8775,7 @@ fn errNoteNode(
});
}
-fn identAsString(astgen: *AstGen, ident_token: ast.TokenIndex) !u32 {
+fn identAsString(astgen: *AstGen, ident_token: Ast.TokenIndex) !u32 {
const gpa = astgen.gpa;
const string_bytes = &astgen.string_bytes;
const str_index = @intCast(u32, string_bytes.items.len);
@@ -8795,7 +8798,7 @@ fn identAsString(astgen: *AstGen, ident_token: ast.TokenIndex) !u32 {
const IndexSlice = struct { index: u32, len: u32 };
-fn strLitAsString(astgen: *AstGen, str_lit_token: ast.TokenIndex) !IndexSlice {
+fn strLitAsString(astgen: *AstGen, str_lit_token: Ast.TokenIndex) !IndexSlice {
const gpa = astgen.gpa;
const string_bytes = &astgen.string_bytes;
const str_index = @intCast(u32, string_bytes.items.len);
@@ -8826,7 +8829,7 @@ fn strLitAsString(astgen: *AstGen, str_lit_token: ast.TokenIndex) !IndexSlice {
}
}
-fn strLitNodeAsString(astgen: *AstGen, node: ast.Node.Index) !IndexSlice {
+fn strLitNodeAsString(astgen: *AstGen, node: Ast.Node.Index) !IndexSlice {
const tree = astgen.tree;
const node_datas = tree.nodes.items(.data);
@@ -8861,7 +8864,7 @@ fn strLitNodeAsString(astgen: *AstGen, node: ast.Node.Index) !IndexSlice {
};
}
-fn testNameString(astgen: *AstGen, str_lit_token: ast.TokenIndex) !u32 {
+fn testNameString(astgen: *AstGen, str_lit_token: Ast.TokenIndex) !u32 {
const gpa = astgen.gpa;
const string_bytes = &astgen.string_bytes;
const str_index = @intCast(u32, string_bytes.items.len);
@@ -8918,7 +8921,7 @@ const Scope = struct {
gen_zir: *GenZir,
inst: Zir.Inst.Ref,
/// Source location of the corresponding variable declaration.
- token_src: ast.TokenIndex,
+ token_src: Ast.TokenIndex,
/// String table index.
name: u32,
id_cat: IdCat,
@@ -8937,7 +8940,7 @@ const Scope = struct {
gen_zir: *GenZir,
ptr: Zir.Inst.Ref,
/// Source location of the corresponding variable declaration.
- token_src: ast.TokenIndex,
+ token_src: Ast.TokenIndex,
/// String table index.
name: u32,
id_cat: IdCat,
@@ -8952,7 +8955,7 @@ const Scope = struct {
base: Scope,
/// Parents can be: `LocalVal`, `LocalPtr`, `GenZir`, `Defer`.
parent: *Scope,
- defer_node: ast.Node.Index,
+ defer_node: Ast.Node.Index,
};
/// Represents a global scope that has any number of declarations in it.
@@ -8964,8 +8967,8 @@ const Scope = struct {
parent: *Scope,
/// Maps string table index to the source location of declaration,
/// for the purposes of reporting name shadowing compile errors.
- decls: std.AutoHashMapUnmanaged(u32, ast.Node.Index) = .{},
- node: ast.Node.Index,
+ decls: std.AutoHashMapUnmanaged(u32, Ast.Node.Index) = .{},
+ node: Ast.Node.Index,
};
const Top = struct {
@@ -8984,7 +8987,7 @@ const GenZir = struct {
/// How decls created in this scope should be named.
anon_name_strategy: Zir.Inst.NameStrategy = .anon,
/// The containing decl AST node.
- decl_node_index: ast.Node.Index,
+ decl_node_index: Ast.Node.Index,
/// The containing decl line index, absolute.
decl_line: u32,
parent: *Scope,
@@ -9019,8 +9022,8 @@ const GenZir = struct {
/// a result location pointer.
labeled_store_to_block_ptr_list: ArrayListUnmanaged(Zir.Inst.Index) = .{},
- suspend_node: ast.Node.Index = 0,
- nosuspend_node: ast.Node.Index = 0,
+ suspend_node: Ast.Node.Index = 0,
+ nosuspend_node: Ast.Node.Index = 0,
fn makeSubBlock(gz: *GenZir, scope: *Scope) GenZir {
return .{
@@ -9036,7 +9039,7 @@ const GenZir = struct {
}
const Label = struct {
- token: ast.TokenIndex,
+ token: Ast.TokenIndex,
block_inst: Zir.Inst.Index,
used: bool = false,
};
@@ -9057,7 +9060,7 @@ const GenZir = struct {
return false;
}
- fn calcLine(gz: GenZir, node: ast.Node.Index) u32 {
+ fn calcLine(gz: GenZir, node: Ast.Node.Index) u32 {
const astgen = gz.astgen;
const tree = astgen.tree;
const source = tree.source;
@@ -9069,23 +9072,15 @@ const GenZir = struct {
return @intCast(u32, gz.decl_line + astgen.source_line);
}
- fn tokSrcLoc(gz: GenZir, token_index: ast.TokenIndex) LazySrcLoc {
- return .{ .token_offset = token_index - gz.srcToken() };
- }
-
- fn nodeSrcLoc(gz: GenZir, node_index: ast.Node.Index) LazySrcLoc {
- return .{ .node_offset = gz.nodeIndexToRelative(node_index) };
- }
-
- fn nodeIndexToRelative(gz: GenZir, node_index: ast.Node.Index) i32 {
+ fn nodeIndexToRelative(gz: GenZir, node_index: Ast.Node.Index) i32 {
return @bitCast(i32, node_index) - @bitCast(i32, gz.decl_node_index);
}
- fn tokenIndexToRelative(gz: GenZir, token: ast.TokenIndex) u32 {
+ fn tokenIndexToRelative(gz: GenZir, token: Ast.TokenIndex) u32 {
return token - gz.srcToken();
}
- fn srcToken(gz: GenZir) ast.TokenIndex {
+ fn srcToken(gz: GenZir) Ast.TokenIndex {
return gz.astgen.tree.firstToken(gz.decl_node_index);
}
@@ -9170,7 +9165,7 @@ const GenZir = struct {
}
fn addFunc(gz: *GenZir, args: struct {
- src_node: ast.Node.Index,
+ src_node: Ast.Node.Index,
body: []const Zir.Inst.Index,
param_block: Zir.Inst.Index,
ret_ty: []const Zir.Inst.Index,
@@ -9363,7 +9358,7 @@ const GenZir = struct {
callee: Zir.Inst.Ref,
args: []const Zir.Inst.Ref,
/// Absolute node index. This function does the conversion to offset from Decl.
- src_node: ast.Node.Index,
+ src_node: Ast.Node.Index,
) !Zir.Inst.Ref {
assert(callee != .none);
assert(src_node != 0);
@@ -9454,7 +9449,7 @@ const GenZir = struct {
tag: Zir.Inst.Tag,
operand: Zir.Inst.Ref,
/// Absolute node index. This function does the conversion to offset from Decl.
- src_node: ast.Node.Index,
+ src_node: Ast.Node.Index,
) !Zir.Inst.Ref {
assert(operand != .none);
return gz.add(.{
@@ -9470,7 +9465,7 @@ const GenZir = struct {
gz: *GenZir,
tag: Zir.Inst.Tag,
/// Absolute node index. This function does the conversion to offset from Decl.
- src_node: ast.Node.Index,
+ src_node: Ast.Node.Index,
extra: anytype,
) !Zir.Inst.Ref {
const gpa = gz.astgen.gpa;
@@ -9494,7 +9489,7 @@ const GenZir = struct {
gz: *GenZir,
tag: Zir.Inst.Tag,
/// Absolute token index. This function does the conversion to Decl offset.
- abs_tok_index: ast.TokenIndex,
+ abs_tok_index: Ast.TokenIndex,
name: u32,
body: []const u32,
) !Zir.Inst.Index {
@@ -9549,7 +9544,7 @@ const GenZir = struct {
fn addExtendedMultiOp(
gz: *GenZir,
opcode: Zir.Inst.Extended,
- node: ast.Node.Index,
+ node: Ast.Node.Index,
operands: []const Zir.Inst.Ref,
) !Zir.Inst.Ref {
const astgen = gz.astgen;
@@ -9610,7 +9605,7 @@ const GenZir = struct {
tag: Zir.Inst.Tag,
operand: Zir.Inst.Ref,
/// Absolute token index. This function does the conversion to Decl offset.
- abs_tok_index: ast.TokenIndex,
+ abs_tok_index: Ast.TokenIndex,
) !Zir.Inst.Ref {
assert(operand != .none);
return gz.add(.{
@@ -9627,7 +9622,7 @@ const GenZir = struct {
tag: Zir.Inst.Tag,
str_index: u32,
/// Absolute token index. This function does the conversion to Decl offset.
- abs_tok_index: ast.TokenIndex,
+ abs_tok_index: Ast.TokenIndex,
) !Zir.Inst.Ref {
return gz.add(.{
.tag = tag,
@@ -9674,7 +9669,7 @@ const GenZir = struct {
gz: *GenZir,
tag: Zir.Inst.Tag,
decl_index: u32,
- src_node: ast.Node.Index,
+ src_node: Ast.Node.Index,
) !Zir.Inst.Ref {
return gz.add(.{
.tag = tag,
@@ -9689,7 +9684,7 @@ const GenZir = struct {
gz: *GenZir,
tag: Zir.Inst.Tag,
/// Absolute node index. This function does the conversion to offset from Decl.
- src_node: ast.Node.Index,
+ src_node: Ast.Node.Index,
) !Zir.Inst.Ref {
return gz.add(.{
.tag = tag,
@@ -9701,7 +9696,7 @@ const GenZir = struct {
gz: *GenZir,
opcode: Zir.Inst.Extended,
/// Absolute node index. This function does the conversion to offset from Decl.
- src_node: ast.Node.Index,
+ src_node: Ast.Node.Index,
) !Zir.Inst.Ref {
return gz.add(.{
.tag = .extended,
@@ -9717,7 +9712,7 @@ const GenZir = struct {
gz: *GenZir,
args: struct {
/// Absolute node index. This function does the conversion to offset from Decl.
- node: ast.Node.Index,
+ node: Ast.Node.Index,
type_inst: Zir.Inst.Ref,
align_inst: Zir.Inst.Ref,
is_const: bool,
@@ -9768,7 +9763,7 @@ const GenZir = struct {
gz: *GenZir,
args: struct {
/// Absolute node index. This function does the conversion to offset from Decl.
- node: ast.Node.Index,
+ node: Ast.Node.Index,
asm_source: u32,
output_type_bits: u32,
is_volatile: bool,
@@ -9825,7 +9820,7 @@ const GenZir = struct {
/// Note that this returns a `Zir.Inst.Index` not a ref.
/// Does *not* append the block instruction to the scope.
/// Leaves the `payload_index` field undefined.
- fn addBlock(gz: *GenZir, tag: Zir.Inst.Tag, node: ast.Node.Index) !Zir.Inst.Index {
+ fn addBlock(gz: *GenZir, tag: Zir.Inst.Tag, node: Ast.Node.Index) !Zir.Inst.Index {
const new_index = @intCast(Zir.Inst.Index, gz.astgen.instructions.len);
const gpa = gz.astgen.gpa;
try gz.astgen.instructions.append(gpa, .{
@@ -9840,7 +9835,7 @@ const GenZir = struct {
/// Note that this returns a `Zir.Inst.Index` not a ref.
/// Leaves the `payload_index` field undefined.
- fn addCondBr(gz: *GenZir, tag: Zir.Inst.Tag, node: ast.Node.Index) !Zir.Inst.Index {
+ fn addCondBr(gz: *GenZir, tag: Zir.Inst.Tag, node: Ast.Node.Index) !Zir.Inst.Index {
const gpa = gz.astgen.gpa;
try gz.instructions.ensureUnusedCapacity(gpa, 1);
const new_index = @intCast(Zir.Inst.Index, gz.astgen.instructions.len);
@@ -9856,7 +9851,7 @@ const GenZir = struct {
}
fn setStruct(gz: *GenZir, inst: Zir.Inst.Index, args: struct {
- src_node: ast.Node.Index,
+ src_node: Ast.Node.Index,
body_len: u32,
fields_len: u32,
decls_len: u32,
@@ -9901,7 +9896,7 @@ const GenZir = struct {
}
fn setUnion(gz: *GenZir, inst: Zir.Inst.Index, args: struct {
- src_node: ast.Node.Index,
+ src_node: Ast.Node.Index,
tag_type: Zir.Inst.Ref,
body_len: u32,
fields_len: u32,
@@ -9951,7 +9946,7 @@ const GenZir = struct {
}
fn setEnum(gz: *GenZir, inst: Zir.Inst.Index, args: struct {
- src_node: ast.Node.Index,
+ src_node: Ast.Node.Index,
tag_type: Zir.Inst.Ref,
body_len: u32,
fields_len: u32,
@@ -10024,7 +10019,7 @@ const GenZir = struct {
return new_index;
}
- fn addRet(gz: *GenZir, rl: ResultLoc, operand: Zir.Inst.Ref, node: ast.Node.Index) !void {
+ fn addRet(gz: *GenZir, rl: ResultLoc, operand: Zir.Inst.Ref, node: Ast.Node.Index) !void {
switch (rl) {
.ptr => |ret_ptr| _ = try gz.addUnNode(.ret_load, ret_ptr, node),
.ty => _ = try gz.addUnNode(.ret_node, operand, node),
@@ -10052,12 +10047,12 @@ fn isPrimitive(name: []const u8) bool {
}
}
-/// Local variables shadowing detection, including function parameters and primitives.
+/// Local variables shadowing detection, including function parameters.
fn detectLocalShadowing(
astgen: *AstGen,
scope: *Scope,
ident_name: u32,
- name_token: ast.TokenIndex,
+ name_token: Ast.TokenIndex,
token_bytes: []const u8,
) !void {
const gpa = astgen.gpa;
@@ -10162,7 +10157,7 @@ fn refToIndex(inst: Zir.Inst.Ref) ?Zir.Inst.Index {
}
}
-fn scanDecls(astgen: *AstGen, namespace: *Scope.Namespace, members: []const ast.Node.Index) !void {
+fn scanDecls(astgen: *AstGen, namespace: *Scope.Namespace, members: []const Ast.Node.Index) !void {
const gpa = astgen.gpa;
const tree = astgen.tree;
const node_tags = tree.nodes.items(.tag);
diff --git a/src/Compilation.zig b/src/Compilation.zig
index 7dc726aeb269..7ac75130f2fa 100644
--- a/src/Compilation.zig
+++ b/src/Compilation.zig
@@ -2408,7 +2408,7 @@ const AstGenSrc = union(enum) {
root,
import: struct {
importing_file: *Module.Scope.File,
- import_tok: std.zig.ast.TokenIndex,
+ import_tok: std.zig.Ast.TokenIndex,
},
};
diff --git a/src/Module.zig b/src/Module.zig
index 77f880b492b8..07b86c0d517c 100644
--- a/src/Module.zig
+++ b/src/Module.zig
@@ -11,7 +11,7 @@ const log = std.log.scoped(.module);
const BigIntConst = std.math.big.int.Const;
const BigIntMutable = std.math.big.int.Mutable;
const Target = std.Target;
-const ast = std.zig.ast;
+const Ast = std.zig.Ast;
const Module = @This();
const Compilation = @import("Compilation.zig");
@@ -291,7 +291,7 @@ pub const Decl = struct {
generation: u32,
/// The AST node index of this declaration.
/// Must be recomputed when the corresponding source file is modified.
- src_node: ast.Node.Index,
+ src_node: Ast.Node.Index,
/// Line number corresponding to `src_node`. Stored separately so that source files
/// do not need to be loaded into memory in order to compute debug line numbers.
src_line: u32,
@@ -365,6 +365,8 @@ pub const Decl = struct {
/// Decl is marked alive, then it sends the Decl to the linker. Otherwise it
/// deletes the Decl on the spot.
alive: bool,
+ /// Whether the Decl is a `usingnamespace` declaration.
+ is_usingnamespace: bool,
/// Represents the position of the code in the output file.
/// This is populated regardless of semantic analysis and code generation.
@@ -497,19 +499,19 @@ pub const Decl = struct {
return decl.src_line + offset;
}
- pub fn relativeToNodeIndex(decl: Decl, offset: i32) ast.Node.Index {
- return @bitCast(ast.Node.Index, offset + @bitCast(i32, decl.src_node));
+ pub fn relativeToNodeIndex(decl: Decl, offset: i32) Ast.Node.Index {
+ return @bitCast(Ast.Node.Index, offset + @bitCast(i32, decl.src_node));
}
- pub fn nodeIndexToRelative(decl: Decl, node_index: ast.Node.Index) i32 {
+ pub fn nodeIndexToRelative(decl: Decl, node_index: Ast.Node.Index) i32 {
return @bitCast(i32, node_index) - @bitCast(i32, decl.src_node);
}
- pub fn tokSrcLoc(decl: Decl, token_index: ast.TokenIndex) LazySrcLoc {
+ pub fn tokSrcLoc(decl: Decl, token_index: Ast.TokenIndex) LazySrcLoc {
return .{ .token_offset = token_index - decl.srcToken() };
}
- pub fn nodeSrcLoc(decl: Decl, node_index: ast.Node.Index) LazySrcLoc {
+ pub fn nodeSrcLoc(decl: Decl, node_index: Ast.Node.Index) LazySrcLoc {
return .{ .node_offset = decl.nodeIndexToRelative(node_index) };
}
@@ -525,7 +527,7 @@ pub const Decl = struct {
};
}
- pub fn srcToken(decl: Decl) ast.TokenIndex {
+ pub fn srcToken(decl: Decl) Ast.TokenIndex {
const tree = &decl.namespace.file_scope.tree;
return tree.firstToken(decl.src_node);
}
@@ -1008,6 +1010,11 @@ pub const Scope = struct {
anon_decls: std.AutoArrayHashMapUnmanaged(*Decl, void) = .{},
+ /// Key is usingnamespace Decl itself. To find the namespace being included,
+ /// the Decl Value has to be resolved as a Type which has a Namespace.
+ /// Value is whether the usingnamespace decl is marked `pub`.
+ usingnamespace_set: std.AutoHashMapUnmanaged(*Decl, bool) = .{},
+
pub fn deinit(ns: *Namespace, mod: *Module) void {
ns.destroyDecls(mod);
ns.* = undefined;
@@ -1114,7 +1121,7 @@ pub const Scope = struct {
/// Whether this is populated depends on `status`.
stat_mtime: i128,
/// Whether this is populated or not depends on `tree_loaded`.
- tree: ast.Tree,
+ tree: Ast,
/// Whether this is populated or not depends on `zir_loaded`.
zir: Zir,
/// Package that this file is a part of, managed externally.
@@ -1213,7 +1220,7 @@ pub const Scope = struct {
return source;
}
- pub fn getTree(file: *File, gpa: *Allocator) !*const ast.Tree {
+ pub fn getTree(file: *File, gpa: *Allocator) !*const Ast {
if (file.tree_loaded) return &file.tree;
const source = try file.getSource(gpa);
@@ -1558,17 +1565,17 @@ pub const ErrorMsg = struct {
pub const SrcLoc = struct {
file_scope: *Scope.File,
/// Might be 0 depending on tag of `lazy`.
- parent_decl_node: ast.Node.Index,
+ parent_decl_node: Ast.Node.Index,
/// Relative to `parent_decl_node`.
lazy: LazySrcLoc,
- pub fn declSrcToken(src_loc: SrcLoc) ast.TokenIndex {
+ pub fn declSrcToken(src_loc: SrcLoc) Ast.TokenIndex {
const tree = src_loc.file_scope.tree;
return tree.firstToken(src_loc.parent_decl_node);
}
- pub fn declRelativeToNodeIndex(src_loc: SrcLoc, offset: i32) ast.TokenIndex {
- return @bitCast(ast.Node.Index, offset + @bitCast(i32, src_loc.parent_decl_node));
+ pub fn declRelativeToNodeIndex(src_loc: SrcLoc, offset: i32) Ast.TokenIndex {
+ return @bitCast(Ast.Node.Index, offset + @bitCast(i32, src_loc.parent_decl_node));
}
pub fn byteOffset(src_loc: SrcLoc, gpa: *Allocator) !u32 {
@@ -1694,7 +1701,7 @@ pub const SrcLoc = struct {
const tree = try src_loc.file_scope.getTree(gpa);
const node_tags = tree.nodes.items(.tag);
const node = src_loc.declRelativeToNodeIndex(node_off);
- var params: [1]ast.Node.Index = undefined;
+ var params: [1]Ast.Node.Index = undefined;
const full = switch (node_tags[node]) {
.call_one,
.call_one_comma,
@@ -1824,7 +1831,7 @@ pub const SrcLoc = struct {
const node_datas = tree.nodes.items(.data);
const node_tags = tree.nodes.items(.tag);
const main_tokens = tree.nodes.items(.main_token);
- const extra = tree.extraData(node_datas[switch_node].rhs, ast.Node.SubRange);
+ const extra = tree.extraData(node_datas[switch_node].rhs, Ast.Node.SubRange);
const case_nodes = tree.extra_data[extra.start..extra.end];
for (case_nodes) |case_node| {
const case = switch (node_tags[case_node]) {
@@ -1850,7 +1857,7 @@ pub const SrcLoc = struct {
const node_datas = tree.nodes.items(.data);
const node_tags = tree.nodes.items(.tag);
const main_tokens = tree.nodes.items(.main_token);
- const extra = tree.extraData(node_datas[switch_node].rhs, ast.Node.SubRange);
+ const extra = tree.extraData(node_datas[switch_node].rhs, Ast.Node.SubRange);
const case_nodes = tree.extra_data[extra.start..extra.end];
for (case_nodes) |case_node| {
const case = switch (node_tags[case_node]) {
@@ -1879,7 +1886,7 @@ pub const SrcLoc = struct {
const node_datas = tree.nodes.items(.data);
const node_tags = tree.nodes.items(.tag);
const node = src_loc.declRelativeToNodeIndex(node_off);
- var params: [1]ast.Node.Index = undefined;
+ var params: [1]Ast.Node.Index = undefined;
const full = switch (node_tags[node]) {
.fn_proto_simple => tree.fnProtoSimple(¶ms, node),
.fn_proto_multi => tree.fnProtoMulti(node),
@@ -1904,7 +1911,7 @@ pub const SrcLoc = struct {
const tree = try src_loc.file_scope.getTree(gpa);
const node_tags = tree.nodes.items(.tag);
const node = src_loc.declRelativeToNodeIndex(node_off);
- var params: [1]ast.Node.Index = undefined;
+ var params: [1]Ast.Node.Index = undefined;
const full = switch (node_tags[node]) {
.fn_proto_simple => tree.fnProtoSimple(¶ms, node),
.fn_proto_multi => tree.fnProtoMulti(node),
@@ -1934,7 +1941,7 @@ pub const SrcLoc = struct {
const node_datas = tree.nodes.items(.data);
const node_tags = tree.nodes.items(.tag);
const parent_node = src_loc.declRelativeToNodeIndex(node_off);
- var params: [1]ast.Node.Index = undefined;
+ var params: [1]Ast.Node.Index = undefined;
const full = switch (node_tags[parent_node]) {
.fn_proto_simple => tree.fnProtoSimple(¶ms, parent_node),
.fn_proto_multi => tree.fnProtoMulti(parent_node),
@@ -3174,6 +3181,31 @@ fn semaDecl(mod: *Module, decl: *Decl) !bool {
errdefer decl_arena.deinit();
const decl_arena_state = try decl_arena.allocator.create(std.heap.ArenaAllocator.State);
+ if (decl.is_usingnamespace) {
+ const ty_ty = Type.initTag(.type);
+ if (!decl_tv.ty.eql(ty_ty)) {
+ return mod.fail(&block_scope.base, src, "expected type, found {}", .{decl_tv.ty});
+ }
+ var buffer: Value.ToTypeBuffer = undefined;
+ const ty = decl_tv.val.toType(&buffer);
+ if (ty.getNamespace() == null) {
+ return mod.fail(&block_scope.base, src, "type {} has no namespace", .{ty});
+ }
+
+ decl.ty = ty_ty;
+ decl.val = try Value.Tag.ty.create(&decl_arena.allocator, ty);
+ decl.align_val = Value.initTag(.null_value);
+ decl.linksection_val = Value.initTag(.null_value);
+ decl.has_tv = true;
+ decl.owns_tv = false;
+ decl_arena_state.* = decl_arena.state;
+ decl.value_arena = decl_arena_state;
+ decl.analysis = .complete;
+ decl.generation = mod.generation;
+
+ return true;
+ }
+
if (decl_tv.val.castTag(.function)) |fn_payload| {
const func = fn_payload.data;
const owns_tv = func.owner_decl == decl;
@@ -3269,16 +3301,13 @@ fn semaDecl(mod: *Module, decl: *Decl) !bool {
if (type_changed and mod.emit_h != null) {
try mod.comp.work_queue.writeItem(.{ .emit_h_decl = decl });
}
- } else if (decl_tv.ty.zigTypeTag() == .Type) {
- // In case this Decl is a struct or union, we need to resolve the fields
- // while we still have the `Sema` in scope, so that the field type expressions
- // can use the resolved AIR instructions that they possibly reference.
- // We do this after the decl is populated and set to `complete` so that a `Decl`
- // may reference itself.
- var buffer: Value.ToTypeBuffer = undefined;
- const ty = decl.val.toType(&buffer);
- try sema.resolveDeclFields(&block_scope, src, ty);
}
+ // In case this Decl is a struct or union, we need to resolve the fields
+ // while we still have the `Sema` in scope, so that the field type expressions
+ // can use the resolved AIR instructions that they possibly reference.
+ // We do this after the decl is populated and set to `complete` so that a `Decl`
+ // may reference itself.
+ try sema.resolvePendingTypes(&block_scope);
if (decl.is_exported) {
const export_src = src; // TODO point to the export token
@@ -3494,7 +3523,7 @@ fn scanDecl(iter: *ScanDeclIter, decl_sub_index: usize, flags: u4) SemaError!voi
// zig fmt: off
const is_pub = (flags & 0b0001) != 0;
- const is_exported = (flags & 0b0010) != 0;
+ const export_bit = (flags & 0b0010) != 0;
const has_align = (flags & 0b0100) != 0;
const has_linksection = (flags & 0b1000) != 0;
// zig fmt: on
@@ -3509,7 +3538,7 @@ fn scanDecl(iter: *ScanDeclIter, decl_sub_index: usize, flags: u4) SemaError!voi
var is_named_test = false;
const decl_name: [:0]const u8 = switch (decl_name_index) {
0 => name: {
- if (is_exported) {
+ if (export_bit) {
const i = iter.usingnamespace_index;
iter.usingnamespace_index += 1;
break :name try std.fmt.allocPrintZ(gpa, "usingnamespace_{d}", .{i});
@@ -3535,11 +3564,17 @@ fn scanDecl(iter: *ScanDeclIter, decl_sub_index: usize, flags: u4) SemaError!voi
}
},
};
+ const is_exported = export_bit and decl_name_index != 0;
+ const is_usingnamespace = export_bit and decl_name_index == 0;
+ if (is_usingnamespace) try namespace.usingnamespace_set.ensureUnusedCapacity(gpa, 1);
// We create a Decl for it regardless of analysis status.
const gop = try namespace.decls.getOrPut(gpa, decl_name);
if (!gop.found_existing) {
const new_decl = try mod.allocateNewDecl(namespace, decl_node);
+ if (is_usingnamespace) {
+ namespace.usingnamespace_set.putAssumeCapacity(new_decl, is_pub);
+ }
log.debug("scan new {*} ({s}) into {*}", .{ new_decl, decl_name, namespace });
new_decl.src_line = line;
new_decl.name = decl_name;
@@ -3548,7 +3583,7 @@ fn scanDecl(iter: *ScanDeclIter, decl_sub_index: usize, flags: u4) SemaError!voi
// test decls if in test mode, get analyzed.
const decl_pkg = namespace.file_scope.pkg;
const want_analysis = is_exported or switch (decl_name_index) {
- 0 => true, // comptime decl
+ 0 => true, // comptime or usingnamespace decl
1 => blk: {
// test decl with no name. Skip the part where we check against
// the test name filter.
@@ -3571,6 +3606,7 @@ fn scanDecl(iter: *ScanDeclIter, decl_sub_index: usize, flags: u4) SemaError!voi
}
new_decl.is_pub = is_pub;
new_decl.is_exported = is_exported;
+ new_decl.is_usingnamespace = is_usingnamespace;
new_decl.has_align = has_align;
new_decl.has_linksection = has_linksection;
new_decl.zir_decl_index = @intCast(u32, decl_sub_index);
@@ -3587,6 +3623,7 @@ fn scanDecl(iter: *ScanDeclIter, decl_sub_index: usize, flags: u4) SemaError!voi
decl.is_pub = is_pub;
decl.is_exported = is_exported;
+ decl.is_usingnamespace = is_usingnamespace;
decl.has_align = has_align;
decl.has_linksection = has_linksection;
decl.zir_decl_index = @intCast(u32, decl_sub_index);
@@ -3930,7 +3967,7 @@ fn markOutdatedDecl(mod: *Module, decl: *Decl) !void {
decl.analysis = .outdated;
}
-pub fn allocateNewDecl(mod: *Module, namespace: *Scope.Namespace, src_node: ast.Node.Index) !*Decl {
+pub fn allocateNewDecl(mod: *Module, namespace: *Scope.Namespace, src_node: Ast.Node.Index) !*Decl {
// If we have emit-h then we must allocate a bigger structure to store the emit-h state.
const new_decl: *Decl = if (mod.emit_h != null) blk: {
const parent_struct = try mod.gpa.create(DeclPlusEmitH);
@@ -3979,6 +4016,7 @@ pub fn allocateNewDecl(mod: *Module, namespace: *Scope.Namespace, src_node: ast.
.has_linksection = false,
.has_align = false,
.alive = false,
+ .is_usingnamespace = false,
};
return new_decl;
}
@@ -4199,7 +4237,7 @@ pub fn fail(
pub fn failTok(
mod: *Module,
scope: *Scope,
- token_index: ast.TokenIndex,
+ token_index: Ast.TokenIndex,
comptime format: []const u8,
args: anytype,
) CompileError {
@@ -4212,7 +4250,7 @@ pub fn failTok(
pub fn failNode(
mod: *Module,
scope: *Scope,
- node_index: ast.Node.Index,
+ node_index: Ast.Node.Index,
comptime format: []const u8,
args: anytype,
) CompileError {
@@ -4417,7 +4455,7 @@ pub const SwitchProngSrc = union(enum) {
const main_tokens = tree.nodes.items(.main_token);
const node_datas = tree.nodes.items(.data);
const node_tags = tree.nodes.items(.tag);
- const extra = tree.extraData(node_datas[switch_node].rhs, ast.Node.SubRange);
+ const extra = tree.extraData(node_datas[switch_node].rhs, Ast.Node.SubRange);
const case_nodes = tree.extra_data[extra.start..extra.end];
var multi_i: u32 = 0;
diff --git a/src/Sema.zig b/src/Sema.zig
index 108470ec7917..46c1f1122ef3 100644
--- a/src/Sema.zig
+++ b/src/Sema.zig
@@ -58,6 +58,9 @@ comptime_args_fn_inst: Zir.Inst.Index = 0,
/// extra hash table lookup in the `monomorphed_funcs` set.
/// Sema will set this to null when it takes ownership.
preallocated_new_func: ?*Module.Fn = null,
+/// Collects struct, union, enum, and opaque decls which need to have their
+/// fields resolved before this Sema is deinitialized.
+types_pending_resolution: std.ArrayListUnmanaged(Type) = .{},
const std = @import("std");
const mem = std.mem;
@@ -90,6 +93,7 @@ pub fn deinit(sema: *Sema) void {
sema.air_values.deinit(gpa);
sema.inst_map.deinit(gpa);
sema.decl_val_table.deinit(gpa);
+ sema.types_pending_resolution.deinit(gpa);
sema.* = undefined;
}
@@ -908,7 +912,9 @@ fn zirStructDecl(
&struct_obj.namespace, new_decl, new_decl.name,
});
try sema.analyzeStructDecl(new_decl, inst, struct_obj);
+ try sema.types_pending_resolution.ensureUnusedCapacity(sema.gpa, 1);
try new_decl.finalizeNewArena(&new_decl_arena);
+ sema.types_pending_resolution.appendAssumeCapacity(struct_ty);
return sema.analyzeDeclVal(block, src, new_decl);
}
@@ -1198,7 +1204,9 @@ fn zirUnionDecl(
_ = try sema.mod.scanNamespace(&union_obj.namespace, extra_index, decls_len, new_decl);
+ try sema.types_pending_resolution.ensureUnusedCapacity(sema.gpa, 1);
try new_decl.finalizeNewArena(&new_decl_arena);
+ sema.types_pending_resolution.appendAssumeCapacity(union_ty);
return sema.analyzeDeclVal(block, src, new_decl);
}
@@ -2324,42 +2332,105 @@ fn zirDeclVal(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileErr
}
fn lookupIdentifier(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, name: []const u8) !*Decl {
- // TODO emit a compile error if more than one decl would be matched.
var namespace = sema.namespace;
while (true) {
- if (try sema.lookupInNamespace(namespace, name)) |decl| {
+ if (try sema.lookupInNamespace(block, src, namespace, name, false)) |decl| {
return decl;
}
namespace = namespace.parent orelse break;
}
- return sema.mod.fail(&block.base, src, "use of undeclared identifier '{s}'", .{name});
+ unreachable; // AstGen detects use of undeclared identifier errors.
}
/// This looks up a member of a specific namespace. It is affected by `usingnamespace` but
/// only for ones in the specified namespace.
fn lookupInNamespace(
sema: *Sema,
+ block: *Scope.Block,
+ src: LazySrcLoc,
namespace: *Scope.Namespace,
ident_name: []const u8,
+ observe_usingnamespace: bool,
) CompileError!?*Decl {
+ const mod = sema.mod;
+
const namespace_decl = namespace.getDecl();
if (namespace_decl.analysis == .file_failure) {
- try sema.mod.declareDeclDependency(sema.owner_decl, namespace_decl);
+ try mod.declareDeclDependency(sema.owner_decl, namespace_decl);
return error.AnalysisFail;
}
- // TODO implement usingnamespace
- if (namespace.decls.get(ident_name)) |decl| {
- try sema.mod.declareDeclDependency(sema.owner_decl, decl);
+ if (observe_usingnamespace and namespace.usingnamespace_set.count() != 0) {
+ const src_file = block.src_decl.namespace.file_scope;
+
+ const gpa = sema.gpa;
+ var checked_namespaces: std.AutoArrayHashMapUnmanaged(*Scope.Namespace, void) = .{};
+ defer checked_namespaces.deinit(gpa);
+
+ // Keep track of name conflicts for error notes.
+ var candidates: std.ArrayListUnmanaged(*Decl) = .{};
+ defer candidates.deinit(gpa);
+
+ try checked_namespaces.put(gpa, namespace, {});
+ var check_i: usize = 0;
+
+ while (check_i < checked_namespaces.count()) : (check_i += 1) {
+ const check_ns = checked_namespaces.keys()[check_i];
+ if (check_ns.decls.get(ident_name)) |decl| {
+ // Skip decls which are not marked pub, which are in a different
+ // file than the `a.b`/`@hasDecl` syntax.
+ if (decl.is_pub or src_file == decl.namespace.file_scope) {
+ try candidates.append(gpa, decl);
+ }
+ }
+ var it = check_ns.usingnamespace_set.iterator();
+ while (it.next()) |entry| {
+ const sub_usingnamespace_decl = entry.key_ptr.*;
+ const sub_is_pub = entry.value_ptr.*;
+ if (!sub_is_pub and src_file != sub_usingnamespace_decl.namespace.file_scope) {
+ // Skip usingnamespace decls which are not marked pub, which are in
+ // a different file than the `a.b`/`@hasDecl` syntax.
+ continue;
+ }
+ try sema.ensureDeclAnalyzed(sub_usingnamespace_decl);
+ const ns_ty = sub_usingnamespace_decl.val.castTag(.ty).?.data;
+ const sub_ns = ns_ty.getNamespace().?;
+ try checked_namespaces.put(gpa, sub_ns, {});
+ }
+ }
+
+ switch (candidates.items.len) {
+ 0 => {},
+ 1 => {
+ const decl = candidates.items[0];
+ try mod.declareDeclDependency(sema.owner_decl, decl);
+ return decl;
+ },
+ else => {
+ const msg = msg: {
+ const msg = try mod.errMsg(&block.base, src, "ambiguous reference", .{});
+ errdefer msg.destroy(gpa);
+ for (candidates.items) |candidate| {
+ const src_loc = candidate.srcLoc();
+ try mod.errNoteNonLazy(src_loc, msg, "declared here", .{});
+ }
+ break :msg msg;
+ };
+ return mod.failWithOwnedErrorMsg(&block.base, msg);
+ },
+ }
+ } else if (namespace.decls.get(ident_name)) |decl| {
+ try mod.declareDeclDependency(sema.owner_decl, decl);
return decl;
}
+
log.debug("{*} ({s}) depends on non-existence of '{s}' in {*} ({s})", .{
sema.owner_decl, sema.owner_decl.name, ident_name, namespace_decl, namespace_decl.name,
});
// TODO This dependency is too strong. Really, it should only be a dependency
// on the non-existence of `ident_name` in the namespace. We can lessen the number of
// outdated declarations by making this dependency more sophisticated.
- try sema.mod.declareDeclDependency(sema.owner_decl, namespace_decl);
+ try mod.declareDeclDependency(sema.owner_decl, namespace_decl);
return null;
}
@@ -2727,10 +2798,7 @@ fn analyzeCall(
// we need to resolve the field type expressions right here, right now, while
// the child `Sema` is still available, with the AIR instruction map intact,
// because the field type expressions may reference into it.
- if (sema.typeOf(result).zigTypeTag() == .Type) {
- const ty = try sema.analyzeAsType(&child_block, call_src, result);
- try sema.resolveDeclFields(&child_block, call_src, ty);
- }
+ try sema.resolvePendingTypes(&child_block);
}
break :res2 result;
@@ -5332,6 +5400,7 @@ fn zirHasField(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileEr
fn zirHasDecl(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
+ const src = inst_data.src();
const lhs_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
const rhs_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };
const container_type = try sema.resolveType(block, lhs_src, extra.lhs);
@@ -5344,7 +5413,7 @@ fn zirHasDecl(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileErr
"expected struct, enum, union, or opaque, found '{}'",
.{container_type},
);
- if (try sema.lookupInNamespace(namespace, decl_name)) |decl| {
+ if (try sema.lookupInNamespace(block, src, namespace, decl_name, true)) |decl| {
if (decl.is_pub or decl.namespace.file_scope == block.base.namespace().file_scope) {
return Air.Inst.Ref.bool_true;
}
@@ -8203,7 +8272,7 @@ fn namespaceLookup(
) CompileError!?*Decl {
const mod = sema.mod;
const gpa = sema.gpa;
- if (try sema.lookupInNamespace(namespace, decl_name)) |decl| {
+ if (try sema.lookupInNamespace(block, src, namespace, decl_name, true)) |decl| {
if (!decl.is_pub and decl.namespace.file_scope != block.getFileScope()) {
const msg = msg: {
const msg = try mod.errMsg(&block.base, src, "'{s}' is not marked 'pub'", .{
@@ -8919,8 +8988,7 @@ fn analyzeDeclVal(
return result;
}
-fn analyzeDeclRef(sema: *Sema, decl: *Decl) CompileError!Air.Inst.Ref {
- try sema.mod.declareDeclDependency(sema.owner_decl, decl);
+fn ensureDeclAnalyzed(sema: *Sema, decl: *Decl) CompileError!void {
sema.mod.ensureDeclAnalyzed(decl) catch |err| {
if (sema.owner_func) |owner_func| {
owner_func.state = .dependency_failure;
@@ -8929,6 +8997,11 @@ fn analyzeDeclRef(sema: *Sema, decl: *Decl) CompileError!Air.Inst.Ref {
}
return err;
};
+}
+
+fn analyzeDeclRef(sema: *Sema, decl: *Decl) CompileError!Air.Inst.Ref {
+ try sema.mod.declareDeclDependency(sema.owner_decl, decl);
+ try sema.ensureDeclAnalyzed(decl);
const decl_tv = try decl.typedValue();
if (decl_tv.val.castTag(.variable)) |payload| {
@@ -9560,6 +9633,16 @@ pub fn resolveTypeLayout(
}
}
+pub fn resolvePendingTypes(sema: *Sema, block: *Scope.Block) !void {
+ for (sema.types_pending_resolution.items) |ty| {
+ // If an error happens resolving the fields of a struct, it will be marked
+ // invalid and a proper compile error set up. But we should still look at the
+ // other types pending resolution.
+ const src: LazySrcLoc = .{ .node_offset = 0 };
+ sema.resolveDeclFields(block, src, ty) catch continue;
+ }
+}
+
/// `sema` and `block` are expected to be the same ones used for the `Decl`.
pub fn resolveDeclFields(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, ty: Type) !void {
switch (ty.tag()) {
@@ -10094,7 +10177,7 @@ fn typeHasOnePossibleValue(
};
}
-fn getAstTree(sema: *Sema, block: *Scope.Block) CompileError!*const std.zig.ast.Tree {
+fn getAstTree(sema: *Sema, block: *Scope.Block) CompileError!*const std.zig.Ast {
return block.src_decl.namespace.file_scope.getTree(sema.gpa) catch |err| {
log.err("unable to load AST to report compile error: {s}", .{@errorName(err)});
return error.AnalysisFail;
@@ -10103,14 +10186,14 @@ fn getAstTree(sema: *Sema, block: *Scope.Block) CompileError!*const std.zig.ast.
fn enumFieldSrcLoc(
decl: *Decl,
- tree: std.zig.ast.Tree,
+ tree: std.zig.Ast,
node_offset: i32,
field_index: usize,
) LazySrcLoc {
@setCold(true);
const enum_node = decl.relativeToNodeIndex(node_offset);
const node_tags = tree.nodes.items(.tag);
- var buffer: [2]std.zig.ast.Node.Index = undefined;
+ var buffer: [2]std.zig.Ast.Node.Index = undefined;
const container_decl = switch (node_tags[enum_node]) {
.container_decl,
.container_decl_trailing,
diff --git a/src/Zir.zig b/src/Zir.zig
index e8e79fe1b5ea..329dbcef51ef 100644
--- a/src/Zir.zig
+++ b/src/Zir.zig
@@ -16,7 +16,7 @@ const Allocator = std.mem.Allocator;
const assert = std.debug.assert;
const BigIntConst = std.math.big.int.Const;
const BigIntMutable = std.math.big.int.Mutable;
-const ast = std.zig.ast;
+const Ast = std.zig.Ast;
const Zir = @This();
const Type = @import("type.zig").Type;
@@ -2092,7 +2092,7 @@ pub const Inst = struct {
/// Used for unary operators, with a token source location.
un_tok: struct {
/// Offset from Decl AST token index.
- src_tok: ast.TokenIndex,
+ src_tok: Ast.TokenIndex,
/// The meaning of this operand depends on the corresponding `Tag`.
operand: Ref,
@@ -2114,7 +2114,7 @@ pub const Inst = struct {
},
pl_tok: struct {
/// Offset from Decl AST token index.
- src_tok: ast.TokenIndex,
+ src_tok: Ast.TokenIndex,
/// index into extra.
/// `Tag` determines what lives there.
payload_index: u32,
@@ -2150,7 +2150,7 @@ pub const Inst = struct {
}
},
/// Offset from Decl AST token index.
- tok: ast.TokenIndex,
+ tok: Ast.TokenIndex,
/// Offset from Decl AST node index.
node: i32,
int: u64,
@@ -2878,9 +2878,9 @@ pub const Inst = struct {
pub const Item = struct {
/// null terminated string index
msg: u32,
- node: ast.Node.Index,
+ node: Ast.Node.Index,
/// If node is 0 then this will be populated.
- token: ast.TokenIndex,
+ token: Ast.TokenIndex,
/// Can be used in combination with `token`.
byte_offset: u32,
/// 0 or a payload index of a `Block`, each is a payload
@@ -2897,7 +2897,7 @@ pub const Inst = struct {
/// null terminated string index
name: u32,
/// points to the import name
- token: ast.TokenIndex,
+ token: Ast.TokenIndex,
};
};
};
@@ -2912,8 +2912,8 @@ const Writer = struct {
indent: u32,
parent_decl_node: u32,
- fn relativeToNodeIndex(self: *Writer, offset: i32) ast.Node.Index {
- return @bitCast(ast.Node.Index, offset + @bitCast(i32, self.parent_decl_node));
+ fn relativeToNodeIndex(self: *Writer, offset: i32) Ast.Node.Index {
+ return @bitCast(Ast.Node.Index, offset + @bitCast(i32, self.parent_decl_node));
}
fn writeInstToStream(
diff --git a/src/clang_options_data.zig b/src/clang_options_data.zig
index eb8dfc5753e6..524374a7e967 100644
--- a/src/clang_options_data.zig
+++ b/src/clang_options_data.zig
@@ -1,6 +1,12 @@
// This file is generated by tools/update_clang_options.zig.
// zig fmt: off
-usingnamespace @import("clang_options.zig");
+const clang_options = @import("clang_options.zig");
+const CliArg = clang_options.CliArg;
+const flagpd1 = clang_options.flagpd1;
+const flagpsl = clang_options.flagpsl;
+const joinpd1 = clang_options.joinpd1;
+const jspd1 = clang_options.jspd1;
+const sepd1 = clang_options.sepd1;
pub const data = blk: { @setEvalBranchQuota(6000); break :blk &[_]CliArg{
flagpd1("C"),
flagpd1("CC"),
diff --git a/src/codegen.zig b/src/codegen.zig
index cf51f30fe33f..0a8797d8875e 100644
--- a/src/codegen.zig
+++ b/src/codegen.zig
@@ -899,7 +899,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
fn dbgSetPrologueEnd(self: *Self) InnerError!void {
switch (self.debug_output) {
.dwarf => |dbg_out| {
- try dbg_out.dbg_line.append(DW.LNS_set_prologue_end);
+ try dbg_out.dbg_line.append(DW.LNS.set_prologue_end);
try self.dbgAdvancePCAndLine(self.prev_di_line, self.prev_di_column);
},
.none => {},
@@ -909,7 +909,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
fn dbgSetEpilogueBegin(self: *Self) InnerError!void {
switch (self.debug_output) {
.dwarf => |dbg_out| {
- try dbg_out.dbg_line.append(DW.LNS_set_epilogue_begin);
+ try dbg_out.dbg_line.append(DW.LNS.set_epilogue_begin);
try self.dbgAdvancePCAndLine(self.prev_di_line, self.prev_di_column);
},
.none => {},
@@ -925,13 +925,13 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
// It lets you emit single-byte opcodes that add different numbers to
// both the PC and the line number at the same time.
try dbg_out.dbg_line.ensureUnusedCapacity(11);
- dbg_out.dbg_line.appendAssumeCapacity(DW.LNS_advance_pc);
+ dbg_out.dbg_line.appendAssumeCapacity(DW.LNS.advance_pc);
leb128.writeULEB128(dbg_out.dbg_line.writer(), delta_pc) catch unreachable;
if (delta_line != 0) {
- dbg_out.dbg_line.appendAssumeCapacity(DW.LNS_advance_line);
+ dbg_out.dbg_line.appendAssumeCapacity(DW.LNS.advance_line);
leb128.writeILEB128(dbg_out.dbg_line.writer(), delta_line) catch unreachable;
}
- dbg_out.dbg_line.appendAssumeCapacity(DW.LNS_copy);
+ dbg_out.dbg_line.appendAssumeCapacity(DW.LNS.copy);
},
.none => {},
}
@@ -1010,7 +1010,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
.dwarf => |dbg_out| {
assert(ty.hasCodeGenBits());
const index = dbg_out.dbg_info.items.len;
- try dbg_out.dbg_info.resize(index + 4); // DW.AT_type, DW.FORM_ref4
+ try dbg_out.dbg_info.resize(index + 4); // DW.AT.type, DW.FORM.ref4
const gop = try dbg_out.dbg_info_type_relocs.getOrPut(self.gpa, ty);
if (!gop.found_existing) {
@@ -2438,13 +2438,13 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
.dwarf => |dbg_out| {
try dbg_out.dbg_info.ensureCapacity(dbg_out.dbg_info.items.len + 3);
dbg_out.dbg_info.appendAssumeCapacity(link.File.Elf.abbrev_parameter);
- dbg_out.dbg_info.appendSliceAssumeCapacity(&[2]u8{ // DW.AT_location, DW.FORM_exprloc
+ dbg_out.dbg_info.appendSliceAssumeCapacity(&[2]u8{ // DW.AT.location, DW.FORM.exprloc
1, // ULEB128 dwarf expression length
reg.dwarfLocOp(),
});
try dbg_out.dbg_info.ensureCapacity(dbg_out.dbg_info.items.len + 5 + name_with_null.len);
- try self.addDbgInfoTypeReloc(ty); // DW.AT_type, DW.FORM_ref4
- dbg_out.dbg_info.appendSliceAssumeCapacity(name_with_null); // DW.AT_name, DW.FORM_string
+ try self.addDbgInfoTypeReloc(ty); // DW.AT.type, DW.FORM.ref4
+ dbg_out.dbg_info.appendSliceAssumeCapacity(name_with_null); // DW.AT.name, DW.FORM.string
},
.none => {},
}
@@ -2467,15 +2467,15 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
var counting_writer = std.io.countingWriter(std.io.null_writer);
leb128.writeILEB128(counting_writer.writer(), adjusted_stack_offset) catch unreachable;
- // DW.AT_location, DW.FORM_exprloc
+ // DW.AT.location, DW.FORM.exprloc
// ULEB128 dwarf expression length
try leb128.writeULEB128(dbg_out.dbg_info.writer(), counting_writer.bytes_written + 1);
- try dbg_out.dbg_info.append(DW.OP_breg11);
+ try dbg_out.dbg_info.append(DW.OP.breg11);
try leb128.writeILEB128(dbg_out.dbg_info.writer(), adjusted_stack_offset);
try dbg_out.dbg_info.ensureCapacity(dbg_out.dbg_info.items.len + 5 + name_with_null.len);
- try self.addDbgInfoTypeReloc(ty); // DW.AT_type, DW.FORM_ref4
- dbg_out.dbg_info.appendSliceAssumeCapacity(name_with_null); // DW.AT_name, DW.FORM_string
+ try self.addDbgInfoTypeReloc(ty); // DW.AT.type, DW.FORM.ref4
+ dbg_out.dbg_info.appendSliceAssumeCapacity(name_with_null); // DW.AT.name, DW.FORM.string
},
else => {},
}
diff --git a/src/codegen/aarch64.zig b/src/codegen/aarch64.zig
index 1c176df017cb..dfda04da8519 100644
--- a/src/codegen/aarch64.zig
+++ b/src/codegen/aarch64.zig
@@ -52,7 +52,7 @@ pub const Register = enum(u6) {
}
pub fn dwarfLocOp(self: Register) u8 {
- return @as(u8, self.id()) + DW.OP_reg0;
+ return @as(u8, self.id()) + DW.OP.reg0;
}
};
diff --git a/src/codegen/arm.zig b/src/codegen/arm.zig
index 42e3e52facb7..ec9152f96b0d 100644
--- a/src/codegen/arm.zig
+++ b/src/codegen/arm.zig
@@ -170,7 +170,7 @@ pub const Register = enum(u5) {
}
pub fn dwarfLocOp(self: Register) u8 {
- return @as(u8, self.id()) + DW.OP_reg0;
+ return @as(u8, self.id()) + DW.OP.reg0;
}
};
diff --git a/src/codegen/riscv64.zig b/src/codegen/riscv64.zig
index 831f74b1b728..b29773781649 100644
--- a/src/codegen/riscv64.zig
+++ b/src/codegen/riscv64.zig
@@ -390,7 +390,7 @@ pub const RawRegister = enum(u5) {
x24, x25, x26, x27, x28, x29, x30, x31,
pub fn dwarfLocOp(reg: RawRegister) u8 {
- return @enumToInt(reg) + DW.OP_reg0;
+ return @enumToInt(reg) + DW.OP.reg0;
}
};
@@ -424,7 +424,7 @@ pub const Register = enum(u5) {
}
pub fn dwarfLocOp(reg: Register) u8 {
- return @as(u8, @enumToInt(reg)) + DW.OP_reg0;
+ return @as(u8, @enumToInt(reg)) + DW.OP.reg0;
}
};
diff --git a/src/codegen/spirv/spec.zig b/src/codegen/spirv/spec.zig
index 429ed63d2368..26d192564694 100644
--- a/src/codegen/spirv/spec.zig
+++ b/src/codegen/spirv/spec.zig
@@ -582,8 +582,8 @@ pub const Opcode = enum(u16) {
OpSpecConstantCompositeContinuedINTEL = 6092,
_,
- const OpReportIntersectionKHR = OpReportIntersectionNV;
- const OpTypeAccelerationStructureKHR = OpTypeAccelerationStructureNV;
+ const OpReportIntersectionKHR: Opcode = .OpReportIntersectionNV;
+ const OpTypeAccelerationStructureKHR: Opcode = .OpTypeAccelerationStructureNV;
};
pub const ImageOperands = packed struct {
Bias: bool align(@alignOf(u32)) = false,
diff --git a/src/codegen/x86.zig b/src/codegen/x86.zig
index fdad4e56db61..5b981b9ef483 100644
--- a/src/codegen/x86.zig
+++ b/src/codegen/x86.zig
@@ -59,14 +59,14 @@ pub const Register = enum(u8) {
pub fn dwarfLocOp(reg: Register) u8 {
return switch (reg.to32()) {
- .eax => DW.OP_reg0,
- .ecx => DW.OP_reg1,
- .edx => DW.OP_reg2,
- .ebx => DW.OP_reg3,
- .esp => DW.OP_reg4,
- .ebp => DW.OP_reg5,
- .esi => DW.OP_reg6,
- .edi => DW.OP_reg7,
+ .eax => DW.OP.reg0,
+ .ecx => DW.OP.reg1,
+ .edx => DW.OP.reg2,
+ .ebx => DW.OP.reg3,
+ .esp => DW.OP.reg4,
+ .ebp => DW.OP.reg5,
+ .esi => DW.OP.reg6,
+ .edi => DW.OP.reg7,
else => unreachable,
};
}
diff --git a/src/codegen/x86_64.zig b/src/codegen/x86_64.zig
index 2964d7245e18..72a746804135 100644
--- a/src/codegen/x86_64.zig
+++ b/src/codegen/x86_64.zig
@@ -115,23 +115,23 @@ pub const Register = enum(u8) {
pub fn dwarfLocOp(self: Register) u8 {
return switch (self.to64()) {
- .rax => DW.OP_reg0,
- .rdx => DW.OP_reg1,
- .rcx => DW.OP_reg2,
- .rbx => DW.OP_reg3,
- .rsi => DW.OP_reg4,
- .rdi => DW.OP_reg5,
- .rbp => DW.OP_reg6,
- .rsp => DW.OP_reg7,
-
- .r8 => DW.OP_reg8,
- .r9 => DW.OP_reg9,
- .r10 => DW.OP_reg10,
- .r11 => DW.OP_reg11,
- .r12 => DW.OP_reg12,
- .r13 => DW.OP_reg13,
- .r14 => DW.OP_reg14,
- .r15 => DW.OP_reg15,
+ .rax => DW.OP.reg0,
+ .rdx => DW.OP.reg1,
+ .rcx => DW.OP.reg2,
+ .rbx => DW.OP.reg3,
+ .rsi => DW.OP.reg4,
+ .rdi => DW.OP.reg5,
+ .rbp => DW.OP.reg6,
+ .rsp => DW.OP.reg7,
+
+ .r8 => DW.OP.reg8,
+ .r9 => DW.OP.reg9,
+ .r10 => DW.OP.reg10,
+ .r11 => DW.OP.reg11,
+ .r12 => DW.OP.reg12,
+ .r13 => DW.OP.reg13,
+ .r14 => DW.OP.reg14,
+ .r15 => DW.OP.reg15,
else => unreachable,
};
diff --git a/src/libc_installation.zig b/src/libc_installation.zig
index b639e0f2f8d1..c011abbfcc2c 100644
--- a/src/libc_installation.zig
+++ b/src/libc_installation.zig
@@ -12,7 +12,7 @@ const is_haiku = Target.current.os.tag == .haiku;
const log = std.log.scoped(.libc_installation);
-usingnamespace @import("windows_sdk.zig");
+const ZigWindowsSDK = @import("windows_sdk.zig").ZigWindowsSDK;
/// See the render function implementation for documentation of the fields.
pub const LibCInstallation = struct {
@@ -183,9 +183,9 @@ pub const LibCInstallation = struct {
if (!build_options.have_llvm)
return error.WindowsSdkNotFound;
var sdk: *ZigWindowsSDK = undefined;
- switch (zig_find_windows_sdk(&sdk)) {
+ switch (ZigWindowsSDK.find(&sdk)) {
.None => {
- defer zig_free_windows_sdk(sdk);
+ defer sdk.free();
var batch = Batch(FindError!void, 5, .auto_async).init();
batch.add(&async self.findNativeMsvcIncludeDir(args, sdk));
diff --git a/src/link.zig b/src/link.zig
index 1293fab4d28c..dbca4fc95652 100644
--- a/src/link.zig
+++ b/src/link.zig
@@ -179,7 +179,7 @@ pub const File = struct {
/// This is where the .debug_info tag for the type is.
off: u32,
/// Offset from `TextBlock.dbg_info_off` (the buffer that is local to a Decl).
- /// List of DW.AT_type / DW.FORM_ref4 that points to the type.
+ /// List of DW.AT.type / DW.FORM.ref4 that points to the type.
relocs: std.ArrayListUnmanaged(u32),
};
diff --git a/src/link/Elf.zig b/src/link/Elf.zig
index 9ddebd345327..938fede8abaa 100644
--- a/src/link/Elf.zig
+++ b/src/link/Elf.zig
@@ -772,48 +772,48 @@ pub fn flushModule(self: *Elf, comp: *Compilation) !void {
// These are LEB encoded but since the values are all less than 127
// we can simply append these bytes.
const abbrev_buf = [_]u8{
- abbrev_compile_unit, DW.TAG_compile_unit, DW.CHILDREN_yes, // header
- DW.AT_stmt_list, DW.FORM_sec_offset, DW.AT_low_pc,
- DW.FORM_addr, DW.AT_high_pc, DW.FORM_addr,
- DW.AT_name, DW.FORM_strp, DW.AT_comp_dir,
- DW.FORM_strp, DW.AT_producer, DW.FORM_strp,
- DW.AT_language, DW.FORM_data2, 0,
+ abbrev_compile_unit, DW.TAG.compile_unit, DW.CHILDREN.yes, // header
+ DW.AT.stmt_list, DW.FORM.sec_offset, DW.AT.low_pc,
+ DW.FORM.addr, DW.AT.high_pc, DW.FORM.addr,
+ DW.AT.name, DW.FORM.strp, DW.AT.comp_dir,
+ DW.FORM.strp, DW.AT.producer, DW.FORM.strp,
+ DW.AT.language, DW.FORM.data2, 0,
0, // table sentinel
abbrev_subprogram,
- DW.TAG_subprogram,
- DW.CHILDREN_yes, // header
- DW.AT_low_pc,
- DW.FORM_addr,
- DW.AT_high_pc,
- DW.FORM_data4,
- DW.AT_type,
- DW.FORM_ref4,
- DW.AT_name,
- DW.FORM_string,
+ DW.TAG.subprogram,
+ DW.CHILDREN.yes, // header
+ DW.AT.low_pc,
+ DW.FORM.addr,
+ DW.AT.high_pc,
+ DW.FORM.data4,
+ DW.AT.type,
+ DW.FORM.ref4,
+ DW.AT.name,
+ DW.FORM.string,
0, 0, // table sentinel
abbrev_subprogram_retvoid,
- DW.TAG_subprogram, DW.CHILDREN_yes, // header
- DW.AT_low_pc, DW.FORM_addr,
- DW.AT_high_pc, DW.FORM_data4,
- DW.AT_name, DW.FORM_string,
+ DW.TAG.subprogram, DW.CHILDREN.yes, // header
+ DW.AT.low_pc, DW.FORM.addr,
+ DW.AT.high_pc, DW.FORM.data4,
+ DW.AT.name, DW.FORM.string,
0,
0, // table sentinel
abbrev_base_type,
- DW.TAG_base_type,
- DW.CHILDREN_no, // header
- DW.AT_encoding,
- DW.FORM_data1,
- DW.AT_byte_size,
- DW.FORM_data1,
- DW.AT_name,
- DW.FORM_string, 0, 0, // table sentinel
- abbrev_pad1, DW.TAG_unspecified_type, DW.CHILDREN_no, // header
+ DW.TAG.base_type,
+ DW.CHILDREN.no, // header
+ DW.AT.encoding,
+ DW.FORM.data1,
+ DW.AT.byte_size,
+ DW.FORM.data1,
+ DW.AT.name,
+ DW.FORM.string, 0, 0, // table sentinel
+ abbrev_pad1, DW.TAG.unspecified_type, DW.CHILDREN.no, // header
0, 0, // table sentinel
abbrev_parameter,
- DW.TAG_formal_parameter, DW.CHILDREN_no, // header
- DW.AT_location, DW.FORM_exprloc,
- DW.AT_type, DW.FORM_ref4,
- DW.AT_name, DW.FORM_string,
+ DW.TAG.formal_parameter, DW.CHILDREN.no, // header
+ DW.AT.location, DW.FORM.exprloc,
+ DW.AT.type, DW.FORM.ref4,
+ DW.AT.name, DW.FORM.string,
0,
0, // table sentinel
0,
@@ -897,7 +897,7 @@ pub fn flushModule(self: *Elf, comp: *Compilation) !void {
const high_pc = text_phdr.p_vaddr + text_phdr.p_memsz;
di_buf.appendAssumeCapacity(abbrev_compile_unit);
- self.writeDwarfAddrAssumeCapacity(&di_buf, 0); // DW.AT_stmt_list, DW.FORM_sec_offset
+ self.writeDwarfAddrAssumeCapacity(&di_buf, 0); // DW.AT.stmt_list, DW.FORM.sec_offset
self.writeDwarfAddrAssumeCapacity(&di_buf, low_pc);
self.writeDwarfAddrAssumeCapacity(&di_buf, high_pc);
self.writeDwarfAddrAssumeCapacity(&di_buf, name_strp);
@@ -906,7 +906,7 @@ pub fn flushModule(self: *Elf, comp: *Compilation) !void {
// We are still waiting on dwarf-std.org to assign DW_LANG_Zig a number:
// http://dwarfstd.org/ShowIssue.php?issue=171115.1
// Until then we say it is C99.
- mem.writeInt(u16, di_buf.addManyAsArrayAssumeCapacity(2), DW.LANG_C99, target_endian);
+ mem.writeInt(u16, di_buf.addManyAsArrayAssumeCapacity(2), DW.LANG.C99, target_endian);
if (di_buf.items.len > first_dbg_info_decl.dbg_info_off) {
// Move the first N decls to the end to make more padding for the header.
@@ -1030,7 +1030,7 @@ pub fn flushModule(self: *Elf, comp: *Compilation) !void {
di_buf.items.len += ptr_width_bytes; // We will come back and write this.
const after_header_len = di_buf.items.len;
- const opcode_base = DW.LNS_set_isa + 1;
+ const opcode_base = DW.LNS.set_isa + 1;
di_buf.appendSliceAssumeCapacity(&[_]u8{
1, // minimum_instruction_length
1, // maximum_operations_per_instruction
@@ -1041,18 +1041,18 @@ pub fn flushModule(self: *Elf, comp: *Compilation) !void {
// Standard opcode lengths. The number of items here is based on `opcode_base`.
// The value is the number of LEB128 operands the instruction takes.
- 0, // `DW.LNS_copy`
- 1, // `DW.LNS_advance_pc`
- 1, // `DW.LNS_advance_line`
- 1, // `DW.LNS_set_file`
- 1, // `DW.LNS_set_column`
- 0, // `DW.LNS_negate_stmt`
- 0, // `DW.LNS_set_basic_block`
- 0, // `DW.LNS_const_add_pc`
- 1, // `DW.LNS_fixed_advance_pc`
- 0, // `DW.LNS_set_prologue_end`
- 0, // `DW.LNS_set_epilogue_begin`
- 1, // `DW.LNS_set_isa`
+ 0, // `DW.LNS.copy`
+ 1, // `DW.LNS.advance_pc`
+ 1, // `DW.LNS.advance_line`
+ 1, // `DW.LNS.set_file`
+ 1, // `DW.LNS.set_column`
+ 0, // `DW.LNS.negate_stmt`
+ 0, // `DW.LNS.set_basic_block`
+ 0, // `DW.LNS.const_add_pc`
+ 1, // `DW.LNS.fixed_advance_pc`
+ 0, // `DW.LNS.set_prologue_end`
+ 0, // `DW.LNS.set_epilogue_begin`
+ 1, // `DW.LNS.set_isa`
0, // include_directories (none except the compilation unit cwd)
});
// file_names[0]
@@ -2053,7 +2053,7 @@ fn allocateTextBlock(self: *Elf, text_block: *TextBlock, new_block_size: u64, al
// The .debug_info section has `low_pc` and `high_pc` values which is the virtual address
// range of the compilation unit. When we expand the text section, this range changes,
- // so the DW_TAG_compile_unit tag of the .debug_info section becomes dirty.
+ // so the DW_TAG.compile_unit tag of the .debug_info section becomes dirty.
self.debug_info_header_dirty = true;
// This becomes dirty for the same reason. We could potentially make this more
// fine-grained with the addition of support for more compilation units. It is planned to
@@ -2303,22 +2303,22 @@ pub fn updateFunc(self: *Elf, module: *Module, func: *Module.Fn, air: Air, liven
const ptr_width_bytes = self.ptrWidthBytes();
dbg_line_buffer.appendSliceAssumeCapacity(&[_]u8{
- DW.LNS_extended_op,
+ DW.LNS.extended_op,
ptr_width_bytes + 1,
- DW.LNE_set_address,
+ DW.LNE.set_address,
});
// This is the "relocatable" vaddr, corresponding to `code_buffer` index `0`.
assert(dbg_line_vaddr_reloc_index == dbg_line_buffer.items.len);
dbg_line_buffer.items.len += ptr_width_bytes;
- dbg_line_buffer.appendAssumeCapacity(DW.LNS_advance_line);
+ dbg_line_buffer.appendAssumeCapacity(DW.LNS.advance_line);
// This is the "relocatable" relative line offset from the previous function's end curly
// to this function's begin curly.
assert(self.getRelocDbgLineOff() == dbg_line_buffer.items.len);
// Here we use a ULEB128-fixed-4 to make sure this field can be overwritten later.
leb128.writeUnsignedFixed(4, dbg_line_buffer.addManyAsArrayAssumeCapacity(4), line_off);
- dbg_line_buffer.appendAssumeCapacity(DW.LNS_set_file);
+ dbg_line_buffer.appendAssumeCapacity(DW.LNS.set_file);
assert(self.getRelocDbgFileIndex() == dbg_line_buffer.items.len);
// Once we support more than one source file, this will have the ability to be more
// than one possible value.
@@ -2327,7 +2327,7 @@ pub fn updateFunc(self: *Elf, module: *Module, func: *Module.Fn, air: Air, liven
// Emit a line for the begin curly with prologue_end=false. The codegen will
// do the work of setting prologue_end=true and epilogue_begin=true.
- dbg_line_buffer.appendAssumeCapacity(DW.LNS_copy);
+ dbg_line_buffer.appendAssumeCapacity(DW.LNS.copy);
// .debug_info subprogram
const decl_name_with_null = decl.name[0 .. mem.lenZ(decl.name) + 1];
@@ -2344,9 +2344,9 @@ pub fn updateFunc(self: *Elf, module: *Module, func: *Module.Fn, air: Air, liven
// "relocations" and have to be in this fixed place so that functions can be
// moved in virtual address space.
assert(dbg_info_low_pc_reloc_index == dbg_info_buffer.items.len);
- dbg_info_buffer.items.len += ptr_width_bytes; // DW.AT_low_pc, DW.FORM_addr
+ dbg_info_buffer.items.len += ptr_width_bytes; // DW.AT.low_pc, DW.FORM.addr
assert(self.getRelocDbgInfoSubprogramHighPC() == dbg_info_buffer.items.len);
- dbg_info_buffer.items.len += 4; // DW.AT_high_pc, DW.FORM_data4
+ dbg_info_buffer.items.len += 4; // DW.AT.high_pc, DW.FORM.data4
if (fn_ret_has_bits) {
const gop = try dbg_info_type_relocs.getOrPut(self.base.allocator, fn_ret_type);
if (!gop.found_existing) {
@@ -2356,9 +2356,9 @@ pub fn updateFunc(self: *Elf, module: *Module, func: *Module.Fn, air: Air, liven
};
}
try gop.value_ptr.relocs.append(self.base.allocator, @intCast(u32, dbg_info_buffer.items.len));
- dbg_info_buffer.items.len += 4; // DW.AT_type, DW.FORM_ref4
+ dbg_info_buffer.items.len += 4; // DW.AT.type, DW.FORM.ref4
}
- dbg_info_buffer.appendSliceAssumeCapacity(decl_name_with_null); // DW.AT_name, DW.FORM_string
+ dbg_info_buffer.appendSliceAssumeCapacity(decl_name_with_null); // DW.AT.name, DW.FORM.string
const res = try codegen.generateFunction(&self.base, decl.srcLoc(), func, air, liveness, &code_buffer, .{
.dwarf = .{
@@ -2409,7 +2409,7 @@ pub fn updateFunc(self: *Elf, module: *Module, func: *Module.Fn, air: Air, liven
mem.writeInt(u32, ptr, @intCast(u32, local_sym.st_size), target_endian);
}
- try dbg_line_buffer.appendSlice(&[_]u8{ DW.LNS_extended_op, 1, DW.LNE_end_sequence });
+ try dbg_line_buffer.appendSlice(&[_]u8{ DW.LNS.extended_op, 1, DW.LNE.end_sequence });
// Now we have the full contents and may allocate a region to store it.
@@ -2493,7 +2493,7 @@ pub fn updateFunc(self: *Elf, module: *Module, func: *Module.Fn, air: Air, liven
const file_pos = debug_line_sect.sh_offset + src_fn.off;
try self.pwriteDbgLineNops(prev_padding_size, dbg_line_buffer.items, next_padding_size, file_pos);
- // .debug_info - End the TAG_subprogram children.
+ // .debug_info - End the TAG.subprogram children.
try dbg_info_buffer.append(0);
return self.finishUpdateDecl(module, decl, &dbg_info_type_relocs, &dbg_info_buffer);
@@ -2566,34 +2566,34 @@ fn addDbgInfoType(self: *Elf, ty: Type, dbg_info_buffer: *std.ArrayList(u8)) !vo
.Bool => {
try dbg_info_buffer.appendSlice(&[_]u8{
abbrev_base_type,
- DW.ATE_boolean, // DW.AT_encoding , DW.FORM_data1
- 1, // DW.AT_byte_size, DW.FORM_data1
- 'b', 'o', 'o', 'l', 0, // DW.AT_name, DW.FORM_string
+ DW.ATE.boolean, // DW.AT.encoding , DW.FORM.data1
+ 1, // DW.AT.byte_size, DW.FORM.data1
+ 'b', 'o', 'o', 'l', 0, // DW.AT.name, DW.FORM.string
});
},
.Int => {
const info = ty.intInfo(self.base.options.target);
try dbg_info_buffer.ensureCapacity(dbg_info_buffer.items.len + 12);
dbg_info_buffer.appendAssumeCapacity(abbrev_base_type);
- // DW.AT_encoding, DW.FORM_data1
+ // DW.AT.encoding, DW.FORM.data1
dbg_info_buffer.appendAssumeCapacity(switch (info.signedness) {
- .signed => DW.ATE_signed,
- .unsigned => DW.ATE_unsigned,
+ .signed => DW.ATE.signed,
+ .unsigned => DW.ATE.unsigned,
});
- // DW.AT_byte_size, DW.FORM_data1
+ // DW.AT.byte_size, DW.FORM.data1
dbg_info_buffer.appendAssumeCapacity(@intCast(u8, ty.abiSize(self.base.options.target)));
- // DW.AT_name, DW.FORM_string
+ // DW.AT.name, DW.FORM.string
try dbg_info_buffer.writer().print("{}\x00", .{ty});
},
.Optional => {
if (ty.isPtrLikeOptional()) {
try dbg_info_buffer.ensureCapacity(dbg_info_buffer.items.len + 12);
dbg_info_buffer.appendAssumeCapacity(abbrev_base_type);
- // DW.AT_encoding, DW.FORM_data1
- dbg_info_buffer.appendAssumeCapacity(DW.ATE_address);
- // DW.AT_byte_size, DW.FORM_data1
+ // DW.AT.encoding, DW.FORM.data1
+ dbg_info_buffer.appendAssumeCapacity(DW.ATE.address);
+ // DW.AT.byte_size, DW.FORM.data1
dbg_info_buffer.appendAssumeCapacity(@intCast(u8, ty.abiSize(self.base.options.target)));
- // DW.AT_name, DW.FORM_string
+ // DW.AT.name, DW.FORM.string
try dbg_info_buffer.writer().print("{}\x00", .{ty});
} else {
log.err("TODO implement .debug_info for type '{}'", .{ty});
@@ -3034,7 +3034,7 @@ fn archPtrWidthBytes(self: Elf) u8 {
/// The reloc offset for the virtual address of a function in its Line Number Program.
/// Size is a virtual address integer.
const dbg_line_vaddr_reloc_index = 3;
-/// The reloc offset for the virtual address of a function in its .debug_info TAG_subprogram.
+/// The reloc offset for the virtual address of a function in its .debug_info TAG.subprogram.
/// Size is a virtual address integer.
const dbg_info_low_pc_reloc_index = 1;
@@ -3060,7 +3060,7 @@ fn dbgLineNeededHeaderBytes(self: Elf) u32 {
const root_src_dir_path_len = if (self.base.options.module.?.root_pkg.root_src_directory.path) |p| p.len else 1; // "."
return @intCast(u32, 53 + directory_entry_format_count * 2 + file_name_entry_format_count * 2 +
directory_count * 8 + file_name_count * 8 +
- // These are encoded as DW.FORM_string rather than DW.FORM_strp as we would like
+ // These are encoded as DW.FORM.string rather than DW.FORM.strp as we would like
// because of a workaround for readelf and gdb failing to understand DWARFv5 correctly.
root_src_dir_path_len +
self.base.options.module.?.root_pkg.root_src_path.len);
@@ -3088,8 +3088,8 @@ fn pwriteDbgLineNops(
const tracy = trace(@src());
defer tracy.end();
- const page_of_nops = [1]u8{DW.LNS_negate_stmt} ** 4096;
- const three_byte_nop = [3]u8{ DW.LNS_advance_pc, 0b1000_0000, 0 };
+ const page_of_nops = [1]u8{DW.LNS.negate_stmt} ** 4096;
+ const three_byte_nop = [3]u8{ DW.LNS.advance_pc, 0b1000_0000, 0 };
var vecs: [512]std.os.iovec_const = undefined;
var vec_index: usize = 0;
{
diff --git a/src/link/MachO/DebugSymbols.zig b/src/link/MachO/DebugSymbols.zig
index 025959793e38..ee99adafaaf0 100644
--- a/src/link/MachO/DebugSymbols.zig
+++ b/src/link/MachO/DebugSymbols.zig
@@ -20,7 +20,10 @@ const SrcFn = MachO.SrcFn;
const TextBlock = MachO.TextBlock;
const padToIdeal = MachO.padToIdeal;
-usingnamespace @import("commands.zig");
+const commands = @import("commands.zig");
+const emptyHeader = commands.emptyHeader;
+const LoadCommand = commands.LoadCommand;
+const SegmentCommand = commands.SegmentCommand;
const page_size: u16 = 0x1000;
@@ -93,7 +96,7 @@ const abbrev_parameter = 6;
/// The reloc offset for the virtual address of a function in its Line Number Program.
/// Size is a virtual address integer.
const dbg_line_vaddr_reloc_index = 3;
-/// The reloc offset for the virtual address of a function in its .debug_info TAG_subprogram.
+/// The reloc offset for the virtual address of a function in its .debug_info TAG.subprogram.
/// Size is a virtual address integer.
const dbg_info_low_pc_reloc_index = 1;
@@ -299,40 +302,40 @@ pub fn flushModule(self: *DebugSymbols, allocator: *Allocator, options: link.Opt
// These are LEB encoded but since the values are all less than 127
// we can simply append these bytes.
const abbrev_buf = [_]u8{
- abbrev_compile_unit, DW.TAG_compile_unit, DW.CHILDREN_yes, // header
- DW.AT_stmt_list, DW.FORM_sec_offset, // offset
- DW.AT_low_pc, DW.FORM_addr,
- DW.AT_high_pc, DW.FORM_addr,
- DW.AT_name, DW.FORM_strp,
- DW.AT_comp_dir, DW.FORM_strp,
- DW.AT_producer, DW.FORM_strp,
- DW.AT_language, DW.FORM_data2,
+ abbrev_compile_unit, DW.TAG.compile_unit, DW.CHILDREN.yes, // header
+ DW.AT.stmt_list, DW.FORM.sec_offset, // offset
+ DW.AT.low_pc, DW.FORM.addr,
+ DW.AT.high_pc, DW.FORM.addr,
+ DW.AT.name, DW.FORM.strp,
+ DW.AT.comp_dir, DW.FORM.strp,
+ DW.AT.producer, DW.FORM.strp,
+ DW.AT.language, DW.FORM.data2,
0, 0, // table sentinel
- abbrev_subprogram, DW.TAG_subprogram, DW.CHILDREN_yes, // header
- DW.AT_low_pc, DW.FORM_addr, // start VM address
- DW.AT_high_pc, DW.FORM_data4,
- DW.AT_type, DW.FORM_ref4,
- DW.AT_name, DW.FORM_string,
- DW.AT_decl_line, DW.FORM_data4,
- DW.AT_decl_file, DW.FORM_data1,
+ abbrev_subprogram, DW.TAG.subprogram, DW.CHILDREN.yes, // header
+ DW.AT.low_pc, DW.FORM.addr, // start VM address
+ DW.AT.high_pc, DW.FORM.data4,
+ DW.AT.type, DW.FORM.ref4,
+ DW.AT.name, DW.FORM.string,
+ DW.AT.decl_line, DW.FORM.data4,
+ DW.AT.decl_file, DW.FORM.data1,
0, 0, // table sentinel
abbrev_subprogram_retvoid,
- DW.TAG_subprogram, DW.CHILDREN_yes, // header
- DW.AT_low_pc, DW.FORM_addr,
- DW.AT_high_pc, DW.FORM_data4,
- DW.AT_name, DW.FORM_string,
- DW.AT_decl_line, DW.FORM_data4,
- DW.AT_decl_file, DW.FORM_data1,
+ DW.TAG.subprogram, DW.CHILDREN.yes, // header
+ DW.AT.low_pc, DW.FORM.addr,
+ DW.AT.high_pc, DW.FORM.data4,
+ DW.AT.name, DW.FORM.string,
+ DW.AT.decl_line, DW.FORM.data4,
+ DW.AT.decl_file, DW.FORM.data1,
0, 0, // table sentinel
- abbrev_base_type, DW.TAG_base_type, DW.CHILDREN_no, // header
- DW.AT_encoding, DW.FORM_data1, DW.AT_byte_size,
- DW.FORM_data1, DW.AT_name, DW.FORM_string,
+ abbrev_base_type, DW.TAG.base_type, DW.CHILDREN.no, // header
+ DW.AT.encoding, DW.FORM.data1, DW.AT.byte_size,
+ DW.FORM.data1, DW.AT.name, DW.FORM.string,
0, 0, // table sentinel
- abbrev_pad1, DW.TAG_unspecified_type, DW.CHILDREN_no, // header
+ abbrev_pad1, DW.TAG.unspecified_type, DW.CHILDREN.no, // header
0, 0, // table sentinel
- abbrev_parameter, DW.TAG_formal_parameter, DW.CHILDREN_no, // header
- DW.AT_location, DW.FORM_exprloc, DW.AT_type,
- DW.FORM_ref4, DW.AT_name, DW.FORM_string,
+ abbrev_parameter, DW.TAG.formal_parameter, DW.CHILDREN.no, // header
+ DW.AT.location, DW.FORM.exprloc, DW.AT.type,
+ DW.FORM.ref4, DW.AT.name, DW.FORM.string,
0, 0, // table sentinel
0, 0, 0, // section sentinel
};
@@ -397,7 +400,7 @@ pub fn flushModule(self: *DebugSymbols, allocator: *Allocator, options: link.Opt
const high_pc = text_section.addr + text_section.size;
di_buf.appendAssumeCapacity(abbrev_compile_unit);
- mem.writeIntLittle(u32, di_buf.addManyAsArrayAssumeCapacity(4), 0); // DW.AT_stmt_list, DW.FORM_sec_offset
+ mem.writeIntLittle(u32, di_buf.addManyAsArrayAssumeCapacity(4), 0); // DW.AT.stmt_list, DW.FORM.sec_offset
mem.writeIntLittle(u64, di_buf.addManyAsArrayAssumeCapacity(8), low_pc);
mem.writeIntLittle(u64, di_buf.addManyAsArrayAssumeCapacity(8), high_pc);
mem.writeIntLittle(u32, di_buf.addManyAsArrayAssumeCapacity(4), @intCast(u32, name_strp));
@@ -406,7 +409,7 @@ pub fn flushModule(self: *DebugSymbols, allocator: *Allocator, options: link.Opt
// We are still waiting on dwarf-std.org to assign DW_LANG_Zig a number:
// http://dwarfstd.org/ShowIssue.php?issue=171115.1
// Until then we say it is C99.
- mem.writeIntLittle(u16, di_buf.addManyAsArrayAssumeCapacity(2), DW.LANG_C99);
+ mem.writeIntLittle(u16, di_buf.addManyAsArrayAssumeCapacity(2), DW.LANG.C99);
if (di_buf.items.len > first_dbg_info_decl.dbg_info_off) {
// Move the first N decls to the end to make more padding for the header.
@@ -514,7 +517,7 @@ pub fn flushModule(self: *DebugSymbols, allocator: *Allocator, options: link.Opt
di_buf.items.len += @sizeOf(u32); // We will come back and write this.
const after_header_len = di_buf.items.len;
- const opcode_base = DW.LNS_set_isa + 1;
+ const opcode_base = DW.LNS.set_isa + 1;
di_buf.appendSliceAssumeCapacity(&[_]u8{
1, // minimum_instruction_length
1, // maximum_operations_per_instruction
@@ -525,18 +528,18 @@ pub fn flushModule(self: *DebugSymbols, allocator: *Allocator, options: link.Opt
// Standard opcode lengths. The number of items here is based on `opcode_base`.
// The value is the number of LEB128 operands the instruction takes.
- 0, // `DW.LNS_copy`
- 1, // `DW.LNS_advance_pc`
- 1, // `DW.LNS_advance_line`
- 1, // `DW.LNS_set_file`
- 1, // `DW.LNS_set_column`
- 0, // `DW.LNS_negate_stmt`
- 0, // `DW.LNS_set_basic_block`
- 0, // `DW.LNS_const_add_pc`
- 1, // `DW.LNS_fixed_advance_pc`
- 0, // `DW.LNS_set_prologue_end`
- 0, // `DW.LNS_set_epilogue_begin`
- 1, // `DW.LNS_set_isa`
+ 0, // `DW.LNS.copy`
+ 1, // `DW.LNS.advance_pc`
+ 1, // `DW.LNS.advance_line`
+ 1, // `DW.LNS.set_file`
+ 1, // `DW.LNS.set_column`
+ 0, // `DW.LNS.negate_stmt`
+ 0, // `DW.LNS.set_basic_block`
+ 0, // `DW.LNS.const_add_pc`
+ 1, // `DW.LNS.fixed_advance_pc`
+ 0, // `DW.LNS.set_prologue_end`
+ 0, // `DW.LNS.set_epilogue_begin`
+ 1, // `DW.LNS.set_isa`
0, // include_directories (none except the compilation unit cwd)
});
// file_names[0]
@@ -876,22 +879,22 @@ pub fn initDeclDebugBuffers(
const line_off = @intCast(u28, decl.src_line + func.lbrace_line);
dbg_line_buffer.appendSliceAssumeCapacity(&[_]u8{
- DW.LNS_extended_op,
+ DW.LNS.extended_op,
@sizeOf(u64) + 1,
- DW.LNE_set_address,
+ DW.LNE.set_address,
});
// This is the "relocatable" vaddr, corresponding to `code_buffer` index `0`.
assert(dbg_line_vaddr_reloc_index == dbg_line_buffer.items.len);
dbg_line_buffer.items.len += @sizeOf(u64);
- dbg_line_buffer.appendAssumeCapacity(DW.LNS_advance_line);
+ dbg_line_buffer.appendAssumeCapacity(DW.LNS.advance_line);
// This is the "relocatable" relative line offset from the previous function's end curly
// to this function's begin curly.
assert(getRelocDbgLineOff() == dbg_line_buffer.items.len);
// Here we use a ULEB128-fixed-4 to make sure this field can be overwritten later.
leb.writeUnsignedFixed(4, dbg_line_buffer.addManyAsArrayAssumeCapacity(4), line_off);
- dbg_line_buffer.appendAssumeCapacity(DW.LNS_set_file);
+ dbg_line_buffer.appendAssumeCapacity(DW.LNS.set_file);
assert(getRelocDbgFileIndex() == dbg_line_buffer.items.len);
// Once we support more than one source file, this will have the ability to be more
// than one possible value.
@@ -900,7 +903,7 @@ pub fn initDeclDebugBuffers(
// Emit a line for the begin curly with prologue_end=false. The codegen will
// do the work of setting prologue_end=true and epilogue_begin=true.
- dbg_line_buffer.appendAssumeCapacity(DW.LNS_copy);
+ dbg_line_buffer.appendAssumeCapacity(DW.LNS.copy);
// .debug_info subprogram
const decl_name_with_null = decl.name[0 .. mem.lenZ(decl.name) + 1];
@@ -917,9 +920,9 @@ pub fn initDeclDebugBuffers(
// "relocations" and have to be in this fixed place so that functions can be
// moved in virtual address space.
assert(dbg_info_low_pc_reloc_index == dbg_info_buffer.items.len);
- dbg_info_buffer.items.len += @sizeOf(u64); // DW.AT_low_pc, DW.FORM_addr
+ dbg_info_buffer.items.len += @sizeOf(u64); // DW.AT.low_pc, DW.FORM.addr
assert(getRelocDbgInfoSubprogramHighPC() == dbg_info_buffer.items.len);
- dbg_info_buffer.items.len += 4; // DW.AT_high_pc, DW.FORM_data4
+ dbg_info_buffer.items.len += 4; // DW.AT.high_pc, DW.FORM.data4
if (fn_ret_has_bits) {
const gop = try dbg_info_type_relocs.getOrPut(allocator, fn_ret_type);
if (!gop.found_existing) {
@@ -929,11 +932,11 @@ pub fn initDeclDebugBuffers(
};
}
try gop.value_ptr.relocs.append(allocator, @intCast(u32, dbg_info_buffer.items.len));
- dbg_info_buffer.items.len += 4; // DW.AT_type, DW.FORM_ref4
+ dbg_info_buffer.items.len += 4; // DW.AT.type, DW.FORM.ref4
}
- dbg_info_buffer.appendSliceAssumeCapacity(decl_name_with_null); // DW.AT_name, DW.FORM_string
- mem.writeIntLittle(u32, dbg_info_buffer.addManyAsArrayAssumeCapacity(4), line_off + 1); // DW.AT_decl_line, DW.FORM_data4
- dbg_info_buffer.appendAssumeCapacity(file_index); // DW.AT_decl_file, DW.FORM_data1
+ dbg_info_buffer.appendSliceAssumeCapacity(decl_name_with_null); // DW.AT.name, DW.FORM.string
+ mem.writeIntLittle(u32, dbg_info_buffer.addManyAsArrayAssumeCapacity(4), line_off + 1); // DW.AT.decl_line, DW.FORM.data4
+ dbg_info_buffer.appendAssumeCapacity(file_index); // DW.AT.decl_file, DW.FORM.data1
},
else => {
// TODO implement .debug_info for global variables
@@ -985,16 +988,16 @@ pub fn commitDeclDebugInfo(
{
// Advance line and PC.
// TODO encapsulate logic in a helper function.
- try dbg_line_buffer.append(DW.LNS_advance_pc);
+ try dbg_line_buffer.append(DW.LNS.advance_pc);
try leb.writeULEB128(dbg_line_buffer.writer(), text_block.size);
- try dbg_line_buffer.append(DW.LNS_advance_line);
+ try dbg_line_buffer.append(DW.LNS.advance_line);
const func = decl.val.castTag(.function).?.data;
const line_off = @intCast(u28, func.rbrace_line - func.lbrace_line);
try leb.writeULEB128(dbg_line_buffer.writer(), line_off);
}
- try dbg_line_buffer.appendSlice(&[_]u8{ DW.LNS_extended_op, 1, DW.LNE_end_sequence });
+ try dbg_line_buffer.appendSlice(&[_]u8{ DW.LNS.extended_op, 1, DW.LNE.end_sequence });
// Now we have the full contents and may allocate a region to store it.
@@ -1075,7 +1078,7 @@ pub fn commitDeclDebugInfo(
const file_pos = debug_line_sect.offset + src_fn.off;
try self.pwriteDbgLineNops(prev_padding_size, dbg_line_buffer.items, next_padding_size, file_pos);
- // .debug_info - End the TAG_subprogram children.
+ // .debug_info - End the TAG.subprogram children.
try dbg_info_buffer.append(0);
},
else => {},
@@ -1128,27 +1131,27 @@ fn addDbgInfoType(
.Bool => {
try dbg_info_buffer.appendSlice(&[_]u8{
abbrev_base_type,
- DW.ATE_boolean, // DW.AT_encoding , DW.FORM_data1
- 1, // DW.AT_byte_size, DW.FORM_data1
+ DW.ATE.boolean, // DW.AT.encoding , DW.FORM.data1
+ 1, // DW.AT.byte_size, DW.FORM.data1
'b',
'o',
'o',
'l',
- 0, // DW.AT_name, DW.FORM_string
+ 0, // DW.AT.name, DW.FORM.string
});
},
.Int => {
const info = ty.intInfo(target);
try dbg_info_buffer.ensureCapacity(dbg_info_buffer.items.len + 12);
dbg_info_buffer.appendAssumeCapacity(abbrev_base_type);
- // DW.AT_encoding, DW.FORM_data1
+ // DW.AT.encoding, DW.FORM.data1
dbg_info_buffer.appendAssumeCapacity(switch (info.signedness) {
- .signed => DW.ATE_signed,
- .unsigned => DW.ATE_unsigned,
+ .signed => DW.ATE.signed,
+ .unsigned => DW.ATE.unsigned,
});
- // DW.AT_byte_size, DW.FORM_data1
+ // DW.AT.byte_size, DW.FORM.data1
dbg_info_buffer.appendAssumeCapacity(@intCast(u8, ty.abiSize(target)));
- // DW.AT_name, DW.FORM_string
+ // DW.AT.name, DW.FORM.string
try dbg_info_buffer.writer().print("{}\x00", .{ty});
},
else => {
@@ -1306,7 +1309,7 @@ fn dbgLineNeededHeaderBytes(self: DebugSymbols, module: *Module) u32 {
const root_src_dir_path_len = if (module.root_pkg.root_src_directory.path) |p| p.len else 1; // "."
return @intCast(u32, 53 + directory_entry_format_count * 2 + file_name_entry_format_count * 2 +
directory_count * 8 + file_name_count * 8 +
- // These are encoded as DW.FORM_string rather than DW.FORM_strp as we would like
+ // These are encoded as DW.FORM.string rather than DW.FORM.strp as we would like
// because of a workaround for readelf and gdb failing to understand DWARFv5 correctly.
root_src_dir_path_len +
module.root_pkg.root_src_path.len);
@@ -1332,8 +1335,8 @@ fn pwriteDbgLineNops(
const tracy = trace(@src());
defer tracy.end();
- const page_of_nops = [1]u8{DW.LNS_negate_stmt} ** 4096;
- const three_byte_nop = [3]u8{ DW.LNS_advance_pc, 0b1000_0000, 0 };
+ const page_of_nops = [1]u8{DW.LNS.negate_stmt} ** 4096;
+ const three_byte_nop = [3]u8{ DW.LNS.advance_pc, 0b1000_0000, 0 };
var vecs: [32]std.os.iovec_const = undefined;
var vec_index: usize = 0;
{
diff --git a/src/link/MachO/Object.zig b/src/link/MachO/Object.zig
index 06c76b259db8..1051cda69429 100644
--- a/src/link/MachO/Object.zig
+++ b/src/link/MachO/Object.zig
@@ -836,8 +836,8 @@ pub fn parseDebugInfo(self: *Object, allocator: *Allocator) !void {
},
else => |e| return e,
};
- const name = try compile_unit.die.getAttrString(&debug_info.inner, dwarf.AT_name);
- const comp_dir = try compile_unit.die.getAttrString(&debug_info.inner, dwarf.AT_comp_dir);
+ const name = try compile_unit.die.getAttrString(&debug_info.inner, dwarf.AT.name);
+ const comp_dir = try compile_unit.die.getAttrString(&debug_info.inner, dwarf.AT.comp_dir);
self.debug_info = debug_info;
self.tu_name = try allocator.dupe(u8, name);
diff --git a/src/link/tapi/parse/test.zig b/src/link/tapi/parse/test.zig
index b96a71fe97a6..fc0bed5df6ad 100644
--- a/src/link/tapi/parse/test.zig
+++ b/src/link/tapi/parse/test.zig
@@ -1,8 +1,8 @@
const std = @import("std");
const mem = std.mem;
const testing = std.testing;
-
-usingnamespace @import("../parse.zig");
+const Tree = @import("../parse.zig").Tree;
+const Node = @import("../parse.zig").Node;
test "explicit doc" {
const source =
diff --git a/src/main.zig b/src/main.zig
index 44b3a0515c7d..d58c3525c529 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -6,7 +6,7 @@ const mem = std.mem;
const process = std.process;
const Allocator = mem.Allocator;
const ArrayList = std.ArrayList;
-const ast = std.zig.ast;
+const Ast = std.zig.Ast;
const warn = std.log.warn;
const Compilation = @import("Compilation.zig");
@@ -3423,8 +3423,8 @@ fn fmtPathFile(
fn printErrMsgToStdErr(
gpa: *mem.Allocator,
arena: *mem.Allocator,
- parse_error: ast.Error,
- tree: ast.Tree,
+ parse_error: Ast.Error,
+ tree: Ast,
path: []const u8,
color: Color,
) !void {
@@ -3828,7 +3828,7 @@ fn parseCodeModel(arg: []const u8) std.builtin.CodeModel {
/// garbage collector to run concurrently to zig processes, and to allow multiple
/// zig processes to run concurrently with each other, without clobbering each other.
fn gimmeMoreOfThoseSweetSweetFileDescriptors() void {
- if (!@hasDecl(std.os, "rlimit")) return;
+ if (!@hasDecl(std.os.system, "rlimit")) return;
const posix = std.os;
var lim = posix.getrlimit(.NOFILE) catch return; // Oh well; we tried.
@@ -3836,7 +3836,7 @@ fn gimmeMoreOfThoseSweetSweetFileDescriptors() void {
// On Darwin, `NOFILE` is bounded by a hardcoded value `OPEN_MAX`.
// According to the man pages for setrlimit():
// setrlimit() now returns with errno set to EINVAL in places that historically succeeded.
- // It no longer accepts "rlim_cur = RLIM_INFINITY" for RLIM_NOFILE.
+ // It no longer accepts "rlim_cur = RLIM.INFINITY" for RLIM.NOFILE.
// Use "rlim_cur = min(OPEN_MAX, rlim_max)".
lim.max = std.math.min(std.os.darwin.OPEN_MAX, lim.max);
}
@@ -3846,7 +3846,7 @@ fn gimmeMoreOfThoseSweetSweetFileDescriptors() void {
var min: posix.rlim_t = lim.cur;
var max: posix.rlim_t = 1 << 20;
// But if there's a defined upper bound, don't search, just set it.
- if (lim.max != posix.RLIM_INFINITY) {
+ if (lim.max != posix.RLIM.INFINITY) {
min = lim.max;
max = lim.max;
}
@@ -4029,12 +4029,12 @@ pub fn cmdAstCheck(
}
{
- const token_bytes = @sizeOf(std.zig.ast.TokenList) +
- file.tree.tokens.len * (@sizeOf(std.zig.Token.Tag) + @sizeOf(std.zig.ast.ByteOffset));
- const tree_bytes = @sizeOf(std.zig.ast.Tree) + file.tree.nodes.len *
- (@sizeOf(std.zig.ast.Node.Tag) +
- @sizeOf(std.zig.ast.Node.Data) +
- @sizeOf(std.zig.ast.TokenIndex));
+ const token_bytes = @sizeOf(Ast.TokenList) +
+ file.tree.tokens.len * (@sizeOf(std.zig.Token.Tag) + @sizeOf(Ast.ByteOffset));
+ const tree_bytes = @sizeOf(Ast) + file.tree.nodes.len *
+ (@sizeOf(Ast.Node.Tag) +
+ @sizeOf(Ast.Node.Data) +
+ @sizeOf(Ast.TokenIndex));
const instruction_bytes = file.zir.instructions.len *
// Here we don't use @sizeOf(Zir.Inst.Data) because it would include
// the debug safety tag but we want to measure release size.
diff --git a/src/translate_c.zig b/src/translate_c.zig
index 6b7165176b68..d980fa657e66 100644
--- a/src/translate_c.zig
+++ b/src/translate_c.zig
@@ -356,7 +356,7 @@ pub fn translate(
args_end: [*]?[*]const u8,
errors: *[]ClangErrMsg,
resources_path: [*:0]const u8,
-) !std.zig.ast.Tree {
+) !std.zig.Ast {
const ast_unit = clang.LoadFromCommandLine(
args_begin,
args_end,
@@ -369,7 +369,7 @@ pub fn translate(
};
defer ast_unit.delete();
- // For memory that has the same lifetime as the Tree that we return
+ // For memory that has the same lifetime as the Ast that we return
// from this function.
var arena = std.heap.ArenaAllocator.init(gpa);
errdefer arena.deinit();
@@ -395,7 +395,15 @@ pub fn translate(
context.pattern_list.deinit(gpa);
}
- try context.global_scope.nodes.append(Tag.usingnamespace_builtins.init());
+ inline for (meta.declarations(std.zig.c_builtins)) |decl| {
+ if (decl.is_pub) {
+ const builtin = try Tag.pub_var_simple.create(context.arena, .{
+ .name = decl.name,
+ .init = try Tag.import_c_builtin.create(context.arena, decl.name),
+ });
+ try addTopLevelDecl(&context, decl.name, builtin);
+ }
+ }
try prepopulateGlobalNameTable(ast_unit, &context);
@@ -1982,6 +1990,7 @@ fn transImplicitCastExpr(
fn isBuiltinDefined(name: []const u8) bool {
inline for (meta.declarations(std.zig.c_builtins)) |decl| {
+ if (!decl.is_pub) continue;
if (std.mem.eql(u8, name, decl.name)) return true;
}
return false;
@@ -5248,6 +5257,26 @@ const MacroCtx = struct {
fn makeSlicer(self: *const MacroCtx) MacroSlicer {
return MacroSlicer{ .source = self.source, .tokens = self.list };
}
+
+ fn containsUndefinedIdentifier(self: *MacroCtx, scope: *Scope, params: []const ast.Payload.Param) ?[]const u8 {
+ const slicer = self.makeSlicer();
+ var i: usize = 1; // index 0 is the macro name
+ while (i < self.list.len) : (i += 1) {
+ const token = self.list[i];
+ switch (token.id) {
+ .Period, .Arrow => i += 1, // skip next token since field identifiers can be unknown
+ .Identifier => {
+ const identifier = slicer.slice(token);
+ const is_param = for (params) |param| {
+ if (param.name != null and mem.eql(u8, identifier, param.name.?)) break true;
+ } else false;
+ if (!scope.contains(identifier) and !isBuiltinDefined(identifier) and !is_param) return identifier;
+ },
+ else => {},
+ }
+ }
+ return null;
+ }
};
fn tokenizeMacro(source: []const u8, tok_list: *std.ArrayList(CToken)) Error!void {
@@ -5318,7 +5347,10 @@ fn transPreprocessorEntities(c: *Context, unit: *clang.ASTUnit) Error!void {
},
.Nl, .Eof => {
// this means it is a macro without a value
- // we don't care about such things
+ // We define it as an empty string so that it can still be used with ++
+ const str_node = try Tag.string_literal.create(c.arena, "\"\"");
+ const var_decl = try Tag.pub_var_simple.create(c.arena, .{ .name = name, .init = str_node });
+ try c.global_scope.macro_table.put(name, var_decl);
continue;
},
.LParen => {
@@ -5344,6 +5376,9 @@ fn transPreprocessorEntities(c: *Context, unit: *clang.ASTUnit) Error!void {
fn transMacroDefine(c: *Context, m: *MacroCtx) ParseError!void {
const scope = &c.global_scope.base;
+ if (m.containsUndefinedIdentifier(scope, &.{})) |ident|
+ return m.fail(c, "unable to translate macro: undefined identifier `{s}`", .{ident});
+
const init_node = try parseCExpr(c, m, scope);
const last = m.next().?;
if (last != .Eof and last != .Nl)
@@ -5394,6 +5429,9 @@ fn transMacroFnDefine(c: *Context, m: *MacroCtx) ParseError!void {
return m.fail(c, "unable to translate C expr: expected ')'", .{});
}
+ if (m.containsUndefinedIdentifier(scope, fn_params.items)) |ident|
+ return m.fail(c, "unable to translate macro: undefined identifier `{s}`", .{ident});
+
const expr = try parseCExpr(c, m, scope);
const last = m.next().?;
if (last != .Eof and last != .Nl)
@@ -5735,10 +5773,6 @@ fn parseCPrimaryExprInner(c: *Context, m: *MacroCtx, scope: *Scope) ParseError!N
},
.Identifier => {
const mangled_name = scope.getAlias(slice);
- if (mem.startsWith(u8, mangled_name, "__builtin_") and !isBuiltinDefined(mangled_name)) {
- try m.fail(c, "TODO implement function '{s}' in std.zig.c_builtins", .{mangled_name});
- return error.ParseError;
- }
if (builtin_typedef_map.get(mangled_name)) |ty| return Tag.type.create(c.arena, ty);
const identifier = try Tag.identifier.create(c.arena, mangled_name);
scope.skipVariableDiscard(identifier.castTag(.identifier).?.data);
diff --git a/src/translate_c/ast.zig b/src/translate_c/ast.zig
index 01f7d24d0444..3686b90bdac1 100644
--- a/src/translate_c/ast.zig
+++ b/src/translate_c/ast.zig
@@ -31,8 +31,6 @@ pub const Node = extern union {
@"anytype",
@"continue",
@"break",
- /// pub usingnamespace @import("std").zig.c_builtins
- usingnamespace_builtins,
// After this, the tag requires a payload.
integer_literal,
@@ -119,6 +117,8 @@ pub const Node = extern union {
ellipsis3,
assign,
+ /// @import("std").zig.c_builtins.
+ import_c_builtin,
log2_int_type,
/// @import("std").math.Log2Int(operand)
std_math_Log2Int,
@@ -224,7 +224,7 @@ pub const Node = extern union {
/// [1]type{val} ** count
array_filler,
- pub const last_no_payload_tag = Tag.usingnamespace_builtins;
+ pub const last_no_payload_tag = Tag.@"break";
pub const no_payload_count = @enumToInt(last_no_payload_tag) + 1;
pub fn Type(comptime t: Tag) type {
@@ -236,7 +236,6 @@ pub const Node = extern union {
.true_literal,
.false_literal,
.empty_block,
- .usingnamespace_builtins,
.return_void,
.zero_literal,
.one_literal,
@@ -344,6 +343,7 @@ pub const Node = extern union {
.warning,
.type,
.helpers_macro,
+ .import_c_builtin,
=> Payload.Value,
.discard => Payload.Discard,
.@"if" => Payload.If,
@@ -714,9 +714,9 @@ pub const Payload = struct {
};
};
-/// Converts the nodes into a Zig ast.
+/// Converts the nodes into a Zig Ast.
/// Caller must free the source slice.
-pub fn render(gpa: *Allocator, nodes: []const Node) !std.zig.ast.Tree {
+pub fn render(gpa: *Allocator, nodes: []const Node) !std.zig.Ast {
var ctx = Context{
.gpa = gpa,
.buf = std.ArrayList(u8).init(gpa),
@@ -767,7 +767,7 @@ pub fn render(gpa: *Allocator, nodes: []const Node) !std.zig.ast.Tree {
.start = @intCast(u32, ctx.buf.items.len),
});
- return std.zig.ast.Tree{
+ return std.zig.Ast{
.source = try ctx.buf.toOwnedSliceSentinel(0),
.tokens = ctx.tokens.toOwnedSlice(),
.nodes = ctx.nodes.toOwnedSlice(),
@@ -776,17 +776,17 @@ pub fn render(gpa: *Allocator, nodes: []const Node) !std.zig.ast.Tree {
};
}
-const NodeIndex = std.zig.ast.Node.Index;
-const NodeSubRange = std.zig.ast.Node.SubRange;
-const TokenIndex = std.zig.ast.TokenIndex;
+const NodeIndex = std.zig.Ast.Node.Index;
+const NodeSubRange = std.zig.Ast.Node.SubRange;
+const TokenIndex = std.zig.Ast.TokenIndex;
const TokenTag = std.zig.Token.Tag;
const Context = struct {
gpa: *Allocator,
buf: std.ArrayList(u8) = .{},
- nodes: std.zig.ast.NodeList = .{},
- extra_data: std.ArrayListUnmanaged(std.zig.ast.Node.Index) = .{},
- tokens: std.zig.ast.TokenList = .{},
+ nodes: std.zig.Ast.NodeList = .{},
+ extra_data: std.ArrayListUnmanaged(std.zig.Ast.Node.Index) = .{},
+ tokens: std.zig.Ast.TokenList = .{},
fn addTokenFmt(c: *Context, tag: TokenTag, comptime format: []const u8, args: anytype) Allocator.Error!TokenIndex {
const start_index = c.buf.items.len;
@@ -831,7 +831,7 @@ const Context = struct {
};
}
- fn addNode(c: *Context, elem: std.zig.ast.NodeList.Elem) Allocator.Error!NodeIndex {
+ fn addNode(c: *Context, elem: std.zig.Ast.NodeList.Elem) Allocator.Error!NodeIndex {
const result = @intCast(NodeIndex, c.nodes.len);
try c.nodes.append(c.gpa, elem);
return result;
@@ -871,22 +871,6 @@ fn renderNode(c: *Context, node: Node) Allocator.Error!NodeIndex {
try c.buf.append('\n');
return @as(NodeIndex, 0); // error: integer value 0 cannot be coerced to type 'std.mem.Allocator.Error!u32'
},
- .usingnamespace_builtins => {
- // pub usingnamespace @import("std").c.builtins;
- _ = try c.addToken(.keyword_pub, "pub");
- const usingnamespace_token = try c.addToken(.keyword_usingnamespace, "usingnamespace");
- const import_node = try renderStdImport(c, &.{ "zig", "c_builtins" });
- _ = try c.addToken(.semicolon, ";");
-
- return c.addNode(.{
- .tag = .@"usingnamespace",
- .main_token = usingnamespace_token,
- .data = .{
- .lhs = import_node,
- .rhs = undefined,
- },
- });
- },
.std_math_Log2Int => {
const payload = node.castTag(.std_math_Log2Int).?.data;
const import_node = try renderStdImport(c, &.{ "math", "Log2Int" });
@@ -1143,6 +1127,15 @@ fn renderNode(c: *Context, node: Node) Allocator.Error!NodeIndex {
};
return renderStdImport(c, &chain);
},
+ .import_c_builtin => {
+ const payload = node.castTag(.import_c_builtin).?.data;
+ const chain = [_][]const u8{
+ "zig",
+ "c_builtins",
+ payload,
+ };
+ return renderStdImport(c, &chain);
+ },
.string_slice => {
const payload = node.castTag(.string_slice).?.data;
@@ -1166,7 +1159,7 @@ fn renderNode(c: *Context, node: Node) Allocator.Error!NodeIndex {
.main_token = l_bracket,
.data = .{
.lhs = string,
- .rhs = try c.addExtra(std.zig.ast.Node.Slice{
+ .rhs = try c.addExtra(std.zig.Ast.Node.Slice{
.start = start,
.end = end,
}),
@@ -1601,7 +1594,7 @@ fn renderNode(c: *Context, node: Node) Allocator.Error!NodeIndex {
.main_token = while_tok,
.data = .{
.lhs = cond,
- .rhs = try c.addExtra(std.zig.ast.Node.WhileCont{
+ .rhs = try c.addExtra(std.zig.Ast.Node.WhileCont{
.cont_expr = cont_expr,
.then_expr = body,
}),
@@ -1654,7 +1647,7 @@ fn renderNode(c: *Context, node: Node) Allocator.Error!NodeIndex {
.main_token = if_tok,
.data = .{
.lhs = cond,
- .rhs = try c.addExtra(std.zig.ast.Node.If{
+ .rhs = try c.addExtra(std.zig.Ast.Node.If{
.then_expr = then_expr,
.else_expr = else_expr,
}),
@@ -2175,7 +2168,7 @@ fn renderNullSentinelArrayType(c: *Context, len: usize, elem_type: Node) !NodeIn
.main_token = l_bracket,
.data = .{
.lhs = len_expr,
- .rhs = try c.addExtra(std.zig.ast.Node.ArrayTypeSentinel{
+ .rhs = try c.addExtra(std.zig.Ast.Node.ArrayTypeSentinel{
.sentinel = sentinel_expr,
.elem_type = elem_type_expr,
}),
@@ -2352,7 +2345,6 @@ fn renderNodeGrouped(c: *Context, node: Node) !NodeIndex {
.@"comptime",
.@"defer",
.asm_simple,
- .usingnamespace_builtins,
.while_true,
.if_not_break,
.switch_else,
@@ -2371,6 +2363,7 @@ fn renderNodeGrouped(c: *Context, node: Node) !NodeIndex {
.bit_xor_assign,
.assign,
.helpers_macro,
+ .import_c_builtin,
=> {
// these should never appear in places where grouping might be needed.
unreachable;
@@ -2378,7 +2371,7 @@ fn renderNodeGrouped(c: *Context, node: Node) !NodeIndex {
}
}
-fn renderPrefixOp(c: *Context, node: Node, tag: std.zig.ast.Node.Tag, tok_tag: TokenTag, bytes: []const u8) !NodeIndex {
+fn renderPrefixOp(c: *Context, node: Node, tag: std.zig.Ast.Node.Tag, tok_tag: TokenTag, bytes: []const u8) !NodeIndex {
const payload = @fieldParentPtr(Payload.UnOp, "base", node.ptr_otherwise).data;
return c.addNode(.{
.tag = tag,
@@ -2390,7 +2383,7 @@ fn renderPrefixOp(c: *Context, node: Node, tag: std.zig.ast.Node.Tag, tok_tag: T
});
}
-fn renderBinOpGrouped(c: *Context, node: Node, tag: std.zig.ast.Node.Tag, tok_tag: TokenTag, bytes: []const u8) !NodeIndex {
+fn renderBinOpGrouped(c: *Context, node: Node, tag: std.zig.Ast.Node.Tag, tok_tag: TokenTag, bytes: []const u8) !NodeIndex {
const payload = @fieldParentPtr(Payload.BinOp, "base", node.ptr_otherwise).data;
const lhs = try renderNodeGrouped(c, payload.lhs);
return c.addNode(.{
@@ -2403,7 +2396,7 @@ fn renderBinOpGrouped(c: *Context, node: Node, tag: std.zig.ast.Node.Tag, tok_ta
});
}
-fn renderBinOp(c: *Context, node: Node, tag: std.zig.ast.Node.Tag, tok_tag: TokenTag, bytes: []const u8) !NodeIndex {
+fn renderBinOp(c: *Context, node: Node, tag: std.zig.Ast.Node.Tag, tok_tag: TokenTag, bytes: []const u8) !NodeIndex {
const payload = @fieldParentPtr(Payload.BinOp, "base", node.ptr_otherwise).data;
const lhs = try renderNode(c, payload.lhs);
return c.addNode(.{
@@ -2604,7 +2597,7 @@ fn renderVar(c: *Context, node: Node) !NodeIndex {
.tag = .local_var_decl,
.main_token = mut_tok,
.data = .{
- .lhs = try c.addExtra(std.zig.ast.Node.LocalVarDecl{
+ .lhs = try c.addExtra(std.zig.Ast.Node.LocalVarDecl{
.type_node = type_node,
.align_node = align_node,
}),
@@ -2617,7 +2610,7 @@ fn renderVar(c: *Context, node: Node) !NodeIndex {
.tag = .global_var_decl,
.main_token = mut_tok,
.data = .{
- .lhs = try c.addExtra(std.zig.ast.Node.GlobalVarDecl{
+ .lhs = try c.addExtra(std.zig.Ast.Node.GlobalVarDecl{
.type_node = type_node,
.align_node = align_node,
.section_node = section_node,
@@ -2709,7 +2702,7 @@ fn renderFunc(c: *Context, node: Node) !NodeIndex {
.tag = .fn_proto_one,
.main_token = fn_token,
.data = .{
- .lhs = try c.addExtra(std.zig.ast.Node.FnProtoOne{
+ .lhs = try c.addExtra(std.zig.Ast.Node.FnProtoOne{
.param = params.items[0],
.align_expr = align_expr,
.section_expr = section_expr,
@@ -2723,7 +2716,7 @@ fn renderFunc(c: *Context, node: Node) !NodeIndex {
.tag = .fn_proto,
.main_token = fn_token,
.data = .{
- .lhs = try c.addExtra(std.zig.ast.Node.FnProto{
+ .lhs = try c.addExtra(std.zig.Ast.Node.FnProto{
.params_start = span.start,
.params_end = span.end,
.align_expr = align_expr,
@@ -2781,7 +2774,7 @@ fn renderMacroFunc(c: *Context, node: Node) !NodeIndex {
.tag = .fn_proto_multi,
.main_token = fn_token,
.data = .{
- .lhs = try c.addExtra(std.zig.ast.Node.SubRange{
+ .lhs = try c.addExtra(std.zig.Ast.Node.SubRange{
.start = span.start,
.end = span.end,
}),
diff --git a/src/type.zig b/src/type.zig
index aa4517ab05b0..b6602ba18dcf 100644
--- a/src/type.zig
+++ b/src/type.zig
@@ -197,7 +197,7 @@ pub const Type = extern union {
/// Prefer `castTag` to this.
pub fn cast(self: Type, comptime T: type) ?*T {
if (@hasField(T, "base_tag")) {
- return base.castTag(T.base_tag);
+ return self.castTag(T.base_tag);
}
if (self.tag_if_small_enough < Tag.no_payload_count) {
return null;
diff --git a/src/value.zig b/src/value.zig
index 5ac9f142c46c..8aaf70c4287c 100644
--- a/src/value.zig
+++ b/src/value.zig
@@ -315,7 +315,7 @@ pub const Value = extern union {
/// Prefer `castTag` to this.
pub fn cast(self: Value, comptime T: type) ?*T {
if (@hasField(T, "base_tag")) {
- return base.castTag(T.base_tag);
+ return self.castTag(T.base_tag);
}
if (self.tag_if_small_enough < Tag.no_payload_count) {
return null;
diff --git a/src/windows_sdk.zig b/src/windows_sdk.zig
index ca69ff4548ec..3ff53dc2e1d5 100644
--- a/src/windows_sdk.zig
+++ b/src/windows_sdk.zig
@@ -11,12 +11,17 @@ pub const ZigWindowsSDK = extern struct {
version81_len: usize,
msvc_lib_dir_ptr: ?[*]const u8,
msvc_lib_dir_len: usize,
+
+ pub const find = zig_find_windows_sdk;
+ pub const free = zig_free_windows_sdk;
+
+ pub const FindError = enum(c_int) {
+ None,
+ OutOfMemory,
+ NotFound,
+ PathTooLong,
+ };
+
+ extern fn zig_find_windows_sdk(out_sdk: **ZigWindowsSDK) FindError;
+ extern fn zig_free_windows_sdk(sdk: *ZigWindowsSDK) void;
};
-pub const ZigFindWindowsSdkError = enum(c_int) {
- None,
- OutOfMemory,
- NotFound,
- PathTooLong,
-};
-pub extern fn zig_find_windows_sdk(out_sdk: **ZigWindowsSDK) ZigFindWindowsSdkError;
-pub extern fn zig_free_windows_sdk(sdk: *ZigWindowsSDK) void;
diff --git a/test/behavior.zig b/test/behavior.zig
index 7028d6cbf669..b39c50df322e 100644
--- a/test/behavior.zig
+++ b/test/behavior.zig
@@ -10,6 +10,7 @@ test {
_ = @import("behavior/if.zig");
_ = @import("behavior/cast.zig");
_ = @import("behavior/array.zig");
+ _ = @import("behavior/usingnamespace.zig");
if (!builtin.zig_is_stage2) {
// Tests that only pass for stage1.
@@ -137,7 +138,6 @@ test {
_ = @import("behavior/switch.zig");
_ = @import("behavior/switch_prong_err_enum.zig");
_ = @import("behavior/switch_prong_implicit_cast.zig");
- _ = @import("behavior/syntax.zig");
_ = @import("behavior/this.zig");
_ = @import("behavior/truncate.zig");
_ = @import("behavior/try.zig");
@@ -148,7 +148,7 @@ test {
_ = @import("behavior/undefined.zig");
_ = @import("behavior/underscore.zig");
_ = @import("behavior/union.zig");
- _ = @import("behavior/usingnamespace.zig");
+ _ = @import("behavior/usingnamespace_stage1.zig");
_ = @import("behavior/var_args.zig");
_ = @import("behavior/vector.zig");
_ = @import("behavior/void.zig");
diff --git a/test/behavior/eval.zig b/test/behavior/eval.zig
index 1b6540cd32a8..0d103bc49aa1 100644
--- a/test/behavior/eval.zig
+++ b/test/behavior/eval.zig
@@ -125,12 +125,6 @@ test "pointer to type" {
}
}
-test "no undeclared identifier error in unanalyzed branches" {
- if (false) {
- lol_this_doesnt_exist = nonsense;
- }
-}
-
test "a type constructed in a global expression" {
var l: List = undefined;
l.array[0] = 10;
diff --git a/test/behavior/syntax.zig b/test/behavior/syntax.zig
deleted file mode 100644
index c5f9fc70b1d4..000000000000
--- a/test/behavior/syntax.zig
+++ /dev/null
@@ -1,66 +0,0 @@
-// Test trailing comma syntax
-// zig fmt: off
-
-extern var a: c_int;
-extern "c" var b: c_int;
-export var c: c_int = 0;
-threadlocal var d: c_int = 0;
-extern threadlocal var e: c_int;
-extern "c" threadlocal var f: c_int;
-export threadlocal var g: c_int = 0;
-
-const struct_trailing_comma = struct { x: i32, y: i32, };
-const struct_no_comma = struct { x: i32, y: i32 };
-const struct_fn_no_comma = struct { fn m() void {} y: i32 };
-
-const enum_no_comma = enum { A, B };
-
-fn container_init() void {
- const S = struct { x: i32, y: i32 };
- _ = S { .x = 1, .y = 2 };
- _ = S { .x = 1, .y = 2, };
-}
-
-fn type_expr_return1() if (true) A {}
-fn type_expr_return2() for (true) |_| A {}
-fn type_expr_return3() while (true) A {}
-
-fn switch_cases(x: i32) void {
- switch (x) {
- 1,2,3 => {},
- 4,5, => {},
- 6...8, => {},
- else => {},
- }
-}
-
-fn switch_prongs(x: i32) void {
- switch (x) {
- 0 => {},
- else => {},
- }
- switch (x) {
- 0 => {},
- else => {}
- }
-}
-
-const fn_no_comma = fn(i32, i32)void;
-const fn_trailing_comma = fn(i32, i32,)void;
-
-fn fn_calls() void {
- fn add(x: i32, y: i32,) i32 { x + y };
- _ = add(1, 2);
- _ = add(1, 2,);
-}
-
-fn asm_lists() void {
- if (false) { // Build AST but don't analyze
- asm ("not real assembly"
- :[a] "x" (x),);
- asm ("not real assembly"
- :[a] "x" (->i32),:[a] "x" (1),);
- asm volatile ("still not real assembly"
- :::"a","b",);
- }
-}
diff --git a/test/behavior/usingnamespace.zig b/test/behavior/usingnamespace.zig
index b529b24dd494..e81956600230 100644
--- a/test/behavior/usingnamespace.zig
+++ b/test/behavior/usingnamespace.zig
@@ -1,22 +1,13 @@
const std = @import("std");
-fn Foo(comptime T: type) type {
- return struct {
- usingnamespace T;
- };
-}
-
-test "usingnamespace inside a generic struct" {
- const std2 = Foo(std);
- const testing2 = Foo(std.testing);
- try std2.testing.expect(true);
- try testing2.expect(true);
-}
+const A = struct {
+ pub const B = bool;
+};
-usingnamespace struct {
- pub const foo = 42;
+const C = struct {
+ usingnamespace A;
};
-test "usingnamespace does not redeclare an imported variable" {
- comptime try std.testing.expect(foo == 42);
+test "basic usingnamespace" {
+ try std.testing.expect(C.B == bool);
}
diff --git a/test/behavior/usingnamespace/a.zig b/test/behavior/usingnamespace/a.zig
new file mode 100644
index 000000000000..21d4278e15ee
--- /dev/null
+++ b/test/behavior/usingnamespace/a.zig
@@ -0,0 +1,7 @@
+usingnamespace @import("b.zig");
+
+pub const a_text = "OK\n";
+
+pub fn ok() bool {
+ return @import("std").mem.eql(u8, @This().b_text, "OK\n");
+}
diff --git a/test/behavior/usingnamespace/b.zig b/test/behavior/usingnamespace/b.zig
new file mode 100644
index 000000000000..08dafa3c5015
--- /dev/null
+++ b/test/behavior/usingnamespace/b.zig
@@ -0,0 +1,3 @@
+usingnamespace @import("a.zig");
+
+pub const b_text = @This().a_text;
diff --git a/test/behavior/usingnamespace/bar.zig b/test/behavior/usingnamespace/bar.zig
new file mode 100644
index 000000000000..faa3f27dbe92
--- /dev/null
+++ b/test/behavior/usingnamespace/bar.zig
@@ -0,0 +1,8 @@
+usingnamespace @import("other.zig");
+
+pub var saw_bar_function = false;
+pub fn bar_function() void {
+ if (@This().foo_function()) {
+ saw_bar_function = true;
+ }
+}
diff --git a/test/behavior/usingnamespace/foo.zig b/test/behavior/usingnamespace/foo.zig
new file mode 100644
index 000000000000..6b2b14e51ce3
--- /dev/null
+++ b/test/behavior/usingnamespace/foo.zig
@@ -0,0 +1,14 @@
+// purposefully conflicting function with main source file
+// but it's private so it should be OK
+fn privateFunction() bool {
+ return false;
+}
+
+pub fn printText() bool {
+ return privateFunction();
+}
+
+pub var saw_foo_function = false;
+pub fn foo_function() void {
+ saw_foo_function = true;
+}
diff --git a/test/behavior/usingnamespace/import_segregation.zig b/test/behavior/usingnamespace/import_segregation.zig
new file mode 100644
index 000000000000..a509189be3e4
--- /dev/null
+++ b/test/behavior/usingnamespace/import_segregation.zig
@@ -0,0 +1,11 @@
+const expect = @import("std").testing.expect;
+
+usingnamespace @import("foo.zig");
+usingnamespace @import("bar.zig");
+
+test "no clobbering happened" {
+ @This().foo_function();
+ @This().bar_function();
+ try expect(@This().saw_foo_function);
+ try expect(@This().saw_bar_function);
+}
diff --git a/test/behavior/usingnamespace/other.zig b/test/behavior/usingnamespace/other.zig
new file mode 100644
index 000000000000..02e0f39e9010
--- /dev/null
+++ b/test/behavior/usingnamespace/other.zig
@@ -0,0 +1,4 @@
+pub fn foo_function() bool {
+ // this one conflicts with the one from foo
+ return true;
+}
diff --git a/test/behavior/usingnamespace_stage1.zig b/test/behavior/usingnamespace_stage1.zig
new file mode 100644
index 000000000000..142df21549c1
--- /dev/null
+++ b/test/behavior/usingnamespace_stage1.zig
@@ -0,0 +1,41 @@
+const std = @import("std");
+const expect = std.testing.expect;
+
+fn Foo(comptime T: type) type {
+ return struct {
+ usingnamespace T;
+ };
+}
+
+test "usingnamespace inside a generic struct" {
+ const std2 = Foo(std);
+ const testing2 = Foo(std.testing);
+ try std2.testing.expect(true);
+ try testing2.expect(true);
+}
+
+usingnamespace struct {
+ pub const foo = 42;
+};
+
+test "usingnamespace does not redeclare an imported variable" {
+ comptime try std.testing.expect(@This().foo == 42);
+}
+
+usingnamespace @import("usingnamespace/foo.zig");
+test "usingnamespace omits mixing in private functions" {
+ try expect(@This().privateFunction());
+ try expect(!@This().printText());
+}
+fn privateFunction() bool {
+ return true;
+}
+
+test {
+ _ = @import("usingnamespace/import_segregation.zig");
+}
+
+usingnamespace @import("usingnamespace/a.zig");
+test "two files usingnamespace import each other" {
+ try expect(@This().ok());
+}
diff --git a/test/cases.zig b/test/cases.zig
index 2f3884de1ed1..64fe39e07be0 100644
--- a/test/cases.zig
+++ b/test/cases.zig
@@ -1073,37 +1073,37 @@ pub fn addCases(ctx: *TestContext) !void {
case.addError(
\\pub fn main() void {
\\ var i = 0;
- \\ for (n) |_, i| {
+ \\ for ("n") |_, i| {
\\ }
\\}
, &[_][]const u8{
- ":3:17: error: redeclaration of local variable 'i'",
+ ":3:19: error: redeclaration of local variable 'i'",
":2:9: note: previous declaration here",
});
case.addError(
\\pub fn main() void {
\\ var i = 0;
- \\ for (n) |i| {
+ \\ for ("n") |i| {
\\ }
\\}
, &[_][]const u8{
- ":3:14: error: redeclaration of local variable 'i'",
+ ":3:16: error: redeclaration of local variable 'i'",
":2:9: note: previous declaration here",
});
case.addError(
\\pub fn main() void {
\\ var i = 0;
- \\ while (n) |i| {
+ \\ while ("n") |i| {
\\ }
\\}
, &[_][]const u8{
- ":3:16: error: redeclaration of local variable 'i'",
+ ":3:18: error: redeclaration of local variable 'i'",
":2:9: note: previous declaration here",
});
case.addError(
\\pub fn main() void {
\\ var i = 0;
- \\ while (n) |bruh| {
+ \\ while ("n") |bruh| {
\\ _ = bruh;
\\ } else |i| {
\\
diff --git a/test/cli.zig b/test/cli.zig
index e3a00fe735ad..59fb7095af53 100644
--- a/test/cli.zig
+++ b/test/cli.zig
@@ -45,13 +45,6 @@ pub fn main() !void {
}
}
-fn unwrapArg(arg: UnwrapArgError![]u8) UnwrapArgError![]u8 {
- return arg catch |err| {
- warn("Unable to parse command line: {}\n", .{err});
- return err;
- };
-}
-
fn printCmd(cwd: []const u8, argv: []const []const u8) void {
std.debug.warn("cd {s} && ", .{cwd});
for (argv) |arg| {
diff --git a/test/compare_output.zig b/test/compare_output.zig
index c3da3cc4a5c0..7ff428fb336f 100644
--- a/test/compare_output.zig
+++ b/test/compare_output.zig
@@ -17,111 +17,6 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
\\}
, "Hello, world!" ++ std.cstr.line_sep);
- cases.addCase(x: {
- var tc = cases.create("multiple files with private function",
- \\usingnamespace @import("std").io;
- \\usingnamespace @import("foo.zig");
- \\
- \\pub fn main() void {
- \\ privateFunction();
- \\ const stdout = getStdOut().writer();
- \\ stdout.print("OK 2\n", .{}) catch unreachable;
- \\}
- \\
- \\fn privateFunction() void {
- \\ printText();
- \\}
- , "OK 1\nOK 2\n");
-
- tc.addSourceFile("foo.zig",
- \\usingnamespace @import("std").io;
- \\
- \\// purposefully conflicting function with main.zig
- \\// but it's private so it should be OK
- \\fn privateFunction() void {
- \\ const stdout = getStdOut().writer();
- \\ stdout.print("OK 1\n", .{}) catch unreachable;
- \\}
- \\
- \\pub fn printText() void {
- \\ privateFunction();
- \\}
- );
-
- break :x tc;
- });
-
- cases.addCase(x: {
- var tc = cases.create("import segregation",
- \\usingnamespace @import("foo.zig");
- \\usingnamespace @import("bar.zig");
- \\
- \\pub fn main() void {
- \\ foo_function();
- \\ bar_function();
- \\}
- , "OK\nOK\n");
-
- tc.addSourceFile("foo.zig",
- \\usingnamespace @import("std").io;
- \\pub fn foo_function() void {
- \\ const stdout = getStdOut().writer();
- \\ stdout.print("OK\n", .{}) catch unreachable;
- \\}
- );
-
- tc.addSourceFile("bar.zig",
- \\usingnamespace @import("other.zig");
- \\usingnamespace @import("std").io;
- \\
- \\pub fn bar_function() void {
- \\ if (foo_function()) {
- \\ const stdout = getStdOut().writer();
- \\ stdout.print("OK\n", .{}) catch unreachable;
- \\ }
- \\}
- );
-
- tc.addSourceFile("other.zig",
- \\pub fn foo_function() bool {
- \\ // this one conflicts with the one from foo
- \\ return true;
- \\}
- );
-
- break :x tc;
- });
-
- cases.addCase(x: {
- var tc = cases.create("two files usingnamespace import each other",
- \\usingnamespace @import("a.zig");
- \\
- \\pub fn main() void {
- \\ ok();
- \\}
- , "OK\n");
-
- tc.addSourceFile("a.zig",
- \\usingnamespace @import("b.zig");
- \\const io = @import("std").io;
- \\
- \\pub const a_text = "OK\n";
- \\
- \\pub fn ok() void {
- \\ const stdout = io.getStdOut().writer();
- \\ stdout.print(b_text, .{}) catch unreachable;
- \\}
- );
-
- tc.addSourceFile("b.zig",
- \\usingnamespace @import("a.zig");
- \\
- \\pub const b_text = a_text;
- );
-
- break :x tc;
- });
-
cases.add("hello world without libc",
\\const io = @import("std").io;
\\
diff --git a/test/compile_errors.zig b/test/compile_errors.zig
index 4c55e39ac7c7..9fd125a77596 100644
--- a/test/compile_errors.zig
+++ b/test/compile_errors.zig
@@ -243,9 +243,9 @@ pub fn addCases(ctx: *TestContext) !void {
ctx.objErrStage1("array in c exported function",
\\export fn zig_array(x: [10]u8) void {
- \\try expect(std.mem.eql(u8, &x, "1234567890"));
+ \\ try std.testing.expect(std.mem.eql(u8, &x, "1234567890"));
\\}
- \\
+ \\const std = @import("std");
\\export fn zig_return_array() [10]u8 {
\\ return "1234567890".*;
\\}
@@ -2787,6 +2787,7 @@ pub fn addCases(ctx: *TestContext) !void {
\\ _ = msg; _ = error_return_trace;
\\ while (true) {}
\\}
+ \\const builtin = @import("std").builtin;
, &[_][]const u8{
"error: expected type 'fn([]const u8, ?*std.builtin.StackTrace) noreturn', found 'fn([]const u8,anytype) anytype'",
"note: only one of the functions is generic",
@@ -2832,6 +2833,7 @@ pub fn addCases(ctx: *TestContext) !void {
\\ var s: Foo = Foo.E;
\\ _ = s;
\\}
+ \\const D = 1;
, &[_][]const u8{
"tmp.zig:1:17: error: enum 'Foo' depends on itself",
});
@@ -8846,4 +8848,14 @@ pub fn addCases(ctx: *TestContext) !void {
, &[_][]const u8{
"error: invalid operands to binary expression: 'f32' and 'f32'",
});
+
+ ctx.objErrStage1("undeclared identifier in unanalyzed branch",
+ \\export fn a() void {
+ \\ if (false) {
+ \\ lol_this_doesnt_exist = nonsense;
+ \\ }
+ \\}
+ , &[_][]const u8{
+ "tmp.zig:3:9: error: use of undeclared identifier 'lol_this_doesnt_exist'",
+ });
}
diff --git a/test/standalone/brace_expansion/main.zig b/test/standalone/brace_expansion/main.zig
index 990c2b16600a..35fe6e5c6a08 100644
--- a/test/standalone/brace_expansion/main.zig
+++ b/test/standalone/brace_expansion/main.zig
@@ -234,7 +234,7 @@ pub fn main() !void {
var result_buf = ArrayList(u8).init(global_allocator);
defer result_buf.deinit();
- try expandString(stdin_buf.items, &result_buf);
+ try expandString(stdin.items, &result_buf);
try stdout_file.write(result_buf.items);
}
diff --git a/test/translate_c.zig b/test/translate_c.zig
index 70ff464c8aa4..5ff6c22ead59 100644
--- a/test/translate_c.zig
+++ b/test/translate_c.zig
@@ -195,6 +195,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
cases.add("use cast param as macro fn return type",
\\#include
+ \\#define SYS_BASE_CACHED 0
\\#define MEM_PHYSICAL_TO_K0(x) (void*)((uint32_t)(x) + SYS_BASE_CACHED)
, &[_][]const u8{
\\pub inline fn MEM_PHYSICAL_TO_K0(x: anytype) ?*c_void {
@@ -228,6 +229,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
});
cases.add("macro expressions respect C operator precedence",
+ \\int *foo = 0;
\\#define FOO *((foo) + 2)
\\#define VALUE (1 + 2 * 3 + 4 * 5 + 6 << 7 | 8 == 9)
\\#define _AL_READ3BYTES(p) ((*(unsigned char *)(p)) \
@@ -363,6 +365,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
});
cases.add("correct semicolon after infixop",
+ \\#define _IO_ERR_SEEN 0
\\#define __ferror_unlocked_body(_fp) (((_fp)->_flags & _IO_ERR_SEEN) != 0)
, &[_][]const u8{
\\pub inline fn __ferror_unlocked_body(_fp: anytype) @TypeOf((_fp.*._flags & _IO_ERR_SEEN) != @as(c_int, 0)) {
@@ -429,6 +432,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
cases.add("macro comma operator",
\\#define foo (foo, bar)
+ \\int baz(int x, int y) { return 0; }
\\#define bar(x) (&x, +3, 4 == 4, 5 * 6, baz(1, 2), 2 % 2, baz(1,2))
, &[_][]const u8{
\\pub const foo = blk: {
@@ -459,6 +463,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
});
cases.add("macro line continuation",
+ \\int BAR = 0;
\\#define FOO -\
\\BAR
, &[_][]const u8{
@@ -1833,6 +1838,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
});
cases.add("macro pointer cast",
+ \\#define NRF_GPIO_BASE 0
\\typedef struct { int dummy; } NRF_GPIO_Type;
\\#define NRF_GPIO ((NRF_GPIO_Type *) NRF_GPIO_BASE)
, &[_][]const u8{
@@ -1873,6 +1879,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
});
cases.add("macro add",
+ \\#define D3_AHB1PERIPH_BASE 0
\\#define PERIPH_BASE (0x40000000UL) /*!< Base address of : AHB/APB Peripherals */
\\#define D3_APB1PERIPH_BASE (PERIPH_BASE + 0x18000000UL)
\\#define RCC_BASE (D3_AHB1PERIPH_BASE + 0x4400UL)
@@ -2569,6 +2576,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
cases.add("macro call",
\\#define CALL(arg) bar(arg)
+ \\int bar(int x) { return x; }
, &[_][]const u8{
\\pub inline fn CALL(arg: anytype) @TypeOf(bar(arg)) {
\\ return bar(arg);
@@ -2577,6 +2585,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
cases.add("macro call with no args",
\\#define CALL(arg) bar()
+ \\int bar(void) { return 0; }
, &[_][]const u8{
\\pub inline fn CALL(arg: anytype) @TypeOf(bar()) {
\\ _ = arg;
@@ -3135,9 +3144,11 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
cases.add("macro cast",
\\#include
+ \\int baz(void *arg) { return 0; }
\\#define FOO(bar) baz((void *)(baz))
\\#define BAR (void*) a
\\#define BAZ (uint32_t)(2)
+ \\#define a 2
, &[_][]const u8{
\\pub inline fn FOO(bar: anytype) @TypeOf(baz(@import("std").zig.c_translation.cast(?*c_void, baz))) {
\\ _ = bar;
@@ -3160,6 +3171,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
});
cases.add("macro conditional operator",
+ \\ int a, b, c;
\\#define FOO a ? b : c
, &[_][]const u8{
\\pub const FOO = if (a) b else c;
@@ -3469,11 +3481,10 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
\\pub const MAY_NEED_PROMOTION_OCT = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0o20000000000, .octal);
});
- // See __builtin_alloca_with_align comment in std.zig.c_builtins
cases.add("demote un-implemented builtins",
\\#define FOO(X) __builtin_alloca_with_align((X), 8)
, &[_][]const u8{
- \\pub const FOO = @compileError("TODO implement function '__builtin_alloca_with_align' in std.zig.c_builtins");
+ \\pub const FOO = @compileError("unable to translate macro: undefined identifier `__builtin_alloca_with_align`");
});
cases.add("null sentinel arrays when initialized from string literal. Issue #8256",
@@ -3649,4 +3660,28 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
,
\\_ = p[@intCast(c_uint, @as(c_int, 1))];
});
+
+ cases.add("Undefined macro identifier",
+ \\#define FOO BAR
+ , &[_][]const u8{
+ \\pub const FOO = @compileError("unable to translate macro: undefined identifier `BAR`");
+ });
+
+ cases.add("Macro redefines builtin",
+ \\#define FOO __builtin_popcount
+ , &[_][]const u8{
+ \\pub const FOO = __builtin_popcount;
+ });
+
+ cases.add("Only consider public decls in `isBuiltinDefined`",
+ \\#define FOO std
+ , &[_][]const u8{
+ \\pub const FOO = @compileError("unable to translate macro: undefined identifier `std`");
+ });
+
+ cases.add("Macro without a value",
+ \\#define FOO
+ , &[_][]const u8{
+ \\pub const FOO = "";
+ });
}
diff --git a/tools/update_clang_options.zig b/tools/update_clang_options.zig
index 04cdbf44de89..407e813ef3f3 100644
--- a/tools/update_clang_options.zig
+++ b/tools/update_clang_options.zig
@@ -473,7 +473,13 @@ pub fn main() anyerror!void {
try stdout.writeAll(
\\// This file is generated by tools/update_clang_options.zig.
\\// zig fmt: off
- \\usingnamespace @import("clang_options.zig");
+ \\const clang_options = @import("clang_options.zig");
+ \\const CliArg = clang_options.CliArg;
+ \\const flagpd1 = clang_options.flagpd1;
+ \\const flagpsl = clang_options.flagpsl;
+ \\const joinpd1 = clang_options.joinpd1;
+ \\const jspd1 = clang_options.jspd1;
+ \\const sepd1 = clang_options.sepd1;
\\pub const data = blk: { @setEvalBranchQuota(6000); break :blk &[_]CliArg{
\\
);