| ... | ... | @@ -19,18 +19,22 @@ fn alloc(_: *anyopaque, n: usize, log2_align: u8, ra: usize) ?[*]u8 { |
| 19 | 19 | _ = log2_align; |
| 20 | 20 | assert(n > 0); |
| 21 | 21 | if (n > maxInt(usize) - (mem.page_size - 1)) return null; |
| 22 | | const aligned_len = mem.alignForward(usize, n, mem.page_size); |
| 23 | 22 | |
| 24 | 23 | if (native_os == .windows) { |
| 25 | 24 | const addr = windows.VirtualAlloc( |
| 26 | 25 | null, |
| 27 | | aligned_len, |
| 26 | |
| 27 | // VirtualAlloc will round the length to a multiple of page size. |
| 28 | // VirtualAlloc docs: If the lpAddress parameter is NULL, this value is rounded up to the next page boundary |
| 29 | n, |
| 30 | |
| 28 | 31 | windows.MEM_COMMIT | windows.MEM_RESERVE, |
| 29 | 32 | windows.PAGE_READWRITE, |
| 30 | 33 | ) catch return null; |
| 31 | 34 | return @ptrCast(addr); |
| 32 | 35 | } |
| 33 | 36 | |
| 37 | const aligned_len = mem.alignForward(usize, n, mem.page_size); |
| 34 | 38 | const hint = @atomicLoad(@TypeOf(std.heap.next_mmap_addr_hint), &std.heap.next_mmap_addr_hint, .unordered); |
| 35 | 39 | const slice = posix.mmap( |
| 36 | 40 | hint, |