std: [breaking] move errno to become an nonexhaustive enum

The primary purpose of this change is to eliminate one usage of
`usingnamespace` in the standard library - specifically the usage for
errno values in `std.os.linux`.

This is accomplished by truncating the `E` prefix from error values, and
making errno a proper enum.

A similar strategy can be used to eliminate some other `usingnamespace`
sites in the std lib.
This commit is contained in:
Andrew Kelley 2021-08-23 17:06:56 -07:00
parent 9e3ec98937
commit a98fa56ae9
40 changed files with 3440 additions and 3379 deletions

View file

@ -426,7 +426,7 @@ set(ZIG_STAGE2_SOURCES
"${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/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"

View file

@ -9,9 +9,10 @@
//! both evented I/O and async I/O, see the respective names in the top level std namespace.
const std = @import("std.zig");
const builtin = @import("builtin");
const os = std.os;
const assert = std.debug.assert;
const target = std.Target.current;
const target = builtin.target;
const Atomic = std.atomic.Atomic;
pub const AutoResetEvent = @import("Thread/AutoResetEvent.zig");
@ -24,7 +25,8 @@ pub const Condition = @import("Thread/Condition.zig");
pub const spinLoopHint = @compileError("deprecated: use std.atomic.spinLoopHint");
pub const use_pthreads = target.os.tag != .windows and std.Target.current.os.tag != .wasi and std.builtin.link_libc;
pub const use_pthreads = target.os.tag != .windows and target.os.tag != .wasi and builtin.link_libc;
const is_gnu = target.abi.isGnu();
const Thread = @This();
const Impl = if (target.os.tag == .windows)
@ -38,7 +40,7 @@ else
impl: Impl,
pub const max_name_len = switch (std.Target.current.os.tag) {
pub const max_name_len = switch (target.os.tag) {
.linux => 15,
.windows => 31,
.macos, .ios, .watchos, .tvos => 63,
@ -64,20 +66,21 @@ pub fn setName(self: Thread, name: []const u8) SetNameError!void {
break :blk name_buf[0..name.len :0];
};
switch (std.Target.current.os.tag) {
switch (target.os.tag) {
.linux => if (use_pthreads) {
const err = std.c.pthread_setname_np(self.getHandle(), name_with_terminator.ptr);
return switch (err) {
0 => {},
os.ERANGE => unreachable,
else => return os.unexpectedErrno(err),
};
switch (err) {
.SUCCESS => return,
.RANGE => unreachable,
else => |e| return os.unexpectedErrno(e),
}
} else if (use_pthreads and self.getHandle() == std.c.pthread_self()) {
// TODO: this is dead code. what did the author of this code intend to happen here?
const err = try os.prctl(.SET_NAME, .{@ptrToInt(name_with_terminator.ptr)});
return switch (err) {
0 => {},
else => return os.unexpectedErrno(err),
};
switch (@intToEnum(os.E, err)) {
.SUCCESS => return,
else => |e| return os.unexpectedErrno(e),
}
} else {
var buf: [32]u8 = undefined;
const path = try std.fmt.bufPrint(&buf, "/proc/self/task/{d}/comm", .{self.getHandle()});
@ -87,7 +90,7 @@ pub fn setName(self: Thread, name: []const u8) SetNameError!void {
try file.writer().writeAll(name);
},
.windows => if (std.Target.current.os.isAtLeast(.windows, .win10_rs1)) |res| {
.windows => if (target.os.isAtLeast(.windows, .win10_rs1)) |res| {
// SetThreadDescription is only available since version 1607, which is 10.0.14393.795
// See https://en.wikipedia.org/wiki/Microsoft_Windows_SDK
if (!res) {
@ -110,24 +113,25 @@ pub fn setName(self: Thread, name: []const u8) SetNameError!void {
if (self.getHandle() != std.c.pthread_self()) return error.Unsupported;
const err = std.c.pthread_setname_np(name_with_terminator.ptr);
return switch (err) {
0 => {},
else => return os.unexpectedErrno(err),
};
switch (err) {
.SUCCESS => return,
else => |e| return os.unexpectedErrno(e),
}
},
.netbsd => if (use_pthreads) {
const err = std.c.pthread_setname_np(self.getHandle(), name_with_terminator.ptr, null);
return switch (err) {
0 => {},
os.EINVAL => unreachable,
os.ESRCH => unreachable,
os.ENOMEM => unreachable,
else => return os.unexpectedErrno(err),
};
switch (err) {
.SUCCESS => return,
.INVAL => unreachable,
.SRCH => unreachable,
.NOMEM => unreachable,
else => |e| return os.unexpectedErrno(e),
}
},
.freebsd, .openbsd => if (use_pthreads) {
// Use pthread_set_name_np for FreeBSD because pthread_setname_np is FreeBSD 12.2+ only.
// TODO maybe revisit this if depending on FreeBSD 12.2+ is acceptable because pthread_setname_np can return an error.
// TODO maybe revisit this if depending on FreeBSD 12.2+ is acceptable because
// pthread_setname_np can return an error.
std.c.pthread_set_name_np(self.getHandle(), name_with_terminator.ptr);
},
@ -151,20 +155,20 @@ pub fn getName(self: Thread, buffer_ptr: *[max_name_len:0]u8) GetNameError!?[]co
buffer_ptr[max_name_len] = 0;
var buffer = std.mem.span(buffer_ptr);
switch (std.Target.current.os.tag) {
.linux => if (use_pthreads and comptime std.Target.current.abi.isGnu()) {
switch (target.os.tag) {
.linux => if (use_pthreads and is_gnu) {
const err = std.c.pthread_getname_np(self.getHandle(), buffer.ptr, max_name_len + 1);
return switch (err) {
0 => std.mem.sliceTo(buffer, 0),
os.ERANGE => unreachable,
else => return os.unexpectedErrno(err),
};
switch (err) {
.SUCCESS => return std.mem.sliceTo(buffer, 0),
.RANGE => unreachable,
else => |e| return os.unexpectedErrno(e),
}
} else if (use_pthreads and self.getHandle() == std.c.pthread_self()) {
const err = try os.prctl(.GET_NAME, .{@ptrToInt(buffer.ptr)});
return switch (err) {
0 => std.mem.sliceTo(buffer, 0),
else => return os.unexpectedErrno(err),
};
switch (@intToEnum(os.E, err)) {
.SUCCESS => return std.mem.sliceTo(buffer, 0),
else => |e| return os.unexpectedErrno(e),
}
} else if (!use_pthreads) {
var buf: [32]u8 = undefined;
const path = try std.fmt.bufPrint(&buf, "/proc/self/task/{d}/comm", .{self.getHandle()});
@ -179,7 +183,7 @@ pub fn getName(self: Thread, buffer_ptr: *[max_name_len:0]u8) GetNameError!?[]co
// musl doesn't provide pthread_getname_np and there's no way to retrieve the thread id of an arbitrary thread.
return error.Unsupported;
},
.windows => if (std.Target.current.os.isAtLeast(.windows, .win10_rs1)) |res| {
.windows => if (target.os.isAtLeast(.windows, .win10_rs1)) |res| {
// GetThreadDescription is only available since version 1607, which is 10.0.14393.795
// See https://en.wikipedia.org/wiki/Microsoft_Windows_SDK
if (!res) {
@ -198,20 +202,20 @@ pub fn getName(self: Thread, buffer_ptr: *[max_name_len:0]u8) GetNameError!?[]co
},
.macos, .ios, .watchos, .tvos => if (use_pthreads) {
const err = std.c.pthread_getname_np(self.getHandle(), buffer.ptr, max_name_len + 1);
return switch (err) {
0 => std.mem.sliceTo(buffer, 0),
os.ESRCH => unreachable,
else => return os.unexpectedErrno(err),
};
switch (err) {
.SUCCESS => return std.mem.sliceTo(buffer, 0),
.SRCH => unreachable,
else => |e| return os.unexpectedErrno(e),
}
},
.netbsd => if (use_pthreads) {
const err = std.c.pthread_getname_np(self.getHandle(), buffer.ptr, max_name_len + 1);
return switch (err) {
0 => std.mem.sliceTo(buffer, 0),
os.EINVAL => unreachable,
os.ESRCH => unreachable,
else => return os.unexpectedErrno(err),
};
switch (err) {
.SUCCESS => return std.mem.sliceTo(buffer, 0),
.INVAL => unreachable,
.SRCH => unreachable,
else => |e| return os.unexpectedErrno(e),
}
},
.freebsd, .openbsd => if (use_pthreads) {
// Use pthread_get_name_np for FreeBSD because pthread_getname_np is FreeBSD 12.2+ only.
@ -288,7 +292,7 @@ pub const SpawnError = error{
/// The caller must eventually either call `join()` to wait for the thread to finish and free its resources
/// or call `detach()` to excuse the caller from calling `join()` and have the thread clean up its resources on completion`.
pub fn spawn(config: SpawnConfig, comptime function: anytype, args: anytype) SpawnError!Thread {
if (std.builtin.single_threaded) {
if (builtin.single_threaded) {
@compileError("Cannot spawn thread when building in single-threaded mode");
}
@ -611,13 +615,13 @@ const PosixThreadImpl = struct {
errdefer allocator.destroy(args_ptr);
var attr: c.pthread_attr_t = undefined;
if (c.pthread_attr_init(&attr) != 0) return error.SystemResources;
defer assert(c.pthread_attr_destroy(&attr) == 0);
if (c.pthread_attr_init(&attr) != .SUCCESS) return error.SystemResources;
defer assert(c.pthread_attr_destroy(&attr) == .SUCCESS);
// Use the same set of parameters used by the libc-less impl.
const stack_size = std.math.max(config.stack_size, 16 * 1024);
assert(c.pthread_attr_setstacksize(&attr, stack_size) == 0);
assert(c.pthread_attr_setguardsize(&attr, std.mem.page_size) == 0);
assert(c.pthread_attr_setstacksize(&attr, stack_size) == .SUCCESS);
assert(c.pthread_attr_setguardsize(&attr, std.mem.page_size) == .SUCCESS);
var handle: c.pthread_t = undefined;
switch (c.pthread_create(
@ -626,10 +630,10 @@ const PosixThreadImpl = struct {
Instance.entryFn,
if (@sizeOf(Args) > 1) @ptrCast(*c_void, args_ptr) else undefined,
)) {
0 => return Impl{ .handle = handle },
os.EAGAIN => return error.SystemResources,
os.EPERM => unreachable,
os.EINVAL => unreachable,
.SUCCESS => return Impl{ .handle = handle },
.AGAIN => return error.SystemResources,
.PERM => unreachable,
.INVAL => unreachable,
else => |err| return os.unexpectedErrno(err),
}
}
@ -640,19 +644,19 @@ const PosixThreadImpl = struct {
fn detach(self: Impl) void {
switch (c.pthread_detach(self.handle)) {
0 => {},
os.EINVAL => unreachable, // thread handle is not joinable
os.ESRCH => unreachable, // thread handle is invalid
.SUCCESS => {},
.INVAL => unreachable, // thread handle is not joinable
.SRCH => unreachable, // thread handle is invalid
else => unreachable,
}
}
fn join(self: Impl) void {
switch (c.pthread_join(self.handle, null)) {
0 => {},
os.EINVAL => unreachable, // thread handle is not joinable (or another thread is already joining in)
os.ESRCH => unreachable, // thread handle is invalid
os.EDEADLK => unreachable, // two threads tried to join each other
.SUCCESS => {},
.INVAL => unreachable, // thread handle is not joinable (or another thread is already joining in)
.SRCH => unreachable, // thread handle is invalid
.DEADLK => unreachable, // two threads tried to join each other
else => unreachable,
}
}
@ -937,13 +941,13 @@ const LinuxThreadImpl = struct {
tls_ptr,
&instance.thread.child_tid.value,
))) {
0 => return Impl{ .thread = &instance.thread },
os.EAGAIN => return error.ThreadQuotaExceeded,
os.EINVAL => unreachable,
os.ENOMEM => return error.SystemResources,
os.ENOSPC => unreachable,
os.EPERM => unreachable,
os.EUSERS => unreachable,
.SUCCESS => return Impl{ .thread = &instance.thread },
.AGAIN => return error.ThreadQuotaExceeded,
.INVAL => unreachable,
.NOMEM => return error.SystemResources,
.NOSPC => unreachable,
.PERM => unreachable,
.USERS => unreachable,
else => |err| return os.unexpectedErrno(err),
}
}
@ -982,9 +986,9 @@ const LinuxThreadImpl = struct {
tid,
null,
))) {
0 => continue,
os.EINTR => continue,
os.EAGAIN => continue,
.SUCCESS => continue,
.INTR => continue,
.AGAIN => continue,
else => unreachable,
}
}
@ -1011,7 +1015,7 @@ fn testThreadName(thread: *Thread) !void {
}
test "setName, getName" {
if (std.builtin.single_threaded) return error.SkipZigTest;
if (builtin.single_threaded) return error.SkipZigTest;
const Context = struct {
start_wait_event: ResetEvent = undefined,
@ -1029,7 +1033,7 @@ test "setName, getName" {
// Wait for the main thread to have set the thread field in the context.
ctx.start_wait_event.wait();
switch (std.Target.current.os.tag) {
switch (target.os.tag) {
.windows => testThreadName(&ctx.thread) catch |err| switch (err) {
error.Unsupported => return error.SkipZigTest,
else => return err,
@ -1054,7 +1058,7 @@ test "setName, getName" {
context.start_wait_event.set();
context.test_done_event.wait();
switch (std.Target.current.os.tag) {
switch (target.os.tag) {
.macos, .ios, .watchos, .tvos => {
const res = thread.setName("foobar");
try std.testing.expectError(error.Unsupported, res);
@ -1063,7 +1067,7 @@ test "setName, getName" {
error.Unsupported => return error.SkipZigTest,
else => return err,
},
else => |tag| if (tag == .linux and use_pthreads and comptime std.Target.current.abi.isMusl()) {
else => |tag| if (tag == .linux and use_pthreads and comptime target.abi.isMusl()) {
try thread.setName("foobar");
var name_buffer: [max_name_len:0]u8 = undefined;
@ -1096,7 +1100,7 @@ fn testIncrementNotify(value: *usize, event: *ResetEvent) void {
}
test "Thread.join" {
if (std.builtin.single_threaded) return error.SkipZigTest;
if (builtin.single_threaded) return error.SkipZigTest;
var value: usize = 0;
var event: ResetEvent = undefined;
@ -1110,7 +1114,7 @@ test "Thread.join" {
}
test "Thread.detach" {
if (std.builtin.single_threaded) return error.SkipZigTest;
if (builtin.single_threaded) return error.SkipZigTest;
var value: usize = 0;
var event: ResetEvent = undefined;

View file

@ -81,17 +81,17 @@ pub const PthreadCondition = struct {
pub fn wait(cond: *PthreadCondition, mutex: *Mutex) void {
const rc = std.c.pthread_cond_wait(&cond.cond, &mutex.impl.pthread_mutex);
assert(rc == 0);
assert(rc == .SUCCESS);
}
pub fn signal(cond: *PthreadCondition) void {
const rc = std.c.pthread_cond_signal(&cond.cond);
assert(rc == 0);
assert(rc == .SUCCESS);
}
pub fn broadcast(cond: *PthreadCondition) void {
const rc = std.c.pthread_cond_broadcast(&cond.cond);
assert(rc == 0);
assert(rc == .SUCCESS);
}
};
@ -115,9 +115,9 @@ pub const AtomicCondition = struct {
0,
null,
))) {
0 => {},
std.os.EINTR => {},
std.os.EAGAIN => {},
.SUCCESS => {},
.INTR => {},
.AGAIN => {},
else => unreachable,
}
},
@ -136,8 +136,8 @@ pub const AtomicCondition = struct {
linux.FUTEX_PRIVATE_FLAG | linux.FUTEX_WAKE,
1,
))) {
0 => {},
std.os.EFAULT => {},
.SUCCESS => {},
.FAULT => {},
else => unreachable,
}
},

View file

@ -152,12 +152,12 @@ const LinuxFutex = struct {
@bitCast(i32, expect),
ts_ptr,
))) {
0 => {}, // notified by `wake()`
std.os.EINTR => {}, // spurious wakeup
std.os.EAGAIN => {}, // ptr.* != expect
std.os.ETIMEDOUT => return error.TimedOut,
std.os.EINVAL => {}, // possibly timeout overflow
std.os.EFAULT => unreachable,
.SUCCESS => {}, // notified by `wake()`
.INTR => {}, // spurious wakeup
.AGAIN => {}, // ptr.* != expect
.TIMEDOUT => return error.TimedOut,
.INVAL => {}, // possibly timeout overflow
.FAULT => unreachable,
else => unreachable,
}
}
@ -168,9 +168,9 @@ const LinuxFutex = struct {
linux.FUTEX_PRIVATE_FLAG | linux.FUTEX_WAKE,
std.math.cast(i32, num_waiters) catch std.math.maxInt(i32),
))) {
0 => {}, // successful wake up
std.os.EINVAL => {}, // invalid futex_wait() on ptr done elsewhere
std.os.EFAULT => {}, // pointer became invalid while doing the wake
.SUCCESS => {}, // successful wake up
.INVAL => {}, // invalid futex_wait() on ptr done elsewhere
.FAULT => {}, // pointer became invalid while doing the wake
else => unreachable,
}
}
@ -215,13 +215,13 @@ const DarwinFutex = struct {
};
if (status >= 0) return;
switch (-status) {
darwin.EINTR => {},
switch (@intToEnum(std.os.E, -status)) {
.INTR => {},
// Address of the futex is paged out. This is unlikely, but possible in theory, and
// pthread/libdispatch on darwin bother to handle it. In this case we'll return
// without waiting, but the caller should retry anyway.
darwin.EFAULT => {},
darwin.ETIMEDOUT => if (!timeout_overflowed) return error.TimedOut,
.FAULT => {},
.TIMEDOUT => if (!timeout_overflowed) return error.TimedOut,
else => unreachable,
}
}
@ -237,11 +237,11 @@ const DarwinFutex = struct {
const status = darwin.__ulock_wake(flags, addr, 0);
if (status >= 0) return;
switch (-status) {
darwin.EINTR => continue, // spurious wake()
darwin.EFAULT => continue, // address of the lock was paged out
darwin.ENOENT => return, // nothing was woken up
darwin.EALREADY => unreachable, // only for ULF_WAKE_THREAD
switch (@intToEnum(std.os.E, -status)) {
.INTR => continue, // spurious wake()
.FAULT => continue, // address of the lock was paged out
.NOENT => return, // nothing was woken up
.ALREADY => unreachable, // only for ULF_WAKE_THREAD
else => unreachable,
}
}
@ -255,8 +255,8 @@ const PosixFutex = struct {
var waiter: List.Node = undefined;
{
assert(std.c.pthread_mutex_lock(&bucket.mutex) == 0);
defer assert(std.c.pthread_mutex_unlock(&bucket.mutex) == 0);
assert(std.c.pthread_mutex_lock(&bucket.mutex) == .SUCCESS);
defer assert(std.c.pthread_mutex_unlock(&bucket.mutex) == .SUCCESS);
if (ptr.load(.SeqCst) != expect) {
return;
@ -272,8 +272,8 @@ const PosixFutex = struct {
waiter.data.wait(null) catch unreachable;
};
assert(std.c.pthread_mutex_lock(&bucket.mutex) == 0);
defer assert(std.c.pthread_mutex_unlock(&bucket.mutex) == 0);
assert(std.c.pthread_mutex_lock(&bucket.mutex) == .SUCCESS);
defer assert(std.c.pthread_mutex_unlock(&bucket.mutex) == .SUCCESS);
if (waiter.data.address == address) {
timed_out = true;
@ -297,8 +297,8 @@ const PosixFutex = struct {
waiter.data.notify();
};
assert(std.c.pthread_mutex_lock(&bucket.mutex) == 0);
defer assert(std.c.pthread_mutex_unlock(&bucket.mutex) == 0);
assert(std.c.pthread_mutex_lock(&bucket.mutex) == .SUCCESS);
defer assert(std.c.pthread_mutex_unlock(&bucket.mutex) == .SUCCESS);
var waiters = bucket.list.first;
while (waiters) |waiter| {
@ -340,16 +340,13 @@ const PosixFutex = struct {
};
fn deinit(self: *Self) void {
const rc = std.c.pthread_cond_destroy(&self.cond);
assert(rc == 0 or rc == std.os.EINVAL);
const rm = std.c.pthread_mutex_destroy(&self.mutex);
assert(rm == 0 or rm == std.os.EINVAL);
_ = std.c.pthread_cond_destroy(&self.cond);
_ = std.c.pthread_mutex_destroy(&self.mutex);
}
fn wait(self: *Self, timeout: ?u64) error{TimedOut}!void {
assert(std.c.pthread_mutex_lock(&self.mutex) == 0);
defer assert(std.c.pthread_mutex_unlock(&self.mutex) == 0);
assert(std.c.pthread_mutex_lock(&self.mutex) == .SUCCESS);
defer assert(std.c.pthread_mutex_unlock(&self.mutex) == .SUCCESS);
switch (self.state) {
.empty => self.state = .waiting,
@ -378,28 +375,31 @@ const PosixFutex = struct {
}
const ts_ref = ts_ptr orelse {
assert(std.c.pthread_cond_wait(&self.cond, &self.mutex) == 0);
assert(std.c.pthread_cond_wait(&self.cond, &self.mutex) == .SUCCESS);
continue;
};
const rc = std.c.pthread_cond_timedwait(&self.cond, &self.mutex, ts_ref);
assert(rc == 0 or rc == std.os.ETIMEDOUT);
if (rc == std.os.ETIMEDOUT) {
self.state = .empty;
return error.TimedOut;
switch (rc) {
.SUCCESS => {},
.TIMEDOUT => {
self.state = .empty;
return error.TimedOut;
},
else => unreachable,
}
}
}
fn notify(self: *Self) void {
assert(std.c.pthread_mutex_lock(&self.mutex) == 0);
defer assert(std.c.pthread_mutex_unlock(&self.mutex) == 0);
assert(std.c.pthread_mutex_lock(&self.mutex) == .SUCCESS);
defer assert(std.c.pthread_mutex_unlock(&self.mutex) == .SUCCESS);
switch (self.state) {
.empty => self.state = .notified,
.waiting => {
self.state = .notified;
assert(std.c.pthread_cond_signal(&self.cond) == 0);
assert(std.c.pthread_cond_signal(&self.cond) == .SUCCESS);
},
.notified => unreachable,
}

View file

@ -143,9 +143,9 @@ pub const AtomicMutex = struct {
@enumToInt(new_state),
null,
))) {
0 => {},
std.os.EINTR => {},
std.os.EAGAIN => {},
.SUCCESS => {},
.INTR => {},
.AGAIN => {},
else => unreachable,
}
},
@ -164,8 +164,8 @@ pub const AtomicMutex = struct {
linux.FUTEX_PRIVATE_FLAG | linux.FUTEX_WAKE,
1,
))) {
0 => {},
std.os.EFAULT => {},
.SUCCESS => {},
.FAULT => unreachable, // invalid pointer passed to futex_wake
else => unreachable,
}
},
@ -182,10 +182,10 @@ pub const PthreadMutex = struct {
pub fn release(held: Held) void {
switch (std.c.pthread_mutex_unlock(&held.mutex.pthread_mutex)) {
0 => return,
std.c.EINVAL => unreachable,
std.c.EAGAIN => unreachable,
std.c.EPERM => unreachable,
.SUCCESS => return,
.INVAL => unreachable,
.AGAIN => unreachable,
.PERM => unreachable,
else => unreachable,
}
}
@ -195,7 +195,7 @@ pub const PthreadMutex = struct {
/// the mutex is unavailable. Otherwise returns Held. Call
/// release on Held.
pub fn tryAcquire(m: *PthreadMutex) ?Held {
if (std.c.pthread_mutex_trylock(&m.pthread_mutex) == 0) {
if (std.c.pthread_mutex_trylock(&m.pthread_mutex) == .SUCCESS) {
return Held{ .mutex = m };
} else {
return null;
@ -206,12 +206,12 @@ pub const PthreadMutex = struct {
/// held by the calling thread.
pub fn acquire(m: *PthreadMutex) Held {
switch (std.c.pthread_mutex_lock(&m.pthread_mutex)) {
0 => return Held{ .mutex = m },
std.c.EINVAL => unreachable,
std.c.EBUSY => unreachable,
std.c.EAGAIN => unreachable,
std.c.EDEADLK => unreachable,
std.c.EPERM => unreachable,
.SUCCESS => return Held{ .mutex = m },
.INVAL => unreachable,
.BUSY => unreachable,
.AGAIN => unreachable,
.DEADLK => unreachable,
.PERM => unreachable,
else => unreachable,
}
}

View file

@ -130,7 +130,7 @@ pub const PosixEvent = struct {
pub fn init(ev: *PosixEvent) !void {
switch (c.getErrno(c.sem_init(&ev.sem, 0, 0))) {
0 => return,
.SUCCESS => return,
else => return error.SystemResources,
}
}
@ -147,9 +147,9 @@ pub const PosixEvent = struct {
pub fn wait(ev: *PosixEvent) void {
while (true) {
switch (c.getErrno(c.sem_wait(&ev.sem))) {
0 => return,
c.EINTR => continue,
c.EINVAL => unreachable,
.SUCCESS => return,
.INTR => continue,
.INVAL => unreachable,
else => unreachable,
}
}
@ -165,10 +165,10 @@ pub const PosixEvent = struct {
ts.tv_nsec = @intCast(@TypeOf(ts.tv_nsec), @mod(timeout_abs, time.ns_per_s));
while (true) {
switch (c.getErrno(c.sem_timedwait(&ev.sem, &ts))) {
0 => return .event_set,
c.EINTR => continue,
c.EINVAL => unreachable,
c.ETIMEDOUT => return .timed_out,
.SUCCESS => return .event_set,
.INTR => continue,
.INVAL => unreachable,
.TIMEDOUT => return .timed_out,
else => unreachable,
}
}
@ -177,10 +177,10 @@ pub const PosixEvent = struct {
pub fn reset(ev: *PosixEvent) void {
while (true) {
switch (c.getErrno(c.sem_trywait(&ev.sem))) {
0 => continue, // Need to make it go to zero.
c.EINTR => continue,
c.EINVAL => unreachable,
c.EAGAIN => return, // The semaphore currently has the value zero.
.SUCCESS => continue, // Need to make it go to zero.
.INTR => continue,
.INVAL => unreachable,
.AGAIN => return, // The semaphore currently has the value zero.
else => unreachable,
}
}

View file

@ -13,7 +13,7 @@ impl: Impl,
const RwLock = @This();
const std = @import("../std.zig");
const builtin = std.builtin;
const builtin = @import("builtin");
const assert = std.debug.assert;
const Mutex = std.Thread.Mutex;
const Semaphore = std.Semaphore;
@ -165,43 +165,41 @@ pub const PthreadRwLock = struct {
}
pub fn deinit(rwl: *PthreadRwLock) void {
const safe_rc = switch (std.builtin.os.tag) {
.dragonfly, .netbsd => std.os.EAGAIN,
else => 0,
const safe_rc: std.os.E = switch (builtin.os.tag) {
.dragonfly, .netbsd => .AGAIN,
else => .SUCCESS,
};
const rc = std.c.pthread_rwlock_destroy(&rwl.rwlock);
assert(rc == 0 or rc == safe_rc);
assert(rc == .SUCCESS or rc == safe_rc);
rwl.* = undefined;
}
pub fn tryLock(rwl: *PthreadRwLock) bool {
return pthread_rwlock_trywrlock(&rwl.rwlock) == 0;
return pthread_rwlock_trywrlock(&rwl.rwlock) == .SUCCESS;
}
pub fn lock(rwl: *PthreadRwLock) void {
const rc = pthread_rwlock_wrlock(&rwl.rwlock);
assert(rc == 0);
assert(rc == .SUCCESS);
}
pub fn unlock(rwl: *PthreadRwLock) void {
const rc = pthread_rwlock_unlock(&rwl.rwlock);
assert(rc == 0);
assert(rc == .SUCCESS);
}
pub fn tryLockShared(rwl: *PthreadRwLock) bool {
return pthread_rwlock_tryrdlock(&rwl.rwlock) == 0;
return pthread_rwlock_tryrdlock(&rwl.rwlock) == .SUCCESS;
}
pub fn lockShared(rwl: *PthreadRwLock) void {
const rc = pthread_rwlock_rdlock(&rwl.rwlock);
assert(rc == 0);
assert(rc == .SUCCESS);
}
pub fn unlockShared(rwl: *PthreadRwLock) void {
const rc = pthread_rwlock_unlock(&rwl.rwlock);
assert(rc == 0);
assert(rc == .SUCCESS);
}
};

View file

@ -201,7 +201,7 @@ pub const AtomicEvent = struct {
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);
assert(linux.getErrno(rc) == 0);
assert(linux.getErrno(rc) == .SUCCESS);
}
fn wait(waiters: *u32, timeout: ?u64) !void {
@ -221,10 +221,10 @@ pub const AtomicEvent = struct {
const ptr = @ptrCast(*const i32, waiters);
const rc = linux.futex_wait(ptr, linux.FUTEX_WAIT | linux.FUTEX_PRIVATE_FLAG, expected, ts_ptr);
switch (linux.getErrno(rc)) {
0 => continue,
os.ETIMEDOUT => return error.TimedOut,
os.EINTR => continue,
os.EAGAIN => return,
.SUCCESS => continue,
.TIMEDOUT => return error.TimedOut,
.INTR => continue,
.AGAIN => return,
else => unreachable,
}
}

View file

@ -35,11 +35,11 @@ pub usingnamespace switch (std.Target.current.os.tag) {
else => struct {},
};
pub fn getErrno(rc: anytype) c_int {
pub fn getErrno(rc: anytype) E {
if (rc == -1) {
return _errno().*;
return @intToEnum(E, _errno().*);
} else {
return 0;
return .SUCCESS;
}
}
@ -270,22 +270,22 @@ pub extern "c" fn utimes(path: [*:0]const u8, times: *[2]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 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) c_int;
pub extern "c" fn pthread_attr_init(attr: *pthread_attr_t) c_int;
pub extern "c" fn pthread_attr_setstack(attr: *pthread_attr_t, stackaddr: *c_void, stacksize: usize) c_int;
pub extern "c" fn pthread_attr_setstacksize(attr: *pthread_attr_t, stacksize: usize) c_int;
pub extern "c" fn pthread_attr_setguardsize(attr: *pthread_attr_t, guardsize: usize) c_int;
pub extern "c" fn pthread_attr_destroy(attr: *pthread_attr_t) 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_self() pthread_t;
pub extern "c" fn pthread_join(thread: pthread_t, arg_return: ?*?*c_void) c_int;
pub extern "c" fn pthread_detach(thread: pthread_t) c_int;
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_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) c_int;
pub extern "c" fn pthread_key_delete(key: pthread_key_t) 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;
@ -339,24 +339,24 @@ pub extern "c" fn dn_expand(
) c_int;
pub const PTHREAD_MUTEX_INITIALIZER = pthread_mutex_t{};
pub extern "c" fn pthread_mutex_lock(mutex: *pthread_mutex_t) c_int;
pub extern "c" fn pthread_mutex_unlock(mutex: *pthread_mutex_t) c_int;
pub extern "c" fn pthread_mutex_trylock(mutex: *pthread_mutex_t) c_int;
pub extern "c" fn pthread_mutex_destroy(mutex: *pthread_mutex_t) c_int;
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) c_int;
pub extern "c" fn pthread_cond_timedwait(noalias cond: *pthread_cond_t, noalias mutex: *pthread_mutex_t, noalias abstime: *const timespec) c_int;
pub extern "c" fn pthread_cond_signal(cond: *pthread_cond_t) c_int;
pub extern "c" fn pthread_cond_broadcast(cond: *pthread_cond_t) c_int;
pub extern "c" fn pthread_cond_destroy(cond: *pthread_cond_t) c_int;
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) c_int;
pub extern "c" fn pthread_rwlock_rdlock(rwl: *pthread_rwlock_t) callconv(.C) c_int;
pub extern "c" fn pthread_rwlock_wrlock(rwl: *pthread_rwlock_t) callconv(.C) c_int;
pub extern "c" fn pthread_rwlock_tryrdlock(rwl: *pthread_rwlock_t) callconv(.C) c_int;
pub extern "c" fn pthread_rwlock_trywrlock(rwl: *pthread_rwlock_t) callconv(.C) c_int;
pub extern "c" fn pthread_rwlock_unlock(rwl: *pthread_rwlock_t) callconv(.C) c_int;
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_t = *opaque {};
pub const FILE = opaque {};

View file

@ -193,8 +193,8 @@ pub const pthread_attr_t = extern struct {
const pthread_t = std.c.pthread_t;
pub extern "c" fn pthread_threadid_np(thread: ?pthread_t, thread_id: *u64) c_int;
pub extern "c" fn pthread_setname_np(name: [*:0]const u8) c_int;
pub extern "c" fn pthread_getname_np(thread: std.c.pthread_t, name: [*:0]u8, len: usize) c_int;
pub extern "c" fn pthread_setname_np(name: [*:0]const u8) E;
pub extern "c" fn pthread_getname_np(thread: std.c.pthread_t, name: [*:0]u8, len: usize) E;
pub extern "c" fn arc4random_buf(buf: [*]u8, len: usize) void;

View file

@ -186,8 +186,8 @@ const __SIZEOF_PTHREAD_MUTEX_T = if (os_tag == .fuchsia) 40 else switch (abi) {
};
const __SIZEOF_SEM_T = 4 * @sizeOf(usize);
pub extern "c" fn pthread_setname_np(thread: std.c.pthread_t, name: [*:0]const u8) c_int;
pub extern "c" fn pthread_getname_np(thread: std.c.pthread_t, name: [*:0]u8, len: usize) c_int;
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;

View file

@ -95,5 +95,5 @@ pub const pthread_attr_t = extern struct {
pub const sem_t = ?*opaque {};
pub extern "c" fn pthread_setname_np(thread: std.c.pthread_t, name: [*:0]const u8, arg: ?*c_void) c_int;
pub extern "c" fn pthread_getname_np(thread: std.c.pthread_t, name: [*:0]u8, len: usize) c_int;
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;

View file

@ -339,10 +339,10 @@ pub const Dir = struct {
if (rc == 0) return null;
if (rc < 0) {
switch (os.errno(rc)) {
os.EBADF => unreachable, // Dir is invalid or was opened without iteration ability
os.EFAULT => unreachable,
os.ENOTDIR => unreachable,
os.EINVAL => unreachable,
.BADF => unreachable, // Dir is invalid or was opened without iteration ability
.FAULT => unreachable,
.NOTDIR => unreachable,
.INVAL => unreachable,
else => |err| return os.unexpectedErrno(err),
}
}
@ -385,11 +385,11 @@ pub const Dir = struct {
else
os.system.getdents(self.dir.fd, &self.buf, self.buf.len);
switch (os.errno(rc)) {
0 => {},
os.EBADF => unreachable, // Dir is invalid or was opened without iteration ability
os.EFAULT => unreachable,
os.ENOTDIR => unreachable,
os.EINVAL => unreachable,
.SUCCESS => {},
.BADF => unreachable, // Dir is invalid or was opened without iteration ability
.FAULT => unreachable,
.NOTDIR => unreachable,
.INVAL => unreachable,
else => |err| return os.unexpectedErrno(err),
}
if (rc == 0) return null;
@ -457,10 +457,10 @@ pub const Dir = struct {
if (rc == 0) return null;
if (rc < 0) {
switch (os.errno(rc)) {
os.EBADF => unreachable, // Dir is invalid or was opened without iteration ability
os.EFAULT => unreachable,
os.ENOTDIR => unreachable,
os.EINVAL => unreachable,
.BADF => unreachable, // Dir is invalid or was opened without iteration ability
.FAULT => unreachable,
.NOTDIR => unreachable,
.INVAL => unreachable,
else => |err| return os.unexpectedErrno(err),
}
}
@ -522,11 +522,11 @@ pub const Dir = struct {
if (self.index >= self.end_index) {
const rc = os.linux.getdents64(self.dir.fd, &self.buf, self.buf.len);
switch (os.linux.getErrno(rc)) {
0 => {},
os.EBADF => unreachable, // Dir is invalid or was opened without iteration ability
os.EFAULT => unreachable,
os.ENOTDIR => unreachable,
os.EINVAL => unreachable,
.SUCCESS => {},
.BADF => unreachable, // Dir is invalid or was opened without iteration ability
.FAULT => unreachable,
.NOTDIR => unreachable,
.INVAL => unreachable,
else => |err| return os.unexpectedErrno(err),
}
if (rc == 0) return null;
@ -655,12 +655,12 @@ pub const Dir = struct {
if (self.index >= self.end_index) {
var bufused: usize = undefined;
switch (w.fd_readdir(self.dir.fd, &self.buf, self.buf.len, self.cookie, &bufused)) {
w.ESUCCESS => {},
w.EBADF => unreachable, // Dir is invalid or was opened without iteration ability
w.EFAULT => unreachable,
w.ENOTDIR => unreachable,
w.EINVAL => unreachable,
w.ENOTCAPABLE => return error.AccessDenied,
.SUCCESS => {},
.BADF => unreachable, // Dir is invalid or was opened without iteration ability
.FAULT => unreachable,
.NOTDIR => unreachable,
.INVAL => unreachable,
.NOTCAPABLE => return error.AccessDenied,
else => |err| return os.unexpectedErrno(err),
}
if (bufused == 0) return null;
@ -2557,12 +2557,12 @@ fn copy_file(fd_in: os.fd_t, fd_out: os.fd_t) CopyFileError!void {
if (comptime std.Target.current.isDarwin()) {
const rc = os.system.fcopyfile(fd_in, fd_out, null, os.system.COPYFILE_DATA);
switch (os.errno(rc)) {
0 => return,
os.EINVAL => unreachable,
os.ENOMEM => return error.SystemResources,
.SUCCESS => return,
.INVAL => unreachable,
.NOMEM => return error.SystemResources,
// The source file is not a directory, symbolic link, or regular file.
// Try with the fallback path before giving up.
os.ENOTSUP => {},
.OPNOTSUPP => {},
else => |err| return os.unexpectedErrno(err),
}
}

View file

@ -121,13 +121,13 @@ pub const PreopenList = struct {
while (true) {
var buf: prestat_t = undefined;
switch (fd_prestat_get(fd, &buf)) {
ESUCCESS => {},
ENOTSUP => {
.SUCCESS => {},
.OPNOTSUPP => {
// not a preopen, so keep going
fd = try math.add(fd_t, fd, 1);
continue;
},
EBADF => {
.BADF => {
// OK, no more fds available
break;
},
@ -137,7 +137,7 @@ pub const PreopenList = struct {
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)) {
ESUCCESS => {},
.SUCCESS => {},
else => |err| return os.unexpectedErrno(err),
}
const preopen = Preopen.new(fd, PreopenType{ .Dir = path_buf });

View file

@ -17,19 +17,19 @@ pub fn cWriter(c_file: *std.c.FILE) CWriter {
fn cWriterWrite(c_file: *std.c.FILE, bytes: []const u8) std.fs.File.WriteError!usize {
const amt_written = std.c.fwrite(bytes.ptr, 1, bytes.len, c_file);
if (amt_written >= 0) return amt_written;
switch (std.c._errno().*) {
0 => unreachable,
os.EINVAL => unreachable,
os.EFAULT => unreachable,
os.EAGAIN => unreachable, // this is a blocking API
os.EBADF => unreachable, // always a race condition
os.EDESTADDRREQ => unreachable, // connect was never called
os.EDQUOT => return error.DiskQuota,
os.EFBIG => return error.FileTooBig,
os.EIO => return error.InputOutput,
os.ENOSPC => return error.NoSpaceLeft,
os.EPERM => return error.AccessDenied,
os.EPIPE => return error.BrokenPipe,
switch (@intToEnum(os.E, std.c._errno().*)) {
.SUCCESS => unreachable,
.INVAL => unreachable,
.FAULT => unreachable,
.AGAIN => unreachable, // this is a blocking API
.BADF => unreachable, // always a race condition
.DESTADDRREQ => unreachable, // connect was never called
.DQUOT => return error.DiskQuota,
.FBIG => return error.FileTooBig,
.IO => return error.InputOutput,
.NOSPC => return error.NoSpaceLeft,
.PERM => return error.AccessDenied,
.PIPE => return error.BrokenPipe,
else => |err| return os.unexpectedErrno(err),
}
}

File diff suppressed because it is too large Load diff

View file

@ -866,337 +866,342 @@ pub fn WIFSIGNALED(x: u32) bool {
return wstatus(x) != wstopped and wstatus(x) != 0;
}
/// Operation not permitted
pub const EPERM = 1;
pub const E = enum(u16) {
/// No error occurred.
SUCCESS = 0,
/// No such file or directory
pub const ENOENT = 2;
/// Operation not permitted
PERM = 1,
/// No such process
pub const ESRCH = 3;
/// No such file or directory
NOENT = 2,
/// Interrupted system call
pub const EINTR = 4;
/// No such process
SRCH = 3,
/// Input/output error
pub const EIO = 5;
/// Interrupted system call
INTR = 4,
/// Device not configured
pub const ENXIO = 6;
/// Input/output error
IO = 5,
/// Argument list too long
pub const E2BIG = 7;
/// Device not configured
NXIO = 6,
/// Exec format error
pub const ENOEXEC = 8;
/// Argument list too long
@"2BIG" = 7,
/// Bad file descriptor
pub const EBADF = 9;
/// Exec format error
NOEXEC = 8,
/// No child processes
pub const ECHILD = 10;
/// Bad file descriptor
BADF = 9,
/// Resource deadlock avoided
pub const EDEADLK = 11;
/// No child processes
CHILD = 10,
/// Cannot allocate memory
pub const ENOMEM = 12;
/// Resource deadlock avoided
DEADLK = 11,
/// Permission denied
pub const EACCES = 13;
/// Cannot allocate memory
NOMEM = 12,
/// Bad address
pub const EFAULT = 14;
/// Permission denied
ACCES = 13,
/// Block device required
pub const ENOTBLK = 15;
/// Bad address
FAULT = 14,
/// Device / Resource busy
pub const EBUSY = 16;
/// Block device required
NOTBLK = 15,
/// File exists
pub const EEXIST = 17;
/// Device / Resource busy
BUSY = 16,
/// Cross-device link
pub const EXDEV = 18;
/// File exists
EXIST = 17,
/// Operation not supported by device
pub const ENODEV = 19;
/// Cross-device link
XDEV = 18,
/// Not a directory
pub const ENOTDIR = 20;
/// Operation not supported by device
NODEV = 19,
/// Is a directory
pub const EISDIR = 21;
/// Not a directory
NOTDIR = 20,
/// Invalid argument
pub const EINVAL = 22;
/// Is a directory
ISDIR = 21,
/// Too many open files in system
pub const ENFILE = 23;
/// Invalid argument
INVAL = 22,
/// Too many open files
pub const EMFILE = 24;
/// Too many open files in system
NFILE = 23,
/// Inappropriate ioctl for device
pub const ENOTTY = 25;
/// Too many open files
MFILE = 24,
/// Text file busy
pub const ETXTBSY = 26;
/// Inappropriate ioctl for device
NOTTY = 25,
/// File too large
pub const EFBIG = 27;
/// Text file busy
TXTBSY = 26,
/// No space left on device
pub const ENOSPC = 28;
/// File too large
FBIG = 27,
/// Illegal seek
pub const ESPIPE = 29;
/// No space left on device
NOSPC = 28,
/// Read-only file system
pub const EROFS = 30;
/// Illegal seek
SPIPE = 29,
/// Too many links
pub const EMLINK = 31;
/// Broken pipe
/// Read-only file system
ROFS = 30,
// math software
pub const EPIPE = 32;
/// Too many links
MLINK = 31,
/// Numerical argument out of domain
pub const EDOM = 33;
/// Result too large
/// Broken pipe
PIPE = 32,
// non-blocking and interrupt i/o
pub const ERANGE = 34;
// math software
/// Resource temporarily unavailable
pub const EAGAIN = 35;
/// Numerical argument out of domain
DOM = 33,
/// Operation would block
pub const EWOULDBLOCK = EAGAIN;
/// Result too large
RANGE = 34,
/// Operation now in progress
pub const EINPROGRESS = 36;
/// Operation already in progress
// non-blocking and interrupt i/o
// ipc/network software -- argument errors
pub const EALREADY = 37;
/// Resource temporarily unavailable
/// This is the same code used for `WOULDBLOCK`.
AGAIN = 35,
/// Socket operation on non-socket
pub const ENOTSOCK = 38;
/// Operation now in progress
INPROGRESS = 36,
/// Destination address required
pub const EDESTADDRREQ = 39;
/// Operation already in progress
ALREADY = 37,
/// Message too long
pub const EMSGSIZE = 40;
// ipc/network software -- argument errors
/// Protocol wrong type for socket
pub const EPROTOTYPE = 41;
/// Socket operation on non-socket
NOTSOCK = 38,
/// Protocol not available
pub const ENOPROTOOPT = 42;
/// Destination address required
DESTADDRREQ = 39,
/// Protocol not supported
pub const EPROTONOSUPPORT = 43;
/// Message too long
MSGSIZE = 40,
/// Socket type not supported
pub const ESOCKTNOSUPPORT = 44;
/// Protocol wrong type for socket
PROTOTYPE = 41,
/// Operation not supported
pub const ENOTSUP = 45;
/// Protocol not available
NOPROTOOPT = 42,
/// Operation not supported. Alias of `ENOTSUP`.
pub const EOPNOTSUPP = ENOTSUP;
/// Protocol not supported
PROTONOSUPPORT = 43,
/// Protocol family not supported
pub const EPFNOSUPPORT = 46;
/// Socket type not supported
SOCKTNOSUPPORT = 44,
/// Address family not supported by protocol family
pub const EAFNOSUPPORT = 47;
/// Operation not supported
/// The same code is used for `NOTSUP`.
OPNOTSUPP = 45,
/// Address already in use
pub const EADDRINUSE = 48;
/// Can't assign requested address
/// Protocol family not supported
PFNOSUPPORT = 46,
// ipc/network software -- operational errors
pub const EADDRNOTAVAIL = 49;
/// Address family not supported by protocol family
AFNOSUPPORT = 47,
/// Network is down
pub const ENETDOWN = 50;
/// Address already in use
ADDRINUSE = 48,
/// Can't assign requested address
/// Network is unreachable
pub const ENETUNREACH = 51;
// ipc/network software -- operational errors
ADDRNOTAVAIL = 49,
/// Network dropped connection on reset
pub const ENETRESET = 52;
/// Network is down
NETDOWN = 50,
/// Software caused connection abort
pub const ECONNABORTED = 53;
/// Network is unreachable
NETUNREACH = 51,
/// Connection reset by peer
pub const ECONNRESET = 54;
/// Network dropped connection on reset
NETRESET = 52,
/// No buffer space available
pub const ENOBUFS = 55;
/// Software caused connection abort
CONNABORTED = 53,
/// Socket is already connected
pub const EISCONN = 56;
/// Connection reset by peer
CONNRESET = 54,
/// Socket is not connected
pub const ENOTCONN = 57;
/// No buffer space available
NOBUFS = 55,
/// Can't send after socket shutdown
pub const ESHUTDOWN = 58;
/// Socket is already connected
ISCONN = 56,
/// Too many references: can't splice
pub const ETOOMANYREFS = 59;
/// Socket is not connected
NOTCONN = 57,
/// Operation timed out
pub const ETIMEDOUT = 60;
/// Can't send after socket shutdown
SHUTDOWN = 58,
/// Connection refused
pub const ECONNREFUSED = 61;
/// Too many references: can't splice
TOOMANYREFS = 59,
/// Too many levels of symbolic links
pub const ELOOP = 62;
/// Operation timed out
TIMEDOUT = 60,
/// File name too long
pub const ENAMETOOLONG = 63;
/// Connection refused
CONNREFUSED = 61,
/// Host is down
pub const EHOSTDOWN = 64;
/// Too many levels of symbolic links
LOOP = 62,
/// No route to host
pub const EHOSTUNREACH = 65;
/// Directory not empty
/// File name too long
NAMETOOLONG = 63,
// quotas & mush
pub const ENOTEMPTY = 66;
/// Host is down
HOSTDOWN = 64,
/// Too many processes
pub const EPROCLIM = 67;
/// No route to host
HOSTUNREACH = 65,
/// Directory not empty
/// Too many users
pub const EUSERS = 68;
/// Disc quota exceeded
// quotas & mush
NOTEMPTY = 66,
// Network File System
pub const EDQUOT = 69;
/// Too many processes
PROCLIM = 67,
/// Stale NFS file handle
pub const ESTALE = 70;
/// Too many users
USERS = 68,
/// Disc quota exceeded
/// Too many levels of remote in path
pub const EREMOTE = 71;
// Network File System
DQUOT = 69,
/// RPC struct is bad
pub const EBADRPC = 72;
/// Stale NFS file handle
STALE = 70,
/// RPC version wrong
pub const ERPCMISMATCH = 73;
/// Too many levels of remote in path
REMOTE = 71,
/// RPC prog. not avail
pub const EPROGUNAVAIL = 74;
/// RPC struct is bad
BADRPC = 72,
/// Program version wrong
pub const EPROGMISMATCH = 75;
/// RPC version wrong
RPCMISMATCH = 73,
/// Bad procedure for program
pub const EPROCUNAVAIL = 76;
/// RPC prog. not avail
PROGUNAVAIL = 74,
/// No locks available
pub const ENOLCK = 77;
/// Program version wrong
PROGMISMATCH = 75,
/// Function not implemented
pub const ENOSYS = 78;
/// Bad procedure for program
PROCUNAVAIL = 76,
/// Inappropriate file type or format
pub const EFTYPE = 79;
/// No locks available
NOLCK = 77,
/// Authentication error
pub const EAUTH = 80;
/// Need authenticator
/// Function not implemented
NOSYS = 78,
// Intelligent device errors
pub const ENEEDAUTH = 81;
/// Inappropriate file type or format
FTYPE = 79,
/// Device power is off
pub const EPWROFF = 82;
/// Authentication error
AUTH = 80,
/// Device error, e.g. paper out
pub const EDEVERR = 83;
/// Value too large to be stored in data type
/// Need authenticator
NEEDAUTH = 81,
// Program loading errors
pub const EOVERFLOW = 84;
// Intelligent device errors
/// Bad executable
pub const EBADEXEC = 85;
/// Device power is off
PWROFF = 82,
/// Bad CPU type in executable
pub const EBADARCH = 86;
/// Device error, e.g. paper out
DEVERR = 83,
/// Shared library version mismatch
pub const ESHLIBVERS = 87;
/// Value too large to be stored in data type
OVERFLOW = 84,
/// Malformed Macho file
pub const EBADMACHO = 88;
// Program loading errors
/// Operation canceled
pub const ECANCELED = 89;
/// Bad executable
BADEXEC = 85,
/// Identifier removed
pub const EIDRM = 90;
/// Bad CPU type in executable
BADARCH = 86,
/// No message of desired type
pub const ENOMSG = 91;
/// Shared library version mismatch
SHLIBVERS = 87,
/// Illegal byte sequence
pub const EILSEQ = 92;
/// Malformed Macho file
BADMACHO = 88,
/// Attribute not found
pub const ENOATTR = 93;
/// Operation canceled
CANCELED = 89,
/// Bad message
pub const EBADMSG = 94;
/// Identifier removed
IDRM = 90,
/// Reserved
pub const EMULTIHOP = 95;
/// No message of desired type
NOMSG = 91,
/// No message available on STREAM
pub const ENODATA = 96;
/// Illegal byte sequence
ILSEQ = 92,
/// Reserved
pub const ENOLINK = 97;
/// Attribute not found
NOATTR = 93,
/// No STREAM resources
pub const ENOSR = 98;
/// Bad message
BADMSG = 94,
/// Not a STREAM
pub const ENOSTR = 99;
/// Reserved
MULTIHOP = 95,
/// Protocol error
pub const EPROTO = 100;
/// No message available on STREAM
NODATA = 96,
/// STREAM ioctl timeout
pub const ETIME = 101;
/// Reserved
NOLINK = 97,
/// No such policy registered
pub const ENOPOLICY = 103;
/// No STREAM resources
NOSR = 98,
/// State not recoverable
pub const ENOTRECOVERABLE = 104;
/// Not a STREAM
NOSTR = 99,
/// Previous owner died
pub const EOWNERDEAD = 105;
/// Protocol error
PROTO = 100,
/// Interface output queue is full
pub const EQFULL = 106;
/// STREAM ioctl timeout
TIME = 101,
/// Must be equal largest errno
pub const ELAST = 106;
/// 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;

View file

@ -25,103 +25,108 @@ pub const gid_t = u32;
pub const time_t = isize;
pub const suseconds_t = c_long;
pub const ENOTSUP = EOPNOTSUPP;
pub const EWOULDBLOCK = EAGAIN;
pub const EPERM = 1;
pub const ENOENT = 2;
pub const ESRCH = 3;
pub const EINTR = 4;
pub const EIO = 5;
pub const ENXIO = 6;
pub const E2BIG = 7;
pub const ENOEXEC = 8;
pub const EBADF = 9;
pub const ECHILD = 10;
pub const EDEADLK = 11;
pub const ENOMEM = 12;
pub const EACCES = 13;
pub const EFAULT = 14;
pub const ENOTBLK = 15;
pub const EBUSY = 16;
pub const EEXIST = 17;
pub const EXDEV = 18;
pub const ENODEV = 19;
pub const ENOTDIR = 20;
pub const EISDIR = 21;
pub const EINVAL = 22;
pub const ENFILE = 23;
pub const EMFILE = 24;
pub const ENOTTY = 25;
pub const ETXTBSY = 26;
pub const EFBIG = 27;
pub const ENOSPC = 28;
pub const ESPIPE = 29;
pub const EROFS = 30;
pub const EMLINK = 31;
pub const EPIPE = 32;
pub const EDOM = 33;
pub const ERANGE = 34;
pub const EAGAIN = 35;
pub const EINPROGRESS = 36;
pub const EALREADY = 37;
pub const ENOTSOCK = 38;
pub const EDESTADDRREQ = 39;
pub const EMSGSIZE = 40;
pub const EPROTOTYPE = 41;
pub const ENOPROTOOPT = 42;
pub const EPROTONOSUPPORT = 43;
pub const ESOCKTNOSUPPORT = 44;
pub const EOPNOTSUPP = 45;
pub const EPFNOSUPPORT = 46;
pub const EAFNOSUPPORT = 47;
pub const EADDRINUSE = 48;
pub const EADDRNOTAVAIL = 49;
pub const ENETDOWN = 50;
pub const ENETUNREACH = 51;
pub const ENETRESET = 52;
pub const ECONNABORTED = 53;
pub const ECONNRESET = 54;
pub const ENOBUFS = 55;
pub const EISCONN = 56;
pub const ENOTCONN = 57;
pub const ESHUTDOWN = 58;
pub const ETOOMANYREFS = 59;
pub const ETIMEDOUT = 60;
pub const ECONNREFUSED = 61;
pub const ELOOP = 62;
pub const ENAMETOOLONG = 63;
pub const EHOSTDOWN = 64;
pub const EHOSTUNREACH = 65;
pub const ENOTEMPTY = 66;
pub const EPROCLIM = 67;
pub const EUSERS = 68;
pub const EDQUOT = 69;
pub const ESTALE = 70;
pub const EREMOTE = 71;
pub const EBADRPC = 72;
pub const ERPCMISMATCH = 73;
pub const EPROGUNAVAIL = 74;
pub const EPROGMISMATCH = 75;
pub const EPROCUNAVAIL = 76;
pub const ENOLCK = 77;
pub const ENOSYS = 78;
pub const EFTYPE = 79;
pub const EAUTH = 80;
pub const ENEEDAUTH = 81;
pub const EIDRM = 82;
pub const ENOMSG = 83;
pub const EOVERFLOW = 84;
pub const ECANCELED = 85;
pub const EILSEQ = 86;
pub const ENOATTR = 87;
pub const EDOOFUS = 88;
pub const EBADMSG = 89;
pub const EMULTIHOP = 90;
pub const ENOLINK = 91;
pub const EPROTO = 92;
pub const ENOMEDIUM = 93;
pub const ELAST = 99;
pub const EASYNC = 99;
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;

View file

@ -887,127 +887,134 @@ pub usingnamespace switch (builtin.target.cpu.arch) {
else => struct {},
};
pub const EPERM = 1; // Operation not permitted
pub const ENOENT = 2; // No such file or directory
pub const ESRCH = 3; // No such process
pub const EINTR = 4; // Interrupted system call
pub const EIO = 5; // Input/output error
pub const ENXIO = 6; // Device not configured
pub const E2BIG = 7; // Argument list too long
pub const ENOEXEC = 8; // Exec format error
pub const EBADF = 9; // Bad file descriptor
pub const ECHILD = 10; // No child processes
pub const EDEADLK = 11; // Resource deadlock avoided
// 11 was EAGAIN
pub const ENOMEM = 12; // Cannot allocate memory
pub const EACCES = 13; // Permission denied
pub const EFAULT = 14; // Bad address
pub const ENOTBLK = 15; // Block device required
pub const EBUSY = 16; // Device busy
pub const EEXIST = 17; // File exists
pub const EXDEV = 18; // Cross-device link
pub const ENODEV = 19; // Operation not supported by device
pub const ENOTDIR = 20; // Not a directory
pub const EISDIR = 21; // Is a directory
pub const EINVAL = 22; // Invalid argument
pub const ENFILE = 23; // Too many open files in system
pub const EMFILE = 24; // Too many open files
pub const ENOTTY = 25; // Inappropriate ioctl for device
pub const ETXTBSY = 26; // Text file busy
pub const EFBIG = 27; // File too large
pub const ENOSPC = 28; // No space left on device
pub const ESPIPE = 29; // Illegal seek
pub const EROFS = 30; // Read-only filesystem
pub const EMLINK = 31; // Too many links
pub const EPIPE = 32; // Broken pipe
pub const E = enum(u16) {
/// No error occurred.
SUCCESS = 0,
// math software
pub const EDOM = 33; // Numerical argument out of domain
pub const ERANGE = 34; // Result too large
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
// non-blocking and interrupt i/o
pub const EAGAIN = 35; // Resource temporarily unavailable
pub const EWOULDBLOCK = EAGAIN; // Operation would block
pub const EINPROGRESS = 36; // Operation now in progress
pub const EALREADY = 37; // Operation already in progress
// math software
DOM = 33, // Numerical argument out of domain
RANGE = 34, // Result too large
// ipc/network software -- argument errors
pub const ENOTSOCK = 38; // Socket operation on non-socket
pub const EDESTADDRREQ = 39; // Destination address required
pub const EMSGSIZE = 40; // Message too long
pub const EPROTOTYPE = 41; // Protocol wrong type for socket
pub const ENOPROTOOPT = 42; // Protocol not available
pub const EPROTONOSUPPORT = 43; // Protocol not supported
pub const ESOCKTNOSUPPORT = 44; // Socket type not supported
pub const EOPNOTSUPP = 45; // Operation not supported
pub const ENOTSUP = EOPNOTSUPP; // Operation not supported
pub const EPFNOSUPPORT = 46; // Protocol family not supported
pub const EAFNOSUPPORT = 47; // Address family not supported by protocol family
pub const EADDRINUSE = 48; // Address already in use
pub const EADDRNOTAVAIL = 49; // Can't assign requested address
// non-blocking and interrupt i/o
// ipc/network software -- operational errors
pub const ENETDOWN = 50; // Network is down
pub const ENETUNREACH = 51; // Network is unreachable
pub const ENETRESET = 52; // Network dropped connection on reset
pub const ECONNABORTED = 53; // Software caused connection abort
pub const ECONNRESET = 54; // Connection reset by peer
pub const ENOBUFS = 55; // No buffer space available
pub const EISCONN = 56; // Socket is already connected
pub const ENOTCONN = 57; // Socket is not connected
pub const ESHUTDOWN = 58; // Can't send after socket shutdown
pub const ETOOMANYREFS = 59; // Too many references: can't splice
pub const ETIMEDOUT = 60; // Operation timed out
pub const ECONNREFUSED = 61; // Connection refused
/// 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
pub const ELOOP = 62; // Too many levels of symbolic links
pub const ENAMETOOLONG = 63; // File name too long
// 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
// should be rearranged
pub const EHOSTDOWN = 64; // Host is down
pub const EHOSTUNREACH = 65; // No route to host
pub const ENOTEMPTY = 66; // Directory not empty
// 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
// quotas & mush
pub const EPROCLIM = 67; // Too many processes
pub const EUSERS = 68; // Too many users
pub const EDQUOT = 69; // Disc quota exceeded
LOOP = 62, // Too many levels of symbolic links
NAMETOOLONG = 63, // File name too long
// Network File System
pub const ESTALE = 70; // Stale NFS file handle
pub const EREMOTE = 71; // Too many levels of remote in path
pub const EBADRPC = 72; // RPC struct is bad
pub const ERPCMISMATCH = 73; // RPC version wrong
pub const EPROGUNAVAIL = 74; // RPC prog. not avail
pub const EPROGMISMATCH = 75; // Program version wrong
pub const EPROCUNAVAIL = 76; // Bad procedure for program
// should be rearranged
HOSTDOWN = 64, // Host is down
HOSTUNREACH = 65, // No route to host
NOTEMPTY = 66, // Directory not empty
pub const ENOLCK = 77; // No locks available
pub const ENOSYS = 78; // Function not implemented
// quotas & mush
PROCLIM = 67, // Too many processes
USERS = 68, // Too many users
DQUOT = 69, // Disc quota exceeded
pub const EFTYPE = 79; // Inappropriate file type or format
pub const EAUTH = 80; // Authentication error
pub const ENEEDAUTH = 81; // Need authenticator
pub const EIDRM = 82; // Identifier removed
pub const ENOMSG = 83; // No message of desired type
pub const EOVERFLOW = 84; // Value too large to be stored in data type
pub const ECANCELED = 85; // Operation canceled
pub const EILSEQ = 86; // Illegal byte sequence
pub const ENOATTR = 87; // Attribute not found
// 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
pub const EDOOFUS = 88; // Programming error
NOLCK = 77, // No locks available
NOSYS = 78, // Function not implemented
pub const EBADMSG = 89; // Bad message
pub const EMULTIHOP = 90; // Multihop attempted
pub const ENOLINK = 91; // Link has been severed
pub const EPROTO = 92; // Protocol error
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
pub const ENOTCAPABLE = 93; // Capabilities insufficient
pub const ECAPMODE = 94; // Not permitted in capability mode
pub const ENOTRECOVERABLE = 95; // State not recoverable
pub const EOWNERDEAD = 96; // Previous owner died
DOOFUS = 88, // Programming error
pub const ELAST = 96; // Must be equal largest errno
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,

View file

@ -734,125 +734,130 @@ pub const sigset_t = extern struct {
__bits: [_SIG_WORDS]u32,
};
pub const EPERM = -0x7ffffff1; // Operation not permitted
pub const ENOENT = -0x7fff9ffd; // No such file or directory
pub const ESRCH = -0x7fff8ff3; // No such process
pub const EINTR = -0x7ffffff6; // Interrupted system call
pub const EIO = -0x7fffffff; // Input/output error
pub const ENXIO = -0x7fff8ff5; // Device not configured
pub const E2BIG = -0x7fff8fff; // Argument list too long
pub const ENOEXEC = -0x7fffecfe; // Exec format error
pub const ECHILD = -0x7fff8ffe; // No child processes
pub const EDEADLK = -0x7fff8ffd; // Resource deadlock avoided
pub const ENOMEM = -0x80000000; // Cannot allocate memory
pub const EACCES = -0x7ffffffe; // Permission denied
pub const EFAULT = -0x7fffecff; // Bad address
pub const EBUSY = -0x7ffffff2; // Device busy
pub const EEXIST = -0x7fff9ffe; // File exists
pub const EXDEV = -0x7fff9ff5; // Cross-device link
pub const ENODEV = -0x7fff8ff9; // Operation not supported by device
pub const ENOTDIR = -0x7fff9ffb; // Not a directory
pub const EISDIR = -0x7fff9ff7; // Is a directory
pub const EINVAL = -0x7ffffffb; // Invalid argument
pub const ENFILE = -0x7fff8ffa; // Too many open files in system
pub const EMFILE = -0x7fff9ff6; // Too many open files
pub const ENOTTY = -0x7fff8ff6; // Inappropriate ioctl for device
pub const ETXTBSY = -0x7fff8fc5; // Text file busy
pub const EFBIG = -0x7fff8ffc; // File too large
pub const ENOSPC = -0x7fff9ff9; // No space left on device
pub const ESPIPE = -0x7fff8ff4; // Illegal seek
pub const EROFS = -0x7fff9ff8; // Read-only filesystem
pub const EMLINK = -0x7fff8ffb; // Too many links
pub const EPIPE = -0x7fff9ff3; // Broken pipe
pub const EBADF = -0x7fffa000; // Bad file descriptor
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
pub const EDOM = 33; // Numerical argument out of domain
pub const ERANGE = 34; // Result too large
// math software
DOM = 33, // Numerical argument out of domain
RANGE = 34, // Result too large
// non-blocking and interrupt i/o
pub const EAGAIN = -0x7ffffff5;
pub const EWOULDBLOCK = -0x7ffffff5;
pub const EINPROGRESS = -0x7fff8fdc;
pub const EALREADY = -0x7fff8fdb;
// non-blocking and interrupt i/o
// ipc/network software -- argument errors
pub const ENOTSOCK = 38; // Socket operation on non-socket
pub const EDESTADDRREQ = 39; // Destination address required
pub const EMSGSIZE = 40; // Message too long
pub const EPROTOTYPE = 41; // Protocol wrong type for socket
pub const ENOPROTOOPT = 42; // Protocol not available
pub const EPROTONOSUPPORT = 43; // Protocol not supported
pub const ESOCKTNOSUPPORT = 44; // Socket type not supported
pub const EOPNOTSUPP = 45; // Operation not supported
pub const ENOTSUP = EOPNOTSUPP; // Operation not supported
pub const EPFNOSUPPORT = 46; // Protocol family not supported
pub const EAFNOSUPPORT = 47; // Address family not supported by protocol family
pub const EADDRINUSE = 48; // Address already in use
pub const EADDRNOTAVAIL = 49; // Can't assign requested address
/// Also used for `WOULDBLOCK`.
AGAIN = -0x7ffffff5,
INPROGRESS = -0x7fff8fdc,
ALREADY = -0x7fff8fdb,
// ipc/network software -- operational errors
pub const ENETDOWN = 50; // Network is down
pub const ENETUNREACH = 51; // Network is unreachable
pub const ENETRESET = 52; // Network dropped connection on reset
pub const ECONNABORTED = 53; // Software caused connection abort
pub const ECONNRESET = 54; // Connection reset by peer
pub const ENOBUFS = 55; // No buffer space available
pub const EISCONN = 56; // Socket is already connected
pub const ENOTCONN = 57; // Socket is not connected
pub const ESHUTDOWN = 58; // Can't send after socket shutdown
pub const ETOOMANYREFS = 59; // Too many references: can't splice
pub const ETIMEDOUT = 60; // Operation timed out
pub const ECONNREFUSED = 61; // Connection refused
// 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
pub const ELOOP = 62; // Too many levels of symbolic links
pub const ENAMETOOLONG = 63; // File name too long
// 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
// should be rearranged
pub const EHOSTDOWN = 64; // Host is down
pub const EHOSTUNREACH = 65; // No route to host
pub const ENOTEMPTY = 66; // Directory not empty
LOOP = 62, // Too many levels of symbolic links
NAMETOOLONG = 63, // File name too long
// quotas & mush
pub const EPROCLIM = 67; // Too many processes
pub const EUSERS = 68; // Too many users
pub const EDQUOT = 69; // Disc quota exceeded
// should be rearranged
HOSTDOWN = 64, // Host is down
HOSTUNREACH = 65, // No route to host
NOTEMPTY = 66, // Directory not empty
// Network File System
pub const ESTALE = 70; // Stale NFS file handle
pub const EREMOTE = 71; // Too many levels of remote in path
pub const EBADRPC = 72; // RPC struct is bad
pub const ERPCMISMATCH = 73; // RPC version wrong
pub const EPROGUNAVAIL = 74; // RPC prog. not avail
pub const EPROGMISMATCH = 75; // Program version wrong
pub const EPROCUNAVAIL = 76; // Bad procedure for program
// quotas & mush
PROCLIM = 67, // Too many processes
USERS = 68, // Too many users
DQUOT = 69, // Disc quota exceeded
pub const ENOLCK = 77; // No locks available
pub const ENOSYS = 78; // Function not implemented
// 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
pub const EFTYPE = 79; // Inappropriate file type or format
pub const EAUTH = 80; // Authentication error
pub const ENEEDAUTH = 81; // Need authenticator
pub const EIDRM = 82; // Identifier removed
pub const ENOMSG = 83; // No message of desired type
pub const EOVERFLOW = 84; // Value too large to be stored in data type
pub const ECANCELED = 85; // Operation canceled
pub const EILSEQ = 86; // Illegal byte sequence
pub const ENOATTR = 87; // Attribute not found
NOLCK = 77, // No locks available
NOSYS = 78, // Function not implemented
pub const EDOOFUS = 88; // Programming error
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
pub const EBADMSG = 89; // Bad message
pub const EMULTIHOP = 90; // Multihop attempted
pub const ENOLINK = 91; // Link has been severed
pub const EPROTO = 92; // Protocol error
DOOFUS = 88, // Programming error
pub const ENOTCAPABLE = 93; // Capabilities insufficient
pub const ECAPMODE = 94; // Not permitted in capability mode
pub const ENOTRECOVERABLE = 95; // State not recoverable
pub const EOWNERDEAD = 96; // Previous owner died
BADMSG = 89, // Bad message
MULTIHOP = 90, // Multihop attempted
NOLINK = 91, // Link has been severed
PROTO = 92, // Protocol error
pub const ELAST = 96; // Must be equal largest errno
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,

View file

@ -8,10 +8,10 @@ const maxInt = std.math.maxInt;
const arch = @import("builtin").target.cpu.arch;
pub usingnamespace @import("posix.zig");
pub usingnamespace switch (arch) {
.mips, .mipsel => @import("linux/errno-mips.zig"),
.sparc, .sparcel, .sparcv9 => @import("linux/errno-sparc.zig"),
else => @import("linux/errno-generic.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) {
@ -1665,6 +1665,13 @@ pub const io_uring_cqe = extern struct {
/// 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

View file

@ -1,462 +0,0 @@
// SPDX-License-Identifier: MIT
// Copyright (c) 2015-2021 Zig Contributors
// This file is part of [zig](https://ziglang.org/), which is MIT licensed.
// The MIT license requires this copyright notice to be included in all copies
// and substantial portions of the software.
/// Operation not permitted
pub const EPERM = 1;
/// No such file or directory
pub const ENOENT = 2;
/// No such process
pub const ESRCH = 3;
/// Interrupted system call
pub const EINTR = 4;
/// I/O error
pub const EIO = 5;
/// No such device or address
pub const ENXIO = 6;
/// Arg list too long
pub const E2BIG = 7;
/// Exec format error
pub const ENOEXEC = 8;
/// Bad file number
pub const EBADF = 9;
/// No child processes
pub const ECHILD = 10;
/// Try again
pub const EAGAIN = 11;
/// Out of memory
pub const ENOMEM = 12;
/// Permission denied
pub const EACCES = 13;
/// Bad address
pub const EFAULT = 14;
/// Block device required
pub const ENOTBLK = 15;
/// Device or resource busy
pub const EBUSY = 16;
/// File exists
pub const EEXIST = 17;
/// Cross-device link
pub const EXDEV = 18;
/// No such device
pub const ENODEV = 19;
/// Not a directory
pub const ENOTDIR = 20;
/// Is a directory
pub const EISDIR = 21;
/// Invalid argument
pub const EINVAL = 22;
/// File table overflow
pub const ENFILE = 23;
/// Too many open files
pub const EMFILE = 24;
/// Not a typewriter
pub const ENOTTY = 25;
/// Text file busy
pub const ETXTBSY = 26;
/// File too large
pub const EFBIG = 27;
/// No space left on device
pub const ENOSPC = 28;
/// Illegal seek
pub const ESPIPE = 29;
/// Read-only file system
pub const EROFS = 30;
/// Too many links
pub const EMLINK = 31;
/// Broken pipe
pub const EPIPE = 32;
/// Math argument out of domain of func
pub const EDOM = 33;
/// Math result not representable
pub const ERANGE = 34;
/// Resource deadlock would occur
pub const EDEADLK = 35;
/// File name too long
pub const ENAMETOOLONG = 36;
/// No record locks available
pub const ENOLCK = 37;
/// Function not implemented
pub const ENOSYS = 38;
/// Directory not empty
pub const ENOTEMPTY = 39;
/// Too many symbolic links encountered
pub const ELOOP = 40;
/// Operation would block
pub const EWOULDBLOCK = EAGAIN;
/// No message of desired type
pub const ENOMSG = 42;
/// Identifier removed
pub const EIDRM = 43;
/// Channel number out of range
pub const ECHRNG = 44;
/// Level 2 not synchronized
pub const EL2NSYNC = 45;
/// Level 3 halted
pub const EL3HLT = 46;
/// Level 3 reset
pub const EL3RST = 47;
/// Link number out of range
pub const ELNRNG = 48;
/// Protocol driver not attached
pub const EUNATCH = 49;
/// No CSI structure available
pub const ENOCSI = 50;
/// Level 2 halted
pub const EL2HLT = 51;
/// Invalid exchange
pub const EBADE = 52;
/// Invalid request descriptor
pub const EBADR = 53;
/// Exchange full
pub const EXFULL = 54;
/// No anode
pub const ENOANO = 55;
/// Invalid request code
pub const EBADRQC = 56;
/// Invalid slot
pub const EBADSLT = 57;
/// Bad font file format
pub const EBFONT = 59;
/// Device not a stream
pub const ENOSTR = 60;
/// No data available
pub const ENODATA = 61;
/// Timer expired
pub const ETIME = 62;
/// Out of streams resources
pub const ENOSR = 63;
/// Machine is not on the network
pub const ENONET = 64;
/// Package not installed
pub const ENOPKG = 65;
/// Object is remote
pub const EREMOTE = 66;
/// Link has been severed
pub const ENOLINK = 67;
/// Advertise error
pub const EADV = 68;
/// Srmount error
pub const ESRMNT = 69;
/// Communication error on send
pub const ECOMM = 70;
/// Protocol error
pub const EPROTO = 71;
/// Multihop attempted
pub const EMULTIHOP = 72;
/// RFS specific error
pub const EDOTDOT = 73;
/// Not a data message
pub const EBADMSG = 74;
/// Value too large for defined data type
pub const EOVERFLOW = 75;
/// Name not unique on network
pub const ENOTUNIQ = 76;
/// File descriptor in bad state
pub const EBADFD = 77;
/// Remote address changed
pub const EREMCHG = 78;
/// Can not access a needed shared library
pub const ELIBACC = 79;
/// Accessing a corrupted shared library
pub const ELIBBAD = 80;
/// .lib section in a.out corrupted
pub const ELIBSCN = 81;
/// Attempting to link in too many shared libraries
pub const ELIBMAX = 82;
/// Cannot exec a shared library directly
pub const ELIBEXEC = 83;
/// Illegal byte sequence
pub const EILSEQ = 84;
/// Interrupted system call should be restarted
pub const ERESTART = 85;
/// Streams pipe error
pub const ESTRPIPE = 86;
/// Too many users
pub const EUSERS = 87;
/// Socket operation on non-socket
pub const ENOTSOCK = 88;
/// Destination address required
pub const EDESTADDRREQ = 89;
/// Message too long
pub const EMSGSIZE = 90;
/// Protocol wrong type for socket
pub const EPROTOTYPE = 91;
/// Protocol not available
pub const ENOPROTOOPT = 92;
/// Protocol not supported
pub const EPROTONOSUPPORT = 93;
/// Socket type not supported
pub const ESOCKTNOSUPPORT = 94;
/// Operation not supported on transport endpoint
pub const EOPNOTSUPP = 95;
pub const ENOTSUP = EOPNOTSUPP;
/// Protocol family not supported
pub const EPFNOSUPPORT = 96;
/// Address family not supported by protocol
pub const EAFNOSUPPORT = 97;
/// Address already in use
pub const EADDRINUSE = 98;
/// Cannot assign requested address
pub const EADDRNOTAVAIL = 99;
/// Network is down
pub const ENETDOWN = 100;
/// Network is unreachable
pub const ENETUNREACH = 101;
/// Network dropped connection because of reset
pub const ENETRESET = 102;
/// Software caused connection abort
pub const ECONNABORTED = 103;
/// Connection reset by peer
pub const ECONNRESET = 104;
/// No buffer space available
pub const ENOBUFS = 105;
/// Transport endpoint is already connected
pub const EISCONN = 106;
/// Transport endpoint is not connected
pub const ENOTCONN = 107;
/// Cannot send after transport endpoint shutdown
pub const ESHUTDOWN = 108;
/// Too many references: cannot splice
pub const ETOOMANYREFS = 109;
/// Connection timed out
pub const ETIMEDOUT = 110;
/// Connection refused
pub const ECONNREFUSED = 111;
/// Host is down
pub const EHOSTDOWN = 112;
/// No route to host
pub const EHOSTUNREACH = 113;
/// Operation already in progress
pub const EALREADY = 114;
/// Operation now in progress
pub const EINPROGRESS = 115;
/// Stale NFS file handle
pub const ESTALE = 116;
/// Structure needs cleaning
pub const EUCLEAN = 117;
/// Not a XENIX named type file
pub const ENOTNAM = 118;
/// No XENIX semaphores available
pub const ENAVAIL = 119;
/// Is a named type file
pub const EISNAM = 120;
/// Remote I/O error
pub const EREMOTEIO = 121;
/// Quota exceeded
pub const EDQUOT = 122;
/// No medium found
pub const ENOMEDIUM = 123;
/// Wrong medium type
pub const EMEDIUMTYPE = 124;
/// Operation canceled
pub const ECANCELED = 125;
/// Required key not available
pub const ENOKEY = 126;
/// Key has expired
pub const EKEYEXPIRED = 127;
/// Key has been revoked
pub const EKEYREVOKED = 128;
/// Key was rejected by service
pub const EKEYREJECTED = 129;
// for robust mutexes
/// Owner died
pub const EOWNERDEAD = 130;
/// State not recoverable
pub const ENOTRECOVERABLE = 131;
/// Operation not possible due to RF-kill
pub const ERFKILL = 132;
/// Memory page has hardware error
pub const EHWPOISON = 133;
// nameserver query return codes
/// DNS server returned answer with no data
pub const ENSROK = 0;
/// DNS server returned answer with no data
pub const ENSRNODATA = 160;
/// DNS server claims query was misformatted
pub const ENSRFORMERR = 161;
/// DNS server returned general failure
pub const ENSRSERVFAIL = 162;
/// Domain name not found
pub const ENSRNOTFOUND = 163;
/// DNS server does not implement requested operation
pub const ENSRNOTIMP = 164;
/// DNS server refused query
pub const ENSRREFUSED = 165;
/// Misformatted DNS query
pub const ENSRBADQUERY = 166;
/// Misformatted domain name
pub const ENSRBADNAME = 167;
/// Unsupported address family
pub const ENSRBADFAMILY = 168;
/// Misformatted DNS reply
pub const ENSRBADRESP = 169;
/// Could not contact DNS servers
pub const ENSRCONNREFUSED = 170;
/// Timeout while contacting DNS servers
pub const ENSRTIMEOUT = 171;
/// End of file
pub const ENSROF = 172;
/// Error reading file
pub const ENSRFILE = 173;
/// Out of memory
pub const ENSRNOMEM = 174;
/// Application terminated lookup
pub const ENSRDESTRUCTION = 175;
/// Domain name is too long
pub const ENSRQUERYDOMAINTOOLONG = 176;
/// Domain name is too long
pub const ENSRCNAMELOOP = 177;

View file

@ -1,143 +0,0 @@
// SPDX-License-Identifier: MIT
// Copyright (c) 2015-2021 Zig Contributors
// This file is part of [zig](https://ziglang.org/), which is MIT licensed.
// The MIT license requires this copyright notice to be included in all copies
// and substantial portions of the software.
// These are MIPS ABI compatible.
pub const EPERM = 1;
pub const ENOENT = 2;
pub const ESRCH = 3;
pub const EINTR = 4;
pub const EIO = 5;
pub const ENXIO = 6;
pub const E2BIG = 7;
pub const ENOEXEC = 8;
pub const EBADF = 9;
pub const ECHILD = 10;
pub const EAGAIN = 11;
pub const ENOMEM = 12;
pub const EACCES = 13;
pub const EFAULT = 14;
pub const ENOTBLK = 15;
pub const EBUSY = 16;
pub const EEXIST = 17;
pub const EXDEV = 18;
pub const ENODEV = 19;
pub const ENOTDIR = 20;
pub const EISDIR = 21;
pub const EINVAL = 22;
pub const ENFILE = 23;
pub const EMFILE = 24;
pub const ENOTTY = 25;
pub const ETXTBSY = 26;
pub const EFBIG = 27;
pub const ENOSPC = 28;
pub const ESPIPE = 29;
pub const EROFS = 30;
pub const EMLINK = 31;
pub const EPIPE = 32;
pub const EDOM = 33;
pub const ERANGE = 34;
pub const ENOMSG = 35;
pub const EIDRM = 36;
pub const ECHRNG = 37;
pub const EL2NSYNC = 38;
pub const EL3HLT = 39;
pub const EL3RST = 40;
pub const ELNRNG = 41;
pub const EUNATCH = 42;
pub const ENOCSI = 43;
pub const EL2HLT = 44;
pub const EDEADLK = 45;
pub const ENOLCK = 46;
pub const EBADE = 50;
pub const EBADR = 51;
pub const EXFULL = 52;
pub const ENOANO = 53;
pub const EBADRQC = 54;
pub const EBADSLT = 55;
pub const EDEADLOCK = 56;
pub const EBFONT = 59;
pub const ENOSTR = 60;
pub const ENODATA = 61;
pub const ETIME = 62;
pub const ENOSR = 63;
pub const ENONET = 64;
pub const ENOPKG = 65;
pub const EREMOTE = 66;
pub const ENOLINK = 67;
pub const EADV = 68;
pub const ESRMNT = 69;
pub const ECOMM = 70;
pub const EPROTO = 71;
pub const EDOTDOT = 73;
pub const EMULTIHOP = 74;
pub const EBADMSG = 77;
pub const ENAMETOOLONG = 78;
pub const EOVERFLOW = 79;
pub const ENOTUNIQ = 80;
pub const EBADFD = 81;
pub const EREMCHG = 82;
pub const ELIBACC = 83;
pub const ELIBBAD = 84;
pub const ELIBSCN = 85;
pub const ELIBMAX = 86;
pub const ELIBEXEC = 87;
pub const EILSEQ = 88;
pub const ENOSYS = 89;
pub const ELOOP = 90;
pub const ERESTART = 91;
pub const ESTRPIPE = 92;
pub const ENOTEMPTY = 93;
pub const EUSERS = 94;
pub const ENOTSOCK = 95;
pub const EDESTADDRREQ = 96;
pub const EMSGSIZE = 97;
pub const EPROTOTYPE = 98;
pub const ENOPROTOOPT = 99;
pub const EPROTONOSUPPORT = 120;
pub const ESOCKTNOSUPPORT = 121;
pub const EOPNOTSUPP = 122;
pub const ENOTSUP = EOPNOTSUPP;
pub const EPFNOSUPPORT = 123;
pub const EAFNOSUPPORT = 124;
pub const EADDRINUSE = 125;
pub const EADDRNOTAVAIL = 126;
pub const ENETDOWN = 127;
pub const ENETUNREACH = 128;
pub const ENETRESET = 129;
pub const ECONNABORTED = 130;
pub const ECONNRESET = 131;
pub const ENOBUFS = 132;
pub const EISCONN = 133;
pub const ENOTCONN = 134;
pub const EUCLEAN = 135;
pub const ENOTNAM = 137;
pub const ENAVAIL = 138;
pub const EISNAM = 139;
pub const EREMOTEIO = 140;
pub const ESHUTDOWN = 143;
pub const ETOOMANYREFS = 144;
pub const ETIMEDOUT = 145;
pub const ECONNREFUSED = 146;
pub const EHOSTDOWN = 147;
pub const EHOSTUNREACH = 148;
pub const EWOULDBLOCK = EAGAIN;
pub const EALREADY = 149;
pub const EINPROGRESS = 150;
pub const ESTALE = 151;
pub const ECANCELED = 158;
pub const ENOMEDIUM = 159;
pub const EMEDIUMTYPE = 160;
pub const ENOKEY = 161;
pub const EKEYEXPIRED = 162;
pub const EKEYREVOKED = 163;
pub const EKEYREJECTED = 164;
pub const EOWNERDEAD = 165;
pub const ENOTRECOVERABLE = 166;
pub const ERFKILL = 167;
pub const EHWPOISON = 168;
pub const EDQUOT = 1133;

View file

@ -1,145 +0,0 @@
// SPDX-License-Identifier: MIT
// Copyright (c) 2015-2021 Zig Contributors
// This file is part of [zig](https://ziglang.org/), which is MIT licensed.
// The MIT license requires this copyright notice to be included in all copies
// and substantial portions of the software.
// These match the SunOS error numbering scheme.
pub const EPERM = 1;
pub const ENOENT = 2;
pub const ESRCH = 3;
pub const EINTR = 4;
pub const EIO = 5;
pub const ENXIO = 6;
pub const E2BIG = 7;
pub const ENOEXEC = 8;
pub const EBADF = 9;
pub const ECHILD = 10;
pub const EAGAIN = 11;
pub const ENOMEM = 12;
pub const EACCES = 13;
pub const EFAULT = 14;
pub const ENOTBLK = 15;
pub const EBUSY = 16;
pub const EEXIST = 17;
pub const EXDEV = 18;
pub const ENODEV = 19;
pub const ENOTDIR = 20;
pub const EISDIR = 21;
pub const EINVAL = 22;
pub const ENFILE = 23;
pub const EMFILE = 24;
pub const ENOTTY = 25;
pub const ETXTBSY = 26;
pub const EFBIG = 27;
pub const ENOSPC = 28;
pub const ESPIPE = 29;
pub const EROFS = 30;
pub const EMLINK = 31;
pub const EPIPE = 32;
pub const EDOM = 33;
pub const ERANGE = 34;
pub const EWOULDBLOCK = EAGAIN;
pub const EINPROGRESS = 36;
pub const EALREADY = 37;
pub const ENOTSOCK = 38;
pub const EDESTADDRREQ = 39;
pub const EMSGSIZE = 40;
pub const EPROTOTYPE = 41;
pub const ENOPROTOOPT = 42;
pub const EPROTONOSUPPORT = 43;
pub const ESOCKTNOSUPPORT = 44;
pub const EOPNOTSUPP = 45;
pub const ENOTSUP = EOPNOTSUPP;
pub const EPFNOSUPPORT = 46;
pub const EAFNOSUPPORT = 47;
pub const EADDRINUSE = 48;
pub const EADDRNOTAVAIL = 49;
pub const ENETDOWN = 50;
pub const ENETUNREACH = 51;
pub const ENETRESET = 52;
pub const ECONNABORTED = 53;
pub const ECONNRESET = 54;
pub const ENOBUFS = 55;
pub const EISCONN = 56;
pub const ENOTCONN = 57;
pub const ESHUTDOWN = 58;
pub const ETOOMANYREFS = 59;
pub const ETIMEDOUT = 60;
pub const ECONNREFUSED = 61;
pub const ELOOP = 62;
pub const ENAMETOOLONG = 63;
pub const EHOSTDOWN = 64;
pub const EHOSTUNREACH = 65;
pub const ENOTEMPTY = 66;
pub const EPROCLIM = 67;
pub const EUSERS = 68;
pub const EDQUOT = 69;
pub const ESTALE = 70;
pub const EREMOTE = 71;
pub const ENOSTR = 72;
pub const ETIME = 73;
pub const ENOSR = 74;
pub const ENOMSG = 75;
pub const EBADMSG = 76;
pub const EIDRM = 77;
pub const EDEADLK = 78;
pub const ENOLCK = 79;
pub const ENONET = 80;
pub const ERREMOTE = 81;
pub const ENOLINK = 82;
pub const EADV = 83;
pub const ESRMNT = 84;
pub const ECOMM = 85;
pub const EPROTO = 86;
pub const EMULTIHOP = 87;
pub const EDOTDOT = 88;
pub const EREMCHG = 89;
pub const ENOSYS = 90;
pub const ESTRPIPE = 91;
pub const EOVERFLOW = 92;
pub const EBADFD = 93;
pub const ECHRNG = 94;
pub const EL2NSYNC = 95;
pub const EL3HLT = 96;
pub const EL3RST = 97;
pub const ELNRNG = 98;
pub const EUNATCH = 99;
pub const ENOCSI = 100;
pub const EL2HLT = 101;
pub const EBADE = 102;
pub const EBADR = 103;
pub const EXFULL = 104;
pub const ENOANO = 105;
pub const EBADRQC = 106;
pub const EBADSLT = 107;
pub const EDEADLOCK = 108;
pub const EBFONT = 109;
pub const ELIBEXEC = 110;
pub const ENODATA = 111;
pub const ELIBBAD = 112;
pub const ENOPKG = 113;
pub const ELIBACC = 114;
pub const ENOTUNIQ = 115;
pub const ERESTART = 116;
pub const EUCLEAN = 117;
pub const ENOTNAM = 118;
pub const ENAVAIL = 119;
pub const EISNAM = 120;
pub const EREMOTEIO = 121;
pub const EILSEQ = 122;
pub const ELIBMAX = 123;
pub const ELIBSCN = 124;
pub const ENOMEDIUM = 125;
pub const EMEDIUMTYPE = 126;
pub const ECANCELED = 127;
pub const ENOKEY = 128;
pub const EKEYEXPIRED = 129;
pub const EKEYREVOKED = 130;
pub const EKEYREJECTED = 131;
pub const EOWNERDEAD = 132;
pub const ENOTRECOVERABLE = 133;
pub const ERFKILL = 134;
pub const EHWPOISON = 135;

View file

@ -0,0 +1,466 @@
// SPDX-License-Identifier: MIT
// Copyright (c) 2015-2021 Zig Contributors
// This file is part of [zig](https://ziglang.org/), which is MIT licensed.
// The MIT license requires this copyright notice to be included in all copies
// and substantial portions of the software.
pub const E = enum(u16) {
/// No error occurred.
/// Same code used for `NSROK`.
SUCCESS = 0,
/// Operation not permitted
PERM = 1,
/// No such file or directory
NOENT = 2,
/// No such process
SRCH = 3,
/// Interrupted system call
INTR = 4,
/// I/O error
IO = 5,
/// No such device or address
NXIO = 6,
/// Arg list too long
@"2BIG" = 7,
/// Exec format error
NOEXEC = 8,
/// Bad file number
BADF = 9,
/// No child processes
CHILD = 10,
/// Try again
/// Also means: WOULDBLOCK: operation would block
AGAIN = 11,
/// Out of memory
NOMEM = 12,
/// Permission denied
ACCES = 13,
/// Bad address
FAULT = 14,
/// Block device required
NOTBLK = 15,
/// Device or resource busy
BUSY = 16,
/// File exists
EXIST = 17,
/// Cross-device link
XDEV = 18,
/// No such device
NODEV = 19,
/// Not a directory
NOTDIR = 20,
/// Is a directory
ISDIR = 21,
/// Invalid argument
INVAL = 22,
/// File table overflow
NFILE = 23,
/// Too many open files
MFILE = 24,
/// Not a typewriter
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 argument out of domain of func
DOM = 33,
/// Math result not representable
RANGE = 34,
/// Resource deadlock would occur
DEADLK = 35,
/// File name too long
NAMETOOLONG = 36,
/// No record locks available
NOLCK = 37,
/// Function not implemented
NOSYS = 38,
/// Directory not empty
NOTEMPTY = 39,
/// Too many symbolic links encountered
LOOP = 40,
/// No message of desired type
NOMSG = 42,
/// Identifier removed
IDRM = 43,
/// Channel number out of range
CHRNG = 44,
/// Level 2 not synchronized
L2NSYNC = 45,
/// Level 3 halted
L3HLT = 46,
/// Level 3 reset
L3RST = 47,
/// Link number out of range
LNRNG = 48,
/// Protocol driver not attached
UNATCH = 49,
/// No CSI structure available
NOCSI = 50,
/// Level 2 halted
L2HLT = 51,
/// Invalid exchange
BADE = 52,
/// Invalid request descriptor
BADR = 53,
/// Exchange full
XFULL = 54,
/// No anode
NOANO = 55,
/// Invalid request code
BADRQC = 56,
/// Invalid slot
BADSLT = 57,
/// Bad font file format
BFONT = 59,
/// Device not a stream
NOSTR = 60,
/// No data available
NODATA = 61,
/// Timer expired
TIME = 62,
/// Out of streams resources
NOSR = 63,
/// Machine is not on the network
NONET = 64,
/// Package not installed
NOPKG = 65,
/// Object is remote
REMOTE = 66,
/// Link has been severed
NOLINK = 67,
/// Advertise error
ADV = 68,
/// Srmount error
SRMNT = 69,
/// Communication error on send
COMM = 70,
/// Protocol error
PROTO = 71,
/// Multihop attempted
MULTIHOP = 72,
/// RFS specific error
DOTDOT = 73,
/// Not a data message
BADMSG = 74,
/// Value too large for defined data type
OVERFLOW = 75,
/// Name not unique on network
NOTUNIQ = 76,
/// File descriptor in bad state
BADFD = 77,
/// Remote address changed
REMCHG = 78,
/// Can not access a needed shared library
LIBACC = 79,
/// Accessing a corrupted shared library
LIBBAD = 80,
/// .lib section in a.out corrupted
LIBSCN = 81,
/// Attempting to link in too many shared libraries
LIBMAX = 82,
/// Cannot exec a shared library directly
LIBEXEC = 83,
/// Illegal byte sequence
ILSEQ = 84,
/// Interrupted system call should be restarted
RESTART = 85,
/// Streams pipe error
STRPIPE = 86,
/// Too many users
USERS = 87,
/// Socket operation on non-socket
NOTSOCK = 88,
/// Destination address required
DESTADDRREQ = 89,
/// Message too long
MSGSIZE = 90,
/// Protocol wrong type for socket
PROTOTYPE = 91,
/// Protocol not available
NOPROTOOPT = 92,
/// Protocol not supported
PROTONOSUPPORT = 93,
/// Socket type not supported
SOCKTNOSUPPORT = 94,
/// Operation not supported on transport endpoint
/// This code also means `NOTSUP`.
OPNOTSUPP = 95,
/// Protocol family not supported
PFNOSUPPORT = 96,
/// Address family not supported by protocol
AFNOSUPPORT = 97,
/// Address already in use
ADDRINUSE = 98,
/// Cannot assign requested address
ADDRNOTAVAIL = 99,
/// Network is down
NETDOWN = 100,
/// Network is unreachable
NETUNREACH = 101,
/// Network dropped connection because of reset
NETRESET = 102,
/// Software caused connection abort
CONNABORTED = 103,
/// Connection reset by peer
CONNRESET = 104,
/// No buffer space available
NOBUFS = 105,
/// Transport endpoint is already connected
ISCONN = 106,
/// Transport endpoint is not connected
NOTCONN = 107,
/// Cannot send after transport endpoint shutdown
SHUTDOWN = 108,
/// Too many references: cannot splice
TOOMANYREFS = 109,
/// Connection timed out
TIMEDOUT = 110,
/// Connection refused
CONNREFUSED = 111,
/// Host is down
HOSTDOWN = 112,
/// No route to host
HOSTUNREACH = 113,
/// Operation already in progress
ALREADY = 114,
/// Operation now in progress
INPROGRESS = 115,
/// Stale NFS file handle
STALE = 116,
/// Structure needs cleaning
UCLEAN = 117,
/// Not a XENIX named type file
NOTNAM = 118,
/// No XENIX semaphores available
NAVAIL = 119,
/// Is a named type file
ISNAM = 120,
/// Remote I/O error
REMOTEIO = 121,
/// Quota exceeded
DQUOT = 122,
/// No medium found
NOMEDIUM = 123,
/// Wrong medium type
MEDIUMTYPE = 124,
/// Operation canceled
CANCELED = 125,
/// Required key not available
NOKEY = 126,
/// Key has expired
KEYEXPIRED = 127,
/// Key has been revoked
KEYREVOKED = 128,
/// Key was rejected by service
KEYREJECTED = 129,
// for robust mutexes
/// Owner died
OWNERDEAD = 130,
/// State not recoverable
NOTRECOVERABLE = 131,
/// Operation not possible due to RF-kill
RFKILL = 132,
/// Memory page has hardware error
HWPOISON = 133,
// nameserver query return codes
/// DNS server returned answer with no data
NSRNODATA = 160,
/// DNS server claims query was misformatted
NSRFORMERR = 161,
/// DNS server returned general failure
NSRSERVFAIL = 162,
/// Domain name not found
NSRNOTFOUND = 163,
/// DNS server does not implement requested operation
NSRNOTIMP = 164,
/// DNS server refused query
NSRREFUSED = 165,
/// Misformatted DNS query
NSRBADQUERY = 166,
/// Misformatted domain name
NSRBADNAME = 167,
/// Unsupported address family
NSRBADFAMILY = 168,
/// Misformatted DNS reply
NSRBADRESP = 169,
/// Could not contact DNS servers
NSRCONNREFUSED = 170,
/// Timeout while contacting DNS servers
NSRTIMEOUT = 171,
/// End of file
NSROF = 172,
/// Error reading file
NSRFILE = 173,
/// Out of memory
NSRNOMEM = 174,
/// Application terminated lookup
NSRDESTRUCTION = 175,
/// Domain name is too long
NSRQUERYDOMAINTOOLONG = 176,
/// Domain name is too long
NSRCNAMELOOP = 177,
_,
};

View file

@ -0,0 +1,147 @@
// SPDX-License-Identifier: MIT
// Copyright (c) 2015-2021 Zig Contributors
// This file is part of [zig](https://ziglang.org/), which is MIT licensed.
// The MIT license requires this copyright notice to be included in all copies
// and substantial portions of the software.
//! These are MIPS ABI compatible.
pub const E = enum(i32) {
/// 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,
/// Also used for WOULDBLOCK.
AGAIN = 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,
NOMSG = 35,
IDRM = 36,
CHRNG = 37,
L2NSYNC = 38,
L3HLT = 39,
L3RST = 40,
LNRNG = 41,
UNATCH = 42,
NOCSI = 43,
L2HLT = 44,
DEADLK = 45,
NOLCK = 46,
BADE = 50,
BADR = 51,
XFULL = 52,
NOANO = 53,
BADRQC = 54,
BADSLT = 55,
DEADLOCK = 56,
BFONT = 59,
NOSTR = 60,
NODATA = 61,
TIME = 62,
NOSR = 63,
NONET = 64,
NOPKG = 65,
REMOTE = 66,
NOLINK = 67,
ADV = 68,
SRMNT = 69,
COMM = 70,
PROTO = 71,
DOTDOT = 73,
MULTIHOP = 74,
BADMSG = 77,
NAMETOOLONG = 78,
OVERFLOW = 79,
NOTUNIQ = 80,
BADFD = 81,
REMCHG = 82,
LIBACC = 83,
LIBBAD = 84,
LIBSCN = 85,
LIBMAX = 86,
LIBEXEC = 87,
ILSEQ = 88,
NOSYS = 89,
LOOP = 90,
RESTART = 91,
STRPIPE = 92,
NOTEMPTY = 93,
USERS = 94,
NOTSOCK = 95,
DESTADDRREQ = 96,
MSGSIZE = 97,
PROTOTYPE = 98,
NOPROTOOPT = 99,
PROTONOSUPPORT = 120,
SOCKTNOSUPPORT = 121,
OPNOTSUPP = 122,
PFNOSUPPORT = 123,
AFNOSUPPORT = 124,
ADDRINUSE = 125,
ADDRNOTAVAIL = 126,
NETDOWN = 127,
NETUNREACH = 128,
NETRESET = 129,
CONNABORTED = 130,
CONNRESET = 131,
NOBUFS = 132,
ISCONN = 133,
NOTCONN = 134,
UCLEAN = 135,
NOTNAM = 137,
NAVAIL = 138,
ISNAM = 139,
REMOTEIO = 140,
SHUTDOWN = 143,
TOOMANYREFS = 144,
TIMEDOUT = 145,
CONNREFUSED = 146,
HOSTDOWN = 147,
HOSTUNREACH = 148,
ALREADY = 149,
INPROGRESS = 150,
STALE = 151,
CANCELED = 158,
NOMEDIUM = 159,
MEDIUMTYPE = 160,
NOKEY = 161,
KEYEXPIRED = 162,
KEYREVOKED = 163,
KEYREJECTED = 164,
OWNERDEAD = 165,
NOTRECOVERABLE = 166,
RFKILL = 167,
HWPOISON = 168,
DQUOT = 1133,
_,
};

View file

@ -0,0 +1,150 @@
// SPDX-License-Identifier: MIT
// Copyright (c) 2015-2021 Zig Contributors
// This file is part of [zig](https://ziglang.org/), which is MIT licensed.
// The MIT license requires this copyright notice to be included in all copies
// and substantial portions of the software.
//! These match the SunOS error numbering scheme.
pub const E = enum(i32) {
/// 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,
/// Also used for WOULDBLOCK
AGAIN = 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,
INPROGRESS = 36,
ALREADY = 37,
NOTSOCK = 38,
DESTADDRREQ = 39,
MSGSIZE = 40,
PROTOTYPE = 41,
NOPROTOOPT = 42,
PROTONOSUPPORT = 43,
SOCKTNOSUPPORT = 44,
/// 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,
NOSTR = 72,
TIME = 73,
NOSR = 74,
NOMSG = 75,
BADMSG = 76,
IDRM = 77,
DEADLK = 78,
NOLCK = 79,
NONET = 80,
RREMOTE = 81,
NOLINK = 82,
ADV = 83,
SRMNT = 84,
COMM = 85,
PROTO = 86,
MULTIHOP = 87,
DOTDOT = 88,
REMCHG = 89,
NOSYS = 90,
STRPIPE = 91,
OVERFLOW = 92,
BADFD = 93,
CHRNG = 94,
L2NSYNC = 95,
L3HLT = 96,
L3RST = 97,
LNRNG = 98,
UNATCH = 99,
NOCSI = 100,
L2HLT = 101,
BADE = 102,
BADR = 103,
XFULL = 104,
NOANO = 105,
BADRQC = 106,
BADSLT = 107,
DEADLOCK = 108,
BFONT = 109,
LIBEXEC = 110,
NODATA = 111,
LIBBAD = 112,
NOPKG = 113,
LIBACC = 114,
NOTUNIQ = 115,
RESTART = 116,
UCLEAN = 117,
NOTNAM = 118,
NAVAIL = 119,
ISNAM = 120,
REMOTEIO = 121,
ILSEQ = 122,
LIBMAX = 123,
LIBSCN = 124,
NOMEDIUM = 125,
MEDIUMTYPE = 126,
CANCELED = 127,
NOKEY = 128,
KEYEXPIRED = 129,
KEYREVOKED = 130,
KEYREJECTED = 131,
OWNERDEAD = 132,
NOTRECOVERABLE = 133,
RFKILL = 134,
HWPOISON = 135,
_,
};

View file

@ -933,140 +933,144 @@ pub const ucontext_t = extern struct {
]u32,
};
pub const EPERM = 1; // Operation not permitted
pub const ENOENT = 2; // No such file or directory
pub const ESRCH = 3; // No such process
pub const EINTR = 4; // Interrupted system call
pub const EIO = 5; // Input/output error
pub const ENXIO = 6; // Device not configured
pub const E2BIG = 7; // Argument list too long
pub const ENOEXEC = 8; // Exec format error
pub const EBADF = 9; // Bad file descriptor
pub const ECHILD = 10; // No child processes
pub const EDEADLK = 11; // Resource deadlock avoided
// 11 was EAGAIN
pub const ENOMEM = 12; // Cannot allocate memory
pub const EACCES = 13; // Permission denied
pub const EFAULT = 14; // Bad address
pub const ENOTBLK = 15; // Block device required
pub const EBUSY = 16; // Device busy
pub const EEXIST = 17; // File exists
pub const EXDEV = 18; // Cross-device link
pub const ENODEV = 19; // Operation not supported by device
pub const ENOTDIR = 20; // Not a directory
pub const EISDIR = 21; // Is a directory
pub const EINVAL = 22; // Invalid argument
pub const ENFILE = 23; // Too many open files in system
pub const EMFILE = 24; // Too many open files
pub const ENOTTY = 25; // Inappropriate ioctl for device
pub const ETXTBSY = 26; // Text file busy
pub const EFBIG = 27; // File too large
pub const ENOSPC = 28; // No space left on device
pub const ESPIPE = 29; // Illegal seek
pub const EROFS = 30; // Read-only file system
pub const EMLINK = 31; // Too many links
pub const EPIPE = 32; // Broken pipe
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
pub const EDOM = 33; // Numerical argument out of domain
pub const ERANGE = 34; // Result too large or too small
// math software
DOM = 33, // Numerical argument out of domain
RANGE = 34, // Result too large or too small
// non-blocking and interrupt i/o
pub const EAGAIN = 35; // Resource temporarily unavailable
pub const EWOULDBLOCK = EAGAIN; // Operation would block
pub const EINPROGRESS = 36; // Operation now in progress
pub const EALREADY = 37; // Operation already in progress
// 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
pub const ENOTSOCK = 38; // Socket operation on non-socket
pub const EDESTADDRREQ = 39; // Destination address required
pub const EMSGSIZE = 40; // Message too long
pub const EPROTOTYPE = 41; // Protocol wrong type for socket
pub const ENOPROTOOPT = 42; // Protocol option not available
pub const EPROTONOSUPPORT = 43; // Protocol not supported
pub const ESOCKTNOSUPPORT = 44; // Socket type not supported
pub const EOPNOTSUPP = 45; // Operation not supported
pub const EPFNOSUPPORT = 46; // Protocol family not supported
pub const EAFNOSUPPORT = 47; // Address family not supported by protocol family
pub const EADDRINUSE = 48; // Address already in use
pub const EADDRNOTAVAIL = 49; // Can't assign requested address
// 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
pub const ENETDOWN = 50; // Network is down
pub const ENETUNREACH = 51; // Network is unreachable
pub const ENETRESET = 52; // Network dropped connection on reset
pub const ECONNABORTED = 53; // Software caused connection abort
pub const ECONNRESET = 54; // Connection reset by peer
pub const ENOBUFS = 55; // No buffer space available
pub const EISCONN = 56; // Socket is already connected
pub const ENOTCONN = 57; // Socket is not connected
pub const ESHUTDOWN = 58; // Can't send after socket shutdown
pub const ETOOMANYREFS = 59; // Too many references: can't splice
pub const ETIMEDOUT = 60; // Operation timed out
pub const ECONNREFUSED = 61; // Connection refused
// 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
pub const ELOOP = 62; // Too many levels of symbolic links
pub const ENAMETOOLONG = 63; // File name too long
LOOP = 62, // Too many levels of symbolic links
NAMETOOLONG = 63, // File name too long
// should be rearranged
pub const EHOSTDOWN = 64; // Host is down
pub const EHOSTUNREACH = 65; // No route to host
pub const ENOTEMPTY = 66; // Directory not empty
// should be rearranged
HOSTDOWN = 64, // Host is down
HOSTUNREACH = 65, // No route to host
NOTEMPTY = 66, // Directory not empty
// quotas & mush
pub const EPROCLIM = 67; // Too many processes
pub const EUSERS = 68; // Too many users
pub const EDQUOT = 69; // Disc quota exceeded
// quotas & mush
PROCLIM = 67, // Too many processes
USERS = 68, // Too many users
DQUOT = 69, // Disc quota exceeded
// Network File System
pub const ESTALE = 70; // Stale NFS file handle
pub const EREMOTE = 71; // Too many levels of remote in path
pub const EBADRPC = 72; // RPC struct is bad
pub const ERPCMISMATCH = 73; // RPC version wrong
pub const EPROGUNAVAIL = 74; // RPC prog. not avail
pub const EPROGMISMATCH = 75; // Program version wrong
pub const EPROCUNAVAIL = 76; // Bad procedure for program
// 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
pub const ENOLCK = 77; // No locks available
pub const ENOSYS = 78; // Function not implemented
NOLCK = 77, // No locks available
NOSYS = 78, // Function not implemented
pub const EFTYPE = 79; // Inappropriate file type or format
pub const EAUTH = 80; // Authentication error
pub const ENEEDAUTH = 81; // Need authenticator
FTYPE = 79, // Inappropriate file type or format
AUTH = 80, // Authentication error
NEEDAUTH = 81, // Need authenticator
// SystemV IPC
pub const EIDRM = 82; // Identifier removed
pub const ENOMSG = 83; // No message of desired type
pub const EOVERFLOW = 84; // Value too large to be stored in data type
// 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
pub const EILSEQ = 85; // Illegal byte sequence
// 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
pub const ENOTSUP = 86; // Not supported
// From IEEE Std 1003.1-2001
// Base, Realtime, Threads or Thread Priority Scheduling option errors
NOTSUP = 86, // Not supported
// Realtime option errors
pub const ECANCELED = 87; // Operation canceled
// Realtime option errors
CANCELED = 87, // Operation canceled
// Realtime, XSI STREAMS option errors
pub const EBADMSG = 88; // Bad or Corrupt message
// Realtime, XSI STREAMS option errors
BADMSG = 88, // Bad or Corrupt message
// XSI STREAMS option errors
pub const ENODATA = 89; // No message available
pub const ENOSR = 90; // No STREAM resources
pub const ENOSTR = 91; // Not a STREAM
pub const ETIME = 92; // STREAM ioctl timeout
// 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
pub const ENOATTR = 93; // Attribute not found
// File system extended attribute errors
NOATTR = 93, // Attribute not found
// Realtime, XSI STREAMS option errors
pub const EMULTIHOP = 94; // Multihop attempted
pub const ENOLINK = 95; // Link has been severed
pub const EPROTO = 96; // Protocol error
// Realtime, XSI STREAMS option errors
MULTIHOP = 94, // Multihop attempted
NOLINK = 95, // Link has been severed
PROTO = 96, // Protocol error
pub const ELAST = 96; // Must equal largest errno
_,
};
pub const MINSIGSTKSZ = 8192;
pub const SIGSTKSZ = MINSIGSTKSZ + 32768;

View file

@ -295,6 +295,7 @@ pub const AI_NUMERICSERV = 16;
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;
@ -824,125 +825,129 @@ pub usingnamespace switch (builtin.target.cpu.arch) {
pub const sigset_t = c_uint;
pub const empty_sigset: sigset_t = 0;
pub const EPERM = 1; // Operation not permitted
pub const ENOENT = 2; // No such file or directory
pub const ESRCH = 3; // No such process
pub const EINTR = 4; // Interrupted system call
pub const EIO = 5; // Input/output error
pub const ENXIO = 6; // Device not configured
pub const E2BIG = 7; // Argument list too long
pub const ENOEXEC = 8; // Exec format error
pub const EBADF = 9; // Bad file descriptor
pub const ECHILD = 10; // No child processes
pub const EDEADLK = 11; // Resource deadlock avoided
// 11 was EAGAIN
pub const ENOMEM = 12; // Cannot allocate memory
pub const EACCES = 13; // Permission denied
pub const EFAULT = 14; // Bad address
pub const ENOTBLK = 15; // Block device required
pub const EBUSY = 16; // Device busy
pub const EEXIST = 17; // File exists
pub const EXDEV = 18; // Cross-device link
pub const ENODEV = 19; // Operation not supported by device
pub const ENOTDIR = 20; // Not a directory
pub const EISDIR = 21; // Is a directory
pub const EINVAL = 22; // Invalid argument
pub const ENFILE = 23; // Too many open files in system
pub const EMFILE = 24; // Too many open files
pub const ENOTTY = 25; // Inappropriate ioctl for device
pub const ETXTBSY = 26; // Text file busy
pub const EFBIG = 27; // File too large
pub const ENOSPC = 28; // No space left on device
pub const ESPIPE = 29; // Illegal seek
pub const EROFS = 30; // Read-only file system
pub const EMLINK = 31; // Too many links
pub const EPIPE = 32; // Broken pipe
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
pub const EDOM = 33; // Numerical argument out of domain
pub const ERANGE = 34; // Result too large or too small
// math software
DOM = 33, // Numerical argument out of domain
RANGE = 34, // Result too large or too small
// non-blocking and interrupt i/o
pub const EAGAIN = 35; // Resource temporarily unavailable
pub const EWOULDBLOCK = EAGAIN; // Operation would block
pub const EINPROGRESS = 36; // Operation now in progress
pub const EALREADY = 37; // Operation already in progress
// 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
pub const ENOTSOCK = 38; // Socket operation on non-socket
pub const EDESTADDRREQ = 39; // Destination address required
pub const EMSGSIZE = 40; // Message too long
pub const EPROTOTYPE = 41; // Protocol wrong type for socket
pub const ENOPROTOOPT = 42; // Protocol option not available
pub const EPROTONOSUPPORT = 43; // Protocol not supported
pub const ESOCKTNOSUPPORT = 44; // Socket type not supported
pub const EOPNOTSUPP = 45; // Operation not supported
pub const EPFNOSUPPORT = 46; // Protocol family not supported
pub const EAFNOSUPPORT = 47; // Address family not supported by protocol family
pub const EADDRINUSE = 48; // Address already in use
pub const EADDRNOTAVAIL = 49; // Can't assign requested address
// 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
pub const ENETDOWN = 50; // Network is down
pub const ENETUNREACH = 51; // Network is unreachable
pub const ENETRESET = 52; // Network dropped connection on reset
pub const ECONNABORTED = 53; // Software caused connection abort
pub const ECONNRESET = 54; // Connection reset by peer
pub const ENOBUFS = 55; // No buffer space available
pub const EISCONN = 56; // Socket is already connected
pub const ENOTCONN = 57; // Socket is not connected
pub const ESHUTDOWN = 58; // Can't send after socket shutdown
pub const ETOOMANYREFS = 59; // Too many references: can't splice
pub const ETIMEDOUT = 60; // Operation timed out
pub const ECONNREFUSED = 61; // Connection refused
// 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
pub const ELOOP = 62; // Too many levels of symbolic links
pub const ENAMETOOLONG = 63; // File name too long
LOOP = 62, // Too many levels of symbolic links
NAMETOOLONG = 63, // File name too long
// should be rearranged
pub const EHOSTDOWN = 64; // Host is down
pub const EHOSTUNREACH = 65; // No route to host
pub const ENOTEMPTY = 66; // Directory not empty
// should be rearranged
HOSTDOWN = 64, // Host is down
HOSTUNREACH = 65, // No route to host
NOTEMPTY = 66, // Directory not empty
// quotas & mush
pub const EPROCLIM = 67; // Too many processes
pub const EUSERS = 68; // Too many users
pub const EDQUOT = 69; // Disc quota exceeded
// quotas & mush
PROCLIM = 67, // Too many processes
USERS = 68, // Too many users
DQUOT = 69, // Disc quota exceeded
// Network File System
pub const ESTALE = 70; // Stale NFS file handle
pub const EREMOTE = 71; // Too many levels of remote in path
pub const EBADRPC = 72; // RPC struct is bad
pub const ERPCMISMATCH = 73; // RPC version wrong
pub const EPROGUNAVAIL = 74; // RPC prog. not avail
pub const EPROGMISMATCH = 75; // Program version wrong
pub const EPROCUNAVAIL = 76; // Bad procedure for program
// 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
pub const ENOLCK = 77; // No locks available
pub const ENOSYS = 78; // Function not implemented
NOLCK = 77, // No locks available
NOSYS = 78, // Function not implemented
pub const EFTYPE = 79; // Inappropriate file type or format
pub const EAUTH = 80; // Authentication error
pub const ENEEDAUTH = 81; // Need authenticator
pub const EIPSEC = 82; // IPsec processing failure
pub const ENOATTR = 83; // Attribute not found
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
pub const EILSEQ = 84; // Illegal byte sequence
// Wide/multibyte-character handling, ISO/IEC 9899/AMD1:1995
ILSEQ = 84, // Illegal byte sequence
pub const ENOMEDIUM = 85; // No medium found
pub const EMEDIUMTYPE = 86; // Wrong medium type
pub const EOVERFLOW = 87; // Value too large to be stored in data type
pub const ECANCELED = 88; // Operation canceled
pub const EIDRM = 89; // Identifier removed
pub const ENOMSG = 90; // No message of desired type
pub const ENOTSUP = 91; // Not supported
pub const EBADMSG = 92; // Bad or Corrupt message
pub const ENOTRECOVERABLE = 93; // State not recoverable
pub const EOWNERDEAD = 94; // Previous owner died
pub const EPROTO = 95; // Protocol error
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
pub const ELAST = 95; // Must equal largest errno
_,
};
const _MAX_PAGE_SHIFT = switch (builtin.target.cpu.arch) {
.i386 => 12,

View file

@ -111,86 +111,89 @@ pub const dirent_t = extern struct {
d_type: filetype_t,
};
pub const errno_t = u16;
pub const ESUCCESS: errno_t = 0;
pub const E2BIG: errno_t = 1;
pub const EACCES: errno_t = 2;
pub const EADDRINUSE: errno_t = 3;
pub const EADDRNOTAVAIL: errno_t = 4;
pub const EAFNOSUPPORT: errno_t = 5;
pub const EAGAIN: errno_t = 6;
pub const EWOULDBLOCK = EAGAIN;
pub const EALREADY: errno_t = 7;
pub const EBADF: errno_t = 8;
pub const EBADMSG: errno_t = 9;
pub const EBUSY: errno_t = 10;
pub const ECANCELED: errno_t = 11;
pub const ECHILD: errno_t = 12;
pub const ECONNABORTED: errno_t = 13;
pub const ECONNREFUSED: errno_t = 14;
pub const ECONNRESET: errno_t = 15;
pub const EDEADLK: errno_t = 16;
pub const EDESTADDRREQ: errno_t = 17;
pub const EDOM: errno_t = 18;
pub const EDQUOT: errno_t = 19;
pub const EEXIST: errno_t = 20;
pub const EFAULT: errno_t = 21;
pub const EFBIG: errno_t = 22;
pub const EHOSTUNREACH: errno_t = 23;
pub const EIDRM: errno_t = 24;
pub const EILSEQ: errno_t = 25;
pub const EINPROGRESS: errno_t = 26;
pub const EINTR: errno_t = 27;
pub const EINVAL: errno_t = 28;
pub const EIO: errno_t = 29;
pub const EISCONN: errno_t = 30;
pub const EISDIR: errno_t = 31;
pub const ELOOP: errno_t = 32;
pub const EMFILE: errno_t = 33;
pub const EMLINK: errno_t = 34;
pub const EMSGSIZE: errno_t = 35;
pub const EMULTIHOP: errno_t = 36;
pub const ENAMETOOLONG: errno_t = 37;
pub const ENETDOWN: errno_t = 38;
pub const ENETRESET: errno_t = 39;
pub const ENETUNREACH: errno_t = 40;
pub const ENFILE: errno_t = 41;
pub const ENOBUFS: errno_t = 42;
pub const ENODEV: errno_t = 43;
pub const ENOENT: errno_t = 44;
pub const ENOEXEC: errno_t = 45;
pub const ENOLCK: errno_t = 46;
pub const ENOLINK: errno_t = 47;
pub const ENOMEM: errno_t = 48;
pub const ENOMSG: errno_t = 49;
pub const ENOPROTOOPT: errno_t = 50;
pub const ENOSPC: errno_t = 51;
pub const ENOSYS: errno_t = 52;
pub const ENOTCONN: errno_t = 53;
pub const ENOTDIR: errno_t = 54;
pub const ENOTEMPTY: errno_t = 55;
pub const ENOTRECOVERABLE: errno_t = 56;
pub const ENOTSOCK: errno_t = 57;
pub const ENOTSUP: errno_t = 58;
pub const EOPNOTSUPP = ENOTSUP;
pub const ENOTTY: errno_t = 59;
pub const ENXIO: errno_t = 60;
pub const EOVERFLOW: errno_t = 61;
pub const EOWNERDEAD: errno_t = 62;
pub const EPERM: errno_t = 63;
pub const EPIPE: errno_t = 64;
pub const EPROTO: errno_t = 65;
pub const EPROTONOSUPPORT: errno_t = 66;
pub const EPROTOTYPE: errno_t = 67;
pub const ERANGE: errno_t = 68;
pub const EROFS: errno_t = 69;
pub const ESPIPE: errno_t = 70;
pub const ESRCH: errno_t = 71;
pub const ESTALE: errno_t = 72;
pub const ETIMEDOUT: errno_t = 73;
pub const ETXTBSY: errno_t = 74;
pub const EXDEV: errno_t = 75;
pub const ENOTCAPABLE: errno_t = 76;
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,

View file

@ -87,94 +87,98 @@ pub const SEEK_SET = 0;
pub const SEEK_CUR = 1;
pub const SEEK_END = 2;
pub const EPERM = 1;
pub const ENOENT = 2;
pub const ESRCH = 3;
pub const EINTR = 4;
pub const EIO = 5;
pub const ENXIO = 6;
pub const E2BIG = 7;
pub const ENOEXEC = 8;
pub const EBADF = 9;
pub const ECHILD = 10;
pub const EAGAIN = 11;
pub const ENOMEM = 12;
pub const EACCES = 13;
pub const EFAULT = 14;
pub const EBUSY = 16;
pub const EEXIST = 17;
pub const EXDEV = 18;
pub const ENODEV = 19;
pub const ENOTDIR = 20;
pub const EISDIR = 21;
pub const ENFILE = 23;
pub const EMFILE = 24;
pub const ENOTTY = 25;
pub const EFBIG = 27;
pub const ENOSPC = 28;
pub const ESPIPE = 29;
pub const EROFS = 30;
pub const EMLINK = 31;
pub const EPIPE = 32;
pub const EDOM = 33;
pub const EDEADLK = 36;
pub const ENAMETOOLONG = 38;
pub const ENOLCK = 39;
pub const ENOSYS = 40;
pub const ENOTEMPTY = 41;
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 EINVAL = 22;
pub const ERANGE = 34;
pub const EILSEQ = 42;
pub const STRUNCATE = 80;
// Support EDEADLOCK for compatibility with older Microsoft C versions
pub const EDEADLOCK = EDEADLK;
// POSIX Supplement
pub const EADDRINUSE = 100;
pub const EADDRNOTAVAIL = 101;
pub const EAFNOSUPPORT = 102;
pub const EALREADY = 103;
pub const EBADMSG = 104;
pub const ECANCELED = 105;
pub const ECONNABORTED = 106;
pub const ECONNREFUSED = 107;
pub const ECONNRESET = 108;
pub const EDESTADDRREQ = 109;
pub const EHOSTUNREACH = 110;
pub const EIDRM = 111;
pub const EINPROGRESS = 112;
pub const EISCONN = 113;
pub const ELOOP = 114;
pub const EMSGSIZE = 115;
pub const ENETDOWN = 116;
pub const ENETRESET = 117;
pub const ENETUNREACH = 118;
pub const ENOBUFS = 119;
pub const ENODATA = 120;
pub const ENOLINK = 121;
pub const ENOMSG = 122;
pub const ENOPROTOOPT = 123;
pub const ENOSR = 124;
pub const ENOSTR = 125;
pub const ENOTCONN = 126;
pub const ENOTRECOVERABLE = 127;
pub const ENOTSOCK = 128;
pub const ENOTSUP = 129;
pub const EOPNOTSUPP = 130;
pub const EOTHER = 131;
pub const EOVERFLOW = 132;
pub const EOWNERDEAD = 133;
pub const EPROTO = 134;
pub const EPROTONOSUPPORT = 135;
pub const EPROTOTYPE = 136;
pub const ETIME = 137;
pub const ETIMEDOUT = 138;
pub const ETXTBSY = 139;
pub const EWOULDBLOCK = 140;
pub const EDQUOT = 10069;
pub const F_OK = 0;
/// Remove directory instead of unlinking file

View file

@ -91,9 +91,10 @@ fn splitValue64(val: i64) [2]u32 {
}
/// Get the errno from a syscall return value, or 0 for no error.
pub fn getErrno(r: usize) u12 {
pub fn getErrno(r: usize) E {
const signed_r = @bitCast(isize, r);
return if (signed_r > -4096 and signed_r < 0) @intCast(u12, -signed_r) else 0;
const int = if (signed_r > -4096 and signed_r < 0) -signed_r else 0;
return @intToEnum(E, int);
}
pub fn dup(old: i32) usize {
@ -281,7 +282,7 @@ pub fn mmap(address: ?[*]u8, length: usize, prot: usize, flags: u32, fd: i32, of
if (@hasField(SYS, "mmap2")) {
// Make sure the offset is also specified in multiples of page size
if ((offset & (MMAP2_UNIT - 1)) != 0)
return @bitCast(usize, @as(isize, -EINVAL));
return @bitCast(usize, -@as(isize, @enumToInt(E.INVAL)));
return syscall6(
.mmap2,
@ -746,7 +747,7 @@ pub fn clock_gettime(clk_id: i32, tp: *timespec) usize {
const f = @ptrCast(vdso_clock_gettime_ty, fn_ptr);
const rc = f(clk_id, tp);
switch (rc) {
0, @bitCast(usize, @as(isize, -EINVAL)) => return rc,
0, @bitCast(usize, -@as(isize, @enumToInt(E.INVAL))) => return rc,
else => {},
}
}
@ -764,7 +765,7 @@ fn init_vdso_clock_gettime(clk: i32, ts: *timespec) callconv(.C) usize {
const f = @ptrCast(vdso_clock_gettime_ty, fn_ptr);
return f(clk, ts);
}
return @bitCast(usize, @as(isize, -ENOSYS));
return @bitCast(usize, -@as(isize, @enumToInt(E.NOSYS)));
}
pub fn clock_getres(clk_id: i32, tp: *timespec) usize {
@ -961,7 +962,7 @@ pub fn sigaction(sig: u6, noalias act: ?*const Sigaction, noalias oact: ?*Sigact
.sparc, .sparcv9 => syscall5(.rt_sigaction, sig, ksa_arg, oldksa_arg, @ptrToInt(ksa.restorer), mask_size),
else => syscall4(.rt_sigaction, sig, ksa_arg, oldksa_arg, mask_size),
};
if (getErrno(result) != 0) return result;
if (getErrno(result) != .SUCCESS) return result;
if (oact) |old| {
old.handler.handler = oldksa.handler;
@ -1202,7 +1203,7 @@ pub fn statx(dirfd: i32, path: [*]const u8, flags: u32, mask: u32, statx_buf: *S
@ptrToInt(statx_buf),
);
}
return @bitCast(usize, @as(isize, -ENOSYS));
return @bitCast(usize, -@as(isize, @enumToInt(E.NOSYS)));
}
pub fn listxattr(path: [*:0]const u8, list: [*]u8, size: usize) usize {

View file

@ -1508,13 +1508,13 @@ pub fn map_create(map_type: MapType, key_size: u32, value_size: u32, max_entries
attr.map_create.max_entries = max_entries;
const rc = bpf(.map_create, &attr, @sizeOf(MapCreateAttr));
return switch (errno(rc)) {
0 => @intCast(fd_t, rc),
EINVAL => error.MapTypeOrAttrInvalid,
ENOMEM => error.SystemResources,
EPERM => error.AccessDenied,
else => |err| unexpectedErrno(err),
};
switch (errno(rc)) {
.SUCCESS => return @intCast(fd_t, rc),
.INVAL => return error.MapTypeOrAttrInvalid,
.NOMEM => return error.SystemResources,
.PERM => return error.AccessDenied,
else => |err| return unexpectedErrno(err),
}
}
test "map_create" {
@ -1533,12 +1533,12 @@ pub fn map_lookup_elem(fd: fd_t, key: []const u8, value: []u8) !void {
const rc = bpf(.map_lookup_elem, &attr, @sizeOf(MapElemAttr));
switch (errno(rc)) {
0 => return,
EBADF => return error.BadFd,
EFAULT => unreachable,
EINVAL => return error.FieldInAttrNeedsZeroing,
ENOENT => return error.NotFound,
EPERM => return error.AccessDenied,
.SUCCESS => return,
.BADF => return error.BadFd,
.FAULT => unreachable,
.INVAL => return error.FieldInAttrNeedsZeroing,
.NOENT => return error.NotFound,
.PERM => return error.AccessDenied,
else => |err| return unexpectedErrno(err),
}
}
@ -1555,13 +1555,13 @@ pub fn map_update_elem(fd: fd_t, key: []const u8, value: []const u8, flags: u64)
const rc = bpf(.map_update_elem, &attr, @sizeOf(MapElemAttr));
switch (errno(rc)) {
0 => return,
E2BIG => return error.ReachedMaxEntries,
EBADF => return error.BadFd,
EFAULT => unreachable,
EINVAL => return error.FieldInAttrNeedsZeroing,
ENOMEM => return error.SystemResources,
EPERM => return error.AccessDenied,
.SUCCESS => return,
.@"2BIG" => return error.ReachedMaxEntries,
.BADF => return error.BadFd,
.FAULT => unreachable,
.INVAL => return error.FieldInAttrNeedsZeroing,
.NOMEM => return error.SystemResources,
.PERM => return error.AccessDenied,
else => |err| return unexpectedErrno(err),
}
}
@ -1576,12 +1576,12 @@ pub fn map_delete_elem(fd: fd_t, key: []const u8) !void {
const rc = bpf(.map_delete_elem, &attr, @sizeOf(MapElemAttr));
switch (errno(rc)) {
0 => return,
EBADF => return error.BadFd,
EFAULT => unreachable,
EINVAL => return error.FieldInAttrNeedsZeroing,
ENOENT => return error.NotFound,
EPERM => return error.AccessDenied,
.SUCCESS => return,
.BADF => return error.BadFd,
.FAULT => unreachable,
.INVAL => return error.FieldInAttrNeedsZeroing,
.NOENT => return error.NotFound,
.PERM => return error.AccessDenied,
else => |err| return unexpectedErrno(err),
}
}
@ -1639,11 +1639,11 @@ pub fn prog_load(
const rc = bpf(.prog_load, &attr, @sizeOf(ProgLoadAttr));
return switch (errno(rc)) {
0 => @intCast(fd_t, rc),
EACCES => error.UnsafeProgram,
EFAULT => unreachable,
EINVAL => error.InvalidProgram,
EPERM => error.AccessDenied,
.SUCCESS => @intCast(fd_t, rc),
.ACCES => error.UnsafeProgram,
.FAULT => unreachable,
.INVAL => error.InvalidProgram,
.PERM => error.AccessDenied,
else => |err| unexpectedErrno(err),
};
}

View file

@ -54,19 +54,19 @@ pub const IO_Uring = struct {
const res = linux.io_uring_setup(entries, p);
switch (linux.getErrno(res)) {
0 => {},
linux.EFAULT => return error.ParamsOutsideAccessibleAddressSpace,
.SUCCESS => {},
.FAULT => return error.ParamsOutsideAccessibleAddressSpace,
// The resv array contains non-zero data, p.flags contains an unsupported flag,
// entries out of bounds, IORING_SETUP_SQ_AFF was specified without IORING_SETUP_SQPOLL,
// or IORING_SETUP_CQSIZE was specified but io_uring_params.cq_entries was invalid:
linux.EINVAL => return error.ArgumentsInvalid,
linux.EMFILE => return error.ProcessFdQuotaExceeded,
linux.ENFILE => return error.SystemFdQuotaExceeded,
linux.ENOMEM => return error.SystemResources,
.INVAL => return error.ArgumentsInvalid,
.MFILE => return error.ProcessFdQuotaExceeded,
.NFILE => return error.SystemFdQuotaExceeded,
.NOMEM => return error.SystemResources,
// IORING_SETUP_SQPOLL was specified but effective user ID lacks sufficient privileges,
// or a container seccomp policy prohibits io_uring syscalls:
linux.EPERM => return error.PermissionDenied,
linux.ENOSYS => return error.SystemOutdated,
.PERM => return error.PermissionDenied,
.NOSYS => return error.SystemOutdated,
else => |errno| return os.unexpectedErrno(errno),
}
const fd = @intCast(os.fd_t, res);
@ -180,31 +180,31 @@ pub const IO_Uring = struct {
assert(self.fd >= 0);
const res = linux.io_uring_enter(self.fd, to_submit, min_complete, flags, null);
switch (linux.getErrno(res)) {
0 => {},
.SUCCESS => {},
// The kernel was unable to allocate memory or ran out of resources for the request.
// The application should wait for some completions and try again:
linux.EAGAIN => return error.SystemResources,
.AGAIN => return error.SystemResources,
// The SQE `fd` is invalid, or IOSQE_FIXED_FILE was set but no files were registered:
linux.EBADF => return error.FileDescriptorInvalid,
.BADF => return error.FileDescriptorInvalid,
// The file descriptor is valid, but the ring is not in the right state.
// See io_uring_register(2) for how to enable the ring.
linux.EBADFD => return error.FileDescriptorInBadState,
.BADFD => return error.FileDescriptorInBadState,
// The application attempted to overcommit the number of requests it can have pending.
// The application should wait for some completions and try again:
linux.EBUSY => return error.CompletionQueueOvercommitted,
.BUSY => return error.CompletionQueueOvercommitted,
// The SQE is invalid, or valid but the ring was setup with IORING_SETUP_IOPOLL:
linux.EINVAL => return error.SubmissionQueueEntryInvalid,
.INVAL => return error.SubmissionQueueEntryInvalid,
// The buffer is outside the process' accessible address space, or IORING_OP_READ_FIXED
// or IORING_OP_WRITE_FIXED was specified but no buffers were registered, or the range
// described by `addr` and `len` is not within the buffer registered at `buf_index`:
linux.EFAULT => return error.BufferInvalid,
linux.ENXIO => return error.RingShuttingDown,
.FAULT => return error.BufferInvalid,
.NXIO => return error.RingShuttingDown,
// The kernel believes our `self.fd` does not refer to an io_uring instance,
// or the opcode is valid but not supported by this kernel (more likely):
linux.EOPNOTSUPP => return error.OpcodeNotSupported,
.OPNOTSUPP => return error.OpcodeNotSupported,
// The operation was interrupted by a delivery of a signal before it could complete.
// This can happen while waiting for events with IORING_ENTER_GETEVENTS:
linux.EINTR => return error.SignalInterrupt,
.INTR => return error.SignalInterrupt,
else => |errno| return os.unexpectedErrno(errno),
}
return @intCast(u32, res);
@ -681,22 +681,22 @@ pub const IO_Uring = struct {
fn handle_registration_result(res: usize) !void {
switch (linux.getErrno(res)) {
0 => {},
.SUCCESS => {},
// One or more fds in the array are invalid, or the kernel does not support sparse sets:
linux.EBADF => return error.FileDescriptorInvalid,
linux.EBUSY => return error.FilesAlreadyRegistered,
linux.EINVAL => return error.FilesEmpty,
.BADF => return error.FileDescriptorInvalid,
.BUSY => return error.FilesAlreadyRegistered,
.INVAL => return error.FilesEmpty,
// Adding `nr_args` file references would exceed the maximum allowed number of files the
// user is allowed to have according to the per-user RLIMIT_NOFILE resource limit and
// the CAP_SYS_RESOURCE capability is not set, or `nr_args` exceeds the maximum allowed
// for a fixed file set (older kernels have a limit of 1024 files vs 64K files):
linux.EMFILE => return error.UserFdQuotaExceeded,
.MFILE => return error.UserFdQuotaExceeded,
// Insufficient kernel resources, or the caller had a non-zero RLIMIT_MEMLOCK soft
// resource limit but tried to lock more memory than the limit permitted (not enforced
// when the process is privileged with CAP_IPC_LOCK):
linux.ENOMEM => return error.SystemResources,
.NOMEM => return error.SystemResources,
// Attempt to register files on a ring already registering files or being torn down:
linux.ENXIO => return error.RingShuttingDownOrAlreadyRegisteringFiles,
.NXIO => return error.RingShuttingDownOrAlreadyRegisteringFiles,
else => |errno| return os.unexpectedErrno(errno),
}
}
@ -706,8 +706,8 @@ pub const IO_Uring = struct {
assert(self.fd >= 0);
const res = linux.io_uring_register(self.fd, .UNREGISTER_FILES, null, 0);
switch (linux.getErrno(res)) {
0 => {},
linux.ENXIO => return error.FilesNotRegistered,
.SUCCESS => {},
.NXIO => return error.FilesNotRegistered,
else => |errno| return os.unexpectedErrno(errno),
}
}
@ -1272,8 +1272,8 @@ test "write/read" {
const cqe_read = try ring.copy_cqe();
// Prior to Linux Kernel 5.6 this is the only way to test for read/write support:
// https://lwn.net/Articles/809820/
if (cqe_write.res == -linux.EINVAL) return error.SkipZigTest;
if (cqe_read.res == -linux.EINVAL) return error.SkipZigTest;
if (cqe_write.err() == .INVAL) return error.SkipZigTest;
if (cqe_read.err() == .INVAL) return error.SkipZigTest;
try testing.expectEqual(linux.io_uring_cqe{
.user_data = 0x11111111,
.res = buffer_write.len,
@ -1322,11 +1322,11 @@ test "openat" {
const cqe_openat = try ring.copy_cqe();
try testing.expectEqual(@as(u64, 0x33333333), cqe_openat.user_data);
if (cqe_openat.res == -linux.EINVAL) return error.SkipZigTest;
if (cqe_openat.err() == .INVAL) return error.SkipZigTest;
// 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.res == -linux.EBADF and (ring.features & linux.IORING_FEAT_RW_CUR_POS) == 0) {
if (cqe_openat.err() == .BADF and (ring.features & linux.IORING_FEAT_RW_CUR_POS) == 0) {
return error.SkipZigTest;
}
if (cqe_openat.res <= 0) std.debug.print("\ncqe_openat.res={}\n", .{cqe_openat.res});
@ -1357,7 +1357,7 @@ test "close" {
try testing.expectEqual(@as(u32, 1), try ring.submit());
const cqe_close = try ring.copy_cqe();
if (cqe_close.res == -linux.EINVAL) return error.SkipZigTest;
if (cqe_close.err() == .INVAL) return error.SkipZigTest;
try testing.expectEqual(linux.io_uring_cqe{
.user_data = 0x44444444,
.res = 0,
@ -1397,9 +1397,9 @@ test "accept/connect/send/recv" {
try testing.expectEqual(@as(u32, 1), try ring.submit());
var cqe_accept = try ring.copy_cqe();
if (cqe_accept.res == -linux.EINVAL) return error.SkipZigTest;
if (cqe_accept.err() == .INVAL) return error.SkipZigTest;
var cqe_connect = try ring.copy_cqe();
if (cqe_connect.res == -linux.EINVAL) return error.SkipZigTest;
if (cqe_connect.err() == .INVAL) return error.SkipZigTest;
// The accept/connect CQEs may arrive in any order, the connect CQE will sometimes come first:
if (cqe_accept.user_data == 0xcccccccc and cqe_connect.user_data == 0xaaaaaaaa) {
@ -1425,7 +1425,7 @@ test "accept/connect/send/recv" {
try testing.expectEqual(@as(u32, 2), try ring.submit());
const cqe_send = try ring.copy_cqe();
if (cqe_send.res == -linux.EINVAL) return error.SkipZigTest;
if (cqe_send.err() == .INVAL) return error.SkipZigTest;
try testing.expectEqual(linux.io_uring_cqe{
.user_data = 0xeeeeeeee,
.res = buffer_send.len,
@ -1433,7 +1433,7 @@ test "accept/connect/send/recv" {
}, cqe_send);
const cqe_recv = try ring.copy_cqe();
if (cqe_recv.res == -linux.EINVAL) return error.SkipZigTest;
if (cqe_recv.err() == .INVAL) return error.SkipZigTest;
try testing.expectEqual(linux.io_uring_cqe{
.user_data = 0xffffffff,
.res = buffer_recv.len,
@ -1466,7 +1466,7 @@ test "timeout (after a relative time)" {
try testing.expectEqual(linux.io_uring_cqe{
.user_data = 0x55555555,
.res = -linux.ETIME,
.res = -@as(i32, @enumToInt(linux.E.TIME)),
.flags = 0,
}, cqe);
@ -1535,14 +1535,14 @@ test "timeout_remove" {
// We use IORING_FEAT_RW_CUR_POS as a safety check here to make sure we are at least pre-5.6.
// We don't want to skip this test for newer kernels.
if (cqe_timeout.user_data == 0x99999999 and
cqe_timeout.res == -linux.EBADF and
cqe_timeout.err() == .BADF and
(ring.features & linux.IORING_FEAT_RW_CUR_POS) == 0)
{
return error.SkipZigTest;
}
try testing.expectEqual(linux.io_uring_cqe{
.user_data = 0x88888888,
.res = -linux.ECANCELED,
.res = -@as(i32, @enumToInt(linux.E.CANCELED)),
.flags = 0,
}, cqe_timeout);
@ -1578,15 +1578,15 @@ test "fallocate" {
try testing.expectEqual(@as(u32, 1), try ring.submit());
const cqe = try ring.copy_cqe();
switch (-cqe.res) {
0 => {},
switch (cqe.err()) {
.SUCCESS => {},
// This kernel's io_uring does not yet implement fallocate():
linux.EINVAL => return error.SkipZigTest,
.INVAL => return error.SkipZigTest,
// This kernel does not implement fallocate():
linux.ENOSYS => return error.SkipZigTest,
.NOSYS => return error.SkipZigTest,
// The filesystem containing the file referred to by fd does not support this operation;
// or the mode is not supported by the filesystem containing the file referred to by fd:
linux.EOPNOTSUPP => return error.SkipZigTest,
.OPNOTSUPP => return error.SkipZigTest,
else => |errno| std.debug.panic("unhandled errno: {}", .{errno}),
}
try testing.expectEqual(linux.io_uring_cqe{

View file

@ -22,9 +22,9 @@ test "fallocate" {
const len: i64 = 65536;
switch (linux.getErrno(linux.fallocate(file.handle, 0, 0, len))) {
0 => {},
linux.ENOSYS => return error.SkipZigTest,
linux.EOPNOTSUPP => return error.SkipZigTest,
.SUCCESS => {},
.NOSYS => return error.SkipZigTest,
.OPNOTSUPP => return error.SkipZigTest,
else => |errno| std.debug.panic("unhandled errno: {}", .{errno}),
}
@ -37,11 +37,11 @@ test "getpid" {
test "timer" {
const epoll_fd = linux.epoll_create();
var err: usize = linux.getErrno(epoll_fd);
try expect(err == 0);
var err: linux.E = linux.getErrno(epoll_fd);
try expect(err == .SUCCESS);
const timer_fd = linux.timerfd_create(linux.CLOCK_MONOTONIC, 0);
try expect(linux.getErrno(timer_fd) == 0);
try expect(linux.getErrno(timer_fd) == .SUCCESS);
const time_interval = linux.timespec{
.tv_sec = 0,
@ -53,22 +53,22 @@ test "timer" {
.it_value = time_interval,
};
err = linux.timerfd_settime(@intCast(i32, timer_fd), 0, &new_time, null);
try expect(err == 0);
err = linux.getErrno(linux.timerfd_settime(@intCast(i32, timer_fd), 0, &new_time, null));
try expect(err == .SUCCESS);
var event = linux.epoll_event{
.events = linux.EPOLLIN | linux.EPOLLOUT | linux.EPOLLET,
.data = linux.epoll_data{ .ptr = 0 },
};
err = linux.epoll_ctl(@intCast(i32, epoll_fd), linux.EPOLL_CTL_ADD, @intCast(i32, timer_fd), &event);
try expect(err == 0);
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;
var events = [_]linux.epoll_event{events_one} ** 8;
// TODO implicit cast from *[N]T to [*]T
err = linux.epoll_wait(@intCast(i32, epoll_fd), @ptrCast([*]linux.epoll_event, &events), 8, -1);
err = linux.getErrno(linux.epoll_wait(@intCast(i32, epoll_fd), &events, 8, -1));
try expect(err == .SUCCESS);
}
test "statx" {
@ -81,15 +81,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))) {
0 => {},
.SUCCESS => {},
// The statx syscall was only introduced in linux 4.11
linux.ENOSYS => return error.SkipZigTest,
.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))) {
0 => {},
.SUCCESS => {},
else => unreachable,
}

View file

@ -83,6 +83,6 @@ pub extern "wasi_snapshot_preview1" fn sock_send(sock: fd_t, si_data: *const cio
pub extern "wasi_snapshot_preview1" fn sock_shutdown(sock: fd_t, how: sdflags_t) errno_t;
/// Get the errno from a syscall return value, or 0 for no error.
pub fn getErrno(r: errno_t) usize {
pub fn getErrno(r: errno_t) errno_t {
return r;
}

View file

@ -93,7 +93,7 @@ pub fn getEnvMap(allocator: *Allocator) !BufMap {
var environ_buf_size: usize = undefined;
const environ_sizes_get_ret = os.wasi.environ_sizes_get(&environ_count, &environ_buf_size);
if (environ_sizes_get_ret != os.wasi.ESUCCESS) {
if (environ_sizes_get_ret != .SUCCESS) {
return os.unexpectedErrno(environ_sizes_get_ret);
}
@ -103,7 +103,7 @@ pub fn getEnvMap(allocator: *Allocator) !BufMap {
defer allocator.free(environ_buf);
const environ_get_ret = os.wasi.environ_get(environ.ptr, environ_buf.ptr);
if (environ_get_ret != os.wasi.ESUCCESS) {
if (environ_get_ret != .SUCCESS) {
return os.unexpectedErrno(environ_get_ret);
}
@ -255,7 +255,7 @@ pub const ArgIteratorWasi = struct {
var buf_size: usize = undefined;
switch (w.args_sizes_get(&count, &buf_size)) {
w.ESUCCESS => {},
.SUCCESS => {},
else => |err| return os.unexpectedErrno(err),
}
@ -265,7 +265,7 @@ pub const ArgIteratorWasi = struct {
var argv_buf = try allocator.alloc(u8, buf_size);
switch (w.args_get(argv.ptr, argv_buf.ptr)) {
w.ESUCCESS => {},
.SUCCESS => {},
else => |err| return os.unexpectedErrno(err),
}

View file

@ -201,7 +201,7 @@ const current_thread_storage = struct {
/// Initialize pthread_key_t.
fn init() void {
if (std.c.pthread_key_create(&current_thread_storage.key, current_thread_storage.deinit) != 0) {
if (std.c.pthread_key_create(&current_thread_storage.key, current_thread_storage.deinit) != .SUCCESS) {
abort();
}
}
@ -248,14 +248,14 @@ const emutls_control = extern struct {
/// Simple wrapper for global lock.
fn lock() void {
if (std.c.pthread_mutex_lock(&emutls_control.mutex) != 0) {
if (std.c.pthread_mutex_lock(&emutls_control.mutex) != .SUCCESS) {
abort();
}
}
/// Simple wrapper for global unlock.
fn unlock() void {
if (std.c.pthread_mutex_unlock(&emutls_control.mutex) != 0) {
if (std.c.pthread_mutex_unlock(&emutls_control.mutex) != .SUCCESS) {
abort();
}
}

View file

@ -92,7 +92,7 @@ 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);
assert(err == os.wasi.ESUCCESS);
assert(err == .SUCCESS);
return ns;
}
var ts: os.timespec = undefined;

View file

@ -82,32 +82,32 @@ pub fn Mixin(comptime Socket: type) type {
while (true) {
const rc = os.system.sendmsg(self.fd, &msg, @intCast(c_int, flags));
return switch (os.errno(rc)) {
0 => return @intCast(usize, rc),
os.EACCES => error.AccessDenied,
os.EAGAIN => error.WouldBlock,
os.EALREADY => error.FastOpenAlreadyInProgress,
os.EBADF => unreachable, // always a race condition
os.ECONNRESET => error.ConnectionResetByPeer,
os.EDESTADDRREQ => unreachable, // The socket is not connection-mode, and no peer address is set.
os.EFAULT => unreachable, // An invalid user space address was specified for an argument.
os.EINTR => continue,
os.EINVAL => unreachable, // Invalid argument passed.
os.EISCONN => unreachable, // connection-mode socket was connected already but a recipient was specified
os.EMSGSIZE => error.MessageTooBig,
os.ENOBUFS => error.SystemResources,
os.ENOMEM => error.SystemResources,
os.ENOTSOCK => unreachable, // The file descriptor sockfd does not refer to a socket.
os.EOPNOTSUPP => unreachable, // Some bit in the flags argument is inappropriate for the socket type.
os.EPIPE => error.BrokenPipe,
os.EAFNOSUPPORT => error.AddressFamilyNotSupported,
os.ELOOP => error.SymLinkLoop,
os.ENAMETOOLONG => error.NameTooLong,
os.ENOENT => error.FileNotFound,
os.ENOTDIR => error.NotDir,
os.EHOSTUNREACH => error.NetworkUnreachable,
os.ENETUNREACH => error.NetworkUnreachable,
os.ENOTCONN => error.SocketNotConnected,
os.ENETDOWN => error.NetworkSubsystemFailed,
.SUCCESS => return @intCast(usize, rc),
.ACCES => error.AccessDenied,
.AGAIN => error.WouldBlock,
.ALREADY => error.FastOpenAlreadyInProgress,
.BADF => unreachable, // always a race condition
.CONNRESET => error.ConnectionResetByPeer,
.DESTADDRREQ => unreachable, // The socket is not connection-mode, and no peer address is set.
.FAULT => unreachable, // An invalid user space address was specified for an argument.
.INTR => continue,
.INVAL => unreachable, // Invalid argument passed.
.ISCONN => unreachable, // connection-mode socket was connected already but a recipient was specified
.MSGSIZE => error.MessageTooBig,
.NOBUFS => error.SystemResources,
.NOMEM => error.SystemResources,
.NOTSOCK => unreachable, // The file descriptor sockfd does not refer to a socket.
.OPNOTSUPP => unreachable, // Some bit in the flags argument is inappropriate for the socket type.
.PIPE => error.BrokenPipe,
.AFNOSUPPORT => error.AddressFamilyNotSupported,
.LOOP => error.SymLinkLoop,
.NAMETOOLONG => error.NameTooLong,
.NOENT => error.FileNotFound,
.NOTDIR => error.NotDir,
.HOSTUNREACH => error.NetworkUnreachable,
.NETUNREACH => error.NetworkUnreachable,
.NOTCONN => error.SocketNotConnected,
.NETDOWN => error.NetworkSubsystemFailed,
else => |err| os.unexpectedErrno(err),
};
}
@ -120,17 +120,17 @@ pub fn Mixin(comptime Socket: type) type {
while (true) {
const rc = os.system.recvmsg(self.fd, msg, @intCast(c_int, flags));
return switch (os.errno(rc)) {
0 => @intCast(usize, rc),
os.EBADF => unreachable, // always a race condition
os.EFAULT => unreachable,
os.EINVAL => unreachable,
os.ENOTCONN => unreachable,
os.ENOTSOCK => unreachable,
os.EINTR => continue,
os.EAGAIN => error.WouldBlock,
os.ENOMEM => error.SystemResources,
os.ECONNREFUSED => error.ConnectionRefused,
os.ECONNRESET => error.ConnectionResetByPeer,
.SUCCESS => @intCast(usize, rc),
.BADF => unreachable, // always a race condition
.FAULT => unreachable,
.INVAL => unreachable,
.NOTCONN => unreachable,
.NOTSOCK => unreachable,
.INTR => continue,
.AGAIN => error.WouldBlock,
.NOMEM => error.SystemResources,
.CONNREFUSED => error.ConnectionRefused,
.CONNRESET => error.ConnectionResetByPeer,
else => |err| os.unexpectedErrno(err),
};
}
@ -164,12 +164,12 @@ pub fn Mixin(comptime Socket: type) type {
const rc = os.system.getsockopt(self.fd, os.SOL_SOCKET, os.SO_RCVBUF, mem.asBytes(&value), &value_len);
return switch (os.errno(rc)) {
0 => value,
os.EBADF => error.BadFileDescriptor,
os.EFAULT => error.InvalidAddressSpace,
os.EINVAL => error.InvalidSocketOption,
os.ENOPROTOOPT => error.UnknownSocketOption,
os.ENOTSOCK => error.NotASocket,
.SUCCESS => value,
.BADF => error.BadFileDescriptor,
.FAULT => error.InvalidAddressSpace,
.INVAL => error.InvalidSocketOption,
.NOPROTOOPT => error.UnknownSocketOption,
.NOTSOCK => error.NotASocket,
else => |err| os.unexpectedErrno(err),
};
}
@ -181,12 +181,12 @@ pub fn Mixin(comptime Socket: type) type {
const rc = os.system.getsockopt(self.fd, os.SOL_SOCKET, os.SO_SNDBUF, mem.asBytes(&value), &value_len);
return switch (os.errno(rc)) {
0 => value,
os.EBADF => error.BadFileDescriptor,
os.EFAULT => error.InvalidAddressSpace,
os.EINVAL => error.InvalidSocketOption,
os.ENOPROTOOPT => error.UnknownSocketOption,
os.ENOTSOCK => error.NotASocket,
.SUCCESS => value,
.BADF => error.BadFileDescriptor,
.FAULT => error.InvalidAddressSpace,
.INVAL => error.InvalidSocketOption,
.NOPROTOOPT => error.UnknownSocketOption,
.NOTSOCK => error.NotASocket,
else => |err| os.unexpectedErrno(err),
};
}