From eb1050b83aecc3b681901613eeb316030f08ad12 Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Tue, 20 Jun 2023 10:08:54 +0200 Subject: [PATCH] macho: fix 32bit compilation issues --- src/link/MachO/hasher.zig | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/link/MachO/hasher.zig b/src/link/MachO/hasher.zig index 5cdba0b527..40c034c90c 100644 --- a/src/link/MachO/hasher.zig +++ b/src/link/MachO/hasher.zig @@ -20,9 +20,13 @@ pub fn ParallelHasher(comptime Hasher: type) type { }) !void { var wg: WaitGroup = .{}; - const file_size = opts.max_file_size orelse try file.getEndPos(); + const file_size = blk: { + const file_size = opts.max_file_size orelse try file.getEndPos(); + break :blk std.math.cast(usize, file_size) orelse return error.Overflow; + }; + const chunk_size = std.math.cast(usize, opts.chunk_size) orelse return error.Overflow; - const buffer = try self.allocator.alloc(u8, opts.chunk_size * out.len); + const buffer = try self.allocator.alloc(u8, chunk_size * out.len); defer self.allocator.free(buffer); const results = try self.allocator.alloc(fs.File.PReadError!usize, out.len); @@ -33,8 +37,8 @@ pub fn ParallelHasher(comptime Hasher: type) type { defer wg.wait(); for (out, results, 0..) |*out_buf, *result, i| { - const fstart = i * opts.chunk_size; - const fsize = if (fstart + opts.chunk_size > file_size) file_size - fstart else opts.chunk_size; + const fstart = i * chunk_size; + const fsize = if (fstart + chunk_size > file_size) file_size - fstart else chunk_size; wg.start(); try self.thread_pool.spawn(worker, .{ file,