authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-06-20 10:08:54+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-06-20 10:08:54+02:00
logeb1050b83aecc3b681901613eeb316030f08ad12
tree8a2b1ee68c14c45353b6647b0cba400f6b7d495a
parent22540e5402799d1c4ee12b5163744cf7431a4c2c

macho: fix 32bit compilation issues


1 files changed, 8 insertions(+), 4 deletions(-)

src/link/MachO/hasher.zig+8-4
...@@ -20,9 +20,13 @@ pub fn ParallelHasher(comptime Hasher: type) type {...@@ -20,9 +20,13 @@ pub fn ParallelHasher(comptime Hasher: type) type {
20 }) !void {20 }) !void {
21 var wg: WaitGroup = .{};21 var wg: WaitGroup = .{};
2222
23 const file_size = opts.max_file_size orelse try file.getEndPos();23 const file_size = blk: {
24 const file_size = opts.max_file_size orelse try file.getEndPos();
25 break :blk std.math.cast(usize, file_size) orelse return error.Overflow;
26 };
27 const chunk_size = std.math.cast(usize, opts.chunk_size) orelse return error.Overflow;
2428
25 const buffer = try self.allocator.alloc(u8, opts.chunk_size * out.len);29 const buffer = try self.allocator.alloc(u8, chunk_size * out.len);
26 defer self.allocator.free(buffer);30 defer self.allocator.free(buffer);
2731
28 const results = try self.allocator.alloc(fs.File.PReadError!usize, out.len);32 const results = try self.allocator.alloc(fs.File.PReadError!usize, out.len);
...@@ -33,8 +37,8 @@ pub fn ParallelHasher(comptime Hasher: type) type {...@@ -33,8 +37,8 @@ pub fn ParallelHasher(comptime Hasher: type) type {
33 defer wg.wait();37 defer wg.wait();
3438
35 for (out, results, 0..) |*out_buf, *result, i| {39 for (out, results, 0..) |*out_buf, *result, i| {
36 const fstart = i * opts.chunk_size;40 const fstart = i * chunk_size;
37 const fsize = if (fstart + opts.chunk_size > file_size) file_size - fstart else opts.chunk_size;41 const fsize = if (fstart + chunk_size > file_size) file_size - fstart else chunk_size;
38 wg.start();42 wg.start();
39 try self.thread_pool.spawn(worker, .{43 try self.thread_pool.spawn(worker, .{
40 file,44 file,