From 4f1a33ea2200fc0f1d2a2d0a72faddaced45fef9 Mon Sep 17 00:00:00 2001 From: Archbirdplus Date: Tue, 16 Jul 2024 15:00:19 -0700 Subject: [PATCH] page size: don't assert if pageSize() is 0 --- lib/std/heap.zig | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/std/heap.zig b/lib/std/heap.zig index 8b1f33b15c4e..fb4579e9c638 100644 --- a/lib/std/heap.zig +++ b/lib/std/heap.zig @@ -94,10 +94,12 @@ pub inline fn pageSize() usize { @compileError("pageSize() must NOT be used in comptime. Use page_size variants instead."); } if (page_size == page_size_cap) { - assert(queryPageSize() == page_size); + if (queryPageSize() != 0) + assert(queryPageSize() == page_size); return page_size; } const size = queryPageSize(); + std.debug.assert(size > 0); return size; } @@ -106,9 +108,10 @@ fn queryPageSize() usize { var size = runtimePageSize.load(.unordered); if (size > 0) return size; defer { - std.debug.assert(size > 0); - std.debug.assert(size >= page_size); - std.debug.assert(size <= page_size_cap); + if (size != 0) { + std.debug.assert(size >= page_size); + std.debug.assert(size <= page_size_cap); + } runtimePageSize.store(size, .unordered); } switch (builtin.os.tag) {