authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-05-19 00:31:16-04:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2019-05-19 00:31:16-04:00
log860684cc2f867b568137319930981904968c9577
treece7c5c56ba326cac807891279b9553b2e8263b56
parent0a3aec020a6c24e82e8b0accfd8d1a78286f4eda
parent232bc1bdeecc62185984705118adb81e7cf759c2
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #2516 from LemonBoy/32bfix

More 32bit fixes for stdlib

6 files changed, 25 insertions(+), 20 deletions(-)

std/debug.zig+13-13
...@@ -1181,8 +1181,8 @@ pub const DwarfInfo = struct {...@@ -1181,8 +1181,8 @@ pub const DwarfInfo = struct {
1181 func_list: ArrayList(Func),1181 func_list: ArrayList(Func),
11821182
1183 pub const Section = struct {1183 pub const Section = struct {
1184 offset: usize,1184 offset: u64,
1185 size: usize,1185 size: u64,
1186 };1186 };
11871187
1188 pub fn allocator(self: DwarfInfo) *mem.Allocator {1188 pub fn allocator(self: DwarfInfo) *mem.Allocator {
...@@ -1344,8 +1344,8 @@ const FileEntry = struct {...@@ -1344,8 +1344,8 @@ const FileEntry = struct {
1344};1344};
13451345
1346pub const LineInfo = struct {1346pub const LineInfo = struct {
1347 line: usize,1347 line: u64,
1348 column: usize,1348 column: u64,
1349 file_name: []const u8,1349 file_name: []const u8,
1350 allocator: ?*mem.Allocator,1350 allocator: ?*mem.Allocator,
13511351
...@@ -1358,8 +1358,8 @@ pub const LineInfo = struct {...@@ -1358,8 +1358,8 @@ pub const LineInfo = struct {
1358const LineNumberProgram = struct {1358const LineNumberProgram = struct {
1359 address: usize,1359 address: usize,
1360 file: usize,1360 file: usize,
1361 line: isize,1361 line: i64,
1362 column: usize,1362 column: u64,
1363 is_stmt: bool,1363 is_stmt: bool,
1364 basic_block: bool,1364 basic_block: bool,
1365 end_sequence: bool,1365 end_sequence: bool,
...@@ -1370,8 +1370,8 @@ const LineNumberProgram = struct {...@@ -1370,8 +1370,8 @@ const LineNumberProgram = struct {
13701370
1371 prev_address: usize,1371 prev_address: usize,
1372 prev_file: usize,1372 prev_file: usize,
1373 prev_line: isize,1373 prev_line: i64,
1374 prev_column: usize,1374 prev_column: u64,
1375 prev_is_stmt: bool,1375 prev_is_stmt: bool,
1376 prev_basic_block: bool,1376 prev_basic_block: bool,
1377 prev_end_sequence: bool,1377 prev_end_sequence: bool,
...@@ -1414,7 +1414,7 @@ const LineNumberProgram = struct {...@@ -1414,7 +1414,7 @@ const LineNumberProgram = struct {
1414 const file_name = try os.path.join(self.file_entries.allocator, [][]const u8{ dir_name, file_entry.file_name });1414 const file_name = try os.path.join(self.file_entries.allocator, [][]const u8{ dir_name, file_entry.file_name });
1415 errdefer self.file_entries.allocator.free(file_name);1415 errdefer self.file_entries.allocator.free(file_name);
1416 return LineInfo{1416 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,
1418 .column = self.prev_column,1418 .column = self.prev_column,
1419 .file_name = file_name,1419 .file_name = file_name,
1420 .allocator = self.file_entries.allocator,1420 .allocator = self.file_entries.allocator,
...@@ -1789,7 +1789,7 @@ fn getLineNumberInfoMacOs(di: *DebugInfo, symbol: MachoSymbol, target_address: u...@@ -1789,7 +1789,7 @@ fn getLineNumberInfoMacOs(di: *DebugInfo, symbol: MachoSymbol, target_address: u
1789 prog.basic_block = false;1789 prog.basic_block = false;
1790 },1790 },
1791 DW.LNS_advance_pc => {1791 DW.LNS_advance_pc => {
1792 const arg = try leb.readULEB128Mem(u64, &ptr);1792 const arg = try leb.readULEB128Mem(usize, &ptr);
1793 prog.address += arg * minimum_instruction_length;1793 prog.address += arg * minimum_instruction_length;
1794 },1794 },
1795 DW.LNS_advance_line => {1795 DW.LNS_advance_line => {
...@@ -1797,7 +1797,7 @@ fn getLineNumberInfoMacOs(di: *DebugInfo, symbol: MachoSymbol, target_address: u...@@ -1797,7 +1797,7 @@ fn getLineNumberInfoMacOs(di: *DebugInfo, symbol: MachoSymbol, target_address: u
1797 prog.line += arg;1797 prog.line += arg;
1798 },1798 },
1799 DW.LNS_set_file => {1799 DW.LNS_set_file => {
1800 const arg = try leb.readULEB128Mem(u64, &ptr);1800 const arg = try leb.readULEB128Mem(usize, &ptr);
1801 prog.file = arg;1801 prog.file = arg;
1802 },1802 },
1803 DW.LNS_set_column => {1803 DW.LNS_set_column => {
...@@ -1955,7 +1955,7 @@ fn getLineNumberInfoDwarf(di: *DwarfInfo, compile_unit: CompileUnit, target_addr...@@ -1955,7 +1955,7 @@ fn getLineNumberInfoDwarf(di: *DwarfInfo, compile_unit: CompileUnit, target_addr
1955 prog.basic_block = false;1955 prog.basic_block = false;
1956 },1956 },
1957 DW.LNS_advance_pc => {1957 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);
1959 prog.address += arg * minimum_instruction_length;1959 prog.address += arg * minimum_instruction_length;
1960 },1960 },
1961 DW.LNS_advance_line => {1961 DW.LNS_advance_line => {
...@@ -1963,7 +1963,7 @@ fn getLineNumberInfoDwarf(di: *DwarfInfo, compile_unit: CompileUnit, target_addr...@@ -1963,7 +1963,7 @@ fn getLineNumberInfoDwarf(di: *DwarfInfo, compile_unit: CompileUnit, target_addr
1963 prog.line += arg;1963 prog.line += arg;
1964 },1964 },
1965 DW.LNS_set_file => {1965 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);
1967 prog.file = arg;1967 prog.file = arg;
1968 },1968 },
1969 DW.LNS_set_column => {1969 DW.LNS_set_column => {
std/elf.zig+2-2
...@@ -363,7 +363,7 @@ pub const Elf = struct {...@@ -363,7 +363,7 @@ pub const Elf = struct {
363 entry_addr: u64,363 entry_addr: u64,
364 program_header_offset: u64,364 program_header_offset: u64,
365 section_header_offset: u64,365 section_header_offset: u64,
366 string_section_index: u64,366 string_section_index: usize,
367 string_section: *SectionHeader,367 string_section: *SectionHeader,
368 section_headers: []SectionHeader,368 section_headers: []SectionHeader,
369 allocator: *mem.Allocator,369 allocator: *mem.Allocator,
...@@ -458,7 +458,7 @@ pub const Elf = struct {...@@ -458,7 +458,7 @@ pub const Elf = struct {
458 const ph_entry_count = try in.readInt(u16, elf.endian);458 const ph_entry_count = try in.readInt(u16, elf.endian);
459 const sh_entry_size = try in.readInt(u16, elf.endian);459 const sh_entry_size = try in.readInt(u16, elf.endian);
460 const sh_entry_count = try in.readInt(u16, elf.endian);460 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
463 if (elf.string_section_index >= sh_entry_count) return error.InvalidFormat;463 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 {...@@ -238,7 +238,8 @@ pub const File = struct {
238 pub fn seekForward(self: File, amount: i64) SeekError!void {238 pub fn seekForward(self: File, amount: i64) SeekError!void {
239 switch (builtin.os) {239 switch (builtin.os) {
240 Os.linux, Os.macosx, Os.ios, Os.freebsd, Os.netbsd => {240 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);
242 const err = posix.getErrno(result);243 const err = posix.getErrno(result);
243 if (err > 0) {244 if (err > 0) {
244 return switch (err) {245 return switch (err) {
std/pdb.zig+1-1
...@@ -632,7 +632,7 @@ const MsfStream = struct {...@@ -632,7 +632,7 @@ const MsfStream = struct {
632 }632 }
633633
634 fn read(self: *MsfStream, buffer: []u8) !usize {634 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);
636 var block = self.blocks[block_id];636 var block = self.blocks[block_id];
637 var offset = self.pos % self.block_size;637 var offset = self.pos % self.block_size;
638638
test/stage1/behavior/pointers.zig+2-2
...@@ -132,8 +132,8 @@ test "initialize const optional C pointer to null" {...@@ -132,8 +132,8 @@ test "initialize const optional C pointer to null" {
132}132}
133133
134test "compare equality of optional and non-optional pointer" {134test "compare equality of optional and non-optional pointer" {
135 const a = @intToPtr(*const usize, 0x123456789);135 const a = @intToPtr(*const usize, 0x12345678);
136 const b = @intToPtr(?*usize, 0x123456789);136 const b = @intToPtr(?*usize, 0x12345678);
137 expect(a == b);137 expect(a == b);
138 expect(b == a);138 expect(b == a);
139}139}
test/stage1/behavior/struct.zig+5-1
...@@ -257,7 +257,11 @@ const Foo96Bits = packed struct {...@@ -257,7 +257,11 @@ const Foo96Bits = packed struct {
257test "packed struct 24bits" {257test "packed struct 24bits" {
258 comptime {258 comptime {
259 expect(@sizeOf(Foo24Bits) == 4);259 expect(@sizeOf(Foo24Bits) == 4);
260 expect(@sizeOf(Foo96Bits) == 16);260 if (@sizeOf(usize) == 4) {
261 expect(@sizeOf(Foo96Bits) == 12);
262 } else {
263 expect(@sizeOf(Foo96Bits) == 16);
264 }
261 }265 }
262266
263 var value = Foo96Bits{267 var value = Foo96Bits{