diff options
Diffstat (limited to 'lib/std/debug/MemoryAccessor.zig')
| -rw-r--r-- | lib/std/debug/MemoryAccessor.zig | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/std/debug/MemoryAccessor.zig b/lib/std/debug/MemoryAccessor.zig index 5f57ad5853..8c9c93b52e 100644 --- a/lib/std/debug/MemoryAccessor.zig +++ b/lib/std/debug/MemoryAccessor.zig @@ -7,7 +7,7 @@ const native_os = builtin.os.tag; const std = @import("../std.zig"); const posix = std.posix; const File = std.fs.File; -const page_size = std.mem.page_size; +const min_page_size = std.heap.min_page_size; const MemoryAccessor = @This(); @@ -93,9 +93,10 @@ pub fn isValidMemory(address: usize) bool { // We are unable to determine validity of memory for freestanding targets if (native_os == .freestanding or native_os == .other or native_os == .uefi) return true; - const aligned_address = address & ~@as(usize, @intCast((page_size - 1))); + const page_size = std.heap.pageSize(); + const aligned_address = address & ~(page_size - 1); if (aligned_address == 0) return false; - const aligned_memory = @as([*]align(page_size) u8, @ptrFromInt(aligned_address))[0..page_size]; + const aligned_memory = @as([*]align(min_page_size) u8, @ptrFromInt(aligned_address))[0..page_size]; if (native_os == .windows) { const windows = std.os.windows; @@ -104,7 +105,7 @@ pub fn isValidMemory(address: usize) bool { // The only error this function can throw is ERROR_INVALID_PARAMETER. // supply an address that invalid i'll be thrown. - const rc = windows.VirtualQuery(aligned_memory, &memory_info, aligned_memory.len) catch { + const rc = windows.VirtualQuery(@ptrCast(aligned_memory), &memory_info, aligned_memory.len) catch { return false; }; |
