summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.zig20
1 files changed, 4 insertions, 16 deletions
diff --git a/main.zig b/main.zig
index 650aa11..6c85c6d 100644
--- a/main.zig
+++ b/main.zig
@@ -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);
- }
-}