Skip to content

Commit 860684c

Browse files
authored
Merge pull request #2516 from LemonBoy/32bfix
More 32bit fixes for stdlib
2 parents 0a3aec0 + 232bc1b commit 860684c

File tree

6 files changed

+25
-20
lines changed

6 files changed

+25
-20
lines changed

std/debug.zig

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -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

13461346
pub 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 {
13581358
const 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,15 +1789,15 @@ 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 => {
17961796
const arg = try leb.readILEB128Mem(i64, &ptr);
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,15 +1955,15 @@ 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 => {
19621962
const arg = try leb.readILEB128(i64, di.dwarf_in_stream);
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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

test/stage1/behavior/pointers.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ test "initialize const optional C pointer to null" {
132132
}
133133

134134
test "compare equality of optional and non-optional pointer" {
135-
const a = @intToPtr(*const usize, 0x123456789);
136-
const b = @intToPtr(?*usize, 0x123456789);
135+
const a = @intToPtr(*const usize, 0x12345678);
136+
const b = @intToPtr(?*usize, 0x12345678);
137137
expect(a == b);
138138
expect(b == a);
139139
}

test/stage1/behavior/struct.zig

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,11 @@ const Foo96Bits = packed struct {
257257
test "packed struct 24bits" {
258258
comptime {
259259
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+
}
261265
}
262266

263267
var value = Foo96Bits{

0 commit comments

Comments
 (0)