address latest zig changes

This commit is contained in:
Mitchell Hashimoto
2024-03-22 20:29:45 -07:00
parent 25a5e078fa
commit eb6536f4a7
2 changed files with 12 additions and 11 deletions

View File

@ -78,7 +78,7 @@ pub const LoadingImage = struct {
if (comptime builtin.os.tag != .windows) {
if (std.mem.indexOfScalar(u8, buf[0..size], 0) != null) {
// std.os.realpath *asserts* that the path does not have
// std.posix.realpath *asserts* that the path does not have
// internal nulls instead of erroring.
log.warn("failed to get absolute path: BadPathName", .{});
return error.InvalidData;
@ -86,7 +86,7 @@ pub const LoadingImage = struct {
}
var abs_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
const path = std.os.realpath(buf[0..size], &abs_buf) catch |err| {
const path = std.posix.realpath(buf[0..size], &abs_buf) catch |err| {
log.warn("failed to get absolute path: {}", .{err});
return error.InvalidData;
};
@ -151,7 +151,7 @@ pub const LoadingImage = struct {
if (!isPathInTempDir(path)) return error.TemporaryFileNotInTempDir;
}
defer if (medium == .temporary_file) {
std.os.unlink(path) catch |err| {
std.posix.unlink(path) catch |err| {
log.warn("failed to delete temporary file: {}", .{err});
};
};
@ -209,7 +209,7 @@ pub const LoadingImage = struct {
// The temporary dir is sometimes a symlink. On macOS for
// example /tmp is /private/var/...
var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
if (std.os.realpath(dir, &buf)) |real_dir| {
if (std.posix.realpath(dir, &buf)) |real_dir| {
if (std.mem.startsWith(u8, path, real_dir)) return true;
} else |_| {}
}

View File

@ -4,6 +4,7 @@ const Allocator = std.mem.Allocator;
const ArenaAllocator = std.heap.ArenaAllocator;
const assert = std.debug.assert;
const testing = std.testing;
const posix = std.posix;
const fastmem = @import("../fastmem.zig");
const color = @import("color.zig");
const sgr = @import("sgr.zig");
@ -113,15 +114,15 @@ pub const Page = struct {
// anonymous mmap is guaranteed on Linux and macOS to be zeroed,
// which is a critical property for us.
assert(l.total_size % std.mem.page_size == 0);
const backing = try std.os.mmap(
const backing = try posix.mmap(
null,
l.total_size,
std.os.PROT.READ | std.os.PROT.WRITE,
posix.PROT.READ | posix.PROT.WRITE,
.{ .TYPE = .PRIVATE, .ANONYMOUS = true },
-1,
0,
);
errdefer std.os.munmap(backing);
errdefer posix.munmap(backing);
const buf = OffsetBuf.init(backing);
return initBuf(buf, l);
@ -170,7 +171,7 @@ pub const Page = struct {
/// this if you allocated the backing memory yourself (i.e. you used
/// initBuf).
pub fn deinit(self: *Page) void {
std.os.munmap(self.memory);
posix.munmap(self.memory);
self.* = undefined;
}
@ -310,15 +311,15 @@ pub const Page = struct {
/// using the page allocator. If you want to manage memory manually,
/// use cloneBuf.
pub fn clone(self: *const Page) !Page {
const backing = try std.os.mmap(
const backing = try posix.mmap(
null,
self.memory.len,
std.os.PROT.READ | std.os.PROT.WRITE,
posix.PROT.READ | posix.PROT.WRITE,
.{ .TYPE = .PRIVATE, .ANONYMOUS = true },
-1,
0,
);
errdefer std.os.munmap(backing);
errdefer posix.munmap(backing);
return self.cloneBuf(backing);
}