| author | |
| committer | |
| log | bc567312bf58389ffed40f5fc3d0b3ee26271c3e |
| tree | d240b4455bf755bd2c9339f39dccbda7dd57152f |
| parent | 6069f908e9f1f8655af3faca3bd6de99de58af16 |
| signature |
3 files changed, 10 insertions(+), 6 deletions(-)
lib/std/fs/File.zig+1-1| ... | @@ -1967,7 +1967,7 @@ pub const Writer = struct { | ... | @@ -1967,7 +1967,7 @@ pub const Writer = struct { |
| 1967 | 1967 | ||
| 1968 | const copy_file_range = switch (native_os) { | 1968 | const copy_file_range = switch (native_os) { |
| 1969 | .freebsd => std.os.freebsd.copy_file_range, | 1969 | .freebsd => std.os.freebsd.copy_file_range, |
| 1970 | .linux => if (std.c.versionCheck(if (builtin.abi.isAndroid()) .{ .major = 34, .minor = 0, .patch = 0 } else .{ .major = 2, .minor = 27, .patch = 0 })) std.os.linux.wrapped.copy_file_range else {}, | 1970 | .linux => std.os.linux.wrapped.copy_file_range, |
| 1971 | else => {}, | 1971 | else => {}, |
| 1972 | }; | 1972 | }; |
| 1973 | if (@TypeOf(copy_file_range) != void) cfr: { | 1973 | if (@TypeOf(copy_file_range) != void) cfr: { |
lib/std/os/linux.zig+3-1| ... | @@ -9802,7 +9802,9 @@ pub const wrapped = struct { | ... | @@ -9802,7 +9802,9 @@ pub const wrapped = struct { |
| 9802 | }; | 9802 | }; |
| 9803 | 9803 | ||
| 9804 | pub fn copy_file_range(fd_in: fd_t, off_in: ?*i64, fd_out: fd_t, off_out: ?*i64, len: usize, flags: u32) CopyFileRangeError!usize { | 9804 | pub fn copy_file_range(fd_in: fd_t, off_in: ?*i64, fd_out: fd_t, off_out: ?*i64, len: usize, flags: u32) CopyFileRangeError!usize { |
| 9805 | const rc = system.copy_file_range(fd_in, off_in, fd_out, off_out, len, flags); | 9805 | const use_c = std.c.versionCheck(if (builtin.abi.isAndroid()) .{ .major = 34, .minor = 0, .patch = 0 } else .{ .major = 2, .minor = 27, .patch = 0 }); |
| 9806 | const sys = if (use_c) std.c else std.os.linux; | ||
| 9807 | const rc = sys.copy_file_range(fd_in, off_in, fd_out, off_out, len, flags); | ||
| 9806 | switch (errno(rc)) { | 9808 | switch (errno(rc)) { |
| 9807 | .SUCCESS => return @intCast(rc), | 9809 | .SUCCESS => return @intCast(rc), |
| 9808 | .BADF => return error.BadFileFlags, | 9810 | .BADF => return error.BadFileFlags, |
lib/std/posix.zig+6-4| ... | @@ -6387,14 +6387,16 @@ pub const CopyFileRangeError = error{ | ... | @@ -6387,14 +6387,16 @@ pub const CopyFileRangeError = error{ |
| 6387 | /// | 6387 | /// |
| 6388 | /// Maximum offsets on Linux and FreeBSD are `maxInt(i64)`. | 6388 | /// Maximum offsets on Linux and FreeBSD are `maxInt(i64)`. |
| 6389 | pub fn copy_file_range(fd_in: fd_t, off_in: u64, fd_out: fd_t, off_out: u64, len: usize, flags: u32) CopyFileRangeError!usize { | 6389 | pub fn copy_file_range(fd_in: fd_t, off_in: u64, fd_out: fd_t, off_out: u64, len: usize, flags: u32) CopyFileRangeError!usize { |
| 6390 | if (builtin.os.tag == .freebsd or | 6390 | if (builtin.os.tag == .freebsd or builtin.os.tag == .linux) { |
| 6391 | (comptime builtin.os.tag == .linux and std.c.versionCheck(if (builtin.abi.isAndroid()) .{ .major = 34, .minor = 0, .patch = 0 } else .{ .major = 2, .minor = 27, .patch = 0 }))) | 6391 | const use_c = native_os != .linux or |
| 6392 | { | 6392 | std.c.versionCheck(if (builtin.abi.isAndroid()) .{ .major = 34, .minor = 0, .patch = 0 } else .{ .major = 2, .minor = 27, .patch = 0 }); |
| 6393 | const sys = if (use_c) std.c else linux; | ||
| 6394 | |||
| 6393 | var off_in_copy: i64 = @bitCast(off_in); | 6395 | var off_in_copy: i64 = @bitCast(off_in); |
| 6394 | var off_out_copy: i64 = @bitCast(off_out); | 6396 | var off_out_copy: i64 = @bitCast(off_out); |
| 6395 | 6397 | ||
| 6396 | while (true) { | 6398 | while (true) { |
| 6397 | const rc = system.copy_file_range(fd_in, &off_in_copy, fd_out, &off_out_copy, len, flags); | 6399 | const rc = sys.copy_file_range(fd_in, &off_in_copy, fd_out, &off_out_copy, len, flags); |
| 6398 | if (native_os == .freebsd) { | 6400 | if (native_os == .freebsd) { |
| 6399 | switch (errno(rc)) { | 6401 | switch (errno(rc)) { |
| 6400 | .SUCCESS => return @intCast(rc), | 6402 | .SUCCESS => return @intCast(rc), |