You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
570 B
27 lines
570 B
|
|
#include <errno.h> |
|
#include <sys/mman.h> |
|
|
|
|
|
// NOTE(Patrick): The memory here is by default allocated uncommitted. |
|
// This means that we don't lock down 1GB of memory up front, but get |
|
// allocated pages by the kernel as needed. |
|
int linux_allocate_arena_memory( |
|
Memory_Arena *arena, |
|
size_t arena_size) |
|
{ |
|
void *arena_memory = mmap( |
|
NULL, arena_size, |
|
PROT_READ|PROT_WRITE|PROT_EXEC, MAP_SHARED|MAP_ANONYMOUS, -1, 0); |
|
if(arena_memory == (void*)-1) { |
|
//perror("mmap"); |
|
return errno; |
|
} |
|
arena->memory = arena_memory; |
|
arena->size = arena_size; |
|
return 0; |
|
} |
|
|
|
|
|
|
|
|
|
|