| author | |
| committer | |
| log | a98fa56ae9ad437d3e4241bc2c231e0745766ba9 |
| tree | fa621754f81e0007a6f894c0f726e810f0462d95 |
| parent | 9e3ec98937de07d0e06f483ba8f7e6592b4dd152 |
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.40 files changed, 3509 insertions(+), 3448 deletions(-)
CMakeLists.txt+1-1| ... | ... | @@ -426,7 +426,7 @@ set(ZIG_STAGE2_SOURCES |
| 426 | 426 | "${CMAKE_SOURCE_DIR}/lib/std/os.zig" |
| 427 | 427 | "${CMAKE_SOURCE_DIR}/lib/std/os/bits.zig" |
| 428 | 428 | "${CMAKE_SOURCE_DIR}/lib/std/os/bits/linux.zig" |
| 429 | "${CMAKE_SOURCE_DIR}/lib/std/os/bits/linux/errno-generic.zig" | |
| 429 | "${CMAKE_SOURCE_DIR}/lib/std/os/bits/linux/errno/generic.zig" | |
| 430 | 430 | "${CMAKE_SOURCE_DIR}/lib/std/os/bits/linux/netlink.zig" |
| 431 | 431 | "${CMAKE_SOURCE_DIR}/lib/std/os/bits/linux/prctl.zig" |
| 432 | 432 | "${CMAKE_SOURCE_DIR}/lib/std/os/bits/linux/securebits.zig" |
lib/std/Thread.zig+85-81| ... | ... | @@ -9,9 +9,10 @@ |
| 9 | 9 | //! both evented I/O and async I/O, see the respective names in the top level std namespace. |
| 10 | 10 | |
| 11 | 11 | const std = @import("std.zig"); |
| 12 | const builtin = @import("builtin"); | |
| 12 | 13 | const os = std.os; |
| 13 | 14 | const assert = std.debug.assert; |
| 14 | const target = std.Target.current; | |
| 15 | const target = builtin.target; | |
| 15 | 16 | const Atomic = std.atomic.Atomic; |
| 16 | 17 | |
| 17 | 18 | pub const AutoResetEvent = @import("Thread/AutoResetEvent.zig"); |
| ... | ... | @@ -24,7 +25,8 @@ pub const Condition = @import("Thread/Condition.zig"); |
| 24 | 25 | |
| 25 | 26 | pub const spinLoopHint = @compileError("deprecated: use std.atomic.spinLoopHint"); |
| 26 | 27 | |
| 27 | pub const use_pthreads = target.os.tag != .windows and std.Target.current.os.tag != .wasi and std.builtin.link_libc; | |
| 28 | pub const use_pthreads = target.os.tag != .windows and target.os.tag != .wasi and builtin.link_libc; | |
| 29 | const is_gnu = target.abi.isGnu(); | |
| 28 | 30 | |
| 29 | 31 | const Thread = @This(); |
| 30 | 32 | const Impl = if (target.os.tag == .windows) |
| ... | ... | @@ -38,7 +40,7 @@ else |
| 38 | 40 | |
| 39 | 41 | impl: Impl, |
| 40 | 42 | |
| 41 | pub const max_name_len = switch (std.Target.current.os.tag) { | |
| 43 | pub const max_name_len = switch (target.os.tag) { | |
| 42 | 44 | .linux => 15, |
| 43 | 45 | .windows => 31, |
| 44 | 46 | .macos, .ios, .watchos, .tvos => 63, |
| ... | ... | @@ -64,20 +66,21 @@ pub fn setName(self: Thread, name: []const u8) SetNameError!void { |
| 64 | 66 | break :blk name_buf[0..name.len :0]; |
| 65 | 67 | }; |
| 66 | 68 | |
| 67 | switch (std.Target.current.os.tag) { | |
| 69 | switch (target.os.tag) { | |
| 68 | 70 | .linux => if (use_pthreads) { |
| 69 | 71 | const err = std.c.pthread_setname_np(self.getHandle(), name_with_terminator.ptr); |
| 70 | return switch (err) { | |
| 71 | 0 => {}, | |
| 72 | os.ERANGE => unreachable, | |
| 73 | else => return os.unexpectedErrno(err), | |
| 74 | }; | |
| 72 | switch (err) { | |
| 73 | .SUCCESS => return, | |
| 74 | .RANGE => unreachable, | |
| 75 | else => |e| return os.unexpectedErrno(e), | |
| 76 | } | |
| 75 | 77 | } else if (use_pthreads and self.getHandle() == std.c.pthread_self()) { |
| 78 | // TODO: this is dead code. what did the author of this code intend to happen here? | |
| 76 | 79 | const err = try os.prctl(.SET_NAME, .{@ptrToInt(name_with_terminator.ptr)}); |
| 77 | return switch (err) { | |
| 78 | 0 => {}, | |
| 79 | else => return os.unexpectedErrno(err), | |
| 80 | }; | |
| 80 | switch (@intToEnum(os.E, err)) { | |
| 81 | .SUCCESS => return, | |
| 82 | else => |e| return os.unexpectedErrno(e), | |
| 83 | } | |
| 81 | 84 | } else { |
| 82 | 85 | var buf: [32]u8 = undefined; |
| 83 | 86 | 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 { |
| 87 | 90 | |
| 88 | 91 | try file.writer().writeAll(name); |
| 89 | 92 | }, |
| 90 | .windows => if (std.Target.current.os.isAtLeast(.windows, .win10_rs1)) |res| { | |
| 93 | .windows => if (target.os.isAtLeast(.windows, .win10_rs1)) |res| { | |
| 91 | 94 | // SetThreadDescription is only available since version 1607, which is 10.0.14393.795 |
| 92 | 95 | // See https://en.wikipedia.org/wiki/Microsoft_Windows_SDK |
| 93 | 96 | if (!res) { |
| ... | ... | @@ -110,24 +113,25 @@ pub fn setName(self: Thread, name: []const u8) SetNameError!void { |
| 110 | 113 | if (self.getHandle() != std.c.pthread_self()) return error.Unsupported; |
| 111 | 114 | |
| 112 | 115 | const err = std.c.pthread_setname_np(name_with_terminator.ptr); |
| 113 | return switch (err) { | |
| 114 | 0 => {}, | |
| 115 | else => return os.unexpectedErrno(err), | |
| 116 | }; | |
| 116 | switch (err) { | |
| 117 | .SUCCESS => return, | |
| 118 | else => |e| return os.unexpectedErrno(e), | |
| 119 | } | |
| 117 | 120 | }, |
| 118 | 121 | .netbsd => if (use_pthreads) { |
| 119 | 122 | const err = std.c.pthread_setname_np(self.getHandle(), name_with_terminator.ptr, null); |
| 120 | return switch (err) { | |
| 121 | 0 => {}, | |
| 122 | os.EINVAL => unreachable, | |
| 123 | os.ESRCH => unreachable, | |
| 124 | os.ENOMEM => unreachable, | |
| 125 | else => return os.unexpectedErrno(err), | |
| 126 | }; | |
| 123 | switch (err) { | |
| 124 | .SUCCESS => return, | |
| 125 | .INVAL => unreachable, | |
| 126 | .SRCH => unreachable, | |
| 127 | .NOMEM => unreachable, | |
| 128 | else => |e| return os.unexpectedErrno(e), | |
| 129 | } | |
| 127 | 130 | }, |
| 128 | 131 | .freebsd, .openbsd => if (use_pthreads) { |
| 129 | 132 | // Use pthread_set_name_np for FreeBSD because pthread_setname_np is FreeBSD 12.2+ only. |
| 130 | // TODO maybe revisit this if depending on FreeBSD 12.2+ is acceptable because pthread_setname_np can return an error. | |
| 133 | // TODO maybe revisit this if depending on FreeBSD 12.2+ is acceptable because | |
| 134 | // pthread_setname_np can return an error. | |
| 131 | 135 | |
| 132 | 136 | std.c.pthread_set_name_np(self.getHandle(), name_with_terminator.ptr); |
| 133 | 137 | }, |
| ... | ... | @@ -151,20 +155,20 @@ pub fn getName(self: Thread, buffer_ptr: *[max_name_len:0]u8) GetNameError!?[]co |
| 151 | 155 | buffer_ptr[max_name_len] = 0; |
| 152 | 156 | var buffer = std.mem.span(buffer_ptr); |
| 153 | 157 | |
| 154 | switch (std.Target.current.os.tag) { | |
| 155 | .linux => if (use_pthreads and comptime std.Target.current.abi.isGnu()) { | |
| 158 | switch (target.os.tag) { | |
| 159 | .linux => if (use_pthreads and is_gnu) { | |
| 156 | 160 | const err = std.c.pthread_getname_np(self.getHandle(), buffer.ptr, max_name_len + 1); |
| 157 | return switch (err) { | |
| 158 | 0 => std.mem.sliceTo(buffer, 0), | |
| 159 | os.ERANGE => unreachable, | |
| 160 | else => return os.unexpectedErrno(err), | |
| 161 | }; | |
| 161 | switch (err) { | |
| 162 | .SUCCESS => return std.mem.sliceTo(buffer, 0), | |
| 163 | .RANGE => unreachable, | |
| 164 | else => |e| return os.unexpectedErrno(e), | |
| 165 | } | |
| 162 | 166 | } else if (use_pthreads and self.getHandle() == std.c.pthread_self()) { |
| 163 | 167 | const err = try os.prctl(.GET_NAME, .{@ptrToInt(buffer.ptr)}); |
| 164 | return switch (err) { | |
| 165 | 0 => std.mem.sliceTo(buffer, 0), | |
| 166 | else => return os.unexpectedErrno(err), | |
| 167 | }; | |
| 168 | switch (@intToEnum(os.E, err)) { | |
| 169 | .SUCCESS => return std.mem.sliceTo(buffer, 0), | |
| 170 | else => |e| return os.unexpectedErrno(e), | |
| 171 | } | |
| 168 | 172 | } else if (!use_pthreads) { |
| 169 | 173 | var buf: [32]u8 = undefined; |
| 170 | 174 | 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 |
| 179 | 183 | // musl doesn't provide pthread_getname_np and there's no way to retrieve the thread id of an arbitrary thread. |
| 180 | 184 | return error.Unsupported; |
| 181 | 185 | }, |
| 182 | .windows => if (std.Target.current.os.isAtLeast(.windows, .win10_rs1)) |res| { | |
| 186 | .windows => if (target.os.isAtLeast(.windows, .win10_rs1)) |res| { | |
| 183 | 187 | // GetThreadDescription is only available since version 1607, which is 10.0.14393.795 |
| 184 | 188 | // See https://en.wikipedia.org/wiki/Microsoft_Windows_SDK |
| 185 | 189 | if (!res) { |
| ... | ... | @@ -198,20 +202,20 @@ pub fn getName(self: Thread, buffer_ptr: *[max_name_len:0]u8) GetNameError!?[]co |
| 198 | 202 | }, |
| 199 | 203 | .macos, .ios, .watchos, .tvos => if (use_pthreads) { |
| 200 | 204 | const err = std.c.pthread_getname_np(self.getHandle(), buffer.ptr, max_name_len + 1); |
| 201 | return switch (err) { | |
| 202 | 0 => std.mem.sliceTo(buffer, 0), | |
| 203 | os.ESRCH => unreachable, | |
| 204 | else => return os.unexpectedErrno(err), | |
| 205 | }; | |
| 205 | switch (err) { | |
| 206 | .SUCCESS => return std.mem.sliceTo(buffer, 0), | |
| 207 | .SRCH => unreachable, | |
| 208 | else => |e| return os.unexpectedErrno(e), | |
| 209 | } | |
| 206 | 210 | }, |
| 207 | 211 | .netbsd => if (use_pthreads) { |
| 208 | 212 | const err = std.c.pthread_getname_np(self.getHandle(), buffer.ptr, max_name_len + 1); |
| 209 | return switch (err) { | |
| 210 | 0 => std.mem.sliceTo(buffer, 0), | |
| 211 | os.EINVAL => unreachable, | |
| 212 | os.ESRCH => unreachable, | |
| 213 | else => return os.unexpectedErrno(err), | |
| 214 | }; | |
| 213 | switch (err) { | |
| 214 | .SUCCESS => return std.mem.sliceTo(buffer, 0), | |
| 215 | .INVAL => unreachable, | |
| 216 | .SRCH => unreachable, | |
| 217 | else => |e| return os.unexpectedErrno(e), | |
| 218 | } | |
| 215 | 219 | }, |
| 216 | 220 | .freebsd, .openbsd => if (use_pthreads) { |
| 217 | 221 | // Use pthread_get_name_np for FreeBSD because pthread_getname_np is FreeBSD 12.2+ only. |
| ... | ... | @@ -288,7 +292,7 @@ pub const SpawnError = error{ |
| 288 | 292 | /// The caller must eventually either call `join()` to wait for the thread to finish and free its resources |
| 289 | 293 | /// or call `detach()` to excuse the caller from calling `join()` and have the thread clean up its resources on completion`. |
| 290 | 294 | pub fn spawn(config: SpawnConfig, comptime function: anytype, args: anytype) SpawnError!Thread { |
| 291 | if (std.builtin.single_threaded) { | |
| 295 | if (builtin.single_threaded) { | |
| 292 | 296 | @compileError("Cannot spawn thread when building in single-threaded mode"); |
| 293 | 297 | } |
| 294 | 298 | |
| ... | ... | @@ -611,13 +615,13 @@ const PosixThreadImpl = struct { |
| 611 | 615 | errdefer allocator.destroy(args_ptr); |
| 612 | 616 | |
| 613 | 617 | var attr: c.pthread_attr_t = undefined; |
| 614 | if (c.pthread_attr_init(&attr) != 0) return error.SystemResources; | |
| 615 | defer assert(c.pthread_attr_destroy(&attr) == 0); | |
| 618 | if (c.pthread_attr_init(&attr) != .SUCCESS) return error.SystemResources; | |
| 619 | defer assert(c.pthread_attr_destroy(&attr) == .SUCCESS); | |
| 616 | 620 | |
| 617 | 621 | // Use the same set of parameters used by the libc-less impl. |
| 618 | 622 | const stack_size = std.math.max(config.stack_size, 16 * 1024); |
| 619 | assert(c.pthread_attr_setstacksize(&attr, stack_size) == 0); | |
| 620 | assert(c.pthread_attr_setguardsize(&attr, std.mem.page_size) == 0); | |
| 623 | assert(c.pthread_attr_setstacksize(&attr, stack_size) == .SUCCESS); | |
| 624 | assert(c.pthread_attr_setguardsize(&attr, std.mem.page_size) == .SUCCESS); | |
| 621 | 625 | |
| 622 | 626 | var handle: c.pthread_t = undefined; |
| 623 | 627 | switch (c.pthread_create( |
| ... | ... | @@ -626,10 +630,10 @@ const PosixThreadImpl = struct { |
| 626 | 630 | Instance.entryFn, |
| 627 | 631 | if (@sizeOf(Args) > 1) @ptrCast(*c_void, args_ptr) else undefined, |
| 628 | 632 | )) { |
| 629 | 0 => return Impl{ .handle = handle }, | |
| 630 | os.EAGAIN => return error.SystemResources, | |
| 631 | os.EPERM => unreachable, | |
| 632 | os.EINVAL => unreachable, | |
| 633 | .SUCCESS => return Impl{ .handle = handle }, | |
| 634 | .AGAIN => return error.SystemResources, | |
| 635 | .PERM => unreachable, | |
| 636 | .INVAL => unreachable, | |
| 633 | 637 | else => |err| return os.unexpectedErrno(err), |
| 634 | 638 | } |
| 635 | 639 | } |
| ... | ... | @@ -640,19 +644,19 @@ const PosixThreadImpl = struct { |
| 640 | 644 | |
| 641 | 645 | fn detach(self: Impl) void { |
| 642 | 646 | switch (c.pthread_detach(self.handle)) { |
| 643 | 0 => {}, | |
| 644 | os.EINVAL => unreachable, // thread handle is not joinable | |
| 645 | os.ESRCH => unreachable, // thread handle is invalid | |
| 647 | .SUCCESS => {}, | |
| 648 | .INVAL => unreachable, // thread handle is not joinable | |
| 649 | .SRCH => unreachable, // thread handle is invalid | |
| 646 | 650 | else => unreachable, |
| 647 | 651 | } |
| 648 | 652 | } |
| 649 | 653 | |
| 650 | 654 | fn join(self: Impl) void { |
| 651 | 655 | switch (c.pthread_join(self.handle, null)) { |
| 652 | 0 => {}, | |
| 653 | os.EINVAL => unreachable, // thread handle is not joinable (or another thread is already joining in) | |
| 654 | os.ESRCH => unreachable, // thread handle is invalid | |
| 655 | os.EDEADLK => unreachable, // two threads tried to join each other | |
| 656 | .SUCCESS => {}, | |
| 657 | .INVAL => unreachable, // thread handle is not joinable (or another thread is already joining in) | |
| 658 | .SRCH => unreachable, // thread handle is invalid | |
| 659 | .DEADLK => unreachable, // two threads tried to join each other | |
| 656 | 660 | else => unreachable, |
| 657 | 661 | } |
| 658 | 662 | } |
| ... | ... | @@ -937,13 +941,13 @@ const LinuxThreadImpl = struct { |
| 937 | 941 | tls_ptr, |
| 938 | 942 | &instance.thread.child_tid.value, |
| 939 | 943 | ))) { |
| 940 | 0 => return Impl{ .thread = &instance.thread }, | |
| 941 | os.EAGAIN => return error.ThreadQuotaExceeded, | |
| 942 | os.EINVAL => unreachable, | |
| 943 | os.ENOMEM => return error.SystemResources, | |
| 944 | os.ENOSPC => unreachable, | |
| 945 | os.EPERM => unreachable, | |
| 946 | os.EUSERS => unreachable, | |
| 944 | .SUCCESS => return Impl{ .thread = &instance.thread }, | |
| 945 | .AGAIN => return error.ThreadQuotaExceeded, | |
| 946 | .INVAL => unreachable, | |
| 947 | .NOMEM => return error.SystemResources, | |
| 948 | .NOSPC => unreachable, | |
| 949 | .PERM => unreachable, | |
| 950 | .USERS => unreachable, | |
| 947 | 951 | else => |err| return os.unexpectedErrno(err), |
| 948 | 952 | } |
| 949 | 953 | } |
| ... | ... | @@ -982,9 +986,9 @@ const LinuxThreadImpl = struct { |
| 982 | 986 | tid, |
| 983 | 987 | null, |
| 984 | 988 | ))) { |
| 985 | 0 => continue, | |
| 986 | os.EINTR => continue, | |
| 987 | os.EAGAIN => continue, | |
| 989 | .SUCCESS => continue, | |
| 990 | .INTR => continue, | |
| 991 | .AGAIN => continue, | |
| 988 | 992 | else => unreachable, |
| 989 | 993 | } |
| 990 | 994 | } |
| ... | ... | @@ -1011,7 +1015,7 @@ fn testThreadName(thread: *Thread) !void { |
| 1011 | 1015 | } |
| 1012 | 1016 | |
| 1013 | 1017 | test "setName, getName" { |
| 1014 | if (std.builtin.single_threaded) return error.SkipZigTest; | |
| 1018 | if (builtin.single_threaded) return error.SkipZigTest; | |
| 1015 | 1019 | |
| 1016 | 1020 | const Context = struct { |
| 1017 | 1021 | start_wait_event: ResetEvent = undefined, |
| ... | ... | @@ -1029,7 +1033,7 @@ test "setName, getName" { |
| 1029 | 1033 | // Wait for the main thread to have set the thread field in the context. |
| 1030 | 1034 | ctx.start_wait_event.wait(); |
| 1031 | 1035 | |
| 1032 | switch (std.Target.current.os.tag) { | |
| 1036 | switch (target.os.tag) { | |
| 1033 | 1037 | .windows => testThreadName(&ctx.thread) catch |err| switch (err) { |
| 1034 | 1038 | error.Unsupported => return error.SkipZigTest, |
| 1035 | 1039 | else => return err, |
| ... | ... | @@ -1054,7 +1058,7 @@ test "setName, getName" { |
| 1054 | 1058 | context.start_wait_event.set(); |
| 1055 | 1059 | context.test_done_event.wait(); |
| 1056 | 1060 | |
| 1057 | switch (std.Target.current.os.tag) { | |
| 1061 | switch (target.os.tag) { | |
| 1058 | 1062 | .macos, .ios, .watchos, .tvos => { |
| 1059 | 1063 | const res = thread.setName("foobar"); |
| 1060 | 1064 | try std.testing.expectError(error.Unsupported, res); |
| ... | ... | @@ -1063,7 +1067,7 @@ test "setName, getName" { |
| 1063 | 1067 | error.Unsupported => return error.SkipZigTest, |
| 1064 | 1068 | else => return err, |
| 1065 | 1069 | }, |
| 1066 | else => |tag| if (tag == .linux and use_pthreads and comptime std.Target.current.abi.isMusl()) { | |
| 1070 | else => |tag| if (tag == .linux and use_pthreads and comptime target.abi.isMusl()) { | |
| 1067 | 1071 | try thread.setName("foobar"); |
| 1068 | 1072 | |
| 1069 | 1073 | var name_buffer: [max_name_len:0]u8 = undefined; |
| ... | ... | @@ -1096,7 +1100,7 @@ fn testIncrementNotify(value: *usize, event: *ResetEvent) void { |
| 1096 | 1100 | } |
| 1097 | 1101 | |
| 1098 | 1102 | test "Thread.join" { |
| 1099 | if (std.builtin.single_threaded) return error.SkipZigTest; | |
| 1103 | if (builtin.single_threaded) return error.SkipZigTest; | |
| 1100 | 1104 | |
| 1101 | 1105 | var value: usize = 0; |
| 1102 | 1106 | var event: ResetEvent = undefined; |
| ... | ... | @@ -1110,7 +1114,7 @@ test "Thread.join" { |
| 1110 | 1114 | } |
| 1111 | 1115 | |
| 1112 | 1116 | test "Thread.detach" { |
| 1113 | if (std.builtin.single_threaded) return error.SkipZigTest; | |
| 1117 | if (builtin.single_threaded) return error.SkipZigTest; | |
| 1114 | 1118 | |
| 1115 | 1119 | var value: usize = 0; |
| 1116 | 1120 | var event: ResetEvent = undefined; |
lib/std/Thread/Condition.zig+8-8| ... | ... | @@ -81,17 +81,17 @@ pub const PthreadCondition = struct { |
| 81 | 81 | |
| 82 | 82 | pub fn wait(cond: *PthreadCondition, mutex: *Mutex) void { |
| 83 | 83 | const rc = std.c.pthread_cond_wait(&cond.cond, &mutex.impl.pthread_mutex); |
| 84 | assert(rc == 0); | |
| 84 | assert(rc == .SUCCESS); | |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | pub fn signal(cond: *PthreadCondition) void { |
| 88 | 88 | const rc = std.c.pthread_cond_signal(&cond.cond); |
| 89 | assert(rc == 0); | |
| 89 | assert(rc == .SUCCESS); | |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | pub fn broadcast(cond: *PthreadCondition) void { |
| 93 | 93 | const rc = std.c.pthread_cond_broadcast(&cond.cond); |
| 94 | assert(rc == 0); | |
| 94 | assert(rc == .SUCCESS); | |
| 95 | 95 | } |
| 96 | 96 | }; |
| 97 | 97 | |
| ... | ... | @@ -115,9 +115,9 @@ pub const AtomicCondition = struct { |
| 115 | 115 | 0, |
| 116 | 116 | null, |
| 117 | 117 | ))) { |
| 118 | 0 => {}, | |
| 119 | std.os.EINTR => {}, | |
| 120 | std.os.EAGAIN => {}, | |
| 118 | .SUCCESS => {}, | |
| 119 | .INTR => {}, | |
| 120 | .AGAIN => {}, | |
| 121 | 121 | else => unreachable, |
| 122 | 122 | } |
| 123 | 123 | }, |
| ... | ... | @@ -136,8 +136,8 @@ pub const AtomicCondition = struct { |
| 136 | 136 | linux.FUTEX_PRIVATE_FLAG | linux.FUTEX_WAKE, |
| 137 | 137 | 1, |
| 138 | 138 | ))) { |
| 139 | 0 => {}, | |
| 140 | std.os.EFAULT => {}, | |
| 139 | .SUCCESS => {}, | |
| 140 | .FAULT => {}, | |
| 141 | 141 | else => unreachable, |
| 142 | 142 | } |
| 143 | 143 | }, |
lib/std/Thread/Futex.zig+39-39| ... | ... | @@ -152,12 +152,12 @@ const LinuxFutex = struct { |
| 152 | 152 | @bitCast(i32, expect), |
| 153 | 153 | ts_ptr, |
| 154 | 154 | ))) { |
| 155 | 0 => {}, // notified by `wake()` | |
| 156 | std.os.EINTR => {}, // spurious wakeup | |
| 157 | std.os.EAGAIN => {}, // ptr.* != expect | |
| 158 | std.os.ETIMEDOUT => return error.TimedOut, | |
| 159 | std.os.EINVAL => {}, // possibly timeout overflow | |
| 160 | std.os.EFAULT => unreachable, | |
| 155 | .SUCCESS => {}, // notified by `wake()` | |
| 156 | .INTR => {}, // spurious wakeup | |
| 157 | .AGAIN => {}, // ptr.* != expect | |
| 158 | .TIMEDOUT => return error.TimedOut, | |
| 159 | .INVAL => {}, // possibly timeout overflow | |
| 160 | .FAULT => unreachable, | |
| 161 | 161 | else => unreachable, |
| 162 | 162 | } |
| 163 | 163 | } |
| ... | ... | @@ -168,9 +168,9 @@ const LinuxFutex = struct { |
| 168 | 168 | linux.FUTEX_PRIVATE_FLAG | linux.FUTEX_WAKE, |
| 169 | 169 | std.math.cast(i32, num_waiters) catch std.math.maxInt(i32), |
| 170 | 170 | ))) { |
| 171 | 0 => {}, // successful wake up | |
| 172 | std.os.EINVAL => {}, // invalid futex_wait() on ptr done elsewhere | |
| 173 | std.os.EFAULT => {}, // pointer became invalid while doing the wake | |
| 171 | .SUCCESS => {}, // successful wake up | |
| 172 | .INVAL => {}, // invalid futex_wait() on ptr done elsewhere | |
| 173 | .FAULT => {}, // pointer became invalid while doing the wake | |
| 174 | 174 | else => unreachable, |
| 175 | 175 | } |
| 176 | 176 | } |
| ... | ... | @@ -215,13 +215,13 @@ const DarwinFutex = struct { |
| 215 | 215 | }; |
| 216 | 216 | |
| 217 | 217 | if (status >= 0) return; |
| 218 | switch (-status) { | |
| 219 | darwin.EINTR => {}, | |
| 218 | switch (@intToEnum(std.os.E, -status)) { | |
| 219 | .INTR => {}, | |
| 220 | 220 | // Address of the futex is paged out. This is unlikely, but possible in theory, and |
| 221 | 221 | // pthread/libdispatch on darwin bother to handle it. In this case we'll return |
| 222 | 222 | // without waiting, but the caller should retry anyway. |
| 223 | darwin.EFAULT => {}, | |
| 224 | darwin.ETIMEDOUT => if (!timeout_overflowed) return error.TimedOut, | |
| 223 | .FAULT => {}, | |
| 224 | .TIMEDOUT => if (!timeout_overflowed) return error.TimedOut, | |
| 225 | 225 | else => unreachable, |
| 226 | 226 | } |
| 227 | 227 | } |
| ... | ... | @@ -237,11 +237,11 @@ const DarwinFutex = struct { |
| 237 | 237 | const status = darwin.__ulock_wake(flags, addr, 0); |
| 238 | 238 | |
| 239 | 239 | if (status >= 0) return; |
| 240 | switch (-status) { | |
| 241 | darwin.EINTR => continue, // spurious wake() | |
| 242 | darwin.EFAULT => continue, // address of the lock was paged out | |
| 243 | darwin.ENOENT => return, // nothing was woken up | |
| 244 | darwin.EALREADY => unreachable, // only for ULF_WAKE_THREAD | |
| 240 | switch (@intToEnum(std.os.E, -status)) { | |
| 241 | .INTR => continue, // spurious wake() | |
| 242 | .FAULT => continue, // address of the lock was paged out | |
| 243 | .NOENT => return, // nothing was woken up | |
| 244 | .ALREADY => unreachable, // only for ULF_WAKE_THREAD | |
| 245 | 245 | else => unreachable, |
| 246 | 246 | } |
| 247 | 247 | } |
| ... | ... | @@ -255,8 +255,8 @@ const PosixFutex = struct { |
| 255 | 255 | var waiter: List.Node = undefined; |
| 256 | 256 | |
| 257 | 257 | { |
| 258 | assert(std.c.pthread_mutex_lock(&bucket.mutex) == 0); | |
| 259 | defer assert(std.c.pthread_mutex_unlock(&bucket.mutex) == 0); | |
| 258 | assert(std.c.pthread_mutex_lock(&bucket.mutex) == .SUCCESS); | |
| 259 | defer assert(std.c.pthread_mutex_unlock(&bucket.mutex) == .SUCCESS); | |
| 260 | 260 | |
| 261 | 261 | if (ptr.load(.SeqCst) != expect) { |
| 262 | 262 | return; |
| ... | ... | @@ -272,8 +272,8 @@ const PosixFutex = struct { |
| 272 | 272 | waiter.data.wait(null) catch unreachable; |
| 273 | 273 | }; |
| 274 | 274 | |
| 275 | assert(std.c.pthread_mutex_lock(&bucket.mutex) == 0); | |
| 276 | defer assert(std.c.pthread_mutex_unlock(&bucket.mutex) == 0); | |
| 275 | assert(std.c.pthread_mutex_lock(&bucket.mutex) == .SUCCESS); | |
| 276 | defer assert(std.c.pthread_mutex_unlock(&bucket.mutex) == .SUCCESS); | |
| 277 | 277 | |
| 278 | 278 | if (waiter.data.address == address) { |
| 279 | 279 | timed_out = true; |
| ... | ... | @@ -297,8 +297,8 @@ const PosixFutex = struct { |
| 297 | 297 | waiter.data.notify(); |
| 298 | 298 | }; |
| 299 | 299 | |
| 300 | assert(std.c.pthread_mutex_lock(&bucket.mutex) == 0); | |
| 301 | defer assert(std.c.pthread_mutex_unlock(&bucket.mutex) == 0); | |
| 300 | assert(std.c.pthread_mutex_lock(&bucket.mutex) == .SUCCESS); | |
| 301 | defer assert(std.c.pthread_mutex_unlock(&bucket.mutex) == .SUCCESS); | |
| 302 | 302 | |
| 303 | 303 | var waiters = bucket.list.first; |
| 304 | 304 | while (waiters) |waiter| { |
| ... | ... | @@ -340,16 +340,13 @@ const PosixFutex = struct { |
| 340 | 340 | }; |
| 341 | 341 | |
| 342 | 342 | fn deinit(self: *Self) void { |
| 343 | const rc = std.c.pthread_cond_destroy(&self.cond); | |
| 344 | assert(rc == 0 or rc == std.os.EINVAL); | |
| 345 | ||
| 346 | const rm = std.c.pthread_mutex_destroy(&self.mutex); | |
| 347 | assert(rm == 0 or rm == std.os.EINVAL); | |
| 343 | _ = std.c.pthread_cond_destroy(&self.cond); | |
| 344 | _ = std.c.pthread_mutex_destroy(&self.mutex); | |
| 348 | 345 | } |
| 349 | 346 | |
| 350 | 347 | fn wait(self: *Self, timeout: ?u64) error{TimedOut}!void { |
| 351 | assert(std.c.pthread_mutex_lock(&self.mutex) == 0); | |
| 352 | defer assert(std.c.pthread_mutex_unlock(&self.mutex) == 0); | |
| 348 | assert(std.c.pthread_mutex_lock(&self.mutex) == .SUCCESS); | |
| 349 | defer assert(std.c.pthread_mutex_unlock(&self.mutex) == .SUCCESS); | |
| 353 | 350 | |
| 354 | 351 | switch (self.state) { |
| 355 | 352 | .empty => self.state = .waiting, |
| ... | ... | @@ -378,28 +375,31 @@ const PosixFutex = struct { |
| 378 | 375 | } |
| 379 | 376 | |
| 380 | 377 | const ts_ref = ts_ptr orelse { |
| 381 | assert(std.c.pthread_cond_wait(&self.cond, &self.mutex) == 0); | |
| 378 | assert(std.c.pthread_cond_wait(&self.cond, &self.mutex) == .SUCCESS); | |
| 382 | 379 | continue; |
| 383 | 380 | }; |
| 384 | 381 | |
| 385 | 382 | const rc = std.c.pthread_cond_timedwait(&self.cond, &self.mutex, ts_ref); |
| 386 | assert(rc == 0 or rc == std.os.ETIMEDOUT); | |
| 387 | if (rc == std.os.ETIMEDOUT) { | |
| 388 | self.state = .empty; | |
| 389 | return error.TimedOut; | |
| 383 | switch (rc) { | |
| 384 | .SUCCESS => {}, | |
| 385 | .TIMEDOUT => { | |
| 386 | self.state = .empty; | |
| 387 | return error.TimedOut; | |
| 388 | }, | |
| 389 | else => unreachable, | |
| 390 | 390 | } |
| 391 | 391 | } |
| 392 | 392 | } |
| 393 | 393 | |
| 394 | 394 | fn notify(self: *Self) void { |
| 395 | assert(std.c.pthread_mutex_lock(&self.mutex) == 0); | |
| 396 | defer assert(std.c.pthread_mutex_unlock(&self.mutex) == 0); | |
| 395 | assert(std.c.pthread_mutex_lock(&self.mutex) == .SUCCESS); | |
| 396 | defer assert(std.c.pthread_mutex_unlock(&self.mutex) == .SUCCESS); | |
| 397 | 397 | |
| 398 | 398 | switch (self.state) { |
| 399 | 399 | .empty => self.state = .notified, |
| 400 | 400 | .waiting => { |
| 401 | 401 | self.state = .notified; |
| 402 | assert(std.c.pthread_cond_signal(&self.cond) == 0); | |
| 402 | assert(std.c.pthread_cond_signal(&self.cond) == .SUCCESS); | |
| 403 | 403 | }, |
| 404 | 404 | .notified => unreachable, |
| 405 | 405 | } |
lib/std/Thread/Mutex.zig+16-16| ... | ... | @@ -143,9 +143,9 @@ pub const AtomicMutex = struct { |
| 143 | 143 | @enumToInt(new_state), |
| 144 | 144 | null, |
| 145 | 145 | ))) { |
| 146 | 0 => {}, | |
| 147 | std.os.EINTR => {}, | |
| 148 | std.os.EAGAIN => {}, | |
| 146 | .SUCCESS => {}, | |
| 147 | .INTR => {}, | |
| 148 | .AGAIN => {}, | |
| 149 | 149 | else => unreachable, |
| 150 | 150 | } |
| 151 | 151 | }, |
| ... | ... | @@ -164,8 +164,8 @@ pub const AtomicMutex = struct { |
| 164 | 164 | linux.FUTEX_PRIVATE_FLAG | linux.FUTEX_WAKE, |
| 165 | 165 | 1, |
| 166 | 166 | ))) { |
| 167 | 0 => {}, | |
| 168 | std.os.EFAULT => {}, | |
| 167 | .SUCCESS => {}, | |
| 168 | .FAULT => unreachable, // invalid pointer passed to futex_wake | |
| 169 | 169 | else => unreachable, |
| 170 | 170 | } |
| 171 | 171 | }, |
| ... | ... | @@ -182,10 +182,10 @@ pub const PthreadMutex = struct { |
| 182 | 182 | |
| 183 | 183 | pub fn release(held: Held) void { |
| 184 | 184 | switch (std.c.pthread_mutex_unlock(&held.mutex.pthread_mutex)) { |
| 185 | 0 => return, | |
| 186 | std.c.EINVAL => unreachable, | |
| 187 | std.c.EAGAIN => unreachable, | |
| 188 | std.c.EPERM => unreachable, | |
| 185 | .SUCCESS => return, | |
| 186 | .INVAL => unreachable, | |
| 187 | .AGAIN => unreachable, | |
| 188 | .PERM => unreachable, | |
| 189 | 189 | else => unreachable, |
| 190 | 190 | } |
| 191 | 191 | } |
| ... | ... | @@ -195,7 +195,7 @@ pub const PthreadMutex = struct { |
| 195 | 195 | /// the mutex is unavailable. Otherwise returns Held. Call |
| 196 | 196 | /// release on Held. |
| 197 | 197 | pub fn tryAcquire(m: *PthreadMutex) ?Held { |
| 198 | if (std.c.pthread_mutex_trylock(&m.pthread_mutex) == 0) { | |
| 198 | if (std.c.pthread_mutex_trylock(&m.pthread_mutex) == .SUCCESS) { | |
| 199 | 199 | return Held{ .mutex = m }; |
| 200 | 200 | } else { |
| 201 | 201 | return null; |
| ... | ... | @@ -206,12 +206,12 @@ pub const PthreadMutex = struct { |
| 206 | 206 | /// held by the calling thread. |
| 207 | 207 | pub fn acquire(m: *PthreadMutex) Held { |
| 208 | 208 | switch (std.c.pthread_mutex_lock(&m.pthread_mutex)) { |
| 209 | 0 => return Held{ .mutex = m }, | |
| 210 | std.c.EINVAL => unreachable, | |
| 211 | std.c.EBUSY => unreachable, | |
| 212 | std.c.EAGAIN => unreachable, | |
| 213 | std.c.EDEADLK => unreachable, | |
| 214 | std.c.EPERM => unreachable, | |
| 209 | .SUCCESS => return Held{ .mutex = m }, | |
| 210 | .INVAL => unreachable, | |
| 211 | .BUSY => unreachable, | |
| 212 | .AGAIN => unreachable, | |
| 213 | .DEADLK => unreachable, | |
| 214 | .PERM => unreachable, | |
| 215 | 215 | else => unreachable, |
| 216 | 216 | } |
| 217 | 217 | } |
lib/std/Thread/ResetEvent.zig+12-12| ... | ... | @@ -130,7 +130,7 @@ pub const PosixEvent = struct { |
| 130 | 130 | |
| 131 | 131 | pub fn init(ev: *PosixEvent) !void { |
| 132 | 132 | switch (c.getErrno(c.sem_init(&ev.sem, 0, 0))) { |
| 133 | 0 => return, | |
| 133 | .SUCCESS => return, | |
| 134 | 134 | else => return error.SystemResources, |
| 135 | 135 | } |
| 136 | 136 | } |
| ... | ... | @@ -147,9 +147,9 @@ pub const PosixEvent = struct { |
| 147 | 147 | pub fn wait(ev: *PosixEvent) void { |
| 148 | 148 | while (true) { |
| 149 | 149 | switch (c.getErrno(c.sem_wait(&ev.sem))) { |
| 150 | 0 => return, | |
| 151 | c.EINTR => continue, | |
| 152 | c.EINVAL => unreachable, | |
| 150 | .SUCCESS => return, | |
| 151 | .INTR => continue, | |
| 152 | .INVAL => unreachable, | |
| 153 | 153 | else => unreachable, |
| 154 | 154 | } |
| 155 | 155 | } |
| ... | ... | @@ -165,10 +165,10 @@ pub const PosixEvent = struct { |
| 165 | 165 | ts.tv_nsec = @intCast(@TypeOf(ts.tv_nsec), @mod(timeout_abs, time.ns_per_s)); |
| 166 | 166 | while (true) { |
| 167 | 167 | switch (c.getErrno(c.sem_timedwait(&ev.sem, &ts))) { |
| 168 | 0 => return .event_set, | |
| 169 | c.EINTR => continue, | |
| 170 | c.EINVAL => unreachable, | |
| 171 | c.ETIMEDOUT => return .timed_out, | |
| 168 | .SUCCESS => return .event_set, | |
| 169 | .INTR => continue, | |
| 170 | .INVAL => unreachable, | |
| 171 | .TIMEDOUT => return .timed_out, | |
| 172 | 172 | else => unreachable, |
| 173 | 173 | } |
| 174 | 174 | } |
| ... | ... | @@ -177,10 +177,10 @@ pub const PosixEvent = struct { |
| 177 | 177 | pub fn reset(ev: *PosixEvent) void { |
| 178 | 178 | while (true) { |
| 179 | 179 | switch (c.getErrno(c.sem_trywait(&ev.sem))) { |
| 180 | 0 => continue, // Need to make it go to zero. | |
| 181 | c.EINTR => continue, | |
| 182 | c.EINVAL => unreachable, | |
| 183 | c.EAGAIN => return, // The semaphore currently has the value zero. | |
| 180 | .SUCCESS => continue, // Need to make it go to zero. | |
| 181 | .INTR => continue, | |
| 182 | .INVAL => unreachable, | |
| 183 | .AGAIN => return, // The semaphore currently has the value zero. | |
| 184 | 184 | else => unreachable, |
| 185 | 185 | } |
| 186 | 186 | } |
lib/std/Thread/RwLock.zig+11-13| ... | ... | @@ -13,7 +13,7 @@ impl: Impl, |
| 13 | 13 | |
| 14 | 14 | const RwLock = @This(); |
| 15 | 15 | const std = @import("../std.zig"); |
| 16 | const builtin = std.builtin; | |
| 16 | const builtin = @import("builtin"); | |
| 17 | 17 | const assert = std.debug.assert; |
| 18 | 18 | const Mutex = std.Thread.Mutex; |
| 19 | 19 | const Semaphore = std.Semaphore; |
| ... | ... | @@ -165,43 +165,41 @@ pub const PthreadRwLock = struct { |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | pub fn deinit(rwl: *PthreadRwLock) void { |
| 168 | const safe_rc = switch (std.builtin.os.tag) { | |
| 169 | .dragonfly, .netbsd => std.os.EAGAIN, | |
| 170 | else => 0, | |
| 168 | const safe_rc: std.os.E = switch (builtin.os.tag) { | |
| 169 | .dragonfly, .netbsd => .AGAIN, | |
| 170 | else => .SUCCESS, | |
| 171 | 171 | }; |
| 172 | ||
| 173 | 172 | const rc = std.c.pthread_rwlock_destroy(&rwl.rwlock); |
| 174 | assert(rc == 0 or rc == safe_rc); | |
| 175 | ||
| 173 | assert(rc == .SUCCESS or rc == safe_rc); | |
| 176 | 174 | rwl.* = undefined; |
| 177 | 175 | } |
| 178 | 176 | |
| 179 | 177 | pub fn tryLock(rwl: *PthreadRwLock) bool { |
| 180 | return pthread_rwlock_trywrlock(&rwl.rwlock) == 0; | |
| 178 | return pthread_rwlock_trywrlock(&rwl.rwlock) == .SUCCESS; | |
| 181 | 179 | } |
| 182 | 180 | |
| 183 | 181 | pub fn lock(rwl: *PthreadRwLock) void { |
| 184 | 182 | const rc = pthread_rwlock_wrlock(&rwl.rwlock); |
| 185 | assert(rc == 0); | |
| 183 | assert(rc == .SUCCESS); | |
| 186 | 184 | } |
| 187 | 185 | |
| 188 | 186 | pub fn unlock(rwl: *PthreadRwLock) void { |
| 189 | 187 | const rc = pthread_rwlock_unlock(&rwl.rwlock); |
| 190 | assert(rc == 0); | |
| 188 | assert(rc == .SUCCESS); | |
| 191 | 189 | } |
| 192 | 190 | |
| 193 | 191 | pub fn tryLockShared(rwl: *PthreadRwLock) bool { |
| 194 | return pthread_rwlock_tryrdlock(&rwl.rwlock) == 0; | |
| 192 | return pthread_rwlock_tryrdlock(&rwl.rwlock) == .SUCCESS; | |
| 195 | 193 | } |
| 196 | 194 | |
| 197 | 195 | pub fn lockShared(rwl: *PthreadRwLock) void { |
| 198 | 196 | const rc = pthread_rwlock_rdlock(&rwl.rwlock); |
| 199 | assert(rc == 0); | |
| 197 | assert(rc == .SUCCESS); | |
| 200 | 198 | } |
| 201 | 199 | |
| 202 | 200 | pub fn unlockShared(rwl: *PthreadRwLock) void { |
| 203 | 201 | const rc = pthread_rwlock_unlock(&rwl.rwlock); |
| 204 | assert(rc == 0); | |
| 202 | assert(rc == .SUCCESS); | |
| 205 | 203 | } |
| 206 | 204 | }; |
| 207 | 205 |
lib/std/Thread/StaticResetEvent.zig+5-5| ... | ... | @@ -201,7 +201,7 @@ pub const AtomicEvent = struct { |
| 201 | 201 | const waiting = std.math.maxInt(i32); // wake_count |
| 202 | 202 | const ptr = @ptrCast(*const i32, waiters); |
| 203 | 203 | const rc = linux.futex_wake(ptr, linux.FUTEX_WAKE | linux.FUTEX_PRIVATE_FLAG, waiting); |
| 204 | assert(linux.getErrno(rc) == 0); | |
| 204 | assert(linux.getErrno(rc) == .SUCCESS); | |
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | fn wait(waiters: *u32, timeout: ?u64) !void { |
| ... | ... | @@ -221,10 +221,10 @@ pub const AtomicEvent = struct { |
| 221 | 221 | const ptr = @ptrCast(*const i32, waiters); |
| 222 | 222 | const rc = linux.futex_wait(ptr, linux.FUTEX_WAIT | linux.FUTEX_PRIVATE_FLAG, expected, ts_ptr); |
| 223 | 223 | switch (linux.getErrno(rc)) { |
| 224 | 0 => continue, | |
| 225 | os.ETIMEDOUT => return error.TimedOut, | |
| 226 | os.EINTR => continue, | |
| 227 | os.EAGAIN => return, | |
| 224 | .SUCCESS => continue, | |
| 225 | .TIMEDOUT => return error.TimedOut, | |
| 226 | .INTR => continue, | |
| 227 | .AGAIN => return, | |
| 228 | 228 | else => unreachable, |
| 229 | 229 | } |
| 230 | 230 | } |
lib/std/c.zig+29-29| ... | ... | @@ -35,11 +35,11 @@ pub usingnamespace switch (std.Target.current.os.tag) { |
| 35 | 35 | else => struct {}, |
| 36 | 36 | }; |
| 37 | 37 | |
| 38 | pub fn getErrno(rc: anytype) c_int { | |
| 38 | pub fn getErrno(rc: anytype) E { | |
| 39 | 39 | if (rc == -1) { |
| 40 | return _errno().*; | |
| 40 | return @intToEnum(E, _errno().*); | |
| 41 | 41 | } else { |
| 42 | return 0; | |
| 42 | return .SUCCESS; | |
| 43 | 43 | } |
| 44 | 44 | } |
| 45 | 45 | |
| ... | ... | @@ -270,22 +270,22 @@ pub extern "c" fn utimes(path: [*:0]const u8, times: *[2]timeval) c_int; |
| 270 | 270 | pub extern "c" fn utimensat(dirfd: fd_t, pathname: [*:0]const u8, times: *[2]timespec, flags: u32) c_int; |
| 271 | 271 | pub extern "c" fn futimens(fd: fd_t, times: *const [2]timespec) c_int; |
| 272 | 272 | |
| 273 | 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; | |
| 274 | pub extern "c" fn pthread_attr_init(attr: *pthread_attr_t) c_int; | |
| 275 | pub extern "c" fn pthread_attr_setstack(attr: *pthread_attr_t, stackaddr: *c_void, stacksize: usize) c_int; | |
| 276 | pub extern "c" fn pthread_attr_setstacksize(attr: *pthread_attr_t, stacksize: usize) c_int; | |
| 277 | pub extern "c" fn pthread_attr_setguardsize(attr: *pthread_attr_t, guardsize: usize) c_int; | |
| 278 | pub extern "c" fn pthread_attr_destroy(attr: *pthread_attr_t) c_int; | |
| 273 | 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; | |
| 274 | pub extern "c" fn pthread_attr_init(attr: *pthread_attr_t) E; | |
| 275 | pub extern "c" fn pthread_attr_setstack(attr: *pthread_attr_t, stackaddr: *c_void, stacksize: usize) E; | |
| 276 | pub extern "c" fn pthread_attr_setstacksize(attr: *pthread_attr_t, stacksize: usize) E; | |
| 277 | pub extern "c" fn pthread_attr_setguardsize(attr: *pthread_attr_t, guardsize: usize) E; | |
| 278 | pub extern "c" fn pthread_attr_destroy(attr: *pthread_attr_t) E; | |
| 279 | 279 | pub extern "c" fn pthread_self() pthread_t; |
| 280 | pub extern "c" fn pthread_join(thread: pthread_t, arg_return: ?*?*c_void) c_int; | |
| 281 | pub extern "c" fn pthread_detach(thread: pthread_t) c_int; | |
| 280 | pub extern "c" fn pthread_join(thread: pthread_t, arg_return: ?*?*c_void) E; | |
| 281 | pub extern "c" fn pthread_detach(thread: pthread_t) E; | |
| 282 | 282 | pub extern "c" fn pthread_atfork( |
| 283 | 283 | prepare: ?fn () callconv(.C) void, |
| 284 | 284 | parent: ?fn () callconv(.C) void, |
| 285 | 285 | child: ?fn () callconv(.C) void, |
| 286 | 286 | ) c_int; |
| 287 | pub extern "c" fn pthread_key_create(key: *pthread_key_t, destructor: ?fn (value: *c_void) callconv(.C) void) c_int; | |
| 288 | pub extern "c" fn pthread_key_delete(key: pthread_key_t) c_int; | |
| 287 | pub extern "c" fn pthread_key_create(key: *pthread_key_t, destructor: ?fn (value: *c_void) callconv(.C) void) E; | |
| 288 | pub extern "c" fn pthread_key_delete(key: pthread_key_t) E; | |
| 289 | 289 | pub extern "c" fn pthread_getspecific(key: pthread_key_t) ?*c_void; |
| 290 | 290 | pub extern "c" fn pthread_setspecific(key: pthread_key_t, value: ?*c_void) c_int; |
| 291 | 291 | 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( |
| 339 | 339 | ) c_int; |
| 340 | 340 | |
| 341 | 341 | pub const PTHREAD_MUTEX_INITIALIZER = pthread_mutex_t{}; |
| 342 | pub extern "c" fn pthread_mutex_lock(mutex: *pthread_mutex_t) c_int; | |
| 343 | pub extern "c" fn pthread_mutex_unlock(mutex: *pthread_mutex_t) c_int; | |
| 344 | pub extern "c" fn pthread_mutex_trylock(mutex: *pthread_mutex_t) c_int; | |
| 345 | pub extern "c" fn pthread_mutex_destroy(mutex: *pthread_mutex_t) c_int; | |
| 342 | pub extern "c" fn pthread_mutex_lock(mutex: *pthread_mutex_t) E; | |
| 343 | pub extern "c" fn pthread_mutex_unlock(mutex: *pthread_mutex_t) E; | |
| 344 | pub extern "c" fn pthread_mutex_trylock(mutex: *pthread_mutex_t) E; | |
| 345 | pub extern "c" fn pthread_mutex_destroy(mutex: *pthread_mutex_t) E; | |
| 346 | 346 | |
| 347 | 347 | pub const PTHREAD_COND_INITIALIZER = pthread_cond_t{}; |
| 348 | pub extern "c" fn pthread_cond_wait(noalias cond: *pthread_cond_t, noalias mutex: *pthread_mutex_t) c_int; | |
| 349 | pub extern "c" fn pthread_cond_timedwait(noalias cond: *pthread_cond_t, noalias mutex: *pthread_mutex_t, noalias abstime: *const timespec) c_int; | |
| 350 | pub extern "c" fn pthread_cond_signal(cond: *pthread_cond_t) c_int; | |
| 351 | pub extern "c" fn pthread_cond_broadcast(cond: *pthread_cond_t) c_int; | |
| 352 | pub extern "c" fn pthread_cond_destroy(cond: *pthread_cond_t) c_int; | |
| 353 | ||
| 354 | pub extern "c" fn pthread_rwlock_destroy(rwl: *pthread_rwlock_t) callconv(.C) c_int; | |
| 355 | pub extern "c" fn pthread_rwlock_rdlock(rwl: *pthread_rwlock_t) callconv(.C) c_int; | |
| 356 | pub extern "c" fn pthread_rwlock_wrlock(rwl: *pthread_rwlock_t) callconv(.C) c_int; | |
| 357 | pub extern "c" fn pthread_rwlock_tryrdlock(rwl: *pthread_rwlock_t) callconv(.C) c_int; | |
| 358 | pub extern "c" fn pthread_rwlock_trywrlock(rwl: *pthread_rwlock_t) callconv(.C) c_int; | |
| 359 | pub extern "c" fn pthread_rwlock_unlock(rwl: *pthread_rwlock_t) callconv(.C) c_int; | |
| 348 | pub extern "c" fn pthread_cond_wait(noalias cond: *pthread_cond_t, noalias mutex: *pthread_mutex_t) E; | |
| 349 | pub extern "c" fn pthread_cond_timedwait(noalias cond: *pthread_cond_t, noalias mutex: *pthread_mutex_t, noalias abstime: *const timespec) E; | |
| 350 | pub extern "c" fn pthread_cond_signal(cond: *pthread_cond_t) E; | |
| 351 | pub extern "c" fn pthread_cond_broadcast(cond: *pthread_cond_t) E; | |
| 352 | pub extern "c" fn pthread_cond_destroy(cond: *pthread_cond_t) E; | |
| 353 | ||
| 354 | pub extern "c" fn pthread_rwlock_destroy(rwl: *pthread_rwlock_t) callconv(.C) E; | |
| 355 | pub extern "c" fn pthread_rwlock_rdlock(rwl: *pthread_rwlock_t) callconv(.C) E; | |
| 356 | pub extern "c" fn pthread_rwlock_wrlock(rwl: *pthread_rwlock_t) callconv(.C) E; | |
| 357 | pub extern "c" fn pthread_rwlock_tryrdlock(rwl: *pthread_rwlock_t) callconv(.C) E; | |
| 358 | pub extern "c" fn pthread_rwlock_trywrlock(rwl: *pthread_rwlock_t) callconv(.C) E; | |
| 359 | pub extern "c" fn pthread_rwlock_unlock(rwl: *pthread_rwlock_t) callconv(.C) E; | |
| 360 | 360 | |
| 361 | 361 | pub const pthread_t = *opaque {}; |
| 362 | 362 | pub const FILE = opaque {}; |
lib/std/c/darwin.zig+2-2| ... | ... | @@ -193,8 +193,8 @@ pub const pthread_attr_t = extern struct { |
| 193 | 193 | |
| 194 | 194 | const pthread_t = std.c.pthread_t; |
| 195 | 195 | pub extern "c" fn pthread_threadid_np(thread: ?pthread_t, thread_id: *u64) c_int; |
| 196 | pub extern "c" fn pthread_setname_np(name: [*:0]const u8) c_int; | |
| 197 | pub extern "c" fn pthread_getname_np(thread: std.c.pthread_t, name: [*:0]u8, len: usize) c_int; | |
| 196 | pub extern "c" fn pthread_setname_np(name: [*:0]const u8) E; | |
| 197 | pub extern "c" fn pthread_getname_np(thread: std.c.pthread_t, name: [*:0]u8, len: usize) E; | |
| 198 | 198 | |
| 199 | 199 | pub extern "c" fn arc4random_buf(buf: [*]u8, len: usize) void; |
| 200 | 200 |
lib/std/c/linux.zig+2-2| ... | ... | @@ -186,8 +186,8 @@ const __SIZEOF_PTHREAD_MUTEX_T = if (os_tag == .fuchsia) 40 else switch (abi) { |
| 186 | 186 | }; |
| 187 | 187 | const __SIZEOF_SEM_T = 4 * @sizeOf(usize); |
| 188 | 188 | |
| 189 | pub extern "c" fn pthread_setname_np(thread: std.c.pthread_t, name: [*:0]const u8) c_int; | |
| 190 | pub extern "c" fn pthread_getname_np(thread: std.c.pthread_t, name: [*:0]u8, len: usize) c_int; | |
| 189 | pub extern "c" fn pthread_setname_np(thread: std.c.pthread_t, name: [*:0]const u8) E; | |
| 190 | pub extern "c" fn pthread_getname_np(thread: std.c.pthread_t, name: [*:0]u8, len: usize) E; | |
| 191 | 191 | |
| 192 | 192 | pub const RTLD_LAZY = 1; |
| 193 | 193 | pub const RTLD_NOW = 2; |
lib/std/c/netbsd.zig+2-2| ... | ... | @@ -95,5 +95,5 @@ pub const pthread_attr_t = extern struct { |
| 95 | 95 | |
| 96 | 96 | pub const sem_t = ?*opaque {}; |
| 97 | 97 | |
| 98 | pub extern "c" fn pthread_setname_np(thread: std.c.pthread_t, name: [*:0]const u8, arg: ?*c_void) c_int; | |
| 99 | pub extern "c" fn pthread_getname_np(thread: std.c.pthread_t, name: [*:0]u8, len: usize) c_int; | |
| 98 | pub extern "c" fn pthread_setname_np(thread: std.c.pthread_t, name: [*:0]const u8, arg: ?*c_void) E; | |
| 99 | pub extern "c" fn pthread_getname_np(thread: std.c.pthread_t, name: [*:0]u8, len: usize) E; |
lib/std/fs.zig+28-28| ... | ... | @@ -339,10 +339,10 @@ pub const Dir = struct { |
| 339 | 339 | if (rc == 0) return null; |
| 340 | 340 | if (rc < 0) { |
| 341 | 341 | switch (os.errno(rc)) { |
| 342 | os.EBADF => unreachable, // Dir is invalid or was opened without iteration ability | |
| 343 | os.EFAULT => unreachable, | |
| 344 | os.ENOTDIR => unreachable, | |
| 345 | os.EINVAL => unreachable, | |
| 342 | .BADF => unreachable, // Dir is invalid or was opened without iteration ability | |
| 343 | .FAULT => unreachable, | |
| 344 | .NOTDIR => unreachable, | |
| 345 | .INVAL => unreachable, | |
| 346 | 346 | else => |err| return os.unexpectedErrno(err), |
| 347 | 347 | } |
| 348 | 348 | } |
| ... | ... | @@ -385,11 +385,11 @@ pub const Dir = struct { |
| 385 | 385 | else |
| 386 | 386 | os.system.getdents(self.dir.fd, &self.buf, self.buf.len); |
| 387 | 387 | switch (os.errno(rc)) { |
| 388 | 0 => {}, | |
| 389 | os.EBADF => unreachable, // Dir is invalid or was opened without iteration ability | |
| 390 | os.EFAULT => unreachable, | |
| 391 | os.ENOTDIR => unreachable, | |
| 392 | os.EINVAL => unreachable, | |
| 388 | .SUCCESS => {}, | |
| 389 | .BADF => unreachable, // Dir is invalid or was opened without iteration ability | |
| 390 | .FAULT => unreachable, | |
| 391 | .NOTDIR => unreachable, | |
| 392 | .INVAL => unreachable, | |
| 393 | 393 | else => |err| return os.unexpectedErrno(err), |
| 394 | 394 | } |
| 395 | 395 | if (rc == 0) return null; |
| ... | ... | @@ -457,10 +457,10 @@ pub const Dir = struct { |
| 457 | 457 | if (rc == 0) return null; |
| 458 | 458 | if (rc < 0) { |
| 459 | 459 | switch (os.errno(rc)) { |
| 460 | os.EBADF => unreachable, // Dir is invalid or was opened without iteration ability | |
| 461 | os.EFAULT => unreachable, | |
| 462 | os.ENOTDIR => unreachable, | |
| 463 | os.EINVAL => unreachable, | |
| 460 | .BADF => unreachable, // Dir is invalid or was opened without iteration ability | |
| 461 | .FAULT => unreachable, | |
| 462 | .NOTDIR => unreachable, | |
| 463 | .INVAL => unreachable, | |
| 464 | 464 | else => |err| return os.unexpectedErrno(err), |
| 465 | 465 | } |
| 466 | 466 | } |
| ... | ... | @@ -522,11 +522,11 @@ pub const Dir = struct { |
| 522 | 522 | if (self.index >= self.end_index) { |
| 523 | 523 | const rc = os.linux.getdents64(self.dir.fd, &self.buf, self.buf.len); |
| 524 | 524 | switch (os.linux.getErrno(rc)) { |
| 525 | 0 => {}, | |
| 526 | os.EBADF => unreachable, // Dir is invalid or was opened without iteration ability | |
| 527 | os.EFAULT => unreachable, | |
| 528 | os.ENOTDIR => unreachable, | |
| 529 | os.EINVAL => unreachable, | |
| 525 | .SUCCESS => {}, | |
| 526 | .BADF => unreachable, // Dir is invalid or was opened without iteration ability | |
| 527 | .FAULT => unreachable, | |
| 528 | .NOTDIR => unreachable, | |
| 529 | .INVAL => unreachable, | |
| 530 | 530 | else => |err| return os.unexpectedErrno(err), |
| 531 | 531 | } |
| 532 | 532 | if (rc == 0) return null; |
| ... | ... | @@ -655,12 +655,12 @@ pub const Dir = struct { |
| 655 | 655 | if (self.index >= self.end_index) { |
| 656 | 656 | var bufused: usize = undefined; |
| 657 | 657 | switch (w.fd_readdir(self.dir.fd, &self.buf, self.buf.len, self.cookie, &bufused)) { |
| 658 | w.ESUCCESS => {}, | |
| 659 | w.EBADF => unreachable, // Dir is invalid or was opened without iteration ability | |
| 660 | w.EFAULT => unreachable, | |
| 661 | w.ENOTDIR => unreachable, | |
| 662 | w.EINVAL => unreachable, | |
| 663 | w.ENOTCAPABLE => return error.AccessDenied, | |
| 658 | .SUCCESS => {}, | |
| 659 | .BADF => unreachable, // Dir is invalid or was opened without iteration ability | |
| 660 | .FAULT => unreachable, | |
| 661 | .NOTDIR => unreachable, | |
| 662 | .INVAL => unreachable, | |
| 663 | .NOTCAPABLE => return error.AccessDenied, | |
| 664 | 664 | else => |err| return os.unexpectedErrno(err), |
| 665 | 665 | } |
| 666 | 666 | if (bufused == 0) return null; |
| ... | ... | @@ -2557,12 +2557,12 @@ fn copy_file(fd_in: os.fd_t, fd_out: os.fd_t) CopyFileError!void { |
| 2557 | 2557 | if (comptime std.Target.current.isDarwin()) { |
| 2558 | 2558 | const rc = os.system.fcopyfile(fd_in, fd_out, null, os.system.COPYFILE_DATA); |
| 2559 | 2559 | switch (os.errno(rc)) { |
| 2560 | 0 => return, | |
| 2561 | os.EINVAL => unreachable, | |
| 2562 | os.ENOMEM => return error.SystemResources, | |
| 2560 | .SUCCESS => return, | |
| 2561 | .INVAL => unreachable, | |
| 2562 | .NOMEM => return error.SystemResources, | |
| 2563 | 2563 | // The source file is not a directory, symbolic link, or regular file. |
| 2564 | 2564 | // Try with the fallback path before giving up. |
| 2565 | os.ENOTSUP => {}, | |
| 2565 | .OPNOTSUPP => {}, | |
| 2566 | 2566 | else => |err| return os.unexpectedErrno(err), |
| 2567 | 2567 | } |
| 2568 | 2568 | } |
lib/std/fs/wasi.zig+4-4| ... | ... | @@ -121,13 +121,13 @@ pub const PreopenList = struct { |
| 121 | 121 | while (true) { |
| 122 | 122 | var buf: prestat_t = undefined; |
| 123 | 123 | switch (fd_prestat_get(fd, &buf)) { |
| 124 | ESUCCESS => {}, | |
| 125 | ENOTSUP => { | |
| 124 | .SUCCESS => {}, | |
| 125 | .OPNOTSUPP => { | |
| 126 | 126 | // not a preopen, so keep going |
| 127 | 127 | fd = try math.add(fd_t, fd, 1); |
| 128 | 128 | continue; |
| 129 | 129 | }, |
| 130 | EBADF => { | |
| 130 | .BADF => { | |
| 131 | 131 | // OK, no more fds available |
| 132 | 132 | break; |
| 133 | 133 | }, |
| ... | ... | @@ -137,7 +137,7 @@ pub const PreopenList = struct { |
| 137 | 137 | const path_buf = try self.buffer.allocator.alloc(u8, preopen_len); |
| 138 | 138 | mem.set(u8, path_buf, 0); |
| 139 | 139 | switch (fd_prestat_dir_name(fd, path_buf.ptr, preopen_len)) { |
| 140 | ESUCCESS => {}, | |
| 140 | .SUCCESS => {}, | |
| 141 | 141 | else => |err| return os.unexpectedErrno(err), |
| 142 | 142 | } |
| 143 | 143 | const preopen = Preopen.new(fd, PreopenType{ .Dir = path_buf }); |
lib/std/io/c_writer.zig+13-13| ... | ... | @@ -17,19 +17,19 @@ pub fn cWriter(c_file: *std.c.FILE) CWriter { |
| 17 | 17 | fn cWriterWrite(c_file: *std.c.FILE, bytes: []const u8) std.fs.File.WriteError!usize { |
| 18 | 18 | const amt_written = std.c.fwrite(bytes.ptr, 1, bytes.len, c_file); |
| 19 | 19 | if (amt_written >= 0) return amt_written; |
| 20 | switch (std.c._errno().*) { | |
| 21 | 0 => unreachable, | |
| 22 | os.EINVAL => unreachable, | |
| 23 | os.EFAULT => unreachable, | |
| 24 | os.EAGAIN => unreachable, // this is a blocking API | |
| 25 | os.EBADF => unreachable, // always a race condition | |
| 26 | os.EDESTADDRREQ => unreachable, // connect was never called | |
| 27 | os.EDQUOT => return error.DiskQuota, | |
| 28 | os.EFBIG => return error.FileTooBig, | |
| 29 | os.EIO => return error.InputOutput, | |
| 30 | os.ENOSPC => return error.NoSpaceLeft, | |
| 31 | os.EPERM => return error.AccessDenied, | |
| 32 | os.EPIPE => return error.BrokenPipe, | |
| 20 | switch (@intToEnum(os.E, std.c._errno().*)) { | |
| 21 | .SUCCESS => unreachable, | |
| 22 | .INVAL => unreachable, | |
| 23 | .FAULT => unreachable, | |
| 24 | .AGAIN => unreachable, // this is a blocking API | |
| 25 | .BADF => unreachable, // always a race condition | |
| 26 | .DESTADDRREQ => unreachable, // connect was never called | |
| 27 | .DQUOT => return error.DiskQuota, | |
| 28 | .FBIG => return error.FileTooBig, | |
| 29 | .IO => return error.InputOutput, | |
| 30 | .NOSPC => return error.NoSpaceLeft, | |
| 31 | .PERM => return error.AccessDenied, | |
| 32 | .PIPE => return error.BrokenPipe, | |
| 33 | 33 | else => |err| return os.unexpectedErrno(err), |
| 34 | 34 | } |
| 35 | 35 | } |
lib/std/os.zig+1304-1304| ... | ... | @@ -116,13 +116,13 @@ pub fn close(fd: fd_t) void { |
| 116 | 116 | if (comptime std.Target.current.isDarwin()) { |
| 117 | 117 | // This avoids the EINTR problem. |
| 118 | 118 | switch (darwin.getErrno(darwin.@"close$NOCANCEL"(fd))) { |
| 119 | EBADF => unreachable, // Always a race condition. | |
| 119 | .BADF => unreachable, // Always a race condition. | |
| 120 | 120 | else => return, |
| 121 | 121 | } |
| 122 | 122 | } |
| 123 | 123 | switch (errno(system.close(fd))) { |
| 124 | EBADF => unreachable, // Always a race condition. | |
| 125 | EINTR => return, // This is still a success. See https://github.com/ziglang/zig/issues/2425 | |
| 124 | .BADF => unreachable, // Always a race condition. | |
| 125 | .INTR => return, // This is still a success. See https://github.com/ziglang/zig/issues/2425 | |
| 126 | 126 | else => return, |
| 127 | 127 | } |
| 128 | 128 | } |
| ... | ... | @@ -159,11 +159,11 @@ pub fn getrandom(buffer: []u8) GetRandomError!void { |
| 159 | 159 | }; |
| 160 | 160 | |
| 161 | 161 | switch (res.err) { |
| 162 | 0 => buf = buf[res.num_read..], | |
| 163 | EINVAL => unreachable, | |
| 164 | EFAULT => unreachable, | |
| 165 | EINTR => continue, | |
| 166 | ENOSYS => return getRandomBytesDevURandom(buf), | |
| 162 | .SUCCESS => buf = buf[res.num_read..], | |
| 163 | .INVAL => unreachable, | |
| 164 | .FAULT => unreachable, | |
| 165 | .INTR => continue, | |
| 166 | .NOSYS => return getRandomBytesDevURandom(buf), | |
| 167 | 167 | else => return unexpectedErrno(res.err), |
| 168 | 168 | } |
| 169 | 169 | } |
| ... | ... | @@ -175,7 +175,7 @@ pub fn getrandom(buffer: []u8) GetRandomError!void { |
| 175 | 175 | return; |
| 176 | 176 | }, |
| 177 | 177 | .wasi => switch (wasi.random_get(buffer.ptr, buffer.len)) { |
| 178 | 0 => return, | |
| 178 | .SUCCESS => return, | |
| 179 | 179 | else => |err| return unexpectedErrno(err), |
| 180 | 180 | }, |
| 181 | 181 | else => return getRandomBytesDevURandom(buffer), |
| ... | ... | @@ -238,7 +238,7 @@ pub const RaiseError = UnexpectedError; |
| 238 | 238 | pub fn raise(sig: u8) RaiseError!void { |
| 239 | 239 | if (builtin.link_libc) { |
| 240 | 240 | switch (errno(system.raise(sig))) { |
| 241 | 0 => return, | |
| 241 | .SUCCESS => return, | |
| 242 | 242 | else => |err| return unexpectedErrno(err), |
| 243 | 243 | } |
| 244 | 244 | } |
| ... | ... | @@ -255,7 +255,7 @@ pub fn raise(sig: u8) RaiseError!void { |
| 255 | 255 | _ = linux.sigprocmask(SIG_SETMASK, &set, null); |
| 256 | 256 | |
| 257 | 257 | switch (errno(rc)) { |
| 258 | 0 => return, | |
| 258 | .SUCCESS => return, | |
| 259 | 259 | else => |err| return unexpectedErrno(err), |
| 260 | 260 | } |
| 261 | 261 | } |
| ... | ... | @@ -267,10 +267,10 @@ pub const KillError = error{PermissionDenied} || UnexpectedError; |
| 267 | 267 | |
| 268 | 268 | pub fn kill(pid: pid_t, sig: u8) KillError!void { |
| 269 | 269 | switch (errno(system.kill(pid, sig))) { |
| 270 | 0 => return, | |
| 271 | EINVAL => unreachable, // invalid signal | |
| 272 | EPERM => return error.PermissionDenied, | |
| 273 | ESRCH => unreachable, // always a race condition | |
| 270 | .SUCCESS => return, | |
| 271 | .INVAL => unreachable, // invalid signal | |
| 272 | .PERM => return error.PermissionDenied, | |
| 273 | .SRCH => unreachable, // always a race condition | |
| 274 | 274 | else => |err| return unexpectedErrno(err), |
| 275 | 275 | } |
| 276 | 276 | } |
| ... | ... | @@ -342,19 +342,19 @@ pub fn read(fd: fd_t, buf: []u8) ReadError!usize { |
| 342 | 342 | |
| 343 | 343 | var nread: usize = undefined; |
| 344 | 344 | switch (wasi.fd_read(fd, &iovs, iovs.len, &nread)) { |
| 345 | wasi.ESUCCESS => return nread, | |
| 346 | wasi.EINTR => unreachable, | |
| 347 | wasi.EINVAL => unreachable, | |
| 348 | wasi.EFAULT => unreachable, | |
| 349 | wasi.EAGAIN => unreachable, | |
| 350 | wasi.EBADF => return error.NotOpenForReading, // Can be a race condition. | |
| 351 | wasi.EIO => return error.InputOutput, | |
| 352 | wasi.EISDIR => return error.IsDir, | |
| 353 | wasi.ENOBUFS => return error.SystemResources, | |
| 354 | wasi.ENOMEM => return error.SystemResources, | |
| 355 | wasi.ECONNRESET => return error.ConnectionResetByPeer, | |
| 356 | wasi.ETIMEDOUT => return error.ConnectionTimedOut, | |
| 357 | wasi.ENOTCAPABLE => return error.AccessDenied, | |
| 345 | .SUCCESS => return nread, | |
| 346 | .INTR => unreachable, | |
| 347 | .INVAL => unreachable, | |
| 348 | .FAULT => unreachable, | |
| 349 | .AGAIN => unreachable, | |
| 350 | .BADF => return error.NotOpenForReading, // Can be a race condition. | |
| 351 | .IO => return error.InputOutput, | |
| 352 | .ISDIR => return error.IsDir, | |
| 353 | .NOBUFS => return error.SystemResources, | |
| 354 | .NOMEM => return error.SystemResources, | |
| 355 | .CONNRESET => return error.ConnectionResetByPeer, | |
| 356 | .TIMEDOUT => return error.ConnectionTimedOut, | |
| 357 | .NOTCAPABLE => return error.AccessDenied, | |
| 358 | 358 | else => |err| return unexpectedErrno(err), |
| 359 | 359 | } |
| 360 | 360 | } |
| ... | ... | @@ -370,18 +370,18 @@ pub fn read(fd: fd_t, buf: []u8) ReadError!usize { |
| 370 | 370 | while (true) { |
| 371 | 371 | const rc = system.read(fd, buf.ptr, adjusted_len); |
| 372 | 372 | switch (errno(rc)) { |
| 373 | 0 => return @intCast(usize, rc), | |
| 374 | EINTR => continue, | |
| 375 | EINVAL => unreachable, | |
| 376 | EFAULT => unreachable, | |
| 377 | EAGAIN => return error.WouldBlock, | |
| 378 | EBADF => return error.NotOpenForReading, // Can be a race condition. | |
| 379 | EIO => return error.InputOutput, | |
| 380 | EISDIR => return error.IsDir, | |
| 381 | ENOBUFS => return error.SystemResources, | |
| 382 | ENOMEM => return error.SystemResources, | |
| 383 | ECONNRESET => return error.ConnectionResetByPeer, | |
| 384 | ETIMEDOUT => return error.ConnectionTimedOut, | |
| 373 | .SUCCESS => return @intCast(usize, rc), | |
| 374 | .INTR => continue, | |
| 375 | .INVAL => unreachable, | |
| 376 | .FAULT => unreachable, | |
| 377 | .AGAIN => return error.WouldBlock, | |
| 378 | .BADF => return error.NotOpenForReading, // Can be a race condition. | |
| 379 | .IO => return error.InputOutput, | |
| 380 | .ISDIR => return error.IsDir, | |
| 381 | .NOBUFS => return error.SystemResources, | |
| 382 | .NOMEM => return error.SystemResources, | |
| 383 | .CONNRESET => return error.ConnectionResetByPeer, | |
| 384 | .TIMEDOUT => return error.ConnectionTimedOut, | |
| 385 | 385 | else => |err| return unexpectedErrno(err), |
| 386 | 386 | } |
| 387 | 387 | } |
| ... | ... | @@ -407,17 +407,17 @@ pub fn readv(fd: fd_t, iov: []const iovec) ReadError!usize { |
| 407 | 407 | if (builtin.os.tag == .wasi and !builtin.link_libc) { |
| 408 | 408 | var nread: usize = undefined; |
| 409 | 409 | switch (wasi.fd_read(fd, iov.ptr, iov.len, &nread)) { |
| 410 | wasi.ESUCCESS => return nread, | |
| 411 | wasi.EINTR => unreachable, | |
| 412 | wasi.EINVAL => unreachable, | |
| 413 | wasi.EFAULT => unreachable, | |
| 414 | wasi.EAGAIN => unreachable, // currently not support in WASI | |
| 415 | wasi.EBADF => return error.NotOpenForReading, // can be a race condition | |
| 416 | wasi.EIO => return error.InputOutput, | |
| 417 | wasi.EISDIR => return error.IsDir, | |
| 418 | wasi.ENOBUFS => return error.SystemResources, | |
| 419 | wasi.ENOMEM => return error.SystemResources, | |
| 420 | wasi.ENOTCAPABLE => return error.AccessDenied, | |
| 410 | .SUCCESS => return nread, | |
| 411 | .INTR => unreachable, | |
| 412 | .INVAL => unreachable, | |
| 413 | .FAULT => unreachable, | |
| 414 | .AGAIN => unreachable, // currently not support in WASI | |
| 415 | .BADF => return error.NotOpenForReading, // can be a race condition | |
| 416 | .IO => return error.InputOutput, | |
| 417 | .ISDIR => return error.IsDir, | |
| 418 | .NOBUFS => return error.SystemResources, | |
| 419 | .NOMEM => return error.SystemResources, | |
| 420 | .NOTCAPABLE => return error.AccessDenied, | |
| 421 | 421 | else => |err| return unexpectedErrno(err), |
| 422 | 422 | } |
| 423 | 423 | } |
| ... | ... | @@ -426,16 +426,16 @@ pub fn readv(fd: fd_t, iov: []const iovec) ReadError!usize { |
| 426 | 426 | // TODO handle the case when iov_len is too large and get rid of this @intCast |
| 427 | 427 | const rc = system.readv(fd, iov.ptr, iov_count); |
| 428 | 428 | switch (errno(rc)) { |
| 429 | 0 => return @intCast(usize, rc), | |
| 430 | EINTR => continue, | |
| 431 | EINVAL => unreachable, | |
| 432 | EFAULT => unreachable, | |
| 433 | EAGAIN => return error.WouldBlock, | |
| 434 | EBADF => return error.NotOpenForReading, // can be a race condition | |
| 435 | EIO => return error.InputOutput, | |
| 436 | EISDIR => return error.IsDir, | |
| 437 | ENOBUFS => return error.SystemResources, | |
| 438 | ENOMEM => return error.SystemResources, | |
| 429 | .SUCCESS => return @intCast(usize, rc), | |
| 430 | .INTR => continue, | |
| 431 | .INVAL => unreachable, | |
| 432 | .FAULT => unreachable, | |
| 433 | .AGAIN => return error.WouldBlock, | |
| 434 | .BADF => return error.NotOpenForReading, // can be a race condition | |
| 435 | .IO => return error.InputOutput, | |
| 436 | .ISDIR => return error.IsDir, | |
| 437 | .NOBUFS => return error.SystemResources, | |
| 438 | .NOMEM => return error.SystemResources, | |
| 439 | 439 | else => |err| return unexpectedErrno(err), |
| 440 | 440 | } |
| 441 | 441 | } |
| ... | ... | @@ -469,21 +469,21 @@ pub fn pread(fd: fd_t, buf: []u8, offset: u64) PReadError!usize { |
| 469 | 469 | |
| 470 | 470 | var nread: usize = undefined; |
| 471 | 471 | switch (wasi.fd_pread(fd, &iovs, iovs.len, offset, &nread)) { |
| 472 | wasi.ESUCCESS => return nread, | |
| 473 | wasi.EINTR => unreachable, | |
| 474 | wasi.EINVAL => unreachable, | |
| 475 | wasi.EFAULT => unreachable, | |
| 476 | wasi.EAGAIN => unreachable, | |
| 477 | wasi.EBADF => return error.NotOpenForReading, // Can be a race condition. | |
| 478 | wasi.EIO => return error.InputOutput, | |
| 479 | wasi.EISDIR => return error.IsDir, | |
| 480 | wasi.ENOBUFS => return error.SystemResources, | |
| 481 | wasi.ENOMEM => return error.SystemResources, | |
| 482 | wasi.ECONNRESET => return error.ConnectionResetByPeer, | |
| 483 | wasi.ENXIO => return error.Unseekable, | |
| 484 | wasi.ESPIPE => return error.Unseekable, | |
| 485 | wasi.EOVERFLOW => return error.Unseekable, | |
| 486 | wasi.ENOTCAPABLE => return error.AccessDenied, | |
| 472 | .SUCCESS => return nread, | |
| 473 | .INTR => unreachable, | |
| 474 | .INVAL => unreachable, | |
| 475 | .FAULT => unreachable, | |
| 476 | .AGAIN => unreachable, | |
| 477 | .BADF => return error.NotOpenForReading, // Can be a race condition. | |
| 478 | .IO => return error.InputOutput, | |
| 479 | .ISDIR => return error.IsDir, | |
| 480 | .NOBUFS => return error.SystemResources, | |
| 481 | .NOMEM => return error.SystemResources, | |
| 482 | .CONNRESET => return error.ConnectionResetByPeer, | |
| 483 | .NXIO => return error.Unseekable, | |
| 484 | .SPIPE => return error.Unseekable, | |
| 485 | .OVERFLOW => return error.Unseekable, | |
| 486 | .NOTCAPABLE => return error.AccessDenied, | |
| 487 | 487 | else => |err| return unexpectedErrno(err), |
| 488 | 488 | } |
| 489 | 489 | } |
| ... | ... | @@ -505,20 +505,20 @@ pub fn pread(fd: fd_t, buf: []u8, offset: u64) PReadError!usize { |
| 505 | 505 | while (true) { |
| 506 | 506 | const rc = pread_sym(fd, buf.ptr, adjusted_len, ioffset); |
| 507 | 507 | switch (errno(rc)) { |
| 508 | 0 => return @intCast(usize, rc), | |
| 509 | EINTR => continue, | |
| 510 | EINVAL => unreachable, | |
| 511 | EFAULT => unreachable, | |
| 512 | EAGAIN => return error.WouldBlock, | |
| 513 | EBADF => return error.NotOpenForReading, // Can be a race condition. | |
| 514 | EIO => return error.InputOutput, | |
| 515 | EISDIR => return error.IsDir, | |
| 516 | ENOBUFS => return error.SystemResources, | |
| 517 | ENOMEM => return error.SystemResources, | |
| 518 | ECONNRESET => return error.ConnectionResetByPeer, | |
| 519 | ENXIO => return error.Unseekable, | |
| 520 | ESPIPE => return error.Unseekable, | |
| 521 | EOVERFLOW => return error.Unseekable, | |
| 508 | .SUCCESS => return @intCast(usize, rc), | |
| 509 | .INTR => continue, | |
| 510 | .INVAL => unreachable, | |
| 511 | .FAULT => unreachable, | |
| 512 | .AGAIN => return error.WouldBlock, | |
| 513 | .BADF => return error.NotOpenForReading, // Can be a race condition. | |
| 514 | .IO => return error.InputOutput, | |
| 515 | .ISDIR => return error.IsDir, | |
| 516 | .NOBUFS => return error.SystemResources, | |
| 517 | .NOMEM => return error.SystemResources, | |
| 518 | .CONNRESET => return error.ConnectionResetByPeer, | |
| 519 | .NXIO => return error.Unseekable, | |
| 520 | .SPIPE => return error.Unseekable, | |
| 521 | .OVERFLOW => return error.Unseekable, | |
| 522 | 522 | else => |err| return unexpectedErrno(err), |
| 523 | 523 | } |
| 524 | 524 | } |
| ... | ... | @@ -558,15 +558,15 @@ pub fn ftruncate(fd: fd_t, length: u64) TruncateError!void { |
| 558 | 558 | } |
| 559 | 559 | if (std.Target.current.os.tag == .wasi and !builtin.link_libc) { |
| 560 | 560 | switch (wasi.fd_filestat_set_size(fd, length)) { |
| 561 | wasi.ESUCCESS => return, | |
| 562 | wasi.EINTR => unreachable, | |
| 563 | wasi.EFBIG => return error.FileTooBig, | |
| 564 | wasi.EIO => return error.InputOutput, | |
| 565 | wasi.EPERM => return error.AccessDenied, | |
| 566 | wasi.ETXTBSY => return error.FileBusy, | |
| 567 | wasi.EBADF => unreachable, // Handle not open for writing | |
| 568 | wasi.EINVAL => unreachable, // Handle not open for writing | |
| 569 | wasi.ENOTCAPABLE => return error.AccessDenied, | |
| 561 | .SUCCESS => return, | |
| 562 | .INTR => unreachable, | |
| 563 | .FBIG => return error.FileTooBig, | |
| 564 | .IO => return error.InputOutput, | |
| 565 | .PERM => return error.AccessDenied, | |
| 566 | .TXTBSY => return error.FileBusy, | |
| 567 | .BADF => unreachable, // Handle not open for writing | |
| 568 | .INVAL => unreachable, // Handle not open for writing | |
| 569 | .NOTCAPABLE => return error.AccessDenied, | |
| 570 | 570 | else => |err| return unexpectedErrno(err), |
| 571 | 571 | } |
| 572 | 572 | } |
| ... | ... | @@ -579,14 +579,14 @@ pub fn ftruncate(fd: fd_t, length: u64) TruncateError!void { |
| 579 | 579 | |
| 580 | 580 | const ilen = @bitCast(i64, length); // the OS treats this as unsigned |
| 581 | 581 | switch (errno(ftruncate_sym(fd, ilen))) { |
| 582 | 0 => return, | |
| 583 | EINTR => continue, | |
| 584 | EFBIG => return error.FileTooBig, | |
| 585 | EIO => return error.InputOutput, | |
| 586 | EPERM => return error.AccessDenied, | |
| 587 | ETXTBSY => return error.FileBusy, | |
| 588 | EBADF => unreachable, // Handle not open for writing | |
| 589 | EINVAL => unreachable, // Handle not open for writing | |
| 582 | .SUCCESS => return, | |
| 583 | .INTR => continue, | |
| 584 | .FBIG => return error.FileTooBig, | |
| 585 | .IO => return error.InputOutput, | |
| 586 | .PERM => return error.AccessDenied, | |
| 587 | .TXTBSY => return error.FileBusy, | |
| 588 | .BADF => unreachable, // Handle not open for writing | |
| 589 | .INVAL => unreachable, // Handle not open for writing | |
| 590 | 590 | else => |err| return unexpectedErrno(err), |
| 591 | 591 | } |
| 592 | 592 | } |
| ... | ... | @@ -620,20 +620,20 @@ pub fn preadv(fd: fd_t, iov: []const iovec, offset: u64) PReadError!usize { |
| 620 | 620 | if (builtin.os.tag == .wasi and !builtin.link_libc) { |
| 621 | 621 | var nread: usize = undefined; |
| 622 | 622 | switch (wasi.fd_pread(fd, iov.ptr, iov.len, offset, &nread)) { |
| 623 | wasi.ESUCCESS => return nread, | |
| 624 | wasi.EINTR => unreachable, | |
| 625 | wasi.EINVAL => unreachable, | |
| 626 | wasi.EFAULT => unreachable, | |
| 627 | wasi.EAGAIN => unreachable, | |
| 628 | wasi.EBADF => return error.NotOpenForReading, // can be a race condition | |
| 629 | wasi.EIO => return error.InputOutput, | |
| 630 | wasi.EISDIR => return error.IsDir, | |
| 631 | wasi.ENOBUFS => return error.SystemResources, | |
| 632 | wasi.ENOMEM => return error.SystemResources, | |
| 633 | wasi.ENXIO => return error.Unseekable, | |
| 634 | wasi.ESPIPE => return error.Unseekable, | |
| 635 | wasi.EOVERFLOW => return error.Unseekable, | |
| 636 | wasi.ENOTCAPABLE => return error.AccessDenied, | |
| 623 | .SUCCESS => return nread, | |
| 624 | .INTR => unreachable, | |
| 625 | .INVAL => unreachable, | |
| 626 | .FAULT => unreachable, | |
| 627 | .AGAIN => unreachable, | |
| 628 | .BADF => return error.NotOpenForReading, // can be a race condition | |
| 629 | .IO => return error.InputOutput, | |
| 630 | .ISDIR => return error.IsDir, | |
| 631 | .NOBUFS => return error.SystemResources, | |
| 632 | .NOMEM => return error.SystemResources, | |
| 633 | .NXIO => return error.Unseekable, | |
| 634 | .SPIPE => return error.Unseekable, | |
| 635 | .OVERFLOW => return error.Unseekable, | |
| 636 | .NOTCAPABLE => return error.AccessDenied, | |
| 637 | 637 | else => |err| return unexpectedErrno(err), |
| 638 | 638 | } |
| 639 | 639 | } |
| ... | ... | @@ -649,19 +649,19 @@ pub fn preadv(fd: fd_t, iov: []const iovec, offset: u64) PReadError!usize { |
| 649 | 649 | while (true) { |
| 650 | 650 | const rc = preadv_sym(fd, iov.ptr, iov_count, ioffset); |
| 651 | 651 | switch (errno(rc)) { |
| 652 | 0 => return @bitCast(usize, rc), | |
| 653 | EINTR => continue, | |
| 654 | EINVAL => unreachable, | |
| 655 | EFAULT => unreachable, | |
| 656 | EAGAIN => return error.WouldBlock, | |
| 657 | EBADF => return error.NotOpenForReading, // can be a race condition | |
| 658 | EIO => return error.InputOutput, | |
| 659 | EISDIR => return error.IsDir, | |
| 660 | ENOBUFS => return error.SystemResources, | |
| 661 | ENOMEM => return error.SystemResources, | |
| 662 | ENXIO => return error.Unseekable, | |
| 663 | ESPIPE => return error.Unseekable, | |
| 664 | EOVERFLOW => return error.Unseekable, | |
| 652 | .SUCCESS => return @bitCast(usize, rc), | |
| 653 | .INTR => continue, | |
| 654 | .INVAL => unreachable, | |
| 655 | .FAULT => unreachable, | |
| 656 | .AGAIN => return error.WouldBlock, | |
| 657 | .BADF => return error.NotOpenForReading, // can be a race condition | |
| 658 | .IO => return error.InputOutput, | |
| 659 | .ISDIR => return error.IsDir, | |
| 660 | .NOBUFS => return error.SystemResources, | |
| 661 | .NOMEM => return error.SystemResources, | |
| 662 | .NXIO => return error.Unseekable, | |
| 663 | .SPIPE => return error.Unseekable, | |
| 664 | .OVERFLOW => return error.Unseekable, | |
| 665 | 665 | else => |err| return unexpectedErrno(err), |
| 666 | 666 | } |
| 667 | 667 | } |
| ... | ... | @@ -723,20 +723,20 @@ pub fn write(fd: fd_t, bytes: []const u8) WriteError!usize { |
| 723 | 723 | }}; |
| 724 | 724 | var nwritten: usize = undefined; |
| 725 | 725 | switch (wasi.fd_write(fd, &ciovs, ciovs.len, &nwritten)) { |
| 726 | wasi.ESUCCESS => return nwritten, | |
| 727 | wasi.EINTR => unreachable, | |
| 728 | wasi.EINVAL => unreachable, | |
| 729 | wasi.EFAULT => unreachable, | |
| 730 | wasi.EAGAIN => unreachable, | |
| 731 | wasi.EBADF => return error.NotOpenForWriting, // can be a race condition. | |
| 732 | wasi.EDESTADDRREQ => unreachable, // `connect` was never called. | |
| 733 | wasi.EDQUOT => return error.DiskQuota, | |
| 734 | wasi.EFBIG => return error.FileTooBig, | |
| 735 | wasi.EIO => return error.InputOutput, | |
| 736 | wasi.ENOSPC => return error.NoSpaceLeft, | |
| 737 | wasi.EPERM => return error.AccessDenied, | |
| 738 | wasi.EPIPE => return error.BrokenPipe, | |
| 739 | wasi.ENOTCAPABLE => return error.AccessDenied, | |
| 726 | .SUCCESS => return nwritten, | |
| 727 | .INTR => unreachable, | |
| 728 | .INVAL => unreachable, | |
| 729 | .FAULT => unreachable, | |
| 730 | .AGAIN => unreachable, | |
| 731 | .BADF => return error.NotOpenForWriting, // can be a race condition. | |
| 732 | .DESTADDRREQ => unreachable, // `connect` was never called. | |
| 733 | .DQUOT => return error.DiskQuota, | |
| 734 | .FBIG => return error.FileTooBig, | |
| 735 | .IO => return error.InputOutput, | |
| 736 | .NOSPC => return error.NoSpaceLeft, | |
| 737 | .PERM => return error.AccessDenied, | |
| 738 | .PIPE => return error.BrokenPipe, | |
| 739 | .NOTCAPABLE => return error.AccessDenied, | |
| 740 | 740 | else => |err| return unexpectedErrno(err), |
| 741 | 741 | } |
| 742 | 742 | } |
| ... | ... | @@ -751,20 +751,20 @@ pub fn write(fd: fd_t, bytes: []const u8) WriteError!usize { |
| 751 | 751 | while (true) { |
| 752 | 752 | const rc = system.write(fd, bytes.ptr, adjusted_len); |
| 753 | 753 | switch (errno(rc)) { |
| 754 | 0 => return @intCast(usize, rc), | |
| 755 | EINTR => continue, | |
| 756 | EINVAL => unreachable, | |
| 757 | EFAULT => unreachable, | |
| 758 | EAGAIN => return error.WouldBlock, | |
| 759 | EBADF => return error.NotOpenForWriting, // can be a race condition. | |
| 760 | EDESTADDRREQ => unreachable, // `connect` was never called. | |
| 761 | EDQUOT => return error.DiskQuota, | |
| 762 | EFBIG => return error.FileTooBig, | |
| 763 | EIO => return error.InputOutput, | |
| 764 | ENOSPC => return error.NoSpaceLeft, | |
| 765 | EPERM => return error.AccessDenied, | |
| 766 | EPIPE => return error.BrokenPipe, | |
| 767 | ECONNRESET => return error.ConnectionResetByPeer, | |
| 754 | .SUCCESS => return @intCast(usize, rc), | |
| 755 | .INTR => continue, | |
| 756 | .INVAL => unreachable, | |
| 757 | .FAULT => unreachable, | |
| 758 | .AGAIN => return error.WouldBlock, | |
| 759 | .BADF => return error.NotOpenForWriting, // can be a race condition. | |
| 760 | .DESTADDRREQ => unreachable, // `connect` was never called. | |
| 761 | .DQUOT => return error.DiskQuota, | |
| 762 | .FBIG => return error.FileTooBig, | |
| 763 | .IO => return error.InputOutput, | |
| 764 | .NOSPC => return error.NoSpaceLeft, | |
| 765 | .PERM => return error.AccessDenied, | |
| 766 | .PIPE => return error.BrokenPipe, | |
| 767 | .CONNRESET => return error.ConnectionResetByPeer, | |
| 768 | 768 | else => |err| return unexpectedErrno(err), |
| 769 | 769 | } |
| 770 | 770 | } |
| ... | ... | @@ -798,20 +798,20 @@ pub fn writev(fd: fd_t, iov: []const iovec_const) WriteError!usize { |
| 798 | 798 | if (builtin.os.tag == .wasi and !builtin.link_libc) { |
| 799 | 799 | var nwritten: usize = undefined; |
| 800 | 800 | switch (wasi.fd_write(fd, iov.ptr, iov.len, &nwritten)) { |
| 801 | wasi.ESUCCESS => return nwritten, | |
| 802 | wasi.EINTR => unreachable, | |
| 803 | wasi.EINVAL => unreachable, | |
| 804 | wasi.EFAULT => unreachable, | |
| 805 | wasi.EAGAIN => unreachable, | |
| 806 | wasi.EBADF => return error.NotOpenForWriting, // can be a race condition. | |
| 807 | wasi.EDESTADDRREQ => unreachable, // `connect` was never called. | |
| 808 | wasi.EDQUOT => return error.DiskQuota, | |
| 809 | wasi.EFBIG => return error.FileTooBig, | |
| 810 | wasi.EIO => return error.InputOutput, | |
| 811 | wasi.ENOSPC => return error.NoSpaceLeft, | |
| 812 | wasi.EPERM => return error.AccessDenied, | |
| 813 | wasi.EPIPE => return error.BrokenPipe, | |
| 814 | wasi.ENOTCAPABLE => return error.AccessDenied, | |
| 801 | .SUCCESS => return nwritten, | |
| 802 | .INTR => unreachable, | |
| 803 | .INVAL => unreachable, | |
| 804 | .FAULT => unreachable, | |
| 805 | .AGAIN => unreachable, | |
| 806 | .BADF => return error.NotOpenForWriting, // can be a race condition. | |
| 807 | .DESTADDRREQ => unreachable, // `connect` was never called. | |
| 808 | .DQUOT => return error.DiskQuota, | |
| 809 | .FBIG => return error.FileTooBig, | |
| 810 | .IO => return error.InputOutput, | |
| 811 | .NOSPC => return error.NoSpaceLeft, | |
| 812 | .PERM => return error.AccessDenied, | |
| 813 | .PIPE => return error.BrokenPipe, | |
| 814 | .NOTCAPABLE => return error.AccessDenied, | |
| 815 | 815 | else => |err| return unexpectedErrno(err), |
| 816 | 816 | } |
| 817 | 817 | } |
| ... | ... | @@ -820,20 +820,20 @@ pub fn writev(fd: fd_t, iov: []const iovec_const) WriteError!usize { |
| 820 | 820 | while (true) { |
| 821 | 821 | const rc = system.writev(fd, iov.ptr, iov_count); |
| 822 | 822 | switch (errno(rc)) { |
| 823 | 0 => return @intCast(usize, rc), | |
| 824 | EINTR => continue, | |
| 825 | EINVAL => unreachable, | |
| 826 | EFAULT => unreachable, | |
| 827 | EAGAIN => return error.WouldBlock, | |
| 828 | EBADF => return error.NotOpenForWriting, // Can be a race condition. | |
| 829 | EDESTADDRREQ => unreachable, // `connect` was never called. | |
| 830 | EDQUOT => return error.DiskQuota, | |
| 831 | EFBIG => return error.FileTooBig, | |
| 832 | EIO => return error.InputOutput, | |
| 833 | ENOSPC => return error.NoSpaceLeft, | |
| 834 | EPERM => return error.AccessDenied, | |
| 835 | EPIPE => return error.BrokenPipe, | |
| 836 | ECONNRESET => return error.ConnectionResetByPeer, | |
| 823 | .SUCCESS => return @intCast(usize, rc), | |
| 824 | .INTR => continue, | |
| 825 | .INVAL => unreachable, | |
| 826 | .FAULT => unreachable, | |
| 827 | .AGAIN => return error.WouldBlock, | |
| 828 | .BADF => return error.NotOpenForWriting, // Can be a race condition. | |
| 829 | .DESTADDRREQ => unreachable, // `connect` was never called. | |
| 830 | .DQUOT => return error.DiskQuota, | |
| 831 | .FBIG => return error.FileTooBig, | |
| 832 | .IO => return error.InputOutput, | |
| 833 | .NOSPC => return error.NoSpaceLeft, | |
| 834 | .PERM => return error.AccessDenied, | |
| 835 | .PIPE => return error.BrokenPipe, | |
| 836 | .CONNRESET => return error.ConnectionResetByPeer, | |
| 837 | 837 | else => |err| return unexpectedErrno(err), |
| 838 | 838 | } |
| 839 | 839 | } |
| ... | ... | @@ -875,23 +875,23 @@ pub fn pwrite(fd: fd_t, bytes: []const u8, offset: u64) PWriteError!usize { |
| 875 | 875 | |
| 876 | 876 | var nwritten: usize = undefined; |
| 877 | 877 | switch (wasi.fd_pwrite(fd, &ciovs, ciovs.len, offset, &nwritten)) { |
| 878 | wasi.ESUCCESS => return nwritten, | |
| 879 | wasi.EINTR => unreachable, | |
| 880 | wasi.EINVAL => unreachable, | |
| 881 | wasi.EFAULT => unreachable, | |
| 882 | wasi.EAGAIN => unreachable, | |
| 883 | wasi.EBADF => return error.NotOpenForWriting, // can be a race condition. | |
| 884 | wasi.EDESTADDRREQ => unreachable, // `connect` was never called. | |
| 885 | wasi.EDQUOT => return error.DiskQuota, | |
| 886 | wasi.EFBIG => return error.FileTooBig, | |
| 887 | wasi.EIO => return error.InputOutput, | |
| 888 | wasi.ENOSPC => return error.NoSpaceLeft, | |
| 889 | wasi.EPERM => return error.AccessDenied, | |
| 890 | wasi.EPIPE => return error.BrokenPipe, | |
| 891 | wasi.ENXIO => return error.Unseekable, | |
| 892 | wasi.ESPIPE => return error.Unseekable, | |
| 893 | wasi.EOVERFLOW => return error.Unseekable, | |
| 894 | wasi.ENOTCAPABLE => return error.AccessDenied, | |
| 878 | .SUCCESS => return nwritten, | |
| 879 | .INTR => unreachable, | |
| 880 | .INVAL => unreachable, | |
| 881 | .FAULT => unreachable, | |
| 882 | .AGAIN => unreachable, | |
| 883 | .BADF => return error.NotOpenForWriting, // can be a race condition. | |
| 884 | .DESTADDRREQ => unreachable, // `connect` was never called. | |
| 885 | .DQUOT => return error.DiskQuota, | |
| 886 | .FBIG => return error.FileTooBig, | |
| 887 | .IO => return error.InputOutput, | |
| 888 | .NOSPC => return error.NoSpaceLeft, | |
| 889 | .PERM => return error.AccessDenied, | |
| 890 | .PIPE => return error.BrokenPipe, | |
| 891 | .NXIO => return error.Unseekable, | |
| 892 | .SPIPE => return error.Unseekable, | |
| 893 | .OVERFLOW => return error.Unseekable, | |
| 894 | .NOTCAPABLE => return error.AccessDenied, | |
| 895 | 895 | else => |err| return unexpectedErrno(err), |
| 896 | 896 | } |
| 897 | 897 | } |
| ... | ... | @@ -913,22 +913,22 @@ pub fn pwrite(fd: fd_t, bytes: []const u8, offset: u64) PWriteError!usize { |
| 913 | 913 | while (true) { |
| 914 | 914 | const rc = pwrite_sym(fd, bytes.ptr, adjusted_len, ioffset); |
| 915 | 915 | switch (errno(rc)) { |
| 916 | 0 => return @intCast(usize, rc), | |
| 917 | EINTR => continue, | |
| 918 | EINVAL => unreachable, | |
| 919 | EFAULT => unreachable, | |
| 920 | EAGAIN => return error.WouldBlock, | |
| 921 | EBADF => return error.NotOpenForWriting, // Can be a race condition. | |
| 922 | EDESTADDRREQ => unreachable, // `connect` was never called. | |
| 923 | EDQUOT => return error.DiskQuota, | |
| 924 | EFBIG => return error.FileTooBig, | |
| 925 | EIO => return error.InputOutput, | |
| 926 | ENOSPC => return error.NoSpaceLeft, | |
| 927 | EPERM => return error.AccessDenied, | |
| 928 | EPIPE => return error.BrokenPipe, | |
| 929 | ENXIO => return error.Unseekable, | |
| 930 | ESPIPE => return error.Unseekable, | |
| 931 | EOVERFLOW => return error.Unseekable, | |
| 916 | .SUCCESS => return @intCast(usize, rc), | |
| 917 | .INTR => continue, | |
| 918 | .INVAL => unreachable, | |
| 919 | .FAULT => unreachable, | |
| 920 | .AGAIN => return error.WouldBlock, | |
| 921 | .BADF => return error.NotOpenForWriting, // Can be a race condition. | |
| 922 | .DESTADDRREQ => unreachable, // `connect` was never called. | |
| 923 | .DQUOT => return error.DiskQuota, | |
| 924 | .FBIG => return error.FileTooBig, | |
| 925 | .IO => return error.InputOutput, | |
| 926 | .NOSPC => return error.NoSpaceLeft, | |
| 927 | .PERM => return error.AccessDenied, | |
| 928 | .PIPE => return error.BrokenPipe, | |
| 929 | .NXIO => return error.Unseekable, | |
| 930 | .SPIPE => return error.Unseekable, | |
| 931 | .OVERFLOW => return error.Unseekable, | |
| 932 | 932 | else => |err| return unexpectedErrno(err), |
| 933 | 933 | } |
| 934 | 934 | } |
| ... | ... | @@ -971,23 +971,23 @@ pub fn pwritev(fd: fd_t, iov: []const iovec_const, offset: u64) PWriteError!usiz |
| 971 | 971 | if (builtin.os.tag == .wasi and !builtin.link_libc) { |
| 972 | 972 | var nwritten: usize = undefined; |
| 973 | 973 | switch (wasi.fd_pwrite(fd, iov.ptr, iov.len, offset, &nwritten)) { |
| 974 | wasi.ESUCCESS => return nwritten, | |
| 975 | wasi.EINTR => unreachable, | |
| 976 | wasi.EINVAL => unreachable, | |
| 977 | wasi.EFAULT => unreachable, | |
| 978 | wasi.EAGAIN => unreachable, | |
| 979 | wasi.EBADF => return error.NotOpenForWriting, // Can be a race condition. | |
| 980 | wasi.EDESTADDRREQ => unreachable, // `connect` was never called. | |
| 981 | wasi.EDQUOT => return error.DiskQuota, | |
| 982 | wasi.EFBIG => return error.FileTooBig, | |
| 983 | wasi.EIO => return error.InputOutput, | |
| 984 | wasi.ENOSPC => return error.NoSpaceLeft, | |
| 985 | wasi.EPERM => return error.AccessDenied, | |
| 986 | wasi.EPIPE => return error.BrokenPipe, | |
| 987 | wasi.ENXIO => return error.Unseekable, | |
| 988 | wasi.ESPIPE => return error.Unseekable, | |
| 989 | wasi.EOVERFLOW => return error.Unseekable, | |
| 990 | wasi.ENOTCAPABLE => return error.AccessDenied, | |
| 974 | .SUCCESS => return nwritten, | |
| 975 | .INTR => unreachable, | |
| 976 | .INVAL => unreachable, | |
| 977 | .FAULT => unreachable, | |
| 978 | .AGAIN => unreachable, | |
| 979 | .BADF => return error.NotOpenForWriting, // Can be a race condition. | |
| 980 | .DESTADDRREQ => unreachable, // `connect` was never called. | |
| 981 | .DQUOT => return error.DiskQuota, | |
| 982 | .FBIG => return error.FileTooBig, | |
| 983 | .IO => return error.InputOutput, | |
| 984 | .NOSPC => return error.NoSpaceLeft, | |
| 985 | .PERM => return error.AccessDenied, | |
| 986 | .PIPE => return error.BrokenPipe, | |
| 987 | .NXIO => return error.Unseekable, | |
| 988 | .SPIPE => return error.Unseekable, | |
| 989 | .OVERFLOW => return error.Unseekable, | |
| 990 | .NOTCAPABLE => return error.AccessDenied, | |
| 991 | 991 | else => |err| return unexpectedErrno(err), |
| 992 | 992 | } |
| 993 | 993 | } |
| ... | ... | @@ -1002,22 +1002,22 @@ pub fn pwritev(fd: fd_t, iov: []const iovec_const, offset: u64) PWriteError!usiz |
| 1002 | 1002 | while (true) { |
| 1003 | 1003 | const rc = pwritev_sym(fd, iov.ptr, iov_count, ioffset); |
| 1004 | 1004 | switch (errno(rc)) { |
| 1005 | 0 => return @intCast(usize, rc), | |
| 1006 | EINTR => continue, | |
| 1007 | EINVAL => unreachable, | |
| 1008 | EFAULT => unreachable, | |
| 1009 | EAGAIN => return error.WouldBlock, | |
| 1010 | EBADF => return error.NotOpenForWriting, // Can be a race condition. | |
| 1011 | EDESTADDRREQ => unreachable, // `connect` was never called. | |
| 1012 | EDQUOT => return error.DiskQuota, | |
| 1013 | EFBIG => return error.FileTooBig, | |
| 1014 | EIO => return error.InputOutput, | |
| 1015 | ENOSPC => return error.NoSpaceLeft, | |
| 1016 | EPERM => return error.AccessDenied, | |
| 1017 | EPIPE => return error.BrokenPipe, | |
| 1018 | ENXIO => return error.Unseekable, | |
| 1019 | ESPIPE => return error.Unseekable, | |
| 1020 | EOVERFLOW => return error.Unseekable, | |
| 1005 | .SUCCESS => return @intCast(usize, rc), | |
| 1006 | .INTR => continue, | |
| 1007 | .INVAL => unreachable, | |
| 1008 | .FAULT => unreachable, | |
| 1009 | .AGAIN => return error.WouldBlock, | |
| 1010 | .BADF => return error.NotOpenForWriting, // Can be a race condition. | |
| 1011 | .DESTADDRREQ => unreachable, // `connect` was never called. | |
| 1012 | .DQUOT => return error.DiskQuota, | |
| 1013 | .FBIG => return error.FileTooBig, | |
| 1014 | .IO => return error.InputOutput, | |
| 1015 | .NOSPC => return error.NoSpaceLeft, | |
| 1016 | .PERM => return error.AccessDenied, | |
| 1017 | .PIPE => return error.BrokenPipe, | |
| 1018 | .NXIO => return error.Unseekable, | |
| 1019 | .SPIPE => return error.Unseekable, | |
| 1020 | .OVERFLOW => return error.Unseekable, | |
| 1021 | 1021 | else => |err| return unexpectedErrno(err), |
| 1022 | 1022 | } |
| 1023 | 1023 | } |
| ... | ... | @@ -1098,27 +1098,27 @@ pub fn openZ(file_path: [*:0]const u8, flags: u32, perm: mode_t) OpenError!fd_t |
| 1098 | 1098 | while (true) { |
| 1099 | 1099 | const rc = open_sym(file_path, flags, perm); |
| 1100 | 1100 | switch (errno(rc)) { |
| 1101 | 0 => return @intCast(fd_t, rc), | |
| 1102 | EINTR => continue, | |
| 1103 | ||
| 1104 | EFAULT => unreachable, | |
| 1105 | EINVAL => unreachable, | |
| 1106 | EACCES => return error.AccessDenied, | |
| 1107 | EFBIG => return error.FileTooBig, | |
| 1108 | EOVERFLOW => return error.FileTooBig, | |
| 1109 | EISDIR => return error.IsDir, | |
| 1110 | ELOOP => return error.SymLinkLoop, | |
| 1111 | EMFILE => return error.ProcessFdQuotaExceeded, | |
| 1112 | ENAMETOOLONG => return error.NameTooLong, | |
| 1113 | ENFILE => return error.SystemFdQuotaExceeded, | |
| 1114 | ENODEV => return error.NoDevice, | |
| 1115 | ENOENT => return error.FileNotFound, | |
| 1116 | ENOMEM => return error.SystemResources, | |
| 1117 | ENOSPC => return error.NoSpaceLeft, | |
| 1118 | ENOTDIR => return error.NotDir, | |
| 1119 | EPERM => return error.AccessDenied, | |
| 1120 | EEXIST => return error.PathAlreadyExists, | |
| 1121 | EBUSY => return error.DeviceBusy, | |
| 1101 | .SUCCESS => return @intCast(fd_t, rc), | |
| 1102 | .INTR => continue, | |
| 1103 | ||
| 1104 | .FAULT => unreachable, | |
| 1105 | .INVAL => unreachable, | |
| 1106 | .ACCES => return error.AccessDenied, | |
| 1107 | .FBIG => return error.FileTooBig, | |
| 1108 | .OVERFLOW => return error.FileTooBig, | |
| 1109 | .ISDIR => return error.IsDir, | |
| 1110 | .LOOP => return error.SymLinkLoop, | |
| 1111 | .MFILE => return error.ProcessFdQuotaExceeded, | |
| 1112 | .NAMETOOLONG => return error.NameTooLong, | |
| 1113 | .NFILE => return error.SystemFdQuotaExceeded, | |
| 1114 | .NODEV => return error.NoDevice, | |
| 1115 | .NOENT => return error.FileNotFound, | |
| 1116 | .NOMEM => return error.SystemResources, | |
| 1117 | .NOSPC => return error.NoSpaceLeft, | |
| 1118 | .NOTDIR => return error.NotDir, | |
| 1119 | .PERM => return error.AccessDenied, | |
| 1120 | .EXIST => return error.PathAlreadyExists, | |
| 1121 | .BUSY => return error.DeviceBusy, | |
| 1122 | 1122 | else => |err| return unexpectedErrno(err), |
| 1123 | 1123 | } |
| 1124 | 1124 | } |
| ... | ... | @@ -1193,28 +1193,28 @@ pub fn openatWasi(dir_fd: fd_t, file_path: []const u8, lookup_flags: lookupflags |
| 1193 | 1193 | while (true) { |
| 1194 | 1194 | var fd: fd_t = undefined; |
| 1195 | 1195 | switch (wasi.path_open(dir_fd, lookup_flags, file_path.ptr, file_path.len, oflags, base, inheriting, fdflags, &fd)) { |
| 1196 | wasi.ESUCCESS => return fd, | |
| 1197 | wasi.EINTR => continue, | |
| 1198 | ||
| 1199 | wasi.EFAULT => unreachable, | |
| 1200 | wasi.EINVAL => unreachable, | |
| 1201 | wasi.EACCES => return error.AccessDenied, | |
| 1202 | wasi.EFBIG => return error.FileTooBig, | |
| 1203 | wasi.EOVERFLOW => return error.FileTooBig, | |
| 1204 | wasi.EISDIR => return error.IsDir, | |
| 1205 | wasi.ELOOP => return error.SymLinkLoop, | |
| 1206 | wasi.EMFILE => return error.ProcessFdQuotaExceeded, | |
| 1207 | wasi.ENAMETOOLONG => return error.NameTooLong, | |
| 1208 | wasi.ENFILE => return error.SystemFdQuotaExceeded, | |
| 1209 | wasi.ENODEV => return error.NoDevice, | |
| 1210 | wasi.ENOENT => return error.FileNotFound, | |
| 1211 | wasi.ENOMEM => return error.SystemResources, | |
| 1212 | wasi.ENOSPC => return error.NoSpaceLeft, | |
| 1213 | wasi.ENOTDIR => return error.NotDir, | |
| 1214 | wasi.EPERM => return error.AccessDenied, | |
| 1215 | wasi.EEXIST => return error.PathAlreadyExists, | |
| 1216 | wasi.EBUSY => return error.DeviceBusy, | |
| 1217 | wasi.ENOTCAPABLE => return error.AccessDenied, | |
| 1196 | .SUCCESS => return fd, | |
| 1197 | .INTR => continue, | |
| 1198 | ||
| 1199 | .FAULT => unreachable, | |
| 1200 | .INVAL => unreachable, | |
| 1201 | .ACCES => return error.AccessDenied, | |
| 1202 | .FBIG => return error.FileTooBig, | |
| 1203 | .OVERFLOW => return error.FileTooBig, | |
| 1204 | .ISDIR => return error.IsDir, | |
| 1205 | .LOOP => return error.SymLinkLoop, | |
| 1206 | .MFILE => return error.ProcessFdQuotaExceeded, | |
| 1207 | .NAMETOOLONG => return error.NameTooLong, | |
| 1208 | .NFILE => return error.SystemFdQuotaExceeded, | |
| 1209 | .NODEV => return error.NoDevice, | |
| 1210 | .NOENT => return error.FileNotFound, | |
| 1211 | .NOMEM => return error.SystemResources, | |
| 1212 | .NOSPC => return error.NoSpaceLeft, | |
| 1213 | .NOTDIR => return error.NotDir, | |
| 1214 | .PERM => return error.AccessDenied, | |
| 1215 | .EXIST => return error.PathAlreadyExists, | |
| 1216 | .BUSY => return error.DeviceBusy, | |
| 1217 | .NOTCAPABLE => return error.AccessDenied, | |
| 1218 | 1218 | else => |err| return unexpectedErrno(err), |
| 1219 | 1219 | } |
| 1220 | 1220 | } |
| ... | ... | @@ -1239,30 +1239,30 @@ pub fn openatZ(dir_fd: fd_t, file_path: [*:0]const u8, flags: u32, mode: mode_t) |
| 1239 | 1239 | while (true) { |
| 1240 | 1240 | const rc = openat_sym(dir_fd, file_path, flags, mode); |
| 1241 | 1241 | switch (errno(rc)) { |
| 1242 | 0 => return @intCast(fd_t, rc), | |
| 1243 | EINTR => continue, | |
| 1244 | ||
| 1245 | EFAULT => unreachable, | |
| 1246 | EINVAL => unreachable, | |
| 1247 | EBADF => unreachable, | |
| 1248 | EACCES => return error.AccessDenied, | |
| 1249 | EFBIG => return error.FileTooBig, | |
| 1250 | EOVERFLOW => return error.FileTooBig, | |
| 1251 | EISDIR => return error.IsDir, | |
| 1252 | ELOOP => return error.SymLinkLoop, | |
| 1253 | EMFILE => return error.ProcessFdQuotaExceeded, | |
| 1254 | ENAMETOOLONG => return error.NameTooLong, | |
| 1255 | ENFILE => return error.SystemFdQuotaExceeded, | |
| 1256 | ENODEV => return error.NoDevice, | |
| 1257 | ENOENT => return error.FileNotFound, | |
| 1258 | ENOMEM => return error.SystemResources, | |
| 1259 | ENOSPC => return error.NoSpaceLeft, | |
| 1260 | ENOTDIR => return error.NotDir, | |
| 1261 | EPERM => return error.AccessDenied, | |
| 1262 | EEXIST => return error.PathAlreadyExists, | |
| 1263 | EBUSY => return error.DeviceBusy, | |
| 1264 | EOPNOTSUPP => return error.FileLocksNotSupported, | |
| 1265 | EWOULDBLOCK => return error.WouldBlock, | |
| 1242 | .SUCCESS => return @intCast(fd_t, rc), | |
| 1243 | .INTR => continue, | |
| 1244 | ||
| 1245 | .FAULT => unreachable, | |
| 1246 | .INVAL => unreachable, | |
| 1247 | .BADF => unreachable, | |
| 1248 | .ACCES => return error.AccessDenied, | |
| 1249 | .FBIG => return error.FileTooBig, | |
| 1250 | .OVERFLOW => return error.FileTooBig, | |
| 1251 | .ISDIR => return error.IsDir, | |
| 1252 | .LOOP => return error.SymLinkLoop, | |
| 1253 | .MFILE => return error.ProcessFdQuotaExceeded, | |
| 1254 | .NAMETOOLONG => return error.NameTooLong, | |
| 1255 | .NFILE => return error.SystemFdQuotaExceeded, | |
| 1256 | .NODEV => return error.NoDevice, | |
| 1257 | .NOENT => return error.FileNotFound, | |
| 1258 | .NOMEM => return error.SystemResources, | |
| 1259 | .NOSPC => return error.NoSpaceLeft, | |
| 1260 | .NOTDIR => return error.NotDir, | |
| 1261 | .PERM => return error.AccessDenied, | |
| 1262 | .EXIST => return error.PathAlreadyExists, | |
| 1263 | .BUSY => return error.DeviceBusy, | |
| 1264 | .OPNOTSUPP => return error.FileLocksNotSupported, | |
| 1265 | .AGAIN => return error.WouldBlock, | |
| 1266 | 1266 | else => |err| return unexpectedErrno(err), |
| 1267 | 1267 | } |
| 1268 | 1268 | } |
| ... | ... | @@ -1286,9 +1286,9 @@ pub fn openatW(dir_fd: fd_t, file_path_w: []const u16, flags: u32, mode: mode_t) |
| 1286 | 1286 | pub fn dup(old_fd: fd_t) !fd_t { |
| 1287 | 1287 | const rc = system.dup(old_fd); |
| 1288 | 1288 | return switch (errno(rc)) { |
| 1289 | 0 => return @intCast(fd_t, rc), | |
| 1290 | EMFILE => error.ProcessFdQuotaExceeded, | |
| 1291 | EBADF => unreachable, // invalid file descriptor | |
| 1289 | .SUCCESS => return @intCast(fd_t, rc), | |
| 1290 | .MFILE => error.ProcessFdQuotaExceeded, | |
| 1291 | .BADF => unreachable, // invalid file descriptor | |
| 1292 | 1292 | else => |err| return unexpectedErrno(err), |
| 1293 | 1293 | }; |
| 1294 | 1294 | } |
| ... | ... | @@ -1296,11 +1296,11 @@ pub fn dup(old_fd: fd_t) !fd_t { |
| 1296 | 1296 | pub fn dup2(old_fd: fd_t, new_fd: fd_t) !void { |
| 1297 | 1297 | while (true) { |
| 1298 | 1298 | switch (errno(system.dup2(old_fd, new_fd))) { |
| 1299 | 0 => return, | |
| 1300 | EBUSY, EINTR => continue, | |
| 1301 | EMFILE => return error.ProcessFdQuotaExceeded, | |
| 1302 | EINVAL => unreachable, // invalid parameters passed to dup2 | |
| 1303 | EBADF => unreachable, // invalid file descriptor | |
| 1299 | .SUCCESS => return, | |
| 1300 | .BUSY, .INTR => continue, | |
| 1301 | .MFILE => return error.ProcessFdQuotaExceeded, | |
| 1302 | .INVAL => unreachable, // invalid parameters passed to dup2 | |
| 1303 | .BADF => unreachable, // invalid file descriptor | |
| 1304 | 1304 | else => |err| return unexpectedErrno(err), |
| 1305 | 1305 | } |
| 1306 | 1306 | } |
| ... | ... | @@ -1331,23 +1331,23 @@ pub fn execveZ( |
| 1331 | 1331 | envp: [*:null]const ?[*:0]const u8, |
| 1332 | 1332 | ) ExecveError { |
| 1333 | 1333 | switch (errno(system.execve(path, child_argv, envp))) { |
| 1334 | 0 => unreachable, | |
| 1335 | EFAULT => unreachable, | |
| 1336 | E2BIG => return error.SystemResources, | |
| 1337 | EMFILE => return error.ProcessFdQuotaExceeded, | |
| 1338 | ENAMETOOLONG => return error.NameTooLong, | |
| 1339 | ENFILE => return error.SystemFdQuotaExceeded, | |
| 1340 | ENOMEM => return error.SystemResources, | |
| 1341 | EACCES => return error.AccessDenied, | |
| 1342 | EPERM => return error.AccessDenied, | |
| 1343 | EINVAL => return error.InvalidExe, | |
| 1344 | ENOEXEC => return error.InvalidExe, | |
| 1345 | EIO => return error.FileSystem, | |
| 1346 | ELOOP => return error.FileSystem, | |
| 1347 | EISDIR => return error.IsDir, | |
| 1348 | ENOENT => return error.FileNotFound, | |
| 1349 | ENOTDIR => return error.NotDir, | |
| 1350 | ETXTBSY => return error.FileBusy, | |
| 1334 | .SUCCESS => unreachable, | |
| 1335 | .FAULT => unreachable, | |
| 1336 | .@"2BIG" => return error.SystemResources, | |
| 1337 | .MFILE => return error.ProcessFdQuotaExceeded, | |
| 1338 | .NAMETOOLONG => return error.NameTooLong, | |
| 1339 | .NFILE => return error.SystemFdQuotaExceeded, | |
| 1340 | .NOMEM => return error.SystemResources, | |
| 1341 | .ACCES => return error.AccessDenied, | |
| 1342 | .PERM => return error.AccessDenied, | |
| 1343 | .INVAL => return error.InvalidExe, | |
| 1344 | .NOEXEC => return error.InvalidExe, | |
| 1345 | .IO => return error.FileSystem, | |
| 1346 | .LOOP => return error.FileSystem, | |
| 1347 | .ISDIR => return error.IsDir, | |
| 1348 | .NOENT => return error.FileNotFound, | |
| 1349 | .NOTDIR => return error.NotDir, | |
| 1350 | .TXTBSY => return error.FileBusy, | |
| 1351 | 1351 | else => |err| return unexpectedErrno(err), |
| 1352 | 1352 | } |
| 1353 | 1353 | } |
| ... | ... | @@ -1543,16 +1543,17 @@ pub fn getcwd(out_buffer: []u8) GetCwdError![]u8 { |
| 1543 | 1543 | } |
| 1544 | 1544 | |
| 1545 | 1545 | const err = if (builtin.link_libc) blk: { |
| 1546 | break :blk if (std.c.getcwd(out_buffer.ptr, out_buffer.len)) |_| 0 else std.c._errno().*; | |
| 1546 | const c_err = if (std.c.getcwd(out_buffer.ptr, out_buffer.len)) |_| 0 else std.c._errno().*; | |
| 1547 | break :blk @intToEnum(E, c_err); | |
| 1547 | 1548 | } else blk: { |
| 1548 | 1549 | break :blk errno(system.getcwd(out_buffer.ptr, out_buffer.len)); |
| 1549 | 1550 | }; |
| 1550 | 1551 | switch (err) { |
| 1551 | 0 => return mem.spanZ(std.meta.assumeSentinel(out_buffer.ptr, 0)), | |
| 1552 | EFAULT => unreachable, | |
| 1553 | EINVAL => unreachable, | |
| 1554 | ENOENT => return error.CurrentWorkingDirectoryUnlinked, | |
| 1555 | ERANGE => return error.NameTooLong, | |
| 1552 | .SUCCESS => return mem.spanZ(std.meta.assumeSentinel(out_buffer.ptr, 0)), | |
| 1553 | .FAULT => unreachable, | |
| 1554 | .INVAL => unreachable, | |
| 1555 | .NOENT => return error.CurrentWorkingDirectoryUnlinked, | |
| 1556 | .RANGE => return error.NameTooLong, | |
| 1556 | 1557 | else => return unexpectedErrno(err), |
| 1557 | 1558 | } |
| 1558 | 1559 | } |
| ... | ... | @@ -1601,21 +1602,21 @@ pub fn symlinkZ(target_path: [*:0]const u8, sym_link_path: [*:0]const u8) SymLin |
| 1601 | 1602 | @compileError("symlink is not supported on Windows; use std.os.windows.CreateSymbolicLink instead"); |
| 1602 | 1603 | } |
| 1603 | 1604 | switch (errno(system.symlink(target_path, sym_link_path))) { |
| 1604 | 0 => return, | |
| 1605 | EFAULT => unreachable, | |
| 1606 | EINVAL => unreachable, | |
| 1607 | EACCES => return error.AccessDenied, | |
| 1608 | EPERM => return error.AccessDenied, | |
| 1609 | EDQUOT => return error.DiskQuota, | |
| 1610 | EEXIST => return error.PathAlreadyExists, | |
| 1611 | EIO => return error.FileSystem, | |
| 1612 | ELOOP => return error.SymLinkLoop, | |
| 1613 | ENAMETOOLONG => return error.NameTooLong, | |
| 1614 | ENOENT => return error.FileNotFound, | |
| 1615 | ENOTDIR => return error.NotDir, | |
| 1616 | ENOMEM => return error.SystemResources, | |
| 1617 | ENOSPC => return error.NoSpaceLeft, | |
| 1618 | EROFS => return error.ReadOnlyFileSystem, | |
| 1605 | .SUCCESS => return, | |
| 1606 | .FAULT => unreachable, | |
| 1607 | .INVAL => unreachable, | |
| 1608 | .ACCES => return error.AccessDenied, | |
| 1609 | .PERM => return error.AccessDenied, | |
| 1610 | .DQUOT => return error.DiskQuota, | |
| 1611 | .EXIST => return error.PathAlreadyExists, | |
| 1612 | .IO => return error.FileSystem, | |
| 1613 | .LOOP => return error.SymLinkLoop, | |
| 1614 | .NAMETOOLONG => return error.NameTooLong, | |
| 1615 | .NOENT => return error.FileNotFound, | |
| 1616 | .NOTDIR => return error.NotDir, | |
| 1617 | .NOMEM => return error.SystemResources, | |
| 1618 | .NOSPC => return error.NoSpaceLeft, | |
| 1619 | .ROFS => return error.ReadOnlyFileSystem, | |
| 1619 | 1620 | else => |err| return unexpectedErrno(err), |
| 1620 | 1621 | } |
| 1621 | 1622 | } |
| ... | ... | @@ -1644,22 +1645,22 @@ pub const symlinkatC = @compileError("deprecated: renamed to symlinkatZ"); |
| 1644 | 1645 | /// See also `symlinkat`. |
| 1645 | 1646 | pub fn symlinkatWasi(target_path: []const u8, newdirfd: fd_t, sym_link_path: []const u8) SymLinkError!void { |
| 1646 | 1647 | switch (wasi.path_symlink(target_path.ptr, target_path.len, newdirfd, sym_link_path.ptr, sym_link_path.len)) { |
| 1647 | wasi.ESUCCESS => {}, | |
| 1648 | wasi.EFAULT => unreachable, | |
| 1649 | wasi.EINVAL => unreachable, | |
| 1650 | wasi.EACCES => return error.AccessDenied, | |
| 1651 | wasi.EPERM => return error.AccessDenied, | |
| 1652 | wasi.EDQUOT => return error.DiskQuota, | |
| 1653 | wasi.EEXIST => return error.PathAlreadyExists, | |
| 1654 | wasi.EIO => return error.FileSystem, | |
| 1655 | wasi.ELOOP => return error.SymLinkLoop, | |
| 1656 | wasi.ENAMETOOLONG => return error.NameTooLong, | |
| 1657 | wasi.ENOENT => return error.FileNotFound, | |
| 1658 | wasi.ENOTDIR => return error.NotDir, | |
| 1659 | wasi.ENOMEM => return error.SystemResources, | |
| 1660 | wasi.ENOSPC => return error.NoSpaceLeft, | |
| 1661 | wasi.EROFS => return error.ReadOnlyFileSystem, | |
| 1662 | wasi.ENOTCAPABLE => return error.AccessDenied, | |
| 1648 | .SUCCESS => {}, | |
| 1649 | .FAULT => unreachable, | |
| 1650 | .INVAL => unreachable, | |
| 1651 | .ACCES => return error.AccessDenied, | |
| 1652 | .PERM => return error.AccessDenied, | |
| 1653 | .DQUOT => return error.DiskQuota, | |
| 1654 | .EXIST => return error.PathAlreadyExists, | |
| 1655 | .IO => return error.FileSystem, | |
| 1656 | .LOOP => return error.SymLinkLoop, | |
| 1657 | .NAMETOOLONG => return error.NameTooLong, | |
| 1658 | .NOENT => return error.FileNotFound, | |
| 1659 | .NOTDIR => return error.NotDir, | |
| 1660 | .NOMEM => return error.SystemResources, | |
| 1661 | .NOSPC => return error.NoSpaceLeft, | |
| 1662 | .ROFS => return error.ReadOnlyFileSystem, | |
| 1663 | .NOTCAPABLE => return error.AccessDenied, | |
| 1663 | 1664 | else => |err| return unexpectedErrno(err), |
| 1664 | 1665 | } |
| 1665 | 1666 | } |
| ... | ... | @@ -1671,21 +1672,21 @@ pub fn symlinkatZ(target_path: [*:0]const u8, newdirfd: fd_t, sym_link_path: [*: |
| 1671 | 1672 | @compileError("symlinkat is not supported on Windows; use std.os.windows.CreateSymbolicLink instead"); |
| 1672 | 1673 | } |
| 1673 | 1674 | switch (errno(system.symlinkat(target_path, newdirfd, sym_link_path))) { |
| 1674 | 0 => return, | |
| 1675 | EFAULT => unreachable, | |
| 1676 | EINVAL => unreachable, | |
| 1677 | EACCES => return error.AccessDenied, | |
| 1678 | EPERM => return error.AccessDenied, | |
| 1679 | EDQUOT => return error.DiskQuota, | |
| 1680 | EEXIST => return error.PathAlreadyExists, | |
| 1681 | EIO => return error.FileSystem, | |
| 1682 | ELOOP => return error.SymLinkLoop, | |
| 1683 | ENAMETOOLONG => return error.NameTooLong, | |
| 1684 | ENOENT => return error.FileNotFound, | |
| 1685 | ENOTDIR => return error.NotDir, | |
| 1686 | ENOMEM => return error.SystemResources, | |
| 1687 | ENOSPC => return error.NoSpaceLeft, | |
| 1688 | EROFS => return error.ReadOnlyFileSystem, | |
| 1675 | .SUCCESS => return, | |
| 1676 | .FAULT => unreachable, | |
| 1677 | .INVAL => unreachable, | |
| 1678 | .ACCES => return error.AccessDenied, | |
| 1679 | .PERM => return error.AccessDenied, | |
| 1680 | .DQUOT => return error.DiskQuota, | |
| 1681 | .EXIST => return error.PathAlreadyExists, | |
| 1682 | .IO => return error.FileSystem, | |
| 1683 | .LOOP => return error.SymLinkLoop, | |
| 1684 | .NAMETOOLONG => return error.NameTooLong, | |
| 1685 | .NOENT => return error.FileNotFound, | |
| 1686 | .NOTDIR => return error.NotDir, | |
| 1687 | .NOMEM => return error.SystemResources, | |
| 1688 | .NOSPC => return error.NoSpaceLeft, | |
| 1689 | .ROFS => return error.ReadOnlyFileSystem, | |
| 1689 | 1690 | else => |err| return unexpectedErrno(err), |
| 1690 | 1691 | } |
| 1691 | 1692 | } |
| ... | ... | @@ -1707,22 +1708,22 @@ pub const LinkError = UnexpectedError || error{ |
| 1707 | 1708 | |
| 1708 | 1709 | pub fn linkZ(oldpath: [*:0]const u8, newpath: [*:0]const u8, flags: i32) LinkError!void { |
| 1709 | 1710 | switch (errno(system.link(oldpath, newpath, flags))) { |
| 1710 | 0 => return, | |
| 1711 | EACCES => return error.AccessDenied, | |
| 1712 | EDQUOT => return error.DiskQuota, | |
| 1713 | EEXIST => return error.PathAlreadyExists, | |
| 1714 | EFAULT => unreachable, | |
| 1715 | EIO => return error.FileSystem, | |
| 1716 | ELOOP => return error.SymLinkLoop, | |
| 1717 | EMLINK => return error.LinkQuotaExceeded, | |
| 1718 | ENAMETOOLONG => return error.NameTooLong, | |
| 1719 | ENOENT => return error.FileNotFound, | |
| 1720 | ENOMEM => return error.SystemResources, | |
| 1721 | ENOSPC => return error.NoSpaceLeft, | |
| 1722 | EPERM => return error.AccessDenied, | |
| 1723 | EROFS => return error.ReadOnlyFileSystem, | |
| 1724 | EXDEV => return error.NotSameFileSystem, | |
| 1725 | EINVAL => unreachable, | |
| 1711 | .SUCCESS => return, | |
| 1712 | .ACCES => return error.AccessDenied, | |
| 1713 | .DQUOT => return error.DiskQuota, | |
| 1714 | .EXIST => return error.PathAlreadyExists, | |
| 1715 | .FAULT => unreachable, | |
| 1716 | .IO => return error.FileSystem, | |
| 1717 | .LOOP => return error.SymLinkLoop, | |
| 1718 | .MLINK => return error.LinkQuotaExceeded, | |
| 1719 | .NAMETOOLONG => return error.NameTooLong, | |
| 1720 | .NOENT => return error.FileNotFound, | |
| 1721 | .NOMEM => return error.SystemResources, | |
| 1722 | .NOSPC => return error.NoSpaceLeft, | |
| 1723 | .PERM => return error.AccessDenied, | |
| 1724 | .ROFS => return error.ReadOnlyFileSystem, | |
| 1725 | .XDEV => return error.NotSameFileSystem, | |
| 1726 | .INVAL => unreachable, | |
| 1726 | 1727 | else => |err| return unexpectedErrno(err), |
| 1727 | 1728 | } |
| 1728 | 1729 | } |
| ... | ... | @@ -1743,23 +1744,23 @@ pub fn linkatZ( |
| 1743 | 1744 | flags: i32, |
| 1744 | 1745 | ) LinkatError!void { |
| 1745 | 1746 | switch (errno(system.linkat(olddir, oldpath, newdir, newpath, flags))) { |
| 1746 | 0 => return, | |
| 1747 | EACCES => return error.AccessDenied, | |
| 1748 | EDQUOT => return error.DiskQuota, | |
| 1749 | EEXIST => return error.PathAlreadyExists, | |
| 1750 | EFAULT => unreachable, | |
| 1751 | EIO => return error.FileSystem, | |
| 1752 | ELOOP => return error.SymLinkLoop, | |
| 1753 | EMLINK => return error.LinkQuotaExceeded, | |
| 1754 | ENAMETOOLONG => return error.NameTooLong, | |
| 1755 | ENOENT => return error.FileNotFound, | |
| 1756 | ENOMEM => return error.SystemResources, | |
| 1757 | ENOSPC => return error.NoSpaceLeft, | |
| 1758 | ENOTDIR => return error.NotDir, | |
| 1759 | EPERM => return error.AccessDenied, | |
| 1760 | EROFS => return error.ReadOnlyFileSystem, | |
| 1761 | EXDEV => return error.NotSameFileSystem, | |
| 1762 | EINVAL => unreachable, | |
| 1747 | .SUCCESS => return, | |
| 1748 | .ACCES => return error.AccessDenied, | |
| 1749 | .DQUOT => return error.DiskQuota, | |
| 1750 | .EXIST => return error.PathAlreadyExists, | |
| 1751 | .FAULT => unreachable, | |
| 1752 | .IO => return error.FileSystem, | |
| 1753 | .LOOP => return error.SymLinkLoop, | |
| 1754 | .MLINK => return error.LinkQuotaExceeded, | |
| 1755 | .NAMETOOLONG => return error.NameTooLong, | |
| 1756 | .NOENT => return error.FileNotFound, | |
| 1757 | .NOMEM => return error.SystemResources, | |
| 1758 | .NOSPC => return error.NoSpaceLeft, | |
| 1759 | .NOTDIR => return error.NotDir, | |
| 1760 | .PERM => return error.AccessDenied, | |
| 1761 | .ROFS => return error.ReadOnlyFileSystem, | |
| 1762 | .XDEV => return error.NotSameFileSystem, | |
| 1763 | .INVAL => unreachable, | |
| 1763 | 1764 | else => |err| return unexpectedErrno(err), |
| 1764 | 1765 | } |
| 1765 | 1766 | } |
| ... | ... | @@ -1822,20 +1823,20 @@ pub fn unlinkZ(file_path: [*:0]const u8) UnlinkError!void { |
| 1822 | 1823 | return unlinkW(file_path_w.span()); |
| 1823 | 1824 | } |
| 1824 | 1825 | switch (errno(system.unlink(file_path))) { |
| 1825 | 0 => return, | |
| 1826 | EACCES => return error.AccessDenied, | |
| 1827 | EPERM => return error.AccessDenied, | |
| 1828 | EBUSY => return error.FileBusy, | |
| 1829 | EFAULT => unreachable, | |
| 1830 | EINVAL => unreachable, | |
| 1831 | EIO => return error.FileSystem, | |
| 1832 | EISDIR => return error.IsDir, | |
| 1833 | ELOOP => return error.SymLinkLoop, | |
| 1834 | ENAMETOOLONG => return error.NameTooLong, | |
| 1835 | ENOENT => return error.FileNotFound, | |
| 1836 | ENOTDIR => return error.NotDir, | |
| 1837 | ENOMEM => return error.SystemResources, | |
| 1838 | EROFS => return error.ReadOnlyFileSystem, | |
| 1826 | .SUCCESS => return, | |
| 1827 | .ACCES => return error.AccessDenied, | |
| 1828 | .PERM => return error.AccessDenied, | |
| 1829 | .BUSY => return error.FileBusy, | |
| 1830 | .FAULT => unreachable, | |
| 1831 | .INVAL => unreachable, | |
| 1832 | .IO => return error.FileSystem, | |
| 1833 | .ISDIR => return error.IsDir, | |
| 1834 | .LOOP => return error.SymLinkLoop, | |
| 1835 | .NAMETOOLONG => return error.NameTooLong, | |
| 1836 | .NOENT => return error.FileNotFound, | |
| 1837 | .NOTDIR => return error.NotDir, | |
| 1838 | .NOMEM => return error.SystemResources, | |
| 1839 | .ROFS => return error.ReadOnlyFileSystem, | |
| 1839 | 1840 | else => |err| return unexpectedErrno(err), |
| 1840 | 1841 | } |
| 1841 | 1842 | } |
| ... | ... | @@ -1875,24 +1876,24 @@ pub fn unlinkatWasi(dirfd: fd_t, file_path: []const u8, flags: u32) UnlinkatErro |
| 1875 | 1876 | else |
| 1876 | 1877 | wasi.path_unlink_file(dirfd, file_path.ptr, file_path.len); |
| 1877 | 1878 | switch (res) { |
| 1878 | wasi.ESUCCESS => return, | |
| 1879 | wasi.EACCES => return error.AccessDenied, | |
| 1880 | wasi.EPERM => return error.AccessDenied, | |
| 1881 | wasi.EBUSY => return error.FileBusy, | |
| 1882 | wasi.EFAULT => unreachable, | |
| 1883 | wasi.EIO => return error.FileSystem, | |
| 1884 | wasi.EISDIR => return error.IsDir, | |
| 1885 | wasi.ELOOP => return error.SymLinkLoop, | |
| 1886 | wasi.ENAMETOOLONG => return error.NameTooLong, | |
| 1887 | wasi.ENOENT => return error.FileNotFound, | |
| 1888 | wasi.ENOTDIR => return error.NotDir, | |
| 1889 | wasi.ENOMEM => return error.SystemResources, | |
| 1890 | wasi.EROFS => return error.ReadOnlyFileSystem, | |
| 1891 | wasi.ENOTEMPTY => return error.DirNotEmpty, | |
| 1892 | wasi.ENOTCAPABLE => return error.AccessDenied, | |
| 1893 | ||
| 1894 | wasi.EINVAL => unreachable, // invalid flags, or pathname has . as last component | |
| 1895 | wasi.EBADF => unreachable, // always a race condition | |
| 1879 | .SUCCESS => return, | |
| 1880 | .ACCES => return error.AccessDenied, | |
| 1881 | .PERM => return error.AccessDenied, | |
| 1882 | .BUSY => return error.FileBusy, | |
| 1883 | .FAULT => unreachable, | |
| 1884 | .IO => return error.FileSystem, | |
| 1885 | .ISDIR => return error.IsDir, | |
| 1886 | .LOOP => return error.SymLinkLoop, | |
| 1887 | .NAMETOOLONG => return error.NameTooLong, | |
| 1888 | .NOENT => return error.FileNotFound, | |
| 1889 | .NOTDIR => return error.NotDir, | |
| 1890 | .NOMEM => return error.SystemResources, | |
| 1891 | .ROFS => return error.ReadOnlyFileSystem, | |
| 1892 | .NOTEMPTY => return error.DirNotEmpty, | |
| 1893 | .NOTCAPABLE => return error.AccessDenied, | |
| 1894 | ||
| 1895 | .INVAL => unreachable, // invalid flags, or pathname has . as last component | |
| 1896 | .BADF => unreachable, // always a race condition | |
| 1896 | 1897 | |
| 1897 | 1898 | else => |err| return unexpectedErrno(err), |
| 1898 | 1899 | } |
| ... | ... | @@ -1905,23 +1906,23 @@ pub fn unlinkatZ(dirfd: fd_t, file_path_c: [*:0]const u8, flags: u32) UnlinkatEr |
| 1905 | 1906 | return unlinkatW(dirfd, file_path_w.span(), flags); |
| 1906 | 1907 | } |
| 1907 | 1908 | switch (errno(system.unlinkat(dirfd, file_path_c, flags))) { |
| 1908 | 0 => return, | |
| 1909 | EACCES => return error.AccessDenied, | |
| 1910 | EPERM => return error.AccessDenied, | |
| 1911 | EBUSY => return error.FileBusy, | |
| 1912 | EFAULT => unreachable, | |
| 1913 | EIO => return error.FileSystem, | |
| 1914 | EISDIR => return error.IsDir, | |
| 1915 | ELOOP => return error.SymLinkLoop, | |
| 1916 | ENAMETOOLONG => return error.NameTooLong, | |
| 1917 | ENOENT => return error.FileNotFound, | |
| 1918 | ENOTDIR => return error.NotDir, | |
| 1919 | ENOMEM => return error.SystemResources, | |
| 1920 | EROFS => return error.ReadOnlyFileSystem, | |
| 1921 | ENOTEMPTY => return error.DirNotEmpty, | |
| 1922 | ||
| 1923 | EINVAL => unreachable, // invalid flags, or pathname has . as last component | |
| 1924 | EBADF => unreachable, // always a race condition | |
| 1909 | .SUCCESS => return, | |
| 1910 | .ACCES => return error.AccessDenied, | |
| 1911 | .PERM => return error.AccessDenied, | |
| 1912 | .BUSY => return error.FileBusy, | |
| 1913 | .FAULT => unreachable, | |
| 1914 | .IO => return error.FileSystem, | |
| 1915 | .ISDIR => return error.IsDir, | |
| 1916 | .LOOP => return error.SymLinkLoop, | |
| 1917 | .NAMETOOLONG => return error.NameTooLong, | |
| 1918 | .NOENT => return error.FileNotFound, | |
| 1919 | .NOTDIR => return error.NotDir, | |
| 1920 | .NOMEM => return error.SystemResources, | |
| 1921 | .ROFS => return error.ReadOnlyFileSystem, | |
| 1922 | .NOTEMPTY => return error.DirNotEmpty, | |
| 1923 | ||
| 1924 | .INVAL => unreachable, // invalid flags, or pathname has . as last component | |
| 1925 | .BADF => unreachable, // always a race condition | |
| 1925 | 1926 | |
| 1926 | 1927 | else => |err| return unexpectedErrno(err), |
| 1927 | 1928 | } |
| ... | ... | @@ -1982,25 +1983,25 @@ pub fn renameZ(old_path: [*:0]const u8, new_path: [*:0]const u8) RenameError!voi |
| 1982 | 1983 | return renameW(old_path_w.span().ptr, new_path_w.span().ptr); |
| 1983 | 1984 | } |
| 1984 | 1985 | switch (errno(system.rename(old_path, new_path))) { |
| 1985 | 0 => return, | |
| 1986 | EACCES => return error.AccessDenied, | |
| 1987 | EPERM => return error.AccessDenied, | |
| 1988 | EBUSY => return error.FileBusy, | |
| 1989 | EDQUOT => return error.DiskQuota, | |
| 1990 | EFAULT => unreachable, | |
| 1991 | EINVAL => unreachable, | |
| 1992 | EISDIR => return error.IsDir, | |
| 1993 | ELOOP => return error.SymLinkLoop, | |
| 1994 | EMLINK => return error.LinkQuotaExceeded, | |
| 1995 | ENAMETOOLONG => return error.NameTooLong, | |
| 1996 | ENOENT => return error.FileNotFound, | |
| 1997 | ENOTDIR => return error.NotDir, | |
| 1998 | ENOMEM => return error.SystemResources, | |
| 1999 | ENOSPC => return error.NoSpaceLeft, | |
| 2000 | EEXIST => return error.PathAlreadyExists, | |
| 2001 | ENOTEMPTY => return error.PathAlreadyExists, | |
| 2002 | EROFS => return error.ReadOnlyFileSystem, | |
| 2003 | EXDEV => return error.RenameAcrossMountPoints, | |
| 1986 | .SUCCESS => return, | |
| 1987 | .ACCES => return error.AccessDenied, | |
| 1988 | .PERM => return error.AccessDenied, | |
| 1989 | .BUSY => return error.FileBusy, | |
| 1990 | .DQUOT => return error.DiskQuota, | |
| 1991 | .FAULT => unreachable, | |
| 1992 | .INVAL => unreachable, | |
| 1993 | .ISDIR => return error.IsDir, | |
| 1994 | .LOOP => return error.SymLinkLoop, | |
| 1995 | .MLINK => return error.LinkQuotaExceeded, | |
| 1996 | .NAMETOOLONG => return error.NameTooLong, | |
| 1997 | .NOENT => return error.FileNotFound, | |
| 1998 | .NOTDIR => return error.NotDir, | |
| 1999 | .NOMEM => return error.SystemResources, | |
| 2000 | .NOSPC => return error.NoSpaceLeft, | |
| 2001 | .EXIST => return error.PathAlreadyExists, | |
| 2002 | .NOTEMPTY => return error.PathAlreadyExists, | |
| 2003 | .ROFS => return error.ReadOnlyFileSystem, | |
| 2004 | .XDEV => return error.RenameAcrossMountPoints, | |
| 2004 | 2005 | else => |err| return unexpectedErrno(err), |
| 2005 | 2006 | } |
| 2006 | 2007 | } |
| ... | ... | @@ -2036,26 +2037,26 @@ pub fn renameat( |
| 2036 | 2037 | /// See also `renameat`. |
| 2037 | 2038 | pub fn renameatWasi(old_dir_fd: fd_t, old_path: []const u8, new_dir_fd: fd_t, new_path: []const u8) RenameError!void { |
| 2038 | 2039 | switch (wasi.path_rename(old_dir_fd, old_path.ptr, old_path.len, new_dir_fd, new_path.ptr, new_path.len)) { |
| 2039 | wasi.ESUCCESS => return, | |
| 2040 | wasi.EACCES => return error.AccessDenied, | |
| 2041 | wasi.EPERM => return error.AccessDenied, | |
| 2042 | wasi.EBUSY => return error.FileBusy, | |
| 2043 | wasi.EDQUOT => return error.DiskQuota, | |
| 2044 | wasi.EFAULT => unreachable, | |
| 2045 | wasi.EINVAL => unreachable, | |
| 2046 | wasi.EISDIR => return error.IsDir, | |
| 2047 | wasi.ELOOP => return error.SymLinkLoop, | |
| 2048 | wasi.EMLINK => return error.LinkQuotaExceeded, | |
| 2049 | wasi.ENAMETOOLONG => return error.NameTooLong, | |
| 2050 | wasi.ENOENT => return error.FileNotFound, | |
| 2051 | wasi.ENOTDIR => return error.NotDir, | |
| 2052 | wasi.ENOMEM => return error.SystemResources, | |
| 2053 | wasi.ENOSPC => return error.NoSpaceLeft, | |
| 2054 | wasi.EEXIST => return error.PathAlreadyExists, | |
| 2055 | wasi.ENOTEMPTY => return error.PathAlreadyExists, | |
| 2056 | wasi.EROFS => return error.ReadOnlyFileSystem, | |
| 2057 | wasi.EXDEV => return error.RenameAcrossMountPoints, | |
| 2058 | wasi.ENOTCAPABLE => return error.AccessDenied, | |
| 2040 | .SUCCESS => return, | |
| 2041 | .ACCES => return error.AccessDenied, | |
| 2042 | .PERM => return error.AccessDenied, | |
| 2043 | .BUSY => return error.FileBusy, | |
| 2044 | .DQUOT => return error.DiskQuota, | |
| 2045 | .FAULT => unreachable, | |
| 2046 | .INVAL => unreachable, | |
| 2047 | .ISDIR => return error.IsDir, | |
| 2048 | .LOOP => return error.SymLinkLoop, | |
| 2049 | .MLINK => return error.LinkQuotaExceeded, | |
| 2050 | .NAMETOOLONG => return error.NameTooLong, | |
| 2051 | .NOENT => return error.FileNotFound, | |
| 2052 | .NOTDIR => return error.NotDir, | |
| 2053 | .NOMEM => return error.SystemResources, | |
| 2054 | .NOSPC => return error.NoSpaceLeft, | |
| 2055 | .EXIST => return error.PathAlreadyExists, | |
| 2056 | .NOTEMPTY => return error.PathAlreadyExists, | |
| 2057 | .ROFS => return error.ReadOnlyFileSystem, | |
| 2058 | .XDEV => return error.RenameAcrossMountPoints, | |
| 2059 | .NOTCAPABLE => return error.AccessDenied, | |
| 2059 | 2060 | else => |err| return unexpectedErrno(err), |
| 2060 | 2061 | } |
| 2061 | 2062 | } |
| ... | ... | @@ -2074,25 +2075,25 @@ pub fn renameatZ( |
| 2074 | 2075 | } |
| 2075 | 2076 | |
| 2076 | 2077 | switch (errno(system.renameat(old_dir_fd, old_path, new_dir_fd, new_path))) { |
| 2077 | 0 => return, | |
| 2078 | EACCES => return error.AccessDenied, | |
| 2079 | EPERM => return error.AccessDenied, | |
| 2080 | EBUSY => return error.FileBusy, | |
| 2081 | EDQUOT => return error.DiskQuota, | |
| 2082 | EFAULT => unreachable, | |
| 2083 | EINVAL => unreachable, | |
| 2084 | EISDIR => return error.IsDir, | |
| 2085 | ELOOP => return error.SymLinkLoop, | |
| 2086 | EMLINK => return error.LinkQuotaExceeded, | |
| 2087 | ENAMETOOLONG => return error.NameTooLong, | |
| 2088 | ENOENT => return error.FileNotFound, | |
| 2089 | ENOTDIR => return error.NotDir, | |
| 2090 | ENOMEM => return error.SystemResources, | |
| 2091 | ENOSPC => return error.NoSpaceLeft, | |
| 2092 | EEXIST => return error.PathAlreadyExists, | |
| 2093 | ENOTEMPTY => return error.PathAlreadyExists, | |
| 2094 | EROFS => return error.ReadOnlyFileSystem, | |
| 2095 | EXDEV => return error.RenameAcrossMountPoints, | |
| 2078 | .SUCCESS => return, | |
| 2079 | .ACCES => return error.AccessDenied, | |
| 2080 | .PERM => return error.AccessDenied, | |
| 2081 | .BUSY => return error.FileBusy, | |
| 2082 | .DQUOT => return error.DiskQuota, | |
| 2083 | .FAULT => unreachable, | |
| 2084 | .INVAL => unreachable, | |
| 2085 | .ISDIR => return error.IsDir, | |
| 2086 | .LOOP => return error.SymLinkLoop, | |
| 2087 | .MLINK => return error.LinkQuotaExceeded, | |
| 2088 | .NAMETOOLONG => return error.NameTooLong, | |
| 2089 | .NOENT => return error.FileNotFound, | |
| 2090 | .NOTDIR => return error.NotDir, | |
| 2091 | .NOMEM => return error.SystemResources, | |
| 2092 | .NOSPC => return error.NoSpaceLeft, | |
| 2093 | .EXIST => return error.PathAlreadyExists, | |
| 2094 | .NOTEMPTY => return error.PathAlreadyExists, | |
| 2095 | .ROFS => return error.ReadOnlyFileSystem, | |
| 2096 | .XDEV => return error.RenameAcrossMountPoints, | |
| 2096 | 2097 | else => |err| return unexpectedErrno(err), |
| 2097 | 2098 | } |
| 2098 | 2099 | } |
| ... | ... | @@ -2172,22 +2173,22 @@ pub const mkdiratC = @compileError("deprecated: renamed to mkdiratZ"); |
| 2172 | 2173 | pub fn mkdiratWasi(dir_fd: fd_t, sub_dir_path: []const u8, mode: u32) MakeDirError!void { |
| 2173 | 2174 | _ = mode; |
| 2174 | 2175 | switch (wasi.path_create_directory(dir_fd, sub_dir_path.ptr, sub_dir_path.len)) { |
| 2175 | wasi.ESUCCESS => return, | |
| 2176 | wasi.EACCES => return error.AccessDenied, | |
| 2177 | wasi.EBADF => unreachable, | |
| 2178 | wasi.EPERM => return error.AccessDenied, | |
| 2179 | wasi.EDQUOT => return error.DiskQuota, | |
| 2180 | wasi.EEXIST => return error.PathAlreadyExists, | |
| 2181 | wasi.EFAULT => unreachable, | |
| 2182 | wasi.ELOOP => return error.SymLinkLoop, | |
| 2183 | wasi.EMLINK => return error.LinkQuotaExceeded, | |
| 2184 | wasi.ENAMETOOLONG => return error.NameTooLong, | |
| 2185 | wasi.ENOENT => return error.FileNotFound, | |
| 2186 | wasi.ENOMEM => return error.SystemResources, | |
| 2187 | wasi.ENOSPC => return error.NoSpaceLeft, | |
| 2188 | wasi.ENOTDIR => return error.NotDir, | |
| 2189 | wasi.EROFS => return error.ReadOnlyFileSystem, | |
| 2190 | wasi.ENOTCAPABLE => return error.AccessDenied, | |
| 2176 | .SUCCESS => return, | |
| 2177 | .ACCES => return error.AccessDenied, | |
| 2178 | .BADF => unreachable, | |
| 2179 | .PERM => return error.AccessDenied, | |
| 2180 | .DQUOT => return error.DiskQuota, | |
| 2181 | .EXIST => return error.PathAlreadyExists, | |
| 2182 | .FAULT => unreachable, | |
| 2183 | .LOOP => return error.SymLinkLoop, | |
| 2184 | .MLINK => return error.LinkQuotaExceeded, | |
| 2185 | .NAMETOOLONG => return error.NameTooLong, | |
| 2186 | .NOENT => return error.FileNotFound, | |
| 2187 | .NOMEM => return error.SystemResources, | |
| 2188 | .NOSPC => return error.NoSpaceLeft, | |
| 2189 | .NOTDIR => return error.NotDir, | |
| 2190 | .ROFS => return error.ReadOnlyFileSystem, | |
| 2191 | .NOTCAPABLE => return error.AccessDenied, | |
| 2191 | 2192 | else => |err| return unexpectedErrno(err), |
| 2192 | 2193 | } |
| 2193 | 2194 | } |
| ... | ... | @@ -2198,21 +2199,21 @@ pub fn mkdiratZ(dir_fd: fd_t, sub_dir_path: [*:0]const u8, mode: u32) MakeDirErr |
| 2198 | 2199 | return mkdiratW(dir_fd, sub_dir_path_w.span().ptr, mode); |
| 2199 | 2200 | } |
| 2200 | 2201 | switch (errno(system.mkdirat(dir_fd, sub_dir_path, mode))) { |
| 2201 | 0 => return, | |
| 2202 | EACCES => return error.AccessDenied, | |
| 2203 | EBADF => unreachable, | |
| 2204 | EPERM => return error.AccessDenied, | |
| 2205 | EDQUOT => return error.DiskQuota, | |
| 2206 | EEXIST => return error.PathAlreadyExists, | |
| 2207 | EFAULT => unreachable, | |
| 2208 | ELOOP => return error.SymLinkLoop, | |
| 2209 | EMLINK => return error.LinkQuotaExceeded, | |
| 2210 | ENAMETOOLONG => return error.NameTooLong, | |
| 2211 | ENOENT => return error.FileNotFound, | |
| 2212 | ENOMEM => return error.SystemResources, | |
| 2213 | ENOSPC => return error.NoSpaceLeft, | |
| 2214 | ENOTDIR => return error.NotDir, | |
| 2215 | EROFS => return error.ReadOnlyFileSystem, | |
| 2202 | .SUCCESS => return, | |
| 2203 | .ACCES => return error.AccessDenied, | |
| 2204 | .BADF => unreachable, | |
| 2205 | .PERM => return error.AccessDenied, | |
| 2206 | .DQUOT => return error.DiskQuota, | |
| 2207 | .EXIST => return error.PathAlreadyExists, | |
| 2208 | .FAULT => unreachable, | |
| 2209 | .LOOP => return error.SymLinkLoop, | |
| 2210 | .MLINK => return error.LinkQuotaExceeded, | |
| 2211 | .NAMETOOLONG => return error.NameTooLong, | |
| 2212 | .NOENT => return error.FileNotFound, | |
| 2213 | .NOMEM => return error.SystemResources, | |
| 2214 | .NOSPC => return error.NoSpaceLeft, | |
| 2215 | .NOTDIR => return error.NotDir, | |
| 2216 | .ROFS => return error.ReadOnlyFileSystem, | |
| 2216 | 2217 | else => |err| return unexpectedErrno(err), |
| 2217 | 2218 | } |
| 2218 | 2219 | } |
| ... | ... | @@ -2274,20 +2275,20 @@ pub fn mkdirZ(dir_path: [*:0]const u8, mode: u32) MakeDirError!void { |
| 2274 | 2275 | return mkdirW(dir_path_w.span(), mode); |
| 2275 | 2276 | } |
| 2276 | 2277 | switch (errno(system.mkdir(dir_path, mode))) { |
| 2277 | 0 => return, | |
| 2278 | EACCES => return error.AccessDenied, | |
| 2279 | EPERM => return error.AccessDenied, | |
| 2280 | EDQUOT => return error.DiskQuota, | |
| 2281 | EEXIST => return error.PathAlreadyExists, | |
| 2282 | EFAULT => unreachable, | |
| 2283 | ELOOP => return error.SymLinkLoop, | |
| 2284 | EMLINK => return error.LinkQuotaExceeded, | |
| 2285 | ENAMETOOLONG => return error.NameTooLong, | |
| 2286 | ENOENT => return error.FileNotFound, | |
| 2287 | ENOMEM => return error.SystemResources, | |
| 2288 | ENOSPC => return error.NoSpaceLeft, | |
| 2289 | ENOTDIR => return error.NotDir, | |
| 2290 | EROFS => return error.ReadOnlyFileSystem, | |
| 2278 | .SUCCESS => return, | |
| 2279 | .ACCES => return error.AccessDenied, | |
| 2280 | .PERM => return error.AccessDenied, | |
| 2281 | .DQUOT => return error.DiskQuota, | |
| 2282 | .EXIST => return error.PathAlreadyExists, | |
| 2283 | .FAULT => unreachable, | |
| 2284 | .LOOP => return error.SymLinkLoop, | |
| 2285 | .MLINK => return error.LinkQuotaExceeded, | |
| 2286 | .NAMETOOLONG => return error.NameTooLong, | |
| 2287 | .NOENT => return error.FileNotFound, | |
| 2288 | .NOMEM => return error.SystemResources, | |
| 2289 | .NOSPC => return error.NoSpaceLeft, | |
| 2290 | .NOTDIR => return error.NotDir, | |
| 2291 | .ROFS => return error.ReadOnlyFileSystem, | |
| 2291 | 2292 | else => |err| return unexpectedErrno(err), |
| 2292 | 2293 | } |
| 2293 | 2294 | } |
| ... | ... | @@ -2346,20 +2347,20 @@ pub fn rmdirZ(dir_path: [*:0]const u8) DeleteDirError!void { |
| 2346 | 2347 | return rmdirW(dir_path_w.span()); |
| 2347 | 2348 | } |
| 2348 | 2349 | switch (errno(system.rmdir(dir_path))) { |
| 2349 | 0 => return, | |
| 2350 | EACCES => return error.AccessDenied, | |
| 2351 | EPERM => return error.AccessDenied, | |
| 2352 | EBUSY => return error.FileBusy, | |
| 2353 | EFAULT => unreachable, | |
| 2354 | EINVAL => unreachable, | |
| 2355 | ELOOP => return error.SymLinkLoop, | |
| 2356 | ENAMETOOLONG => return error.NameTooLong, | |
| 2357 | ENOENT => return error.FileNotFound, | |
| 2358 | ENOMEM => return error.SystemResources, | |
| 2359 | ENOTDIR => return error.NotDir, | |
| 2360 | EEXIST => return error.DirNotEmpty, | |
| 2361 | ENOTEMPTY => return error.DirNotEmpty, | |
| 2362 | EROFS => return error.ReadOnlyFileSystem, | |
| 2350 | .SUCCESS => return, | |
| 2351 | .ACCES => return error.AccessDenied, | |
| 2352 | .PERM => return error.AccessDenied, | |
| 2353 | .BUSY => return error.FileBusy, | |
| 2354 | .FAULT => unreachable, | |
| 2355 | .INVAL => unreachable, | |
| 2356 | .LOOP => return error.SymLinkLoop, | |
| 2357 | .NAMETOOLONG => return error.NameTooLong, | |
| 2358 | .NOENT => return error.FileNotFound, | |
| 2359 | .NOMEM => return error.SystemResources, | |
| 2360 | .NOTDIR => return error.NotDir, | |
| 2361 | .EXIST => return error.DirNotEmpty, | |
| 2362 | .NOTEMPTY => return error.DirNotEmpty, | |
| 2363 | .ROFS => return error.ReadOnlyFileSystem, | |
| 2363 | 2364 | else => |err| return unexpectedErrno(err), |
| 2364 | 2365 | } |
| 2365 | 2366 | } |
| ... | ... | @@ -2413,15 +2414,15 @@ pub fn chdirZ(dir_path: [*:0]const u8) ChangeCurDirError!void { |
| 2413 | 2414 | return chdirW(utf16_dir_path[0..len]); |
| 2414 | 2415 | } |
| 2415 | 2416 | switch (errno(system.chdir(dir_path))) { |
| 2416 | 0 => return, | |
| 2417 | EACCES => return error.AccessDenied, | |
| 2418 | EFAULT => unreachable, | |
| 2419 | EIO => return error.FileSystem, | |
| 2420 | ELOOP => return error.SymLinkLoop, | |
| 2421 | ENAMETOOLONG => return error.NameTooLong, | |
| 2422 | ENOENT => return error.FileNotFound, | |
| 2423 | ENOMEM => return error.SystemResources, | |
| 2424 | ENOTDIR => return error.NotDir, | |
| 2417 | .SUCCESS => return, | |
| 2418 | .ACCES => return error.AccessDenied, | |
| 2419 | .FAULT => unreachable, | |
| 2420 | .IO => return error.FileSystem, | |
| 2421 | .LOOP => return error.SymLinkLoop, | |
| 2422 | .NAMETOOLONG => return error.NameTooLong, | |
| 2423 | .NOENT => return error.FileNotFound, | |
| 2424 | .NOMEM => return error.SystemResources, | |
| 2425 | .NOTDIR => return error.NotDir, | |
| 2425 | 2426 | else => |err| return unexpectedErrno(err), |
| 2426 | 2427 | } |
| 2427 | 2428 | } |
| ... | ... | @@ -2443,12 +2444,12 @@ pub const FchdirError = error{ |
| 2443 | 2444 | pub fn fchdir(dirfd: fd_t) FchdirError!void { |
| 2444 | 2445 | while (true) { |
| 2445 | 2446 | switch (errno(system.fchdir(dirfd))) { |
| 2446 | 0 => return, | |
| 2447 | EACCES => return error.AccessDenied, | |
| 2448 | EBADF => unreachable, | |
| 2449 | ENOTDIR => return error.NotDir, | |
| 2450 | EINTR => continue, | |
| 2451 | EIO => return error.FileSystem, | |
| 2447 | .SUCCESS => return, | |
| 2448 | .ACCES => return error.AccessDenied, | |
| 2449 | .BADF => unreachable, | |
| 2450 | .NOTDIR => return error.NotDir, | |
| 2451 | .INTR => continue, | |
| 2452 | .IO => return error.FileSystem, | |
| 2452 | 2453 | else => |err| return unexpectedErrno(err), |
| 2453 | 2454 | } |
| 2454 | 2455 | } |
| ... | ... | @@ -2501,16 +2502,16 @@ pub fn readlinkZ(file_path: [*:0]const u8, out_buffer: []u8) ReadLinkError![]u8 |
| 2501 | 2502 | } |
| 2502 | 2503 | const rc = system.readlink(file_path, out_buffer.ptr, out_buffer.len); |
| 2503 | 2504 | switch (errno(rc)) { |
| 2504 | 0 => return out_buffer[0..@bitCast(usize, rc)], | |
| 2505 | EACCES => return error.AccessDenied, | |
| 2506 | EFAULT => unreachable, | |
| 2507 | EINVAL => unreachable, | |
| 2508 | EIO => return error.FileSystem, | |
| 2509 | ELOOP => return error.SymLinkLoop, | |
| 2510 | ENAMETOOLONG => return error.NameTooLong, | |
| 2511 | ENOENT => return error.FileNotFound, | |
| 2512 | ENOMEM => return error.SystemResources, | |
| 2513 | ENOTDIR => return error.NotDir, | |
| 2505 | .SUCCESS => return out_buffer[0..@bitCast(usize, rc)], | |
| 2506 | .ACCES => return error.AccessDenied, | |
| 2507 | .FAULT => unreachable, | |
| 2508 | .INVAL => unreachable, | |
| 2509 | .IO => return error.FileSystem, | |
| 2510 | .LOOP => return error.SymLinkLoop, | |
| 2511 | .NAMETOOLONG => return error.NameTooLong, | |
| 2512 | .NOENT => return error.FileNotFound, | |
| 2513 | .NOMEM => return error.SystemResources, | |
| 2514 | .NOTDIR => return error.NotDir, | |
| 2514 | 2515 | else => |err| return unexpectedErrno(err), |
| 2515 | 2516 | } |
| 2516 | 2517 | } |
| ... | ... | @@ -2537,17 +2538,17 @@ pub const readlinkatC = @compileError("deprecated: renamed to readlinkatZ"); |
| 2537 | 2538 | pub fn readlinkatWasi(dirfd: fd_t, file_path: []const u8, out_buffer: []u8) ReadLinkError![]u8 { |
| 2538 | 2539 | var bufused: usize = undefined; |
| 2539 | 2540 | switch (wasi.path_readlink(dirfd, file_path.ptr, file_path.len, out_buffer.ptr, out_buffer.len, &bufused)) { |
| 2540 | wasi.ESUCCESS => return out_buffer[0..bufused], | |
| 2541 | wasi.EACCES => return error.AccessDenied, | |
| 2542 | wasi.EFAULT => unreachable, | |
| 2543 | wasi.EINVAL => unreachable, | |
| 2544 | wasi.EIO => return error.FileSystem, | |
| 2545 | wasi.ELOOP => return error.SymLinkLoop, | |
| 2546 | wasi.ENAMETOOLONG => return error.NameTooLong, | |
| 2547 | wasi.ENOENT => return error.FileNotFound, | |
| 2548 | wasi.ENOMEM => return error.SystemResources, | |
| 2549 | wasi.ENOTDIR => return error.NotDir, | |
| 2550 | wasi.ENOTCAPABLE => return error.AccessDenied, | |
| 2541 | .SUCCESS => return out_buffer[0..bufused], | |
| 2542 | .ACCES => return error.AccessDenied, | |
| 2543 | .FAULT => unreachable, | |
| 2544 | .INVAL => unreachable, | |
| 2545 | .IO => return error.FileSystem, | |
| 2546 | .LOOP => return error.SymLinkLoop, | |
| 2547 | .NAMETOOLONG => return error.NameTooLong, | |
| 2548 | .NOENT => return error.FileNotFound, | |
| 2549 | .NOMEM => return error.SystemResources, | |
| 2550 | .NOTDIR => return error.NotDir, | |
| 2551 | .NOTCAPABLE => return error.AccessDenied, | |
| 2551 | 2552 | else => |err| return unexpectedErrno(err), |
| 2552 | 2553 | } |
| 2553 | 2554 | } |
| ... | ... | @@ -2567,16 +2568,16 @@ pub fn readlinkatZ(dirfd: fd_t, file_path: [*:0]const u8, out_buffer: []u8) Read |
| 2567 | 2568 | } |
| 2568 | 2569 | const rc = system.readlinkat(dirfd, file_path, out_buffer.ptr, out_buffer.len); |
| 2569 | 2570 | switch (errno(rc)) { |
| 2570 | 0 => return out_buffer[0..@bitCast(usize, rc)], | |
| 2571 | EACCES => return error.AccessDenied, | |
| 2572 | EFAULT => unreachable, | |
| 2573 | EINVAL => unreachable, | |
| 2574 | EIO => return error.FileSystem, | |
| 2575 | ELOOP => return error.SymLinkLoop, | |
| 2576 | ENAMETOOLONG => return error.NameTooLong, | |
| 2577 | ENOENT => return error.FileNotFound, | |
| 2578 | ENOMEM => return error.SystemResources, | |
| 2579 | ENOTDIR => return error.NotDir, | |
| 2571 | .SUCCESS => return out_buffer[0..@bitCast(usize, rc)], | |
| 2572 | .ACCES => return error.AccessDenied, | |
| 2573 | .FAULT => unreachable, | |
| 2574 | .INVAL => unreachable, | |
| 2575 | .IO => return error.FileSystem, | |
| 2576 | .LOOP => return error.SymLinkLoop, | |
| 2577 | .NAMETOOLONG => return error.NameTooLong, | |
| 2578 | .NOENT => return error.FileNotFound, | |
| 2579 | .NOMEM => return error.SystemResources, | |
| 2580 | .NOTDIR => return error.NotDir, | |
| 2580 | 2581 | else => |err| return unexpectedErrno(err), |
| 2581 | 2582 | } |
| 2582 | 2583 | } |
| ... | ... | @@ -2590,58 +2591,58 @@ pub const SetIdError = error{ResourceLimitReached} || SetEidError; |
| 2590 | 2591 | |
| 2591 | 2592 | pub fn setuid(uid: uid_t) SetIdError!void { |
| 2592 | 2593 | switch (errno(system.setuid(uid))) { |
| 2593 | 0 => return, | |
| 2594 | EAGAIN => return error.ResourceLimitReached, | |
| 2595 | EINVAL => return error.InvalidUserId, | |
| 2596 | EPERM => return error.PermissionDenied, | |
| 2594 | .SUCCESS => return, | |
| 2595 | .AGAIN => return error.ResourceLimitReached, | |
| 2596 | .INVAL => return error.InvalidUserId, | |
| 2597 | .PERM => return error.PermissionDenied, | |
| 2597 | 2598 | else => |err| return unexpectedErrno(err), |
| 2598 | 2599 | } |
| 2599 | 2600 | } |
| 2600 | 2601 | |
| 2601 | 2602 | pub fn seteuid(uid: uid_t) SetEidError!void { |
| 2602 | 2603 | switch (errno(system.seteuid(uid))) { |
| 2603 | 0 => return, | |
| 2604 | EINVAL => return error.InvalidUserId, | |
| 2605 | EPERM => return error.PermissionDenied, | |
| 2604 | .SUCCESS => return, | |
| 2605 | .INVAL => return error.InvalidUserId, | |
| 2606 | .PERM => return error.PermissionDenied, | |
| 2606 | 2607 | else => |err| return unexpectedErrno(err), |
| 2607 | 2608 | } |
| 2608 | 2609 | } |
| 2609 | 2610 | |
| 2610 | 2611 | pub fn setreuid(ruid: uid_t, euid: uid_t) SetIdError!void { |
| 2611 | 2612 | switch (errno(system.setreuid(ruid, euid))) { |
| 2612 | 0 => return, | |
| 2613 | EAGAIN => return error.ResourceLimitReached, | |
| 2614 | EINVAL => return error.InvalidUserId, | |
| 2615 | EPERM => return error.PermissionDenied, | |
| 2613 | .SUCCESS => return, | |
| 2614 | .AGAIN => return error.ResourceLimitReached, | |
| 2615 | .INVAL => return error.InvalidUserId, | |
| 2616 | .PERM => return error.PermissionDenied, | |
| 2616 | 2617 | else => |err| return unexpectedErrno(err), |
| 2617 | 2618 | } |
| 2618 | 2619 | } |
| 2619 | 2620 | |
| 2620 | 2621 | pub fn setgid(gid: gid_t) SetIdError!void { |
| 2621 | 2622 | switch (errno(system.setgid(gid))) { |
| 2622 | 0 => return, | |
| 2623 | EAGAIN => return error.ResourceLimitReached, | |
| 2624 | EINVAL => return error.InvalidUserId, | |
| 2625 | EPERM => return error.PermissionDenied, | |
| 2623 | .SUCCESS => return, | |
| 2624 | .AGAIN => return error.ResourceLimitReached, | |
| 2625 | .INVAL => return error.InvalidUserId, | |
| 2626 | .PERM => return error.PermissionDenied, | |
| 2626 | 2627 | else => |err| return unexpectedErrno(err), |
| 2627 | 2628 | } |
| 2628 | 2629 | } |
| 2629 | 2630 | |
| 2630 | 2631 | pub fn setegid(uid: uid_t) SetEidError!void { |
| 2631 | 2632 | switch (errno(system.setegid(uid))) { |
| 2632 | 0 => return, | |
| 2633 | EINVAL => return error.InvalidUserId, | |
| 2634 | EPERM => return error.PermissionDenied, | |
| 2633 | .SUCCESS => return, | |
| 2634 | .INVAL => return error.InvalidUserId, | |
| 2635 | .PERM => return error.PermissionDenied, | |
| 2635 | 2636 | else => |err| return unexpectedErrno(err), |
| 2636 | 2637 | } |
| 2637 | 2638 | } |
| 2638 | 2639 | |
| 2639 | 2640 | pub fn setregid(rgid: gid_t, egid: gid_t) SetIdError!void { |
| 2640 | 2641 | switch (errno(system.setregid(rgid, egid))) { |
| 2641 | 0 => return, | |
| 2642 | EAGAIN => return error.ResourceLimitReached, | |
| 2643 | EINVAL => return error.InvalidUserId, | |
| 2644 | EPERM => return error.PermissionDenied, | |
| 2642 | .SUCCESS => return, | |
| 2643 | .AGAIN => return error.ResourceLimitReached, | |
| 2644 | .INVAL => return error.InvalidUserId, | |
| 2645 | .PERM => return error.PermissionDenied, | |
| 2645 | 2646 | else => |err| return unexpectedErrno(err), |
| 2646 | 2647 | } |
| 2647 | 2648 | } |
| ... | ... | @@ -2680,9 +2681,10 @@ pub fn isatty(handle: fd_t) bool { |
| 2680 | 2681 | while (true) { |
| 2681 | 2682 | var wsz: linux.winsize = undefined; |
| 2682 | 2683 | const fd = @bitCast(usize, @as(isize, handle)); |
| 2683 | switch (linux.syscall3(.ioctl, fd, linux.TIOCGWINSZ, @ptrToInt(&wsz))) { | |
| 2684 | 0 => return true, | |
| 2685 | EINTR => continue, | |
| 2684 | const rc = linux.syscall3(.ioctl, fd, linux.TIOCGWINSZ, @ptrToInt(&wsz)); | |
| 2685 | switch (linux.getErrno(rc)) { | |
| 2686 | .SUCCESS => return true, | |
| 2687 | .INTR => continue, | |
| 2686 | 2688 | else => return false, |
| 2687 | 2689 | } |
| 2688 | 2690 | } |
| ... | ... | @@ -2777,22 +2779,22 @@ pub fn socket(domain: u32, socket_type: u32, protocol: u32) SocketError!socket_t |
| 2777 | 2779 | socket_type; |
| 2778 | 2780 | const rc = system.socket(domain, filtered_sock_type, protocol); |
| 2779 | 2781 | switch (errno(rc)) { |
| 2780 | 0 => { | |
| 2782 | .SUCCESS => { | |
| 2781 | 2783 | const fd = @intCast(fd_t, rc); |
| 2782 | 2784 | if (!have_sock_flags) { |
| 2783 | 2785 | try setSockFlags(fd, socket_type); |
| 2784 | 2786 | } |
| 2785 | 2787 | return fd; |
| 2786 | 2788 | }, |
| 2787 | EACCES => return error.PermissionDenied, | |
| 2788 | EAFNOSUPPORT => return error.AddressFamilyNotSupported, | |
| 2789 | EINVAL => return error.ProtocolFamilyNotAvailable, | |
| 2790 | EMFILE => return error.ProcessFdQuotaExceeded, | |
| 2791 | ENFILE => return error.SystemFdQuotaExceeded, | |
| 2792 | ENOBUFS => return error.SystemResources, | |
| 2793 | ENOMEM => return error.SystemResources, | |
| 2794 | EPROTONOSUPPORT => return error.ProtocolNotSupported, | |
| 2795 | EPROTOTYPE => return error.SocketTypeNotSupported, | |
| 2789 | .ACCES => return error.PermissionDenied, | |
| 2790 | .AFNOSUPPORT => return error.AddressFamilyNotSupported, | |
| 2791 | .INVAL => return error.ProtocolFamilyNotAvailable, | |
| 2792 | .MFILE => return error.ProcessFdQuotaExceeded, | |
| 2793 | .NFILE => return error.SystemFdQuotaExceeded, | |
| 2794 | .NOBUFS => return error.SystemResources, | |
| 2795 | .NOMEM => return error.SystemResources, | |
| 2796 | .PROTONOSUPPORT => return error.ProtocolNotSupported, | |
| 2797 | .PROTOTYPE => return error.SocketTypeNotSupported, | |
| 2796 | 2798 | else => |err| return unexpectedErrno(err), |
| 2797 | 2799 | } |
| 2798 | 2800 | } |
| ... | ... | @@ -2840,12 +2842,12 @@ pub fn shutdown(sock: socket_t, how: ShutdownHow) ShutdownError!void { |
| 2840 | 2842 | .both => SHUT_RDWR, |
| 2841 | 2843 | }); |
| 2842 | 2844 | switch (errno(rc)) { |
| 2843 | 0 => return, | |
| 2844 | EBADF => unreachable, | |
| 2845 | EINVAL => unreachable, | |
| 2846 | ENOTCONN => return error.SocketNotConnected, | |
| 2847 | ENOTSOCK => unreachable, | |
| 2848 | ENOBUFS => return error.SystemResources, | |
| 2845 | .SUCCESS => return, | |
| 2846 | .BADF => unreachable, | |
| 2847 | .INVAL => unreachable, | |
| 2848 | .NOTCONN => return error.SocketNotConnected, | |
| 2849 | .NOTSOCK => unreachable, | |
| 2850 | .NOBUFS => return error.SystemResources, | |
| 2849 | 2851 | else => |err| return unexpectedErrno(err), |
| 2850 | 2852 | } |
| 2851 | 2853 | } |
| ... | ... | @@ -2924,20 +2926,20 @@ pub fn bind(sock: socket_t, addr: *const sockaddr, len: socklen_t) BindError!voi |
| 2924 | 2926 | } else { |
| 2925 | 2927 | const rc = system.bind(sock, addr, len); |
| 2926 | 2928 | switch (errno(rc)) { |
| 2927 | 0 => return, | |
| 2928 | EACCES => return error.AccessDenied, | |
| 2929 | EADDRINUSE => return error.AddressInUse, | |
| 2930 | EBADF => unreachable, // always a race condition if this error is returned | |
| 2931 | EINVAL => unreachable, // invalid parameters | |
| 2932 | ENOTSOCK => unreachable, // invalid `sockfd` | |
| 2933 | EADDRNOTAVAIL => return error.AddressNotAvailable, | |
| 2934 | EFAULT => unreachable, // invalid `addr` pointer | |
| 2935 | ELOOP => return error.SymLinkLoop, | |
| 2936 | ENAMETOOLONG => return error.NameTooLong, | |
| 2937 | ENOENT => return error.FileNotFound, | |
| 2938 | ENOMEM => return error.SystemResources, | |
| 2939 | ENOTDIR => return error.NotDir, | |
| 2940 | EROFS => return error.ReadOnlyFileSystem, | |
| 2929 | .SUCCESS => return, | |
| 2930 | .ACCES => return error.AccessDenied, | |
| 2931 | .ADDRINUSE => return error.AddressInUse, | |
| 2932 | .BADF => unreachable, // always a race condition if this error is returned | |
| 2933 | .INVAL => unreachable, // invalid parameters | |
| 2934 | .NOTSOCK => unreachable, // invalid `sockfd` | |
| 2935 | .ADDRNOTAVAIL => return error.AddressNotAvailable, | |
| 2936 | .FAULT => unreachable, // invalid `addr` pointer | |
| 2937 | .LOOP => return error.SymLinkLoop, | |
| 2938 | .NAMETOOLONG => return error.NameTooLong, | |
| 2939 | .NOENT => return error.FileNotFound, | |
| 2940 | .NOMEM => return error.SystemResources, | |
| 2941 | .NOTDIR => return error.NotDir, | |
| 2942 | .ROFS => return error.ReadOnlyFileSystem, | |
| 2941 | 2943 | else => |err| return unexpectedErrno(err), |
| 2942 | 2944 | } |
| 2943 | 2945 | } |
| ... | ... | @@ -2993,11 +2995,11 @@ pub fn listen(sock: socket_t, backlog: u31) ListenError!void { |
| 2993 | 2995 | } else { |
| 2994 | 2996 | const rc = system.listen(sock, backlog); |
| 2995 | 2997 | switch (errno(rc)) { |
| 2996 | 0 => return, | |
| 2997 | EADDRINUSE => return error.AddressInUse, | |
| 2998 | EBADF => unreachable, | |
| 2999 | ENOTSOCK => return error.FileDescriptorNotASocket, | |
| 3000 | EOPNOTSUPP => return error.OperationNotSupported, | |
| 2998 | .SUCCESS => return, | |
| 2999 | .ADDRINUSE => return error.AddressInUse, | |
| 3000 | .BADF => unreachable, | |
| 3001 | .NOTSOCK => return error.FileDescriptorNotASocket, | |
| 3002 | .OPNOTSUPP => return error.OperationNotSupported, | |
| 3001 | 3003 | else => |err| return unexpectedErrno(err), |
| 3002 | 3004 | } |
| 3003 | 3005 | } |
| ... | ... | @@ -3099,23 +3101,23 @@ pub fn accept( |
| 3099 | 3101 | } |
| 3100 | 3102 | } else { |
| 3101 | 3103 | switch (errno(rc)) { |
| 3102 | 0 => { | |
| 3104 | .SUCCESS => { | |
| 3103 | 3105 | break @intCast(socket_t, rc); |
| 3104 | 3106 | }, |
| 3105 | EINTR => continue, | |
| 3106 | EAGAIN => return error.WouldBlock, | |
| 3107 | EBADF => unreachable, // always a race condition | |
| 3108 | ECONNABORTED => return error.ConnectionAborted, | |
| 3109 | EFAULT => unreachable, | |
| 3110 | EINVAL => return error.SocketNotListening, | |
| 3111 | ENOTSOCK => unreachable, | |
| 3112 | EMFILE => return error.ProcessFdQuotaExceeded, | |
| 3113 | ENFILE => return error.SystemFdQuotaExceeded, | |
| 3114 | ENOBUFS => return error.SystemResources, | |
| 3115 | ENOMEM => return error.SystemResources, | |
| 3116 | EOPNOTSUPP => unreachable, | |
| 3117 | EPROTO => return error.ProtocolFailure, | |
| 3118 | EPERM => return error.BlockedByFirewall, | |
| 3107 | .INTR => continue, | |
| 3108 | .AGAIN => return error.WouldBlock, | |
| 3109 | .BADF => unreachable, // always a race condition | |
| 3110 | .CONNABORTED => return error.ConnectionAborted, | |
| 3111 | .FAULT => unreachable, | |
| 3112 | .INVAL => return error.SocketNotListening, | |
| 3113 | .NOTSOCK => unreachable, | |
| 3114 | .MFILE => return error.ProcessFdQuotaExceeded, | |
| 3115 | .NFILE => return error.SystemFdQuotaExceeded, | |
| 3116 | .NOBUFS => return error.SystemResources, | |
| 3117 | .NOMEM => return error.SystemResources, | |
| 3118 | .OPNOTSUPP => unreachable, | |
| 3119 | .PROTO => return error.ProtocolFailure, | |
| 3120 | .PERM => return error.BlockedByFirewall, | |
| 3119 | 3121 | else => |err| return unexpectedErrno(err), |
| 3120 | 3122 | } |
| 3121 | 3123 | } |
| ... | ... | @@ -3144,13 +3146,13 @@ pub const EpollCreateError = error{ |
| 3144 | 3146 | pub fn epoll_create1(flags: u32) EpollCreateError!i32 { |
| 3145 | 3147 | const rc = system.epoll_create1(flags); |
| 3146 | 3148 | switch (errno(rc)) { |
| 3147 | 0 => return @intCast(i32, rc), | |
| 3149 | .SUCCESS => return @intCast(i32, rc), | |
| 3148 | 3150 | else => |err| return unexpectedErrno(err), |
| 3149 | 3151 | |
| 3150 | EINVAL => unreachable, | |
| 3151 | EMFILE => return error.ProcessFdQuotaExceeded, | |
| 3152 | ENFILE => return error.SystemFdQuotaExceeded, | |
| 3153 | ENOMEM => return error.SystemResources, | |
| 3152 | .INVAL => unreachable, | |
| 3153 | .MFILE => return error.ProcessFdQuotaExceeded, | |
| 3154 | .NFILE => return error.SystemFdQuotaExceeded, | |
| 3155 | .NOMEM => return error.SystemResources, | |
| 3154 | 3156 | } |
| 3155 | 3157 | } |
| 3156 | 3158 | |
| ... | ... | @@ -3183,17 +3185,17 @@ pub const EpollCtlError = error{ |
| 3183 | 3185 | pub fn epoll_ctl(epfd: i32, op: u32, fd: i32, event: ?*epoll_event) EpollCtlError!void { |
| 3184 | 3186 | const rc = system.epoll_ctl(epfd, op, fd, event); |
| 3185 | 3187 | switch (errno(rc)) { |
| 3186 | 0 => return, | |
| 3188 | .SUCCESS => return, | |
| 3187 | 3189 | else => |err| return unexpectedErrno(err), |
| 3188 | 3190 | |
| 3189 | EBADF => unreachable, // always a race condition if this happens | |
| 3190 | EEXIST => return error.FileDescriptorAlreadyPresentInSet, | |
| 3191 | EINVAL => unreachable, | |
| 3192 | ELOOP => return error.OperationCausesCircularLoop, | |
| 3193 | ENOENT => return error.FileDescriptorNotRegistered, | |
| 3194 | ENOMEM => return error.SystemResources, | |
| 3195 | ENOSPC => return error.UserResourceLimitReached, | |
| 3196 | EPERM => return error.FileDescriptorIncompatibleWithEpoll, | |
| 3191 | .BADF => unreachable, // always a race condition if this happens | |
| 3192 | .EXIST => return error.FileDescriptorAlreadyPresentInSet, | |
| 3193 | .INVAL => unreachable, | |
| 3194 | .LOOP => return error.OperationCausesCircularLoop, | |
| 3195 | .NOENT => return error.FileDescriptorNotRegistered, | |
| 3196 | .NOMEM => return error.SystemResources, | |
| 3197 | .NOSPC => return error.UserResourceLimitReached, | |
| 3198 | .PERM => return error.FileDescriptorIncompatibleWithEpoll, | |
| 3197 | 3199 | } |
| 3198 | 3200 | } |
| 3199 | 3201 | |
| ... | ... | @@ -3205,11 +3207,11 @@ pub fn epoll_wait(epfd: i32, events: []epoll_event, timeout: i32) usize { |
| 3205 | 3207 | // TODO get rid of the @intCast |
| 3206 | 3208 | const rc = system.epoll_wait(epfd, events.ptr, @intCast(u32, events.len), timeout); |
| 3207 | 3209 | switch (errno(rc)) { |
| 3208 | 0 => return @intCast(usize, rc), | |
| 3209 | EINTR => continue, | |
| 3210 | EBADF => unreachable, | |
| 3211 | EFAULT => unreachable, | |
| 3212 | EINVAL => unreachable, | |
| 3210 | .SUCCESS => return @intCast(usize, rc), | |
| 3211 | .INTR => continue, | |
| 3212 | .BADF => unreachable, | |
| 3213 | .FAULT => unreachable, | |
| 3214 | .INVAL => unreachable, | |
| 3213 | 3215 | else => unreachable, |
| 3214 | 3216 | } |
| 3215 | 3217 | } |
| ... | ... | @@ -3224,14 +3226,14 @@ pub const EventFdError = error{ |
| 3224 | 3226 | pub fn eventfd(initval: u32, flags: u32) EventFdError!i32 { |
| 3225 | 3227 | const rc = system.eventfd(initval, flags); |
| 3226 | 3228 | switch (errno(rc)) { |
| 3227 | 0 => return @intCast(i32, rc), | |
| 3229 | .SUCCESS => return @intCast(i32, rc), | |
| 3228 | 3230 | else => |err| return unexpectedErrno(err), |
| 3229 | 3231 | |
| 3230 | EINVAL => unreachable, // invalid parameters | |
| 3231 | EMFILE => return error.ProcessFdQuotaExceeded, | |
| 3232 | ENFILE => return error.SystemFdQuotaExceeded, | |
| 3233 | ENODEV => return error.SystemResources, | |
| 3234 | ENOMEM => return error.SystemResources, | |
| 3232 | .INVAL => unreachable, // invalid parameters | |
| 3233 | .MFILE => return error.ProcessFdQuotaExceeded, | |
| 3234 | .NFILE => return error.SystemFdQuotaExceeded, | |
| 3235 | .NODEV => return error.SystemResources, | |
| 3236 | .NOMEM => return error.SystemResources, | |
| 3235 | 3237 | } |
| 3236 | 3238 | } |
| 3237 | 3239 | |
| ... | ... | @@ -3265,14 +3267,14 @@ pub fn getsockname(sock: socket_t, addr: *sockaddr, addrlen: *socklen_t) GetSock |
| 3265 | 3267 | } else { |
| 3266 | 3268 | const rc = system.getsockname(sock, addr, addrlen); |
| 3267 | 3269 | switch (errno(rc)) { |
| 3268 | 0 => return, | |
| 3270 | .SUCCESS => return, | |
| 3269 | 3271 | else => |err| return unexpectedErrno(err), |
| 3270 | 3272 | |
| 3271 | EBADF => unreachable, // always a race condition | |
| 3272 | EFAULT => unreachable, | |
| 3273 | EINVAL => unreachable, // invalid parameters | |
| 3274 | ENOTSOCK => return error.FileDescriptorNotASocket, | |
| 3275 | ENOBUFS => return error.SystemResources, | |
| 3273 | .BADF => unreachable, // always a race condition | |
| 3274 | .FAULT => unreachable, | |
| 3275 | .INVAL => unreachable, // invalid parameters | |
| 3276 | .NOTSOCK => return error.FileDescriptorNotASocket, | |
| 3277 | .NOBUFS => return error.SystemResources, | |
| 3276 | 3278 | } |
| 3277 | 3279 | } |
| 3278 | 3280 | } |
| ... | ... | @@ -3294,14 +3296,14 @@ pub fn getpeername(sock: socket_t, addr: *sockaddr, addrlen: *socklen_t) GetSock |
| 3294 | 3296 | } else { |
| 3295 | 3297 | const rc = system.getpeername(sock, addr, addrlen); |
| 3296 | 3298 | switch (errno(rc)) { |
| 3297 | 0 => return, | |
| 3299 | .SUCCESS => return, | |
| 3298 | 3300 | else => |err| return unexpectedErrno(err), |
| 3299 | 3301 | |
| 3300 | EBADF => unreachable, // always a race condition | |
| 3301 | EFAULT => unreachable, | |
| 3302 | EINVAL => unreachable, // invalid parameters | |
| 3303 | ENOTSOCK => return error.FileDescriptorNotASocket, | |
| 3304 | ENOBUFS => return error.SystemResources, | |
| 3302 | .BADF => unreachable, // always a race condition | |
| 3303 | .FAULT => unreachable, | |
| 3304 | .INVAL => unreachable, // invalid parameters | |
| 3305 | .NOTSOCK => return error.FileDescriptorNotASocket, | |
| 3306 | .NOBUFS => return error.SystemResources, | |
| 3305 | 3307 | } |
| 3306 | 3308 | } |
| 3307 | 3309 | } |
| ... | ... | @@ -3384,61 +3386,61 @@ pub fn connect(sock: socket_t, sock_addr: *const sockaddr, len: socklen_t) Conne |
| 3384 | 3386 | |
| 3385 | 3387 | while (true) { |
| 3386 | 3388 | switch (errno(system.connect(sock, sock_addr, len))) { |
| 3387 | 0 => return, | |
| 3388 | EACCES => return error.PermissionDenied, | |
| 3389 | EPERM => return error.PermissionDenied, | |
| 3390 | EADDRINUSE => return error.AddressInUse, | |
| 3391 | EADDRNOTAVAIL => return error.AddressNotAvailable, | |
| 3392 | EAFNOSUPPORT => return error.AddressFamilyNotSupported, | |
| 3393 | EAGAIN, EINPROGRESS => return error.WouldBlock, | |
| 3394 | EALREADY => return error.ConnectionPending, | |
| 3395 | EBADF => unreachable, // sockfd is not a valid open file descriptor. | |
| 3396 | ECONNREFUSED => return error.ConnectionRefused, | |
| 3397 | ECONNRESET => return error.ConnectionResetByPeer, | |
| 3398 | EFAULT => unreachable, // The socket structure address is outside the user's address space. | |
| 3399 | EINTR => continue, | |
| 3400 | EISCONN => unreachable, // The socket is already connected. | |
| 3401 | ENETUNREACH => return error.NetworkUnreachable, | |
| 3402 | ENOTSOCK => unreachable, // The file descriptor sockfd does not refer to a socket. | |
| 3403 | EPROTOTYPE => unreachable, // The socket type does not support the requested communications protocol. | |
| 3404 | ETIMEDOUT => return error.ConnectionTimedOut, | |
| 3405 | ENOENT => return error.FileNotFound, // Returned when socket is AF_UNIX and the given path does not exist. | |
| 3389 | .SUCCESS => return, | |
| 3390 | .ACCES => return error.PermissionDenied, | |
| 3391 | .PERM => return error.PermissionDenied, | |
| 3392 | .ADDRINUSE => return error.AddressInUse, | |
| 3393 | .ADDRNOTAVAIL => return error.AddressNotAvailable, | |
| 3394 | .AFNOSUPPORT => return error.AddressFamilyNotSupported, | |
| 3395 | .AGAIN, .INPROGRESS => return error.WouldBlock, | |
| 3396 | .ALREADY => return error.ConnectionPending, | |
| 3397 | .BADF => unreachable, // sockfd is not a valid open file descriptor. | |
| 3398 | .CONNREFUSED => return error.ConnectionRefused, | |
| 3399 | .CONNRESET => return error.ConnectionResetByPeer, | |
| 3400 | .FAULT => unreachable, // The socket structure address is outside the user's address space. | |
| 3401 | .INTR => continue, | |
| 3402 | .ISCONN => unreachable, // The socket is already connected. | |
| 3403 | .NETUNREACH => return error.NetworkUnreachable, | |
| 3404 | .NOTSOCK => unreachable, // The file descriptor sockfd does not refer to a socket. | |
| 3405 | .PROTOTYPE => unreachable, // The socket type does not support the requested communications protocol. | |
| 3406 | .TIMEDOUT => return error.ConnectionTimedOut, | |
| 3407 | .NOENT => return error.FileNotFound, // Returned when socket is AF_UNIX and the given path does not exist. | |
| 3406 | 3408 | else => |err| return unexpectedErrno(err), |
| 3407 | 3409 | } |
| 3408 | 3410 | } |
| 3409 | 3411 | } |
| 3410 | 3412 | |
| 3411 | 3413 | pub fn getsockoptError(sockfd: fd_t) ConnectError!void { |
| 3412 | var err_code: u32 = undefined; | |
| 3414 | var err_code: i32 = undefined; | |
| 3413 | 3415 | var size: u32 = @sizeOf(u32); |
| 3414 | 3416 | const rc = system.getsockopt(sockfd, SOL_SOCKET, SO_ERROR, @ptrCast([*]u8, &err_code), &size); |
| 3415 | 3417 | assert(size == 4); |
| 3416 | 3418 | switch (errno(rc)) { |
| 3417 | 0 => switch (err_code) { | |
| 3418 | 0 => return, | |
| 3419 | EACCES => return error.PermissionDenied, | |
| 3420 | EPERM => return error.PermissionDenied, | |
| 3421 | EADDRINUSE => return error.AddressInUse, | |
| 3422 | EADDRNOTAVAIL => return error.AddressNotAvailable, | |
| 3423 | EAFNOSUPPORT => return error.AddressFamilyNotSupported, | |
| 3424 | EAGAIN => return error.SystemResources, | |
| 3425 | EALREADY => return error.ConnectionPending, | |
| 3426 | EBADF => unreachable, // sockfd is not a valid open file descriptor. | |
| 3427 | ECONNREFUSED => return error.ConnectionRefused, | |
| 3428 | EFAULT => unreachable, // The socket structure address is outside the user's address space. | |
| 3429 | EISCONN => unreachable, // The socket is already connected. | |
| 3430 | ENETUNREACH => return error.NetworkUnreachable, | |
| 3431 | ENOTSOCK => unreachable, // The file descriptor sockfd does not refer to a socket. | |
| 3432 | EPROTOTYPE => unreachable, // The socket type does not support the requested communications protocol. | |
| 3433 | ETIMEDOUT => return error.ConnectionTimedOut, | |
| 3434 | ECONNRESET => return error.ConnectionResetByPeer, | |
| 3419 | .SUCCESS => switch (@intToEnum(E, err_code)) { | |
| 3420 | .SUCCESS => return, | |
| 3421 | .ACCES => return error.PermissionDenied, | |
| 3422 | .PERM => return error.PermissionDenied, | |
| 3423 | .ADDRINUSE => return error.AddressInUse, | |
| 3424 | .ADDRNOTAVAIL => return error.AddressNotAvailable, | |
| 3425 | .AFNOSUPPORT => return error.AddressFamilyNotSupported, | |
| 3426 | .AGAIN => return error.SystemResources, | |
| 3427 | .ALREADY => return error.ConnectionPending, | |
| 3428 | .BADF => unreachable, // sockfd is not a valid open file descriptor. | |
| 3429 | .CONNREFUSED => return error.ConnectionRefused, | |
| 3430 | .FAULT => unreachable, // The socket structure address is outside the user's address space. | |
| 3431 | .ISCONN => unreachable, // The socket is already connected. | |
| 3432 | .NETUNREACH => return error.NetworkUnreachable, | |
| 3433 | .NOTSOCK => unreachable, // The file descriptor sockfd does not refer to a socket. | |
| 3434 | .PROTOTYPE => unreachable, // The socket type does not support the requested communications protocol. | |
| 3435 | .TIMEDOUT => return error.ConnectionTimedOut, | |
| 3436 | .CONNRESET => return error.ConnectionResetByPeer, | |
| 3435 | 3437 | else => |err| return unexpectedErrno(err), |
| 3436 | 3438 | }, |
| 3437 | EBADF => unreachable, // The argument sockfd is not a valid file descriptor. | |
| 3438 | EFAULT => unreachable, // The address pointed to by optval or optlen is not in a valid part of the process address space. | |
| 3439 | EINVAL => unreachable, | |
| 3440 | ENOPROTOOPT => unreachable, // The option is unknown at the level indicated. | |
| 3441 | ENOTSOCK => unreachable, // The file descriptor sockfd does not refer to a socket. | |
| 3439 | .BADF => unreachable, // The argument sockfd is not a valid file descriptor. | |
| 3440 | .FAULT => unreachable, // The address pointed to by optval or optlen is not in a valid part of the process address space. | |
| 3441 | .INVAL => unreachable, | |
| 3442 | .NOPROTOOPT => unreachable, // The option is unknown at the level indicated. | |
| 3443 | .NOTSOCK => unreachable, // The file descriptor sockfd does not refer to a socket. | |
| 3442 | 3444 | else => |err| return unexpectedErrno(err), |
| 3443 | 3445 | } |
| 3444 | 3446 | } |
| ... | ... | @@ -3454,13 +3456,13 @@ pub fn waitpid(pid: pid_t, flags: u32) WaitPidResult { |
| 3454 | 3456 | while (true) { |
| 3455 | 3457 | const rc = system.waitpid(pid, &status, if (builtin.link_libc) @intCast(c_int, flags) else flags); |
| 3456 | 3458 | switch (errno(rc)) { |
| 3457 | 0 => return .{ | |
| 3459 | .SUCCESS => return .{ | |
| 3458 | 3460 | .pid = @intCast(pid_t, rc), |
| 3459 | 3461 | .status = @bitCast(u32, status), |
| 3460 | 3462 | }, |
| 3461 | EINTR => continue, | |
| 3462 | ECHILD => unreachable, // The process specified does not exist. It would be a race condition to handle this error. | |
| 3463 | EINVAL => unreachable, // Invalid flags. | |
| 3463 | .INTR => continue, | |
| 3464 | .CHILD => unreachable, // The process specified does not exist. It would be a race condition to handle this error. | |
| 3465 | .INVAL => unreachable, // Invalid flags. | |
| 3464 | 3466 | else => unreachable, |
| 3465 | 3467 | } |
| 3466 | 3468 | } |
| ... | ... | @@ -3484,12 +3486,12 @@ pub fn fstat(fd: fd_t) FStatError!Stat { |
| 3484 | 3486 | if (builtin.os.tag == .wasi and !builtin.link_libc) { |
| 3485 | 3487 | var stat: wasi.filestat_t = undefined; |
| 3486 | 3488 | switch (wasi.fd_filestat_get(fd, &stat)) { |
| 3487 | wasi.ESUCCESS => return Stat.fromFilestat(stat), | |
| 3488 | wasi.EINVAL => unreachable, | |
| 3489 | wasi.EBADF => unreachable, // Always a race condition. | |
| 3490 | wasi.ENOMEM => return error.SystemResources, | |
| 3491 | wasi.EACCES => return error.AccessDenied, | |
| 3492 | wasi.ENOTCAPABLE => return error.AccessDenied, | |
| 3489 | .SUCCESS => return Stat.fromFilestat(stat), | |
| 3490 | .INVAL => unreachable, | |
| 3491 | .BADF => unreachable, // Always a race condition. | |
| 3492 | .NOMEM => return error.SystemResources, | |
| 3493 | .ACCES => return error.AccessDenied, | |
| 3494 | .NOTCAPABLE => return error.AccessDenied, | |
| 3493 | 3495 | else => |err| return unexpectedErrno(err), |
| 3494 | 3496 | } |
| 3495 | 3497 | } |
| ... | ... | @@ -3504,11 +3506,11 @@ pub fn fstat(fd: fd_t) FStatError!Stat { |
| 3504 | 3506 | |
| 3505 | 3507 | var stat = mem.zeroes(Stat); |
| 3506 | 3508 | switch (errno(fstat_sym(fd, &stat))) { |
| 3507 | 0 => return stat, | |
| 3508 | EINVAL => unreachable, | |
| 3509 | EBADF => unreachable, // Always a race condition. | |
| 3510 | ENOMEM => return error.SystemResources, | |
| 3511 | EACCES => return error.AccessDenied, | |
| 3509 | .SUCCESS => return stat, | |
| 3510 | .INVAL => unreachable, | |
| 3511 | .BADF => unreachable, // Always a race condition. | |
| 3512 | .NOMEM => return error.SystemResources, | |
| 3513 | .ACCES => return error.AccessDenied, | |
| 3512 | 3514 | else => |err| return unexpectedErrno(err), |
| 3513 | 3515 | } |
| 3514 | 3516 | } |
| ... | ... | @@ -3536,16 +3538,16 @@ pub const fstatatC = @compileError("deprecated: renamed to fstatatZ"); |
| 3536 | 3538 | pub fn fstatatWasi(dirfd: fd_t, pathname: []const u8, flags: u32) FStatAtError!Stat { |
| 3537 | 3539 | var stat: wasi.filestat_t = undefined; |
| 3538 | 3540 | switch (wasi.path_filestat_get(dirfd, flags, pathname.ptr, pathname.len, &stat)) { |
| 3539 | wasi.ESUCCESS => return Stat.fromFilestat(stat), | |
| 3540 | wasi.EINVAL => unreachable, | |
| 3541 | wasi.EBADF => unreachable, // Always a race condition. | |
| 3542 | wasi.ENOMEM => return error.SystemResources, | |
| 3543 | wasi.EACCES => return error.AccessDenied, | |
| 3544 | wasi.EFAULT => unreachable, | |
| 3545 | wasi.ENAMETOOLONG => return error.NameTooLong, | |
| 3546 | wasi.ENOENT => return error.FileNotFound, | |
| 3547 | wasi.ENOTDIR => return error.FileNotFound, | |
| 3548 | wasi.ENOTCAPABLE => return error.AccessDenied, | |
| 3541 | .SUCCESS => return Stat.fromFilestat(stat), | |
| 3542 | .INVAL => unreachable, | |
| 3543 | .BADF => unreachable, // Always a race condition. | |
| 3544 | .NOMEM => return error.SystemResources, | |
| 3545 | .ACCES => return error.AccessDenied, | |
| 3546 | .FAULT => unreachable, | |
| 3547 | .NAMETOOLONG => return error.NameTooLong, | |
| 3548 | .NOENT => return error.FileNotFound, | |
| 3549 | .NOTDIR => return error.FileNotFound, | |
| 3550 | .NOTCAPABLE => return error.AccessDenied, | |
| 3549 | 3551 | else => |err| return unexpectedErrno(err), |
| 3550 | 3552 | } |
| 3551 | 3553 | } |
| ... | ... | @@ -3560,17 +3562,17 @@ pub fn fstatatZ(dirfd: fd_t, pathname: [*:0]const u8, flags: u32) FStatAtError!S |
| 3560 | 3562 | |
| 3561 | 3563 | var stat = mem.zeroes(Stat); |
| 3562 | 3564 | switch (errno(fstatat_sym(dirfd, pathname, &stat, flags))) { |
| 3563 | 0 => return stat, | |
| 3564 | EINVAL => unreachable, | |
| 3565 | EBADF => unreachable, // Always a race condition. | |
| 3566 | ENOMEM => return error.SystemResources, | |
| 3567 | EACCES => return error.AccessDenied, | |
| 3568 | EPERM => return error.AccessDenied, | |
| 3569 | EFAULT => unreachable, | |
| 3570 | ENAMETOOLONG => return error.NameTooLong, | |
| 3571 | ELOOP => return error.SymLinkLoop, | |
| 3572 | ENOENT => return error.FileNotFound, | |
| 3573 | ENOTDIR => return error.FileNotFound, | |
| 3565 | .SUCCESS => return stat, | |
| 3566 | .INVAL => unreachable, | |
| 3567 | .BADF => unreachable, // Always a race condition. | |
| 3568 | .NOMEM => return error.SystemResources, | |
| 3569 | .ACCES => return error.AccessDenied, | |
| 3570 | .PERM => return error.AccessDenied, | |
| 3571 | .FAULT => unreachable, | |
| 3572 | .NAMETOOLONG => return error.NameTooLong, | |
| 3573 | .LOOP => return error.SymLinkLoop, | |
| 3574 | .NOENT => return error.FileNotFound, | |
| 3575 | .NOTDIR => return error.FileNotFound, | |
| 3574 | 3576 | else => |err| return unexpectedErrno(err), |
| 3575 | 3577 | } |
| 3576 | 3578 | } |
| ... | ... | @@ -3586,9 +3588,9 @@ pub const KQueueError = error{ |
| 3586 | 3588 | pub fn kqueue() KQueueError!i32 { |
| 3587 | 3589 | const rc = system.kqueue(); |
| 3588 | 3590 | switch (errno(rc)) { |
| 3589 | 0 => return @intCast(i32, rc), | |
| 3590 | EMFILE => return error.ProcessFdQuotaExceeded, | |
| 3591 | ENFILE => return error.SystemFdQuotaExceeded, | |
| 3591 | .SUCCESS => return @intCast(i32, rc), | |
| 3592 | .MFILE => return error.ProcessFdQuotaExceeded, | |
| 3593 | .NFILE => return error.SystemFdQuotaExceeded, | |
| 3592 | 3594 | else => |err| return unexpectedErrno(err), |
| 3593 | 3595 | } |
| 3594 | 3596 | } |
| ... | ... | @@ -3627,15 +3629,15 @@ pub fn kevent( |
| 3627 | 3629 | timeout, |
| 3628 | 3630 | ); |
| 3629 | 3631 | switch (errno(rc)) { |
| 3630 | 0 => return @intCast(usize, rc), | |
| 3631 | EACCES => return error.AccessDenied, | |
| 3632 | EFAULT => unreachable, | |
| 3633 | EBADF => unreachable, // Always a race condition. | |
| 3634 | EINTR => continue, | |
| 3635 | EINVAL => unreachable, | |
| 3636 | ENOENT => return error.EventNotFound, | |
| 3637 | ENOMEM => return error.SystemResources, | |
| 3638 | ESRCH => return error.ProcessNotFound, | |
| 3632 | .SUCCESS => return @intCast(usize, rc), | |
| 3633 | .ACCES => return error.AccessDenied, | |
| 3634 | .FAULT => unreachable, | |
| 3635 | .BADF => unreachable, // Always a race condition. | |
| 3636 | .INTR => continue, | |
| 3637 | .INVAL => unreachable, | |
| 3638 | .NOENT => return error.EventNotFound, | |
| 3639 | .NOMEM => return error.SystemResources, | |
| 3640 | .SRCH => return error.ProcessNotFound, | |
| 3639 | 3641 | else => unreachable, |
| 3640 | 3642 | } |
| 3641 | 3643 | } |
| ... | ... | @@ -3651,11 +3653,11 @@ pub const INotifyInitError = error{ |
| 3651 | 3653 | pub fn inotify_init1(flags: u32) INotifyInitError!i32 { |
| 3652 | 3654 | const rc = system.inotify_init1(flags); |
| 3653 | 3655 | switch (errno(rc)) { |
| 3654 | 0 => return @intCast(i32, rc), | |
| 3655 | EINVAL => unreachable, | |
| 3656 | EMFILE => return error.ProcessFdQuotaExceeded, | |
| 3657 | ENFILE => return error.SystemFdQuotaExceeded, | |
| 3658 | ENOMEM => return error.SystemResources, | |
| 3656 | .SUCCESS => return @intCast(i32, rc), | |
| 3657 | .INVAL => unreachable, | |
| 3658 | .MFILE => return error.ProcessFdQuotaExceeded, | |
| 3659 | .NFILE => return error.SystemFdQuotaExceeded, | |
| 3660 | .NOMEM => return error.SystemResources, | |
| 3659 | 3661 | else => |err| return unexpectedErrno(err), |
| 3660 | 3662 | } |
| 3661 | 3663 | } |
| ... | ... | @@ -3681,16 +3683,16 @@ pub const inotify_add_watchC = @compileError("deprecated: renamed to inotify_add |
| 3681 | 3683 | pub fn inotify_add_watchZ(inotify_fd: i32, pathname: [*:0]const u8, mask: u32) INotifyAddWatchError!i32 { |
| 3682 | 3684 | const rc = system.inotify_add_watch(inotify_fd, pathname, mask); |
| 3683 | 3685 | switch (errno(rc)) { |
| 3684 | 0 => return @intCast(i32, rc), | |
| 3685 | EACCES => return error.AccessDenied, | |
| 3686 | EBADF => unreachable, | |
| 3687 | EFAULT => unreachable, | |
| 3688 | EINVAL => unreachable, | |
| 3689 | ENAMETOOLONG => return error.NameTooLong, | |
| 3690 | ENOENT => return error.FileNotFound, | |
| 3691 | ENOMEM => return error.SystemResources, | |
| 3692 | ENOSPC => return error.UserResourceLimitReached, | |
| 3693 | ENOTDIR => return error.NotDir, | |
| 3686 | .SUCCESS => return @intCast(i32, rc), | |
| 3687 | .ACCES => return error.AccessDenied, | |
| 3688 | .BADF => unreachable, | |
| 3689 | .FAULT => unreachable, | |
| 3690 | .INVAL => unreachable, | |
| 3691 | .NAMETOOLONG => return error.NameTooLong, | |
| 3692 | .NOENT => return error.FileNotFound, | |
| 3693 | .NOMEM => return error.SystemResources, | |
| 3694 | .NOSPC => return error.UserResourceLimitReached, | |
| 3695 | .NOTDIR => return error.NotDir, | |
| 3694 | 3696 | else => |err| return unexpectedErrno(err), |
| 3695 | 3697 | } |
| 3696 | 3698 | } |
| ... | ... | @@ -3698,9 +3700,9 @@ pub fn inotify_add_watchZ(inotify_fd: i32, pathname: [*:0]const u8, mask: u32) I |
| 3698 | 3700 | /// remove an existing watch from an inotify instance |
| 3699 | 3701 | pub fn inotify_rm_watch(inotify_fd: i32, wd: i32) void { |
| 3700 | 3702 | switch (errno(system.inotify_rm_watch(inotify_fd, wd))) { |
| 3701 | 0 => return, | |
| 3702 | EBADF => unreachable, | |
| 3703 | EINVAL => unreachable, | |
| 3703 | .SUCCESS => return, | |
| 3704 | .BADF => unreachable, | |
| 3705 | .INVAL => unreachable, | |
| 3704 | 3706 | else => unreachable, |
| 3705 | 3707 | } |
| 3706 | 3708 | } |
| ... | ... | @@ -3723,10 +3725,10 @@ pub const MProtectError = error{ |
| 3723 | 3725 | pub fn mprotect(memory: []align(mem.page_size) u8, protection: u32) MProtectError!void { |
| 3724 | 3726 | assert(mem.isAligned(memory.len, mem.page_size)); |
| 3725 | 3727 | switch (errno(system.mprotect(memory.ptr, memory.len, protection))) { |
| 3726 | 0 => return, | |
| 3727 | EINVAL => unreachable, | |
| 3728 | EACCES => return error.AccessDenied, | |
| 3729 | ENOMEM => return error.OutOfMemory, | |
| 3728 | .SUCCESS => return, | |
| 3729 | .INVAL => unreachable, | |
| 3730 | .ACCES => return error.AccessDenied, | |
| 3731 | .NOMEM => return error.OutOfMemory, | |
| 3730 | 3732 | else => |err| return unexpectedErrno(err), |
| 3731 | 3733 | } |
| 3732 | 3734 | } |
| ... | ... | @@ -3736,9 +3738,9 @@ pub const ForkError = error{SystemResources} || UnexpectedError; |
| 3736 | 3738 | pub fn fork() ForkError!pid_t { |
| 3737 | 3739 | const rc = system.fork(); |
| 3738 | 3740 | switch (errno(rc)) { |
| 3739 | 0 => return @intCast(pid_t, rc), | |
| 3740 | EAGAIN => return error.SystemResources, | |
| 3741 | ENOMEM => return error.SystemResources, | |
| 3741 | .SUCCESS => return @intCast(pid_t, rc), | |
| 3742 | .AGAIN => return error.SystemResources, | |
| 3743 | .NOMEM => return error.SystemResources, | |
| 3742 | 3744 | else => |err| return unexpectedErrno(err), |
| 3743 | 3745 | } |
| 3744 | 3746 | } |
| ... | ... | @@ -3782,22 +3784,23 @@ pub fn mmap( |
| 3782 | 3784 | const rc = mmap_sym(ptr, length, prot, flags, fd, ioffset); |
| 3783 | 3785 | const err = if (builtin.link_libc) blk: { |
| 3784 | 3786 | if (rc != std.c.MAP_FAILED) return @ptrCast([*]align(mem.page_size) u8, @alignCast(mem.page_size, rc))[0..length]; |
| 3785 | break :blk system._errno().*; | |
| 3787 | break :blk @intToEnum(E, system._errno().*); | |
| 3786 | 3788 | } else blk: { |
| 3787 | 3789 | const err = errno(rc); |
| 3788 | if (err == 0) return @intToPtr([*]align(mem.page_size) u8, rc)[0..length]; | |
| 3790 | if (err == .SUCCESS) return @intToPtr([*]align(mem.page_size) u8, rc)[0..length]; | |
| 3789 | 3791 | break :blk err; |
| 3790 | 3792 | }; |
| 3791 | 3793 | switch (err) { |
| 3792 | ETXTBSY => return error.AccessDenied, | |
| 3793 | EACCES => return error.AccessDenied, | |
| 3794 | EPERM => return error.PermissionDenied, | |
| 3795 | EAGAIN => return error.LockedMemoryLimitExceeded, | |
| 3796 | EBADF => unreachable, // Always a race condition. | |
| 3797 | EOVERFLOW => unreachable, // The number of pages used for length + offset would overflow. | |
| 3798 | ENODEV => return error.MemoryMappingNotSupported, | |
| 3799 | EINVAL => unreachable, // Invalid parameters to mmap() | |
| 3800 | ENOMEM => return error.OutOfMemory, | |
| 3794 | .SUCCESS => unreachable, | |
| 3795 | .TXTBSY => return error.AccessDenied, | |
| 3796 | .ACCES => return error.AccessDenied, | |
| 3797 | .PERM => return error.PermissionDenied, | |
| 3798 | .AGAIN => return error.LockedMemoryLimitExceeded, | |
| 3799 | .BADF => unreachable, // Always a race condition. | |
| 3800 | .OVERFLOW => unreachable, // The number of pages used for length + offset would overflow. | |
| 3801 | .NODEV => return error.MemoryMappingNotSupported, | |
| 3802 | .INVAL => unreachable, // Invalid parameters to mmap() | |
| 3803 | .NOMEM => return error.OutOfMemory, | |
| 3801 | 3804 | else => return unexpectedErrno(err), |
| 3802 | 3805 | } |
| 3803 | 3806 | } |
| ... | ... | @@ -3810,9 +3813,9 @@ pub fn mmap( |
| 3810 | 3813 | /// * The Windows function, VirtualFree, has this restriction. |
| 3811 | 3814 | pub fn munmap(memory: []align(mem.page_size) const u8) void { |
| 3812 | 3815 | switch (errno(system.munmap(memory.ptr, memory.len))) { |
| 3813 | 0 => return, | |
| 3814 | EINVAL => unreachable, // Invalid parameters. | |
| 3815 | ENOMEM => unreachable, // Attempted to unmap a region in the middle of an existing mapping. | |
| 3816 | .SUCCESS => return, | |
| 3817 | .INVAL => unreachable, // Invalid parameters. | |
| 3818 | .NOMEM => unreachable, // Attempted to unmap a region in the middle of an existing mapping. | |
| 3816 | 3819 | else => unreachable, |
| 3817 | 3820 | } |
| 3818 | 3821 | } |
| ... | ... | @@ -3854,18 +3857,18 @@ pub fn accessZ(path: [*:0]const u8, mode: u32) AccessError!void { |
| 3854 | 3857 | return; |
| 3855 | 3858 | } |
| 3856 | 3859 | switch (errno(system.access(path, mode))) { |
| 3857 | 0 => return, | |
| 3858 | EACCES => return error.PermissionDenied, | |
| 3859 | EROFS => return error.ReadOnlyFileSystem, | |
| 3860 | ELOOP => return error.SymLinkLoop, | |
| 3861 | ETXTBSY => return error.FileBusy, | |
| 3862 | ENOTDIR => return error.FileNotFound, | |
| 3863 | ENOENT => return error.FileNotFound, | |
| 3864 | ENAMETOOLONG => return error.NameTooLong, | |
| 3865 | EINVAL => unreachable, | |
| 3866 | EFAULT => unreachable, | |
| 3867 | EIO => return error.InputOutput, | |
| 3868 | ENOMEM => return error.SystemResources, | |
| 3860 | .SUCCESS => return, | |
| 3861 | .ACCES => return error.PermissionDenied, | |
| 3862 | .ROFS => return error.ReadOnlyFileSystem, | |
| 3863 | .LOOP => return error.SymLinkLoop, | |
| 3864 | .TXTBSY => return error.FileBusy, | |
| 3865 | .NOTDIR => return error.FileNotFound, | |
| 3866 | .NOENT => return error.FileNotFound, | |
| 3867 | .NAMETOOLONG => return error.NameTooLong, | |
| 3868 | .INVAL => unreachable, | |
| 3869 | .FAULT => unreachable, | |
| 3870 | .IO => return error.InputOutput, | |
| 3871 | .NOMEM => return error.SystemResources, | |
| 3869 | 3872 | else => |err| return unexpectedErrno(err), |
| 3870 | 3873 | } |
| 3871 | 3874 | } |
| ... | ... | @@ -3905,18 +3908,18 @@ pub fn faccessatZ(dirfd: fd_t, path: [*:0]const u8, mode: u32, flags: u32) Acces |
| 3905 | 3908 | return faccessatW(dirfd, path_w.span().ptr, mode, flags); |
| 3906 | 3909 | } |
| 3907 | 3910 | switch (errno(system.faccessat(dirfd, path, mode, flags))) { |
| 3908 | 0 => return, | |
| 3909 | EACCES => return error.PermissionDenied, | |
| 3910 | EROFS => return error.ReadOnlyFileSystem, | |
| 3911 | ELOOP => return error.SymLinkLoop, | |
| 3912 | ETXTBSY => return error.FileBusy, | |
| 3913 | ENOTDIR => return error.FileNotFound, | |
| 3914 | ENOENT => return error.FileNotFound, | |
| 3915 | ENAMETOOLONG => return error.NameTooLong, | |
| 3916 | EINVAL => unreachable, | |
| 3917 | EFAULT => unreachable, | |
| 3918 | EIO => return error.InputOutput, | |
| 3919 | ENOMEM => return error.SystemResources, | |
| 3911 | .SUCCESS => return, | |
| 3912 | .ACCES => return error.PermissionDenied, | |
| 3913 | .ROFS => return error.ReadOnlyFileSystem, | |
| 3914 | .LOOP => return error.SymLinkLoop, | |
| 3915 | .TXTBSY => return error.FileBusy, | |
| 3916 | .NOTDIR => return error.FileNotFound, | |
| 3917 | .NOENT => return error.FileNotFound, | |
| 3918 | .NAMETOOLONG => return error.NameTooLong, | |
| 3919 | .INVAL => unreachable, | |
| 3920 | .FAULT => unreachable, | |
| 3921 | .IO => return error.InputOutput, | |
| 3922 | .NOMEM => return error.SystemResources, | |
| 3920 | 3923 | else => |err| return unexpectedErrno(err), |
| 3921 | 3924 | } |
| 3922 | 3925 | } |
| ... | ... | @@ -3972,11 +3975,11 @@ pub const PipeError = error{ |
| 3972 | 3975 | pub fn pipe() PipeError![2]fd_t { |
| 3973 | 3976 | var fds: [2]fd_t = undefined; |
| 3974 | 3977 | switch (errno(system.pipe(&fds))) { |
| 3975 | 0 => return fds, | |
| 3976 | EINVAL => unreachable, // Invalid parameters to pipe() | |
| 3977 | EFAULT => unreachable, // Invalid fds pointer | |
| 3978 | ENFILE => return error.SystemFdQuotaExceeded, | |
| 3979 | EMFILE => return error.ProcessFdQuotaExceeded, | |
| 3978 | .SUCCESS => return fds, | |
| 3979 | .INVAL => unreachable, // Invalid parameters to pipe() | |
| 3980 | .FAULT => unreachable, // Invalid fds pointer | |
| 3981 | .NFILE => return error.SystemFdQuotaExceeded, | |
| 3982 | .MFILE => return error.ProcessFdQuotaExceeded, | |
| 3980 | 3983 | else => |err| return unexpectedErrno(err), |
| 3981 | 3984 | } |
| 3982 | 3985 | } |
| ... | ... | @@ -3985,11 +3988,11 @@ pub fn pipe2(flags: u32) PipeError![2]fd_t { |
| 3985 | 3988 | if (@hasDecl(system, "pipe2")) { |
| 3986 | 3989 | var fds: [2]fd_t = undefined; |
| 3987 | 3990 | switch (errno(system.pipe2(&fds, flags))) { |
| 3988 | 0 => return fds, | |
| 3989 | EINVAL => unreachable, // Invalid flags | |
| 3990 | EFAULT => unreachable, // Invalid fds pointer | |
| 3991 | ENFILE => return error.SystemFdQuotaExceeded, | |
| 3992 | EMFILE => return error.ProcessFdQuotaExceeded, | |
| 3991 | .SUCCESS => return fds, | |
| 3992 | .INVAL => unreachable, // Invalid flags | |
| 3993 | .FAULT => unreachable, // Invalid fds pointer | |
| 3994 | .NFILE => return error.SystemFdQuotaExceeded, | |
| 3995 | .MFILE => return error.ProcessFdQuotaExceeded, | |
| 3993 | 3996 | else => |err| return unexpectedErrno(err), |
| 3994 | 3997 | } |
| 3995 | 3998 | } |
| ... | ... | @@ -4008,9 +4011,9 @@ pub fn pipe2(flags: u32) PipeError![2]fd_t { |
| 4008 | 4011 | if (flags & O_CLOEXEC != 0) { |
| 4009 | 4012 | for (fds) |fd| { |
| 4010 | 4013 | switch (errno(system.fcntl(fd, F_SETFD, @as(u32, FD_CLOEXEC)))) { |
| 4011 | 0 => {}, | |
| 4012 | EINVAL => unreachable, // Invalid flags | |
| 4013 | EBADF => unreachable, // Always a race condition | |
| 4014 | .SUCCESS => {}, | |
| 4015 | .INVAL => unreachable, // Invalid flags | |
| 4016 | .BADF => unreachable, // Always a race condition | |
| 4014 | 4017 | else => |err| return unexpectedErrno(err), |
| 4015 | 4018 | } |
| 4016 | 4019 | } |
| ... | ... | @@ -4021,9 +4024,9 @@ pub fn pipe2(flags: u32) PipeError![2]fd_t { |
| 4021 | 4024 | if (new_flags != 0) { |
| 4022 | 4025 | for (fds) |fd| { |
| 4023 | 4026 | switch (errno(system.fcntl(fd, F_SETFL, new_flags))) { |
| 4024 | 0 => {}, | |
| 4025 | EINVAL => unreachable, // Invalid flags | |
| 4026 | EBADF => unreachable, // Always a race condition | |
| 4027 | .SUCCESS => {}, | |
| 4028 | .INVAL => unreachable, // Invalid flags | |
| 4029 | .BADF => unreachable, // Always a race condition | |
| 4027 | 4030 | else => |err| return unexpectedErrno(err), |
| 4028 | 4031 | } |
| 4029 | 4032 | } |
| ... | ... | @@ -4055,11 +4058,11 @@ pub fn sysctl( |
| 4055 | 4058 | |
| 4056 | 4059 | const name_len = math.cast(c_uint, name.len) catch return error.NameTooLong; |
| 4057 | 4060 | switch (errno(system.sysctl(name.ptr, name_len, oldp, oldlenp, newp, newlen))) { |
| 4058 | 0 => return, | |
| 4059 | EFAULT => unreachable, | |
| 4060 | EPERM => return error.PermissionDenied, | |
| 4061 | ENOMEM => return error.SystemResources, | |
| 4062 | ENOENT => return error.UnknownName, | |
| 4061 | .SUCCESS => return, | |
| 4062 | .FAULT => unreachable, | |
| 4063 | .PERM => return error.PermissionDenied, | |
| 4064 | .NOMEM => return error.SystemResources, | |
| 4065 | .NOENT => return error.UnknownName, | |
| 4063 | 4066 | else => |err| return unexpectedErrno(err), |
| 4064 | 4067 | } |
| 4065 | 4068 | } |
| ... | ... | @@ -4081,19 +4084,19 @@ pub fn sysctlbynameZ( |
| 4081 | 4084 | } |
| 4082 | 4085 | |
| 4083 | 4086 | switch (errno(system.sysctlbyname(name, oldp, oldlenp, newp, newlen))) { |
| 4084 | 0 => return, | |
| 4085 | EFAULT => unreachable, | |
| 4086 | EPERM => return error.PermissionDenied, | |
| 4087 | ENOMEM => return error.SystemResources, | |
| 4088 | ENOENT => return error.UnknownName, | |
| 4087 | .SUCCESS => return, | |
| 4088 | .FAULT => unreachable, | |
| 4089 | .PERM => return error.PermissionDenied, | |
| 4090 | .NOMEM => return error.SystemResources, | |
| 4091 | .NOENT => return error.UnknownName, | |
| 4089 | 4092 | else => |err| return unexpectedErrno(err), |
| 4090 | 4093 | } |
| 4091 | 4094 | } |
| 4092 | 4095 | |
| 4093 | 4096 | pub fn gettimeofday(tv: ?*timeval, tz: ?*timezone) void { |
| 4094 | 4097 | switch (errno(system.gettimeofday(tv, tz))) { |
| 4095 | 0 => return, | |
| 4096 | EINVAL => unreachable, | |
| 4098 | .SUCCESS => return, | |
| 4099 | .INVAL => unreachable, | |
| 4097 | 4100 | else => unreachable, |
| 4098 | 4101 | } |
| 4099 | 4102 | } |
| ... | ... | @@ -4111,12 +4114,12 @@ pub fn lseek_SET(fd: fd_t, offset: u64) SeekError!void { |
| 4111 | 4114 | if (builtin.os.tag == .linux and !builtin.link_libc and @sizeOf(usize) == 4) { |
| 4112 | 4115 | var result: u64 = undefined; |
| 4113 | 4116 | switch (errno(system.llseek(fd, offset, &result, SEEK_SET))) { |
| 4114 | 0 => return, | |
| 4115 | EBADF => unreachable, // always a race condition | |
| 4116 | EINVAL => return error.Unseekable, | |
| 4117 | EOVERFLOW => return error.Unseekable, | |
| 4118 | ESPIPE => return error.Unseekable, | |
| 4119 | ENXIO => return error.Unseekable, | |
| 4117 | .SUCCESS => return, | |
| 4118 | .BADF => unreachable, // always a race condition | |
| 4119 | .INVAL => return error.Unseekable, | |
| 4120 | .OVERFLOW => return error.Unseekable, | |
| 4121 | .SPIPE => return error.Unseekable, | |
| 4122 | .NXIO => return error.Unseekable, | |
| 4120 | 4123 | else => |err| return unexpectedErrno(err), |
| 4121 | 4124 | } |
| 4122 | 4125 | } |
| ... | ... | @@ -4126,13 +4129,13 @@ pub fn lseek_SET(fd: fd_t, offset: u64) SeekError!void { |
| 4126 | 4129 | if (builtin.os.tag == .wasi and !builtin.link_libc) { |
| 4127 | 4130 | var new_offset: wasi.filesize_t = undefined; |
| 4128 | 4131 | switch (wasi.fd_seek(fd, @bitCast(wasi.filedelta_t, offset), wasi.WHENCE_SET, &new_offset)) { |
| 4129 | wasi.ESUCCESS => return, | |
| 4130 | wasi.EBADF => unreachable, // always a race condition | |
| 4131 | wasi.EINVAL => return error.Unseekable, | |
| 4132 | wasi.EOVERFLOW => return error.Unseekable, | |
| 4133 | wasi.ESPIPE => return error.Unseekable, | |
| 4134 | wasi.ENXIO => return error.Unseekable, | |
| 4135 | wasi.ENOTCAPABLE => return error.AccessDenied, | |
| 4132 | .SUCCESS => return, | |
| 4133 | .BADF => unreachable, // always a race condition | |
| 4134 | .INVAL => return error.Unseekable, | |
| 4135 | .OVERFLOW => return error.Unseekable, | |
| 4136 | .SPIPE => return error.Unseekable, | |
| 4137 | .NXIO => return error.Unseekable, | |
| 4138 | .NOTCAPABLE => return error.AccessDenied, | |
| 4136 | 4139 | else => |err| return unexpectedErrno(err), |
| 4137 | 4140 | } |
| 4138 | 4141 | } |
| ... | ... | @@ -4144,12 +4147,12 @@ pub fn lseek_SET(fd: fd_t, offset: u64) SeekError!void { |
| 4144 | 4147 | |
| 4145 | 4148 | const ioffset = @bitCast(i64, offset); // the OS treats this as unsigned |
| 4146 | 4149 | switch (errno(lseek_sym(fd, ioffset, SEEK_SET))) { |
| 4147 | 0 => return, | |
| 4148 | EBADF => unreachable, // always a race condition | |
| 4149 | EINVAL => return error.Unseekable, | |
| 4150 | EOVERFLOW => return error.Unseekable, | |
| 4151 | ESPIPE => return error.Unseekable, | |
| 4152 | ENXIO => return error.Unseekable, | |
| 4150 | .SUCCESS => return, | |
| 4151 | .BADF => unreachable, // always a race condition | |
| 4152 | .INVAL => return error.Unseekable, | |
| 4153 | .OVERFLOW => return error.Unseekable, | |
| 4154 | .SPIPE => return error.Unseekable, | |
| 4155 | .NXIO => return error.Unseekable, | |
| 4153 | 4156 | else => |err| return unexpectedErrno(err), |
| 4154 | 4157 | } |
| 4155 | 4158 | } |
| ... | ... | @@ -4159,12 +4162,12 @@ pub fn lseek_CUR(fd: fd_t, offset: i64) SeekError!void { |
| 4159 | 4162 | if (builtin.os.tag == .linux and !builtin.link_libc and @sizeOf(usize) == 4) { |
| 4160 | 4163 | var result: u64 = undefined; |
| 4161 | 4164 | switch (errno(system.llseek(fd, @bitCast(u64, offset), &result, SEEK_CUR))) { |
| 4162 | 0 => return, | |
| 4163 | EBADF => unreachable, // always a race condition | |
| 4164 | EINVAL => return error.Unseekable, | |
| 4165 | EOVERFLOW => return error.Unseekable, | |
| 4166 | ESPIPE => return error.Unseekable, | |
| 4167 | ENXIO => return error.Unseekable, | |
| 4165 | .SUCCESS => return, | |
| 4166 | .BADF => unreachable, // always a race condition | |
| 4167 | .INVAL => return error.Unseekable, | |
| 4168 | .OVERFLOW => return error.Unseekable, | |
| 4169 | .SPIPE => return error.Unseekable, | |
| 4170 | .NXIO => return error.Unseekable, | |
| 4168 | 4171 | else => |err| return unexpectedErrno(err), |
| 4169 | 4172 | } |
| 4170 | 4173 | } |
| ... | ... | @@ -4174,13 +4177,13 @@ pub fn lseek_CUR(fd: fd_t, offset: i64) SeekError!void { |
| 4174 | 4177 | if (builtin.os.tag == .wasi and !builtin.link_libc) { |
| 4175 | 4178 | var new_offset: wasi.filesize_t = undefined; |
| 4176 | 4179 | switch (wasi.fd_seek(fd, offset, wasi.WHENCE_CUR, &new_offset)) { |
| 4177 | wasi.ESUCCESS => return, | |
| 4178 | wasi.EBADF => unreachable, // always a race condition | |
| 4179 | wasi.EINVAL => return error.Unseekable, | |
| 4180 | wasi.EOVERFLOW => return error.Unseekable, | |
| 4181 | wasi.ESPIPE => return error.Unseekable, | |
| 4182 | wasi.ENXIO => return error.Unseekable, | |
| 4183 | wasi.ENOTCAPABLE => return error.AccessDenied, | |
| 4180 | .SUCCESS => return, | |
| 4181 | .BADF => unreachable, // always a race condition | |
| 4182 | .INVAL => return error.Unseekable, | |
| 4183 | .OVERFLOW => return error.Unseekable, | |
| 4184 | .SPIPE => return error.Unseekable, | |
| 4185 | .NXIO => return error.Unseekable, | |
| 4186 | .NOTCAPABLE => return error.AccessDenied, | |
| 4184 | 4187 | else => |err| return unexpectedErrno(err), |
| 4185 | 4188 | } |
| 4186 | 4189 | } |
| ... | ... | @@ -4191,12 +4194,12 @@ pub fn lseek_CUR(fd: fd_t, offset: i64) SeekError!void { |
| 4191 | 4194 | |
| 4192 | 4195 | const ioffset = @bitCast(i64, offset); // the OS treats this as unsigned |
| 4193 | 4196 | switch (errno(lseek_sym(fd, ioffset, SEEK_CUR))) { |
| 4194 | 0 => return, | |
| 4195 | EBADF => unreachable, // always a race condition | |
| 4196 | EINVAL => return error.Unseekable, | |
| 4197 | EOVERFLOW => return error.Unseekable, | |
| 4198 | ESPIPE => return error.Unseekable, | |
| 4199 | ENXIO => return error.Unseekable, | |
| 4197 | .SUCCESS => return, | |
| 4198 | .BADF => unreachable, // always a race condition | |
| 4199 | .INVAL => return error.Unseekable, | |
| 4200 | .OVERFLOW => return error.Unseekable, | |
| 4201 | .SPIPE => return error.Unseekable, | |
| 4202 | .NXIO => return error.Unseekable, | |
| 4200 | 4203 | else => |err| return unexpectedErrno(err), |
| 4201 | 4204 | } |
| 4202 | 4205 | } |
| ... | ... | @@ -4206,12 +4209,12 @@ pub fn lseek_END(fd: fd_t, offset: i64) SeekError!void { |
| 4206 | 4209 | if (builtin.os.tag == .linux and !builtin.link_libc and @sizeOf(usize) == 4) { |
| 4207 | 4210 | var result: u64 = undefined; |
| 4208 | 4211 | switch (errno(system.llseek(fd, @bitCast(u64, offset), &result, SEEK_END))) { |
| 4209 | 0 => return, | |
| 4210 | EBADF => unreachable, // always a race condition | |
| 4211 | EINVAL => return error.Unseekable, | |
| 4212 | EOVERFLOW => return error.Unseekable, | |
| 4213 | ESPIPE => return error.Unseekable, | |
| 4214 | ENXIO => return error.Unseekable, | |
| 4212 | .SUCCESS => return, | |
| 4213 | .BADF => unreachable, // always a race condition | |
| 4214 | .INVAL => return error.Unseekable, | |
| 4215 | .OVERFLOW => return error.Unseekable, | |
| 4216 | .SPIPE => return error.Unseekable, | |
| 4217 | .NXIO => return error.Unseekable, | |
| 4215 | 4218 | else => |err| return unexpectedErrno(err), |
| 4216 | 4219 | } |
| 4217 | 4220 | } |
| ... | ... | @@ -4221,13 +4224,13 @@ pub fn lseek_END(fd: fd_t, offset: i64) SeekError!void { |
| 4221 | 4224 | if (builtin.os.tag == .wasi and !builtin.link_libc) { |
| 4222 | 4225 | var new_offset: wasi.filesize_t = undefined; |
| 4223 | 4226 | switch (wasi.fd_seek(fd, offset, wasi.WHENCE_END, &new_offset)) { |
| 4224 | wasi.ESUCCESS => return, | |
| 4225 | wasi.EBADF => unreachable, // always a race condition | |
| 4226 | wasi.EINVAL => return error.Unseekable, | |
| 4227 | wasi.EOVERFLOW => return error.Unseekable, | |
| 4228 | wasi.ESPIPE => return error.Unseekable, | |
| 4229 | wasi.ENXIO => return error.Unseekable, | |
| 4230 | wasi.ENOTCAPABLE => return error.AccessDenied, | |
| 4227 | .SUCCESS => return, | |
| 4228 | .BADF => unreachable, // always a race condition | |
| 4229 | .INVAL => return error.Unseekable, | |
| 4230 | .OVERFLOW => return error.Unseekable, | |
| 4231 | .SPIPE => return error.Unseekable, | |
| 4232 | .NXIO => return error.Unseekable, | |
| 4233 | .NOTCAPABLE => return error.AccessDenied, | |
| 4231 | 4234 | else => |err| return unexpectedErrno(err), |
| 4232 | 4235 | } |
| 4233 | 4236 | } |
| ... | ... | @@ -4238,12 +4241,12 @@ pub fn lseek_END(fd: fd_t, offset: i64) SeekError!void { |
| 4238 | 4241 | |
| 4239 | 4242 | const ioffset = @bitCast(i64, offset); // the OS treats this as unsigned |
| 4240 | 4243 | switch (errno(lseek_sym(fd, ioffset, SEEK_END))) { |
| 4241 | 0 => return, | |
| 4242 | EBADF => unreachable, // always a race condition | |
| 4243 | EINVAL => return error.Unseekable, | |
| 4244 | EOVERFLOW => return error.Unseekable, | |
| 4245 | ESPIPE => return error.Unseekable, | |
| 4246 | ENXIO => return error.Unseekable, | |
| 4244 | .SUCCESS => return, | |
| 4245 | .BADF => unreachable, // always a race condition | |
| 4246 | .INVAL => return error.Unseekable, | |
| 4247 | .OVERFLOW => return error.Unseekable, | |
| 4248 | .SPIPE => return error.Unseekable, | |
| 4249 | .NXIO => return error.Unseekable, | |
| 4247 | 4250 | else => |err| return unexpectedErrno(err), |
| 4248 | 4251 | } |
| 4249 | 4252 | } |
| ... | ... | @@ -4253,12 +4256,12 @@ pub fn lseek_CUR_get(fd: fd_t) SeekError!u64 { |
| 4253 | 4256 | if (builtin.os.tag == .linux and !builtin.link_libc and @sizeOf(usize) == 4) { |
| 4254 | 4257 | var result: u64 = undefined; |
| 4255 | 4258 | switch (errno(system.llseek(fd, 0, &result, SEEK_CUR))) { |
| 4256 | 0 => return result, | |
| 4257 | EBADF => unreachable, // always a race condition | |
| 4258 | EINVAL => return error.Unseekable, | |
| 4259 | EOVERFLOW => return error.Unseekable, | |
| 4260 | ESPIPE => return error.Unseekable, | |
| 4261 | ENXIO => return error.Unseekable, | |
| 4259 | .SUCCESS => return result, | |
| 4260 | .BADF => unreachable, // always a race condition | |
| 4261 | .INVAL => return error.Unseekable, | |
| 4262 | .OVERFLOW => return error.Unseekable, | |
| 4263 | .SPIPE => return error.Unseekable, | |
| 4264 | .NXIO => return error.Unseekable, | |
| 4262 | 4265 | else => |err| return unexpectedErrno(err), |
| 4263 | 4266 | } |
| 4264 | 4267 | } |
| ... | ... | @@ -4268,13 +4271,13 @@ pub fn lseek_CUR_get(fd: fd_t) SeekError!u64 { |
| 4268 | 4271 | if (builtin.os.tag == .wasi and !builtin.link_libc) { |
| 4269 | 4272 | var new_offset: wasi.filesize_t = undefined; |
| 4270 | 4273 | switch (wasi.fd_seek(fd, 0, wasi.WHENCE_CUR, &new_offset)) { |
| 4271 | wasi.ESUCCESS => return new_offset, | |
| 4272 | wasi.EBADF => unreachable, // always a race condition | |
| 4273 | wasi.EINVAL => return error.Unseekable, | |
| 4274 | wasi.EOVERFLOW => return error.Unseekable, | |
| 4275 | wasi.ESPIPE => return error.Unseekable, | |
| 4276 | wasi.ENXIO => return error.Unseekable, | |
| 4277 | wasi.ENOTCAPABLE => return error.AccessDenied, | |
| 4274 | .SUCCESS => return new_offset, | |
| 4275 | .BADF => unreachable, // always a race condition | |
| 4276 | .INVAL => return error.Unseekable, | |
| 4277 | .OVERFLOW => return error.Unseekable, | |
| 4278 | .SPIPE => return error.Unseekable, | |
| 4279 | .NXIO => return error.Unseekable, | |
| 4280 | .NOTCAPABLE => return error.AccessDenied, | |
| 4278 | 4281 | else => |err| return unexpectedErrno(err), |
| 4279 | 4282 | } |
| 4280 | 4283 | } |
| ... | ... | @@ -4285,12 +4288,12 @@ pub fn lseek_CUR_get(fd: fd_t) SeekError!u64 { |
| 4285 | 4288 | |
| 4286 | 4289 | const rc = lseek_sym(fd, 0, SEEK_CUR); |
| 4287 | 4290 | switch (errno(rc)) { |
| 4288 | 0 => return @bitCast(u64, rc), | |
| 4289 | EBADF => unreachable, // always a race condition | |
| 4290 | EINVAL => return error.Unseekable, | |
| 4291 | EOVERFLOW => return error.Unseekable, | |
| 4292 | ESPIPE => return error.Unseekable, | |
| 4293 | ENXIO => return error.Unseekable, | |
| 4291 | .SUCCESS => return @bitCast(u64, rc), | |
| 4292 | .BADF => unreachable, // always a race condition | |
| 4293 | .INVAL => return error.Unseekable, | |
| 4294 | .OVERFLOW => return error.Unseekable, | |
| 4295 | .SPIPE => return error.Unseekable, | |
| 4296 | .NXIO => return error.Unseekable, | |
| 4294 | 4297 | else => |err| return unexpectedErrno(err), |
| 4295 | 4298 | } |
| 4296 | 4299 | } |
| ... | ... | @@ -4306,15 +4309,15 @@ pub fn fcntl(fd: fd_t, cmd: i32, arg: usize) FcntlError!usize { |
| 4306 | 4309 | while (true) { |
| 4307 | 4310 | const rc = system.fcntl(fd, cmd, arg); |
| 4308 | 4311 | switch (errno(rc)) { |
| 4309 | 0 => return @intCast(usize, rc), | |
| 4310 | EINTR => continue, | |
| 4311 | EACCES => return error.Locked, | |
| 4312 | EBADF => unreachable, | |
| 4313 | EBUSY => return error.FileBusy, | |
| 4314 | EINVAL => unreachable, // invalid parameters | |
| 4315 | EPERM => return error.PermissionDenied, | |
| 4316 | EMFILE => return error.ProcessFdQuotaExceeded, | |
| 4317 | ENOTDIR => unreachable, // invalid parameter | |
| 4312 | .SUCCESS => return @intCast(usize, rc), | |
| 4313 | .INTR => continue, | |
| 4314 | .ACCES => return error.Locked, | |
| 4315 | .BADF => unreachable, | |
| 4316 | .BUSY => return error.FileBusy, | |
| 4317 | .INVAL => unreachable, // invalid parameters | |
| 4318 | .PERM => return error.PermissionDenied, | |
| 4319 | .MFILE => return error.ProcessFdQuotaExceeded, | |
| 4320 | .NOTDIR => unreachable, // invalid parameter | |
| 4318 | 4321 | else => |err| return unexpectedErrno(err), |
| 4319 | 4322 | } |
| 4320 | 4323 | } |
| ... | ... | @@ -4381,12 +4384,12 @@ pub fn flock(fd: fd_t, operation: i32) FlockError!void { |
| 4381 | 4384 | while (true) { |
| 4382 | 4385 | const rc = system.flock(fd, operation); |
| 4383 | 4386 | switch (errno(rc)) { |
| 4384 | 0 => return, | |
| 4385 | EBADF => unreachable, | |
| 4386 | EINTR => continue, | |
| 4387 | EINVAL => unreachable, // invalid parameters | |
| 4388 | ENOLCK => return error.SystemResources, | |
| 4389 | EWOULDBLOCK => return error.WouldBlock, // TODO: integrate with async instead of just returning an error | |
| 4387 | .SUCCESS => return, | |
| 4388 | .BADF => unreachable, | |
| 4389 | .INTR => continue, | |
| 4390 | .INVAL => unreachable, // invalid parameters | |
| 4391 | .NOLCK => return error.SystemResources, | |
| 4392 | .AGAIN => return error.WouldBlock, // TODO: integrate with async instead of just returning an error | |
| 4390 | 4393 | else => |err| return unexpectedErrno(err), |
| 4391 | 4394 | } |
| 4392 | 4395 | } |
| ... | ... | @@ -4456,17 +4459,18 @@ pub fn realpathZ(pathname: [*:0]const u8, out_buffer: *[MAX_PATH_BYTES]u8) RealP |
| 4456 | 4459 | |
| 4457 | 4460 | return getFdPath(fd, out_buffer); |
| 4458 | 4461 | } |
| 4459 | const result_path = std.c.realpath(pathname, out_buffer) orelse switch (std.c._errno().*) { | |
| 4460 | EINVAL => unreachable, | |
| 4461 | EBADF => unreachable, | |
| 4462 | EFAULT => unreachable, | |
| 4463 | EACCES => return error.AccessDenied, | |
| 4464 | ENOENT => return error.FileNotFound, | |
| 4465 | ENOTSUP => return error.NotSupported, | |
| 4466 | ENOTDIR => return error.NotDir, | |
| 4467 | ENAMETOOLONG => return error.NameTooLong, | |
| 4468 | ELOOP => return error.SymLinkLoop, | |
| 4469 | EIO => return error.InputOutput, | |
| 4462 | const result_path = std.c.realpath(pathname, out_buffer) orelse switch (@intToEnum(E, std.c._errno().*)) { | |
| 4463 | .SUCCESS => unreachable, | |
| 4464 | .INVAL => unreachable, | |
| 4465 | .BADF => unreachable, | |
| 4466 | .FAULT => unreachable, | |
| 4467 | .ACCES => return error.AccessDenied, | |
| 4468 | .NOENT => return error.FileNotFound, | |
| 4469 | .OPNOTSUPP => return error.NotSupported, | |
| 4470 | .NOTDIR => return error.NotDir, | |
| 4471 | .NAMETOOLONG => return error.NameTooLong, | |
| 4472 | .LOOP => return error.SymLinkLoop, | |
| 4473 | .IO => return error.InputOutput, | |
| 4470 | 4474 | else => |err| return unexpectedErrno(err), |
| 4471 | 4475 | }; |
| 4472 | 4476 | return mem.spanZ(result_path); |
| ... | ... | @@ -4528,8 +4532,8 @@ pub fn getFdPath(fd: fd_t, out_buffer: *[MAX_PATH_BYTES]u8) RealPathError![]u8 { |
| 4528 | 4532 | // the path to the file descriptor. |
| 4529 | 4533 | @memset(out_buffer, 0, MAX_PATH_BYTES); |
| 4530 | 4534 | switch (errno(system.fcntl(fd, F_GETPATH, out_buffer))) { |
| 4531 | 0 => {}, | |
| 4532 | EBADF => return error.FileNotFound, | |
| 4535 | .SUCCESS => {}, | |
| 4536 | .BADF => return error.FileNotFound, | |
| 4533 | 4537 | // TODO man pages for fcntl on macOS don't really tell you what |
| 4534 | 4538 | // errno values to expect when command is F_GETPATH... |
| 4535 | 4539 | else => |err| return unexpectedErrno(err), |
| ... | ... | @@ -4562,13 +4566,13 @@ pub fn nanosleep(seconds: u64, nanoseconds: u64) void { |
| 4562 | 4566 | var rem: timespec = undefined; |
| 4563 | 4567 | while (true) { |
| 4564 | 4568 | switch (errno(system.nanosleep(&req, &rem))) { |
| 4565 | EFAULT => unreachable, | |
| 4566 | EINVAL => { | |
| 4569 | .FAULT => unreachable, | |
| 4570 | .INVAL => { | |
| 4567 | 4571 | // Sometimes Darwin returns EINVAL for no reason. |
| 4568 | 4572 | // We treat it as a spurious wakeup. |
| 4569 | 4573 | return; |
| 4570 | 4574 | }, |
| 4571 | EINTR => { | |
| 4575 | .INTR => { | |
| 4572 | 4576 | req = rem; |
| 4573 | 4577 | continue; |
| 4574 | 4578 | }, |
| ... | ... | @@ -4668,13 +4672,13 @@ pub fn clock_gettime(clk_id: i32, tp: *timespec) ClockGetTimeError!void { |
| 4668 | 4672 | if (std.Target.current.os.tag == .wasi and !builtin.link_libc) { |
| 4669 | 4673 | var ts: timestamp_t = undefined; |
| 4670 | 4674 | switch (system.clock_time_get(@bitCast(u32, clk_id), 1, &ts)) { |
| 4671 | 0 => { | |
| 4675 | .SUCCESS => { | |
| 4672 | 4676 | tp.* = .{ |
| 4673 | 4677 | .tv_sec = @intCast(i64, ts / std.time.ns_per_s), |
| 4674 | 4678 | .tv_nsec = @intCast(isize, ts % std.time.ns_per_s), |
| 4675 | 4679 | }; |
| 4676 | 4680 | }, |
| 4677 | EINVAL => return error.UnsupportedClock, | |
| 4681 | .INVAL => return error.UnsupportedClock, | |
| 4678 | 4682 | else => |err| return unexpectedErrno(err), |
| 4679 | 4683 | } |
| 4680 | 4684 | return; |
| ... | ... | @@ -4698,9 +4702,9 @@ pub fn clock_gettime(clk_id: i32, tp: *timespec) ClockGetTimeError!void { |
| 4698 | 4702 | } |
| 4699 | 4703 | |
| 4700 | 4704 | switch (errno(system.clock_gettime(clk_id, tp))) { |
| 4701 | 0 => return, | |
| 4702 | EFAULT => unreachable, | |
| 4703 | EINVAL => return error.UnsupportedClock, | |
| 4705 | .SUCCESS => return, | |
| 4706 | .FAULT => unreachable, | |
| 4707 | .INVAL => return error.UnsupportedClock, | |
| 4704 | 4708 | else => |err| return unexpectedErrno(err), |
| 4705 | 4709 | } |
| 4706 | 4710 | } |
| ... | ... | @@ -4709,20 +4713,20 @@ pub fn clock_getres(clk_id: i32, res: *timespec) ClockGetTimeError!void { |
| 4709 | 4713 | if (std.Target.current.os.tag == .wasi and !builtin.link_libc) { |
| 4710 | 4714 | var ts: timestamp_t = undefined; |
| 4711 | 4715 | switch (system.clock_res_get(@bitCast(u32, clk_id), &ts)) { |
| 4712 | 0 => res.* = .{ | |
| 4716 | .SUCCESS => res.* = .{ | |
| 4713 | 4717 | .tv_sec = @intCast(i64, ts / std.time.ns_per_s), |
| 4714 | 4718 | .tv_nsec = @intCast(isize, ts % std.time.ns_per_s), |
| 4715 | 4719 | }, |
| 4716 | EINVAL => return error.UnsupportedClock, | |
| 4720 | .INVAL => return error.UnsupportedClock, | |
| 4717 | 4721 | else => |err| return unexpectedErrno(err), |
| 4718 | 4722 | } |
| 4719 | 4723 | return; |
| 4720 | 4724 | } |
| 4721 | 4725 | |
| 4722 | 4726 | switch (errno(system.clock_getres(clk_id, res))) { |
| 4723 | 0 => return, | |
| 4724 | EFAULT => unreachable, | |
| 4725 | EINVAL => return error.UnsupportedClock, | |
| 4727 | .SUCCESS => return, | |
| 4728 | .FAULT => unreachable, | |
| 4729 | .INVAL => return error.UnsupportedClock, | |
| 4726 | 4730 | else => |err| return unexpectedErrno(err), |
| 4727 | 4731 | } |
| 4728 | 4732 | } |
| ... | ... | @@ -4732,11 +4736,11 @@ pub const SchedGetAffinityError = error{PermissionDenied} || UnexpectedError; |
| 4732 | 4736 | pub fn sched_getaffinity(pid: pid_t) SchedGetAffinityError!cpu_set_t { |
| 4733 | 4737 | var set: cpu_set_t = undefined; |
| 4734 | 4738 | switch (errno(system.sched_getaffinity(pid, @sizeOf(cpu_set_t), &set))) { |
| 4735 | 0 => return set, | |
| 4736 | EFAULT => unreachable, | |
| 4737 | EINVAL => unreachable, | |
| 4738 | ESRCH => unreachable, | |
| 4739 | EPERM => return error.PermissionDenied, | |
| 4739 | .SUCCESS => return set, | |
| 4740 | .FAULT => unreachable, | |
| 4741 | .INVAL => unreachable, | |
| 4742 | .SRCH => unreachable, | |
| 4743 | .PERM => return error.PermissionDenied, | |
| 4740 | 4744 | else => |err| return unexpectedErrno(err), |
| 4741 | 4745 | } |
| 4742 | 4746 | } |
| ... | ... | @@ -4768,13 +4772,9 @@ pub const UnexpectedError = error{ |
| 4768 | 4772 | |
| 4769 | 4773 | /// Call this when you made a syscall or something that sets errno |
| 4770 | 4774 | /// and you get an unexpected error. |
| 4771 | pub fn unexpectedErrno(err: anytype) UnexpectedError { | |
| 4772 | if (@typeInfo(@TypeOf(err)) != .Int) { | |
| 4773 | @compileError("err is expected to be an integer"); | |
| 4774 | } | |
| 4775 | ||
| 4775 | pub fn unexpectedErrno(err: E) UnexpectedError { | |
| 4776 | 4776 | if (unexpected_error_tracing) { |
| 4777 | std.debug.warn("unexpected errno: {d}\n", .{err}); | |
| 4777 | std.debug.warn("unexpected errno: {d}\n", .{@enumToInt(err)}); | |
| 4778 | 4778 | std.debug.dumpCurrentStackTrace(null); |
| 4779 | 4779 | } |
| 4780 | 4780 | return error.Unexpected; |
| ... | ... | @@ -4790,11 +4790,11 @@ pub const SigaltstackError = error{ |
| 4790 | 4790 | |
| 4791 | 4791 | pub fn sigaltstack(ss: ?*stack_t, old_ss: ?*stack_t) SigaltstackError!void { |
| 4792 | 4792 | switch (errno(system.sigaltstack(ss, old_ss))) { |
| 4793 | 0 => return, | |
| 4794 | EFAULT => unreachable, | |
| 4795 | EINVAL => unreachable, | |
| 4796 | ENOMEM => return error.SizeTooSmall, | |
| 4797 | EPERM => return error.PermissionDenied, | |
| 4793 | .SUCCESS => return, | |
| 4794 | .FAULT => unreachable, | |
| 4795 | .INVAL => unreachable, | |
| 4796 | .NOMEM => return error.SizeTooSmall, | |
| 4797 | .PERM => return error.PermissionDenied, | |
| 4798 | 4798 | else => |err| return unexpectedErrno(err), |
| 4799 | 4799 | } |
| 4800 | 4800 | } |
| ... | ... | @@ -4802,9 +4802,9 @@ pub fn sigaltstack(ss: ?*stack_t, old_ss: ?*stack_t) SigaltstackError!void { |
| 4802 | 4802 | /// Examine and change a signal action. |
| 4803 | 4803 | pub fn sigaction(sig: u6, act: ?*const Sigaction, oact: ?*Sigaction) void { |
| 4804 | 4804 | switch (errno(system.sigaction(sig, act, oact))) { |
| 4805 | 0 => return, | |
| 4806 | EFAULT => unreachable, | |
| 4807 | EINVAL => unreachable, | |
| 4805 | .SUCCESS => return, | |
| 4806 | .FAULT => unreachable, | |
| 4807 | .INVAL => unreachable, | |
| 4808 | 4808 | else => unreachable, |
| 4809 | 4809 | } |
| 4810 | 4810 | } |
| ... | ... | @@ -4841,25 +4841,25 @@ pub fn futimens(fd: fd_t, times: *const [2]timespec) FutimensError!void { |
| 4841 | 4841 | const atim = times[0].toTimestamp(); |
| 4842 | 4842 | const mtim = times[1].toTimestamp(); |
| 4843 | 4843 | switch (wasi.fd_filestat_set_times(fd, atim, mtim, wasi.FILESTAT_SET_ATIM | wasi.FILESTAT_SET_MTIM)) { |
| 4844 | wasi.ESUCCESS => return, | |
| 4845 | wasi.EACCES => return error.AccessDenied, | |
| 4846 | wasi.EPERM => return error.PermissionDenied, | |
| 4847 | wasi.EBADF => unreachable, // always a race condition | |
| 4848 | wasi.EFAULT => unreachable, | |
| 4849 | wasi.EINVAL => unreachable, | |
| 4850 | wasi.EROFS => return error.ReadOnlyFileSystem, | |
| 4844 | .SUCCESS => return, | |
| 4845 | .ACCES => return error.AccessDenied, | |
| 4846 | .PERM => return error.PermissionDenied, | |
| 4847 | .BADF => unreachable, // always a race condition | |
| 4848 | .FAULT => unreachable, | |
| 4849 | .INVAL => unreachable, | |
| 4850 | .ROFS => return error.ReadOnlyFileSystem, | |
| 4851 | 4851 | else => |err| return unexpectedErrno(err), |
| 4852 | 4852 | } |
| 4853 | 4853 | } |
| 4854 | 4854 | |
| 4855 | 4855 | switch (errno(system.futimens(fd, times))) { |
| 4856 | 0 => return, | |
| 4857 | EACCES => return error.AccessDenied, | |
| 4858 | EPERM => return error.PermissionDenied, | |
| 4859 | EBADF => unreachable, // always a race condition | |
| 4860 | EFAULT => unreachable, | |
| 4861 | EINVAL => unreachable, | |
| 4862 | EROFS => return error.ReadOnlyFileSystem, | |
| 4856 | .SUCCESS => return, | |
| 4857 | .ACCES => return error.AccessDenied, | |
| 4858 | .PERM => return error.PermissionDenied, | |
| 4859 | .BADF => unreachable, // always a race condition | |
| 4860 | .FAULT => unreachable, | |
| 4861 | .INVAL => unreachable, | |
| 4862 | .ROFS => return error.ReadOnlyFileSystem, | |
| 4863 | 4863 | else => |err| return unexpectedErrno(err), |
| 4864 | 4864 | } |
| 4865 | 4865 | } |
| ... | ... | @@ -4869,10 +4869,10 @@ pub const GetHostNameError = error{PermissionDenied} || UnexpectedError; |
| 4869 | 4869 | pub fn gethostname(name_buffer: *[HOST_NAME_MAX]u8) GetHostNameError![]u8 { |
| 4870 | 4870 | if (builtin.link_libc) { |
| 4871 | 4871 | switch (errno(system.gethostname(name_buffer, name_buffer.len))) { |
| 4872 | 0 => return mem.spanZ(std.meta.assumeSentinel(name_buffer, 0)), | |
| 4873 | EFAULT => unreachable, | |
| 4874 | ENAMETOOLONG => unreachable, // HOST_NAME_MAX prevents this | |
| 4875 | EPERM => return error.PermissionDenied, | |
| 4872 | .SUCCESS => return mem.spanZ(std.meta.assumeSentinel(name_buffer, 0)), | |
| 4873 | .FAULT => unreachable, | |
| 4874 | .NAMETOOLONG => unreachable, // HOST_NAME_MAX prevents this | |
| 4875 | .PERM => return error.PermissionDenied, | |
| 4876 | 4876 | else => |err| return unexpectedErrno(err), |
| 4877 | 4877 | } |
| 4878 | 4878 | } |
| ... | ... | @@ -4889,8 +4889,8 @@ pub fn gethostname(name_buffer: *[HOST_NAME_MAX]u8) GetHostNameError![]u8 { |
| 4889 | 4889 | pub fn uname() utsname { |
| 4890 | 4890 | var uts: utsname = undefined; |
| 4891 | 4891 | switch (errno(system.uname(&uts))) { |
| 4892 | 0 => return uts, | |
| 4893 | EFAULT => unreachable, | |
| 4892 | .SUCCESS => return uts, | |
| 4893 | .FAULT => unreachable, | |
| 4894 | 4894 | else => unreachable, |
| 4895 | 4895 | } |
| 4896 | 4896 | } |
| ... | ... | @@ -5049,33 +5049,33 @@ pub fn sendmsg( |
| 5049 | 5049 | } |
| 5050 | 5050 | } else { |
| 5051 | 5051 | switch (errno(rc)) { |
| 5052 | 0 => return @intCast(usize, rc), | |
| 5053 | ||
| 5054 | EACCES => return error.AccessDenied, | |
| 5055 | EAGAIN => return error.WouldBlock, | |
| 5056 | EALREADY => return error.FastOpenAlreadyInProgress, | |
| 5057 | EBADF => unreachable, // always a race condition | |
| 5058 | ECONNRESET => return error.ConnectionResetByPeer, | |
| 5059 | EDESTADDRREQ => unreachable, // The socket is not connection-mode, and no peer address is set. | |
| 5060 | EFAULT => unreachable, // An invalid user space address was specified for an argument. | |
| 5061 | EINTR => continue, | |
| 5062 | EINVAL => unreachable, // Invalid argument passed. | |
| 5063 | EISCONN => unreachable, // connection-mode socket was connected already but a recipient was specified | |
| 5064 | EMSGSIZE => return error.MessageTooBig, | |
| 5065 | ENOBUFS => return error.SystemResources, | |
| 5066 | ENOMEM => return error.SystemResources, | |
| 5067 | ENOTSOCK => unreachable, // The file descriptor sockfd does not refer to a socket. | |
| 5068 | EOPNOTSUPP => unreachable, // Some bit in the flags argument is inappropriate for the socket type. | |
| 5069 | EPIPE => return error.BrokenPipe, | |
| 5070 | EAFNOSUPPORT => return error.AddressFamilyNotSupported, | |
| 5071 | ELOOP => return error.SymLinkLoop, | |
| 5072 | ENAMETOOLONG => return error.NameTooLong, | |
| 5073 | ENOENT => return error.FileNotFound, | |
| 5074 | ENOTDIR => return error.NotDir, | |
| 5075 | EHOSTUNREACH => return error.NetworkUnreachable, | |
| 5076 | ENETUNREACH => return error.NetworkUnreachable, | |
| 5077 | ENOTCONN => return error.SocketNotConnected, | |
| 5078 | ENETDOWN => return error.NetworkSubsystemFailed, | |
| 5052 | .SUCCESS => return @intCast(usize, rc), | |
| 5053 | ||
| 5054 | .ACCES => return error.AccessDenied, | |
| 5055 | .AGAIN => return error.WouldBlock, | |
| 5056 | .ALREADY => return error.FastOpenAlreadyInProgress, | |
| 5057 | .BADF => unreachable, // always a race condition | |
| 5058 | .CONNRESET => return error.ConnectionResetByPeer, | |
| 5059 | .DESTADDRREQ => unreachable, // The socket is not connection-mode, and no peer address is set. | |
| 5060 | .FAULT => unreachable, // An invalid user space address was specified for an argument. | |
| 5061 | .INTR => continue, | |
| 5062 | .INVAL => unreachable, // Invalid argument passed. | |
| 5063 | .ISCONN => unreachable, // connection-mode socket was connected already but a recipient was specified | |
| 5064 | .MSGSIZE => return error.MessageTooBig, | |
| 5065 | .NOBUFS => return error.SystemResources, | |
| 5066 | .NOMEM => return error.SystemResources, | |
| 5067 | .NOTSOCK => unreachable, // The file descriptor sockfd does not refer to a socket. | |
| 5068 | .OPNOTSUPP => unreachable, // Some bit in the flags argument is inappropriate for the socket type. | |
| 5069 | .PIPE => return error.BrokenPipe, | |
| 5070 | .AFNOSUPPORT => return error.AddressFamilyNotSupported, | |
| 5071 | .LOOP => return error.SymLinkLoop, | |
| 5072 | .NAMETOOLONG => return error.NameTooLong, | |
| 5073 | .NOENT => return error.FileNotFound, | |
| 5074 | .NOTDIR => return error.NotDir, | |
| 5075 | .HOSTUNREACH => return error.NetworkUnreachable, | |
| 5076 | .NETUNREACH => return error.NetworkUnreachable, | |
| 5077 | .NOTCONN => return error.SocketNotConnected, | |
| 5078 | .NETDOWN => return error.NetworkSubsystemFailed, | |
| 5079 | 5079 | else => |err| return unexpectedErrno(err), |
| 5080 | 5080 | } |
| 5081 | 5081 | } |
| ... | ... | @@ -5149,33 +5149,33 @@ pub fn sendto( |
| 5149 | 5149 | } |
| 5150 | 5150 | } else { |
| 5151 | 5151 | switch (errno(rc)) { |
| 5152 | 0 => return @intCast(usize, rc), | |
| 5153 | ||
| 5154 | EACCES => return error.AccessDenied, | |
| 5155 | EAGAIN => return error.WouldBlock, | |
| 5156 | EALREADY => return error.FastOpenAlreadyInProgress, | |
| 5157 | EBADF => unreachable, // always a race condition | |
| 5158 | ECONNRESET => return error.ConnectionResetByPeer, | |
| 5159 | EDESTADDRREQ => unreachable, // The socket is not connection-mode, and no peer address is set. | |
| 5160 | EFAULT => unreachable, // An invalid user space address was specified for an argument. | |
| 5161 | EINTR => continue, | |
| 5162 | EINVAL => unreachable, // Invalid argument passed. | |
| 5163 | EISCONN => unreachable, // connection-mode socket was connected already but a recipient was specified | |
| 5164 | EMSGSIZE => return error.MessageTooBig, | |
| 5165 | ENOBUFS => return error.SystemResources, | |
| 5166 | ENOMEM => return error.SystemResources, | |
| 5167 | ENOTSOCK => unreachable, // The file descriptor sockfd does not refer to a socket. | |
| 5168 | EOPNOTSUPP => unreachable, // Some bit in the flags argument is inappropriate for the socket type. | |
| 5169 | EPIPE => return error.BrokenPipe, | |
| 5170 | EAFNOSUPPORT => return error.AddressFamilyNotSupported, | |
| 5171 | ELOOP => return error.SymLinkLoop, | |
| 5172 | ENAMETOOLONG => return error.NameTooLong, | |
| 5173 | ENOENT => return error.FileNotFound, | |
| 5174 | ENOTDIR => return error.NotDir, | |
| 5175 | EHOSTUNREACH => return error.NetworkUnreachable, | |
| 5176 | ENETUNREACH => return error.NetworkUnreachable, | |
| 5177 | ENOTCONN => return error.SocketNotConnected, | |
| 5178 | ENETDOWN => return error.NetworkSubsystemFailed, | |
| 5152 | .SUCCESS => return @intCast(usize, rc), | |
| 5153 | ||
| 5154 | .ACCES => return error.AccessDenied, | |
| 5155 | .AGAIN => return error.WouldBlock, | |
| 5156 | .ALREADY => return error.FastOpenAlreadyInProgress, | |
| 5157 | .BADF => unreachable, // always a race condition | |
| 5158 | .CONNRESET => return error.ConnectionResetByPeer, | |
| 5159 | .DESTADDRREQ => unreachable, // The socket is not connection-mode, and no peer address is set. | |
| 5160 | .FAULT => unreachable, // An invalid user space address was specified for an argument. | |
| 5161 | .INTR => continue, | |
| 5162 | .INVAL => unreachable, // Invalid argument passed. | |
| 5163 | .ISCONN => unreachable, // connection-mode socket was connected already but a recipient was specified | |
| 5164 | .MSGSIZE => return error.MessageTooBig, | |
| 5165 | .NOBUFS => return error.SystemResources, | |
| 5166 | .NOMEM => return error.SystemResources, | |
| 5167 | .NOTSOCK => unreachable, // The file descriptor sockfd does not refer to a socket. | |
| 5168 | .OPNOTSUPP => unreachable, // Some bit in the flags argument is inappropriate for the socket type. | |
| 5169 | .PIPE => return error.BrokenPipe, | |
| 5170 | .AFNOSUPPORT => return error.AddressFamilyNotSupported, | |
| 5171 | .LOOP => return error.SymLinkLoop, | |
| 5172 | .NAMETOOLONG => return error.NameTooLong, | |
| 5173 | .NOENT => return error.FileNotFound, | |
| 5174 | .NOTDIR => return error.NotDir, | |
| 5175 | .HOSTUNREACH => return error.NetworkUnreachable, | |
| 5176 | .NETUNREACH => return error.NetworkUnreachable, | |
| 5177 | .NOTCONN => return error.SocketNotConnected, | |
| 5178 | .NETDOWN => return error.NetworkSubsystemFailed, | |
| 5179 | 5179 | else => |err| return unexpectedErrno(err), |
| 5180 | 5180 | } |
| 5181 | 5181 | } |
| ... | ... | @@ -5312,7 +5312,7 @@ pub fn sendfile( |
| 5312 | 5312 | var offset: off_t = @bitCast(off_t, in_offset); |
| 5313 | 5313 | const rc = sendfile_sym(out_fd, in_fd, &offset, adjusted_count); |
| 5314 | 5314 | switch (errno(rc)) { |
| 5315 | 0 => { | |
| 5315 | .SUCCESS => { | |
| 5316 | 5316 | const amt = @bitCast(usize, rc); |
| 5317 | 5317 | total_written += amt; |
| 5318 | 5318 | if (in_len == 0 and amt == 0) { |
| ... | ... | @@ -5325,12 +5325,12 @@ pub fn sendfile( |
| 5325 | 5325 | } |
| 5326 | 5326 | }, |
| 5327 | 5327 | |
| 5328 | EBADF => unreachable, // Always a race condition. | |
| 5329 | EFAULT => unreachable, // Segmentation fault. | |
| 5330 | EOVERFLOW => unreachable, // We avoid passing too large of a `count`. | |
| 5331 | ENOTCONN => unreachable, // `out_fd` is an unconnected socket. | |
| 5328 | .BADF => unreachable, // Always a race condition. | |
| 5329 | .FAULT => unreachable, // Segmentation fault. | |
| 5330 | .OVERFLOW => unreachable, // We avoid passing too large of a `count`. | |
| 5331 | .NOTCONN => unreachable, // `out_fd` is an unconnected socket. | |
| 5332 | 5332 | |
| 5333 | EINVAL, ENOSYS => { | |
| 5333 | .INVAL, .NOSYS => { | |
| 5334 | 5334 | // EINVAL could be any of the following situations: |
| 5335 | 5335 | // * Descriptor is not valid or locked |
| 5336 | 5336 | // * an mmap(2)-like operation is not available for in_fd |
| ... | ... | @@ -5340,17 +5340,17 @@ pub fn sendfile( |
| 5340 | 5340 | // manually, the same as ENOSYS. |
| 5341 | 5341 | break :sf; |
| 5342 | 5342 | }, |
| 5343 | EAGAIN => if (std.event.Loop.instance) |loop| { | |
| 5343 | .AGAIN => if (std.event.Loop.instance) |loop| { | |
| 5344 | 5344 | loop.waitUntilFdWritable(out_fd); |
| 5345 | 5345 | continue; |
| 5346 | 5346 | } else { |
| 5347 | 5347 | return error.WouldBlock; |
| 5348 | 5348 | }, |
| 5349 | EIO => return error.InputOutput, | |
| 5350 | EPIPE => return error.BrokenPipe, | |
| 5351 | ENOMEM => return error.SystemResources, | |
| 5352 | ENXIO => return error.Unseekable, | |
| 5353 | ESPIPE => return error.Unseekable, | |
| 5349 | .IO => return error.InputOutput, | |
| 5350 | .PIPE => return error.BrokenPipe, | |
| 5351 | .NOMEM => return error.SystemResources, | |
| 5352 | .NXIO => return error.Unseekable, | |
| 5353 | .SPIPE => return error.Unseekable, | |
| 5354 | 5354 | else => |err| { |
| 5355 | 5355 | unexpectedErrno(err) catch {}; |
| 5356 | 5356 | break :sf; |
| ... | ... | @@ -5392,13 +5392,13 @@ pub fn sendfile( |
| 5392 | 5392 | const err = errno(system.sendfile(in_fd, out_fd, offset, adjusted_count, hdtr, &sbytes, flags)); |
| 5393 | 5393 | const amt = @bitCast(usize, sbytes); |
| 5394 | 5394 | switch (err) { |
| 5395 | 0 => return amt, | |
| 5395 | .SUCCESS => return amt, | |
| 5396 | 5396 | |
| 5397 | EBADF => unreachable, // Always a race condition. | |
| 5398 | EFAULT => unreachable, // Segmentation fault. | |
| 5399 | ENOTCONN => unreachable, // `out_fd` is an unconnected socket. | |
| 5397 | .BADF => unreachable, // Always a race condition. | |
| 5398 | .FAULT => unreachable, // Segmentation fault. | |
| 5399 | .NOTCONN => unreachable, // `out_fd` is an unconnected socket. | |
| 5400 | 5400 | |
| 5401 | EINVAL, EOPNOTSUPP, ENOTSOCK, ENOSYS => { | |
| 5401 | .INVAL, .OPNOTSUPP, .NOTSOCK, .NOSYS => { | |
| 5402 | 5402 | // EINVAL could be any of the following situations: |
| 5403 | 5403 | // * The fd argument is not a regular file. |
| 5404 | 5404 | // * The s argument is not a SOCK_STREAM type socket. |
| ... | ... | @@ -5408,9 +5408,9 @@ pub fn sendfile( |
| 5408 | 5408 | break :sf; |
| 5409 | 5409 | }, |
| 5410 | 5410 | |
| 5411 | EINTR => if (amt != 0) return amt else continue, | |
| 5411 | .INTR => if (amt != 0) return amt else continue, | |
| 5412 | 5412 | |
| 5413 | EAGAIN => if (amt != 0) { | |
| 5413 | .AGAIN => if (amt != 0) { | |
| 5414 | 5414 | return amt; |
| 5415 | 5415 | } else if (std.event.Loop.instance) |loop| { |
| 5416 | 5416 | loop.waitUntilFdWritable(out_fd); |
| ... | ... | @@ -5419,7 +5419,7 @@ pub fn sendfile( |
| 5419 | 5419 | return error.WouldBlock; |
| 5420 | 5420 | }, |
| 5421 | 5421 | |
| 5422 | EBUSY => if (amt != 0) { | |
| 5422 | .BUSY => if (amt != 0) { | |
| 5423 | 5423 | return amt; |
| 5424 | 5424 | } else if (std.event.Loop.instance) |loop| { |
| 5425 | 5425 | loop.waitUntilFdReadable(in_fd); |
| ... | ... | @@ -5428,9 +5428,9 @@ pub fn sendfile( |
| 5428 | 5428 | return error.WouldBlock; |
| 5429 | 5429 | }, |
| 5430 | 5430 | |
| 5431 | EIO => return error.InputOutput, | |
| 5432 | ENOBUFS => return error.SystemResources, | |
| 5433 | EPIPE => return error.BrokenPipe, | |
| 5431 | .IO => return error.InputOutput, | |
| 5432 | .NOBUFS => return error.SystemResources, | |
| 5433 | .PIPE => return error.BrokenPipe, | |
| 5434 | 5434 | |
| 5435 | 5435 | else => { |
| 5436 | 5436 | unexpectedErrno(err) catch {}; |
| ... | ... | @@ -5471,18 +5471,18 @@ pub fn sendfile( |
| 5471 | 5471 | const err = errno(system.sendfile(in_fd, out_fd, signed_offset, &sbytes, hdtr, flags)); |
| 5472 | 5472 | const amt = @bitCast(usize, sbytes); |
| 5473 | 5473 | switch (err) { |
| 5474 | 0 => return amt, | |
| 5474 | .SUCCESS => return amt, | |
| 5475 | 5475 | |
| 5476 | EBADF => unreachable, // Always a race condition. | |
| 5477 | EFAULT => unreachable, // Segmentation fault. | |
| 5478 | EINVAL => unreachable, | |
| 5479 | ENOTCONN => unreachable, // `out_fd` is an unconnected socket. | |
| 5476 | .BADF => unreachable, // Always a race condition. | |
| 5477 | .FAULT => unreachable, // Segmentation fault. | |
| 5478 | .INVAL => unreachable, | |
| 5479 | .NOTCONN => unreachable, // `out_fd` is an unconnected socket. | |
| 5480 | 5480 | |
| 5481 | ENOTSUP, ENOTSOCK, ENOSYS => break :sf, | |
| 5481 | .OPNOTSUPP, .NOTSOCK, .NOSYS => break :sf, | |
| 5482 | 5482 | |
| 5483 | EINTR => if (amt != 0) return amt else continue, | |
| 5483 | .INTR => if (amt != 0) return amt else continue, | |
| 5484 | 5484 | |
| 5485 | EAGAIN => if (amt != 0) { | |
| 5485 | .AGAIN => if (amt != 0) { | |
| 5486 | 5486 | return amt; |
| 5487 | 5487 | } else if (std.event.Loop.instance) |loop| { |
| 5488 | 5488 | loop.waitUntilFdWritable(out_fd); |
| ... | ... | @@ -5491,8 +5491,8 @@ pub fn sendfile( |
| 5491 | 5491 | return error.WouldBlock; |
| 5492 | 5492 | }, |
| 5493 | 5493 | |
| 5494 | EIO => return error.InputOutput, | |
| 5495 | EPIPE => return error.BrokenPipe, | |
| 5494 | .IO => return error.InputOutput, | |
| 5495 | .PIPE => return error.BrokenPipe, | |
| 5496 | 5496 | |
| 5497 | 5497 | else => { |
| 5498 | 5498 | unexpectedErrno(err) catch {}; |
| ... | ... | @@ -5595,22 +5595,22 @@ pub fn copy_file_range(fd_in: fd_t, off_in: u64, fd_out: fd_t, off_out: u64, len |
| 5595 | 5595 | |
| 5596 | 5596 | const rc = system.copy_file_range(fd_in, &off_in_copy, fd_out, &off_out_copy, len, flags); |
| 5597 | 5597 | switch (system.getErrno(rc)) { |
| 5598 | 0 => return @intCast(usize, rc), | |
| 5599 | EBADF => return error.FilesOpenedWithWrongFlags, | |
| 5600 | EFBIG => return error.FileTooBig, | |
| 5601 | EIO => return error.InputOutput, | |
| 5602 | EISDIR => return error.IsDir, | |
| 5603 | ENOMEM => return error.OutOfMemory, | |
| 5604 | ENOSPC => return error.NoSpaceLeft, | |
| 5605 | EOVERFLOW => return error.Unseekable, | |
| 5606 | EPERM => return error.PermissionDenied, | |
| 5607 | ETXTBSY => return error.FileBusy, | |
| 5598 | .SUCCESS => return @intCast(usize, rc), | |
| 5599 | .BADF => return error.FilesOpenedWithWrongFlags, | |
| 5600 | .FBIG => return error.FileTooBig, | |
| 5601 | .IO => return error.InputOutput, | |
| 5602 | .ISDIR => return error.IsDir, | |
| 5603 | .NOMEM => return error.OutOfMemory, | |
| 5604 | .NOSPC => return error.NoSpaceLeft, | |
| 5605 | .OVERFLOW => return error.Unseekable, | |
| 5606 | .PERM => return error.PermissionDenied, | |
| 5607 | .TXTBSY => return error.FileBusy, | |
| 5608 | 5608 | // these may not be regular files, try fallback |
| 5609 | EINVAL => {}, | |
| 5609 | .INVAL => {}, | |
| 5610 | 5610 | // support for cross-filesystem copy added in Linux 5.3, use fallback |
| 5611 | EXDEV => {}, | |
| 5611 | .XDEV => {}, | |
| 5612 | 5612 | // syscall added in Linux 4.5, use fallback |
| 5613 | ENOSYS => { | |
| 5613 | .NOSYS => { | |
| 5614 | 5614 | has_copy_file_range_syscall.store(false, .Monotonic); |
| 5615 | 5615 | }, |
| 5616 | 5616 | else => |err| return unexpectedErrno(err), |
| ... | ... | @@ -5652,11 +5652,11 @@ pub fn poll(fds: []pollfd, timeout: i32) PollError!usize { |
| 5652 | 5652 | } |
| 5653 | 5653 | } else { |
| 5654 | 5654 | switch (errno(rc)) { |
| 5655 | 0 => return @intCast(usize, rc), | |
| 5656 | EFAULT => unreachable, | |
| 5657 | EINTR => continue, | |
| 5658 | EINVAL => unreachable, | |
| 5659 | ENOMEM => return error.SystemResources, | |
| 5655 | .SUCCESS => return @intCast(usize, rc), | |
| 5656 | .FAULT => unreachable, | |
| 5657 | .INTR => continue, | |
| 5658 | .INVAL => unreachable, | |
| 5659 | .NOMEM => return error.SystemResources, | |
| 5660 | 5660 | else => |err| return unexpectedErrno(err), |
| 5661 | 5661 | } |
| 5662 | 5662 | } |
| ... | ... | @@ -5681,11 +5681,11 @@ pub fn ppoll(fds: []pollfd, timeout: ?*const timespec, mask: ?*const sigset_t) P |
| 5681 | 5681 | } |
| 5682 | 5682 | const rc = system.ppoll(fds.ptr, fds.len, ts_ptr, mask); |
| 5683 | 5683 | switch (errno(rc)) { |
| 5684 | 0 => return @intCast(usize, rc), | |
| 5685 | EFAULT => unreachable, | |
| 5686 | EINTR => return error.SignalInterrupt, | |
| 5687 | EINVAL => unreachable, | |
| 5688 | ENOMEM => return error.SystemResources, | |
| 5684 | .SUCCESS => return @intCast(usize, rc), | |
| 5685 | .FAULT => unreachable, | |
| 5686 | .INTR => return error.SignalInterrupt, | |
| 5687 | .INVAL => unreachable, | |
| 5688 | .NOMEM => return error.SystemResources, | |
| 5689 | 5689 | else => |err| return unexpectedErrno(err), |
| 5690 | 5690 | } |
| 5691 | 5691 | } |
| ... | ... | @@ -5750,17 +5750,17 @@ pub fn recvfrom( |
| 5750 | 5750 | } |
| 5751 | 5751 | } else { |
| 5752 | 5752 | switch (errno(rc)) { |
| 5753 | 0 => return @intCast(usize, rc), | |
| 5754 | EBADF => unreachable, // always a race condition | |
| 5755 | EFAULT => unreachable, | |
| 5756 | EINVAL => unreachable, | |
| 5757 | ENOTCONN => unreachable, | |
| 5758 | ENOTSOCK => unreachable, | |
| 5759 | EINTR => continue, | |
| 5760 | EAGAIN => return error.WouldBlock, | |
| 5761 | ENOMEM => return error.SystemResources, | |
| 5762 | ECONNREFUSED => return error.ConnectionRefused, | |
| 5763 | ECONNRESET => return error.ConnectionResetByPeer, | |
| 5753 | .SUCCESS => return @intCast(usize, rc), | |
| 5754 | .BADF => unreachable, // always a race condition | |
| 5755 | .FAULT => unreachable, | |
| 5756 | .INVAL => unreachable, | |
| 5757 | .NOTCONN => unreachable, | |
| 5758 | .NOTSOCK => unreachable, | |
| 5759 | .INTR => continue, | |
| 5760 | .AGAIN => return error.WouldBlock, | |
| 5761 | .NOMEM => return error.SystemResources, | |
| 5762 | .CONNREFUSED => return error.ConnectionRefused, | |
| 5763 | .CONNRESET => return error.ConnectionResetByPeer, | |
| 5764 | 5764 | else => |err| return unexpectedErrno(err), |
| 5765 | 5765 | } |
| 5766 | 5766 | } |
| ... | ... | @@ -5830,8 +5830,8 @@ pub fn sched_yield() SchedYieldError!void { |
| 5830 | 5830 | return; |
| 5831 | 5831 | } |
| 5832 | 5832 | switch (errno(system.sched_yield())) { |
| 5833 | 0 => return, | |
| 5834 | ENOSYS => return error.SystemCannotYield, | |
| 5833 | .SUCCESS => return, | |
| 5834 | .NOSYS => return error.SystemCannotYield, | |
| 5835 | 5835 | else => return error.SystemCannotYield, |
| 5836 | 5836 | } |
| 5837 | 5837 | } |
| ... | ... | @@ -5874,17 +5874,17 @@ pub fn setsockopt(fd: socket_t, level: u32, optname: u32, opt: []const u8) SetSo |
| 5874 | 5874 | return; |
| 5875 | 5875 | } else { |
| 5876 | 5876 | switch (errno(system.setsockopt(fd, level, optname, opt.ptr, @intCast(socklen_t, opt.len)))) { |
| 5877 | 0 => {}, | |
| 5878 | EBADF => unreachable, // always a race condition | |
| 5879 | ENOTSOCK => unreachable, // always a race condition | |
| 5880 | EINVAL => unreachable, | |
| 5881 | EFAULT => unreachable, | |
| 5882 | EDOM => return error.TimeoutTooBig, | |
| 5883 | EISCONN => return error.AlreadyConnected, | |
| 5884 | ENOPROTOOPT => return error.InvalidProtocolOption, | |
| 5885 | ENOMEM => return error.SystemResources, | |
| 5886 | ENOBUFS => return error.SystemResources, | |
| 5887 | EPERM => return error.PermissionDenied, | |
| 5877 | .SUCCESS => {}, | |
| 5878 | .BADF => unreachable, // always a race condition | |
| 5879 | .NOTSOCK => unreachable, // always a race condition | |
| 5880 | .INVAL => unreachable, | |
| 5881 | .FAULT => unreachable, | |
| 5882 | .DOM => return error.TimeoutTooBig, | |
| 5883 | .ISCONN => return error.AlreadyConnected, | |
| 5884 | .NOPROTOOPT => return error.InvalidProtocolOption, | |
| 5885 | .NOMEM => return error.SystemResources, | |
| 5886 | .NOBUFS => return error.SystemResources, | |
| 5887 | .PERM => return error.PermissionDenied, | |
| 5888 | 5888 | else => |err| return unexpectedErrno(err), |
| 5889 | 5889 | } |
| 5890 | 5890 | } |
| ... | ... | @@ -5909,13 +5909,13 @@ pub fn memfd_createZ(name: [*:0]const u8, flags: u32) MemFdCreateError!fd_t { |
| 5909 | 5909 | const getErrno = if (use_c) std.c.getErrno else linux.getErrno; |
| 5910 | 5910 | const rc = sys.memfd_create(name, flags); |
| 5911 | 5911 | switch (getErrno(rc)) { |
| 5912 | 0 => return @intCast(fd_t, rc), | |
| 5913 | EFAULT => unreachable, // name has invalid memory | |
| 5914 | EINVAL => unreachable, // name/flags are faulty | |
| 5915 | ENFILE => return error.SystemFdQuotaExceeded, | |
| 5916 | EMFILE => return error.ProcessFdQuotaExceeded, | |
| 5917 | ENOMEM => return error.OutOfMemory, | |
| 5918 | ENOSYS => return error.SystemOutdated, | |
| 5912 | .SUCCESS => return @intCast(fd_t, rc), | |
| 5913 | .FAULT => unreachable, // name has invalid memory | |
| 5914 | .INVAL => unreachable, // name/flags are faulty | |
| 5915 | .NFILE => return error.SystemFdQuotaExceeded, | |
| 5916 | .MFILE => return error.ProcessFdQuotaExceeded, | |
| 5917 | .NOMEM => return error.OutOfMemory, | |
| 5918 | .NOSYS => return error.SystemOutdated, | |
| 5919 | 5919 | else => |err| return unexpectedErrno(err), |
| 5920 | 5920 | } |
| 5921 | 5921 | } |
| ... | ... | @@ -5940,9 +5940,9 @@ pub fn getrusage(who: i32) rusage { |
| 5940 | 5940 | var result: rusage = undefined; |
| 5941 | 5941 | const rc = system.getrusage(who, &result); |
| 5942 | 5942 | switch (errno(rc)) { |
| 5943 | 0 => return result, | |
| 5944 | EINVAL => unreachable, | |
| 5945 | EFAULT => unreachable, | |
| 5943 | .SUCCESS => return result, | |
| 5944 | .INVAL => unreachable, | |
| 5945 | .FAULT => unreachable, | |
| 5946 | 5946 | else => unreachable, |
| 5947 | 5947 | } |
| 5948 | 5948 | } |
| ... | ... | @@ -5953,10 +5953,10 @@ pub fn tcgetattr(handle: fd_t) TermiosGetError!termios { |
| 5953 | 5953 | while (true) { |
| 5954 | 5954 | var term: termios = undefined; |
| 5955 | 5955 | switch (errno(system.tcgetattr(handle, &term))) { |
| 5956 | 0 => return term, | |
| 5957 | EINTR => continue, | |
| 5958 | EBADF => unreachable, | |
| 5959 | ENOTTY => return error.NotATerminal, | |
| 5956 | .SUCCESS => return term, | |
| 5957 | .INTR => continue, | |
| 5958 | .BADF => unreachable, | |
| 5959 | .NOTTY => return error.NotATerminal, | |
| 5960 | 5960 | else => |err| return unexpectedErrno(err), |
| 5961 | 5961 | } |
| 5962 | 5962 | } |
| ... | ... | @@ -5967,12 +5967,12 @@ pub const TermiosSetError = TermiosGetError || error{ProcessOrphaned}; |
| 5967 | 5967 | pub fn tcsetattr(handle: fd_t, optional_action: TCSA, termios_p: termios) TermiosSetError!void { |
| 5968 | 5968 | while (true) { |
| 5969 | 5969 | switch (errno(system.tcsetattr(handle, optional_action, &termios_p))) { |
| 5970 | 0 => return, | |
| 5971 | EBADF => unreachable, | |
| 5972 | EINTR => continue, | |
| 5973 | EINVAL => unreachable, | |
| 5974 | ENOTTY => return error.NotATerminal, | |
| 5975 | EIO => return error.ProcessOrphaned, | |
| 5970 | .SUCCESS => return, | |
| 5971 | .BADF => unreachable, | |
| 5972 | .INTR => continue, | |
| 5973 | .INVAL => unreachable, | |
| 5974 | .NOTTY => return error.NotATerminal, | |
| 5975 | .IO => return error.ProcessOrphaned, | |
| 5976 | 5976 | else => |err| return unexpectedErrno(err), |
| 5977 | 5977 | } |
| 5978 | 5978 | } |
| ... | ... | @@ -5986,15 +5986,15 @@ pub const IoCtl_SIOCGIFINDEX_Error = error{ |
| 5986 | 5986 | pub fn ioctl_SIOCGIFINDEX(fd: fd_t, ifr: *ifreq) IoCtl_SIOCGIFINDEX_Error!void { |
| 5987 | 5987 | while (true) { |
| 5988 | 5988 | switch (errno(system.ioctl(fd, SIOCGIFINDEX, @ptrToInt(ifr)))) { |
| 5989 | 0 => return, | |
| 5990 | EINVAL => unreachable, // Bad parameters. | |
| 5991 | ENOTTY => unreachable, | |
| 5992 | ENXIO => unreachable, | |
| 5993 | EBADF => unreachable, // Always a race condition. | |
| 5994 | EFAULT => unreachable, // Bad pointer parameter. | |
| 5995 | EINTR => continue, | |
| 5996 | EIO => return error.FileSystem, | |
| 5997 | ENODEV => return error.InterfaceNotFound, | |
| 5989 | .SUCCESS => return, | |
| 5990 | .INVAL => unreachable, // Bad parameters. | |
| 5991 | .NOTTY => unreachable, | |
| 5992 | .NXIO => unreachable, | |
| 5993 | .BADF => unreachable, // Always a race condition. | |
| 5994 | .FAULT => unreachable, // Bad pointer parameter. | |
| 5995 | .INTR => continue, | |
| 5996 | .IO => return error.FileSystem, | |
| 5997 | .NODEV => return error.InterfaceNotFound, | |
| 5998 | 5998 | else => |err| return unexpectedErrno(err), |
| 5999 | 5999 | } |
| 6000 | 6000 | } |
| ... | ... | @@ -6003,13 +6003,13 @@ pub fn ioctl_SIOCGIFINDEX(fd: fd_t, ifr: *ifreq) IoCtl_SIOCGIFINDEX_Error!void { |
| 6003 | 6003 | pub fn signalfd(fd: fd_t, mask: *const sigset_t, flags: u32) !fd_t { |
| 6004 | 6004 | const rc = system.signalfd(fd, mask, flags); |
| 6005 | 6005 | switch (errno(rc)) { |
| 6006 | 0 => return @intCast(fd_t, rc), | |
| 6007 | EBADF, EINVAL => unreachable, | |
| 6008 | ENFILE => return error.SystemFdQuotaExceeded, | |
| 6009 | ENOMEM => return error.SystemResources, | |
| 6010 | EMFILE => return error.ProcessResources, | |
| 6011 | ENODEV => return error.InodeMountFail, | |
| 6012 | ENOSYS => return error.SystemOutdated, | |
| 6006 | .SUCCESS => return @intCast(fd_t, rc), | |
| 6007 | .BADF, .INVAL => unreachable, | |
| 6008 | .NFILE => return error.SystemFdQuotaExceeded, | |
| 6009 | .NOMEM => return error.SystemResources, | |
| 6010 | .MFILE => return error.ProcessResources, | |
| 6011 | .NODEV => return error.InodeMountFail, | |
| 6012 | .NOSYS => return error.SystemOutdated, | |
| 6013 | 6013 | else => |err| return unexpectedErrno(err), |
| 6014 | 6014 | } |
| 6015 | 6015 | } |
| ... | ... | @@ -6030,11 +6030,11 @@ pub fn sync() void { |
| 6030 | 6030 | pub fn syncfs(fd: fd_t) SyncError!void { |
| 6031 | 6031 | const rc = system.syncfs(fd); |
| 6032 | 6032 | switch (errno(rc)) { |
| 6033 | 0 => return, | |
| 6034 | EBADF, EINVAL, EROFS => unreachable, | |
| 6035 | EIO => return error.InputOutput, | |
| 6036 | ENOSPC => return error.NoSpaceLeft, | |
| 6037 | EDQUOT => return error.DiskQuota, | |
| 6033 | .SUCCESS => return, | |
| 6034 | .BADF, .INVAL, .ROFS => unreachable, | |
| 6035 | .IO => return error.InputOutput, | |
| 6036 | .NOSPC => return error.NoSpaceLeft, | |
| 6037 | .DQUOT => return error.DiskQuota, | |
| 6038 | 6038 | else => |err| return unexpectedErrno(err), |
| 6039 | 6039 | } |
| 6040 | 6040 | } |
| ... | ... | @@ -6054,11 +6054,11 @@ pub fn fsync(fd: fd_t) SyncError!void { |
| 6054 | 6054 | } |
| 6055 | 6055 | const rc = system.fsync(fd); |
| 6056 | 6056 | switch (errno(rc)) { |
| 6057 | 0 => return, | |
| 6058 | EBADF, EINVAL, EROFS => unreachable, | |
| 6059 | EIO => return error.InputOutput, | |
| 6060 | ENOSPC => return error.NoSpaceLeft, | |
| 6061 | EDQUOT => return error.DiskQuota, | |
| 6057 | .SUCCESS => return, | |
| 6058 | .BADF, .INVAL, .ROFS => unreachable, | |
| 6059 | .IO => return error.InputOutput, | |
| 6060 | .NOSPC => return error.NoSpaceLeft, | |
| 6061 | .DQUOT => return error.DiskQuota, | |
| 6062 | 6062 | else => |err| return unexpectedErrno(err), |
| 6063 | 6063 | } |
| 6064 | 6064 | } |
| ... | ... | @@ -6073,11 +6073,11 @@ pub fn fdatasync(fd: fd_t) SyncError!void { |
| 6073 | 6073 | } |
| 6074 | 6074 | const rc = system.fdatasync(fd); |
| 6075 | 6075 | switch (errno(rc)) { |
| 6076 | 0 => return, | |
| 6077 | EBADF, EINVAL, EROFS => unreachable, | |
| 6078 | EIO => return error.InputOutput, | |
| 6079 | ENOSPC => return error.NoSpaceLeft, | |
| 6080 | EDQUOT => return error.DiskQuota, | |
| 6076 | .SUCCESS => return, | |
| 6077 | .BADF, .INVAL, .ROFS => unreachable, | |
| 6078 | .IO => return error.InputOutput, | |
| 6079 | .NOSPC => return error.NoSpaceLeft, | |
| 6080 | .DQUOT => return error.DiskQuota, | |
| 6081 | 6081 | else => |err| return unexpectedErrno(err), |
| 6082 | 6082 | } |
| 6083 | 6083 | } |
| ... | ... | @@ -6111,15 +6111,15 @@ pub fn prctl(option: PR, args: anytype) PrctlError!u31 { |
| 6111 | 6111 | |
| 6112 | 6112 | const rc = system.prctl(@enumToInt(option), buf[0], buf[1], buf[2], buf[3]); |
| 6113 | 6113 | switch (errno(rc)) { |
| 6114 | 0 => return @intCast(u31, rc), | |
| 6115 | EACCES => return error.AccessDenied, | |
| 6116 | EBADF => return error.InvalidFileDescriptor, | |
| 6117 | EFAULT => return error.InvalidAddress, | |
| 6118 | EINVAL => unreachable, | |
| 6119 | ENODEV, ENXIO => return error.UnsupportedFeature, | |
| 6120 | EOPNOTSUPP => return error.OperationNotSupported, | |
| 6121 | EPERM, EBUSY => return error.PermissionDenied, | |
| 6122 | ERANGE => unreachable, | |
| 6114 | .SUCCESS => return @intCast(u31, rc), | |
| 6115 | .ACCES => return error.AccessDenied, | |
| 6116 | .BADF => return error.InvalidFileDescriptor, | |
| 6117 | .FAULT => return error.InvalidAddress, | |
| 6118 | .INVAL => unreachable, | |
| 6119 | .NODEV, .NXIO => return error.UnsupportedFeature, | |
| 6120 | .OPNOTSUPP => return error.OperationNotSupported, | |
| 6121 | .PERM, .BUSY => return error.PermissionDenied, | |
| 6122 | .RANGE => unreachable, | |
| 6123 | 6123 | else => |err| return unexpectedErrno(err), |
| 6124 | 6124 | } |
| 6125 | 6125 | } |
| ... | ... | @@ -6134,9 +6134,9 @@ pub fn getrlimit(resource: rlimit_resource) GetrlimitError!rlimit { |
| 6134 | 6134 | |
| 6135 | 6135 | var limits: rlimit = undefined; |
| 6136 | 6136 | switch (errno(getrlimit_sym(resource, &limits))) { |
| 6137 | 0 => return limits, | |
| 6138 | EFAULT => unreachable, // bogus pointer | |
| 6139 | EINVAL => unreachable, | |
| 6137 | .SUCCESS => return limits, | |
| 6138 | .FAULT => unreachable, // bogus pointer | |
| 6139 | .INVAL => unreachable, | |
| 6140 | 6140 | else => |err| return unexpectedErrno(err), |
| 6141 | 6141 | } |
| 6142 | 6142 | } |
| ... | ... | @@ -6150,10 +6150,10 @@ pub fn setrlimit(resource: rlimit_resource, limits: rlimit) SetrlimitError!void |
| 6150 | 6150 | system.setrlimit; |
| 6151 | 6151 | |
| 6152 | 6152 | switch (errno(setrlimit_sym(resource, &limits))) { |
| 6153 | 0 => return, | |
| 6154 | EFAULT => unreachable, // bogus pointer | |
| 6155 | EINVAL => return error.LimitTooBig, // this could also mean "invalid resource", but that would be unreachable | |
| 6156 | EPERM => return error.PermissionDenied, | |
| 6153 | .SUCCESS => return, | |
| 6154 | .FAULT => unreachable, // bogus pointer | |
| 6155 | .INVAL => return error.LimitTooBig, // this could also mean "invalid resource", but that would be unreachable | |
| 6156 | .PERM => return error.PermissionDenied, | |
| 6157 | 6157 | else => |err| return unexpectedErrno(err), |
| 6158 | 6158 | } |
| 6159 | 6159 | } |
| ... | ... | @@ -6194,14 +6194,14 @@ pub const MadviseError = error{ |
| 6194 | 6194 | /// This syscall is optional and is sometimes configured to be disabled. |
| 6195 | 6195 | pub fn madvise(ptr: [*]align(mem.page_size) u8, length: usize, advice: u32) MadviseError!void { |
| 6196 | 6196 | switch (errno(system.madvise(ptr, length, advice))) { |
| 6197 | 0 => return, | |
| 6198 | EACCES => return error.AccessDenied, | |
| 6199 | EAGAIN => return error.SystemResources, | |
| 6200 | EBADF => unreachable, // The map exists, but the area maps something that isn't a file. | |
| 6201 | EINVAL => return error.InvalidSyscall, | |
| 6202 | EIO => return error.WouldExceedMaximumResidentSetSize, | |
| 6203 | ENOMEM => return error.OutOfMemory, | |
| 6204 | ENOSYS => return error.MadviseUnavailable, | |
| 6197 | .SUCCESS => return, | |
| 6198 | .ACCES => return error.AccessDenied, | |
| 6199 | .AGAIN => return error.SystemResources, | |
| 6200 | .BADF => unreachable, // The map exists, but the area maps something that isn't a file. | |
| 6201 | .INVAL => return error.InvalidSyscall, | |
| 6202 | .IO => return error.WouldExceedMaximumResidentSetSize, | |
| 6203 | .NOMEM => return error.OutOfMemory, | |
| 6204 | .NOSYS => return error.MadviseUnavailable, | |
| 6205 | 6205 | else => |err| return unexpectedErrno(err), |
| 6206 | 6206 | } |
| 6207 | 6207 | } |
lib/std/os/bits/darwin.zig+229-224| ... | ... | @@ -866,337 +866,342 @@ pub fn WIFSIGNALED(x: u32) bool { |
| 866 | 866 | return wstatus(x) != wstopped and wstatus(x) != 0; |
| 867 | 867 | } |
| 868 | 868 | |
| 869 | /// Operation not permitted | |
| 870 | pub const EPERM = 1; | |
| 869 | pub const E = enum(u16) { | |
| 870 | /// No error occurred. | |
| 871 | SUCCESS = 0, | |
| 871 | 872 | |
| 872 | /// No such file or directory | |
| 873 | pub const ENOENT = 2; | |
| 873 | /// Operation not permitted | |
| 874 | PERM = 1, | |
| 874 | 875 | |
| 875 | /// No such process | |
| 876 | pub const ESRCH = 3; | |
| 876 | /// No such file or directory | |
| 877 | NOENT = 2, | |
| 877 | 878 | |
| 878 | /// Interrupted system call | |
| 879 | pub const EINTR = 4; | |
| 879 | /// No such process | |
| 880 | SRCH = 3, | |
| 880 | 881 | |
| 881 | /// Input/output error | |
| 882 | pub const EIO = 5; | |
| 882 | /// Interrupted system call | |
| 883 | INTR = 4, | |
| 883 | 884 | |
| 884 | /// Device not configured | |
| 885 | pub const ENXIO = 6; | |
| 885 | /// Input/output error | |
| 886 | IO = 5, | |
| 886 | 887 | |
| 887 | /// Argument list too long | |
| 888 | pub const E2BIG = 7; | |
| 888 | /// Device not configured | |
| 889 | NXIO = 6, | |
| 889 | 890 | |
| 890 | /// Exec format error | |
| 891 | pub const ENOEXEC = 8; | |
| 891 | /// Argument list too long | |
| 892 | @"2BIG" = 7, | |
| 892 | 893 | |
| 893 | /// Bad file descriptor | |
| 894 | pub const EBADF = 9; | |
| 894 | /// Exec format error | |
| 895 | NOEXEC = 8, | |
| 895 | 896 | |
| 896 | /// No child processes | |
| 897 | pub const ECHILD = 10; | |
| 897 | /// Bad file descriptor | |
| 898 | BADF = 9, | |
| 898 | 899 | |
| 899 | /// Resource deadlock avoided | |
| 900 | pub const EDEADLK = 11; | |
| 900 | /// No child processes | |
| 901 | CHILD = 10, | |
| 901 | 902 | |
| 902 | /// Cannot allocate memory | |
| 903 | pub const ENOMEM = 12; | |
| 903 | /// Resource deadlock avoided | |
| 904 | DEADLK = 11, | |
| 904 | 905 | |
| 905 | /// Permission denied | |
| 906 | pub const EACCES = 13; | |
| 906 | /// Cannot allocate memory | |
| 907 | NOMEM = 12, | |
| 907 | 908 | |
| 908 | /// Bad address | |
| 909 | pub const EFAULT = 14; | |
| 909 | /// Permission denied | |
| 910 | ACCES = 13, | |
| 910 | 911 | |
| 911 | /// Block device required | |
| 912 | pub const ENOTBLK = 15; | |
| 912 | /// Bad address | |
| 913 | FAULT = 14, | |
| 913 | 914 | |
| 914 | /// Device / Resource busy | |
| 915 | pub const EBUSY = 16; | |
| 915 | /// Block device required | |
| 916 | NOTBLK = 15, | |
| 916 | 917 | |
| 917 | /// File exists | |
| 918 | pub const EEXIST = 17; | |
| 918 | /// Device / Resource busy | |
| 919 | BUSY = 16, | |
| 919 | 920 | |
| 920 | /// Cross-device link | |
| 921 | pub const EXDEV = 18; | |
| 921 | /// File exists | |
| 922 | EXIST = 17, | |
| 922 | 923 | |
| 923 | /// Operation not supported by device | |
| 924 | pub const ENODEV = 19; | |
| 924 | /// Cross-device link | |
| 925 | XDEV = 18, | |
| 925 | 926 | |
| 926 | /// Not a directory | |
| 927 | pub const ENOTDIR = 20; | |
| 927 | /// Operation not supported by device | |
| 928 | NODEV = 19, | |
| 928 | 929 | |
| 929 | /// Is a directory | |
| 930 | pub const EISDIR = 21; | |
| 930 | /// Not a directory | |
| 931 | NOTDIR = 20, | |
| 931 | 932 | |
| 932 | /// Invalid argument | |
| 933 | pub const EINVAL = 22; | |
| 933 | /// Is a directory | |
| 934 | ISDIR = 21, | |
| 934 | 935 | |
| 935 | /// Too many open files in system | |
| 936 | pub const ENFILE = 23; | |
| 936 | /// Invalid argument | |
| 937 | INVAL = 22, | |
| 937 | 938 | |
| 938 | /// Too many open files | |
| 939 | pub const EMFILE = 24; | |
| 939 | /// Too many open files in system | |
| 940 | NFILE = 23, | |
| 940 | 941 | |
| 941 | /// Inappropriate ioctl for device | |
| 942 | pub const ENOTTY = 25; | |
| 942 | /// Too many open files | |
| 943 | MFILE = 24, | |
| 943 | 944 | |
| 944 | /// Text file busy | |
| 945 | pub const ETXTBSY = 26; | |
| 945 | /// Inappropriate ioctl for device | |
| 946 | NOTTY = 25, | |
| 946 | 947 | |
| 947 | /// File too large | |
| 948 | pub const EFBIG = 27; | |
| 948 | /// Text file busy | |
| 949 | TXTBSY = 26, | |
| 949 | 950 | |
| 950 | /// No space left on device | |
| 951 | pub const ENOSPC = 28; | |
| 951 | /// File too large | |
| 952 | FBIG = 27, | |
| 952 | 953 | |
| 953 | /// Illegal seek | |
| 954 | pub const ESPIPE = 29; | |
| 954 | /// No space left on device | |
| 955 | NOSPC = 28, | |
| 955 | 956 | |
| 956 | /// Read-only file system | |
| 957 | pub const EROFS = 30; | |
| 957 | /// Illegal seek | |
| 958 | SPIPE = 29, | |
| 958 | 959 | |
| 959 | /// Too many links | |
| 960 | pub const EMLINK = 31; | |
| 961 | /// Broken pipe | |
| 960 | /// Read-only file system | |
| 961 | ROFS = 30, | |
| 962 | 962 | |
| 963 | // math software | |
| 964 | pub const EPIPE = 32; | |
| 963 | /// Too many links | |
| 964 | MLINK = 31, | |
| 965 | 965 | |
| 966 | /// Numerical argument out of domain | |
| 967 | pub const EDOM = 33; | |
| 968 | /// Result too large | |
| 966 | /// Broken pipe | |
| 967 | PIPE = 32, | |
| 969 | 968 | |
| 970 | // non-blocking and interrupt i/o | |
| 971 | pub const ERANGE = 34; | |
| 969 | // math software | |
| 972 | 970 | |
| 973 | /// Resource temporarily unavailable | |
| 974 | pub const EAGAIN = 35; | |
| 971 | /// Numerical argument out of domain | |
| 972 | DOM = 33, | |
| 975 | 973 | |
| 976 | /// Operation would block | |
| 977 | pub const EWOULDBLOCK = EAGAIN; | |
| 974 | /// Result too large | |
| 975 | RANGE = 34, | |
| 978 | 976 | |
| 979 | /// Operation now in progress | |
| 980 | pub const EINPROGRESS = 36; | |
| 981 | /// Operation already in progress | |
| 977 | // non-blocking and interrupt i/o | |
| 982 | 978 | |
| 983 | // ipc/network software -- argument errors | |
| 984 | pub const EALREADY = 37; | |
| 979 | /// Resource temporarily unavailable | |
| 980 | /// This is the same code used for `WOULDBLOCK`. | |
| 981 | AGAIN = 35, | |
| 985 | 982 | |
| 986 | /// Socket operation on non-socket | |
| 987 | pub const ENOTSOCK = 38; | |
| 983 | /// Operation now in progress | |
| 984 | INPROGRESS = 36, | |
| 988 | 985 | |
| 989 | /// Destination address required | |
| 990 | pub const EDESTADDRREQ = 39; | |
| 986 | /// Operation already in progress | |
| 987 | ALREADY = 37, | |
| 991 | 988 | |
| 992 | /// Message too long | |
| 993 | pub const EMSGSIZE = 40; | |
| 989 | // ipc/network software -- argument errors | |
| 994 | 990 | |
| 995 | /// Protocol wrong type for socket | |
| 996 | pub const EPROTOTYPE = 41; | |
| 991 | /// Socket operation on non-socket | |
| 992 | NOTSOCK = 38, | |
| 997 | 993 | |
| 998 | /// Protocol not available | |
| 999 | pub const ENOPROTOOPT = 42; | |
| 994 | /// Destination address required | |
| 995 | DESTADDRREQ = 39, | |
| 1000 | 996 | |
| 1001 | /// Protocol not supported | |
| 1002 | pub const EPROTONOSUPPORT = 43; | |
| 997 | /// Message too long | |
| 998 | MSGSIZE = 40, | |
| 1003 | 999 | |
| 1004 | /// Socket type not supported | |
| 1005 | pub const ESOCKTNOSUPPORT = 44; | |
| 1000 | /// Protocol wrong type for socket | |
| 1001 | PROTOTYPE = 41, | |
| 1006 | 1002 | |
| 1007 | /// Operation not supported | |
| 1008 | pub const ENOTSUP = 45; | |
| 1003 | /// Protocol not available | |
| 1004 | NOPROTOOPT = 42, | |
| 1009 | 1005 | |
| 1010 | /// Operation not supported. Alias of `ENOTSUP`. | |
| 1011 | pub const EOPNOTSUPP = ENOTSUP; | |
| 1006 | /// Protocol not supported | |
| 1007 | PROTONOSUPPORT = 43, | |
| 1012 | 1008 | |
| 1013 | /// Protocol family not supported | |
| 1014 | pub const EPFNOSUPPORT = 46; | |
| 1009 | /// Socket type not supported | |
| 1010 | SOCKTNOSUPPORT = 44, | |
| 1015 | 1011 | |
| 1016 | /// Address family not supported by protocol family | |
| 1017 | pub const EAFNOSUPPORT = 47; | |
| 1012 | /// Operation not supported | |
| 1013 | /// The same code is used for `NOTSUP`. | |
| 1014 | OPNOTSUPP = 45, | |
| 1018 | 1015 | |
| 1019 | /// Address already in use | |
| 1020 | pub const EADDRINUSE = 48; | |
| 1021 | /// Can't assign requested address | |
| 1016 | /// Protocol family not supported | |
| 1017 | PFNOSUPPORT = 46, | |
| 1022 | 1018 | |
| 1023 | // ipc/network software -- operational errors | |
| 1024 | pub const EADDRNOTAVAIL = 49; | |
| 1019 | /// Address family not supported by protocol family | |
| 1020 | AFNOSUPPORT = 47, | |
| 1025 | 1021 | |
| 1026 | /// Network is down | |
| 1027 | pub const ENETDOWN = 50; | |
| 1022 | /// Address already in use | |
| 1023 | ADDRINUSE = 48, | |
| 1024 | /// Can't assign requested address | |
| 1028 | 1025 | |
| 1029 | /// Network is unreachable | |
| 1030 | pub const ENETUNREACH = 51; | |
| 1026 | // ipc/network software -- operational errors | |
| 1027 | ADDRNOTAVAIL = 49, | |
| 1031 | 1028 | |
| 1032 | /// Network dropped connection on reset | |
| 1033 | pub const ENETRESET = 52; | |
| 1029 | /// Network is down | |
| 1030 | NETDOWN = 50, | |
| 1034 | 1031 | |
| 1035 | /// Software caused connection abort | |
| 1036 | pub const ECONNABORTED = 53; | |
| 1032 | /// Network is unreachable | |
| 1033 | NETUNREACH = 51, | |
| 1037 | 1034 | |
| 1038 | /// Connection reset by peer | |
| 1039 | pub const ECONNRESET = 54; | |
| 1035 | /// Network dropped connection on reset | |
| 1036 | NETRESET = 52, | |
| 1040 | 1037 | |
| 1041 | /// No buffer space available | |
| 1042 | pub const ENOBUFS = 55; | |
| 1038 | /// Software caused connection abort | |
| 1039 | CONNABORTED = 53, | |
| 1043 | 1040 | |
| 1044 | /// Socket is already connected | |
| 1045 | pub const EISCONN = 56; | |
| 1041 | /// Connection reset by peer | |
| 1042 | CONNRESET = 54, | |
| 1046 | 1043 | |
| 1047 | /// Socket is not connected | |
| 1048 | pub const ENOTCONN = 57; | |
| 1044 | /// No buffer space available | |
| 1045 | NOBUFS = 55, | |
| 1049 | 1046 | |
| 1050 | /// Can't send after socket shutdown | |
| 1051 | pub const ESHUTDOWN = 58; | |
| 1047 | /// Socket is already connected | |
| 1048 | ISCONN = 56, | |
| 1052 | 1049 | |
| 1053 | /// Too many references: can't splice | |
| 1054 | pub const ETOOMANYREFS = 59; | |
| 1050 | /// Socket is not connected | |
| 1051 | NOTCONN = 57, | |
| 1055 | 1052 | |
| 1056 | /// Operation timed out | |
| 1057 | pub const ETIMEDOUT = 60; | |
| 1053 | /// Can't send after socket shutdown | |
| 1054 | SHUTDOWN = 58, | |
| 1058 | 1055 | |
| 1059 | /// Connection refused | |
| 1060 | pub const ECONNREFUSED = 61; | |
| 1056 | /// Too many references: can't splice | |
| 1057 | TOOMANYREFS = 59, | |
| 1061 | 1058 | |
| 1062 | /// Too many levels of symbolic links | |
| 1063 | pub const ELOOP = 62; | |
| 1059 | /// Operation timed out | |
| 1060 | TIMEDOUT = 60, | |
| 1064 | 1061 | |
| 1065 | /// File name too long | |
| 1066 | pub const ENAMETOOLONG = 63; | |
| 1062 | /// Connection refused | |
| 1063 | CONNREFUSED = 61, | |
| 1067 | 1064 | |
| 1068 | /// Host is down | |
| 1069 | pub const EHOSTDOWN = 64; | |
| 1065 | /// Too many levels of symbolic links | |
| 1066 | LOOP = 62, | |
| 1070 | 1067 | |
| 1071 | /// No route to host | |
| 1072 | pub const EHOSTUNREACH = 65; | |
| 1073 | /// Directory not empty | |
| 1068 | /// File name too long | |
| 1069 | NAMETOOLONG = 63, | |
| 1074 | 1070 | |
| 1075 | // quotas & mush | |
| 1076 | pub const ENOTEMPTY = 66; | |
| 1071 | /// Host is down | |
| 1072 | HOSTDOWN = 64, | |
| 1077 | 1073 | |
| 1078 | /// Too many processes | |
| 1079 | pub const EPROCLIM = 67; | |
| 1074 | /// No route to host | |
| 1075 | HOSTUNREACH = 65, | |
| 1076 | /// Directory not empty | |
| 1080 | 1077 | |
| 1081 | /// Too many users | |
| 1082 | pub const EUSERS = 68; | |
| 1083 | /// Disc quota exceeded | |
| 1078 | // quotas & mush | |
| 1079 | NOTEMPTY = 66, | |
| 1084 | 1080 | |
| 1085 | // Network File System | |
| 1086 | pub const EDQUOT = 69; | |
| 1081 | /// Too many processes | |
| 1082 | PROCLIM = 67, | |
| 1087 | 1083 | |
| 1088 | /// Stale NFS file handle | |
| 1089 | pub const ESTALE = 70; | |
| 1084 | /// Too many users | |
| 1085 | USERS = 68, | |
| 1086 | /// Disc quota exceeded | |
| 1090 | 1087 | |
| 1091 | /// Too many levels of remote in path | |
| 1092 | pub const EREMOTE = 71; | |
| 1088 | // Network File System | |
| 1089 | DQUOT = 69, | |
| 1093 | 1090 | |
| 1094 | /// RPC struct is bad | |
| 1095 | pub const EBADRPC = 72; | |
| 1091 | /// Stale NFS file handle | |
| 1092 | STALE = 70, | |
| 1096 | 1093 | |
| 1097 | /// RPC version wrong | |
| 1098 | pub const ERPCMISMATCH = 73; | |
| 1094 | /// Too many levels of remote in path | |
| 1095 | REMOTE = 71, | |
| 1099 | 1096 | |
| 1100 | /// RPC prog. not avail | |
| 1101 | pub const EPROGUNAVAIL = 74; | |
| 1097 | /// RPC struct is bad | |
| 1098 | BADRPC = 72, | |
| 1102 | 1099 | |
| 1103 | /// Program version wrong | |
| 1104 | pub const EPROGMISMATCH = 75; | |
| 1100 | /// RPC version wrong | |
| 1101 | RPCMISMATCH = 73, | |
| 1105 | 1102 | |
| 1106 | /// Bad procedure for program | |
| 1107 | pub const EPROCUNAVAIL = 76; | |
| 1103 | /// RPC prog. not avail | |
| 1104 | PROGUNAVAIL = 74, | |
| 1108 | 1105 | |
| 1109 | /// No locks available | |
| 1110 | pub const ENOLCK = 77; | |
| 1106 | /// Program version wrong | |
| 1107 | PROGMISMATCH = 75, | |
| 1111 | 1108 | |
| 1112 | /// Function not implemented | |
| 1113 | pub const ENOSYS = 78; | |
| 1109 | /// Bad procedure for program | |
| 1110 | PROCUNAVAIL = 76, | |
| 1114 | 1111 | |
| 1115 | /// Inappropriate file type or format | |
| 1116 | pub const EFTYPE = 79; | |
| 1112 | /// No locks available | |
| 1113 | NOLCK = 77, | |
| 1117 | 1114 | |
| 1118 | /// Authentication error | |
| 1119 | pub const EAUTH = 80; | |
| 1120 | /// Need authenticator | |
| 1115 | /// Function not implemented | |
| 1116 | NOSYS = 78, | |
| 1121 | 1117 | |
| 1122 | // Intelligent device errors | |
| 1123 | pub const ENEEDAUTH = 81; | |
| 1118 | /// Inappropriate file type or format | |
| 1119 | FTYPE = 79, | |
| 1124 | 1120 | |
| 1125 | /// Device power is off | |
| 1126 | pub const EPWROFF = 82; | |
| 1121 | /// Authentication error | |
| 1122 | AUTH = 80, | |
| 1127 | 1123 | |
| 1128 | /// Device error, e.g. paper out | |
| 1129 | pub const EDEVERR = 83; | |
| 1130 | /// Value too large to be stored in data type | |
| 1124 | /// Need authenticator | |
| 1125 | NEEDAUTH = 81, | |
| 1131 | 1126 | |
| 1132 | // Program loading errors | |
| 1133 | pub const EOVERFLOW = 84; | |
| 1127 | // Intelligent device errors | |
| 1134 | 1128 | |
| 1135 | /// Bad executable | |
| 1136 | pub const EBADEXEC = 85; | |
| 1129 | /// Device power is off | |
| 1130 | PWROFF = 82, | |
| 1137 | 1131 | |
| 1138 | /// Bad CPU type in executable | |
| 1139 | pub const EBADARCH = 86; | |
| 1132 | /// Device error, e.g. paper out | |
| 1133 | DEVERR = 83, | |
| 1140 | 1134 | |
| 1141 | /// Shared library version mismatch | |
| 1142 | pub const ESHLIBVERS = 87; | |
| 1135 | /// Value too large to be stored in data type | |
| 1136 | OVERFLOW = 84, | |
| 1143 | 1137 | |
| 1144 | /// Malformed Macho file | |
| 1145 | pub const EBADMACHO = 88; | |
| 1138 | // Program loading errors | |
| 1146 | 1139 | |
| 1147 | /// Operation canceled | |
| 1148 | pub const ECANCELED = 89; | |
| 1140 | /// Bad executable | |
| 1141 | BADEXEC = 85, | |
| 1149 | 1142 | |
| 1150 | /// Identifier removed | |
| 1151 | pub const EIDRM = 90; | |
| 1143 | /// Bad CPU type in executable | |
| 1144 | BADARCH = 86, | |
| 1152 | 1145 | |
| 1153 | /// No message of desired type | |
| 1154 | pub const ENOMSG = 91; | |
| 1146 | /// Shared library version mismatch | |
| 1147 | SHLIBVERS = 87, | |
| 1155 | 1148 | |
| 1156 | /// Illegal byte sequence | |
| 1157 | pub const EILSEQ = 92; | |
| 1149 | /// Malformed Macho file | |
| 1150 | BADMACHO = 88, | |
| 1158 | 1151 | |
| 1159 | /// Attribute not found | |
| 1160 | pub const ENOATTR = 93; | |
| 1152 | /// Operation canceled | |
| 1153 | CANCELED = 89, | |
| 1161 | 1154 | |
| 1162 | /// Bad message | |
| 1163 | pub const EBADMSG = 94; | |
| 1155 | /// Identifier removed | |
| 1156 | IDRM = 90, | |
| 1164 | 1157 | |
| 1165 | /// Reserved | |
| 1166 | pub const EMULTIHOP = 95; | |
| 1158 | /// No message of desired type | |
| 1159 | NOMSG = 91, | |
| 1167 | 1160 | |
| 1168 | /// No message available on STREAM | |
| 1169 | pub const ENODATA = 96; | |
| 1161 | /// Illegal byte sequence | |
| 1162 | ILSEQ = 92, | |
| 1170 | 1163 | |
| 1171 | /// Reserved | |
| 1172 | pub const ENOLINK = 97; | |
| 1164 | /// Attribute not found | |
| 1165 | NOATTR = 93, | |
| 1173 | 1166 | |
| 1174 | /// No STREAM resources | |
| 1175 | pub const ENOSR = 98; | |
| 1167 | /// Bad message | |
| 1168 | BADMSG = 94, | |
| 1176 | 1169 | |
| 1177 | /// Not a STREAM | |
| 1178 | pub const ENOSTR = 99; | |
| 1170 | /// Reserved | |
| 1171 | MULTIHOP = 95, | |
| 1179 | 1172 | |
| 1180 | /// Protocol error | |
| 1181 | pub const EPROTO = 100; | |
| 1173 | /// No message available on STREAM | |
| 1174 | NODATA = 96, | |
| 1182 | 1175 | |
| 1183 | /// STREAM ioctl timeout | |
| 1184 | pub const ETIME = 101; | |
| 1176 | /// Reserved | |
| 1177 | NOLINK = 97, | |
| 1185 | 1178 | |
| 1186 | /// No such policy registered | |
| 1187 | pub const ENOPOLICY = 103; | |
| 1179 | /// No STREAM resources | |
| 1180 | NOSR = 98, | |
| 1188 | 1181 | |
| 1189 | /// State not recoverable | |
| 1190 | pub const ENOTRECOVERABLE = 104; | |
| 1182 | /// Not a STREAM | |
| 1183 | NOSTR = 99, | |
| 1191 | 1184 | |
| 1192 | /// Previous owner died | |
| 1193 | pub const EOWNERDEAD = 105; | |
| 1185 | /// Protocol error | |
| 1186 | PROTO = 100, | |
| 1194 | 1187 | |
| 1195 | /// Interface output queue is full | |
| 1196 | pub const EQFULL = 106; | |
| 1188 | /// STREAM ioctl timeout | |
| 1189 | TIME = 101, | |
| 1197 | 1190 | |
| 1198 | /// Must be equal largest errno | |
| 1199 | pub const ELAST = 106; | |
| 1191 | /// No such policy registered | |
| 1192 | NOPOLICY = 103, | |
| 1193 | ||
| 1194 | /// State not recoverable | |
| 1195 | NOTRECOVERABLE = 104, | |
| 1196 | ||
| 1197 | /// Previous owner died | |
| 1198 | OWNERDEAD = 105, | |
| 1199 | ||
| 1200 | /// Interface output queue is full | |
| 1201 | QFULL = 106, | |
| 1202 | ||
| 1203 | _, | |
| 1204 | }; | |
| 1200 | 1205 | |
| 1201 | 1206 | pub const SIGSTKSZ = 131072; |
| 1202 | 1207 | pub const MINSIGSTKSZ = 32768; |
lib/std/os/bits/dragonfly.zig+102-97| ... | ... | @@ -25,103 +25,108 @@ pub const gid_t = u32; |
| 25 | 25 | pub const time_t = isize; |
| 26 | 26 | pub const suseconds_t = c_long; |
| 27 | 27 | |
| 28 | pub const ENOTSUP = EOPNOTSUPP; | |
| 29 | pub const EWOULDBLOCK = EAGAIN; | |
| 30 | pub const EPERM = 1; | |
| 31 | pub const ENOENT = 2; | |
| 32 | pub const ESRCH = 3; | |
| 33 | pub const EINTR = 4; | |
| 34 | pub const EIO = 5; | |
| 35 | pub const ENXIO = 6; | |
| 36 | pub const E2BIG = 7; | |
| 37 | pub const ENOEXEC = 8; | |
| 38 | pub const EBADF = 9; | |
| 39 | pub const ECHILD = 10; | |
| 40 | pub const EDEADLK = 11; | |
| 41 | pub const ENOMEM = 12; | |
| 42 | pub const EACCES = 13; | |
| 43 | pub const EFAULT = 14; | |
| 44 | pub const ENOTBLK = 15; | |
| 45 | pub const EBUSY = 16; | |
| 46 | pub const EEXIST = 17; | |
| 47 | pub const EXDEV = 18; | |
| 48 | pub const ENODEV = 19; | |
| 49 | pub const ENOTDIR = 20; | |
| 50 | pub const EISDIR = 21; | |
| 51 | pub const EINVAL = 22; | |
| 52 | pub const ENFILE = 23; | |
| 53 | pub const EMFILE = 24; | |
| 54 | pub const ENOTTY = 25; | |
| 55 | pub const ETXTBSY = 26; | |
| 56 | pub const EFBIG = 27; | |
| 57 | pub const ENOSPC = 28; | |
| 58 | pub const ESPIPE = 29; | |
| 59 | pub const EROFS = 30; | |
| 60 | pub const EMLINK = 31; | |
| 61 | pub const EPIPE = 32; | |
| 62 | pub const EDOM = 33; | |
| 63 | pub const ERANGE = 34; | |
| 64 | pub const EAGAIN = 35; | |
| 65 | pub const EINPROGRESS = 36; | |
| 66 | pub const EALREADY = 37; | |
| 67 | pub const ENOTSOCK = 38; | |
| 68 | pub const EDESTADDRREQ = 39; | |
| 69 | pub const EMSGSIZE = 40; | |
| 70 | pub const EPROTOTYPE = 41; | |
| 71 | pub const ENOPROTOOPT = 42; | |
| 72 | pub const EPROTONOSUPPORT = 43; | |
| 73 | pub const ESOCKTNOSUPPORT = 44; | |
| 74 | pub const EOPNOTSUPP = 45; | |
| 75 | pub const EPFNOSUPPORT = 46; | |
| 76 | pub const EAFNOSUPPORT = 47; | |
| 77 | pub const EADDRINUSE = 48; | |
| 78 | pub const EADDRNOTAVAIL = 49; | |
| 79 | pub const ENETDOWN = 50; | |
| 80 | pub const ENETUNREACH = 51; | |
| 81 | pub const ENETRESET = 52; | |
| 82 | pub const ECONNABORTED = 53; | |
| 83 | pub const ECONNRESET = 54; | |
| 84 | pub const ENOBUFS = 55; | |
| 85 | pub const EISCONN = 56; | |
| 86 | pub const ENOTCONN = 57; | |
| 87 | pub const ESHUTDOWN = 58; | |
| 88 | pub const ETOOMANYREFS = 59; | |
| 89 | pub const ETIMEDOUT = 60; | |
| 90 | pub const ECONNREFUSED = 61; | |
| 91 | pub const ELOOP = 62; | |
| 92 | pub const ENAMETOOLONG = 63; | |
| 93 | pub const EHOSTDOWN = 64; | |
| 94 | pub const EHOSTUNREACH = 65; | |
| 95 | pub const ENOTEMPTY = 66; | |
| 96 | pub const EPROCLIM = 67; | |
| 97 | pub const EUSERS = 68; | |
| 98 | pub const EDQUOT = 69; | |
| 99 | pub const ESTALE = 70; | |
| 100 | pub const EREMOTE = 71; | |
| 101 | pub const EBADRPC = 72; | |
| 102 | pub const ERPCMISMATCH = 73; | |
| 103 | pub const EPROGUNAVAIL = 74; | |
| 104 | pub const EPROGMISMATCH = 75; | |
| 105 | pub const EPROCUNAVAIL = 76; | |
| 106 | pub const ENOLCK = 77; | |
| 107 | pub const ENOSYS = 78; | |
| 108 | pub const EFTYPE = 79; | |
| 109 | pub const EAUTH = 80; | |
| 110 | pub const ENEEDAUTH = 81; | |
| 111 | pub const EIDRM = 82; | |
| 112 | pub const ENOMSG = 83; | |
| 113 | pub const EOVERFLOW = 84; | |
| 114 | pub const ECANCELED = 85; | |
| 115 | pub const EILSEQ = 86; | |
| 116 | pub const ENOATTR = 87; | |
| 117 | pub const EDOOFUS = 88; | |
| 118 | pub const EBADMSG = 89; | |
| 119 | pub const EMULTIHOP = 90; | |
| 120 | pub const ENOLINK = 91; | |
| 121 | pub const EPROTO = 92; | |
| 122 | pub const ENOMEDIUM = 93; | |
| 123 | pub const ELAST = 99; | |
| 124 | pub const EASYNC = 99; | |
| 28 | pub const E = enum(u16) { | |
| 29 | /// No error occurred. | |
| 30 | SUCCESS = 0, | |
| 31 | ||
| 32 | PERM = 1, | |
| 33 | NOENT = 2, | |
| 34 | SRCH = 3, | |
| 35 | INTR = 4, | |
| 36 | IO = 5, | |
| 37 | NXIO = 6, | |
| 38 | @"2BIG" = 7, | |
| 39 | NOEXEC = 8, | |
| 40 | BADF = 9, | |
| 41 | CHILD = 10, | |
| 42 | DEADLK = 11, | |
| 43 | NOMEM = 12, | |
| 44 | ACCES = 13, | |
| 45 | FAULT = 14, | |
| 46 | NOTBLK = 15, | |
| 47 | BUSY = 16, | |
| 48 | EXIST = 17, | |
| 49 | XDEV = 18, | |
| 50 | NODEV = 19, | |
| 51 | NOTDIR = 20, | |
| 52 | ISDIR = 21, | |
| 53 | INVAL = 22, | |
| 54 | NFILE = 23, | |
| 55 | MFILE = 24, | |
| 56 | NOTTY = 25, | |
| 57 | TXTBSY = 26, | |
| 58 | FBIG = 27, | |
| 59 | NOSPC = 28, | |
| 60 | SPIPE = 29, | |
| 61 | ROFS = 30, | |
| 62 | MLINK = 31, | |
| 63 | PIPE = 32, | |
| 64 | DOM = 33, | |
| 65 | RANGE = 34, | |
| 66 | /// This code is also used for `WOULDBLOCK`. | |
| 67 | AGAIN = 35, | |
| 68 | INPROGRESS = 36, | |
| 69 | ALREADY = 37, | |
| 70 | NOTSOCK = 38, | |
| 71 | DESTADDRREQ = 39, | |
| 72 | MSGSIZE = 40, | |
| 73 | PROTOTYPE = 41, | |
| 74 | NOPROTOOPT = 42, | |
| 75 | PROTONOSUPPORT = 43, | |
| 76 | SOCKTNOSUPPORT = 44, | |
| 77 | /// This code is also used for `NOTSUP`. | |
| 78 | OPNOTSUPP = 45, | |
| 79 | PFNOSUPPORT = 46, | |
| 80 | AFNOSUPPORT = 47, | |
| 81 | ADDRINUSE = 48, | |
| 82 | ADDRNOTAVAIL = 49, | |
| 83 | NETDOWN = 50, | |
| 84 | NETUNREACH = 51, | |
| 85 | NETRESET = 52, | |
| 86 | CONNABORTED = 53, | |
| 87 | CONNRESET = 54, | |
| 88 | NOBUFS = 55, | |
| 89 | ISCONN = 56, | |
| 90 | NOTCONN = 57, | |
| 91 | SHUTDOWN = 58, | |
| 92 | TOOMANYREFS = 59, | |
| 93 | TIMEDOUT = 60, | |
| 94 | CONNREFUSED = 61, | |
| 95 | LOOP = 62, | |
| 96 | NAMETOOLONG = 63, | |
| 97 | HOSTDOWN = 64, | |
| 98 | HOSTUNREACH = 65, | |
| 99 | NOTEMPTY = 66, | |
| 100 | PROCLIM = 67, | |
| 101 | USERS = 68, | |
| 102 | DQUOT = 69, | |
| 103 | STALE = 70, | |
| 104 | REMOTE = 71, | |
| 105 | BADRPC = 72, | |
| 106 | RPCMISMATCH = 73, | |
| 107 | PROGUNAVAIL = 74, | |
| 108 | PROGMISMATCH = 75, | |
| 109 | PROCUNAVAIL = 76, | |
| 110 | NOLCK = 77, | |
| 111 | NOSYS = 78, | |
| 112 | FTYPE = 79, | |
| 113 | AUTH = 80, | |
| 114 | NEEDAUTH = 81, | |
| 115 | IDRM = 82, | |
| 116 | NOMSG = 83, | |
| 117 | OVERFLOW = 84, | |
| 118 | CANCELED = 85, | |
| 119 | ILSEQ = 86, | |
| 120 | NOATTR = 87, | |
| 121 | DOOFUS = 88, | |
| 122 | BADMSG = 89, | |
| 123 | MULTIHOP = 90, | |
| 124 | NOLINK = 91, | |
| 125 | PROTO = 92, | |
| 126 | NOMEDIUM = 93, | |
| 127 | ASYNC = 99, | |
| 128 | _, | |
| 129 | }; | |
| 125 | 130 | |
| 126 | 131 | pub const STDIN_FILENO = 0; |
| 127 | 132 | pub const STDOUT_FILENO = 1; |
lib/std/os/bits/freebsd.zig+128-121| ... | ... | @@ -887,127 +887,134 @@ pub usingnamespace switch (builtin.target.cpu.arch) { |
| 887 | 887 | else => struct {}, |
| 888 | 888 | }; |
| 889 | 889 | |
| 890 | pub const EPERM = 1; // Operation not permitted | |
| 891 | pub const ENOENT = 2; // No such file or directory | |
| 892 | pub const ESRCH = 3; // No such process | |
| 893 | pub const EINTR = 4; // Interrupted system call | |
| 894 | pub const EIO = 5; // Input/output error | |
| 895 | pub const ENXIO = 6; // Device not configured | |
| 896 | pub const E2BIG = 7; // Argument list too long | |
| 897 | pub const ENOEXEC = 8; // Exec format error | |
| 898 | pub const EBADF = 9; // Bad file descriptor | |
| 899 | pub const ECHILD = 10; // No child processes | |
| 900 | pub const EDEADLK = 11; // Resource deadlock avoided | |
| 901 | // 11 was EAGAIN | |
| 902 | pub const ENOMEM = 12; // Cannot allocate memory | |
| 903 | pub const EACCES = 13; // Permission denied | |
| 904 | pub const EFAULT = 14; // Bad address | |
| 905 | pub const ENOTBLK = 15; // Block device required | |
| 906 | pub const EBUSY = 16; // Device busy | |
| 907 | pub const EEXIST = 17; // File exists | |
| 908 | pub const EXDEV = 18; // Cross-device link | |
| 909 | pub const ENODEV = 19; // Operation not supported by device | |
| 910 | pub const ENOTDIR = 20; // Not a directory | |
| 911 | pub const EISDIR = 21; // Is a directory | |
| 912 | pub const EINVAL = 22; // Invalid argument | |
| 913 | pub const ENFILE = 23; // Too many open files in system | |
| 914 | pub const EMFILE = 24; // Too many open files | |
| 915 | pub const ENOTTY = 25; // Inappropriate ioctl for device | |
| 916 | pub const ETXTBSY = 26; // Text file busy | |
| 917 | pub const EFBIG = 27; // File too large | |
| 918 | pub const ENOSPC = 28; // No space left on device | |
| 919 | pub const ESPIPE = 29; // Illegal seek | |
| 920 | pub const EROFS = 30; // Read-only filesystem | |
| 921 | pub const EMLINK = 31; // Too many links | |
| 922 | pub const EPIPE = 32; // Broken pipe | |
| 923 | ||
| 924 | // math software | |
| 925 | pub const EDOM = 33; // Numerical argument out of domain | |
| 926 | pub const ERANGE = 34; // Result too large | |
| 927 | ||
| 928 | // non-blocking and interrupt i/o | |
| 929 | pub const EAGAIN = 35; // Resource temporarily unavailable | |
| 930 | pub const EWOULDBLOCK = EAGAIN; // Operation would block | |
| 931 | pub const EINPROGRESS = 36; // Operation now in progress | |
| 932 | pub const EALREADY = 37; // Operation already in progress | |
| 933 | ||
| 934 | // ipc/network software -- argument errors | |
| 935 | pub const ENOTSOCK = 38; // Socket operation on non-socket | |
| 936 | pub const EDESTADDRREQ = 39; // Destination address required | |
| 937 | pub const EMSGSIZE = 40; // Message too long | |
| 938 | pub const EPROTOTYPE = 41; // Protocol wrong type for socket | |
| 939 | pub const ENOPROTOOPT = 42; // Protocol not available | |
| 940 | pub const EPROTONOSUPPORT = 43; // Protocol not supported | |
| 941 | pub const ESOCKTNOSUPPORT = 44; // Socket type not supported | |
| 942 | pub const EOPNOTSUPP = 45; // Operation not supported | |
| 943 | pub const ENOTSUP = EOPNOTSUPP; // Operation not supported | |
| 944 | pub const EPFNOSUPPORT = 46; // Protocol family not supported | |
| 945 | pub const EAFNOSUPPORT = 47; // Address family not supported by protocol family | |
| 946 | pub const EADDRINUSE = 48; // Address already in use | |
| 947 | pub const EADDRNOTAVAIL = 49; // Can't assign requested address | |
| 948 | ||
| 949 | // ipc/network software -- operational errors | |
| 950 | pub const ENETDOWN = 50; // Network is down | |
| 951 | pub const ENETUNREACH = 51; // Network is unreachable | |
| 952 | pub const ENETRESET = 52; // Network dropped connection on reset | |
| 953 | pub const ECONNABORTED = 53; // Software caused connection abort | |
| 954 | pub const ECONNRESET = 54; // Connection reset by peer | |
| 955 | pub const ENOBUFS = 55; // No buffer space available | |
| 956 | pub const EISCONN = 56; // Socket is already connected | |
| 957 | pub const ENOTCONN = 57; // Socket is not connected | |
| 958 | pub const ESHUTDOWN = 58; // Can't send after socket shutdown | |
| 959 | pub const ETOOMANYREFS = 59; // Too many references: can't splice | |
| 960 | pub const ETIMEDOUT = 60; // Operation timed out | |
| 961 | pub const ECONNREFUSED = 61; // Connection refused | |
| 962 | ||
| 963 | pub const ELOOP = 62; // Too many levels of symbolic links | |
| 964 | pub const ENAMETOOLONG = 63; // File name too long | |
| 965 | ||
| 966 | // should be rearranged | |
| 967 | pub const EHOSTDOWN = 64; // Host is down | |
| 968 | pub const EHOSTUNREACH = 65; // No route to host | |
| 969 | pub const ENOTEMPTY = 66; // Directory not empty | |
| 970 | ||
| 971 | // quotas & mush | |
| 972 | pub const EPROCLIM = 67; // Too many processes | |
| 973 | pub const EUSERS = 68; // Too many users | |
| 974 | pub const EDQUOT = 69; // Disc quota exceeded | |
| 975 | ||
| 976 | // Network File System | |
| 977 | pub const ESTALE = 70; // Stale NFS file handle | |
| 978 | pub const EREMOTE = 71; // Too many levels of remote in path | |
| 979 | pub const EBADRPC = 72; // RPC struct is bad | |
| 980 | pub const ERPCMISMATCH = 73; // RPC version wrong | |
| 981 | pub const EPROGUNAVAIL = 74; // RPC prog. not avail | |
| 982 | pub const EPROGMISMATCH = 75; // Program version wrong | |
| 983 | pub const EPROCUNAVAIL = 76; // Bad procedure for program | |
| 984 | ||
| 985 | pub const ENOLCK = 77; // No locks available | |
| 986 | pub const ENOSYS = 78; // Function not implemented | |
| 987 | ||
| 988 | pub const EFTYPE = 79; // Inappropriate file type or format | |
| 989 | pub const EAUTH = 80; // Authentication error | |
| 990 | pub const ENEEDAUTH = 81; // Need authenticator | |
| 991 | pub const EIDRM = 82; // Identifier removed | |
| 992 | pub const ENOMSG = 83; // No message of desired type | |
| 993 | pub const EOVERFLOW = 84; // Value too large to be stored in data type | |
| 994 | pub const ECANCELED = 85; // Operation canceled | |
| 995 | pub const EILSEQ = 86; // Illegal byte sequence | |
| 996 | pub const ENOATTR = 87; // Attribute not found | |
| 997 | ||
| 998 | pub const EDOOFUS = 88; // Programming error | |
| 999 | ||
| 1000 | pub const EBADMSG = 89; // Bad message | |
| 1001 | pub const EMULTIHOP = 90; // Multihop attempted | |
| 1002 | pub const ENOLINK = 91; // Link has been severed | |
| 1003 | pub const EPROTO = 92; // Protocol error | |
| 1004 | ||
| 1005 | pub const ENOTCAPABLE = 93; // Capabilities insufficient | |
| 1006 | pub const ECAPMODE = 94; // Not permitted in capability mode | |
| 1007 | pub const ENOTRECOVERABLE = 95; // State not recoverable | |
| 1008 | pub const EOWNERDEAD = 96; // Previous owner died | |
| 1009 | ||
| 1010 | pub const ELAST = 96; // Must be equal largest errno | |
| 890 | pub const E = enum(u16) { | |
| 891 | /// No error occurred. | |
| 892 | SUCCESS = 0, | |
| 893 | ||
| 894 | PERM = 1, // Operation not permitted | |
| 895 | NOENT = 2, // No such file or directory | |
| 896 | SRCH = 3, // No such process | |
| 897 | INTR = 4, // Interrupted system call | |
| 898 | IO = 5, // Input/output error | |
| 899 | NXIO = 6, // Device not configured | |
| 900 | @"2BIG" = 7, // Argument list too long | |
| 901 | NOEXEC = 8, // Exec format error | |
| 902 | BADF = 9, // Bad file descriptor | |
| 903 | CHILD = 10, // No child processes | |
| 904 | DEADLK = 11, // Resource deadlock avoided | |
| 905 | // 11 was AGAIN | |
| 906 | NOMEM = 12, // Cannot allocate memory | |
| 907 | ACCES = 13, // Permission denied | |
| 908 | FAULT = 14, // Bad address | |
| 909 | NOTBLK = 15, // Block device required | |
| 910 | BUSY = 16, // Device busy | |
| 911 | EXIST = 17, // File exists | |
| 912 | XDEV = 18, // Cross-device link | |
| 913 | NODEV = 19, // Operation not supported by device | |
| 914 | NOTDIR = 20, // Not a directory | |
| 915 | ISDIR = 21, // Is a directory | |
| 916 | INVAL = 22, // Invalid argument | |
| 917 | NFILE = 23, // Too many open files in system | |
| 918 | MFILE = 24, // Too many open files | |
| 919 | NOTTY = 25, // Inappropriate ioctl for device | |
| 920 | TXTBSY = 26, // Text file busy | |
| 921 | FBIG = 27, // File too large | |
| 922 | NOSPC = 28, // No space left on device | |
| 923 | SPIPE = 29, // Illegal seek | |
| 924 | ROFS = 30, // Read-only filesystem | |
| 925 | MLINK = 31, // Too many links | |
| 926 | PIPE = 32, // Broken pipe | |
| 927 | ||
| 928 | // math software | |
| 929 | DOM = 33, // Numerical argument out of domain | |
| 930 | RANGE = 34, // Result too large | |
| 931 | ||
| 932 | // non-blocking and interrupt i/o | |
| 933 | ||
| 934 | /// Resource temporarily unavailable | |
| 935 | /// This code is also used for `WOULDBLOCK`: operation would block. | |
| 936 | AGAIN = 35, | |
| 937 | INPROGRESS = 36, // Operation now in progress | |
| 938 | ALREADY = 37, // Operation already in progress | |
| 939 | ||
| 940 | // ipc/network software -- argument errors | |
| 941 | NOTSOCK = 38, // Socket operation on non-socket | |
| 942 | DESTADDRREQ = 39, // Destination address required | |
| 943 | MSGSIZE = 40, // Message too long | |
| 944 | PROTOTYPE = 41, // Protocol wrong type for socket | |
| 945 | NOPROTOOPT = 42, // Protocol not available | |
| 946 | PROTONOSUPPORT = 43, // Protocol not supported | |
| 947 | SOCKTNOSUPPORT = 44, // Socket type not supported | |
| 948 | /// Operation not supported | |
| 949 | /// This code is also used for `NOTSUP`. | |
| 950 | OPNOTSUPP = 45, | |
| 951 | PFNOSUPPORT = 46, // Protocol family not supported | |
| 952 | AFNOSUPPORT = 47, // Address family not supported by protocol family | |
| 953 | ADDRINUSE = 48, // Address already in use | |
| 954 | ADDRNOTAVAIL = 49, // Can't assign requested address | |
| 955 | ||
| 956 | // ipc/network software -- operational errors | |
| 957 | NETDOWN = 50, // Network is down | |
| 958 | NETUNREACH = 51, // Network is unreachable | |
| 959 | NETRESET = 52, // Network dropped connection on reset | |
| 960 | CONNABORTED = 53, // Software caused connection abort | |
| 961 | CONNRESET = 54, // Connection reset by peer | |
| 962 | NOBUFS = 55, // No buffer space available | |
| 963 | ISCONN = 56, // Socket is already connected | |
| 964 | NOTCONN = 57, // Socket is not connected | |
| 965 | SHUTDOWN = 58, // Can't send after socket shutdown | |
| 966 | TOOMANYREFS = 59, // Too many references: can't splice | |
| 967 | TIMEDOUT = 60, // Operation timed out | |
| 968 | CONNREFUSED = 61, // Connection refused | |
| 969 | ||
| 970 | LOOP = 62, // Too many levels of symbolic links | |
| 971 | NAMETOOLONG = 63, // File name too long | |
| 972 | ||
| 973 | // should be rearranged | |
| 974 | HOSTDOWN = 64, // Host is down | |
| 975 | HOSTUNREACH = 65, // No route to host | |
| 976 | NOTEMPTY = 66, // Directory not empty | |
| 977 | ||
| 978 | // quotas & mush | |
| 979 | PROCLIM = 67, // Too many processes | |
| 980 | USERS = 68, // Too many users | |
| 981 | DQUOT = 69, // Disc quota exceeded | |
| 982 | ||
| 983 | // Network File System | |
| 984 | STALE = 70, // Stale NFS file handle | |
| 985 | REMOTE = 71, // Too many levels of remote in path | |
| 986 | BADRPC = 72, // RPC struct is bad | |
| 987 | RPCMISMATCH = 73, // RPC version wrong | |
| 988 | PROGUNAVAIL = 74, // RPC prog. not avail | |
| 989 | PROGMISMATCH = 75, // Program version wrong | |
| 990 | PROCUNAVAIL = 76, // Bad procedure for program | |
| 991 | ||
| 992 | NOLCK = 77, // No locks available | |
| 993 | NOSYS = 78, // Function not implemented | |
| 994 | ||
| 995 | FTYPE = 79, // Inappropriate file type or format | |
| 996 | AUTH = 80, // Authentication error | |
| 997 | NEEDAUTH = 81, // Need authenticator | |
| 998 | IDRM = 82, // Identifier removed | |
| 999 | NOMSG = 83, // No message of desired type | |
| 1000 | OVERFLOW = 84, // Value too large to be stored in data type | |
| 1001 | CANCELED = 85, // Operation canceled | |
| 1002 | ILSEQ = 86, // Illegal byte sequence | |
| 1003 | NOATTR = 87, // Attribute not found | |
| 1004 | ||
| 1005 | DOOFUS = 88, // Programming error | |
| 1006 | ||
| 1007 | BADMSG = 89, // Bad message | |
| 1008 | MULTIHOP = 90, // Multihop attempted | |
| 1009 | NOLINK = 91, // Link has been severed | |
| 1010 | PROTO = 92, // Protocol error | |
| 1011 | ||
| 1012 | NOTCAPABLE = 93, // Capabilities insufficient | |
| 1013 | CAPMODE = 94, // Not permitted in capability mode | |
| 1014 | NOTRECOVERABLE = 95, // State not recoverable | |
| 1015 | OWNERDEAD = 96, // Previous owner died | |
| 1016 | _, | |
| 1017 | }; | |
| 1011 | 1018 | |
| 1012 | 1019 | pub const MINSIGSTKSZ = switch (builtin.target.cpu.arch) { |
| 1013 | 1020 | .i386, .x86_64 => 2048, |
lib/std/os/bits/haiku.zig+124-119| ... | ... | @@ -734,125 +734,130 @@ pub const sigset_t = extern struct { |
| 734 | 734 | __bits: [_SIG_WORDS]u32, |
| 735 | 735 | }; |
| 736 | 736 | |
| 737 | pub const EPERM = -0x7ffffff1; // Operation not permitted | |
| 738 | pub const ENOENT = -0x7fff9ffd; // No such file or directory | |
| 739 | pub const ESRCH = -0x7fff8ff3; // No such process | |
| 740 | pub const EINTR = -0x7ffffff6; // Interrupted system call | |
| 741 | pub const EIO = -0x7fffffff; // Input/output error | |
| 742 | pub const ENXIO = -0x7fff8ff5; // Device not configured | |
| 743 | pub const E2BIG = -0x7fff8fff; // Argument list too long | |
| 744 | pub const ENOEXEC = -0x7fffecfe; // Exec format error | |
| 745 | pub const ECHILD = -0x7fff8ffe; // No child processes | |
| 746 | pub const EDEADLK = -0x7fff8ffd; // Resource deadlock avoided | |
| 747 | pub const ENOMEM = -0x80000000; // Cannot allocate memory | |
| 748 | pub const EACCES = -0x7ffffffe; // Permission denied | |
| 749 | pub const EFAULT = -0x7fffecff; // Bad address | |
| 750 | pub const EBUSY = -0x7ffffff2; // Device busy | |
| 751 | pub const EEXIST = -0x7fff9ffe; // File exists | |
| 752 | pub const EXDEV = -0x7fff9ff5; // Cross-device link | |
| 753 | pub const ENODEV = -0x7fff8ff9; // Operation not supported by device | |
| 754 | pub const ENOTDIR = -0x7fff9ffb; // Not a directory | |
| 755 | pub const EISDIR = -0x7fff9ff7; // Is a directory | |
| 756 | pub const EINVAL = -0x7ffffffb; // Invalid argument | |
| 757 | pub const ENFILE = -0x7fff8ffa; // Too many open files in system | |
| 758 | pub const EMFILE = -0x7fff9ff6; // Too many open files | |
| 759 | pub const ENOTTY = -0x7fff8ff6; // Inappropriate ioctl for device | |
| 760 | pub const ETXTBSY = -0x7fff8fc5; // Text file busy | |
| 761 | pub const EFBIG = -0x7fff8ffc; // File too large | |
| 762 | pub const ENOSPC = -0x7fff9ff9; // No space left on device | |
| 763 | pub const ESPIPE = -0x7fff8ff4; // Illegal seek | |
| 764 | pub const EROFS = -0x7fff9ff8; // Read-only filesystem | |
| 765 | pub const EMLINK = -0x7fff8ffb; // Too many links | |
| 766 | pub const EPIPE = -0x7fff9ff3; // Broken pipe | |
| 767 | pub const EBADF = -0x7fffa000; // Bad file descriptor | |
| 768 | ||
| 769 | // math software | |
| 770 | pub const EDOM = 33; // Numerical argument out of domain | |
| 771 | pub const ERANGE = 34; // Result too large | |
| 772 | ||
| 773 | // non-blocking and interrupt i/o | |
| 774 | pub const EAGAIN = -0x7ffffff5; | |
| 775 | pub const EWOULDBLOCK = -0x7ffffff5; | |
| 776 | pub const EINPROGRESS = -0x7fff8fdc; | |
| 777 | pub const EALREADY = -0x7fff8fdb; | |
| 778 | ||
| 779 | // ipc/network software -- argument errors | |
| 780 | pub const ENOTSOCK = 38; // Socket operation on non-socket | |
| 781 | pub const EDESTADDRREQ = 39; // Destination address required | |
| 782 | pub const EMSGSIZE = 40; // Message too long | |
| 783 | pub const EPROTOTYPE = 41; // Protocol wrong type for socket | |
| 784 | pub const ENOPROTOOPT = 42; // Protocol not available | |
| 785 | pub const EPROTONOSUPPORT = 43; // Protocol not supported | |
| 786 | pub const ESOCKTNOSUPPORT = 44; // Socket type not supported | |
| 787 | pub const EOPNOTSUPP = 45; // Operation not supported | |
| 788 | pub const ENOTSUP = EOPNOTSUPP; // Operation not supported | |
| 789 | pub const EPFNOSUPPORT = 46; // Protocol family not supported | |
| 790 | pub const EAFNOSUPPORT = 47; // Address family not supported by protocol family | |
| 791 | pub const EADDRINUSE = 48; // Address already in use | |
| 792 | pub const EADDRNOTAVAIL = 49; // Can't assign requested address | |
| 793 | ||
| 794 | // ipc/network software -- operational errors | |
| 795 | pub const ENETDOWN = 50; // Network is down | |
| 796 | pub const ENETUNREACH = 51; // Network is unreachable | |
| 797 | pub const ENETRESET = 52; // Network dropped connection on reset | |
| 798 | pub const ECONNABORTED = 53; // Software caused connection abort | |
| 799 | pub const ECONNRESET = 54; // Connection reset by peer | |
| 800 | pub const ENOBUFS = 55; // No buffer space available | |
| 801 | pub const EISCONN = 56; // Socket is already connected | |
| 802 | pub const ENOTCONN = 57; // Socket is not connected | |
| 803 | pub const ESHUTDOWN = 58; // Can't send after socket shutdown | |
| 804 | pub const ETOOMANYREFS = 59; // Too many references: can't splice | |
| 805 | pub const ETIMEDOUT = 60; // Operation timed out | |
| 806 | pub const ECONNREFUSED = 61; // Connection refused | |
| 807 | ||
| 808 | pub const ELOOP = 62; // Too many levels of symbolic links | |
| 809 | pub const ENAMETOOLONG = 63; // File name too long | |
| 810 | ||
| 811 | // should be rearranged | |
| 812 | pub const EHOSTDOWN = 64; // Host is down | |
| 813 | pub const EHOSTUNREACH = 65; // No route to host | |
| 814 | pub const ENOTEMPTY = 66; // Directory not empty | |
| 815 | ||
| 816 | // quotas & mush | |
| 817 | pub const EPROCLIM = 67; // Too many processes | |
| 818 | pub const EUSERS = 68; // Too many users | |
| 819 | pub const EDQUOT = 69; // Disc quota exceeded | |
| 820 | ||
| 821 | // Network File System | |
| 822 | pub const ESTALE = 70; // Stale NFS file handle | |
| 823 | pub const EREMOTE = 71; // Too many levels of remote in path | |
| 824 | pub const EBADRPC = 72; // RPC struct is bad | |
| 825 | pub const ERPCMISMATCH = 73; // RPC version wrong | |
| 826 | pub const EPROGUNAVAIL = 74; // RPC prog. not avail | |
| 827 | pub const EPROGMISMATCH = 75; // Program version wrong | |
| 828 | pub const EPROCUNAVAIL = 76; // Bad procedure for program | |
| 829 | ||
| 830 | pub const ENOLCK = 77; // No locks available | |
| 831 | pub const ENOSYS = 78; // Function not implemented | |
| 832 | ||
| 833 | pub const EFTYPE = 79; // Inappropriate file type or format | |
| 834 | pub const EAUTH = 80; // Authentication error | |
| 835 | pub const ENEEDAUTH = 81; // Need authenticator | |
| 836 | pub const EIDRM = 82; // Identifier removed | |
| 837 | pub const ENOMSG = 83; // No message of desired type | |
| 838 | pub const EOVERFLOW = 84; // Value too large to be stored in data type | |
| 839 | pub const ECANCELED = 85; // Operation canceled | |
| 840 | pub const EILSEQ = 86; // Illegal byte sequence | |
| 841 | pub const ENOATTR = 87; // Attribute not found | |
| 842 | ||
| 843 | pub const EDOOFUS = 88; // Programming error | |
| 844 | ||
| 845 | pub const EBADMSG = 89; // Bad message | |
| 846 | pub const EMULTIHOP = 90; // Multihop attempted | |
| 847 | pub const ENOLINK = 91; // Link has been severed | |
| 848 | pub const EPROTO = 92; // Protocol error | |
| 849 | ||
| 850 | pub const ENOTCAPABLE = 93; // Capabilities insufficient | |
| 851 | pub const ECAPMODE = 94; // Not permitted in capability mode | |
| 852 | pub const ENOTRECOVERABLE = 95; // State not recoverable | |
| 853 | pub const EOWNERDEAD = 96; // Previous owner died | |
| 854 | ||
| 855 | pub const ELAST = 96; // Must be equal largest errno | |
| 737 | pub const E = enum(i32) { | |
| 738 | /// No error occurred. | |
| 739 | SUCCESS = 0, | |
| 740 | PERM = -0x7ffffff1, // Operation not permitted | |
| 741 | NOENT = -0x7fff9ffd, // No such file or directory | |
| 742 | SRCH = -0x7fff8ff3, // No such process | |
| 743 | INTR = -0x7ffffff6, // Interrupted system call | |
| 744 | IO = -0x7fffffff, // Input/output error | |
| 745 | NXIO = -0x7fff8ff5, // Device not configured | |
| 746 | @"2BIG" = -0x7fff8fff, // Argument list too long | |
| 747 | NOEXEC = -0x7fffecfe, // Exec format error | |
| 748 | CHILD = -0x7fff8ffe, // No child processes | |
| 749 | DEADLK = -0x7fff8ffd, // Resource deadlock avoided | |
| 750 | NOMEM = -0x80000000, // Cannot allocate memory | |
| 751 | ACCES = -0x7ffffffe, // Permission denied | |
| 752 | FAULT = -0x7fffecff, // Bad address | |
| 753 | BUSY = -0x7ffffff2, // Device busy | |
| 754 | EXIST = -0x7fff9ffe, // File exists | |
| 755 | XDEV = -0x7fff9ff5, // Cross-device link | |
| 756 | NODEV = -0x7fff8ff9, // Operation not supported by device | |
| 757 | NOTDIR = -0x7fff9ffb, // Not a directory | |
| 758 | ISDIR = -0x7fff9ff7, // Is a directory | |
| 759 | INVAL = -0x7ffffffb, // Invalid argument | |
| 760 | NFILE = -0x7fff8ffa, // Too many open files in system | |
| 761 | MFILE = -0x7fff9ff6, // Too many open files | |
| 762 | NOTTY = -0x7fff8ff6, // Inappropriate ioctl for device | |
| 763 | TXTBSY = -0x7fff8fc5, // Text file busy | |
| 764 | FBIG = -0x7fff8ffc, // File too large | |
| 765 | NOSPC = -0x7fff9ff9, // No space left on device | |
| 766 | SPIPE = -0x7fff8ff4, // Illegal seek | |
| 767 | ROFS = -0x7fff9ff8, // Read-only filesystem | |
| 768 | MLINK = -0x7fff8ffb, // Too many links | |
| 769 | PIPE = -0x7fff9ff3, // Broken pipe | |
| 770 | BADF = -0x7fffa000, // Bad file descriptor | |
| 771 | ||
| 772 | // math software | |
| 773 | DOM = 33, // Numerical argument out of domain | |
| 774 | RANGE = 34, // Result too large | |
| 775 | ||
| 776 | // non-blocking and interrupt i/o | |
| 777 | ||
| 778 | /// Also used for `WOULDBLOCK`. | |
| 779 | AGAIN = -0x7ffffff5, | |
| 780 | INPROGRESS = -0x7fff8fdc, | |
| 781 | ALREADY = -0x7fff8fdb, | |
| 782 | ||
| 783 | // ipc/network software -- argument errors | |
| 784 | NOTSOCK = 38, // Socket operation on non-socket | |
| 785 | DESTADDRREQ = 39, // Destination address required | |
| 786 | MSGSIZE = 40, // Message too long | |
| 787 | PROTOTYPE = 41, // Protocol wrong type for socket | |
| 788 | NOPROTOOPT = 42, // Protocol not available | |
| 789 | PROTONOSUPPORT = 43, // Protocol not supported | |
| 790 | SOCKTNOSUPPORT = 44, // Socket type not supported | |
| 791 | /// Also used for `NOTSUP`. | |
| 792 | OPNOTSUPP = 45, // Operation not supported | |
| 793 | PFNOSUPPORT = 46, // Protocol family not supported | |
| 794 | AFNOSUPPORT = 47, // Address family not supported by protocol family | |
| 795 | ADDRINUSE = 48, // Address already in use | |
| 796 | ADDRNOTAVAIL = 49, // Can't assign requested address | |
| 797 | ||
| 798 | // ipc/network software -- operational errors | |
| 799 | NETDOWN = 50, // Network is down | |
| 800 | NETUNREACH = 51, // Network is unreachable | |
| 801 | NETRESET = 52, // Network dropped connection on reset | |
| 802 | CONNABORTED = 53, // Software caused connection abort | |
| 803 | CONNRESET = 54, // Connection reset by peer | |
| 804 | NOBUFS = 55, // No buffer space available | |
| 805 | ISCONN = 56, // Socket is already connected | |
| 806 | NOTCONN = 57, // Socket is not connected | |
| 807 | SHUTDOWN = 58, // Can't send after socket shutdown | |
| 808 | TOOMANYREFS = 59, // Too many references: can't splice | |
| 809 | TIMEDOUT = 60, // Operation timed out | |
| 810 | CONNREFUSED = 61, // Connection refused | |
| 811 | ||
| 812 | LOOP = 62, // Too many levels of symbolic links | |
| 813 | NAMETOOLONG = 63, // File name too long | |
| 814 | ||
| 815 | // should be rearranged | |
| 816 | HOSTDOWN = 64, // Host is down | |
| 817 | HOSTUNREACH = 65, // No route to host | |
| 818 | NOTEMPTY = 66, // Directory not empty | |
| 819 | ||
| 820 | // quotas & mush | |
| 821 | PROCLIM = 67, // Too many processes | |
| 822 | USERS = 68, // Too many users | |
| 823 | DQUOT = 69, // Disc quota exceeded | |
| 824 | ||
| 825 | // Network File System | |
| 826 | STALE = 70, // Stale NFS file handle | |
| 827 | REMOTE = 71, // Too many levels of remote in path | |
| 828 | BADRPC = 72, // RPC struct is bad | |
| 829 | RPCMISMATCH = 73, // RPC version wrong | |
| 830 | PROGUNAVAIL = 74, // RPC prog. not avail | |
| 831 | PROGMISMATCH = 75, // Program version wrong | |
| 832 | PROCUNAVAIL = 76, // Bad procedure for program | |
| 833 | ||
| 834 | NOLCK = 77, // No locks available | |
| 835 | NOSYS = 78, // Function not implemented | |
| 836 | ||
| 837 | FTYPE = 79, // Inappropriate file type or format | |
| 838 | AUTH = 80, // Authentication error | |
| 839 | NEEDAUTH = 81, // Need authenticator | |
| 840 | IDRM = 82, // Identifier removed | |
| 841 | NOMSG = 83, // No message of desired type | |
| 842 | OVERFLOW = 84, // Value too large to be stored in data type | |
| 843 | CANCELED = 85, // Operation canceled | |
| 844 | ILSEQ = 86, // Illegal byte sequence | |
| 845 | NOATTR = 87, // Attribute not found | |
| 846 | ||
| 847 | DOOFUS = 88, // Programming error | |
| 848 | ||
| 849 | BADMSG = 89, // Bad message | |
| 850 | MULTIHOP = 90, // Multihop attempted | |
| 851 | NOLINK = 91, // Link has been severed | |
| 852 | PROTO = 92, // Protocol error | |
| 853 | ||
| 854 | NOTCAPABLE = 93, // Capabilities insufficient | |
| 855 | CAPMODE = 94, // Not permitted in capability mode | |
| 856 | NOTRECOVERABLE = 95, // State not recoverable | |
| 857 | OWNERDEAD = 96, // Previous owner died | |
| 858 | ||
| 859 | _, | |
| 860 | }; | |
| 856 | 861 | |
| 857 | 862 | pub const MINSIGSTKSZ = switch (builtin.cpu.arch) { |
| 858 | 863 | .i386, .x86_64 => 2048, |
lib/std/os/bits/linux.zig+11-4| ... | ... | @@ -8,10 +8,10 @@ const maxInt = std.math.maxInt; |
| 8 | 8 | const arch = @import("builtin").target.cpu.arch; |
| 9 | 9 | pub usingnamespace @import("posix.zig"); |
| 10 | 10 | |
| 11 | pub usingnamespace switch (arch) { | |
| 12 | .mips, .mipsel => @import("linux/errno-mips.zig"), | |
| 13 | .sparc, .sparcel, .sparcv9 => @import("linux/errno-sparc.zig"), | |
| 14 | else => @import("linux/errno-generic.zig"), | |
| 11 | pub const E = switch (arch) { | |
| 12 | .mips, .mipsel => @import("linux/errno/mips.zig").E, | |
| 13 | .sparc, .sparcel, .sparcv9 => @import("linux/errno/sparc.zig").E, | |
| 14 | else => @import("linux/errno/generic.zig").E, | |
| 15 | 15 | }; |
| 16 | 16 | |
| 17 | 17 | pub usingnamespace switch (arch) { |
| ... | ... | @@ -1665,6 +1665,13 @@ pub const io_uring_cqe = extern struct { |
| 1665 | 1665 | /// result code for this event |
| 1666 | 1666 | res: i32, |
| 1667 | 1667 | flags: u32, |
| 1668 | ||
| 1669 | pub fn err(self: io_uring_cqe) E { | |
| 1670 | if (self.res > -4096 and self.res < 0) { | |
| 1671 | return @intToEnum(E, -self.res); | |
| 1672 | } | |
| 1673 | return .SUCCESS; | |
| 1674 | } | |
| 1668 | 1675 | }; |
| 1669 | 1676 | |
| 1670 | 1677 | // io_uring_cqe.flags |
lib/std/os/bits/linux/errno-generic.zig deleted-462| ... | ... | @@ -1,462 +0,0 @@ |
| 1 | // SPDX-License-Identifier: MIT | |
| 2 | // Copyright (c) 2015-2021 Zig Contributors | |
| 3 | // This file is part of [zig](https://ziglang.org/), which is MIT licensed. | |
| 4 | // The MIT license requires this copyright notice to be included in all copies | |
| 5 | // and substantial portions of the software. | |
| 6 | /// Operation not permitted | |
| 7 | pub const EPERM = 1; | |
| 8 | ||
| 9 | /// No such file or directory | |
| 10 | pub const ENOENT = 2; | |
| 11 | ||
| 12 | /// No such process | |
| 13 | pub const ESRCH = 3; | |
| 14 | ||
| 15 | /// Interrupted system call | |
| 16 | pub const EINTR = 4; | |
| 17 | ||
| 18 | /// I/O error | |
| 19 | pub const EIO = 5; | |
| 20 | ||
| 21 | /// No such device or address | |
| 22 | pub const ENXIO = 6; | |
| 23 | ||
| 24 | /// Arg list too long | |
| 25 | pub const E2BIG = 7; | |
| 26 | ||
| 27 | /// Exec format error | |
| 28 | pub const ENOEXEC = 8; | |
| 29 | ||
| 30 | /// Bad file number | |
| 31 | pub const EBADF = 9; | |
| 32 | ||
| 33 | /// No child processes | |
| 34 | pub const ECHILD = 10; | |
| 35 | ||
| 36 | /// Try again | |
| 37 | pub const EAGAIN = 11; | |
| 38 | ||
| 39 | /// Out of memory | |
| 40 | pub const ENOMEM = 12; | |
| 41 | ||
| 42 | /// Permission denied | |
| 43 | pub const EACCES = 13; | |
| 44 | ||
| 45 | /// Bad address | |
| 46 | pub const EFAULT = 14; | |
| 47 | ||
| 48 | /// Block device required | |
| 49 | pub const ENOTBLK = 15; | |
| 50 | ||
| 51 | /// Device or resource busy | |
| 52 | pub const EBUSY = 16; | |
| 53 | ||
| 54 | /// File exists | |
| 55 | pub const EEXIST = 17; | |
| 56 | ||
| 57 | /// Cross-device link | |
| 58 | pub const EXDEV = 18; | |
| 59 | ||
| 60 | /// No such device | |
| 61 | pub const ENODEV = 19; | |
| 62 | ||
| 63 | /// Not a directory | |
| 64 | pub const ENOTDIR = 20; | |
| 65 | ||
| 66 | /// Is a directory | |
| 67 | pub const EISDIR = 21; | |
| 68 | ||
| 69 | /// Invalid argument | |
| 70 | pub const EINVAL = 22; | |
| 71 | ||
| 72 | /// File table overflow | |
| 73 | pub const ENFILE = 23; | |
| 74 | ||
| 75 | /// Too many open files | |
| 76 | pub const EMFILE = 24; | |
| 77 | ||
| 78 | /// Not a typewriter | |
| 79 | pub const ENOTTY = 25; | |
| 80 | ||
| 81 | /// Text file busy | |
| 82 | pub const ETXTBSY = 26; | |
| 83 | ||
| 84 | /// File too large | |
| 85 | pub const EFBIG = 27; | |
| 86 | ||
| 87 | /// No space left on device | |
| 88 | pub const ENOSPC = 28; | |
| 89 | ||
| 90 | /// Illegal seek | |
| 91 | pub const ESPIPE = 29; | |
| 92 | ||
| 93 | /// Read-only file system | |
| 94 | pub const EROFS = 30; | |
| 95 | ||
| 96 | /// Too many links | |
| 97 | pub const EMLINK = 31; | |
| 98 | ||
| 99 | /// Broken pipe | |
| 100 | pub const EPIPE = 32; | |
| 101 | ||
| 102 | /// Math argument out of domain of func | |
| 103 | pub const EDOM = 33; | |
| 104 | ||
| 105 | /// Math result not representable | |
| 106 | pub const ERANGE = 34; | |
| 107 | ||
| 108 | /// Resource deadlock would occur | |
| 109 | pub const EDEADLK = 35; | |
| 110 | ||
| 111 | /// File name too long | |
| 112 | pub const ENAMETOOLONG = 36; | |
| 113 | ||
| 114 | /// No record locks available | |
| 115 | pub const ENOLCK = 37; | |
| 116 | ||
| 117 | /// Function not implemented | |
| 118 | pub const ENOSYS = 38; | |
| 119 | ||
| 120 | /// Directory not empty | |
| 121 | pub const ENOTEMPTY = 39; | |
| 122 | ||
| 123 | /// Too many symbolic links encountered | |
| 124 | pub const ELOOP = 40; | |
| 125 | ||
| 126 | /// Operation would block | |
| 127 | pub const EWOULDBLOCK = EAGAIN; | |
| 128 | ||
| 129 | /// No message of desired type | |
| 130 | pub const ENOMSG = 42; | |
| 131 | ||
| 132 | /// Identifier removed | |
| 133 | pub const EIDRM = 43; | |
| 134 | ||
| 135 | /// Channel number out of range | |
| 136 | pub const ECHRNG = 44; | |
| 137 | ||
| 138 | /// Level 2 not synchronized | |
| 139 | pub const EL2NSYNC = 45; | |
| 140 | ||
| 141 | /// Level 3 halted | |
| 142 | pub const EL3HLT = 46; | |
| 143 | ||
| 144 | /// Level 3 reset | |
| 145 | pub const EL3RST = 47; | |
| 146 | ||
| 147 | /// Link number out of range | |
| 148 | pub const ELNRNG = 48; | |
| 149 | ||
| 150 | /// Protocol driver not attached | |
| 151 | pub const EUNATCH = 49; | |
| 152 | ||
| 153 | /// No CSI structure available | |
| 154 | pub const ENOCSI = 50; | |
| 155 | ||
| 156 | /// Level 2 halted | |
| 157 | pub const EL2HLT = 51; | |
| 158 | ||
| 159 | /// Invalid exchange | |
| 160 | pub const EBADE = 52; | |
| 161 | ||
| 162 | /// Invalid request descriptor | |
| 163 | pub const EBADR = 53; | |
| 164 | ||
| 165 | /// Exchange full | |
| 166 | pub const EXFULL = 54; | |
| 167 | ||
| 168 | /// No anode | |
| 169 | pub const ENOANO = 55; | |
| 170 | ||
| 171 | /// Invalid request code | |
| 172 | pub const EBADRQC = 56; | |
| 173 | ||
| 174 | /// Invalid slot | |
| 175 | pub const EBADSLT = 57; | |
| 176 | ||
| 177 | /// Bad font file format | |
| 178 | pub const EBFONT = 59; | |
| 179 | ||
| 180 | /// Device not a stream | |
| 181 | pub const ENOSTR = 60; | |
| 182 | ||
| 183 | /// No data available | |
| 184 | pub const ENODATA = 61; | |
| 185 | ||
| 186 | /// Timer expired | |
| 187 | pub const ETIME = 62; | |
| 188 | ||
| 189 | /// Out of streams resources | |
| 190 | pub const ENOSR = 63; | |
| 191 | ||
| 192 | /// Machine is not on the network | |
| 193 | pub const ENONET = 64; | |
| 194 | ||
| 195 | /// Package not installed | |
| 196 | pub const ENOPKG = 65; | |
| 197 | ||
| 198 | /// Object is remote | |
| 199 | pub const EREMOTE = 66; | |
| 200 | ||
| 201 | /// Link has been severed | |
| 202 | pub const ENOLINK = 67; | |
| 203 | ||
| 204 | /// Advertise error | |
| 205 | pub const EADV = 68; | |
| 206 | ||
| 207 | /// Srmount error | |
| 208 | pub const ESRMNT = 69; | |
| 209 | ||
| 210 | /// Communication error on send | |
| 211 | pub const ECOMM = 70; | |
| 212 | ||
| 213 | /// Protocol error | |
| 214 | pub const EPROTO = 71; | |
| 215 | ||
| 216 | /// Multihop attempted | |
| 217 | pub const EMULTIHOP = 72; | |
| 218 | ||
| 219 | /// RFS specific error | |
| 220 | pub const EDOTDOT = 73; | |
| 221 | ||
| 222 | /// Not a data message | |
| 223 | pub const EBADMSG = 74; | |
| 224 | ||
| 225 | /// Value too large for defined data type | |
| 226 | pub const EOVERFLOW = 75; | |
| 227 | ||
| 228 | /// Name not unique on network | |
| 229 | pub const ENOTUNIQ = 76; | |
| 230 | ||
| 231 | /// File descriptor in bad state | |
| 232 | pub const EBADFD = 77; | |
| 233 | ||
| 234 | /// Remote address changed | |
| 235 | pub const EREMCHG = 78; | |
| 236 | ||
| 237 | /// Can not access a needed shared library | |
| 238 | pub const ELIBACC = 79; | |
| 239 | ||
| 240 | /// Accessing a corrupted shared library | |
| 241 | pub const ELIBBAD = 80; | |
| 242 | ||
| 243 | /// .lib section in a.out corrupted | |
| 244 | pub const ELIBSCN = 81; | |
| 245 | ||
| 246 | /// Attempting to link in too many shared libraries | |
| 247 | pub const ELIBMAX = 82; | |
| 248 | ||
| 249 | /// Cannot exec a shared library directly | |
| 250 | pub const ELIBEXEC = 83; | |
| 251 | ||
| 252 | /// Illegal byte sequence | |
| 253 | pub const EILSEQ = 84; | |
| 254 | ||
| 255 | /// Interrupted system call should be restarted | |
| 256 | pub const ERESTART = 85; | |
| 257 | ||
| 258 | /// Streams pipe error | |
| 259 | pub const ESTRPIPE = 86; | |
| 260 | ||
| 261 | /// Too many users | |
| 262 | pub const EUSERS = 87; | |
| 263 | ||
| 264 | /// Socket operation on non-socket | |
| 265 | pub const ENOTSOCK = 88; | |
| 266 | ||
| 267 | /// Destination address required | |
| 268 | pub const EDESTADDRREQ = 89; | |
| 269 | ||
| 270 | /// Message too long | |
| 271 | pub const EMSGSIZE = 90; | |
| 272 | ||
| 273 | /// Protocol wrong type for socket | |
| 274 | pub const EPROTOTYPE = 91; | |
| 275 | ||
| 276 | /// Protocol not available | |
| 277 | pub const ENOPROTOOPT = 92; | |
| 278 | ||
| 279 | /// Protocol not supported | |
| 280 | pub const EPROTONOSUPPORT = 93; | |
| 281 | ||
| 282 | /// Socket type not supported | |
| 283 | pub const ESOCKTNOSUPPORT = 94; | |
| 284 | ||
| 285 | /// Operation not supported on transport endpoint | |
| 286 | pub const EOPNOTSUPP = 95; | |
| 287 | pub const ENOTSUP = EOPNOTSUPP; | |
| 288 | ||
| 289 | /// Protocol family not supported | |
| 290 | pub const EPFNOSUPPORT = 96; | |
| 291 | ||
| 292 | /// Address family not supported by protocol | |
| 293 | pub const EAFNOSUPPORT = 97; | |
| 294 | ||
| 295 | /// Address already in use | |
| 296 | pub const EADDRINUSE = 98; | |
| 297 | ||
| 298 | /// Cannot assign requested address | |
| 299 | pub const EADDRNOTAVAIL = 99; | |
| 300 | ||
| 301 | /// Network is down | |
| 302 | pub const ENETDOWN = 100; | |
| 303 | ||
| 304 | /// Network is unreachable | |
| 305 | pub const ENETUNREACH = 101; | |
| 306 | ||
| 307 | /// Network dropped connection because of reset | |
| 308 | pub const ENETRESET = 102; | |
| 309 | ||
| 310 | /// Software caused connection abort | |
| 311 | pub const ECONNABORTED = 103; | |
| 312 | ||
| 313 | /// Connection reset by peer | |
| 314 | pub const ECONNRESET = 104; | |
| 315 | ||
| 316 | /// No buffer space available | |
| 317 | pub const ENOBUFS = 105; | |
| 318 | ||
| 319 | /// Transport endpoint is already connected | |
| 320 | pub const EISCONN = 106; | |
| 321 | ||
| 322 | /// Transport endpoint is not connected | |
| 323 | pub const ENOTCONN = 107; | |
| 324 | ||
| 325 | /// Cannot send after transport endpoint shutdown | |
| 326 | pub const ESHUTDOWN = 108; | |
| 327 | ||
| 328 | /// Too many references: cannot splice | |
| 329 | pub const ETOOMANYREFS = 109; | |
| 330 | ||
| 331 | /// Connection timed out | |
| 332 | pub const ETIMEDOUT = 110; | |
| 333 | ||
| 334 | /// Connection refused | |
| 335 | pub const ECONNREFUSED = 111; | |
| 336 | ||
| 337 | /// Host is down | |
| 338 | pub const EHOSTDOWN = 112; | |
| 339 | ||
| 340 | /// No route to host | |
| 341 | pub const EHOSTUNREACH = 113; | |
| 342 | ||
| 343 | /// Operation already in progress | |
| 344 | pub const EALREADY = 114; | |
| 345 | ||
| 346 | /// Operation now in progress | |
| 347 | pub const EINPROGRESS = 115; | |
| 348 | ||
| 349 | /// Stale NFS file handle | |
| 350 | pub const ESTALE = 116; | |
| 351 | ||
| 352 | /// Structure needs cleaning | |
| 353 | pub const EUCLEAN = 117; | |
| 354 | ||
| 355 | /// Not a XENIX named type file | |
| 356 | pub const ENOTNAM = 118; | |
| 357 | ||
| 358 | /// No XENIX semaphores available | |
| 359 | pub const ENAVAIL = 119; | |
| 360 | ||
| 361 | /// Is a named type file | |
| 362 | pub const EISNAM = 120; | |
| 363 | ||
| 364 | /// Remote I/O error | |
| 365 | pub const EREMOTEIO = 121; | |
| 366 | ||
| 367 | /// Quota exceeded | |
| 368 | pub const EDQUOT = 122; | |
| 369 | ||
| 370 | /// No medium found | |
| 371 | pub const ENOMEDIUM = 123; | |
| 372 | ||
| 373 | /// Wrong medium type | |
| 374 | pub const EMEDIUMTYPE = 124; | |
| 375 | ||
| 376 | /// Operation canceled | |
| 377 | pub const ECANCELED = 125; | |
| 378 | ||
| 379 | /// Required key not available | |
| 380 | pub const ENOKEY = 126; | |
| 381 | ||
| 382 | /// Key has expired | |
| 383 | pub const EKEYEXPIRED = 127; | |
| 384 | ||
| 385 | /// Key has been revoked | |
| 386 | pub const EKEYREVOKED = 128; | |
| 387 | ||
| 388 | /// Key was rejected by service | |
| 389 | pub const EKEYREJECTED = 129; | |
| 390 | ||
| 391 | // for robust mutexes | |
| 392 | ||
| 393 | /// Owner died | |
| 394 | pub const EOWNERDEAD = 130; | |
| 395 | ||
| 396 | /// State not recoverable | |
| 397 | pub const ENOTRECOVERABLE = 131; | |
| 398 | ||
| 399 | /// Operation not possible due to RF-kill | |
| 400 | pub const ERFKILL = 132; | |
| 401 | ||
| 402 | /// Memory page has hardware error | |
| 403 | pub const EHWPOISON = 133; | |
| 404 | ||
| 405 | // nameserver query return codes | |
| 406 | ||
| 407 | /// DNS server returned answer with no data | |
| 408 | pub const ENSROK = 0; | |
| 409 | ||
| 410 | /// DNS server returned answer with no data | |
| 411 | pub const ENSRNODATA = 160; | |
| 412 | ||
| 413 | /// DNS server claims query was misformatted | |
| 414 | pub const ENSRFORMERR = 161; | |
| 415 | ||
| 416 | /// DNS server returned general failure | |
| 417 | pub const ENSRSERVFAIL = 162; | |
| 418 | ||
| 419 | /// Domain name not found | |
| 420 | pub const ENSRNOTFOUND = 163; | |
| 421 | ||
| 422 | /// DNS server does not implement requested operation | |
| 423 | pub const ENSRNOTIMP = 164; | |
| 424 | ||
| 425 | /// DNS server refused query | |
| 426 | pub const ENSRREFUSED = 165; | |
| 427 | ||
| 428 | /// Misformatted DNS query | |
| 429 | pub const ENSRBADQUERY = 166; | |
| 430 | ||
| 431 | /// Misformatted domain name | |
| 432 | pub const ENSRBADNAME = 167; | |
| 433 | ||
| 434 | /// Unsupported address family | |
| 435 | pub const ENSRBADFAMILY = 168; | |
| 436 | ||
| 437 | /// Misformatted DNS reply | |
| 438 | pub const ENSRBADRESP = 169; | |
| 439 | ||
| 440 | /// Could not contact DNS servers | |
| 441 | pub const ENSRCONNREFUSED = 170; | |
| 442 | ||
| 443 | /// Timeout while contacting DNS servers | |
| 444 | pub const ENSRTIMEOUT = 171; | |
| 445 | ||
| 446 | /// End of file | |
| 447 | pub const ENSROF = 172; | |
| 448 | ||
| 449 | /// Error reading file | |
| 450 | pub const ENSRFILE = 173; | |
| 451 | ||
| 452 | /// Out of memory | |
| 453 | pub const ENSRNOMEM = 174; | |
| 454 | ||
| 455 | /// Application terminated lookup | |
| 456 | pub const ENSRDESTRUCTION = 175; | |
| 457 | ||
| 458 | /// Domain name is too long | |
| 459 | pub const ENSRQUERYDOMAINTOOLONG = 176; | |
| 460 | ||
| 461 | /// Domain name is too long | |
| 462 | pub const ENSRCNAMELOOP = 177; |
lib/std/os/bits/linux/errno-mips.zig deleted-143| ... | ... | @@ -1,143 +0,0 @@ |
| 1 | // SPDX-License-Identifier: MIT | |
| 2 | // Copyright (c) 2015-2021 Zig Contributors | |
| 3 | // This file is part of [zig](https://ziglang.org/), which is MIT licensed. | |
| 4 | // The MIT license requires this copyright notice to be included in all copies | |
| 5 | // and substantial portions of the software. | |
| 6 | ||
| 7 | // These are MIPS ABI compatible. | |
| 8 | ||
| 9 | pub const EPERM = 1; | |
| 10 | pub const ENOENT = 2; | |
| 11 | pub const ESRCH = 3; | |
| 12 | pub const EINTR = 4; | |
| 13 | pub const EIO = 5; | |
| 14 | pub const ENXIO = 6; | |
| 15 | pub const E2BIG = 7; | |
| 16 | pub const ENOEXEC = 8; | |
| 17 | pub const EBADF = 9; | |
| 18 | pub const ECHILD = 10; | |
| 19 | pub const EAGAIN = 11; | |
| 20 | pub const ENOMEM = 12; | |
| 21 | pub const EACCES = 13; | |
| 22 | pub const EFAULT = 14; | |
| 23 | pub const ENOTBLK = 15; | |
| 24 | pub const EBUSY = 16; | |
| 25 | pub const EEXIST = 17; | |
| 26 | pub const EXDEV = 18; | |
| 27 | pub const ENODEV = 19; | |
| 28 | pub const ENOTDIR = 20; | |
| 29 | pub const EISDIR = 21; | |
| 30 | pub const EINVAL = 22; | |
| 31 | pub const ENFILE = 23; | |
| 32 | pub const EMFILE = 24; | |
| 33 | pub const ENOTTY = 25; | |
| 34 | pub const ETXTBSY = 26; | |
| 35 | pub const EFBIG = 27; | |
| 36 | pub const ENOSPC = 28; | |
| 37 | pub const ESPIPE = 29; | |
| 38 | pub const EROFS = 30; | |
| 39 | pub const EMLINK = 31; | |
| 40 | pub const EPIPE = 32; | |
| 41 | pub const EDOM = 33; | |
| 42 | pub const ERANGE = 34; | |
| 43 | ||
| 44 | pub const ENOMSG = 35; | |
| 45 | pub const EIDRM = 36; | |
| 46 | pub const ECHRNG = 37; | |
| 47 | pub const EL2NSYNC = 38; | |
| 48 | pub const EL3HLT = 39; | |
| 49 | pub const EL3RST = 40; | |
| 50 | pub const ELNRNG = 41; | |
| 51 | pub const EUNATCH = 42; | |
| 52 | pub const ENOCSI = 43; | |
| 53 | pub const EL2HLT = 44; | |
| 54 | pub const EDEADLK = 45; | |
| 55 | pub const ENOLCK = 46; | |
| 56 | pub const EBADE = 50; | |
| 57 | pub const EBADR = 51; | |
| 58 | pub const EXFULL = 52; | |
| 59 | pub const ENOANO = 53; | |
| 60 | pub const EBADRQC = 54; | |
| 61 | pub const EBADSLT = 55; | |
| 62 | pub const EDEADLOCK = 56; | |
| 63 | pub const EBFONT = 59; | |
| 64 | pub const ENOSTR = 60; | |
| 65 | pub const ENODATA = 61; | |
| 66 | pub const ETIME = 62; | |
| 67 | pub const ENOSR = 63; | |
| 68 | pub const ENONET = 64; | |
| 69 | pub const ENOPKG = 65; | |
| 70 | pub const EREMOTE = 66; | |
| 71 | pub const ENOLINK = 67; | |
| 72 | pub const EADV = 68; | |
| 73 | pub const ESRMNT = 69; | |
| 74 | pub const ECOMM = 70; | |
| 75 | pub const EPROTO = 71; | |
| 76 | pub const EDOTDOT = 73; | |
| 77 | pub const EMULTIHOP = 74; | |
| 78 | pub const EBADMSG = 77; | |
| 79 | pub const ENAMETOOLONG = 78; | |
| 80 | pub const EOVERFLOW = 79; | |
| 81 | pub const ENOTUNIQ = 80; | |
| 82 | pub const EBADFD = 81; | |
| 83 | pub const EREMCHG = 82; | |
| 84 | pub const ELIBACC = 83; | |
| 85 | pub const ELIBBAD = 84; | |
| 86 | pub const ELIBSCN = 85; | |
| 87 | pub const ELIBMAX = 86; | |
| 88 | pub const ELIBEXEC = 87; | |
| 89 | pub const EILSEQ = 88; | |
| 90 | pub const ENOSYS = 89; | |
| 91 | pub const ELOOP = 90; | |
| 92 | pub const ERESTART = 91; | |
| 93 | pub const ESTRPIPE = 92; | |
| 94 | pub const ENOTEMPTY = 93; | |
| 95 | pub const EUSERS = 94; | |
| 96 | pub const ENOTSOCK = 95; | |
| 97 | pub const EDESTADDRREQ = 96; | |
| 98 | pub const EMSGSIZE = 97; | |
| 99 | pub const EPROTOTYPE = 98; | |
| 100 | pub const ENOPROTOOPT = 99; | |
| 101 | pub const EPROTONOSUPPORT = 120; | |
| 102 | pub const ESOCKTNOSUPPORT = 121; | |
| 103 | pub const EOPNOTSUPP = 122; | |
| 104 | pub const ENOTSUP = EOPNOTSUPP; | |
| 105 | pub const EPFNOSUPPORT = 123; | |
| 106 | pub const EAFNOSUPPORT = 124; | |
| 107 | pub const EADDRINUSE = 125; | |
| 108 | pub const EADDRNOTAVAIL = 126; | |
| 109 | pub const ENETDOWN = 127; | |
| 110 | pub const ENETUNREACH = 128; | |
| 111 | pub const ENETRESET = 129; | |
| 112 | pub const ECONNABORTED = 130; | |
| 113 | pub const ECONNRESET = 131; | |
| 114 | pub const ENOBUFS = 132; | |
| 115 | pub const EISCONN = 133; | |
| 116 | pub const ENOTCONN = 134; | |
| 117 | pub const EUCLEAN = 135; | |
| 118 | pub const ENOTNAM = 137; | |
| 119 | pub const ENAVAIL = 138; | |
| 120 | pub const EISNAM = 139; | |
| 121 | pub const EREMOTEIO = 140; | |
| 122 | pub const ESHUTDOWN = 143; | |
| 123 | pub const ETOOMANYREFS = 144; | |
| 124 | pub const ETIMEDOUT = 145; | |
| 125 | pub const ECONNREFUSED = 146; | |
| 126 | pub const EHOSTDOWN = 147; | |
| 127 | pub const EHOSTUNREACH = 148; | |
| 128 | pub const EWOULDBLOCK = EAGAIN; | |
| 129 | pub const EALREADY = 149; | |
| 130 | pub const EINPROGRESS = 150; | |
| 131 | pub const ESTALE = 151; | |
| 132 | pub const ECANCELED = 158; | |
| 133 | pub const ENOMEDIUM = 159; | |
| 134 | pub const EMEDIUMTYPE = 160; | |
| 135 | pub const ENOKEY = 161; | |
| 136 | pub const EKEYEXPIRED = 162; | |
| 137 | pub const EKEYREVOKED = 163; | |
| 138 | pub const EKEYREJECTED = 164; | |
| 139 | pub const EOWNERDEAD = 165; | |
| 140 | pub const ENOTRECOVERABLE = 166; | |
| 141 | pub const ERFKILL = 167; | |
| 142 | pub const EHWPOISON = 168; | |
| 143 | pub const EDQUOT = 1133; |
lib/std/os/bits/linux/errno-sparc.zig deleted-145| ... | ... | @@ -1,145 +0,0 @@ |
| 1 | // SPDX-License-Identifier: MIT | |
| 2 | // Copyright (c) 2015-2021 Zig Contributors | |
| 3 | // This file is part of [zig](https://ziglang.org/), which is MIT licensed. | |
| 4 | // The MIT license requires this copyright notice to be included in all copies | |
| 5 | // and substantial portions of the software. | |
| 6 | ||
| 7 | // These match the SunOS error numbering scheme. | |
| 8 | ||
| 9 | pub const EPERM = 1; | |
| 10 | pub const ENOENT = 2; | |
| 11 | pub const ESRCH = 3; | |
| 12 | pub const EINTR = 4; | |
| 13 | pub const EIO = 5; | |
| 14 | pub const ENXIO = 6; | |
| 15 | pub const E2BIG = 7; | |
| 16 | pub const ENOEXEC = 8; | |
| 17 | pub const EBADF = 9; | |
| 18 | pub const ECHILD = 10; | |
| 19 | pub const EAGAIN = 11; | |
| 20 | pub const ENOMEM = 12; | |
| 21 | pub const EACCES = 13; | |
| 22 | pub const EFAULT = 14; | |
| 23 | pub const ENOTBLK = 15; | |
| 24 | pub const EBUSY = 16; | |
| 25 | pub const EEXIST = 17; | |
| 26 | pub const EXDEV = 18; | |
| 27 | pub const ENODEV = 19; | |
| 28 | pub const ENOTDIR = 20; | |
| 29 | pub const EISDIR = 21; | |
| 30 | pub const EINVAL = 22; | |
| 31 | pub const ENFILE = 23; | |
| 32 | pub const EMFILE = 24; | |
| 33 | pub const ENOTTY = 25; | |
| 34 | pub const ETXTBSY = 26; | |
| 35 | pub const EFBIG = 27; | |
| 36 | pub const ENOSPC = 28; | |
| 37 | pub const ESPIPE = 29; | |
| 38 | pub const EROFS = 30; | |
| 39 | pub const EMLINK = 31; | |
| 40 | pub const EPIPE = 32; | |
| 41 | pub const EDOM = 33; | |
| 42 | pub const ERANGE = 34; | |
| 43 | ||
| 44 | pub const EWOULDBLOCK = EAGAIN; | |
| 45 | pub const EINPROGRESS = 36; | |
| 46 | pub const EALREADY = 37; | |
| 47 | pub const ENOTSOCK = 38; | |
| 48 | pub const EDESTADDRREQ = 39; | |
| 49 | pub const EMSGSIZE = 40; | |
| 50 | pub const EPROTOTYPE = 41; | |
| 51 | pub const ENOPROTOOPT = 42; | |
| 52 | pub const EPROTONOSUPPORT = 43; | |
| 53 | pub const ESOCKTNOSUPPORT = 44; | |
| 54 | pub const EOPNOTSUPP = 45; | |
| 55 | pub const ENOTSUP = EOPNOTSUPP; | |
| 56 | pub const EPFNOSUPPORT = 46; | |
| 57 | pub const EAFNOSUPPORT = 47; | |
| 58 | pub const EADDRINUSE = 48; | |
| 59 | pub const EADDRNOTAVAIL = 49; | |
| 60 | pub const ENETDOWN = 50; | |
| 61 | pub const ENETUNREACH = 51; | |
| 62 | pub const ENETRESET = 52; | |
| 63 | pub const ECONNABORTED = 53; | |
| 64 | pub const ECONNRESET = 54; | |
| 65 | pub const ENOBUFS = 55; | |
| 66 | pub const EISCONN = 56; | |
| 67 | pub const ENOTCONN = 57; | |
| 68 | pub const ESHUTDOWN = 58; | |
| 69 | pub const ETOOMANYREFS = 59; | |
| 70 | pub const ETIMEDOUT = 60; | |
| 71 | pub const ECONNREFUSED = 61; | |
| 72 | pub const ELOOP = 62; | |
| 73 | pub const ENAMETOOLONG = 63; | |
| 74 | pub const EHOSTDOWN = 64; | |
| 75 | pub const EHOSTUNREACH = 65; | |
| 76 | pub const ENOTEMPTY = 66; | |
| 77 | pub const EPROCLIM = 67; | |
| 78 | pub const EUSERS = 68; | |
| 79 | pub const EDQUOT = 69; | |
| 80 | pub const ESTALE = 70; | |
| 81 | pub const EREMOTE = 71; | |
| 82 | pub const ENOSTR = 72; | |
| 83 | pub const ETIME = 73; | |
| 84 | pub const ENOSR = 74; | |
| 85 | pub const ENOMSG = 75; | |
| 86 | pub const EBADMSG = 76; | |
| 87 | pub const EIDRM = 77; | |
| 88 | pub const EDEADLK = 78; | |
| 89 | pub const ENOLCK = 79; | |
| 90 | pub const ENONET = 80; | |
| 91 | pub const ERREMOTE = 81; | |
| 92 | pub const ENOLINK = 82; | |
| 93 | pub const EADV = 83; | |
| 94 | pub const ESRMNT = 84; | |
| 95 | pub const ECOMM = 85; | |
| 96 | pub const EPROTO = 86; | |
| 97 | pub const EMULTIHOP = 87; | |
| 98 | pub const EDOTDOT = 88; | |
| 99 | pub const EREMCHG = 89; | |
| 100 | pub const ENOSYS = 90; | |
| 101 | pub const ESTRPIPE = 91; | |
| 102 | pub const EOVERFLOW = 92; | |
| 103 | pub const EBADFD = 93; | |
| 104 | pub const ECHRNG = 94; | |
| 105 | pub const EL2NSYNC = 95; | |
| 106 | pub const EL3HLT = 96; | |
| 107 | pub const EL3RST = 97; | |
| 108 | pub const ELNRNG = 98; | |
| 109 | pub const EUNATCH = 99; | |
| 110 | pub const ENOCSI = 100; | |
| 111 | pub const EL2HLT = 101; | |
| 112 | pub const EBADE = 102; | |
| 113 | pub const EBADR = 103; | |
| 114 | pub const EXFULL = 104; | |
| 115 | pub const ENOANO = 105; | |
| 116 | pub const EBADRQC = 106; | |
| 117 | pub const EBADSLT = 107; | |
| 118 | pub const EDEADLOCK = 108; | |
| 119 | pub const EBFONT = 109; | |
| 120 | pub const ELIBEXEC = 110; | |
| 121 | pub const ENODATA = 111; | |
| 122 | pub const ELIBBAD = 112; | |
| 123 | pub const ENOPKG = 113; | |
| 124 | pub const ELIBACC = 114; | |
| 125 | pub const ENOTUNIQ = 115; | |
| 126 | pub const ERESTART = 116; | |
| 127 | pub const EUCLEAN = 117; | |
| 128 | pub const ENOTNAM = 118; | |
| 129 | pub const ENAVAIL = 119; | |
| 130 | pub const EISNAM = 120; | |
| 131 | pub const EREMOTEIO = 121; | |
| 132 | pub const EILSEQ = 122; | |
| 133 | pub const ELIBMAX = 123; | |
| 134 | pub const ELIBSCN = 124; | |
| 135 | pub const ENOMEDIUM = 125; | |
| 136 | pub const EMEDIUMTYPE = 126; | |
| 137 | pub const ECANCELED = 127; | |
| 138 | pub const ENOKEY = 128; | |
| 139 | pub const EKEYEXPIRED = 129; | |
| 140 | pub const EKEYREVOKED = 130; | |
| 141 | pub const EKEYREJECTED = 131; | |
| 142 | pub const EOWNERDEAD = 132; | |
| 143 | pub const ENOTRECOVERABLE = 133; | |
| 144 | pub const ERFKILL = 134; | |
| 145 | pub const EHWPOISON = 135; |
lib/std/os/bits/linux/errno/generic.zig created+466| ... | ... | @@ -0,0 +1,466 @@ |
| 1 | // SPDX-License-Identifier: MIT | |
| 2 | // Copyright (c) 2015-2021 Zig Contributors | |
| 3 | // This file is part of [zig](https://ziglang.org/), which is MIT licensed. | |
| 4 | // The MIT license requires this copyright notice to be included in all copies | |
| 5 | // and substantial portions of the software. | |
| 6 | ||
| 7 | pub const E = enum(u16) { | |
| 8 | /// No error occurred. | |
| 9 | /// Same code used for `NSROK`. | |
| 10 | SUCCESS = 0, | |
| 11 | ||
| 12 | /// Operation not permitted | |
| 13 | PERM = 1, | |
| 14 | ||
| 15 | /// No such file or directory | |
| 16 | NOENT = 2, | |
| 17 | ||
| 18 | /// No such process | |
| 19 | SRCH = 3, | |
| 20 | ||
| 21 | /// Interrupted system call | |
| 22 | INTR = 4, | |
| 23 | ||
| 24 | /// I/O error | |
| 25 | IO = 5, | |
| 26 | ||
| 27 | /// No such device or address | |
| 28 | NXIO = 6, | |
| 29 | ||
| 30 | /// Arg list too long | |
| 31 | @"2BIG" = 7, | |
| 32 | ||
| 33 | /// Exec format error | |
| 34 | NOEXEC = 8, | |
| 35 | ||
| 36 | /// Bad file number | |
| 37 | BADF = 9, | |
| 38 | ||
| 39 | /// No child processes | |
| 40 | CHILD = 10, | |
| 41 | ||
| 42 | /// Try again | |
| 43 | /// Also means: WOULDBLOCK: operation would block | |
| 44 | AGAIN = 11, | |
| 45 | ||
| 46 | /// Out of memory | |
| 47 | NOMEM = 12, | |
| 48 | ||
| 49 | /// Permission denied | |
| 50 | ACCES = 13, | |
| 51 | ||
| 52 | /// Bad address | |
| 53 | FAULT = 14, | |
| 54 | ||
| 55 | /// Block device required | |
| 56 | NOTBLK = 15, | |
| 57 | ||
| 58 | /// Device or resource busy | |
| 59 | BUSY = 16, | |
| 60 | ||
| 61 | /// File exists | |
| 62 | EXIST = 17, | |
| 63 | ||
| 64 | /// Cross-device link | |
| 65 | XDEV = 18, | |
| 66 | ||
| 67 | /// No such device | |
| 68 | NODEV = 19, | |
| 69 | ||
| 70 | /// Not a directory | |
| 71 | NOTDIR = 20, | |
| 72 | ||
| 73 | /// Is a directory | |
| 74 | ISDIR = 21, | |
| 75 | ||
| 76 | /// Invalid argument | |
| 77 | INVAL = 22, | |
| 78 | ||
| 79 | /// File table overflow | |
| 80 | NFILE = 23, | |
| 81 | ||
| 82 | /// Too many open files | |
| 83 | MFILE = 24, | |
| 84 | ||
| 85 | /// Not a typewriter | |
| 86 | NOTTY = 25, | |
| 87 | ||
| 88 | /// Text file busy | |
| 89 | TXTBSY = 26, | |
| 90 | ||
| 91 | /// File too large | |
| 92 | FBIG = 27, | |
| 93 | ||
| 94 | /// No space left on device | |
| 95 | NOSPC = 28, | |
| 96 | ||
| 97 | /// Illegal seek | |
| 98 | SPIPE = 29, | |
| 99 | ||
| 100 | /// Read-only file system | |
| 101 | ROFS = 30, | |
| 102 | ||
| 103 | /// Too many links | |
| 104 | MLINK = 31, | |
| 105 | ||
| 106 | /// Broken pipe | |
| 107 | PIPE = 32, | |
| 108 | ||
| 109 | /// Math argument out of domain of func | |
| 110 | DOM = 33, | |
| 111 | ||
| 112 | /// Math result not representable | |
| 113 | RANGE = 34, | |
| 114 | ||
| 115 | /// Resource deadlock would occur | |
| 116 | DEADLK = 35, | |
| 117 | ||
| 118 | /// File name too long | |
| 119 | NAMETOOLONG = 36, | |
| 120 | ||
| 121 | /// No record locks available | |
| 122 | NOLCK = 37, | |
| 123 | ||
| 124 | /// Function not implemented | |
| 125 | NOSYS = 38, | |
| 126 | ||
| 127 | /// Directory not empty | |
| 128 | NOTEMPTY = 39, | |
| 129 | ||
| 130 | /// Too many symbolic links encountered | |
| 131 | LOOP = 40, | |
| 132 | ||
| 133 | /// No message of desired type | |
| 134 | NOMSG = 42, | |
| 135 | ||
| 136 | /// Identifier removed | |
| 137 | IDRM = 43, | |
| 138 | ||
| 139 | /// Channel number out of range | |
| 140 | CHRNG = 44, | |
| 141 | ||
| 142 | /// Level 2 not synchronized | |
| 143 | L2NSYNC = 45, | |
| 144 | ||
| 145 | /// Level 3 halted | |
| 146 | L3HLT = 46, | |
| 147 | ||
| 148 | /// Level 3 reset | |
| 149 | L3RST = 47, | |
| 150 | ||
| 151 | /// Link number out of range | |
| 152 | LNRNG = 48, | |
| 153 | ||
| 154 | /// Protocol driver not attached | |
| 155 | UNATCH = 49, | |
| 156 | ||
| 157 | /// No CSI structure available | |
| 158 | NOCSI = 50, | |
| 159 | ||
| 160 | /// Level 2 halted | |
| 161 | L2HLT = 51, | |
| 162 | ||
| 163 | /// Invalid exchange | |
| 164 | BADE = 52, | |
| 165 | ||
| 166 | /// Invalid request descriptor | |
| 167 | BADR = 53, | |
| 168 | ||
| 169 | /// Exchange full | |
| 170 | XFULL = 54, | |
| 171 | ||
| 172 | /// No anode | |
| 173 | NOANO = 55, | |
| 174 | ||
| 175 | /// Invalid request code | |
| 176 | BADRQC = 56, | |
| 177 | ||
| 178 | /// Invalid slot | |
| 179 | BADSLT = 57, | |
| 180 | ||
| 181 | /// Bad font file format | |
| 182 | BFONT = 59, | |
| 183 | ||
| 184 | /// Device not a stream | |
| 185 | NOSTR = 60, | |
| 186 | ||
| 187 | /// No data available | |
| 188 | NODATA = 61, | |
| 189 | ||
| 190 | /// Timer expired | |
| 191 | TIME = 62, | |
| 192 | ||
| 193 | /// Out of streams resources | |
| 194 | NOSR = 63, | |
| 195 | ||
| 196 | /// Machine is not on the network | |
| 197 | NONET = 64, | |
| 198 | ||
| 199 | /// Package not installed | |
| 200 | NOPKG = 65, | |
| 201 | ||
| 202 | /// Object is remote | |
| 203 | REMOTE = 66, | |
| 204 | ||
| 205 | /// Link has been severed | |
| 206 | NOLINK = 67, | |
| 207 | ||
| 208 | /// Advertise error | |
| 209 | ADV = 68, | |
| 210 | ||
| 211 | /// Srmount error | |
| 212 | SRMNT = 69, | |
| 213 | ||
| 214 | /// Communication error on send | |
| 215 | COMM = 70, | |
| 216 | ||
| 217 | /// Protocol error | |
| 218 | PROTO = 71, | |
| 219 | ||
| 220 | /// Multihop attempted | |
| 221 | MULTIHOP = 72, | |
| 222 | ||
| 223 | /// RFS specific error | |
| 224 | DOTDOT = 73, | |
| 225 | ||
| 226 | /// Not a data message | |
| 227 | BADMSG = 74, | |
| 228 | ||
| 229 | /// Value too large for defined data type | |
| 230 | OVERFLOW = 75, | |
| 231 | ||
| 232 | /// Name not unique on network | |
| 233 | NOTUNIQ = 76, | |
| 234 | ||
| 235 | /// File descriptor in bad state | |
| 236 | BADFD = 77, | |
| 237 | ||
| 238 | /// Remote address changed | |
| 239 | REMCHG = 78, | |
| 240 | ||
| 241 | /// Can not access a needed shared library | |
| 242 | LIBACC = 79, | |
| 243 | ||
| 244 | /// Accessing a corrupted shared library | |
| 245 | LIBBAD = 80, | |
| 246 | ||
| 247 | /// .lib section in a.out corrupted | |
| 248 | LIBSCN = 81, | |
| 249 | ||
| 250 | /// Attempting to link in too many shared libraries | |
| 251 | LIBMAX = 82, | |
| 252 | ||
| 253 | /// Cannot exec a shared library directly | |
| 254 | LIBEXEC = 83, | |
| 255 | ||
| 256 | /// Illegal byte sequence | |
| 257 | ILSEQ = 84, | |
| 258 | ||
| 259 | /// Interrupted system call should be restarted | |
| 260 | RESTART = 85, | |
| 261 | ||
| 262 | /// Streams pipe error | |
| 263 | STRPIPE = 86, | |
| 264 | ||
| 265 | /// Too many users | |
| 266 | USERS = 87, | |
| 267 | ||
| 268 | /// Socket operation on non-socket | |
| 269 | NOTSOCK = 88, | |
| 270 | ||
| 271 | /// Destination address required | |
| 272 | DESTADDRREQ = 89, | |
| 273 | ||
| 274 | /// Message too long | |
| 275 | MSGSIZE = 90, | |
| 276 | ||
| 277 | /// Protocol wrong type for socket | |
| 278 | PROTOTYPE = 91, | |
| 279 | ||
| 280 | /// Protocol not available | |
| 281 | NOPROTOOPT = 92, | |
| 282 | ||
| 283 | /// Protocol not supported | |
| 284 | PROTONOSUPPORT = 93, | |
| 285 | ||
| 286 | /// Socket type not supported | |
| 287 | SOCKTNOSUPPORT = 94, | |
| 288 | ||
| 289 | /// Operation not supported on transport endpoint | |
| 290 | /// This code also means `NOTSUP`. | |
| 291 | OPNOTSUPP = 95, | |
| 292 | ||
| 293 | /// Protocol family not supported | |
| 294 | PFNOSUPPORT = 96, | |
| 295 | ||
| 296 | /// Address family not supported by protocol | |
| 297 | AFNOSUPPORT = 97, | |
| 298 | ||
| 299 | /// Address already in use | |
| 300 | ADDRINUSE = 98, | |
| 301 | ||
| 302 | /// Cannot assign requested address | |
| 303 | ADDRNOTAVAIL = 99, | |
| 304 | ||
| 305 | /// Network is down | |
| 306 | NETDOWN = 100, | |
| 307 | ||
| 308 | /// Network is unreachable | |
| 309 | NETUNREACH = 101, | |
| 310 | ||
| 311 | /// Network dropped connection because of reset | |
| 312 | NETRESET = 102, | |
| 313 | ||
| 314 | /// Software caused connection abort | |
| 315 | CONNABORTED = 103, | |
| 316 | ||
| 317 | /// Connection reset by peer | |
| 318 | CONNRESET = 104, | |
| 319 | ||
| 320 | /// No buffer space available | |
| 321 | NOBUFS = 105, | |
| 322 | ||
| 323 | /// Transport endpoint is already connected | |
| 324 | ISCONN = 106, | |
| 325 | ||
| 326 | /// Transport endpoint is not connected | |
| 327 | NOTCONN = 107, | |
| 328 | ||
| 329 | /// Cannot send after transport endpoint shutdown | |
| 330 | SHUTDOWN = 108, | |
| 331 | ||
| 332 | /// Too many references: cannot splice | |
| 333 | TOOMANYREFS = 109, | |
| 334 | ||
| 335 | /// Connection timed out | |
| 336 | TIMEDOUT = 110, | |
| 337 | ||
| 338 | /// Connection refused | |
| 339 | CONNREFUSED = 111, | |
| 340 | ||
| 341 | /// Host is down | |
| 342 | HOSTDOWN = 112, | |
| 343 | ||
| 344 | /// No route to host | |
| 345 | HOSTUNREACH = 113, | |
| 346 | ||
| 347 | /// Operation already in progress | |
| 348 | ALREADY = 114, | |
| 349 | ||
| 350 | /// Operation now in progress | |
| 351 | INPROGRESS = 115, | |
| 352 | ||
| 353 | /// Stale NFS file handle | |
| 354 | STALE = 116, | |
| 355 | ||
| 356 | /// Structure needs cleaning | |
| 357 | UCLEAN = 117, | |
| 358 | ||
| 359 | /// Not a XENIX named type file | |
| 360 | NOTNAM = 118, | |
| 361 | ||
| 362 | /// No XENIX semaphores available | |
| 363 | NAVAIL = 119, | |
| 364 | ||
| 365 | /// Is a named type file | |
| 366 | ISNAM = 120, | |
| 367 | ||
| 368 | /// Remote I/O error | |
| 369 | REMOTEIO = 121, | |
| 370 | ||
| 371 | /// Quota exceeded | |
| 372 | DQUOT = 122, | |
| 373 | ||
| 374 | /// No medium found | |
| 375 | NOMEDIUM = 123, | |
| 376 | ||
| 377 | /// Wrong medium type | |
| 378 | MEDIUMTYPE = 124, | |
| 379 | ||
| 380 | /// Operation canceled | |
| 381 | CANCELED = 125, | |
| 382 | ||
| 383 | /// Required key not available | |
| 384 | NOKEY = 126, | |
| 385 | ||
| 386 | /// Key has expired | |
| 387 | KEYEXPIRED = 127, | |
| 388 | ||
| 389 | /// Key has been revoked | |
| 390 | KEYREVOKED = 128, | |
| 391 | ||
| 392 | /// Key was rejected by service | |
| 393 | KEYREJECTED = 129, | |
| 394 | ||
| 395 | // for robust mutexes | |
| 396 | ||
| 397 | /// Owner died | |
| 398 | OWNERDEAD = 130, | |
| 399 | ||
| 400 | /// State not recoverable | |
| 401 | NOTRECOVERABLE = 131, | |
| 402 | ||
| 403 | /// Operation not possible due to RF-kill | |
| 404 | RFKILL = 132, | |
| 405 | ||
| 406 | /// Memory page has hardware error | |
| 407 | HWPOISON = 133, | |
| 408 | ||
| 409 | // nameserver query return codes | |
| 410 | ||
| 411 | /// DNS server returned answer with no data | |
| 412 | NSRNODATA = 160, | |
| 413 | ||
| 414 | /// DNS server claims query was misformatted | |
| 415 | NSRFORMERR = 161, | |
| 416 | ||
| 417 | /// DNS server returned general failure | |
| 418 | NSRSERVFAIL = 162, | |
| 419 | ||
| 420 | /// Domain name not found | |
| 421 | NSRNOTFOUND = 163, | |
| 422 | ||
| 423 | /// DNS server does not implement requested operation | |
| 424 | NSRNOTIMP = 164, | |
| 425 | ||
| 426 | /// DNS server refused query | |
| 427 | NSRREFUSED = 165, | |
| 428 | ||
| 429 | /// Misformatted DNS query | |
| 430 | NSRBADQUERY = 166, | |
| 431 | ||
| 432 | /// Misformatted domain name | |
| 433 | NSRBADNAME = 167, | |
| 434 | ||
| 435 | /// Unsupported address family | |
| 436 | NSRBADFAMILY = 168, | |
| 437 | ||
| 438 | /// Misformatted DNS reply | |
| 439 | NSRBADRESP = 169, | |
| 440 | ||
| 441 | /// Could not contact DNS servers | |
| 442 | NSRCONNREFUSED = 170, | |
| 443 | ||
| 444 | /// Timeout while contacting DNS servers | |
| 445 | NSRTIMEOUT = 171, | |
| 446 | ||
| 447 | /// End of file | |
| 448 | NSROF = 172, | |
| 449 | ||
| 450 | /// Error reading file | |
| 451 | NSRFILE = 173, | |
| 452 | ||
| 453 | /// Out of memory | |
| 454 | NSRNOMEM = 174, | |
| 455 | ||
| 456 | /// Application terminated lookup | |
| 457 | NSRDESTRUCTION = 175, | |
| 458 | ||
| 459 | /// Domain name is too long | |
| 460 | NSRQUERYDOMAINTOOLONG = 176, | |
| 461 | ||
| 462 | /// Domain name is too long | |
| 463 | NSRCNAMELOOP = 177, | |
| 464 | ||
| 465 | _, | |
| 466 | }; |
lib/std/os/bits/linux/errno/mips.zig created+147| ... | ... | @@ -0,0 +1,147 @@ |
| 1 | // SPDX-License-Identifier: MIT | |
| 2 | // Copyright (c) 2015-2021 Zig Contributors | |
| 3 | // This file is part of [zig](https://ziglang.org/), which is MIT licensed. | |
| 4 | // The MIT license requires this copyright notice to be included in all copies | |
| 5 | // and substantial portions of the software. | |
| 6 | ||
| 7 | //! These are MIPS ABI compatible. | |
| 8 | pub const E = enum(i32) { | |
| 9 | /// No error occurred. | |
| 10 | SUCCESS = 0, | |
| 11 | ||
| 12 | PERM = 1, | |
| 13 | NOENT = 2, | |
| 14 | SRCH = 3, | |
| 15 | INTR = 4, | |
| 16 | IO = 5, | |
| 17 | NXIO = 6, | |
| 18 | @"2BIG" = 7, | |
| 19 | NOEXEC = 8, | |
| 20 | BADF = 9, | |
| 21 | CHILD = 10, | |
| 22 | /// Also used for WOULDBLOCK. | |
| 23 | AGAIN = 11, | |
| 24 | NOMEM = 12, | |
| 25 | ACCES = 13, | |
| 26 | FAULT = 14, | |
| 27 | NOTBLK = 15, | |
| 28 | BUSY = 16, | |
| 29 | EXIST = 17, | |
| 30 | XDEV = 18, | |
| 31 | NODEV = 19, | |
| 32 | NOTDIR = 20, | |
| 33 | ISDIR = 21, | |
| 34 | INVAL = 22, | |
| 35 | NFILE = 23, | |
| 36 | MFILE = 24, | |
| 37 | NOTTY = 25, | |
| 38 | TXTBSY = 26, | |
| 39 | FBIG = 27, | |
| 40 | NOSPC = 28, | |
| 41 | SPIPE = 29, | |
| 42 | ROFS = 30, | |
| 43 | MLINK = 31, | |
| 44 | PIPE = 32, | |
| 45 | DOM = 33, | |
| 46 | RANGE = 34, | |
| 47 | ||
| 48 | NOMSG = 35, | |
| 49 | IDRM = 36, | |
| 50 | CHRNG = 37, | |
| 51 | L2NSYNC = 38, | |
| 52 | L3HLT = 39, | |
| 53 | L3RST = 40, | |
| 54 | LNRNG = 41, | |
| 55 | UNATCH = 42, | |
| 56 | NOCSI = 43, | |
| 57 | L2HLT = 44, | |
| 58 | DEADLK = 45, | |
| 59 | NOLCK = 46, | |
| 60 | BADE = 50, | |
| 61 | BADR = 51, | |
| 62 | XFULL = 52, | |
| 63 | NOANO = 53, | |
| 64 | BADRQC = 54, | |
| 65 | BADSLT = 55, | |
| 66 | DEADLOCK = 56, | |
| 67 | BFONT = 59, | |
| 68 | NOSTR = 60, | |
| 69 | NODATA = 61, | |
| 70 | TIME = 62, | |
| 71 | NOSR = 63, | |
| 72 | NONET = 64, | |
| 73 | NOPKG = 65, | |
| 74 | REMOTE = 66, | |
| 75 | NOLINK = 67, | |
| 76 | ADV = 68, | |
| 77 | SRMNT = 69, | |
| 78 | COMM = 70, | |
| 79 | PROTO = 71, | |
| 80 | DOTDOT = 73, | |
| 81 | MULTIHOP = 74, | |
| 82 | BADMSG = 77, | |
| 83 | NAMETOOLONG = 78, | |
| 84 | OVERFLOW = 79, | |
| 85 | NOTUNIQ = 80, | |
| 86 | BADFD = 81, | |
| 87 | REMCHG = 82, | |
| 88 | LIBACC = 83, | |
| 89 | LIBBAD = 84, | |
| 90 | LIBSCN = 85, | |
| 91 | LIBMAX = 86, | |
| 92 | LIBEXEC = 87, | |
| 93 | ILSEQ = 88, | |
| 94 | NOSYS = 89, | |
| 95 | LOOP = 90, | |
| 96 | RESTART = 91, | |
| 97 | STRPIPE = 92, | |
| 98 | NOTEMPTY = 93, | |
| 99 | USERS = 94, | |
| 100 | NOTSOCK = 95, | |
| 101 | DESTADDRREQ = 96, | |
| 102 | MSGSIZE = 97, | |
| 103 | PROTOTYPE = 98, | |
| 104 | NOPROTOOPT = 99, | |
| 105 | PROTONOSUPPORT = 120, | |
| 106 | SOCKTNOSUPPORT = 121, | |
| 107 | OPNOTSUPP = 122, | |
| 108 | PFNOSUPPORT = 123, | |
| 109 | AFNOSUPPORT = 124, | |
| 110 | ADDRINUSE = 125, | |
| 111 | ADDRNOTAVAIL = 126, | |
| 112 | NETDOWN = 127, | |
| 113 | NETUNREACH = 128, | |
| 114 | NETRESET = 129, | |
| 115 | CONNABORTED = 130, | |
| 116 | CONNRESET = 131, | |
| 117 | NOBUFS = 132, | |
| 118 | ISCONN = 133, | |
| 119 | NOTCONN = 134, | |
| 120 | UCLEAN = 135, | |
| 121 | NOTNAM = 137, | |
| 122 | NAVAIL = 138, | |
| 123 | ISNAM = 139, | |
| 124 | REMOTEIO = 140, | |
| 125 | SHUTDOWN = 143, | |
| 126 | TOOMANYREFS = 144, | |
| 127 | TIMEDOUT = 145, | |
| 128 | CONNREFUSED = 146, | |
| 129 | HOSTDOWN = 147, | |
| 130 | HOSTUNREACH = 148, | |
| 131 | ALREADY = 149, | |
| 132 | INPROGRESS = 150, | |
| 133 | STALE = 151, | |
| 134 | CANCELED = 158, | |
| 135 | NOMEDIUM = 159, | |
| 136 | MEDIUMTYPE = 160, | |
| 137 | NOKEY = 161, | |
| 138 | KEYEXPIRED = 162, | |
| 139 | KEYREVOKED = 163, | |
| 140 | KEYREJECTED = 164, | |
| 141 | OWNERDEAD = 165, | |
| 142 | NOTRECOVERABLE = 166, | |
| 143 | RFKILL = 167, | |
| 144 | HWPOISON = 168, | |
| 145 | DQUOT = 1133, | |
| 146 | _, | |
| 147 | }; |
lib/std/os/bits/linux/errno/sparc.zig created+150| ... | ... | @@ -0,0 +1,150 @@ |
| 1 | // SPDX-License-Identifier: MIT | |
| 2 | // Copyright (c) 2015-2021 Zig Contributors | |
| 3 | // This file is part of [zig](https://ziglang.org/), which is MIT licensed. | |
| 4 | // The MIT license requires this copyright notice to be included in all copies | |
| 5 | // and substantial portions of the software. | |
| 6 | ||
| 7 | //! These match the SunOS error numbering scheme. | |
| 8 | pub const E = enum(i32) { | |
| 9 | /// No error occurred. | |
| 10 | SUCCESS = 0, | |
| 11 | ||
| 12 | PERM = 1, | |
| 13 | NOENT = 2, | |
| 14 | SRCH = 3, | |
| 15 | INTR = 4, | |
| 16 | IO = 5, | |
| 17 | NXIO = 6, | |
| 18 | @"2BIG" = 7, | |
| 19 | NOEXEC = 8, | |
| 20 | BADF = 9, | |
| 21 | CHILD = 10, | |
| 22 | /// Also used for WOULDBLOCK | |
| 23 | AGAIN = 11, | |
| 24 | NOMEM = 12, | |
| 25 | ACCES = 13, | |
| 26 | FAULT = 14, | |
| 27 | NOTBLK = 15, | |
| 28 | BUSY = 16, | |
| 29 | EXIST = 17, | |
| 30 | XDEV = 18, | |
| 31 | NODEV = 19, | |
| 32 | NOTDIR = 20, | |
| 33 | ISDIR = 21, | |
| 34 | INVAL = 22, | |
| 35 | NFILE = 23, | |
| 36 | MFILE = 24, | |
| 37 | NOTTY = 25, | |
| 38 | TXTBSY = 26, | |
| 39 | FBIG = 27, | |
| 40 | NOSPC = 28, | |
| 41 | SPIPE = 29, | |
| 42 | ROFS = 30, | |
| 43 | MLINK = 31, | |
| 44 | PIPE = 32, | |
| 45 | DOM = 33, | |
| 46 | RANGE = 34, | |
| 47 | ||
| 48 | INPROGRESS = 36, | |
| 49 | ALREADY = 37, | |
| 50 | NOTSOCK = 38, | |
| 51 | DESTADDRREQ = 39, | |
| 52 | MSGSIZE = 40, | |
| 53 | PROTOTYPE = 41, | |
| 54 | NOPROTOOPT = 42, | |
| 55 | PROTONOSUPPORT = 43, | |
| 56 | SOCKTNOSUPPORT = 44, | |
| 57 | /// Also used for NOTSUP | |
| 58 | OPNOTSUPP = 45, | |
| 59 | PFNOSUPPORT = 46, | |
| 60 | AFNOSUPPORT = 47, | |
| 61 | ADDRINUSE = 48, | |
| 62 | ADDRNOTAVAIL = 49, | |
| 63 | NETDOWN = 50, | |
| 64 | NETUNREACH = 51, | |
| 65 | NETRESET = 52, | |
| 66 | CONNABORTED = 53, | |
| 67 | CONNRESET = 54, | |
| 68 | NOBUFS = 55, | |
| 69 | ISCONN = 56, | |
| 70 | NOTCONN = 57, | |
| 71 | SHUTDOWN = 58, | |
| 72 | TOOMANYREFS = 59, | |
| 73 | TIMEDOUT = 60, | |
| 74 | CONNREFUSED = 61, | |
| 75 | LOOP = 62, | |
| 76 | NAMETOOLONG = 63, | |
| 77 | HOSTDOWN = 64, | |
| 78 | HOSTUNREACH = 65, | |
| 79 | NOTEMPTY = 66, | |
| 80 | PROCLIM = 67, | |
| 81 | USERS = 68, | |
| 82 | DQUOT = 69, | |
| 83 | STALE = 70, | |
| 84 | REMOTE = 71, | |
| 85 | NOSTR = 72, | |
| 86 | TIME = 73, | |
| 87 | NOSR = 74, | |
| 88 | NOMSG = 75, | |
| 89 | BADMSG = 76, | |
| 90 | IDRM = 77, | |
| 91 | DEADLK = 78, | |
| 92 | NOLCK = 79, | |
| 93 | NONET = 80, | |
| 94 | RREMOTE = 81, | |
| 95 | NOLINK = 82, | |
| 96 | ADV = 83, | |
| 97 | SRMNT = 84, | |
| 98 | COMM = 85, | |
| 99 | PROTO = 86, | |
| 100 | MULTIHOP = 87, | |
| 101 | DOTDOT = 88, | |
| 102 | REMCHG = 89, | |
| 103 | NOSYS = 90, | |
| 104 | STRPIPE = 91, | |
| 105 | OVERFLOW = 92, | |
| 106 | BADFD = 93, | |
| 107 | CHRNG = 94, | |
| 108 | L2NSYNC = 95, | |
| 109 | L3HLT = 96, | |
| 110 | L3RST = 97, | |
| 111 | LNRNG = 98, | |
| 112 | UNATCH = 99, | |
| 113 | NOCSI = 100, | |
| 114 | L2HLT = 101, | |
| 115 | BADE = 102, | |
| 116 | BADR = 103, | |
| 117 | XFULL = 104, | |
| 118 | NOANO = 105, | |
| 119 | BADRQC = 106, | |
| 120 | BADSLT = 107, | |
| 121 | DEADLOCK = 108, | |
| 122 | BFONT = 109, | |
| 123 | LIBEXEC = 110, | |
| 124 | NODATA = 111, | |
| 125 | LIBBAD = 112, | |
| 126 | NOPKG = 113, | |
| 127 | LIBACC = 114, | |
| 128 | NOTUNIQ = 115, | |
| 129 | RESTART = 116, | |
| 130 | UCLEAN = 117, | |
| 131 | NOTNAM = 118, | |
| 132 | NAVAIL = 119, | |
| 133 | ISNAM = 120, | |
| 134 | REMOTEIO = 121, | |
| 135 | ILSEQ = 122, | |
| 136 | LIBMAX = 123, | |
| 137 | LIBSCN = 124, | |
| 138 | NOMEDIUM = 125, | |
| 139 | MEDIUMTYPE = 126, | |
| 140 | CANCELED = 127, | |
| 141 | NOKEY = 128, | |
| 142 | KEYEXPIRED = 129, | |
| 143 | KEYREVOKED = 130, | |
| 144 | KEYREJECTED = 131, | |
| 145 | OWNERDEAD = 132, | |
| 146 | NOTRECOVERABLE = 133, | |
| 147 | RFKILL = 134, | |
| 148 | HWPOISON = 135, | |
| 149 | _, | |
| 150 | }; |
lib/std/os/bits/netbsd.zig+138-134| ... | ... | @@ -933,140 +933,144 @@ pub const ucontext_t = extern struct { |
| 933 | 933 | ]u32, |
| 934 | 934 | }; |
| 935 | 935 | |
| 936 | pub const EPERM = 1; // Operation not permitted | |
| 937 | pub const ENOENT = 2; // No such file or directory | |
| 938 | pub const ESRCH = 3; // No such process | |
| 939 | pub const EINTR = 4; // Interrupted system call | |
| 940 | pub const EIO = 5; // Input/output error | |
| 941 | pub const ENXIO = 6; // Device not configured | |
| 942 | pub const E2BIG = 7; // Argument list too long | |
| 943 | pub const ENOEXEC = 8; // Exec format error | |
| 944 | pub const EBADF = 9; // Bad file descriptor | |
| 945 | pub const ECHILD = 10; // No child processes | |
| 946 | pub const EDEADLK = 11; // Resource deadlock avoided | |
| 947 | // 11 was EAGAIN | |
| 948 | pub const ENOMEM = 12; // Cannot allocate memory | |
| 949 | pub const EACCES = 13; // Permission denied | |
| 950 | pub const EFAULT = 14; // Bad address | |
| 951 | pub const ENOTBLK = 15; // Block device required | |
| 952 | pub const EBUSY = 16; // Device busy | |
| 953 | pub const EEXIST = 17; // File exists | |
| 954 | pub const EXDEV = 18; // Cross-device link | |
| 955 | pub const ENODEV = 19; // Operation not supported by device | |
| 956 | pub const ENOTDIR = 20; // Not a directory | |
| 957 | pub const EISDIR = 21; // Is a directory | |
| 958 | pub const EINVAL = 22; // Invalid argument | |
| 959 | pub const ENFILE = 23; // Too many open files in system | |
| 960 | pub const EMFILE = 24; // Too many open files | |
| 961 | pub const ENOTTY = 25; // Inappropriate ioctl for device | |
| 962 | pub const ETXTBSY = 26; // Text file busy | |
| 963 | pub const EFBIG = 27; // File too large | |
| 964 | pub const ENOSPC = 28; // No space left on device | |
| 965 | pub const ESPIPE = 29; // Illegal seek | |
| 966 | pub const EROFS = 30; // Read-only file system | |
| 967 | pub const EMLINK = 31; // Too many links | |
| 968 | pub const EPIPE = 32; // Broken pipe | |
| 969 | ||
| 970 | // math software | |
| 971 | pub const EDOM = 33; // Numerical argument out of domain | |
| 972 | pub const ERANGE = 34; // Result too large or too small | |
| 973 | ||
| 974 | // non-blocking and interrupt i/o | |
| 975 | pub const EAGAIN = 35; // Resource temporarily unavailable | |
| 976 | pub const EWOULDBLOCK = EAGAIN; // Operation would block | |
| 977 | pub const EINPROGRESS = 36; // Operation now in progress | |
| 978 | pub const EALREADY = 37; // Operation already in progress | |
| 979 | ||
| 980 | // ipc/network software -- argument errors | |
| 981 | pub const ENOTSOCK = 38; // Socket operation on non-socket | |
| 982 | pub const EDESTADDRREQ = 39; // Destination address required | |
| 983 | pub const EMSGSIZE = 40; // Message too long | |
| 984 | pub const EPROTOTYPE = 41; // Protocol wrong type for socket | |
| 985 | pub const ENOPROTOOPT = 42; // Protocol option not available | |
| 986 | pub const EPROTONOSUPPORT = 43; // Protocol not supported | |
| 987 | pub const ESOCKTNOSUPPORT = 44; // Socket type not supported | |
| 988 | pub const EOPNOTSUPP = 45; // Operation not supported | |
| 989 | pub const EPFNOSUPPORT = 46; // Protocol family not supported | |
| 990 | pub const EAFNOSUPPORT = 47; // Address family not supported by protocol family | |
| 991 | pub const EADDRINUSE = 48; // Address already in use | |
| 992 | pub const EADDRNOTAVAIL = 49; // Can't assign requested address | |
| 993 | ||
| 994 | // ipc/network software -- operational errors | |
| 995 | pub const ENETDOWN = 50; // Network is down | |
| 996 | pub const ENETUNREACH = 51; // Network is unreachable | |
| 997 | pub const ENETRESET = 52; // Network dropped connection on reset | |
| 998 | pub const ECONNABORTED = 53; // Software caused connection abort | |
| 999 | pub const ECONNRESET = 54; // Connection reset by peer | |
| 1000 | pub const ENOBUFS = 55; // No buffer space available | |
| 1001 | pub const EISCONN = 56; // Socket is already connected | |
| 1002 | pub const ENOTCONN = 57; // Socket is not connected | |
| 1003 | pub const ESHUTDOWN = 58; // Can't send after socket shutdown | |
| 1004 | pub const ETOOMANYREFS = 59; // Too many references: can't splice | |
| 1005 | pub const ETIMEDOUT = 60; // Operation timed out | |
| 1006 | pub const ECONNREFUSED = 61; // Connection refused | |
| 1007 | ||
| 1008 | pub const ELOOP = 62; // Too many levels of symbolic links | |
| 1009 | pub const ENAMETOOLONG = 63; // File name too long | |
| 1010 | ||
| 1011 | // should be rearranged | |
| 1012 | pub const EHOSTDOWN = 64; // Host is down | |
| 1013 | pub const EHOSTUNREACH = 65; // No route to host | |
| 1014 | pub const ENOTEMPTY = 66; // Directory not empty | |
| 1015 | ||
| 1016 | // quotas & mush | |
| 1017 | pub const EPROCLIM = 67; // Too many processes | |
| 1018 | pub const EUSERS = 68; // Too many users | |
| 1019 | pub const EDQUOT = 69; // Disc quota exceeded | |
| 1020 | ||
| 1021 | // Network File System | |
| 1022 | pub const ESTALE = 70; // Stale NFS file handle | |
| 1023 | pub const EREMOTE = 71; // Too many levels of remote in path | |
| 1024 | pub const EBADRPC = 72; // RPC struct is bad | |
| 1025 | pub const ERPCMISMATCH = 73; // RPC version wrong | |
| 1026 | pub const EPROGUNAVAIL = 74; // RPC prog. not avail | |
| 1027 | pub const EPROGMISMATCH = 75; // Program version wrong | |
| 1028 | pub const EPROCUNAVAIL = 76; // Bad procedure for program | |
| 1029 | ||
| 1030 | pub const ENOLCK = 77; // No locks available | |
| 1031 | pub const ENOSYS = 78; // Function not implemented | |
| 1032 | ||
| 1033 | pub const EFTYPE = 79; // Inappropriate file type or format | |
| 1034 | pub const EAUTH = 80; // Authentication error | |
| 1035 | pub const ENEEDAUTH = 81; // Need authenticator | |
| 1036 | ||
| 1037 | // SystemV IPC | |
| 1038 | pub const EIDRM = 82; // Identifier removed | |
| 1039 | pub const ENOMSG = 83; // No message of desired type | |
| 1040 | pub const EOVERFLOW = 84; // Value too large to be stored in data type | |
| 1041 | ||
| 1042 | // Wide/multibyte-character handling, ISO/IEC 9899/AMD1:1995 | |
| 1043 | pub const EILSEQ = 85; // Illegal byte sequence | |
| 1044 | ||
| 1045 | // From IEEE Std 1003.1-2001 | |
| 1046 | // Base, Realtime, Threads or Thread Priority Scheduling option errors | |
| 1047 | pub const ENOTSUP = 86; // Not supported | |
| 1048 | ||
| 1049 | // Realtime option errors | |
| 1050 | pub const ECANCELED = 87; // Operation canceled | |
| 1051 | ||
| 1052 | // Realtime, XSI STREAMS option errors | |
| 1053 | pub const EBADMSG = 88; // Bad or Corrupt message | |
| 1054 | ||
| 1055 | // XSI STREAMS option errors | |
| 1056 | pub const ENODATA = 89; // No message available | |
| 1057 | pub const ENOSR = 90; // No STREAM resources | |
| 1058 | pub const ENOSTR = 91; // Not a STREAM | |
| 1059 | pub const ETIME = 92; // STREAM ioctl timeout | |
| 1060 | ||
| 1061 | // File system extended attribute errors | |
| 1062 | pub const ENOATTR = 93; // Attribute not found | |
| 1063 | ||
| 1064 | // Realtime, XSI STREAMS option errors | |
| 1065 | pub const EMULTIHOP = 94; // Multihop attempted | |
| 1066 | pub const ENOLINK = 95; // Link has been severed | |
| 1067 | pub const EPROTO = 96; // Protocol error | |
| 1068 | ||
| 1069 | pub const ELAST = 96; // Must equal largest errno | |
| 936 | pub const E = enum(u16) { | |
| 937 | /// No error occurred. | |
| 938 | SUCCESS = 0, | |
| 939 | PERM = 1, // Operation not permitted | |
| 940 | NOENT = 2, // No such file or directory | |
| 941 | SRCH = 3, // No such process | |
| 942 | INTR = 4, // Interrupted system call | |
| 943 | IO = 5, // Input/output error | |
| 944 | NXIO = 6, // Device not configured | |
| 945 | @"2BIG" = 7, // Argument list too long | |
| 946 | NOEXEC = 8, // Exec format error | |
| 947 | BADF = 9, // Bad file descriptor | |
| 948 | CHILD = 10, // No child processes | |
| 949 | DEADLK = 11, // Resource deadlock avoided | |
| 950 | // 11 was AGAIN | |
| 951 | NOMEM = 12, // Cannot allocate memory | |
| 952 | ACCES = 13, // Permission denied | |
| 953 | FAULT = 14, // Bad address | |
| 954 | NOTBLK = 15, // Block device required | |
| 955 | BUSY = 16, // Device busy | |
| 956 | EXIST = 17, // File exists | |
| 957 | XDEV = 18, // Cross-device link | |
| 958 | NODEV = 19, // Operation not supported by device | |
| 959 | NOTDIR = 20, // Not a directory | |
| 960 | ISDIR = 21, // Is a directory | |
| 961 | INVAL = 22, // Invalid argument | |
| 962 | NFILE = 23, // Too many open files in system | |
| 963 | MFILE = 24, // Too many open files | |
| 964 | NOTTY = 25, // Inappropriate ioctl for device | |
| 965 | TXTBSY = 26, // Text file busy | |
| 966 | FBIG = 27, // File too large | |
| 967 | NOSPC = 28, // No space left on device | |
| 968 | SPIPE = 29, // Illegal seek | |
| 969 | ROFS = 30, // Read-only file system | |
| 970 | MLINK = 31, // Too many links | |
| 971 | PIPE = 32, // Broken pipe | |
| 972 | ||
| 973 | // math software | |
| 974 | DOM = 33, // Numerical argument out of domain | |
| 975 | RANGE = 34, // Result too large or too small | |
| 976 | ||
| 977 | // non-blocking and interrupt i/o | |
| 978 | // also: WOULDBLOCK: operation would block | |
| 979 | AGAIN = 35, // Resource temporarily unavailable | |
| 980 | INPROGRESS = 36, // Operation now in progress | |
| 981 | ALREADY = 37, // Operation already in progress | |
| 982 | ||
| 983 | // ipc/network software -- argument errors | |
| 984 | NOTSOCK = 38, // Socket operation on non-socket | |
| 985 | DESTADDRREQ = 39, // Destination address required | |
| 986 | MSGSIZE = 40, // Message too long | |
| 987 | PROTOTYPE = 41, // Protocol wrong type for socket | |
| 988 | NOPROTOOPT = 42, // Protocol option not available | |
| 989 | PROTONOSUPPORT = 43, // Protocol not supported | |
| 990 | SOCKTNOSUPPORT = 44, // Socket type not supported | |
| 991 | OPNOTSUPP = 45, // Operation not supported | |
| 992 | PFNOSUPPORT = 46, // Protocol family not supported | |
| 993 | AFNOSUPPORT = 47, // Address family not supported by protocol family | |
| 994 | ADDRINUSE = 48, // Address already in use | |
| 995 | ADDRNOTAVAIL = 49, // Can't assign requested address | |
| 996 | ||
| 997 | // ipc/network software -- operational errors | |
| 998 | NETDOWN = 50, // Network is down | |
| 999 | NETUNREACH = 51, // Network is unreachable | |
| 1000 | NETRESET = 52, // Network dropped connection on reset | |
| 1001 | CONNABORTED = 53, // Software caused connection abort | |
| 1002 | CONNRESET = 54, // Connection reset by peer | |
| 1003 | NOBUFS = 55, // No buffer space available | |
| 1004 | ISCONN = 56, // Socket is already connected | |
| 1005 | NOTCONN = 57, // Socket is not connected | |
| 1006 | SHUTDOWN = 58, // Can't send after socket shutdown | |
| 1007 | TOOMANYREFS = 59, // Too many references: can't splice | |
| 1008 | TIMEDOUT = 60, // Operation timed out | |
| 1009 | CONNREFUSED = 61, // Connection refused | |
| 1010 | ||
| 1011 | LOOP = 62, // Too many levels of symbolic links | |
| 1012 | NAMETOOLONG = 63, // File name too long | |
| 1013 | ||
| 1014 | // should be rearranged | |
| 1015 | HOSTDOWN = 64, // Host is down | |
| 1016 | HOSTUNREACH = 65, // No route to host | |
| 1017 | NOTEMPTY = 66, // Directory not empty | |
| 1018 | ||
| 1019 | // quotas & mush | |
| 1020 | PROCLIM = 67, // Too many processes | |
| 1021 | USERS = 68, // Too many users | |
| 1022 | DQUOT = 69, // Disc quota exceeded | |
| 1023 | ||
| 1024 | // Network File System | |
| 1025 | STALE = 70, // Stale NFS file handle | |
| 1026 | REMOTE = 71, // Too many levels of remote in path | |
| 1027 | BADRPC = 72, // RPC struct is bad | |
| 1028 | RPCMISMATCH = 73, // RPC version wrong | |
| 1029 | PROGUNAVAIL = 74, // RPC prog. not avail | |
| 1030 | PROGMISMATCH = 75, // Program version wrong | |
| 1031 | PROCUNAVAIL = 76, // Bad procedure for program | |
| 1032 | ||
| 1033 | NOLCK = 77, // No locks available | |
| 1034 | NOSYS = 78, // Function not implemented | |
| 1035 | ||
| 1036 | FTYPE = 79, // Inappropriate file type or format | |
| 1037 | AUTH = 80, // Authentication error | |
| 1038 | NEEDAUTH = 81, // Need authenticator | |
| 1039 | ||
| 1040 | // SystemV IPC | |
| 1041 | IDRM = 82, // Identifier removed | |
| 1042 | NOMSG = 83, // No message of desired type | |
| 1043 | OVERFLOW = 84, // Value too large to be stored in data type | |
| 1044 | ||
| 1045 | // Wide/multibyte-character handling, ISO/IEC 9899/AMD1:1995 | |
| 1046 | ILSEQ = 85, // Illegal byte sequence | |
| 1047 | ||
| 1048 | // From IEEE Std 1003.1-2001 | |
| 1049 | // Base, Realtime, Threads or Thread Priority Scheduling option errors | |
| 1050 | NOTSUP = 86, // Not supported | |
| 1051 | ||
| 1052 | // Realtime option errors | |
| 1053 | CANCELED = 87, // Operation canceled | |
| 1054 | ||
| 1055 | // Realtime, XSI STREAMS option errors | |
| 1056 | BADMSG = 88, // Bad or Corrupt message | |
| 1057 | ||
| 1058 | // XSI STREAMS option errors | |
| 1059 | NODATA = 89, // No message available | |
| 1060 | NOSR = 90, // No STREAM resources | |
| 1061 | NOSTR = 91, // Not a STREAM | |
| 1062 | TIME = 92, // STREAM ioctl timeout | |
| 1063 | ||
| 1064 | // File system extended attribute errors | |
| 1065 | NOATTR = 93, // Attribute not found | |
| 1066 | ||
| 1067 | // Realtime, XSI STREAMS option errors | |
| 1068 | MULTIHOP = 94, // Multihop attempted | |
| 1069 | NOLINK = 95, // Link has been severed | |
| 1070 | PROTO = 96, // Protocol error | |
| 1071 | ||
| 1072 | _, | |
| 1073 | }; | |
| 1070 | 1074 | |
| 1071 | 1075 | pub const MINSIGSTKSZ = 8192; |
| 1072 | 1076 | pub const SIGSTKSZ = MINSIGSTKSZ + 32768; |
lib/std/os/bits/openbsd.zig+124-119| ... | ... | @@ -295,6 +295,7 @@ pub const AI_NUMERICSERV = 16; |
| 295 | 295 | pub const AI_ADDRCONFIG = 64; |
| 296 | 296 | |
| 297 | 297 | pub const PATH_MAX = 1024; |
| 298 | pub const IOV_MAX = 1024; | |
| 298 | 299 | |
| 299 | 300 | pub const STDIN_FILENO = 0; |
| 300 | 301 | pub const STDOUT_FILENO = 1; |
| ... | ... | @@ -824,125 +825,129 @@ pub usingnamespace switch (builtin.target.cpu.arch) { |
| 824 | 825 | pub const sigset_t = c_uint; |
| 825 | 826 | pub const empty_sigset: sigset_t = 0; |
| 826 | 827 | |
| 827 | pub const EPERM = 1; // Operation not permitted | |
| 828 | pub const ENOENT = 2; // No such file or directory | |
| 829 | pub const ESRCH = 3; // No such process | |
| 830 | pub const EINTR = 4; // Interrupted system call | |
| 831 | pub const EIO = 5; // Input/output error | |
| 832 | pub const ENXIO = 6; // Device not configured | |
| 833 | pub const E2BIG = 7; // Argument list too long | |
| 834 | pub const ENOEXEC = 8; // Exec format error | |
| 835 | pub const EBADF = 9; // Bad file descriptor | |
| 836 | pub const ECHILD = 10; // No child processes | |
| 837 | pub const EDEADLK = 11; // Resource deadlock avoided | |
| 838 | // 11 was EAGAIN | |
| 839 | pub const ENOMEM = 12; // Cannot allocate memory | |
| 840 | pub const EACCES = 13; // Permission denied | |
| 841 | pub const EFAULT = 14; // Bad address | |
| 842 | pub const ENOTBLK = 15; // Block device required | |
| 843 | pub const EBUSY = 16; // Device busy | |
| 844 | pub const EEXIST = 17; // File exists | |
| 845 | pub const EXDEV = 18; // Cross-device link | |
| 846 | pub const ENODEV = 19; // Operation not supported by device | |
| 847 | pub const ENOTDIR = 20; // Not a directory | |
| 848 | pub const EISDIR = 21; // Is a directory | |
| 849 | pub const EINVAL = 22; // Invalid argument | |
| 850 | pub const ENFILE = 23; // Too many open files in system | |
| 851 | pub const EMFILE = 24; // Too many open files | |
| 852 | pub const ENOTTY = 25; // Inappropriate ioctl for device | |
| 853 | pub const ETXTBSY = 26; // Text file busy | |
| 854 | pub const EFBIG = 27; // File too large | |
| 855 | pub const ENOSPC = 28; // No space left on device | |
| 856 | pub const ESPIPE = 29; // Illegal seek | |
| 857 | pub const EROFS = 30; // Read-only file system | |
| 858 | pub const EMLINK = 31; // Too many links | |
| 859 | pub const EPIPE = 32; // Broken pipe | |
| 860 | ||
| 861 | // math software | |
| 862 | pub const EDOM = 33; // Numerical argument out of domain | |
| 863 | pub const ERANGE = 34; // Result too large or too small | |
| 864 | ||
| 865 | // non-blocking and interrupt i/o | |
| 866 | pub const EAGAIN = 35; // Resource temporarily unavailable | |
| 867 | pub const EWOULDBLOCK = EAGAIN; // Operation would block | |
| 868 | pub const EINPROGRESS = 36; // Operation now in progress | |
| 869 | pub const EALREADY = 37; // Operation already in progress | |
| 870 | ||
| 871 | // ipc/network software -- argument errors | |
| 872 | pub const ENOTSOCK = 38; // Socket operation on non-socket | |
| 873 | pub const EDESTADDRREQ = 39; // Destination address required | |
| 874 | pub const EMSGSIZE = 40; // Message too long | |
| 875 | pub const EPROTOTYPE = 41; // Protocol wrong type for socket | |
| 876 | pub const ENOPROTOOPT = 42; // Protocol option not available | |
| 877 | pub const EPROTONOSUPPORT = 43; // Protocol not supported | |
| 878 | pub const ESOCKTNOSUPPORT = 44; // Socket type not supported | |
| 879 | pub const EOPNOTSUPP = 45; // Operation not supported | |
| 880 | pub const EPFNOSUPPORT = 46; // Protocol family not supported | |
| 881 | pub const EAFNOSUPPORT = 47; // Address family not supported by protocol family | |
| 882 | pub const EADDRINUSE = 48; // Address already in use | |
| 883 | pub const EADDRNOTAVAIL = 49; // Can't assign requested address | |
| 884 | ||
| 885 | // ipc/network software -- operational errors | |
| 886 | pub const ENETDOWN = 50; // Network is down | |
| 887 | pub const ENETUNREACH = 51; // Network is unreachable | |
| 888 | pub const ENETRESET = 52; // Network dropped connection on reset | |
| 889 | pub const ECONNABORTED = 53; // Software caused connection abort | |
| 890 | pub const ECONNRESET = 54; // Connection reset by peer | |
| 891 | pub const ENOBUFS = 55; // No buffer space available | |
| 892 | pub const EISCONN = 56; // Socket is already connected | |
| 893 | pub const ENOTCONN = 57; // Socket is not connected | |
| 894 | pub const ESHUTDOWN = 58; // Can't send after socket shutdown | |
| 895 | pub const ETOOMANYREFS = 59; // Too many references: can't splice | |
| 896 | pub const ETIMEDOUT = 60; // Operation timed out | |
| 897 | pub const ECONNREFUSED = 61; // Connection refused | |
| 898 | ||
| 899 | pub const ELOOP = 62; // Too many levels of symbolic links | |
| 900 | pub const ENAMETOOLONG = 63; // File name too long | |
| 901 | ||
| 902 | // should be rearranged | |
| 903 | pub const EHOSTDOWN = 64; // Host is down | |
| 904 | pub const EHOSTUNREACH = 65; // No route to host | |
| 905 | pub const ENOTEMPTY = 66; // Directory not empty | |
| 906 | ||
| 907 | // quotas & mush | |
| 908 | pub const EPROCLIM = 67; // Too many processes | |
| 909 | pub const EUSERS = 68; // Too many users | |
| 910 | pub const EDQUOT = 69; // Disc quota exceeded | |
| 911 | ||
| 912 | // Network File System | |
| 913 | pub const ESTALE = 70; // Stale NFS file handle | |
| 914 | pub const EREMOTE = 71; // Too many levels of remote in path | |
| 915 | pub const EBADRPC = 72; // RPC struct is bad | |
| 916 | pub const ERPCMISMATCH = 73; // RPC version wrong | |
| 917 | pub const EPROGUNAVAIL = 74; // RPC prog. not avail | |
| 918 | pub const EPROGMISMATCH = 75; // Program version wrong | |
| 919 | pub const EPROCUNAVAIL = 76; // Bad procedure for program | |
| 920 | ||
| 921 | pub const ENOLCK = 77; // No locks available | |
| 922 | pub const ENOSYS = 78; // Function not implemented | |
| 923 | ||
| 924 | pub const EFTYPE = 79; // Inappropriate file type or format | |
| 925 | pub const EAUTH = 80; // Authentication error | |
| 926 | pub const ENEEDAUTH = 81; // Need authenticator | |
| 927 | pub const EIPSEC = 82; // IPsec processing failure | |
| 928 | pub const ENOATTR = 83; // Attribute not found | |
| 929 | ||
| 930 | // Wide/multibyte-character handling, ISO/IEC 9899/AMD1:1995 | |
| 931 | pub const EILSEQ = 84; // Illegal byte sequence | |
| 932 | ||
| 933 | pub const ENOMEDIUM = 85; // No medium found | |
| 934 | pub const EMEDIUMTYPE = 86; // Wrong medium type | |
| 935 | pub const EOVERFLOW = 87; // Value too large to be stored in data type | |
| 936 | pub const ECANCELED = 88; // Operation canceled | |
| 937 | pub const EIDRM = 89; // Identifier removed | |
| 938 | pub const ENOMSG = 90; // No message of desired type | |
| 939 | pub const ENOTSUP = 91; // Not supported | |
| 940 | pub const EBADMSG = 92; // Bad or Corrupt message | |
| 941 | pub const ENOTRECOVERABLE = 93; // State not recoverable | |
| 942 | pub const EOWNERDEAD = 94; // Previous owner died | |
| 943 | pub const EPROTO = 95; // Protocol error | |
| 944 | ||
| 945 | pub const ELAST = 95; // Must equal largest errno | |
| 828 | pub const E = enum(u16) { | |
| 829 | /// No error occurred. | |
| 830 | SUCCESS = 0, | |
| 831 | PERM = 1, // Operation not permitted | |
| 832 | NOENT = 2, // No such file or directory | |
| 833 | SRCH = 3, // No such process | |
| 834 | INTR = 4, // Interrupted system call | |
| 835 | IO = 5, // Input/output error | |
| 836 | NXIO = 6, // Device not configured | |
| 837 | @"2BIG" = 7, // Argument list too long | |
| 838 | NOEXEC = 8, // Exec format error | |
| 839 | BADF = 9, // Bad file descriptor | |
| 840 | CHILD = 10, // No child processes | |
| 841 | DEADLK = 11, // Resource deadlock avoided | |
| 842 | // 11 was AGAIN | |
| 843 | NOMEM = 12, // Cannot allocate memory | |
| 844 | ACCES = 13, // Permission denied | |
| 845 | FAULT = 14, // Bad address | |
| 846 | NOTBLK = 15, // Block device required | |
| 847 | BUSY = 16, // Device busy | |
| 848 | EXIST = 17, // File exists | |
| 849 | XDEV = 18, // Cross-device link | |
| 850 | NODEV = 19, // Operation not supported by device | |
| 851 | NOTDIR = 20, // Not a directory | |
| 852 | ISDIR = 21, // Is a directory | |
| 853 | INVAL = 22, // Invalid argument | |
| 854 | NFILE = 23, // Too many open files in system | |
| 855 | MFILE = 24, // Too many open files | |
| 856 | NOTTY = 25, // Inappropriate ioctl for device | |
| 857 | TXTBSY = 26, // Text file busy | |
| 858 | FBIG = 27, // File too large | |
| 859 | NOSPC = 28, // No space left on device | |
| 860 | SPIPE = 29, // Illegal seek | |
| 861 | ROFS = 30, // Read-only file system | |
| 862 | MLINK = 31, // Too many links | |
| 863 | PIPE = 32, // Broken pipe | |
| 864 | ||
| 865 | // math software | |
| 866 | DOM = 33, // Numerical argument out of domain | |
| 867 | RANGE = 34, // Result too large or too small | |
| 868 | ||
| 869 | // non-blocking and interrupt i/o | |
| 870 | // also: WOULDBLOCK: operation would block | |
| 871 | AGAIN = 35, // Resource temporarily unavailable | |
| 872 | INPROGRESS = 36, // Operation now in progress | |
| 873 | ALREADY = 37, // Operation already in progress | |
| 874 | ||
| 875 | // ipc/network software -- argument errors | |
| 876 | NOTSOCK = 38, // Socket operation on non-socket | |
| 877 | DESTADDRREQ = 39, // Destination address required | |
| 878 | MSGSIZE = 40, // Message too long | |
| 879 | PROTOTYPE = 41, // Protocol wrong type for socket | |
| 880 | NOPROTOOPT = 42, // Protocol option not available | |
| 881 | PROTONOSUPPORT = 43, // Protocol not supported | |
| 882 | SOCKTNOSUPPORT = 44, // Socket type not supported | |
| 883 | OPNOTSUPP = 45, // Operation not supported | |
| 884 | PFNOSUPPORT = 46, // Protocol family not supported | |
| 885 | AFNOSUPPORT = 47, // Address family not supported by protocol family | |
| 886 | ADDRINUSE = 48, // Address already in use | |
| 887 | ADDRNOTAVAIL = 49, // Can't assign requested address | |
| 888 | ||
| 889 | // ipc/network software -- operational errors | |
| 890 | NETDOWN = 50, // Network is down | |
| 891 | NETUNREACH = 51, // Network is unreachable | |
| 892 | NETRESET = 52, // Network dropped connection on reset | |
| 893 | CONNABORTED = 53, // Software caused connection abort | |
| 894 | CONNRESET = 54, // Connection reset by peer | |
| 895 | NOBUFS = 55, // No buffer space available | |
| 896 | ISCONN = 56, // Socket is already connected | |
| 897 | NOTCONN = 57, // Socket is not connected | |
| 898 | SHUTDOWN = 58, // Can't send after socket shutdown | |
| 899 | TOOMANYREFS = 59, // Too many references: can't splice | |
| 900 | TIMEDOUT = 60, // Operation timed out | |
| 901 | CONNREFUSED = 61, // Connection refused | |
| 902 | ||
| 903 | LOOP = 62, // Too many levels of symbolic links | |
| 904 | NAMETOOLONG = 63, // File name too long | |
| 905 | ||
| 906 | // should be rearranged | |
| 907 | HOSTDOWN = 64, // Host is down | |
| 908 | HOSTUNREACH = 65, // No route to host | |
| 909 | NOTEMPTY = 66, // Directory not empty | |
| 910 | ||
| 911 | // quotas & mush | |
| 912 | PROCLIM = 67, // Too many processes | |
| 913 | USERS = 68, // Too many users | |
| 914 | DQUOT = 69, // Disc quota exceeded | |
| 915 | ||
| 916 | // Network File System | |
| 917 | STALE = 70, // Stale NFS file handle | |
| 918 | REMOTE = 71, // Too many levels of remote in path | |
| 919 | BADRPC = 72, // RPC struct is bad | |
| 920 | RPCMISMATCH = 73, // RPC version wrong | |
| 921 | PROGUNAVAIL = 74, // RPC prog. not avail | |
| 922 | PROGMISMATCH = 75, // Program version wrong | |
| 923 | PROCUNAVAIL = 76, // Bad procedure for program | |
| 924 | ||
| 925 | NOLCK = 77, // No locks available | |
| 926 | NOSYS = 78, // Function not implemented | |
| 927 | ||
| 928 | FTYPE = 79, // Inappropriate file type or format | |
| 929 | AUTH = 80, // Authentication error | |
| 930 | NEEDAUTH = 81, // Need authenticator | |
| 931 | IPSEC = 82, // IPsec processing failure | |
| 932 | NOATTR = 83, // Attribute not found | |
| 933 | ||
| 934 | // Wide/multibyte-character handling, ISO/IEC 9899/AMD1:1995 | |
| 935 | ILSEQ = 84, // Illegal byte sequence | |
| 936 | ||
| 937 | NOMEDIUM = 85, // No medium found | |
| 938 | MEDIUMTYPE = 86, // Wrong medium type | |
| 939 | OVERFLOW = 87, // Value too large to be stored in data type | |
| 940 | CANCELED = 88, // Operation canceled | |
| 941 | IDRM = 89, // Identifier removed | |
| 942 | NOMSG = 90, // No message of desired type | |
| 943 | NOTSUP = 91, // Not supported | |
| 944 | BADMSG = 92, // Bad or Corrupt message | |
| 945 | NOTRECOVERABLE = 93, // State not recoverable | |
| 946 | OWNERDEAD = 94, // Previous owner died | |
| 947 | PROTO = 95, // Protocol error | |
| 948 | ||
| 949 | _, | |
| 950 | }; | |
| 946 | 951 | |
| 947 | 952 | const _MAX_PAGE_SHIFT = switch (builtin.target.cpu.arch) { |
| 948 | 953 | .i386 => 12, |
lib/std/os/bits/wasi.zig+83-80| ... | ... | @@ -111,86 +111,89 @@ pub const dirent_t = extern struct { |
| 111 | 111 | d_type: filetype_t, |
| 112 | 112 | }; |
| 113 | 113 | |
| 114 | pub const errno_t = u16; | |
| 115 | pub const ESUCCESS: errno_t = 0; | |
| 116 | pub const E2BIG: errno_t = 1; | |
| 117 | pub const EACCES: errno_t = 2; | |
| 118 | pub const EADDRINUSE: errno_t = 3; | |
| 119 | pub const EADDRNOTAVAIL: errno_t = 4; | |
| 120 | pub const EAFNOSUPPORT: errno_t = 5; | |
| 121 | pub const EAGAIN: errno_t = 6; | |
| 122 | pub const EWOULDBLOCK = EAGAIN; | |
| 123 | pub const EALREADY: errno_t = 7; | |
| 124 | pub const EBADF: errno_t = 8; | |
| 125 | pub const EBADMSG: errno_t = 9; | |
| 126 | pub const EBUSY: errno_t = 10; | |
| 127 | pub const ECANCELED: errno_t = 11; | |
| 128 | pub const ECHILD: errno_t = 12; | |
| 129 | pub const ECONNABORTED: errno_t = 13; | |
| 130 | pub const ECONNREFUSED: errno_t = 14; | |
| 131 | pub const ECONNRESET: errno_t = 15; | |
| 132 | pub const EDEADLK: errno_t = 16; | |
| 133 | pub const EDESTADDRREQ: errno_t = 17; | |
| 134 | pub const EDOM: errno_t = 18; | |
| 135 | pub const EDQUOT: errno_t = 19; | |
| 136 | pub const EEXIST: errno_t = 20; | |
| 137 | pub const EFAULT: errno_t = 21; | |
| 138 | pub const EFBIG: errno_t = 22; | |
| 139 | pub const EHOSTUNREACH: errno_t = 23; | |
| 140 | pub const EIDRM: errno_t = 24; | |
| 141 | pub const EILSEQ: errno_t = 25; | |
| 142 | pub const EINPROGRESS: errno_t = 26; | |
| 143 | pub const EINTR: errno_t = 27; | |
| 144 | pub const EINVAL: errno_t = 28; | |
| 145 | pub const EIO: errno_t = 29; | |
| 146 | pub const EISCONN: errno_t = 30; | |
| 147 | pub const EISDIR: errno_t = 31; | |
| 148 | pub const ELOOP: errno_t = 32; | |
| 149 | pub const EMFILE: errno_t = 33; | |
| 150 | pub const EMLINK: errno_t = 34; | |
| 151 | pub const EMSGSIZE: errno_t = 35; | |
| 152 | pub const EMULTIHOP: errno_t = 36; | |
| 153 | pub const ENAMETOOLONG: errno_t = 37; | |
| 154 | pub const ENETDOWN: errno_t = 38; | |
| 155 | pub const ENETRESET: errno_t = 39; | |
| 156 | pub const ENETUNREACH: errno_t = 40; | |
| 157 | pub const ENFILE: errno_t = 41; | |
| 158 | pub const ENOBUFS: errno_t = 42; | |
| 159 | pub const ENODEV: errno_t = 43; | |
| 160 | pub const ENOENT: errno_t = 44; | |
| 161 | pub const ENOEXEC: errno_t = 45; | |
| 162 | pub const ENOLCK: errno_t = 46; | |
| 163 | pub const ENOLINK: errno_t = 47; | |
| 164 | pub const ENOMEM: errno_t = 48; | |
| 165 | pub const ENOMSG: errno_t = 49; | |
| 166 | pub const ENOPROTOOPT: errno_t = 50; | |
| 167 | pub const ENOSPC: errno_t = 51; | |
| 168 | pub const ENOSYS: errno_t = 52; | |
| 169 | pub const ENOTCONN: errno_t = 53; | |
| 170 | pub const ENOTDIR: errno_t = 54; | |
| 171 | pub const ENOTEMPTY: errno_t = 55; | |
| 172 | pub const ENOTRECOVERABLE: errno_t = 56; | |
| 173 | pub const ENOTSOCK: errno_t = 57; | |
| 174 | pub const ENOTSUP: errno_t = 58; | |
| 175 | pub const EOPNOTSUPP = ENOTSUP; | |
| 176 | pub const ENOTTY: errno_t = 59; | |
| 177 | pub const ENXIO: errno_t = 60; | |
| 178 | pub const EOVERFLOW: errno_t = 61; | |
| 179 | pub const EOWNERDEAD: errno_t = 62; | |
| 180 | pub const EPERM: errno_t = 63; | |
| 181 | pub const EPIPE: errno_t = 64; | |
| 182 | pub const EPROTO: errno_t = 65; | |
| 183 | pub const EPROTONOSUPPORT: errno_t = 66; | |
| 184 | pub const EPROTOTYPE: errno_t = 67; | |
| 185 | pub const ERANGE: errno_t = 68; | |
| 186 | pub const EROFS: errno_t = 69; | |
| 187 | pub const ESPIPE: errno_t = 70; | |
| 188 | pub const ESRCH: errno_t = 71; | |
| 189 | pub const ESTALE: errno_t = 72; | |
| 190 | pub const ETIMEDOUT: errno_t = 73; | |
| 191 | pub const ETXTBSY: errno_t = 74; | |
| 192 | pub const EXDEV: errno_t = 75; | |
| 193 | pub const ENOTCAPABLE: errno_t = 76; | |
| 114 | pub const errno_t = enum(u16) { | |
| 115 | SUCCESS = 0, | |
| 116 | @"2BIG" = 1, | |
| 117 | ACCES = 2, | |
| 118 | ADDRINUSE = 3, | |
| 119 | ADDRNOTAVAIL = 4, | |
| 120 | AFNOSUPPORT = 5, | |
| 121 | /// This is also the error code used for `WOULDBLOCK`. | |
| 122 | AGAIN = 6, | |
| 123 | ALREADY = 7, | |
| 124 | BADF = 8, | |
| 125 | BADMSG = 9, | |
| 126 | BUSY = 10, | |
| 127 | CANCELED = 11, | |
| 128 | CHILD = 12, | |
| 129 | CONNABORTED = 13, | |
| 130 | CONNREFUSED = 14, | |
| 131 | CONNRESET = 15, | |
| 132 | DEADLK = 16, | |
| 133 | DESTADDRREQ = 17, | |
| 134 | DOM = 18, | |
| 135 | DQUOT = 19, | |
| 136 | EXIST = 20, | |
| 137 | FAULT = 21, | |
| 138 | FBIG = 22, | |
| 139 | HOSTUNREACH = 23, | |
| 140 | IDRM = 24, | |
| 141 | ILSEQ = 25, | |
| 142 | INPROGRESS = 26, | |
| 143 | INTR = 27, | |
| 144 | INVAL = 28, | |
| 145 | IO = 29, | |
| 146 | ISCONN = 30, | |
| 147 | ISDIR = 31, | |
| 148 | LOOP = 32, | |
| 149 | MFILE = 33, | |
| 150 | MLINK = 34, | |
| 151 | MSGSIZE = 35, | |
| 152 | MULTIHOP = 36, | |
| 153 | NAMETOOLONG = 37, | |
| 154 | NETDOWN = 38, | |
| 155 | NETRESET = 39, | |
| 156 | NETUNREACH = 40, | |
| 157 | NFILE = 41, | |
| 158 | NOBUFS = 42, | |
| 159 | NODEV = 43, | |
| 160 | NOENT = 44, | |
| 161 | NOEXEC = 45, | |
| 162 | NOLCK = 46, | |
| 163 | NOLINK = 47, | |
| 164 | NOMEM = 48, | |
| 165 | NOMSG = 49, | |
| 166 | NOPROTOOPT = 50, | |
| 167 | NOSPC = 51, | |
| 168 | NOSYS = 52, | |
| 169 | NOTCONN = 53, | |
| 170 | NOTDIR = 54, | |
| 171 | NOTEMPTY = 55, | |
| 172 | NOTRECOVERABLE = 56, | |
| 173 | NOTSOCK = 57, | |
| 174 | /// This is also the code used for `NOTSUP`. | |
| 175 | OPNOTSUPP = 58, | |
| 176 | NOTTY = 59, | |
| 177 | NXIO = 60, | |
| 178 | OVERFLOW = 61, | |
| 179 | OWNERDEAD = 62, | |
| 180 | PERM = 63, | |
| 181 | PIPE = 64, | |
| 182 | PROTO = 65, | |
| 183 | PROTONOSUPPORT = 66, | |
| 184 | PROTOTYPE = 67, | |
| 185 | RANGE = 68, | |
| 186 | ROFS = 69, | |
| 187 | SPIPE = 70, | |
| 188 | SRCH = 71, | |
| 189 | STALE = 72, | |
| 190 | TIMEDOUT = 73, | |
| 191 | TXTBSY = 74, | |
| 192 | XDEV = 75, | |
| 193 | NOTCAPABLE = 76, | |
| 194 | _, | |
| 195 | }; | |
| 196 | pub const E = errno_t; | |
| 194 | 197 | |
| 195 | 198 | pub const event_t = extern struct { |
| 196 | 199 | userdata: userdata_t, |
lib/std/os/bits/windows.zig+90-86| ... | ... | @@ -87,93 +87,97 @@ pub const SEEK_SET = 0; |
| 87 | 87 | pub const SEEK_CUR = 1; |
| 88 | 88 | pub const SEEK_END = 2; |
| 89 | 89 | |
| 90 | pub const EPERM = 1; | |
| 91 | pub const ENOENT = 2; | |
| 92 | pub const ESRCH = 3; | |
| 93 | pub const EINTR = 4; | |
| 94 | pub const EIO = 5; | |
| 95 | pub const ENXIO = 6; | |
| 96 | pub const E2BIG = 7; | |
| 97 | pub const ENOEXEC = 8; | |
| 98 | pub const EBADF = 9; | |
| 99 | pub const ECHILD = 10; | |
| 100 | pub const EAGAIN = 11; | |
| 101 | pub const ENOMEM = 12; | |
| 102 | pub const EACCES = 13; | |
| 103 | pub const EFAULT = 14; | |
| 104 | pub const EBUSY = 16; | |
| 105 | pub const EEXIST = 17; | |
| 106 | pub const EXDEV = 18; | |
| 107 | pub const ENODEV = 19; | |
| 108 | pub const ENOTDIR = 20; | |
| 109 | pub const EISDIR = 21; | |
| 110 | pub const ENFILE = 23; | |
| 111 | pub const EMFILE = 24; | |
| 112 | pub const ENOTTY = 25; | |
| 113 | pub const EFBIG = 27; | |
| 114 | pub const ENOSPC = 28; | |
| 115 | pub const ESPIPE = 29; | |
| 116 | pub const EROFS = 30; | |
| 117 | pub const EMLINK = 31; | |
| 118 | pub const EPIPE = 32; | |
| 119 | pub const EDOM = 33; | |
| 120 | pub const EDEADLK = 36; | |
| 121 | pub const ENAMETOOLONG = 38; | |
| 122 | pub const ENOLCK = 39; | |
| 123 | pub const ENOSYS = 40; | |
| 124 | pub const ENOTEMPTY = 41; | |
| 125 | ||
| 126 | pub const EINVAL = 22; | |
| 127 | pub const ERANGE = 34; | |
| 128 | pub const EILSEQ = 42; | |
| 129 | pub const STRUNCATE = 80; | |
| 90 | pub const E = enum(u16) { | |
| 91 | /// No error occurred. | |
| 92 | SUCCESS = 0, | |
| 93 | PERM = 1, | |
| 94 | NOENT = 2, | |
| 95 | SRCH = 3, | |
| 96 | INTR = 4, | |
| 97 | IO = 5, | |
| 98 | NXIO = 6, | |
| 99 | @"2BIG" = 7, | |
| 100 | NOEXEC = 8, | |
| 101 | BADF = 9, | |
| 102 | CHILD = 10, | |
| 103 | AGAIN = 11, | |
| 104 | NOMEM = 12, | |
| 105 | ACCES = 13, | |
| 106 | FAULT = 14, | |
| 107 | BUSY = 16, | |
| 108 | EXIST = 17, | |
| 109 | XDEV = 18, | |
| 110 | NODEV = 19, | |
| 111 | NOTDIR = 20, | |
| 112 | ISDIR = 21, | |
| 113 | NFILE = 23, | |
| 114 | MFILE = 24, | |
| 115 | NOTTY = 25, | |
| 116 | FBIG = 27, | |
| 117 | NOSPC = 28, | |
| 118 | SPIPE = 29, | |
| 119 | ROFS = 30, | |
| 120 | MLINK = 31, | |
| 121 | PIPE = 32, | |
| 122 | DOM = 33, | |
| 123 | /// Also means `DEADLOCK`. | |
| 124 | DEADLK = 36, | |
| 125 | NAMETOOLONG = 38, | |
| 126 | NOLCK = 39, | |
| 127 | NOSYS = 40, | |
| 128 | NOTEMPTY = 41, | |
| 129 | ||
| 130 | INVAL = 22, | |
| 131 | RANGE = 34, | |
| 132 | ILSEQ = 42, | |
| 133 | ||
| 134 | // POSIX Supplement | |
| 135 | ADDRINUSE = 100, | |
| 136 | ADDRNOTAVAIL = 101, | |
| 137 | AFNOSUPPORT = 102, | |
| 138 | ALREADY = 103, | |
| 139 | BADMSG = 104, | |
| 140 | CANCELED = 105, | |
| 141 | CONNABORTED = 106, | |
| 142 | CONNREFUSED = 107, | |
| 143 | CONNRESET = 108, | |
| 144 | DESTADDRREQ = 109, | |
| 145 | HOSTUNREACH = 110, | |
| 146 | IDRM = 111, | |
| 147 | INPROGRESS = 112, | |
| 148 | ISCONN = 113, | |
| 149 | LOOP = 114, | |
| 150 | MSGSIZE = 115, | |
| 151 | NETDOWN = 116, | |
| 152 | NETRESET = 117, | |
| 153 | NETUNREACH = 118, | |
| 154 | NOBUFS = 119, | |
| 155 | NODATA = 120, | |
| 156 | NOLINK = 121, | |
| 157 | NOMSG = 122, | |
| 158 | NOPROTOOPT = 123, | |
| 159 | NOSR = 124, | |
| 160 | NOSTR = 125, | |
| 161 | NOTCONN = 126, | |
| 162 | NOTRECOVERABLE = 127, | |
| 163 | NOTSOCK = 128, | |
| 164 | NOTSUP = 129, | |
| 165 | OPNOTSUPP = 130, | |
| 166 | OTHER = 131, | |
| 167 | OVERFLOW = 132, | |
| 168 | OWNERDEAD = 133, | |
| 169 | PROTO = 134, | |
| 170 | PROTONOSUPPORT = 135, | |
| 171 | PROTOTYPE = 136, | |
| 172 | TIME = 137, | |
| 173 | TIMEDOUT = 138, | |
| 174 | TXTBSY = 139, | |
| 175 | WOULDBLOCK = 140, | |
| 176 | DQUOT = 10069, | |
| 177 | _, | |
| 178 | }; | |
| 130 | 179 | |
| 131 | // Support EDEADLOCK for compatibility with older Microsoft C versions | |
| 132 | pub const EDEADLOCK = EDEADLK; | |
| 133 | ||
| 134 | // POSIX Supplement | |
| 135 | pub const EADDRINUSE = 100; | |
| 136 | pub const EADDRNOTAVAIL = 101; | |
| 137 | pub const EAFNOSUPPORT = 102; | |
| 138 | pub const EALREADY = 103; | |
| 139 | pub const EBADMSG = 104; | |
| 140 | pub const ECANCELED = 105; | |
| 141 | pub const ECONNABORTED = 106; | |
| 142 | pub const ECONNREFUSED = 107; | |
| 143 | pub const ECONNRESET = 108; | |
| 144 | pub const EDESTADDRREQ = 109; | |
| 145 | pub const EHOSTUNREACH = 110; | |
| 146 | pub const EIDRM = 111; | |
| 147 | pub const EINPROGRESS = 112; | |
| 148 | pub const EISCONN = 113; | |
| 149 | pub const ELOOP = 114; | |
| 150 | pub const EMSGSIZE = 115; | |
| 151 | pub const ENETDOWN = 116; | |
| 152 | pub const ENETRESET = 117; | |
| 153 | pub const ENETUNREACH = 118; | |
| 154 | pub const ENOBUFS = 119; | |
| 155 | pub const ENODATA = 120; | |
| 156 | pub const ENOLINK = 121; | |
| 157 | pub const ENOMSG = 122; | |
| 158 | pub const ENOPROTOOPT = 123; | |
| 159 | pub const ENOSR = 124; | |
| 160 | pub const ENOSTR = 125; | |
| 161 | pub const ENOTCONN = 126; | |
| 162 | pub const ENOTRECOVERABLE = 127; | |
| 163 | pub const ENOTSOCK = 128; | |
| 164 | pub const ENOTSUP = 129; | |
| 165 | pub const EOPNOTSUPP = 130; | |
| 166 | pub const EOTHER = 131; | |
| 167 | pub const EOVERFLOW = 132; | |
| 168 | pub const EOWNERDEAD = 133; | |
| 169 | pub const EPROTO = 134; | |
| 170 | pub const EPROTONOSUPPORT = 135; | |
| 171 | pub const EPROTOTYPE = 136; | |
| 172 | pub const ETIME = 137; | |
| 173 | pub const ETIMEDOUT = 138; | |
| 174 | pub const ETXTBSY = 139; | |
| 175 | pub const EWOULDBLOCK = 140; | |
| 176 | pub const EDQUOT = 10069; | |
| 180 | pub const STRUNCATE = 80; | |
| 177 | 181 | |
| 178 | 182 | pub const F_OK = 0; |
| 179 | 183 |
lib/std/os/linux.zig+8-7| ... | ... | @@ -91,9 +91,10 @@ fn splitValue64(val: i64) [2]u32 { |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | /// Get the errno from a syscall return value, or 0 for no error. |
| 94 | pub fn getErrno(r: usize) u12 { | |
| 94 | pub fn getErrno(r: usize) E { | |
| 95 | 95 | const signed_r = @bitCast(isize, r); |
| 96 | return if (signed_r > -4096 and signed_r < 0) @intCast(u12, -signed_r) else 0; | |
| 96 | const int = if (signed_r > -4096 and signed_r < 0) -signed_r else 0; | |
| 97 | return @intToEnum(E, int); | |
| 97 | 98 | } |
| 98 | 99 | |
| 99 | 100 | pub fn dup(old: i32) usize { |
| ... | ... | @@ -281,7 +282,7 @@ pub fn mmap(address: ?[*]u8, length: usize, prot: usize, flags: u32, fd: i32, of |
| 281 | 282 | if (@hasField(SYS, "mmap2")) { |
| 282 | 283 | // Make sure the offset is also specified in multiples of page size |
| 283 | 284 | if ((offset & (MMAP2_UNIT - 1)) != 0) |
| 284 | return @bitCast(usize, @as(isize, -EINVAL)); | |
| 285 | return @bitCast(usize, -@as(isize, @enumToInt(E.INVAL))); | |
| 285 | 286 | |
| 286 | 287 | return syscall6( |
| 287 | 288 | .mmap2, |
| ... | ... | @@ -746,7 +747,7 @@ pub fn clock_gettime(clk_id: i32, tp: *timespec) usize { |
| 746 | 747 | const f = @ptrCast(vdso_clock_gettime_ty, fn_ptr); |
| 747 | 748 | const rc = f(clk_id, tp); |
| 748 | 749 | switch (rc) { |
| 749 | 0, @bitCast(usize, @as(isize, -EINVAL)) => return rc, | |
| 750 | 0, @bitCast(usize, -@as(isize, @enumToInt(E.INVAL))) => return rc, | |
| 750 | 751 | else => {}, |
| 751 | 752 | } |
| 752 | 753 | } |
| ... | ... | @@ -764,7 +765,7 @@ fn init_vdso_clock_gettime(clk: i32, ts: *timespec) callconv(.C) usize { |
| 764 | 765 | const f = @ptrCast(vdso_clock_gettime_ty, fn_ptr); |
| 765 | 766 | return f(clk, ts); |
| 766 | 767 | } |
| 767 | return @bitCast(usize, @as(isize, -ENOSYS)); | |
| 768 | return @bitCast(usize, -@as(isize, @enumToInt(E.NOSYS))); | |
| 768 | 769 | } |
| 769 | 770 | |
| 770 | 771 | 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 |
| 961 | 962 | .sparc, .sparcv9 => syscall5(.rt_sigaction, sig, ksa_arg, oldksa_arg, @ptrToInt(ksa.restorer), mask_size), |
| 962 | 963 | else => syscall4(.rt_sigaction, sig, ksa_arg, oldksa_arg, mask_size), |
| 963 | 964 | }; |
| 964 | if (getErrno(result) != 0) return result; | |
| 965 | if (getErrno(result) != .SUCCESS) return result; | |
| 965 | 966 | |
| 966 | 967 | if (oact) |old| { |
| 967 | 968 | old.handler.handler = oldksa.handler; |
| ... | ... | @@ -1202,7 +1203,7 @@ pub fn statx(dirfd: i32, path: [*]const u8, flags: u32, mask: u32, statx_buf: *S |
| 1202 | 1203 | @ptrToInt(statx_buf), |
| 1203 | 1204 | ); |
| 1204 | 1205 | } |
| 1205 | return @bitCast(usize, @as(isize, -ENOSYS)); | |
| 1206 | return @bitCast(usize, -@as(isize, @enumToInt(E.NOSYS))); | |
| 1206 | 1207 | } |
| 1207 | 1208 | |
| 1208 | 1209 | pub fn listxattr(path: [*:0]const u8, list: [*]u8, size: usize) usize { |
lib/std/os/linux/bpf.zig+31-31| ... | ... | @@ -1508,13 +1508,13 @@ pub fn map_create(map_type: MapType, key_size: u32, value_size: u32, max_entries |
| 1508 | 1508 | attr.map_create.max_entries = max_entries; |
| 1509 | 1509 | |
| 1510 | 1510 | const rc = bpf(.map_create, &attr, @sizeOf(MapCreateAttr)); |
| 1511 | return switch (errno(rc)) { | |
| 1512 | 0 => @intCast(fd_t, rc), | |
| 1513 | EINVAL => error.MapTypeOrAttrInvalid, | |
| 1514 | ENOMEM => error.SystemResources, | |
| 1515 | EPERM => error.AccessDenied, | |
| 1516 | else => |err| unexpectedErrno(err), | |
| 1517 | }; | |
| 1511 | switch (errno(rc)) { | |
| 1512 | .SUCCESS => return @intCast(fd_t, rc), | |
| 1513 | .INVAL => return error.MapTypeOrAttrInvalid, | |
| 1514 | .NOMEM => return error.SystemResources, | |
| 1515 | .PERM => return error.AccessDenied, | |
| 1516 | else => |err| return unexpectedErrno(err), | |
| 1517 | } | |
| 1518 | 1518 | } |
| 1519 | 1519 | |
| 1520 | 1520 | test "map_create" { |
| ... | ... | @@ -1533,12 +1533,12 @@ pub fn map_lookup_elem(fd: fd_t, key: []const u8, value: []u8) !void { |
| 1533 | 1533 | |
| 1534 | 1534 | const rc = bpf(.map_lookup_elem, &attr, @sizeOf(MapElemAttr)); |
| 1535 | 1535 | switch (errno(rc)) { |
| 1536 | 0 => return, | |
| 1537 | EBADF => return error.BadFd, | |
| 1538 | EFAULT => unreachable, | |
| 1539 | EINVAL => return error.FieldInAttrNeedsZeroing, | |
| 1540 | ENOENT => return error.NotFound, | |
| 1541 | EPERM => return error.AccessDenied, | |
| 1536 | .SUCCESS => return, | |
| 1537 | .BADF => return error.BadFd, | |
| 1538 | .FAULT => unreachable, | |
| 1539 | .INVAL => return error.FieldInAttrNeedsZeroing, | |
| 1540 | .NOENT => return error.NotFound, | |
| 1541 | .PERM => return error.AccessDenied, | |
| 1542 | 1542 | else => |err| return unexpectedErrno(err), |
| 1543 | 1543 | } |
| 1544 | 1544 | } |
| ... | ... | @@ -1555,13 +1555,13 @@ pub fn map_update_elem(fd: fd_t, key: []const u8, value: []const u8, flags: u64) |
| 1555 | 1555 | |
| 1556 | 1556 | const rc = bpf(.map_update_elem, &attr, @sizeOf(MapElemAttr)); |
| 1557 | 1557 | switch (errno(rc)) { |
| 1558 | 0 => return, | |
| 1559 | E2BIG => return error.ReachedMaxEntries, | |
| 1560 | EBADF => return error.BadFd, | |
| 1561 | EFAULT => unreachable, | |
| 1562 | EINVAL => return error.FieldInAttrNeedsZeroing, | |
| 1563 | ENOMEM => return error.SystemResources, | |
| 1564 | EPERM => return error.AccessDenied, | |
| 1558 | .SUCCESS => return, | |
| 1559 | .@"2BIG" => return error.ReachedMaxEntries, | |
| 1560 | .BADF => return error.BadFd, | |
| 1561 | .FAULT => unreachable, | |
| 1562 | .INVAL => return error.FieldInAttrNeedsZeroing, | |
| 1563 | .NOMEM => return error.SystemResources, | |
| 1564 | .PERM => return error.AccessDenied, | |
| 1565 | 1565 | else => |err| return unexpectedErrno(err), |
| 1566 | 1566 | } |
| 1567 | 1567 | } |
| ... | ... | @@ -1576,12 +1576,12 @@ pub fn map_delete_elem(fd: fd_t, key: []const u8) !void { |
| 1576 | 1576 | |
| 1577 | 1577 | const rc = bpf(.map_delete_elem, &attr, @sizeOf(MapElemAttr)); |
| 1578 | 1578 | switch (errno(rc)) { |
| 1579 | 0 => return, | |
| 1580 | EBADF => return error.BadFd, | |
| 1581 | EFAULT => unreachable, | |
| 1582 | EINVAL => return error.FieldInAttrNeedsZeroing, | |
| 1583 | ENOENT => return error.NotFound, | |
| 1584 | EPERM => return error.AccessDenied, | |
| 1579 | .SUCCESS => return, | |
| 1580 | .BADF => return error.BadFd, | |
| 1581 | .FAULT => unreachable, | |
| 1582 | .INVAL => return error.FieldInAttrNeedsZeroing, | |
| 1583 | .NOENT => return error.NotFound, | |
| 1584 | .PERM => return error.AccessDenied, | |
| 1585 | 1585 | else => |err| return unexpectedErrno(err), |
| 1586 | 1586 | } |
| 1587 | 1587 | } |
| ... | ... | @@ -1639,11 +1639,11 @@ pub fn prog_load( |
| 1639 | 1639 | |
| 1640 | 1640 | const rc = bpf(.prog_load, &attr, @sizeOf(ProgLoadAttr)); |
| 1641 | 1641 | return switch (errno(rc)) { |
| 1642 | 0 => @intCast(fd_t, rc), | |
| 1643 | EACCES => error.UnsafeProgram, | |
| 1644 | EFAULT => unreachable, | |
| 1645 | EINVAL => error.InvalidProgram, | |
| 1646 | EPERM => error.AccessDenied, | |
| 1642 | .SUCCESS => @intCast(fd_t, rc), | |
| 1643 | .ACCES => error.UnsafeProgram, | |
| 1644 | .FAULT => unreachable, | |
| 1645 | .INVAL => error.InvalidProgram, | |
| 1646 | .PERM => error.AccessDenied, | |
| 1647 | 1647 | else => |err| unexpectedErrno(err), |
| 1648 | 1648 | }; |
| 1649 | 1649 | } |
lib/std/os/linux/io_uring.zig+44-44| ... | ... | @@ -54,19 +54,19 @@ pub const IO_Uring = struct { |
| 54 | 54 | |
| 55 | 55 | const res = linux.io_uring_setup(entries, p); |
| 56 | 56 | switch (linux.getErrno(res)) { |
| 57 | 0 => {}, | |
| 58 | linux.EFAULT => return error.ParamsOutsideAccessibleAddressSpace, | |
| 57 | .SUCCESS => {}, | |
| 58 | .FAULT => return error.ParamsOutsideAccessibleAddressSpace, | |
| 59 | 59 | // The resv array contains non-zero data, p.flags contains an unsupported flag, |
| 60 | 60 | // entries out of bounds, IORING_SETUP_SQ_AFF was specified without IORING_SETUP_SQPOLL, |
| 61 | 61 | // or IORING_SETUP_CQSIZE was specified but io_uring_params.cq_entries was invalid: |
| 62 | linux.EINVAL => return error.ArgumentsInvalid, | |
| 63 | linux.EMFILE => return error.ProcessFdQuotaExceeded, | |
| 64 | linux.ENFILE => return error.SystemFdQuotaExceeded, | |
| 65 | linux.ENOMEM => return error.SystemResources, | |
| 62 | .INVAL => return error.ArgumentsInvalid, | |
| 63 | .MFILE => return error.ProcessFdQuotaExceeded, | |
| 64 | .NFILE => return error.SystemFdQuotaExceeded, | |
| 65 | .NOMEM => return error.SystemResources, | |
| 66 | 66 | // IORING_SETUP_SQPOLL was specified but effective user ID lacks sufficient privileges, |
| 67 | 67 | // or a container seccomp policy prohibits io_uring syscalls: |
| 68 | linux.EPERM => return error.PermissionDenied, | |
| 69 | linux.ENOSYS => return error.SystemOutdated, | |
| 68 | .PERM => return error.PermissionDenied, | |
| 69 | .NOSYS => return error.SystemOutdated, | |
| 70 | 70 | else => |errno| return os.unexpectedErrno(errno), |
| 71 | 71 | } |
| 72 | 72 | const fd = @intCast(os.fd_t, res); |
| ... | ... | @@ -180,31 +180,31 @@ pub const IO_Uring = struct { |
| 180 | 180 | assert(self.fd >= 0); |
| 181 | 181 | const res = linux.io_uring_enter(self.fd, to_submit, min_complete, flags, null); |
| 182 | 182 | switch (linux.getErrno(res)) { |
| 183 | 0 => {}, | |
| 183 | .SUCCESS => {}, | |
| 184 | 184 | // The kernel was unable to allocate memory or ran out of resources for the request. |
| 185 | 185 | // The application should wait for some completions and try again: |
| 186 | linux.EAGAIN => return error.SystemResources, | |
| 186 | .AGAIN => return error.SystemResources, | |
| 187 | 187 | // The SQE `fd` is invalid, or IOSQE_FIXED_FILE was set but no files were registered: |
| 188 | linux.EBADF => return error.FileDescriptorInvalid, | |
| 188 | .BADF => return error.FileDescriptorInvalid, | |
| 189 | 189 | // The file descriptor is valid, but the ring is not in the right state. |
| 190 | 190 | // See io_uring_register(2) for how to enable the ring. |
| 191 | linux.EBADFD => return error.FileDescriptorInBadState, | |
| 191 | .BADFD => return error.FileDescriptorInBadState, | |
| 192 | 192 | // The application attempted to overcommit the number of requests it can have pending. |
| 193 | 193 | // The application should wait for some completions and try again: |
| 194 | linux.EBUSY => return error.CompletionQueueOvercommitted, | |
| 194 | .BUSY => return error.CompletionQueueOvercommitted, | |
| 195 | 195 | // The SQE is invalid, or valid but the ring was setup with IORING_SETUP_IOPOLL: |
| 196 | linux.EINVAL => return error.SubmissionQueueEntryInvalid, | |
| 196 | .INVAL => return error.SubmissionQueueEntryInvalid, | |
| 197 | 197 | // The buffer is outside the process' accessible address space, or IORING_OP_READ_FIXED |
| 198 | 198 | // or IORING_OP_WRITE_FIXED was specified but no buffers were registered, or the range |
| 199 | 199 | // described by `addr` and `len` is not within the buffer registered at `buf_index`: |
| 200 | linux.EFAULT => return error.BufferInvalid, | |
| 201 | linux.ENXIO => return error.RingShuttingDown, | |
| 200 | .FAULT => return error.BufferInvalid, | |
| 201 | .NXIO => return error.RingShuttingDown, | |
| 202 | 202 | // The kernel believes our `self.fd` does not refer to an io_uring instance, |
| 203 | 203 | // or the opcode is valid but not supported by this kernel (more likely): |
| 204 | linux.EOPNOTSUPP => return error.OpcodeNotSupported, | |
| 204 | .OPNOTSUPP => return error.OpcodeNotSupported, | |
| 205 | 205 | // The operation was interrupted by a delivery of a signal before it could complete. |
| 206 | 206 | // This can happen while waiting for events with IORING_ENTER_GETEVENTS: |
| 207 | linux.EINTR => return error.SignalInterrupt, | |
| 207 | .INTR => return error.SignalInterrupt, | |
| 208 | 208 | else => |errno| return os.unexpectedErrno(errno), |
| 209 | 209 | } |
| 210 | 210 | return @intCast(u32, res); |
| ... | ... | @@ -681,22 +681,22 @@ pub const IO_Uring = struct { |
| 681 | 681 | |
| 682 | 682 | fn handle_registration_result(res: usize) !void { |
| 683 | 683 | switch (linux.getErrno(res)) { |
| 684 | 0 => {}, | |
| 684 | .SUCCESS => {}, | |
| 685 | 685 | // One or more fds in the array are invalid, or the kernel does not support sparse sets: |
| 686 | linux.EBADF => return error.FileDescriptorInvalid, | |
| 687 | linux.EBUSY => return error.FilesAlreadyRegistered, | |
| 688 | linux.EINVAL => return error.FilesEmpty, | |
| 686 | .BADF => return error.FileDescriptorInvalid, | |
| 687 | .BUSY => return error.FilesAlreadyRegistered, | |
| 688 | .INVAL => return error.FilesEmpty, | |
| 689 | 689 | // Adding `nr_args` file references would exceed the maximum allowed number of files the |
| 690 | 690 | // user is allowed to have according to the per-user RLIMIT_NOFILE resource limit and |
| 691 | 691 | // the CAP_SYS_RESOURCE capability is not set, or `nr_args` exceeds the maximum allowed |
| 692 | 692 | // for a fixed file set (older kernels have a limit of 1024 files vs 64K files): |
| 693 | linux.EMFILE => return error.UserFdQuotaExceeded, | |
| 693 | .MFILE => return error.UserFdQuotaExceeded, | |
| 694 | 694 | // Insufficient kernel resources, or the caller had a non-zero RLIMIT_MEMLOCK soft |
| 695 | 695 | // resource limit but tried to lock more memory than the limit permitted (not enforced |
| 696 | 696 | // when the process is privileged with CAP_IPC_LOCK): |
| 697 | linux.ENOMEM => return error.SystemResources, | |
| 697 | .NOMEM => return error.SystemResources, | |
| 698 | 698 | // Attempt to register files on a ring already registering files or being torn down: |
| 699 | linux.ENXIO => return error.RingShuttingDownOrAlreadyRegisteringFiles, | |
| 699 | .NXIO => return error.RingShuttingDownOrAlreadyRegisteringFiles, | |
| 700 | 700 | else => |errno| return os.unexpectedErrno(errno), |
| 701 | 701 | } |
| 702 | 702 | } |
| ... | ... | @@ -706,8 +706,8 @@ pub const IO_Uring = struct { |
| 706 | 706 | assert(self.fd >= 0); |
| 707 | 707 | const res = linux.io_uring_register(self.fd, .UNREGISTER_FILES, null, 0); |
| 708 | 708 | switch (linux.getErrno(res)) { |
| 709 | 0 => {}, | |
| 710 | linux.ENXIO => return error.FilesNotRegistered, | |
| 709 | .SUCCESS => {}, | |
| 710 | .NXIO => return error.FilesNotRegistered, | |
| 711 | 711 | else => |errno| return os.unexpectedErrno(errno), |
| 712 | 712 | } |
| 713 | 713 | } |
| ... | ... | @@ -1272,8 +1272,8 @@ test "write/read" { |
| 1272 | 1272 | const cqe_read = try ring.copy_cqe(); |
| 1273 | 1273 | // Prior to Linux Kernel 5.6 this is the only way to test for read/write support: |
| 1274 | 1274 | // https://lwn.net/Articles/809820/ |
| 1275 | if (cqe_write.res == -linux.EINVAL) return error.SkipZigTest; | |
| 1276 | if (cqe_read.res == -linux.EINVAL) return error.SkipZigTest; | |
| 1275 | if (cqe_write.err() == .INVAL) return error.SkipZigTest; | |
| 1276 | if (cqe_read.err() == .INVAL) return error.SkipZigTest; | |
| 1277 | 1277 | try testing.expectEqual(linux.io_uring_cqe{ |
| 1278 | 1278 | .user_data = 0x11111111, |
| 1279 | 1279 | .res = buffer_write.len, |
| ... | ... | @@ -1322,11 +1322,11 @@ test "openat" { |
| 1322 | 1322 | |
| 1323 | 1323 | const cqe_openat = try ring.copy_cqe(); |
| 1324 | 1324 | try testing.expectEqual(@as(u64, 0x33333333), cqe_openat.user_data); |
| 1325 | if (cqe_openat.res == -linux.EINVAL) return error.SkipZigTest; | |
| 1325 | if (cqe_openat.err() == .INVAL) return error.SkipZigTest; | |
| 1326 | 1326 | // AT_FDCWD is not fully supported before kernel 5.6: |
| 1327 | 1327 | // See https://lore.kernel.org/io-uring/20200207155039.12819-1-axboe@kernel.dk/T/ |
| 1328 | 1328 | // We use IORING_FEAT_RW_CUR_POS to know if we are pre-5.6 since that feature was added in 5.6. |
| 1329 | if (cqe_openat.res == -linux.EBADF and (ring.features & linux.IORING_FEAT_RW_CUR_POS) == 0) { | |
| 1329 | if (cqe_openat.err() == .BADF and (ring.features & linux.IORING_FEAT_RW_CUR_POS) == 0) { | |
| 1330 | 1330 | return error.SkipZigTest; |
| 1331 | 1331 | } |
| 1332 | 1332 | if (cqe_openat.res <= 0) std.debug.print("\ncqe_openat.res={}\n", .{cqe_openat.res}); |
| ... | ... | @@ -1357,7 +1357,7 @@ test "close" { |
| 1357 | 1357 | try testing.expectEqual(@as(u32, 1), try ring.submit()); |
| 1358 | 1358 | |
| 1359 | 1359 | const cqe_close = try ring.copy_cqe(); |
| 1360 | if (cqe_close.res == -linux.EINVAL) return error.SkipZigTest; | |
| 1360 | if (cqe_close.err() == .INVAL) return error.SkipZigTest; | |
| 1361 | 1361 | try testing.expectEqual(linux.io_uring_cqe{ |
| 1362 | 1362 | .user_data = 0x44444444, |
| 1363 | 1363 | .res = 0, |
| ... | ... | @@ -1397,9 +1397,9 @@ test "accept/connect/send/recv" { |
| 1397 | 1397 | try testing.expectEqual(@as(u32, 1), try ring.submit()); |
| 1398 | 1398 | |
| 1399 | 1399 | var cqe_accept = try ring.copy_cqe(); |
| 1400 | if (cqe_accept.res == -linux.EINVAL) return error.SkipZigTest; | |
| 1400 | if (cqe_accept.err() == .INVAL) return error.SkipZigTest; | |
| 1401 | 1401 | var cqe_connect = try ring.copy_cqe(); |
| 1402 | if (cqe_connect.res == -linux.EINVAL) return error.SkipZigTest; | |
| 1402 | if (cqe_connect.err() == .INVAL) return error.SkipZigTest; | |
| 1403 | 1403 | |
| 1404 | 1404 | // The accept/connect CQEs may arrive in any order, the connect CQE will sometimes come first: |
| 1405 | 1405 | if (cqe_accept.user_data == 0xcccccccc and cqe_connect.user_data == 0xaaaaaaaa) { |
| ... | ... | @@ -1425,7 +1425,7 @@ test "accept/connect/send/recv" { |
| 1425 | 1425 | try testing.expectEqual(@as(u32, 2), try ring.submit()); |
| 1426 | 1426 | |
| 1427 | 1427 | const cqe_send = try ring.copy_cqe(); |
| 1428 | if (cqe_send.res == -linux.EINVAL) return error.SkipZigTest; | |
| 1428 | if (cqe_send.err() == .INVAL) return error.SkipZigTest; | |
| 1429 | 1429 | try testing.expectEqual(linux.io_uring_cqe{ |
| 1430 | 1430 | .user_data = 0xeeeeeeee, |
| 1431 | 1431 | .res = buffer_send.len, |
| ... | ... | @@ -1433,7 +1433,7 @@ test "accept/connect/send/recv" { |
| 1433 | 1433 | }, cqe_send); |
| 1434 | 1434 | |
| 1435 | 1435 | const cqe_recv = try ring.copy_cqe(); |
| 1436 | if (cqe_recv.res == -linux.EINVAL) return error.SkipZigTest; | |
| 1436 | if (cqe_recv.err() == .INVAL) return error.SkipZigTest; | |
| 1437 | 1437 | try testing.expectEqual(linux.io_uring_cqe{ |
| 1438 | 1438 | .user_data = 0xffffffff, |
| 1439 | 1439 | .res = buffer_recv.len, |
| ... | ... | @@ -1466,7 +1466,7 @@ test "timeout (after a relative time)" { |
| 1466 | 1466 | |
| 1467 | 1467 | try testing.expectEqual(linux.io_uring_cqe{ |
| 1468 | 1468 | .user_data = 0x55555555, |
| 1469 | .res = -linux.ETIME, | |
| 1469 | .res = -@as(i32, @enumToInt(linux.E.TIME)), | |
| 1470 | 1470 | .flags = 0, |
| 1471 | 1471 | }, cqe); |
| 1472 | 1472 | |
| ... | ... | @@ -1535,14 +1535,14 @@ test "timeout_remove" { |
| 1535 | 1535 | // We use IORING_FEAT_RW_CUR_POS as a safety check here to make sure we are at least pre-5.6. |
| 1536 | 1536 | // We don't want to skip this test for newer kernels. |
| 1537 | 1537 | if (cqe_timeout.user_data == 0x99999999 and |
| 1538 | cqe_timeout.res == -linux.EBADF and | |
| 1538 | cqe_timeout.err() == .BADF and | |
| 1539 | 1539 | (ring.features & linux.IORING_FEAT_RW_CUR_POS) == 0) |
| 1540 | 1540 | { |
| 1541 | 1541 | return error.SkipZigTest; |
| 1542 | 1542 | } |
| 1543 | 1543 | try testing.expectEqual(linux.io_uring_cqe{ |
| 1544 | 1544 | .user_data = 0x88888888, |
| 1545 | .res = -linux.ECANCELED, | |
| 1545 | .res = -@as(i32, @enumToInt(linux.E.CANCELED)), | |
| 1546 | 1546 | .flags = 0, |
| 1547 | 1547 | }, cqe_timeout); |
| 1548 | 1548 | |
| ... | ... | @@ -1578,15 +1578,15 @@ test "fallocate" { |
| 1578 | 1578 | try testing.expectEqual(@as(u32, 1), try ring.submit()); |
| 1579 | 1579 | |
| 1580 | 1580 | const cqe = try ring.copy_cqe(); |
| 1581 | switch (-cqe.res) { | |
| 1582 | 0 => {}, | |
| 1581 | switch (cqe.err()) { | |
| 1582 | .SUCCESS => {}, | |
| 1583 | 1583 | // This kernel's io_uring does not yet implement fallocate(): |
| 1584 | linux.EINVAL => return error.SkipZigTest, | |
| 1584 | .INVAL => return error.SkipZigTest, | |
| 1585 | 1585 | // This kernel does not implement fallocate(): |
| 1586 | linux.ENOSYS => return error.SkipZigTest, | |
| 1586 | .NOSYS => return error.SkipZigTest, | |
| 1587 | 1587 | // The filesystem containing the file referred to by fd does not support this operation; |
| 1588 | 1588 | // or the mode is not supported by the filesystem containing the file referred to by fd: |
| 1589 | linux.EOPNOTSUPP => return error.SkipZigTest, | |
| 1589 | .OPNOTSUPP => return error.SkipZigTest, | |
| 1590 | 1590 | else => |errno| std.debug.panic("unhandled errno: {}", .{errno}), |
| 1591 | 1591 | } |
| 1592 | 1592 | try testing.expectEqual(linux.io_uring_cqe{ |
lib/std/os/linux/test.zig+15-15| ... | ... | @@ -22,9 +22,9 @@ test "fallocate" { |
| 22 | 22 | |
| 23 | 23 | const len: i64 = 65536; |
| 24 | 24 | switch (linux.getErrno(linux.fallocate(file.handle, 0, 0, len))) { |
| 25 | 0 => {}, | |
| 26 | linux.ENOSYS => return error.SkipZigTest, | |
| 27 | linux.EOPNOTSUPP => return error.SkipZigTest, | |
| 25 | .SUCCESS => {}, | |
| 26 | .NOSYS => return error.SkipZigTest, | |
| 27 | .OPNOTSUPP => return error.SkipZigTest, | |
| 28 | 28 | else => |errno| std.debug.panic("unhandled errno: {}", .{errno}), |
| 29 | 29 | } |
| 30 | 30 | |
| ... | ... | @@ -37,11 +37,11 @@ test "getpid" { |
| 37 | 37 | |
| 38 | 38 | test "timer" { |
| 39 | 39 | const epoll_fd = linux.epoll_create(); |
| 40 | var err: usize = linux.getErrno(epoll_fd); | |
| 41 | try expect(err == 0); | |
| 40 | var err: linux.E = linux.getErrno(epoll_fd); | |
| 41 | try expect(err == .SUCCESS); | |
| 42 | 42 | |
| 43 | 43 | const timer_fd = linux.timerfd_create(linux.CLOCK_MONOTONIC, 0); |
| 44 | try expect(linux.getErrno(timer_fd) == 0); | |
| 44 | try expect(linux.getErrno(timer_fd) == .SUCCESS); | |
| 45 | 45 | |
| 46 | 46 | const time_interval = linux.timespec{ |
| 47 | 47 | .tv_sec = 0, |
| ... | ... | @@ -53,22 +53,22 @@ test "timer" { |
| 53 | 53 | .it_value = time_interval, |
| 54 | 54 | }; |
| 55 | 55 | |
| 56 | err = linux.timerfd_settime(@intCast(i32, timer_fd), 0, &new_time, null); | |
| 57 | try expect(err == 0); | |
| 56 | err = linux.getErrno(linux.timerfd_settime(@intCast(i32, timer_fd), 0, &new_time, null)); | |
| 57 | try expect(err == .SUCCESS); | |
| 58 | 58 | |
| 59 | 59 | var event = linux.epoll_event{ |
| 60 | 60 | .events = linux.EPOLLIN | linux.EPOLLOUT | linux.EPOLLET, |
| 61 | 61 | .data = linux.epoll_data{ .ptr = 0 }, |
| 62 | 62 | }; |
| 63 | 63 | |
| 64 | err = linux.epoll_ctl(@intCast(i32, epoll_fd), linux.EPOLL_CTL_ADD, @intCast(i32, timer_fd), &event); | |
| 65 | try expect(err == 0); | |
| 64 | err = linux.getErrno(linux.epoll_ctl(@intCast(i32, epoll_fd), linux.EPOLL_CTL_ADD, @intCast(i32, timer_fd), &event)); | |
| 65 | try expect(err == .SUCCESS); | |
| 66 | 66 | |
| 67 | 67 | const events_one: linux.epoll_event = undefined; |
| 68 | 68 | var events = [_]linux.epoll_event{events_one} ** 8; |
| 69 | 69 | |
| 70 | // TODO implicit cast from *[N]T to [*]T | |
| 71 | err = linux.epoll_wait(@intCast(i32, epoll_fd), @ptrCast([*]linux.epoll_event, &events), 8, -1); | |
| 70 | err = linux.getErrno(linux.epoll_wait(@intCast(i32, epoll_fd), &events, 8, -1)); | |
| 71 | try expect(err == .SUCCESS); | |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | test "statx" { |
| ... | ... | @@ -81,15 +81,15 @@ test "statx" { |
| 81 | 81 | |
| 82 | 82 | var statx_buf: linux.Statx = undefined; |
| 83 | 83 | switch (linux.getErrno(linux.statx(file.handle, "", linux.AT_EMPTY_PATH, linux.STATX_BASIC_STATS, &statx_buf))) { |
| 84 | 0 => {}, | |
| 84 | .SUCCESS => {}, | |
| 85 | 85 | // The statx syscall was only introduced in linux 4.11 |
| 86 | linux.ENOSYS => return error.SkipZigTest, | |
| 86 | .NOSYS => return error.SkipZigTest, | |
| 87 | 87 | else => unreachable, |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | var stat_buf: linux.kernel_stat = undefined; |
| 91 | 91 | switch (linux.getErrno(linux.fstatat(file.handle, "", &stat_buf, linux.AT_EMPTY_PATH))) { |
| 92 | 0 => {}, | |
| 92 | .SUCCESS => {}, | |
| 93 | 93 | else => unreachable, |
| 94 | 94 | } |
| 95 | 95 |
lib/std/os/wasi.zig+1-1| ... | ... | @@ -83,6 +83,6 @@ pub extern "wasi_snapshot_preview1" fn sock_send(sock: fd_t, si_data: *const cio |
| 83 | 83 | pub extern "wasi_snapshot_preview1" fn sock_shutdown(sock: fd_t, how: sdflags_t) errno_t; |
| 84 | 84 | |
| 85 | 85 | /// Get the errno from a syscall return value, or 0 for no error. |
| 86 | pub fn getErrno(r: errno_t) usize { | |
| 86 | pub fn getErrno(r: errno_t) errno_t { | |
| 87 | 87 | return r; |
| 88 | 88 | } |
lib/std/process.zig+4-4| ... | ... | @@ -93,7 +93,7 @@ pub fn getEnvMap(allocator: *Allocator) !BufMap { |
| 93 | 93 | var environ_buf_size: usize = undefined; |
| 94 | 94 | |
| 95 | 95 | const environ_sizes_get_ret = os.wasi.environ_sizes_get(&environ_count, &environ_buf_size); |
| 96 | if (environ_sizes_get_ret != os.wasi.ESUCCESS) { | |
| 96 | if (environ_sizes_get_ret != .SUCCESS) { | |
| 97 | 97 | return os.unexpectedErrno(environ_sizes_get_ret); |
| 98 | 98 | } |
| 99 | 99 | |
| ... | ... | @@ -103,7 +103,7 @@ pub fn getEnvMap(allocator: *Allocator) !BufMap { |
| 103 | 103 | defer allocator.free(environ_buf); |
| 104 | 104 | |
| 105 | 105 | const environ_get_ret = os.wasi.environ_get(environ.ptr, environ_buf.ptr); |
| 106 | if (environ_get_ret != os.wasi.ESUCCESS) { | |
| 106 | if (environ_get_ret != .SUCCESS) { | |
| 107 | 107 | return os.unexpectedErrno(environ_get_ret); |
| 108 | 108 | } |
| 109 | 109 | |
| ... | ... | @@ -255,7 +255,7 @@ pub const ArgIteratorWasi = struct { |
| 255 | 255 | var buf_size: usize = undefined; |
| 256 | 256 | |
| 257 | 257 | switch (w.args_sizes_get(&count, &buf_size)) { |
| 258 | w.ESUCCESS => {}, | |
| 258 | .SUCCESS => {}, | |
| 259 | 259 | else => |err| return os.unexpectedErrno(err), |
| 260 | 260 | } |
| 261 | 261 | |
| ... | ... | @@ -265,7 +265,7 @@ pub const ArgIteratorWasi = struct { |
| 265 | 265 | var argv_buf = try allocator.alloc(u8, buf_size); |
| 266 | 266 | |
| 267 | 267 | switch (w.args_get(argv.ptr, argv_buf.ptr)) { |
| 268 | w.ESUCCESS => {}, | |
| 268 | .SUCCESS => {}, | |
| 269 | 269 | else => |err| return os.unexpectedErrno(err), |
| 270 | 270 | } |
| 271 | 271 |
lib/std/special/compiler_rt/emutls.zig+3-3| ... | ... | @@ -201,7 +201,7 @@ const current_thread_storage = struct { |
| 201 | 201 | |
| 202 | 202 | /// Initialize pthread_key_t. |
| 203 | 203 | fn init() void { |
| 204 | if (std.c.pthread_key_create(&current_thread_storage.key, current_thread_storage.deinit) != 0) { | |
| 204 | if (std.c.pthread_key_create(&current_thread_storage.key, current_thread_storage.deinit) != .SUCCESS) { | |
| 205 | 205 | abort(); |
| 206 | 206 | } |
| 207 | 207 | } |
| ... | ... | @@ -248,14 +248,14 @@ const emutls_control = extern struct { |
| 248 | 248 | |
| 249 | 249 | /// Simple wrapper for global lock. |
| 250 | 250 | fn lock() void { |
| 251 | if (std.c.pthread_mutex_lock(&emutls_control.mutex) != 0) { | |
| 251 | if (std.c.pthread_mutex_lock(&emutls_control.mutex) != .SUCCESS) { | |
| 252 | 252 | abort(); |
| 253 | 253 | } |
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | /// Simple wrapper for global unlock. |
| 257 | 257 | fn unlock() void { |
| 258 | if (std.c.pthread_mutex_unlock(&emutls_control.mutex) != 0) { | |
| 258 | if (std.c.pthread_mutex_unlock(&emutls_control.mutex) != .SUCCESS) { | |
| 259 | 259 | abort(); |
| 260 | 260 | } |
| 261 | 261 | } |
lib/std/time.zig+1-1| ... | ... | @@ -92,7 +92,7 @@ pub fn nanoTimestamp() i128 { |
| 92 | 92 | if (builtin.os.tag == .wasi and !builtin.link_libc) { |
| 93 | 93 | var ns: os.wasi.timestamp_t = undefined; |
| 94 | 94 | const err = os.wasi.clock_time_get(os.wasi.CLOCK_REALTIME, 1, &ns); |
| 95 | assert(err == os.wasi.ESUCCESS); | |
| 95 | assert(err == .SUCCESS); | |
| 96 | 96 | return ns; |
| 97 | 97 | } |
| 98 | 98 | var ts: os.timespec = undefined; |
lib/std/x/os/socket_posix.zig+49-49| ... | ... | @@ -82,32 +82,32 @@ pub fn Mixin(comptime Socket: type) type { |
| 82 | 82 | while (true) { |
| 83 | 83 | const rc = os.system.sendmsg(self.fd, &msg, @intCast(c_int, flags)); |
| 84 | 84 | return switch (os.errno(rc)) { |
| 85 | 0 => return @intCast(usize, rc), | |
| 86 | os.EACCES => error.AccessDenied, | |
| 87 | os.EAGAIN => error.WouldBlock, | |
| 88 | os.EALREADY => error.FastOpenAlreadyInProgress, | |
| 89 | os.EBADF => unreachable, // always a race condition | |
| 90 | os.ECONNRESET => error.ConnectionResetByPeer, | |
| 91 | os.EDESTADDRREQ => unreachable, // The socket is not connection-mode, and no peer address is set. | |
| 92 | os.EFAULT => unreachable, // An invalid user space address was specified for an argument. | |
| 93 | os.EINTR => continue, | |
| 94 | os.EINVAL => unreachable, // Invalid argument passed. | |
| 95 | os.EISCONN => unreachable, // connection-mode socket was connected already but a recipient was specified | |
| 96 | os.EMSGSIZE => error.MessageTooBig, | |
| 97 | os.ENOBUFS => error.SystemResources, | |
| 98 | os.ENOMEM => error.SystemResources, | |
| 99 | os.ENOTSOCK => unreachable, // The file descriptor sockfd does not refer to a socket. | |
| 100 | os.EOPNOTSUPP => unreachable, // Some bit in the flags argument is inappropriate for the socket type. | |
| 101 | os.EPIPE => error.BrokenPipe, | |
| 102 | os.EAFNOSUPPORT => error.AddressFamilyNotSupported, | |
| 103 | os.ELOOP => error.SymLinkLoop, | |
| 104 | os.ENAMETOOLONG => error.NameTooLong, | |
| 105 | os.ENOENT => error.FileNotFound, | |
| 106 | os.ENOTDIR => error.NotDir, | |
| 107 | os.EHOSTUNREACH => error.NetworkUnreachable, | |
| 108 | os.ENETUNREACH => error.NetworkUnreachable, | |
| 109 | os.ENOTCONN => error.SocketNotConnected, | |
| 110 | os.ENETDOWN => error.NetworkSubsystemFailed, | |
| 85 | .SUCCESS => return @intCast(usize, rc), | |
| 86 | .ACCES => error.AccessDenied, | |
| 87 | .AGAIN => error.WouldBlock, | |
| 88 | .ALREADY => error.FastOpenAlreadyInProgress, | |
| 89 | .BADF => unreachable, // always a race condition | |
| 90 | .CONNRESET => error.ConnectionResetByPeer, | |
| 91 | .DESTADDRREQ => unreachable, // The socket is not connection-mode, and no peer address is set. | |
| 92 | .FAULT => unreachable, // An invalid user space address was specified for an argument. | |
| 93 | .INTR => continue, | |
| 94 | .INVAL => unreachable, // Invalid argument passed. | |
| 95 | .ISCONN => unreachable, // connection-mode socket was connected already but a recipient was specified | |
| 96 | .MSGSIZE => error.MessageTooBig, | |
| 97 | .NOBUFS => error.SystemResources, | |
| 98 | .NOMEM => error.SystemResources, | |
| 99 | .NOTSOCK => unreachable, // The file descriptor sockfd does not refer to a socket. | |
| 100 | .OPNOTSUPP => unreachable, // Some bit in the flags argument is inappropriate for the socket type. | |
| 101 | .PIPE => error.BrokenPipe, | |
| 102 | .AFNOSUPPORT => error.AddressFamilyNotSupported, | |
| 103 | .LOOP => error.SymLinkLoop, | |
| 104 | .NAMETOOLONG => error.NameTooLong, | |
| 105 | .NOENT => error.FileNotFound, | |
| 106 | .NOTDIR => error.NotDir, | |
| 107 | .HOSTUNREACH => error.NetworkUnreachable, | |
| 108 | .NETUNREACH => error.NetworkUnreachable, | |
| 109 | .NOTCONN => error.SocketNotConnected, | |
| 110 | .NETDOWN => error.NetworkSubsystemFailed, | |
| 111 | 111 | else => |err| os.unexpectedErrno(err), |
| 112 | 112 | }; |
| 113 | 113 | } |
| ... | ... | @@ -120,17 +120,17 @@ pub fn Mixin(comptime Socket: type) type { |
| 120 | 120 | while (true) { |
| 121 | 121 | const rc = os.system.recvmsg(self.fd, msg, @intCast(c_int, flags)); |
| 122 | 122 | return switch (os.errno(rc)) { |
| 123 | 0 => @intCast(usize, rc), | |
| 124 | os.EBADF => unreachable, // always a race condition | |
| 125 | os.EFAULT => unreachable, | |
| 126 | os.EINVAL => unreachable, | |
| 127 | os.ENOTCONN => unreachable, | |
| 128 | os.ENOTSOCK => unreachable, | |
| 129 | os.EINTR => continue, | |
| 130 | os.EAGAIN => error.WouldBlock, | |
| 131 | os.ENOMEM => error.SystemResources, | |
| 132 | os.ECONNREFUSED => error.ConnectionRefused, | |
| 133 | os.ECONNRESET => error.ConnectionResetByPeer, | |
| 123 | .SUCCESS => @intCast(usize, rc), | |
| 124 | .BADF => unreachable, // always a race condition | |
| 125 | .FAULT => unreachable, | |
| 126 | .INVAL => unreachable, | |
| 127 | .NOTCONN => unreachable, | |
| 128 | .NOTSOCK => unreachable, | |
| 129 | .INTR => continue, | |
| 130 | .AGAIN => error.WouldBlock, | |
| 131 | .NOMEM => error.SystemResources, | |
| 132 | .CONNREFUSED => error.ConnectionRefused, | |
| 133 | .CONNRESET => error.ConnectionResetByPeer, | |
| 134 | 134 | else => |err| os.unexpectedErrno(err), |
| 135 | 135 | }; |
| 136 | 136 | } |
| ... | ... | @@ -164,12 +164,12 @@ pub fn Mixin(comptime Socket: type) type { |
| 164 | 164 | |
| 165 | 165 | const rc = os.system.getsockopt(self.fd, os.SOL_SOCKET, os.SO_RCVBUF, mem.asBytes(&value), &value_len); |
| 166 | 166 | return switch (os.errno(rc)) { |
| 167 | 0 => value, | |
| 168 | os.EBADF => error.BadFileDescriptor, | |
| 169 | os.EFAULT => error.InvalidAddressSpace, | |
| 170 | os.EINVAL => error.InvalidSocketOption, | |
| 171 | os.ENOPROTOOPT => error.UnknownSocketOption, | |
| 172 | os.ENOTSOCK => error.NotASocket, | |
| 167 | .SUCCESS => value, | |
| 168 | .BADF => error.BadFileDescriptor, | |
| 169 | .FAULT => error.InvalidAddressSpace, | |
| 170 | .INVAL => error.InvalidSocketOption, | |
| 171 | .NOPROTOOPT => error.UnknownSocketOption, | |
| 172 | .NOTSOCK => error.NotASocket, | |
| 173 | 173 | else => |err| os.unexpectedErrno(err), |
| 174 | 174 | }; |
| 175 | 175 | } |
| ... | ... | @@ -181,12 +181,12 @@ pub fn Mixin(comptime Socket: type) type { |
| 181 | 181 | |
| 182 | 182 | const rc = os.system.getsockopt(self.fd, os.SOL_SOCKET, os.SO_SNDBUF, mem.asBytes(&value), &value_len); |
| 183 | 183 | return switch (os.errno(rc)) { |
| 184 | 0 => value, | |
| 185 | os.EBADF => error.BadFileDescriptor, | |
| 186 | os.EFAULT => error.InvalidAddressSpace, | |
| 187 | os.EINVAL => error.InvalidSocketOption, | |
| 188 | os.ENOPROTOOPT => error.UnknownSocketOption, | |
| 189 | os.ENOTSOCK => error.NotASocket, | |
| 184 | .SUCCESS => value, | |
| 185 | .BADF => error.BadFileDescriptor, | |
| 186 | .FAULT => error.InvalidAddressSpace, | |
| 187 | .INVAL => error.InvalidSocketOption, | |
| 188 | .NOPROTOOPT => error.UnknownSocketOption, | |
| 189 | .NOTSOCK => error.NotASocket, | |
| 190 | 190 | else => |err| os.unexpectedErrno(err), |
| 191 | 191 | }; |
| 192 | 192 | } |