libc: malloc: store the global heap in a fixed region of virtual memory

This commit is contained in:
2026-05-31 17:22:47 +01:00
parent b773439aa1
commit 1b7c3b1b0d
2 changed files with 8 additions and 2 deletions
+1 -1
View File
@@ -30,5 +30,5 @@ sysroot_add_library(
HEADER_DIR /usr/include
LIB_DIR /usr/lib)
target_compile_definitions(libc-malloc PRIVATE ENABLE_GLOBAL_HEAP=1)
target_compile_definitions(libc-malloc PRIVATE LIBC_STATIC=1 ENABLE_GLOBAL_HEAP=1)
target_link_libraries(libc-malloc libc-core libmagenta)
+7 -1
View File
@@ -8,6 +8,12 @@
#include <magenta/vm.h>
#include <stdio.h>
#if defined(LIBC_STATIC)
#define HEAP_REGION_BASE 0x20000000000
#else
#define HEAP_REGION_BASE 0x60000000000
#endif
#define HEAP_REGION_SIZE 0x40000000
#define HEAP_EXPAND_INCREMENT 0x100000
@@ -40,7 +46,7 @@ static kern_status_t init_heap_region(heap_t *heap)
kern_status_t status = address_space_reserve(
address_space,
MAP_ADDRESS_ANY,
HEAP_REGION_BASE,
HEAP_REGION_SIZE,
&heap->heap_base);