|
| 1 | +const std = @import("std"); |
| 2 | +const Allocator = std.mem.Allocator; |
| 3 | +const os = @import("../os.zig"); |
| 4 | + |
| 5 | +pub const GemClose = extern struct { |
| 6 | + handle: u32 = 0, |
| 7 | + pad: u32 = 0, |
| 8 | + |
| 9 | + pub const req = os.IOCTL.IOW(0x9, GemClose); |
| 10 | + |
| 11 | + pub fn get(self: *GemClose, fd: std.os.fd_t) !void { |
| 12 | + return switch (std.os.errno(os.ioctl(fd, req, @intFromPtr(self)))) { |
| 13 | + .SUCCESS => {}, |
| 14 | + .BADF => error.NotOpenForWriting, |
| 15 | + .NOENT => error.NotFound, |
| 16 | + .FAULT => unreachable, |
| 17 | + .INVAL => unreachable, |
| 18 | + .NOTTY => error.NotATerminal, |
| 19 | + .OPNOTSUPP => error.NotSupported, |
| 20 | + else => |e| std.os.unexpectedErrno(e), |
| 21 | + }; |
| 22 | + } |
| 23 | +}; |
| 24 | + |
| 25 | +pub const GemFlink = extern struct { |
| 26 | + handle: u32 = 0, |
| 27 | + name: u32 = 0, |
| 28 | + |
| 29 | + pub const req = os.IOCTL.IOWR(0xA, GemFlink); |
| 30 | + |
| 31 | + pub fn get(self: *GemFlink, fd: std.os.fd_t) !void { |
| 32 | + return switch (std.os.errno(os.ioctl(fd, req, @intFromPtr(self)))) { |
| 33 | + .SUCCESS => {}, |
| 34 | + .BADF => error.NotOpenForWriting, |
| 35 | + .NOENT => error.NotFound, |
| 36 | + .FAULT => unreachable, |
| 37 | + .INVAL => unreachable, |
| 38 | + .NOTTY => error.NotATerminal, |
| 39 | + .OPNOTSUPP => error.NotSupported, |
| 40 | + else => |e| std.os.unexpectedErrno(e), |
| 41 | + }; |
| 42 | + } |
| 43 | +}; |
| 44 | + |
| 45 | +pub const GemOpen = extern struct { |
| 46 | + name: u32 = 0, |
| 47 | + handle: u32 = 0, |
| 48 | + size: u64 = 0, |
| 49 | + |
| 50 | + pub const req = os.IOCTL.IOWR(0xB, GemOpen); |
| 51 | + |
| 52 | + pub fn get(self: *GemOpen, fd: std.os.fd_t) !void { |
| 53 | + return switch (std.os.errno(os.ioctl(fd, req, @intFromPtr(self)))) { |
| 54 | + .SUCCESS => {}, |
| 55 | + .BADF => error.NotOpenForWriting, |
| 56 | + .NOENT => error.NotFound, |
| 57 | + .FAULT => unreachable, |
| 58 | + .INVAL => unreachable, |
| 59 | + .NOTTY => error.NotATerminal, |
| 60 | + .OPNOTSUPP => error.NotSupported, |
| 61 | + else => |e| std.os.unexpectedErrno(e), |
| 62 | + }; |
| 63 | + } |
| 64 | +}; |
0 commit comments