authorgravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2019-05-10 10:15:47+02:00
committergravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2019-05-18 11:08:04+02:00
log232bc1bdeecc62185984705118adb81e7cf759c2
tree283875215723c5820b2953870e610c539028fff1
parent695792719450facba99adf2b6711392657975268

Remove more 64bit-centric assumptions from stdlib


4 files changed, 18 insertions(+), 17 deletions(-)

std/debug.zig+13-13
......@@ -1181,8 +1181,8 @@ pub const DwarfInfo = struct {
11811181 func_list: ArrayList(Func),
11821182
11831183 pub const Section = struct {
1184 offset: usize,
1185 size: usize,
1184 offset: u64,
1185 size: u64,
11861186 };
11871187
11881188 pub fn allocator(self: DwarfInfo) *mem.Allocator {
......@@ -1344,8 +1344,8 @@ const FileEntry = struct {
13441344};
13451345
13461346pub const LineInfo = struct {
1347 line: usize,
1348 column: usize,
1347 line: u64,
1348 column: u64,
13491349 file_name: []const u8,
13501350 allocator: ?*mem.Allocator,
13511351
......@@ -1358,8 +1358,8 @@ pub const LineInfo = struct {
13581358const LineNumberProgram = struct {
13591359 address: usize,
13601360 file: usize,
1361 line: isize,
1362 column: usize,
1361 line: i64,
1362 column: u64,
13631363 is_stmt: bool,
13641364 basic_block: bool,
13651365 end_sequence: bool,
......@@ -1370,8 +1370,8 @@ const LineNumberProgram = struct {
13701370
13711371 prev_address: usize,
13721372 prev_file: usize,
1373 prev_line: isize,
1374 prev_column: usize,
1373 prev_line: i64,
1374 prev_column: u64,
13751375 prev_is_stmt: bool,
13761376 prev_basic_block: bool,
13771377 prev_end_sequence: bool,
......@@ -1414,7 +1414,7 @@ const LineNumberProgram = struct {
14141414 const file_name = try os.path.join(self.file_entries.allocator, [][]const u8{ dir_name, file_entry.file_name });
14151415 errdefer self.file_entries.allocator.free(file_name);
14161416 return LineInfo{
1417 .line = if (self.prev_line >= 0) @intCast(usize, self.prev_line) else 0,
1417 .line = if (self.prev_line >= 0) @intCast(u64, self.prev_line) else 0,
14181418 .column = self.prev_column,
14191419 .file_name = file_name,
14201420 .allocator = self.file_entries.allocator,
......@@ -1789,7 +1789,7 @@ fn getLineNumberInfoMacOs(di: *DebugInfo, symbol: MachoSymbol, target_address: u
17891789 prog.basic_block = false;
17901790 },
17911791 DW.LNS_advance_pc => {
1792 const arg = try leb.readULEB128Mem(u64, &ptr);
1792 const arg = try leb.readULEB128Mem(usize, &ptr);
17931793 prog.address += arg * minimum_instruction_length;
17941794 },
17951795 DW.LNS_advance_line => {
......@@ -1797,7 +1797,7 @@ fn getLineNumberInfoMacOs(di: *DebugInfo, symbol: MachoSymbol, target_address: u
17971797 prog.line += arg;
17981798 },
17991799 DW.LNS_set_file => {
1800 const arg = try leb.readULEB128Mem(u64, &ptr);
1800 const arg = try leb.readULEB128Mem(usize, &ptr);
18011801 prog.file = arg;
18021802 },
18031803 DW.LNS_set_column => {
......@@ -1955,7 +1955,7 @@ fn getLineNumberInfoDwarf(di: *DwarfInfo, compile_unit: CompileUnit, target_addr
19551955 prog.basic_block = false;
19561956 },
19571957 DW.LNS_advance_pc => {
1958 const arg = try leb.readULEB128(u64, di.dwarf_in_stream);
1958 const arg = try leb.readULEB128(usize, di.dwarf_in_stream);
19591959 prog.address += arg * minimum_instruction_length;
19601960 },
19611961 DW.LNS_advance_line => {
......@@ -1963,7 +1963,7 @@ fn getLineNumberInfoDwarf(di: *DwarfInfo, compile_unit: CompileUnit, target_addr
19631963 prog.line += arg;
19641964 },
19651965 DW.LNS_set_file => {
1966 const arg = try leb.readULEB128(u64, di.dwarf_in_stream);
1966 const arg = try leb.readULEB128(usize, di.dwarf_in_stream);
19671967 prog.file = arg;
19681968 },
19691969 DW.LNS_set_column => {
std/elf.zig+2-2
......@@ -363,7 +363,7 @@ pub const Elf = struct {
363363 entry_addr: u64,
364364 program_header_offset: u64,
365365 section_header_offset: u64,
366 string_section_index: u64,
366 string_section_index: usize,
367367 string_section: *SectionHeader,
368368 section_headers: []SectionHeader,
369369 allocator: *mem.Allocator,
......@@ -458,7 +458,7 @@ pub const Elf = struct {
458458 const ph_entry_count = try in.readInt(u16, elf.endian);
459459 const sh_entry_size = try in.readInt(u16, elf.endian);
460460 const sh_entry_count = try in.readInt(u16, elf.endian);
461 elf.string_section_index = u64(try in.readInt(u16, elf.endian));
461 elf.string_section_index = usize(try in.readInt(u16, elf.endian));
462462
463463 if (elf.string_section_index >= sh_entry_count) return error.InvalidFormat;
464464
std/os/file.zig+2-1
......@@ -238,7 +238,8 @@ pub const File = struct {
238238 pub fn seekForward(self: File, amount: i64) SeekError!void {
239239 switch (builtin.os) {
240240 Os.linux, Os.macosx, Os.ios, Os.freebsd, Os.netbsd => {
241 const result = posix.lseek(self.handle, amount, posix.SEEK_CUR);
241 const iamount = try math.cast(isize, amount);
242 const result = posix.lseek(self.handle, iamount, posix.SEEK_CUR);
242243 const err = posix.getErrno(result);
243244 if (err > 0) {
244245 return switch (err) {
std/pdb.zig+1-1
......@@ -632,7 +632,7 @@ const MsfStream = struct {
632632 }
633633
634634 fn read(self: *MsfStream, buffer: []u8) !usize {
635 var block_id = self.pos / self.block_size;
635 var block_id = @intCast(usize, self.pos / self.block_size);
636636 var block = self.blocks[block_id];
637637 var offset = self.pos % self.block_size;
638638