Skip to content

Commit

Permalink
Fix usage of deprecated std lib APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
squeek502 committed May 23, 2024
1 parent 00273a1 commit 64e0ecb
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/aro/Driver.zig
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ pub fn invokeLinker(d: *Driver, tc: *Toolchain, comptime fast_exit: bool) !void
var argv = std.ArrayList([]const u8).init(d.comp.gpa);
defer argv.deinit();

var linker_path_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
var linker_path_buf: [std.fs.max_path_bytes]u8 = undefined;
const linker_path = try tc.getLinkerPath(&linker_path_buf);
try argv.append(linker_path);

Expand All @@ -803,7 +803,7 @@ pub fn invokeLinker(d: *Driver, tc: *Toolchain, comptime fast_exit: bool) !void
return d.fatal("unable to dump linker args: {s}", .{errorDescription(er)});
};
}
var child = std.ChildProcess.init(argv.items, d.comp.gpa);
var child = std.process.Child.init(argv.items, d.comp.gpa);
// TODO handle better
child.stdin_behavior = .Inherit;
child.stdout_behavior = .Inherit;
Expand Down
4 changes: 2 additions & 2 deletions src/aro/Driver/Filesystem.zig
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ fn canExecuteFake(entries: []const Filesystem.Entry, path: []const u8) bool {

fn existsFake(entries: []const Filesystem.Entry, path: []const u8) bool {
@setCold(true);
var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
var buf: [std.fs.max_path_bytes]u8 = undefined;
var fib = std.heap.FixedBufferAllocator.init(&buf);
const resolved = std.fs.path.resolvePosix(fib.allocator(), &.{path}) catch return false;
for (entries) |entry| {
Expand Down Expand Up @@ -181,7 +181,7 @@ pub const Filesystem = union(enum) {
}

pub fn joinedExists(fs: Filesystem, parts: []const []const u8) bool {
var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
var buf: [std.fs.max_path_bytes]u8 = undefined;
var fib = std.heap.FixedBufferAllocator.init(&buf);
const joined = std.fs.path.join(fib.allocator(), parts) catch return false;
return fs.exists(joined);
Expand Down
4 changes: 2 additions & 2 deletions src/aro/Driver/GCCDetector.zig
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ fn collectLibDirsAndTriples(
}

pub fn discover(self: *GCCDetector, tc: *Toolchain) !void {
var path_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
var path_buf: [std.fs.max_path_bytes]u8 = undefined;
var fib = std.heap.FixedBufferAllocator.init(&path_buf);

const target = tc.getTarget();
Expand Down Expand Up @@ -589,7 +589,7 @@ fn scanLibDirForGCCTriple(
gcc_dir_exists: bool,
gcc_cross_dir_exists: bool,
) !void {
var path_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
var path_buf: [std.fs.max_path_bytes]u8 = undefined;
var fib = std.heap.FixedBufferAllocator.init(&path_buf);
for (0..2) |i| {
if (i == 0 and !gcc_dir_exists) continue;
Expand Down
6 changes: 3 additions & 3 deletions src/aro/Toolchain.zig
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ pub fn addFilePathLibArgs(tc: *const Toolchain, argv: *std.ArrayList([]const u8)
/// If not found there, just use `name`
/// Writes the result to `buf` and returns a slice of it
fn getProgramPath(tc: *const Toolchain, name: []const u8, buf: []u8) []const u8 {
var path_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
var path_buf: [std.fs.max_path_bytes]u8 = undefined;
var fib = std.heap.FixedBufferAllocator.init(&path_buf);

var tool_specific_buf: [64]u8 = undefined;
Expand Down Expand Up @@ -251,7 +251,7 @@ pub fn getSysroot(tc: *const Toolchain) []const u8 {
/// Search for `name` in a variety of places
/// TODO: cache results based on `name` so we're not repeatedly allocating the same strings?
pub fn getFilePath(tc: *const Toolchain, name: []const u8) ![]const u8 {
var path_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
var path_buf: [std.fs.max_path_bytes]u8 = undefined;
var fib = std.heap.FixedBufferAllocator.init(&path_buf);
const allocator = fib.allocator();

Expand Down Expand Up @@ -304,7 +304,7 @@ const PathKind = enum {
/// Join `components` into a path. If the path exists, dupe it into the toolchain arena and
/// add it to the specified path list.
pub fn addPathIfExists(tc: *Toolchain, components: []const []const u8, dest_kind: PathKind) !void {
var path_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
var path_buf: [std.fs.max_path_bytes]u8 = undefined;
var fib = std.heap.FixedBufferAllocator.init(&path_buf);

const candidate = try std.fs.path.join(fib.allocator(), components);
Expand Down
2 changes: 1 addition & 1 deletion src/aro/toolchains/Linux.zig
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ test Linux {
var argv = std.ArrayList([]const u8).init(driver.comp.gpa);
defer argv.deinit();

var linker_path_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
var linker_path_buf: [std.fs.max_path_bytes]u8 = undefined;
const linker_path = try toolchain.getLinkerPath(&linker_path_buf);
try argv.append(linker_path);

Expand Down
2 changes: 1 addition & 1 deletion test/runner.zig
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ pub fn main() !void {
// try obj.finish(out_file);
// }

var child = std.ChildProcess.init(&.{ args[2], "run", "-lc", obj_name }, gpa);
var child = std.process.Child.init(&.{ args[2], "run", "-lc", obj_name }, gpa);
child.stdout_behavior = .Pipe;

try child.spawn();
Expand Down

0 comments on commit 64e0ecb

Please sign in to comment.