| author | |
| committer | |
| log | f2d374e8465042fa5cb6bf2be7b9b086948f3a94 |
| tree | 28b7a8997249dafa8b1171e789fbb0dfce2a9d56 |
| parent | fb63a2cfaecb981010e0b9d656fd372dbb331888 |
| parent | b2b0bf0506e708e6b8c143eb438a84592310b5a9 |
6 files changed, 19 insertions(+), 13 deletions(-)
lib/std/fs/file.zig+9-7| ... | ... | @@ -615,7 +615,7 @@ pub const File = struct { |
| 615 | 615 | } |
| 616 | 616 | } |
| 617 | 617 | |
| 618 | pub fn pwritev(self: File, iovecs: []os.iovec_const, offset: usize) PWriteError!usize { | |
| 618 | pub fn pwritev(self: File, iovecs: []os.iovec_const, offset: u64) PWriteError!usize { | |
| 619 | 619 | if (is_windows) { |
| 620 | 620 | // TODO improve this to use WriteFileScatter |
| 621 | 621 | if (iovecs.len == 0) return @as(usize, 0); |
| ... | ... | @@ -632,11 +632,11 @@ pub const File = struct { |
| 632 | 632 | |
| 633 | 633 | /// The `iovecs` parameter is mutable because this function needs to mutate the fields in |
| 634 | 634 | /// order to handle partial writes from the underlying OS layer. |
| 635 | pub fn pwritevAll(self: File, iovecs: []os.iovec_const, offset: usize) PWriteError!void { | |
| 635 | pub fn pwritevAll(self: File, iovecs: []os.iovec_const, offset: u64) PWriteError!void { | |
| 636 | 636 | if (iovecs.len == 0) return; |
| 637 | 637 | |
| 638 | 638 | var i: usize = 0; |
| 639 | var off: usize = 0; | |
| 639 | var off: u64 = 0; | |
| 640 | 640 | while (true) { |
| 641 | 641 | var amt = try self.pwritev(iovecs[i..], offset + off); |
| 642 | 642 | off += amt; |
| ... | ... | @@ -652,14 +652,16 @@ pub const File = struct { |
| 652 | 652 | |
| 653 | 653 | pub const CopyRangeError = os.CopyFileRangeError; |
| 654 | 654 | |
| 655 | pub fn copyRange(in: File, in_offset: u64, out: File, out_offset: u64, len: usize) CopyRangeError!usize { | |
| 656 | return os.copy_file_range(in.handle, in_offset, out.handle, out_offset, len, 0); | |
| 655 | pub fn copyRange(in: File, in_offset: u64, out: File, out_offset: u64, len: u64) CopyRangeError!u64 { | |
| 656 | const adjusted_len = math.cast(usize, len) catch math.maxInt(usize); | |
| 657 | const result = try os.copy_file_range(in.handle, in_offset, out.handle, out_offset, adjusted_len, 0); | |
| 658 | return result; | |
| 657 | 659 | } |
| 658 | 660 | |
| 659 | 661 | /// Returns the number of bytes copied. If the number read is smaller than `buffer.len`, it |
| 660 | 662 | /// means the in file reached the end. Reaching the end of a file is not an error condition. |
| 661 | pub fn copyRangeAll(in: File, in_offset: u64, out: File, out_offset: u64, len: usize) CopyRangeError!usize { | |
| 662 | var total_bytes_copied: usize = 0; | |
| 663 | pub fn copyRangeAll(in: File, in_offset: u64, out: File, out_offset: u64, len: u64) CopyRangeError!u64 { | |
| 664 | var total_bytes_copied: u64 = 0; | |
| 663 | 665 | var in_off = in_offset; |
| 664 | 666 | var out_off = out_offset; |
| 665 | 667 | while (total_bytes_copied < len) { |
src/codegen.zig+1-1| ... | ... | @@ -32,7 +32,7 @@ pub const BlockData = struct { |
| 32 | 32 | /// comptime assert that makes sure we guessed correctly about the size. This only |
| 33 | 33 | /// exists so that we can bitcast an arch-independent field to and from the real MCValue. |
| 34 | 34 | pub const AnyMCValue = extern struct { |
| 35 | a: u64, | |
| 35 | a: usize, | |
| 36 | 36 | b: u64, |
| 37 | 37 | }; |
| 38 | 38 |
src/link/Elf.zig+2-2| ... | ... | @@ -2911,7 +2911,7 @@ fn pwriteDbgLineNops( |
| 2911 | 2911 | prev_padding_size: usize, |
| 2912 | 2912 | buf: []const u8, |
| 2913 | 2913 | next_padding_size: usize, |
| 2914 | offset: usize, | |
| 2914 | offset: u64, | |
| 2915 | 2915 | ) !void { |
| 2916 | 2916 | const tracy = trace(@src()); |
| 2917 | 2917 | defer tracy.end(); |
| ... | ... | @@ -2990,7 +2990,7 @@ fn pwriteDbgInfoNops( |
| 2990 | 2990 | buf: []const u8, |
| 2991 | 2991 | next_padding_size: usize, |
| 2992 | 2992 | trailing_zero: bool, |
| 2993 | offset: usize, | |
| 2993 | offset: u64, | |
| 2994 | 2994 | ) !void { |
| 2995 | 2995 | const tracy = trace(@src()); |
| 2996 | 2996 | defer tracy.end(); |
src/link/MachO.zig+5-1| ... | ... | @@ -1264,10 +1264,14 @@ fn updateString(self: *MachO, old_str_off: u32, new_name: []const u8) !u32 { |
| 1264 | 1264 | return self.makeString(new_name); |
| 1265 | 1265 | } |
| 1266 | 1266 | |
| 1267 | /// TODO This should not heap allocate, instead it should utilize a fixed size, statically allocated | |
| 1268 | /// global const array. You could even use pwritev to write the same buffer multiple times with only | |
| 1269 | /// 1 syscall if you needed to, for example, write 8192 bytes using a buffer of only 4096 bytes. | |
| 1270 | /// This size parameter should probably be a usize not u64. | |
| 1267 | 1271 | fn addPadding(self: *MachO, size: u64, file_offset: u64) !void { |
| 1268 | 1272 | if (size == 0) return; |
| 1269 | 1273 | |
| 1270 | const buf = try self.base.allocator.alloc(u8, size); | |
| 1274 | const buf = try self.base.allocator.alloc(u8, @intCast(usize, size)); | |
| 1271 | 1275 | defer self.base.allocator.free(buf); |
| 1272 | 1276 | |
| 1273 | 1277 | mem.set(u8, buf[0..], 0); |
src/main.zig+1-1| ... | ... | @@ -2554,7 +2554,7 @@ fn fmtPathFile( |
| 2554 | 2554 | const source_code = source_file.readToEndAllocOptions( |
| 2555 | 2555 | fmt.gpa, |
| 2556 | 2556 | max_src_size, |
| 2557 | stat.size, | |
| 2557 | std.math.cast(usize, stat.size) catch return error.FileTooBig, | |
| 2558 | 2558 | @alignOf(u8), |
| 2559 | 2559 | null, |
| 2560 | 2560 | ) catch |err| switch (err) { |
src/value.zig+1-1| ... | ... | @@ -842,7 +842,7 @@ pub const Value = extern union { |
| 842 | 842 | .int_u64 => { |
| 843 | 843 | const x = self.cast(Payload.Int_u64).?.int; |
| 844 | 844 | if (x == 0) return 0; |
| 845 | return std.math.log2(x) + 1; | |
| 845 | return @intCast(usize, std.math.log2(x) + 1); | |
| 846 | 846 | }, |
| 847 | 847 | .int_i64 => { |
| 848 | 848 | @panic("TODO implement i64 intBitCountTwosComp"); |