diff options
Diffstat (limited to 'lib/std/os/plan9.zig')
| -rw-r--r-- | lib/std/os/plan9.zig | 97 |
1 files changed, 90 insertions, 7 deletions
diff --git a/lib/std/os/plan9.zig b/lib/std/os/plan9.zig index 354e05e570..a01e6f59eb 100644 --- a/lib/std/os/plan9.zig +++ b/lib/std/os/plan9.zig @@ -11,13 +11,96 @@ pub const syscall_bits = switch (builtin.cpu.arch) { .x86_64 => @import("plan9/x86_64.zig"), else => @compileError("more plan9 syscall implementations (needs more inline asm in stage2"), }; -pub const E = @import("plan9/errno.zig").E; -/// Get the errno from a syscall return value, or 0 for no error. -pub fn getErrno(r: usize) E { - const signed_r = @as(isize, @bitCast(r)); - const int = if (signed_r > -4096 and signed_r < 0) -signed_r else 0; - return @as(E, @enumFromInt(int)); -} +/// Ported from /sys/include/ape/errno.h +pub const E = enum(u16) { + SUCCESS = 0, + DOM = 1000, + RANGE = 1001, + PLAN9 = 1002, + + @"2BIG" = 1, + ACCES = 2, + AGAIN = 3, + // WOULDBLOCK = 3, // TODO errno.h has 2 names for 3 + BADF = 4, + BUSY = 5, + CHILD = 6, + DEADLK = 7, + EXIST = 8, + FAULT = 9, + FBIG = 10, + INTR = 11, + INVAL = 12, + IO = 13, + ISDIR = 14, + MFILE = 15, + MLINK = 16, + NAMETOOLONG = 17, + NFILE = 18, + NODEV = 19, + NOENT = 20, + NOEXEC = 21, + NOLCK = 22, + NOMEM = 23, + NOSPC = 24, + NOSYS = 25, + NOTDIR = 26, + NOTEMPTY = 27, + NOTTY = 28, + NXIO = 29, + PERM = 30, + PIPE = 31, + ROFS = 32, + SPIPE = 33, + SRCH = 34, + XDEV = 35, + + // bsd networking software + NOTSOCK = 36, + PROTONOSUPPORT = 37, + // PROTOTYPE = 37, // TODO errno.h has two names for 37 + CONNREFUSED = 38, + AFNOSUPPORT = 39, + NOBUFS = 40, + OPNOTSUPP = 41, + ADDRINUSE = 42, + DESTADDRREQ = 43, + MSGSIZE = 44, + NOPROTOOPT = 45, + SOCKTNOSUPPORT = 46, + PFNOSUPPORT = 47, + ADDRNOTAVAIL = 48, + NETDOWN = 49, + NETUNREACH = 50, + NETRESET = 51, + CONNABORTED = 52, + ISCONN = 53, + NOTCONN = 54, + SHUTDOWN = 55, + TOOMANYREFS = 56, + TIMEDOUT = 57, + HOSTDOWN = 58, + HOSTUNREACH = 59, + GREG = 60, + + // These added in 1003.1b-1993 + CANCELED = 61, + INPROGRESS = 62, + + // We just add these to be compatible with std.os, which uses them, + // They should never get used. + DQUOT, + CONNRESET, + OVERFLOW, + LOOP, + TXTBSY, + + pub fn init(r: usize) E { + const signed_r: isize = @bitCast(r); + const int = if (signed_r > -4096 and signed_r < 0) -signed_r else 0; + return @enumFromInt(int); + } +}; // The max bytes that can be in the errstr buff pub const ERRMAX = 128; var errstr_buf: [ERRMAX]u8 = undefined; |
