authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-02-23 21:27:51-08:00
committergravatar for david@vortan.devDavid Rubin <david@vortan.dev> 2025-02-25 11:22:33-08:00
logfaf256e429914a816dd5ab1555671b7ee69ecc4e
tree0d18c16ef226ba40119455d0e9ed4a8ea2c82512
parente18c7f9cca42731792cb9700744380197812747e

std.mem.indexOfSentinel: don't ask the OS the page size

simply use page_size_min instead. better yet, this logic would avoid depending on page size entirely...

1 files changed, 3 insertions(+), 3 deletions(-)

lib/std/mem.zig+3-3
......@@ -1098,12 +1098,12 @@ pub fn indexOfSentinel(comptime T: type, comptime sentinel: T, p: [*:sentinel]co
10981098 // as we don't read into a new page. This should be the case for most architectures
10991099 // which use paged memory, however should be confirmed before adding a new arch below.
11001100 .aarch64, .x86, .x86_64 => if (std.simd.suggestVectorLength(T)) |block_len| {
1101 const page_size = std.heap.pageSize();
1101 const page_size = std.heap.page_size_min;
11021102 const block_size = @sizeOf(T) * block_len;
11031103 const Block = @Vector(block_len, T);
11041104 const mask: Block = @splat(sentinel);
11051105
1106 comptime assert(std.heap.page_size_max % @sizeOf(Block) == 0);
1106 comptime assert(std.heap.page_size_min % @sizeOf(Block) == 0);
11071107 assert(page_size % @sizeOf(Block) == 0);
11081108
11091109 // First block may be unaligned
......@@ -1153,7 +1153,7 @@ pub fn indexOfSentinel(comptime T: type, comptime sentinel: T, p: [*:sentinel]co
11531153test "indexOfSentinel vector paths" {
11541154 const Types = [_]type{ u8, u16, u32, u64 };
11551155 const allocator = std.testing.allocator;
1156 const page_size = std.heap.pageSize();
1156 const page_size = std.heap.page_size_min;
11571157
11581158 inline for (Types) |T| {
11591159 const block_len = std.simd.suggestVectorLength(T) orelse continue;