update zig to latest, fix todos

This commit is contained in:
Mitchell Hashimoto
2022-10-23 10:54:39 -07:00
parent 79f69885ca
commit bc3762e85b
2 changed files with 6 additions and 9 deletions

6
flake.lock generated
View File

@ -109,11 +109,11 @@
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1666181436,
"narHash": "sha256-BfVbxHew4bLVXYms5eUiKL7jbaI+Hp6TF2PH2Vb62cg=",
"lastModified": 1666526970,
"narHash": "sha256-qfhQNN36Bc1RNGtIC63Gc2UcE27Y9FQ/+uKuujimKms=",
"owner": "mitchellh",
"repo": "zig-overlay",
"rev": "cf94d6039dd8205e48013eaef619da6a52bdc34e",
"rev": "c6d01ab96647f8dc4b5f99bc2eb71eeec48d1330",
"type": "github"
},
"original": {

View File

@ -19,9 +19,6 @@ const c = switch (builtin.os.tag) {
}),
};
// https://github.com/ziglang/zig/issues/12944
const ioctl = if (builtin.os.tag == .macos) c.ioctl else std.c.ioctl;
/// Redeclare this winsize struct so we can just use a Zig struct. This
/// layout should be correct on all tested platforms.
const winsize = extern struct {
@ -67,7 +64,7 @@ pub fn deinit(self: *Pty) void {
/// Return the size of the pty.
pub fn getSize(self: Pty) !winsize {
var ws: winsize = undefined;
if (ioctl(self.master, c.TIOCGWINSZ, @ptrToInt(&ws)) < 0)
if (c.ioctl(self.master, c.TIOCGWINSZ, @ptrToInt(&ws)) < 0)
return error.IoctlFailed;
return ws;
@ -75,7 +72,7 @@ pub fn getSize(self: Pty) !winsize {
/// Set the size of the pty.
pub fn setSize(self: Pty, size: winsize) !void {
if (ioctl(self.master, c.TIOCSWINSZ, @ptrToInt(&size)) < 0)
if (c.ioctl(self.master, c.TIOCSWINSZ, @ptrToInt(&size)) < 0)
return error.IoctlFailed;
}
@ -86,7 +83,7 @@ pub fn childPreExec(self: Pty) !void {
if (setsid() < 0) return error.ProcessGroupFailed;
// Set controlling terminal
if (ioctl(self.slave, c.TIOCSCTTY, @as(c_ulong, 0)) < 0)
if (c.ioctl(self.slave, c.TIOCSCTTY, @as(c_ulong, 0)) < 0)
return error.SetControllingTerminalFailed;
// Can close master/slave pair now