From 2447b87d98ee4b0fe13938c9b2acf2bb06cab572 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sun, 23 Feb 2025 21:28:26 -0800 Subject: [PATCH] std.heap.page_size_min: relax freestanding restriction x86_64 and aarch64 have safe values for page_size_min --- lib/std/heap.zig | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/std/heap.zig b/lib/std/heap.zig index 6fbc3d8b75..0d35c98c1c 100644 --- a/lib/std/heap.zig +++ b/lib/std/heap.zig @@ -42,10 +42,8 @@ pub var next_mmap_addr_hint: ?[*]align(page_size_min) u8 = null; /// /// On many systems, the actual page size can only be determined at runtime /// with `pageSize`. -pub const page_size_min: usize = std.options.page_size_min orelse (page_size_min_default orelse if (builtin.os.tag == .freestanding or builtin.os.tag == .other) - @compileError("freestanding/other page_size_min must provided with std.options.page_size_min") -else - @compileError(@tagName(builtin.cpu.arch) ++ "-" ++ @tagName(builtin.os.tag) ++ " has unknown page_size_min; populate std.options.page_size_min")); +pub const page_size_min: usize = std.options.page_size_min orelse page_size_min_default orelse + @compileError(@tagName(builtin.cpu.arch) ++ "-" ++ @tagName(builtin.os.tag) ++ " has unknown page_size_min; populate std.options.page_size_min"); /// comptime-known maximum page size of the target. /// @@ -831,8 +829,10 @@ const page_size_min_default: ?usize = switch (builtin.os.tag) { .xtensa => 4 << 10, else => null, }, - .freestanding => switch (builtin.cpu.arch) { + .freestanding, .other => switch (builtin.cpu.arch) { .wasm32, .wasm64 => 64 << 10, + .x86, .x86_64 => 4 << 10, + .aarch64, .aarch64_be => 4 << 10, else => null, }, else => null,