aboutsummaryrefslogtreecommitdiff
path: root/src/linux_c.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/linux_c.zig')
-rw-r--r--src/linux_c.zig14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/linux_c.zig b/src/linux_c.zig
index 2ff96c966..b652a6490 100644
--- a/src/linux_c.zig
+++ b/src/linux_c.zig
@@ -141,6 +141,20 @@ pub const SystemErrno = enum(u8) {
pub const max = 134;
+ pub fn init(code: anytype) ?SystemErrno {
+ if (comptime std.meta.trait.isSignedInt(@TypeOf(code))) {
+ if (code < 0)
+ return init(-code);
+ }
+
+ if (code >= max) return null;
+ return @intToEnum(SystemErrno, code);
+ }
+
+ pub fn label(this: SystemErrno) ?[]const u8 {
+ return labels.get(this) orelse null;
+ }
+
const LabelMap = std.EnumMap(SystemErrno, []const u8);
pub const labels: LabelMap = brk: {
var map: LabelMap = LabelMap.initFull("");