authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-05-30 19:42:55 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-05-30 19:42:55 -07:00
logaaea5467f1a8b4c2ce7129ee7bc6bf2e11544167
treed282cb42eb357b8a8dc1a3e365e2f99009e6ee65
parentf0b155d3627f8c19868be1b2f15d71cda908b575
signaturebadge-check Signed by SSH key SHA256:4hHJbtBRU58AYXwjL7fkz2fnQHdiye8x1QpTCQ0sHNw

add copy_file_range


2 files changed, 9 insertions(+), 0 deletions(-)

mod.zig+7
......@@ -2811,6 +2811,7 @@ pub const libc = struct {
28112811 pub extern fn sched_getaffinity(pid: pid_t, cpusetsize: usize, mask: *cpu_set_t) c_int;
28122812 pub extern fn getrandom(buf: [*]u8, size: usize, flags: c_uint) isize;
28132813 pub extern fn flock(fd: c_int, op: c_int) c_int;
2814 pub extern fn copy_file_range(fd_int: c_int, off_in: ?*off_t, fd_out: c_int, off_out: ?*off_t, size: usize, flags: c_uint) isize;
28142815};
28152816
28162817comptime {
......@@ -3727,3 +3728,9 @@ pub fn fchmod(fd: c_int, mode: mode_t) !void {
37273728 if (rc == -1) return errno.fromInt(errno.fromLibC());
37283729 std.debug.assert(rc == 0);
37293730}
3731pub fn copy_file_range(fd_int: c_int, off_in: ?*off_t, fd_out: c_int, off_out: ?*off_t, size: usize, flags: c_uint) errno.Error!usize {
3732 const rc = libc.copy_file_range(fd_int, off_in, fd_out, off_out, size, flags);
3733 if (rc == -1) return errno.fromInt(errno.fromLibC());
3734 std.debug.assert(rc >= 0);
3735 return @intCast(rc);
3736}
test.zig+2
......@@ -81,4 +81,6 @@ test {
8181 _ = &linux.unlinkat;
8282 _ = &linux.lseek;
8383 _ = &linux.getcwd;
84 _ = &linux.fchmod;
85 _ = &linux.copy_file_range;
8486}