| author | |
| committer | |
| log | bc512648dbb27d895e69857202b22bc34d27f122 |
| tree | a011c33695bd1258dbfb35e77f1ff9452e25a4b6 |
| parent | 6260d2772ffbf11b02e13cb93e49c58b1b3b73f2 |
3 files changed, 10 insertions(+), 6 deletions(-)
lib/std/fs/File.zig+1-1| ... | @@ -1916,7 +1916,7 @@ pub const Writer = struct { | ... | @@ -1916,7 +1916,7 @@ pub const Writer = struct { |
| 1916 | 1916 | ||
| 1917 | const copy_file_range = switch (native_os) { | 1917 | const copy_file_range = switch (native_os) { |
| 1918 | .freebsd => std.os.freebsd.copy_file_range, | 1918 | .freebsd => std.os.freebsd.copy_file_range, |
| 1919 | .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 {}, | 1919 | .linux => std.os.linux.wrapped.copy_file_range, |
| 1920 | else => {}, | 1920 | else => {}, |
| 1921 | }; | 1921 | }; |
| 1922 | if (@TypeOf(copy_file_range) != void) cfr: { | 1922 | if (@TypeOf(copy_file_range) != void) cfr: { |
lib/std/os/linux.zig+3-1| ... | @@ -9891,7 +9891,9 @@ pub const wrapped = struct { | ... | @@ -9891,7 +9891,9 @@ pub const wrapped = struct { |
| 9891 | }; | 9891 | }; |
| 9892 | 9892 | ||
| 9893 | 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 { | 9893 | 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 { |
| 9894 | const rc = system.copy_file_range(fd_in, off_in, fd_out, off_out, len, flags); | 9894 | const use_c = std.c.versionCheck(if (builtin.abi.isAndroid()) .{ .major = 34, .minor = 0, .patch = 0 } else .{ .major = 2, .minor = 27, .patch = 0 }); |
| 9895 | const sys = if (use_c) std.c else std.os.linux; | ||
| 9896 | const rc = sys.copy_file_range(fd_in, off_in, fd_out, off_out, len, flags); | ||
| 9895 | switch (errno(rc)) { | 9897 | switch (errno(rc)) { |
| 9896 | .SUCCESS => return @intCast(rc), | 9898 | .SUCCESS => return @intCast(rc), |
| 9897 | .BADF => return error.BadFileFlags, | 9899 | .BADF => return error.BadFileFlags, |
lib/std/posix.zig+6-4| ... | @@ -6515,14 +6515,16 @@ pub const CopyFileRangeError = error{ | ... | @@ -6515,14 +6515,16 @@ pub const CopyFileRangeError = error{ |
| 6515 | /// | 6515 | /// |
| 6516 | /// Maximum offsets on Linux and FreeBSD are `maxInt(i64)`. | 6516 | /// Maximum offsets on Linux and FreeBSD are `maxInt(i64)`. |
| 6517 | 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 { | 6517 | 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 { |
| 6518 | if (builtin.os.tag == .freebsd or | 6518 | if (builtin.os.tag == .freebsd or builtin.os.tag == .linux) { |
| 6519 | (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 }))) | 6519 | const use_c = native_os != .linux or |
| 6520 | { | 6520 | std.c.versionCheck(if (builtin.abi.isAndroid()) .{ .major = 34, .minor = 0, .patch = 0 } else .{ .major = 2, .minor = 27, .patch = 0 }); |
| 6521 | const sys = if (use_c) std.c else linux; | ||
| 6522 | |||
| 6521 | var off_in_copy: i64 = @bitCast(off_in); | 6523 | var off_in_copy: i64 = @bitCast(off_in); |
| 6522 | var off_out_copy: i64 = @bitCast(off_out); | 6524 | var off_out_copy: i64 = @bitCast(off_out); |
| 6523 | 6525 | ||
| 6524 | while (true) { | 6526 | while (true) { |
| 6525 | const rc = system.copy_file_range(fd_in, &off_in_copy, fd_out, &off_out_copy, len, flags); | 6527 | const rc = sys.copy_file_range(fd_in, &off_in_copy, fd_out, &off_out_copy, len, flags); |
| 6526 | if (native_os == .freebsd) { | 6528 | if (native_os == .freebsd) { |
| 6527 | switch (errno(rc)) { | 6529 | switch (errno(rc)) { |
| 6528 | .SUCCESS => return @intCast(rc), | 6530 | .SUCCESS => return @intCast(rc), |