aboutsummaryrefslogtreecommitdiff
path: root/lib/std
diff options
context:
space:
mode:
authorAlex Rønne Petersen <alex@alexrp.com>2025-08-04 20:48:09 +0200
committerAlex Rønne Petersen <alex@alexrp.com>2025-08-30 06:36:41 +0200
commitf6879c35af446c3ca3ef61f4b5b7d03d0e064769 (patch)
tree9347c9109155e6707dbaf1081cd38b304cc40363 /lib/std
parent59ee4e8e5484a2f976485fca5b085a7ba0358074 (diff)
downloadzig-f6879c35af446c3ca3ef61f4b5b7d03d0e064769.tar.gz
zig-f6879c35af446c3ca3ef61f4b5b7d03d0e064769.zip
std.posix.test: fix mmap() test to use actual page size instead of 4096
Diffstat (limited to 'lib/std')
-rw-r--r--lib/std/posix/test.zig12
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/std/posix/test.zig b/lib/std/posix/test.zig
index 6c18999d4b..8d1c7ae195 100644
--- a/lib/std/posix/test.zig
+++ b/lib/std/posix/test.zig
@@ -675,8 +675,8 @@ test "mmap" {
}
const test_out_file = "os_tmp_test";
- // Must be a multiple of 4096 so that the test works with mmap2
- const alloc_size = 8 * 4096;
+ // Must be a multiple of the page size so that the test works with mmap2
+ const alloc_size = 8 * std.heap.pageSize();
// Create a file used for testing mmap() calls with a file descriptor
{
@@ -685,9 +685,9 @@ test "mmap" {
var stream = file.writer(&.{});
- var i: u32 = 0;
+ var i: usize = 0;
while (i < alloc_size / @sizeOf(u32)) : (i += 1) {
- try stream.interface.writeInt(u32, i, .little);
+ try stream.interface.writeInt(u32, @intCast(i), .little);
}
}
@@ -709,7 +709,7 @@ test "mmap" {
var mem_stream = io.fixedBufferStream(data);
const stream = mem_stream.reader();
- var i: u32 = 0;
+ var i: usize = 0;
while (i < alloc_size / @sizeOf(u32)) : (i += 1) {
try testing.expectEqual(i, try stream.readInt(u32, .little));
}
@@ -733,7 +733,7 @@ test "mmap" {
var mem_stream = io.fixedBufferStream(data);
const stream = mem_stream.reader();
- var i: u32 = alloc_size / 2 / @sizeOf(u32);
+ var i: usize = alloc_size / 2 / @sizeOf(u32);
while (i < alloc_size / @sizeOf(u32)) : (i += 1) {
try testing.expectEqual(i, try stream.readInt(u32, .little));
}