From c81345c8aec56a108f6f98001666a1552d65ce85 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Tue, 3 Mar 2020 02:03:22 -0500 Subject: breaking: std.os read/write functions + sendfile * rework os.sendfile and add macosx support, and a fallback implementation for any OS. * fix sendto compile error * std.os write functions support partial writes. closes #3443. * std.os pread / pwrite functions can now return `error.Unseekable`. * std.fs.File read/write functions now have readAll/writeAll variants which loop to complete operations even when partial reads/writes happen. * Audit std.os read/write functions with respect to Linux returning EINVAL for lengths greater than 0x7fff0000. * std.os read/write shim functions do not unnecessarily loop. Since partial reads/writes are part of the API, the caller will be forced to loop anyway, and so that would just be code bloat. * Improve doc comments * Add a non-trivial test for std.os.sendfile * Fix std.os.pread on 32 bit Linux * Add missing SYS_sendfile bit on aarch64 --- lib/std/c/linux.zig | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'lib/std/c/linux.zig') diff --git a/lib/std/c/linux.zig b/lib/std/c/linux.zig index be32536d6f..7ac5ecd3fe 100644 --- a/lib/std/c/linux.zig +++ b/lib/std/c/linux.zig @@ -82,6 +82,13 @@ pub extern "c" fn sigaltstack(ss: ?*stack_t, old_ss: ?*stack_t) c_int; pub extern "c" fn memfd_create(name: [*:0]const u8, flags: c_uint) c_int; +pub extern "c" fn sendfile( + out_fd: fd_t, + in_fd: fd_t, + offset: ?*off_t, + count: usize, +) isize; + pub const pthread_attr_t = extern struct { __size: [56]u8, __align: c_long, -- cgit v1.2.3