Skip to content

Commit

Permalink
page size: don't assert if pageSize() is 0
Browse files Browse the repository at this point in the history
  • Loading branch information
archbirdplus committed Jul 16, 2024
1 parent be36772 commit 4f1a33e
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/std/heap.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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) {
Expand Down

0 comments on commit 4f1a33e

Please sign in to comment.