Skip to content

Commit

Permalink
Unbreak list_symbols.zig for modern Zig.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexrp authored and andrewrk committed Aug 30, 2024
1 parent d57bb26 commit 0c1764d
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions list_symbols.zig
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const std = @import("std");
const Version = std.builtin.Version;
const Version = std.SemanticVersion;
const mem = std.mem;
const log = std.log;
const fs = std.fs;
Expand Down Expand Up @@ -72,7 +72,7 @@ pub fn main() !void {

{
try w.writeAll("Functions:\n");
const fns_len = try r.readIntLittle(u16);
const fns_len = try r.readInt(u16, .little);
var i: u16 = 0;
var opt_symbol_name: ?[]const u8 = null;
while (i < fns_len) : (i += 1) {
Expand All @@ -82,7 +82,7 @@ pub fn main() !void {
break :n name;
};
try w.print(" {s}:\n", .{symbol_name});
const targets = try r.readIntLittle(u32);
const targets = try r.readInt(u32, .little);
const lib_index = try r.readByte();
const is_terminal = (targets & (1 << 31)) != 0;
if (is_terminal) opt_symbol_name = null;
Expand All @@ -92,7 +92,7 @@ pub fn main() !void {
while (true) {
const byte = try r.readByte();
const last = (byte & 0b1000_0000) != 0;
ver_buf[ver_buf_index] = @truncate(u7, byte);
ver_buf[ver_buf_index] = @as(u7, @truncate(byte));
ver_buf_index += 1;
if (last) break;
}
Expand All @@ -111,8 +111,8 @@ pub fn main() !void {
try w.writeAll("\n");

try w.writeAll(" targets:");
for (all_targets) |target, target_i| {
if ((targets & (@as(u32, 1) << @intCast(u5, target_i))) != 0) {
for (all_targets, 0..) |target, target_i| {
if ((targets & (@as(u32, 1) << @as(u5, @intCast(target_i)))) != 0) {
try w.print(" {s}", .{target});
}
}
Expand All @@ -122,7 +122,7 @@ pub fn main() !void {

{
try w.writeAll("Objects:\n");
const objects_len = try r.readIntLittle(u16);
const objects_len = try r.readInt(u16, .little);
var i: u16 = 0;
var opt_symbol_name: ?[]const u8 = null;
while (i < objects_len) : (i += 1) {
Expand All @@ -132,8 +132,8 @@ pub fn main() !void {
break :n name;
};
try w.print(" {s}:\n", .{symbol_name});
const targets = try r.readIntLittle(u32);
const size = try r.readIntLittle(u16);
const targets = try r.readInt(u32, .little);
const size = try r.readInt(u16, .little);
const lib_index = try r.readByte();
const is_terminal = (targets & (1 << 31)) != 0;
if (is_terminal) opt_symbol_name = null;
Expand All @@ -143,7 +143,7 @@ pub fn main() !void {
while (true) {
const byte = try r.readByte();
const last = (byte & 0b1000_0000) != 0;
ver_buf[ver_buf_index] = @truncate(u7, byte);
ver_buf[ver_buf_index] = @as(u7, @truncate(byte));
ver_buf_index += 1;
if (last) break;
}
Expand All @@ -163,8 +163,8 @@ pub fn main() !void {
try w.writeAll("\n");

try w.writeAll(" targets:");
for (all_targets) |target, target_i| {
if ((targets & (@as(u32, 1) << @intCast(u5, target_i))) != 0) {
for (all_targets, 0..) |target, target_i| {
if ((targets & (@as(u32, 1) << @as(u5, @intCast(target_i)))) != 0) {
try w.print(" {s}", .{target});
}
}
Expand Down

0 comments on commit 0c1764d

Please sign in to comment.