diff options
-rw-r--r-- | main.zig | 20 |
1 files changed, 4 insertions, 16 deletions
@@ -43,7 +43,7 @@ pub fn main() !void { "HTTP/1.1 200 OK\r\nServer: ziggetty\r\nConnection: closed\r\nContent-Length: {}\r\n\r\n", .{stat.size}, ) catch unreachable; - try conn.file.write(hdr); + _ = try conn.file.write(hdr); // TODO: remove this cast const size = @intCast(usize, stat.size); @@ -66,16 +66,12 @@ const SendFileError = error{ WouldBlock, } || os.UnexpectedError; -fn sendfile(outfd: os.fd_t, infd: os.fd_t, offset: ?*u64, count: usize) SendFileError!usize { +fn sendfile(outfd: os.fd_t, infd: os.fd_t, offset: ?*i64, count: usize) SendFileError!usize { while (true) { var rc: usize = undefined; var err: usize = undefined; - if (builtin.os == .linux) { - rc = _sendfile(outfd, infd, offset, count); - err = os.errno(rc); - } else { - @compileError("sendfile unimplemented for this target"); - } + rc = os.linux.sendfile(outfd, infd, offset, count); + err = os.errno(rc); switch (err) { 0 => return @intCast(usize, rc), @@ -97,11 +93,3 @@ fn sendfile(outfd: os.fd_t, infd: os.fd_t, offset: ?*u64, count: usize) SendFile } } } - -fn _sendfile(outfd: i32, infd: i32, offset: ?*u64, count: usize) usize { - if (@hasDecl(os, "SYS_sendfile64")) { - return std.os.linux.syscall4(os.SYS_sendfile64, @bitCast(usize, @as(isize, outfd)), @bitCast(usize, @as(isize, infd)), @ptrToInt(offset), count); - } else { - return std.os.linux.syscall4(os.SYS_sendfile, @bitCast(usize, @as(isize, outfd)), @bitCast(usize, @as(isize, infd)), @ptrToInt(offset), count); - } -} |