mirror of
https://github.com/ziglang/zig.git
synced 2025-02-18 02:20:17 +00:00
heap: create a work-around page-allocator
the risc-v backend doesn't have `@cmpxchg*` implemented and so it can't use the hint that the current page-allocator uses. this work-around branch can be removed when I implement the atomic built-in.
This commit is contained in:
parent
d3f75522d7
commit
ba58b7b881
@ -34,6 +34,20 @@ fn alloc(_: *anyopaque, n: usize, log2_align: u8, ra: usize) ?[*]u8 {
|
||||
return @ptrCast(addr);
|
||||
}
|
||||
|
||||
if (builtin.zig_backend == .stage2_riscv64) {
|
||||
const aligned_len = mem.alignForward(usize, n, mem.page_size);
|
||||
const slice = posix.mmap(
|
||||
null,
|
||||
aligned_len,
|
||||
posix.PROT.READ | posix.PROT.WRITE,
|
||||
.{ .TYPE = .PRIVATE, .ANONYMOUS = true },
|
||||
-1,
|
||||
0,
|
||||
) catch return null;
|
||||
assert(mem.isAligned(@intFromPtr(slice.ptr), mem.page_size));
|
||||
return slice.ptr;
|
||||
}
|
||||
|
||||
const aligned_len = mem.alignForward(usize, n, mem.page_size);
|
||||
const hint = @atomicLoad(@TypeOf(std.heap.next_mmap_addr_hint), &std.heap.next_mmap_addr_hint, .unordered);
|
||||
const slice = posix.mmap(
|
||||
|
Loading…
Reference in New Issue
Block a user